Hello
I got a very very newbie question.. Well it's more a weird behaviour than a question actually.
Trying to load a driver of mine
The problem is that CreateService always returns NULL, and the strange thing , GetLastError() always returns ERROR_SUCCESS (0) :o
I don't really know if CreateService checks the driver's code, so don't know if it comes from my User app, or from my driver.
EDIT: OSRLoader successfully loaded the driver
I got a very very newbie question.. Well it's more a weird behaviour than a question actually.
Trying to load a driver of mine
The problem is that CreateService always returns NULL, and the strange thing , GetLastError() always returns ERROR_SUCCESS (0) :o
I don't really know if CreateService checks the driver's code, so don't know if it comes from my User app, or from my driver.
Code: Select all
#define DriverName "MyDrv"
#define DriverDisplay "MyDrv"
#define Driver "\\MyDrv.sys"
...
//******* Driver loading *******
WCHAR path[MAX_PATH], pathDummy[MAX_PATH], Name[MAX_PATH], Display[MAX_PATH];
//Getting whole path
wcscpy_s(path, L"\"");
::GetCurrentDirectory(MAX_PATH, pathDummy);
wcscat_s(path, pathDummy);
wcscat_s(path, _T(Driver));
wcscat_s(path, L"\"");
wcscpy_s(Name, _T(DriverName));
wcscpy_s(Display, _T(DriverDisplay));
hService = LoadDriver(Name, Display, path);
Code: Select all
SC_HANDLE LoadDriver(TCHAR* Name, TCHAR* NameDisplay, TCHAR* Path)
{
SC_HANDLE hSCManager, hService;
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
if(hSCManager)
{
hService = CreateService(hSCManager, Name, NameDisplay, SERVICE_START | DELETE | SERVICE_STOP, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, Path, NULL, NULL, NULL, NULL, NULL);
WCHAR buff[256];
swprintf(buff, 256, L"Error %d", GetLastError());
MessageBox(NULL, buff, L"Info", MB_OK);
hService = OpenService(hSCManager, Name, SERVICE_START | DELETE | SERVICE_STOP);
StartService(hService, 0, NULL);
CloseServiceHandle(hSCManager);
return hService;
}
return NULL;
}
EDIT: OSRLoader successfully loaded the driver