PspDeleteCreateProcessContext

INT64 __fastcall PspDeleteCreateProcessContext(INT64 a1){
  void *v2; 
  struct _DMA_ADAPTER *v3; 
  struct _DMA_ADAPTER *v4; 
  void *v5; 
  void *v6; 
  void *v7; 
  struct _DMA_ADAPTER *v8; 
  void *v9; 
  void *v10; 
  PVOID *v11; 
  INT64 v12; 
  INT64 v13; 
  __int64 v14; 
  void *v15; 
  unsigned __int64 v17; 
  PVOID *v18; 
  void *v19; 
  v2 = *(void **)(a1 + 168);
  if( v2 )
    ObCloseHandle(v2, 0);
  v3 = *(struct _DMA_ADAPTER **)(a1 + 176);
  if( v3 )
    HalPutDmaAdapter(v3);
  v4 = *(struct _DMA_ADAPTER **)(a1 + 152);
  if( v4 )
    HalPutDmaAdapter(v4);
  v5 = *(void **)(a1 + 128);
  if( v5 )
    ObfDereferenceObjectWithTag(v5, 0x72437350ui64);
  v6 = *(void **)(a1 + 184);
  if( v6 )
    ObCloseHandle(v6, 0);
  v7 = *(void **)(a1 + 192);
  if( v7 )
    ObCloseHandle(v7, 0);
  v8 = *(struct _DMA_ADAPTER **)(a1 + 200);
  if( v8 )
    HalPutDmaAdapter(v8);
  if( (*(_BYTE *)(a1 + 8) & 4) != 0 )
    ExFreePoolWithTag(*(PVOID *)(a1 + 208), 0);
  v9 = *(void **)(a1 + 280);
  if( v9 && v9 != (void *)(a1 + 264) )
    ExFreePoolWithTag(v9, 0);
  v10 = *(void **)(a1 + 296);
  if( v10 )
    ExFreePoolWithTag(v10, 0);
  v11 = *(PVOID **)(a1 + 400);
  if( v11 )
  {
    v17 = 0i64;
    if( *(_DWORD *)(a1 + 412) )
    {
      v18 = *(PVOID **)(a1 + 400);
      do
      {
        if( v11[v17] )
        {
          ObfDereferenceObjectWithTag(v11[v17], 0x6C4A7350ui64);
          v11 = *(PVOID **)(a1 + 400);
          v18 = v11;
        }
        ++v17;
      }
      while( v17 < *(unsigned int *)(a1 + 412) );
      v11 = v18;
    }
    ExFreePoolWithTag(v11, 0x6C4A7350u);
  }
  v12 = *(_QWORD *)(a1 + 392);
  if( v12 )
  {
    memset(v12, 0i64);
    ExFreePoolWithTag(*(PVOID *)(a1 + 392), 0);
  }
  v13 = *(_QWORD *)(a1 + 424);
  if( v13 )
  {
    memset(v13, 0i64);
    ExFreePoolWithTag(*(PVOID *)(a1 + 424), 0);
  }
  v14 = *(_QWORD *)(a1 + 440);
  if( v14 )
  {
    v19 = *(void **)(v14 + 8);
    if( v19 || (v19 = *(void **)(v14 + 24)) != 0i64 )
      ExFreePoolWithTag(v19, 0);
    ExFreePoolWithTag(*(PVOID *)(a1 + 440), 0);
  }
  v15 = *(void **)(a1 + 472);
  if( v15 )
  {
    ExFreePoolWithTag(v15, 0);
    *(_QWORD *)(a1 + 472) = 0i64;
  }
  RtlFreeAnsiString((_UNICODE_STRING *)(a1 + 232));
  return PspDestroyProcessParameterOverrides(*(_QWORD *)(a1 + 512));
}

Referenced by:

NtCreateThreadEx
NtCreateUserProcess
PspBuildCreateProcessContext