ReactOS 0.4.16-dev-195-g3bb1e64
QueryServiceConfig2.c File Reference
#include "precomp.h"
Include dependency graph for QueryServiceConfig2.c:

Go to the source code of this file.

Macros

#define TESTING_SERVICEW   L"Spooler"
 
#define TESTING_SERVICEA   "Spooler"
 

Functions

static DWORD RegReadStringW (HKEY hKey, LPWSTR lpValueName, LPWSTR *lpValue)
 
static DWORD RegReadStringA (HKEY hKey, LPSTR lpValueName, LPSTR *lpValue)
 
static int QueryConfig2W (SC_HANDLE hService, LPCWSTR serviceName, DWORD dwInfoLevel)
 
static int QueryConfig2A (SC_HANDLE hService, LPCSTR serviceName, DWORD dwInfoLevel)
 
static void Test_QueryServiceConfig2W (void)
 
static void Test_QueryServiceConfig2A (void)
 
 START_TEST (QueryServiceConfig2)
 

Macro Definition Documentation

◆ TESTING_SERVICEA

#define TESTING_SERVICEA   "Spooler"

Definition at line 11 of file QueryServiceConfig2.c.

◆ TESTING_SERVICEW

#define TESTING_SERVICEW   L"Spooler"

Definition at line 10 of file QueryServiceConfig2.c.

Function Documentation

◆ QueryConfig2A()

static int QueryConfig2A ( SC_HANDLE  hService,
LPCSTR  serviceName,
DWORD  dwInfoLevel 
)
static

Definition at line 290 of file QueryServiceConfig2.c.

291{
292 int iRet = 0;
293 LONG lRet = 0;
294 DWORD dwRet = 0;
295 BOOL bError = FALSE;
296 DWORD dwRequiredSize = 0;
298
299 CHAR keyName[256];
300 HKEY hKey = NULL;
301 DWORD dwType = 0;
302
303 /* Get the needed size */
304 SetLastError(0xdeadbeef);
305 bError = QueryServiceConfig2A(hService,
307 NULL,
308 0,
309 &dwRequiredSize);
310 ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER);
311 ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n");
312 if (dwRequiredSize == 0)
313 {
314 skip("Required size is null; cannot proceed with QueryConfig2A --> %lu test\n", dwInfoLevel);
315 return 1;
316 }
317
318 /* Allocate memory */
320 if (lpBuffer == NULL)
321 {
322 skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize);
323 return 2;
324 }
325
326 /* Get the actual value */
327 SetLastError(0xdeadbeef);
328 bError = QueryServiceConfig2A(hService,
330 lpBuffer,
331 dwRequiredSize,
332 &dwRequiredSize);
333 ok(bError, "bError = %u, expected TRUE\n", bError);
334 if (bError == FALSE)
335 {
336 skip("QueryServiceConfig2A returned an error; cannot proceed with QueryConfig2A --> %lu test\n", dwInfoLevel);
338 return 3;
339 }
340
341 /* Now we can compare the retrieved value with what it's actually stored in the registry */
342 StringCbPrintfA(keyName, sizeof(keyName), "System\\CurrentControlSet\\Services\\%s", serviceName);
343 SetLastError(0xdeadbeef);
345 ok(lRet == ERROR_SUCCESS, "RegOpenKeyExA failed with 0x%08lx\n", lRet);
346 if (lRet != ERROR_SUCCESS)
347 {
348 skip("No regkey; cannot proceed with QueryConfig2A --> %lu test\n", dwInfoLevel);
350 return 4;
351 }
352
353 switch (dwInfoLevel)
354 {
356 {
358 LPSTR lpszDescription = NULL;
359
360 /* Retrieve the description via the registry */
361 dwRet = RegReadStringA(hKey, "Description", &lpszDescription);
362 ok(dwRet == ERROR_SUCCESS, "RegReadStringA returned 0x%08lx\n", dwRet);
363 ok(lpszDescription != NULL, "lpszDescription is null, expected non-null\n");
364
365 /* Compare it with the description retrieved via QueryServiceConfig2 */
366 if (lpszDescription)
367 iRet = strcmp(lpDescription->lpDescription, lpszDescription);
368 else
369 iRet = 0;
370
371 ok(iRet == 0, "Retrieved descriptions are different !\n");
372
373
374 /* Memory cleanup */
375 HeapFree(GetProcessHeap(), 0, lpszDescription);
376
377 break;
378 }
379
381 {
383 LPSERVICE_FAILURE_ACTIONSA lpFailureActions2 = NULL;
384 LPSTR lpRebootMessage = NULL;
385 LPSTR lpFailureCommand = NULL;
386 DWORD i = 0;
387
388 /* Retrieve the failure actions via the registry */
389 lRet = RegQueryValueExA(hKey,
390 "FailureActions",
391 NULL,
392 &dwType,
393 NULL,
394 &dwRequiredSize);
395 ok(lRet == ERROR_SUCCESS, "RegQueryValueExA returned 0x%08lx\n", lRet);
396 ok(dwType == REG_BINARY, "dwType = %lu, expected REG_BINARY\n", dwType);
397 ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n");
398
399 lpFailureActions2 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize);
400 if (lpFailureActions2 == NULL)
401 {
402 skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize);
403 break;
404 }
405
406 lRet = RegQueryValueExA(hKey,
407 "FailureActions",
408 NULL,
409 NULL,
410 (LPBYTE)lpFailureActions2,
411 &dwRequiredSize);
412 ok(lRet == ERROR_SUCCESS, "RegQueryValueExA returned 0x%08lx\n", lRet);
413 ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n");
414
415 /* Get the strings */
416 RegReadStringA(hKey, "FailureCommand", &lpFailureCommand);
417 RegReadStringA(hKey, "RebootMessage" , &lpRebootMessage );
418
419 /* Check the values */
420 ok(lpFailureActions1->dwResetPeriod == lpFailureActions2->dwResetPeriod, "lpFailureActions1->dwResetPeriod != lpFailureActions2->dwResetPeriod\n");
421#ifndef _M_AMD64 // Fails on Win 2003 x64
422 ok(lpFailureActions1->cActions == lpFailureActions2->cActions, "lpFailureActions1->cActions != lpFailureActions2->cActions\n");
423#endif
424
425 /* Compare the actions */
426 if (lpFailureActions1->cActions == lpFailureActions2->cActions)
427 {
428 lpFailureActions2->lpsaActions = (lpFailureActions2->cActions > 0 ? (LPSC_ACTION)(lpFailureActions2 + 1) : NULL);
429
430 if (lpFailureActions1->cActions > 0 &&
431 lpFailureActions1->lpsaActions != NULL)
432 {
433 for (i = 0; i < lpFailureActions1->cActions; ++i)
434 {
435 ok(lpFailureActions1->lpsaActions[i].Type == lpFailureActions2->lpsaActions[i].Type , "lpFailureActions1->lpsaActions[%lu].Type != lpFailureActions2->lpsaActions[%lu].Type\n" , i, i);
436 ok(lpFailureActions1->lpsaActions[i].Delay == lpFailureActions2->lpsaActions[i].Delay, "lpFailureActions1->lpsaActions[%lu].Delay != lpFailureActions2->lpsaActions[%lu].Delay\n", i, i);
437 }
438 }
439 }
440
441 /* TODO: retrieve the strings if they are in MUI format */
442
443 /* Compare RebootMsg */
444 if (lpFailureActions1->lpRebootMsg && lpRebootMessage)
445 iRet = strcmp(lpFailureActions1->lpRebootMsg, lpRebootMessage);
446 else
447 iRet = 0;
448
449 ok(iRet == 0, "Retrieved reboot messages are different !\n");
450
451 /* Compare Command */
452 if (lpFailureActions1->lpCommand && lpFailureCommand)
453 iRet = strcmp(lpFailureActions1->lpCommand, lpFailureCommand);
454 else
455 iRet = 0;
456
457 ok(iRet == 0, "Retrieved commands are different !\n");
458
459
460 /* Memory cleanup */
461 if (lpRebootMessage)
462 HeapFree(GetProcessHeap(), 0, lpRebootMessage);
463
464 if (lpFailureCommand)
465 HeapFree(GetProcessHeap(), 0, lpFailureCommand);
466
467 HeapFree(GetProcessHeap(), 0, lpFailureActions2);
468
469 break;
470 }
471
472 default:
473 skip("Unknown dwInfoLevel %lu, cannot proceed with QueryConfig2A --> %lu test\n", dwInfoLevel, dwInfoLevel);
474 break;
475 }
476
478
480
481 return 0;
482}
static DWORD RegReadStringA(HKEY hKey, LPSTR lpValueName, LPSTR *lpValue)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define RegCloseKey(hKey)
Definition: registry.h:49
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3298
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
long LONG
Definition: pedump.c:60
BOOL WINAPI QueryServiceConfig2A(SC_HANDLE hService, DWORD dwInfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2374
STRSAFEAPI StringCbPrintfA(STRSAFE_LPSTR pszDest, size_t cbDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:547
DWORD Delay
Definition: winsvc.h:206
SC_ACTION_TYPE Type
Definition: winsvc.h:205
SC_ACTION * lpsaActions
Definition: winsvc.h:213
char serviceName[]
Definition: tftpd.cpp:34
unsigned char * LPBYTE
Definition: typedefs.h:53
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define SERVICE_CONFIG_DESCRIPTION
Definition: winsvc.h:65
struct _SERVICE_FAILURE_ACTIONSA * LPSERVICE_FAILURE_ACTIONSA
_In_ DWORD dwInfoLevel
Definition: winsvc.h:422
struct _SC_ACTION * LPSC_ACTION
struct _SERVICE_DESCRIPTIONA * LPSERVICE_DESCRIPTIONA
#define SERVICE_CONFIG_FAILURE_ACTIONS
Definition: winsvc.h:66
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175

Referenced by Test_QueryServiceConfig2A().

◆ QueryConfig2W()

static int QueryConfig2W ( SC_HANDLE  hService,
LPCWSTR  serviceName,
DWORD  dwInfoLevel 
)
static

Definition at line 97 of file QueryServiceConfig2.c.

98{
99 int iRet = 0;
100 LONG lRet = 0;
101 DWORD dwRet = 0;
102 BOOL bError = FALSE;
103 DWORD dwRequiredSize = 0;
105
106 WCHAR keyName[256];
107 HKEY hKey = NULL;
108 DWORD dwType = 0;
109
110 /* Get the needed size */
111 SetLastError(0xdeadbeef);
112 bError = QueryServiceConfig2W(hService,
114 NULL,
115 0,
116 &dwRequiredSize);
117 ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER);
118 ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n");
119 if (dwRequiredSize == 0)
120 {
121 skip("Required size is null; cannot proceed with QueryConfig2W --> %lu test\n", dwInfoLevel);
122 return 1;
123 }
124
125 /* Allocate memory */
127 if (lpBuffer == NULL)
128 {
129 skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize);
130 return 2;
131 }
132
133 /* Get the actual value */
134 SetLastError(0xdeadbeef);
135 bError = QueryServiceConfig2W(hService,
137 lpBuffer,
138 dwRequiredSize,
139 &dwRequiredSize);
140 ok(bError, "bError = %u, expected TRUE\n", bError);
141 if (bError == FALSE)
142 {
143 skip("QueryServiceConfig2W returned an error; cannot proceed with QueryConfig2W --> %lu test\n", dwInfoLevel);
145 return 3;
146 }
147
148 /* Now we can compare the retrieved value with what it's actually stored in the registry */
149 StringCbPrintfW(keyName, sizeof(keyName), L"System\\CurrentControlSet\\Services\\%s", serviceName);
150 SetLastError(0xdeadbeef);
152 ok(lRet == ERROR_SUCCESS, "RegOpenKeyExW failed with 0x%08lx\n", lRet);
153 if (lRet != ERROR_SUCCESS)
154 {
155 skip("No regkey; cannot proceed with QueryConfig2W --> %lu test\n", dwInfoLevel);
157 return 4;
158 }
159
160 switch (dwInfoLevel)
161 {
163 {
165 LPWSTR lpszDescription = NULL;
166
167 /* Retrieve the description via the registry */
168 dwRet = RegReadStringW(hKey, L"Description", &lpszDescription);
169 ok(dwRet == ERROR_SUCCESS, "RegReadStringW returned 0x%08lx\n", dwRet);
170 ok(lpszDescription != NULL, "lpszDescription is null, expected non-null\n");
171
172 /* Compare it with the description retrieved via QueryServiceConfig2 */
173 if (lpszDescription)
174 iRet = wcscmp(lpDescription->lpDescription, lpszDescription);
175 else
176 iRet = 0;
177
178 ok(iRet == 0, "Retrieved descriptions are different !\n");
179
180
181 /* Memory cleanup */
182 HeapFree(GetProcessHeap(), 0, lpszDescription);
183
184 break;
185 }
186
188 {
190 LPSERVICE_FAILURE_ACTIONSW lpFailureActions2 = NULL;
191 LPWSTR lpRebootMessage = NULL;
192 LPWSTR lpFailureCommand = NULL;
193 DWORD i = 0;
194
195 /* Retrieve the failure actions via the registry */
196 lRet = RegQueryValueExW(hKey,
197 L"FailureActions",
198 NULL,
199 &dwType,
200 NULL,
201 &dwRequiredSize);
202 ok(lRet == ERROR_SUCCESS, "RegQueryValueExW returned 0x%08lx\n", lRet);
203 ok(dwType == REG_BINARY, "dwType = %lu, expected REG_BINARY\n", dwType);
204 ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n");
205
206 lpFailureActions2 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize);
207 if (lpFailureActions2 == NULL)
208 {
209 skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize);
210 break;
211 }
212
213 lRet = RegQueryValueExW(hKey,
214 L"FailureActions",
215 NULL,
216 NULL,
217 (LPBYTE)lpFailureActions2,
218 &dwRequiredSize);
219 ok(lRet == ERROR_SUCCESS, "RegQueryValueExW returned 0x%08lx\n", lRet);
220 ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n");
221
222 /* Get the strings */
223 RegReadStringW(hKey, L"FailureCommand", &lpFailureCommand);
224 RegReadStringW(hKey, L"RebootMessage" , &lpRebootMessage );
225
226 /* Check the values */
227 ok(lpFailureActions1->dwResetPeriod == lpFailureActions2->dwResetPeriod, "lpFailureActions1->dwResetPeriod != lpFailureActions2->dwResetPeriod\n");
228#ifndef _M_AMD64 // Fails on Win 2003 x64
229 ok(lpFailureActions1->cActions == lpFailureActions2->cActions, "lpFailureActions1->cActions != lpFailureActions2->cActions\n");
230#endif
231 /* Compare the actions */
232 if (lpFailureActions1->cActions == lpFailureActions2->cActions)
233 {
234 lpFailureActions2->lpsaActions = (lpFailureActions2->cActions > 0 ? (LPSC_ACTION)(lpFailureActions2 + 1) : NULL);
235
236 if (lpFailureActions1->cActions > 0 &&
237 lpFailureActions1->lpsaActions != NULL)
238 {
239 for (i = 0; i < lpFailureActions1->cActions; ++i)
240 {
241 ok(lpFailureActions1->lpsaActions[i].Type == lpFailureActions2->lpsaActions[i].Type , "lpFailureActions1->lpsaActions[%lu].Type != lpFailureActions2->lpsaActions[%lu].Type\n" , i, i);
242 ok(lpFailureActions1->lpsaActions[i].Delay == lpFailureActions2->lpsaActions[i].Delay, "lpFailureActions1->lpsaActions[%lu].Delay != lpFailureActions2->lpsaActions[%lu].Delay\n", i, i);
243 }
244 }
245 }
246
247 /* TODO: retrieve the strings if they are in MUI format */
248
249 /* Compare RebootMsg */
250 if (lpFailureActions1->lpRebootMsg && lpRebootMessage)
251 iRet = wcscmp(lpFailureActions1->lpRebootMsg, lpRebootMessage);
252 else
253 iRet = 0;
254
255 ok(iRet == 0, "Retrieved reboot messages are different !\n");
256
257 /* Compare Command */
258 if (lpFailureActions1->lpCommand && lpFailureCommand)
259 iRet = wcscmp(lpFailureActions1->lpCommand, lpFailureCommand);
260 else
261 iRet = 0;
262
263 ok(iRet == 0, "Retrieved commands are different !\n");
264
265
266 /* Memory cleanup */
267 if (lpRebootMessage)
268 HeapFree(GetProcessHeap(), 0, lpRebootMessage);
269
270 if (lpFailureCommand)
271 HeapFree(GetProcessHeap(), 0, lpFailureCommand);
272
273 HeapFree(GetProcessHeap(), 0, lpFailureActions2);
274
275 break;
276 }
277
278 default:
279 skip("Unknown dwInfoLevel %lu, cannot proceed with QueryConfig2W --> %lu test\n", dwInfoLevel, dwInfoLevel);
280 break;
281 }
282
284
286
287 return 0;
288}
static DWORD RegReadStringW(HKEY hKey, LPWSTR lpValueName, LPWSTR *lpValue)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define L(x)
Definition: ntvdm.h:50
BOOL WINAPI QueryServiceConfig2W(SC_HANDLE hService, DWORD dwInfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2491
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LPWSTR lpDescription
Definition: winsvc.h:196
SC_ACTION * lpsaActions
Definition: winsvc.h:220
struct _SERVICE_DESCRIPTIONW * LPSERVICE_DESCRIPTIONW
struct _SERVICE_FAILURE_ACTIONSW * LPSERVICE_FAILURE_ACTIONSW
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Test_QueryServiceConfig2W().

◆ RegReadStringA()

static DWORD RegReadStringA ( HKEY  hKey,
LPSTR  lpValueName,
LPSTR lpValue 
)
static

Definition at line 57 of file QueryServiceConfig2.c.

60{
61 DWORD dwError;
63 DWORD dwType;
64
65 *lpValue = NULL;
66
67 dwSize = 0;
68 dwError = RegQueryValueExA(hKey,
69 lpValueName,
70 0,
71 &dwType,
72 NULL,
73 &dwSize);
74 if (dwError != ERROR_SUCCESS)
75 return dwError;
76
77 *lpValue = HeapAlloc(GetProcessHeap(), 0, dwSize);
78 if (*lpValue == NULL)
80
81 dwError = RegQueryValueExA(hKey,
82 lpValueName,
83 0,
84 &dwType,
85 (LPBYTE)*lpValue,
86 &dwSize);
87 if (dwError != ERROR_SUCCESS)
88 {
89 HeapFree(GetProcessHeap(), 0, *lpValue);
90 *lpValue = NULL;
91 }
92
93 return dwError;
94}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by QueryConfig2A().

◆ RegReadStringW()

static DWORD RegReadStringW ( HKEY  hKey,
LPWSTR  lpValueName,
LPWSTR lpValue 
)
static

Definition at line 17 of file QueryServiceConfig2.c.

20{
21 DWORD dwError;
23 DWORD dwType;
24
25 *lpValue = NULL;
26
27 dwSize = 0;
28 dwError = RegQueryValueExW(hKey,
29 lpValueName,
30 0,
31 &dwType,
32 NULL,
33 &dwSize);
34 if (dwError != ERROR_SUCCESS)
35 return dwError;
36
37 *lpValue = HeapAlloc(GetProcessHeap(), 0, dwSize);
38 if (*lpValue == NULL)
40
41 dwError = RegQueryValueExW(hKey,
42 lpValueName,
43 0,
44 &dwType,
45 (LPBYTE)*lpValue,
46 &dwSize);
47 if (dwError != ERROR_SUCCESS)
48 {
49 HeapFree(GetProcessHeap(), 0, *lpValue);
50 *lpValue = NULL;
51 }
52
53 return dwError;
54}

Referenced by QueryConfig2W().

◆ START_TEST()

START_TEST ( QueryServiceConfig2  )

Definition at line 568 of file QueryServiceConfig2.c.

569{
572}
static void Test_QueryServiceConfig2A(void)
static void Test_QueryServiceConfig2W(void)

◆ Test_QueryServiceConfig2A()

static void Test_QueryServiceConfig2A ( void  )
static

Definition at line 526 of file QueryServiceConfig2.c.

527{
528 SC_HANDLE hScm = NULL;
529 SC_HANDLE hService = NULL;
530
531 SetLastError(0xdeadbeef);
533 ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError());
534 if (!hScm)
535 {
536 skip("No service control manager; cannot proceed with QueryServiceConfig2A test\n");
537 goto cleanup;
538 }
539
541
542 SetLastError(0xdeadbeef);
544 ok(hService != NULL, "Failed to open service handle, error=0x%08lx\n", GetLastError());
545 if (!hService)
546 {
547 skip("Service not found; cannot proceed with QueryServiceConfig2A test\n");
548 goto cleanup;
549 }
550
552
554 goto cleanup;
555
557 goto cleanup;
558
559cleanup:
560 if (hService)
561 CloseServiceHandle(hService);
562
563 if (hScm)
564 CloseServiceHandle(hScm);
565}
static int QueryConfig2A(SC_HANDLE hService, LPCSTR serviceName, DWORD dwInfoLevel)
#define TESTING_SERVICEA
#define ok_err(error)
Definition: atltest.h:124
static void cleanup(void)
Definition: main.c:1335
SC_HANDLE WINAPI OpenServiceA(SC_HANDLE hSCManager, LPCSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2112
SC_HANDLE WINAPI OpenSCManagerA(LPCSTR lpMachineName, LPCSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2024
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define SERVICE_QUERY_CONFIG
Definition: winsvc.h:53

Referenced by START_TEST().

◆ Test_QueryServiceConfig2W()

static void Test_QueryServiceConfig2W ( void  )
static

Definition at line 485 of file QueryServiceConfig2.c.

486{
487 SC_HANDLE hScm = NULL;
488 SC_HANDLE hService = NULL;
489
490 SetLastError(0xdeadbeef);
492 ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError());
493 if (!hScm)
494 {
495 skip("No service control manager; cannot proceed with QueryServiceConfig2W test\n");
496 goto cleanup;
497 }
498
500
501 SetLastError(0xdeadbeef);
503 ok(hService != NULL, "Failed to open service handle, error=0x%08lx\n", GetLastError());
504 if (!hService)
505 {
506 skip("Service not found; cannot proceed with QueryServiceConfig2W test\n");
507 goto cleanup;
508 }
509
511
513 goto cleanup;
514
516 goto cleanup;
517
518cleanup:
519 if (hService)
520 CloseServiceHandle(hService);
521
522 if (hScm)
523 CloseServiceHandle(hScm);
524}
static int QueryConfig2W(SC_HANDLE hService, LPCWSTR serviceName, DWORD dwInfoLevel)
#define TESTING_SERVICEW
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2068
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2160

Referenced by START_TEST().