Browse Source

Added CreateWellKnownSid and IsWellKnownSid imports.

Visual Studio 2008 doesn't recognise the functions so we need to load
them to the imports table.
Iain Patterson 8 years ago
parent
commit
aece13df3c
2 changed files with 19 additions and 0 deletions
  1. 14 0
      imports.cpp
  2. 5 0
      imports.h

+ 14 - 0
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));
 }

+ 5 - 0
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 *);