WdHwCreateHardwareRegister

NTSTATUS __stdcall WdHwCreateHardwareRegister(
        _LARGE_INTEGER PhysicalAddress,
        INT64 AccessSize,
        UINT8 HardwareRegister,
        _WD_HARDWARE_REGISTER *a4){
  NTSTATUS v4; 
  char v6; 
  unsigned __int8 v8; 
  NTSTATUS(__stdcall *Method)(UINT16); 
  char v10; 
  NTSTATUS(__stdcall *v11)(UINT16, UINT64); 
  UINT8 v12; 
  void(__fastcall *v13)(unsigned __int64, unsigned int); 
  unsigned __int64 QuadPart; 

  v4 = 0;
  v6 = AccessSize;
  if( !PhysicalAddress.QuadPart )
    return -1073741811;
  if( (unsigned __int8)(HardwareRegister - 1) > 2u )
    return -1073741811;
  if( !a4 )
    return -1073741811;
  v8 = 1 << (HardwareRegister - 1);
  Method = WdHwpGetReadMethod(AccessSize, v8);
  v11 = WdHwpGetWriteMethod(v6, v10);
  v13 = (void(__fastcall *)(unsigned __int64, unsigned int))v11;
  if( !Method || !v11 )
    return -1073741811;
  if( v6 )
  {
    if( v6 == v12 )
    {
      QuadPart = PhysicalAddress.QuadPart;
      goto LABEL_11;
    }
    return -1073741811;
  }
  QuadPart = HalMapIoSpace(PhysicalAddress, v8, MmNonCached, v12);
  if( QuadPart )
  {
LABEL_11:
    *(_DWORD *)(&a4->AccessSize + 1) = 0;
    *(_WORD *)(&a4->AccessSize + 5) = 0;
    a4->PhysicalAddress = PhysicalAddress;
    a4->AddressSpaceId = v6;
    a4->AccessSize = v8;
    a4->Address = QuadPart;
    a4->Read = (unsigned int(__fastcall *)(unsigned __int64))Method;
    a4->Write = v13;
    return v4;
  }
  return -1073741670;
}

Referenced by:

HalpWdatProcessWdrtInternalData
WdInstrInitializeInstruction