 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Sun Mar 29, 2009 9:12 pm Post subject: [C++] Loading a driver |
|
|
Hi, I've just started learning how to make drivers and I made this driver loader. But it isn't working all the times and I can't find anything that's wrong with it. Also does anyone know a good driver tutorial? So far I can only print "Hello World".. :p.
| Code: | #include <windows.h>
#include <stdio.h>
WCHAR szDriverName[256];
SC_HANDLE schManager, schCreate;
BOOL LoadAndStartDriver(LPCTSTR lpDriverName, LPCTSTR lpPath)
{
schManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(schManager != NULL)
{
wcscat_s(szDriverName, lpDriverName);
wcscat_s(szDriverName, L".sys");
schCreate = CreateService(schManager, szDriverName, lpDriverName, SERVICE_ALL_ACCESS,
SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, lpPath, NULL, NULL, NULL, NULL, NULL);
if(!StartService(schCreate, 0, NULL))
{
if(GetLastError() == ERROR_SERVICE_ALREADY_RUNNING)
{
wprintf(L"Driver already running!");
return FALSE;
}
}
}
return TRUE;
}
void UnloadDriver()
{
SERVICE_STATUS Status;
DeleteService(schCreate);
ControlService(schCreate, SERVICE_CONTROL_STOP, &Status);
CloseServiceHandle(schCreate);
CloseServiceHandle(schManager);
}
int wmain()
{
LoadAndStartDriver(L"Driver", L"C:\\Driver.sys");
Sleep(5000);
UnloadDriver();
} |
|
|
| Back to top |
|
 |
Zerith Master Cheater
Reputation: 1
Joined: 07 Oct 2007 Posts: 468
|
Posted: Mon Mar 30, 2009 12:08 am Post subject: |
|
|
Why are you first deleting the service then trying to control it?
And i recommend on reading "Rootkits: Subverting the windows kernel", which i have read myself.
|
|
| Back to top |
|
 |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Mon Mar 30, 2009 8:45 am Post subject: |
|
|
| Zerith wrote: | Why are you first deleting the service then trying to control it?
And i recommend on reading "Rootkits: Subverting the windows kernel", which i have read myself. | Didn't notice I deleted the service before ControlService. And I found out why it stoped working, for some reason I couldnt use the name "Driver" :s.
I downloaded "Rootkits: Subverting the windows kernel" and will start reading it.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|