advapi32: add more helper functions (revised)
Robert Reif
reif at earthlink.net
Mon Jul 31 05:59:43 CDT 2006
Add ADVAPI_GetComputerSid.
-------------- next part --------------
diff -p -u -r1.1 advapi32_misc.h
--- dlls/advapi32/advapi32_misc.h 31 Jul 2006 09:33:02 -0000 1.1
+++ dlls/advapi32/advapi32_misc.h 31 Jul 2006 10:56:01 -0000
@@ -22,5 +22,6 @@
const char * debugstr_sid(PSID sid);
BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName);
+BOOL ADVAPI_GetComputerSid(PSID sid);
#endif /* __WINE_ADVAPI32MISC_H */
Index: dlls/advapi32/security.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/security.c,v
retrieving revision 1.140
diff -p -u -r1.140 security.c
--- dlls/advapi32/security.c 31 Jul 2006 09:33:02 -0000 1.140
+++ dlls/advapi32/security.c 31 Jul 2006 10:56:04 -0000
@@ -342,6 +343,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 ######
##############################
More information about the wine-patches
mailing list