2 * Kernel-Mode Tests Loader (based on PnP Test Driver Loader by Filip Navara)
4 * Copyright 2004 Filip Navara <xnavara@volny.cz>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; see the file COPYING.LIB.
18 * If not, write to the Free Software Foundation,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /* INCLUDES *******************************************************************/
27 /* PUBLIC FUNCTIONS ***********************************************************/
31 SC_HANDLE schSCManager
;
33 PWCHAR DriverName
= L
"KMTEST";
34 WCHAR ServiceExe
[MAX_PATH
];
36 printf("Kernel Mode Tests loader\n\n");
37 GetCurrentDirectoryW(MAX_PATH
, ServiceExe
);
38 wcscat(ServiceExe
, L
"\\kmtest.sys");
40 printf("Opening SC Manager...\n");
41 schSCManager
= OpenSCManager(NULL
, NULL
, SC_MANAGER_ALL_ACCESS
);
43 if (schSCManager
== NULL
)
45 DWORD Err
= GetLastError();
46 printf("OpenSCManager failed with error 0x%lx\n", Err
);
50 printf("Creating service...\n");
51 schService
= CreateServiceW(
56 SERVICE_KERNEL_DRIVER
,
66 if (schService
== NULL
)
68 printf("Opening service...\n");
69 schService
= OpenServiceW(schSCManager
, DriverName
, SERVICE_ALL_ACCESS
);
72 if (schService
== NULL
)
74 DWORD Err
= GetLastError();
75 printf("Create/OpenService failed with error 0x%lx\n", Err
);
76 CloseServiceHandle(schSCManager
);
82 printf("Starting service...\n");
83 StartService(schService
, 0, NULL
);
85 printf("Cleaning up and exiting\n");
86 CloseServiceHandle(schService
);
87 CloseServiceHandle(schSCManager
);