aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/SecurityUtils.cpp
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2022-07-16 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2023-12-17 14:35:38 +0500
commit93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (patch)
tree9b11631a70ca7150321838d9d6bd473e52d6684d /CPP/Windows/SecurityUtils.cpp
parenta3e1d227377188734b82f023f96f8e25dc40f3e6 (diff)
download7zip-22.01.tar.gz
7zip-22.01.tar.bz2
7zip-22.01.zip
22.0122.01
Diffstat (limited to 'CPP/Windows/SecurityUtils.cpp')
-rw-r--r--CPP/Windows/SecurityUtils.cpp13
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
7namespace NWindows { 10namespace NWindows {
8namespace NSecurity { 11namespace NSecurity {
9 12
@@ -50,8 +53,10 @@ static void MyLookupSids(CPolicy &policy, PSID ps)
50} 53}
51*/ 54*/
52 55
56extern "C" {
57
53#ifndef _UNICODE 58#ifndef _UNICODE
54typedef BOOL (WINAPI * LookupAccountNameWP)( 59typedef 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
65static PSID GetSid(LPWSTR accountName) 72static 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