Hello
I got a little problem with my driver...
With DeviceIOControl I call an IOCTL with buffer passed in argument, for both IN and OUT
In 90% of the runs, all is fine, and I keep the adresses of the fields of apiHookObj equals to what I have initialized.
But in some case, reported by some users, I got this in the log:
Normally, it should (and it does almost everytime) looks like this:
Userland
I got a little problem with my driver...
With DeviceIOControl I call an IOCTL with buffer passed in argument, for both IN and OUT
In 90% of the runs, all is fine, and I keep the adresses of the fields of apiHookObj equals to what I have initialized.
But in some case, reported by some users, I got this in the log:
[00:08:0986] [SSDT] Iterate refApi : (0x9f0732c) 0x6456744e, refModule : (0x9f0712c) 0x6e6f436dHere you can see the fields of the object passed to KM relocated up in the kernel (adresses with high ranges)
Normally, it should (and it does almost everytime) looks like this:
[00:08:0986] [SSDT] Iterate refApi : (0x9f0732c) 0x9f0732c, refModule : (0x9f0712c) 0x9f0712chere's the code:
Code: Select all
typedef struct _API_HOOK_SSDT {
PDWORD ApiIndex;
char* ApiName;
char* ModuleName;
PULONG ApiAdress;
} API_HOOK_SSDT, *PAPI_HOOK_SSDT;
Userland
Code: Select all
KernelLand
API_HOOK_SSDT apiHookObj = {0};
char Module[512] = "", ApiName[512] = "";
DWORD ApiIndex = 0; ULONG ApiAdress = 0x0;
// Init buffers
apiHookObj.ApiAdress = &ApiAdress;
apiHookObj.ApiIndex = &ApiIndex;
apiHookObj.ApiName = ApiName;
apiHookObj.ModuleName = Module;
while (DeviceIoControl( varEnv.driver.hDriver, IOCTL_SSDT, &apiHookObj, sizeof(API_HOOK_SSDT), &apiHookObj, sizeof(API_HOOK_SSDT), &dwBytesRet, 0) && dwBytesRet)
{
printLog(L"[SSDT] Iterate refApi : (0x%x) 0x%x, refModule : (0x%x) 0x%x", (DWORD)ApiName, (DWORD)apiHookObj.ApiName, (DWORD)Module, (DWORD)apiHookObj.ModuleName);
...
}
Code: Select all
case IOCTL_SSDT:
{
PAPI_HOOK_SSDT pBufferIn = pIrp->AssociatedIrp.SystemBuffer;
// Basically only a strcpy(pBufferIn->Field, "Something")
ScanSSDT(pBufferIn);
//We got a hook left
if (*pBufferIn->ApiAdress != 0x0)
{
pIrp->IoStatus.Information = 1;
retVal = STATUS_SUCCESS;
}
else
{
pIrp->IoStatus.Information = 0;
retVal = STATUS_UNSUCCESSFUL;
}
break;
}