Skip to content

Commit e92be1e

Browse files
committed
[MSGINA] Simplify GetRegistrySettings() (reactos#8381)
1 parent 27db7ec commit e92be1e

File tree

1 file changed

+16
-53
lines changed

1 file changed

+16
-53
lines changed

dll/win32/msgina/msgina.c

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,8 @@ BOOL
153153
GetRegistrySettings(PGINA_CONTEXT pgContext)
154154
{
155155
HKEY hKey = NULL;
156-
LPWSTR lpAutoAdminLogon = NULL;
157-
LPWSTR lpDontDisplayLastUserName = NULL;
158-
LPWSTR lpShutdownWithoutLogon = NULL;
159-
LPWSTR lpIgnoreShiftOverride = NULL;
156+
DWORD dwValue, dwSize;
160157
DWORD dwDisableCAD = 0;
161-
DWORD dwSize;
162158
LONG rc;
163159

164160
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
@@ -172,94 +168,61 @@ GetRegistrySettings(PGINA_CONTEXT pgContext)
172168
return FALSE;
173169
}
174170

175-
rc = ReadRegSzValue(hKey,
176-
L"AutoAdminLogon",
177-
&lpAutoAdminLogon);
171+
rc = ReadRegDwordValue(hKey, L"AutoAdminLogon", &dwValue);
178172
if (rc == ERROR_SUCCESS)
179-
{
180-
if (wcscmp(lpAutoAdminLogon, L"1") == 0)
181-
pgContext->bAutoAdminLogon = TRUE;
182-
}
183-
173+
pgContext->bAutoAdminLogon = !!dwValue;
184174
TRACE("bAutoAdminLogon: %s\n", pgContext->bAutoAdminLogon ? "TRUE" : "FALSE");
185175

186-
rc = ReadRegDwordValue(hKey,
187-
L"DisableCAD",
188-
&dwDisableCAD);
176+
// TODO: What to do also depends whether we are on Terminal Services.
177+
rc = ReadRegDwordValue(hKey, L"DisableCAD", &dwDisableCAD);
189178
if (rc == ERROR_SUCCESS)
190179
{
191180
if (dwDisableCAD != 0)
192181
pgContext->bDisableCAD = TRUE;
193182
}
194-
195183
TRACE("bDisableCAD: %s\n", pgContext->bDisableCAD ? "TRUE" : "FALSE");
196184

185+
// NOTE: The default value is always read from the registry (Workstation: TRUE; Server: FALSE).
186+
// TODO: Set it to TRUE always on SafeMode. Keep it FALSE for remote sessions.
197187
pgContext->bShutdownWithoutLogon = TRUE;
198-
rc = ReadRegSzValue(hKey,
199-
L"ShutdownWithoutLogon",
200-
&lpShutdownWithoutLogon);
188+
rc = ReadRegDwordValue(hKey, L"ShutdownWithoutLogon", &dwValue);
201189
if (rc == ERROR_SUCCESS)
202-
{
203-
if (wcscmp(lpShutdownWithoutLogon, L"0") == 0)
204-
pgContext->bShutdownWithoutLogon = FALSE;
205-
}
190+
pgContext->bShutdownWithoutLogon = !!dwValue;
206191

207-
rc = ReadRegSzValue(hKey,
208-
L"DontDisplayLastUserName",
209-
&lpDontDisplayLastUserName);
192+
rc = ReadRegDwordValue(hKey, L"DontDisplayLastUserName", &dwValue);
210193
if (rc == ERROR_SUCCESS)
211-
{
212-
if (wcscmp(lpDontDisplayLastUserName, L"1") == 0)
213-
pgContext->bDontDisplayLastUserName = TRUE;
214-
}
194+
pgContext->bDontDisplayLastUserName = !!dwValue;
215195

216-
rc = ReadRegSzValue(hKey,
217-
L"IgnoreShiftOverride",
218-
&lpIgnoreShiftOverride);
196+
rc = ReadRegDwordValue(hKey, L"IgnoreShiftOverride", &dwValue);
219197
if (rc == ERROR_SUCCESS)
220-
{
221-
if (wcscmp(lpIgnoreShiftOverride, L"1") == 0)
222-
pgContext->bIgnoreShiftOverride = TRUE;
223-
}
198+
pgContext->bIgnoreShiftOverride = !!dwValue;
224199

225200
dwSize = sizeof(pgContext->UserName);
226201
rc = RegQueryValueExW(hKey,
227202
L"DefaultUserName",
228203
NULL,
229204
NULL,
230-
(LPBYTE)&pgContext->UserName,
205+
(PBYTE)&pgContext->UserName,
231206
&dwSize);
232207

233208
dwSize = sizeof(pgContext->DomainName);
234209
rc = RegQueryValueExW(hKey,
235210
L"DefaultDomainName",
236211
NULL,
237212
NULL,
238-
(LPBYTE)&pgContext->DomainName,
213+
(PBYTE)&pgContext->DomainName,
239214
&dwSize);
240215

241216
dwSize = sizeof(pgContext->Password);
242217
rc = RegQueryValueExW(hKey,
243218
L"DefaultPassword",
244219
NULL,
245220
NULL,
246-
(LPBYTE)&pgContext->Password,
221+
(PBYTE)&pgContext->Password,
247222
&dwSize);
248223
if (rc)
249224
GetLsaDefaultPassword(pgContext);
250225

251-
if (lpIgnoreShiftOverride != NULL)
252-
HeapFree(GetProcessHeap(), 0, lpIgnoreShiftOverride);
253-
254-
if (lpShutdownWithoutLogon != NULL)
255-
HeapFree(GetProcessHeap(), 0, lpShutdownWithoutLogon);
256-
257-
if (lpDontDisplayLastUserName != NULL)
258-
HeapFree(GetProcessHeap(), 0, lpDontDisplayLastUserName);
259-
260-
if (lpAutoAdminLogon != NULL)
261-
HeapFree(GetProcessHeap(), 0, lpAutoAdminLogon);
262-
263226
if (hKey != NULL)
264227
RegCloseKey(hKey);
265228

0 commit comments

Comments
 (0)