oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Jul 18, 2008 8:41 am Post subject: Driver loader and Unloader code |
|
|
| Code: |
#include <windows.h>
#include <conio.h>
BOOL LoadUnload(LPCWSTR ServiceName, LPCWSTR DisplayName, LPCWSTR DriverPath) {
HANDLE hSCManager, hService;
SERVICE_STATUS ss;
hSCManager = OpenSCManager(NULL, NULL. SC_MANAGER_CREATE_SERVICE);
if(hSCManager) {
hService = CreateServiceFunction(hSCManager, DriverPath, DisplayName, SERVICE_START | SERVICE_STOP | DELETE, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_IGNORE, DriverPath, NULL, NULL, NULL, NULL, NULL);
if(hService) {
if(StartService(hService, 0, NULL) != 0) {
cout<<"Press any key to unload driver.";
_getch();
if(ControlService(hService, SERVICE_CONTROL_STOP, &ss) != 0) {
if(DeleteService(hService) != 0) {
CloseServiceHandle(hSCManager);
CloseServiceHandle(hService);
return TRUE;
}
}
}
}
}
/*For the sake of ease, I didn't put the two lines of code below in between every brace that needed it.*/
CloseServiceHandle(hSCManager);
CloseServiceHandle(hService);
return FALSE;
}
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|