Hi all,
I’m playing with writing a security software (for fun) and have hit a brick wall. I’ve read & read but am having difficulty on passing a UserMode Event HANDLE to Kernel Mode.
ObReferenceObjectByHandle keeps returning 0xc0000008 - STATUS_INVALID_HANDLE.
I know I must be very close and overlooking something simple…
UserMode creates the unnamed event HANDLE successfully:
procLaunched.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (procLaunched.hEvent == INVALID_HANDLE_VALUE) {
ShowLastError();
return FALSE;
}
Then passes it to Kernel Mode through IOCTL:
result = DeviceIoControl(
device,
IOCTL_EVENT_READY,
&procLaunched,
sizeof(REGISTER_EVENT),
NULL, 0, &ignore, NULL);
if(!result) {
ShowLastError();
return FALSE;
}
Which gets picked up in Kernel Mode:
PREGISTER_EVENT registerEvent;
PKEVENT pEvent;
registerEvent = (PREGISTER_EVENT)Irp->AssociatedIrp.SystemBuffer;
status = ObReferenceObjectByHandle(
registerEvent->hEvent,
EVENT_MODIFY_STATE,
*ExEventObjectType,
Irp->RequestorMode,
&pEvent,
NULL);
Which is where I hit the problem of STATUS_INVALID_HANDLE.
Please help me find out why the handle is invalid?