Robert Reif : advapi32: Move duplicated code into function.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Aug 14 14:10:19 CDT 2006
Module: wine
Branch: master
Commit: b0498a76e096c560fdde7c197c175ea66dc7d1fb
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=b0498a76e096c560fdde7c197c175ea66dc7d1fb
Author: Robert Reif <reif at earthlink.net>
Date: Mon Aug 14 07:24:42 2006 -0400
advapi32: Move duplicated code into function.
---
dlls/advapi32/lsa.c | 111 ++++++++++++++++++++-------------------------------
1 files changed, 43 insertions(+), 68 deletions(-)
diff --git a/dlls/advapi32/lsa.c b/dlls/advapi32/lsa.c
index 42221f3..c5e7deb 100644
--- a/dlls/advapi32/lsa.c
+++ b/dlls/advapi32/lsa.c
@@ -48,13 +48,52 @@ static void dumpLsaAttributes(PLSA_OBJEC
{
if (oa)
{
- TRACE("\n\tlength=%lu, rootdir=%p, objectname=%s\n\tattr=0x%08lx, sid=%p qos=%p\n",
+ TRACE("\n\tlength=%lu, rootdir=%p, objectname=%s\n\tattr=0x%08lx, sid=%s qos=%p\n",
oa->Length, oa->RootDirectory,
oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null",
- oa->Attributes, oa->SecurityDescriptor, oa->SecurityQualityOfService);
+ oa->Attributes, debugstr_sid(oa->SecurityDescriptor),
+ oa->SecurityQualityOfService);
}
}
+static void ADVAPI_GetDomainName(UNICODE_STRING * name)
+{
+ HKEY key;
+ BOOL useDefault = TRUE;
+ LONG ret;
+
+ if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
+ "System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0,
+ KEY_READ, &key)) == ERROR_SUCCESS)
+ {
+ DWORD size = 0;
+ static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
+
+ ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
+ if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
+ {
+ name->Buffer = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY, size);
+
+ if ((ret = RegQueryValueExW(key, wg, NULL, NULL,
+ (LPBYTE)name->Buffer, &size)) == ERROR_SUCCESS)
+ {
+ name->Length = (USHORT)(size - sizeof(WCHAR));
+ name->MaximumLength = (USHORT)size;
+ useDefault = FALSE;
+ }
+ else
+ {
+ HeapFree(GetProcessHeap(), 0, name->Buffer);
+ name->Buffer = NULL;
+ }
+ }
+ RegCloseKey(key);
+ }
+ if (useDefault)
+ RtlCreateUnicodeStringFromAsciiz(name, "DOMAIN");
+}
+
/******************************************************************************
* LsaAddAccountRights [ADVAPI32.@]
*
@@ -394,40 +433,8 @@ NTSTATUS WINAPI LsaQueryInformationPolic
*/
PPOLICY_PRIMARY_DOMAIN_INFO pinfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(POLICY_PRIMARY_DOMAIN_INFO));
- HKEY key;
- BOOL useDefault = TRUE;
- LONG ret;
- if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
- "System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0,
- KEY_READ, &key)) == ERROR_SUCCESS)
- {
- DWORD size = 0;
- static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
-
- ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
- if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
- {
- pinfo->Name.Buffer = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY, size);
-
- if ((ret = RegQueryValueExW(key, wg, NULL, NULL,
- (LPBYTE)pinfo->Name.Buffer, &size)) == ERROR_SUCCESS)
- {
- pinfo->Name.Length = (USHORT)(size - sizeof(WCHAR));
- pinfo->Name.MaximumLength = (USHORT)size;
- useDefault = FALSE;
- }
- else
- {
- HeapFree(GetProcessHeap(), 0, pinfo->Name.Buffer);
- pinfo->Name.Buffer = NULL;
- }
- }
- RegCloseKey(key);
- }
- if (useDefault)
- RtlCreateUnicodeStringFromAsciiz(&(pinfo->Name), "DOMAIN");
+ ADVAPI_GetDomainName(&pinfo->Name);
TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
@@ -482,40 +489,8 @@ NTSTATUS WINAPI LsaQueryInformationPolic
*/
PPOLICY_DNS_DOMAIN_INFO pinfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(POLICY_DNS_DOMAIN_INFO));
- HKEY key;
- BOOL useDefault = TRUE;
- LONG ret;
- if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
- "System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0,
- KEY_READ, &key)) == ERROR_SUCCESS)
- {
- DWORD size = 0;
- static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
-
- ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
- if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
- {
- pinfo->Name.Buffer = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY, size);
-
- if ((ret = RegQueryValueExW(key, wg, NULL, NULL,
- (LPBYTE)pinfo->Name.Buffer, &size)) == ERROR_SUCCESS)
- {
- pinfo->Name.Length = (USHORT)(size - sizeof(WCHAR));
- pinfo->Name.MaximumLength = (USHORT)size;
- useDefault = FALSE;
- }
- else
- {
- HeapFree(GetProcessHeap(), 0, pinfo->Name.Buffer);
- pinfo->Name.Buffer = NULL;
- }
- }
- RegCloseKey(key);
- }
- if (useDefault)
- RtlCreateUnicodeStringFromAsciiz(&(pinfo->Name), "DOMAIN");
+ ADVAPI_GetDomainName(&pinfo->Name);
TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
More information about the wine-cvs
mailing list