CmpCreateHwProfileFriendlyName
INT64 __stdcall CmpCreateHwProfileFriendlyName(
PVOID IDConfigDB,
UINT64 DockingState,
UINT64 NewProfileNumber,
_UNICODE_STRING *FriendlyName){
unsigned int v5;
unsigned int v8;
const wchar_t *v9;
INT64 v10;
unsigned __int16 v11;
wchar_t *Buffer;
NTSTATUS v13;
INT64 v14;
int v15;
INT64 Length;
UINT64 Lengtha;
UINT64 Lengthb;
UINT64 *ResultLength;
UINT64 *ResultLengtha;
INT64 Data;
VOID *KeyHandle;
UINT64 v23;
_UNICODE_STRING DestinationString;
_UNICODE_STRING UnicodeString;
_STRING ReturnedString;
_UNICODE_STRING v27;
_OBJECT_ATTRIBUTES ObjectAttributes;
wchar_t Dst[80];
int KeyValueInformation[64];
LODWORD(v23) = 0;
LODWORD(Data) = 0;
KeyHandle = 0i64;
v5 = NewProfileNumber;
ReturnedString = 0i64;
UnicodeString = 0i64;
DestinationString = 0i64;
v27 = 0i64;
memset(&ObjectAttributes, 0, sizeof(ObjectAttributes));
if( !FriendlyName )
return 3221225485i64;
if( IDConfigDB )
{
if( (DockingState & 3) == 3 )
goto LABEL_9;
if( (DockingState & 2) != 0 )
{
v8 = 1073807362;
v9 = L"Docked";
goto LABEL_10;
}
if( (DockingState & 1) == 0 )
{
LABEL_9:
v8 = 1073807363;
v9 = L"Unknown";
}
else
{
v8 = 1073807361;
v9 = L"Undocked";
}
LABEL_10:
RtlInitUnicodeString(&DestinationString, v9);
if( KeGetBugMessageText(v8, &ReturnedString, v10)
&& RtlAnsiStringToUnicodeString(&UnicodeString, &ReturnedString, 1u) >= 0 )
{
v11 = UnicodeString.Length;
Buffer = UnicodeString.Buffer;
if( UnicodeString.Length > 4u )
{
v11 = UnicodeString.Length - 4;
UnicodeString.Length = v11;
UnicodeString.Buffer[(unsigned __int64)v11 >> 1] = 0;
}
if( (unsigned __int64)v11 + 12 <= 0xA0 )
{
RtlInitUnicodeString(&v27, L"Hardware Profiles");
ObjectAttributes.Length = 48;
ObjectAttributes.ObjectName = &v27;
ObjectAttributes.RootDirectory = IDConfigDB;
ObjectAttributes.Attributes = 576;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v13 = ZwOpenKey(
&KeyHandle,
0x20019ui64,
&ObjectAttributes,
v14,
Length,
(INT64)ResultLength,
Data,
(INT64)KeyHandle);
if( v13 >= 0 )
{
LODWORD(Lengtha) = 256;
if( ZwQueryValueKey(
KeyHandle,
&DestinationString,
KeyValueFullInformation,
KeyValueInformation,
Lengtha,
&v23) >= 0
&& KeyValueInformation[1] == 4 )
{
v15 = *(int *)((char *)KeyValueInformation + (unsigned int)KeyValueInformation[2]) + 1;
}
else
{
v15 = 1;
}
LODWORD(Data) = v15;
LODWORD(ResultLengtha) = 4;
v13 = ZwSetValueKey(KeyHandle, &DestinationString, 0i64, 4ui64, &Data, (UINT64)ResultLengtha);
if( v13 >= 0 )
{
if( v8 == 1073807363 || (unsigned int)Data > 1 )
{
LODWORD(Lengthb) = Data;
swprintf_s(Dst, 0x50ui64, (WCHAR *)L"%s %u", Buffer, Lengthb);
}
else
{
wcscpy_s(Dst, 0x50ui64, Buffer);
}
}
}
else
{
KeyHandle = 0i64;
}
}
else
{
v13 = -1073741823;
}
RtlFreeAnsiString(&UnicodeString);
if( KeyHandle )
ZwClose((_HANDLE)KeyHandle);
if( v13 >= 0 )
goto LABEL_31;
}
}
Dst[0] = 0;
swprintf_s(Dst, 0x50ui64, (WCHAR *)L"%04d", v5);
v13 = 0;
LABEL_31:
if( !RtlCreateUnicodeString((INT64)FriendlyName, (INT8 *)Dst) )
return(unsigned int)-1073741823;
return(unsigned int)v13;
}Referenced by:
CmpCloneHwProfile