From: Iain Patterson Date: Tue, 28 Jan 2014 22:56:02 +0000 (+0000) Subject: Added CreateWellKnownSid and IsWellKnownSid imports. X-Git-Tag: v2.22~24 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=aece13df3cc7a17d5827cc59fc59c13538b52517;p=nssm.git Added CreateWellKnownSid and IsWellKnownSid imports. Visual Studio 2008 doesn't recognise the functions so we need to load them to the imports table. --- diff --git a/imports.cpp b/imports.cpp index d0970bd..18c8bb0 100644 --- a/imports.cpp +++ b/imports.cpp @@ -69,10 +69,24 @@ int get_imports() { } else if (error != ERROR_MOD_NOT_FOUND) return 1; + imports.advapi32 = get_dll(_T("advapi32.dll"), &error); + if (imports.advapi32) { + imports.CreateWellKnownSid = (CreateWellKnownSid_ptr) get_import(imports.advapi32, "CreateWellKnownSid", &error); + if (! imports.CreateWellKnownSid) { + if (error != ERROR_PROC_NOT_FOUND) return 6; + } + imports.IsWellKnownSid = (IsWellKnownSid_ptr) get_import(imports.advapi32, "IsWellKnownSid", &error); + if (! imports.IsWellKnownSid) { + if (error != ERROR_PROC_NOT_FOUND) return 7; + } + } + else if (error != ERROR_MOD_NOT_FOUND) return 5; + return 0; } void free_imports() { if (imports.kernel32) FreeLibrary(imports.kernel32); + if (imports.advapi32) FreeLibrary(imports.advapi32); ZeroMemory(&imports, sizeof(imports)); } diff --git a/imports.h b/imports.h index 8b36778..03e2df1 100644 --- a/imports.h +++ b/imports.h @@ -4,12 +4,17 @@ typedef BOOL (WINAPI *AttachConsole_ptr)(DWORD); typedef BOOL (WINAPI *SleepConditionVariableCS_ptr)(PCONDITION_VARIABLE, PCRITICAL_SECTION, DWORD); typedef void (WINAPI *WakeConditionVariable_ptr)(PCONDITION_VARIABLE); +typedef BOOL (WINAPI *CreateWellKnownSid_ptr)(WELL_KNOWN_SID_TYPE, SID *, SID *, unsigned long *); +typedef BOOL (WINAPI *IsWellKnownSid_ptr)(SID *, WELL_KNOWN_SID_TYPE); typedef struct { HMODULE kernel32; + HMODULE advapi32; AttachConsole_ptr AttachConsole; SleepConditionVariableCS_ptr SleepConditionVariableCS; WakeConditionVariable_ptr WakeConditionVariable; + CreateWellKnownSid_ptr CreateWellKnownSid; + IsWellKnownSid_ptr IsWellKnownSid; } imports_t; HMODULE get_dll(const TCHAR *, unsigned long *);