Module: wine Branch: refs/heads/master Commit: 9d435046550dd44801784f96cb3a9ee94c112e7c URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=9d435046550dd44801784f96...
Author: Robert Reif reif@earthlink.net Date: Mon Jul 31 06:59:43 2006 -0400
advapi32: Add more helper functions.
Add ADVAPI_GetComputerSid.
---
dlls/advapi32/advapi32_misc.h | 1 + dlls/advapi32/security.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/dlls/advapi32/advapi32_misc.h b/dlls/advapi32/advapi32_misc.h index 436c0fe..35f806e 100644 --- a/dlls/advapi32/advapi32_misc.h +++ b/dlls/advapi32/advapi32_misc.h @@ -22,5 +22,6 @@ #define __WINE_ADVAPI32MISC_H
const char * debugstr_sid(PSID sid); BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName); +BOOL ADVAPI_GetComputerSid(PSID sid);
#endif /* __WINE_ADVAPI32MISC_H */ diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c index d2a5d81..3ff2081 100644 --- a/dlls/advapi32/security.c +++ b/dlls/advapi32/security.c @@ -342,6 +342,43 @@ BOOL ADVAPI_IsLocalComputer(LPCWSTR Serv return Result; }
+/************************************************************ + * ADVAPI_GetComputerSid + * + * Reads the computer SID from the registry. + */ +BOOL ADVAPI_GetComputerSid(PSID sid) +{ + HKEY key; + LONG ret; + + if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "SECURITY\SAM\Domains\Account", 0, + KEY_READ, &key)) == ERROR_SUCCESS) + { + static const WCHAR V[] = { 'V',0 }; + DWORD size = 0; + ret = RegQueryValueExW(key, V, NULL, NULL, NULL, &size); + if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS) + { + BYTE * data = HeapAlloc(GetProcessHeap(), 0, size); + if (data) + { + if ((ret = RegQueryValueExW(key, V, NULL, NULL, + data, &size)) == ERROR_SUCCESS) + { + /* the SID is in the last 24 bytes of the binary data */ + CopyMemory(sid, &data[size-24], 24); + return TRUE; + } + } + } + RegCloseKey(key); + } + + return FALSE; +} + /* ############################## ###### TOKEN FUNCTIONS ###### ##############################