RtlFormatCurrentUserKeyPath
NTSTATUS __stdcall RtlFormatCurrentUserKeyPath(_UNICODE_STRING *CurrentUserKeyPath){
NTSTATUS result;
unsigned __int16 v3;
UINT64 v4;
wchar_t *StringRoutine;
wchar_t *Buffer;
unsigned __int64 v7;
int v8;
UINT64 StringLength;
_UNICODE_STRING UnicodeString;
VOID *TokenInformation;
StringLength = 0i64;
*(_DWORD *)(&UnicodeString.MaximumLength + 1) = 0;
result = ZwQueryInformationToken(
0xFFFFFFFFFFFFFFFAui64,
1i64,
(UINT64)&TokenInformation,
0x58ui64,
(UINT64)&StringLength + 4);
if( result >= 0 )
{
result = RtlLengthSidAsUnicodeString(TokenInformation, &StringLength);
if( result >= 0 )
{
v3 = StringLength;
CurrentUserKeyPath->Length = 0;
v4 = (unsigned __int16)(v3 + 34);
CurrentUserKeyPath->MaximumLength = v4;
StringRoutine = (wchar_t *)ExpAllocateStringRoutine(v4);
CurrentUserKeyPath->Buffer = StringRoutine;
if( StringRoutine )
{
RtlAppendUnicodeToString(CurrentUserKeyPath, (WCHAR *)L"\\REGISTRY\\USER\\");
Buffer = CurrentUserKeyPath->Buffer;
v7 = (unsigned __int64)CurrentUserKeyPath->Length >> 1;
UnicodeString.MaximumLength = v3;
UnicodeString.Length = 0;
UnicodeString.Buffer = &Buffer[v7];
v8 = RtlConvertSidToUnicodeString(&UnicodeString, TokenInformation, 0);
if( v8 < 0 )
RtlFreeAnsiString(CurrentUserKeyPath);
else
CurrentUserKeyPath->Length += UnicodeString.Length;
return v8;
}
else
{
return -1073741801;
}
}
}
return result;
}Referenced by:
AslRegistryBuildUserPath
RegRtlOpenPredefinedKey
RtlOpenCurrentUser
RtlpGetRegistryHandle