10#define TESTING_SERVICE L"Spooler"
16 SC_HANDLE hScm =
NULL;
23 ok(hLock ==
NULL,
"hLock = 0x%p, expected 0\n", hLock);
27 hScm = (SC_HANDLE)(
ULONG_PTR)0xdeadbeefdeadbeefull;
29 ok(hLock ==
NULL,
"hLock = 0x%p, expected 0\n", hLock);
36 ok(bError ==
FALSE,
"bError = %u, expected FALSE\n", bError);
43 ok(bError ==
FALSE,
"bError = %u, expected FALSE\n", bError);
53 skip(
"No service control manager; cannot proceed with LockUnlockServiceDatabase test\n");
60 ok(hLock ==
NULL,
"hLock = 0x%p, expected 0\n", hLock);
73 skip(
"No service control manager; cannot proceed with LockUnlockServiceDatabase test\n");
81 ok(hLock !=
NULL,
"hLock = 0x%p, expected non-zero\n", hLock);
88 ok(bError ==
TRUE,
"bError = %u, expected TRUE\n", bError);
104 SC_HANDLE hScm =
NULL;
105 SC_HANDLE hSvc =
NULL;
109 DWORD dwRequiredSize = 0;
112 DWORD dwOldStartType = 0;
120 skip(
"No service control manager; cannot proceed with LockUnlockServiceDatabaseWithServiceStart test\n");
128 ok(hSvc !=
NULL,
"hSvc = 0x%p, expected non-null, error=0x%08lx\n", hSvc,
GetLastError());
131 skip(
"Cannot open a handle to service %S; cannot proceed with LockUnlockServiceDatabaseWithServiceStart test\n",
TESTING_SERVICE);
139 ok(hLock !=
NULL,
"hLock = 0x%p, expected non-zero, error=0x%08lx\n", hLock,
GetLastError());
142 skip(
"Cannot lock the services database; cannot proceed with LockUnlockServiceDatabaseWithServiceStart test\n");
178 ok(bError ==
FALSE,
"bError = %u, expected FALSE\n", bError);
189 ok(bError ==
TRUE,
"bError = %u, expected TRUE\n", bError);
195 ok(bError ==
TRUE,
"bError = %u, expected TRUE\n", bError);
239 SC_HANDLE hScm =
NULL;
242 DWORD dwRequiredSize = 0;
251 ok(dwRequiredSize == 0,
"dwRequiredSize is non-zero, expected zero\n");
259 skip(
"No service control manager; cannot proceed with QueryLockStatusW test\n");
271 ok(dwRequiredSize == 0,
"dwRequiredSize is non-zero, expected zero\n");
285 skip(
"No service control manager; cannot proceed with QueryLockStatusW test\n");
297 ok(dwRequiredSize != 0,
"dwRequiredSize is zero, expected non-zero\n");
298 if (dwRequiredSize == 0)
300 skip(
"Required size is null; cannot proceed with QueryLockStatusW test\n");
306 if (lpLockStatus ==
NULL)
308 skip(
"Cannot allocate %lu bytes of memory\n", dwRequiredSize);
318 ok(bError,
"bError = %u, expected TRUE\n", bError);
321 ok(lpLockStatus->
fIsLocked == 0,
"lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->
fIsLocked);
322 ok(lpLockStatus->
lpLockOwner !=
NULL,
"lpLockStatus->lpLockOwner is null, expected non-null\n");
323 ok(lpLockStatus->
lpLockOwner && *lpLockStatus->
lpLockOwner == 0,
"*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n");
340 skip(
"No service control manager; cannot proceed with QueryLockStatusW test\n");
352 ok(dwRequiredSize != 0,
"dwRequiredSize is zero, expected non-zero\n");
353 if (dwRequiredSize == 0)
355 skip(
"Required size is null; cannot proceed with QueryLockStatusW test\n");
361 if (lpLockStatus ==
NULL)
363 skip(
"Cannot allocate %lu bytes of memory\n", dwRequiredSize);
373 ok(bError,
"bError = %u, expected TRUE\n", bError);
376 ok(lpLockStatus->
fIsLocked == 0,
"lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->
fIsLocked);
377 ok(lpLockStatus->
lpLockOwner !=
NULL,
"lpLockStatus->lpLockOwner is null, expected non-null\n");
378 ok(lpLockStatus->
lpLockOwner && *lpLockStatus->
lpLockOwner == 0,
"*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n");
390 ok(hLock !=
NULL,
"hLock = 0x%p, expected non-zero\n", hLock);
402 ok(dwRequiredSize != 0,
"dwRequiredSize is zero, expected non-zero\n");
403 if (dwRequiredSize == 0)
405 skip(
"Required size is null; cannot proceed with QueryLockStatusW test\n");
411 if (lpLockStatus ==
NULL)
413 skip(
"Cannot allocate %lu bytes of memory\n", dwRequiredSize);
423 ok(bError,
"bError = %u, expected TRUE\n", bError);
426 ok(lpLockStatus->
fIsLocked != 0,
"lpLockStatus->fIsLocked = %lu, expected non-zero\n", lpLockStatus->
fIsLocked);
427 ok(lpLockStatus->
lpLockOwner !=
NULL,
"lpLockStatus->lpLockOwner is null, expected non-null\n");
428 ok(lpLockStatus->
lpLockOwner && *lpLockStatus->
lpLockOwner != 0,
"*lpLockStatus->lpLockOwner = \"\\0\", expected non-zero\n");
440 ok(bError ==
TRUE,
"bError = %u, expected TRUE\n", bError);
451 ok(dwRequiredSize != 0,
"dwRequiredSize is zero, expected non-zero\n");
452 if (dwRequiredSize == 0)
454 skip(
"Required size is null; cannot proceed with QueryLockStatusW test\n");
460 if (lpLockStatus ==
NULL)
462 skip(
"Cannot allocate %lu bytes of memory\n", dwRequiredSize);
472 ok(bError,
"bError = %u, expected TRUE\n", bError);
475 ok(lpLockStatus->
fIsLocked == 0,
"lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->
fIsLocked);
476 ok(lpLockStatus->
lpLockOwner !=
NULL,
"lpLockStatus->lpLockOwner is null, expected non-null\n");
477 ok(lpLockStatus->
lpLockOwner && *lpLockStatus->
lpLockOwner == 0,
"*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n");
497 SC_HANDLE hScm =
NULL;
500 DWORD dwRequiredSize = 0;
509 ok(dwRequiredSize == 0,
"dwRequiredSize is non-zero, expected zero\n");
517 skip(
"No service control manager; cannot proceed with QueryLockStatusA test\n");
529 ok(dwRequiredSize == 0,
"dwRequiredSize is non-zero, expected zero\n");
543 skip(
"No service control manager; cannot proceed with QueryLockStatusA test\n");
555 ok(dwRequiredSize != 0,
"dwRequiredSize is zero, expected non-zero\n");
556 if (dwRequiredSize == 0)
558 skip(
"Required size is null; cannot proceed with QueryLockStatusA test\n");
564 if (lpLockStatus ==
NULL)
566 skip(
"Cannot allocate %lu bytes of memory\n", dwRequiredSize);
576 ok(bError,
"bError = %u, expected TRUE\n", bError);
579 ok(lpLockStatus->
fIsLocked == 0,
"lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->
fIsLocked);
580 ok(lpLockStatus->
lpLockOwner !=
NULL,
"lpLockStatus->lpLockOwner is null, expected non-null\n");
581 ok(lpLockStatus->
lpLockOwner && *lpLockStatus->
lpLockOwner == 0,
"*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n");
598 skip(
"No service control manager; cannot proceed with QueryLockStatusA test\n");
610 ok(dwRequiredSize != 0,
"dwRequiredSize is zero, expected non-zero\n");
611 if (dwRequiredSize == 0)
613 skip(
"Required size is null; cannot proceed with QueryLockStatusA test\n");
619 if (lpLockStatus ==
NULL)
621 skip(
"Cannot allocate %lu bytes of memory\n", dwRequiredSize);
631 ok(bError,
"bError = %u, expected TRUE\n", bError);
634 ok(lpLockStatus->
fIsLocked == 0,
"lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->
fIsLocked);
635 ok(lpLockStatus->
lpLockOwner !=
NULL,
"lpLockStatus->lpLockOwner is null, expected non-null\n");
636 ok(lpLockStatus->
lpLockOwner && *lpLockStatus->
lpLockOwner == 0,
"*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n");
648 ok(hLock !=
NULL,
"hLock = 0x%p, expected non-zero\n", hLock);
660 ok(dwRequiredSize != 0,
"dwRequiredSize is zero, expected non-zero\n");
661 if (dwRequiredSize == 0)
663 skip(
"Required size is null; cannot proceed with QueryLockStatusA test\n");
669 if (lpLockStatus ==
NULL)
671 skip(
"Cannot allocate %lu bytes of memory\n", dwRequiredSize);
681 ok(bError,
"bError = %u, expected TRUE\n", bError);
684 ok(lpLockStatus->
fIsLocked != 0,
"lpLockStatus->fIsLocked = %lu, expected non-zero\n", lpLockStatus->
fIsLocked);
685 ok(lpLockStatus->
lpLockOwner !=
NULL,
"lpLockStatus->lpLockOwner is null, expected non-null\n");
686 ok(lpLockStatus->
lpLockOwner && *lpLockStatus->
lpLockOwner != 0,
"*lpLockStatus->lpLockOwner = \"\\0\", expected non-zero\n");
698 ok(bError ==
TRUE,
"bError = %u, expected TRUE\n", bError);
709 ok(dwRequiredSize != 0,
"dwRequiredSize is zero, expected non-zero\n");
710 if (dwRequiredSize == 0)
712 skip(
"Required size is null; cannot proceed with QueryLockStatusA test\n");
718 if (lpLockStatus ==
NULL)
720 skip(
"Cannot allocate %lu bytes of memory\n", dwRequiredSize);
730 ok(bError,
"bError = %u, expected TRUE\n", bError);
733 ok(lpLockStatus->
fIsLocked == 0,
"lpLockStatus->fIsLocked = %lu, expected 0\n", lpLockStatus->
fIsLocked);
734 ok(lpLockStatus->
lpLockOwner !=
NULL,
"lpLockStatus->lpLockOwner is null, expected non-null\n");
735 ok(lpLockStatus->
lpLockOwner && *lpLockStatus->
lpLockOwner == 0,
"*lpLockStatus->lpLockOwner != \"\\0\", expected \"\\0\"\n");
static void Test_LockUnlockServiceDatabaseWithServiceStart(void)
static void Test_QueryLockStatusA(void)
static void Test_QueryLockStatusW(void)
static void Test_LockUnlockServiceDatabase(void)
#define ERROR_INSUFFICIENT_BUFFER
#define HeapFree(x, y, z)
#define ERROR_INVALID_HANDLE
#define ERROR_ACCESS_DENIED
static void cleanup(void)
BOOL WINAPI QueryServiceStatus(SC_HANDLE hService, LPSERVICE_STATUS lpServiceStatus)
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
BOOL WINAPI UnlockServiceDatabase(SC_LOCK ScLock)
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
BOOL WINAPI QueryServiceConfigW(SC_HANDLE hService, LPQUERY_SERVICE_CONFIGW lpServiceConfig, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
BOOL WINAPI QueryServiceLockStatusA(SC_HANDLE hSCManager, LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
BOOL WINAPI ChangeServiceConfigW(SC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword, LPCWSTR lpDisplayName)
BOOL WINAPI QueryServiceLockStatusW(SC_HANDLE hSCManager, LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
BOOL WINAPI StartServiceW(SC_HANDLE hService, DWORD dwNumServiceArgs, LPCWSTR *lpServiceArgVectors)
SC_LOCK WINAPI LockServiceDatabase(SC_HANDLE hSCManager)
SC_HANDLE WINAPI OpenSCManagerA(LPCSTR lpMachineName, LPCSTR lpDatabaseName, DWORD dwDesiredAccess)
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
DWORD WINAPI GetLastError(void)
#define ERROR_INVALID_SERVICE_LOCK
#define ERROR_SERVICE_DATABASE_LOCKED
#define SERVICE_QUERY_STATUS
#define SC_MANAGER_QUERY_LOCK_STATUS
#define SC_MANAGER_CONNECT
#define SERVICE_NO_CHANGE
#define SERVICE_CHANGE_CONFIG
#define SERVICE_CONTROL_STOP
#define SERVICE_QUERY_CONFIG
#define SERVICE_DEMAND_START