PnpUnicodeStringToWstr
INT64 __stdcall PnpUnicodeStringToWstr(
WCHAR **OutString,
UINT64 *OutStringMaximumSize,
UNICODE_STRING *InUnicodeString){
unsigned int v3;
__int64 MaximumLength;
wchar_t *Buffer;
unsigned __int64 Length;
WCHAR v10;
unsigned __int64 v11;
int v12;
UINT8 *PoolWithTag;
WCHAR *v14;
unsigned __int64 v15;
WCHAR *v17;
v3 = 0;
if( !OutString || !InUnicodeString )
return(unsigned int)-1073741811;
MaximumLength = InUnicodeString->MaximumLength;
if( (unsigned __int16)MaximumLength < 2u || (Buffer = InUnicodeString->Buffer) == 0i64 )
{
*OutString = 0i64;
if( OutStringMaximumSize )
*(_DWORD *)OutStringMaximumSize = 0;
return v3;
}
Length = InUnicodeString->Length;
if( (unsigned __int16)Length > (unsigned __int16)MaximumLength )
return(unsigned int)-1073741811;
v10 = *Buffer;
if( (_WORD)Length )
{
if( !v10 )
goto LABEL_17;
v11 = (unsigned __int64)InUnicodeString->Length >> 1;
if( (_WORD)Length == (_WORD)MaximumLength && !Buffer[v11 - 1] )
goto LABEL_17;
if( Length <= MaximumLength - 2 && (!Buffer[v11 - 1] || !Buffer[v11]) )
goto LABEL_17;
v12 = Length + 2;
PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, (unsigned int)(Length + 2), 0x75737050ui64);
v14 = (WCHAR *)PoolWithTag;
if( PoolWithTag )
{
memmove(PoolWithTag, (UINT8 *)InUnicodeString->Buffer, InUnicodeString->Length);
v15 = (unsigned __int64)InUnicodeString->Length >> 1;
*OutString = v14;
v14[v15] = 0;
if( OutStringMaximumSize )
*(_DWORD *)OutStringMaximumSize = v12;
return v3;
}
return(unsigned int)-1073741670;
}
if( !v10 )
{
LABEL_17:
*OutString = Buffer;
if( OutStringMaximumSize )
*(_DWORD *)OutStringMaximumSize = MaximumLength;
return v3;
}
v17 = (WCHAR *)ExAllocatePoolWithTag(PagedPool, 2ui64, 0x75737050ui64);
if( !v17 )
return(unsigned int)-1073741670;
*v17 = 0;
*OutString = v17;
if( OutStringMaximumSize )
*(_DWORD *)OutStringMaximumSize = 2;
return v3;
}Referenced by:
IoGetDeviceInterfaceAlias
IoOpenDeviceInterfaceRegistryKey
IoRegisterDeviceInterface
IoReportDetectedDevice
IopBuildGlobalSymbolicLinkString
IopDeviceObjectFromSymbolicName
IopGetDeviceInterfaces
IopInitializeBootDrivers
IopProcessSetInterfaceState
PiControlGetDeviceInterfaceEnabled
PiDeviceRegistration
PiInitializeDevice
PipApplyFunctionToServiceInstances
PipInitComputerIds
PnpDeleteDeviceInterfaces
PnpDisableDeviceInterfaces
PnpGetDeviceDependencyList
PnpGetDeviceInstanceCsConfigFlags
PnpGetDeviceInterfacePropertyData
PnpIsDeviceInstanceEnabled
PnpSetDeviceInterfacePropertyData
PpForEachDeviceInstanceDriver