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");
|
12453
|
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;
|
12453
|
27 }
|
12057
|
28 // Install the driver
|
|
29 hService = CreateService(hSCManager,
|
|
30 "DHAHELPER",
|
|
31 "DHAHELPER",
|
|
32 SERVICE_ALL_ACCESS,
|
|
33 SERVICE_KERNEL_DRIVER,
|
|
34 SERVICE_SYSTEM_START,
|
|
35 SERVICE_ERROR_NORMAL,
|
12058
|
36 path,
|
12057
|
37 NULL,
|
|
38 NULL,
|
|
39 NULL,
|
|
40 NULL,
|
|
41 NULL);
|
12450
|
42 if(!hService){
|
12452
|
43 printf("Unable to register DHAHELPER Service (0x%x).\n",GetLastError());
|
12450
|
44 }
|
12057
|
45 }
|
|
46 else if(!strcmp(argv[1],"remove")){
|
|
47 SERVICE_STATUS ServiceStatus;
|
12098
|
48 printf("Removing dhahelper...\n");
|
12057
|
49 hService = OpenService(hSCManager, "DHAHELPER", SERVICE_ALL_ACCESS);
|
|
50 ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus);
|
|
51 DeleteService(hService);
|
12058
|
52 DeleteFile(path);
|
12057
|
53 }
|
|
54 else {
|
|
55 printf("unknown parameter: %s\n",argv[1]);
|
|
56 }
|
|
57 CloseServiceHandle(hService);
|
|
58 CloseServiceHandle(hSCManager);
|
12098
|
59 printf("Please reboot to let the changes take effect.\n");
|
12057
|
60 return 0;
|
|
61 }
|