2004-04-01 22:48:37 +00:00
|
|
|
/* dhahelper setup program (c) 2004 Sascha Sommer */
|
|
|
|
/* compile with gcc -o dhasetup.exe dhasetup.c */
|
|
|
|
/* LICENSE: GPL */
|
2004-03-23 10:41:04 +00:00
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc,char* argv[]){
|
|
|
|
SC_HANDLE hSCManager;
|
|
|
|
SC_HANDLE hService;
|
2004-03-23 12:43:54 +00:00
|
|
|
char path[MAX_PATH];
|
2004-03-23 10:41:04 +00:00
|
|
|
printf("dhasetup (c) 2004 Sascha Sommer\n");
|
2004-04-01 22:48:37 +00:00
|
|
|
GetWindowsDirectory(path,MAX_PATH);
|
|
|
|
strcpy(path+strlen(path),"\\system32\\drivers\\dhahelper.sys");
|
2004-03-23 10:41:04 +00:00
|
|
|
if(argc==1){
|
2004-04-01 22:48:37 +00:00
|
|
|
printf("Usage:\n");
|
|
|
|
printf("dhasetup install - Copies dhahelper.sys from the current directory to\n%s and configures it to start at boot.\n", path);
|
|
|
|
printf("dhasetup remove - Removes the dhahelper utility.\n");
|
2004-03-23 10:41:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
|
|
|
if(!strcmp(argv[1],"install")){
|
2004-04-01 22:48:37 +00:00
|
|
|
printf("Installing dhahelper...\n");
|
2004-05-09 17:36:44 +00:00
|
|
|
if(!CopyFile("dhahelper.sys",path,FALSE)){
|
2004-04-01 22:48:37 +00:00
|
|
|
printf("Copying dhahelper.sys failed.\nEither dhahelper.sys is not in the current directory or you lack sufficient\nprivileges to write to %s.", path);
|
|
|
|
return 1;
|
2004-05-09 17:36:44 +00:00
|
|
|
}
|
2004-03-23 10:41:04 +00:00
|
|
|
// Install the driver
|
|
|
|
hService = CreateService(hSCManager,
|
|
|
|
"DHAHELPER",
|
|
|
|
"DHAHELPER",
|
|
|
|
SERVICE_ALL_ACCESS,
|
|
|
|
SERVICE_KERNEL_DRIVER,
|
|
|
|
SERVICE_SYSTEM_START,
|
|
|
|
SERVICE_ERROR_NORMAL,
|
2004-03-23 12:43:54 +00:00
|
|
|
path,
|
2004-03-23 10:41:04 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2004-05-09 14:03:10 +00:00
|
|
|
if(!hService){
|
2004-05-09 16:36:58 +00:00
|
|
|
printf("Unable to register DHAHELPER Service (0x%x).\n",GetLastError());
|
2004-05-09 14:03:10 +00:00
|
|
|
}
|
2004-03-23 10:41:04 +00:00
|
|
|
}
|
|
|
|
else if(!strcmp(argv[1],"remove")){
|
|
|
|
SERVICE_STATUS ServiceStatus;
|
2004-04-01 22:48:37 +00:00
|
|
|
printf("Removing dhahelper...\n");
|
2004-03-23 10:41:04 +00:00
|
|
|
hService = OpenService(hSCManager, "DHAHELPER", SERVICE_ALL_ACCESS);
|
|
|
|
ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus);
|
|
|
|
DeleteService(hService);
|
2004-03-23 12:43:54 +00:00
|
|
|
DeleteFile(path);
|
2004-03-23 10:41:04 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("unknown parameter: %s\n",argv[1]);
|
|
|
|
}
|
|
|
|
CloseServiceHandle(hService);
|
|
|
|
CloseServiceHandle(hSCManager);
|
2004-04-01 22:48:37 +00:00
|
|
|
printf("Please reboot to let the changes take effect.\n");
|
2004-03-23 10:41:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|