Skip to content

Commit

Permalink
Fixed probing ReturnLength in HookedNtQueryInformationProcess and Hoo…
Browse files Browse the repository at this point in the history
…kedNtQueryInformationThread
  • Loading branch information
Air14 committed Feb 16, 2023
1 parent 0042fe8 commit 55ab75c
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions HyperHideDrv/HookedFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,17 @@ NTSTATUS NTAPI HookedNtQueryInformationProcess(
ProcessInformationClass == ProcessHandleTracing)
)
{
if (ProcessInformationLength != 0)
__try
{
__try
{
if (ProcessInformationLength != 0)
ProbeForRead(ProcessInformation, ProcessInformationLength, 4);
if (ReturnLength != 0)
ProbeForWrite(ReturnLength, 4, 1);
}

__except (EXCEPTION_EXECUTE_HANDLER)
{
return GetExceptionCode();
}
if (ReturnLength != 0)
ProbeForWrite(ReturnLength, 4, 1);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return GetExceptionCode();
}

if (ProcessInformationClass == ProcessDebugObjectHandle)
Expand Down Expand Up @@ -1001,21 +999,18 @@ NTSTATUS NTAPI HookedNtQueryInformationThread(HANDLE ThreadHandle, THREADINFOCLA
ExGetPreviousMode() == UserMode && (ThreadInformationClass == ThreadHideFromDebugger ||
ThreadInformationClass == ThreadBreakOnTermination || ThreadInformationClass == ThreadWow64Context))
{
if (ThreadInformationLength != 0)
__try
{
const auto alignment = ThreadInformationLength < 4 ? 1 : 4;

__try
{
if(ThreadInformationLength != 0)
ProbeForRead(ThreadInformation, ThreadInformationLength, alignment);
if(ReturnLength != 0)
ProbeForWrite(ReturnLength, 4, 1);

}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return GetExceptionCode();
}
if(ReturnLength != 0)
ProbeForWrite(ReturnLength, 4, 1);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
return GetExceptionCode();
}

if (ThreadInformationClass == ThreadHideFromDebugger)
Expand Down

0 comments on commit 55ab75c

Please sign in to comment.