Hello everyone
In my Syscall Hooker, I want to print the values of hooked-syscall arguments; I've defined a function for each data type (save_HANDLE, save_ULONG, save_PUNICODE_STRING ...) that writes the value of that argument to a file.
Before designing this save_XXX functions, everything worked correctly, but now I've BSOD in save_PUNICODE_STRING.
Is there anything wrong with my save_UNICODE_STRING ?
In my Syscall Hooker, I want to print the values of hooked-syscall arguments; I've defined a function for each data type (save_HANDLE, save_ULONG, save_PUNICODE_STRING ...) that writes the value of that argument to a file.
Before designing this save_XXX functions, everything worked correctly, but now I've BSOD in save_PUNICODE_STRING.
Code: Select all
I call it like this:
void save_UNICODE_STRING(HANDLE fileHandle,WCHAR* name, PUNICODE_STRING value)
{
size_t cb;
IO_STATUS_BLOCK ioStatusBlock;
WCHAR* msg;
msg = (WCHAR*)ExAllocatePoolWithTag(NonPagedPool,255 * sizeof(WCHAR), 'abWd');
RtlStringCbPrintfW(msg,255 * sizeof(WCHAR),L"%wZ:%d\"%wZ\"\n",name,(value->Length)/2,value);
RtlStringCbLengthW(msg, 255 * sizeof(WCHAR), &cb);
ZwWriteFile(fileHandle, NULL, NULL, NULL, &ioStatusBlock,msg, cb, NULL, NULL);
ExFreePoolWithTag(msg,'abWd');
}
Code: Select all
I analyzed the crash dump file and the exact point of crash is after RtlStringCbPrintfW. ....
save_UNICODE_STRING(fileHandle,L"ValueName",ValueName); // ValueName is a PUNICODE_STRING (its the argument of hooked ZwSetValueKey)
...
Is there anything wrong with my save_UNICODE_STRING ?
We work in the dark, we do what we can, we give what we have.
Our doubt is our passion and our passion is our task.
The rest is the madness of art
Our doubt is our passion and our passion is our task.
The rest is the madness of art