-
Notifications
You must be signed in to change notification settings - Fork 55
Improve log args for a few hooks: #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: capemon
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -898,8 +898,27 @@ HOOKDEF(NTSTATUS, WINAPI, NtReadVirtualMemory, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ENSURE_SIZET(NumberOfBytesRead); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ret = Old_NtReadVirtualMemory(ProcessHandle, BaseAddress, Buffer, NumberOfBytesToRead, NumberOfBytesRead); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DWORD pid = pid_from_process_handle(ProcessHandle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_ntstatus("process", "pphB", "ProcessHandle", ProcessHandle, "BaseAddress", BaseAddress, "Size", NumberOfBytesToRead, "Buffer", NumberOfBytesRead, Buffer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (pid != GetCurrentProcessId()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_ntstatus( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"process", "piphB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessHandle", ProcessHandle, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessId", pid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BaseAddress", BaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Size", NumberOfBytesToRead, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", NumberOfBytesRead, Buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_ntstatus( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"process", "piphB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessHandle", ProcessHandle, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BaseAddress", BaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Size", NumberOfBytesToRead, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", NumberOfBytesRead, Buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return ret; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -915,8 +934,28 @@ HOOKDEF(BOOL, WINAPI, ReadProcessMemory, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ENSURE_SIZET(lpNumberOfBytesRead); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ret = Old_ReadProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, lpNumberOfBytesRead); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_bool("process", "pphB", "ProcessHandle", hProcess, "BaseAddress", lpBaseAddress, "Size", nSize, "Buffer", lpNumberOfBytesRead, lpBuffer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DWORD pid = pid_from_process_handle(hProcess); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (pid != GetCurrentProcessId()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_bool( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"process", "pphB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessHandle", hProcess, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BaseAddress", lpBaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Size", nSize, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", lpNumberOfBytesRead, lpBuffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessId", pid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_bool( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"process", "pphB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessHandle", hProcess, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BaseAddress", lpBaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Size", nSize, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", lpNumberOfBytesRead, lpBuffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessId", pid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+939
to
+957
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous comment, the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return ret; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -937,12 +976,27 @@ HOOKDEF(NTSTATUS, WINAPI, NtWriteVirtualMemory, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pid = pid_from_process_handle(ProcessHandle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_ntstatus("process", "ppBhs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessHandle", ProcessHandle, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BaseAddress", BaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", NumberOfBytesWritten, Buffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BufferLength", is_valid_address_range((ULONG_PTR)NumberOfBytesWritten, 4) ? *NumberOfBytesWritten : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"StackPivoted", is_stack_pivoted() ? "yes" : "no"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (pid != GetCurrentProcess()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_ntstatus( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"process", "pipBhs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessHandle", ProcessHandle, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessId", pid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BaseAddress", BaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", NumberOfBytesWritten, Buffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BufferLength", is_valid_address_range((ULONG_PTR)NumberOfBytesWritten, 4) ? *NumberOfBytesWritten : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"StackPivoted", is_stack_pivoted() ? "yes" : "no" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_ntstatus( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"process", "pipBhs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessHandle", ProcessHandle, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BaseAddress", BaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", NumberOfBytesWritten, Buffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BufferLength", is_valid_address_range((ULONG_PTR)NumberOfBytesWritten, 4) ? *NumberOfBytesWritten : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"StackPivoted", is_stack_pivoted() ? "yes" : "no" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+980
to
+998
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous comments, the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (pid != GetCurrentProcessId() && NT_SUCCESS(ret)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (g_config.injection) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -970,8 +1024,27 @@ HOOKDEF(BOOL, WINAPI, WriteProcessMemory, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pid = pid_from_process_handle(hProcess); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_bool("process", "ppBhs", "ProcessHandle", hProcess, "BaseAddress", lpBaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", lpNumberOfBytesWritten, lpBuffer, "BufferLength", *lpNumberOfBytesWritten, "StackPivoted", is_stack_pivoted() ? "yes" : "no"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (pid != GetCurrentProcess()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_bool( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"process", "pipBhs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessHandle", hProcess, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessId", pid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BaseAddress", lpBaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", lpNumberOfBytesWritten, lpBuffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BufferLength", *lpNumberOfBytesWritten, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"StackPivoted", is_stack_pivoted() ? "yes" : "no" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LOQ_bool( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"process", "ppBhs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ProcessHandle", hProcess, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BaseAddress", lpBaseAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"Buffer", lpNumberOfBytesWritten, lpBuffer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"BufferLength", *lpNumberOfBytesWritten, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"StackPivoted", is_stack_pivoted() ? "yes" : "no" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+1028
to
+1046
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous comments, the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (pid != GetCurrentProcessId() && ret) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (g_config.injection) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
LOQ_ntstatus
calls are identical in both theif
andelse
blocks, except for the inclusion ofProcessId
in theif
block. This redundancy can be eliminated by moving theLOQ_ntstatus
call outside the conditional and conditionally including theProcessId
argument in the format string.