CmGetDeviceInterfaceSubkeyPath
NTSTATUS __fastcall CmGetDeviceInterfaceSubkeyPath(
__int64 a1,
const WCHAR *a2,
char a3,
wchar_t *a4,
wchar_t *pszDest,
unsigned int cchDest){
NTSTATUS result;
WCHAR *v10;
__int64 v11;
WCHAR *v12;
unsigned __int64 v13;
unsigned __int64 v14;
size_t *pcchRemaining;
size_t *pcchRemaininga;
UINT64 dwFlags;
size_t v18;
NTSTRSAFE_PWSTR ppszDestEnd;
struct _UNICODE_STRING DestinationString;
GUID Guid;
ppszDestEnd = 0i64;
v18 = 0i64;
Guid = 0i64;
DestinationString = 0i64;
result = CmValidateDeviceInterfaceName(a1, a2);
if( result >= 0 )
{
v10 = wcschr((WCHAR *)a2 + 4, 0x5Cu);
v11 = -1i64;
if( v10 )
{
v12 = v10 + 1;
v13 = v10 - a2;
}
else
{
v12 = 0i64;
v13 = -1i64;
do
++v13;
while( a2[v13] );
}
if( v13 > 0xFFFFFFFF )
return -1073741675;
if( (unsigned int)v13 < 0x30 )
return -1073741773;
v14 = (unsigned int)(v13 + 1);
if( a3 )
{
v14 += 2i64;
if( v12 )
{
do
++v11;
while( v12[v11] );
v14 += v11;
}
}
if( v14 > 0xFFFFFFFF )
return -1073741675;
if( !a4
|| (LODWORD(dwFlags) = 2048,
result = RtlStringCchCopyNExW(
a4,
0x27ui64,
(WCHAR *)&a2[(unsigned int)v13 - 38],
0x26ui64,
0i64,
0i64,
dwFlags),
result >= 0)
&& (result = RtlInitUnicodeStringEx(&DestinationString, a4), result >= 0)
&& (result = RtlGUIDFromString(&DestinationString, &Guid), result >= 0) )
{
if( (unsigned int)v14 > cchDest )
{
return -1073741789;
}
else
{
LODWORD(dwFlags) = 2048;
result = RtlStringCchCopyNExW(pszDest, cchDest, (WCHAR *)a2, (unsigned int)v13, &ppszDestEnd, &v18, dwFlags);
if( result >= 0 )
{
*(_QWORD *)pszDest = 0x23003F00230023i64;
if( a3 )
{
LODWORD(pcchRemaining) = 2048;
result = RtlStringCchCopyExW(ppszDestEnd, v18, (WCHAR *)L"\\#", &ppszDestEnd, &v18, (UINT64)pcchRemaining);
if( result >= 0 )
{
if( v12 )
{
LODWORD(pcchRemaininga) = 2048;
return RtlStringCchCopyExW(ppszDestEnd, v18, v12, &ppszDestEnd, &v18, (UINT64)pcchRemaininga);
}
}
}
}
}
}
}
return result;
}Referenced by:
CmGetDeviceInterfaceClassGuidString
CmGetDeviceInterfaceRegKeyPath