diff options
Diffstat (limited to 'CPP/Windows/SecurityUtils.cpp')
| -rw-r--r-- | CPP/Windows/SecurityUtils.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/CPP/Windows/SecurityUtils.cpp b/CPP/Windows/SecurityUtils.cpp index 8a7f45c..ede83fa 100644 --- a/CPP/Windows/SecurityUtils.cpp +++ b/CPP/Windows/SecurityUtils.cpp | |||
| @@ -4,6 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | #include "SecurityUtils.h" | 5 | #include "SecurityUtils.h" |
| 6 | 6 | ||
| 7 | #define MY_CAST_FUNC (void(*)()) | ||
| 8 | // #define MY_CAST_FUNC | ||
| 9 | |||
| 7 | namespace NWindows { | 10 | namespace NWindows { |
| 8 | namespace NSecurity { | 11 | namespace NSecurity { |
| 9 | 12 | ||
| @@ -50,8 +53,10 @@ static void MyLookupSids(CPolicy &policy, PSID ps) | |||
| 50 | } | 53 | } |
| 51 | */ | 54 | */ |
| 52 | 55 | ||
| 56 | extern "C" { | ||
| 57 | |||
| 53 | #ifndef _UNICODE | 58 | #ifndef _UNICODE |
| 54 | typedef BOOL (WINAPI * LookupAccountNameWP)( | 59 | typedef BOOL (WINAPI * Func_LookupAccountNameW)( |
| 55 | LPCWSTR lpSystemName, | 60 | LPCWSTR lpSystemName, |
| 56 | LPCWSTR lpAccountName, | 61 | LPCWSTR lpAccountName, |
| 57 | PSID Sid, | 62 | PSID Sid, |
| @@ -62,13 +67,17 @@ typedef BOOL (WINAPI * LookupAccountNameWP)( | |||
| 62 | ); | 67 | ); |
| 63 | #endif | 68 | #endif |
| 64 | 69 | ||
| 70 | } | ||
| 71 | |||
| 65 | static PSID GetSid(LPWSTR accountName) | 72 | static PSID GetSid(LPWSTR accountName) |
| 66 | { | 73 | { |
| 67 | #ifndef _UNICODE | 74 | #ifndef _UNICODE |
| 68 | HMODULE hModule = GetModuleHandle(TEXT("Advapi32.dll")); | 75 | HMODULE hModule = GetModuleHandle(TEXT("Advapi32.dll")); |
| 69 | if (hModule == NULL) | 76 | if (hModule == NULL) |
| 70 | return NULL; | 77 | return NULL; |
| 71 | LookupAccountNameWP lookupAccountNameW = (LookupAccountNameWP)GetProcAddress(hModule, "LookupAccountNameW"); | 78 | Func_LookupAccountNameW lookupAccountNameW = (Func_LookupAccountNameW) |
| 79 | MY_CAST_FUNC | ||
| 80 | GetProcAddress(hModule, "LookupAccountNameW"); | ||
| 72 | if (lookupAccountNameW == NULL) | 81 | if (lookupAccountNameW == NULL) |
| 73 | return NULL; | 82 | return NULL; |
| 74 | #endif | 83 | #endif |
