IoRegisterDeviceInterface

NTSTATUS __stdcall IoRegisterDeviceInterface(
        DEVICE_OBJECT *PhysicalDeviceObject,
        GUID *InterfaceClassGuid,
        UNICODE_STRING *ReferenceString,
        UNICODE_STRING *SymbolicLinkName){
  WCHAR *v4; 
  wchar_t *v5; 
  __int64 v9; 
  WCHAR *v10; 
  int v11; 
  NTSTATUS inited; 
  WCHAR *v13; 
  int v15; 
  WCHAR v16; 
  wchar_t *Str; 
  PCWSTR SourceString; 
  UINT64 ReturnLength; 
  GUID *InterfaceClassGuida; 
  InterfaceClassGuida = InterfaceClassGuid;
  LODWORD(ReturnLength) = 0;
  v4 = 0i64;
  v5 = 0i64;
  SourceString = 0i64;
  Str = 0i64;
  *SymbolicLinkName = 0i64;
  if( !PhysicalDeviceObject
    || (v9 = *(_QWORD *)(*((_QWORD *)PhysicalDeviceObject + 39) + 40i64)) == 0
    || (*(_DWORD *)(v9 + 396) & 0x20000) != 0 )
  {
    inited = -1073741808;
LABEL_15:
    if( v4 )
      ExFreePoolWithTag(v4, 0);
    goto LABEL_9;
  }
  if( !*(_QWORD *)(v9 + 48) )
    goto LABEL_13;
  ObQueryNameStringMode(PhysicalDeviceObject, 0i64, 0i64, &ReturnLength, 0);
  if( (unsigned int)ReturnLength <= 0x10 )
    goto LABEL_13;
  if( ReferenceString && ReferenceString->Length >= 2u )
  {
    v15 = PnpUnicodeStringToWstr(&Str, 0i64, ReferenceString);
    v5 = Str;
    inited = v15;
    if( v15 < 0 )
      goto LABEL_9;
    if( wcspbrk(Str, (PWCHAR)L"\\/", v16) )
    {
LABEL_13:
      inited = -1073741808;
      goto LABEL_9;
    }
  }
  v10 = *(WCHAR **)(v9 + 48);
  LODWORD(Str) = 0;
  v11 = IopRegisterDeviceInterface(v10, InterfaceClassGuida, v5, 0, (WCHAR **)&SourceString, (UINT64 *)&Str);
  v4 = (WCHAR *)SourceString;
  inited = v11;
  if( v11 < 0 )
    goto LABEL_15;
  v13 = (WCHAR *)SourceString;
  *((_DWORD *)PhysicalDeviceObject + 12) |= (unsigned int)Str;
  inited = RtlInitUnicodeStringEx(SymbolicLinkName, v13);
  if( inited < 0 )
    goto LABEL_15;
LABEL_9:
  PnpUnicodeStringToWstrFree(v5, ReferenceString);
  return inited;
}

Referenced by:

PiSwCompleteCreate