NtReplacePartitionUnit

NTSTATUS __stdcall NtReplacePartitionUnit(
        UNICODE_STRING *TargetInstancePath,
        UNICODE_STRING *SpareInstancePath,
        UINT64 Flags){
  int v3; 
  _DEVICE_OBJECT *v6; 
  _DEVICE_OBJECT *v7; 
  NTSTATUS UserModeCallersCopy; 
  ULONG v9; 
  _DEVICE_OBJECT *v10; 
  _DEVICE_OBJECT *v11; 
  _DEVICE_OBJECT *v12; 
  __int64 v13; 
  _DEVICE_OBJECT *v14; 
  __int64 v15; 
  UINT64 AllocateDestination; 
  UINT64 AllocateDestinationa; 
  PVOID Destination[3]; 
  VOID *Src[2]; 
  UNICODE_STRING a1; 
  PVOID P; 
  v3 = Flags;
  *(_OWORD *)Src = 0i64;
  a1 = 0i64;
  P = 0i64;
  v6 = 0i64;
  Destination[1] = 0i64;
  Destination[0] = 0i64;
  v7 = 0i64;
  if( *((_BYTE *)KeGetCurrentThread() + 562) != 1 )
  {
    UserModeCallersCopy = -1073741790;
    goto LABEL_35;
  }
  if( !SeSinglePrivilegeCheck(*(_QWORD *)&SeShutdownPrivilege, 1) )
  {
    UserModeCallersCopy = -1073741727;
    goto LABEL_35;
  }
  v9 = 0x80000000;
  if( v3 == 0x80000000 )
  {
    v10 = 0i64;
    v11 = 0i64;
LABEL_7:
    UserModeCallersCopy = IoReplacePartitionUnit(v11, v10, v9);
    goto LABEL_35;
  }
  if( v3 )
  {
    UserModeCallersCopy = -1073741583;
    goto LABEL_35;
  }
  if( ((unsigned __int8)SpareInstancePath & 7) != 0 )
    ExRaiseDatatypeMisalignment();
  if( (unsigned __int64)&SpareInstancePath[1] > 0x7FFFFFFF0000i64 || &SpareInstancePath[1] < SpareInstancePath )
    MEMORY[0x7FFFFFFF0000] = 0;
  if( ((unsigned __int8)TargetInstancePath & 7) != 0 )
    ExRaiseDatatypeMisalignment();
  if( (unsigned __int64)&TargetInstancePath[1] > 0x7FFFFFFF0000i64 || &TargetInstancePath[1] < TargetInstancePath )
    MEMORY[0x7FFFFFFF0000] = 0;
  *(UNICODE_STRING *)Src = *SpareInstancePath;
  a1 = *TargetInstancePath;
  if( (unsigned __int16)(a1.Length - 1) > 0xC8u || (a1.MaximumLength & 1) != 0 )
    goto LABEL_34;
  if( (unsigned __int16)(LOWORD(Src[0]) - 1) > 0xC8u || (BYTE2(Src[0]) & 1) != 0 )
  {
LABEL_33:
    UserModeCallersCopy = -1073741584;
    goto LABEL_35;
  }
  LODWORD(AllocateDestination) = 1;
  UserModeCallersCopy = PiControlMakeUserModeCallersCopy(&P, Src[1], LOWORD(Src[0]), 2ui64, 1, AllocateDestination);
  if( UserModeCallersCopy >= 0 )
  {
    LODWORD(AllocateDestinationa) = 1;
    UserModeCallersCopy = PiControlMakeUserModeCallersCopy(
                            Destination,
                            a1.Buffer,
                            a1.Length,
                            2ui64,
                            1,
                            AllocateDestinationa);
    if( UserModeCallersCopy >= 0 )
    {
      Src[1] = P;
      WORD1(Src[0]) = Src[0];
      a1.Buffer = (wchar_t *)Destination[0];
      a1.MaximumLength = a1.Length;
      v12 = (_DEVICE_OBJECT *)PnpDeviceObjectFromDeviceInstanceWithTag((INT64)Src, 0x746C6644ui64);
      v6 = v12;
      if( v12 )
      {
        v13 = *(_QWORD *)(*((_QWORD *)v12 + 39) + 40i64);
        if( v13 )
        {
          if( (*(_DWORD *)(v13 + 396) & 0x20000) == 0 )
          {
            v14 = (_DEVICE_OBJECT *)PnpDeviceObjectFromDeviceInstanceWithTag((INT64)&a1, 0x746C6644ui64);
            v7 = v14;
            if( v14 )
            {
              v15 = *(_QWORD *)(*((_QWORD *)v14 + 39) + 40i64);
              if( v15 )
              {
                if( (*(_DWORD *)(v15 + 396) & 0x20000) == 0 )
                {
                  v9 = 0;
                  v10 = v6;
                  v11 = v7;
                  goto LABEL_7;
                }
              }
            }
LABEL_34:
            UserModeCallersCopy = -1073741585;
            goto LABEL_35;
          }
        }
      }
      goto LABEL_33;
    }
  }
LABEL_35:
  if( v6 )
    ObfDereferenceObjectWithTag(v6, 0x746C6644ui64);
  if( v7 )
    ObfDereferenceObjectWithTag(v7, 0x746C6644ui64);
  if( P )
    ExFreePoolWithTag(P, 0);
  if( Destination[0] )
    ExFreePoolWithTag(Destination[0], 0);
  return UserModeCallersCopy;
}

Referenced by:

No references.