IopCreateArcName

INT64 __stdcall IopCreateArcName(DEVICE_OBJECT *DeviceObject, UINT64 DeviceNumber){
  CHAR *v3; 
  int v4; 
  _DWORD *PoolWithTag; 
  DEVICE_OBJECT *v6; 
  UINT64 OutputBufferLength; 
  IRP *v8; 
  NTSTATUS Status; 
  IRP *v10; 
  unsigned int v11; 
  UINT64 i; 
  UINT64 v13; 
  IRP *v14; 
  UINT8 v15; 
  UINT8 v16; 
  char v17; 
  PVOID *v18; 
  PVOID *v19; 
  bool v21; 
  WCHAR *v22; 
  WCHAR v23; 
  int v24; 
  WCHAR v25; 
  CHAR *Pool_1; 
  IRP *v27; 
  IRP *v28; 
  unsigned __int64 v29; 
  unsigned __int64 v30; 
  UINT8 v31; 
  unsigned __int8 *v32; 
  __int64 v33; 
  int v34; 
  int v35; 
  IRP *OutputBuffer; 
  struct _KEVENT Object; 
  IO_STATUS_BLOCK IoStatusBlock; 
  struct _UNICODE_STRING SymbolicLinkName; 
  LARGE_INTEGER StartingOffset; 
  struct _UNICODE_STRING DestinationString; 
  __int128 v42; 
  UINT64 Length; 
  __int64 v44; 
  int v45; 
  INT8 AnsiBuffer[64]; 
  wchar_t pszDest[64]; 
  VOID *retaddr; 
  v44 = 0i64;
  v45 = 0;
  v3 = 0i64;
  Length = 0i64;
  v4 = 0;
  PoolWithTag = 0i64;
  v6 = (DEVICE_OBJECT *)IoArcTableListHead;
  LODWORD(OutputBufferLength) = 4096;
  SymbolicLinkName = 0i64;
  DestinationString = 0i64;
  v42 = 0i64;
  memset(&Object, 0, sizeof(Object));
  IoStatusBlock = 0i64;
  while( 1 )
  {
    if( v6 == (DEVICE_OBJECT *)&IoArcTableListHead )
    {
      if( (_DWORD)DeviceNumber == -1 )
      {
        v8 = IoBuildDeviceIoControlRequest(0x2D1080u, DeviceObject, 0i64, 0, &v44, 0xCu, 0, &Object, &IoStatusBlock);
        if( !v8 )
          return(unsigned int)-1073741670;
        KeInitializeEvent(&Object, NotificationEvent, 0);
        Status = IofCallDriver(DeviceObject, v8);
        if( Status == 259 )
        {
          KeWaitForSingleObject(&Object, Executive, 0, 0, 0i64);
          Status = IoStatusBlock.Status;
        }
        if( Status < 0 )
          return(unsigned int)Status;
      }
      else
      {
        HIDWORD(v44) = DeviceNumber;
      }
      v10 = IoBuildDeviceIoControlRequest(0x70000u, DeviceObject, 0i64, 0, &v42, 0x18u, 0, &Object, &IoStatusBlock);
      if( v10 )
      {
        KeInitializeEvent(&Object, NotificationEvent, 0);
        Status = IofCallDriver(DeviceObject, v10);
        if( Status == 259 )
        {
          KeWaitForSingleObject(&Object, Executive, 0, 0, 0i64);
          Status = IoStatusBlock.Status;
        }
        if( Status < 0 )
          return(unsigned int)Status;
        v11 = HIDWORD(Length);
        if( HIDWORD(Length) < 0x200 )
          v11 = 512;
        v21 = *((_DWORD *)DeviceObject + 18) == 2;
        HIDWORD(Length) = v11;
        if( !v21 )
        {
          for( i = 4096i64; ; i = OutputBufferLength )
          {
            PoolWithTag = ExAllocatePoolWithTag(NonPagedPoolNx, i, 0x6F426F49ui64);
            if( !PoolWithTag )
            {
              Status = -1073741670;
              goto LABEL_36;
            }
            v14 = IoBuildDeviceIoControlRequest(
                    0x70050u,
                    DeviceObject,
                    0i64,
                    0,
                    PoolWithTag,
                    OutputBufferLength,
                    0,
                    &Object,
                    &IoStatusBlock);
            if( !v14 )
              break;
            KeResetEvent(&Object, v13, v15, v16, OutputBuffer);
            Status = IofCallDriver(DeviceObject, v14);
            if( Status == 259 )
            {
              KeWaitForSingleObject(&Object, Suspended, 0, 0, 0i64);
              Status = IoStatusBlock.Status;
            }
            if( Status != -1073741789 )
              goto LABEL_23;
            ExFreePoolWithTag(PoolWithTag, 0);
            OutputBufferLength = (unsigned int)(2 * OutputBufferLength);
          }
          Status = -1073741670;
LABEL_23:
          if( Status < 0 )
            goto LABEL_36;
          if( *PoolWithTag != 2 && (*PoolWithTag || PoolWithTag[1] || PoolWithTag[2]) )
          {
            v17 = 0;
            goto LABEL_30;
          }
          v4 = PoolWithTag[3];
LABEL_29:
          v17 = 1;
LABEL_30:
          v18 = (PVOID *)IoArcTableListHead;
          v19 = &IoArcTableListHead;
          while( 1 )
          {
            if( v18 == v19 )
            {
              Status = -1073741637;
              goto LABEL_36;
            }
            if( !*((_BYTE *)v18 + 72) && !v18[8] )
            {
              if( v17 )
              {
                if( *((_BYTE *)v18 + 36) )
                  goto LABEL_34;
                v21 = *((_DWORD *)v18 + 8) == v4;
              }
              else
              {
                if( !IopVerifyDiskSignature((__int64)PoolWithTag, (__int64)v18, &StartingOffset) )
                  goto LABEL_34;
                if( v18[7] )
                {
                  v31 = VhdiVerifyBootDisk(DeviceObject);
                  v19 = &IoArcTableListHead;
                  if( !v31 )
                    goto LABEL_34;
                }
                if( *PoolWithTag )
                  goto LABEL_47;
                v21 = *((_DWORD *)v18 + 8) == PoolWithTag[3];
              }
              if( v21 )
              {
LABEL_47:
                v18[8] = DeviceObject;
                v22 = L"\\Device\\CdRom%d";
                if( *((_DWORD *)DeviceObject + 18) != 2 )
                  v22 = (WCHAR *)L"\\Device\\Harddisk%d\\Partition0";
                RtlStringCchPrintfW(pszDest, 0x40ui64, v22);
                RtlInitUnicodeString(&DestinationString, pszDest, v23);
                RtlStringCchPrintfA(AnsiBuffer, 0x40ui64, (INT8 *)"\\ArcName\\%s");
                Status = IopCreateUnicodeFromAnsiBuffer(&SymbolicLinkName, AnsiBuffer);
                if( Status >= 0 )
                {
                  IoCreateSymbolicLink(&SymbolicLinkName, &DestinationString);
                  RtlFreeAnsiString(&SymbolicLinkName);
                  if( *((_DWORD *)DeviceObject + 18) == 2 )
                  {
                    if( *(_DWORD *)InitializationPhase < 2u )
                    {
                      v32 = (unsigned __int8 *)v18[3];
                      v33 = *((_QWORD *)KeLoaderBlock_0 + 23) - (_QWORD)v32;
                      do
                      {
                        v34 = v32[v33];
                        v35 = *v32 - v34;
                        if( v35 )
                          break;
                        ++v32;
                      }
                      while( v34 );
                      if( !v35 )
                        *((_DWORD *)DeviceObject + 12) |= 0x100u;
                    }
                  }
                  else if( PoolWithTag[1] )
                  {
                    Status = 0;
                    v24 = 1;
                    do
                    {
                      RtlStringCchPrintfW(pszDest, 0x40ui64, (WCHAR *)L"\\Device\\Harddisk%d\\Partition%d");
                      RtlInitUnicodeString(&DestinationString, pszDest, v25);
                      RtlStringCchPrintfA(AnsiBuffer, 0x40ui64, (INT8 *)"\\ArcName\\%spartition(%d)");
                      if( IopCreateUnicodeFromAnsiBuffer(&SymbolicLinkName, AnsiBuffer) >= 0 )
                      {
                        IoCreateSymbolicLink(&SymbolicLinkName, &DestinationString);
                        RtlFreeAnsiString(&SymbolicLinkName);
                      }
                      ++v24;
                    }
                    while( (unsigned int)(v24 - 1) < PoolWithTag[1] );
                  }
                }
LABEL_36:
                if( PoolWithTag )
                  ExFreePoolWithTag(PoolWithTag, 0);
                goto LABEL_38;
              }
            }
LABEL_34:
            v18 = (PVOID *)*v18;
          }
        }
        StartingOffset.QuadPart = 0x8000i64;
        Pool_1 = IopVerifierExAllocatePool_1(NonPagedPoolNxCacheAligned, v11);
        v3 = Pool_1;
        if( Pool_1 )
        {
          v27 = IopBuildSynchronousFsdRequest(
                  3ui64,
                  DeviceObject,
                  Pool_1,
                  HIDWORD(Length),
                  &StartingOffset,
                  &Object,
                  &IoStatusBlock,
                  retaddr);
          v28 = v27;
          if( !v27 )
          {
            Status = -1073741670;
            goto LABEL_38;
          }
          *(_BYTE *)(*((_QWORD *)v27 + 23) - 70i64) |= 2u;
          KeInitializeEvent(&Object, NotificationEvent, 0);
          Status = IofCallDriver(DeviceObject, v28);
          if( Status == 259 )
          {
            KeWaitForSingleObject(&Object, Executive, 0, 0, 0i64);
            Status = IoStatusBlock.Status;
          }
          if( Status >= 0 )
          {
            v29 = 0i64;
            v30 = (unsigned __int64)HIDWORD(Length) >> 2;
            if( v30 )
            {
              do
                v4 += *(_DWORD *)&v3[4 * v29++];
              while( v29 < v30 );
            }
            v4 = -v4;
            goto LABEL_29;
          }
LABEL_38:
          if( v3 )
            ExFreePoolWithTag(v3, 0);
          return(unsigned int)Status;
        }
      }
      return(unsigned int)-1073741670;
    }
    if( *((DEVICE_OBJECT **)v6 + 8) == DeviceObject )
      return 0i64;
    v6 = *(DEVICE_OBJECT **)v6;
  }
}

Referenced by:

IoCreateArcName
IopCreateArcNamesDisk