12098
|
1 /* dhahelper setup program (c) 2004 Sascha Sommer */
|
|
2 /* compile with gcc -o dhasetup.exe dhasetup.c */
|
|
3 /* LICENSE: GPL */
|
12057
|
4
|
|
5 #include <windows.h>
|
|
6 #include <stdio.h>
|
|
7
|
|
8 int main(int argc,char* argv[]){
|
|
9 SC_HANDLE hSCManager;
|
|
10 SC_HANDLE hService;
|
12058
|
11 char path[MAX_PATH];
|
12057
|
12 printf("dhasetup (c) 2004 Sascha Sommer\n");
|
12098
|
13 GetWindowsDirectory(path,MAX_PATH);
|
|
14 strcpy(path+strlen(path),"\\system32\\drivers\\dhahelper.sys");
|
12057
|
15 if(argc==1){
|
12098
|
16 printf("Usage:\n");
|
|
17 printf("dhasetup install - Copies dhahelper.sys from the current directory to\n%s and configures it to start at boot.\n", path);
|
|
18 printf("dhasetup remove - Removes the dhahelper utility.\n");
|
12057
|
19 return 0;
|
|
20 }
|
|
21 hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
|
22 if(!strcmp(argv[1],"install")){
|
12098
|
23 printf("Installing dhahelper...\n");
|
12058
|
24 if(!CopyFile("dhahelper.sys",path,FALSE))
|
12098
|
25 printf("Copying dhahelper.sys failed.\nEither dhahelper.sys is not in the current directory or you lack sufficient\nprivileges to write to %s.", path);
|
|
26 return 1;
|
12057
|
27 // Install the driver
|
|
28 hService = CreateService(hSCManager,
|
|
29 "DHAHELPER",
|
|
30 "DHAHELPER",
|
|
31 SERVICE_ALL_ACCESS,
|
|
32 SERVICE_KERNEL_DRIVER,
|
|
33 SERVICE_SYSTEM_START,
|
|
34 SERVICE_ERROR_NORMAL,
|
12058
|
35 path,
|
12057
|
36 NULL,
|
|
37 NULL,
|
|
38 NULL,
|
|
39 NULL,
|
|
40 NULL);
|
|
41 }
|
|
42 else if(!strcmp(argv[1],"remove")){
|
|
43 SERVICE_STATUS ServiceStatus;
|
12098
|
44 printf("Removing dhahelper...\n");
|
12057
|
45 hService = OpenService(hSCManager, "DHAHELPER", SERVICE_ALL_ACCESS);
|
|
46 ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus);
|
|
47 DeleteService(hService);
|
12058
|
48 DeleteFile(path);
|
12057
|
49 }
|
|
50 else {
|
|
51 printf("unknown parameter: %s\n",argv[1]);
|
|
52 }
|
|
53 CloseServiceHandle(hService);
|
|
54 CloseServiceHandle(hSCManager);
|
12098
|
55 printf("Please reboot to let the changes take effect.\n");
|
12057
|
56 return 0;
|
|
57 }
|