42{
44 char szBuffer[1024];
52 SC_HANDLE hService =
NULL;
56
57
58
60
61
63 {
66 }
67
68
71 {
72 skip(
"File path has no file extension: %S\n", wszFilePath);
74 }
75
77
78
81 {
82 skip(
"My DLL file \"%S\" does not exist!\n", wszFilePath);
84 }
85
86
88
89
91 if (!hSC)
92 {
95 }
96
97
99 if (!hService)
100 {
101 skip(
"OpenServiceW failed for the spooler service with error %lu!\n",
GetLastError());
103 }
104
106 {
107 skip(
"QueryServiceStatus failed for the spooler service with error %lu!\n",
GetLastError());
109 }
110
112 {
113 skip(
"Spooler Service is not running!\n");
115 }
116
118
119
121 if (!hService)
122 {
124 {
125
126 hService =
CreateServiceW(hSC,
SERVICE_NAME,
NULL,
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START,
SERVICE_ERROR_IGNORE, wszFilePath,
NULL,
NULL,
NULL,
NULL,
NULL);
127 if (!hService)
128 {
131 }
132 }
133 else
134 {
137 }
138 }
139
140
143 {
144 skip(
"CreateNamedPipeW failed for the command pipe with error %lu!\n",
GetLastError());
146 }
147
150 {
151 skip(
"CreateNamedPipeW failed for the output pipe with error %lu!\n",
GetLastError());
153 }
154
155
157 {
160 }
161
162
164 {
165 skip(
"ConnectNamedPipe failed for the command pipe with error %lu!\n",
GetLastError());
167 }
168
169
171 {
174 }
175
176
178 {
179 skip(
"ConnectNamedPipe failed for the output pipe with error %lu!\n",
GetLastError());
181 }
182
183
184 while (
ReadFile(hOutputPipe, szBuffer,
sizeof(szBuffer), &cbRead,
NULL) && cbRead)
186
188
192
195
198
199 if (hService)
201
202 if (hSC)
204
205
206
207 if (bSuccessful)
209}
static SERVICE_STATUS ServiceStatus
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
BOOL WINAPI FindClose(HANDLE hFindFile)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
VOID WINAPI ExitProcess(IN UINT uExitCode)
static const WCHAR Cleanup[]
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
#define COMMAND_PIPE_NAME
int WINAPI lstrlenA(LPCSTR lpString)
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
HANDLE WINAPI CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
BOOL WINAPI QueryServiceStatus(SC_HANDLE hService, LPSERVICE_STATUS lpServiceStatus)
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
SC_HANDLE WINAPI CreateServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, LPCWSTR lpDisplayName, DWORD dwDesiredAccess, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword)
BOOL WINAPI StartServiceW(SC_HANDLE hService, DWORD dwNumServiceArgs, LPCWSTR *lpServiceArgVectors)
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define PIPE_ACCESS_INBOUND
#define PIPE_READMODE_BYTE
DWORD WINAPI GetLastError(void)
#define PIPE_READMODE_MESSAGE
#define PIPE_ACCESS_OUTBOUND
#define PIPE_TYPE_MESSAGE
#define ERROR_SERVICE_DOES_NOT_EXIST
#define ERROR_PIPE_CONNECTED
#define PRINTER_ENUM_LOCAL
WINBOOL WINAPI EnumPrintersW(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
#define PRINTER_ENUM_NAME
#define SERVICE_QUERY_STATUS
#define SERVICE_ALL_ACCESS
#define SC_MANAGER_ALL_ACCESS
#define SERVICE_DEMAND_START
#define SERVICE_WIN32_OWN_PROCESS
#define SERVICE_ERROR_IGNORE