comparison vidix/dhahelperwin/dhasetup.c @ 22900:a9e111b88c4a

merged libdha and libvidix, moved all files from libdha to vidix directory
author ben
date Fri, 06 Apr 2007 15:20:49 +0000
parents libdha/dhahelperwin/dhasetup.c@33dab236c631
children 40a61e5ef8ca
comparison
equal deleted inserted replaced
22899:515545f81186 22900:a9e111b88c4a
1 /* dhahelper setup program (c) 2004 Sascha Sommer */
2 /* compile with gcc -o dhasetup.exe dhasetup.c */
3 /* LICENSE: GPL */
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;
11 char path[MAX_PATH];
12 printf("dhasetup (c) 2004 Sascha Sommer\n");
13 GetWindowsDirectory(path,MAX_PATH);
14 strcpy(path+strlen(path),"\\system32\\drivers\\dhahelper.sys");
15 if(argc==1){
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");
19 return 0;
20 }
21 hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
22 if(!strcmp(argv[1],"install")){
23 printf("Installing dhahelper...\n");
24 if(!CopyFile("dhahelper.sys",path,FALSE)){
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;
27 }
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,
36 path,
37 NULL,
38 NULL,
39 NULL,
40 NULL,
41 NULL);
42 if(!hService){
43 printf("Unable to register DHAHELPER Service (0x%x).\n",GetLastError());
44 }
45 }
46 else if(!strcmp(argv[1],"remove")){
47 SERVICE_STATUS ServiceStatus;
48 printf("Removing dhahelper...\n");
49 hService = OpenService(hSCManager, "DHAHELPER", SERVICE_ALL_ACCESS);
50 ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus);
51 DeleteService(hService);
52 DeleteFile(path);
53 }
54 else {
55 printf("unknown parameter: %s\n",argv[1]);
56 }
57 CloseServiceHandle(hService);
58 CloseServiceHandle(hSCManager);
59 printf("Please reboot to let the changes take effect.\n");
60 return 0;
61 }