IoWMISuggestInstanceName
NTSTATUS __stdcall IoWMISuggestInstanceName(
_DEVICE_OBJECT *PhysicalDeviceObject,
_UNICODE_STRING *SymbolicLinkName,
UINT8 CombineNames,
_UNICODE_STRING *SuggestedInstanceName){
int DeviceProperty;
NTSTATUS result;
unsigned __int16 v10;
void *PoolWithTag;
NTSTATUS v12;
unsigned __int16 *v13;
WCHAR *v14;
ULONG v15;
wchar_t *v16;
wchar_t *v17;
ULONG BufferLength;
ULONG Length;
void *DeviceInterfaceRegKey;
struct _UNICODE_STRING ValueName;
DeviceInterfaceRegKey = 0i64;
Length = 0;
DeviceProperty = -1073741776;
ValueName = 0i64;
if( !WmipServiceDeviceObject )
return -1073741823;
v10 = 0;
PoolWithTag = 0i64;
BufferLength = 0;
if( PhysicalDeviceObject )
{
result = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyDeviceDescription, 0, 0i64, &BufferLength);
DeviceProperty = result;
if( result == -1073741789 )
{
PoolWithTag = ExAllocatePoolWithTag(PagedPool, BufferLength, 0x70696D57ui64);
if( !PoolWithTag )
return -1073741670;
DeviceProperty = IoGetDeviceProperty(
PhysicalDeviceObject,
DevicePropertyDeviceDescription,
BufferLength,
PoolWithTag,
&BufferLength);
if( DeviceProperty < 0 )
goto LABEL_35;
}
else if( result < 0 )
{
return result;
}
v10 = BufferLength;
}
if( !SymbolicLinkName )
{
if( PoolWithTag )
{
SuggestedInstanceName->Buffer = (wchar_t *)PoolWithTag;
SuggestedInstanceName->Length = v10 - 2;
SuggestedInstanceName->MaximumLength = v10;
}
else
{
SuggestedInstanceName->Buffer = 0i64;
*(_DWORD *)&SuggestedInstanceName->Length = 0;
}
return DeviceProperty;
}
DeviceProperty = IoOpenDeviceInterfaceRegistryKey(SymbolicLinkName, 0xF003Fui64, &DeviceInterfaceRegKey);
if( DeviceProperty >= 0 )
{
v12 = ZwQueryValueKey(DeviceInterfaceRegKey, &ValueName, KeyValueFullInformation, 0i64, 0, &Length);
DeviceProperty = v12;
if( v12 == -2147483643 || v12 == -1073741789 )
{
v13 = (unsigned __int16 *)ExAllocatePoolWithTag(PagedPool, Length, 0x70696D57ui64);
if( v13 )
{
DeviceProperty = ZwQueryValueKey(
DeviceInterfaceRegKey,
&ValueName,
KeyValueFullInformation,
v13,
Length,
&Length);
if( DeviceProperty >= 0 )
{
v14 = (unsigned __int16 *)((char *)v13 + *((unsigned int *)v13 + 2));
if( CombineNames )
{
v15 = *((_DWORD *)v13 + 3) + BufferLength + 2;
v16 = (wchar_t *)ExAllocatePoolWithTag(PagedPool, v15, 0x70696D57ui64);
if( v16 )
{
SuggestedInstanceName->Buffer = v16;
SuggestedInstanceName->Length = 0;
SuggestedInstanceName->MaximumLength = v15;
if( PoolWithTag )
RtlAppendUnicodeToString(SuggestedInstanceName, (PWCHAR)PoolWithTag);
RtlAppendUnicodeToString(SuggestedInstanceName, (PWCHAR)&stru_1407CDE30.OutputLength);
RtlAppendUnicodeToString(SuggestedInstanceName, v14);
}
else
{
DeviceProperty = -1073741670;
}
if( PoolWithTag )
{
ExFreePoolWithTag(PoolWithTag, 0);
PoolWithTag = 0i64;
}
}
else
{
if( PoolWithTag )
{
ExFreePoolWithTag(PoolWithTag, 0);
PoolWithTag = 0i64;
}
v17 = (wchar_t *)ExAllocatePoolWithTag(PagedPool, *((unsigned int *)v13 + 3), 0x70696D57ui64);
if( v17 )
{
SuggestedInstanceName->Buffer = v17;
SuggestedInstanceName->Length = 0;
SuggestedInstanceName->MaximumLength = v13[6];
RtlAppendUnicodeToString(SuggestedInstanceName, v14);
}
else
{
DeviceProperty = -1073741670;
}
}
}
ExFreePoolWithTag(v13, 0);
}
else
{
DeviceProperty = -1073741670;
}
}
ZwClose(DeviceInterfaceRegKey);
}
if( !PoolWithTag || DeviceProperty >= 0 )
return DeviceProperty;
LABEL_35:
ExFreePoolWithTag(PoolWithTag, 0);
return DeviceProperty;
}Referenced by:
No references.