Hi guys!
I'm currently trying to bypass every sort ok hooks to kill a PID.
I already got the true adresses of NtOpenProcess & NtTerminateProcess. My prototypes for theses funcs are good too.
The problem is NtOpenProcess always returns STATUS_ACCESS_VIOLATION, while ZwOpenProcess does not.
The parameteres are the same. Anybody knows why? It must be a check inside , but how to avoid this?
Here's my code:
I'm currently trying to bypass every sort ok hooks to kill a PID.
I already got the true adresses of NtOpenProcess & NtTerminateProcess. My prototypes for theses funcs are good too.
The problem is NtOpenProcess always returns STATUS_ACCESS_VIOLATION, while ZwOpenProcess does not.
The parameteres are the same. Anybody knows why? It must be a check inside , but how to avoid this?
Here's my code:
Code: Select all
HANDLE process;
OBJECT_ATTRIBUTES ObjectAttributes;
CLIENT_ID ClientId;
ACCESS_MASK DesiredAccess;
if (OrigNtTerminateProcess != 0x0 && OrigNtOpenProcess != 0x0)
{
DesiredAccess = PROCESS_TERMINATE;
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
ClientId.UniqueProcess = (HANDLE)pBufferIn[0]; //My pid to kill
ClientId.UniqueThread = 0;
Status = ((NTOPENPROCESS) OrigNtOpenProcess)( &process, DesiredAccess, &ObjectAttributes, &ClientId);
//Status = ZwOpenProcess( &process, DesiredAccess, &ObjectAttributes, &ClientId); //If I replace the line above with this one, all works!
if (NT_SUCCESS(Status))
{
retVal = ((NTTERMINATEPROCESS)(OrigNtTerminateProcess)) (process, 0);
pIrp->IoStatus.Information = 1;
ZwClose(process);
}
else
{
DbgPrint("OpenProcess failed 0x%x\n", Status);
retVal = STATUS_UNSUCCESSFUL;
pIrp->IoStatus.Information = 0;
}
}
...