HalSetEnvironmentVariableEx

NTSTATUS __stdcall HalSetEnvironmentVariableEx(
        WCHAR *VariableName,
        _GUID *VendorGuid,
        VOID *Value,
        UINT64 ValueLength,
        UINT64 Attributes){
  int v5; 
  char v8; 
  __int64 v9; 
  __int64 v10; 
  UINT64 v11; 
  unsigned __int64 v12; 
  __int64 v13; 
  signed __int64 v14; 
  void *v15; 
  void *v16; 
  unsigned int v17; 
  NTSTATUS v18; 
  wchar_t Dst[8]; 
  _GROUP_AFFINITY PreviousAffinity; 

  v5 = ValueLength;
  *(_OWORD *)Dst = 0i64;
  PreviousAffinity = 0i64;
  if( !byte_140C49D08 )
    return -1073741822;
  v8 = 1;
  if( (Attributes & 1) == 0 )
    return -1073741811;
  v9 = -1i64;
  do
    ++v9;
  while( VariableName[v9] );
  v10 = (unsigned int)(v9 + 1);
  if( (unsigned int)v10 >= 0x100 )
    v10 = 256i64;
  v11 = (unsigned int)v10;
  v12 = 2 * v10;
  v13 = v12 + 15;
  if( v12 + 15 <= v12 )
    v13 = 0xFFFFFFFFFFFFFF0i64;
  v14 = v13 & 0xFFFFFFFFFFFFFFF0ui64;
  v15 = alloca(v14);
  v16 = alloca(v14);
  wcscpy_s(Dst, v11, VariableName);
  if( KeGetCurrentIrql() >= 2u )
  {
    v8 = 0;
  }
  else
  {
    v17 = KiProcessorIndexToNumberMappingTable[KeGetPcr()->Prcb.Number];
    Dst[6] = 0;
    Dst[7] = 0;
    *(_DWORD *)&Dst[4] = (unsigned __int16)(v17 >> 6);
    *(_QWORD *)Dst = 1i64 << (v17 & 0x3F);
    KeSetSystemGroupAffinityThread((PGROUP_AFFINITY)Dst, &PreviousAffinity);
  }
  if( (Attributes & 0x40) != 0 )
    v18 = -1073741811;
  else
    v18 = HalEfiSetEnvironmentVariable((__int64)Dst);
  if( v5 )
    v18 = HalEfiSetEnvironmentVariable((__int64)Dst);
  if( v8 )
    KeRevertToUserGroupAffinityThread(&PreviousAffinity);
  return v18;
}

Referenced by:

HaliAcpiSleep
IopSetEnvironmentVariableHal
PopCheckpointSystemSleepUnsafe
PopSetMemoryOverwriteRequestAction
WheapCheckForAndReportErrorsFromPreviousSession
WheapPersistPageForMemoryError