Recently I tried to obtain OICTL Codes from the iscflashx64.sys driver and I have found it in DispatchDeviceControl function. After driver being installed and have started with SCM it displayed in WinObj. when I invoke DeviceIOControl function with this codes in my user-land app it returns "1" error code. that means my codes is invalid.
Here is IDA view capture and userapp code
Next:
lea rdx, cs:10000h
movzx eax, ds:(byte_1C9C8 - 10000h)[rdx+rsi]
mov ecx, ds:(off_1C988 - 10000h)[rdx+rax*4]
add rcx, rdx
jmp rcx ; switch jump
And function call:
lea rcx, [rsp+188h+PhysicalAddress]
call MSR_read1
jmp short loc_1C2BC
in userapp:
#define IOCTL_READ_MSR\
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x2237134, METHOD_BUFFERED, FILE_ANY_ACCESS)
...
bool msr_get(unsigned int reg, unsigned long long *val)
{
if (hHandle == NULL)
{
printf("## ERROR: Not initialized\n");
return false;
}
DWORD dwBytes = 0;
UCHAR Request[0x100];
ZeroMemory(&Request, sizeof(Request));
*(PDWORD)(Request + 0x08) = reg;
// send request to the driver
if (DeviceIoControl(
hHandle, IOCTL_READ_MSR,
&Request, sizeof(Request), &Request, sizeof(Request),
&dwBytes, NULL))
{
LARGE_INTEGER Val;
Val.HighPart = *(PDWORD)(Request + 0x0c);
Val.LowPart = *(PDWORD)(Request + 0x00);
*val = Val.QuadPart;
return true;
}
else
{
printf("## ERROR DeviceIoControl() %d\n", GetLastError());
}
return false;
}
After googling I found this answer. So this step by step solution does`t work for me. May be problem in switch case tables, but IDA get comments that seems like a codes like that:
loc_1C55A:
sub esi, 222406h
jz loc_1C6E7
What is going wrong? Will be very grateful for any suggestions or just a common techniques in using IOCTL.
P.S. Sorry for my English.