ReactOS 0.4.15-dev-7924-g5949c20
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 289 of file QueryServiceConfig2.c.

290{
291 int iRet = 0;
292 LONG lRet = 0;
293 DWORD dwRet = 0;
294 BOOL bError = FALSE;
295 DWORD dwRequiredSize = 0;
297
298 CHAR keyName[256];
299 HKEY hKey = NULL;
300 DWORD dwType = 0;
301
302 /* Get the needed size */
303 SetLastError(0xdeadbeef);
304 bError = QueryServiceConfig2A(hService,
306 NULL,
307 0,
308 &dwRequiredSize);
309 ok(bError == FALSE && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "(bError, GetLastError()) = (%u, 0x%08lx), expected (FALSE, 0x%08lx)\n", bError, GetLastError(), (DWORD)ERROR_INSUFFICIENT_BUFFER);
310 ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n");
311 if (dwRequiredSize == 0)
312 {
313 skip("Required size is null; cannot proceed with QueryConfig2A --> %lu test\n", dwInfoLevel);
314 return 1;
315 }
316
317 /* Allocate memory */
319 if (lpBuffer == NULL)
320 {
321 skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize);
322 return 2;
323 }
324
325 /* Get the actual value */
326 SetLastError(0xdeadbeef);
327 bError = QueryServiceConfig2A(hService,
329 lpBuffer,
330 dwRequiredSize,
331 &dwRequiredSize);
332 ok(bError, "bError = %u, expected TRUE\n", bError);
333 if (bError == FALSE)
334 {
335 skip("QueryServiceConfig2A returned an error; cannot proceed with QueryConfig2A --> %lu test\n", dwInfoLevel);
337 return 3;
338 }
339
340 /* Now we can compare the retrieved value with what it's actually stored in the registry */
341 StringCbPrintfA(keyName, sizeof(keyName), "System\\CurrentControlSet\\Services\\%s", serviceName);
342 SetLastError(0xdeadbeef);
344 ok(lRet == ERROR_SUCCESS, "RegOpenKeyExA failed with 0x%08lx\n", lRet);
345 if (lRet != ERROR_SUCCESS)
346 {
347 skip("No regkey; cannot proceed with QueryConfig2A --> %lu test\n", dwInfoLevel);
349 return 4;
350 }
351
352 switch (dwInfoLevel)
353 {
355 {
357 LPSTR lpszDescription = NULL;
358
359 /* Retrieve the description via the registry */
360 dwRet = RegReadStringA(hKey, "Description", &lpszDescription);
361 ok(dwRet == ERROR_SUCCESS, "RegReadStringA returned 0x%08lx\n", dwRet);
362 ok(lpszDescription != NULL, "lpszDescription is null, expected non-null\n");
363
364 /* Compare it with the description retrieved via QueryServiceConfig2 */
365 if (lpszDescription)
366 iRet = strcmp(lpDescription->lpDescription, lpszDescription);
367 else
368 iRet = 0;
369
370 ok(iRet == 0, "Retrieved descriptions are different !\n");
371
372
373 /* Memory cleanup */
374 HeapFree(GetProcessHeap(), 0, lpszDescription);
375
376 break;
377 }
378
380 {
382 LPSERVICE_FAILURE_ACTIONSA lpFailureActions2 = NULL;
383 LPSTR lpRebootMessage = NULL;
384 LPSTR lpFailureCommand = NULL;
385 DWORD i = 0;
386
387 /* Retrieve the failure actions via the registry */
388 lRet = RegQueryValueExA(hKey,
389 "FailureActions",
390 NULL,
391 &dwType,
392 NULL,
393 &dwRequiredSize);
394 ok(lRet == ERROR_SUCCESS, "RegQueryValueExA returned 0x%08lx\n", lRet);
395 ok(dwType == REG_BINARY, "dwType = %lu, expected REG_BINARY\n", dwType);
396 ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n");
397
398 lpFailureActions2 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwRequiredSize);
399 if (lpFailureActions2 == NULL)
400 {
401 skip("Cannot allocate %lu bytes of memory\n", dwRequiredSize);
402 break;
403 }
404
405 lRet = RegQueryValueExA(hKey,
406 "FailureActions",
407 NULL,
408 NULL,
409 (LPBYTE)lpFailureActions2,
410 &dwRequiredSize);
411 ok(lRet == ERROR_SUCCESS, "RegQueryValueExA returned 0x%08lx\n", lRet);
412 ok(dwRequiredSize != 0, "dwRequiredSize is zero, expected non-zero\n");
413
414 /* Get the strings */
415 RegReadStringA(hKey, "FailureCommand", &lpFailureCommand);
416 RegReadStringA(hKey, "RebootMessage" , &lpRebootMessage );
417
418 /* Check the values */
419 ok(lpFailureActions1->dwResetPeriod == lpFailureActions2->dwResetPeriod, "lpFailureActions1->dwResetPeriod != lpFailureActions2->dwResetPeriod\n");
420 ok(lpFailureActions1->cActions == lpFailureActions2->cActions, "lpFailureActions1->cActions != lpFailureActions2->cActions\n");
421
422 /* Compare the actions */
423 if (lpFailureActions1->cActions == lpFailureActions2->cActions)
424 {
425 lpFailureActions2->lpsaActions = (lpFailureActions2->cActions > 0 ? (LPSC_ACTION)(lpFailureActions2 + 1) : NULL);
426
427 if (lpFailureActions1->cActions > 0 &&
428 lpFailureActions1->lpsaActions != NULL)
429 {
430 for (i = 0; i < lpFailureActions1->cActions; ++i)
431 {
432 ok(lpFailureActions1->lpsaActions[i].Type == lpFailureActions2->lpsaActions[i].Type , "lpFailureActions1->lpsaActions[%lu].Type != lpFailureActions2->lpsaActions[%lu].Type\n" , i, i);
433 ok(lpFailureActions1->lpsaActions[i].Delay == lpFailureActions2->lpsaActions[i].Delay, "lpFailureActions1->lpsaActions[%lu].Delay != lpFailureActions2->lpsaActions[%lu].Delay\n", i, i);
434 }
435 }
436 }
437
438 /* TODO: retrieve the strings if they are in MUI format */
439
440 /* Compare RebootMsg */
441 if (lpFailureActions1->lpRebootMsg && lpRebootMessage)
442 iRet = strcmp(lpFailureActions1->lpRebootMsg, lpRebootMessage);
443 else
444 iRet = 0;
445
446 ok(iRet == 0, "Retrieved reboot messages are different !\n");
447
448 /* Compare Command */
449 if (lpFailureActions1->lpCommand && lpFailureCommand)
450 iRet = strcmp(lpFailureActions1->lpCommand, lpFailureCommand);
451 else
452 iRet = 0;
453
454 ok(iRet == 0, "Retrieved commands are different !\n");
455
456
457 /* Memory cleanup */
458 if (lpRebootMessage)
459 HeapFree(GetProcessHeap(), 0, lpRebootMessage);
460
461 if (lpFailureCommand)
462 HeapFree(GetProcessHeap(), 0, lpFailureCommand);
463
464 HeapFree(GetProcessHeap(), 0, lpFailureActions2);
465
466 break;
467 }
468
469 default:
470 skip("Unknown dwInfoLevel %lu, cannot proceed with QueryConfig2A --> %lu test\n", dwInfoLevel, dwInfoLevel);
471 break;
472 }
473
475
477
478 return 0;
479}
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 ok(lpFailureActions1->cActions == lpFailureActions2->cActions, "lpFailureActions1->cActions != lpFailureActions2->cActions\n");
229
230 /* Compare the actions */
231 if (lpFailureActions1->cActions == lpFailureActions2->cActions)
232 {
233 lpFailureActions2->lpsaActions = (lpFailureActions2->cActions > 0 ? (LPSC_ACTION)(lpFailureActions2 + 1) : NULL);
234
235 if (lpFailureActions1->cActions > 0 &&
236 lpFailureActions1->lpsaActions != NULL)
237 {
238 for (i = 0; i < lpFailureActions1->cActions; ++i)
239 {
240 ok(lpFailureActions1->lpsaActions[i].Type == lpFailureActions2->lpsaActions[i].Type , "lpFailureActions1->lpsaActions[%lu].Type != lpFailureActions2->lpsaActions[%lu].Type\n" , i, i);
241 ok(lpFailureActions1->lpsaActions[i].Delay == lpFailureActions2->lpsaActions[i].Delay, "lpFailureActions1->lpsaActions[%lu].Delay != lpFailureActions2->lpsaActions[%lu].Delay\n", i, i);
242 }
243 }
244 }
245
246 /* TODO: retrieve the strings if they are in MUI format */
247
248 /* Compare RebootMsg */
249 if (lpFailureActions1->lpRebootMsg && lpRebootMessage)
250 iRet = wcscmp(lpFailureActions1->lpRebootMsg, lpRebootMessage);
251 else
252 iRet = 0;
253
254 ok(iRet == 0, "Retrieved reboot messages are different !\n");
255
256 /* Compare Command */
257 if (lpFailureActions1->lpCommand && lpFailureCommand)
258 iRet = wcscmp(lpFailureActions1->lpCommand, lpFailureCommand);
259 else
260 iRet = 0;
261
262 ok(iRet == 0, "Retrieved commands are different !\n");
263
264
265 /* Memory cleanup */
266 if (lpRebootMessage)
267 HeapFree(GetProcessHeap(), 0, lpRebootMessage);
268
269 if (lpFailureCommand)
270 HeapFree(GetProcessHeap(), 0, lpFailureCommand);
271
272 HeapFree(GetProcessHeap(), 0, lpFailureActions2);
273
274 break;
275 }
276
277 default:
278 skip("Unknown dwInfoLevel %lu, cannot proceed with QueryConfig2W --> %lu test\n", dwInfoLevel, dwInfoLevel);
279 break;
280 }
281
283
285
286 return 0;
287}
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 565 of file QueryServiceConfig2.c.

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

◆ Test_QueryServiceConfig2A()

static void Test_QueryServiceConfig2A ( void  )
static

Definition at line 523 of file QueryServiceConfig2.c.

524{
525 SC_HANDLE hScm = NULL;
526 SC_HANDLE hService = NULL;
527
528 SetLastError(0xdeadbeef);
530 ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError());
531 if (!hScm)
532 {
533 skip("No service control manager; cannot proceed with QueryServiceConfig2A test\n");
534 goto cleanup;
535 }
536
538
539 SetLastError(0xdeadbeef);
541 ok(hService != NULL, "Failed to open service handle, error=0x%08lx\n", GetLastError());
542 if (!hService)
543 {
544 skip("Service not found; cannot proceed with QueryServiceConfig2A test\n");
545 goto cleanup;
546 }
547
549
551 goto cleanup;
552
554 goto cleanup;
555
556cleanup:
557 if (hService)
558 CloseServiceHandle(hService);
559
560 if (hScm)
561 CloseServiceHandle(hScm);
562}
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 482 of file QueryServiceConfig2.c.

483{
484 SC_HANDLE hScm = NULL;
485 SC_HANDLE hService = NULL;
486
487 SetLastError(0xdeadbeef);
489 ok(hScm != NULL, "Failed to open service manager, error=0x%08lx\n", GetLastError());
490 if (!hScm)
491 {
492 skip("No service control manager; cannot proceed with QueryServiceConfig2W test\n");
493 goto cleanup;
494 }
495
497
498 SetLastError(0xdeadbeef);
500 ok(hService != NULL, "Failed to open service handle, error=0x%08lx\n", GetLastError());
501 if (!hService)
502 {
503 skip("Service not found; cannot proceed with QueryServiceConfig2W test\n");
504 goto cleanup;
505 }
506
508
510 goto cleanup;
511
513 goto cleanup;
514
515cleanup:
516 if (hService)
517 CloseServiceHandle(hService);
518
519 if (hScm)
520 CloseServiceHandle(hScm);
521}
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().