Closed oalieno closed 1 year ago
Hi oalieno, thanks for this, I will push the fix today. I'll check there aren't similar issues in other similar hooks.
I checked for any other parameters passed as PUNICODE_STRING and dereferenced - there are no others thankfully.
My sandbox is running at Windows 10. The crashed happened when
NtQueryValueKey
hooked function is trigger fromPrivateRegQueryValueExT
(I guess) inadvapi32.dll
.https://github.com/kevoreilly/capemon/blob/64d21309ad498819a678e640324c71c5feeba93b/hook_reg_native.c#L195-L196
In
loq
function, it will handle the "k" :"FullName", KeyHandle, ValueName
https://github.com/kevoreilly/capemon/blob/64d21309ad498819a678e640324c71c5feeba93b/log.c#L711
Then the
PUNICODE_STRING s
, which is theValueName
, is passed intoget_full_keyvalue_pathUS
https://github.com/kevoreilly/capemon/blob/64d21309ad498819a678e640324c71c5feeba93b/misc.c#L1195-L1201
Inside of
get_full_keyvalue_pathUS
. When accessingbuf[i]
, it crashed becausebuf
is null.https://github.com/kevoreilly/capemon/blob/64d21309ad498819a678e640324c71c5feeba93b/misc.c#L1153-L1154
For unknown reason, the
ValueName
passed toNtQueryValueKey
hasLength
> 0 andBuffer
null. That's the root cause of the crash.Fix is simple, just check
in->Buffer
before doing anything.