Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VOID
- EtwpAddDebugInfoEvents(PEPROCESS Process,
- PPROCESS_DIAGNOSTIC_INFORMATION_WOW64 DiagInfo,
- ULONG DiagInfoSize)
- {
- UNICODE_STRING BuildLabEx;
- ULONG BytesAvailable;
- ULONG BytesWritten;
- ULONG Length;
- NTSTATUS Status;
- PDBG_MODULE_INFORMATION_WOW64 Module;
- /* Calculate the number of bytes available for writing events */
- BytesAvailable = DiagInfoSize - DiagInfo->NextEventOffset;
- /* Query the registry for the build number */
- Status = EtwpQueryRegString(L"\\Registry\\Machine\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
- L"BuildLabEx",
- BuildLabExData,
- sizeof(BuildLabExData));
- if (!NT_SUCCESS(Status))
- goto Quit;
- /* Validate the heap before using it */
- if (!(RtlValidateHeap((PVOID)&BuildLabEx, sizeof(BuildLabExData), 0) >= 0))
- goto Quit;
- /* Initialize the unicode string */
- BuildLabEx.Buffer = (PWSTR)&BuildLabExData;
- BuildLabEx.Length = 0;
- BuildLabEx.MaximumLength = 0;
- /* Calculate the length of the string */
- Length = 0;
- while (BuildLabExData[Length] != 0)
- Length++;
- /* Add the build number event */
- if (EtwpAddEventToBuffer(DiagInfo,
- 0x42,
- &DiagInfo->NextEventGuid,
- BuildLabEx.Buffer,
- Length + 1,
- BytesAvailable,
- &BytesWritten) < 0)
- goto Quit;
- /* Update the number of bytes available */
- BytesAvailable -= ((BytesWritten + 7) & ~0x7);
- /* Add the debug module events */
- Module = (PDBG_MODULE_INFORMATION_WOW64)Process->Peb.Wow64Information.DbglProcessData;
- while (Module != (PDBG_MODULE_INFORMATION_WOW64)&Process->Peb.Wow64Information.DbglProcessData)
- {
- /* Add the module event */
- if (EtwpAddEventToBuffer(DiagInfo,
- 0x40,
- &DiagInfo->NextEventGuid,
- (PCHAR)&Module->BaseAddress,
- Module->ModuleSize - sizeof(ULONG),
- BytesAvailable,
- &BytesWritten) < 0)
- goto Quit;
- /* Update the number of bytes available */
- BytesAvailable -= ((BytesWritten + 7) & ~0x7);
- /* Get the next module */
- Module = (PDBG_MODULE_INFORMATION_WOW64)Module->Next;
- }
- Quit:
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement