dlload ConvertStringSidToSid, does not exist on NT

This commit is contained in:
Doug MacEachern 2005-10-02 21:13:26 +00:00
parent 90c453d4ac
commit 3974333f06
2 changed files with 21 additions and 4 deletions

View File

@ -204,6 +204,9 @@ typedef struct {
} MIB_UDPEXTABLE, *PMIB_UDPEXTABLE;
/* end undocumented structures */
typedef BOOL (CALLBACK *LPCONVERTSTRINGSID)(LPCSTR, PSID *);
typedef DWORD (CALLBACK *LPGETIPFORWARDTABLE)(PMIB_IPFORWARDTABLE, PULONG, BOOL);
typedef DWORD (CALLBACK *LPGETIFTABLE)(PMIB_IFTABLE, PULONG, BOOL);
@ -279,11 +282,13 @@ struct sigar_t {
HKEY handle;
char *perfbuf;
DWORD perfbuf_size;
HINSTANCE adv_handle;
HINSTANCE ip_handle;
HINSTANCE nt_handle;
HINSTANCE ps_handle;
HINSTANCE wts_handle;
HINSTANCE sta_handle;
LPCONVERTSTRINGSID convert_string_sid;
LPGETIFTABLE get_if_table;
LPGETIPFORWARDTABLE get_ipforward_table;
LPGETTCPTABLE get_tcp_table;

View File

@ -258,6 +258,17 @@ int sigar_os_open(sigar_t **sigar)
(*sigar)->ip_handle = NULL;
}
if ((h = LoadLibrary("advapi32.dll"))) {
(*sigar)->convert_string_sid =
(LPCONVERTSTRINGSID)GetProcAddress(h,
"ConvertStringSidToSidA");
(*sigar)->adv_handle = h;
}
else {
(*sigar)->adv_handle = NULL;
(*sigar)->convert_string_sid = NULL;
}
if ((h = LoadLibrary("Ntdll.dll"))) {
(*sigar)->get_ntsys_info =
(LPSYSINFO)GetProcAddress(h, "NtQuerySystemInformation");
@ -2212,15 +2223,16 @@ static int get_logon_info(HKEY users,
return SIGAR_OK;
}
/*XXX dlload, not in NT */
BOOL WINAPI ConvertStringSidToSidA(LPCSTR, PSID *);
static int sigar_who_registry(sigar_t *sigar,
sigar_who_list_t *wholist)
{
HKEY users;
DWORD index=0, status;
if (!sigar->convert_string_sid) {
return ENOENT;
}
status = RegOpenKey(HKEY_USERS, NULL, &users);
if (status != ERROR_SUCCESS) {
return status;
@ -2249,7 +2261,7 @@ static int sigar_who_registry(sigar_t *sigar,
continue;
}
if (!ConvertStringSidToSidA(subkey, &sid)) {
if (!sigar->convert_string_sid(subkey, &sid)) {
continue;
}