# CVE-2026-54113 — ntoskrnl.exe patch diff

`ntoskrnl.exe` 10.0.26100.8875 -> 10.0.26100.9168 (ghidriff).

## `PopTransitionSystemPowerStateEx`  (modified)

```diff
--- PopTransitionSystemPowerStateEx
+++ PopTransitionSystemPowerStateEx
@@ -1,49 +1,757 @@
 

 /* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

+/* WARNING: Type propagation algorithm not settling */

+/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

 

-void PopTransitionSystemPowerStateEx(int param_1)

+ulonglong PopTransitionSystemPowerStateEx(int *param_1)

 

 {

-  ulonglong uVar1;

-  char cVar2;

-  undefined4 uVar3;

-  undefined4 extraout_var;

-  uint unaff_EBX;

-  longlong unaff_RDI;

+  int *piVar1;

+  int *piVar2;

+  int *piVar3;

+  code *pcVar4;

+  int iVar5;

+  char cVar6;

+  char cVar7;

+  uint uVar8;

+  int iVar9;

+  ulonglong uVar10;

+  ulonglong uVar11;

+  undefined8 uVar12;

+  longlong lVar13;

+  undefined1 *puVar14;

+  longlong lVar15;

+  int *piVar16;

+  undefined8 *puVar17;

+  undefined1 uVar18;

+  ulonglong uVar19;

+  int *piVar20;

+  undefined1 local_res8 [8];

+  undefined4 local_res10 [2];

+  undefined4 local_res18 [2];

+  longlong local_res20;

+  ulonglong in_stack_ffffffffffffff08;

+  int *in_stack_ffffffffffffff10;

+  undefined4 uVar21;

+  ulonglong in_stack_ffffffffffffff18;

+  undefined4 uVar22;

+  longlong local_c8 [2];

+  undefined8 *local_b8;

+  undefined8 *local_b0;

+  undefined8 local_a8;

+  undefined1 *local_a0;

+  undefined8 local_98;

+  undefined8 uStack_90;

+  undefined8 local_88;

+  undefined8 uStack_80;

+  undefined4 local_78 [2];

+  undefined1 *local_70;

+  undefined4 local_68;

+  undefined4 local_60;

+  undefined1 *local_58;

+  undefined4 local_50;

   

-  uVar3 = 0;

-  if (param_1 != 0) {

-    if ((PopCheckpointSystemSleepSimulateFlags & 1) == 0) {

-      if (PoAllProcIntrDisabled == '\0') {

-        LOCK();

-        UNLOCK();

-        if (PopPagingEnabled == 0) {

-                    /* WARNING: Subroutine does not return */

-          KeBugCheckEx(0xa0);

-        }

+  local_a8 = 0x20000;

+  local_a0 = &u_;

+  local_res10[0] = 0;

+  local_b0 = &local_a8;

+  *(undefined1 *)(param_1 + 3) = 0;

+  piVar1 = param_1 + 0x1b;

+  *(undefined1 *)(param_1 + 6) = 0;

+  param_1[7] = 0;

+  param_1[0x10] = 0;

+  param_1[0x11] = 0;

+  param_1[10] = 0;

+  param_1[0xb] = 0;

+  uVar12 = 0;

+  param_1[0x19] = 0;

+  *piVar1 = 0;

+  param_1[0x32] = 0;

+  param_1[0x33] = 0;

+  param_1[0x2c] = 0;

+  param_1[0x2d] = 0;

+  param_1[0x2e] = 0;

+  param_1[0x2f] = 0;

+  param_1[0x4c] = 0;

+  param_1[0x4d] = 0;

+  *(undefined1 *)(param_1 + 0x54) = 0;

+  param_1[0x50] = 0;

+  param_1[0x51] = 0;

+  param_1[0x53] = 0;

+  local_b8 = &local_a8;

+  local_res18[0] = 0;

+  local_res20 = 0;

+  local_c8[0] = 0;

+  local_c8[1] = 0;

+  param_1[0x1c] = 1;

+  param_1[0x1d] = 1;

+  *(undefined1 *)(param_1 + 0x36) = 1;

+  param_1[0x52] = 1;

+  param_1[0x30] = 0;

+  param_1[0x31] = 0;

+  uVar8 = PopSimulate & 0x10000;

+  param_1[0x16] = 0;

+  local_98 = 0;

+  uStack_90 = 0;

+  param_1[0x55] = (-(uint)(uVar8 != 0) & 0xee1e5d00) + 600000000;

+  PopTransitionCheckpoint(8,1);

+  if (*param_1 == 2) {

+    PnpSurpriseFailUnsafeDmaDevices();

+  }

+  if (*param_1 == 4) {

+    PopReadShutdownPolicy();

+  }

+  PopAcquireTransitionLockAfterSleep();

+  MmLockPagableSectionByHandle(ExPageLockHandle);

+  PopRunMaximumIrpWorkers();

+  _DAT_0 = 0;

+  _DAT_1 = PopUnlockAfterSleepWorker;

+  _PopUnlockAfterSleepWorkItem = 0;

+  CmSetLazyFlushState(0);

+  PopNotifyCallbacksPreSleep();

+  ExSwapinWorkerThreads(0);

+  if (DAT_2 == 1) {

+    uVar12 = 2;

+  }

+  iVar9 = PoInitializeBroadcast(uVar12);

+  param_1[0x16] = iVar9;

+  if (iVar9 < 0) {

+    ExQueueWorkItem(&PopUnlockAfterSleepWorkItem,1);

+    *piVar1 = 5;

+    lVar13 = 0;

+    lVar15 = 0;

+    goto LAB_3;

+  }

+  PopCheckPowerSourceAfterRtcWakeCancel();

+  PopCurrentPowerStatePrecise(param_1 + 0x1e,local_c8 + 1);

+  PopAcquirePolicyLock();

+  *(undefined1 *)(param_1 + 0xc) = 1;

+  PopFilterCapabilities(&PopCapabilities,&DAT_4);

+  if (DAT_5 == '\0') {

+    PopResetActionDefaults();

+  }

+  else if (DAT_5 != '\x02') {

+    PopReleasePolicyLock();

+    PoClearBroadcast();

+    ExQueueWorkItem(&PopUnlockAfterSleepWorkItem,1);

+    *piVar1 = 6;

+    param_1[0x16] = -0x3fffffdf;

+    lVar13 = 0;

+    lVar15 = 0;

+    goto LAB_3;

+  }

+  PopSetPowerActionState(3);

+  DAT_6 = DAT_140f0b4b0;

+  PopIgnoreBatteryStatusChange();

+  PopCheckResiliencyScenarios();

+  PopEnforceResiliencyScenarios(param_1 + 0x34);

+  PopExecuteOnTargetProcessors(&KeActiveProcessors,PpmStopIllegalProcessorThrottleLogging,0,0);

+  if (*param_1 == 6) {

+    DAT_7 = 6;

+  }

+  if (*param_1 - 4U < 3) {

+    PoPowerDownActionInProgress = 1;

+    if (*param_1 == 5) {

+      PoPowerResetActionInProgress = 1;

+    }

+    if (((PopHiberInfo != 0) && (DAT_8 != 0)) &&

+       (iVar9 = MmZeroPageFileAtShutdown(), iVar9 != 0)) {

+      PopZeroHiberFile(PopHiberInfo,DAT_8);

+    }

+  }

+  piVar2 = param_1 + 0x12;

+  *(char *)piVar2 = '\0';

+  piVar3 = param_1 + 4;

+  *piVar3 = 0;

+  if (*param_1 - 2U < 2) {

+    PoPowerDownActionInProgress = 1;

+  }

+  *(undefined1 *)(param_1 + 0x18) = 0;

+  param_1[0x16] = -0x3ffffee0;

+LAB_9:

+  do {

+    while( true ) {

+      piVar20 = param_1 + 0x52;

+      piVar16 = param_1 + 0x53;

+      if ((char)param_1[0xc] == '\0') {

+        PopAcquirePolicyLock();

+        *(undefined1 *)(param_1 + 0xc) = 1;

+      }

+      if (DAT_7 == 0) {

+        *piVar1 = 6;

+        param_1[0x16] = 0;

+        goto LAB_10;

+      }

+      *(byte *)(param_1 + 0x1a) = PopAction;

+      PopAction = 0;

+      if (param_1[0x16] == -0x3ffffee0) {

+        if ((((*(byte *)(param_1 + 0x1a) & 2) != 0) && (-1 < (int)DAT_11)) &&

+           ((DAT_11 & 3) != 0)) {

+          PopGetPolicyWorker(2);

+          *piVar1 = 8;

+          goto LAB_10;

+        }

+        PopActionRetrieveInitialState(&DAT_12,piVar3,&DAT_140f0b90c,piVar2);

+        if (DAT_7 - 4U < 3) {

+          DAT_13 = '\x01';

+          DAT_11 = param_1[2];

+        }

+        param_1[0x16] = 0;

+      }

+      else if (param_1[0x16] < 0) goto LAB_10;

+      PopReleasePolicyLock();

+      *piVar16 = 0;

+      *(undefined1 *)(param_1 + 0xc) = 0;

+      *piVar20 = 1;

+      PopQueryPowerSettingUlong(&GUID_ALLOW_RTC_WAKE,piVar20,piVar16);

+      if ((DAT_11 & 0x40000000) != 0) {

+        *piVar20 = 0;

+        *piVar16 = 0;

+      }

+      if (((DAT_14 == '\0') && (DAT_140f0b9c4 == '\0')) && (DAT_140f0b9cb == '\0')) {

+        *piVar16 = 0;

+      }

+      PopInitializePowerPolicySimulate();

+      DAT_15 = DAT_140f0b90c;

+      uVar8 = DAT_11 >> 0x1b & 2;

+      param_1[0x17] = uVar8;

+      PopAdvanceSystemPowerState(&DAT_15,uVar8,DAT_140f0b8e8,*piVar3);

+      if ((param_1[2] & 8U) == 0) break;

+      DAT_16 = '\x01';

+      *(undefined1 *)(param_1 + 6) = 0;

+      DAT_17 = 5;

+      param_1[8] = 6;

+      iVar9 = DAT_18;

+LAB_19:

+      uVar8 = *(uint *)(&PopPowerStateHandlerLookup + (longlong)iVar9 * 4);

+      param_1[0xd] = uVar8;

+      if (uVar8 < 7) goto LAB_20;

+LAB_21:

+      cVar6 = PopFindNextSystemPowerState(*piVar3,(char)param_1[6],piVar2);

+      *(char *)(param_1 + 9) = cVar6;

+      if (cVar6 == '\0') goto LAB_10;

+LAB_22:

+      param_1[0x16] = 0;

+    }

+    cVar6 = PopFastS4Check();

+    if (cVar6 == '\0') {

+      DAT_17 = DAT_140f0b90c;

+      param_1[8] = DAT_18;

+      iVar9 = DAT_18;

+      *(undefined1 *)(param_1 + 6) = 0;

+      goto LAB_19;

+    }

+    param_1[8] = DAT_18;

+    uVar8 = 6;

+    DAT_17 = 5;

+    *(undefined1 *)(param_1 + 6) = 1;

+    param_1[0xd] = 6;

+LAB_20:

+    if (*(longlong *)(&DAT_23 + (longlong)(int)uVar8 * 0x18) == 0) goto LAB_140b70e1d;

+    if ((param_1[2] & 8U) == 0) {

+      iVar9 = DAT_18;

+      if (DAT_13 == '\0') goto LAB_140b70d62;

+      PopSetShutdownMarker();

+      PopSaveLidReliabilityState();

+    }

+    else {

+      iVar9 = 6;

+LAB_24:

+      PopSetSleepMarker(iVar9);

+    }

+    PopAcquirePolicyLock();

+    if ((PopAction & 6) != 0) {

+      *(undefined1 *)(param_1 + 0xc) = 1;

+      param_1[0x16] = -0x3ffffee0;

+      goto LAB_9;

+    }

+    cVar6 = *(char *)(PopSmartSuspendDecision + 2);

+    uVar11 = *(ulonglong *)(PopSmartSuspendDecision + 0x38);

+    PopReleasePolicyLock();

+    PopCheckpointSystemSleep(10);

+    DAT_25 = 3;

+    PopDiagTraceKernelQueriesAllowed((char)*piVar2);

+    if ((char)*piVar2 != '\0') {

+      iVar9 = PopSetDevicesSystemState();

+      param_1[0x16] = iVar9;

+      if (-1 < iVar9) {

+        *(undefined1 *)(param_1 + 0x18) = 1;

+        goto LAB_26;

+      }

+      if (iVar9 == -0x3ffffee0) goto LAB_26;

+      cVar6 = PopFindNextSystemPowerState(*piVar3,(char)param_1[6],piVar2);

+      *(char *)(param_1 + 9) = cVar6;

+      if (cVar6 != '\0') goto LAB_22;

+      *piVar1 = 9;

+      goto LAB_10;

+    }

+LAB_26:

+  } while (param_1[0x16] == -0x3ffffee0);

+  if (-1 < param_1[0x16]) {

+    PopCheckpointSystemSleep(0xd);

+    iVar9 = PopAllocateHiberContext(piVar1);

+    param_1[0x16] = iVar9;

+    if (-1 < iVar9) {

+      in_stack_ffffffffffffff08 = CONCAT71((int7)(in_stack_ffffffffffffff08 >> 8),1);

+      iVar9 = PopNotifyTelemetryOsState

+                        (DAT_7,DAT_140f0b90c,DAT_140f0b914,param_1[2],

+                         in_stack_ffffffffffffff08);

+      param_1[0x19] = iVar9;

+      PopTransitionCheckpoint(9);

+      if (DAT_13 == '\0') {

+        in_stack_ffffffffffffff10 = param_1 + 0x1e;

+        PopCurrentPowerState(in_stack_ffffffffffffff10);

+        in_stack_ffffffffffffff08 = CONCAT44((int)(in_stack_ffffffffffffff08 >> 0x20),param_1[0x19])

+        ;

+        in_stack_ffffffffffffff18 = DAT_27;

+        PopDiagTracePreSleepNotification

+                  (param_1[8],DAT_17,DAT_140f0b8f4,DAT_140f0b8f8,in_stack_ffffffffffffff08,

+                   in_stack_ffffffffffffff10,DAT_27);

+        PopCheckpointSystemSleep(0x10);

+        PopUmpoSendFlushSleepStudyLoggerNotification();

+      }

+      PopEsEnterSleepShutdown();

+      PopThermalSxEntry();

+      PopFanSxEntry();

+      if ((char)param_1[3] == '\0') {

+        if (DAT_13 != '\0') {

+          local_res8[0] = 1;

+          local_70 = local_res8;

+          local_78[0] = 5;

+          local_68 = 1;

+          local_60 = 0xb;

+          local_58 = &DAT_28;

+          local_50 = 4;

+          RtlSetSystemBootStatusEx(local_78,2);

+        }

+        *(undefined1 *)(param_1 + 3) = 1;

+      }

+      iVar9 = 5;

+      if ((char)param_1[6] == '\0') {

+        iVar9 = DAT_18;

+      }

+      PopFlushVolumes(iVar9);

+      if (DAT_17 < DAT_140f0b90c) {

+        DAT_17 = DAT_140f0b90c;

+      }

+      DAT_25 = 2;

+      if (DAT_13 != '\0') {

+        PopFxPrepareDevicesForShutdown();

+        IoFreePoDeviceNotifyList(DAT_6 + 0x30);

+        if (DAT_29 == 2) {

+          PopCriticalShutdownInProgress = 1;

+        }

+        PopTransitionCheckpoint(8,2);

+        PopGracefulShutdown();

+        pcVar4 = (code *)swi(3);

+        uVar11 = (*pcVar4)();

+        return uVar11;

+      }

+      KeMtrrComparisonFailed = '\0';

+      iVar9 = PopInitSystemSleeperThread(param_1[0xd],param_1 + 0x38,&local_98);

+      uVar21 = (undefined4)((ulonglong)in_stack_ffffffffffffff10 >> 0x20);

+      uVar22 = (undefined4)(in_stack_ffffffffffffff18 >> 0x20);

+      param_1[0x16] = iVar9;

+      if (iVar9 < 0) {

+        *piVar1 = 0x14;

       }

       else {

-        if (*(int *)((longlong)FiberData + 0x24) != 0) {

-                    /* WARNING: Subroutine does not return */

-          KeBugCheckEx(0xa0);

-        }

-        cVar2 = (*(code *)PTR_xHalQueryWakeTime_140e00b80)();

-        if (cVar2 != '\0') {

-                    /* WARNING: Subroutine does not return */

-          KeBugCheckEx(0xa0);

-        }

-      }

-      PopCheckpointSystemSleepUnsafe(unaff_EBX);

-      uVar3 = extraout_var;

-    }

-    else if (unaff_EBX <= PopCheckpointSystemSleepSimulateFlags >> 0x18) {

-      FUN_140b72610();

-      return;

-    }

-  }

-  uVar1 = rdtsc();

-  DAT_0 =

-       DAT_0 + ((CONCAT44(uVar3,(int)uVar1) | uVar1 & 0xffffffff00000000) - unaff_RDI);

-  return;

+        if (DAT_30 == '\0') {

+          ExWakeTimersPause();

+          DAT_30 = '\x01';

+        }

+        *(longlong *)(param_1 + 0x26) = _DAT_31;

+        uVar19 = _DAT_32;

+        uVar10 = PopWakeAlarmTimeOverrideAc;

+        *(ulonglong *)(param_1 + 0x28) = _DAT_32;

+        param_1[0x2e] = 0;

+        param_1[0x2f] = 0;

+        if ((uVar10 == 0) && (PopWakeAlarmTimeOverrideDc == 0)) {

+          if (((((DAT_33 == '\0') || (DAT_140f0b90c != 5)) || (DAT_140f0b820 != '\0')) ||

+              ((DAT_29 == 2 || (cVar6 == '\0')))) ||

+             ((uVar11 == 0xffffffffffffffff || (uVar11 <= uVar19)))) {

+            cVar6 = DAT_33;

+            if ((((*(int *)(PopPolicy + 0x58) == 0) || (DAT_18 == 5)) ||

+                (lVar13 = PopPolicy, cVar7 = PopIsDozeSupported(&PopCapabilities), cVar7 == '\0'))

+               || ((DAT_11 & 0x40000000) != 0)) {

+              if ((((cVar6 != '\0') && (DAT_18 == 5)) && (DAT_140f0b820 == '\0')) &&

+                 ((DAT_34 != 0 && (DAT_140f0b8f4 == 0xb)))) {

+                lVar15 = DAT_34 - uVar19;

+                *(longlong *)(param_1 + 0x4e) = lVar15;

+                lVar15 = lVar15 + (ulonglong)PopSmartUserPresenceWakeOffset * -10000000;

+                lVar13 = *(longlong *)(param_1 + 0x26) + lVar15;

+                *(longlong *)(param_1 + 0x4e) = lVar15;

+                goto LAB_35;

+              }

+            }

+            else {

+              *(longlong *)(param_1 + 0x2c) = *(longlong *)(param_1 + 0x26);

+              uVar8 = *(uint *)(lVar13 + 0x58);

+              param_1[0x2e] = -1;

+              param_1[0x2f] = -1;

+              *(ulonglong *)(param_1 + 0x2c) =

+                   (ulonglong)uVar8 * 10000000 + *(longlong *)(param_1 + 0x26);

+            }

+          }

+          else {

+            *(ulonglong *)(param_1 + 0x4e) = uVar11 - uVar19;

+            lVar13 = *(longlong *)(param_1 + 0x26) + (uVar11 - uVar19);

+LAB_35:

+            *(longlong *)(param_1 + 0x2c) = lVar13;

+            param_1[0x2e] = -2;

+            param_1[0x2f] = -1;

+          }

+        }

+        else {

+          param_1[0x2e] = -3;

+          param_1[0x2f] = -1;

+        }

+        if ((*(longlong *)(param_1 + 0x2e) == -1) && (DAT_36 == 0)) {

+          DAT_36 = *(longlong *)(param_1 + 0x26);

+        }

+        puVar17 = &DAT_37;

+        memset(&DAT_37,0,0x48);

+        DAT_38 = 3;

+        if (*(longlong *)(param_1 + 0x2e) == -3) {

+          DAT_39 = 0xfffffffffffffffd;

+          DAT_37 = uVar10;

+          DAT_40 = *(undefined8 *)(param_1 + 0x2e);

+          DAT_41 = PopWakeAlarmTimeOverrideDc;

+        }

+        else if ((DAT_16 == '\0') && (DAT_140f0b8f4 != 0xe)) {

+          piVar1 = param_1 + 0x52;

+          piVar2 = param_1 + 0x53;

+          if ((DAT_18 == 5) && ((*piVar1 != 1 && (*piVar2 != 1)))) {

+            PopQueryPowerSettingUlong(&GUID_LEGACY_RTC_MITIGATION,param_1 + 0x30);

+            if ((param_1[0x30] != 0) || (param_1[0x31] != 0)) {

+              *piVar1 = 0;

+              *piVar2 = 0;

+            }

+          }

+          if (*(ulonglong *)(param_1 + 0x2c) != 0) {

+            if (*(longlong *)(param_1 + 0x2e) == -2) {

+              if (*piVar1 != 0) {

+                DAT_39 = *(undefined8 *)(param_1 + 0x2e);

+                DAT_37 = *(ulonglong *)(param_1 + 0x2c);

+              }

+              if (*piVar2 != 0) {

+                DAT_41 = *(ulonglong *)(param_1 + 0x2c);

+                DAT_40 = *(undefined8 *)(param_1 + 0x2e);

+              }

+            }

+            else {

+              do {

+                *puVar17 = *(undefined8 *)(param_1 + 0x2c);

+                puVar17 = puVar17 + 3;

+              } while ((longlong)puVar17 < 0x140f0b988);

+              puVar17 = &DAT_39;

+              do {

+                *puVar17 = *(undefined8 *)(param_1 + 0x2e);

+                puVar17 = puVar17 + 3;

+              } while ((longlong)puVar17 < 0x140f0b998);

+            }

+          }

+          uVar11 = DAT_42;

+          *(ulonglong *)(param_1 + 0x10) = DAT_42;

+          if ((uVar11 != 0) && (uVar10 = *(longlong *)(param_1 + 0x26) + 20000000, uVar11 < uVar10))

+          {

+            *(ulonglong *)(param_1 + 0x10) = uVar10;

+            uVar11 = uVar10;

+          }

+          if (*piVar1 != 0) {

+            if ((*piVar1 == 2) && (-1 < (int)PopSimulate)) {

+              uVar18 = 1;

+            }

+            else {

+              uVar18 = 0;

+            }

+            *(undefined1 *)((longlong)param_1 + 0xa9) = uVar18;

+            cVar6 = ExGetNextWakeTime(uVar11 + 1,*(undefined8 *)(param_1 + 0x2c),uVar18,param_1 + 10

+                                      ,param_1 + 0x32);

+            *(char *)(param_1 + 0x54) = cVar6;

+            if (cVar6 != '\0') {

+              DAT_37 = *(ulonglong *)(param_1 + 10);

+              DAT_39 = *(undefined8 *)(param_1 + 0x32);

+            }

+          }

+          if (*piVar2 != 0) {

+            if ((*piVar2 != 2) || (uVar18 = 1, (int)PopSimulate < 0)) {

+              uVar18 = 0;

+            }

+            *(undefined1 *)((longlong)param_1 + 0xa9) = uVar18;

+            cVar6 = ExGetNextWakeTime(*(longlong *)(param_1 + 0x10) + 1,

+                                      *(undefined8 *)(param_1 + 0x2c),uVar18,param_1 + 10,

+                                      param_1 + 0x32);

+            *(char *)(param_1 + 0x54) = cVar6;

+            if (cVar6 != '\0') {

+              DAT_41 = *(ulonglong *)(param_1 + 10);

+              DAT_40 = *(undefined8 *)(param_1 + 0x32);

+            }

+          }

+        }

+        DAT_43 = DAT_140f0b958;

+        if ((DAT_37 != 0) &&

+           (DAT_37 < (ulonglong)(uint)param_1[0x55] + *(longlong *)(param_1 + 0x26))) {

+          DAT_43 = (ulonglong)(uint)param_1[0x55] + *(longlong *)(param_1 + 0x26);

+        }

+        DAT_44 = DAT_140f0b970;

+        if ((DAT_41 != 0) &&

+           (DAT_41 < (ulonglong)(uint)param_1[0x55] + *(longlong *)(param_1 + 0x26))) {

+          DAT_44 = (ulonglong)(uint)param_1[0x55] + *(longlong *)(param_1 + 0x26);

+        }

+        iVar9 = PopTransitionGetWakeTimerType(DAT_39);

+        param_1[0x50] = iVar9;

+        iVar9 = PopTransitionGetWakeTimerType(DAT_40);

+        param_1[0x51] = iVar9;

+        _DAT_45 = KeQueryPerformanceCounter(0);

+        ExAcquireTimeRefreshLockExclusive();

+        ExUpdateSystemTimeFromCmos(1);

+        ExReleaseTimeRefreshLockExclusive();

+        (*(code *)PTR_MmMapUserAddressesToPage_140e00800)(DAT_43,DAT_140f0b978);

+        PopBootStatCheckpointAvailable = 0;

+        PpmCheckPausePpmEngineForSx();

+        PsLookupProcessByProcessId(local_98,&local_res20);

+        PsLookupThreadByThreadId(uStack_90,local_c8);

+        PopSetDevicesSystemState();

+        *(undefined1 *)(param_1 + 0x18) = 1;

+        PopNewWakeInfo();

+        *(longlong *)(param_1 + 0x4c) = _DAT_31;

+        param_1[0x1c] = DAT_46;

+        iVar9 = PopPushPowerStateTransitionRecordWithCallback(local_res20,local_c8[0],0,0,0);

+        KeSetEvent(param_1 + 0x3e,0,1);

+        KeWaitForMutexObject(param_1 + 0x44,0,0,0,0);

+        if (-1 < iVar9) {

+          PoDelistPowerStateTransitionBlocker();

+        }

+        _DAT_47 = 0;

+        param_1[0x16] = param_1[0x4b];

+        PopSetPowerActionWatchdogState(2);

+        DAT_48 = DAT_140f0b90c;

+        if (PoResumeFromHibernate != '\0') {

+          DAT_48 = DAT_140f0b914;

+        }

+        _PopTransitionCritialResumeThread = SystemReserved1[0xf];

+        if ((param_1[2] & 8U) == 0) {

+          param_1[8] = DAT_18;

+          iVar9 = DAT_18;

+        }

+        else {

+          param_1[8] = 6;

+          iVar9 = 6;

+        }

+        iVar5 = DAT_48;

+        in_stack_ffffffffffffff18 = CONCAT44(uVar22,param_1[0x51]);

+        param_1[7] = DAT_48;

+        in_stack_ffffffffffffff10 = (int *)CONCAT44(uVar21,param_1[0x50]);

+        in_stack_ffffffffffffff08 = DAT_44;

+        PopDiagTracePostSleepNotification

+                  (iVar9,DAT_17,iVar5,DAT_140f0b960,DAT_140f0b978,in_stack_ffffffffffffff10,

+                   in_stack_ffffffffffffff18);

+        if (KeMtrrComparisonFailed != '\0') {

+          PopDiagTraceMtrrError();

+        }

+        if ((param_1[0x16] < 0) && (DAT_18 == 5)) {

+          local_88 = 0;

+          uStack_80 = 0;

+          StringCchPrintfW((STRSAFE_LPWSTR)&PopHibernationErrorSubstitutionString,0x80,L"0x%x");

+          RtlInitUnicodeString(&local_88,&PopHibernationErrorSubstitutionString);

+          IoRaiseInformationalHardError(0xc0000411,&local_88,0);

+          PopDiagTraceHibernateErrorStatus(param_1[0x16]);

+        }

+      }

+    }

+  }

+LAB_10:

+  if ((char)param_1[0xc] != '\0') {

+    PopReleasePolicyLock();

+  }

+  if (DAT_16 != '\0') {

+    _DAT_49 = KeQueryPerformanceCounter(0);

+    DAT_50 = PopQpcTimeInMs(&DAT_140f0bce0,&DAT_140f0bce8);

+  }

+  if (-1 < param_1[0x16]) {

+    _DAT_51 = *(undefined8 *)(param_1 + 0x4c);

+    ExUpdateSystemTimeFromCmos(1);

+    iVar9 = (*(code *)PTR_xHalTimerQueryRtcErrors_140e00b88)(1,0);

+    if (iVar9 != 0) {

+      *(undefined1 *)(param_1 + 0x2a) = 1;

+    }

+    _DAT_52 = KeQueryPerformanceCounter(0);

+    PfPowerActionNotify(2,0,0);

+    DAT_53 = _DAT_fffff78000000008;

+    PopDiagComputeEarlyHiberStats();

+    if (param_1[7] == 4) {

+      PopDiagTraceFirmwareS3Stats();

+    }

+  }

+  DAT_54 = 1;

+  PoPowerDownActionInProgress = 0;

+  PoPowerResetActionInProgress = 0;

+  if ((char)param_1[0x18] != '\0') {

+    PfPowerActionNotify(3,0,0);

+    PopSetDevicesSystemState();

+    PfPowerActionNotify(3);

+  }

+  if (-1 < param_1[0x16]) {

+    WheaResumedFromHibernate();

+  }

+  PpmCheckResumePpmEngineFromSx();

+  PopCurrentPowerStatePrecise(param_1 + 0x1e,local_c8 + 1);

+  uVar21 = (undefined4)((ulonglong)in_stack_ffffffffffffff10 >> 0x20);

+  if ((char)param_1[0x2a] != '\0') {

+    uVar11 = (ulonglong)in_stack_ffffffffffffff10 & 0xffffffff00000000;

+    in_stack_ffffffffffffff08 = 0;

+    ZwUpdateWnfStateData

+              (&WNF_BOOT_INVALID_TIME_SOURCE,0,0,0,0,uVar11,

+               in_stack_ffffffffffffff18 & 0xffffffff00000000);

+    uVar21 = (undefined4)(uVar11 >> 0x20);

+  }

+  cVar6 = PopIsDetailedSleepReliabilityDiagEnabled();

+  if (cVar6 == '\0') {

+    RtlBootStatusDisableFlushing(1);

+  }

+  else {

+    PopBootStatCheckpointAvailable = 1;

+  }

+  PopCheckpointSystemSleep(0x38);

+  (*(code *)PTR_MmMapUserAddressesToPage_140e00800)(0,0);

+  in_stack_ffffffffffffff08 = in_stack_ffffffffffffff08 & 0xffffffffffffff00;

+  iVar9 = PopNotifyTelemetryOsState

+                    (DAT_7,DAT_140f0b90c,DAT_140f0b914,param_1[2],in_stack_ffffffffffffff08)

+  ;

+  uVar22 = (undefined4)(in_stack_ffffffffffffff08 >> 0x20);

+  param_1[0x19] = iVar9;

+  PopCancelIgnoreBatteryStatusChange();

+  PopExecuteOnTargetProcessors(&KeActiveProcessors,PpmStartIllegalProcessorThrottleLogging,0,0);

+  if ((char)param_1[0xc] != '\0') {

+    PopReleasePolicyLock();

+    *(undefined1 *)(param_1 + 0xc) = 0;

+  }

+  if ((char)param_1[0x18] != '\0') {

+    PopProcessDeviceWakeSource();

+  }

+  PoClearBroadcast();

+  DAT_6 = 0;

+  PopFanSxExit();

+  PopEsExitSleep();

+  param_1[0x1d] = DAT_46;

+  _DAT_55 = 0;

+  _DAT_56 = PopSpoilEstimatesOnPowerStateTransitionWorker;

+  _PopSpoilEstimatesOnPowerStateTransitionWorkItem = 0;

+  ExQueueWorkItem(&PopSpoilEstimatesOnPowerStateTransitionWorkItem,1);

+  if (-1 < param_1[0x16]) {

+    PopCurrentPowerState(param_1 + 0x1e);

+  }

+  if ((char)param_1[0x18] != '\0') {

+    PopHandleWakeSources();

+  }

+  if (-1 < param_1[0x16]) {

+    PopQueryMostRecentWakeSourceAttributes(local_res10,&local_b0,&local_b8,local_res18);

+    SshSessionManagerTracePostSleepNotification

+              (DAT_43,DAT_140f0b978,param_1[0x50],param_1[0x51],

+               CONCAT44(uVar22,param_1[0x21]),CONCAT44(uVar21,param_1[0x20]),local_b0,local_b8,

+               local_res10[0]);

+  }

+  if ((char)param_1[0xc] == '\0') {

+    PopAcquirePolicyLock();

+    *(undefined1 *)(param_1 + 0xc) = 1;

+  }

+  if (-1 < param_1[0x16]) {

+    PopUpdateSystemIdleContext(1);

+    PopPowerAggregatorNotifySystemWake(param_1[7]);

+    puVar14 = (undefined1 *)(longlong)DAT_38;

+    PopAction = 0;

+    if (&DAT_57 < puVar14) {

+      cVar6 = PopIsMostRecentWakeAttended();

+      if (cVar6 == '\0') {

+        PopFullWake = 0;

+        PopPendingUserPresenceDuringSystemSleep = 0;

+        PopPendingUserPresenceMonitorOnReason = 0;

+      }

+    }

+    else {

+      DAT_42 = (&DAT_140f0b960)[(longlong)puVar14 * 3];

+      lVar13 = (&DAT_39)[(longlong)puVar14 * 3];

+      PopFullWake = 0;

+      PopPendingUserPresenceDuringSystemSleep = 0;

+      PopPendingUserPresenceMonitorOnReason = 0;

+      if (lVar13 == -1) {

+        cVar6 = PopDeferDoze(param_1[0x52],param_1[0x53],param_1 + 0x1e);

+        if (cVar6 == '\0') {

+          DAT_7 = 2;

+          DAT_12 = 5;

+        }

+        else {

+          DAT_7 = *param_1;

+          DAT_12 = param_1[1];

+        }

+        PopAction = PopAction | 2;

+LAB_58:

+        *(undefined1 *)(param_1 + 0x36) = 0;

+      }

+      else if (lVar13 == -2) {

+        if (DAT_59 == 0) {

+          DAT_59 = DAT_140f0b938;

+        }

+      }

+      else if (lVar13 == -3) {

+        PopWakeAlarmTimeOverrideAc = 0;

+        PopWakeAlarmTimeOverrideDc = 0;

+      }

+      else if (DAT_46 == 1) {

+        if (param_1[0x53] == 0) {

+          DAT_7 = *param_1;

+          DAT_12 = param_1[1];

+          PopAction = 2;

+          goto LAB_58;

+        }

+      }

+      else if ((param_1[0x53] == 0) && (param_1[0x1c] == param_1[0x1d])) {

+        PopCheckPowerSourceAfterRtcWakeSet();

+      }

+    }

+  }

+  if ((DAT_30 != '\0') && ((char)param_1[0x36] != '\0')) {

+    ExWakeTimersResume();

+    DAT_30 = '\0';

+    DAT_42 = 0;

+  }

+  if (PoResumeFromHibernate != '\0') {

+    PopBootLoaderTraceProcess();

+  }

+  DAT_16 = '\0';

+  PopResetActionDefaults();

+  PopSetPowerActionState(2);

+  PopReleasePolicyLock();

+  if (PopPendingUserPresenceDuringSystemSleep != 0) {

+    PoSetUserPresent(PopPendingUserPresenceMonitorOnReason);

+  }

+  ExQueueWorkItem(&PopUnlockAfterSleepWorkItem,1);

+  PopCheckForWork();

+  if (-1 < param_1[0x16]) {

+    PpmPerfReApplyStates();

+  }

+  DAT_29 = 0x11;

+  _DAT_60 = KeQueryPerformanceCounter(0);

+  _DAT_60 = _DAT_60 - _DAT_140f06df0;

+  if (*(longlong *)(param_1 + 0x32) != 0) {

+    ExDeleteWakeTimerInfo();

+    param_1[0x32] = 0;

+    param_1[0x33] = 0;

+  }

+  _PopTransitionCritialResumeThread = (void *)0x0;

+  lVar13 = local_c8[0];

+  lVar15 = local_res20;

+LAB_3:

+  if (lVar15 != 0) {

+    ObfDereferenceObject(lVar15);

+  }

+  if (lVar13 != 0) {

+    ObfDereferenceObject(lVar13);

+  }

+  if (param_1[0x1b] != 0) {

+    PopDiagTraceStateTransitionFailurePoint(param_1[0x16]);

+  }

+  return (ulonglong)(uint)param_1[0x16];

 }
```

## `IopSetupArbiterAndTranslators`  (modified)

```diff
--- IopSetupArbiterAndTranslators
+++ IopSetupArbiterAndTranslators
@@ -1,31 +1,306 @@
 

 /* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

 

-void IopSetupArbiterAndTranslators(void)

+ulonglong IopSetupArbiterAndTranslators(int *param_1,undefined8 param_2,ulonglong param_3)

 

 {

-  longlong unaff_RBX;

-  longlong unaff_RBP;

+  code *pcVar1;

+  bool bVar2;

+  bool bVar3;

+  char cVar4;

+  int iVar5;

+  uint uVar6;

+  longlong *plVar7;

+  longlong *plVar8;

+  ulonglong uVar9;

+  undefined2 *puVar10;

+  longlong lVar11;

+  longlong *plVar12;

+  ulonglong uVar13;

+  byte bVar14;

+  char cVar15;

+  longlong lVar16;

+  longlong *plVar17;

+  ulonglong unaff_R12;

+  uint7 uVar18;

   undefined8 unaff_R13;

-  longlong lStack0000000000000028;

-  undefined8 uStack0000000000000078;

+  ushort uVar19;

+  undefined8 unaff_R14;

+  longlong *plVar20;

+  undefined1 local_res8;

+  longlong *local_res18;

+  longlong *local_res20;

+  undefined2 auStack_79 [4];

+  undefined1 uStack_71;

+  undefined7 uStack_70;

+  undefined1 uStack_69;

+  undefined1 local_68;

+  undefined2 uStack_67;

+  undefined4 uStack_65;

+  undefined1 uStack_61;

+  undefined7 local_60;

+  undefined1 uStack_59;

+  undefined7 uStack_58;

+  undefined4 uStack_31;

+  undefined4 uStack_2d;

+  undefined4 uStack_29;

+  undefined4 uStack_25;

+  undefined1 uStack_21;

   

-  *(ulonglong *)(unaff_RBP + 0x180) = (ulonglong)((int)unaff_RBX + 0x120);

-  uStack0000000000000078 = *(undefined8 *)(unaff_RBX + 0x148);

-  *(undefined8 **)(unaff_RBP + 400) = &stack0x00000078;

-  *(longlong *)(unaff_RBP + 0x1a0) = unaff_RBX + 0x150;

-  *(longlong *)(unaff_RBP + 0x1b0) = unaff_RBX + 0x160;

-  lStack0000000000000028 = unaff_RBP + -0x50;

-  *(undefined8 *)(unaff_RBP + 0x138) = unaff_R13;

-  *(undefined8 *)(unaff_RBP + 0x148) = 0x14;

-  *(undefined8 *)(unaff_RBP + 0x158) = 0x28;

-  *(undefined8 *)(unaff_RBP + 0x168) = unaff_R13;

-  *(undefined8 *)(unaff_RBP + 0x178) = 0x14;

-  *(undefined8 *)(unaff_RBP + 0x188) = 0x28;

-  *(undefined8 *)(unaff_RBP + 0x198) = unaff_R13;

-  *(undefined8 *)(unaff_RBP + 0x1a8) = 0xc;

-  *(undefined8 *)(unaff_RBP + 0x1b8) = 0x18;

-  _tlgWriteTransfer_EtwWriteTransfer();

-  return;

+  uStack_29._1_3_ = (undefined3)unaff_R12;

+  uStack_25 = (undefined4)(unaff_R12 >> 0x18);

+  uStack_21 = (undefined1)(unaff_R12 >> 0x38);

+  uStack_31._1_3_ = (undefined3)unaff_R13;

+  uStack_2d = (undefined4)((ulonglong)unaff_R13 >> 0x18);

+  uStack_29._0_1_ = (undefined1)((ulonglong)unaff_R13 >> 0x38);

+  uStack_31._0_1_ = (undefined1)((ulonglong)unaff_R14 >> 0x38);

+  plVar12 = (longlong *)0x0;

+  cVar15 = '\x01';

+  local_68 = 0;

+  uStack_67 = 0;

+  uStack_65 = 0;

+  uStack_61 = 0;

+  local_res20 = *(longlong **)(param_1 + 0x12);

+  uVar9 = unaff_R12 & 0xffffffffffffff00;

+  bVar2 = false;

+  param_3 = param_3 & 0xffffffffffffff00;

+  local_60 = 0;

+  uStack_59 = 0;

+  local_res8 = 0;

+  local_res18 = (longlong *)0x0;

+  bVar14 = *(byte *)(*(longlong *)(*(longlong *)(param_1 + 8) + 0x40) + 1);

+  if (bVar14 == 7) {

+    bVar14 = 3;

+  }

+  if ((param_1[0x14] != 1) || (bVar3 = true, *param_1 != 0)) {

+    bVar3 = false;

+  }

+  lVar11 = IopRootDeviceNode;

+  if ((local_res20 != (longlong *)0x0) && (param_1[0x14] != 1)) {

+    lVar11 = *(longlong *)(local_res20[0x27] + 0x28);

+  }

+LAB_0:

+  if (lVar11 == 0) {

+    uVar9 = (ulonglong)(~-(uint)bVar2 & 0xc000008a);

+  }

+  else {

+    if (((lVar11 == IopRootDeviceNode) && ((char)param_3 == '\0')) && (!bVar3))

+    goto code_r0x000140b3663a;

+    if ((bVar2) || (plVar20 = *(longlong **)(lVar11 + 0x20), plVar20 == local_res20)) {

+LAB_1:

+      plVar17 = plVar12;

+      if (cVar15 != (char)plVar12) {

+        uVar19 = 1 << (bVar14 & 0x1f);

+        if ((*(ushort *)(lVar11 + 0x208) & uVar19) == 0) {

+          if (((*(ushort *)(lVar11 + 0x20a) & uVar19) != 0) || (0xf < bVar14)) {

+            for (plVar7 = *(longlong **)(lVar11 + 0x1f8); plVar7 != (longlong *)(lVar11 + 0x1f8);

+                plVar7 = (longlong *)*plVar7) {

+              if (*(byte *)(plVar7 + 2) == bVar14) {

+                if ((bVar14 < 0x10) ||

+                   (plVar8 = plVar12, plVar20 = plVar12, (longlong *)plVar7[3] != plVar12)) {

+                  plVar8 = plVar7;

+                  plVar12 = plVar7;

+                  plVar20 = plVar7;

+                }

+                goto joined_r0x000140a649cd;

+              }

+            }

+            if (0xf < bVar14) {

+              uVar19 = (ushort)plVar12;

+            }

+          }

+          param_3 = CONCAT71((int7)(param_3 >> 8),bVar14);

+          iVar5 = IopQueryResourceHandlerInterface

+                            (1,*(undefined8 *)(lVar11 + 0x20),param_3,&local_res18);

+          *(ushort *)(lVar11 + 0x20a) = *(ushort *)(lVar11 + 0x20a) | uVar19;

+          plVar17 = (longlong *)0x0;

+          if (iVar5 < 0) {

+            *(ushort *)(lVar11 + 0x208) = *(ushort *)(lVar11 + 0x208) | uVar19;

+            if (bVar14 < 0x10) goto LAB_2;

+            local_res18 = (longlong *)0x0;

+          }

+          plVar20 = local_res18;

+          param_3 = 0x20207050;

+          plVar8 = (longlong *)ExAllocatePool2(0x100,0x28,0x20207050);

+          if (plVar8 == (longlong *)0x0) goto LAB_3;

+          *(byte *)(plVar8 + 2) = bVar14;

+          plVar8[1] = (longlong)plVar8;

+          *plVar8 = (longlong)plVar8;

+          plVar8[3] = (longlong)plVar20;

+          plVar8[4] = lVar11;

+          plVar12 = *(longlong **)(lVar11 + 0x200);

+          if (*plVar12 != lVar11 + 0x1f8) goto LAB_4;

+          *plVar8 = lVar11 + 0x1f8;

+          plVar8[1] = (longlong)plVar12;

+          *plVar12 = (longlong)plVar8;

+          *(longlong **)(lVar11 + 0x200) = plVar8;

+          plVar12 = (longlong *)0x0;

+          plVar17 = (longlong *)0x0;

+joined_r0x000140a649cd:

+          if (plVar20 != (longlong *)0x0) {

+            local_res8 = 1;

+            plVar12 = plVar8;

+          }

+        }

+LAB_2:

+        if ((bVar2 == false) && (plVar12 != (longlong *)0x0)) {

+          uVar13 = IopTranslateAndAdjustReqDesc(*(undefined8 *)(param_1 + 8),plVar12,&local_60);

+          plVar17 = (longlong *)0x0;

+          if ((int)uVar13 < 0) {

+            return uVar13;

+          }

+          param_3 = CONCAT17(uStack_59,local_60);

+          bVar14 = *(byte *)(*(longlong *)(param_3 + 0x40) + 1);

+          *(undefined8 *)(param_3 + 0x20) = *(undefined8 *)(param_1 + 8);

+          *(ulonglong *)(param_1 + 8) = param_3;

+          if (bVar14 == 7) {

+            bVar14 = 3;

+          }

+          if ((int)uVar13 == 0x120) {

+            cVar15 = '\0';

+          }

+        }

+      }

+      lVar11 = *(longlong *)(lVar11 + 0x10);

+      plVar12 = plVar17;

+      goto LAB_5;

+    }

+    param_3 = CONCAT71((int7)(param_3 >> 8),bVar14);

+    cVar4 = IopFindResourceHandlerInfo(2,lVar11,param_3,&local_68);

+    if (cVar4 != '\0') {

+LAB_6:

+      uVar13 = CONCAT17(uStack_61,CONCAT43(uStack_65,CONCAT21(uStack_67,local_68)));

+LAB_7:

+      plVar12 = (longlong *)0x0;

+      if (uVar13 != 0) {

+        uVar18 = (uint7)(uVar9 >> 8);

+        uVar9 = CONCAT71(uVar18,1);

+        bVar2 = true;

+        if ((*(uint *)(*(longlong *)(uVar13 + 0x18) + 0x28) & 1) != 0) {

+          param_3 = *(ulonglong *)(param_1 + 8);

+          iVar5 = IopCallArbiter(uVar13,7,param_3);

+          plVar12 = (longlong *)0x0;

+          if (iVar5 < 0) {

+            uVar9 = (ulonglong)uVar18 << 8;

+            bVar2 = false;

+            goto LAB_1;

+          }

+        }

+        plVar12 = (longlong *)0x0;

+        *(ulonglong *)(param_1 + 0x48) = uVar13;

+        *(undefined2 *)(uVar13 + 0x68) = 0;

+      }

+      goto LAB_1;

+    }

+    if (bVar14 < 0x10) {

+      uVar19 = 1 << (bVar14 & 0x1f);

+    }

+    else {

+      uVar19 = 0;

+    }

+    iVar5 = IopQueryResourceHandlerInterface(2,plVar20);

+    *(ushort *)(lVar11 + 0x20e) = *(ushort *)(lVar11 + 0x20e) | uVar19;

+    if (iVar5 < 0) {

+      *(ushort *)(lVar11 + 0x20c) = *(ushort *)(lVar11 + 0x20c) | uVar19;

+      if (bVar14 < 0x10) goto LAB_6;

+      local_res18 = (longlong *)0x0;

+    }

+    plVar8 = local_res18;

+    param_3 = 0x20207050;

+    plVar12 = (longlong *)ExAllocatePool2(0x100,0x70,0x20207050);

+    if (plVar12 != (longlong *)0x0) {

+      *(undefined2 *)(plVar12 + 0xd) = 0;

+      plVar17 = plVar12 + 0xb;

+      plVar12[0xc] = (longlong)plVar17;

+      *plVar17 = (longlong)plVar17;

+      plVar17 = plVar12 + 9;

+      plVar12[10] = (longlong)plVar17;

+      *plVar17 = (longlong)plVar17;

+      plVar17 = plVar12 + 5;

+      plVar12[6] = (longlong)plVar17;

+      plVar7 = plVar12 + 7;

+      *plVar17 = (longlong)plVar17;

+      plVar12[8] = (longlong)plVar7;

+      *plVar7 = (longlong)plVar7;

+      plVar12[1] = (longlong)plVar12;

+      *plVar12 = (longlong)plVar12;

+      *(byte *)(plVar12 + 2) = bVar14;

+      plVar12[4] = lVar11;

+      plVar17 = *(longlong **)(lVar11 + 0x1f0);

+      if (*plVar17 == lVar11 + 0x1e8) {

+        *plVar12 = lVar11 + 0x1e8;

+        plVar12[1] = (longlong)plVar17;

+        *plVar17 = (longlong)plVar12;

+        *(longlong **)(lVar11 + 0x1f0) = plVar12;

+        plVar12[3] = (longlong)plVar8;

+        uVar13 = -(ulonglong)(plVar8 != (longlong *)0x0) & (ulonglong)plVar12;

+        local_68 = (undefined1)uVar13;

+        uStack_67 = (undefined2)(uVar13 >> 8);

+        uStack_65 = (undefined4)(uVar13 >> 0x18);

+        uStack_61 = (undefined1)(uVar13 >> 0x38);

+        goto LAB_7;

+      }

+LAB_4:

+      pcVar1 = (code *)swi(0x29);

+      (*pcVar1)(3);

+      uStack_31 = 0x50feb0de;

+      uStack_2d = 0x11d2596a;

+      uStack_29 = 0xb8a5;

+      uStack_25 = 0x19461af8;

+      puVar10 = (undefined2 *)ExAllocatePool2(0x100,0x28,0x20207050);

+      if (puVar10 == (undefined2 *)0x0) {

+        return 0xc000009a;

+      }

+      *puVar10 = 0x28;

+      memset(auStack_79,0,0x48);

+      auStack_79[0] = 0x81b;

+      uStack_71 = SUB81(&uStack_31,0);

+      local_68 = 0;

+      puVar10[1] = 0;

+      uStack_67 = 0;

+      uStack_61 = SUB81(puVar10,0);

+      local_60 = (undefined7)((ulonglong)puVar10 >> 8);

+      uStack_58 = (undefined7)(uVar9 >> 8);

+      uStack_70 = 0;

+      uStack_69 = 0;

+      uStack_59 = bVar2;

+      uVar6 = IopSynchronousCall(plVar20,auStack_79,0xc00000bb,0);

+      uVar9 = (ulonglong)uVar6;

+      if (-1 < (int)uVar6) {

+        iVar5 = (int)plVar8;

+        if (iVar5 == 1) {

+          if ((*(longlong *)(puVar10 + 0x10) != 0) && (*(longlong *)(puVar10 + 0x14) != 0)) {

+LAB_8:

+            *(undefined2 **)param_1 = puVar10;

+            return uVar9;

+          }

+          uVar9 = 0xc0000001;

+        }

+        else if ((iVar5 == 2) || (iVar5 == 3)) {

+          if (*(longlong *)(puVar10 + 0x10) != 0) goto LAB_8;

+          uVar9 = 0xc0000001;

+        }

+        else {

+          uVar9 = 0xc000000d;

+        }

+      }

+      ExFreePoolWithTag(puVar10,0);

+      return uVar9;

+    }

+LAB_3:

+    uVar9 = 0xc000009a;

+  }

+  return uVar9;

+code_r0x000140b3663a:

+  bVar3 = true;

+  lVar16 = IopRootDeviceNode;

+  lVar11 = IopFindLegacyBusDeviceNode(*param_1,param_1[1]);

+  param_3 = CONCAT71((int7)(param_3 >> 8),local_res8);

+  if ((lVar11 == lVar16) && (**(int **)(*(longlong *)(param_1 + 4) + 8) == (int)plVar12)) {

+    lVar11 = IopFindLegacyBusDeviceNode(1);

+LAB_5:

+    param_3 = CONCAT71((int7)(param_3 >> 8),local_res8);

+  }

+  goto LAB_0;

 }
```

## `HvpAddBin`  (modified)

```diff
--- HvpAddBin
+++ HvpAddBin
@@ -1,50 +1,345 @@
 

-ulonglong HvpAddBin(longlong param_1,int param_2,ulonglong param_3,ulonglong param_4)

+/* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

+

+int HvpAddBin(longlong param_1,uint param_2,int param_3,uint *param_4)

 

 {

-  bool bVar1;

-  ulonglong uVar2;

-  uint uVar3;

-  ulonglong uVar4;

-  int iVar5;

-  ulonglong uVar6;

+  longlong lVar1;

+  code *pcVar2;

+  bool bVar3;

+  bool bVar4;

+  undefined4 *puVar5;

+  char cVar6;

+  char cVar7;

+  int iVar8;

+  int iVar9;

+  undefined4 uVar10;

+  int iVar11;

+  ulonglong *puVar12;

+  ulonglong uVar13;

+  longlong *plVar14;

+  ulonglong uVar15;

+  longlong *plVar16;

+  longlong *plVar17;

+  uint *puVar18;

+  uint uVar19;

+  char cVar20;

+  uint uVar21;

+  longlong *plVar22;

+  uint uVar23;

+  ulonglong in_stack_ffffffffffffff78;

+  undefined4 **ppuVar24;

+  uint local_74;

+  uint local_70;

+  uint local_6c;

+  undefined4 *local_68;

+  undefined4 *local_60;

+  uint *local_58;

+  longlong local_50;

   

-  uVar6 = 0;

-  uVar4 = 0;

-  bVar1 = false;

-  if (param_3 != param_4) {

-    if (param_2 == 0) {

-      uVar4 = 0x40000;

-      if (((char)*(undefined4 *)(param_1 + 0x1010) < '\0') ||

-         ((bVar1 = false, param_3 == 0 && (param_4 < 0x40001)))) {

-        bVar1 = true;

-      }

-      uVar6 = (ulonglong)((-(uint)bVar1 & 0xfffc1000) + 0x40000);

+  local_50 = (longlong)param_3;

+  plVar14 = (longlong *)0x0;

+  uVar19 = param_2 + 0x101f & 0xfffff000;

+  local_70 = 0;

+  cVar20 = '\0';

+  bVar3 = false;

+  plVar22 = (longlong *)0x0;

+  local_60 = (undefined4 *)0x0;

+  local_68 = (undefined4 *)0x0;

+  bVar4 = false;

+  local_6c = 0;

+  cVar7 = '\0';

+  if ((uVar19 < 0x3001) && (((ulonglong)uVar19 - (ulonglong)param_2) - 0x20 < 0xe00)) {

+    uVar19 = uVar19 + 0x1000;

+  }

+  plVar16 = (longlong *)(param_1 + 0x378 + local_50 * 0x278);

+  lVar1 = local_50 * 0x278 + param_1;

+  for (plVar17 = (longlong *)*plVar16; plVar17 != plVar16; plVar17 = (longlong *)*plVar17) {

+    uVar23 = *(uint *)(plVar17 + 2);

+    if ((uVar19 <= uVar23) &&

+       (*(int *)((longlong)plVar17 + 0x14) + uVar23 <= *(uint *)(lVar1 + 0x118))) {

+      if (plVar17 != (longlong *)0x0) {

+        lVar1 = *plVar17;

+        if ((*(longlong **)(lVar1 + 8) == plVar17) &&

+           (plVar14 = (longlong *)plVar17[1], (longlong *)*plVar14 == plVar17)) {

+          *plVar14 = lVar1;

+          *(longlong **)(lVar1 + 8) = plVar14;

+          iVar8 = HvpMarkDirty(param_1,*(int *)((longlong)plVar17 + 0x14) + param_3 * -0x80000000,

+                               (int)plVar17[2],0);

+          if (-1 < iVar8) {

+            uVar19 = param_3 * -0x80000000 + *(int *)((longlong)plVar17 + 0x14);

+            uVar15 = 0;

+            if (uVar23 != 0) {

+              do {

+                uVar13 = (ulonglong)((int)uVar15 + uVar19);

+                puVar12 = (ulonglong *)HvpGetCellMap(param_1,uVar13);

+                if (puVar12 == (ulonglong *)0x0) {

+                    /* WARNING: Subroutine does not return */

+                  KeBugCheckEx(0x51,1,param_1,uVar13 & 0xffffffff,0x397);

+                }

+                puVar12[1] = puVar12[1] & 0xfffffffffffffffd;

+                uVar13 = uVar15 & 0xffffffff;

+                uVar21 = (int)uVar15 + 0x1000;

+                uVar15 = (ulonglong)uVar21;

+                *puVar12 = uVar13;

+              } while (uVar21 < uVar23);

+            }

+            (**(code **)(param_1 + 0x20))(plVar17,0x18);

+            *param_4 = uVar19;

+            return 0;

+          }

+          plVar14 = (longlong *)((longlong)param_3 * 0x278 + 0x378 + param_1);

+          lVar1 = *plVar14;

+          if (*(longlong **)(lVar1 + 8) == plVar14) {

+            *plVar17 = lVar1;

+            plVar17[1] = (longlong)plVar14;

+            *(longlong **)(lVar1 + 8) = plVar17;

+            *plVar14 = (longlong)plVar17;

+            return iVar8;

+          }

+        }

+        goto LAB_0;

+      }

+      break;

     }

-    else if ((param_2 == 1) || (param_2 - 4U < 2)) {

-      uVar3 = HvGetEffectiveLogSizeCapForHive();

-      uVar4 = (ulonglong)uVar3;

+  }

+  uVar21 = *(uint *)(lVar1 + 0x118);

+  uVar23 = uVar21 + uVar19;

+  local_74 = uVar21;

+  if (((param_3 == 0) && (uVar19 < 0x40001)) &&

+     (((uVar23 + 0xfff ^ uVar21 + 0x1000) & 0xfffc0000) != 0)) {

+    local_74 = (uVar21 + 0x40fff & 0xfffc0000) - 0x1000;

+    local_70 = local_74 - uVar21;

+    uVar23 = local_74 + uVar19;

+  }

+  if (uVar23 < uVar21) {

+    return -0x3fffff66;

+  }

+  cVar6 = CmpCanGrowHive(param_1,uVar23);

+  if (cVar6 == '\0') {

+    return -0x3fffff66;

+  }

+  iVar8 = HvpExpandMap(param_1,param_3,uVar21,uVar23);

+  if (iVar8 < 0) {

+    return iVar8;

+  }

+  *(uint *)(local_50 * 0x278 + 0x118 + param_1) = uVar23;

+  iVar8 = HvpAdjustHiveFreeDisplay(param_1,uVar23,param_3);

+  plVar17 = plVar14;

+  if (-1 < iVar8) {

+    if (param_3 == 0) {

+      puVar18 = (uint *)(param_1 + 0xa0);

+      if ((*puVar18 & 1) != 0) {

+LAB_1:

+        local_58 = (uint *)(param_1 + 0xa0);

+        if ((*puVar18 & 0x8001) == 0) {

+          iVar8 = CmpDoFileSetSizeEx(param_1,0,uVar23 + 0x1000,1);

+          plVar17 = plVar22;

+          if (iVar8 < 0) goto LAB_2;

+          if (((*(uint *)(param_1 + 0x1010) & 0x800) != 0) &&

+             (puVar18 = local_58, *(int *)(param_1 + 0x1084) == 0)) {

+            *(uint *)(param_1 + 0x1084) = uVar21;

+          }

+        }

+        if ((*puVar18 & 0x20000) == 0) goto LAB_3;

+        if ((*(uint *)(param_1 + 0x100) & 1) == 0) {

+          if ((*(uint *)(param_1 + 0x100) & 8) != 0) {

+            uVar15 = *(ulonglong *)(param_1 + 0xe8);

+            goto LAB_4;

+          }

+LAB_5:

+          uVar15 = 0x7ffff000;

+        }

+        else {

+          uVar15 = *(ulonglong *)(param_1 + 0xf0);

+LAB_4:

+          uVar15 = uVar15 & 0xfffffffffffff000;

+          if (0x7fffefff < (longlong)uVar15) goto LAB_5;

+        }

+        if (uVar23 <= (int)uVar15 - 0x1000U) {

+          iVar8 = HvpViewMapExtendStorage(param_1 + 0xe0,uVar23);

+          plVar17 = plVar22;

+          if (iVar8 < 0) goto LAB_2;

+          cVar20 = '\x01';

+          bVar4 = true;

+        }

+        goto LAB_3;

+      }

+      local_58 = puVar18;

+      iVar8 = HvpGrowDirtyVectors(param_1,uVar23);

+      if (-1 < iVar8) {

+        bVar3 = true;

+        goto LAB_1;

+      }

     }

-    iVar5 = (int)uVar6;

-    uVar2 = param_4;

-    if ((((param_3 != 0) && (param_4 <= uVar4)) && (param_3 < param_4)) && (!bVar1)) {

-      uVar6 = uVar6 & 0xffffffff;

-      if (param_2 == 0) {

-        uVar6 = 0x1000;

-      }

-      do {

-        iVar5 = (int)uVar6;

-        uVar2 = param_3;

-        if (param_4 <= param_3) break;

-        param_3 = param_3 * 2;

-        uVar2 = uVar4;

-      } while (param_3 <= uVar4);

+    else {

+LAB_3:

+      if (local_70 == 0) {

+LAB_6:

+        plVar17 = plVar14;

+        if (cVar20 == '\0') {

+          ppuVar24 = &local_68;

+          iVar8 = HvpAllocateBin(param_1,uVar19,param_3,0x36314d43,ppuVar24);

+          cVar7 = '\0';

+          if (-1 < iVar8) {

+            in_stack_ffffffffffffff78 = CONCAT44((int)((ulonglong)ppuVar24 >> 0x20),uVar19);

+            iVar8 = HvpProtectBinPartial(param_1);

+LAB_7:

+            cVar7 = cVar20;

+            if (-1 < iVar8) {

+              memset(local_68,0,(ulonglong)uVar19);

+              local_68[7] = 0;

+              local_68[1] = local_74 & 0x7fffffff;

+              local_68[8] = uVar19 - 0x20;

+              *local_68 = 0x6e696268;

+              local_68[2] = uVar19;

+              if (local_60 != (undefined4 *)0x0) {

+                in_stack_ffffffffffffff78 =

+                     CONCAT71((int7)(in_stack_ffffffffffffff78 >> 8),cVar20) ^ 1;

+                HvpPointMapEntriesToBuffer

+                          (param_1,local_60,local_74 - uVar21,param_3 * -0x80000000 + uVar21,

+                           in_stack_ffffffffffffff78,plVar14);

+                plVar22 = (longlong *)(local_50 * 0x278 + 0x378 + param_1);

+                lVar1 = *plVar22;

+                if (*(longlong **)(lVar1 + 8) != plVar22) goto LAB_0;

+                plVar14[1] = (longlong)plVar22;

+                *plVar14 = lVar1;

+                *(longlong **)(lVar1 + 8) = plVar14;

+                *plVar22 = (longlong)plVar14;

+              }

+              local_74 = local_74 + param_3 * -0x80000000;

+              HvpPointMapEntriesToBuffer

+                        (param_1,local_68,uVar19,local_74,

+                         CONCAT71((int7)(in_stack_ffffffffffffff78 >> 8),cVar20) ^ 1,0);

+              if (param_3 != 0) {

+LAB_8:

+                *param_4 = local_74;

+                return 0;

+              }

+              if (((*(uint *)(param_1 + 0xa0) & 1) != 0) ||

+                 (iVar8 = HvpMarkDirty(param_1,uVar21,uVar23 - uVar21,0), -1 < iVar8)) {

+                CmpUpdateSystemHiveHysteresis(param_1,uVar23,uVar21);

+                HvpSetRangeProtection(param_1,uVar21,uVar23 - uVar21,4);

+                goto LAB_8;

+              }

+            }

+          }

+        }

+        else {

+          cVar7 = CmpClaimGlobalQuota(uVar19);

+          if (cVar7 == '\0') goto LAB_9;

+          local_6c = local_6c + uVar19;

+          iVar8 = HvpViewMapPromoteRangeToMapping(param_1 + 0xe0,local_74,uVar19,&local_68);

+          cVar7 = cVar20;

+          if (-1 < iVar8) {

+            iVar8 = HvpViewMapCOWAndUnsealRange(param_1 + 0xe0,local_74,uVar19);

+            goto LAB_7;

+          }

+        }

+      }

+      else if (cVar20 == '\0') {

+        ppuVar24 = &local_60;

+        iVar8 = HvpAllocateBin(param_1,local_70,param_3,0x30324d43,ppuVar24);

+        cVar7 = '\0';

+        plVar17 = plVar22;

+        if (-1 < iVar8) {

+          in_stack_ffffffffffffff78 = CONCAT44((int)((ulonglong)ppuVar24 >> 0x20),local_70);

+          iVar8 = HvpProtectBinPartial(param_1);

+LAB_10:

+          puVar5 = local_60;

+          plVar17 = plVar22;

+          cVar7 = cVar20;

+          if (-1 < iVar8) {

+            memset(local_60,0,(ulonglong)local_70);

+            puVar5[7] = 0;

+            *puVar5 = 0x6e696268;

+            puVar5[1] = uVar21 & 0x7fffffff;

+            puVar5[2] = local_70;

+            puVar5[8] = local_70 - 0x20;

+            plVar14 = (longlong *)(**(code **)(param_1 + 0x18))(0x18,0,0x31324d43);

+            if (plVar14 != (longlong *)0x0) {

+              iVar8 = Feature_Servicing_RemoveAlignmentFreeBinFromList__private_IsEnabledDeviceUsageNoInline

+                                ();

+              if (iVar8 != 0) {

+                plVar14[1] = (longlong)plVar14;

+                *plVar14 = (longlong)plVar14;

+              }

+              *(uint *)(plVar14 + 2) = local_70;

+              *(uint *)((longlong)plVar14 + 0x14) = uVar21;

+              goto LAB_6;

+            }

+            goto LAB_9;

+          }

+        }

+      }

+      else {

+        cVar7 = CmpClaimGlobalQuota(local_70);

+        if (cVar7 == '\0') {

+LAB_9:

+          iVar8 = -0x3fffff66;

+          plVar17 = plVar14;

+          cVar7 = cVar20;

+        }

+        else {

+          local_6c = local_70;

+          iVar8 = HvpViewMapPromoteRangeToMapping(param_1 + 0xe0,uVar21,local_70,&local_60);

+          plVar17 = plVar22;

+          cVar7 = cVar20;

+          if (-1 < iVar8) {

+            iVar8 = HvpViewMapCOWAndUnsealRange(param_1 + 0xe0,uVar21,local_70);

+            goto LAB_10;

+          }

+        }

+      }

     }

-    param_4 = uVar2;

-    if (iVar5 != 0) {

-      param_4 = (ulonglong)(uint)((int)param_4 + -1 + iVar5 & -iVar5);

+LAB_2:

+    HvpAdjustHiveFreeDisplay(param_1,uVar21,param_3);

+  }

+  HvpShrinkMap(param_1,param_3,uVar23,uVar21);

+  *(uint *)((longlong)param_3 * 0x278 + 0x118 + param_1) = uVar21;

+  if (bVar3) {

+    *(undefined8 *)(param_1 + 0x60) = *(undefined8 *)(param_1 + 0x60);

+    *(uint *)(param_1 + 0x58) = uVar21 >> 9;

+    iVar11 = *(int *)(param_1 + 0x68);

+    iVar9 = RtlNumberOfSetBits();

+    *(int *)(param_1 + 0x68) = iVar9;

+    LOCK();

+    CmpDirtySectorCount = CmpDirtySectorCount + (iVar9 - iVar11);

+    UNLOCK();

+    *(uint *)(param_1 + 0x70) = uVar21 >> 9;

+    *(undefined8 *)(param_1 + 0x78) = *(undefined8 *)(param_1 + 0x78);

+    uVar10 = RtlNumberOfSetBits();

+    *(undefined4 *)(param_1 + 0x80) = uVar10;

+  }

+  if (cVar7 != '\0') {

+    HvpViewMapShrinkStorage(param_1 + 0xe0,uVar21);

+  }

+  if ((local_60 != (undefined4 *)0x0) && (!bVar4)) {

+    HvpFreeBin(param_1,local_74 - uVar21,local_60);

+  }

+  if (plVar17 != (longlong *)0x0) {

+    iVar11 = Feature_Servicing_RemoveAlignmentFreeBinFromList__private_IsEnabledDeviceUsageNoInline

+                       ();

+    if ((iVar11 != 0) && (plVar14 = (longlong *)*plVar17, plVar14 != plVar17)) {

+      if (((longlong *)plVar14[1] != plVar17) ||

+         (plVar22 = (longlong *)plVar17[1], (longlong *)*plVar22 != plVar17)) {

+LAB_0:

+        pcVar2 = (code *)swi(0x29);

+        (*pcVar2)(3);

+        return -0x3fffff66;

+      }

+      *plVar22 = (longlong)plVar14;

+      plVar14[1] = (longlong)plVar22;

     }

-  }

-  return param_4;

+    (**(code **)(param_1 + 0x20))(plVar17,0x18);

+  }

+  if ((local_68 != (undefined4 *)0x0) && (!bVar4)) {

+    HvpFreeBin(param_1,uVar23 - local_74,local_68);

+  }

+  if (local_6c != 0) {

+    CmpReleaseGlobalQuota(local_6c);

+    return iVar8;

+  }

+  return iVar8;

 }
```

## `PpmParkCalculateCoreParkingMaskEx`  (modified)

```diff
--- PpmParkCalculateCoreParkingMaskEx
+++ PpmParkComputeUnparkMaskEx
@@ -1,67 +1,336 @@
 

+/* WARNING: Instruction at (ram,0x0001405dface) overlaps instruction at (ram,0x0001405dfacc)

+    */

 /* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

 

-void PpmParkCalculateCoreParkingMaskEx(void)

+undefined8

+PpmParkComputeUnparkMaskEx(longlong param_1,_KAFFINITY_EX *param_2,_KAFFINITY_EX *param_3)

 

 {

-  ushort *puVar1;

-  char cVar2;

-  void *_Dst;

-  short in_AX;

-  uint uVar3;

-  longlong unaff_RBX;

+  byte *pbVar1;

+  _KAFFINITY_EX *p_Var2;

+  byte bVar3;

   ushort uVar4;

-  ulonglong unaff_RDI;

-  char cVar5;

-  undefined4 unaff_R12D;

-  short unaff_R15W;

-  longlong in_stack_00000030;

+  ushort uVar5;

+  undefined4 uVar6;

+  int iVar7;

+  ulonglong uVar8;

+  longlong lVar9;

+  ulonglong in_RAX;

+  char *pcVar10;

+  ushort uVar11;

+  uint uVar12;

+  uint uVar13;

+  uint uVar14;

+  char *unaff_RBX;

+  ulonglong uVar15;

+  ulonglong unaff_RBP;

+  ulonglong uVar16;

+  uint unaff_ESI;

+  longlong unaff_RDI;

+  uint uVar17;

+  uint unaff_R12D;

+  _KAFFINITY_EX *p_Var18;

+  _KAFFINITY_EX *unaff_R13;

+  uint unaff_R14D;

+  uint uVar19;

+  ushort *puVar20;

+  bool bVar21;

+  undefined2 uVar22;

   

+  pbVar1 = (byte *)(param_1 + -0x73);

+  bVar3 = *pbVar1;

+  *pbVar1 = *pbVar1 + (byte)param_1;

+  pcVar10 = (char *)(unaff_RBP & 0xffffffff);

+  uVar16 = in_RAX & 0xffffffff;

+  *unaff_RBX = (*unaff_RBX - (char)pcVar10) - CARRY1(bVar3,(byte)param_1);

+  *pcVar10 = *pcVar10 + (char)pcVar10;

   do {

-    *(short *)(unaff_RBX + 0x492) = in_AX;

+    KeAndAffinityEx2(unaff_R13 + 6,param_2,param_3);

+    p_Var2 = unaff_R13 + 6;

+    uVar14 = unaff_R12D;

+    func_0x0001405dfd2c(unaff_RDI,p_Var2,unaff_RDI + 0x240,unaff_R13 + 4,unaff_R12D);

+    uVar22 = (undefined2)(uVar14 >> 0x10);

+    iVar7 = Feature_PpmFixContainmentCandidateListInitialization__private_IsEnabledDeviceUsageNoInline

+                      ();

+    if ((iVar7 != 0) && (*(char *)(uVar16 - 0x7b) != '\0')) {

+      *(undefined4 *)(*(longlong *)(unaff_RDI + 0x500) + 4) = *(undefined4 *)(uVar16 - 0x68);

+    }

+    KeSubtractAffinityEx2(p_Var2,unaff_R13 + 5,unaff_R13 + 8);

+    KeSubtractAffinityEx2(unaff_R13 + 8,unaff_R13 + 7,unaff_R13 + 8);

+    lVar9 = unaff_RDI + 0x138;

+    KeSubtractAffinityEx2(lVar9,p_Var2,unaff_RDI + 0x138);

+    KeOrAffinityEx2(lVar9,unaff_R13 + 5,lVar9);

+    KeOrAffinityEx2(lVar9,unaff_R13 + 7,lVar9);

+    lVar9 = unaff_RDI + 0x348;

+    KeSubtractAffinityEx2(lVar9,unaff_R13 + 6,lVar9);

+    KeOrAffinityEx2(lVar9,unaff_R13 + 7,lVar9);

+    iVar7 = *(int *)(uVar16 - 0x74);

+    PpmEventTraceSoftCoreParkingSelectionEx

+              (unaff_RDI,iVar7,unaff_R12D & 0xffff,unaff_ESI & 0xffff,

+               CONCAT22(uVar22,(short)unaff_R14D));

+    bVar3 = *(byte *)(unaff_RDI + 0xc);

+    p_Var2 = unaff_R13 + 1;

+    uVar14 = *(uint *)(uVar16 - 0x70);

+    uVar19 = iVar7 + 1;

+    uVar8 = (ulonglong)uVar19;

+    *(uint *)(uVar16 - 0x74) = uVar19;

+    if (uVar19 < bVar3) goto LAB_0;

     do {

-      uVar4 = (short)unaff_RDI + unaff_R15W;

-      unaff_RDI = (ulonglong)uVar4;

-      if (PpmParkNumNodes <= uVar4) {

-        cVar5 = (char)unaff_R12D;

-        uVar3 = *(uint *)(in_stack_00000030 + 0xa0);

-        cVar2 = cVar5;

-        if (((PpmPerfMaxOverrideEnabled != cVar5) && (PpmHighPerfSoftParkLatencyUs != 0)) &&

-           ((uVar3 == 0 || (PpmHighPerfSoftParkLatencyUs < uVar3)))) {

-          uVar3 = PpmHighPerfSoftParkLatencyUs;

-          cVar2 = '\x01';

-        }

-        PpmEventSoftParkLatencyUpdate(0,cVar2,uVar3);

-        _Dst = PpmParkOldSoftParkRankList;

-        if (uVar3 == 0) {

-          KeSoftParkedQueueThreshold = unaff_R12D;

-          PpmParkSoftParkingEnabled = cVar5;

-          if ((PpmParkNewSoftParkRankList != (void *)0x0) &&

-             (PpmParkOldSoftParkRankList != (void *)0x0)) {

-            memset(PpmParkNewSoftParkRankList,0xff,(ulonglong)KeMaximumProcessors << 2);

-            memset(_Dst,0xff,(ulonglong)KeMaximumProcessors << 2);

-            KeUpdateSoftParkRankList();

-            PpmEventSoftParkRankListChanged();

+      uVar15 = (ulonglong)*(uint *)(uVar16 - 100);

+      do {

+        do {

+          uVar14 = (int)uVar15 + 1;

+          uVar15 = (ulonglong)uVar14;

+          bVar21 = PpmParkNumNodes <= uVar14;

+          *(uint *)(uVar16 - 100) = uVar14;

+          if (bVar21) {

+            PpmParkComputeDiff();

+            uVar14 = (uint)(PpmParkLpiCap != 0);

+            if ((PpmParkLpiEngaged != uVar14) || (bVar21 = false, PpmParkLpiCapChanged != 0)) {

+              bVar21 = true;

+            }

+            PpmParkLpiCapChanged = 0;

+            PpmParkLpiEngaged = uVar14;

+            if (bVar21) {

+              PpmEventLPICoreParking();

+            }

+            return 1;

           }

+          unaff_RDI = uVar15 * 0x510 + PpmParkNodes;

+          *(longlong *)(uVar16 - 0x38) = unaff_RDI;

+        } while ((*(byte *)(unaff_RDI + 0x4a0) & 1) != 0);

+        KiCopyAffinityEx((_KAFFINITY_EX *)(unaff_RDI + 0x240),*(ushort *)(unaff_RDI + 0x242),

+                         (_KAFFINITY_EX *)(unaff_RDI + 0x138));

+        uVar6 = *(undefined4 *)(uVar16 - 0x48);

+        *(undefined2 *)(unaff_RDI + 0x4e4) = 0;

+        *(undefined1 *)(unaff_RDI + 0x4e6) = 0;

+        uVar11 = *(ushort *)(unaff_RDI + 0x492);

+        if (*(ushort *)(unaff_RDI + 0x496) <= *(ushort *)(unaff_RDI + 0x492)) {

+          uVar11 = *(ushort *)(unaff_RDI + 0x496);

+        }

+        uVar14 = (uint)uVar11;

+        *(uint *)(uVar16 - 0x70) = uVar14;

+        PpmParkFindOverUtilizedProcessorsEx(unaff_RDI,uVar6,unaff_R13 + 3);

+        *(undefined1 *)(unaff_RDI + 0x4c8) = 0;

+        if (PpmHeteroFavoredCoreRotationTimeoutMs != 0) {

+          uVar8 = _DAT_1 / ((ulonglong)PpmHeteroFavoredCoreRotationTimeoutMs * 10000)

+          ;

+          *(ulonglong *)(unaff_RDI + 0x4b8) = uVar8;

+          if (uVar8 != *(ulonglong *)(unaff_RDI + 0x4c0)) {

+            *(undefined1 *)(unaff_RDI + 0x4c8) = 1;

+            *(ulonglong *)(unaff_RDI + 0x4c0) = uVar8;

+          }

+        }

+        uVar8 = 0;

+        *(undefined4 *)(uVar16 - 0x74) = 0;

+      } while (*(char *)(unaff_RDI + 0xc) == '\0');

+LAB_0:

+      uVar11 = unaff_R13[6].Size;

+      puVar20 = (ushort *)(uVar8 * 0x280 + *(longlong *)(unaff_RDI + 0x508));

+      *(undefined4 *)(uVar16 - 0x80) = 0;

+      KiCopyAffinityEx(unaff_R13 + 6,uVar11,(_KAFFINITY_EX *)(puVar20 + 0x14));

+      iVar7 = KeIsEmptyAffinityEx(unaff_R13 + 6);

+    } while (iVar7 != 0);

+    *(undefined4 *)(uVar16 - 0x80) = 0x100000;

+    if (PpmParkGranularity < 2) {

+      KiCopyAffinityEx(unaff_R13,unaff_R13->Size,(_KAFFINITY_EX *)(puVar20 + 0x98));

+    }

+    else {

+      memset(&unaff_R13->field3_0x8,0,(ulonglong)unaff_R13->Count << 3);

+      unaff_R13->Count = 1;

+      *(undefined2 *)(uVar16 - 0x50) = 0;

+      *(undefined8 *)(uVar16 - 0x58) = *(undefined8 *)(puVar20 + 0x9c);

+      *(_KAFFINITY_EX **)(uVar16 - 0x60) = (_KAFFINITY_EX *)(puVar20 + 0x98);

+      while (iVar7 = KeEnumerateNextProcessor(uVar16 - 0x78,uVar16 - 0x60), iVar7 == 0) {

+        KeGetPrcb(*(undefined4 *)(uVar16 - 0x78));

+        KeAddGroupAffinityEx();

+      }

+    }

+    KeAndAffinityEx2();

+    iVar7 = KeIsEmptyAffinityEx();

+    if (iVar7 == 0) {

+      *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x10000;

+    }

+    iVar7 = KeCountSetBitsAffinityEx();

+    if ((uint)*puVar20 - iVar7 <= uVar14) {

+      uVar14 = (uint)*puVar20 - iVar7;

+    }

+    memset(&unaff_R13[1].field3_0x8,0,(ulonglong)p_Var2->Count << 3);

+    bVar21 = KiClockTimerPerCpu == '\0';

+    p_Var2->Count = 1;

+    uVar6 = KiClockTimerOwner;

+    unaff_R14D = 0;

+    if (bVar21) {

+      *(undefined4 *)(uVar16 - 0x78) = KiClockTimerOwner;

+      iVar7 = KeCheckProcessorAffinityEx(unaff_R13 + 6);

+      if (((iVar7 != 0) && (unaff_R14D = 0, uVar14 != 0)) &&

+         (iVar7 = KeCheckProcessorAffinityEx(), iVar7 == 0)) {

+        lVar9 = KeGetPrcb(uVar6);

+        if (PpmParkGranularity < 2) {

+          KeAddProcessorAffinityEx(p_Var2);

         }

         else {

-          PpmParkSoftParkingEnabled = '\x01';

-          KeSoftParkedQueueThreshold =

-               PpmConvertTime((ulonglong)*(uint *)((longlong)FiberData + 0x44) * 1000000,1000000,

-                              uVar3);

-        }

-        PpmHeteroHgsCheckContainmentDecision();

-        return;

-      }

-      unaff_RBX = unaff_RDI * 0x510 + PpmParkNodes;

-      puVar1 = (ushort *)(unaff_RBX + 0x494);

-    } while (((uint)*(ushort *)(unaff_RBX + 0x492) ==

-              (uint)*(ushort *)(unaff_RBX + 10) - (uint)*(ushort *)(unaff_RBX + 0x490)) &&

-            ((uint)*(ushort *)(unaff_RBX + 0x496) ==

-             (uint)*(ushort *)(unaff_RBX + 10) - (uint)*puVar1));

-    PpmEventParkNodeCapChangeEx(unaff_RDI,unaff_RBX + 0x30,*(ushort *)(unaff_RBX + 0x490),*puVar1);

-    in_AX = *(short *)(unaff_RBX + 10) - *(short *)(unaff_RBX + 0x490);

-    *(ushort *)(unaff_RBX + 0x496) = *(short *)(unaff_RBX + 10) - *puVar1;

+          KeAddGroupAffinityEx(p_Var2,*(undefined1 *)(lVar9 + 0xd0),*(undefined8 *)(lVar9 + 0x8e60))

+          ;

+        }

+        *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x100;

+        unaff_R14D = KeCountSetBitsAffinityEx(p_Var2);

+      }

+    }

+    memset(&unaff_R13[2].field3_0x8,0,(ulonglong)unaff_R13[2].Count << 3);

+    unaff_R13[2].Count = 1;

+    uVar19 = KeCpuSetQueryUnparkRecommendationEx();

+    *(uint *)(uVar16 - 0x6c) = uVar19 & 0xffff;

+    if ((uVar19 & 0xffff) != 0) {

+      p_Var2 = unaff_R13 + 2;

+      if (1 < PpmParkGranularity) {

+        *(undefined2 *)(uVar16 - 0x50) = 0;

+        *(undefined8 *)(uVar16 - 0x58) = **(undefined8 **)(uVar16 - 0x40);

+        *(_KAFFINITY_EX **)(uVar16 - 0x60) = p_Var2;

+        iVar7 = KeEnumerateNextProcessor(uVar16 - 0x78,uVar16 - 0x60);

+        while (iVar7 == 0) {

+          lVar9 = KeGetPrcb(*(undefined4 *)(uVar16 - 0x78));

+          KeAddGroupAffinityEx(p_Var2,*(undefined1 *)(lVar9 + 0xd0),*(undefined8 *)(lVar9 + 0x8e60))

+          ;

+          iVar7 = KeEnumerateNextProcessor(uVar16 - 0x78,uVar16 - 0x60);

+        }

+        uVar6 = KeCountSetBitsAffinityEx(p_Var2);

+        *(undefined4 *)(uVar16 - 0x6c) = uVar6;

+      }

+      p_Var18 = unaff_R13 + 1;

+      *(ulong64 *)(uVar16 - 0x58) = unaff_R13[2].field3_0x8.Bitmap[0];

+      *(undefined2 *)(uVar16 - 0x50) = 0;

+      *(_KAFFINITY_EX **)(uVar16 - 0x60) = p_Var2;

+      iVar7 = KeEnumerateNextProcessor();

+      if (iVar7 == 0) {

+        do {

+          if (unaff_R14D < uVar14) {

+            uVar6 = *(undefined4 *)(uVar16 - 0x78);

+            iVar7 = KeCheckProcessorAffinityEx();

+            if (iVar7 == 0) {

+              lVar9 = KeGetPrcb(uVar6);

+              if (PpmParkGranularity < 2) {

+                KeAddProcessorAffinityEx(p_Var18,uVar6);

+              }

+              else {

+                KeAddGroupAffinityEx

+                          (p_Var18,*(undefined1 *)(lVar9 + 0xd0),*(undefined8 *)(lVar9 + 0x8e60));

+              }

+              *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x10;

+              unaff_R14D = KeCountSetBitsAffinityEx(p_Var18);

+            }

+          }

+          iVar7 = KeEnumerateNextProcessor();

+        } while (iVar7 == 0);

+        unaff_RDI = *(longlong *)(uVar16 - 0x38);

+      }

+    }

+    *(undefined1 *)(uVar16 - 0x7b) = 0;

+    *(undefined4 *)(uVar16 - 0x68) = 3;

+    iVar7 = Feature_PpmFixContainmentCandidateListInitialization__private_IsEnabledDeviceUsageNoInline

+                      ();

+    if (((iVar7 != 0) && (iVar7 = KeIsEmptyAffinityEx(), iVar7 == 0)) &&

+       ((PpmHeteroHgsContainmentState & 8) != 0)) {

+      *(undefined8 *)(uVar16 - 0x20) = 0x200001;

+      memset((void *)(uVar16 - 0x18),0,0x100);

+      KiCopyAffinityEx((_KAFFINITY_EX *)(uVar16 - 0x20),*(ushort *)(uVar16 - 0x1e),

+                       (_KAFFINITY_EX *)

+                       ((longlong)*(int *)(*(longlong *)(unaff_RDI + 0x500) + 4) * 0x108 + 0x10 +

+                       *(longlong *)(unaff_RDI + 0x500)));

+      iVar7 = KeIsSubsetAffinityEx();

+      if (iVar7 == 0) {

+        *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x2000000;

+        lVar9 = *(longlong *)(unaff_RDI + 0x500);

+        *(undefined1 *)(uVar16 - 0x7b) = 1;

+        *(undefined4 *)(uVar16 - 0x68) = *(undefined4 *)(lVar9 + 4);

+        *(undefined4 *)(lVar9 + 4) = 2;

+      }

+    }

+    uVar11 = puVar20[1];

+    if ((unaff_R14D < uVar11) && (unaff_R14D < uVar14)) {

+      unaff_R14D = uVar14;

+      if (uVar11 < uVar14) {

+        unaff_R14D = (uint)uVar11;

+      }

+      uVar19 = *(uint *)(uVar16 - 0x80) | 4;

+      *(uint *)(uVar16 - 0x80) = uVar19;

+    }

+    else {

+      uVar19 = *(uint *)(uVar16 - 0x80);

+    }

+    uVar11 = puVar20[2];

+    if ((uVar11 < uVar14) && (unaff_R14D < uVar14)) {

+      uVar19 = uVar19 | 8;

+      *(uint *)(uVar16 - 0x80) = uVar19;

+      uVar14 = (uint)uVar11;

+      if (uVar11 <= unaff_R14D) {

+        uVar14 = unaff_R14D;

+      }

+    }

+    uVar11 = 0;

+    uVar13 = PpmHeteroHgsContainmentState & 8;

+    if (uVar13 != 0) {

+      uVar11 = *(ushort *)

+                (*(longlong *)(unaff_RDI + 0x500) + 8 +

+                (longlong)*(int *)(*(longlong *)(unaff_RDI + 0x500) + 4) * 2);

+    }

+    uVar4 = *puVar20;

+    uVar5 = puVar20[3];

+    if (uVar4 <= puVar20[3]) {

+      uVar5 = uVar4;

+    }

+    uVar17 = (uint)uVar5;

+    if ((PpmCheckLatencyBoostActive != 0) &&

+       (uVar12 = ((uint)*(byte *)((ulonglong)(*(int *)(uVar16 - 0x74) != 0) + 0x89 +

+                                 *(longlong *)(uVar16 - 0x30)) * (uint)uVar4 + 0x32) / 100,

+       uVar5 < uVar12)) {

+      uVar19 = uVar19 | 0x40;

+      *(uint *)(uVar16 - 0x80) = uVar19;

+      uVar17 = uVar12;

+    }

+    if (1 < PpmParkGranularity) {

+      uVar17 = uVar17 + (PpmParkGranularity - 1);

+      uVar17 = uVar17 - uVar17 % (uint)PpmParkGranularity;

+    }

+    if (((uVar13 != 0) && (uVar11 != 0)) && (uVar11 < (ushort)uVar17)) {

+      uVar17 = (uint)uVar11;

+      *(uint *)(uVar16 - 0x80) = uVar19 | 0x400000;

+    }

+    uVar19 = *(int *)(uVar16 - 0x6c) + uVar17;

+    puVar20[4] = (ushort)uVar17;

+    if (uVar14 <= uVar19) {

+      uVar19 = uVar14;

+    }

+    unaff_R12D = unaff_R14D;

+    if (unaff_R14D < uVar19) {

+      unaff_R12D = uVar19;

+    }

+    *(int *)(uVar16 - 0x70) = *(int *)(uVar16 - 0x70) - uVar14;

+    bVar21 = PpmParkSoftParkingEnabled == '\0';

+    puVar20[5] = (ushort)unaff_R12D;

+    if (bVar21) {

+      *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x200000;

+      unaff_ESI = unaff_R12D;

+    }

+    else {

+      unaff_ESI = uVar14;

+      if (uVar13 != 0) {

+        *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x800000;

+        unaff_ESI = (uint)uVar11;

+        if (uVar14 < uVar11) {

+          unaff_ESI = uVar14;

+        }

+      }

+    }

+    bVar21 = PpmHeteroHgsParkingEnabled != '\0';

+    *(undefined1 *)(uVar16 - 0x7c) = 0;

+    if (bVar21) {

+      *(undefined1 *)(uVar16 - 0x7c) = *(undefined1 *)(unaff_RDI + 0x4f6);

+    }

+    param_3 = unaff_R13 + 4;

+    param_2 = unaff_R13 + 3;

   } while( true );

 }
```

## `ApiSetpInsertHashEntry`  (modified)

```diff
--- ApiSetpInsertHashEntry
+++ ApiSetpInsertHashEntry
@@ -1,10 +1,134 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void ApiSetpInsertHashEntry(void)

+undefined8

+ApiSetpInsertHashEntry

+          (longlong param_1,uint *param_2,ushort param_3,undefined8 param_4,undefined1 param_5)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  ushort *puVar1;

+  ushort uVar2;

+  byte bVar3;

+  uint uVar4;

+  undefined8 uVar5;

+  byte bVar6;

+  char cVar7;

+  ushort uVar8;

+  uint uVar9;

+  ulonglong uVar10;

+  undefined7 uVar12;

+  uint *puVar11;

+  uint *puVar13;

+  byte bVar14;

+  longlong lVar15;

+  ulonglong uVar16;

+  uint uVar17;

+  short local_res10 [4];

+  ushort local_res18;

+  ushort local_48 [2];

+  ushort local_44 [2];

+  uint local_40;

+  

+  uVar2 = (ushort)param_2[1];

+  if (param_3 == uVar2) {

+    uVar10 = CONCAT71((int7)((ulonglong)param_2 >> 8),*(byte *)(param_1 + 2)) & 0xffffffffffffff10;

+    bVar3 = *(byte *)(param_1 + 2) & 8;

+    bVar6 = *(byte *)((longlong)param_2 + 9) & 2;

+    bVar14 = *(byte *)((longlong)param_2 + 9) & 4;

+    uVar12 = (undefined7)(uVar10 >> 8);

+    cVar7 = (char)uVar10;

+    local_res18 = param_3;

+    if (bVar14 == 0) {

+      uVar9 = ApiSetpGetSearchKeyHash

+                        (param_4,CONCAT71(uVar12,bVar6 != 0),bVar3 != 0,cVar7 != '\0',

+                         *(undefined1 *)((longlong)param_2 + 10));

+    }

+    else {

+      bVar6 = ApiSetpGetSearchKeyHash

+                        (param_4,CONCAT71(uVar12,bVar6 != 0),bVar3 != 0,cVar7 != '\0',

+                         *(undefined1 *)((longlong)param_2 + 10));

+      uVar9 = (uint)bVar6;

+    }

+    local_40 = uVar9;

+    uVar4 = ApiSetpGetSearchKeyHash

+                      (param_4,param_5,bVar3 != 0,cVar7 != '\0',

+                       *(undefined1 *)((longlong)param_2 + 0xb));

+    if (bVar14 != 0) {

+      uVar4 = uVar4 & 0xff;

+    }

+    local_44[0] = 0;

+    local_48[0] = 0;

+    local_res10[0] = 0;

+    uVar5 = ApiSetpFindHashInsertionPoint_V7(param_1,param_2,uVar9,local_44,local_48,local_res10);

+    if (-1 < (int)uVar5) {

+      if (local_res10[0] != 0) {

+        if (local_48[0] < (ushort)(local_res10[0] + local_48[0])) {

+          uVar8 = local_48[0];

+          do {

+            if (*(uint *)(((ulonglong)

+                           *(ushort *)

+                            (((ulonglong)uVar8 * 8 - (ulonglong)*(ushort *)(param_1 + 0x12)) +

+                             (ulonglong)((uint)(byte)param_2[2] * (uint)uVar2 + *param_2) + 4 +

+                            param_1) * (ulonglong)(byte)param_2[2] -

+                          (ulonglong)*(ushort *)(param_1 + 0x12)) + (ulonglong)*param_2 + param_1)

+                == uVar4) {

+              return 0xc00000bd;

+            }

+            uVar8 = uVar8 + 1;

+          } while (uVar8 < (ushort)(local_res10[0] + local_48[0]));

+        }

+      }

+      uVar10 = (ulonglong)local_44[0];

+      puVar13 = param_2 + 2;

+      puVar1 = (ushort *)(param_1 + 0x12);

+      uVar17 = (uint)local_44[0];

+      uVar9 = uVar2 - uVar17;

+      if (uVar9 != 0) {

+        lVar15 = uVar10 * 8;

+        RtlCopyMemory((void *)((ulonglong)*param_2 +

+                               (((ulonglong)uVar2 + 1) * (ulonglong)(byte)*puVar13 -

+                               (ulonglong)*puVar1) + lVar15 + 8 + param_1),

+                      (void *)(((ulonglong)uVar2 * (ulonglong)(byte)*puVar13 - (ulonglong)*puVar1) +

+                               (ulonglong)*param_2 + lVar15 + param_1),(ulonglong)uVar9 << 3);

+      }

+      uVar16 = (ulonglong)local_res18;

+      puVar11 = (uint *)((ulonglong)*param_2 +

+                        param_1 + ((((ulonglong)(ushort)param_2[1] + 1) * (ulonglong)(byte)*puVar13

+                                   + uVar10 * 8) - (ulonglong)*puVar1));

+      *puVar11 = local_40;

+      puVar11[1] = (uint)local_res18;

+      if (uVar17 != 0) {

+        RtlCopyMemory((void *)((((ulonglong)(ushort)param_2[1] + 1) * (ulonglong)(byte)*puVar13 -

+                               (ulonglong)*puVar1) + (ulonglong)*param_2 + param_1),

+                      (void *)(((ulonglong)(ushort)param_2[1] * (ulonglong)(byte)*puVar13 -

+                               (ulonglong)*puVar1) + (ulonglong)*param_2 + param_1),

+                      (ulonglong)uVar17 << 3);

+      }

+      uVar2 = (ushort)param_2[1];

+      if (uVar2 != 0) {

+        uVar8 = 1;

+        lVar15 = ((ulonglong)uVar2 + 1) * (ulonglong)(byte)*puVar13;

+        if (1 < (ushort)(uVar2 + 1)) {

+          uVar9 = *(uint *)(((ulonglong)*param_2 - (ulonglong)*puVar1) + lVar15 + param_1);

+          do {

+            uVar17 = *(uint *)(((ulonglong)uVar8 * 8 - (ulonglong)*puVar1) + lVar15 +

+                               (ulonglong)*param_2 + param_1);

+            if (uVar17 < uVar9) goto LAB_0;

+            uVar8 = uVar8 + 1;

+            uVar9 = uVar17;

+          } while (uVar8 < (ushort)(uVar2 + 1));

+        }

+      }

+      puVar13 = (uint *)((ulonglong)*param_2 +

+                        param_1 + (uVar16 * (byte)param_2[2] -

+                                  (ulonglong)*(ushort *)(param_1 + 0x12)));

+      memset(puVar13,0,(ulonglong)(byte)param_2[2]);

+      uVar5 = 0;

+      *puVar13 = uVar4;

+    }

+  }

+  else {

+LAB_0:

+    uVar5 = 0xc00000e5;

+  }

+  return uVar5;

 }
```

## `ConvertDevpropertyToString`  (modified)

```diff
--- ConvertDevpropertyToString
+++ ConvertDevpropertyToString
@@ -1,61 +1,348 @@
 

-/* WARNING: Removing unreachable block (ram,0x000140a89eb1) */

-

-undefined4 ConvertDevpropertyToString(void)

+int ConvertDevpropertyToString(longlong param_1,uint param_2,undefined2 *param_3,uint *param_4)

 

 {

-  longlong lVar1;

-  undefined4 uVar2;

-  longlong lVar3;

-  longlong unaff_RBX;

-  longlong unaff_RSI;

-  int unaff_R12D;

-  undefined1 unaff_R14B;

-  longlong unaff_R15;

-  undefined1 uStack0000000000000042;

-  undefined4 in_stack_00000048;

-  undefined8 in_stack_00000050;

-  longlong in_stack_00000060;

-  undefined8 in_stack_00000068;

-  longlong in_stack_000000f0;

-  undefined8 *in_stack_00000100;

-  undefined8 in_stack_00000120;

-  undefined8 in_stack_00000128;

+  undefined4 *puVar1;

+  uint uVar2;

+  int iVar3;

+  ulonglong uVar4;

+  longlong lVar5;

+  int iVar6;

+  longlong lVar7;

+  double *pdVar8;

+  wchar_t *pwVar9;

+  uint uVar10;

+  ulonglong uVar11;

+  ulonglong local_res18;

+  uint *local_res20;

+  undefined8 in_stack_ffffffffffffff28;

+  ulonglong *puVar12;

+  undefined4 uVar13;

+  undefined8 in_stack_ffffffffffffff30;

+  undefined8 uVar14;

+  undefined4 uVar15;

+  double dVar16;

+  ulonglong local_68;

+  undefined2 *local_60;

+  undefined4 local_58;

+  uint uStack_54;

+  uint uStack_50;

+  uint uStack_4c;

   

-  *(undefined8 *)(unaff_RSI + 0x48) = in_stack_00000128;

-  *(undefined8 *)(unaff_RSI + 0x60) = in_stack_00000120;

-  lVar1 = *(longlong *)(unaff_RSI + 0xb8);

-  *(undefined4 *)(lVar1 + -0x48) = 3;

-  *(longlong *)(lVar1 + -0x18) = unaff_R15;

-  *(longlong *)(unaff_RSI + 0x18) = unaff_RBX;

-  *(longlong *)(unaff_RSI + 8) = unaff_RBX;

-  if (unaff_R12D != 0) {

-    lVar3 = IoAllocateMdl(*in_stack_00000100,unaff_R12D,0,1);

-    if (lVar3 == 0) {

-                    /* WARNING: Subroutine does not return */

-      ExRaiseStatus(0xc000009a);

-    }

-    MmProbeAndLockSelectedPages(lVar3,in_stack_00000100,unaff_R14B,1);

-    *(undefined8 *)(unaff_RSI + 0x70) = *in_stack_00000100;

-  }

-  if (in_stack_00000060 != 0) {

-    ExFreePoolWithTag(in_stack_00000060,0);

-    in_stack_00000060 = unaff_RBX;

-  }

-  *(uint *)(unaff_RSI + 0x10) =

-       *(uint *)(unaff_RSI + 0x10) | ((*(uint *)(unaff_R15 + 0x50) & 8) != 0) + 0x900;

-  *(int *)(lVar1 + -0x40) = unaff_R12D;

-  *(undefined4 *)(lVar1 + -0x38) = in_stack_00000048;

-  *(undefined8 *)(lVar1 + -0x30) = in_stack_00000050;

-  if ((*(uint **)(unaff_R15 + 0xd0) != (uint *)0x0) && ((**(uint **)(unaff_R15 + 0xd0) & 0x10) != 0)

-     ) {

-    *(undefined4 *)(lVar1 + -0x34) = *(undefined4 *)(in_stack_000000f0 + 8);

-  }

-  uVar2 = IopSynchronousServiceTail(in_stack_00000068);

-  if (in_stack_00000060 != 0) {

-    uStack0000000000000042 = (char)unaff_RBX;

-    ExFreePoolWithTag(in_stack_00000060,0);

-  }

-  return uVar2;

+  uVar13 = (undefined4)((ulonglong)in_stack_ffffffffffffff28 >> 0x20);

+  uVar15 = (undefined4)((ulonglong)in_stack_ffffffffffffff30 >> 0x20);

+  uVar11 = (ulonglong)param_2;

+  local_res18 = local_res18 & 0xffffffff00000000;

+  if (1 < param_2) {

+    *param_3 = 0;

+  }

+  local_res20 = param_4;

+  local_68 = uVar11;

+  local_60 = param_3;

+  iVar3 = ConvertDevpropcompkeyToString(param_1,param_3,uVar11,&local_res18);

+  if (((iVar3 + 0x80000000U & 0x80000000) == 0) && (iVar3 != -0x3fffffdd)) {

+    return iVar3;

+  }

+  iVar3 = 0;

+  uVar4 = (local_res18 & 0xffffffff) - 2;

+  if (uVar4 <= uVar11) {

+    uVar11 = uVar11 + (2 - (local_res18 & 0xffffffff));

+    param_3 = (undefined2 *)((longlong)param_3 + (uVar4 & 0xfffffffffffffffe));

+    local_68 = uVar11;

+    local_60 = param_3;

+  }

+  uVar10 = *(uint *)(param_1 + 0x20);

+  if (uVar10 < 0x1004) {

+    if (uVar10 == 0x1003) {

+      pwVar9 = L"BINARY";

+    }

+    else if (uVar10 < 0xe) {

+      if (uVar10 == 0xd) {

+        pwVar9 = L"GUID";

+      }

+      else if (uVar10 < 7) {

+        if (uVar10 == 6) {

+          pwVar9 = L"INT32";

+        }

+        else if (uVar10 == 0) {

+          pwVar9 = L"EMPTY";

+        }

+        else if (uVar10 == 1) {

+          pwVar9 = L"NULL";

+        }

+        else if (uVar10 == 2) {

+          pwVar9 = L"SBYTE";

+        }

+        else if (uVar10 == 3) {

+          pwVar9 = L"BYTE";

+        }

+        else if (uVar10 == 4) {

+          pwVar9 = L"INT16";

+        }

+        else {

+          if (uVar10 != 5) {

+            return -0x3ffffff3;

+          }

+          pwVar9 = L"UINT16";

+        }

+      }

+      else if (uVar10 == 7) {

+        pwVar9 = L"UINT32";

+      }

+      else if (uVar10 == 8) {

+        pwVar9 = L"INT64";

+      }

+      else if (uVar10 == 9) {

+        pwVar9 = L"UINT64";

+      }

+      else if (uVar10 == 10) {

+        pwVar9 = L"FLOAT";

+      }

+      else if (uVar10 == 0xb) {

+        pwVar9 = L"DOUBLE";

+      }

+      else {

+        if (uVar10 != 0xc) {

+          return -0x3ffffff3;

+        }

+        pwVar9 = L"DECIMAL";

+      }

+    }

+    else if (uVar10 < 0x15) {

+      if (uVar10 == 0x14) {

+        pwVar9 = L"SECURITY_DESCRIPTOR_STRING";

+      }

+      else if (uVar10 == 0xe) {

+        pwVar9 = L"CURRENCY";

+      }

+      else if (uVar10 == 0xf) {

+        pwVar9 = L"DATE";

+      }

+      else if (uVar10 == 0x10) {

+        pwVar9 = L"FILETIME";

+      }

+      else if (uVar10 == 0x11) {

+        pwVar9 = L"BOOLEAN";

+      }

+      else if (uVar10 == 0x12) {

+        pwVar9 = L"STRING";

+      }

+      else {

+        if (uVar10 != 0x13) {

+          return -0x3ffffff3;

+        }

+        pwVar9 = L"SECURITY_DESCRIPTOR";

+      }

+    }

+    else if (uVar10 == 0x15) {

+      pwVar9 = L"DEVPROPKEY";

+    }

+    else if (uVar10 == 0x16) {

+      pwVar9 = L"DEVPROPTYPE";

+    }

+    else if (uVar10 == 0x17) {

+      pwVar9 = L"ERROR";

+    }

+    else if (uVar10 == 0x18) {

+      pwVar9 = L"NTSTATUS";

+    }

+    else {

+      if (uVar10 != 0x19) {

+        return -0x3ffffff3;

+      }

+      pwVar9 = L"STRING_INDIRECT";

+    }

+  }

+  else if (uVar10 == 0x100d) {

+    pwVar9 = L"GUID_ARRAY";

+  }

+  else {

+    if (uVar10 != 0x2012) {

+      return -0x3ffffff3;

+    }

+    pwVar9 = L"STRING_LIST";

+  }

+  lVar7 = -1;

+  lVar5 = -1;

+  do {

+    lVar5 = lVar5 + 1;

+  } while (pwVar9[lVar5] != L'\0');

+  uVar10 = (int)local_res18 + (int)lVar5 * 2;

+  if (uVar10 <= param_2) {

+    uVar14 = CONCAT44(uVar15,0x400);

+    puVar12 = &local_68;

+    iVar3 = RtlStringCbCopyExW(param_3,uVar11,pwVar9,&local_60,puVar12,uVar14);

+    uVar13 = (undefined4)((ulonglong)puVar12 >> 0x20);

+    uVar15 = (undefined4)((ulonglong)uVar14 >> 0x20);

+    param_3 = local_60;

+    uVar11 = local_68;

+    if (iVar3 < 0) {

+      return iVar3;

+    }

+  }

+  if ((*(int *)(param_1 + 0x24) == 0) ||

+     (pdVar8 = *(double **)(param_1 + 0x28), pdVar8 == (double *)0x0)) goto LAB_0;

+  uVar2 = *(uint *)(param_1 + 0x20);

+  if (0x1003 < uVar2) {

+    if (uVar2 != 0x100d) {

+      if (uVar2 == 0x2012) {

+        for (; *(short *)pdVar8 != 0; pdVar8 = (double *)((longlong)pdVar8 + lVar5 * 2 + 2)) {

+          lVar5 = -1;

+          do {

+            lVar5 = lVar5 + 1;

+          } while (*(short *)((longlong)pdVar8 + lVar5 * 2) != 0);

+          uVar10 = uVar10 + (int)lVar5 * 2 + 4;

+          if ((uVar10 <= param_2) &&

+             (iVar3 = RtlStringCbPrintfExW(param_3,uVar11,&local_60,&local_68,0x400,&u___s_,pdVar8),

+             param_3 = local_60, iVar3 < 0)) {

+            return iVar3;

+          }

+          lVar5 = -1;

+          do {

+            lVar5 = lVar5 + 1;

+          } while (*(short *)((longlong)pdVar8 + lVar5 * 2) != 0);

+          uVar11 = local_68;

+        }

+        goto LAB_0;

+      }

+      goto LAB_1;

+    }

+LAB_2:

+    local_res18 = 0;

+    do {

+      uVar10 = uVar10 + 0x50;

+      puVar1 = (undefined4 *)(*(longlong *)(param_1 + 0x28) + local_res18);

+      local_58 = *puVar1;

+      uStack_54 = puVar1[1];

+      uStack_50 = puVar1[2];

+      uStack_4c = puVar1[3];

+      uVar14 = *(undefined8 *)(puVar1 + 2);

+      if ((uVar10 <= param_2) &&

+         (iVar3 = RtlStringCbPrintfExW

+                            (param_3,local_68,&local_60,&local_68,0x400,

+                             L"({%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x})",local_58,

+                             uStack_54 & 0xffff,uStack_54 >> 0x10,uStack_50 & 0xff,

+                             (uint)((ulonglong)uVar14 >> 8) & 0xff,

+                             (uint)((ulonglong)uVar14 >> 0x10) & 0xff,

+                             (uint)((ulonglong)uVar14 >> 0x18) & 0xff,uStack_4c & 0xff,

+                             uStack_4c >> 8 & 0xff,uStack_4c >> 0x10 & 0xff,uStack_4c >> 0x18),

+         param_3 = local_60, iVar3 < 0)) {

+        return iVar3;

+      }

+      local_res18 = local_res18 + 0x10;

+    } while (local_res18 < *(uint *)(param_1 + 0x24));

+    goto LAB_0;

+  }

+  if (uVar2 == 0x1003) goto LAB_0;

+  if (uVar2 < 0xe) {

+    if (uVar2 == 0xd) goto LAB_2;

+    if (uVar2 < 7) {

+      if (uVar2 == 6) {

+LAB_3:

+        uVar10 = uVar10 + 0x18;

+        if (param_2 < uVar10) goto LAB_0;

+        dVar16 = (double)(ulonglong)(uint)*(float *)pdVar8;

+        pwVar9 = L"(0x%.8x)";

+      }

+      else {

+        if ((uVar2 == 0) || (uVar2 == 1)) {

+          return -0x3ffffff3;

+        }

+        if ((uVar2 == 2) || (uVar2 == 3)) {

+          uVar10 = uVar10 + 0xc;

+          if (param_2 < uVar10) goto LAB_0;

+          dVar16 = (double)(ulonglong)*(byte *)pdVar8;

+          pwVar9 = L"(0x%.2x)";

+        }

+        else {

+          if ((uVar2 != 4) && (uVar2 != 5)) {

+LAB_1:

+            iVar3 = -0x3ffffff3;

+            goto LAB_0;

+          }

+          uVar10 = uVar10 + 0x10;

+          if (param_2 < uVar10) goto LAB_0;

+          dVar16 = (double)(ulonglong)(uint)(int)*(short *)pdVar8;

+          pwVar9 = L"(0x%.4x)";

+        }

+      }

+    }

+    else {

+      if (uVar2 == 7) goto LAB_3;

+      if ((uVar2 == 8) || (uVar2 == 9)) {

+        uVar10 = uVar10 + 0x28;

+        if (param_2 < uVar10) goto LAB_0;

+        dVar16 = *pdVar8;

+        pwVar9 = L"(0x%.16I64x)";

+      }

+      else {

+        if ((uVar2 != 10) && (iVar6 = uVar2 - 0xb, iVar6 != 0)) {

+LAB_4:

+          if (iVar6 == 1) goto LAB_0;

+          goto LAB_1;

+        }

+        uVar10 = uVar10 + 0x20;

+        if (param_2 < uVar10) goto LAB_0;

+        if (uVar2 == 10) {

+          dVar16 = (double)*(float *)pdVar8;

+        }

+        else {

+          dVar16 = *pdVar8;

+        }

+        pwVar9 = L"(%.6e)";

+      }

+    }

+LAB_5:

+    iVar3 = RtlStringCbPrintfExW

+                      (param_3,uVar11,&local_60,&local_68,CONCAT44(uVar13,0x400),pwVar9,dVar16);

+  }

+  else {

+    if (0x14 < uVar2) {

+      if (uVar2 == 0x15) goto LAB_0;

+      if (((uVar2 == 0x16) || (uVar2 == 0x17)) || (uVar2 == 0x18)) goto LAB_3;

+      if (uVar2 != 0x19) goto LAB_1;

+LAB_6:

+      iVar6 = Feature_KernelPnP_DevfilterLogging__private_IsEnabledDeviceUsageNoInline();

+      dVar16 = *(double *)(param_1 + 0x28);

+      do {

+        lVar7 = lVar7 + 1;

+      } while (*(short *)((longlong)dVar16 + lVar7 * 2) != 0);

+      uVar10 = uVar10 + (int)lVar7 * 2;

+      if (iVar6 != 0) {

+        uVar10 = uVar10 + 4;

+      }

+      if (param_2 < uVar10) goto LAB_0;

+      pwVar9 = L"(%s)";

+      goto LAB_5;

+    }

+    if (uVar2 == 0x14) goto LAB_6;

+    if (((uVar2 == 0xe) || (uVar2 == 0xf)) || (uVar2 == 0x10)) goto LAB_0;

+    if (uVar2 != 0x11) {

+      iVar6 = uVar2 - 0x12;

+      if (iVar6 != 0) goto LAB_4;

+      goto LAB_6;

+    }

+    pwVar9 = L"(TRUE)";

+    if (*(char *)pdVar8 != -1) {

+      pwVar9 = L"(FALSE)";

+    }

+    do {

+      lVar7 = lVar7 + 1;

+    } while (pwVar9[lVar7] != L'\0');

+    uVar10 = uVar10 + (int)lVar7 * 2;

+    if (param_2 < uVar10) goto LAB_0;

+    iVar3 = RtlStringCbCopyExW(param_3,uVar11,pwVar9,&local_60,&local_68,CONCAT44(uVar15,0x400));

+  }

+  if (iVar3 < 0) {

+    return iVar3;

+  }

+LAB_0:

+  if (local_res20 != (uint *)0x0) {

+    *local_res20 = uVar10;

+  }

+  if (param_2 < uVar10) {

+    iVar3 = -0x3fffffdd;

+  }

+  return iVar3;

 }
```

## `ConvertDevpropcompkeyToString`  (modified)

```diff
--- ConvertDevpropcompkeyToString
+++ ConvertDevpropcompkeyToString
@@ -1,10 +1,108 @@
 

-/* WARNING: Control flow encountered bad instruction data */

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

 

-void ConvertDevpropcompkeyToString(void)

+int ConvertDevpropcompkeyToString(longlong param_1,undefined2 *param_2,uint param_3,uint *param_4)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  int iVar1;

+  longlong lVar2;

+  int iVar3;

+  longlong lVar4;

+  uint uVar5;

+  undefined1 auStack_d8 [32];

+  undefined4 local_b8;

+  undefined1 *local_b0;

+  undefined8 local_a8;

+  undefined4 local_a0;

+  wchar_t *local_98;

+  undefined1 *local_90;

+  undefined8 local_88;

+  undefined8 uStack_80;

+  short local_78 [16];

+  ulonglong local_58;

+  

+  local_58 = __security_cookie ^ (ulonglong)auStack_d8;

+  local_88 = 0;

+  uStack_80 = 0;

+  local_78[0] = 0;

+  local_78[1] = 0;

+  local_78[2] = 0;

+  local_78[3] = 0;

+  local_78[4] = 0;

+  local_78[5] = 0;

+  local_78[6] = 0;

+  local_78[7] = 0;

+  local_78[8] = 0;

+  local_78[9] = 0;

+  local_78[10] = 0;

+  local_78[0xb] = 0;

+  local_78[0xc] = 0;

+  local_78[0xd] = 0;

+  local_78[0xe] = 0;

+  local_78[0xf] = 0;

+  if (1 < param_3) {

+    *param_2 = 0;

+  }

+  iVar1 = RtlStringFromGUIDEx(0,&local_88,1);

+  if (-1 < iVar1) {

+    uVar5 = (uint)(ushort)local_88;

+    iVar1 = Feature_KernelPnP_DevfilterLogging__private_IsEnabledDeviceUsageNoInline();

+    lVar4 = -1;

+    if (iVar1 == 0) {

+      iVar1 = 0x14;

+    }

+    else {

+      iVar1 = RtlStringCchPrintfW(local_78,0x10,&u__3d,*(undefined4 *)(param_1 + 0x10));

+      if (iVar1 < 0) goto LAB_0;

+      lVar2 = -1;

+      do {

+        lVar2 = lVar2 + 1;

+      } while (local_78[lVar2] != 0);

+      iVar1 = (int)lVar2 * 2;

+    }

+    if (*(int *)(param_1 + 0x14) == 0) {

+      iVar1 = uVar5 + iVar1 + 0x1c;

+    }

+    else {

+      if (*(int *)(param_1 + 0x14) != 1) {

+        iVar1 = -0x3ffffff3;

+        goto LAB_0;

+      }

+      iVar1 = uVar5 + iVar1 + 0x18;

+    }

+    if (*(longlong *)(param_1 + 0x18) == 0) {

+      iVar3 = 0xc;

+    }

+    else {

+      do {

+        lVar4 = lVar4 + 1;

+      } while (*(short *)(*(longlong *)(param_1 + 0x18) + lVar4 * 2) != 0);

+      iVar3 = (int)lVar4 * 2;

+    }

+    if (param_4 != (uint *)0x0) {

+      *param_4 = iVar1 + iVar3;

+    }

+    if (param_3 < (uint)(iVar1 + iVar3)) {

+      iVar1 = -0x3fffffdd;

+    }

+    else {

+      local_98 = L"System";

+      local_90 = &u__NULL_;

+      if (*(undefined1 **)(param_1 + 0x18) != (undefined1 *)0x0) {

+        local_90 = *(undefined1 **)(param_1 + 0x18);

+      }

+      local_a0 = *(undefined4 *)(param_1 + 0x10);

+      if (*(int *)(param_1 + 0x14) != 0) {

+        local_98 = L"User";

+      }

+      local_a8 = uStack_80;

+      local_b0 = &u____s__3d___s__s;

+      local_b8 = 0x800;

+      iVar1 = RtlStringCbPrintfExW(param_2,param_3,0,0);

+    }

+  }

+LAB_0:

+  RtlFreeAnsiString(&local_88);

+  return iVar1;

 }
```

## `EtwQueryPerformanceTraceInformation`  (modified)

```diff
--- EtwQueryPerformanceTraceInformation
+++ EtwQueryPerformanceTraceInformation
@@ -1,597 +1,347 @@
 

 /* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

-/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

 

-uint EtwQueryPerformanceTraceInformation(undefined8 param_1,undefined8 *param_2)

+ulonglong EtwQueryPerformanceTraceInformation(int *param_1,uint param_2,char param_3,uint *param_4)

 

 {

-  undefined8 *puVar1;

-  ulonglong uVar2;

-  code *pcVar3;

-  undefined8 uVar4;

+  int iVar1;

+  char cVar2;

+  uint uVar3;

+  uint uVar4;

   uint uVar5;

-  uint uVar6;

-  uint uVar7;

+  int iVar6;

+  int iVar7;

   longlong lVar8;

-  longlong lVar9;

-  undefined8 *puVar10;

-  undefined8 *puVar11;

-  longlong *plVar12;

-  int *piVar13;

-  ulonglong *puVar14;

-  uint unaff_ESI;

-  int *piVar15;

+  int *piVar9;

+  int *piVar10;

+  longlong lVar11;

+  ulonglong uVar12;

+  undefined8 uVar13;

+  ulonglong uVar14;

+  uint *puVar15;

   ulonglong uVar16;

-  uint uVar17;

-  undefined8 *puVar18;

-  longlong *plVar19;

-  int iVar20;

-  undefined8 *in_R10;

-  longlong unaff_R12;

-  uint unaff_R13D;

-  int *piVar21;

-  uint uVar22;

-  ulonglong *unaff_R14;

-  longlong *unaff_R15;

-  bool bVar23;

-  undefined1 local_res8 [32];

-  uint uStack0000000000000030;

-  uint uStack0000000000000034;

-  undefined8 *in_stack_00000038;

-  uint uStack0000000000000050;

-  uint uStack0000000000000054;

-  ulonglong *in_stack_00000058;

-  uint uStack0000000000000060;

-  uint uStack0000000000000064;

-  uint uStack0000000000000068;

-  undefined4 uStack000000000000006c;

-  longlong *in_stack_00000070;

-  longlong in_stack_00000078;

-  uint uStack0000000000000088;

-  int *in_stack_00000090;

-  int *in_stack_00000098;

-  undefined8 *in_stack_000000a0;

-  int *in_stack_000000b0;

-  int *in_stack_000000b8;

-  undefined8 *in_stack_000000c0;

-  uint *in_stack_000000c8;

-  longlong in_stack_000000d0;

-  longlong in_stack_000000e0;

-  uint uStack00000000000000e8;

-  undefined4 uStack00000000000000ec;

-  int *in_stack_000000f0;

-  int *in_stack_000000f8;

-  longlong *in_stack_00000100;

-  longlong *in_stack_00000108;

-  undefined8 *in_stack_00000160;

-  int *in_stack_00000168;

-  undefined4 uStack0000000000000170;

-  undefined4 uStack0000000000000174;

-  undefined4 uStack0000000000000178;

-  undefined4 uStack000000000000017c;

-  undefined4 uStack0000000000000180;

-  undefined4 uStack0000000000000184;

-  undefined4 uStack0000000000000188;

-  undefined4 uStack000000000000018c;

+  uint local_res10 [2];

+  char local_res18;

+  longlong *plVar17;

+  int **ppiVar18;

+  uint local_58 [2];

+  longlong local_50;

+  int local_48;

+  int *local_40;

+  int *local_38;

   

-  bVar23 = *(int *)(param_2 + -1) == 1;

-code_r0x000140946490:

-  if (bVar23) {

-    LOCK();

-    *(int *)(unaff_R12 + 0x664) = *(int *)(unaff_R12 + 0x664) + 1;

-    UNLOCK();

-  }

-  uVar22 = (uint)unaff_R14;

-  LOCK();

-  *(uint *)((longlong)param_2 + 0x3c) = uVar22;

-  UNLOCK();

-  in_stack_00000038 = in_stack_00000038;

-  plVar19 = in_stack_00000070;

+  uVar12 = 0;

+  if (param_2 < 4) {

+    return 0xc000000d;

+  }

+  iVar7 = *param_1;

+  puVar15 = param_4;

+  local_res18 = param_3;

+  local_48 = iVar7;

+  uVar3 = param_2;

+  lVar8 = PsGetCurrentServerSiloGlobals();

+  lVar8 = *(longlong *)(lVar8 + 0x340);

+  if (0x12 < iVar7) {

+    if (iVar7 != 0x19) {

+      if (iVar7 != 0x1c) {

+        return 0xc0000002;

+      }

+      iVar7 = Feature_LastBranchRecordQuery__private_IsEnabledNoReportingNoInline();

+      if (iVar7 == 0) {

+        return 0xc0000002;

+      }

+      *param_4 = 0xc;

+      if (param_2 != 0xc) {

+        return 0xc0000004;

+      }

+      if (local_res18 == '\0') {

+        param_1[1] = EtwpLastBranchStackSize;

+        param_1[2] = EtwpLastBranchSupportedOptions;

+        return 0;

+      }

+      RtlWriteULongToUser(param_1 + 1,EtwpLastBranchStackSize);

+      RtlWriteULongToUser(param_1 + 2,EtwpLastBranchSupportedOptions);

+      return 0;

+    }

+    uVar3 = EtwpQueryCoverageSamplerInformation(param_1);

 LAB_0:

-  param_2 = in_stack_00000038;

-  if (param_2 != in_R10) goto LAB_1;

-  LOCK();

-  bVar23 = *(longlong *)(unaff_R12 + 0x498) == 0x11;

-  if (bVar23) {

-    *(longlong *)(unaff_R12 + 0x498) = (longlong)unaff_R14;

-  }

-  UNLOCK();

-  if (!bVar23) {

-    ExfReleasePushLockShared(unaff_R12 + 0x498);

-  }

-  KeAbPostRelease(unaff_R12 + 0x498);

-  KiLeaveCriticalRegionUnsafe(SystemReserved1[0xf]);

-  if ((ulonglong)uStack0000000000000034 * 0x30 < 0x100000000) {

-    uVar5 = (int)((ulonglong)uStack0000000000000034 * 0x30) + unaff_ESI;

-    uVar7 = 0xffffffff;

-    if (uVar5 >= unaff_ESI) {

-      uVar7 = uVar5;

-    }

-    uVar17 = -(uint)(uVar5 < unaff_ESI) & 0xc0000095;

-    if (uVar5 < unaff_ESI) goto LAB_2;

-    uVar6 = uStack0000000000000054 + uVar7;

-    uVar5 = 0xffffffff;

-    if (uVar6 >= uVar7) {

-      uVar5 = uVar6;

-    }

-    uVar17 = -(uint)(uVar6 < uVar7) & 0xc0000095;

-    if (uVar7 <= uVar6) {

-      uVar7 = uStack0000000000000050 + uVar5;

-      uStack00000000000000e8 = 0xffffffff;

-      if (uVar7 >= uVar5) {

-        uStack00000000000000e8 = uVar7;

-      }

-      uVar17 = -(uint)(uVar7 < uVar5) & 0xc0000095;

-      if (uVar5 <= uVar7) {

-        uVar16 = (ulonglong)uStack0000000000000030;

-        if (uStack0000000000000088 < uStack00000000000000e8) {

-          *in_stack_000000c8 = uStack00000000000000e8;

-          uVar17 = 0xc0000023;

-          in_stack_00000058 = unaff_R14;

-          goto LAB_3;

-        }

-        if (uStack0000000000000030 != 0) {

-          in_stack_00000058 =

-               (ulonglong *)ExAllocatePool2(0x100,uStack0000000000000030 * 8,0x56777445);

-          if (in_stack_00000058 == (ulonglong *)0x0) {

-            uVar17 = 0xc000009a;

-            goto LAB_3;

-          }

-          memset(in_stack_00000058,0,(ulonglong)(uStack0000000000000030 * 8));

-        }

-        lVar9 = in_stack_00000078;

-        if ((*(uint *)(in_stack_000000d0 + 0x10) & 1) != 0) {

-          puVar14 = *(ulonglong **)(in_stack_00000078 + 0x528);

-          if (puVar14 != (ulonglong *)0x0) {

-            *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) =

-                 *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) + -1;

-            lVar8 = KeAbPreAcquire(puVar14,0,0);

-            LOCK();

-            uVar16 = *puVar14;

-            *puVar14 = *puVar14 | 1;

-            UNLOCK();

-            if ((uVar16 & 1) != 0) {

-              ExfAcquirePushLockExclusiveEx(puVar14,lVar8,puVar14);

+    return (ulonglong)uVar3;

+  }

+  if (iVar7 == 0x12) {

+    uVar3 = EtwpGetSoftRestartInformation(param_1);

+    goto LAB_0;

+  }

+  if (iVar7 < 7) {

+    if (iVar7 == 6) {

+      uVar3 = 0;

+      local_res10[0] = 0;

+      local_40 = param_1 + 4;

+      if (param_2 < 0x10) {

+        return 0xc0000004;

+      }

+      local_38 = *(int **)(param_1 + 2);

+      uVar14 = (ulonglong)local_38 & 0xffff;

+      if ((int)uVar14 == 0xffff) {

+        uVar14 = (ulonglong)*(byte *)(lVar8 + 0x1198);

+      }

+      *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) =

+           *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) + -1;

+      piVar9 = (int *)EtwpAcquireLoggerContextByLoggerId(lVar8,uVar14,1);

+      local_38 = piVar9;

+      if (piVar9 != (int *)0x0) {

+        uVar4 = EtwpCheckLoggerControlAccess(1,piVar9);

+        uVar14 = (ulonglong)uVar4;

+        if (-1 < (int)uVar4) {

+          if ((char)piVar9[0xcc] < '\0') {

+            uVar3 = RtlNumberOfSetBits(piVar9 + 0x104);

+            local_res10[0] = uVar3;

+          }

+          piVar10 = local_40;

+          uVar4 = local_res10[0];

+          uVar3 = uVar3 * 4 + 0x10;

+          *param_4 = uVar3;

+          uVar16 = uVar12;

+          if (param_2 < uVar3) {

+            uVar14 = 0xc0000023;

+          }

+          else {

+            while (uVar3 = (uint)uVar12, local_58[0] = uVar3, uVar3 < uVar4) {

+              uVar5 = RtlFindSetBits(piVar9 + 0x104,1,(int)uVar16 + 1);

+              local_50 = CONCAT44(local_50._4_4_,uVar5);

+              piVar10[uVar12] = uVar5;

+              uVar16 = (ulonglong)uVar5;

+              uVar12 = (ulonglong)(uVar3 + 1);

             }

-            if (lVar8 != 0) {

-              *(undefined1 *)(lVar8 + 10) = 1;

-            }

-            puVar14[1] = (ulonglong)SystemReserved1[0xf];

-            memset(puVar14 + 3,0,(ulonglong)*(uint *)((longlong)puVar14 + 0x14) << 2);

-            puVar14[1] = (ulonglong)unaff_R14;

-            LOCK();

-            uVar16 = *puVar14;

-            *puVar14 = *puVar14 - 1;

-            UNLOCK();

-            if (((byte)uVar16 & 6) == 2) {

-              ExfTryToWakePushLock(puVar14);

-            }

-            KeAbPostRelease(puVar14);

-            KiLeaveCriticalRegionUnsafe(SystemReserved1[0xf]);

-          }

-          puVar14 = *(ulonglong **)(lVar9 + 0x530);

-          if (puVar14 != (ulonglong *)0x0) {

-            *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) =

-                 *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) + -1;

-            lVar9 = KeAbPreAcquire(puVar14,0,0);

-            LOCK();

-            uVar16 = *puVar14;

-            *puVar14 = *puVar14 | 1;

-            UNLOCK();

-            if ((uVar16 & 1) != 0) {

-              ExfAcquirePushLockExclusiveEx(puVar14,lVar9,puVar14);

-            }

-            if (lVar9 != 0) {

-              *(undefined1 *)(lVar9 + 10) = 1;

-            }

-            puVar14[1] = (ulonglong)SystemReserved1[0xf];

-            memset(puVar14 + 3,0,(ulonglong)*(uint *)((longlong)puVar14 + 0x14) << 2);

-            puVar14[1] = (ulonglong)unaff_R14;

-            LOCK();

-            uVar16 = *puVar14;

-            *puVar14 = *puVar14 - 1;

-            UNLOCK();

-            if (((byte)uVar16 & 6) == 2) {

-              ExfTryToWakePushLock(puVar14);

-            }

-            KeAbPostRelease(puVar14);

-            KiLeaveCriticalRegionUnsafe(SystemReserved1[0xf]);

-          }

-        }

-        in_stack_000000a0 = (undefined8 *)(in_stack_000000d0 + 0x14);

-        in_stack_00000160 = (undefined8 *)(in_stack_000000d0 + 0x40);

-        *in_stack_000000a0 = 0;

-        *(undefined8 *)(in_stack_000000d0 + 0x1c) = 0;

-        *(undefined8 *)(in_stack_000000d0 + 0x24) = 0;

-        *(undefined8 *)(in_stack_000000d0 + 0x2c) = 0;

-        *(undefined8 *)(in_stack_000000d0 + 0x34) = 0;

-        *(undefined4 *)(in_stack_000000d0 + 0x3c) = 0;

-        *(undefined4 *)in_stack_000000a0 = 0x2c;

-        *(undefined4 *)(in_stack_000000d0 + 0x1c) = *(undefined4 *)((longlong)unaff_R15 + 0x6bc);

-        *(undefined4 *)(in_stack_000000d0 + 0x24) = 0x454;

-        iVar20 = (int)in_stack_000000a0;

-        *(int *)(in_stack_000000d0 + 0x20) = (int)in_stack_00000160 - iVar20;

-        in_stack_000000c0 = (undefined8 *)(in_stack_000000d0 + 0x494);

-        lVar9 = 8;

-        puVar18 = (undefined8 *)(unaff_R12 + 8);

-        puVar1 = in_stack_00000160;

-        do {

-          puVar11 = puVar1;

-          puVar10 = puVar18;

-          uVar4 = puVar10[1];

-          *puVar11 = *puVar10;

-          puVar11[1] = uVar4;

-          uVar4 = puVar10[3];

-          puVar11[2] = puVar10[2];

-          puVar11[3] = uVar4;

-          uVar4 = puVar10[5];

-          puVar11[4] = puVar10[4];

-          puVar11[5] = uVar4;

-          uVar4 = puVar10[7];

-          puVar11[6] = puVar10[6];

-          puVar11[7] = uVar4;

-          uVar4 = puVar10[9];

-          puVar11[8] = puVar10[8];

-          puVar11[9] = uVar4;

-          uVar4 = puVar10[0xb];

-          puVar11[10] = puVar10[10];

-          puVar11[0xb] = uVar4;

-          uVar4 = puVar10[0xd];

-          puVar11[0xc] = puVar10[0xc];

-          puVar11[0xd] = uVar4;

-          uVar4 = puVar10[0xf];

-          puVar11[0xe] = puVar10[0xe];

-          puVar11[0xf] = uVar4;

-          lVar9 = lVar9 + -1;

-          puVar18 = puVar10 + 0x10;

-          puVar1 = puVar11 + 0x10;

-        } while (lVar9 != 0);

-        uVar4 = puVar10[0x11];

-        puVar11[0x10] = puVar10[0x10];

-        puVar11[0x11] = uVar4;

-        uVar4 = puVar10[0x13];

-        puVar11[0x12] = puVar10[0x12];

-        puVar11[0x13] = uVar4;

-        uVar4 = puVar10[0x15];

-        puVar11[0x14] = puVar10[0x14];

-        puVar11[0x15] = uVar4;

-        uVar4 = puVar10[0x17];

-        puVar11[0x16] = puVar10[0x16];

-        puVar11[0x17] = uVar4;

-        uVar4 = puVar10[0x19];

-        puVar11[0x18] = puVar10[0x18];

-        puVar11[0x19] = uVar4;

-        *(undefined4 *)(puVar11 + 0x1a) = *(undefined4 *)(puVar10 + 0x1a);

-        *(undefined4 *)(in_stack_000000d0 + 0x2c) = 0x3c;

-        *(int *)(in_stack_000000d0 + 0x28) = (int)in_stack_000000c0 - iVar20;

-        piVar13 = (int *)(in_stack_000000d0 + 0x4d0);

-        *(uint *)(in_stack_000000d0 + 0x34) = unaff_R13D;

-        *(int *)(in_stack_000000d0 + 0x30) = (int)piVar13 - iVar20;

-        piVar21 = piVar13 + (ulonglong)unaff_R13D * 2;

-        plVar19 = (longlong *)unaff_R15[0xd2];

-        in_stack_000000f0 = piVar13;

-        while (plVar12 = plVar19, plVar12 != unaff_R15 + 0xd2) {

-          uVar16 = (ulonglong)unaff_R14 & 0xffffffff;

-          _uStack0000000000000088 = (int *)CONCAT44(uVar22,uStack0000000000000088);

-          while (uVar7 = (uint)uVar16, uVar7 < *(uint *)((longlong)plVar12 + 0x14)) {

-            in_stack_00000108 = (longlong *)(plVar12[3] + uVar16 * 8);

-            if (*in_stack_00000108 == 0) {

-              uVar16 = (ulonglong)(uVar7 + 1);

-              _uStack0000000000000088 = (int *)CONCAT44(uVar7 + 1,uStack0000000000000088);

-            }

-            else {

-              if (piVar21 <= piVar13) break;

-              *piVar13 = (int)*in_stack_00000108;

-              piVar13[1] = *(int *)((longlong)in_stack_00000108 + 4);

-              piVar13 = piVar13 + 2;

-              uVar16 = (ulonglong)(uVar7 + 1);

-              _uStack0000000000000088 = (int *)CONCAT44(uVar7 + 1,uStack0000000000000088);

-              in_stack_000000f0 = piVar13;

-            }

-          }

-          in_stack_00000100 = plVar12;

-          plVar19 = (longlong *)*plVar12;

-        }

-        *(uint *)(in_stack_000000d0 + 0x3c) = uStack0000000000000034;

-        *(int *)(in_stack_000000d0 + 0x38) = (int)piVar21 - iVar20;

-        piVar13 = piVar21 + (ulonglong)uStack0000000000000034 * 0xc;

-        in_stack_000000b8 = piVar21;

-        in_stack_00000168 = piVar21;

-        memset(piVar21,0,(longlong)piVar13 - (longlong)piVar21);

-        in_stack_00000090 = (int *)((longlong)piVar13 + (ulonglong)uStack0000000000000050);

-        piVar15 = (int *)((longlong)in_stack_00000090 + (ulonglong)uStack0000000000000054);

-        puVar18 = (undefined8 *)CONCAT44(uStack000000000000006c,uStack0000000000000068);

-        uStack0000000000000064 = uVar22;

-        in_stack_00000098 = piVar13;

-        in_stack_000000b0 = piVar15;

-        in_stack_000000f8 = in_stack_00000090;

-        while ((uint *)puVar18 != &stack0x00000068) {

-          puVar1 = (undefined8 *)*puVar18;

-          piVar21[2] = (int)in_stack_00000098 - (int)in_stack_000000a0;

-          piVar21[3] = *(int *)(puVar18 + -0xb);

-          *piVar21 = (int)in_stack_00000090 - (int)in_stack_000000a0;

-          piVar21[1] = *(uint *)(puVar18 + -3) & 0xffff;

-          piVar21[4] = *(int *)((longlong)puVar18 + -0x6c);

-          piVar21[5] = *(int *)(puVar18 + -0xe);

-          piVar21[6] = *(int *)(puVar18 + -0xd);

-          piVar21[7] = *(int *)((longlong)puVar18 + -0x14);

-          piVar21[8] = *(int *)(puVar18 + -2);

-          piVar21[9] = *(int *)(puVar18 + 2);

-          piVar21[10] = *(int *)((longlong)puVar18 + 0x14);

-          piVar21[0xb] = *(int *)(puVar18 + 3);

-          in_stack_000000b8 = piVar21 + 0xc;

-          RtlCopyMemory(in_stack_00000098,(void *)puVar18[-0xc],(ulonglong)*(uint *)(puVar18 + -0xb)

-                       );

-          piVar21 = in_stack_00000090;

-          in_stack_00000098 =

-               (int *)((longlong)in_stack_00000098 + (ulonglong)*(uint *)(puVar18 + -0xb) + 3 &

-                      0xfffffffffffffffc);

-          if (in_stack_000000f8 < in_stack_00000098) break;

-          RtlStringCchCopyNW(in_stack_00000090,

-                             (longlong)in_stack_000000b0 - (longlong)in_stack_00000090 >> 1,

-                             puVar18[-4],*(uint *)(puVar18 + -3) & 0xffff);

-          in_stack_00000090 =

-               (int *)((ulonglong)((*(uint *)(puVar18 + -3) & 0xffff) + 1) * 2 + (longlong)piVar21);

-          if (in_stack_000000b0 < in_stack_00000090) break;

-          *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) =

-               *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) + -1;

-          lVar9 = KeAbPreAcquire(unaff_R12 + 0x498,0,0);

-          LOCK();

-          puVar14 = (ulonglong *)(unaff_R12 + 0x498);

-          uVar16 = *puVar14;

-          *puVar14 = *puVar14 | 1;

-          UNLOCK();

-          if ((uVar16 & 1) != 0) {

-            ExfAcquirePushLockExclusiveEx(unaff_R12 + 0x498,lVar9,unaff_R12 + 0x498);

-          }

-          if (lVar9 != 0) {

-            *(undefined1 *)(lVar9 + 10) = 1;

-          }

-          *(void **)(unaff_R12 + 0x4a0) = SystemReserved1[0xf];

-          in_stack_00000058[uStack0000000000000064] = puVar18[-5];

-          uStack0000000000000064 = uStack0000000000000064 + 1;

-          puVar18[-5] = unaff_R14;

-          puVar18[-4] = unaff_R14;

-          *(uint *)(puVar18 + -3) = *(uint *)(puVar18 + -3) & 0xffff0000;

-          *(uint *)(puVar18 + -3) = *(uint *)(puVar18 + -3) | 0x80000;

-          *(ulonglong **)(unaff_R12 + 0x4a0) = unaff_R14;

-          LOCK();

-          plVar19 = (longlong *)(unaff_R12 + 0x498);

-          lVar9 = *plVar19;

-          *plVar19 = *plVar19 + -1;

-          UNLOCK();

-          if (((byte)lVar9 & 6) == 2) {

-            ExfTryToWakePushLock(unaff_R12 + 0x498);

-          }

-          KeAbPostRelease(unaff_R12 + 0x498);

-          KiLeaveCriticalRegionUnsafe(SystemReserved1[0xf]);

-          if (puVar18[-10] == 1) {

-            LOCK();

-            *(int *)(unaff_R12 + 0x664) = *(int *)(unaff_R12 + 0x664) + 1;

-            UNLOCK();

-          }

-          LOCK();

-          *(uint *)((longlong)puVar18 + -0xc) = uVar22;

-          UNLOCK();

-          puVar18 = puVar1;

-          piVar21 = in_stack_000000b8;

-        }

-        puVar18 = in_stack_000000c0;

-        uVar4 = *(undefined8 *)(unaff_R12 + 0x464);

-        *in_stack_000000c0 = *(undefined8 *)(unaff_R12 + 0x45c);

-        in_stack_000000c0[1] = uVar4;

-        uVar4 = *(undefined8 *)(unaff_R12 + 0x474);

-        in_stack_000000c0[2] = *(undefined8 *)(unaff_R12 + 0x46c);

-        in_stack_000000c0[3] = uVar4;

-        uVar4 = *(undefined8 *)(unaff_R12 + 0x484);

-        in_stack_000000c0[4] = *(undefined8 *)(unaff_R12 + 0x47c);

-        in_stack_000000c0[5] = uVar4;

-        in_stack_000000c0[6] = *(undefined8 *)(unaff_R12 + 0x48c);

-        *(undefined4 *)(in_stack_000000c0 + 7) = *(undefined4 *)(unaff_R12 + 0x494);

-        *(undefined8 *)(unaff_R12 + 0x45c) = 0;

-        *(undefined8 *)(unaff_R12 + 0x464) = 0;

-        *(undefined8 *)(unaff_R12 + 0x46c) = 0;

-        *(undefined8 *)(unaff_R12 + 0x474) = 0;

-        *(undefined8 *)(unaff_R12 + 0x47c) = 0;

-        *(undefined8 *)(unaff_R12 + 0x484) = 0;

-        *(undefined8 *)(unaff_R12 + 0x48c) = 0;

-        *(undefined4 *)(unaff_R12 + 0x494) = 0;

-        _uStack0000000000000170 = 0;

-        _uStack0000000000000178 = 0;

-        _uStack0000000000000180 = 0;

-        _uStack0000000000000188 = 0;

-        EtwpCovSampCaptureFlushStats(in_stack_00000078);

-        *(undefined4 *)((longlong)puVar18 + 0x1c) = uStack0000000000000170;

-        *(undefined4 *)(puVar18 + 4) = uStack0000000000000174;

-        *(undefined4 *)((longlong)puVar18 + 0x24) = uStack0000000000000178;

-        *(undefined4 *)(puVar18 + 5) = uStack000000000000017c;

-        *(undefined4 *)((longlong)puVar18 + 0x2c) = uStack0000000000000180;

-        *(undefined4 *)(puVar18 + 6) = uStack0000000000000184;

-        *(undefined4 *)((longlong)puVar18 + 0x34) = uStack0000000000000188;

-        *(undefined4 *)(puVar18 + 7) = uStack000000000000018c;

-        *(int *)((longlong)in_stack_000000a0 + 4) = (int)piVar15 - (int)in_stack_000000a0;

-        plVar19 = (longlong *)unaff_R15[0xd2];

-        while (plVar19 != unaff_R15 + 0xd2) {

-          plVar12 = (longlong *)*plVar19;

-          in_stack_00000100 = plVar19;

-          if (plVar19 == (longlong *)unaff_R15[0xd0]) {

-            memset((void *)plVar19[3],0,(ulonglong)*(uint *)((longlong)plVar19 + 0x14) << 3);

-            *(uint *)(plVar19 + 2) = uVar22;

-            plVar19 = plVar12;

-          }

-          else {

-            puVar18 = (undefined8 *)plVar19[1];

-            if (((longlong *)plVar12[1] != plVar19) || ((longlong *)*puVar18 != plVar19))

-            goto LAB_4;

-            *puVar18 = plVar12;

-            plVar12[1] = (longlong)puVar18;

-            *(int *)(unaff_R15 + 0xd4) = (int)unaff_R15[0xd4] + -1;

-            if (plVar19[3] != 0) {

-              ExFreePoolWithTag(plVar19[3],0x56777445);

-              plVar19[3] = (longlong)unaff_R14;

-            }

-            ExFreePoolWithTag(plVar19);

-            plVar19 = plVar12;

-          }

-        }

-        *(int *)((longlong)unaff_R15 + 0x6bc) = *(int *)((longlong)unaff_R15 + 0x6bc) + 1;

-        if (*(int *)(in_stack_00000078 + 0x504) != 0) {

-          *(uint *)(in_stack_00000078 + 0x504) = uVar22;

-          for (puVar18 = *(undefined8 **)(in_stack_00000078 + 0x3b0);

-              puVar18 != (undefined8 *)(in_stack_00000078 + 0x3b0); puVar18 = (undefined8 *)*puVar18

-              ) {

-            *(undefined4 *)((longlong)puVar18 + 0x1c) = *(undefined4 *)(in_stack_00000078 + 0x504);

-          }

-        }

-        unaff_R15[1] = (longlong)unaff_R14;

-        LOCK();

-        lVar9 = *unaff_R15;

-        *unaff_R15 = *unaff_R15 + -1;

-        UNLOCK();

-        if (((byte)lVar9 & 6) == 2) {

-          ExfTryToWakePushLock();

-        }

-        KeAbPostRelease();

-        KiLeaveCriticalRegionUnsafe(SystemReserved1[0xf]);

-        EtwpCovSampContextPruneModules();

-        *in_stack_000000c8 = uStack00000000000000e8;

-        uVar16 = (ulonglong)uStack0000000000000030;

-        uVar17 = uVar22;

+          }

+        }

+LAB_1:

+        uVar13 = 1;

+LAB_2:

+        EtwpReleaseLoggerContext(piVar9,uVar13);

         goto LAB_3;

       }

     }

+    else {

+      if (iVar7 == 0) {

+        *puVar15 = 8;

+        if (param_2 != 8) {

+          return 0xc0000004;

+        }

+        param_1[1] = 0x55;

+        return 0;

+      }

+      if (iVar7 == 1) {

+        *puVar15 = 0x30;

+        if (param_2 != 0x30) {

+          return 0xc0000004;

+        }

+        local_38 = *(int **)(param_1 + 2);

+        uVar14 = (ulonglong)local_38 & 0xffff;

+        if ((int)uVar14 == 0xffff) {

+          uVar14 = (ulonglong)*(byte *)(lVar8 + 0x1198);

+        }

+        *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) =

+             *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) + -1;

+        piVar9 = (int *)EtwpAcquireLoggerContextByLoggerId(lVar8,uVar14,1);

+        local_40 = piVar9;

+        if (piVar9 != (int *)0x0) {

+          if ((piVar9[3] & 0x2000000U) == 0) {

+            EtwpReleaseLoggerContext(piVar9,1);

+            KeLeaveCriticalRegion();

+            return 0xc000000d;

+          }

+          lVar11 = (ulonglong)*(byte *)((longlong)piVar9 + 0x332) * 0x20;

+          piVar10 = (int *)(lVar11 + 0x11cc + lVar8);

+          iVar7 = piVar10[1];

+          iVar6 = piVar10[2];

+          iVar1 = piVar10[3];

+          param_1[4] = *piVar10;

+          param_1[5] = iVar7;

+          param_1[6] = iVar6;

+          param_1[7] = iVar1;

+          piVar10 = (int *)(lVar11 + 0x11dc + lVar8);

+          iVar7 = piVar10[1];

+          iVar6 = piVar10[2];

+          iVar1 = piVar10[3];

+          param_1[8] = *piVar10;

+          param_1[9] = iVar7;

+          param_1[10] = iVar6;

+          param_1[0xb] = iVar1;

+          EtwpMapEnableFlags(param_1 + 4,0);

+          uVar14 = uVar12;

+          goto LAB_1;

+        }

+      }

+      else {

+        if (iVar7 == 2) {

+          *puVar15 = 0x10;

+          if (param_2 != 0x10) {

+            return 0xc0000004;

+          }

+          lVar8 = PsGetCurrentServerSiloGlobals();

+          *(undefined8 *)(param_1 + 2) = *(undefined8 *)(*(longlong *)(lVar8 + 0x340) + 0x1138);

+          return 0;

+        }

+        if (iVar7 == 3) {

+          *puVar15 = 8;

+          if (param_2 != 8) {

+            return 0xc0000004;

+          }

+          param_1[1] = EtwpProfileInterval;

+          return 0;

+        }

+        if (iVar7 != 4) {

+          if (iVar7 != 5) {

+            return 0xc0000002;

+          }

+          *puVar15 = 0x14;

+          if ((uVar3 - 0x10 & 0xfffffffb) != 0) {

+            return 0xc0000004;

+          }

+          param_1[1] = EtwpSpinLockSpinThreshold;

+          param_1[2] = EtwpSpinLockAcquireSampleRate;

+          param_1[3] = EtwpSpinLockContentionSampleRate;

+          if (param_2 == 0x14) {

+            param_1[4] = EtwpSpinLockHoldThreshold;

+            return 0;

+          }

+          return 0;

+        }

+        *puVar15 = 0x18;

+        if (param_2 < 0x18) {

+          return 0xc0000004;

+        }

+        local_38 = *(int **)(param_1 + 2);

+        local_58[0] = param_1[1];

+        uVar12 = (ulonglong)local_38 & 0xffff;

+        if ((int)uVar12 == 0xffff) {

+          uVar12 = (ulonglong)*(byte *)(lVar8 + 0x1198);

+        }

+        *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) =

+             *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) + -1;

+        piVar9 = (int *)EtwpAcquireLoggerContextByLoggerId(lVar8,uVar12,0);

+        if (piVar9 != (int *)0x0) {

+          piVar10 = (int *)EtwpReferenceLoggerSecurityDescriptor(piVar9);

+          local_res10[0] = param_2 - 0x10;

+          local_40 = piVar10;

+          uVar3 = SeQuerySecurityDescriptorInfo(local_58,param_1 + 4,local_res10,&local_40);

+          uVar14 = (ulonglong)uVar3;

+          *param_4 = local_res10[0] + 0x10;

+          EtwpDereferenceLoggerSecurityDescriptor(piVar9,piVar10);

+          uVar13 = 0;

+          goto LAB_2;

+        }

+      }

+    }

   }

   else {

-    uVar17 = 0xc0000095;

-  }

-LAB_2:

-  uVar16 = (ulonglong)uStack0000000000000030;

-  in_stack_00000058 = unaff_R14;

-  goto LAB_3;

-LAB_1:

-  in_stack_00000038 = (undefined8 *)*param_2;

-  if ((*(uint *)((longlong)param_2 + 0x3c) == uVar22) && ((*(uint *)(param_2 + 6) & 0x100000) == 0))

-  goto LAB_0;

-  if ((ulonglong *)param_2[4] == unaff_R14) goto LAB_5;

-  uStack0000000000000030 = uStack0000000000000030 + 1;

-  uStack0000000000000034 = uStack0000000000000034 + 1;

-  uVar7 = (*(uint *)(param_2 + 6) & 0xffff) * 2 + 2;

-  uVar5 = uStack0000000000000054 + uVar7;

-  uStack0000000000000054 = 0xffffffff;

-  if (uVar5 >= uVar7) {

-    uStack0000000000000054 = uVar5;

-  }

-  uVar17 = -(uint)(uVar5 < uVar7) & 0xc0000095;

-  if (uVar7 <= uVar5) {

-    uVar5 = (*(int *)(param_2 + -2) - (*(int *)(param_2 + -2) - 1U & 3)) + 3;

-    uVar7 = uStack0000000000000050 + uVar5;

-    uStack0000000000000050 = 0xffffffff;

-    if (uVar7 >= uVar5) {

-      uStack0000000000000050 = uVar7;

-    }

-    uVar17 = -(uint)(uVar7 < uVar5) & 0xc0000095;

-    if (uVar5 <= uVar7) {

-      plVar12 = param_2 + 9;

-      uStack0000000000000060 = uStack0000000000000030;

-      if ((uint *)*plVar19 != &stack0x00000068) goto LAB_4;

-      *plVar12 = (longlong)&stack0x00000068;

-      param_2[10] = plVar19;

-      *plVar19 = (longlong)plVar12;

-      plVar19 = plVar12;

-      in_stack_00000070 = plVar12;

+    if (iVar7 == 7) {

+      *puVar15 = 0x10;

+      if (param_2 != 0x10) {

+        return 0xc0000004;

+      }

+      param_1[1] = EtwpExecutiveResourceReleaseSampleRate;

+      param_1[2] = EtwpExecutiveResourceContentionSampleRate;

+      param_1[3] = EtwpExecutiveResourceTimeout;

+      return 0;

+    }

+    if ((iVar7 == 8) || (iVar7 == 9)) {

+      if (param_2 < 8) {

+        return 0xc0000004;

+      }

+      cVar2 = PsIsCurrentThreadInServerSilo();

+      if (cVar2 != '\0') {

+        return 0xc0000022;

+      }

+      uVar3 = param_2 - 4 >> 2;

+      piVar9 = (int *)0x0;

+      while( true ) {

+        piVar9 = (int *)PsGetNextProcess(piVar9);

+        uVar4 = (uint)uVar12;

+        if (piVar9 == (int *)0x0) break;

+        local_40 = piVar9;

+        if (((piVar9[0x17f] & 0x1000U) == 0) &&

+           ((iVar7 == 9 || (cVar2 = EtwpUMGLEnabled(piVar9), cVar2 != '\0')))) {

+          iVar6 = PsGetProcessId(piVar9);

+          if (uVar4 < uVar3) {

+            param_1[uVar12 + 1] = iVar6;

+          }

+          uVar12 = (ulonglong)(uVar4 + 1);

+        }

+      }

+      *param_4 = uVar4 * 4 + 4;

+      return (ulonglong)(-(uint)(uVar3 < uVar4) & 0xc0000023);

+    }

+    if (iVar7 != 10) {

+      if (iVar7 != 0xc) {

+        if (iVar7 != 0xd) {

+          return 0xc0000002;

+        }

+        local_40 = (int *)0x0;

+        local_50 = 0;

+        if (param_2 < 0x28) {

+          return 0xc0000004;

+        }

+        ppiVar18 = &local_40;

+        plVar17 = &local_50;

+        uVar12 = ExLockUserBuffer(param_1 + 2,param_2 - 8);

+        if ((int)uVar12 < 0) {

+          return uVar12;

+        }

+        uVar3 = (*(code *)PTR_xHalQuerySystemInformation_140e00708)

+                          (0x14,param_2 - 8,local_50,param_4,plVar17,ppiVar18);

+        if (local_50 != 0) {

+          ExUnlockUserBuffer(local_40);

+          return (ulonglong)uVar3;

+        }

+        return (ulonglong)uVar3;

+      }

+      uVar3 = EtwpGetPmcProfileSource(param_1);

       goto LAB_0;

     }

-  }

-  goto LAB_2;

-LAB_5:

-  bVar23 = param_2[-1] == 1;

-  goto code_r0x000140946490;

-LAB_4:

-  pcVar3 = (code *)swi(0x29);

-  uVar17 = (*pcVar3)(3);

-  register0x00000020 = (BADSPACEBASE *)local_res8;

-  unaff_R14 = (ulonglong *)0x0;

-  _uStack0000000000000088 = in_stack_000000b0;

-  uVar16 = (ulonglong)uStack0000000000000068;

-  unaff_R15 = (longlong *)CONCAT44(uStack00000000000000ec,uStack00000000000000e8);

-  in_stack_00000058 = (ulonglong *)CONCAT44(uStack0000000000000064,uStack0000000000000060);

-  unaff_R12 = in_stack_000000e0;

+    local_38 = param_1 + 4;

+    if (param_2 < 0x10) {

+      return 0xc0000004;

+    }

+    cVar2 = PsIsCurrentThreadInServerSilo();

+    if (cVar2 != '\0') {

+      return 0xc0000022;

+    }

+    local_40 = *(int **)(param_1 + 2);

+    uVar12 = (ulonglong)local_40 & 0xffff;

+    if ((int)uVar12 == 0xffff) {

+      uVar12 = (ulonglong)*(byte *)(lVar8 + 0x1198);

+    }

+    *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) =

+         *(short *)((longlong)SystemReserved1[0xf] + 0x1e4) + -1;

+    piVar9 = (int *)EtwpAcquireLoggerContextByLoggerId(lVar8,uVar12,1);

+    local_40 = piVar9;

+    if (piVar9 != (int *)0x0) {

+      if ((piVar9[3] & 0x2000000U) == 0) {

+        EtwpReleaseLoggerContext(piVar9,1);

+        uVar14 = 0xc000000d;

+        goto LAB_3;

+      }

+      uVar3 = EtwpCheckSystemTraceAccess(piVar9,1);

+      uVar14 = (ulonglong)uVar3;

+      if (-1 < (int)uVar3) {

+        uVar12 = (ulonglong)*(byte *)((longlong)piVar9 + 0x332);

+        uVar3 = (uint)*(ushort *)(&EtwpPoolTagFilter + uVar12 * 0x14) * 4 + 0x10;

+        *param_4 = uVar3;

+        if (param_2 < uVar3) {

+          uVar14 = 0xc0000023;

+        }

+        else {

+          RtlCopyMemory(local_38,&DAT_4 + uVar12 * 0x14,

+                        (ulonglong)*(ushort *)(&EtwpPoolTagFilter + uVar12 * 0x14) << 2);

+        }

+      }

+      goto LAB_1;

+    }

+  }

+  uVar14 = 0xc0000296;

 LAB_3:

-  if (*(void **)(unaff_R12 + 0x4a0) == SystemReserved1[0xf]) {

-    *(ulonglong **)(unaff_R12 + 0x4a0) = unaff_R14;

-    LOCK();

-    plVar19 = (longlong *)(unaff_R12 + 0x498);

-    lVar9 = *plVar19;

-    *plVar19 = *plVar19 + -1;

-    UNLOCK();

-    if (((byte)lVar9 & 6) == 2) {

-      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140946f28;

-      ExfTryToWakePushLock(unaff_R12 + 0x498);

-    }

-    *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140946f35;

-    KeAbPostRelease(unaff_R12 + 0x498);

-    *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140946f43;

-    KiLeaveCriticalRegionUnsafe(SystemReserved1[0xf]);

-  }

-  if ((void *)unaff_R15[1] == SystemReserved1[0xf]) {

-    unaff_R15[1] = (longlong)unaff_R14;

-    LOCK();

-    lVar9 = *unaff_R15;

-    *unaff_R15 = *unaff_R15 + -1;

-    UNLOCK();

-    if (((byte)lVar9 & 6) == 2) {

-      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140946f6e;

-      ExfTryToWakePushLock(unaff_R15);

-    }

-    *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140946f76;

-    KeAbPostRelease(unaff_R15);

-    *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140946f84;

-    KiLeaveCriticalRegionUnsafe(SystemReserved1[0xf]);

-  }

-  if (in_stack_00000058 != (ulonglong *)0x0) {

-    puVar14 = in_stack_00000058;

-    if ((int)uVar16 != 0) {

-      do {

-        uVar2 = *puVar14;

-        if (uVar2 != 0) {

-          if ((uVar2 & 1) == 0) {

-            if ((uVar2 & 0xfffffffffffffff8) != 0) {

-              *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140946fbf;

-              ExFreePool();

-            }

-          }

-          else {

-            pcVar3 = *(code **)(FltMgrCallbacks + 0x20);

-            *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140946fb3;

-            (*pcVar3)();

-          }

-          *puVar14 = (ulonglong)unaff_R14;

-        }

-        uVar16 = uVar16 - 1;

-        puVar14 = puVar14 + 1;

-      } while (uVar16 != 0);

-    }

-    *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140946fd9;

-    ExFreePoolWithTag(in_stack_00000058,0x56777445);

-  }

-  if (*(longlong *)((longlong)register0x00000020 + 0x80) != 0) {

-    uVar16 = DAT_6 & 0xfffffffffffffffe;

-    LOCK();

-    bVar23 = uVar16 != DAT_6;

-    uVar16 = uVar16 - 2;

-    if (bVar23) {

-      uVar16 = DAT_6;

-    }

-    DAT_6 = uVar16;

-    UNLOCK();

-    if (bVar23) {

-      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140947011;

-      ExReleaseRundownProtection(&DAT_6);

-    }

-    *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14094701f;

-    KiLeaveCriticalRegionUnsafe(SystemReserved1[0xf]);

-  }

-  *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140947031;

-  return uVar17;

+  KeLeaveCriticalRegion();

+  return uVar14;

 }
```

## `MiTrimSharedPageFromViews`  (modified)

```diff
--- MiTrimSharedPageFromViews
+++ MiTrimSharedPageFromViews
@@ -1,12 +1,654 @@
 

-void MiTrimSharedPageFromViews(void)

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+

+longlong *

+MiTrimSharedPageFromViews

+          (undefined8 *param_1,int param_2,uint param_3,longlong param_4,ulonglong *param_5)

 

 {

-  char unaff_R13B;

+  ulonglong *puVar1;

+  short *psVar2;

+  ulonglong uVar3;

+  ulonglong uVar4;

+  uint uVar5;

+  byte bVar6;

+  char cVar7;

+  int iVar8;

+  longlong lVar9;

+  longlong *plVar10;

+  longlong *plVar11;

+  longlong *plVar12;

+  undefined2 *puVar13;

+  byte bVar14;

+  undefined8 *puVar15;

+  undefined *puVar16;

+  uint uVar17;

+  ulonglong uVar18;

+  longlong *plVar19;

+  longlong lVar20;

+  longlong *plVar21;

+  ulonglong *puVar22;

+  bool bVar23;

+  ulonglong in_CR8;

+  undefined4 extraout_XMM0_Da;

+  undefined8 unaff_retaddr;

+  undefined1 auStack_1e8 [32];

+  undefined8 *local_1c8;

+  undefined1 local_1b8;

+  longlong *local_1b0;

+  uint local_1a8;

+  undefined4 local_1a4;

+  longlong local_1a0;

+  longlong *local_198;

+  longlong *local_190;

+  longlong *local_188;

+  longlong local_180;

+  longlong *local_178;

+  longlong local_170;

+  int local_168;

+  int local_164;

+  void *local_160;

+  ulonglong local_158;

+  longlong local_150;

+  undefined8 *local_148;

+  ulonglong *local_140;

+  undefined8 *local_138;

+  undefined8 local_130;

+  undefined8 local_128;

+  undefined8 uStack_120;

+  undefined8 local_118;

+  longlong *plStack_110;

+  undefined8 local_108;

+  undefined8 uStack_100;

+  undefined8 local_f8;

+  undefined8 uStack_f0;

+  undefined8 local_e8;

+  undefined8 uStack_e0;

+  undefined8 local_d8;

+  undefined8 uStack_d0;

+  undefined8 local_c8;

+  undefined8 uStack_c0;

+  undefined8 local_b8;

+  undefined8 uStack_b0;

+  undefined8 local_a8;

+  undefined8 uStack_a0;

+  undefined8 local_98;

+  undefined8 uStack_90;

+  undefined8 local_88;

+  undefined8 uStack_80;

+  undefined8 local_78;

+  undefined8 uStack_70;

+  undefined8 local_68;

+  undefined8 uStack_60;

+  undefined8 local_58;

+  undefined8 uStack_50;

+  ulonglong local_48;

   

-  if (unaff_R13B == '\0') {

-    HalRequestSoftwareInterrupt(2);

+  local_48 = __security_cookie ^ (ulonglong)auStack_1e8;

+  plVar11 = (longlong *)0x0;

+  local_140 = param_5;

+  local_1b0 = (longlong *)0x0;

+  local_1a8 = 0;

+  local_130 = 0;

+  local_178 = (longlong *)0x0;

+  local_1b8 = 0x11;

+  local_190 = (longlong *)0x0;

+  local_198 = (longlong *)0x0;

+  local_188 = (longlong *)0x0;

+  local_a8 = 0;

+  uStack_a0 = 0;

+  local_98 = 0;

+  uStack_90 = 0;

+  local_88 = 0;

+  uStack_80 = 0;

+  local_160 = SystemReserved1[0xf];

+  local_128 = 0;

+  uStack_120 = 0;

+  local_118 = 0;

+  plStack_110 = (longlong *)0x0;

+  local_108 = 0;

+  uStack_100 = 0;

+  local_f8 = 0;

+  uStack_f0 = 0;

+  local_e8 = 0;

+  uStack_e0 = 0;

+  local_d8 = 0;

+  uStack_d0 = 0;

+  local_c8 = 0;

+  uStack_c0 = 0;

+  local_b8 = 0;

+  uStack_b0 = 0;

+  plVar10 = plVar11;

+  plVar21 = plVar11;

+  local_170 = param_4;

+  local_164 = param_2;

+  if (param_1 != (undefined8 *)0x0) {

+    do {

+      local_138 = (undefined8 *)*param_1;

+      local_1a4 = 0;

+      local_158 = param_1[3];

+      local_1a0 = param_1[1];

+      uVar18 = param_1[2];

+      lVar9 = param_1[4];

+      local_150 = (local_158 >> 0xc) - (uVar18 >> 0xc);

+      local_168 = 0;

+      local_148 = param_1;

+      if ((local_1a0 == 0) || (local_1a0 == *(longlong *)((longlong)SystemReserved1[0xf] + 0xb8))) {

+        if ((*(uint *)(param_1 + 5) < 2) || (*(uint *)(param_1 + 5) == 3)) goto LAB_0;

+        if ((param_3 & 6) == 0) {

+          *(short *)((longlong)local_160 + 0x1e6) = *(short *)((longlong)local_160 + 0x1e6) + -1;

+          lVar20 = KeAbPreAcquire(&DAT_1,0,0);

+          LOCK();

+          bVar23 = DAT_1 == 0;

+          if (bVar23) {

+            DAT_1 = 0x11;

+          }

+          UNLOCK();

+          if (!bVar23) {

+            ExfAcquirePushLockSharedEx(&DAT_1,0,lVar20);

+          }

+          if (lVar20 != 0) {

+            *(undefined1 *)(lVar20 + 10) = 1;

+          }

+          puVar15 = DAT_2;

+          if (DAT_2 != (undefined8 *)0x0) {

+            do {

+              if (uVar18 < puVar15[4] + (puVar15[0xb] & 0xfffffffffffff000)) {

+                if ((puVar15[0xb] & 0xfffffffffffff000) <= uVar18) break;

+                puVar15 = (undefined8 *)*puVar15;

+              }

+              else {

+                puVar15 = (undefined8 *)puVar15[1];

+              }

+            } while (puVar15 != (undefined8 *)0x0);

+            if (((puVar15 != (undefined8 *)0x0) &&

+                (local_178 = (longlong *)puVar15[6], *local_178 == local_170)) &&

+               ((puVar15[3] * 0x1000 - lVar9) + uVar18 == (puVar15[0xb] & 0xfffffffffffff000))) {

+              local_168 = 1;

+              goto LAB_0;

+            }

+          }

+          LOCK();

+          bVar23 = DAT_1 == 0x11;

+          if (bVar23) {

+            DAT_1 = 0;

+          }

+          UNLOCK();

+          if (!bVar23) {

+            ExfReleasePushLockShared(&DAT_1);

+          }

+          KeAbPostRelease(&DAT_1);

+          psVar2 = (short *)((longlong)local_160 + 0x1e6);

+          *psVar2 = *psVar2 + 1;

+          if ((*psVar2 == 0) &&

+             (*(longlong **)((longlong)local_160 + 0x98) != (longlong *)((longlong)local_160 + 0x98)

+             )) {

+            KiCheckForKernelApcDelivery();

+          }

+        }

+      }

+      else {

+        bVar6 = ExAcquireSpinLockExclusive(&DAT_3);

+        if ((((*(uint *)(local_1a0 + 500) & 0xc00) < 0xc00) ||

+            (*(longlong *)(local_1a0 + 0x468) != 0)) ||

+           ((bVar14 = (byte)((uint)*(undefined4 *)(local_1a0 + 0x4b8) >> 8), (bVar14 & 0xf0) == 0xf0

+            || (*(ulonglong *)(local_1a0 + 0x490) < 2)))) {

+          local_1a4 = 0;

+        }

+        else {

+          local_1a4._0_2_ =

+               CONCAT11((bVar14 ^ bVar14 + 0x10) & 0xf ^ bVar14 + 0x10,

+                        (char)*(undefined4 *)(local_1a0 + 0x4b8));

+          *(undefined2 *)(local_1a0 + 0x4b8) = (undefined2)local_1a4;

+          local_1a4 = 1;

+        }

+        if (bVar6 == 0x11) {

+          if (((DAT_4._2_1_ & 1) == 0) || (PopHibernateInProgress != 0)) {

+            DAT_3 = 0;

+            uVar4 = in_CR8;

+          }

+          else {

+            ExpReleaseSpinLockExclusiveFromDpcLevelInstrumented(&DAT_3,unaff_retaddr);

+            uVar4 = in_CR8;

+          }

+        }

+        else {

+          if (((DAT_4._2_1_ & 1) == 0) || (PopHibernateInProgress != 0)) {

+            DAT_3 = 0;

+          }

+          else {

+            ExpReleaseSpinLockExclusiveFromDpcLevelInstrumented(&DAT_3,unaff_retaddr);

+          }

+          uVar4 = (ulonglong)bVar6;

+          if (KiIrqlFlags != 0) {

+            KiLowerIrqlProcessIrqlFlags(in_CR8,bVar6);

+          }

+        }

+        in_CR8 = uVar4;

+        if (local_1a4 != 0) {

+          local_78 = 0;

+          uStack_70 = 0;

+          local_68 = 0;

+          uStack_60 = 0;

+          local_58 = 0;

+          uStack_50 = 0;

+          KiStackAttachProcess(local_1a0,1,&local_a8);

+LAB_0:

+          uVar18 = uVar18 - 0x1000;

+          plVar12 = local_1b0;

+          lVar9 = lVar9 + -0x1000;

+          plVar19 = plVar10;

+LAB_5:

+          do {

+            iVar8 = Feature_Servicing_Mm_TrimSharedPageFix__private_IsEnabledDeviceUsageNoInline();

+            plVar10 = plVar19;

+            if (iVar8 == 0) {

+              if (local_158 <= uVar18 + 0x1000) break;

+            }

+            else {

+              if (local_150 == 0) break;

+              local_150 = local_150 + -1;

+            }

+            uVar18 = uVar18 + 0x1000;

+            local_180 = lVar9 + 0x1000;

+            if ((plVar19 != (longlong *)0x0) &&

+               ((longlong *)((ulonglong)((uint)(uVar18 >> 0x12) & 0x3ffffff8) - 0x904c0000000) !=

+                plVar21)) {

+              if (plVar12 != (longlong *)0x0) {

+                if ((*(int *)((longlong)plVar12 + 0x1c) != 0) &&

+                   (lVar9 = MiFreeWsleList(plVar19,plVar12,0), lVar9 != 0)) {

+                  local_1a8 = 0x115;

+                }

+                local_1b0 = (longlong *)0x0;

+              }

+              if (local_190 != (longlong *)0x0) {

+                MiFlushTbList(local_190);

+                local_190 = (longlong *)0x0;

+              }

+              if (plVar11 != (longlong *)0x0) {

+                puVar16 = &MxTempPrcb;

+                if (*(undefined **)((longlong)FiberData + 0x8838) != (undefined *)0x0) {

+                  puVar16 = *(undefined **)((longlong)FiberData + 0x8838);

+                }

+                *(undefined8 *)

+                 (puVar16 + ((ulonglong)(*(int *)(puVar16 + 0x15c) - 1) * 0xa0f + 0xa3e) * 8) = 0;

+                *(int *)(puVar16 + 0x15c) = *(int *)(puVar16 + 0x15c) + -1;

+                plVar11 = (longlong *)0x0;

+              }

+              if (local_1a0 == 0) {

+                if (plStack_110 != (longlong *)0x0) {

+                  MiReleaseFaultState(&plStack_110,0x11);

+                  plVar19 = (longlong *)0x0;

+                  plStack_110 = (longlong *)0x0;

+                  local_188 = (longlong *)0x0;

+                  local_198 = (longlong *)0x0;

+                  plVar21 = plVar19;

+                  goto LAB_6;

+                }

+              }

+              else {

+                if (plVar21 != (longlong *)0x0) {

+                  MiUnlockPageTableInternal(plVar19,plVar21);

+                }

+                MiUnlockWorkingSetShared(plVar19,local_1b8);

+              }

+              plVar21 = (longlong *)0x0;

+              local_188 = (longlong *)0x0;

+              plVar19 = (longlong *)0x0;

+              local_198 = (longlong *)0x0;

+            }

+LAB_6:

+            lVar9 = local_1a0;

+            uVar17 = 0;

+            if (local_1a0 == 0) {

+              uVar5 = (uint)(uVar18 >> 0x20);

+              if (plVar19 == (longlong *)0x0) {

+                plVar10 = plVar19;

+                if (uVar18 < 0xffff800000000000) goto LAB_7;

+                bVar6 = (&DAT_8)[(uVar5 >> 7 & 0x1ff) - 0x100];

+                if (((0x11 < bVar6) || ((0x208a0U >> (bVar6 & 0x1f) & 1) == 0)) ||

+                   (plVar10 = (longlong *)MiSystemVaTypeToVm(bVar6), lVar9 = local_1a0,

+                   local_198 = plVar10, plVar10 == (longlong *)0x0)) goto LAB_7;

+                local_1c8 = &local_128;

+                iVar8 = MiSynchronizeSystemVa(plVar10,uVar18);

+                plVar19 = plStack_110;

+                plVar12 = plVar21;

+                if (iVar8 == 0) goto LAB_9;

+                local_198 = plStack_110;

+                if (((param_3 & 1) != 0) && (local_190 == (longlong *)0x0)) {

+                  if (plVar11 == (longlong *)0x0) {

+                    plVar11 = (longlong *)MiGetProcessorFlushList();

+                  }

+                  *plVar11 = (longlong)plStack_110;

+                  *(undefined4 *)(plVar11 + 2) = 0;

+                  *(undefined4 *)((longlong)plVar11 + 0x14) = 10;

+                  *(byte *)(plVar11 + 3) = (byte)((uint)(int)plVar19[0x17] >> 8) >> 3 & 1;

+                  if (((*(uint *)(plStack_110 + 0x17) & 0xf) == 0) &&

+                     (plStack_110 !=

+                      (longlong *)(*(longlong *)((longlong)SystemReserved1[0xf] + 0xb8) + 0x400))) {

+                    *(uint *)(plVar11 + 2) = *(uint *)(plVar11 + 2) | 9;

+                  }

+                  else {

+                    uVar17 = (uint)((*(uint *)(plStack_110 + 0x17) & 0xf) == 0);

+                  }

+                  *(uint *)(plVar11 + 2) = *(uint *)(plVar11 + 2) & 0xffffffdb;

+                  *(uint *)(plVar11 + 1) = uVar17;

+                  *(undefined2 *)((longlong)plVar11 + 0x19) = 0;

+                  *(undefined4 *)((longlong)plVar11 + 0x1c) = 0;

+                  plVar11[4] = 0;

+                  plVar11[5] = 0;

+                  local_190 = plVar11;

+                }

+                plVar21 = (longlong *)

+                          ((ulonglong)((uint)(uVar18 >> 0x12) & 0x3ffffff8) - 0x904c0000000);

+                local_188 = plVar21;

+LAB_10:

+                uVar17 = (uint)(byte)(&DAT_8)[(uVar5 >> 7 & 0x1ff) - 0x100];

+              }

+              else if (0xffff7fffffffffff < uVar18) goto LAB_10;

+              puVar15 = local_148;

+              if (*(int *)(local_148 + 5) == 0) {

+                plVar10 = plVar19;

+                if ((((uVar17 != 7) || (lVar9 = MiGetSystemCacheReverseMap(uVar18), lVar9 == 0)) ||

+                    (plVar12 = (longlong *)MiGetMultiplexedVm(extraout_XMM0_Da,uVar18),

+                    plVar19 != plVar12)) ||

+                   ((byte)((ulonglong)*(undefined8 *)(lVar9 + 0x20) >> 0x3e) != 3)) break;

+                local_178 = *(longlong **)(lVar9 + 0x18);

+                if (((ulonglong)local_178 & 1) != 0) {

+                  local_178 = (longlong *)((ulonglong)local_178 & 0xfffffffffffffffe);

+                }

+                if ((*local_178 != local_170) ||

+                   ((ulonglong)((uint)uVar18 & 0x3ffff) +

+                    (*(ulonglong *)(lVar9 + 0x20) & 0xffffffffffff0000) * 4 != local_180)) break;

+              }

+            }

+            else {

+              if (plVar19 == (longlong *)0x0) {

+                plVar19 = (longlong *)(local_1a0 + 0x400);

+                local_198 = plVar19;

+                local_1b8 = MiLockWorkingSetShared(plVar19);

+                if (((param_3 & 1) != 0) && (local_190 == (longlong *)0x0)) {

+                  if (plVar11 == (longlong *)0x0) {

+                    plVar11 = (longlong *)MiGetProcessorFlushList();

+                  }

+                  *(undefined4 *)(plVar11 + 2) = 0;

+                  *(undefined4 *)((longlong)plVar11 + 0x14) = 10;

+                  *plVar11 = (longlong)plVar19;

+                  *(byte *)(plVar11 + 3) =

+                       (byte)((uint)*(undefined4 *)(lVar9 + 0x4b8) >> 8) >> 3 & 1;

+                  if (((*(uint *)(lVar9 + 0x4b8) & 0xf) == 0) &&

+                     (plVar19 !=

+                      (longlong *)(*(longlong *)((longlong)SystemReserved1[0xf] + 0xb8) + 0x400))) {

+                    *(uint *)(plVar11 + 2) = *(uint *)(plVar11 + 2) | 9;

+                  }

+                  else {

+                    uVar17 = (uint)((*(uint *)(lVar9 + 0x4b8) & 0xf) == 0);

+                  }

+                  *(uint *)(plVar11 + 2) = *(uint *)(plVar11 + 2) & 0xffffffdb;

+                  *(uint *)(plVar11 + 1) = uVar17;

+                  *(undefined2 *)((longlong)plVar11 + 0x19) = 0;

+                  *(undefined4 *)((longlong)plVar11 + 0x1c) = 0;

+                  plVar11[4] = 0;

+                  plVar11[5] = 0;

+                  local_190 = plVar11;

+                }

+              }

+              MiLockVadTree(1);

+              lVar9 = MiLocateAddress(uVar18);

+              plVar10 = plVar19;

+              if ((((lVar9 == 0) || ((*(uint *)(lVar9 + 0x30) >> 0x15 & 1) != 0)) ||

+                  (((*(uint *)(local_170 + 0x38) & 0x20) == 0 &&

+                   ((*(uint *)(lVar9 + 0x30) & 0x70) != 0)))) ||

+                 (local_178 = *(longlong **)(lVar9 + 0x48), *local_178 != local_170)) {

+LAB_11:

+                lVar9 = *(longlong *)(*(longlong *)((longlong)SystemReserved1[0xf] + 0xb8) + 0x410);

+                if (((DAT_4._2_1_ & 1) == 0) || (PopHibernateInProgress != 0)) {

+                  LOCK();

+                  *(uint *)(lVar9 + 0x3ec) = *(uint *)(lVar9 + 0x3ec) & 0xbfffffff;

+                  UNLOCK();

+                  LOCK();

+                  *(int *)(lVar9 + 0x3ec) = *(int *)(lVar9 + 0x3ec) + -1;

+                  UNLOCK();

+                }

+                else {

+                  ExpReleaseSpinLockSharedFromDpcLevelInstrumented(lVar9 + 0x3ec,unaff_retaddr);

+                }

+                break;

+              }

+              if ((*(uint *)(local_170 + 0x38) & 0x20) == 0) {

+                lVar9 = MiGetProtoPteAddress(lVar9,uVar18 >> 0xc,8);

+                if ((lVar9 == 0) || (local_178 == (longlong *)0x0)) goto LAB_11;

+                lVar9 = MiStartingOffset(local_178,lVar9);

+                if (local_180 != lVar9) {

+                  MiUnlockVadTree(1,0x11);

+                  break;

+                }

+              }

+              else {

+                puVar22 = *(ulonglong **)(lVar9 + 0x50);

+                if ((local_140 < puVar22) ||

+                   (uVar18 = (ulonglong)

+                             CONCAT14(*(undefined1 *)(lVar9 + 0x20),*(undefined4 *)(lVar9 + 0x18)),

+                   puVar22 + (((ulonglong)

+                               CONCAT14(*(undefined1 *)(lVar9 + 0x21),*(undefined4 *)(lVar9 + 0x1c))

+                              + 1) - uVar18) <= local_140)) goto LAB_11;

+                uVar18 = ((longlong)local_140 - (longlong)puVar22 >> 3) * 0x1000 + uVar18 * 0x1000;

+              }

+              MiUnlockVadTree(1,0x11);

+              plVar12 = (longlong *)

+                        (((uVar18 >> 9 & 0x7ffffffff8) - 0x98000000000 >> 9 & 0x7ffffffff8) -

+                        0x98000000000);

+              puVar15 = local_148;

+              if (plVar21 != plVar12) {

+                if (plVar21 != (longlong *)0x0) {

+                  uVar18 = uVar18 - 0x1000;

+                  local_150 = local_150 + 1;

+                  plVar12 = local_1b0;

+                  lVar9 = local_180 + -0x1000;

+                  goto LAB_5;

+                }

+                plVar21 = (longlong *)MiLockLowestValidPageTableEx(plVar19);

+                puVar15 = local_148;

+                local_188 = plVar21;

+                if (plVar21 != plVar12) break;

+              }

+            }

+            puVar22 = (ulonglong *)((uVar18 >> 9 & 0x7ffffffff8) - 0x98000000000);

+            uVar4 = *puVar22;

+            plVar12 = local_1b0;

+            lVar9 = local_180;

+            plVar19 = local_198;

+            plVar21 = local_188;

+            if ((uVar4 & 1) != 0) {

+              lVar20 = (uVar4 >> 0xc & 0xffffffffff) * 0x30;

+              if ((((param_3 & 8) == 0) ||

+                  (((uVar4 & 0x42) == 0 && ((*(byte *)(lVar20 + -0x21ffffffffde) & 0x10) == 0)))) &&

+                 (*(longlong *)(lVar20 + -0x21ffffffffd8) < 0)) {

+                if ((param_3 & 1) == 0) {

+                  if (((*(ulonglong *)(lVar20 + -0x21fffffffff0) & 0x400) != 0) ||

+                     (-1 < (char)*(undefined4 *)(local_170 + 0x38))) {

+                    bVar6 = MiGetWsleContents();

+                    plVar10 = local_198;

+                    if ((*(int *)(puVar15 + 5) != 3) ||

+                       (plVar12 = local_1b0, lVar9 = local_180, plVar19 = plVar10,

+                       plVar21 = local_188, (bVar6 & 0xf) != 9)) {

+                      if (((bVar6 & 0xf) == 8) || ((param_3 & 0x10) != 0)) {

+                        if (((param_3 & 8) != 0) ||

+                           (((local_164 == 0 || (((byte)(int)local_198[0x17] & 0xf) == 1)) ||

+                            (iVar8 = MiReplaceLockedPage(lVar20 + -0x220000000000),

+                            plVar12 = local_1b0, lVar9 = local_180, plVar19 = local_198,

+                            plVar21 = local_188, iVar8 == 0)))) {

+                          local_1a8 = 0x115;

+                          plVar12 = local_1b0;

+                          lVar9 = local_180;

+                          plVar19 = local_198;

+                          plVar21 = local_188;

+                        }

+                      }

+                      else {

+                        if (((byte)(int)local_198[0x17] & 0xf) == 1) {

+                          puVar13 = &MiSystemPartition;

+                        }

+                        else {

+                          puVar13 = *(undefined2 **)

+                                     (DAT_12 +

+                                     (ulonglong)*(ushort *)((longlong)local_198 + 0xae) * 8);

+                        }

+                        if (*(int *)(puVar13 + 0x2216) != 0) {

+                          MI_WSLE_LOG_ACCESS(local_198,puVar22);

+                        }

+                        plVar12 = local_1b0;

+                        if (local_1b0 == (longlong *)0x0) {

+                          if (plVar11 == (longlong *)0x0) {

+                            plVar11 = (longlong *)MiGetProcessorFlushList();

+                          }

+                          plVar12 = plVar11 + 0x205;

+                          local_1c8 = (undefined8 *)CONCAT44(local_1c8._4_4_,1);

+                          local_1b0 = plVar12;

+                          MiInitializeTbFlushList

+                                    (plVar12,plVar10,*(undefined4 *)((longlong)plVar11 + 0x1034));

+                        }

+                        MiInsertTbFlushEntry(plVar12);

+                        lVar9 = local_180;

+                        plVar19 = local_198;

+                        plVar21 = local_188;

+                        if (*(int *)((longlong)plVar12 + 0x1c) == *(int *)((longlong)plVar12 + 0xc))

+                        {

+                          lVar9 = MiFreeWsleList(plVar10);

+                          if (lVar9 != 0) {

+                            local_1a8 = 0x115;

+                          }

+                          local_1b0 = (longlong *)0x0;

+                          plVar12 = (longlong *)0x0;

+                          lVar9 = local_180;

+                          plVar19 = plVar10;

+                          plVar21 = local_188;

+                        }

+                      }

+                    }

+                  }

+                }

+                else if (((*(ulonglong *)(lVar20 + -0x21fffffffff0) & 0x400) != 0) &&

+                        ((uVar4 & 0x42) != 0)) {

+                  uVar17 = 0;

+                  while( true ) {

+                    LOCK();

+                    puVar1 = (ulonglong *)(lVar20 + -0x21ffffffffe8);

+                    uVar3 = *puVar1;

+                    *puVar1 = *puVar1 | 0x8000000000000000;

+                    UNLOCK();

+                    if (-1 < (longlong)uVar3) break;

+                    do {

+                      uVar17 = uVar17 + 1;

+                      if ((((HvlLongSpinCountMask & uVar17) == 0) &&

+                          ((HvlEnlightenments & 0x40) != 0)) &&

+                         (cVar7 = KiCheckVpBackingLongSpinWaitHypercall(), cVar7 != '\0')) {

+                        HvlNotifyLongSpinWait(uVar17);

+                      }

+                    } while (*(longlong *)(lVar20 + -0x21ffffffffe8) < 0);

+                  }

+                  if ((*(byte *)(lVar20 + -0x21ffffffffde) & 0x10) == 0) {

+                    MiSetPfnModified(lVar20 + -0x220000000000,1);

+                  }

+                  LOCK();

+                  *(ulonglong *)(lVar20 + -0x21ffffffffe8) =

+                       *(ulonglong *)(lVar20 + -0x21ffffffffe8) & 0x7fffffffffffffff;

+                  UNLOCK();

+                  MiWriteValidPteNewProtection(puVar22,uVar4 & 0xffffffffffffffbd);

+                  MiInsertTbFlushEntry(local_190);

+                  plVar12 = local_1b0;

+                  lVar9 = local_180;

+                  plVar19 = local_198;

+                  plVar21 = local_188;

+                }

+              }

+            }

+          } while( true );

+        }

+      }

+      lVar9 = local_1a0;

+      plVar12 = plVar21;

+      if (plVar10 != (longlong *)0x0) {

+LAB_9:

+        if (local_1b0 != (longlong *)0x0) {

+          if ((*(int *)((longlong)local_1b0 + 0x1c) != 0) &&

+             (lVar9 = MiFreeWsleList(plVar10,local_1b0,0), lVar9 != 0)) {

+            local_1a8 = 0x115;

+          }

+          local_1b0 = (longlong *)0x0;

+        }

+        plVar21 = (longlong *)0x0;

+        if (local_190 != (longlong *)0x0) {

+          MiFlushTbList(local_190);

+          local_190 = (longlong *)0x0;

+        }

+        lVar9 = local_1a0;

+        if (plVar11 != (longlong *)0x0) {

+          puVar16 = &MxTempPrcb;

+          if (*(undefined **)((longlong)FiberData + 0x8838) != (undefined *)0x0) {

+            puVar16 = *(undefined **)((longlong)FiberData + 0x8838);

+          }

+          *(undefined8 *)

+           (puVar16 + ((ulonglong)(*(int *)(puVar16 + 0x15c) - 1) * 0xa0f + 0xa3e) * 8) = 0;

+          *(int *)(puVar16 + 0x15c) = *(int *)(puVar16 + 0x15c) + -1;

+          plVar11 = plVar21;

+        }

+        if (local_1a0 == 0) {

+          if (plStack_110 != (longlong *)0x0) {

+            MiReleaseFaultState(&plStack_110,0x11,0);

+            plStack_110 = (longlong *)0x0;

+            local_188 = (longlong *)0x0;

+            local_198 = (longlong *)0x0;

+            plVar10 = plVar21;

+            goto LAB_7;

+          }

+        }

+        else {

+          if (plVar12 != (longlong *)0x0) {

+            MiUnlockPageTableInternal(plVar10,plVar12);

+          }

+          MiUnlockWorkingSetShared(plVar10,local_1b8);

+        }

+        local_188 = (longlong *)0x0;

+        local_198 = (longlong *)0x0;

+        plVar10 = plVar21;

+      }

+LAB_7:

+      if (local_168 != 0) {

+        LOCK();

+        bVar23 = DAT_1 == 0x11;

+        if (bVar23) {

+          DAT_1 = 0;

+        }

+        UNLOCK();

+        if (!bVar23) {

+          ExfReleasePushLockShared(&DAT_1);

+        }

+        KeAbPostRelease(&DAT_1);

+        psVar2 = (short *)((longlong)local_160 + 0x1e6);

+        *psVar2 = *psVar2 + 1;

+        if ((*psVar2 == 0) &&

+           (*(longlong **)((longlong)local_160 + 0x98) != (longlong *)((longlong)local_160 + 0x98)))

+        {

+          KiCheckForKernelApcDelivery();

+        }

+      }

+      if (local_1a4 != 0) {

+        KeForceDetachProcess(&local_a8,0);

+        MiAttachThreadDone(lVar9 + 0x400);

+      }

+      if (lVar9 != 0) {

+        ObDereferenceObjectDeferDeleteWithTag(lVar9,0x77566d4d);

+      }

+      ExFreePoolWithTag(local_148,0);

+      if ((local_164 != 0) && ((*local_140 & 1) == 0)) {

+        MiDeleteTrimViewInfoList(local_138);

+        return (longlong *)0x0;

+      }

+      param_1 = local_138;

+    } while (local_138 != (undefined8 *)0x0);

+    plVar11 = (longlong *)(ulonglong)local_1a8;

   }

-  return;

+  return plVar11;

 }
```

## `PoInitSystem`  (modified)

```diff
--- PoInitSystem
+++ PoInitSystem
@@ -1,686 +1,520 @@
 

 /* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

 /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

 

-byte PoInitSystem(int param_1)

+byte PoInitSystem(int param_1,longlong param_2)

 

 {

-  undefined8 uVar1;

-  longlong lVar2;

-  undefined7 uVar3;

-  undefined *puVar4;

-  char cVar5;

-  int iVar6;

-  int iVar7;

-  byte bVar8;

-  ulonglong uVar9;

-  ulonglong uVar10;

-  longlong unaff_RBP;

-  longlong unaff_RDI;

-  byte bVar11;

-  undefined2 uVar12;

-  int unaff_R12D;

-  byte bVar13;

-  undefined2 uVar14;

-  ulonglong unaff_R15;

-  undefined8 in_XMM0_Qa;

-  undefined4 in_XMM0_Dc;

-  undefined4 in_XMM0_Dd;

-  int iVar15;

+  longlong lVar1;

+  char cVar2;

+  uint uVar3;

+  int iVar4;

+  int iVar5;

+  undefined1 uVar6;

+  uint uVar7;

+  int local_res8 [4];

+  undefined4 local_res18 [2];

+  undefined8 local_res20;

+  undefined8 in_stack_ffffffffffffff88;

+  undefined4 uVar8;

+  undefined8 in_stack_ffffffffffffff90;

+  uint uVar9;

+  undefined4 in_stack_ffffffffffffff98;

+  ushort uVar10;

+  undefined8 local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

+  undefined4 local_40;

   

-  uVar10 = (ulonglong)((int)unaff_RDI + 1);

-  *(int *)(unaff_RBP + -0x20) = (int)in_XMM0_Qa;

-  *(int *)(unaff_RBP + -0x1c) = (int)((ulonglong)in_XMM0_Qa >> 0x20);

-  *(undefined4 *)(unaff_RBP + -0x18) = in_XMM0_Dc;

-  *(undefined4 *)(unaff_RBP + -0x14) = in_XMM0_Dd;

-  bVar13 = (byte)unaff_R15;

-  iVar15 = (int)unaff_R15;

-  bVar11 = (byte)unaff_R12D;

-  uVar3 = (undefined7)(unaff_R15 >> 8);

+  uVar9 = (uint)((ulonglong)in_stack_ffffffffffffff90 >> 0x20);

+  uVar8 = (undefined4)((ulonglong)in_stack_ffffffffffffff88 >> 0x20);

+  uVar10 = (ushort)((uint)in_stack_ffffffffffffff98 >> 0x10);

+  iVar4 = 0;

+  local_res20 = 0;

+  local_48 = 0;

+  local_40 = 0;

+  local_58 = 0;

+  uStack_50 = 0;

+  uVar7 = 0;

+  uVar6 = 1;

+  PopOsInitPhase = param_1;

   if (param_1 == 0) {

-    *(undefined8 *)(uVar10 - 8) = 0x140c63afc;

-    KeQueryPerformanceCounter(unaff_RBP + 0x58);

-    uVar1 = *(undefined8 *)(unaff_RBP + 0x58);

-    PopQpcFrequency = uVar1;

-    *(undefined8 *)(uVar10 - 8) = 0x140c63b1a;

-    PopComputeCounterShifts(uVar1,&PpmPerformanceDistributionShift,&PpmPerformanceCounterShift);

-    *(undefined8 *)(uVar10 - 8) = 0x140c63b32;

+    KeQueryPerformanceCounter(&local_res20);

+    PopQpcFrequency = local_res20;

+    PopComputeCounterShifts

+              (local_res20,&PpmPerformanceDistributionShift,&PpmPerformanceCounterShift);

     PopComputeCounterShifts

               (10000000,&PpmHvPerformanceDistributionShift,&PpmHvPerformanceCounterShift);

-    _PopCsResiliencyStatsLock = unaff_R15;

-    *(undefined8 *)(uVar10 - 8) = 0x140c63b40;

+    _PopCsResiliencyStatsLock = 0;

     PopSleepstudyInitialize(0);

-    *(undefined8 *)(uVar10 - 8) = 0x140c63b47;

-    iVar6 = PopPowerAggregatorInitialize(0);

-    if (-1 < iVar6) {

-      *(int *)(uVar10 + 0x38) = iVar15;

+    uVar3 = PopPowerAggregatorInitialize(0);

+    if (-1 < (int)uVar3) {

       _DAT_0 = &DAT_140f0a3e8;

       _DAT_1 = &DAT_1;

-      uVar14 = (undefined2)unaff_R15;

-      *(undefined2 *)(uVar10 + 0x30) = uVar14;

       DAT_2 = &PopIrpList;

       PopIrpList = &PopIrpList;

-      *(undefined4 *)(uVar10 + 0x28) = 0x72496f50;

       DAT_3 = &PopInrushIrpList;

       PopInrushIrpList = &PopInrushIrpList;

-      DAT_4 = 6;

-      _PopDeepSleepDisengageReasonLock = unaff_R15;

-      _PopSystemIdleLock = unaff_R15;

-      _DAT_5 = unaff_R15;

-      _PopPowerEventLock = unaff_R15;

-      _DAT_6 = unaff_R15;

-      _PopIdleLoopExecuted = uVar14;

-      DAT_7 = iVar15;

-      PopIrpLock = unaff_R15;

-      _PopCoalRegistrationListLock = unaff_R15;

-      _DAT_8 = unaff_R15;

-      *(undefined8 *)(uVar10 + 0x20) = 0x138;

-      *(undefined8 *)(uVar10 - 8) = 0x140c63c0f;

-      ExInitializeNPagedLookasideListInternal(&PopIrpDataLookaside,0,0,0x200);

+      _DAT_4 = 0;

+      _PopPowerEventLock = 0;

+      _DAT_5 = 0;

+      _PopSystemIdleLock = 0;

+      _DAT_6 = 0;

+      _PopCoalRegistrationListLock = 0;

+      _PopIdleLoopExecuted = 0;

+      DAT_7 = 6;

+      DAT_8 = 0;

+      _PopDeepSleepDisengageReasonLock = 0;

+      PopIrpLock = 0;

+      ExInitializeNPagedLookasideListInternal

+                (&PopIrpDataLookaside,0,0,0x200,0x138,CONCAT44(uVar9,0x72496f50),

+                 (uint)uVar10 << 0x10,0);

+      _PopShutdownNotificationCallbackLock = 0;

       DAT_9 = &PopShutdownNotificationCallbackList;

       PopShutdownNotificationCallbackList = &PopShutdownNotificationCallbackList;

-      _PopShutdownNotificationCallbackLock = unaff_R15;

-      *(undefined8 *)(uVar10 - 8) = 0x140c63c3f;

       memset(&PopStateTransitonBlameStack,0,0xc18);

       DAT_10 = 0xffffffff;

       _DAT_11 = PopDevicePowerTransitionInProgressWorker;

-      BootStatDisableFlush = DAT_12 >> 2 & bVar11;

+      BootStatDisableFlush = DAT_12 >> 2 & 1;

+      _PopPendingPowerTransitionLock = 0;

+      _DAT_13 = 0;

       uRam0000000140f0d3d0 = 0;

-      _DAT_13 = &DAT_140f0e788;

-      _DAT_14 = &DAT_14;

-      uVar12 = (undefined2)unaff_R12D;

-      DAT_15 = 6;

-      BootStatDataCache = unaff_R15;

-      BootStatFileHandleAcquired = bVar13;

-      BootStatKeepHandleOpen = bVar13;

-      BootStatFileHandle = unaff_R15;

-      _PopDevicePowerTransitionInProgressWorkItem = unaff_R15;

-      _DAT_16 = unaff_R15;

-      _PopPendingPowerTransitionLock = unaff_R15;

-      _DAT_17 = unaff_R15;

-      _PopBsdFlushInactiveEvent = uVar12;

-      DAT_18 = unaff_R12D;

-      PopBsdSkipLogging = bVar13;

-      _PopBsdUpdateLock = unaff_R15;

-      _DAT_19 = unaff_R15;

-      *(undefined8 *)(uVar10 - 8) = 0x140c63cfe;

+      _DAT_14 = &DAT_140f0e788;

+      _DAT_15 = &DAT_15;

+      _DAT_16 = 0;

+      _PopDevicePowerTransitionInProgressWorkItem = 0;

+      BootStatFileHandle = 0;

+      BootStatFileHandleAcquired = 0;

+      BootStatKeepHandleOpen = 0;

+      BootStatDataCache = 0;

+      PopBsdSkipLogging = 0;

+      _DAT_17 = 0;

+      _PopBsdUpdateLock = 0;

+      _PopBsdFlushInactiveEvent = 1;

+      DAT_18 = 6;

+      DAT_19 = 1;

       PopInitializeWorkItem(&PopSetUserShutdownMarkerWorkItem,PopSetUserShutdownMarkerWorker,0);

-      *(undefined8 *)(uVar10 - 8) = 0x140c63d11;

       PopInitializeWorkItem(&PopClearUserShutdownMarkerWorkItem,PopClearUserShutdownMarkerWorker);

-      *(undefined8 *)(uVar10 - 8) = 0x140c63d24;

       PopInitializeWorkItem(&PopBsdFlushWorkItem,PopBsdFlushWorker);

-      *(undefined8 *)(uVar10 - 8) = 0x140c63d37;

       PopInitializeWorkItem(&PopBsdUpdateWorkItem,PopBsdUpdateWorker);

+      PopWdiCurrentScenarioInstanceId = 0;

       PopWdiCurrentScenario = &PARTITION_ENTRY_UNUSED_GUID;

-      PopWdiCurrentScenarioInstanceId = unaff_R15;

-      *(undefined8 *)(uVar10 - 8) = 0x140c63d5f;

       PopInitializeWorkItem(&PopExternalMonitorUpdatedWorkItem,PopExternalMonitorUpdatedWorker);

-      *(undefined8 *)(uVar10 - 8) = 0x140c63d64;

-      iVar6 = Feature_NU4MP__private_IsEnabledDeviceUsageNoInline();

-      if (iVar6 != 0) {

-        *(undefined8 *)(uVar10 - 8) = 0x140c63d7e;

+      iVar4 = Feature_NU4MP__private_IsEnabledDeviceUsageNoInline();

+      if (iVar4 != 0) {

         PopInitializeWorkItem

                   (&PopUsb4DisplayPresenceUpdatedWorkItem,PopUsb4DisplayPresenceUpdatedWorker,0);

       }

-      *(undefined8 *)(uVar10 - 8) = 0x140c63d94;

       PopInitializeWorkItem(&PopRecordLidStateWorkItem,PopRecordLidStateWorker,0);

-      DAT_20 = &PopTransitionCheckpoints;

+      _DAT_20 = 0;

+      DAT_21 = &PopTransitionCheckpoints;

       PopTransitionCheckpoints = &PopTransitionCheckpoints;

-      _PopPowerButtonSuppressionLock = unaff_R15;

-      _DAT_21 = unaff_R15;

-      _PopInputSuppressionLock = unaff_R15;

-      _DAT_22 = unaff_R15;

-      PopMonitorOffDueToSleep = bVar13;

-      _PopTransitionCheckpointLock = unaff_R15;

-      _DAT_23 = unaff_R15;

-      *(undefined8 *)(uVar10 - 8) = 0x140c63ddf;

+      _PopInputSuppressionLock = 0;

+      _DAT_22 = 0;

+      _PopPowerButtonSuppressionLock = 0;

+      _DAT_23 = 0;

+      _PopTransitionCheckpointLock = 0;

+      PopMonitorOffDueToSleep = 0;

       PpmCheckInit();

-      *(undefined8 *)(uVar10 - 8) = 0x140c63de4;

-      iVar6 = PopInitializeIrpWorkers();

-      if (-1 < iVar6) {

+      uVar3 = PopInitializeIrpWorkers();

+      if (-1 < (int)uVar3) {

+        _PopIrpSerialLock = 0;

         _DAT_24 = &DAT_140f0bf10;

         _DAT_25 = &DAT_25;

         _DAT_26 = &PopIrpSerialList;

         _PopIrpSerialList = &PopIrpSerialList;

         _DAT_27 = &PopRequestedIrps;

         _PopRequestedIrps = &PopRequestedIrps;

         _DAT_28 = &DAT_140f0afe8;

         _DAT_29 = &DAT_29;

         DAT_30 = &PowerStateDisableReasonListHead;

         PowerStateDisableReasonListHead = &PowerStateDisableReasonListHead;

         _DAT_31 = &DAT_140f0de80;

         _DAT_32 = &DAT_32;

         DAT_33 = &PopDisableSleepList;

         PopDisableSleepList = &PopDisableSleepList;

-        DAT_34 = 6;

-        DAT_35 = 6;

-        DAT_36 = 6;

-        _DAT_37 = unaff_R15;

-        _PopTransitionLock = uVar12;

-        _DAT_38 = unaff_R12D;

-        _DAT_39 = uVar12;

-        _DAT_40 = unaff_R12D;

-        _PpmIdleVetoLock = unaff_R15;

-        _PpmParkStateLock = unaff_R15;

-        _PopIrpSerialLock = unaff_R15;

-        PpmIdlePolicyLock = unaff_R15;

-        DAT_41 = unaff_R15;

-        _PopWorkerLock = unaff_R15;

-        _PopDisableSleepMutex = unaff_R12D;

-        _DAT_42 = unaff_R15;

-        _DAT_43 = iVar15;

-        _DAT_44 = uVar12;

-        _DAT_45 = iVar15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c63f0c;

+        DAT_34 = 0;

+        PpmIdlePolicyLock = 0;

+        _PpmIdleVetoLock = 0;

+        _PpmParkStateLock = 0;

+        _DAT_35 = 0;

+        _DAT_36 = 1;

+        DAT_37 = 6;

+        _DAT_38 = 1;

+        _PopWorkerLock = 0;

+        _PopTransitionLock = 1;

+        DAT_39 = 6;

+        _DAT_40 = 1;

+        _PopDisableSleepMutex = 1;

+        _DAT_41 = 0;

+        _DAT_42 = 0;

+        _DAT_43 = 1;

+        DAT_44 = 6;

+        _DAT_45 = 0;

         PopInitShutdownList();

         DAT_46 = &PopIdleDetectList;

         PopIdleDetectList = &PopIdleDetectList;

+        _PopDopeGlobalLock = 0;

         if (PopIdleScanInterval != 0) {

           if (PopIdleScanInterval == 0xffffffff) {

             PopIdleScanInterval = 0x1e;

           }

           else if (300 < PopIdleScanInterval) {

             PopIdleScanInterval = 300;

           }

           PopIdleBackgroundIgnoreCount = (PopIdleScanInterval + 0x3b) / PopIdleScanInterval;

           PopBackgroundTaskIgnoreCount = (PopIdleScanInterval + 0xb3) / PopIdleScanInterval;

         }

+        _PopWorkerSpinLock = 0;

         _DAT_47 = PopPolicyWorkerThread;

+        _PopPolicyWorker = 0;

         _DAT_48 = 0x80000000;

         PopWorkerStatus = 0xffffffff;

-        _PopPolicyWorker = unaff_R15;

-        _PopWorkerSpinLock = unaff_R15;

-        _PopDopeGlobalLock = unaff_R15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c63fb0;

         ExInitializeResourceLite2(&PopPolicyLock,0xffffffff);

+        PopAwaymodeLock = 0;

         _DAT_49 = &DAT_140f0bfe0;

         _DAT_50 = &DAT_50;

+        _PopVolumeLock = 1;

         _DAT_51 = &DAT_140f0d5a8;

         _DAT_52 = &DAT_52;

         DAT_53 = &PopVolumeDevices;

         PopVolumeDevices = &PopVolumeDevices;

         _DAT_54 = &PopSwitches;

         _PopSwitches = &PopSwitches;

         _DAT_55 = &PopFans;

         PopFans = &PopFans;

-        DAT_56 = 6;

-        DAT_57 = 6;

-        _DAT_58 = &PopThermal;

+        _DAT_56 = 0;

+        _DAT_57 = 0;

+        _DAT_58 = 1;

+        DAT_59 = 6;

+        _DAT_60 = 0;

+        _PopPowerSettingCallbackReturned = 0;

+        DAT_61 = 6;

+        _DAT_62 = 0;

+        _DAT_63 = &PopThermal;

         PopThermal = &PopThermal;

-        PopWaitingForTransitionLock = bVar13;

-        _PopUnlockAfterSleepLock = unaff_R15;

-        _DAT_59 = unaff_R15;

-        PopAwaymodeLock = unaff_R15;

-        _PopVolumeLock = unaff_R12D;

-        _DAT_60 = unaff_R15;

-        _DAT_61 = iVar15;

-        _DAT_62 = uVar12;

-        _DAT_63 = iVar15;

-        _PopPowerSettingCallbackReturned = uVar14;

-        _DAT_64 = iVar15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c64095;

+        PopWaitingForTransitionLock = 0;

+        _DAT_64 = 0;

+        _PopUnlockAfterSleepLock = 0;

         IoAddTriageDumpDataBlock(&PopThermal,0x10);

         DAT_65 = &PopActionWaiters;

         PopActionWaiters = &PopActionWaiters;

-        *(undefined8 *)(uVar10 - 8) = 0x140c640af;

         PopResetActionDefaults();

         PopPolicy = &DAT_66;

-        *(undefined8 *)(uVar10 - 8) = 0x140c640c2;

         PopDefaultPolicy();

         PopAdminPolicy = 2;

         _DAT_67 = 5;

         DAT_68 = 0xffffffff;

-        DAT_69 = 0xffffffff;

-        PopFullWake = unaff_R12D;

-        DAT_70 = iVar15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c640f6;

-        iVar6 = Feature_VpciVscBootDiskHibernation__private_IsEnabledDeviceUsageNoInline();

-        if (iVar6 != 0) {

+        DAT_69 = 0;

+        DAT_70 = 0xffffffff;

+        PopFullWake = 1;

+        iVar4 = Feature_VpciVscBootDiskHibernation__private_IsEnabledDeviceUsageNoInline();

+        if (iVar4 != 0) {

+          _PopSstNotificationHandlerListLock = 0;

           DAT_71 = &PopSstNotificationHandlerList;

           PopSstNotificationHandlerList = &PopSstNotificationHandlerList;

-          _PopSstNotificationHandlerListLock = unaff_R15;

         }

+        PopCoolingMode = 0;

         DAT_72 = 0xffffffff;

         DAT_73 = 2;

-        PopCoolingMode = iVar15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c64132;

         PpmInitPolicyConfiguration();

-        *(undefined8 *)(uVar10 - 8) = 0x140c64137;

         PpmInitIdlePolicy();

-        *(undefined8 *)(uVar10 - 8) = 0x140c6413c;

         PpmPerfInitialize();

-        *(undefined8 *)(uVar10 - 8) = 0x140c64141;

         PpmInitCoreParkingPolicy();

-        *(undefined8 *)(uVar10 - 8) = 0x140c64146;

         PpmInitHeteroPolicy();

-        *(undefined8 *)(uVar10 - 8) = 0x140c6414b;

         PpmIdleRegisterDefaultStates();

-        *(undefined8 *)(uVar10 - 8) = 0x140c64152;

         PopDeepSleepInitialize(0);

-        *(undefined8 *)(uVar10 - 8) = 0x140c64157;

         PopInitializePowerSettings();

-        *(undefined8 *)(uVar10 - 8) = 0x140c6415c;

         PopInitilizeAcDcSettings();

-        _PopPolicyDeviceLock = unaff_R15;

-        _DAT_74 = unaff_R15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c6416f;

+        _DAT_74 = 0;

+        _PopPolicyDeviceLock = 0;

         PopBatteryInit();

-        *(undefined8 *)(uVar10 - 8) = 0x140c64174;

         PopThermalInit();

         DAT_75 = &PopCoolingExtensionList;

         PopCoolingExtensionList = &PopCoolingExtensionList;

         DAT_76 = &PopPowerLimitExtensionList;

         PopPowerLimitExtensionList = &PopPowerLimitExtensionList;

         DAT_77 = PopShutdownHandler;

         DAT_78 = &PopWakeInfoList;

         PopWakeInfoList = &PopWakeInfoList;

         _DAT_79 = &DAT_140f0d508;

         _DAT_80 = &DAT_80;

         DAT_81 = &PopWakeSourceWorkList;

         PopWakeSourceWorkList = &PopWakeSourceWorkList;

         _DAT_82 = &DAT_140f08648;

         _DAT_83 = &DAT_83;

         _DAT_84 = PpmWmiIdleAccountingProcedure;

         _DAT_85 = PopUserPresentSetWorker;

         _DAT_86 = &DAT_140e67678;

         _DAT_87 = &DAT_87;

         _DAT_88 = &DAT_140f0c768;

         _DAT_89 = &DAT_89;

-        _DAT_90 = 4;

-        DAT_91 = 6;

-        _PpmWmiIdleAccountingTimer = CONCAT71(uVar3,8);

+        _DAT_90 = 0;

+        _PopCoolingExtensionLock = 0;

+        _DAT_91 = 0;

+        _PopPowerLimitExtensionLock = 0;

+        _DAT_92 = 4;

+        DAT_93 = 0;

+        PopWakeInfoCount = 0;

+        PopCurrentWakeInfo = 0;

+        _PopWakeSourceLock = 0;

+        _PopWakeSourceAvailable = 0;

+        DAT_94 = 6;

+        _DAT_95 = 1;

+        PopWakeSourceWorkState = 0;

+        _PpmWmiIdleAccountingTimer = 8;

+        _DAT_96 = 0;

+        _DAT_97 = 0;

+        _DAT_98 = 0;

         _PpmWmiIdleAccountingDpc = 0x113;

-        _PopAwayModeUserPresenceTimer = CONCAT71(uVar3,8);

-        DAT_92 = 6;

-        _DAT_93 = unaff_R15;

-        _DAT_94 = uVar14;

-        _DAT_95 = iVar15;

-        _DAT_96 = unaff_R15;

-        _DAT_97 = unaff_R15;

-        _DAT_98 = unaff_R15;

-        _DAT_99 = unaff_R15;

-        _DAT_100 = uVar14;

-        _DAT_101 = iVar15;

-        _PopCoolingExtensionLock = unaff_R15;

-        _DAT_102 = unaff_R15;

-        _PopPowerLimitExtensionLock = unaff_R15;

-        _DAT_103 = unaff_R15;

-        DAT_104 = bVar13;

-        _PopUserPresentCompletedEvent = uVar12;

-        _DAT_105 = iVar15;

-        PopWakeSourceWorkState = iVar15;

-        _PopWakeSourceAvailable = uVar14;

-        _DAT_106 = unaff_R12D;

-        _PopWakeSourceLock = unaff_R15;

-        PopCurrentWakeInfo = unaff_R15;

-        PopWakeInfoCount = iVar15;

-        _PopUserPresentWorkItem = unaff_R15;

-        _DAT_107 = unaff_R15;

-        _PopUserPresentLock = unaff_R15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c6433c;

+        _DAT_99 = 0;

+        _DAT_100 = 0;

+        _DAT_101 = 0;

+        _PopUserPresentLock = 0;

+        _DAT_102 = 0;

+        _PopUserPresentWorkItem = 0;

+        _PopAwayModeUserPresenceTimer = 8;

+        _DAT_103 = 0;

+        _DAT_104 = 0;

+        _DAT_105 = 0;

+        _PopUserPresentCompletedEvent = 1;

+        DAT_106 = 6;

+        _DAT_107 = 0;

         PopSmartSuspendInit();

-        _DAT_108 = &DAT_140f0da70;

-        _DAT_109 = &DAT_109;

-        DAT_110 = 6;

-        _DAT_111 = uVar12;

-        _DAT_112 = unaff_R12D;

-        *(undefined8 *)(uVar10 - 8) = 0x140c6436c;

+        _DAT_108 = 1;

+        _DAT_109 = &DAT_140f0da70;

+        _DAT_110 = &DAT_110;

+        DAT_111 = 6;

+        _DAT_112 = 1;

         PoFxInitPowerManagement();

-        _DAT_113 = 100;

+        DAT_113 = 0;

         _DAT_114 = 100;

-        DAT_115 = 100;

-        DAT_116 = iVar15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c64393;

+        _DAT_115 = 100;

+        DAT_116 = 100;

         PopNetInitialize(0);

-        *(undefined8 *)(uVar10 - 8) = 0x140c6439a;

         PopInitializePowerButtonHold(0);

-        _PopSleepReliabilityDiagLock = unaff_R15;

-        _DAT_117 = unaff_R15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c643ad;

+        _DAT_117 = 0;

+        _PopSleepReliabilityDiagLock = 0;

         PopRecorderInit();

-        *(undefined8 *)(uVar10 - 8) = 0x140c643b5;

-        PopRecordFirmwareResetReason();

-        *(undefined8 *)(uVar10 - 8) = 0x140c643ba;

-        iVar6 = PopCreateTimebrokerServiceSid();

-        if (-1 < iVar6) {

-          *(undefined8 *)(uVar10 - 8) = 0x140c643c9;

+        PopRecordFirmwareResetReason(param_2);

+        uVar3 = PopCreateTimebrokerServiceSid();

+        if (-1 < (int)uVar3) {

           PopInitializeDirectedDrips(0);

-          *(undefined8 *)(uVar10 - 8) = 0x140c643d0;

           SshInitialize(0);

-          iVar6 = iVar15;

+          uVar3 = uVar7;

         }

       }

     }

     goto LAB_118;

   }

-  if (param_1 == unaff_R12D) {

-    *(undefined8 *)(uVar10 - 8) = 0x140c643e3;

-    cVar5 = HviIsAnyHypervisorPresent();

-    if (cVar5 != '\0') {

-      PpmExitLatencySamplingPercentage = iVar15;

-      _PpmExitLatencyCheckEnabled = iVar15;

+  if (param_1 == 1) {

+    cVar2 = HviIsAnyHypervisorPresent();

+    if (cVar2 != '\0') {

+      _PpmExitLatencyCheckEnabled = 0;

+      PpmExitLatencySamplingPercentage = 0;

     }

-    _PopFanLock = unaff_R15;

-    _DAT_119 = unaff_R15;

-    DAT_120 = iVar15;

-    *(undefined8 *)(uVar10 - 8) = 0x140c64411;

+    _DAT_119 = 0;

+    _PopFanLock = 0;

+    DAT_120 = 0;

     PopSendFanNoiseChangeWnf(0);

     if (PopAggressiveStandbyActionsRegValue < 0x10) {

       PopAggressiveStandbyEnabledActions = PopAggressiveStandbyActionsRegValue;

     }

-    _PopSuspendResumeNotification = unaff_R15;

-    _DAT_121 = unaff_R15;

-    _DAT_122 = unaff_R15;

-    _DAT_123 = unaff_R15;

-    *(undefined8 *)(uVar10 - 8) = 0x140c64446;

-    SshInitialize(unaff_R12D);

-    *(undefined8 *)(uVar10 - 8) = 0x140c6444b;

+    _DAT_121 = 0;

+    _DAT_122 = 0;

+    _DAT_123 = 0;

+    _PopSuspendResumeNotification = 0;

+    SshInitialize(1);

     PopUmpoInitializeChannel();

-    *(undefined8 *)(uVar10 - 8) = 0x140c64450;

     PopUmpoInitializeMonitorChannel();

+    PopPdcDeviceListLock = 0;

     _DAT_124 = PopDelayedPdcRegistrationWorker;

-    PopPdcDeviceListLock = unaff_R15;

-    _PopDelayedPdcRegistrationWorkItem = unaff_R15;

-    _DAT_125 = unaff_R15;

-    *(undefined8 *)(uVar10 - 8) = 0x140c6447b;

-    PopEsInit(unaff_R12D);

-    *(undefined8 *)(uVar10 - 8) = 0x140c64480;

+    _DAT_125 = 0;

+    _PopDelayedPdcRegistrationWorkItem = 0;

+    PopEsInit(1);

     PopInitializePowerSettingCallbacks();

-    *(undefined8 *)(uVar10 - 8) = 0x140c64485;

-    iVar6 = PopEtInit();

-    if (-1 < iVar6) {

-      *(undefined8 *)(uVar10 - 8) = 0x140c64492;

-      iVar6 = PopPowerRequestInitialize();

-      if (-1 < iVar6) {

-        *(undefined8 *)(uVar10 - 8) = 0x140c644a2;

-        iVar6 = PopPowerAggregatorInitialize(unaff_R12D);

-        if (-1 < iVar6) {

-          *(undefined8 *)(uVar10 - 8) = 0x140c644af;

-          iVar6 = PopInitializeHighPerfPowerRequest();

-          if (-1 < iVar6) {

-            *(undefined8 *)(uVar10 - 8) = 0x140c644bc;

-            PopCheckPowerSourceAfterRtcWakeInitialize();

-            *(undefined8 *)(uVar10 - 8) = 0x140c644c1;

-            PopWatchdogInit();

-            *(undefined8 *)(uVar10 - 8) = 0x140c644c9;

-            PopInitializePowerButtonHold(unaff_R12D);

-            *(undefined8 *)(uVar10 - 8) = 0x140c644ce;

-            PopInitDripsWakeAccounting();

-            *(longlong *)(uVar10 + 0x28) = unaff_RBP + 0x58;

-            *(undefined4 *)(uVar10 + 0x20) = 2;

-            *(undefined8 *)(uVar10 - 8) = 0x140c644f7;

-            iVar6 = EmpProviderRegister(0,&PopEmEntry,unaff_R12D,&PopEmCallback);

-            if (-1 < iVar6) {

-              *(int *)(unaff_RBP + 0x40) = unaff_R12D;

-              PopErrataDisablePrimaryDeviceFastResume = bVar13;

-              *(undefined8 *)(uVar10 - 8) = 0x140c6451a;

-              EmClientQueryRuleState(&GUID_EM_RULE_DISABLE_DEVICE_FAST_RESUME,unaff_RBP + 0x40);

-              if (*(int *)(unaff_RBP + 0x40) == 2) {

-                PopErrataDisablePrimaryDeviceFastResume = bVar11;

-              }

-              *(undefined8 *)(uVar10 - 8) = 0x140c6452c;

-              PopDetectSimulatedHeteroProcessors();

-              *(undefined8 *)(uVar10 - 8) = 0x140c64535;

-              PpmHeteroHgsDetectContainmentPresence(0,0);

-              iVar6 = iVar15;

-            }

-          }

+    uVar3 = PopEtInit();

+    if ((((-1 < (int)uVar3) && (uVar3 = PopPowerRequestInitialize(), -1 < (int)uVar3)) &&

+        (uVar3 = PopPowerAggregatorInitialize(1), -1 < (int)uVar3)) &&

+       (uVar3 = PopInitializeHighPerfPowerRequest(), -1 < (int)uVar3)) {

+      PopCheckPowerSourceAfterRtcWakeInitialize();

+      PopWatchdogInit();

+      PopInitializePowerButtonHold(1);

+      PopInitDripsWakeAccounting();

+      uVar3 = EmpProviderRegister(0,&PopEmEntry,1,&PopEmCallback,CONCAT44(uVar8,2),&local_res20);

+      if (-1 < (int)uVar3) {

+        local_res8[0] = 1;

+        PopErrataDisablePrimaryDeviceFastResume = 0;

+        EmClientQueryRuleState(&GUID_EM_RULE_DISABLE_DEVICE_FAST_RESUME,local_res8);

+        if (local_res8[0] == 2) {

+          PopErrataDisablePrimaryDeviceFastResume = 1;

         }

+        PopDetectSimulatedHeteroProcessors();

+        PpmHeteroHgsDetectContainmentPresence(0,0);

+        uVar3 = uVar7;

       }

     }

     goto LAB_118;

   }

   if (param_1 == 2) {

-    *(undefined8 *)(uVar10 - 8) = 0x140c64548;

     PoFxRegisterDebugger();

-    *(undefined8 *)(uVar10 - 8) = 0x140c64550;

-    HalReportResourceUsage(unaff_R12D);

-    *(undefined8 *)(uVar10 - 8) = 0x140c64555;

+    HalReportResourceUsage(1);

     PopBatteryInitPhaseTwo();

-    *(undefined8 *)(uVar10 - 8) = 0x140c6455a;

-    iVar6 = PpmEventInitialize();

-    if (-1 < iVar6) {

-      *(undefined8 *)(uVar10 - 8) = 0x140c64573;

+    uVar3 = PpmEventInitialize();

+    if (-1 < (int)uVar3) {

       KeRegisterProcessorChangeCallback(PopNewProcessorCallback,0,0);

-      *(undefined8 *)(uVar10 - 8) = 0x140c6457f;

       PpmAcquireLock(&PpmPerfPolicyLock);

-      *(undefined8 *)(uVar10 - 8) = 0x140c64587;

-      PopInitializeHeteroProcessors(bVar11);

-      *(undefined8 *)(uVar10 - 8) = 0x140c64593;

+      PopInitializeHeteroProcessors(1);

       PpmReleaseLock(&PpmPerfPolicyLock);

       if (PpmPerfArtificialDomainSetting != -1) {

-        PpmPerfArtificialDomainEnabled =

-             (undefined4)CONCAT71(uVar3,PpmPerfArtificialDomainSetting != 0);

+        PpmPerfArtificialDomainEnabled = (uint)(PpmPerfArtificialDomainSetting != 0);

       }

-      *(undefined8 *)(uVar10 - 8) = 0x140c645b1;

       PpmIdleRegisterDefaultStates();

-      *(undefined8 *)(uVar10 - 8) = 0x140c645b6;

-      iVar6 = PpmParkInitialize();

-      if (-1 < iVar6) {

-        *(undefined8 *)(uVar10 - 8) = 0x140c645c8;

-        PpmCheckInitProcessors(0,unaff_R12D);

-        *(undefined8 *)(uVar10 - 8) = 0x140c645d4;

+      uVar3 = PpmParkInitialize();

+      if (-1 < (int)uVar3) {

+        PpmCheckInitProcessors(0,1);

         PpmAcquireLock(&PopFxSystemLatencyLock);

-        *(undefined8 *)(uVar10 - 8) = 0x140c645d9;

         PoFxSendSystemLatencyUpdate();

-        *(undefined8 *)(uVar10 - 8) = 0x140c645e5;

         PpmReleaseLock(&PopFxSystemLatencyLock);

-        *(undefined8 *)(uVar10 - 8) = 0x140c645ea;

         PopPdcCsCheckSystemVolumeDevice();

-        *(undefined8 *)(uVar10 - 8) = 0x140c645f1;

         PopUpdateBackgroundCoolingStatus(0);

-        *(int *)(uVar10 + 0x30) = iVar15;

-        *(int *)(uVar10 + 0x28) = iVar15;

-        *(ulonglong *)(uVar10 + 0x20) = unaff_R15;

-        *(undefined8 *)(uVar10 - 8) = 0x140c6461a;

-        ZwUpdateWnfStateData(&WNF_PO_MULTIMEDIA_POWER_MODEL,&PpmPerfMultimediaPowerModel,4);

-        *(undefined8 *)(uVar10 - 8) = 0x140c6461f;

+        ZwUpdateWnfStateData

+                  (&WNF_PO_MULTIMEDIA_POWER_MODEL,&PpmPerfMultimediaPowerModel,4,0,0,

+                   (ulonglong)uVar9 << 0x20,0);

         PopInitVideoWnfState();

-        iVar6 = iVar15;

+        uVar3 = uVar7;

       }

     }

     goto LAB_118;

   }

-  iVar6 = iVar15;

-  if (param_1 != 3) goto LAB_118;

-  *(undefined8 *)(uVar10 - 8) = 0x140c64638;

-  iVar6 = PopDiagInitialize();

-  if (iVar6 < 0) goto LAB_118;

-  *(undefined8 *)(uVar10 - 8) = 0x140c64648;

+  uVar3 = uVar7;

+  if ((param_1 != 3) || (uVar3 = PopDiagInitialize(), (int)uVar3 < 0)) goto LAB_118;

   SshInitialize(3);

-  *(undefined8 *)(uVar10 - 8) = 0x140c64650;

   PopSleepstudyInitialize(3);

-  bVar8 = -(PopPlatformAoAcCapabilityInitialized != 0) & PopPlatformAoAc;

-  *(undefined8 *)(uVar10 - 8) = 0x140c64665;

-  PopTriggerDiagTraceAoAcCapability(bVar8);

-  *(undefined8 *)(uVar10 - 8) = 0x140c6466a;

+  PopTriggerDiagTraceAoAcCapability(-(PopPlatformAoAcCapabilityInitialized != 0) & PopPlatformAoAc);

   PopFanReportBootStartDevices();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6466f;

   PopInitializeWin32kActivator();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64674;

   PopModernStandbyNotificationInit();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6467c;

   PopPowerAggregatorInitialize(3);

-  *(undefined8 *)(uVar10 - 8) = 0x140c64681;

-  iVar6 = PopUserShutdownScenarioInitialize();

-  if (iVar6 < 0) goto LAB_118;

-  iVar6 = 2;

-  bVar8 = bVar11;

-  if ((PopSkipTickPolicy == 0) || (iVar6 = iVar15, PopSkipTickPolicy != unaff_R12D)) {

+  uVar3 = PopUserShutdownScenarioInitialize();

+  if ((int)uVar3 < 0) goto LAB_118;

+  uVar3 = 2;

+  if ((PopSkipTickPolicy == 0) || (uVar3 = uVar7, PopSkipTickPolicy != 1)) {

 LAB_126:

-    PoSkipTickMode = iVar6;

-    *(undefined8 *)(uVar10 - 8) = 0x140c64707;

-    PopDiagTraceSkipTick(iVar6 == 2,bVar8);

+    PoSkipTickMode = uVar3;

+    PopDiagTraceSkipTick(uVar3 == 2,uVar6);

   }

   else {

-    *(undefined8 *)(uVar10 - 8) = 0x140c646b7;

-    iVar7 = HalGetInterruptTargetInformation(2,0,unaff_RBP + -0x20);

-    iVar6 = 2;

-    bVar8 = bVar13;

-    if (iVar7 < 0) goto LAB_126;

-    PopApicMode = *(int *)(unaff_RBP + -0xc);

-    if (PopApicMode == 3) {

-      PopApicClusterSize = *(undefined4 *)(unaff_RBP + -8);

+    uVar6 = 0;

+    iVar5 = HalGetInterruptTargetInformation(2,0,&local_58);

+    uVar3 = 2;

+    if (iVar5 < 0) goto LAB_126;

+    PopApicMode = local_48._4_4_;

+    if (local_48._4_4_ == 3) {

+      PopApicClusterSize = local_40;

       PoSkipTickMaxOpportunisticProcessors = 8;

     }

-    *(undefined8 *)(uVar10 - 8) = 0x140c646e1;

-    cVar5 = PopCheckSkipTick();

-    PoSkipTickMode = (int)CONCAT71(uVar3,cVar5 == '\0');

-  }

-  *(undefined8 *)(uVar10 - 8) = 0x140c6470c;

+    cVar2 = PopCheckSkipTick();

+    PoSkipTickMode = (uint)(cVar2 == '\0');

+  }

   PpmInitIllegalThrottleLogging();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64714;

-  PopCheckShutdownMarker();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64719;

+  PopCheckShutdownMarker(param_2);

   PopCheckAndClearBootError();

-  puVar4 = PTR_IopDmaOverrideConflict_140e00b10;

-  *(undefined8 *)(uVar10 - 8) = 0x140c64725;

-  cVar5 = (*(code *)puVar4)();

-  iVar6 = DAT_127;

-  if ((cVar5 != '\0') || ((PoOffCrashConfigTable - 1U < 3 && (DAT_127 != iVar15)))) {

-    *(undefined8 *)(uVar10 - 8) = 0x140c6474a;

-    PopDiagTraceAbnormalReset(iVar6);

-  }

-  *(undefined8 *)(uVar10 - 8) = 0x140c6474f;

+  cVar2 = (*(code *)PTR_IopDmaOverrideConflict_140e00b10)();

+  if ((cVar2 != '\0') || ((PoOffCrashConfigTable - 1U < 3 && (DAT_127 != 0)))) {

+    PopDiagTraceAbnormalReset(DAT_127);

+  }

   PopIdleWakeInitialize();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64754;

   PopAcquirePolicyLock();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6475b;

   PopUpdateUpgradeInProgress(0);

-  if (InitIsWinPEMode != bVar13) {

-    *(undefined8 *)(uVar10 - 8) = 0x140c64776;

+  if (InitIsWinPEMode != '\0') {

     PopLogSleepDisabled(0x10,0xf,0);

   }

-  if (DAT_128 != bVar13) {

-    *(undefined8 *)(uVar10 - 8) = 0x140c64791;

+  if (DAT_128 != '\0') {

     PopLogSleepDisabled(0x11,7,0);

   }

-  uVar9 = unaff_R15 & 0xffffffff;

-  if ((*(byte *)(*(longlong *)(unaff_RDI + 0xf0) + 0xa58) & 8) != 0) {

-    uVar9 = 4;

-    PopSecureLaunched = bVar11;

-  }

-  if (((HvlpFlags & 2) == 0) && (VslVsmEnabled != bVar13)) {

-    uVar9 = 0x17;

+  if ((*(byte *)(*(longlong *)(param_2 + 0xf0) + 0xa58) & 8) != 0) {

+    PopSecureLaunched = 1;

+    iVar4 = 4;

+  }

+  if (((HvlpFlags & 2) == 0) && (VslVsmEnabled != '\0')) {

+    iVar4 = 0x17;

 LAB_129:

-    *(undefined8 *)(uVar10 - 8) = 0x140c647dd;

-    PopLogSleepDisabled(0x15,uVar9,0);

-  }

-  else if ((int)uVar9 != 0) goto LAB_129;

-  *(undefined8 *)(uVar10 - 8) = 0x140c647e5;

+    PopLogSleepDisabled(0x15,iVar4,0);

+  }

+  else if (iVar4 != 0) goto LAB_129;

   PopDeepSleepInitialize(3);

-  *(undefined8 *)(uVar10 - 8) = 0x140c647ea;

   PopInitializePowerPolicySimulate();

-  if ((bVar11 & (byte)PopSimulate) != 0) {

-    _DAT_130 = 100;

-    _DAT_131 = 400;

-    _DAT_132 = 10;

-    _DAT_133 = 0xffff;

-    DAT_134 = 4;

-    _DAT_135 = 2;

-    DAT_136 = bVar11;

+  if ((PopSimulate & 1) != 0) {

+    DAT_130 = 1;

+    _DAT_131 = 100;

+    _DAT_132 = 400;

+    _DAT_133 = 10;

+    _DAT_134 = 0xffff;

+    DAT_135 = 4;

+    _DAT_136 = 2;

   }

   if ((PopSimulate & 2) != 0) {

     _PopCapabilities = 0x1010101;

     _DAT_137 = 0x101;

-    _DAT_138 = 0x101;

-    DAT_139 = bVar11;

-  }

-  *(undefined8 *)(uVar10 - 8) = 0x140c64866;

+    DAT_138 = 1;

+    _DAT_139 = 0x101;

+  }

   PopResetCurrentPolicies();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6486b;

   PopInitializeAdpm();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64873;

   PopEsInit(3);

-  *(undefined8 *)(uVar10 - 8) = 0x140c64878;

   PopInitilizeAcDcSettings();

-  *(int *)(unaff_RBP + 0x50) = unaff_R12D;

-  *(undefined8 *)(uVar10 - 8) = 0x140c64884;

-  PopUpdateConsoleDisplayState(unaff_R12D);

-  *(int *)(uVar10 + 0x30) = iVar15;

-  *(int *)(uVar10 + 0x28) = iVar15;

-  *(ulonglong *)(uVar10 + 0x20) = unaff_R15;

-  *(undefined8 *)(uVar10 - 8) = 0x140c648aa;

-  ZwUpdateWnfStateData(&WNF_PO_PRIMARY_DISPLAY_VISIBLE_STATE,unaff_RBP + 0x50,4);

-  *(undefined8 *)(uVar10 - 8) = 0x140c648b2;

+  local_res18[0] = 1;

+  PopUpdateConsoleDisplayState(1);

+  ZwUpdateWnfStateData

+            (&WNF_PO_PRIMARY_DISPLAY_VISIBLE_STATE,local_res18,4,0,0,(ulonglong)uVar9 << 0x20,0);

   PopNetInitialize(3);

-  *(undefined8 *)(uVar10 - 8) = 0x140c648b7;

   PopReleasePolicyLock();

-  *(undefined8 *)(uVar10 - 8) = 0x140c648bc;

   PopIdleInitAoAcDozeS4Timer();

-  *(undefined8 *)(uVar10 - 8) = 0x140c648c1;

   PopCreateIdlePhaseWatchdog();

-  *(undefined8 *)(uVar10 - 8) = 0x140c648c6;

   PopInitializeSystemIdleDetection();

   PopHiberResumeXhciHandoffSkip =

-       (byte)((uint)*(undefined4 *)(*(longlong *)(unaff_RDI + 0xf0) + 0x84) >> 0x1c) & bVar11;

-  *(undefined8 *)(uVar10 - 8) = 0x140c648e4;

+       (byte)((uint)*(undefined4 *)(*(longlong *)(param_2 + 0xf0) + 0x84) >> 0x1c) & 1;

   PopSetupHighPerfPowerRequest();

-  *(undefined8 *)(uVar10 - 8) = 0x140c648e9;

   PpmEnableWmiInterface();

-  lVar2 = *(longlong *)(unaff_RDI + 0xf0);

-  if ((*(uint *)(lVar2 + 0xa58) >> 0xf & 1) != 0) {

-    PopFasr = bVar11;

-  }

-  BootAppSvnInfo._0_4_ = *(undefined4 *)(lVar2 + 0x1120);

-  BootAppSvnInfo._4_4_ = *(undefined4 *)(lVar2 + 0x1124);

-  DAT_140 = *(undefined4 *)(lVar2 + 0x1128);

-  uRam0000000140f0d4bc = *(undefined4 *)(lVar2 + 0x112c);

-  *(undefined8 *)(uVar10 - 8) = 0x140c64918;

+  lVar1 = *(longlong *)(param_2 + 0xf0);

+  if ((*(uint *)(lVar1 + 0xa58) >> 0xf & 1) != 0) {

+    PopFasr = 1;

+  }

+  BootAppSvnInfo._0_4_ = *(undefined4 *)(lVar1 + 0x1120);

+  BootAppSvnInfo._4_4_ = *(undefined4 *)(lVar1 + 0x1124);

+  DAT_140 = *(undefined4 *)(lVar1 + 0x1128);

+  uRam0000000140f0d4bc = *(undefined4 *)(lVar1 + 0x112c);

   PopAcquirePolicyLock();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6491d;

   PopCoalescingInitialize();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64922;

   PopReleasePolicyLock();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6492a;

   PopInitializeDirectedDrips(3);

-  *(undefined8 *)(uVar10 - 8) = 0x140c6492f;

   PopDripsWatchdogInitialize();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64934;

   PopSetupAudioEventNotification();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64939;

   PopSetupMixedRealitytNotification();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6493e;

   PopSetupFullScrenVideoNotification();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64943;

   PopSetupUserPresencePredictionNotification();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64948;

   PopSetupSprActiveSessionChangeNotification();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6494d;

   PopSetupAirplaneModeNotification();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64952;

   PopSetupBluetoothChargingNotification();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64957;

   PopSetupMobileHotspotNotification();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6495c;

   PopThermalHandlePreviousShutdown();

-  PopCheckpointEfiRuntimeRedirected = (byte)(*(uint *)(unaff_RDI + 0x108) >> 1) & bVar11;

-  *(undefined8 *)(uVar10 - 8) = 0x140c64972;

+  PopCheckpointEfiRuntimeRedirected = (byte)(*(uint *)(param_2 + 0x108) >> 1) & 1;

   TtmInit();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64977;

   PopReadErrataForIncorrectLidNotification();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6497c;

   PopLidReliabilityInit();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64981;

   PopEvaluateInputSuppressionRequired();

-  *(undefined8 *)(uVar10 - 8) = 0x140c64986;

-  iVar6 = Feature_NU4MP__private_IsEnabledDeviceUsageNoInline();

-  if (iVar6 != 0) {

-    *(undefined8 *)(uVar10 - 8) = 0x140c6498f;

+  iVar4 = Feature_NU4MP__private_IsEnabledDeviceUsageNoInline();

+  if (iVar4 != 0) {

     PopSetupUsb4DisplayPresenceNotification();

   }

-  *(undefined8 *)(uVar10 - 8) = 0x140c64994;

   PopPowerButtonSuppressionInit();

-  *(undefined8 *)(uVar10 - 8) = 0x140c6499c;

-  PopBatteryQueueWork(unaff_R12D);

-  *(undefined8 *)(uVar10 - 8) = 0x140c649a1;

+  PopBatteryQueueWork(1);

   PopSetupKsrCallbacks();

-  *(undefined8 *)(uVar10 - 8) = 0x140c649a6;

   PopHiberEvaluateSkippingMemoryMapValidation();

-  *(undefined8 *)(uVar10 - 8) = 0x140c649ab;

   PopReadErrataSkipMemoryOverwriteRequestControlLockAction();

-  iVar6 = iVar15;

+  uVar3 = uVar7;

 LAB_118:

-  return (byte)((uint)iVar6 >> 0x1f) ^ bVar11;

+  return (byte)(uVar3 >> 0x1f) ^ 1;

 }
```

## `PopConnectToPolicyDevice`  (modified)

```diff
--- PopConnectToPolicyDevice
+++ PopConnectToPolicyDevice
@@ -1,31 +1,102 @@
 

 /* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

 

-void PopConnectToPolicyDevice(longlong param_1)

+void PopConnectToPolicyDevice(int param_1,ushort *param_2)

 

 {

-  code *pcVar1;

-  uint in_EAX;

-  undefined8 unaff_RBX;

-  ulonglong uVar2;

-  undefined4 unaff_EBP;

-  undefined1 unaff_SIL;

-  undefined1 unaff_DIL;

+  undefined4 uVar1;

+  code *pcVar2;

+  longlong lVar3;

+  int iVar4;

+  longlong *plVar5;

+  longlong lVar6;

+  longlong lVar7;

+  longlong *plVar8;

+  undefined1 *puVar9;

+  undefined1 *puVar10;

+  undefined1 *puVar11;

+  longlong lVar12;

+  longlong local_res18 [2];

+  undefined1 auStack_58 [8];

+  undefined1 auStack_50 [24];

+  code *local_38;

+  longlong *local_30;

+  longlong *local_28;

   

-  uVar2 = (ulonglong)in_EAX;

-  *(undefined1 *)((ulonglong)&stack0x00000000 & 0xffffffff) =

-       *(undefined1 *)((ulonglong)&stack0x00000000 & 0xffffffff);

-  *(char *)(param_1 + 6) = *(char *)(param_1 + 6) + (char)((ulonglong)unaff_RBX >> 8);

-  *(undefined1 *)(uVar2 + 0x88) = unaff_SIL;

-  *(undefined8 *)(uVar2 - 8) = 0x140758ae4;

-  PopDirectedDripsNotify();

-  *(undefined8 *)(uVar2 - 8) = 0x140758aec;

-  PopPowerAggregatorEngageAggressiveStandbyActions(unaff_DIL);

-  pcVar1 = DAT_0;

-  *(undefined8 *)(uVar2 - 8) = 0x140758afa;

-  (*pcVar1)(unaff_EBP);

-  *(undefined8 *)(uVar2 - 8) = 0x140758b06;

-  PopAcquireRwLockExclusive(&PopPowerAggregatorLock);

+  puVar9 = auStack_58;

+  puVar10 = auStack_58;

+  local_res18[0] = 0;

+  lVar12 = (longlong)param_1 * 0x20;

+  plVar5 = (longlong *)**(longlong **)(&DAT_0 + lVar12);

+  if (plVar5 != *(longlong **)(&DAT_0 + lVar12)) {

+    do {

+      local_38 = (code *)CONCAT71(local_38._1_7_,1);

+      iVar4 = RtlCompareUnicodeStrings

+                        (plVar5[5],*(ushort *)(plVar5 + 4) >> 1,*(undefined8 *)(param_2 + 4),

+                         *param_2 >> 1);

+      if (iVar4 == 0) {

+        return;

+      }

+      plVar5 = (longlong *)*plVar5;

+    } while (plVar5 != (longlong *)*(longlong *)(&DAT_0 + lVar12));

+  }

+  plVar5 = (longlong *)

+           ExAllocatePool2(0x40,(uint)*param_2 + *(uint *)(&PopPolicyDeviceParameters + lVar12),

+                           *(undefined4 *)(&DAT_1 + lVar12));

+  if (plVar5 == (longlong *)0x0) {

+    return;

+  }

+  plVar5[5] = (ulonglong)*(uint *)(&PopPolicyDeviceParameters + lVar12) + (longlong)plVar5;

+  *(ushort *)((longlong)plVar5 + 0x22) = *param_2;

+  RtlCopyUnicodeString(plVar5 + 4,param_2);

+  *(int *)(plVar5 + 2) = param_1;

+  lVar6 = PopGetPolicyDeviceObject(plVar5 + 4,local_res18);

+  puVar11 = auStack_58;

+  if (lVar6 == 0) goto LAB_2;

+  lVar7 = IoAllocateIrp(*(undefined1 *)(lVar6 + 0x4c),0);

+  lVar3 = local_res18[0];

+  if (lVar7 == 0) {

+LAB_3:

+    ObfDereferenceObjectWithTag(lVar6,0x64506f50);

+  }

+  else {

+    local_28 = plVar5 + 3;

+    local_38 = PopPolicyDeviceTargetChange;

+    local_30 = plVar5;

+    iVar4 = IoRegisterPlugPlayNotification(3,0,local_res18[0],*(undefined8 *)(lVar6 + 8));

+    if (iVar4 < 0) {

+      IoFreeIrp(lVar7);

+      goto LAB_3;

+    }

+    plVar5[6] = lVar6;

+    plVar5[7] = lVar7;

+    (**(code **)(&DAT_4 + lVar12))(plVar5);

+    lVar6 = *(longlong *)(&DAT_0 + lVar12);

+    plVar8 = *(longlong **)(lVar6 + 8);

+    if (*plVar8 != lVar6) {

+      pcVar2 = (code *)swi(0x29);

+      lVar6 = (*pcVar2)(3);

+      puVar9 = auStack_50;

+    }

+    *plVar5 = lVar6;

+    plVar5[1] = (longlong)plVar8;

+    *plVar8 = (longlong)plVar5;

+    *(longlong **)(lVar6 + 8) = plVar5;

+    plVar5 = (longlong *)0x0;

+    puVar10 = puVar9;

+  }

+  if (lVar3 != 0) {

+    *(undefined8 *)(puVar10 + -8) = 0x140759c99;

+    ObfDereferenceObjectWithTag(lVar3,0x64506f50);

+  }

+  puVar11 = puVar10;

+  if (plVar5 == (longlong *)0x0) {

+    return;

+  }

+LAB_2:

+  uVar1 = *(undefined4 *)(&DAT_1 + lVar12);

+  *(undefined8 *)(puVar11 + -8) = 0x140759ca9;

+  ExFreePoolWithTag(plVar5,uVar1);

   return;

 }
```

## `PspIumInitialize`  (modified)

```diff
--- PspIumInitialize
+++ PspIumInitialize
@@ -1,36 +1,35 @@
 

-/* WARNING: Instruction at (ram,0x000140c37f95) overlaps instruction at (ram,0x000140c37f94)

-    */

+/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

 

-void PspIumInitialize(longlong param_1)

+undefined8 PspIumInitialize(void)

 

 {

-  ulonglong in_RAX;

   ulonglong uVar1;

-  char in_ZF;

   

-  if (param_1 != 1 && in_ZF != '\0') {

-    *(int *)(in_RAX - 0x77) = *(int *)(in_RAX - 0x77) + -1;

-    in_RAX = (ulonglong)((int)in_RAX + 0x38f0b3);

-  }

-  PspIumFreeMapping = in_RAX;

-  if (in_RAX != 0) {

+  if (VslVsmEnabled != '\0') {

+    _DAT_0 = PspIumWorker;

+    _DAT_1 = 0;

+    _PspIumWorkItem = 0;

+    PspIumFreeMapping = MmAllocateMappingAddress(0x1000,0x466d7356);

+    if (PspIumFreeMapping == 0) {

+      return 0;

+    }

     PspIumLogBuffer =

          (undefined4 *)MmAllocateIndependentPagesEx(0x2000,0xffffffff,0xffffffffffffffff,1);

     if (PspIumLogBuffer != (undefined4 *)0x0) {

       *PspIumLogBuffer = 0xffffffff;

       VslRegisterLogPages();

     }

     uVar1 = VslGetNestedPageProtectionFlags(0);

     if ((uVar1 & 0x40) != 0) {

       PspSystemMitigationOptions = PspSystemMitigationOptions & 0xffffff5fffffffff | 0x5000000000;

     }

     if (PspIumLogBuffer != (undefined4 *)0x0) {

-      DAT_0 = 0;

+      DAT_2 = 0;

       KeRegisterBugCheckReasonCallback

                 (&PspVsmLogCallbackRecord,PspVsmLogBugCheckCallback,2,"SecureKernelFailureLog");

     }

   }

-  return;

+  return 1;

 }
```

## `Pdcv2ActivationClientRegister`  (modified)

```diff
--- Pdcv2ActivationClientRegister
+++ Pdcv2ActivationClientRegister
@@ -1,10 +1,79 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void Pdcv2ActivationClientRegister(void)

+int Pdcv2ActivationClientRegister(undefined4 param_1,int *param_2,undefined8 *param_3)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  undefined4 *puVar1;

+  undefined4 *puVar2;

+  undefined8 *puVar3;

+  int iVar4;

+  int iVar5;

+  int iVar6;

+  undefined4 *puVar7;

+  longlong lVar8;

+  code *local_res18 [2];

+  

+  *param_3 = 0;

+  if ((*param_2 == 1) && (*(longlong *)(param_2 + 2) != 0)) {

+    puVar7 = (undefined4 *)PdcAllocate(1,0x120,0x32414450);

+    if (puVar7 == (undefined4 *)0x0) {

+      iVar6 = -0x3fffffe9;

+    }

+    else {

+      puVar1 = puVar7 + 2;

+      iVar6 = PdcRwLockInitialize2(puVar1);

+      if (-1 < iVar6) {

+        PdcAcquireRwLockExclusive2(puVar1,0);

+        lVar8 = PdcAllocate(0,0x18,0x45636450);

+        if (lVar8 != 0) {

+          KeInitializeEvent(lVar8,0,1);

+        }

+        *(longlong *)(puVar7 + 0x1c) = lVar8;

+        if (lVar8 == 0) {

+          iVar6 = -0x3fffff66;

+        }

+        else {

+          *puVar7 = 0x32414450;

+          puVar7[8] = param_1;

+          *(undefined1 *)(puVar7 + 0x12) = 1;

+          iVar6 = Feature_Servicing_PDCActivationsAVL__private_IsEnabledDeviceUsageNoInline();

+          if (iVar6 == 0) {

+            puVar2 = puVar7 + 0x14;

+            *(undefined4 **)(puVar7 + 0x16) = puVar2;

+            *(undefined4 **)puVar2 = puVar2;

+          }

+          else {

+            *(undefined8 *)(puVar7 + 0x18) = 0;

+          }

+          iVar6 = param_2[1];

+          iVar4 = param_2[2];

+          iVar5 = param_2[3];

+          local_res18[0] = Pdcv2pActivationClientCallback;

+          puVar7[0xc] = *param_2;

+          puVar7[0xd] = iVar6;

+          puVar7[0xe] = iVar4;

+          puVar7[0xf] = iVar5;

+          *(undefined8 *)(puVar7 + 0x10) = *(undefined8 *)(param_2 + 4);

+          iVar6 = PdcPortOpenCommon(param_1,7,puVar7,local_res18);

+          if (iVar6 == 0) {

+            *param_3 = puVar7;

+            PdcInitializeETW();

+            Pdcv2EventWrite_ACTIVATION_CLIENT_REGISTER(puVar7,0);

+            PdcReleaseRwLockExclusive2(puVar1,0);

+            return 0;

+          }

+          PdcCloseEvent(*(undefined8 *)(puVar7 + 0x1c));

+        }

+        puVar3 = (undefined8 *)(puVar7 + 2);

+        PdcReleaseRwLockExclusive2(puVar3,0);

+        ExFreePoolWithTag(*puVar3,0);

+        *puVar3 = 0;

+      }

+      ExFreePoolWithTag(puVar7,0);

+    }

+  }

+  else {

+    iVar6 = -0x3fffff10;

+  }

+  return iVar6;

 }
```

## `ApiSetQuerySchemaInfo2_V7`  (modified)

```diff
--- ApiSetQuerySchemaInfo2_V7
+++ ApiSetCompose_ProcessV7Extension_Phase1
@@ -1,11 +1,97 @@
 

-undefined8 ApiSetQuerySchemaInfo2_V7(void)

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+

+ulonglong ApiSetCompose_ProcessV7Extension_Phase1(undefined8 *param_1,uint *param_2,int *param_3)

 

 {

-  undefined4 unaff_EDI;

-  undefined4 *unaff_R15;

+  char cVar1;

+  uint uVar2;

+  uint uVar3;

+  ulonglong uVar4;

+  int *piVar5;

+  ulonglong uVar6;

+  int *piVar7;

+  undefined1 auStack_150 [32];

+  int aiStack_130 [4];

+  char cStack_120;

+  int *piStack_110;

+  int *piStack_108;

+  ulonglong uStack_20;

   

-  *unaff_R15 = unaff_EDI;

-  return 0;

+  uStack_20 = __security_cookie ^ (ulonglong)auStack_150;

+  piVar5 = (int *)*param_1;

+  cVar1 = ApiSetIsSchemaSealed();

+  if ((cVar1 == '\0') &&

+     (((char)*piVar5 == '\a' ||

+      (((*piVar5 == 6 && (8 < (uint)piVar5[4])) && ((char)piVar5[7] == '\a')))))) {

+    uVar4 = ApiSetValidateSchemaFormat_V7();

+    if ((int)uVar4 < 0) {

+      return uVar4;

+    }

+    if ((*param_3 == 6) || ((char)*param_3 == '\a')) {

+      uVar4 = ApiSetValidateSchemaFormat(param_3);

+      if ((int)uVar4 < 0) {

+        return uVar4;

+      }

+      memset(aiStack_130,0,0x110);

+      ApiSetSchemaExpander_Initialize(*param_1,param_3,aiStack_130);

+      if ((char)*param_3 == '\a') {

+        uVar2 = func_0x000140660528();

+      }

+      else {

+        uVar2 = ApiSetCompose_V7_ProcessV6Extension_Phase0(param_3,aiStack_130);

+      }

+      if ((int)uVar2 < 0) {

+        return (ulonglong)uVar2;

+      }

+      uVar2 = ApiSetSchemaExpander_GetNewSchemaSize(aiStack_130);

+      uVar4 = (ulonglong)uVar2;

+      piVar5 = (int *)ExAllocatePool2(0x100,uVar2,0x68635341);

+      if (piVar5 == (int *)0x0) {

+        return 0xc0000017;

+      }

+      memset(piVar5,0x3f,uVar4);

+      piStack_110 = piVar5;

+      if (cStack_120 != '\0') {

+        piStack_110 = piVar5 + 7;

+      }

+      piStack_108 = piVar5;

+      ApiSetSchemaExpander_ExpandSchema(aiStack_130,uVar4);

+      if (((*piVar5 != 6) || ((uint)piVar5[4] < 9)) ||

+         (piVar7 = piVar5 + 7, (char)piVar5[7] != '\a')) {

+        piVar7 = piVar5;

+      }

+      uVar3 = ApiSetValidateSchemaHeader_V7(piVar7,uVar2);

+      uVar6 = (ulonglong)uVar3;

+      if (-1 < (int)uVar3) {

+        ApiSetSchemaExpander_MigrateSchemaData(aiStack_130);

+        uVar3 = ApiSetValidateSchemaElements_V7(piVar7);

+        uVar6 = (ulonglong)uVar3;

+        if (-1 < (int)uVar3) {

+          aiStack_130[0] = aiStack_130[0] + 1;

+          if ((char)*param_3 == '\a') {

+            uVar3 = func_0x0001406607ac();

+          }

+          else {

+            uVar3 = ApiSetCompose_V7_ProcessV6Extension_Phase1(param_3,aiStack_130);

+          }

+          uVar6 = (ulonglong)uVar3;

+          if (-1 < (int)uVar3) {

+            uVar3 = ApiSetValidateSchemaFormat_V7(piVar5,uVar4);

+            uVar6 = (ulonglong)uVar3;

+            if (-1 < (int)uVar3) {

+              ExFreePoolWithTag(*param_1,0);

+              *param_1 = piVar5;

+              *param_2 = uVar2;

+              return uVar6;

+            }

+          }

+        }

+      }

+      ExFreePoolWithTag(piVar5,0);

+      return uVar6;

+    }

+  }

+  return 0xc000000d;

 }
```

## `Pdcv2ActivationClientActivate`  (modified)

```diff
--- Pdcv2ActivationClientActivate
+++ Pdcv2ActivationClientActivate
@@ -1,7 +1,183 @@
 

-void Pdcv2ActivationClientActivate(void)

+/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

+

+int Pdcv2ActivationClientActivate

+              (int *param_1,longlong param_2,undefined8 param_3,uint param_4,longlong param_5,

+              undefined8 param_6,undefined8 *param_7,int *param_8)

 

 {

-  return;

+  undefined4 uVar1;

+  code *pcVar2;

+  undefined1 auVar3 [16];

+  longlong *plVar4;

+  char cVar5;

+  int iVar6;

+  int iVar7;

+  undefined8 *puVar8;

+  int *piVar9;

+  undefined8 *puVar10;

+  undefined1 *puVar11;

+  undefined1 *puVar12;

+  undefined8 uVar13;

+  ulonglong uVar14;

+  longlong *plVar15;

+  uint local_res20 [2];

+  undefined1 auStack_378 [8];

+  undefined1 auStack_370 [24];

+  undefined1 local_358 [40];

+  undefined4 local_330;

+  int local_320;

+  int local_31c;

+  undefined8 local_318;

+  undefined4 local_310;

+  undefined8 local_308;

+  undefined4 local_300;

+  undefined4 local_2fc;

+  undefined1 local_2f8 [256];

+  undefined1 local_1f8 [280];

+  undefined1 local_e0 [168];

+  

+  puVar12 = auStack_378;

+  puVar11 = auStack_378;

+  local_res20[0] = param_4;

+  memset(local_358,0,800);

+  local_res20[0] = local_res20[0] & 0xffffff00;

+  if (param_8 == (int *)0x0) {

+    param_1 = (int *)0x0;

+    local_320 = -0x3fffff0a;

+LAB_0:

+    puVar8 = (undefined8 *)0x0;

+    puVar11 = auStack_378;

+    iVar6 = local_320;

+  }

+  else {

+    *param_8 = 1;

+    if (param_7 == (undefined8 *)0x0) {

+      param_1 = (int *)0x0;

+      local_320 = -0x3fffff0b;

+      goto LAB_0;

+    }

+    *param_7 = 0;

+    if ((param_1 == (int *)0x0) || (*param_1 != 0x32414450)) {

+      param_1 = (int *)0x0;

+      local_320 = -0x3fffff11;

+      goto LAB_0;

+    }

+    cVar5 = Pdcv2pValidateActivationParameters(param_2);

+    if ((cVar5 == '\0') ||

+       (cVar5 = Pdcv2pValidateExtraActivationParameters(param_2,1), cVar5 == '\0')) {

+      local_320 = -0x3fffff10;

+      goto LAB_0;

+    }

+    if (param_5 == 0) {

+      local_320 = -0x3fffff0d;

+      goto LAB_0;

+    }

+    PdcAcquireRwLockExclusive2(param_1 + 2,local_res20);

+    if (*(longlong *)(param_1 + 10) == 0) {

+      local_320 = -0x3ffff900;

+      goto LAB_0;

+    }

+    puVar8 = (undefined8 *)PdcAllocate(1,0x260,0x41434450);

+    if (puVar8 == (undefined8 *)0x0) {

+      local_320 = -0x3fffffe9;

+      goto LAB_0;

+    }

+    *(undefined4 *)(puVar8 + 3) = 0x41434450;

+    uVar14 = 0x80;

+    *(undefined4 *)((longlong)puVar8 + 0x1c) = 1;

+    puVar8[4] = param_1;

+    auVar3._8_8_ = 0;

+    auVar3._0_8_ = _DAT_1 << 8;

+    puVar8[6] = SUB168(auVar3 * (ZEXT416(_DAT_2) << 0x20),8);

+    puVar8[5] = param_3;

+    uVar1 = *(undefined4 *)(param_2 + 4);

+    *(undefined4 *)(puVar8 + 7) = 1;

+    *(undefined4 *)((longlong)puVar8 + 0x3c) = uVar1;

+    RtlStringCchCopyW(puVar8 + 10,0x80,param_5);

+    if (*(longlong *)(param_2 + 0x10) != 0) {

+      RtlStringCchCopyW(puVar8 + 0x2a,uVar14 & 0xffffffff);

+    }

+    local_308 = *(undefined8 *)(param_2 + 8);

+    local_300 = 0;

+    local_2fc = *(undefined4 *)(param_2 + 4);

+    local_330 = 10;

+    local_310 = 1;

+    RtlStringCchCopyW(local_2f8,uVar14,param_5);

+    if (*(longlong *)(param_2 + 0x10) != 0) {

+      RtlStringCchCopyW(local_1f8,uVar14);

+    }

+    if (*(longlong *)(param_2 + 0x18) != 0) {

+      PdcpResizeDiagnosticContext(*(longlong *)(param_2 + 0x18),local_e0);

+    }

+    iVar6 = PdcPortSendMessageSynchronously(*(undefined8 *)(param_1 + 10),local_358);

+    if (iVar6 < 0) {

+      ExFreePoolWithTag(puVar8,0);

+      local_320 = iVar6;

+      goto LAB_0;

+    }

+    *param_8 = local_31c;

+    iVar6 = local_320;

+    if ((local_320 < 0) || (local_31c == 300)) {

+      ExFreePoolWithTag(puVar8,0);

+      if (-1 < local_320) goto LAB_3;

+      goto LAB_0;

+    }

+    puVar8[0x4b] = local_318;

+    *(undefined1 *)((longlong)puVar8 + 0x44) = 0;

+    *(int *)(puVar8 + 8) = local_31c;

+    param_1[0x40] = param_1[0x40] + 1;

+    param_1[0x41] = param_1[0x41] + 1;

+    param_1[0x43] = param_1[0x43] + 1;

+    iVar7 = Feature_Servicing_PDCActivationsAVL__private_IsEnabledDeviceUsageNoInline();

+    if (iVar7 == 0) {

+      piVar9 = param_1 + 0x14;

+      puVar10 = *(undefined8 **)(param_1 + 0x16);

+      puVar11 = auStack_378;

+      if ((int *)*puVar10 != piVar9) {

+        puVar10 = (undefined8 *)0x3;

+        pcVar2 = (code *)swi(0x29);

+        piVar9 = (int *)(*pcVar2)();

+        puVar11 = auStack_370;

+      }

+      *puVar8 = piVar9;

+      puVar8[1] = puVar10;

+      *puVar10 = puVar8;

+      *(undefined8 **)(piVar9 + 2) = puVar8;

+    }

+    else {

+      plVar15 = *(longlong **)(param_1 + 0x18);

+      uVar13 = 0;

+      plVar4 = plVar15;

+      if (plVar15 != (longlong *)0x0) {

+        do {

+          while( true ) {

+            plVar15 = plVar4;

+            iVar7 = PdcpActivationClientTableCompareRoutine(puVar8 + 0x4b,plVar15);

+            if (iVar7 < 0) break;

+            plVar4 = (longlong *)plVar15[1];

+            if ((longlong *)plVar15[1] == (longlong *)0x0) {

+              uVar13 = 1;

+              goto LAB_4;

+            }

+          }

+          plVar4 = (longlong *)*plVar15;

+        } while ((longlong *)*plVar15 != (longlong *)0x0);

+        uVar13 = 0;

+      }

+LAB_4:

+      RtlAvlInsertNodeEx(param_1 + 0x18,plVar15,uVar13,puVar8);

+    }

+    *param_7 = puVar8;

+  }

+  *(undefined8 *)(puVar11 + -8) = 0x1409ecab8;

+  Pdcv2EventWrite_ACTIVATION_CLIENT_ACTIVATE(puVar8,param_1,iVar6);

+  puVar12 = puVar11;

+LAB_3:

+  if ((char)local_res20[0] != '\0') {

+    *(undefined8 *)(puVar12 + -8) = 0x1409ecad1;

+    PdcReleaseRwLockExclusive2(param_1 + 2,local_res20);

+  }

+  return iVar6;

 }
```

## `ApiSetSchemaExpander_InsertHostEntry`  (modified)

```diff
--- ApiSetSchemaExpander_InsertHostEntry
+++ ApiSetSchemaExpander_InsertHostEntry
@@ -1,55 +1,34 @@
 

-undefined2

-ApiSetSchemaExpander_InsertHostEntry

-          (longlong param_1,longlong param_2,undefined8 param_3,undefined1 param_4,

-          undefined8 param_5,undefined8 param_6,undefined2 param_7)

+undefined8

+ApiSetSchemaExpander_InsertHostEntry(longlong param_1,undefined8 *param_2,ushort *param_3)

 

 {

-  byte bVar1;

-  byte bVar2;

-  char cVar3;

-  uint uVar4;

-  uint uVar5;

-  ulonglong uVar6;

-  undefined7 uVar7;

-  char cVar8;

-  ulonglong uVar9;

-  undefined7 uVar10;

-  byte bVar11;

+  short *psVar1;

+  ushort uVar2;

+  undefined2 uVar3;

+  undefined8 uVar4;

+  longlong lVar5;

   

-  uVar9 = CONCAT71((int7)((ulonglong)param_3 >> 8),*(byte *)(param_1 + 2)) & 0xffffffffffffff10;

-  bVar1 = *(byte *)(param_1 + 2) & 8;

-  uVar6 = CONCAT71((int7)((ulonglong)param_2 >> 8),*(byte *)(param_2 + 9)) & 0xffffffffffffff02;

-  bVar11 = *(byte *)(param_2 + 9) & 4;

-  uVar10 = (undefined7)(uVar9 >> 8);

-  uVar7 = (undefined7)(uVar6 >> 8);

-  cVar8 = (char)uVar9;

-  cVar3 = (char)uVar6;

-  if (bVar11 == 0) {

-    uVar4 = ApiSetpGetSearchKeyHash

-                      (param_3,CONCAT71(uVar7,cVar3 != '\0'),CONCAT71(uVar10,bVar1 != 0),

-                       cVar8 != '\0',*(undefined1 *)(param_2 + 10));

+  uVar2 = *(ushort *)(param_1 + 0xd0);

+  *param_3 = uVar2;

+  *(ushort *)(param_1 + 0xd0) = uVar2 + 1;

+  lVar5 = *(longlong *)(param_1 + 0x20);

+  uVar4 = ApiSetpInsertHashEntry(lVar5,lVar5 + 0x5c,uVar2,param_2,*(byte *)(lVar5 + 0x65) >> 1 & 1);

+  if (-1 < (int)uVar4) {

+    lVar5 = *(longlong *)(param_1 + 0x20);

+    uVar3 = *(undefined2 *)((longlong)param_2 + 0x12);

+    uVar4 = *param_2;

+    lVar5 = (ulonglong)*(uint *)(lVar5 + 0x5c) +

+            lVar5 + ((ulonglong)*(byte *)(lVar5 + 100) * (ulonglong)*param_3 -

+                    (ulonglong)*(ushort *)(lVar5 + 0x12));

+    *(undefined2 *)(lVar5 + 8) = uVar3;

+    uVar4 = ApiSetSchemaExpander_AllocateWString(param_1,uVar4,uVar3,lVar5 + 4);

+    if (-1 < (int)uVar4) {

+      psVar1 = (short *)(*(longlong *)(param_1 + 0x20) + 0x60);

+      *psVar1 = *psVar1 + 1;

+      uVar4 = 0;

+    }

   }

-  else {

-    bVar2 = ApiSetpGetSearchKeyHash

-                      (param_3,CONCAT71(uVar7,cVar3 != '\0'),CONCAT71(uVar10,bVar1 != 0),

-                       cVar8 != '\0',*(undefined1 *)(param_2 + 10));

-    uVar4 = (uint)bVar2;

-  }

-  if (bVar11 == 0) {

-    uVar5 = ApiSetpGetSearchKeyHash

-                      (param_3,param_4,bVar1 != 0,cVar8 != '\0',*(undefined1 *)(param_2 + 0xb));

-  }

-  else {

-    bVar1 = ApiSetpGetSearchKeyHash

-                      (param_3,param_4,bVar1 != 0,cVar8 != '\0',*(undefined1 *)(param_2 + 0xb));

-    uVar5 = (uint)bVar1;

-  }

-  param_7 = 0;

-  cVar3 = ApiSetpFindHashtableIndexAndVerify_V7(param_1,param_2,uVar4,uVar5,&param_7);

-  if (cVar3 == '\0') {

-    param_7 = 0xffff;

-  }

-  return param_7;

+  return uVar4;

 }
```

## `SepGetLowBoxNumberEntry`  (modified)

```diff
--- SepGetLowBoxNumberEntry
+++ SepGetLowBoxNumberEntry
@@ -1,10 +1,94 @@
 

-/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

-

-void SepGetLowBoxNumberEntry(void)

+undefined8 SepGetLowBoxNumberEntry(longlong param_1,longlong param_2,longlong *param_3)

 

 {

-  EtwWrite(EtwpMemoryProvRegHandle);

-  return;

+  uint *puVar1;

+  longlong *plVar2;

+  uint uVar3;

+  undefined8 uVar4;

+  code *pcVar5;

+  char cVar6;

+  uint uVar7;

+  int iVar8;

+  longlong lVar9;

+  longlong lVar10;

+  undefined1 *puVar11;

+  ulonglong uVar12;

+  longlong local_res8;

+  undefined1 auStack_58 [8];

+  undefined1 auStack_50 [24];

+  

+  puVar11 = auStack_58;

+  uVar4 = *(undefined8 *)(param_1 + 0x18);

+  puVar1 = (uint *)(param_1 + 8);

+  local_res8 = 0;

+  SepFindMatchingLowBoxNumberEntry(uVar4,param_2,&local_res8);

+  if (local_res8 != 0) {

+    LOCK();

+    plVar2 = (longlong *)(local_res8 + 0x18);

+    lVar9 = *plVar2;

+    *plVar2 = *plVar2 + 1;

+    UNLOCK();

+    if (lVar9 + 1 < 2) {

+      pcVar5 = (code *)swi(0x29);

+      (*pcVar5)(0xe);

+      puVar11 = auStack_50;

+    }

+    *param_3 = *(longlong *)(puVar11 + 0x60);

+    return 0;

+  }

+  iVar8 = (uint)*(byte *)(param_2 + 1) * 4;

+  lVar9 = ExAllocatePool2(0x100,iVar8 + 0x40,0x734c6553);

+  if (lVar9 == 0) {

+    return 0xc000009a;

+  }

+  *(longlong *)(lVar9 + 0x20) = lVar9 + 0x38;

+  RtlCopySid(iVar8 + 8);

+  uVar7 = RtlFindClearBitsAndSet(puVar1,1);

+  if (uVar7 == 0xffffffff) {

+    uVar7 = RtlNumberOfSetBits(puVar1);

+    if ((0x10000 < uVar7 * 2) ||

+       (lVar10 = ExAllocatePool2(0x100,(uVar7 & 0x7fffffff) >> 2,0x734c6553), lVar10 == 0))

+    goto LAB_0;

+    ExFreePoolWithTag(*(undefined8 *)(param_1 + 0x10),0);

+    *puVar1 = uVar7 * 2;

+    *(longlong *)(param_1 + 0x10) = lVar10;

+    RtlClearAllBits(puVar1);

+    RtlSetBits(puVar1,0,uVar7 & 0x7fffffff);

+    uVar7 = RtlFindClearBitsAndSet(puVar1,1,0);

+  }

+  if (uVar7 < 0xffff) {

+    *(undefined8 *)(lVar9 + 0x30) = 0;

+    *(uint *)(lVar9 + 0x28) = uVar7 + 1;

+    *(undefined8 *)(lVar9 + 0x18) = 1;

+    uVar3 = *(uint *)(param_2 + 8 + (ulonglong)(*(byte *)(param_2 + 1) - 1) * 4);

+    uVar12 = (ulonglong)uVar3 + 1;

+    if (uVar3 != 0) {

+      uVar12 = (ulonglong)uVar3;

+    }

+    cVar6 = RtlInsertEntryHashTable(uVar4,lVar9,uVar12,0);

+    if (cVar6 == '\0') {

+      ExFreePoolWithTag(lVar9,0);

+      RtlClearBits(puVar1,1,uVar7);

+      return 0xc000009a;

+    }

+    iVar8 = Feature_LowBoxNumberEntryReferenceIssue__private_IsEnabledDeviceUsageNoInline();

+    if (iVar8 == 0) {

+      LOCK();

+      plVar2 = (longlong *)(lVar9 + 0x18);

+      lVar10 = *plVar2;

+      *plVar2 = *plVar2 + 1;

+      UNLOCK();

+      if (lVar10 + 1 < 2) {

+        pcVar5 = (code *)swi(0x29);

+        (*pcVar5)(0xe);

+      }

+    }

+    *param_3 = lVar9;

+    return 0;

+  }

+LAB_0:

+  ExFreePoolWithTag(lVar9,0);

+  return 0xc000009a;

 }
```

## `MiAllocatePagesForMdl`  (modified)

```diff
--- MiAllocatePagesForMdl
+++ MiAllocatePagesForMdl
@@ -1,84 +1,126 @@
 

-/* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

 

-ulonglong MiAllocatePagesForMdl(undefined8 param_1,longlong param_2,longlong *param_3)

+longlong MiAllocatePagesForMdl

+                   (undefined8 param_1,undefined8 param_2,undefined8 param_3,longlong param_4,

+                   undefined8 param_5,undefined4 param_6,undefined4 param_7,uint param_8,

+                   undefined8 param_9,longlong param_10)

 

 {

-  longlong *plVar1;

-  byte *pbVar2;

-  longlong lVar3;

-  char cVar4;

+  char cVar1;

+  int iVar2;

+  uint uVar3;

+  undefined8 uVar4;

   longlong lVar5;

-  longlong lVar6;

+  ulonglong uVar6;

   ulonglong uVar7;

-  longlong unaff_RBX;

-  uint unaff_ESI;

-  bool in_ZF;

-  bool in_OF;

+  ulonglong uVar8;

+  undefined8 in_CR8;

+  undefined1 auStack_168 [32];

+  longlong local_148;

+  undefined8 local_140;

+  uint local_138;

+  ulonglong local_130;

+  undefined8 local_128;

+  undefined8 local_120;

+  uint local_118;

+  longlong local_110;

+  longlong local_108;

+  undefined8 local_100;

+  undefined1 local_f8 [32];

+  longlong local_d8;

+  longlong local_c8;

+  uint local_c0;

+  longlong local_b8;

+  uint local_64;

+  ulonglong local_58;

   

-  cVar4 = (char)unaff_ESI;

-  if (in_OF) {

-code_r0x0001403946b6:

-    if (in_ZF) {

+  local_58 = __security_cookie ^ (ulonglong)auStack_168;

+  local_100 = param_9;

+  memset(local_f8,0,0x98);

+  uVar4 = KeQueryPerformanceCounter(0);

+  local_120 = param_9;

+  local_128 = CONCAT44(local_128._4_4_,param_8);

+  local_130 = CONCAT44(local_130._4_4_,param_7);

+  local_138 = param_6;

+  local_140 = param_5;

+  local_148 = param_4;

+  iVar2 = MiValidateMdlAllocationRequest(local_f8,param_1,param_2,param_3);

+  uVar6 = 0;

+  if (-1 < iVar2) {

+    if (param_10 != 0) {

+      local_64 = local_64 | 1;

+      local_b8 = param_10;

+    }

+    iVar2 = MiObtainMdlCharges(local_f8);

+    if (iVar2 < 0) {

+      if ((local_64 & 1) != 0) {

+        local_b8 = 0;

+      }

+    }

+    else {

+      local_108 = local_d8;

+      local_110 = local_b8;

+      local_118 = 0;

+      *(undefined4 *)(local_b8 + 0x28) = 0;

+      MiFindPagesForMdl(local_f8);

+      uVar3 = *(uint *)(local_110 + 0x28);

+      lVar5 = (ulonglong)(uVar3 >> 0xc) * local_c8;

+      uVar7 = uVar6;

+      if (lVar5 - local_108 != 0) {

+        do {

+          if ((local_c0 & 0x80) == 0) goto LAB_0;

+          uVar8 = uVar6;

+          if (local_118 == uVar3) {

+            if (((3 < (uint)uVar7) || (1 < (byte)in_CR8)) || ((local_c0 & 8) != 0)) break;

+            KeDelayExecutionThread(0,0,&Mi10Milliseconds);

+            uVar8 = (ulonglong)((uint)uVar7 + 1);

+          }

+          local_c0 = local_c0 & 0xfffeffff;

+          local_118 = *(uint *)(local_110 + 0x28);

+          MiFindPagesForMdl(local_f8);

+          uVar3 = *(uint *)(local_110 + 0x28);

+          lVar5 = (ulonglong)(uVar3 >> 0xc) * local_c8;

+          uVar7 = uVar8;

+        } while (lVar5 - local_108 != 0);

+        if (lVar5 != local_108) {

 LAB_0:

-      if (*(char *)(param_2 + 0x41) != cVar4) {

-        pbVar2 = (byte *)(*(longlong *)(param_2 + 0xb8) + 3);

-        *pbVar2 = *pbVar2 | 1;

-        uVar7 = FUN_1406dfe7e();

-        return uVar7;

+          MiReturnMdlExcess(local_f8);

+        }

       }

-      ExFreePoolWithTag();

-      goto LAB_1;

+      lVar5 = local_b8;

+      if (local_b8 != 0) {

+        if ((param_8 & 0x40) == 0) {

+          MiInitializeMdlBatchPages(local_f8);

+        }

+        if ((DAT_1 & 1) != 0) {

+          local_148 = local_c8;

+          MiLogMdlRangeEvent(local_100,lVar5 + 0x30,0x278,*(uint *)(lVar5 + 0x28) >> 0xc);

+        }

+        if ((local_c0 & 0x100) != 0) {

+          local_b8 = MiRemoveMdlPages(lVar5,local_f8);

+        }

+      }

     }

   }

-  else if (in_ZF) {

-    if (*(char *)(param_2 + 0x44) != cVar4) {

-      in_ZF = *(char *)((longlong)param_3 + 0x1a) == cVar4;

-      goto code_r0x0001403946b6;

+  lVar5 = local_b8;

+  cVar1 = VfPtIsAptEnabledOnKernel();

+  if (cVar1 != '\0') {

+    VfPtMiscPoolNotification();

+    lVar5 = local_b8;

+  }

+  if ((local_c0 & 0x80000000) == 0) {

+    if (lVar5 != 0) {

+      uVar6 = (ulonglong)*(uint *)(lVar5 + 0x28) * local_c8;

     }

-    goto LAB_0;

+    local_138 = local_c0;

+    local_140 = CONCAT44(local_140._4_4_,param_7);

+    local_148 = param_5;

+    local_130 = uVar6;

+    local_128 = uVar4;

+    EtwTraceMdlAllocationEvent();

+    lVar5 = local_b8;

   }

-  lVar3 = *param_3;

-  ObfReferenceObjectWithTag(lVar3,0x70436f49);

-  unaff_ESI = (**(code **)(unaff_RBX + 0x10))();

-  ExFreePoolWithTag();

-  if (ObpTraceFlags != 0) {

-    ObpPushStackInfo(lVar3 + -0x30,0,1,0x70436f49);

-  }

-  LOCK();

-  plVar1 = (longlong *)(lVar3 + -0x30);

-  lVar6 = *plVar1;

-  *plVar1 = *plVar1 + -1;

-  UNLOCK();

-  lVar5 = lVar6 + -1;

-  if (lVar5 == 0 || lVar6 < 1) {

-    if (*(longlong *)(lVar3 + -0x28) != 0) {

-                    /* WARNING: Subroutine does not return */

-      KeBugCheckEx(0x18,*(undefined8 *)

-                         (&ObTypeIndexTable +

-                         (lVar3 - 0x30U >> 8 & 0xff ^ (ulonglong)*(byte *)(lVar3 + -0x18) ^

-                         (ulonglong)ObHeaderCookie) * 8),lVar3,1,*(longlong *)(lVar3 + -0x28));

-    }

-    if (lVar5 < 0) {

-                    /* WARNING: Subroutine does not return */

-      KeBugCheckEx(0x18,0,lVar3,2,lVar5);

-    }

-    cVar4 = KeAreAllApcsDisabled();

-    if (cVar4 == '\0') {

-      lVar6 = OBJECT_HEADER_TO_HANDLE_REVOCATION_INFO();

-      if (lVar6 != 0) {

-        ObpHandleRevocationBlockRemoveObject(lVar6);

-      }

-      if (ObpTraceFlags != 0) {

-        ObpDeregisterObject(lVar3 + -0x30);

-      }

-      ObpRemoveObjectRoutine(lVar3 + -0x30,0);

-    }

-    else {

-      ObpDeferObjectDeletion(lVar3 + -0x30);

-    }

-  }

-LAB_1:

-  return (ulonglong)unaff_ESI;

+  return lVar5;

 }
```

## `Feature_TestUex12__private_IsEnabledOtherReporting`  (modified)

```diff
--- Feature_TestUex12__private_IsEnabledOtherReporting
+++ PdcRwLockInitialize2
@@ -1,10 +1,22 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void Feature_TestUex12__private_IsEnabledOtherReporting(void)

+undefined8 PdcRwLockInitialize2(longlong *param_1)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  longlong lVar1;

+  undefined8 uVar2;

+  

+  lVar1 = PdcAllocate(0,0x38,0x4c636450);

+  uVar2 = 0;

+  if (lVar1 == 0) {

+    uVar2 = 0xc0000017;

+  }

+  else {

+    *param_1 = 0;

+    param_1[1] = 0;

+    param_1[2] = 0;

+    KeInitializeMutex(lVar1,0);

+    *param_1 = lVar1;

+  }

+  return uVar2;

 }
```

## `ExAllocatePool2`  (modified)

```diff
--- ExAllocatePool2 calling
+++ ExAllocatePool2 calling
@@ -534,89 +534,89 @@
-FUN_140403e8e
-FUN_14048ada8
-FUN_1404b4658
-FUN_1404cc81c
-FUN_140507cd0
-FUN_14065402c
-FUN_1406e4ab8
-FUN_1406ee076
-FUN_1406f02ab
-FUN_1406f3224
-FUN_1406f3b20
-FUN_1406f3dbc
-FUN_1406f418c
-FUN_1406f7c28
-FUN_1406f81c4
-FUN_1406f857c
-FUN_14091d694
-FUN_14091d9dc
-FUN_14091eaf0
-FUN_140920507
-FUN_14095b5b0
-FUN_14095c440
-FUN_140960838
-FUN_14097a17f
-FUN_140983015
-FUN_1409c3372
-FUN_1409cd7d4
-FUN_1409da134
-FUN_1409da4c0
-FUN_1409db868
-FUN_1409f4d28
-FUN_1409f5154
-FUN_1409f580c
-FUN_140a003d0
-FUN_140a278cc
-FUN_140a3272c
-FUN_140a46536
-FUN_140a47f90
-FUN_140a4f32c
-FUN_140a5aeb6
-FUN_140a5c04c
-FUN_140a5d974
-FUN_140a714c0
-FUN_140a76726
-FUN_140aabc28
-FUN_140ab32cc
-FUN_140ab5268
-FUN_140ab56b0
-FUN_140ab5ce0
-FUN_140ab8f8c
-FUN_140ab9570
-FUN_140abb350
-FUN_140abc314
-FUN_140abdbc0
-FUN_140b08c8e
-FUN_140b08e4c
-FUN_140b0cd17
-FUN_140b0e144
-FUN_140b1873e
-FUN_140b1bcc6
-FUN_140b1e348
-FUN_140b1ec50
-FUN_140b2112a
-FUN_140b22946
-FUN_140b23386
-FUN_140b233c8
-FUN_140b23401
-FUN_140b2348e
-FUN_140b2421c
-FUN_140b24534
-FUN_140b24a72
-FUN_140b251de
-FUN_140b282bb
-FUN_140b28ba8
-FUN_140b2b8c2
-FUN_140b2ba12
-FUN_140b2bb0e
-FUN_140b2c45f
-FUN_140b2f80a
-FUN_140b3108b
-FUN_140b33b10
-FUN_140b33c54
-FUN_140b35a7e
-FUN_140b37508
-FUN_140b3917e
-FUN_140b398cc
-FUN_140b39fe7
-FUN_140b3a208
-FUN_140b3c3a8
+FUN_140406cce
+FUN_14048c378
+FUN_1404b4708
+FUN_1404cc5ec
+FUN_140507ca0
+FUN_14065426c
+FUN_1406e0c11
+FUN_1406e54a2
+FUN_1406eec26
+FUN_1406f4224
+FUN_1406f4b20
+FUN_1406f4dbc
+FUN_1406f518c
+FUN_1406f8c28
+FUN_1406f91c4
+FUN_1406f957c
+FUN_14091e324
+FUN_14091e66c
+FUN_14091f780
+FUN_140921197
+FUN_14095bb80
+FUN_14095ca10
+FUN_140960e08
+FUN_14097a18f
+FUN_140983025
+FUN_1409c3092
+FUN_1409cd864
+FUN_1409da1c4
+FUN_1409da550
+FUN_1409db8f8
+FUN_1409f50b8
+FUN_1409f54e4
+FUN_1409f5b9c
+FUN_140a007a0
+FUN_140a27fdc
+FUN_140a317ec
+FUN_140a45a16
+FUN_140a47470
+FUN_140a4e6ac
+FUN_140a5a0f6
+FUN_140a5b28c
+FUN_140a5cbb4
+FUN_140a70880
+FUN_140a75a56
+FUN_140aaa338
+FUN_140ab1aa0
+FUN_140ab3a38
+FUN_140ab3e80
+FUN_140ab44b0
+FUN_140ab78ac
+FUN_140ab7e90
+FUN_140ab9c70
+FUN_140abac34
+FUN_140abc4e0
+FUN_140b0974e
+FUN_140b0990c
+FUN_140b0d7d7
+FUN_140b0ec04
+FUN_140b191fe
+FUN_140b1c58a
+FUN_140b1ea6e
+FUN_140b1f376
+FUN_140b21850
+FUN_140b22fb4
+FUN_140b239f4
+FUN_140b23a36
+FUN_140b23a6f
+FUN_140b23afc
+FUN_140b2488a
+FUN_140b24ba2
+FUN_140b250e0
+FUN_140b2584c
+FUN_140b28999
+FUN_140b29230
+FUN_140b2bf56
+FUN_140b2c0a6
+FUN_140b2c1a2
+FUN_140b2caf3
+FUN_140b2ff3e
+FUN_140b31813
+FUN_140b3428c
+FUN_140b343d0
+FUN_140b36236
+FUN_140b37c96
+FUN_140b3990c
+FUN_140b3a05a
+FUN_140b3a775
+FUN_140b3a996
+FUN_140b3cb7a
@@ -1085 +1084,0 @@
-Pdcv2ActivationClientActivate
@@ -1833 +1831,0 @@
-SepVerifyUIAccessChildProcessImage
```

## `MiStartDpcGang`  (modified)

```diff
--- MiStartDpcGang
+++ MiStartDpcGang
@@ -1,63 +1,86 @@
 

-void MiStartDpcGang(longlong *param_1)

+void MiStartDpcGang(longlong param_1)

 

 {

-  longlong *plVar1;

+  uint uVar1;

   longlong lVar2;

-  code *pcVar3;

-  char cVar4;

-  ulonglong in_RAX;

-  longlong unaff_RBP;

-  longlong unaff_RSI;

-  longlong *unaff_RDI;

-  longlong in_R11;

-  longlong unaff_R15;

-  undefined1 local_res20 [8];

+  bool bVar3;

+  uint uVar4;

+  longlong *plVar5;

+  ulonglong in_CR8;

+  undefined8 uVar6;

+  undefined8 local_res8;

   

-  *(ulonglong *)(in_R11 + -0x38) = in_RAX & 0xffffffffffffff20;

-  if ((in_RAX & 0x20) != 0) {

-    CcPerfLogWorkItemEnqueue();

+  uVar1 = *(uint *)(param_1 + 0xbc);

+  uVar4 = 0;

+  bVar3 = false;

+  *(undefined4 *)(param_1 + 0xcc) = 0;

+  *(undefined4 *)(param_1 + 0xb0) = 0;

+  local_res8 = 0;

+  if ((*(uint *)(param_1 + 0xb8) & 1) == 0) {

+    if (*(short *)(param_1 + 0x9a) == 0) {

+      return;

+    }

   }

-  KeAcquireInStackQueuedSpinLock(unaff_RBP + 0x340,local_res20);

-  if (((((int)param_1[0x10] == 3) &&

-       (*(longlong **)(unaff_RSI + 0x68) != (longlong *)(unaff_RSI + 0x68))) &&

-      ((*(ulonglong *)(unaff_RBP + 0x438) >> 2 <= *(ulonglong *)(unaff_RBP + 0x420) ||

-       (*(ulonglong *)(**(longlong **)(unaff_RBP + 8) + 0x4900) >> 1 <

-        *(ulonglong *)(unaff_RBP + 0x420))))) &&

-     (cVar4 = CcIsWriteBehindThreadpoolAtLowPriority(), cVar4 == '\0')) {

-    *(undefined1 *)(unaff_RSI + 0xe0) = 1;

+  else {

+    if (uVar1 != 0) {

+      FUN_1406d3b2a(0,(longlong *)(param_1 + 0x10),uVar1,uVar1);

+      return;

+    }

+    plVar5 = (longlong *)(*(longlong *)(param_1 + 0x10) + -8);

+    *plVar5 = *plVar5 + *(longlong *)(param_1 + 8);

   }

-  plVar1 = *(longlong **)(unaff_R15 + 8);

-  if (*plVar1 == unaff_R15) {

-    *param_1 = unaff_R15;

-    param_1[1] = (longlong)plVar1;

-    *plVar1 = (longlong)param_1;

-    *(longlong **)(unaff_R15 + 8) = param_1;

-    if (((*(char *)(unaff_RSI + 0xc4) == (char)unaff_RDI) &&

-        (plVar1 = (longlong *)(unaff_RSI + 0x38), (longlong *)*plVar1 != plVar1)) &&

-       (((int)param_1[0x10] != 2 ||

-        (*(int *)(unaff_RSI + 0xbc) + 1U <= *(uint *)(unaff_RBP + 0x508))))) {

-      unaff_RDI = (longlong *)*plVar1;

-      if (((longlong *)unaff_RDI[1] != plVar1) ||

-         (lVar2 = *unaff_RDI, *(longlong **)(lVar2 + 8) != unaff_RDI)) goto LAB_0;

-      *plVar1 = lVar2;

-      *(longlong **)(lVar2 + 8) = plVar1;

-      *(int *)(unaff_RSI + 0x30) = *(int *)(unaff_RSI + 0x30) + 1;

-      CcReferencePartitionAndPrivateVolumeCacheMap();

+  if ((uVar1 != 1) || ((*(uint *)(param_1 + 0xb8) & 2) != 0)) {

+    bVar3 = true;

+  }

+  while( true ) {

+    *(undefined4 *)(param_1 + 0xb0) = 0;

+    if (bVar3) {

+      KeGenericCallDpcEx(MiDpcGangTarget,param_1);

     }

-    KeReleaseInStackQueuedSpinLock(local_res20);

-    if (unaff_RDI != (longlong *)0x0) {

-      *unaff_RDI = 0;

-      ExQueueWorkItemToPartition

-                (unaff_RDI,0,*(undefined4 *)(unaff_RSI + 0x18),*(undefined8 *)(unaff_RBP + 8));

+    else {

+      MiGetGangAssignment(param_1,&local_res8);

+      uVar6 = 2;

+      if (KiIrqlFlags != 0) {

+        KiRaiseIrqlProcessIrqlFlags(in_CR8 & 0xff,2);

+      }

+      MiDoGangAssignment(param_1,&local_res8);

+      if (KiIrqlFlags != 0) {

+        KiLowerIrqlProcessIrqlFlags(uVar6,in_CR8 & 0xff);

+      }

+      in_CR8 = in_CR8 & 0xff;

     }

-    return;

+    if (*(int *)(param_1 + 0xcc) == 0) break;

+    *(undefined8 *)(param_1 + 0xcc) = 0;

+    RtlCopyMemory(*(void **)(param_1 + 0xe0),*(void **)(param_1 + 0xd8),

+                  (ulonglong)*(ushort *)(param_1 + 0xd6) << 4);

   }

-LAB_0:

-  pcVar3 = (code *)swi(0x29);

-  (*pcVar3)(3);

-  pcVar3 = (code *)swi(3);

-  (*pcVar3)();

-  return;

+  if (*(int *)(param_1 + 0x9c) != 0) {

+    if ((*(uint *)(param_1 + 0xb8) & 1) != 0) {

+      FUN_1406d3b64();

+      return;

+    }

+    plVar5 = *(longlong **)(param_1 + 8);

+    while( true ) {

+      if (uVar1 <= uVar4) {

+        if (*(longlong *)(param_1 + 8) != param_1 + 0x10) {

+          ExFreePoolWithTag(*(longlong *)(param_1 + 8),0);

+          *(undefined8 *)(param_1 + 8) = 0;

+        }

+        lVar2 = *(longlong *)(param_1 + 0xd8);

+        if ((lVar2 != 0) && (lVar2 != param_1 + 0xe8)) {

+          ExFreePoolWithTag(lVar2,0);

+        }

+        return;

+      }

+      if (*plVar5 != 0) break;

+      plVar5 = plVar5 + 1;

+      uVar4 = uVar4 + 1;

+    }

+                    /* WARNING: Subroutine does not return */

+    KeBugCheckEx(0x1a,0x6183,param_1,*(undefined8 *)(param_1 + 8),uVar4);

+  }

+                    /* WARNING: Subroutine does not return */

+  KeBugCheckEx(0x1a,0x6181,param_1,0,0);

 }
```

## `RtlAppendUnicodeStringToString`  (modified)

```diff
--- RtlAppendUnicodeStringToString
+++ IoGetIoPriorityHint
@@ -1,40 +1,92 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

-

-uint RtlAppendUnicodeStringToString

-               (longlong param_1,longlong param_2,undefined8 param_3,longlong param_4)

+void IoGetIoPriorityHint(longlong param_1,longlong param_2)

 

 {

-  int *piVar1;

-  uint *puVar2;

-  int iVar3;

-  uint uVar4;

-  byte bVar5;

-  uint in_EAX;

-  ulonglong uVar6;

-  longlong unaff_RBX;

-  longlong unaff_RBP;

-  uint unaff_EDI;

-  uint in_R10D;

+  undefined2 *puVar1;

+  undefined2 *puVar2;

+  undefined1 *puVar3;

+  undefined1 *puVar4;

+  undefined1 uVar5;

+  char cVar6;

+  int iVar7;

+  longlong lVar8;

+  longlong lVar9;

+  ushort unaff_SI;

+  undefined1 in_R10B;

+  undefined4 unaff_R13D;

+  byte unaff_R15B;

+  bool in_CF;

+  bool in_ZF;

+  undefined1 *puStack0000000000000028;

+  undefined2 *puStack0000000000000030;

+  undefined1 uStack0000000000000080;

+  undefined1 uStack0000000000000088;

+  ushort in_stack_00000090;

   

-  piVar1 = (int *)(param_4 + 3);

-  *piVar1 = *piVar1 + in_EAX;

-  iVar3 = *piVar1;

-  puVar2 = (uint *)(unaff_RBX + -0x48f0fc20);

-  *puVar2 = *puVar2 << 4 | *puVar2 >> 0x1c;

-  uVar6 = param_1 - 1;

-  if (uVar6 == 0 || iVar3 == 0) {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-    halt_baddata();

+  uStack0000000000000088 =

+       *(undefined1 *)

+        (param_1 + 0xb7 +

+        CONCAT71((int7)((ulonglong)param_2 >> 8),*(undefined1 *)(param_1 + 0xb5 + param_2)));

+  uStack0000000000000080 = in_R10B;

+  if (!in_CF && !in_ZF) {

+    do {

+      lVar9 = (ulonglong)unaff_SI * 0x510 + PpmParkNodes;

+      puStack0000000000000028 = (undefined1 *)(lVar9 + 0x49a);

+      puVar1 = (undefined2 *)(lVar9 + 0x49c);

+      lVar8 = lVar9 + 0x458;

+      puVar2 = (undefined2 *)(lVar9 + 0x498);

+      puStack0000000000000030 = puVar1;

+      cVar6 = PpmParkComputeSnapStatistics

+                        (unaff_R13D,uStack0000000000000080,uStack0000000000000088,lVar8,puVar2);

+      if (cVar6 != '\0') {

+        iVar7 = Feature_PpmParkEx__private_IsEnabledDeviceUsageNoInline();

+        if (iVar7 == 0) {

+          PpmEventParkNodeRecordedStats

+                    (*(undefined2 *)(lVar9 + 4),*(undefined8 *)(lVar9 + 0x10),*(undefined1 *)puVar2,

+                     lVar8,*(undefined1 *)puVar1);

+        }

+        else {

+          PpmEventParkNodeRecordedStatsEx(unaff_SI,lVar9 + 0x30,*puVar2,lVar8,*puVar1);

+        }

+      }

+      uVar5 = uStack0000000000000080;

+      if ((*(byte *)(lVar9 + 0x4a1) != unaff_R15B) && (unaff_R15B < *(byte *)(lVar9 + 0xc))) {

+        do {

+          lVar8 = (ulonglong)unaff_R15B * 0x280 + *(longlong *)(lVar9 + 0x508);

+          puVar1 = (undefined2 *)(lVar8 + 0x278);

+          puVar3 = (undefined1 *)(lVar8 + 0x27c);

+          puVar4 = (undefined1 *)(lVar8 + 0x240);

+          puVar2 = (undefined2 *)(lVar8 + 0x27a);

+          puStack0000000000000028 = puVar3;

+          puStack0000000000000030 = puVar1;

+          cVar6 = PpmParkComputeSnapStatistics

+                            (unaff_R13D,uVar5,uStack0000000000000088,puVar4,puVar2);

+          if (cVar6 != '\0') {

+            iVar7 = Feature_PpmParkEx__private_IsEnabledDeviceUsageNoInline();

+            if (iVar7 == 0) {

+              puStack0000000000000030 =

+                   (undefined2 *)CONCAT71(puStack0000000000000030._1_7_,*(undefined1 *)puVar1);

+              puStack0000000000000028 = puVar4;

+              PpmEventParkNodeClassRecordedStats

+                        (*(undefined2 *)(lVar9 + 4),*(undefined8 *)(lVar9 + 0x10),unaff_R15B,

+                         *(undefined1 *)puVar2,*puVar3);

+            }

+            else {

+              puStack0000000000000028 =

+                   (undefined1 *)CONCAT62(puStack0000000000000028._2_6_,*puVar1);

+              PpmEventParkNodeClassRecordedStatsEx(lVar9 + 0x30,unaff_R15B,*puVar2,*puVar3,puVar4);

+            }

+          }

+          unaff_R15B = unaff_R15B + 1;

+        } while (unaff_R15B < *(byte *)(lVar9 + 0xc));

+        unaff_R15B = 0;

+        unaff_SI = in_stack_00000090;

+      }

+      PpmPerfRecordMostActiveWorkloadClass(lVar9);

+      unaff_SI = unaff_SI + 1;

+      in_stack_00000090 = unaff_SI;

+    } while (unaff_SI < PpmParkNumNodes);

   }

-  uVar4 = *(uint *)(param_2 + 0xc);

-  *(undefined8 *)(unaff_RBP + -0x18) = param_3;

-  *(undefined8 *)(unaff_RBP + -0x20) = param_3;

-  bVar5 = (char)uVar6 + (char)(uint)((ulonglong)in_EAX * (uVar6 & 0xffffffff) >> 0x23) * -0xf + 1U &

-          0x1f;

-  return (*(ushort *)(unaff_RBP + -0x18 + (ulonglong)((int)unaff_RBX + 1 + uVar4 % 3 & 3) * 2) ^

-         unaff_EDI) * (uint)*(ushort *)(unaff_RBP + -0x20 + (ulonglong)(in_R10D & 3) * 2) ^

-         (unaff_EDI >> bVar5 | unaff_EDI << 0x20 - bVar5);

+  return;

 }
```

## `PopBatteryInitPhaseTwo`  (modified)

```diff
--- PopBatteryInitPhaseTwo
+++ PopBatteryInitPhaseTwo
@@ -1,31 +1,32 @@
 

 void PopBatteryInitPhaseTwo(void)

 

 {

   int iVar1;

-  undefined4 unaff_ESI;

+  undefined1 local_res8 [32];

   

+  PopReadUlongPowerKey

+            (L"ChargerWeakDetectionThresholdPercent",&WeakChargerChargeDropMilliPercent,1,1,10,100);

   WeakChargerChargeDropMilliPercent = WeakChargerChargeDropMilliPercent * 1000;

   PopReadUlongPowerKey

             (L"BatteryChargeTrajectoryThresholdPercent",

-             &BatteryChargeTrajectoryThresholdMilliPercent,unaff_ESI,unaff_ESI,10);

+             &BatteryChargeTrajectoryThresholdMilliPercent,1,1,10,100);

   BatteryChargeTrajectoryThresholdMilliPercent = BatteryChargeTrajectoryThresholdMilliPercent * 1000

   ;

   iVar1 = Feature_Servicing_BatteryTestExempt__private_IsEnabledDeviceUsageNoInline();

   if (iVar1 != 0) {

     PopBatteryTestExemptPolicyRegKeyAccess(0);

   }

   iVar1 = EtwRegister(&BATTERY_ETW_PROVIDER,PopBatteryEtwCallback,0,&PopBatteryEtwHandle);

   if (-1 < iVar1) {

-    PopBatteryEtwRegistered = (undefined1)unaff_ESI;

+    PopBatteryEtwRegistered = 1;

     ExSubscribeWnfStateChange

-              (&stack0x00000040,&WNF_USB_ERROR_NOTIFICATION,unaff_ESI,0,

-               PopUsbErrorWNFNotificationCallback);

+              (local_res8,&WNF_USB_ERROR_NOTIFICATION,1,0,PopUsbErrorWNFNotificationCallback,0);

     ExSubscribeWnfStateChange

-              (&stack0x00000040,&WNF_PO_POWER_ADAPTER_REC_OVERRIDE,unaff_ESI,0,

-               PopPowerAdapterRecOverrideWnfCallback);

-    func_0x000140c33f54();

+              (local_res8,&WNF_PO_POWER_ADAPTER_REC_OVERRIDE,1,0,

+               PopPowerAdapterRecOverrideWnfCallback,0);

+    PopBatteryReadOscBits();

   }

   return;

 }
```

## `FsepInitializeOverridesViewForGovernedFeatures`  (modified)

```diff
--- FsepInitializeOverridesViewForGovernedFeatures
+++ FsepInitializeOverridesViewForGovernedFeatures
@@ -1,10 +1,65 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void FsepInitializeOverridesViewForGovernedFeatures(void)

+void FsepInitializeOverridesViewForGovernedFeatures(uint *param_1,uint *param_2,longlong param_3)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  longlong lVar1;

+  uint uVar2;

+  uint *puVar3;

+  uint uVar4;

+  uint uVar5;

+  ulonglong uVar6;

+  uint uVar7;

+  

+  lVar1 = *(longlong *)(param_1 + 2);

+  uVar7 = 0;

+  uVar6 = 0;

+  if (param_2 != (uint *)0x0) {

+    while ((uVar7 < *param_2 && (uVar5 = (uint)uVar6, uVar5 < (*param_1 & 0xffff)))) {

+      uVar2 = *(uint *)((-(ulonglong)(param_2 != (uint *)0x0) & (ulonglong)(param_2 + 1)) +

+                       (ulonglong)uVar7 * 0x10);

+      uVar4 = *(uint *)((longlong)param_1 + uVar6 * 0x10 + lVar1);

+      if (uVar4 < uVar2) {

+        puVar3 = (uint *)(param_3 + uVar6 * 4);

+        *puVar3 = *puVar3 & 0xffffff81;

+        *(uint *)((longlong)param_1 + uVar6 * 0x10 + lVar1 + 0xc) =

+             *(uint *)((longlong)param_1 + uVar6 * 0x10 + lVar1 + 0xc) & 0xff7fff80 | 0x7fff80;

+LAB_0:

+        uVar6 = (ulonglong)(uVar5 + 1);

+      }

+      else {

+        if (uVar4 <= uVar2) {

+          puVar3 = param_2 + 2;

+          uVar4 = *(uint *)(param_3 + uVar6 * 4) | 1;

+          *(uint *)(param_3 + uVar6 * 4) = uVar4;

+          if (param_2 == (uint *)0x0) {

+            puVar3 = (uint *)0x4;

+          }

+          puVar3 = puVar3 + (ulonglong)uVar7 * 4;

+          uVar4 = uVar4 ^ (*puVar3 * 2 ^ uVar4) & 0x1e;

+          *(uint *)(param_3 + uVar6 * 4) = uVar4;

+          uVar4 = uVar4 ^ (*puVar3 * 2 ^ uVar4) & 0x60;

+          *(uint *)(param_3 + uVar6 * 4) = uVar4;

+          *(uint *)(param_3 + uVar6 * 4) = (*puVar3 * 2 ^ uVar4) & 0x80 ^ uVar4;

+          uVar4 = *puVar3;

+          uVar2 = *(uint *)((longlong)param_1 + uVar6 * 0x10 + lVar1 + 0xc) | 1;

+          uVar2 = (uVar4 * 8 ^ uVar2) & 0x78 ^ uVar2;

+          uVar2 = (uVar4 >> 3 ^ uVar2) & 6 ^ uVar2;

+          uVar2 = (uVar5 << 7 ^ uVar2) & 0x7fff80 ^ uVar2;

+          *(uint *)((longlong)param_1 + uVar6 * 0x10 + lVar1 + 0xc) =

+               (uVar4 << 0x11 ^ uVar2) & 0x800000 ^ uVar2;

+          uVar7 = uVar7 + 1;

+          goto LAB_0;

+        }

+        uVar7 = uVar7 + 1;

+      }

+    }

+  }

+  for (; (uint)uVar6 < (*param_1 & 0xffff); uVar6 = (ulonglong)((uint)uVar6 + 1)) {

+    puVar3 = (uint *)(param_3 + uVar6 * 4);

+    *puVar3 = *puVar3 & 0xffffff81;

+    *(uint *)((longlong)param_1 + uVar6 * 0x10 + lVar1 + 0xc) =

+         *(uint *)((longlong)param_1 + uVar6 * 0x10 + lVar1 + 0xc) & 0xff7fff80 | 0x7fff80;

+  }

+  return;

 }
```

## `IopfCompleteRequest`  (modified)

```diff
--- IopfCompleteRequest
+++ IopfCompleteRequest
@@ -1,49 +1,522 @@
 

+/* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

 /* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

 

-undefined4 IopfCompleteRequest(void)

+ulonglong IopfCompleteRequest(longlong *param_1,char param_2)

 

 {

-  uint uVar1;

-  int iVar2;

-  char *in_RAX;

-  longlong unaff_RBX;

-  uint unaff_R15D;

-  char in_stack_00000060;

-  undefined8 in_stack_00000068;

-  undefined8 in_stack_00000070;

-  undefined1 *in_stack_00000200;

-  undefined4 *in_stack_00000ce0;

-  undefined2 *in_stack_00000ce8;

+  int *piVar1;

+  byte *pbVar2;

+  byte bVar3;

+  byte bVar4;

+  ushort uVar5;

+  wchar_t wVar6;

+  uint uVar7;

+  char *pcVar8;

+  longlong lVar9;

+  undefined8 *puVar10;

+  undefined4 *puVar11;

+  void *pvVar12;

+  undefined8 *puVar13;

+  undefined4 uVar14;

+  undefined4 uVar15;

+  bool bVar16;

+  undefined8 *puVar17;

+  char cVar18;

+  undefined1 uVar19;

+  int iVar20;

+  wchar_t *pwVar21;

+  longlong lVar22;

+  ulonglong uVar23;

+  ulonglong uVar24;

+  longlong lVar25;

+  code *pcVar26;

+  wchar_t *pwVar27;

+  longlong lVar28;

+  byte *pbVar29;

+  longlong *plVar30;

+  undefined1 *puVar31;

+  longlong lVar32;

+  bool bVar33;

+  ulonglong in_CR8;

+  undefined8 uVar34;

+  undefined1 auStack_178 [8];

+  undefined1 auStack_170 [24];

+  longlong *local_158;

+  longlong local_150;

+  undefined4 local_148;

+  longlong ***local_140;

+  longlong *local_138 [2];

+  longlong local_128;

+  longlong local_120;

+  longlong local_118;

+  longlong *local_110;

+  undefined8 local_108;

+  undefined1 local_100 [8];

+  longlong **local_f8;

+  undefined8 local_f0;

+  longlong *local_e8;

+  undefined8 local_e0;

+  wchar_t *local_d8;

+  int local_d0;

+  int local_cc;

+  wchar_t local_c8 [64];

+  ulonglong local_48;

   

-  *in_RAX = *in_RAX + (char)in_RAX;

-  *(uint *)(unaff_RBX + 0x90) = (uint)in_RAX & 0x20 | 0x807040;

-  if (((unaff_R15D & 0x40000080) != 0x40000080) ||

-     (iVar2 = FsRtlpCheckSharingAgainstOplockOwner

-                        (in_stack_00000068,*(undefined8 *)(unaff_RBX + 8),*in_stack_00000ce0,

-                         *in_stack_00000ce8), iVar2 < 0)) {

-    in_stack_00000060 = '\x01';

-  }

-  if (in_stack_00000060 != '\0') {

-    uVar1 = *(uint *)(unaff_RBX + 0x90);

-    if ((unaff_R15D & 1) == 0) {

-      if ((uVar1 & 0x40) != 0) {

-        FsRtlpOplockTryStartBreakAckTimeout(unaff_RBX + 0xa0,*(undefined8 *)(unaff_RBX + 0xb0));

-      }

-      if (in_stack_00000070._1_1_ != '\0') {

-        FsRtlpModifyThreadPriorities();

-        FsRtlpOplockSendModernAppTermination();

-      }

-      *in_stack_00000200 = 0;

-      in_stack_00000070._4_4_ = FsRtlpWaitOnIrp();

+  local_48 = __security_cookie ^ (ulonglong)auStack_178;

+  lVar22 = 0;

+  local_128 = 0;

+  puVar31 = auStack_178;

+  local_138[0] = param_1;

+  if (((char)(*(char *)((longlong)param_1 + 0x42) + '\x01') < *(char *)((longlong)param_1 + 0x43))

+     || (puVar31 = auStack_178, (short)*param_1 != 6)) {

+LAB_0:

+    *(longlong *)(puVar31 + 0x20) = lVar22;

+                    /* WARNING: Subroutine does not return */

+    *(undefined **)(puVar31 + -8) = &UNK_1;

+    KeBugCheckEx(0x44,param_1,0x1312);

+  }

+  pcVar8 = (char *)param_1[0x17];

+  if ((*(char *)((longlong)param_1 + 0x42) < *(char *)((longlong)param_1 + 0x43)) ||

+     (*pcVar8 != '\x16')) {

+    bVar16 = false;

+  }

+  else {

+    bVar16 = true;

+    PoDeviceReleaseIrp(param_1,pcVar8[1],*(undefined8 *)(pcVar8 + 0x28));

+  }

+  plVar30 = local_138[0];

+  uVar24 = 0;

+  if ((*(byte *)((longlong)local_138[0] + 0xd3) & 2) != 0) {

+    uVar24 = (ulonglong)*(uint *)(local_138[0] + 0x1e);

+  }

+  *(char *)((longlong)local_138[0] + 0x43) = *(char *)((longlong)local_138[0] + 0x43) + '\x01';

+  local_138[0][0x17] = local_138[0][0x17] + 0x48;

+  lVar32 = lVar22;

+  if (*(char *)((longlong)local_138[0] + 0x43) <=

+      (char)(*(char *)((longlong)local_138[0] + 0x42) + '\x01')) {

+    pbVar29 = (byte *)(pcVar8 + 3);

+    do {

+      lVar22 = -1;

+      lVar32 = 0;

+      *(byte *)((longlong)local_138[0] + 0x41) = *pbVar29 & 1;

+      iVar20 = (int)local_138[0][6];

+      if ((iVar20 < 0) && (iVar20 != (int)uVar24)) {

+        *pbVar29 = *pbVar29 | 2;

+        pbVar2 = (byte *)((longlong)plVar30 + 0xd3);

+        *pbVar2 = *pbVar2 | 2;

+        plVar30[0x1e] = (longlong)iVar20;

+        uVar24 = (longlong)iVar20;

+      }

+      bVar3 = *pbVar29;

+      if ((int)local_138[0][6] < 0) {

+        if (-1 < (char)bVar3) goto LAB_2;

+LAB_3:

+        bVar4 = pbVar29[-2];

+        *pbVar29 = bVar3 & 2;

+        pbVar29[-2] = 0;

+        pbVar29[-1] = 0;

+        pbVar29[5] = 0;

+        pbVar29[6] = 0;

+        pbVar29[7] = 0;

+        pbVar29[8] = 0;

+        pbVar29[9] = 0;

+        pbVar29[10] = 0;

+        pbVar29[0xb] = 0;

+        pbVar29[0xc] = 0;

+        pbVar29[0xd] = 0;

+        pbVar29[0xe] = 0;

+        pbVar29[0xf] = 0;

+        pbVar29[0x10] = 0;

+        pbVar29[0x11] = 0;

+        pbVar29[0x12] = 0;

+        pbVar29[0x13] = 0;

+        pbVar29[0x14] = 0;

+        pbVar29[0x15] = 0;

+        pbVar29[0x16] = 0;

+        pbVar29[0x17] = 0;

+        pbVar29[0x18] = 0;

+        pbVar29[0x19] = 0;

+        pbVar29[0x1a] = 0;

+        pbVar29[0x1b] = 0;

+        pbVar29[0x1c] = 0;

+        pbVar29[0x2d] = 0;

+        pbVar29[0x2e] = 0;

+        pbVar29[0x2f] = 0;

+        pbVar29[0x30] = 0;

+        pbVar29[0x31] = 0;

+        pbVar29[0x32] = 0;

+        pbVar29[0x33] = 0;

+        pbVar29[0x34] = 0;

+        lVar25 = lVar32;

+        if (*(char *)((longlong)local_138[0] + 0x43) !=

+            (char)(*(char *)((longlong)local_138[0] + 0x42) + '\x01')) {

+          lVar25 = *(longlong *)(local_138[0][0x17] + 0x28);

+        }

+        if (((bVar16) && ((byte)(bVar4 - 2) < 2)) && (lVar25 != 0)) {

+          bVar33 = PopDiagHandleRegistered != '\0';

+          local_110 = local_138[0];

+          *(longlong *)

+           (local_138[0][(longlong)*(char *)((longlong)local_138[0] + 0x42) * 9 + 0x19] + 0x28) =

+               lVar25;

+          local_118 = lVar25;

+          if (((bVar33) && (PopDiagHandle != 0)) &&

+             ((((lVar9 = *(longlong *)(PopDiagHandle + 0x20), *(int *)(lVar9 + 0x60) != 0 &&

+                ((2 < (byte)(*(char *)(lVar9 + 100) - 1U) &&

+                 ((*(ulonglong *)(lVar9 + 0x70) & 0x4000000000000008) != 0)))) &&

+               ((*(ulonglong *)(lVar9 + 0x78) & 0x4000000000000008) == *(ulonglong *)(lVar9 + 0x78))

+               ) || ((*(short *)(PopDiagHandle + 0x66) != 0 &&

+                     (cVar18 = EtwpLevelKeywordEnabled

+                                         (*(longlong *)(PopDiagHandle + 0x28) + 0x60,

+                                          CONCAT71((int7)((ulonglong)PopDiagHandle >> 8),4)),

+                     cVar18 != '\0')))))) {

+            local_cc = (int)lVar32;

+            if (local_118 == 0) {

+LAB_4:

+              iVar20 = local_cc;

+            }

+            else {

+              lVar9 = *(longlong *)(*(longlong *)(local_118 + 8) + 0x40);

+              if ((lVar9 == 0) ||

+                 (uVar5 = *(ushort *)(*(longlong *)(local_118 + 8) + 0x38), uVar5 == 0))

+              goto LAB_4;

+              pwVar27 = local_c8;

+              lVar28 = 0x40;

+              do {

+                if ((((ulonglong)(uVar5 >> 1) - 0x40) + lVar28 == 0) ||

+                   (wVar6 = *(wchar_t *)((lVar9 - (longlong)local_c8) + (longlong)pwVar27),

+                   wVar6 == L'\0')) break;

+                *pwVar27 = wVar6;

+                pwVar27 = pwVar27 + 1;

+                lVar28 = lVar28 + -1;

+              } while (lVar28 != 0);

+              pwVar21 = pwVar27 + -1;

+              if (lVar28 != 0) {

+                pwVar21 = pwVar27;

+              }

+              *pwVar21 = (wchar_t)lVar32;

+              iVar20 = 1;

+              if (lVar28 == 0) goto LAB_4;

+            }

+            local_f0 = 8;

+            local_e0 = 8;

+            local_d8 = local_c8;

+            if (iVar20 == 0) {

+              local_d8 = L"";

+            }

+            local_f8 = &local_110;

+            local_e8 = &local_118;

+            do {

+              lVar9 = lVar22 + 1;

+              lVar22 = lVar22 + 1;

+            } while (local_d8[lVar9] != L'\0');

+            local_d0 = (int)lVar22 * 2 + 2;

+            local_140 = &local_f8;

+            local_148 = 3;

+            local_158 = (longlong *)lVar32;

+            local_150 = lVar32;

+            EtwWriteEx(PopDiagHandle,&POP_ETW_EVENT_IRP_DRIVERACQUIRE,0,0);

+          }

+        }

+        uVar23 = (**(code **)(pbVar29 + 0x35))(lVar25,local_138[0],*(undefined8 *)(pbVar29 + 0x3d));

+        if ((int)uVar23 == -0x3fffffea) {

+          return uVar23;

+        }

+        if (bVar16) {

+          PoDeviceReleaseIrp(local_138[0],bVar4,lVar25);

+        }

+      }

+      else {

+        if ((bVar3 & 0x40) != 0) goto LAB_3;

+LAB_2:

+        if ((*(char *)((longlong)local_138[0] + 0x44) != '\0') && ((bVar3 & 0x20) != 0))

+        goto LAB_3;

+        if ((*(char *)((longlong)local_138[0] + 0x41) != '\0') &&

+           (*(char *)((longlong)local_138[0] + 0x43) <= *(char *)((longlong)local_138[0] + 0x42))) {

+          *(byte *)(local_138[0][0x17] + 3) = *(byte *)(local_138[0][0x17] + 3) | 1;

+        }

+        *pbVar29 = *pbVar29 & 2;

+        pbVar29[-2] = 0;

+        pbVar29[-1] = 0;

+        pbVar29[5] = 0;

+        pbVar29[6] = 0;

+        pbVar29[7] = 0;

+        pbVar29[8] = 0;

+        pbVar29[9] = 0;

+        pbVar29[10] = 0;

+        pbVar29[0xb] = 0;

+        pbVar29[0xc] = 0;

+        pbVar29[0xd] = 0;

+        pbVar29[0xe] = 0;

+        pbVar29[0xf] = 0;

+        pbVar29[0x10] = 0;

+        pbVar29[0x11] = 0;

+        pbVar29[0x12] = 0;

+        pbVar29[0x13] = 0;

+        pbVar29[0x14] = 0;

+        pbVar29[0x15] = 0;

+        pbVar29[0x16] = 0;

+        pbVar29[0x17] = 0;

+        pbVar29[0x18] = 0;

+        pbVar29[0x19] = 0;

+        pbVar29[0x1a] = 0;

+        pbVar29[0x1b] = 0;

+        pbVar29[0x1c] = 0;

+        pbVar29[0x2d] = 0;

+        pbVar29[0x2e] = 0;

+        pbVar29[0x2f] = 0;

+        pbVar29[0x30] = 0;

+        pbVar29[0x31] = 0;

+        pbVar29[0x32] = 0;

+        pbVar29[0x33] = 0;

+        pbVar29[0x34] = 0;

+      }

+      pbVar29 = pbVar29 + 0x48;

+      *(char *)((longlong)local_138[0] + 0x43) = *(char *)((longlong)local_138[0] + 0x43) + '\x01';

+      local_138[0][0x17] = local_138[0][0x17] + 0x48;

+      lVar32 = local_128;

+    } while (*(char *)((longlong)local_138[0] + 0x43) <=

+             (char)(*(char *)((longlong)local_138[0] + 0x42) + '\x01'));

+  }

+  plVar30 = local_138[0];

+  lVar22 = 0;

+  if ((*(uint *)(local_138[0] + 2) & 8) == 0) {

+    if (((int)local_138[0][6] == 0x104) && (2 < (ulonglong)local_138[0][7])) {

+      uVar24 = local_138[0][7] - 0xa0000003;

+      if ((uVar24 < 0x17) && ((0x400201UL >> (uVar24 & 0x3f) & 1) != 0)) {

+        lVar32 = local_138[0][0x14];

+        local_138[0][0x14] = 0;

+        local_128 = lVar32;

+      }

+      else {

+        *(undefined4 *)(local_138[0] + 6) = 0xc0000279;

+      }

     }

-    else {

-      if ((uVar1 >> 0x10 & 1) != 0) {

-        *(uint *)(unaff_RBX + 0x90) = uVar1 | 0x20000;

-      }

-      in_stack_00000070._4_4_ = 0x108;

+    if (((param_2 == '\0') && (local_138[0][0x18] != 0)) &&

+       ((*(uint *)(local_138[0] + 2) & 0x400) == 0)) {

+      lVar25 = IoGetRelatedDeviceObject();

+      if ((*(int *)(lVar25 + 0x48) == 8) || (*(int *)(lVar25 + 0x48) == 0x14)) {

+        param_2 = '\x01';

+      }

     }

-  }

-  return in_stack_00000070._4_4_;

+    if (local_138[0][0x14] != 0) {

+      ExFreePoolWithTag(local_138[0][0x14],0);

+      local_138[0][0x14] = 0;

+    }

+    pcVar26 = (code *)IopFreeIrpExtension(local_138[0],0xffffffffffffffff,1);

+    if ((pcVar26 == (code *)0x0) ||

+       (uVar24 = (*pcVar26)(local_138,local_138[0][0x18],param_2), (char)uVar24 == '\0')) {

+      uVar7 = *(uint *)(local_138[0] + 2);

+      if ((uVar7 & 0x402) == 0) {

+        for (puVar10 = (undefined8 *)local_138[0][1]; puVar10 != (undefined8 *)0x0;

+            puVar10 = (undefined8 *)*puVar10) {

+          if ((*(byte *)((longlong)puVar10 + 10) & 2) != 0) {

+            MmUnlockPages(puVar10);

+          }

+        }

+        if ((*(uint *)(local_138[0] + 2) & 0x2000) != 0) {

+          ObfDereferenceObjectWithTag(local_138[0][0x13],0x746c6644);

+        }

+        uVar7 = *(uint *)(local_138[0] + 2);

+        uVar24 = (ulonglong)uVar7;

+        if (((uVar7 >> 0xb & 1) != 0) && (*(char *)((longlong)local_138[0] + 0x41) == '\0')) {

+          if ((int)local_138[0][6] != 0x104) {

+            return uVar24;

+          }

+          if (0x16 < local_138[0][7] - 0xa0000003U) {

+            return uVar24;

+          }

+          if ((0x400201UL >> (local_138[0][7] - 0xa0000003U & 0x3f) & 1) == 0) {

+            return uVar24;

+          }

+          local_138[0][0x14] = lVar32;

+          return uVar24;

+        }

+        lVar25 = local_138[0][0x18];

+        pvVar12 = (void *)local_138[0][0x13];

+        local_120 = lVar25;

+        if ((uVar7 >> 0x15 & 1) == 0) {

+          plVar30 = local_138[0];

+          if (((uVar7 >> 0xd & 1) != 0) &&

+             (uVar24 = IopCompleteIrpInFileObjectList(local_138[0],lVar25,param_2),

+             plVar30 = local_138[0], (char)uVar24 != '\0')) {

+            return uVar24;

+          }

+        }

+        else {

+          iVar20 = Feature_1565498680__private_IsEnabledDeviceUsageNoInline();

+          plVar30 = local_138[0];

+          if (iVar20 == 0) {

+            cVar18 = IopDoesCompletionNeedsApc(local_138[0]);

+            if ((cVar18 == '\0') &&

+               ((*(char *)((longlong)plVar30 + 0x44) == '\0' ||

+                ((*(uint *)(plVar30 + 2) & 0x2000) != 0)))) {

+              uVar24 = IopIoRingCompleteIrp(plVar30,lVar25,param_2);

+              return uVar24;

+            }

+          }

+          else if ((*(uint *)(local_138[0] + 2) & 0x2000) == 0) {

+            if ((((*(char *)((longlong)local_138[0] + 0x44) == '\0') &&

+                 (cVar18 = KeAreAllApcsDisabled(), plVar30 = local_138[0], cVar18 == '\0')) &&

+                (lVar25 = local_120, lVar32 = local_128,

+                *(char *)((longlong)SystemReserved1[0xf] + 0x24a) != '\x01')) &&

+               (pvVar12 == SystemReserved1[0xf])) {

+              uVar24 = IopIoRingCompleteIrp(local_138[0],local_120,param_2);

+              return uVar24;

+            }

+          }

+          else {

+            cVar18 = IopDoesCompletionNeedsApc(local_138[0]);

+            if (cVar18 == '\0') {

+              uVar24 = IopIoRingCompleteIrp(plVar30,lVar25,param_2);

+              return uVar24;

+            }

+          }

+        }

+        if (pvVar12 != (void *)0x0) {

+          uVar19 = KeAcquireSpinLockRaiseToDpc((longlong)pvVar12 + 0x618);

+          KeReleaseSpinLock((longlong)pvVar12 + 0x618,uVar19);

+          plVar30 = local_138[0];

+        }

+        if (*(char *)((longlong)plVar30 + 0x44) != '\0') {

+          uVar19 = KeAcquireQueuedSpinLock(0xb);

+          lVar9 = local_138[0][0x13];

+          puVar10 = IopDeadIrps;

+          do {

+            puVar17 = puVar10;

+            if ((undefined8 **)puVar17 == &IopDeadIrps) {

+              if (lVar9 != 0) {

+                cVar18 = *(char *)((longlong)local_138[0] + 0x46);

+                *(undefined1 *)(local_138[0] + 0xf) = 0x12;

+                *(undefined1 *)((longlong)local_138[0] + 0x7a) = 0x58;

+                if (cVar18 == '\x02') {

+                  cVar18 = *(char *)(lVar9 + 0x24a);

+                }

+                *(char *)(local_138[0] + 0x19) = cVar18;

+                local_138[0][0x13] = (longlong)IopCompleteRequest;

+                local_138[0][0x10] = lVar9;

+                local_138[0][0x14] = (longlong)IopAbortRequest;

+                local_138[0][0x15] = 0;

+                *(undefined2 *)((longlong)local_138[0] + 0xc9) = 0;

+                local_138[0][0x16] = 0;

+                *(undefined1 *)((longlong)local_138[0] + 0x79) = 0;

+                KeInsertQueueApc(local_138[0] + 0xf,lVar25,lVar32,param_2);

+                uVar24 = KeReleaseQueuedSpinLock(0xb,uVar19);

+                return uVar24;

+              }

+              goto LAB_5;

+            }

+            puVar10 = (undefined8 *)*puVar17;

+          } while (puVar17 + -4 != local_138[0]);

+          if (((undefined8 *)puVar10[1] == puVar17) &&

+             (puVar13 = (undefined8 *)puVar17[1], (undefined8 *)*puVar13 == puVar17)) {

+            *puVar13 = puVar10;

+            puVar10[1] = puVar13;

+            puVar17[1] = puVar17;

+            *puVar17 = puVar17;

+            ObfDereferenceObjectWithTag(lVar9,0x746c6644);

+LAB_5:

+            KeReleaseQueuedSpinLock(0xb,uVar19);

+            uVar24 = IopDropIrp(local_138[0],lVar25);

+            return uVar24;

+          }

+          param_1 = (longlong *)0x3;

+          pcVar26 = (code *)swi(0x29);

+          (*pcVar26)(3);

+          puVar31 = auStack_170;

+          goto LAB_0;

+        }

+        if ((((pvVar12 == SystemReserved1[0xf]) &&

+             (*(short *)((longlong)SystemReserved1[0xf] + 0x1e6) == 0)) &&

+            (cVar18 = KeAreInterruptsEnabled(), cVar18 != '\0')) &&

+           (((char)in_CR8 == '\0' && (*(char *)((longlong)SystemReserved1[0xf] + 0x24a) != '\x01')))

+           ) {

+          local_108 = 1;

+          uVar34 = 1;

+          if (KiIrqlFlags != 0) {

+            KiRaiseIrqlProcessIrqlFlags(in_CR8 & 0xff,1);

+          }

+          local_158 = &local_128;

+          IopCompleteRequest(local_138[0] + 0xf,local_100,&local_108,&local_120);

+          if (KiIrqlFlags != 0) {

+            KiLowerIrqlProcessIrqlFlags(uVar34,in_CR8 & 0xff);

+          }

+          return in_CR8 & 0xff;

+        }

+        cVar18 = *(char *)((longlong)local_138[0] + 0x46);

+        *(undefined1 *)(local_138[0] + 0xf) = 0x12;

+        *(undefined1 *)((longlong)local_138[0] + 0x7a) = 0x58;

+        if (cVar18 == '\x02') {

+          cVar18 = *(char *)((longlong)pvVar12 + 0x24a);

+        }

+        *(char *)(local_138[0] + 0x19) = cVar18;

+        local_138[0][0x13] = (longlong)IopCompleteRequest;

+        local_138[0][0x14] = (longlong)IopAbortRequest;

+        local_138[0][0x10] = (longlong)pvVar12;

+        local_138[0][0x15] = 0;

+        *(undefined2 *)((longlong)local_138[0] + 0xc9) = 0;

+        local_138[0][0x16] = 0;

+        *(undefined1 *)((longlong)local_138[0] + 0x79) = 0;

+        lVar22 = local_120;

+        lVar32 = local_128;

+      }

+      else {

+        if ((uVar7 & 0x440) != 0) {

+          uVar14 = *(undefined4 *)((longlong)local_138[0] + 0x34);

+          lVar22 = local_138[0][7];

+          uVar15 = *(undefined4 *)((longlong)local_138[0] + 0x3c);

+          puVar11 = (undefined4 *)local_138[0][9];

+          *puVar11 = (int)local_138[0][6];

+          puVar11[1] = uVar14;

+          puVar11[2] = (int)lVar22;

+          puVar11[3] = uVar15;

+          if ((uVar7 & 0x42) != 0) {

+            IopDequeueIrpFromThread();

+            KeSetEvent(local_138[0][10],param_2,0);

+            uVar24 = IoFreeIrp(local_138[0]);

+            return uVar24;

+          }

+          uVar24 = KeSetEvent(local_138[0][10],param_2,0);

+          return uVar24;

+        }

+        IopDequeueIrpFromThread(local_138[0]);

+        cVar18 = *(char *)((longlong)local_138[0] + 0x46);

+        *(undefined1 *)(local_138[0] + 0xf) = 0x12;

+        *(undefined1 *)((longlong)local_138[0] + 0x7a) = 0x58;

+        if (cVar18 == '\x02') {

+          cVar18 = *(char *)(local_138[0][0x13] + 0x24a);

+        }

+        *(char *)(local_138[0] + 0x19) = cVar18;

+        local_138[0][0x10] = local_138[0][0x13];

+        local_138[0][0x13] = (longlong)IopCompletePageWrite;

+        local_138[0][0x14] = 0;

+        local_138[0][0x15] = 0;

+        *(undefined2 *)((longlong)local_138[0] + 0xc9) = 0;

+        local_138[0][0x16] = 0;

+        *(undefined1 *)((longlong)local_138[0] + 0x79) = 0;

+        lVar22 = 0;

+        lVar32 = 0;

+      }

+      uVar24 = KeInsertQueueApc(local_138[0] + 0xf,lVar22,lVar32,param_2);

+    }

+  }

+  else {

+    puVar10 = (undefined8 *)local_138[0][1];

+    lVar22 = local_138[0][3];

+    while (puVar10 != (undefined8 *)0x0) {

+      puVar10 = (undefined8 *)*puVar10;

+      IoFreeMdl();

+    }

+    uVar24 = IoFreeIrp(plVar30);

+    LOCK();

+    piVar1 = (int *)(lVar22 + 0x18);

+    iVar20 = *piVar1;

+    *piVar1 = *piVar1 + -1;

+    UNLOCK();

+    if (iVar20 == 1) {

+      uVar24 = IofCompleteRequest(lVar22,param_2);

+    }

+  }

+  return uVar24;

 }
```

## `MiFreePagesFromMdl`  (modified)

```diff
--- MiFreePagesFromMdl
+++ MiFreePagesFromMdl
@@ -1,17 +1,213 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void MiFreePagesFromMdl(void)

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+

+void MiFreePagesFromMdl(longlong param_1,uint param_2,uint param_3,longlong param_4)

 

 {

-  char in_AL;

-  undefined7 in_register_00000001;

+  bool bVar1;

+  uint uVar2;

+  int iVar3;

+  int iVar4;

+  int iVar5;

+  undefined1 *puVar6;

+  longlong lVar7;

+  ulonglong *puVar8;

+  uint uVar9;

+  uint uVar10;

+  ulonglong uVar11;

+  longlong lVar12;

+  longlong lVar13;

+  ulonglong *puVar14;

+  longlong lVar15;

+  undefined8 in_CR8;

+  undefined1 auStack_138 [32];

+  undefined1 *local_118;

+  undefined1 local_108;

+  uint local_104;

+  uint local_100;

+  uint local_fc;

+  uint local_f8;

+  longlong local_f0;

+  undefined4 local_e8 [2];

+  longlong local_e0;

+  ulonglong local_d8;

+  undefined8 local_d0;

+  ulonglong *local_c8;

+  undefined1 local_b8 [96];

+  ulonglong local_58;

   

-  *(char *)CONCAT71(in_register_00000001,in_AL) =

-       *(char *)CONCAT71(in_register_00000001,in_AL) + in_AL;

-  *(char *)CONCAT71(in_register_00000001,in_AL) =

-       *(char *)CONCAT71(in_register_00000001,in_AL) + in_AL;

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  local_58 = __security_cookie ^ (ulonglong)auStack_138;

+  local_100 = param_3;

+  local_fc = param_2;

+  memset(local_b8,0,0x60);

+  puVar6 = local_b8;

+  local_f0 = 0;

+  lVar7 = 4;

+  do {

+    *(undefined8 *)(puVar6 + 0x10) = 0;

+    *(undefined1 **)(puVar6 + 8) = puVar6;

+    *(undefined1 **)puVar6 = puVar6;

+    puVar6 = puVar6 + 0x18;

+    lVar7 = lVar7 + -1;

+  } while (lVar7 != 0);

+  iVar4 = 0;

+  local_104 = 1;

+  if ((*(ushort *)(param_1 + 10) >> 9 & 1) != 0) {

+    param_2 = param_2 & 0xfffffffe;

+    local_fc = param_2;

+    MiRetardMdl(param_1);

+  }

+  if ((*(byte *)(param_1 + 10) & 1) != 0) {

+    MmUnmapLockedPages(*(undefined8 *)(param_1 + 0x18),param_1);

+  }

+  if (((longlong)*(short *)(param_1 + 10) & 1U) != 0) {

+    local_118 = (undefined1 *)0x0;

+                    /* WARNING: Subroutine does not return */

+    KeBugCheckEx(0x1a,0x1238,param_1,(longlong)*(short *)(param_1 + 10));

+  }

+  puVar14 = (ulonglong *)(param_1 + 0x30);

+  lVar7 = 0;

+  uVar11 = (ulonglong)*(uint *)(param_1 + 0x28) + 0xfff +

+           (ulonglong)(*(int *)(param_1 + 0x2c) + *(int *)(param_1 + 0x20) & 0xfff) >> 0xc;

+  local_d8 = uVar11;

+  if ((DAT_0 & 1) != 0) {

+    local_118 = (undefined1 *)0x1;

+    MiLogMdlRangeEvent(param_4,puVar14,0x279,uVar11);

+  }

+  if (param_4 == 0) {

+    EtwTraceMdlFreeEvent(param_1,uVar11 << 0xc,param_2);

+  }

+  uVar9 = 0;

+  bVar1 = true;

+  lVar15 = 0;

+  lVar12 = 0;

+  local_d0 = in_CR8;

+  if (uVar11 != 0) {

+    do {

+      local_c8 = puVar14;

+      if ((DAT_1 < *puVar14) ||

+         ((*(ulonglong *)(*puVar14 * 0x30 + -0x21ffffffffd8) >> 0x36 & 1) == 0)) {

+        local_118 = (undefined1 *)*puVar14;

+                    /* WARNING: Subroutine does not return */

+        KeBugCheckEx(0x1a,0x1237,param_1,puVar14);

+      }

+      lVar12 = *puVar14 * 0x30;

+      lVar13 = lVar12 + -0x220000000000;

+      if ((*(ulonglong *)(lVar12 + -0x21ffffffffd8) & 0xffffffffff) != 0x3ffffffffe) {

+        local_118 = (undefined1 *)*puVar14;

+                    /* WARNING: Subroutine does not return */

+        KeBugCheckEx(0x1a,0x1236,param_1,puVar14);

+      }

+      local_e0 = *(longlong *)

+                  (DAT_2 +

+                  (ulonglong)

+                  ((uint)((ulonglong)*(undefined8 *)(lVar12 + -0x21ffffffffd8) >> 0x2b) & 0x3ff) * 8

+                  );

+      iVar3 = MiPageToNode(*puVar14);

+      if (((byte)((ulonglong)*(undefined8 *)(lVar12 + -0x21ffffffffd8) >> 0x3c) & 7) == 3) {

+        if ((char)local_d0 == '\x02') {

+          local_e8[0] = 0;

+          local_108 = 0x11;

+          while( true ) {

+            LOCK();

+            puVar8 = (ulonglong *)(lVar12 + -0x21ffffffffe8);

+            uVar11 = *puVar8;

+            *puVar8 = *puVar8 | 0x8000000000000000;

+            UNLOCK();

+            if (-1 < (longlong)uVar11) break;

+            do {

+              KeYieldProcessorEx(local_e8);

+            } while (*(longlong *)(lVar12 + -0x21ffffffffe8) < 0);

+          }

+        }

+        else {

+          local_108 = MiLockPageInline(lVar13);

+        }

+        MiSetPfnIdentity(lVar13,0);

+        MiUnlockPageInline(lVar13);

+        LOCK();

+        DAT_3 = DAT_3 + -1;

+        UNLOCK();

+      }

+      if (lVar15 == 0) {

+        local_f0 = local_e0;

+        local_104 = (*(uint *)(lVar12 + -0x21ffffffffe0) >> 0x10 & 0xff) >> 6;

+        iVar4 = MiIsPfnEnclave(lVar13);

+        uVar9 = uVar9 ^ (iVar4 << 2 ^ uVar9) & 4;

+LAB_4:

+        lVar15 = 1;

+        iVar4 = iVar3;

+      }

+      else {

+        uVar10 = uVar9 & 0xfffffffd;

+        uVar9 = uVar10 | 2;

+        if (local_f0 == local_e0) {

+          uVar9 = uVar10;

+        }

+        local_f8 = uVar9 & 2;

+        if ((((local_f8 != 0) || (iVar5 = MiIsPfnEnclave(lVar13), iVar5 != 0)) ||

+            ((*(uint *)(lVar12 + -0x21ffffffffe0) >> 0x10 & 0xff) >> 6 != local_104)) ||

+           (iVar3 != iVar4)) {

+LAB_5:

+          if (bVar1) {

+LAB_6:

+            uVar11 = puVar14[-lVar15];

+          }

+          else {

+LAB_7:

+            uVar11 = puVar14[-1];

+          }

+          uVar2 = local_fc;

+          local_118 = local_b8;

+          MiFreeMdlPageRun(uVar11,lVar15,local_fc,local_100);

+          uVar10 = local_100;

+          lVar7 = lVar7 + lVar15;

+          if (local_f8 != 0) {

+            MiZeroAndReleasePages(local_b8,uVar2,local_100);

+            if ((uVar9 & 4) == 0 && (uVar10 & 2) == 0) {

+              LOCK();

+              *(longlong *)(local_f0 + 0x4cc0) = *(longlong *)(local_f0 + 0x4cc0) - lVar7;

+              UNLOCK();

+            }

+            lVar7 = 0;

+            local_f0 = local_e0;

+          }

+          local_104 = (*(uint *)(lVar12 + -0x21ffffffffe0) >> 0x10 & 0xff) >> 6;

+          goto LAB_4;

+        }

+        if (*puVar14 != puVar14[-1] + 1) {

+          if (*puVar14 != puVar14[-1] - 1) goto LAB_5;

+          if ((lVar15 == 1) || (!bVar1)) {

+            bVar1 = false;

+            goto LAB_8;

+          }

+          goto LAB_6;

+        }

+        if ((lVar15 != 1) && (!bVar1)) goto LAB_7;

+        bVar1 = true;

+LAB_8:

+        lVar15 = lVar15 + 1;

+      }

+      puVar14 = puVar14 + 1;

+      local_d8 = local_d8 - 1;

+    } while (local_d8 != 0);

+    local_d8 = 0;

+    puVar8 = local_c8;

+    lVar12 = local_f0;

+    if (!bVar1) goto LAB_9;

+  }

+  puVar8 = puVar14 + -lVar15;

+LAB_9:

+  uVar10 = local_100;

+  local_118 = local_b8;

+  MiFreeMdlPageRun(*puVar8,lVar15,local_fc,local_100);

+  MiZeroAndReleasePages(local_b8,local_fc,uVar10);

+  if ((uVar9 & 4) == 0 && (uVar10 & 2) == 0) {

+    LOCK();

+    *(longlong *)(lVar12 + 0x4cc0) = *(longlong *)(lVar12 + 0x4cc0) - (lVar7 + lVar15);

+    UNLOCK();

+  }

+  *(ushort *)(param_1 + 10) = *(ushort *)(param_1 + 10) & 0xfffd;

+  return;

 }
```

## `SepAdjustPrivileges`  (modified)

```diff
--- SepAdjustPrivileges
+++ SepAdjustPrivileges
@@ -1,190 +1,273 @@
 

 /* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

 

-undefined4 SepAdjustPrivileges(void)

+ulonglong SepAdjustPrivileges(longlong param_1,char param_2,char param_3,uint param_4,

+                             ulonglong *param_5,longlong param_6,int *param_7,uint *param_8,

+                             undefined1 *param_9)

 

 {

-  uint uVar1;

-  ulonglong uVar2;

-  int iVar3;

+  char cVar1;

+  int iVar2;

+  ulonglong uVar3;

   ulonglong uVar4;

-  longlong unaff_RBX;

-  longlong unaff_RBP;

-  int unaff_ESI;

-  undefined4 uVar5;

+  ulonglong uVar5;

   uint uVar6;

-  uint unaff_R12D;

-  ulonglong *unaff_R13;

-  ulonglong *puVar7;

-  longlong unaff_R14;

-  uint *unaff_R15;

-  undefined1 in_ZF;

-  ulonglong extraout_XMM0_Qa;

-  ulonglong uVar8;

-  char cStack0000000000000030;

-  char cStack0000000000000031;

-  char cStack0000000000000032;

-  uint uStack0000000000000034;

-  ulonglong in_stack_00000038;

-  uint in_stack_00000040;

-  undefined4 uStack0000000000000048;

-  uint uStack000000000000004c;

-  char cStack0000000000000050;

-  uint uStack0000000000000054;

-  ulonglong in_stack_00000058;

-  uint in_stack_00000060;

-  longlong in_stack_00000068;

-  longlong in_stack_00000070;

-  ulonglong in_stack_00000078;

+  uint uVar8;

+  undefined1 auStack_438 [32];

+  uint local_418;

+  byte local_410;

+  char local_408;

+  char local_407;

+  char local_406 [2];

+  uint local_404;

+  ulonglong local_400;

+  uint local_3f8;

+  uint local_3f0;

+  uint local_3ec;

+  uint local_3e8;

+  uint local_3e4;

+  ulonglong local_3e0;

+  uint local_3d8;

+  longlong local_3d0;

+  ulonglong local_3c8;

+  ulonglong local_3c0 [2];

+  undefined1 *local_3b0;

+  int *local_3a8;

+  ulonglong local_398;

+  uint auStack_390 [106];

+  ulonglong local_1e8;

+  uint auStack_1e0 [106];

+  ulonglong local_38;

+  ulonglong uVar7;

   

-code_r0x000140984f90:

-  uVar8 = in_stack_00000038;

-  if (!(bool)in_ZF) {

-    *(ulonglong *)(unaff_RBX + 0x48) =

-         *(ulonglong *)(unaff_RBX + 0x48) | 1L << (in_stack_00000038 & 0x3f);

-    goto LAB_0;

+  local_38 = __security_cookie ^ (ulonglong)auStack_438;

+  uVar7 = 0;

+  local_3d0 = param_6;

+  local_3a8 = param_7;

+  local_400 = 0;

+  local_3f8 = 0;

+  local_407 = '\0';

+  local_406[0] = '\0';

+  local_3e8 = local_3e8 & 0xffffff00;

+  local_3b0 = param_9;

+  local_3e4 = 0;

+  local_3c0[0] = 0;

+  local_3c0[1] = 0;

+  local_3e0 = 0;

+  local_404 = 0;

+  local_3ec = 0;

+  local_408 = param_2;

+  local_3d8 = param_4;

+  memset(&local_398,0,0x1b0);

+  memset(&local_1e8,0,0x1b0);

+  *param_8 = 0;

+  *param_9 = 0;

+  SepCopyTokenIntegrity(param_1,local_3c0);

+  uVar4 = local_3c0[0];

+  uVar3 = RtlSidDominates(local_3c0[0],SeHighMandatorySid,&local_407);

+  local_3f0 = (uint)uVar3;

+  if (-1 < (int)local_3f0) {

+    uVar3 = 1;

+    if (local_407 == '\0') {

+      uVar4 = RtlSidDominates(uVar4,SeMediumMandatorySid,local_406);

+      local_3f0 = (uint)uVar4;

+      if ((int)local_3f0 < 0) {

+        return uVar4;

+      }

+      local_3e8 = local_3e8 & 0xff;

+      if (local_406[0] == '\0') {

+        local_3e8 = 1;

+      }

+    }

+    cVar1 = local_408;

+    uVar4 = uVar7;

+    if (param_3 == '\0') {

+      uVar8 = local_3f0;

+      uVar3 = (ulonglong)local_3d8;

+      if (local_3d8 != 0) {

+        do {

+          local_3c8 = uVar3;

+          uVar3 = 1L << ((byte)(uint)*param_5 & 0x3f);

+          if ((uVar3 & *(ulonglong *)(param_1 + 0x40)) != 0) {

+            local_3e4 = local_3e4 + 1;

+            local_400 = *param_5;

+            uVar5 = *(ulonglong *)(param_1 + 0x48);

+            local_3c0[0] = 1L << ((byte)local_400 & 0x3f);

+            uVar8 = (uint)((*(ulonglong *)(param_1 + 0x50) & local_3c0[0]) != 0) |

+                    -(uint)((1L << ((byte)local_400 & 0x3f) & uVar5) != 0) & 2;

+            local_3f8 = uVar8;

+            if ((param_5[1] & 4) == 0) {

+              uVar3 = uVar3 & uVar5;

+              if ((param_5[1] & 2) == 0) {

+                if (uVar3 != 0) {

+                  if (local_408 != '\0') {

+                    if (local_3d0 != 0) {

+                      uVar6 = *param_8;

+                      *(ulonglong *)(local_3d0 + 4 + (ulonglong)uVar6 * 0xc) = local_400;

+                      *(uint *)(local_3d0 + 0xc + (ulonglong)uVar6 * 0xc) = uVar8;

+                    }

+                    iVar2 = Feature_3055530299__private_IsEnabledDeviceUsageNoInline();

+                    if (iVar2 == 0) {

+                      local_404 = (int)uVar4 + 1;

+                      *(ulonglong *)((longlong)&local_398 + uVar4 * 0xc) = local_400;

+                      auStack_390[uVar4 * 3] = uVar8;

+                    }

+                    else {

+                      SepTryAddUniqueAuditPrivilege(&local_398,&local_404,&local_400);

+                    }

+                    uVar4 = (ulonglong)local_404;

+                    *(ulonglong *)(param_1 + 0x48) =

+                         *(ulonglong *)(param_1 + 0x48) & ~(1L << (local_400 & 0x3f));

+                  }

+                  goto LAB_0;

+                }

+              }

+              else if (uVar3 == 0) {

+                if (local_408 != '\0') {

+                  if (local_3d0 != 0) {

+                    uVar6 = *param_8;

+                    *(ulonglong *)(local_3d0 + 4 + (ulonglong)uVar6 * 0xc) = local_400;

+                    *(uint *)(local_3d0 + 0xc + (ulonglong)uVar6 * 0xc) = uVar8;

+                  }

+                  iVar2 = Feature_3055530299__private_IsEnabledDeviceUsageNoInline();

+                  uVar3 = local_400;

+                  if (iVar2 == 0) {

+                    uVar5 = (ulonglong)local_3ec;

+                    local_3ec = local_3ec + 1;

+                    *(ulonglong *)((longlong)&local_1e8 + uVar5 * 0xc) = local_400;

+                    auStack_1e0[uVar5 * 3] = uVar8;

+                  }

+                  if (local_407 == '\0') {

+                    if (local_406[0] == '\0') {

+                      if ((char)local_3e8 != '\0') {

+                        iVar2 = Feature_DecoupleAppContainerAndIntegrityLevel__private_IsEnabledDeviceUsageNoInline

+                                          ();

+                        if (iVar2 != 0) goto LAB_1;

+                        uVar5 = 1L << ((byte)(uint)*param_5 & 0x3f);

+                        local_3e0 = 0x200800000;

+                        if ((*(uint *)(param_1 + 200) & 0x4000) == 0) {

+                          uVar5 = uVar5 & 0x202800000;

+                        }

+                        else {

+                          uVar5 = uVar5 & 0x200800000;

+                        }

+                        if (uVar5 == 0) {

+                          uVar7 = (ulonglong)((int)uVar7 + 1);

+                        }

+                        else {

+                          *(ulonglong *)(param_1 + 0x48) =

+                               *(ulonglong *)(param_1 + 0x48) | 1L << (uVar3 & 0x3f);

+                        }

+                      }

+                    }

+                    else {

+                      if ((0x1120160684U >> ((ulonglong)(uint)*param_5 & 0x3f) & 1) == 0) {

+                        *(ulonglong *)(param_1 + 0x48) =

+                             *(ulonglong *)(param_1 + 0x48) | 1L << (local_400 & 0x3f);

+                      }

+                      else {

+                        uVar7 = (ulonglong)((int)uVar7 + 1);

+                      }

+                      iVar2 = Feature_DecoupleAppContainerAndIntegrityLevel__private_IsEnabledDeviceUsageNoInline

+                                        ();

+                      if (iVar2 != 0) {

+LAB_1:

+                        local_3e0 = 0x200800000;

+                      }

+                    }

+                  }

+                  else {

+                    *(ulonglong *)(param_1 + 0x48) =

+                         *(ulonglong *)(param_1 + 0x48) | 1L << (local_400 & 0x3f);

+                  }

+                  iVar2 = Feature_DecoupleAppContainerAndIntegrityLevel__private_IsEnabledDeviceUsageNoInline

+                                    ();

+                  if ((iVar2 != 0) && ((*(uint *)(param_1 + 200) & 0x4000) != 0)) {

+                    if ((local_3e0 >> ((ulonglong)(uint)*param_5 & 0x3f) & 1) == 0) {

+                      uVar7 = (ulonglong)((int)uVar7 + 1);

+                    }

+                    else {

+                      *(ulonglong *)(param_1 + 0x48) =

+                           *(ulonglong *)(param_1 + 0x48) | 1L << (uVar3 & 0x3f);

+                    }

+                  }

+                  iVar2 = Feature_3055530299__private_IsEnabledDeviceUsageNoInline();

+                  if ((iVar2 != 0) && ((local_3c0[0] & *(ulonglong *)(param_1 + 0x48)) != 0)) {

+                    SepTryAddUniqueAuditPrivilege(&local_1e8,&local_3ec,&local_400);

+                  }

+                }

+LAB_0:

+                *param_8 = *param_8 + 1;

+              }

+            }

+            else if (local_408 != '\0') {

+              *(ulonglong *)(param_1 + 0x48) = uVar5 & ~(1L << (local_400 & 0x3f));

+              *(uint *)(param_1 + 200) = *(uint *)(param_1 + 200) | 0x800;

+              *(ulonglong *)(param_1 + 0x40) =

+                   *(ulonglong *)(param_1 + 0x40) & ~(1L << (local_400 & 0x3f));

+            }

+          }

+          param_5 = (ulonglong *)((longlong)param_5 + 0xc);

+          uVar3 = local_3c8 - 1;

+        } while (local_3c8 - 1 != 0);

+        local_3c8 = 0;

+        if ((local_3e4 < local_3d8) || (uVar8 = local_3f0, (int)uVar7 != 0)) {

+          uVar8 = 0x106;

+        }

+      }

+    }

+    else {

+      do {

+        if ((*(ulonglong *)(param_1 + 0x48) & uVar3) != 0) {

+          if (cVar1 != '\0') {

+            uVar8 = ((*(ulonglong *)(param_1 + 0x50) & uVar3) != 0) + 2;

+            local_3e0 = (ulonglong)(int)uVar7;

+            local_400 = local_3e0;

+            local_3f8 = uVar8;

+            iVar2 = Feature_3055530299__private_IsEnabledDeviceUsageNoInline();

+            uVar5 = local_400;

+            if (iVar2 == 0) {

+              local_404 = (int)uVar4 + 1;

+              *(ulonglong *)((longlong)&local_398 + uVar4 * 0xc) = local_400;

+              auStack_390[uVar4 * 3] = uVar8;

+            }

+            else {

+              SepTryAddUniqueAuditPrivilege(&local_398,&local_404,&local_400);

+            }

+            uVar4 = (ulonglong)local_404;

+            if (local_3d0 != 0) {

+              uVar6 = *param_8;

+              *(ulonglong *)(local_3d0 + 4 + (ulonglong)uVar6 * 0xc) = uVar5;

+              *(uint *)(local_3d0 + 0xc + (ulonglong)uVar6 * 0xc) = uVar8;

+            }

+            *(ulonglong *)(param_1 + 0x48) =

+                 *(ulonglong *)(param_1 + 0x48) & ~(1L << (uVar7 & 0x3f));

+          }

+          *param_8 = *param_8 + 1;

+        }

+        uVar6 = (int)uVar7 + 1;

+        uVar7 = (ulonglong)uVar6;

+        uVar3 = uVar3 << 1 | (ulonglong)((longlong)uVar3 < 0);

+        uVar8 = local_3f0;

+      } while (uVar6 < 0x25);

+    }

+    if ((*param_8 != 0) && (local_408 != '\0')) {

+      *local_3b0 = 1;

+      local_410 = (byte)(uVar8 >> 0x1f) ^ 1;

+      local_418 = local_3ec;

+      SepAdtTokenRightAdjusted(param_1,&local_398,uVar4,&local_1e8);

+    }

+    if (local_3d0 != 0) {

+      if (*param_8 < 2) {

+        iVar2 = 0x10;

+      }

+      else {

+        iVar2 = *param_8 * 0xc + 4;

+      }

+      *local_3a8 = iVar2;

+    }

+    uVar3 = (ulonglong)uVar8;

   }

-  if (cStack0000000000000032 == '\0') {

-    if (cStack0000000000000050 == '\0') goto LAB_0;

-    iVar3 = Feature_DecoupleAppContainerAndIntegrityLevel__private_IsEnabledDeviceUsageNoInline();

-    if (iVar3 == 0) {

-      uVar4 = unaff_R14 << ((byte)(uint)*unaff_R13 & 0x3f);

-      in_stack_00000058 = 0x200800000;

-      if ((*(uint *)(unaff_RBX + 200) & 0x4000) == 0) {

-        uVar4 = uVar4 & 0x202800000;

-      }

-      else {

-        uVar4 = uVar4 & 0x200800000;

-      }

-      if (uVar4 == 0) {

-        unaff_ESI = unaff_ESI + 1;

-      }

-      else {

-        *(ulonglong *)(unaff_RBX + 0x48) = *(ulonglong *)(unaff_RBX + 0x48) | 1L << (uVar8 & 0x3f);

-      }

-      goto LAB_0;

-    }

-  }

-  else {

-    if ((0x1120160684U >> ((ulonglong)(uint)*unaff_R13 & 0x3f) & 1) == 0) {

-      *(ulonglong *)(unaff_RBX + 0x48) =

-           *(ulonglong *)(unaff_RBX + 0x48) | 1L << (in_stack_00000038 & 0x3f);

-    }

-    else {

-      unaff_ESI = unaff_ESI + 1;

-    }

-    iVar3 = Feature_DecoupleAppContainerAndIntegrityLevel__private_IsEnabledDeviceUsageNoInline();

-    if (iVar3 == 0) goto LAB_0;

-  }

-  in_stack_00000058 = 0x200800000;

-LAB_0:

-  iVar3 = Feature_DecoupleAppContainerAndIntegrityLevel__private_IsEnabledDeviceUsageNoInline();

-  if ((iVar3 != 0) && ((*(uint *)(unaff_RBX + 200) & 0x4000) != 0)) {

-    if ((in_stack_00000058 >> ((ulonglong)(uint)*unaff_R13 & 0x3f) & 1) == 0) {

-      unaff_ESI = unaff_ESI + 1;

-    }

-    else {

-      *(ulonglong *)(unaff_RBX + 0x48) = *(ulonglong *)(unaff_RBX + 0x48) | 1L << (uVar8 & 0x3f);

-    }

-  }

-  iVar3 = Feature_3055530299__private_IsEnabledDeviceUsageNoInline();

-  uVar8 = extraout_XMM0_Qa;

-  if ((iVar3 != 0) && ((in_stack_00000078 & *(ulonglong *)(unaff_RBX + 0x48)) != 0)) {

-    uVar8 = SepTryAddUniqueAuditPrivilege

-                      (unaff_RBP + 0x150,(longlong)&stack0x00000048 + 4,&stack0x00000038);

-  }

-LAB_1:

-  do {

-    *unaff_R15 = *unaff_R15 + 1;

-    do {

-      while( true ) {

-        while( true ) {

-          do {

-            puVar7 = unaff_R13;

-            unaff_R13 = (ulonglong *)((longlong)puVar7 + 0xc);

-            in_stack_00000070 = in_stack_00000070 - unaff_R14;

-            if (in_stack_00000070 == 0) {

-              if ((uStack0000000000000054 < in_stack_00000060) ||

-                 (uVar5 = uStack0000000000000048, unaff_ESI != 0)) {

-                uVar5 = 0x106;

-              }

-              if ((*unaff_R15 != 0) && (cStack0000000000000030 != '\0')) {

-                **(undefined1 **)(unaff_RBP + -0x78) = 1;

-                SepAdtTokenRightAdjusted

-                          (uVar8,unaff_RBP + -0x60,unaff_R12D,unaff_RBP + 0x150,

-                           uStack000000000000004c);

-              }

-              if (in_stack_00000068 != 0) {

-                if (*unaff_R15 < 2) {

-                  iVar3 = 0x10;

-                }

-                else {

-                  iVar3 = *unaff_R15 * 0xc + 4;

-                }

-                **(int **)(unaff_RBP + -0x70) = iVar3;

-              }

-              return uVar5;

-            }

-            uVar4 = unaff_R14 << ((byte)*(uint *)unaff_R13 & 0x3f);

-          } while ((uVar4 & *(ulonglong *)(unaff_RBX + 0x40)) == 0);

-          uStack0000000000000054 = uStack0000000000000054 + 1;

-          in_stack_00000038 = *unaff_R13;

-          uVar2 = *(ulonglong *)(unaff_RBX + 0x48);

-          in_stack_00000078 = unaff_R14 << ((byte)in_stack_00000038 & 0x3f);

-          uVar6 = (uint)((*(ulonglong *)(unaff_RBX + 0x50) & in_stack_00000078) != 0) |

-                  -(uint)((unaff_R14 << ((byte)in_stack_00000038 & 0x3f) & uVar2) != 0) & 2;

-          uVar1 = *(uint *)((longlong)puVar7 + 0x14);

-          in_stack_00000040 = uVar6;

-          if ((uVar1 & 4) == 0) break;

-          if (cStack0000000000000030 != '\0') {

-            *(ulonglong *)(unaff_RBX + 0x48) = uVar2 & ~(1L << (in_stack_00000038 & 0x3f));

-            *(uint *)(unaff_RBX + 200) = *(uint *)(unaff_RBX + 200) | 0x800;

-            *(ulonglong *)(unaff_RBX + 0x40) =

-                 *(ulonglong *)(unaff_RBX + 0x40) & ~(1L << (in_stack_00000038 & 0x3f));

-          }

-        }

-        uVar4 = uVar4 & uVar2;

-        if ((uVar1 & 2) == 0) break;

-        if (uVar4 == 0) {

-          if (cStack0000000000000030 == '\0') goto LAB_1;

-          if (in_stack_00000068 != 0) {

-            uVar1 = *unaff_R15;

-            *(ulonglong *)(in_stack_00000068 + 4 + (ulonglong)uVar1 * 0xc) = in_stack_00000038;

-            *(uint *)(in_stack_00000068 + 0xc + (ulonglong)uVar1 * 0xc) = uVar6;

-          }

-          iVar3 = Feature_3055530299__private_IsEnabledDeviceUsageNoInline();

-          if (iVar3 == 0) {

-            uVar8 = (ulonglong)uStack000000000000004c;

-            uStack000000000000004c = uStack000000000000004c + 1;

-            *(ulonglong *)(unaff_RBP + 0x150 + uVar8 * 0xc) = in_stack_00000038;

-            *(uint *)(unaff_RBP + 0x158 + uVar8 * 0xc) = uVar6;

-          }

-          in_ZF = cStack0000000000000031 == '\0';

-          goto code_r0x000140984f90;

-        }

-      }

-    } while (uVar4 == 0);

-    if (cStack0000000000000030 != '\0') {

-      if (in_stack_00000068 != 0) {

-        uVar1 = *unaff_R15;

-        *(ulonglong *)(in_stack_00000068 + 4 + (ulonglong)uVar1 * 0xc) = in_stack_00000038;

-        *(uint *)(in_stack_00000068 + 0xc + (ulonglong)uVar1 * 0xc) = uVar6;

-      }

-      iVar3 = Feature_3055530299__private_IsEnabledDeviceUsageNoInline();

-      if (iVar3 == 0) {

-        uStack0000000000000034 = unaff_R12D + 1;

-        *(ulonglong *)(unaff_RBP + -0x60 + (ulonglong)unaff_R12D * 0xc) = in_stack_00000038;

-        *(uint *)(unaff_RBP + -0x58 + (ulonglong)unaff_R12D * 0xc) = uVar6;

-        uVar8 = in_stack_00000038;

-      }

-      else {

-        uVar8 = SepTryAddUniqueAuditPrivilege

-                          (unaff_RBP + -0x60,(longlong)&stack0x00000030 + 4,&stack0x00000038);

-      }

-      *(ulonglong *)(unaff_RBX + 0x48) =

-           *(ulonglong *)(unaff_RBX + 0x48) & ~(1L << (in_stack_00000038 & 0x3f));

-      unaff_R12D = uStack0000000000000034;

-    }

-  } while( true );

+  return uVar3;

 }
```

## `Pdcv2pActivationClientCallback`  (modified)

```diff
--- Pdcv2pActivationClientCallback
+++ Pdcv2pActivationClientCallback
@@ -1,7 +1,106 @@
 

-void Pdcv2pActivationClientCallback(void)

+/* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

+

+int Pdcv2pActivationClientCallback(_exception *param_1,longlong param_2)

 

 {

-  return;

+  char **ppcVar1;

+  int *piVar2;

+  longlong lVar3;

+  double dVar4;

+  int iVar5;

+  int iVar6;

+  _exception *p_Var7;

+  int iVar8;

+  char local_res8 [8];

+  longlong local_res18 [2];

+  

+  iVar6 = 0;

+  iVar8 = 0;

+  local_res8[0] = '\0';

+  if (param_1 == (_exception *)0x0) {

+    iVar5 = -0x3fffff11;

+    iVar8 = iVar6;

+  }

+  else if (param_1->type == 0x32414450) {

+    if (*(int *)(param_2 + 0x28) == 0xc) {

+      p_Var7 = param_1;

+      iVar5 = _GetStoragePropertyPost_SC_DEVICE__MEAAJW4_STORAGE_PROPERTY_ID__PEAU_STORAGE_DESCRIPTOR_HEADER___Z

+                        (param_1);

+      ppcVar1 = &p_Var7->name;

+      while (PdcAcquireRwLockExclusive2(ppcVar1,local_res8), param_1[2].arg2 != 0.0) {

+        PdcReleaseRwLockExclusive2(ppcVar1,local_res8);

+        PdcWaitForEvent(param_1[2].retval);

+      }

+      if (*(longlong *)(param_1 + 1) == 0) {

+        iVar5 = -0x3ffff900;

+      }

+      else {

+        lVar3 = *(longlong *)(param_2 + 0x38);

+        iVar8 = *(int *)(param_2 + 0x40);

+        local_res18[0] = lVar3;

+        iVar6 = Feature_Servicing_PDCActivationsAVL__private_IsEnabledDeviceUsageNoInline();

+        if (iVar6 == 0) {

+          for (p_Var7 = *(_exception **)(param_1 + 2); p_Var7 != param_1 + 2;

+              p_Var7 = *(_exception **)p_Var7) {

+            if (*(longlong *)(p_Var7 + 0xf) == lVar3) goto LAB_0;

+          }

+        }

+        else {

+          p_Var7 = (_exception *)param_1[2].arg1;

+          while (p_Var7 != (_exception *)0x0) {

+            iVar6 = PdcpActivationClientTableCompareRoutine(local_res18,p_Var7);

+            if (iVar6 < 0) {

+              p_Var7 = *(_exception **)p_Var7;

+            }

+            else {

+              if (iVar6 < 1) break;

+              p_Var7 = (_exception *)p_Var7->name;

+            }

+          }

+LAB_0:

+          if (p_Var7 != (_exception *)0x0) {

+            if (100 < iVar8) {

+              piVar2 = (int *)((longlong)&p_Var7[1].retval + 4);

+              *piVar2 = *piVar2 + 1;

+              *(undefined1 *)((longlong)&p_Var7[1].arg2 + 4) = 1;

+            }

+            Pdcv2EventWrite_ACTIVATION_CLIENT_CALLBACK(p_Var7,param_1,iVar8,iVar5);

+            dVar4 = param_1[2].retval;

+            param_1[2].arg2 = (double)SystemReserved1[0xf];

+            *(_exception **)(param_1 + 3) = p_Var7;

+            PdcResetEvent(dVar4);

+            *(void **)(*(longlong *)(param_1 + 1) + 0x6e0) = SystemReserved1[0xf];

+            PdcReleaseRwLockExclusive2(ppcVar1,local_res8);

+            (*(code *)param_1[1].arg1)(p_Var7,iVar8,param_1[1].arg2,*(undefined8 *)(p_Var7 + 1));

+            PdcAcquireRwLockExclusive2(ppcVar1,local_res8);

+            if (*(longlong *)(param_1 + 1) != 0) {

+              *(undefined8 *)(*(longlong *)(param_1 + 1) + 0x6e0) = 0;

+            }

+            param_1[2].arg2 = 0.0;

+            *(undefined8 *)(param_1 + 3) = 0;

+            KeSetEvent(param_1[2].retval,0,0);

+            goto LAB_1;

+          }

+        }

+        iVar5 = -0x3ffffe77;

+      }

+    }

+    else {

+      iVar5 = -0x3ffff8fe;

+      iVar8 = iVar6;

+    }

+  }

+  else {

+    iVar5 = -0x3fffff11;

+    param_1 = (_exception *)0x0;

+    iVar8 = iVar6;

+  }

+  Pdcv2EventWrite_ACTIVATION_CLIENT_CALLBACK(0,param_1,iVar8,iVar5);

+LAB_1:

+  if (local_res8[0] != '\0') {

+    PdcReleaseRwLockExclusive2(&param_1->name,local_res8);

+  }

+  return iVar5;

 }
```

## `Feature_TestUex12_IsEnabledWithReporting`  (modified)

```diff
--- Feature_TestUex12_IsEnabledWithReporting
+++ Feature_TestUex12_IsEnabledWithReporting
@@ -1,17 +1,8 @@
 

-void Feature_TestUex12_IsEnabledWithReporting(void)

+undefined8 Feature_TestUex12_IsEnabledWithReporting(void)

 

 {

-  char *in_RAX;

-  int unaff_EBX;

-  undefined8 in_stack_00000030;

-  

-  *in_RAX = *in_RAX + (char)in_RAX;

-  wil_details_FeatureReporting_ReportUsageToService();

-  if (unaff_EBX - 3U < 2) {

-    wil_details_FeatureStateCache_TryEnableDeviceUsageFastPath

-              (in_stack_00000030,unaff_EBX,&Feature_TestConfNum__private_descriptor);

-  }

-  return;

+  Feature_TestUex12__private_ReportUsage();

+  return 1;

 }
```

## `SeSubProcessToken`  (modified)

```diff
--- SeSubProcessToken
+++ SeSubProcessToken
@@ -1,156 +1,341 @@
 

 /* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

 

-ulonglong SeSubProcessToken(void)

+uint SeSubProcessToken(longlong param_1,ulonglong param_2,longlong *param_3,uint param_4,int param_5

+                      ,uint *param_6,uint param_7,longlong param_8,undefined4 param_9,

+                      longlong param_10,char *param_11)

 

 {

-  ushort uVar1;

-  int iVar2;

-  uint *puVar3;

-  ulonglong uVar4;

-  char cVar5;

-  undefined1 *unaff_RBX;

-  uint unaff_ESI;

-  ulonglong uVar6;

-  uint uVar7;

-  ulonglong unaff_R12;

-  uint unaff_R13D;

-  uint unaff_R14D;

-  uint unaff_R15D;

-  bool in_ZF;

-  bool bVar8;

-  char local_res20;

-  char cStackX_21;

-  char acStackX_22 [2];

-  uint uStackX_24;

-  undefined1 *in_stack_00000028;

-  uint uStack0000000000000030;

-  uint uStack0000000000000034;

-  undefined1 *in_stack_00000038;

+  undefined8 uVar1;

+  longlong lVar2;

+  char cVar3;

+  int iVar4;

+  uint uVar5;

+  longlong lVar6;

+  undefined8 *puVar7;

+  byte *pbVar8;

+  longlong *plVar9;

+  uint *puVar10;

+  uint uVar11;

+  uint uVar12;

+  uint uVar13;

+  undefined1 auStack_2d8 [32];

+  int *local_2b8;

+  char *local_2b0;

+  char *local_2a8;

+  longlong *local_2a0;

+  char local_298;

+  char local_297 [7];

+  longlong local_290;

+  char local_288;

+  char local_287;

+  char local_286;

+  char local_285;

+  char local_284;

+  char local_283 [3];

+  uint local_280;

+  int local_27c;

+  int local_278 [2];

+  longlong local_270;

+  longlong local_268;

+  longlong local_260;

+  longlong *local_258;

+  char *local_250;

+  undefined8 local_248;

+  undefined8 uStack_240;

+  undefined8 local_238;

+  ulonglong uStack_230;

+  undefined8 local_228;

+  ulonglong uStack_220;

+  undefined8 local_218;

+  undefined8 uStack_210;

+  undefined8 local_208;

+  undefined8 uStack_200;

+  undefined8 local_1f8;

+  undefined8 uStack_1f0;

+  undefined8 local_1e8;

+  undefined4 local_1e0;

+  undefined4 local_1dc;

+  longlong local_1d8;

+  undefined8 local_1d0;

+  undefined1 local_1c8 [160];

+  undefined1 local_128 [224];

+  ulonglong local_48;

   

-  cVar5 = (char)unaff_RBX;

-  cStackX_21 = cVar5;

-  if (in_ZF) {

-    cStackX_21 = (char)unaff_R15D;

-  }

-  local_res20 = SeSinglePrivilegeCheck

-                          (SeTcbPrivilege,*(undefined1 *)((longlong)SystemReserved1[0xf] + 0x232));

-  if ((local_res20 == '\0') &&

-     ((iVar2 = RtlCheckTokenMembership(0,SeAliasAdminsSid,&local_res20), iVar2 < 0 ||

-      (local_res20 == cVar5)))) {

-    uVar6 = 0xc0000022;

-    goto LAB_0;

-  }

-  uStackX_24 = (uint)unaff_RBX;

-  uVar6 = (ulonglong)unaff_RBX & 0xffffffff;

-  if (DAT_1 == unaff_RBX) {

-    uVar6 = 0x80430006;

-    goto LAB_0;

-  }

-  uVar7 = (uint)unaff_R12;

-  if (unaff_R14D == 0) {

-    if ((((unaff_ESI == 0) && (unaff_R13D == 0)) && (in_stack_00000028 == unaff_RBX)) &&

-       (uVar7 == 0)) {

-      LOCK();

-      bVar8 = DAT_2 == 0;

-      uVar7 = uStackX_24;

-      if (!bVar8) {

-        uVar7 = DAT_2;

-      }

-      DAT_2 = uVar7;

-      UNLOCK();

-      if (bVar8) {

-        uStackX_24 = SepSecureBootCorrectBcd(acStackX_22);

-        uVar6 = (ulonglong)uStackX_24;

-        if (((int)uStackX_24 < 0) || ((DAT_3 == cVar5 && (acStackX_22[0] != cVar5))))

-        goto LAB_0;

-        LOCK();

-        UNLOCK();

-        DAT_2 = unaff_R15D;

-      }

-      uVar6 = (ulonglong)uStackX_24;

-      goto LAB_0;

-    }

-LAB_4:

-    uVar6 = 0xc000000d;

-  }

-  else {

-    if (unaff_R14D == 1) {

-      if (((unaff_ESI == 0) || (unaff_R13D == 0)) ||

-         ((in_stack_00000028 == unaff_RBX || (uVar7 == 0)))) goto LAB_4;

-      if ((DAT_5 >> (unaff_R13D >> 0x18 & 0xf) & 1) != 0) {

-        if (*(char *)((longlong)SystemReserved1[0xf] + 0x232) == cVar5) {

-          uVar6 = (ulonglong)unaff_RBX & 0xffffffff;

-        }

-        else {

-          if (uVar7 < 9) {

-            RtlCopyMemory(&stack0x00000040,in_stack_00000028,unaff_R12);

-            in_stack_00000028 = &stack0x00000040;

+  local_48 = __security_cookie ^ (ulonglong)auStack_2d8;

+  local_268 = param_8;

+  local_260 = param_10;

+  uVar12 = 0;

+  uVar13 = 0;

+  local_228 = 0;

+  uStack_220 = uStack_220 & 0xffffffff00000000;

+  local_250 = param_11;

+  local_290 = 0;

+  local_248 = 0;

+  uStack_240 = 0;

+  local_1dc = 0;

+  local_238 = 0;

+  uStack_230 = 0;

+  local_280 = param_4;

+  local_258 = param_3;

+  memset(local_1c8,0,0xa0);

+  memset(local_128,0,0xe0);

+  *param_3 = 0;

+  param_11[0] = '\0';

+  param_11[1] = '\0';

+  param_11[2] = '\0';

+  local_288 = '\0';

+  local_297[0] = '\0';

+  local_284 = '\0';

+  local_283[0] = '\0';

+  local_298 = '\0';

+  local_270 = 0;

+  local_285 = '\0';

+  local_286 = '\0';

+  local_287 = '\0';

+  local_218 = 0;

+  uStack_210 = 0;

+  local_1f8 = 0;

+  local_208 = 0;

+  uStack_200 = 0;

+  uStack_1f0 = (ulonglong)uStack_1f0._4_4_ << 0x20;

+  SeTokenGetNoChildProcessRestricted(param_2,&local_288,&local_286,&local_287);

+  if ((local_288 == '\0') && (local_287 == '\0')) {

+LAB_0:

+    iVar4 = Feature_ShadowAdmin__private_IsEnabledDeviceUsageNoInline();

+    if (iVar4 != 0) {

+      local_27c = 0;

+      RtlQueryElevationFlags(&local_27c);

+      if (((((byte)local_27c & 0x18) == 0x10) &&

+          ((*(uint *)(*(longlong *)(param_2 + 0xd8) + 0x28) & 4) != 0)) &&

+         ((uVar12 = uVar13, (*(uint *)(param_2 + 200) >> 0x1b & 1) != 0 &&

+          (((*(uint *)(param_2 + 200) >> 0xc & 1) != 0 && ((param_4 & 2) != 0)))))) {

+        local_285 = '\x01';

+        puVar7 = (undefined8 *)SepLocateTokenIntegrity(param_2);

+        if (puVar7 != (undefined8 *)0x0) {

+          uVar1 = *puVar7;

+          pbVar8 = (byte *)RtlSubAuthorityCountSid(uVar1);

+          if (*pbVar8 == 0) {

+            uVar12 = 0;

           }

           else {

-            in_stack_00000038 = (undefined1 *)ExAllocatePool2(0x100);

-            if (in_stack_00000038 == (undefined1 *)0x0) {

-              uVar6 = 0xc0000017;

-              uStackX_24 = 0xc0000017;

-              goto LAB_0;

+            puVar10 = (uint *)RtlSubAuthoritySid(uVar1,*pbVar8 - 1);

+            uVar12 = *puVar10;

+          }

+        }

+      }

+    }

+    uStack_240 = 0;

+    local_248 = CONCAT44(local_248._4_4_,0x30);

+    local_228 = 0;

+    uStack_220 = 0;

+    uStack_230 = uStack_230 & 0xffffffff00000000;

+    local_238 = 0;

+    iVar4 = Feature_DecoupleAppContainerAndIntegrityLevel__private_IsEnabledDeviceUsageNoInline();

+    if ((iVar4 == 0) || (*(char **)(param_6 + 8) == (char *)0x0)) {

+      local_2a0 = &local_290;

+      local_2a8 = (char *)CONCAT71(local_2a8._1_7_,1);

+      local_2b0 = (char *)((ulonglong)local_2b0 & 0xffffffffffffff00);

+      local_2b8 = (int *)((ulonglong)local_2b8 & 0xffffffff00000000);

+      uVar5 = SepDuplicateToken(param_2,&local_248,0,1);

+      if (-1 < (int)uVar5) goto LAB_1;

+      local_290 = 0;

+      cVar3 = local_298;

+    }

+    else {

+      local_218 = CONCAT44(local_218._4_4_,0x30);

+      uStack_210 = 0;

+      uStack_200 = CONCAT44(uStack_200._4_4_,0x600);

+      local_208 = 0;

+      local_1f8 = 0;

+      uStack_1f0 = 0;

+      local_2b8 = (int *)((ulonglong)local_2b8 & 0xffffffffffffff00);

+      local_2b0 = *(char **)(param_6 + 8);

+      uVar5 = SepCreateAppContainerToken(0,&local_290,0xf01ff,&local_218);

+      cVar3 = local_298;

+      if (-1 < (int)uVar5) {

+LAB_1:

+        if (((*(uint *)(local_290 + 200) & 0x4000) != 0) && (*(int *)(local_290 + 0x78) != param_5))

+        {

+          SepDereferenceLowBoxNumberEntry

+                    (*(int *)(local_290 + 0x78),*(undefined8 *)(local_290 + 0x438));

+          local_2b8 = (int *)0x0;

+          *(undefined8 *)(local_290 + 0x438) = 0;

+          SepSetTokenSessionById(local_290,param_5,0,0);

+          *(int *)(local_290 + 0x78) = param_5;

+          uVar5 = SepSetTokenLowboxNumber(local_290,*(undefined8 *)(local_290 + 0x310));

+          cVar3 = local_298;

+          if ((int)uVar5 < 0) goto LAB_2;

+        }

+        local_2b8 = (int *)0x0;

+        SepSetTokenSessionById(local_290,param_5,0,0);

+        *(int *)(local_290 + 0x78) = param_5;

+        *(uint *)(local_290 + 200) = *(uint *)(local_290 + 200) & 0xffdfffff;

+        if (((*param_6 & 1) != 0) &&

+           (*(uint *)(local_290 + 200) = *(uint *)(local_290 + 200) | 0x80000, (*param_6 & 4) != 0))

+        {

+          *(uint *)(local_290 + 200) = *(uint *)(local_290 + 200) | 0x100000;

+        }

+        local_2b8 = (int *)0x0;

+        uVar5 = SepSetTokenBnoIsolation(local_290,0,0,0);

+        cVar3 = local_298;

+        if (-1 < (int)uVar5) {

+          local_2a8 = local_283;

+          local_2b0 = &local_284;

+          uVar13 = local_280 & 2;

+          local_2b8 = (int *)CONCAT44(local_2b8._4_4_,param_6[1]);

+          uVar5 = SepDesktopAppxSubProcessToken(local_290,param_1,0);

+          cVar3 = local_298;

+          if ((-1 < (int)uVar5) &&

+             (uVar5 = SepMandatorySubProcessToken

+                                (-(ulonglong)(uVar13 != 0) & param_2,local_290,param_1,&local_270),

+             cVar3 = local_298, -1 < (int)uVar5)) {

+            iVar4 = Feature_ShadowAdmin__private_IsEnabledDeviceUsageNoInline();

+            lVar6 = local_270;

+            if ((iVar4 != 0) &&

+               (((local_285 != '\0' && (uVar12 != 0)) &&

+                (plVar9 = (longlong *)SepLocateTokenIntegrity(local_290), lVar6 = local_270,

+                plVar9 != (longlong *)0x0)))) {

+              lVar2 = *plVar9;

+              pbVar8 = (byte *)RtlSubAuthorityCountSid(lVar2);

+              if (*pbVar8 == 0) {

+                uVar11 = 0;

+              }

+              else {

+                puVar10 = (uint *)RtlSubAuthoritySid(lVar2,*pbVar8 - 1);

+                uVar11 = *puVar10;

+              }

+              lVar6 = local_270;

+              if (uVar11 < uVar12) {

+                puVar10 = (uint *)RtlSubAuthoritySid(lVar2,0);

+                *puVar10 = uVar12;

+                lVar6 = *plVar9;

+                if (0x1fff < uVar12) {

+                  *(uint *)(local_290 + 200) = *(uint *)(local_290 + 200) | 0x2000;

+                }

+              }

             }

-            RtlCopyMemory(in_stack_00000038,in_stack_00000028,unaff_R12);

-            unaff_ESI = uStack0000000000000030;

-            in_stack_00000028 = in_stack_00000038;

+            uVar5 = SepSetTrustLevelForProcessToken(local_290,param_1,local_297);

+            cVar3 = local_298;

+            if (((-1 < (int)uVar5) &&

+                ((((byte)SepTokenSingletonAttributesConfig & 3) != 3 ||

+                 (uVar5 = SepSetProcessUniqueAttribute(local_290), cVar3 = local_298,

+                 -1 < (int)uVar5)))) &&

+               (((*(uint *)(local_290 + 200) & 0x4000) == 0 ||

+                (((param_7 & 1) == 0 ||

+                 (uVar5 = SepSetTokenAllApplicationPackagesPolicy(), cVar3 = local_298,

+                 -1 < (int)uVar5)))))) {

+              if (local_268 != 0) {

+                SepAddTokenOriginClaim(local_268,param_9,local_290,0);

+              }

+              if (local_260 != 0) {

+                local_2b8 = *(int **)(local_260 + 0x18);

+                uVar5 = SepSetTokenBnoIsolation

+                                  (local_290,*(undefined1 *)(local_260 + 0x20),local_260,

+                                   *(undefined4 *)(local_260 + 0x10));

+                cVar3 = local_298;

+                if ((int)uVar5 < 0) goto LAB_2;

+              }

+              if ((uVar13 == 0) || (lVar6 != 0)) {

+                local_297[0] = '\x01';

+              }

+              if (local_297[0] == '\0') {

+                SeCreateAccessState(local_1c8,local_128,0,0);

+              }

+              else {

+                local_1e8 = 0;

+                local_1e0 = 0;

+                local_2b8 = (int *)0x0;

+                local_1d0 = *(undefined8 *)

+                             (*(longlong *)((longlong)SystemReserved1[0xf] + 0xb8) + 0x1d0);

+                local_1d8 = local_290;

+                SepCreateAccessStateFromSubjectContext(&local_1e8,local_1c8,local_128,0);

+              }

+              local_2a8 = (char *)0x0;

+              local_2b0 = (char *)0x0;

+              local_2b8 = (int *)((ulonglong)local_2b8 & 0xffffffff00000000);

+              cVar3 = '\x01';

+              uVar5 = ObInsertObjectEx(local_290,local_1c8,0,0);

+              if ((int)uVar5 < 0) {

+                local_290 = 0;

+              }

+              else {

+                iVar4 = Feature_DecoupleAppContainerAndIntegrityLevel__private_IsEnabledDeviceUsageNoInline

+                                  ();

+                if (((iVar4 == 0) || (*(longlong *)(param_6 + 8) == 0)) ||

+                   (uVar5 = SepAppendAceToTokenObjectAcl

+                                      (local_290,0xf01ff,

+                                       *(undefined8 *)

+                                        (*(longlong *)(*(longlong *)(param_6 + 8) + 8) + 0x10)),

+                   -1 < (int)uVar5)) {

+                  SepFinalizeTokenAcls(local_290);

+                  *(byte *)(local_290 + 0xcc) = (byte)local_280 & 1;

+                  *local_258 = local_290;

+                  *local_250 = local_297[0];

+                  local_250[1] = local_284;

+                  local_250[2] = local_283[0];

+                  if (-1 < (int)uVar5) goto LAB_3;

+                }

+              }

+            }

           }

-          uVar6 = (ulonglong)uStackX_24;

-          unaff_R14D = uStack0000000000000034;

-        }

-LAB_6:

-        uVar4 = (ulonglong)unaff_RBX & 0xffffffff;

-        if (*(ushort *)(DAT_1 + 0x24) != 0) {

-          puVar3 = (uint *)(DAT_7 + 4);

-          do {

-            if (((((*puVar3 == unaff_R13D) && ((puVar3[-1] == 0 || (puVar3[-1] == unaff_ESI)))) &&

-                 (uVar1 = *(ushort *)((ulonglong)puVar3[1] + DAT_8), (uVar1 & 0xf000) == 0))

-                && (((uVar1 & 0x20) == 0 || ((DAT_9 & 4) != 0)))) &&

-               ((((uVar1 & 0x40) == 0 || ((DAT_9 & 0x10) != 0)) &&

-                ((((uVar1 >> 0xb & 1) == 0 || ((DAT_9 & 0x40) != 0)) &&

-                 ((cStackX_21 == cVar5 || (*puVar3 != 0x25000031)))))))) {

-              if (unaff_R14D == unaff_R15D) {

-                uVar7 = SepSecureBootValidateBcdDataAgainstBcdRule

-                                  (DAT_7 + uVar4 * 0xc,in_stack_00000028,

-                                   unaff_R12 & 0xffffffff);

-                uVar6 = (ulonglong)uVar7;

-              }

-              else {

-                uVar6 = (ulonglong)unaff_RBX & 0xffffffff;

-                uVar4 = (ulonglong)*(uint *)(DAT_7 + 8 + uVar4 * 0xc);

-                if (((*(byte *)(uVar4 + DAT_8) & 0x1f) != 8) ||

-                   (*(short *)(uVar4 + 2 + DAT_8) != (short)unaff_RBX)) {

-                  uVar6 = 0xc0430002;

-                }

-              }

-              break;

-            }

-            uVar7 = (int)uVar4 + unaff_R15D;

-            uVar4 = (ulonglong)uVar7;

-            puVar3 = puVar3 + 3;

-          } while (uVar7 < *(ushort *)(DAT_1 + 0x24));

-        }

-        goto LAB_0;

+        }

       }

     }

-    else {

-      if (unaff_R14D != 2) {

-        uVar6 = 0xc00000ef;

-        goto LAB_0;

+  }

+  else {

+    uVar11 = 0xc000049d;

+    if ((*param_6 & 2) != 0) {

+      local_2b8 = &local_27c;

+      local_2b0 = (char *)0x0;

+      local_278[0] = 0;

+      local_27c = 0;

+      lVar6 = PsReferenceEffectiveToken(SystemReserved1[0xf],0x74726853,local_278,&local_287);

+      if ((local_278[0] != 2) || (1 < local_27c)) {

+        cVar3 = SeTokenIsNoChildProcessRestrictionEnforced();

+        uVar11 = -(uint)(cVar3 != '\0') & 0xc000049d;

+        if (local_278[0] == 1) {

+          ObFastDereferenceObject

+                    (*(longlong *)((longlong)SystemReserved1[0xf] + 0xb8) + 0x248,lVar6,0x74726853);

+          goto LAB_4;

+        }

       }

-      if ((((unaff_ESI == 0) || (unaff_R13D == 0)) || (in_stack_00000028 != unaff_RBX)) ||

-         (uVar7 != 0)) goto LAB_4;

-      if ((DAT_5 >> (unaff_R13D >> 0x18 & 0xf) & 1) != 0) goto LAB_140ad67cb;

-    }

-    uVar6 = (ulonglong)unaff_RBX & 0xffffffff;

-  }

-LAB_0:

-  if (in_stack_00000038 != (undefined1 *)0x0) {

-    ExFreePoolWithTag(in_stack_00000038,0x62536553);

-  }

-  return uVar6;

+      if (lVar6 != 0) {

+        ObfDereferenceObjectWithTag(lVar6,0x74726853);

+      }

+    }

+LAB_4:

+    cVar3 = local_288;

+    uVar5 = 0;

+    if (param_6[2] != 1) {

+      uVar5 = uVar11;

+    }

+    param_4 = local_280;

+    if (((((*(uint *)(param_1 + 0x5fc) & 1) != 0) && (*(longlong *)(param_1 + 0x640) == 0)) ||

+        (-1 < (int)uVar5)) || ((local_286 != '\0' && (param_6[3] != 0)))) goto LAB_0;

+    lVar6 = *(longlong *)(param_6 + 6);

+    EtwTimLogProhibitChildProcessCreation

+              ((local_288 != '\0') + '\x01',*(undefined8 *)(param_6 + 4),

+               -(ulonglong)(lVar6 != 0) & lVar6 + 0x60U,-(ulonglong)(lVar6 != 0) & lVar6 + 0x70U);

+    param_4 = local_280;

+    if (cVar3 == '\0') goto LAB_0;

+    local_290 = 0;

+    cVar3 = '\0';

+  }

+LAB_2:

+  if (local_290 != 0) {

+    ObfDereferenceObject();

+  }

+  if (cVar3 == '\0') {

+    return uVar5;

+  }

+LAB_3:

+  if (local_297[0] == '\0') {

+    SeDeleteAccessState(local_1c8);

+  }

+  else {

+    SepDeleteAccessState();

+  }

+  return uVar5;

 }
```

## `Pdcv2ActivationClientDeactivate`  (modified)

```diff
--- Pdcv2ActivationClientDeactivate
+++ Pdcv2ActivationClientDeactivate
@@ -1,10 +1,96 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void Pdcv2ActivationClientDeactivate(void)

+ulonglong Pdcv2ActivationClientDeactivate(longlong *param_1)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  int *piVar1;

+  longlong lVar2;

+  longlong *plVar3;

+  code *pcVar4;

+  uint uVar5;

+  int iVar6;

+  ulonglong uVar7;

+  int *piVar8;

+  char local_res8 [8];

+  undefined1 local_328 [40];

+  undefined4 local_300;

+  uint local_2f0;

+  longlong local_2e8;

+  

+  memset(local_328,0,800);

+  local_res8[0] = '\0';

+  piVar8 = (int *)0x0;

+  if (param_1 == (longlong *)0x0) {

+    param_1 = (longlong *)0x0;

+    uVar5 = 0xc00000ef;

+  }

+  else if ((int)param_1[3] == 0x41434450) {

+    piVar8 = (int *)param_1[4];

+    if (*piVar8 == 0x32414450) {

+      piVar1 = piVar8 + 2;

+      PdcAcquireRwLockExclusive2(piVar1,local_res8);

+      if (SystemReserved1[0xf] != *(void **)(piVar8 + 0x1a)) {

+        while (*(longlong **)(piVar8 + 0x1e) == param_1) {

+          PdcReleaseRwLockExclusive2(piVar1,local_res8);

+          PdcWaitForEvent(*(undefined8 *)(piVar8 + 0x1c));

+          PdcAcquireRwLockExclusive2(piVar1,local_res8);

+        }

+      }

+      if (*(longlong *)(piVar8 + 10) == 0) {

+        uVar5 = 0xc0000700;

+      }

+      else if (piVar8[(longlong)(int)param_1[7] + 0x42] == 0) {

+        uVar5 = 0xc0000001;

+      }

+      else {

+        local_2e8 = param_1[0x4b];

+        local_300 = 0xd;

+        uVar5 = PdcPortSendMessageSynchronously(*(undefined8 *)(piVar8 + 10));

+        if ((-1 < (int)uVar5) && (uVar5 = local_2f0, -1 < (int)local_2f0)) {

+          lVar2 = param_1[4];

+          piVar1 = (int *)(lVar2 + 0x108 + (longlong)(int)param_1[7] * 4);

+          *piVar1 = *piVar1 + -1;

+          piVar1 = (int *)(lVar2 + 0x104);

+          *piVar1 = *piVar1 + -1;

+          *(undefined4 *)(param_1 + 3) = 0;

+          Pdcv2EventWrite_ACTIVATION_CLIENT_DEACTIVATE(param_1,piVar8,0);

+          iVar6 = Feature_Servicing_PDCActivationsAVL__private_IsEnabledDeviceUsageNoInline();

+          if (iVar6 == 0) {

+            lVar2 = *param_1;

+            if ((*(longlong **)(lVar2 + 8) != param_1) ||

+               (plVar3 = (longlong *)param_1[1], (longlong *)*plVar3 != param_1)) {

+              pcVar4 = (code *)swi(0x29);

+              (*pcVar4)(3);

+              pcVar4 = (code *)swi(3);

+              uVar7 = (*pcVar4)();

+              return uVar7;

+            }

+            *plVar3 = lVar2;

+            *(longlong **)(lVar2 + 8) = plVar3;

+          }

+          else {

+            RtlAvlRemoveNode(param_1[4] + 0x60,param_1);

+          }

+          *(undefined4 *)(param_1 + 3) = 0;

+          ExFreePoolWithTag(param_1,0);

+          goto LAB_0;

+        }

+      }

+    }

+    else {

+      param_1 = (longlong *)0x0;

+      piVar8 = (int *)0x0;

+      uVar5 = 0xc00000ef;

+    }

+  }

+  else {

+    param_1 = (longlong *)0x0;

+    uVar5 = 0xc00000ef;

+  }

+  Pdcv2EventWrite_ACTIVATION_CLIENT_DEACTIVATE(param_1,piVar8,uVar5);

+LAB_0:

+  if (local_res8[0] != '\0') {

+    PdcReleaseRwLockExclusive2(piVar8 + 2,local_res8);

+  }

+  return (ulonglong)uVar5;

 }
```

## `ApiSetpSearchForHostOverrideIndex_V7`  (modified)

```diff
--- ApiSetpSearchForHostOverrideIndex_V7
+++ ApiSetpSearchForHostOverrideIndex_V7
@@ -1,164 +1,35 @@
 

 ulonglong ApiSetpSearchForHostOverrideIndex_V7

-                    (char param_1,undefined8 param_2,longlong param_3,longlong *param_4)

+                    (longlong param_1,uint param_2,uint param_3,undefined8 param_4,

+                    undefined2 param_5)

 

 {

-  byte bVar1;

-  char cVar2;

-  ushort uVar3;

-  int in_EAX;

-  ulonglong uVar4;

-  uint uVar5;

-  char *pcVar6;

-  ulonglong uVar7;

-  ushort uVar8;

-  ushort uVar9;

-  char cVar10;

-  longlong lVar11;

-  uint uVar12;

-  longlong unaff_RDI;

-  char cVar13;

-  ulonglong in_R10;

-  char cVar14;

-  char unaff_R12B;

-  byte *pbVar15;

-  char cVar16;

-  bool bVar17;

-  char cStack0000000000000038;

+  int iVar1;

+  ulonglong uVar2;

+  longlong lVar3;

+  uint uVar4;

   

-  cVar13 = (char)param_3;

-  uVar4 = (ulonglong)(in_EAX + 0x3dc4b800U);

-  if ((in_EAX + 0x3dc4b800U == 0) || (uVar4 == 0x2d005400580045)) {

-    param_1 = cVar13;

+  uVar2 = (ulonglong)param_2;

+  if ((param_3 != 0) && (uVar4 = 0, param_3 != 0)) {

+    do {

+      if ((uint)*(ushort *)(param_1 + 0x70) <= (uint)uVar2) {

+        return 0xffff;

+      }

+      lVar3 = (*(ushort *)(param_1 + 0x72) * uVar2 + (ulonglong)*(uint *)(param_1 + 0x68)) -

+              (ulonglong)*(ushort *)(param_1 + 0x12);

+      iVar1 = RtlCompareUnicodeStrings

+                        (param_4,param_5,

+                         (((ulonglong)*(uint *)(param_1 + 0x24) +

+                          (ulonglong)*(uint *)(lVar3 + 4 + param_1)) -

+                         (ulonglong)*(ushort *)(param_1 + 0x12)) + param_1,

+                         *(undefined2 *)(lVar3 + 0xc + param_1),1);

+      if (iVar1 == 0) {

+        return uVar2;

+      }

+      uVar2 = (ulonglong)*(ushort *)(lVar3 + param_1);

+      uVar4 = uVar4 + 1;

+    } while (uVar4 < param_3);

   }

-  if (param_1 != '\0') {

-    cStack0000000000000038 = '\0';

-    *param_4 = unaff_RDI;

-    uVar8 = (ushort)in_R10;

-    *(ushort *)(param_4 + 1) = uVar8;

-    uVar4 = in_R10 * 2;

-    if (unaff_R12B == '\0') {

-      uVar4 = in_R10;

-    }

-    *(char *)((longlong)param_4 + 10) = unaff_R12B;

-    pbVar15 = (byte *)(uVar4 + unaff_RDI);

-    cVar16 = '\0';

-    cVar14 = '\0';

-    uVar7 = 0;

-    uVar3 = (ushort)param_3;

-    lVar11 = (ulonglong)(unaff_R12B != '\0') + param_3;

-    uVar12 = (uint)param_3;

-    cVar10 = cVar13;

-    do {

-      uVar4 = 0xffff;

-      pbVar15 = pbVar15 + -lVar11;

-      uVar8 = uVar8 - 1;

-      bVar1 = *pbVar15;

-      uVar9 = (ushort)in_R10;

-      if (bVar1 == 0x2d) {

-        if (cVar14 == '\0') {

-          *(uint *)((longlong)param_4 + 0xc) = (uint)param_3;

-          *(ushort *)((longlong)param_4 + 0x12) = uVar9;

-          uVar8 = uVar9;

-        }

-        else if (cVar16 == '\0') {

-          cVar14 = '\0';

-          *(short *)(param_4 + 3) = (short)uVar7;

-          uVar7 = 0;

-          *(undefined4 *)((longlong)param_4 + 0xc) = 3;

-          *(ushort *)((longlong)param_4 + 0x12) = uVar8;

-          cVar10 = cVar13;

-          cVar16 = cVar13;

-          goto LAB_0;

-        }

-LAB_1:

-        *(ushort *)((longlong)param_4 + 0x14) = uVar8;

-        if ((((7 < uVar8) &&

-             (pcVar6 = (char *)((-(ulonglong)(unaff_R12B != '\0') & 4) + 4 + unaff_RDI),

-             (*pcVar6 + 0xb3U & 0xdf) == 0)) &&

-            (pcVar6 = pcVar6 + lVar11, (*pcVar6 + 0xadU & 0xdf) == 0)) && (pcVar6[lVar11] == '-')) {

-          *(undefined4 *)((longlong)param_4 + 0x1a) = 0x60004;

-        }

-        uVar4 = (ulonglong)*(ushort *)((longlong)param_4 + 0x14);

-        uVar7 = uVar4 * 2;

-        if (unaff_R12B == '\0') {

-          uVar7 = uVar4;

-        }

-        pcVar6 = (char *)(uVar7 + unaff_RDI);

-        cVar10 = '\0';

-        cVar16 = '\0';

-        cVar14 = '\0';

-        goto joined_r0x000140661291;

-      }

-      if (bVar1 == 0x7e) {

-        if (cVar16 == '\0') {

-          *(ushort *)((longlong)param_4 + 0x12) = uVar9;

-          *(undefined4 *)((longlong)param_4 + 0xc) = 2;

-          *(ushort *)((longlong)param_4 + 0x16) = (uVar9 - uVar8) - uVar3;

-          goto LAB_1;

-        }

-        break;

-      }

-      if (bVar1 == 0x2e) {

-        if ((cVar16 != '\0') || (cStack0000000000000038 != '\0')) break;

-        in_R10 = (ulonglong)uVar8;

-        cVar14 = '\0';

-        cVar10 = cVar13;

-        cStack0000000000000038 = cVar13;

-      }

-      else {

-        if ((byte)(bVar1 - 0x30) < 10) {

-          if (cVar10 == '\0') {

-            if (cVar14 != '\0') {

-              uVar4 = uVar7 & 0xffff;

-              uVar5 = (bVar1 - 0x30) * uVar12 + (int)uVar4;

-              if (0xffff < uVar5) break;

-              uVar7 = (ulonglong)(uVar5 & 0xffff);

-              uVar12 = uVar12 * 10;

-              if (0xffff < uVar12) {

-                uVar12 = 0x10000;

-              }

-            }

-          }

-          else {

-            uVar7 = (ulonglong)(bVar1 - 0x30);

-            uVar12 = 10;

-            cVar14 = cVar13;

-          }

-        }

-        else {

-          cVar14 = '\0';

-        }

-        cVar10 = '\0';

-      }

-LAB_0:

-      uVar4 = 0xffff;

-    } while (uVar3 < uVar8);

-  }

-  return uVar4 & 0xffffffffffffff00;

-joined_r0x000140661291:

-  if (uVar8 < 5) {

-LAB_2:

-    return CONCAT71((int7)(uVar4 >> 8),cVar13);

-  }

-  pcVar6 = pcVar6 + -lVar11;

-  uVar9 = uVar8 - 1;

-  cVar2 = *pcVar6;

-  uVar4 = CONCAT71((int7)(uVar4 >> 8),cVar2 - 0x30U);

-  if (9 < (byte)(cVar2 - 0x30U)) {

-    if (((cVar10 != '\0') && ((cVar2 + 0xb4U & 0xdf) == 0)) && (pcVar6[-lVar11] == '-')) {

-      *(ushort *)((longlong)param_4 + 0x1e) = uVar8 - 2;

-      *(ushort *)(param_4 + 4) = (cVar16 != '\0') + uVar3 + (uVar8 - 2);

-    }

-    goto LAB_2;

-  }

-  bVar17 = cVar10 == '\0';

-  uVar8 = uVar9;

-  cVar10 = cVar13;

-  if ((bVar17) && (cVar16 = cVar14, cVar2 == '1')) {

-    cVar16 = cVar13;

-    cVar14 = cVar13;

-  }

-  goto joined_r0x000140661291;

+  return 0xffff;

 }
```

## `SepRmProcessCreationCommandLineAuditSettingsWrkr`  (modified)

```diff
--- SepRmProcessCreationCommandLineAuditSettingsWrkr
+++ SepRmProcessCreationCommandLineAuditSettingsWrkr
@@ -1,48 +1,17 @@
 

-uint SepRmProcessCreationCommandLineAuditSettingsWrkr

-               (ulonglong param_1,uint param_2,undefined8 param_3,ulonglong param_4)

+/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

+

+void SepRmProcessCreationCommandLineAuditSettingsWrkr(longlong param_1,longlong param_2)

 

 {

-  short sVar1;

-  longlong in_RAX;

-  short *psVar2;

-  longlong lVar3;

-  short *psVar4;

-  longlong unaff_RBX;

-  longlong lVar5;

-  short unaff_SI;

-  longlong unaff_RDI;

-  longlong lVar6;

-  longlong in_R10;

-  longlong in_R11;

+  char cVar1;

   

-  param_1 = -(ulonglong)(in_RAX != 0) & param_1;

-  if (in_R11 != 0) {

-    if (param_4 < 0x7fffffff) {

-      psVar4 = (short *)(unaff_RDI + param_1 * 2);

-      lVar3 = in_R10 - param_1;

-      if (lVar3 != 0) {

-        lVar6 = (param_1 - in_R10) + lVar3 + param_4;

-        lVar5 = unaff_RBX - (longlong)psVar4;

-        do {

-          if ((lVar6 == 0) || (sVar1 = *(short *)(lVar5 + (longlong)psVar4), sVar1 == 0)) break;

-          *psVar4 = sVar1;

-          lVar6 = lVar6 + -1;

-          psVar4 = psVar4 + 1;

-          lVar3 = lVar3 + -1;

-        } while (lVar3 != 0);

-      }

-      psVar2 = psVar4 + -1;

-      if (lVar3 != 0) {

-        psVar2 = psVar4;

-      }

-      param_2 = ~-(uint)(lVar3 != 0) & 0x80000005;

-      *psVar2 = unaff_SI;

-    }

-    else {

-      param_2 = 0xc000000d;

-    }

+  *(undefined4 *)(param_2 + 0x28) = 0;

+  cVar1 = PsIsCurrentThreadInServerSilo();

+  if (cVar1 == '\0') {

+    SepRmAuditProcessCommandLine = *(undefined1 *)(param_1 + 0x2c);

+    _SepRmAuditingEnabled = 1;

   }

-  return param_2;

+  return;

 }
```

## `PopDelayedPdcRegistrationWorker`  (modified)

```diff
--- PopDelayedPdcRegistrationWorker
+++ PopDelayedPdcRegistrationWorker
@@ -1,10 +1,13 @@
-

-/* WARNING: Control flow encountered bad instruction data */

 

 void PopDelayedPdcRegistrationWorker(void)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  int iVar1;

+  

+  iVar1 = Feature_AdaptiveHibernateEnhancements__private_IsEnabledDeviceUsageNoInline();

+  if (iVar1 == 0) {

+    PopAdaptiveStandbyInitializeActivator();

+  }

+  return;

 }
```

## `ApiSetSchemaExpander_InsertContractEntry`  (modified)

```diff
--- ApiSetSchemaExpander_InsertContractEntry
+++ ApiSetSchemaExpander_InsertContractEntry
@@ -1,58 +1,23 @@
 

 undefined8

-ApiSetSchemaExpander_InsertContractEntry

-          (longlong *param_1,undefined8 param_2,undefined8 param_3,char *param_4)

+ApiSetSchemaExpander_InsertContractEntry(longlong param_1,undefined8 param_2,short *param_3)

 

 {

-  char cVar1;

-  longlong in_RAX;

-  int iVar2;

-  char unaff_SIL;

-  char cVar3;

-  char *pcVar4;

-  longlong lVar5;

-  char *in_R11;

+  short *psVar1;

+  short sVar2;

+  undefined8 uVar3;

   

-  cVar3 = '\0';

-  iVar2 = (uint)*(ushort *)(param_1 + 1) - (int)in_RAX;

-  if (0 < iVar2) {

-    lVar5 = in_RAX * 2;

-    if (*(char *)((longlong)param_1 + 10) == '\0') {

-      lVar5 = in_RAX;

-    }

-    pcVar4 = (char *)(lVar5 + *param_1);

-    if (*pcVar4 == '-') {

-      lVar5 = (ulonglong)(*(char *)((longlong)param_1 + 10) != '\0') + 1;

-      iVar2 = iVar2 + -1;

-      if (iVar2 != 0) {

-        while ((pcVar4 = pcVar4 + lVar5, 0 < iVar2 && (cVar1 = *pcVar4, cVar1 != '-'))) {

-          if (9 < (byte)(cVar1 - 0x30U)) {

-            return 0;

-          }

-          iVar2 = iVar2 + -1;

-          unaff_SIL = cVar1 + (unaff_SIL * '\x05' + -0x18) * '\x02';

-        }

-        iVar2 = iVar2 + -1;

-        if (iVar2 != 0) {

-          while( true ) {

-            pcVar4 = pcVar4 + lVar5;

-            if (iVar2 < 1) {

-              if (in_R11 != (char *)0x0) {

-                *in_R11 = unaff_SIL;

-              }

-              if (param_4 != (char *)0x0) {

-                *param_4 = cVar3;

-              }

-              return 1;

-            }

-            if (9 < (byte)(*pcVar4 - 0x30U)) break;

-            iVar2 = iVar2 + -1;

-            cVar3 = *pcVar4 + (cVar3 * '\x05' + -0x18) * '\x02';

-          }

-        }

-      }

-    }

+  sVar2 = *(short *)(param_1 + 0xac);

+  *param_3 = sVar2;

+  *(short *)(param_1 + 0xac) = sVar2 + 1;

+  uVar3 = ApiSetpInsertHashEntry

+                    (*(longlong *)(param_1 + 0x20),*(longlong *)(param_1 + 0x20) + 0x2c,sVar2,

+                     param_2,1);

+  if (-1 < (int)uVar3) {

+    psVar1 = (short *)(*(longlong *)(param_1 + 0x20) + 0x30);

+    *psVar1 = *psVar1 + 1;

+    uVar3 = 0;

   }

-  return 0;

+  return uVar3;

 }
```

## `PopEvaluateWeakChargerState`  (modified)

```diff
--- PopEvaluateWeakChargerState
+++ PopEvaluateWeakChargerState
@@ -1,62 +1,137 @@
 

 /* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+/* WARNING: Removing unreachable block (ram,0x000140ac6109) */

 

-undefined4 PopEvaluateWeakChargerState(char *param_1)

+void PopEvaluateWeakChargerState(char param_1,undefined2 param_2)

 

 {

   char cVar1;

-  longlong unaff_RBX;

-  longlong unaff_RBP;

-  int unaff_ESI;

-  uint uVar2;

-  uint *unaff_RDI;

-  char unaff_R14B;

+  undefined4 uVar2;

+  undefined1 uVar3;

+  uint uVar4;

+  int iVar5;

+  bool bVar6;

+  undefined1 auStack_138 [32];

+  undefined8 local_118;

+  undefined1 *local_110;

+  undefined4 local_108;

+  byte local_f8;

+  undefined1 local_f7;

+  undefined1 local_f6;

+  char local_f5;

+  undefined1 local_f4 [4];

+  undefined2 local_f0 [2];

+  int local_ec;

+  int local_e8;

+  undefined4 local_e4;

+  undefined8 local_e0;

+  undefined1 local_d8 [32];

+  undefined1 *local_b8;

+  undefined8 local_b0;

+  int *local_a8;

+  undefined8 local_a0;

+  int *local_98;

+  undefined8 local_90;

+  undefined1 *local_88;

+  undefined8 local_80;

+  char *local_78;

+  undefined8 local_70;

+  undefined2 *local_68;

+  undefined8 local_60;

+  undefined1 *local_58;

+  undefined8 local_50;

+  undefined4 *local_48;

+  undefined8 local_40;

+  undefined8 *local_38;

+  undefined8 local_30;

+  ulonglong local_28;

   

-  *param_1 = *param_1 + (char)param_1;

-  if ((*unaff_RDI & 8) == 0) {

-    if ((char)unaff_RDI[1] == unaff_R14B) {

-      LOCK();

-      *(uint *)(unaff_RBX + 0x614) = *(uint *)(unaff_RBX + 0x614) & 0xfffffff7;

-      UNLOCK();

+  local_28 = __security_cookie ^ (ulonglong)auStack_138;

+  PopAcquireRwLockExclusive(&PopWeakChargerLock);

+  uVar2 = 0;

+  local_f8 = 0;

+  iVar5 = 0;

+  uVar4 = 0;

+  if (PopWeakChargerNotificationUsbStack == -1) {

+    if (PopWeakChargerNotificationBatteryMiniport != -1) {

+      iVar5 = 1;

+    }

+  }

+  else if (PopWeakChargerNotificationBatteryMiniport == -1) {

+    iVar5 = 2;

+  }

+  else {

+    iVar5 = 3;

+  }

+  if (param_1 != '\0') {

+    if (iVar5 == 1) {

+      if (PopWeakChargerNotificationBatteryMiniport == 1) {

+        uVar4 = 1;

+        local_f8 = 1;

+      }

     }

     else {

-      LOCK();

-      *(uint *)(unaff_RBX + 0x614) = *(uint *)(unaff_RBX + 0x614) | 8;

-      UNLOCK();

+      if (iVar5 == 2) {

+        if (PopWeakChargerNotificationUsbStack == 0) goto LAB_0;

+        uVar4 = 2;

+      }

+      else {

+        if (iVar5 != 3) goto LAB_0;

+        if (PopWeakChargerNotificationUsbStack != 0) {

+          uVar4 = 2;

+          local_f8 = 2;

+        }

+        if (PopWeakChargerNotificationBatteryMiniport != 1) goto LAB_0;

+        uVar4 = uVar4 | 1;

+      }

+      local_f8 = (byte)uVar4;

     }

   }

-  if ((*unaff_RDI & 4) == 0) {

-    if (unaff_ESI == 0) goto LAB_0;

+LAB_0:

+  bVar6 = PopWeakChargerCompositeState != uVar4;

+  if (bVar6) {

+    local_108 = 0;

+    local_110 = (undefined1 *)((ulonglong)local_110 & 0xffffffff00000000);

+    local_118 = 0;

+    uVar2 = ZwUpdateWnfStateData(&WNF_PO_RECONCILED_WEAK_CHARGER,&local_f8,1,0);

+    uVar4 = (uint)local_f8;

+    PopWeakChargerCompositeState = (uint)local_f8;

   }

-  else if (*(char *)((longlong)unaff_RDI + 5) == '\0') {

-    LOCK();

-    *(uint *)(unaff_RBX + 0x610) = *(uint *)(unaff_RBX + 0x610) & 0xfff7ffff;

-    UNLOCK();

+  uVar3 = (undefined1)uVar4;

+  if ((5 < DAT_1) && (cVar1 = _tlgKeywordOn(&DAT_1,0x400000000000), cVar1 != '\0'))

+  {

+    local_b8 = &local_f7;

+    local_ec = PopWeakChargerNotificationBatteryMiniport;

+    local_a8 = &local_ec;

+    local_b0 = 1;

+    local_e8 = PopWeakChargerNotificationUsbStack;

+    local_98 = &local_e8;

+    local_f6 = PopWeakChargerMeasured;

+    local_88 = &local_f6;

+    local_78 = &local_f5;

+    local_68 = local_f0;

+    local_58 = local_f4;

+    local_48 = &local_e4;

+    local_38 = &local_e0;

+    local_110 = local_d8;

+    local_118 = CONCAT44(local_118._4_4_,0xb);

+    local_a0 = 4;

+    local_90 = 4;

+    local_80 = 1;

+    local_70 = 1;

+    local_60 = 2;

+    local_50 = 1;

+    local_40 = 4;

+    local_e0 = 0x1000000;

+    local_30 = 8;

+    local_f7 = uVar3;

+    local_f5 = param_1;

+    local_f4[0] = bVar6;

+    local_f0[0] = param_2;

+    local_e4 = uVar2;

+    _tlgWriteTransfer_EtwWriteTransfer(&DAT_1,&DAT_14004c9a8,0,0);

   }

-  else {

-    LOCK();

-    *(uint *)(unaff_RBX + 0x610) = *(uint *)(unaff_RBX + 0x610) | 0x80000;

-    UNLOCK();

-  }

-  PspEnumJobsAndProcessesInJobHierarchy();

-LAB_0:

-  ExReleaseResourceLite();

-  if ((unaff_ESI != 0) && (PspEnumJobsAndProcessesInJobHierarchy(), *(int *)(unaff_RBP + -0x49) < 0)

-     ) {

-    *unaff_RDI = *unaff_RDI & 0xfffffffb;

-    *(undefined4 *)(unaff_RBP + -0x21) = 4;

-    *(undefined1 *)(unaff_RBP + -0x1c) = 0;

-    PspFreezeJobTree();

-    *(undefined4 *)(unaff_RBP + -0x49) = 0x106;

-  }

-  if (*(int *)(unaff_RBP + -0x3d) != 0 || *(int *)(unaff_RBP + -0x41) != 0) {

-    uVar2 = 0;

-    do {

-      cVar1 = PspSendWakeNotification();

-      if (cVar1 != '\0') break;

-      uVar2 = uVar2 + 1;

-    } while (uVar2 < 7);

-  }

-  return *(undefined4 *)(unaff_RBP + -0x49);

+  PopReleaseRwLock(&PopWeakChargerLock);

+  return;

 }
```

## `ApiSetpSearchForSectionIndex_V7`  (modified)

```diff
--- ApiSetpSearchForSectionIndex_V7
+++ ApiSetpSearchForSectionIndex_V7
@@ -1,140 +1,55 @@
 

-ulonglong ApiSetpSearchForSectionIndex_V7

-                    (undefined8 param_1,ushort param_2,uint param_3,longlong param_4,

-                    undefined8 param_5,undefined8 param_6,char param_7)

+undefined2

+ApiSetpSearchForSectionIndex_V7

+          (longlong param_1,longlong param_2,undefined8 param_3,undefined1 param_4)

 

 {

   byte bVar1;

-  char cVar2;

+  byte bVar2;

   char cVar3;

-  ulonglong in_RAX;

-  ulonglong uVar4;

+  uint uVar4;

   uint uVar5;

-  char *pcVar6;

-  ulonglong uVar7;

-  ushort uVar8;

-  char unaff_BL;

-  longlong unaff_RBP;

-  uint unaff_ESI;

-  longlong unaff_RDI;

-  char cVar9;

-  ushort in_R10W;

-  char in_R11B;

-  char unaff_R12B;

-  byte *unaff_R13;

-  char unaff_R14B;

-  uint unaff_R15D;

-  bool bVar11;

-  ushort uVar10;

+  ulonglong uVar6;

+  undefined7 uVar7;

+  char cVar8;

+  ulonglong uVar9;

+  undefined7 uVar10;

+  byte bVar11;

+  undefined2 local_res10 [4];

   

-  do {

-    bVar1 = *unaff_R13;

-    cVar9 = (char)param_3;

-    uVar10 = (ushort)param_3;

-    if (bVar1 == 0x2d) {

-      if (in_R11B == '\0') {

-        *(uint *)(param_4 + 0xc) = param_3;

-        *(ushort *)(param_4 + 0x12) = in_R10W;

-        param_2 = in_R10W;

-      }

-      else if (unaff_R14B == '\0') {

-        in_R11B = '\0';

-        *(short *)(param_4 + 0x18) = (short)unaff_R15D;

-        unaff_R15D = 0;

-        *(undefined4 *)(param_4 + 0xc) = 3;

-        *(ushort *)(param_4 + 0x12) = param_2;

-        unaff_R14B = cVar9;

-        goto LAB_0;

-      }

-LAB_1:

-      *(ushort *)(param_4 + 0x14) = param_2;

-      if ((((7 < param_2) &&

-           (pcVar6 = (char *)((-(ulonglong)(unaff_R12B != '\0') & 4) + 4 + unaff_RDI),

-           (*pcVar6 + 0xb3U & 0xdf) == 0)) &&

-          (pcVar6 = pcVar6 + unaff_RBP, (*pcVar6 + 0xadU & 0xdf) == 0)) &&

-         (pcVar6[unaff_RBP] == '-')) {

-        *(undefined4 *)(param_4 + 0x1a) = 0x60004;

-      }

-      uVar4 = (ulonglong)*(ushort *)(param_4 + 0x14);

-      uVar7 = uVar4 * 2;

-      if (unaff_R12B == '\0') {

-        uVar7 = uVar4;

-      }

-      pcVar6 = (char *)(uVar7 + unaff_RDI);

-      cVar3 = '\0';

-      uVar5 = 0;

-      break;

-    }

-    if (bVar1 == 0x7e) {

-      if (unaff_R14B == '\0') {

-        *(ushort *)(param_4 + 0x12) = in_R10W;

-        *(undefined4 *)(param_4 + 0xc) = 2;

-        *(ushort *)(param_4 + 0x16) = (in_R10W - param_2) - uVar10;

-        goto LAB_1;

-      }

-LAB_2:

-      return in_RAX & 0xffffffffffffff00;

-    }

-    if (bVar1 == 0x2e) {

-      if ((unaff_R14B != '\0') || (param_7 != '\0')) goto LAB_2;

-      in_R11B = '\0';

-      param_7 = cVar9;

-      in_R10W = param_2;

-    }

-    else {

-      if ((byte)(bVar1 - 0x30) < 10) {

-        if (unaff_BL == '\0') {

-          if (in_R11B != '\0') {

-            in_RAX = (ulonglong)(unaff_R15D & 0xffff);

-            uVar5 = (bVar1 - 0x30) * unaff_ESI + (unaff_R15D & 0xffff);

-            if (0xffff < uVar5) goto LAB_2;

-            unaff_R15D = uVar5 & 0xffff;

-            unaff_ESI = unaff_ESI * 10;

-            if (0xffff < unaff_ESI) {

-              unaff_ESI = 0x10000;

-            }

-          }

-        }

-        else {

-          unaff_R15D = bVar1 - 0x30;

-          in_R11B = cVar9;

-          unaff_ESI = 10;

-        }

-      }

-      else {

-        in_R11B = '\0';

-      }

-      cVar9 = '\0';

-      in_RAX = 0xffff;

-    }

-LAB_0:

-    if (param_2 <= uVar10) goto LAB_2;

-    unaff_R13 = unaff_R13 + -unaff_RBP;

-    param_2 = param_2 + (short)in_RAX;

-    unaff_BL = cVar9;

-  } while( true );

-joined_r0x000140661291:

-  if (param_2 < 5) {

-LAB_3:

-    return CONCAT71((int7)(uVar4 >> 8),cVar9);

+  uVar9 = CONCAT71((int7)((ulonglong)param_3 >> 8),*(byte *)(param_1 + 2)) & 0xffffffffffffff10;

+  bVar1 = *(byte *)(param_1 + 2) & 8;

+  uVar6 = CONCAT71((int7)((ulonglong)param_2 >> 8),*(byte *)(param_2 + 9)) & 0xffffffffffffff02;

+  bVar11 = *(byte *)(param_2 + 9) & 4;

+  uVar10 = (undefined7)(uVar9 >> 8);

+  uVar7 = (undefined7)(uVar6 >> 8);

+  cVar8 = (char)uVar9;

+  cVar3 = (char)uVar6;

+  if (bVar11 == 0) {

+    uVar4 = ApiSetpGetSearchKeyHash

+                      (param_3,CONCAT71(uVar7,cVar3 != '\0'),CONCAT71(uVar10,bVar1 != 0),

+                       cVar8 != '\0',*(undefined1 *)(param_2 + 10));

   }

-  pcVar6 = pcVar6 + -unaff_RBP;

-  uVar8 = param_2 - 1;

-  cVar2 = *pcVar6;

-  uVar4 = CONCAT71((int7)(uVar4 >> 8),cVar2 - 0x30U);

-  if (9 < (byte)(cVar2 - 0x30U)) {

-    if (((cVar3 != '\0') && ((cVar2 + 0xb4U & 0xdf) == 0)) && (pcVar6[-unaff_RBP] == '-')) {

-      *(ushort *)(param_4 + 0x1e) = param_2 - 2;

-      *(ushort *)(param_4 + 0x20) = ((char)uVar5 != '\0') + uVar10 + (param_2 - 2);

-    }

-    goto LAB_3;

+  else {

+    bVar2 = ApiSetpGetSearchKeyHash

+                      (param_3,CONCAT71(uVar7,cVar3 != '\0'),CONCAT71(uVar10,bVar1 != 0),

+                       cVar8 != '\0',*(undefined1 *)(param_2 + 10));

+    uVar4 = (uint)bVar2;

   }

-  bVar11 = cVar3 == '\0';

-  param_2 = uVar8;

-  cVar3 = cVar9;

-  if ((bVar11) && (uVar5 = uVar5 & 0xff, cVar2 == '1')) {

-    uVar5 = param_3;

+  if (bVar11 == 0) {

+    uVar5 = ApiSetpGetSearchKeyHash

+                      (param_3,param_4,bVar1 != 0,cVar8 != '\0',*(undefined1 *)(param_2 + 0xb));

   }

-  goto joined_r0x000140661291;

+  else {

+    bVar1 = ApiSetpGetSearchKeyHash

+                      (param_3,param_4,bVar1 != 0,cVar8 != '\0',*(undefined1 *)(param_2 + 0xb));

+    uVar5 = (uint)bVar1;

+  }

+  local_res10[0] = 0;

+  cVar3 = ApiSetpFindHashtableIndexAndVerify_V7(param_1,param_2,uVar4,uVar5,local_res10);

+  if (cVar3 == '\0') {

+    local_res10[0] = 0xffff;

+  }

+  return local_res10[0];

 }
```

## `PopBatteryWorker`  (modified)

```diff
--- PopBatteryWorker
+++ PopBatteryWorker
@@ -1,99 +1,903 @@
 

 /* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+/* WARNING: Removing unreachable block (ram,0x000140ac5295) */

 /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

 

 void PopBatteryWorker(void)

 

 {

-  uint uVar1;

-  undefined4 uVar2;

-  uint uVar3;

-  undefined4 uVar4;

-  char *pcVar5;

-  char unaff_BL;

-  undefined8 *unaff_RBP;

-  char unaff_SIL;

-  undefined4 unaff_EDI;

-  ulonglong uVar6;

-  undefined4 in_R9D;

-  undefined4 in_R10D;

-  undefined8 unaff_R12;

-  int unaff_R13D;

-  undefined8 in_stack_00000020;

-  undefined8 in_stack_00000050;

-  uint in_stack_00000058;

-  uint uStack0000000000000064;

-  undefined4 in_stack_00000070;

+  byte *pbVar1;

+  undefined8 uVar2;

+  undefined1 auVar3 [16];

+  int iVar4;

+  code *pcVar5;

+  undefined8 uVar6;

+  undefined8 uVar7;

+  undefined8 *puVar8;

+  char cVar9;

+  char cVar10;

+  int iVar11;

+  uint uVar12;

+  uint uVar13;

+  undefined4 uVar14;

+  undefined4 uVar15;

+  ulonglong uVar16;

+  uint uVar17;

+  uint uVar18;

+  undefined8 *puVar19;

+  char *pcVar20;

+  longlong lVar21;

+  undefined1 *puVar22;

+  uint uVar23;

+  undefined8 *puVar24;

+  uint uVar25;

+  undefined8 *puVar26;

+  char *pcVar27;

+  int iVar28;

+  uint uVar29;

+  ulonglong uVar30;

+  int iVar31;

+  ulonglong unaff_R13;

+  uint uVar32;

+  ulonglong uVar33;

+  byte bVar34;

+  uint uVar35;

+  undefined1 local_518 [8];

+  undefined1 auStack_510 [24];

+  ulonglong *local_4f8;

+  int *local_4f0;

+  undefined4 local_4e8;

+  undefined4 local_4e0;

+  int local_4d8;

+  undefined1 local_4c8;

+  undefined1 local_4c7;

+  undefined1 local_4c6;

+  char local_4c5;

+  int local_4c4;

+  int local_4c0;

+  uint local_4bc;

+  uint local_4b8;

+  undefined4 local_4b4;

+  uint local_4b0;

+  uint local_4ac;

+  longlong local_4a8;

+  int local_4a0;

+  uint local_49c;

+  uint local_498;

+  uint local_494;

+  ulonglong local_490;

+  uint local_488;

+  undefined8 local_480;

+  undefined8 uStack_478;

+  longlong local_470;

+  undefined8 uStack_468;

+  int local_460;

+  undefined8 local_458;

+  ulonglong local_450;

+  undefined4 local_448;

+  undefined4 local_444;

+  undefined4 local_440;

+  uint local_43c;

+  uint local_438;

+  undefined4 local_434;

+  undefined4 local_430;

+  uint local_42c;

+  uint local_428 [2];

+  undefined8 local_420;

+  ulonglong local_418;

+  undefined8 local_410;

+  undefined8 local_408;

+  undefined8 uStack_400;

+  undefined8 local_3f8;

+  undefined8 uStack_3f0;

+  undefined4 local_3e8;

+  undefined4 uStack_3e4;

+  undefined4 uStack_3e0;

+  undefined4 uStack_3dc;

+  undefined8 local_3d8;

+  undefined1 local_3c8 [16];

+  undefined8 local_3b8;

+  undefined8 uStack_3b0;

+  undefined8 local_3a8;

+  undefined1 local_398 [16];

+  undefined8 local_388;

+  undefined8 uStack_380;

+  undefined8 local_378;

+  undefined8 local_370;

+  undefined8 uStack_368;

+  undefined8 local_360;

+  undefined8 uStack_358;

+  undefined4 local_350;

+  uint uStack_34c;

+  uint uStack_348;

+  undefined4 uStack_344;

+  undefined4 local_340;

+  uint uStack_33c;

+  undefined4 local_338;

+  undefined1 local_328 [32];

+  undefined1 *local_308;

+  undefined8 local_300;

+  undefined1 *local_2f8;

+  undefined8 local_2f0;

+  undefined1 *local_2e8;

+  undefined8 local_2e0;

+  uint *local_2d8;

+  undefined8 local_2d0;

+  ulonglong *local_2c8;

+  undefined8 local_2c0;

+  undefined1 *local_2b8;

+  undefined8 local_2b0;

+  undefined1 local_2a8 [32];

+  uint *local_288;

+  undefined8 local_280;

+  undefined1 local_278 [16];

+  undefined1 local_268 [16];

+  undefined1 local_258 [16];

+  undefined1 local_248 [16];

+  undefined1 local_238 [16];

+  undefined1 local_228 [16];

+  undefined1 local_218 [16];

+  undefined1 local_208 [16];

+  undefined1 local_1f8 [16];

+  undefined1 *local_1e8;

+  undefined8 local_1e0;

+  undefined1 *local_1d8;

+  undefined8 local_1d0;

+  uint *local_1c8;

+  undefined8 local_1c0;

+  uint *local_1b8;

+  undefined8 local_1b0;

+  undefined4 *local_1a8;

+  undefined8 local_1a0;

+  undefined4 *local_198;

+  undefined8 local_190;

+  undefined4 *local_188;

+  undefined8 local_180;

+  uint *local_178;

+  undefined8 local_170;

+  undefined1 local_168 [16];

+  ulonglong *local_158;

+  undefined8 local_150;

+  undefined1 *local_148;

+  undefined8 local_140;

+  int local_138 [8];

+  undefined1 *local_118;

+  undefined8 local_110;

+  undefined4 *local_108;

+  undefined8 local_100;

+  undefined4 *local_f8;

+  undefined8 local_f0;

+  undefined1 local_e8 [16];

+  undefined1 local_d8 [16];

+  undefined1 local_c8 [16];

+  undefined1 local_b8 [16];

+  undefined8 *local_a8;

+  undefined8 local_a0;

+  undefined1 local_98 [32];

+  undefined1 *local_78;

+  undefined8 local_70;

+  ulonglong local_68;

   

-  uVar4 = (undefined4)((ulonglong)in_stack_00000020 >> 0x20);

-  _tlgCreate1Sz_char((int)unaff_RBP + 0x220);

-  uVar3 = DAT_0;

-  uVar6 = (ulonglong)DAT_0;

-  in_stack_00000058 = (uint)unaff_R12;

-  uStack0000000000000064 = in_stack_00000058;

-  if (DAT_0 != 0) {

-    uStack0000000000000064 = (DAT_1 * 100 + (DAT_140f0b598 >> 1)) / DAT_140f0b598;

-  }

-  unaff_RBP[0x46] = &stack0x00000064;

-  unaff_RBP[0x47] = 4;

-  if (uVar3 != 0) {

-    in_stack_00000058 = (uint)(((ulonglong)DAT_1 * 100000) / uVar6);

-  }

-  uVar1 = _DAT_2 & 0x40000000;

-  pcVar5 = "Relative Capacity Unit";

-  unaff_RBP[0x49] = 4;

-  unaff_RBP[0x48] = &stack0x00000058;

-  *(uint *)((longlong)unaff_RBP + -0x14) = DAT_1;

-  unaff_RBP[0x4a] = (longlong)unaff_RBP + -0x14;

-  unaff_RBP[0x4c] = unaff_RBP + -2;

-  *(undefined4 *)((longlong)unaff_RBP + -0x1c) = DAT_3;

-  unaff_RBP[0x4e] = (longlong)unaff_RBP + -0x1c;

-  *(undefined4 *)((longlong)unaff_RBP + -0x2c) = DAT_4;

-  unaff_RBP[0x50] = (longlong)unaff_RBP + -0x2c;

-  *(undefined4 *)(unaff_RBP + -5) = DAT_5;

-  unaff_RBP[0x52] = unaff_RBP + -5;

-  unaff_RBP[0x54] = (longlong)unaff_RBP + -0x24;

-  if (uVar1 == 0) {

-    pcVar5 = "mWh Unit";

-  }

-  unaff_RBP[0x4b] = 4;

-  *(uint *)(unaff_RBP + -2) = uVar3;

-  unaff_RBP[0x4d] = 4;

-  unaff_RBP[0x4f] = 4;

-  unaff_RBP[0x51] = 4;

-  unaff_RBP[0x53] = 4;

-  *(undefined4 *)((longlong)unaff_RBP + -0x24) = in_R10D;

-  unaff_RBP[0x55] = 4;

-  _tlgCreate1Sz_char(unaff_RBP + 0x56,pcVar5);

-  uVar2 = DAT_6;

-  unaff_RBP[0x58] = unaff_RBP + -0xf;

-  *(undefined4 *)(unaff_RBP + -0xf) = uVar2;

-  unaff_RBP[0x5a] = &stack0x00000070;

-  unaff_RBP[0x59] = 4;

-  unaff_RBP[0x5b] = 4;

-  in_stack_00000070 = in_R9D;

-  _tlgWriteTransfer_EtwWriteTransfer(&DAT_7,&DAT_14004c238,0,0,CONCAT44(uVar4,0x17));

-  if (in_stack_00000050._4_4_ == unaff_R13D) {

-    if (unaff_SIL == '\0') {

-      *unaff_RBP = _DAT_8;

+  puVar22 = local_518;

+  local_68 = __security_cookie ^ (ulonglong)local_518;

+  local_458 = 0;

+  local_450 = 0;

+  local_420 = 0;

+  local_4c8 = 0;

+  local_370 = 0;

+  uStack_368 = 0;

+  local_340 = 0;

+  uStack_33c = 0;

+  local_360 = 0;

+  uStack_358 = 0;

+  local_338 = 0;

+  local_350 = 0;

+  uStack_34c = 0;

+  uStack_348 = 0;

+  uStack_344 = 0;

+  PopAcquireRwLockShared(&PopPolicyDeviceLock);

+  PopAcquireRwLockExclusive(&PopCB);

+  local_4f0 = &local_4c0;

+  local_490 = 0;

+  local_4f8 = &local_490;

+  local_4b4 = 0;

+  local_4c0 = 8;

+  iVar11 = ZwQueryWnfStateData(&WNF_PO_DISCHARGE_START_FILETIME,0,0,&local_4b4);

+  lVar21 = DAT_0;

+  if ((iVar11 == -0x3fffff66) || (iVar11 == -0x3ffffe77)) {

+    local_4c4 = 0;

+  }

+  else if ((iVar11 == 0) && (local_4c0 == 8)) {

+    local_4c4 = (local_490 != 0) + 2;

+  }

+  else {

+    local_4c4 = 1;

+  }

+  local_4a8 = DAT_0;

+  for (puVar19 = DAT_1; (undefined8 **)puVar19 != &DAT_1;

+      puVar19 = (undefined8 *)*puVar19) {

+    IoCancelIrp(puVar19[-1]);

+  }

+  puVar19 = DAT_1;

+  if ((lVar21 != 0) && (*(int *)(lVar21 + 0x80) - 1U < 2)) {

+    IoCancelIrp(*(undefined8 *)(lVar21 + 0x38));

+    puVar19 = DAT_1;

+  }

+  for (; (undefined8 **)puVar19 != &DAT_1; puVar19 = (undefined8 *)*puVar19) {

+    local_4f8 = (ulonglong *)0x0;

+    KeWaitForMutexObject(puVar19 + 2,0,0,0);

+  }

+  if ((lVar21 != 0) && (*(int *)(lVar21 + 0x80) - 1U < 2)) {

+    local_4f8 = (ulonglong *)0x0;

+    KeWaitForMutexObject(lVar21 + 0x68,0,0,0);

+  }

+  uVar16 = unaff_R13 & 0xffffffffffffff00;

+  local_4c7 = 0;

+  local_4bc = (uint)uVar16;

+  local_4ac = 0;

+  while( true ) {

+    uVar17 = PopBatteryWorkRequests;

+    uVar35 = (uint)uVar16;

+    bVar34 = 0;

+    LOCK();

+    PopBatteryWorkRequests = 0x80000000;

+    uVar30 = (ulonglong)uVar17;

+    UNLOCK();

+    local_4b8 = uVar17;

+    uVar33 = (ulonglong)(CONCAT31((uint3)(uVar17 >> 9),(char)(uVar17 >> 1)) & 0xffffff01);

+    local_4ac = local_4ac & 0xff;

+    if ((uVar17 & 8) != 0) {

+      local_4ac = 1;

+    }

+    if ((uVar17 & 0x10) != 0) {

+      PopAcquirePolicyLock();

+      PopResetCBTriggers(0x80);

+      PopReleasePolicyLock();

+    }

+    local_4c5 = (uVar17 >> 6 & 1) != 0;

+    local_488 = (uint)((uVar17 >> 6 & 1) != 0);

+    puVar26 = DAT_2;

+    puVar19 = DAT_1;

+    if (((((char)uVar17 < '\0') && (lVar21 != 0)) && (*(int *)(lVar21 + 0x80) - 1U < 2)) &&

+       ((*(byte *)(lVar21 + 0x8c) & 1) != 0)) {

+      bVar34 = 1;

+    }

+    while (puVar8 = puVar19, DAT_2 = puVar26, (undefined8 **)puVar8 != &DAT_140f0b550) {

+      uVar17 = (uint)uVar33;

+      puVar19 = (undefined8 *)*puVar8;

+      puVar24 = puVar8 + -8;

+      if (*(int *)(puVar8 + 5) == 2) {

+        if (((undefined8 *)puVar19[1] != puVar8) ||

+           (puVar26 = (undefined8 *)puVar8[1], (undefined8 *)*puVar26 != puVar8)) {

+          pcVar5 = (code *)swi(0x29);

+          (*pcVar5)(3);

+          puVar22 = auStack_510;

+          goto LAB_3;

+        }

+        *puVar26 = puVar19;

+        puVar19[1] = puVar26;

+        *puVar8 = 0;

+        _DAT_4 = _DAT_4 + 1;

+        DAT_5 = DAT_5 - 1;

+        DAT_6 = 1;

+        iVar11 = PopBatteryReadTag(puVar24);

+        if (iVar11 < 0) {

+          PopBatteryWaitTag(puVar24);

+        }

+        uVar33 = CONCAT71((int7)(uVar33 >> 8),1);

+        puVar26 = DAT_2;

+      }

+    }

+    for (; (undefined8 **)puVar26 != &DAT_2; puVar26 = (undefined8 *)*puVar26) {

+      if (*(int *)(puVar26 + 0xd) == 1) {

+        local_4f8 = (ulonglong *)0x0;

+        KeWaitForMutexObject(puVar26 + 10,0,0,0);

+        iVar11 = PopBatteryInitialize();

+        if (iVar11 < 0) {

+          PopBatteryWaitTag();

+        }

+        else {

+          uVar33 = 1;

+        }

+      }

+    }

+    puVar19 = DAT_1;

+    if ((undefined8 **)DAT_1 != &DAT_1) {

+      do {

+        puVar26 = puVar19 + -8;

+        local_408 = *(undefined8 *)((longlong)puVar19 + 0x54);

+        uStack_400 = *(undefined8 *)((longlong)puVar19 + 0x5c);

+        iVar11 = PopBatteryQueryStatus(puVar26);

+        if (-1 < iVar11) {

+          PopAccountBatteryEnergyChange(puVar26);

+          if ((((*(uint *)((longlong)puVar19 + 0x54) ^ (uint)local_408) & 7) == 0) &&

+             ((local_408._4_4_ != *(int *)(puVar19 + 0xb) ||

+              (uStack_400._4_4_ != *(int *)(puVar19 + 0xc))))) {

+            local_4ac = CONCAT31(local_4ac._1_3_,1);

+          }

+          iVar11 = -1;

+          if ((*(uint *)((longlong)puVar19 + 0x54) & 2) != 0) {

+            iVar11 = PopBatteryQueryEstimatedTime(puVar26,0);

+          }

+          *(int *)(puVar19 + 0xf) = iVar11;

+          local_4d8 = 0;

+          if (iVar11 != -1) {

+            local_4d8 = iVar11;

+          }

+          local_4e0 = *(undefined4 *)(puVar19 + 0xc);

+          local_4e8 = *(undefined4 *)((longlong)puVar19 + 0x5c);

+          local_4f0 = (int *)CONCAT44(local_4f0._4_4_,*(undefined4 *)(puVar19 + 0xb));

+          local_4f8 = (ulonglong *)

+                      CONCAT44(local_4f8._4_4_,*(undefined4 *)((longlong)puVar19 + 0x54));

+                    /* WARNING: Subroutine does not return */

+          DbgPrintEx(0x92,3,

+                     "\nBattery Status [%p]\n|-- PowerState = 0x%08x\n|-- Capacity   = %u\n|-- Voltage    = %u\n|-- Rate       = %d\n|-- Est Time   = %u\n"

+                     ,puVar26);

+        }

+        *(undefined4 *)(puVar19 + 5) = 2;

+        PopBatteryQueueWork();

+        puVar19 = (undefined8 *)*puVar19;

+      } while ((undefined8 **)puVar19 != &DAT_1);

+      uVar30 = (ulonglong)local_4b8;

+      lVar21 = local_4a8;

+      local_4bc = uVar35;

+    }

+    cVar9 = PopPowerAdapterRecOverride;

+    if ((lVar21 != 0) && (*(int *)(lVar21 + 0x80) - 1U < 2)) {

+      if (bVar34 == 0) {

+        auVar3 = *(undefined1 (*) [16])(lVar21 + 0xb0);

+        uVar6 = *(undefined8 *)(lVar21 + 0xc0);

+        uVar7 = *(undefined8 *)(lVar21 + 200);

+        uVar2 = *(undefined8 *)(lVar21 + 0xd0);

+        local_398 = auVar3;

+        local_388 = uVar6;

+        uStack_380 = uVar7;

+        local_378 = uVar2;

+        iVar11 = PopPowerAdapterQueryStatus();

+        if (iVar11 < 0) {

+          PopPowerAdapterTraceFailure(lVar21,4,iVar11);

+        }

+        else {

+          uVar16 = uVar16 & 0xff;

+          *(undefined4 *)(lVar21 + 0x80) = 1;

+          if (((auVar3[4] ^ *(byte *)(lVar21 + 0xb4)) & 1) != 0) {

+            uVar16 = 1;

+          }

+          local_4bc = (uint)uVar16;

+          if ((*(uint *)(lVar21 + 0x8c) & 1) != 0) {

+            local_3f8 = *(undefined8 *)(lVar21 + 0xb0);

+            uStack_3f0 = *(undefined8 *)(lVar21 + 0xb8);

+            local_3e8 = *(undefined4 *)(lVar21 + 0xc0);

+            uStack_3e4 = *(undefined4 *)(lVar21 + 0xc4);

+            uStack_3e0 = *(undefined4 *)(lVar21 + 200);

+            uStack_3dc = *(undefined4 *)(lVar21 + 0xcc);

+            local_3d8 = *(undefined8 *)(lVar21 + 0xd0);

+            local_3c8 = auVar3;

+            local_3b8 = uVar6;

+            uStack_3b0 = uVar7;

+            local_3a8 = uVar2;

+            PopPowerAdapterPublishRecState();

+          }

+        }

+      }

+      else {

+        LOCK();

+        UNLOCK();

+        if (PopPowerAdapterRecOverride != *(char *)(lVar21 + 0xd8)) {

+          if (PopPowerAdapterRecOverride == '\0') {

+            uVar17 = *(uint *)(lVar21 + 0xb4) & 0xfffffffb;

+          }

+          else {

+            uVar17 = *(uint *)(lVar21 + 0xb4) | 4;

+          }

+          *(uint *)(lVar21 + 0xb4) = uVar17;

+          local_4f0 = (int *)((ulonglong)local_4f0 & 0xffffffff00000000);

+          local_4a0 = (uint)((uVar17 & 4) != 0) << 8;

+          local_4f8 = (ulonglong *)CONCAT44(local_4f8._4_4_,4);

+          PopPrepareIoctl(*(undefined8 *)(lVar21 + 0x38),0x294074,0);

+          iVar11 = IoSynchronousCallDriver();

+          if (iVar11 < 0) {

+            PopPowerAdapterTraceFailure(lVar21,3,iVar11);

+          }

+          else {

+            *(undefined4 *)(lVar21 + 0x80) = 1;

+            *(char *)(lVar21 + 0xd8) = cVar9;

+          }

+        }

+      }

+    }

+    if ((char)uVar33 != '\0') {

+      PopBatteryUpdateCompositeInformation();

+      uVar16 = CONCAT71((int7)(uVar16 >> 8),1);

+      PopMaxChargeRate = 0;

+      local_4bc = (uint)uVar16;

+    }

+    if (((uVar30 & 4) != 0) || ((char)uVar16 != '\0')) {

+      if (PopEstimateSpoilerMask == 0) {

+        PopEstimateSpoiledUntilTime = _DAT_7 + 300000000;

+        local_4f8 = (ulonglong *)&PopPostSpoilingRefresh;

+        KiSetTimerEx(&DAT_8,0xffffffffee1e5d00,0);

+      }

+      else {

+        PopEstimateSpoiledUntilTime = -1;

+        KeCancelTimer();

+      }

+    }

+    local_498 = 0;

+    local_460 = -1;

+    uVar32 = 0x80000000;

+    local_4b8 = 0x80000000;

+    uVar35 = 0xffffffff;

+    iVar28 = -1;

+    uStack_478 = 0x80000000ffffffff;

+    uVar29 = 0xffffffff;

+    local_480 = 0xffffffff00000000;

+    iVar11 = -1;

+    local_470 = -0x100000000;

+    uVar23 = 0xffffffff;

+    iVar31 = -1;

+    uStack_468 = 0xffffffffffffffff;

+    local_458 = 0xffffffffffffffff;

+    local_450 = 0xffffffffffffffff;

+    local_4b0 = 0xffffffff;

+    uVar17 = local_4b0;

+    if (DAT_5 == 0) {

+      uVar32 = 1;

+      local_480 = 0xffffffff00000001;

+      if ((local_4c4 == 3) &&

+         (uVar16 = KiQueryUnbiasedInterruptTime(0xffffff01), uVar32 = 1, uVar17 = local_4b0,

+         299999999 < uVar16)) {

+        local_4c4 = 1;

+      }

     }

     else {

-      *unaff_RBP = unaff_R12;

-    }

-    ZwUpdateWnfStateData(&WNF_PO_DISCHARGE_START_FILETIME);

-  }

-  if (unaff_BL != '\0') {

-    *(undefined4 *)((longlong)unaff_RBP + -4) = 0xffffffff;

-    uVar4 = ZwUpdateWnfStateData(&WNF_PO_POWER_STATE_CHANGE,unaff_RBP + -1,unaff_EDI,0);

-    if (5 < DAT_7) {

-      unaff_RBP[0x75] = 4;

-      unaff_RBP[0x74] = &stack0x00000070;

-      in_stack_00000070 = uVar4;

-      _tlgWriteTransfer_EtwWriteTransfer(&DAT_7,&DAT_14004c455,0,0,3);

-    }

-  }

+      uVar25 = 0;

+      if ((undefined8 **)DAT_1 != &DAT_1) {

+        local_4b8 = 0x80000000;

+        puVar19 = DAT_1;

+        do {

+          uVar12 = *(uint *)((longlong)puVar19 + 0x54);

+          uVar13 = uVar12 & 0xe7 | 8;

+          if (((byte)uVar12 & 10) != 10) {

+            uVar13 = uVar12 & 0xe7;

+          }

+          uVar18 = 0;

+          if (((uVar25 & 0x10) == 0) && (((byte)uVar12 & 0x11) == 0x11)) {

+            uVar18 = 0x10;

+          }

+          if ((uVar12 & 1) == 0) {

+            uVar12 = (-(uint)((uVar12 & 0x10) != 0) & 0xfffffffd) + 4;

+          }

+          else {

+            uVar12 = (-(uint)((uVar12 & 0x10) != 0) & 0xfffffffa) + 8;

+          }

+          local_498 = local_498 | uVar12;

+          uVar25 = uVar25 ^ uVar18 | uVar13;

+          if (*(int *)(puVar19 + 0xb) != -1) {

+            if (iVar28 == -1) {

+              iVar28 = 0;

+            }

+            iVar28 = iVar28 + *(int *)(puVar19 + 0xb);

+            local_480._4_4_ = iVar28;

+          }

+          local_480 = CONCAT44(local_480._4_4_,uVar25);

+          uVar12 = *(uint *)((longlong)puVar19 + 0x5c);

+          uVar13 = 0;

+          if (uVar12 != 0xffffffff) {

+            if (uVar35 == 0xffffffff) {

+              uVar35 = uVar13;

+            }

+            if (uVar35 < uVar12) {

+              uVar35 = uVar12;

+            }

+            uStack_478 = CONCAT44(uStack_478._4_4_,uVar35);

+          }

+          iVar4 = *(int *)(puVar19 + 0xc);

+          if (iVar4 != -0x80000000) {

+            if (uVar32 == 0x80000000) {

+              uVar32 = uVar13;

+            }

+            uVar32 = uVar32 + iVar4;

+            uStack_478 = CONCAT44(uVar32,(undefined4)uStack_478);

+          }

+          if ((uVar12 != 0xffffffff) && (iVar4 != -0x80000000)) {

+            if (local_4b8 == 0x80000000) {

+              local_4b8 = uVar13;

+            }

+            if (uVar12 != 0) {

+              uVar13 = (int)((uVar12 >> 1) + iVar4 * 1000) / (int)uVar12;

+            }

+            local_4b8 = local_4b8 + uVar13;

+          }

+          if (*(int *)(puVar19 + 0xd) != -1) {

+            if (uVar29 == 0xffffffff) {

+              uVar29 = 0;

+            }

+            uVar29 = uVar29 + *(int *)(puVar19 + 0xd);

+            local_470 = (ulonglong)uVar29 << 0x20;

+          }

+          if (*(int *)(puVar19 + 0xe) != -1) {

+            if (uVar23 == 0xffffffff) {

+              uVar23 = 0;

+            }

+            uVar23 = uVar23 + *(int *)(puVar19 + 0xe);

+            uStack_468 = CONCAT44(uVar23,(undefined4)uStack_468);

+          }

+          if (*(int *)((longlong)puVar19 + 0x6c) != -1) {

+            if (iVar11 == -1) {

+              iVar11 = *(int *)((longlong)puVar19 + 0x6c);

+            }

+            uStack_468 = CONCAT44(uStack_468._4_4_,iVar11);

+          }

+          iVar4 = *(int *)((longlong)puVar19 + 0x74);

+          if ((iVar4 != -1) && (local_460 = iVar31, iVar31 == -1)) {

+            iVar31 = iVar4;

+            local_460 = iVar4;

+          }

+          puVar19 = (undefined8 *)*puVar19;

+          lVar21 = local_4a8;

+        } while ((undefined8 **)puVar19 != &DAT_1);

+      }

+      local_49c = uVar25;

+      if ((uVar25 & 2) != 0) {

+        local_49c = uVar25 & 0xfffffffb;

+        local_480 = CONCAT44(local_480._4_4_,uVar25) & 0xfffffffffffffffb;

+      }

+      uVar32 = local_49c;

+      if ((local_49c & 1) == 0) {

+        iVar11 = 0;

+        if ((PopDisableBatteryDischargeEstimator == 0) &&

+           (puVar19 = DAT_1, (undefined8 **)DAT_1 != &DAT_1)) {

+          do {

+            if (*(uint *)(puVar19 + 0xf) - 1 < 0xfffffffe) {

+              iVar11 = iVar11 - (uint)(*(int *)(puVar19 + 0xb) * 0xe10) / *(uint *)(puVar19 + 0xf);

+            }

+            puVar19 = (undefined8 *)*puVar19;

+          } while ((undefined8 **)puVar19 != &DAT_1);

+          if (iVar11 != 0) {

+            uVar17 = 0xffffffff;

+            puVar19 = DAT_1;

+            do {

+              iVar11 = PopBatteryQueryEstimatedTime(puVar19 + -8);

+              if (iVar11 != -1) {

+                uVar35 = 0;

+                if (uVar17 != 0xffffffff) {

+                  uVar35 = uVar17;

+                }

+                uVar17 = iVar11 + uVar35;

+              }

+              puVar19 = (undefined8 *)*puVar19;

+              lVar21 = local_4a8;

+              uVar32 = local_49c;

+            } while ((undefined8 **)puVar19 != &DAT_1);

+          }

+        }

+      }

+      else if ((local_49c & 4) != 0) {

+        local_458 = PopEstimateChargeTime();

+        uVar17 = local_4b0;

+      }

+    }

+    local_4b0 = uVar17;

+    uVar30 = 0;

+    puVar24 = (undefined8 *)(ulonglong)((byte)uVar32 & 1);

+    uVar35 = 1;

+    if (((local_4c4 == 2) && ((uVar32 & 1) == 0)) || ((local_4c4 == 3 && ((uVar32 & 1) != 0)))) {

+      local_4c4 = 1;

+    }

+    iVar11 = 0;

+    if ((DAT_9 & 0x10) != (uVar32 & 0x10)) {

+      local_4c8 = (uVar32 & 0x10) != 0;

+      local_4e8 = 0;

+      local_4f0 = (int *)((ulonglong)local_4f0 & 0xffffffff00000000);

+      local_4f8 = (ulonglong *)0x0;

+      local_438 = (uint)(byte)local_4c8;

+      uVar14 = ZwUpdateWnfStateData(&WNF_PO_BATTERY_CHARGE_LIMITING_MODE,&local_4c8,1);

+      uVar15 = PopSetPowerSettingValueAcDc(&GUID_BATTERY_CHARGE_LIMITING_MODE,4,&local_438);

+      if ((5 < DAT_10) &&

+         (cVar9 = _tlgKeywordOn(&DAT_10,0x400000000000), cVar9 != '\0')) {

+        local_118 = &local_4c6;

+        pcVar20 = "DC + BCL";

+        local_108 = &local_448;

+        uVar16 = (ulonglong)local_498;

+        pcVar27 = "-";

+        local_f8 = &local_430;

+        local_4c6 = local_4c8;

+        if ((local_498 & 1) == 0) {

+          pcVar20 = "-";

+        }

+        local_110 = 1;

+        local_100 = 4;

+        local_f0 = 4;

+        local_448 = uVar14;

+        local_430 = uVar15;

+        _tlgCreate1Sz_char(local_e8,pcVar20);

+        pcVar20 = "AC + BCL";

+        if ((uVar16 & 2) == 0) {

+          pcVar20 = pcVar27;

+        }

+        _tlgCreate1Sz_char(local_d8,pcVar20);

+        pcVar20 = "DC + !BCL";

+        if ((uVar16 & 4) == 0) {

+          pcVar20 = pcVar27;

+        }

+        _tlgCreate1Sz_char(local_c8,pcVar20);

+        pcVar20 = "AC + !BCL";

+        if ((uVar16 & 8) == 0) {

+          pcVar20 = pcVar27;

+        }

+        _tlgCreate1Sz_char(local_b8,pcVar20);

+        local_a8 = &local_410;

+        local_410 = 0x1000000;

+        local_4f0 = local_138;

+        local_a0 = 8;

+        local_4f8 = (ulonglong *)CONCAT44(local_4f8._4_4_,10);

+        _tlgWriteTransfer_EtwWriteTransfer(&DAT_10,&DAT_14004c489,0);

+      }

+    }

+    if ((uVar32 & 0x20) != 0) {

+      iVar11 = ((uVar32 & 0x40) != 0) + 1;

+    }

+    cVar9 = local_4c5;

+    if (DAT_11 != iVar11) {

+      PopAcquireRwLockExclusive(&PopWeakChargerLock);

+      PopWeakChargerNotificationBatteryMiniport = iVar11;

+      DAT_11 = iVar11;

+      PopReleaseRwLock(&PopWeakChargerLock);

+      cVar9 = '\x01';

+    }

+    uVar17 = local_4b0;

+    puVar19 = &local_480;

+    cVar10 = PopBatteryApplyCompositeState(puVar19);

+    if ((cVar10 != '\0') || (cVar9 != '\0')) {

+      PopEvaluateWeakChargerState

+                (CONCAT71((int7)((ulonglong)puVar19 >> 8),(byte)uVar32) & 0xffffffffffffff01);

+    }

+    bVar34 = 4;

+    LOCK();

+    PopBatteryWorkRequests = PopBatteryWorkRequests & 0xffffffdf;

+    UNLOCK();

+    DAT_12 = _DAT_fffff78000000008;

+    LOCK();

+    UNLOCK();

+    if (DAT_13 != 0) {

+      ExfUnblockPushLock(&DAT_13);

+    }

+    LOCK();

+    uVar32 = PopBatteryWorkRequests;

+    if (PopBatteryWorkRequests == 0x80000000) {

+      PopBatteryWorkRequests = 0;

+      uVar32 = 0x80000000;

+    }

+    UNLOCK();

+    if (uVar32 == 0x80000000) break;

+    uVar16 = (ulonglong)local_4bc;

+  }

+LAB_3:

+  puVar19 = DAT_1;

+  if ((undefined8 **)DAT_1 != &DAT_1) {

+    do {

+      *(undefined8 *)(puVar22 + -8) = 0x140ac5a3a;

+      PopBatteryQueryStatus(puVar19 + -8,0);

+      puVar19 = (undefined8 *)*puVar19;

+    } while ((undefined8 **)puVar19 != &DAT_1);

+    uVar17 = *(uint *)(puVar22 + 0x68);

+  }

+  if ((lVar21 != 0) && (*(int *)(lVar21 + 0x80) - uVar35 <= uVar35)) {

+    *(undefined8 *)(puVar22 + -8) = 0x140ac5a64;

+    PopPowerAdapterQueryStatus(lVar21,0);

+  }

+  uVar32 = (uint)uVar30;

+  if (PopUserBatteryChargingEstimator == uVar32) {

+    *(uint *)(puVar22 + 0x30) = uVar32;

+    *(uint *)(puVar22 + 0x28) = uVar32;

+    *(ulonglong *)(puVar22 + 0x20) = uVar30;

+    *(undefined8 *)(puVar22 + -8) = 0x140ac5a97;

+    ZwUpdateWnfStateData(&WNF_PO_CHARGE_ESTIMATE,&local_458,8,0);

+  }

+  if (PopDisableBatteryDischargeEstimator == uVar32) {

+    *(undefined8 *)(puVar22 + -8) = 0x140ac5aa5;

+    cVar9 = PopBatteryEstimatesSpoiled();

+    if ((uVar17 != 0xffffffff) && (cVar9 == '\0')) {

+      local_450 = (ulonglong)uVar17;

+    }

+    *(uint *)(puVar22 + 0x30) = uVar32;

+    *(uint *)(puVar22 + 0x28) = uVar32;

+    *(ulonglong *)(puVar22 + 0x20) = uVar30;

+    *(undefined8 *)(puVar22 + -8) = 0x140ac5add;

+    ZwUpdateWnfStateData(&WNF_PO_DISCHARGE_ESTIMATE,&local_450,8,0);

+  }

+  else {

+    cVar9 = puVar22[0x51];

+  }

+  if (5 < DAT_10) {

+    *(uint *)(puVar22 + 100) = PopUserBatteryChargingEstimator;

+    local_308 = puVar22 + 100;

+    local_300 = 4;

+    *(undefined8 *)(puVar22 + 0x70) = local_458;

+    local_2f8 = puVar22 + 0x70;

+    *(uint *)(puVar22 + 0x58) = PopDisableBatteryDischargeEstimator;

+    local_2e8 = puVar22 + 0x58;

+    local_2d8 = &local_494;

+    local_490 = local_450;

+    local_2c8 = &local_490;

+    local_2b8 = puVar22 + 0x51;

+    *(undefined1 **)(puVar22 + 0x28) = local_328;

+    *(undefined4 *)(puVar22 + 0x20) = 8;

+    local_2f0 = 8;

+    local_2e0 = 4;

+    local_2d0 = 4;

+    local_2c0 = 8;

+    puVar22[0x51] = cVar9;

+    local_2b0 = 1;

+    *(undefined8 *)(puVar22 + -8) = 0x140ac5bce;

+    local_494 = uVar17;

+    _tlgWriteTransfer_EtwWriteTransfer(&DAT_10,&DAT_14004c188,0,0);

+  }

+  uVar14 = *(undefined4 *)(puVar22 + 0x5c);

+  pbVar1 = puVar22 + 0x6c;

+  *pbVar1 = *pbVar1 | (byte)uVar14;

+  if (*pbVar1 != 0) {

+    local_370 = CONCAT44(uRam0000000140f0b58c,_DAT_14);

+    uStack_368 = CONCAT44(DAT_15,uRam0000000140f0b590);

+    local_350 = DAT_16;

+    local_338 = DAT_17;

+    *(uint *)(puVar22 + 0x30) = uVar32;

+    *(uint *)(puVar22 + 0x28) = uVar32;

+    uStack_34c = DAT_9;

+    uStack_348 = DAT_18;

+    uStack_344 = DAT_19;

+    local_340 = DAT_20;

+    uStack_33c = DAT_5;

+    local_360 = CONCAT44(uRam0000000140f0b59c,DAT_21);

+    uStack_358 = CONCAT44(uRam0000000140f0b5a4,uRam0000000140f0b5a0);

+    *(ulonglong *)(puVar22 + 0x20) = uVar30;

+    *(undefined8 *)(puVar22 + -8) = 0x140ac5c54;

+    uVar15 = ZwUpdateWnfStateData(&WNF_PO_COMPOSITE_BATTERY,&local_370,0x3c);

+    if (5 < DAT_10) {

+      *(undefined8 *)(puVar22 + -8) = 0x140ac5c7a;

+      cVar9 = _tlgKeywordOn(&DAT_10,0x400000000000);

+      if (cVar9 != '\0') {

+        uVar16 = (ulonglong)DAT_9;

+        local_288 = &local_494;

+        pcVar20 = "AC Power";

+        local_494 = DAT_5;

+        local_280 = 4;

+        if ((byte)((byte)uVar35 & (byte)DAT_9) == 0) {

+          pcVar20 = "DC Power";

+        }

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5ccb;

+        uVar17 = DAT_5;

+        _tlgCreate1Sz_char(local_278,pcVar20);

+        pcVar20 = "Battery Discharging";

+        pcVar27 = "-";

+        if ((uVar16 & 2) == 0) {

+          pcVar20 = "-";

+        }

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5ced;

+        _tlgCreate1Sz_char(local_268,pcVar20);

+        pcVar20 = "Battery Charging";

+        if ((bVar34 & (byte)uVar16) == 0) {

+          pcVar20 = pcVar27;

+        }

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5d07;

+        _tlgCreate1Sz_char(local_258,pcVar20);

+        pcVar20 = "Battery Critical";

+        if ((uVar16 & 8) == 0) {

+          pcVar20 = pcVar27;

+        }

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5d21;

+        _tlgCreate1Sz_char(local_248,pcVar20);

+        pcVar20 = "Battery charge limiting mode";

+        if ((uVar16 & 0x10) == 0) {

+          pcVar20 = pcVar27;

+        }

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5d40;

+        _tlgCreate1Sz_char(local_238,pcVar20);

+        pcVar20 = "Battery charging state power supply present";

+        if ((uVar16 & 0x20) == 0) {

+          pcVar20 = pcVar27;

+        }

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5d5b;

+        _tlgCreate1Sz_char(local_228,pcVar20);

+        pcVar20 = "Battery charging state adequate";

+        if ((uVar16 & 0x40) == 0) {

+          pcVar20 = pcVar27;

+        }

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5d76;

+        _tlgCreate1Sz_char(local_218,pcVar20);

+        pcVar20 = "Battery trip point supported";

+        if ((uVar16 & 0x80) == 0) {

+          pcVar20 = pcVar27;

+        }

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5d91;

+        _tlgCreate1Sz_char(local_208,pcVar20);

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5daf;

+        _tlgCreate1Sz_char(local_1f8);

+        uVar29 = uVar32;

+        if (DAT_21 != 0) {

+          uVar29 = (DAT_18 * 100 + (DAT_140f0b598 >> 1)) / DAT_140f0b598;

+        }

+        *(uint *)(puVar22 + 100) = uVar29;

+        local_1e8 = puVar22 + 100;

+        local_1e0 = 4;

+        uVar29 = uVar32;

+        if (DAT_21 != 0) {

+          uVar29 = (uint)(((ulonglong)DAT_18 * 100000) / (ulonglong)DAT_140f0b598);

+        }

+        pcVar20 = "Relative Capacity Unit";

+        *(uint *)(puVar22 + 0x58) = uVar29;

+        local_1d8 = puVar22 + 0x58;

+        local_1d0 = 4;

+        local_42c = DAT_18;

+        local_1c8 = &local_42c;

+        local_1b8 = local_428;

+        local_434 = DAT_19;

+        local_1a8 = &local_434;

+        local_444 = DAT_20;

+        local_198 = &local_444;

+        local_440 = DAT_17;

+        local_188 = &local_440;

+        local_178 = &local_43c;

+        if ((_DAT_14 & 0x40000000) == 0) {

+          pcVar20 = "mWh Unit";

+        }

+        local_1c0 = 4;

+        local_428[0] = DAT_21;

+        local_1b0 = 4;

+        local_1a0 = 4;

+        local_190 = 4;

+        local_180 = 4;

+        local_170 = 4;

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5efd;

+        local_43c = uVar17;

+        _tlgCreate1Sz_char(local_168,pcVar20);

+        local_158 = &local_490;

+        local_148 = puVar22 + 0x70;

+        local_490 = CONCAT44(local_490._4_4_,DAT_15);

+        *(undefined4 *)(puVar22 + 0x70) = uVar15;

+        *(undefined1 **)(puVar22 + 0x28) = local_2a8;

+        *(undefined4 *)(puVar22 + 0x20) = 0x17;

+        local_150 = 4;

+        local_140 = 4;

+        *(undefined8 *)(puVar22 + -8) = 0x140ac5f65;

+        _tlgWriteTransfer_EtwWriteTransfer(&DAT_10,&DAT_14004c238,0,0);

+      }

+    }

+    if (*(uint *)(puVar22 + 0x54) == uVar35) {

+      local_418 = uVar30;

+      if ((char)puVar24 == '\0') {

+        local_418 = _DAT_22;

+      }

+      *(uint *)(puVar22 + 0x30) = uVar32;

+      *(uint *)(puVar22 + 0x28) = uVar32;

+      *(ulonglong *)(puVar22 + 0x20) = uVar30;

+      *(undefined8 *)(puVar22 + -8) = 0x140ac5fad;

+      ZwUpdateWnfStateData(&WNF_PO_DISCHARGE_START_FILETIME,&local_418,8,0);

+    }

+    if ((byte)uVar14 != 0) {

+      local_420 = CONCAT44(0xffffffff,(undefined4)local_420);

+      *(uint *)(puVar22 + 0x30) = uVar32;

+      *(uint *)(puVar22 + 0x28) = uVar32;

+      *(ulonglong *)(puVar22 + 0x20) = uVar30;

+      *(undefined8 *)(puVar22 + -8) = 0x140ac5fda;

+      uVar14 = ZwUpdateWnfStateData(&WNF_PO_POWER_STATE_CHANGE,&local_420,8,0);

+      if (5 < DAT_10) {

+        *(undefined4 *)(puVar22 + 0x70) = uVar14;

+        local_78 = puVar22 + 0x70;

+        local_70 = 4;

+        *(undefined1 **)(puVar22 + 0x28) = local_98;

+        *(undefined4 *)(puVar22 + 0x20) = 3;

+        *(undefined8 *)(puVar22 + -8) = 0x140ac602b;

+        _tlgWriteTransfer_EtwWriteTransfer(&DAT_10,&DAT_14004c455,0,0);

+      }

+    }

+  }

+  *(undefined8 *)(puVar22 + -8) = 0x140ac6037;

   PopReleaseRwLock(&PopCB);

+  *(undefined8 *)(puVar22 + -8) = 0x140ac6043;

   PopReleaseRwLock(&PopPolicyDeviceLock);

+  *(undefined8 *)(puVar22 + -8) = 0x140ac6052;

   return;

 }
```

## `IoGetDeviceInstanceName`  (modified)

```diff
--- IoGetDeviceInstanceName
+++ IoGetDeviceInstanceName
@@ -1,137 +1,53 @@
 

-undefined4

-IoGetDeviceInstanceName(undefined8 param_1,longlong param_2,undefined8 param_3,longlong param_4)

+void IoGetDeviceInstanceName(longlong param_1,undefined8 param_2)

 

 {

-  longlong *plVar1;

-  longlong lVar2;

-  code *pcVar3;

-  int iVar4;

-  int iVar5;

-  ulonglong uVar6;

-  undefined8 uVar7;

-  undefined8 uVar8;

-  longlong lVar9;

-  longlong lVar10;

-  ulonglong uVar11;

-  longlong *unaff_RBX;

-  undefined1 *puVar12;

-  undefined1 *puVar13;

-  longlong unaff_RBP;

-  longlong lVar14;

-  longlong *plVar15;

-  longlong *plVar16;

-  undefined8 *puVar17;

-  undefined4 in_R11D;

-  undefined4 uVar18;

-  undefined4 uVar19;

-  undefined8 *puVar20;

-  longlong lVar21;

+  longlong lVar1;

+  short *psVar2;

   

-  do {

-    lVar2 = *(longlong *)(unaff_RBP + 0x140);

-    lVar9 = *(longlong *)(unaff_RBP + 0x148);

-    lVar21 = lVar2 * 0x30 + param_4;

-    if ((int)param_2 < 0) {

-      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14049bb87;

-      MiReleaseInPageRefs(lVar21);

-      unaff_RBX[1] = (longlong)unaff_RBX;

-      *unaff_RBX = (longlong)unaff_RBX;

-      return 0;

+  if (param_1 != 0) {

+    lVar1 = *(longlong *)(*(longlong *)(param_1 + 0x138) + 0x28);

+    if ((lVar1 != 0) && ((*(uint *)(lVar1 + 0x18c) & 0x20000) == 0)) {

+      PnpConcatenateUnicodeStrings(param_2,lVar1 + 0x28);

+      return;

     }

-    puVar20 = (undefined8 *)(*(ulonglong *)(lVar21 + 8) | 0x8000000000000000);

-    uVar19 = 0;

-    lVar10 = lVar9 + 0x110;

-    if (*(longlong *)(lVar9 + 0x100) != 0) {

-      lVar10 = *(longlong *)(lVar9 + 0x100);

+    IoAddTriageDumpDataBlock(param_1,*(undefined2 *)(param_1 + 2));

+    lVar1 = *(longlong *)(param_1 + 8);

+    if (lVar1 != 0) {

+      IoAddTriageDumpDataBlock(lVar1,(int)*(short *)(lVar1 + 2));

+      psVar2 = (short *)(*(longlong *)(param_1 + 8) + 0x38);

+      if (*psVar2 != 0) {

+        IoAddTriageDumpDataBlock(psVar2,2);

+        IoAddTriageDumpDataBlock

+                  (*(undefined8 *)(*(longlong *)(param_1 + 8) + 0x40),

+                   *(undefined2 *)(*(longlong *)(param_1 + 8) + 0x38));

+      }

     }

-    plVar16 = (longlong *)(lVar10 + 0x30);

-    uVar11 = (ulonglong)*(uint *)(lVar10 + 0x28) + 0xfff +

-             (ulonglong)(*(int *)(lVar10 + 0x2c) + *(int *)(lVar10 + 0x20) & 0xfff) >> 0xc;

-    puVar17 = (undefined8 *)(*(ulonglong *)(param_4 + 8 + *plVar16 * 0x30) | 0x8000000000000000);

-    uVar18 = in_R11D;

-    if (((puVar20 < puVar17) ||

-        (uVar6 = (longlong)puVar20 - (longlong)puVar17 >> 3, uVar11 <= uVar6)) ||

-       (lVar14 = plVar16[uVar6] * 0x30,

-       puVar20 != (undefined8 *)(*(ulonglong *)(lVar14 + -0x21fffffffff8) | 0x8000000000000000))) {

-      for (; plVar16 <= (longlong *)(lVar10 + 0x28 + uVar11 * 8); plVar16 = plVar16 + 1) {

-        lVar14 = *plVar16 * 0x30;

-        if ((undefined8 *)(*(ulonglong *)(lVar14 + -0x21fffffffff8) | 0x8000000000000000) == puVar20

-           ) goto LAB_0;

+    lVar1 = *(longlong *)(*(longlong *)(param_1 + 0x138) + 0x28);

+    if (lVar1 != 0) {

+      psVar2 = (short *)(lVar1 + 0x28);

+      IoAddTriageDumpDataBlock(lVar1,0x388);

+      if (*psVar2 != 0) {

+        IoAddTriageDumpDataBlock(psVar2,2);

+        IoAddTriageDumpDataBlock(*(undefined8 *)(lVar1 + 0x30),*psVar2);

       }

-      *(undefined4 *)(lVar9 + 0xb4) = in_R11D;

+      psVar2 = (short *)(*(longlong *)(*(longlong *)(param_1 + 0x138) + 0x28) + 0x38);

+      if (*psVar2 != 0) {

+        IoAddTriageDumpDataBlock(psVar2,2);

+        lVar1 = *(longlong *)(*(longlong *)(param_1 + 0x138) + 0x28);

+        IoAddTriageDumpDataBlock(*(undefined8 *)(lVar1 + 0x40),*(undefined2 *)(lVar1 + 0x38));

+      }

+      lVar1 = *(longlong *)(*(longlong *)(*(longlong *)(param_1 + 0x138) + 0x28) + 0x10);

+      if ((lVar1 != 0) && (psVar2 = (short *)(lVar1 + 0x38), *psVar2 != 0)) {

+        IoAddTriageDumpDataBlock(psVar2,2);

+        lVar1 = *(longlong *)(*(longlong *)(*(longlong *)(param_1 + 0x138) + 0x28) + 0x10);

+        IoAddTriageDumpDataBlock(*(undefined8 *)(lVar1 + 0x40),*(undefined2 *)(lVar1 + 0x38));

+        FUN_14049bdc4();

+        return;

+      }

     }

-    else {

-LAB_0:

-      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14049baf7;

-      uVar7 = MI_READ_PTE_LOCK_FREE(puVar20);

-      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14049bb02;

-      uVar8 = MiUpdateTransitionPteFrame(uVar7,lVar2);

-      *(undefined8 *)((longlong)register0x00000020 + 0x50) = uVar8;

-      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14049bb15;

-      iVar4 = MiPteInShadowRange(puVar20);

-      iVar5 = 0;

-      uVar7 = uVar8;

-      if (iVar4 != 0) {

-        *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14049bb6b;

-        iVar5 = MiSanitizeShadowPxe();

-        uVar7 = *(undefined8 *)((longlong)register0x00000020 + 0x50);

-      }

-      *puVar20 = uVar7;

-      if (iVar5 != 0) {

-        *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14049bb7d;

-        MiWritePteShadow(puVar20,uVar7);

-      }

-      *(undefined8 *)(unaff_RBP + 0xa8) = uVar8;

-      *(ulonglong *)(lVar21 + 0x10) =

-           (*(ulonglong *)(lVar14 + -0x21fffffffff0) ^ *(ulonglong *)(lVar21 + 0x10)) &

-           0xfffffffffffffc1f ^ *(ulonglong *)(lVar14 + -0x21fffffffff0);

-      lVar21 = lVar14 + -0x220000000000;

-      uVar19 = in_R11D;

-    }

-    in_R11D = uVar18;

-    *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14049bb48;

-    MiReleaseInPageRefs(lVar21);

-    plVar16 = *(longlong **)(lVar9 + 0x10);

-    while( true ) {

-      do {

-        plVar15 = plVar16;

-        param_4 = -0x220000000000;

-        if (plVar15 == (longlong *)(lVar9 + 0x10)) {

-          return uVar19;

-        }

-        plVar16 = (longlong *)*plVar15;

-      } while (((*(uint *)(unaff_RBP + 0xc0) & 0x40) != 0) &&

-              ((undefined8 *)

-               (*(ulonglong *)(plVar15[0x26] * 0x30 + -0x21fffffffff8) | 0x8000000000000000) !=

-               puVar20));

-      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14049b9a2;

-      MiReleaseInPageRefs();

-      param_2 = *plVar15;

-      puVar12 = (undefined1 *)register0x00000020;

-      if ((*(longlong **)(param_2 + 8) != plVar15) ||

-         (plVar1 = (longlong *)plVar15[1], (longlong *)*plVar1 != plVar15)) break;

-      *plVar1 = param_2;

-      *(longlong **)(param_2 + 8) = plVar1;

-      plVar15[1] = (longlong)plVar15;

-      *plVar15 = (longlong)plVar15;

-    }

-    do {

-      do {

-        lVar9 = 3;

-        pcVar3 = (code *)swi(0x29);

-        (*pcVar3)();

-        puVar13 = puVar12 + 8;

-        register0x00000020 = (BADSPACEBASE *)(puVar12 + 8);

-        unaff_RBX = (longlong *)(lVar9 + 0x10);

-        lVar2 = *unaff_RBX;

-        puVar12 = puVar12 + 8;

-      } while (*(longlong **)(lVar2 + 8) != unaff_RBX);

-      plVar16 = *(longlong **)(lVar9 + 0x18);

-      puVar12 = puVar13;

-    } while ((longlong *)*plVar16 != unaff_RBX);

-    *plVar16 = lVar2;

-    *(longlong **)(lVar2 + 8) = plVar16;

-  } while( true );

+  }

+                    /* WARNING: Subroutine does not return */

+  KeBugCheckEx(0xca,2,param_1,0,0);

 }
```

## `PopBatteryAdd`  (modified)

```diff
--- PopBatteryAdd
+++ PopBatteryAdd
@@ -1,29 +1,39 @@
 

-undefined8 PopBatteryAdd(void)

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+

+void PopBatteryAdd(longlong param_1)

 

 {

-  undefined8 in_stack_00000030;

-  undefined8 in_stack_00000038;

-  undefined8 in_stack_00000040;

-  undefined8 in_stack_00000048;

+  int iVar1;

+  undefined1 auStack_48 [32];

+  undefined4 local_28;

+  undefined4 local_20;

+  undefined8 local_18;

+  ulonglong local_10;

   

-  KeClearEvent();

-  in_stack_00000038 = 0;

-  in_stack_00000030 = 3;

-  in_stack_00000040 = 0;

-  in_stack_00000048 = 0;

-  PopPowerAggregatorSetCurrentState(0,&stack0x00000030);

-  PopReleaseRwLock(&PopPowerAggregatorLock);

-  PopSleepstudyStartNextSession(1);

-  if (PopIdleScanInterval != 0) {

-    KeClearEvent(&PopIdleLoopExecuted);

-    PopGetPolicyWorker(0x80);

-    PopCheckForWork();

-    KeWaitForMutexObject(&PopIdleLoopExecuted,0,0,0,0);

+  local_10 = __security_cookie ^ (ulonglong)auStack_48;

+  KeInitializeEvent(param_1 + 0x50,1);

+  DAT_0 = DAT_0 + 1;

+  if (DAT_0 == 1) {

+    PopAcquirePolicyLock();

+    PopChangeCapability(&DAT_1,1);

+    PopReleasePolicyLock();

+    PopCadNotifyBatteryPresence();

   }

-  PopSuspendResumePdc(2);

-  PopSuspendResumePdc(3);

-  PopAcquireRwLockExclusive(&PopPowerAggregatorLock);

-  return 0;

+  *(undefined4 *)(param_1 + 0xf8) = 0;

+  local_18 = 0;

+  local_20 = 8;

+  local_28 = 0;

+  PopPrepareIoctl(*(undefined8 *)(param_1 + 0x38),0x294068,0,&local_18);

+  iVar1 = IoSynchronousCallDriver(*(undefined8 *)(param_1 + 0x30),*(undefined8 *)(param_1 + 0x38));

+  if (-1 < iVar1) {

+    *(undefined4 *)(param_1 + 0xf8) = local_18._4_4_;

+  }

+  PopAcquireRwLockExclusive(&PopCB);

+  DAT_2 = 1;

+  PopBatteryWaitTag(param_1);

+  PopBatteryQueueWork(8);

+  PopReleaseRwLock(&PopCB);

+  return;

 }
```

## `PopBatteryInit`  (modified)

```diff
--- PopBatteryInit
+++ PopBatteryInit
@@ -1,106 +1,89 @@
 

 /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

 

-void PopBatteryInit(undefined8 param_1,undefined8 param_2)

+void PopBatteryInit(void)

 

 {

-  undefined8 *in_RAX;

   undefined4 *puVar1;

-  undefined4 in_ECX;

-  ulonglong uVar2;

-  bool in_SF;

-  undefined4 in_XMM0_Dc;

-  undefined4 in_XMM0_Dd;

+  longlong lVar2;

   

-  uRam0000000140f0b744 = (undefined4)((ulonglong)param_1 >> 0x20);

-  DAT_0 = (undefined4)param_1;

-  if (in_SF) {

-    *(char *)((longlong)in_RAX + -0x77) = *(char *)((longlong)in_RAX + -0x77) + (char)in_ECX;

-    DAT_0 = 0;

-    uRam0000000140f0b744 = 0;

-    in_XMM0_Dc = 0;

-    in_XMM0_Dd = 0;

-    _DAT_1 = &DAT_140f0b550;

-    DAT_2 = &DAT_2;

-    in_RAX = &DAT_3;

-    DAT_4 = in_ECX;

-  }

-  _DAT_5 = PopBatteryWorker;

-  puVar1 = &DAT_6;

-  _DAT_7 = (int)param_2;

-  uVar2 = (ulonglong)(_DAT_7 + 4);

-  _DAT_8 = CONCAT31((int3)((uint)DAT_140f0b750 >> 8),1);

-  PopWeakChargerNotificationUsbStack = in_ECX;

-  _PopWeakChargerLock = param_2;

-  _DAT_9 = param_2;

-  PopWeakChargerCompositeState = _DAT_7;

-  PopWeakChargerNotificationBatteryMiniport = in_ECX;

-  _PopBatteryWorkItem = param_2;

-  _DAT_10 = param_2;

-  _PopCB = param_2;

-  _DAT_11 = param_2;

-  DAT_12 = (char)param_2;

-  DAT_13 = _DAT_140f0b644;

-  _DAT_14 = param_2;

-  DAT_15 = param_2;

-  _DAT_16 = param_2;

-  uRam0000000140f0b738 = in_XMM0_Dc;

-  uRam0000000140f0b73c = in_XMM0_Dd;

-  DAT_17 = in_XMM0_Dc;

-  DAT_18 = in_XMM0_Dd;

-  uRam0000000140f0b754 = uRam0000000140f0b744;

-  uRam0000000140f0b758 = in_XMM0_Dc;

-  uRam0000000140f0b75c = in_XMM0_Dd;

-  DAT_19 = in_ECX;

-  DAT_20 = in_ECX;

-  DAT_21 = in_ECX;

-  DAT_22 = in_ECX;

-  DAT_23 = in_ECX;

-  DAT_24 = in_ECX;

-  DAT_25 = in_ECX;

-  DAT_3 = in_RAX;

-  _DAT_26 = in_RAX;

+  _DAT_0 = &DAT_140f0b540;

+  DAT_1 = &DAT_1;

+  DAT_2 = 0xffffffff;

+  _DAT_3 = &DAT_140f0b550;

+  DAT_4 = &DAT_4;

+  _DAT_5 = &DAT_140f0b7c0;

+  DAT_6 = &DAT_6;

+  _DAT_7 = PopBatteryWorker;

+  puVar1 = &DAT_8;

+  uRam0000000140f0b738 = 0;

+  DAT_9 = 0xffffffff;

+  _DAT_10 = 0;

+  DAT_11 = 0xffffffff;

+  DAT_12 = 0xffffffff;

+  DAT_13 = 0xffffffff;

+  DAT_14 = 0xffffffff;

+  DAT_15 = 0xffffffff;

+  DAT_16 = 0xffffffff;

+  PopWeakChargerNotificationBatteryMiniport = 0xffffffff;

+  PopWeakChargerNotificationUsbStack = 0xffffffff;

+  lVar2 = 4;

+  _DAT_17 = 0;

+  _PopCB = 0;

+  _DAT_18 = 0;

+  _DAT_19 = 0;

+  _PopWeakChargerLock = 0;

+  _DAT_20 = 0;

+  uRam0000000140f0b758 = 0;

+  _DAT_21 = 0;

+  DAT_22 = 0;

+  _DAT_23 = 1;

+  DAT_24 = 0;

+  DAT_25 = 0;

+  PopWeakChargerCompositeState = 0;

+  _DAT_26 = 0;

+  _PopBatteryWorkItem = 0;

   do {

     *puVar1 = 2;

     puVar1 = puVar1 + 8;

-    uVar2 = uVar2 - 1;

-  } while (uVar2 != 0);

+    lVar2 = lVar2 + -1;

+  } while (lVar2 != 0);

   _DAT_27 = &DAT_140f0b648;

   _DAT_28 = &DAT_28;

   _DAT_29 = PopBatteryWakeDpc;

   _DAT_30 = &DAT_140f0b5c8;

   _DAT_31 = &DAT_31;

   _DAT_32 = PopBootBatteryStatusWorker;

   _DAT_33 = 1;

   DAT_34 = 6;

-  DAT_35 = param_2;

-  _DAT_36 = 0x113;

-  _DAT_37 = param_2;

-  _DAT_38 = param_2;

-  _DAT_39 = param_2;

-  DAT_40_1 = (undefined7)((ulonglong)param_2 >> 8);

-  _DAT_40 = CONCAT71(DAT_40_1,8);

-  _DAT_41 = param_2;

-  _DAT_42 = _DAT_140f0b644;

-  _DAT_43 = (short)param_2;

-  _DAT_44 = param_2;

-  _DAT_45 = param_2;

-  DAT_46 = (char)param_2;

-  _DAT_47 = _DAT_140f0b644;

-  PopEstimateSpoiledUntilTime = _DAT_48 + 300000000;

-  _DAT_49 = PopRefreshEstimateAfterSpoilingDpc;

-  _DAT_50 = &DAT_140f08748;

-  _DAT_51 = &DAT_51;

+  _DAT_35 = 0;

+  DAT_36 = 0;

+  _DAT_37 = 0x113;

+  _DAT_38 = 0;

+  _DAT_39 = 0;

+  _DAT_40 = 0;

+  _DAT_41 = 8;

+  _DAT_42 = 0;

+  _DAT_43 = 0;

+  _DAT_44 = 0;

+  _DAT_45 = 0;

+  _DAT_46 = 0;

+  DAT_47 = 0;

+  _DAT_48 = 0;

+  PopEstimateSpoiledUntilTime = _DAT_49 + 300000000;

+  _DAT_50 = PopRefreshEstimateAfterSpoilingDpc;

+  _DAT_51 = &DAT_140f08748;

+  _DAT_52 = &DAT_52;

   _PopPostSpoilingRefresh = 0x113;

-  _DAT_52 = param_2;

-  _DAT_53 = param_2;

-  _DAT_54 = param_2;

-  _DAT_55 = CONCAT71(DAT_140f0b5c0_1,8);

-  _DAT_56 = param_2;

-  _DAT_57 = _DAT_140f0b644;

-  _DAT_58 = (short)param_2;

-  DAT_59 = 1;

+  _DAT_53 = 0;

+  _DAT_54 = 0;

+  _DAT_55 = 0;

+  _DAT_56 = 8;

+  _DAT_57 = 0;

+  _DAT_58 = 0;

+  _DAT_59 = 0;

+  DAT_60 = 1;

   PopBatteryInitiateIgnoreStatusDuringBoot = 1;

   return;

 }
```

## `PpmCheckComputeHeteroResponseEx`  (modified)

```diff
--- PpmCheckComputeHeteroResponseEx
+++ PpmCheckComputeHeteroResponseEx
@@ -1,10 +1,400 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void PpmCheckComputeHeteroResponseEx(void)

+undefined8 PpmCheckComputeHeteroResponseEx(void)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  longlong lVar1;

+  undefined *puVar2;

+  uint *_Base;

+  longlong lVar3;

+  void *_Base_00;

+  char cVar4;

+  byte bVar5;

+  int iVar6;

+  uint uVar7;

+  longlong lVar8;

+  uint uVar9;

+  uint uVar10;

+  longlong lVar11;

+  ulonglong uVar12;

+  undefined2 uVar13;

+  uint *puVar14;

+  uint uVar15;

+  uint uVar16;

+  undefined2 uVar17;

+  longlong lVar18;

+  longlong *plVar19;

+  longlong lVar20;

+  ulonglong uVar21;

+  ulonglong unaff_R13;

+  ulonglong uVar22;

+  ushort uVar23;

+  ulonglong uVar24;

+  bool bVar25;

+  undefined4 extraout_XMM0_Da;

+  undefined4 local_res8 [2];

+  uint local_res10;

+  uint local_res18;

+  uint local_res20;

+  undefined4 in_stack_ffffffffffffff28;

+  undefined2 uVar26;

+  ulonglong local_b8;

+  longlong local_b0;

+  uint local_98;

+  ulonglong local_78;

+  uint local_70;

+  longlong local_68;

+  undefined8 uStack_60;

+  ulonglong local_58;

+  longlong local_50;

+  

+  _Base_00 = DAT_0;

+  lVar3 = DAT_1;

+  _Base = PpmHeteroPerfCheckUtilities;

+  puVar2 = PpmCurrentProfile;

+  local_58 = 0;

+  lVar11 = (longlong)DAT_2 * 0x1e8;

+  local_68 = 0;

+  uStack_60 = 0;

+  lVar1 = lVar11 + 0x28;

+  if (PpmHeteroPolicy == 4) {

+    cVar4 = PpmHeteroIsMultiClassParkingEnabled();

+    uVar24 = 0;

+    if (cVar4 != '\0') {

+      PpmCheckComputeMultiClassHeteroResponseEx();

+      return 1;

+    }

+    local_98 = 0;

+    if (PpmParkNumNodes != 0) {

+      do {

+        uVar21 = 0;

+        lVar18 = uVar24 * 0x510 + PpmParkNodes;

+        local_50 = lVar18;

+        if (((PpmHeteroHgsParkingEnabled == '\0') ||

+            (*(short *)(*(longlong *)(lVar18 + 0x508) + 0x280) != 0)) || (PpmHeteroPolicy != 0)) {

+          uVar12 = 0;

+          uVar22 = unaff_R13 & 0xffffffffffffff00;

+          local_b8 = 0;

+          local_70 = 0;

+          local_78 = 0;

+          uVar23 = *(ushort *)(*(longlong *)(lVar18 + 0x508) + 0x288);

+          uVar24 = (ulonglong)uVar23;

+          local_res18 = (uint)uVar23;

+          local_res8[0] = 0;

+          local_res20 = (uint)uVar22;

+          local_res10 = 0;

+          iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline();

+          if ((iVar6 != 0) && (PpmIsUnparkOnUnimportantUtilitySupported != '\0')) {

+            if (((PpmUnparkOnUnimportantUtilityVariant - 2U & 0xfffffff9) != 0) ||

+               (uVar7 = 1, PpmUnparkOnUnimportantUtilityVariant == 8)) {

+              uVar7 = 0;

+            }

+            local_res10 = (uint)*(byte *)(lVar18 + 0x4b0);

+            uVar24 = (ulonglong)local_res18;

+            local_res20 = 0;

+            if (*(byte *)(lVar18 + 0x4b0) != 0) {

+              local_res20 = uVar7;

+            }

+            uVar22 = (ulonglong)local_res20;

+          }

+          cVar4 = (char)uVar22;

+          local_68 = lVar18 + 0x30;

+          local_58 = local_58 & 0xffffffffffff0000;

+          uStack_60 = *(undefined8 *)(lVar18 + 0x38);

+          iVar6 = KeEnumerateNextProcessor(local_res8,&local_68);

+          uVar22 = uVar21;

+          if (iVar6 == 0) {

+            do {

+              lVar8 = KeGetPrcb(local_res8[0]);

+              lVar20 = lVar8 + 0x89b0;

+              iVar6 = *(int *)(lVar8 + 0x89d8);

+              if (PpmCheckCurrentPipelineId != 5) {

+                iVar6 = iVar6 - *(int *)(lVar8 + 0x89e0);

+              }

+              uVar7 = PpmHeteroUtilityToNormalizedUtility(lVar20,iVar6);

+              _Base[uVar12] = uVar7;

+              uVar7 = PpmHeteroUtilityToNormalizedUtility

+                                (extraout_XMM0_Da,*(undefined4 *)(lVar20 + 0x34));

+              *(uint *)((longlong)_Base_00 + uVar12 * 4) = uVar7;

+              local_b8 = uVar22 + uVar7;

+              uVar21 = uVar21 + _Base[uVar12];

+              uVar12 = (ulonglong)((int)uVar12 + 1);

+              iVar6 = KeEnumerateNextProcessor(local_res8,&local_68);

+              uVar22 = local_b8;

+            } while (iVar6 == 0);

+            cVar4 = (char)local_res20;

+            local_78 = uVar21;

+          }

+          qsort(_Base,uVar12,4,PpmUtilityComparer);

+          qsort(_Base_00,uVar12,4,PpmUtilityComparer);

+          uVar26 = (undefined2)((uint)in_stack_ffffffffffffff28 >> 0x10);

+          uVar23 = *(ushort *)(lVar18 + 10);

+          uVar21 = (ulonglong)uVar23;

+          lVar20 = 0;

+          local_b0 = 0;

+          if (uVar23 != 0) {

+            plVar19 = (longlong *)(*(longlong *)(lVar18 + 0x468) + uVar21 * 8);

+            uVar12 = (ulonglong)uVar23;

+            local_b0 = lVar20;

+            do {

+              lVar20 = lVar20 + local_78 * *plVar19;

+              uVar7 = (int)uVar21 - 1;

+              uVar21 = (ulonglong)uVar7;

+              *(longlong *)(lVar3 + uVar21 * 8) = lVar20;

+              lVar8 = *plVar19;

+              plVar19 = plVar19 + -1;

+              local_b0 = local_b0 + uVar12 * lVar8;

+              uVar12 = uVar12 - 1;

+            } while (uVar7 != 0);

+          }

+          if ((int)uVar24 != 0) {

+            uVar24 = (ulonglong)local_res18;

+            puVar14 = _Base;

+            do {

+              local_b8 = local_b8 -

+                         *(uint *)(((longlong)_Base_00 - (longlong)_Base) + (longlong)puVar14);

+              iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline

+                                ();

+              uVar26 = (undefined2)((uint)in_stack_ffffffffffffff28 >> 0x10);

+              if (iVar6 != 0) {

+                local_78 = local_78 - *puVar14;

+              }

+              puVar14 = puVar14 + 1;

+              uVar24 = uVar24 - 1;

+            } while (uVar24 != 0);

+            uVar24 = (ulonglong)local_res18;

+          }

+          uVar23 = *(ushort *)(*(longlong *)(lVar18 + 0x508) + 0x280);

+          if (PpmHeteroHgsParkingEnabled != '\0') {

+            uVar23 = *(ushort *)(lVar18 + 10);

+          }

+          local_res8[0] = CONCAT22(local_res8[0]._2_2_,uVar23);

+          iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline();

+          if (iVar6 != 0) {

+            uVar21 = local_78;

+            if (local_78 == 0) {

+              uVar21 = 1;

+            }

+            local_70 = (uint)((local_b8 * 100) / uVar21);

+            if (100 < local_70) {

+              local_70 = 100;

+            }

+          }

+          if (local_res18 < uVar23) {

+            do {

+              uVar21 = 0x3f;

+              if ((uint)uVar24 < 0x3f) {

+                uVar21 = uVar24;

+              }

+              uVar26 = 0;

+              iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

+                                (local_b0,_Base[uVar24],*(undefined8 *)(lVar3 + uVar24 * 8),

+                                 puVar2[uVar21 + 0x133 + lVar1],0);

+              if (iVar6 == 0) break;

+              uVar26 = 0;

+              iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold(local_b0,local_b8,0);

+              if (iVar6 == 0) break;

+              lVar18 = uVar24 * 4;

+              uVar7 = (uint)uVar24 + 1;

+              uVar24 = (ulonglong)uVar7;

+              local_b8 = local_b8 - *(uint *)((longlong)_Base_00 + lVar18);

+            } while (uVar7 < uVar23);

+            cVar4 = (char)local_res20;

+            lVar18 = local_50;

+            uVar23 = (ushort)local_res8[0];

+          }

+          uVar15 = 0;

+          iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline();

+          uVar7 = local_res18;

+          if (((iVar6 == 0) || (PpmIsUnparkOnUnimportantUtilitySupported == '\0')) ||

+             ((cVar4 != '\0' || (uVar16 = (uint)uVar24, uVar16 != local_res18)))) {

+LAB_3:

+            unaff_R13 = (ulonglong)uVar7;

+            if ((uint)uVar24 <= uVar7) goto LAB_4;

+            uVar7 = 2;

+          }

+          else {

+            if (((uVar16 < uVar23) && (local_70 <= PpmHeteroImportantUtilityLowDominanceCutoff)) &&

+               (999 < local_78)) {

+              uVar21 = 0x3f;

+              if (uVar16 < 0x3f) {

+                uVar21 = uVar24;

+              }

+              uVar9 = (uint)(byte)puVar2[uVar21 + 0x133 + lVar1];

+              if ((PpmUnparkOnUnimportantUtilityVariant == 1) ||

+                 (PpmUnparkOnUnimportantUtilityVariant == 2)) {

+                uVar9 = uVar9 * 0x46;

+              }

+              else if ((PpmUnparkOnUnimportantUtilityVariant == 5) ||

+                      (PpmUnparkOnUnimportantUtilityVariant == 6)) {

+                uVar9 = uVar9 * 0x1e;

+              }

+              else {

+                uVar9 = uVar9 * 0x32;

+              }

+              uVar26 = 0;

+              iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

+                                (local_b0,_Base[uVar24],*(undefined8 *)(lVar3 + uVar24 * 8),

+                                 puVar2[uVar21 + 0x133 + lVar1],0);

+              if (iVar6 != 0) {

+                uVar26 = 0;

+                iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

+                                  (local_b0,local_b8,0,(ulonglong)uVar9 / 100,0);

+                if (iVar6 != 0) {

+                  local_res10 = local_res10 + 1;

+                  uVar24 = (ulonglong)(uVar16 + 1);

+                  *(char *)(lVar18 + 0x4b1) = *(char *)(lVar18 + 0x4b1) + '\x01';

+                  goto LAB_3;

+                }

+              }

+            }

+LAB_4:

+            unaff_R13 = (ulonglong)uVar7;

+            uVar7 = (uint)uVar24;

+            uVar21 = uVar24;

+            do {

+              do {

+                while( true ) {

+                  uVar24 = uVar21;

+                  if (uVar7 == 0) goto LAB_5;

+                  uVar7 = (uint)uVar24 - 1;

+                  uVar21 = (ulonglong)uVar7;

+                  unaff_R13 = local_b8 + *(uint *)((longlong)_Base_00 + uVar21 * 4);

+                  uVar16 = 0x3f;

+                  if (uVar7 < 0x3f) {

+                    uVar16 = uVar7;

+                  }

+                  iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline

+                                    ();

+                  uVar9 = local_res10;

+                  bVar5 = puVar2[(ulonglong)uVar16 + 0xb3 + lVar1];

+                  local_b8 = unaff_R13;

+                  if (iVar6 == 0) break;

+                  uVar10 = (uint)bVar5;

+                  uVar16 = (uint)bVar5;

+                  if ((local_res10 != 0) &&

+                     (uVar16 = uVar10, PpmIsUnparkOnUnimportantUtilitySupported != '\0')) {

+                    if ((PpmUnparkOnUnimportantUtilityVariant == 1) ||

+                       (PpmUnparkOnUnimportantUtilityVariant == 2)) {

+                      uVar10 = uVar10 * 0x46;

+                    }

+                    else if ((PpmUnparkOnUnimportantUtilityVariant == 5) ||

+                            (PpmUnparkOnUnimportantUtilityVariant == 6)) {

+                      uVar10 = uVar10 * 0x1e;

+                    }

+                    else {

+                      uVar10 = uVar10 * 0x32;

+                    }

+                    uVar16 = uVar10 / 100;

+                  }

+                  uVar26 = 0;

+                  iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

+                                    (local_b0,_Base[uVar21],*(undefined8 *)(lVar3 + uVar21 * 8),

+                                     bVar5,0);

+                  if (iVar6 != 0) {

+                    uVar26 = 0;

+                    iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

+                                      (local_b0,unaff_R13,0,uVar16,0);

+                    if (iVar6 != 0) goto LAB_5;

+                  }

+                  if ((uVar9 != 0) && (PpmIsUnparkOnUnimportantUtilitySupported != '\0')) {

+                    local_res10 = uVar9 - 1;

+                  }

+                }

+                uVar26 = 0;

+                iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

+                                  (local_b0,_Base[uVar21],*(undefined8 *)(lVar3 + uVar21 * 8),bVar5,

+                                   0);

+              } while (iVar6 == 0);

+              uVar26 = 0;

+              iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold(local_b0,unaff_R13,0);

+            } while (iVar6 == 0);

+LAB_5:

+            uVar7 = (uint)((uint)uVar24 < local_res18);

+          }

+          if ((int)*(char *)(lVar18 + 0x4a4) == uVar7) {

+            bVar5 = *(char *)(lVar18 + 0x4a2) + 1;

+            *(byte *)(lVar18 + 0x4a2) = bVar5;

+          }

+          else {

+            *(char *)(lVar18 + 0x4a4) = (char)uVar7;

+            bVar5 = 1;

+            *(undefined1 *)(lVar18 + 0x4a2) = 1;

+            uVar15 = 4;

+            iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline()

+            ;

+            if ((((iVar6 != 0) && (uVar7 != 2)) && (*(char *)(lVar18 + 0x4b1) != '\0')) &&

+               (PpmIsUnparkOnUnimportantUtilitySupported != '\0')) {

+              *(undefined1 *)(lVar18 + 0x4b1) = 0;

+              uVar15 = 0x804;

+            }

+          }

+          uVar17 = (undefined2)uVar24;

+          if (PpmCheckCurrentPipelineId == 5) {

+            *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286) = uVar17;

+            uVar16 = uVar15 | 0x10;

+LAB_6:

+            uVar13 = (undefined2)local_res10;

+          }

+          else {

+            uVar16 = uVar15;

+            if (uVar7 != 2) {

+              if ((uVar7 == 1) && ((byte)puVar2[lVar11 + 0xd9] <= bVar5)) {

+                uVar16 = uVar15 | 0x40;

+                *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286) = uVar17;

+                iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline

+                                  ();

+                if ((iVar6 != 0) && (*(char *)(lVar18 + 0x4b0) != '\0')) {

+                  uVar13 = (undefined2)local_res10;

+                  if (PpmIsUnparkOnUnimportantUtilitySupported != '\0') {

+                    *(char *)(lVar18 + 0x4b0) = (char)local_res10;

+                    uVar16 = uVar15 | 0x440;

+                  }

+                  goto LAB_7;

+                }

+              }

+              goto LAB_6;

+            }

+            if (bVar5 < (byte)puVar2[lVar11 + 0xda]) goto LAB_6;

+            uVar16 = uVar15 | 0x20;

+            *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286) = uVar17;

+            iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline()

+            ;

+            if ((iVar6 == 0) || (*(char *)(lVar18 + 0x4b1) == '\0')) goto LAB_6;

+            uVar13 = (undefined2)local_res10;

+            if (PpmIsUnparkOnUnimportantUtilitySupported != '\0') {

+              *(char *)(lVar18 + 0x4b0) = *(char *)(lVar18 + 0x4b0) + '\x01';

+              uVar16 = uVar15 | 0x220;

+              *(undefined1 *)(lVar18 + 0x4b1) = 0;

+            }

+          }

+LAB_7:

+          bVar25 = PpmHeteroHgsParkingEnabled != '\0';

+          *(byte *)(lVar18 + 0x4a0) = *(byte *)(lVar18 + 0x4a0) & 0xfd | 4;

+          if (bVar25) {

+            uVar16 = uVar16 | 0x80;

+            *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x288) =

+                 *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286);

+            *(undefined2 *)(lVar18 + 0x4f0) = *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286)

+            ;

+          }

+          iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline();

+          if (iVar6 == 0) {

+            in_stack_ffffffffffffff28 = CONCAT22(uVar26,uVar17);

+            PpmEventTraceHeteroResponseEx();

+          }

+          else {

+            in_stack_ffffffffffffff28 = CONCAT22(uVar26,uVar17);

+            PpmEventTraceHeteroResponseExV1

+                      (lVar18,_Base,lVar3,local_b0,in_stack_ffffffffffffff28,uVar16 | 1,local_70,

+                       uVar13);

+          }

+        }

+        local_98 = local_98 + 1;

+        uVar24 = (ulonglong)local_98;

+      } while (local_98 < PpmParkNumNodes);

+    }

+  }

+  PpmParkCalculateUnparkCount();

+  return 1;

 }
```

## `PpmCheckComputeHeteroResponseEx`  (modified)

```diff
--- PpmCheckComputeHeteroResponseEx
+++ Feature_UnparkPCoresOnUnimportantUtility__private_GetVariant
@@ -1,400 +1,14 @@
 

-undefined8 PpmCheckComputeHeteroResponseEx(void)

+uint Feature_UnparkPCoresOnUnimportantUtility__private_GetVariant(void)

 

 {

-  longlong lVar1;

-  undefined *puVar2;

-  uint *_Base;

-  longlong lVar3;

-  void *_Base_00;

-  char cVar4;

-  byte bVar5;

-  int iVar6;

-  uint uVar7;

-  longlong lVar8;

-  uint uVar9;

-  uint uVar10;

-  longlong lVar11;

-  ulonglong uVar12;

-  undefined2 uVar13;

-  uint *puVar14;

-  uint uVar15;

-  uint uVar16;

-  undefined2 uVar17;

-  longlong lVar18;

-  longlong *plVar19;

-  longlong lVar20;

-  ulonglong uVar21;

-  ulonglong unaff_R13;

-  ulonglong uVar22;

-  ushort uVar23;

-  ulonglong uVar24;

-  bool bVar25;

-  undefined4 extraout_XMM0_Da;

-  undefined4 local_res8 [2];

-  uint local_res10;

-  uint local_res18;

-  uint local_res20;

-  undefined4 in_stack_ffffffffffffff28;

-  undefined2 uVar26;

-  ulonglong local_b8;

-  longlong local_b0;

-  uint local_98;

-  ulonglong local_78;

-  uint local_70;

-  longlong local_68;

-  undefined8 uStack_60;

-  ulonglong local_58;

-  longlong local_50;

+  ulonglong uVar1;

   

-  _Base_00 = DAT_0;

-  lVar3 = DAT_1;

-  _Base = PpmHeteroPerfCheckUtilities;

-  puVar2 = PpmCurrentProfile;

-  local_58 = 0;

-  lVar11 = (longlong)DAT_2 * 0x1e8;

-  local_68 = 0;

-  uStack_60 = 0;

-  lVar1 = lVar11 + 0x28;

-  if (PpmHeteroPolicy == 4) {

-    cVar4 = PpmHeteroIsMultiClassParkingEnabled();

-    uVar24 = 0;

-    if (cVar4 != '\0') {

-      PpmCheckComputeMultiClassHeteroResponseEx();

-      return 1;

-    }

-    local_98 = 0;

-    if (PpmParkNumNodes != 0) {

-      do {

-        uVar21 = 0;

-        lVar18 = uVar24 * 0x510 + PpmParkNodes;

-        local_50 = lVar18;

-        if (((PpmHeteroHgsParkingEnabled == '\0') ||

-            (*(short *)(*(longlong *)(lVar18 + 0x508) + 0x280) != 0)) || (PpmHeteroPolicy != 0)) {

-          uVar12 = 0;

-          uVar22 = unaff_R13 & 0xffffffffffffff00;

-          local_b8 = 0;

-          local_70 = 0;

-          local_78 = 0;

-          uVar23 = *(ushort *)(*(longlong *)(lVar18 + 0x508) + 0x288);

-          uVar24 = (ulonglong)uVar23;

-          local_res18 = (uint)uVar23;

-          local_res8[0] = 0;

-          local_res20 = (uint)uVar22;

-          local_res10 = 0;

-          iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline();

-          if ((iVar6 != 0) && (PpmIsUnparkOnUnimportantUtilitySupported != '\0')) {

-            if (((PpmUnparkOnUnimportantUtilityVariant - 2U & 0xfffffff9) != 0) ||

-               (uVar7 = 1, PpmUnparkOnUnimportantUtilityVariant == 8)) {

-              uVar7 = 0;

-            }

-            local_res10 = (uint)*(byte *)(lVar18 + 0x4b0);

-            uVar24 = (ulonglong)local_res18;

-            local_res20 = 0;

-            if (*(byte *)(lVar18 + 0x4b0) != 0) {

-              local_res20 = uVar7;

-            }

-            uVar22 = (ulonglong)local_res20;

-          }

-          cVar4 = (char)uVar22;

-          local_68 = lVar18 + 0x30;

-          local_58 = local_58 & 0xffffffffffff0000;

-          uStack_60 = *(undefined8 *)(lVar18 + 0x38);

-          iVar6 = KeEnumerateNextProcessor(local_res8,&local_68);

-          uVar22 = uVar21;

-          if (iVar6 == 0) {

-            do {

-              lVar8 = KeGetPrcb(local_res8[0]);

-              lVar20 = lVar8 + 0x89b0;

-              iVar6 = *(int *)(lVar8 + 0x89d8);

-              if (PpmCheckCurrentPipelineId != 5) {

-                iVar6 = iVar6 - *(int *)(lVar8 + 0x89e0);

-              }

-              uVar7 = PpmHeteroUtilityToNormalizedUtility(lVar20,iVar6);

-              _Base[uVar12] = uVar7;

-              uVar7 = PpmHeteroUtilityToNormalizedUtility

-                                (extraout_XMM0_Da,*(undefined4 *)(lVar20 + 0x34));

-              *(uint *)((longlong)_Base_00 + uVar12 * 4) = uVar7;

-              local_b8 = uVar22 + uVar7;

-              uVar21 = uVar21 + _Base[uVar12];

-              uVar12 = (ulonglong)((int)uVar12 + 1);

-              iVar6 = KeEnumerateNextProcessor(local_res8,&local_68);

-              uVar22 = local_b8;

-            } while (iVar6 == 0);

-            cVar4 = (char)local_res20;

-            local_78 = uVar21;

-          }

-          qsort(_Base,uVar12,4,PpmUtilityComparer);

-          qsort(_Base_00,uVar12,4,PpmUtilityComparer);

-          uVar26 = (undefined2)((uint)in_stack_ffffffffffffff28 >> 0x10);

-          uVar23 = *(ushort *)(lVar18 + 10);

-          uVar21 = (ulonglong)uVar23;

-          lVar20 = 0;

-          local_b0 = 0;

-          if (uVar23 != 0) {

-            plVar19 = (longlong *)(*(longlong *)(lVar18 + 0x468) + uVar21 * 8);

-            uVar12 = (ulonglong)uVar23;

-            local_b0 = lVar20;

-            do {

-              lVar20 = lVar20 + local_78 * *plVar19;

-              uVar7 = (int)uVar21 - 1;

-              uVar21 = (ulonglong)uVar7;

-              *(longlong *)(lVar3 + uVar21 * 8) = lVar20;

-              lVar8 = *plVar19;

-              plVar19 = plVar19 + -1;

-              local_b0 = local_b0 + uVar12 * lVar8;

-              uVar12 = uVar12 - 1;

-            } while (uVar7 != 0);

-          }

-          if ((int)uVar24 != 0) {

-            uVar24 = (ulonglong)local_res18;

-            puVar14 = _Base;

-            do {

-              local_b8 = local_b8 -

-                         *(uint *)(((longlong)_Base_00 - (longlong)_Base) + (longlong)puVar14);

-              iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline

-                                ();

-              uVar26 = (undefined2)((uint)in_stack_ffffffffffffff28 >> 0x10);

-              if (iVar6 != 0) {

-                local_78 = local_78 - *puVar14;

-              }

-              puVar14 = puVar14 + 1;

-              uVar24 = uVar24 - 1;

-            } while (uVar24 != 0);

-            uVar24 = (ulonglong)local_res18;

-          }

-          uVar23 = *(ushort *)(*(longlong *)(lVar18 + 0x508) + 0x280);

-          if (PpmHeteroHgsParkingEnabled != '\0') {

-            uVar23 = *(ushort *)(lVar18 + 10);

-          }

-          local_res8[0] = CONCAT22(local_res8[0]._2_2_,uVar23);

-          iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline();

-          if (iVar6 != 0) {

-            uVar21 = local_78;

-            if (local_78 == 0) {

-              uVar21 = 1;

-            }

-            local_70 = (uint)((local_b8 * 100) / uVar21);

-            if (100 < local_70) {

-              local_70 = 100;

-            }

-          }

-          if (local_res18 < uVar23) {

-            do {

-              uVar21 = 0x3f;

-              if ((uint)uVar24 < 0x3f) {

-                uVar21 = uVar24;

-              }

-              uVar26 = 0;

-              iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

-                                (local_b0,_Base[uVar24],*(undefined8 *)(lVar3 + uVar24 * 8),

-                                 puVar2[uVar21 + 0x133 + lVar1],0);

-              if (iVar6 == 0) break;

-              uVar26 = 0;

-              iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold(local_b0,local_b8,0);

-              if (iVar6 == 0) break;

-              lVar18 = uVar24 * 4;

-              uVar7 = (uint)uVar24 + 1;

-              uVar24 = (ulonglong)uVar7;

-              local_b8 = local_b8 - *(uint *)((longlong)_Base_00 + lVar18);

-            } while (uVar7 < uVar23);

-            cVar4 = (char)local_res20;

-            lVar18 = local_50;

-            uVar23 = (ushort)local_res8[0];

-          }

-          uVar15 = 0;

-          iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline();

-          uVar7 = local_res18;

-          if (((iVar6 == 0) || (PpmIsUnparkOnUnimportantUtilitySupported == '\0')) ||

-             ((cVar4 != '\0' || (uVar16 = (uint)uVar24, uVar16 != local_res18)))) {

-LAB_3:

-            unaff_R13 = (ulonglong)uVar7;

-            if ((uint)uVar24 <= uVar7) goto LAB_4;

-            uVar7 = 2;

-          }

-          else {

-            if (((uVar16 < uVar23) && (local_70 <= PpmHeteroImportantUtilityLowDominanceCutoff)) &&

-               (999 < local_78)) {

-              uVar21 = 0x3f;

-              if (uVar16 < 0x3f) {

-                uVar21 = uVar24;

-              }

-              uVar9 = (uint)(byte)puVar2[uVar21 + 0x133 + lVar1];

-              if ((PpmUnparkOnUnimportantUtilityVariant == 1) ||

-                 (PpmUnparkOnUnimportantUtilityVariant == 2)) {

-                uVar9 = uVar9 * 0x46;

-              }

-              else if ((PpmUnparkOnUnimportantUtilityVariant == 5) ||

-                      (PpmUnparkOnUnimportantUtilityVariant == 6)) {

-                uVar9 = uVar9 * 0x1e;

-              }

-              else {

-                uVar9 = uVar9 * 0x32;

-              }

-              uVar26 = 0;

-              iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

-                                (local_b0,_Base[uVar24],*(undefined8 *)(lVar3 + uVar24 * 8),

-                                 puVar2[uVar21 + 0x133 + lVar1],0);

-              if (iVar6 != 0) {

-                uVar26 = 0;

-                iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

-                                  (local_b0,local_b8,0,(ulonglong)uVar9 / 100,0);

-                if (iVar6 != 0) {

-                  local_res10 = local_res10 + 1;

-                  uVar24 = (ulonglong)(uVar16 + 1);

-                  *(char *)(lVar18 + 0x4b1) = *(char *)(lVar18 + 0x4b1) + '\x01';

-                  goto LAB_3;

-                }

-              }

-            }

-LAB_4:

-            unaff_R13 = (ulonglong)uVar7;

-            uVar7 = (uint)uVar24;

-            uVar21 = uVar24;

-            do {

-              do {

-                while( true ) {

-                  uVar24 = uVar21;

-                  if (uVar7 == 0) goto LAB_5;

-                  uVar7 = (uint)uVar24 - 1;

-                  uVar21 = (ulonglong)uVar7;

-                  unaff_R13 = local_b8 + *(uint *)((longlong)_Base_00 + uVar21 * 4);

-                  uVar16 = 0x3f;

-                  if (uVar7 < 0x3f) {

-                    uVar16 = uVar7;

-                  }

-                  iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline

-                                    ();

-                  uVar9 = local_res10;

-                  bVar5 = puVar2[(ulonglong)uVar16 + 0xb3 + lVar1];

-                  local_b8 = unaff_R13;

-                  if (iVar6 == 0) break;

-                  uVar10 = (uint)bVar5;

-                  uVar16 = (uint)bVar5;

-                  if ((local_res10 != 0) &&

-                     (uVar16 = uVar10, PpmIsUnparkOnUnimportantUtilitySupported != '\0')) {

-                    if ((PpmUnparkOnUnimportantUtilityVariant == 1) ||

-                       (PpmUnparkOnUnimportantUtilityVariant == 2)) {

-                      uVar10 = uVar10 * 0x46;

-                    }

-                    else if ((PpmUnparkOnUnimportantUtilityVariant == 5) ||

-                            (PpmUnparkOnUnimportantUtilityVariant == 6)) {

-                      uVar10 = uVar10 * 0x1e;

-                    }

-                    else {

-                      uVar10 = uVar10 * 0x32;

-                    }

-                    uVar16 = uVar10 / 100;

-                  }

-                  uVar26 = 0;

-                  iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

-                                    (local_b0,_Base[uVar21],*(undefined8 *)(lVar3 + uVar21 * 8),

-                                     bVar5,0);

-                  if (iVar6 != 0) {

-                    uVar26 = 0;

-                    iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

-                                      (local_b0,unaff_R13,0,uVar16,0);

-                    if (iVar6 != 0) goto LAB_5;

-                  }

-                  if ((uVar9 != 0) && (PpmIsUnparkOnUnimportantUtilitySupported != '\0')) {

-                    local_res10 = uVar9 - 1;

-                  }

-                }

-                uVar26 = 0;

-                iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold

-                                  (local_b0,_Base[uVar21],*(undefined8 *)(lVar3 + uVar21 * 8),bVar5,

-                                   0);

-              } while (iVar6 == 0);

-              uVar26 = 0;

-              iVar6 = PpmHeteroUtilityGreaterThanOrEqualThreshold(local_b0,unaff_R13,0);

-            } while (iVar6 == 0);

-LAB_5:

-            uVar7 = (uint)((uint)uVar24 < local_res18);

-          }

-          if ((int)*(char *)(lVar18 + 0x4a4) == uVar7) {

-            bVar5 = *(char *)(lVar18 + 0x4a2) + 1;

-            *(byte *)(lVar18 + 0x4a2) = bVar5;

-          }

-          else {

-            *(char *)(lVar18 + 0x4a4) = (char)uVar7;

-            bVar5 = 1;

-            *(undefined1 *)(lVar18 + 0x4a2) = 1;

-            uVar15 = 4;

-            iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline()

-            ;

-            if ((((iVar6 != 0) && (uVar7 != 2)) && (*(char *)(lVar18 + 0x4b1) != '\0')) &&

-               (PpmIsUnparkOnUnimportantUtilitySupported != '\0')) {

-              *(undefined1 *)(lVar18 + 0x4b1) = 0;

-              uVar15 = 0x804;

-            }

-          }

-          uVar17 = (undefined2)uVar24;

-          if (PpmCheckCurrentPipelineId == 5) {

-            *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286) = uVar17;

-            uVar16 = uVar15 | 0x10;

-LAB_6:

-            uVar13 = (undefined2)local_res10;

-          }

-          else {

-            uVar16 = uVar15;

-            if (uVar7 != 2) {

-              if ((uVar7 == 1) && ((byte)puVar2[lVar11 + 0xd9] <= bVar5)) {

-                uVar16 = uVar15 | 0x40;

-                *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286) = uVar17;

-                iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline

-                                  ();

-                if ((iVar6 != 0) && (*(char *)(lVar18 + 0x4b0) != '\0')) {

-                  uVar13 = (undefined2)local_res10;

-                  if (PpmIsUnparkOnUnimportantUtilitySupported != '\0') {

-                    *(char *)(lVar18 + 0x4b0) = (char)local_res10;

-                    uVar16 = uVar15 | 0x440;

-                  }

-                  goto LAB_7;

-                }

-              }

-              goto LAB_6;

-            }

-            if (bVar5 < (byte)puVar2[lVar11 + 0xda]) goto LAB_6;

-            uVar16 = uVar15 | 0x20;

-            *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286) = uVar17;

-            iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline()

-            ;

-            if ((iVar6 == 0) || (*(char *)(lVar18 + 0x4b1) == '\0')) goto LAB_6;

-            uVar13 = (undefined2)local_res10;

-            if (PpmIsUnparkOnUnimportantUtilitySupported != '\0') {

-              *(char *)(lVar18 + 0x4b0) = *(char *)(lVar18 + 0x4b0) + '\x01';

-              uVar16 = uVar15 | 0x220;

-              *(undefined1 *)(lVar18 + 0x4b1) = 0;

-            }

-          }

-LAB_7:

-          bVar25 = PpmHeteroHgsParkingEnabled != '\0';

-          *(byte *)(lVar18 + 0x4a0) = *(byte *)(lVar18 + 0x4a0) & 0xfd | 4;

-          if (bVar25) {

-            uVar16 = uVar16 | 0x80;

-            *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x288) =

-                 *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286);

-            *(undefined2 *)(lVar18 + 0x4f0) = *(undefined2 *)(*(longlong *)(lVar18 + 0x508) + 0x286)

-            ;

-          }

-          iVar6 = Feature_UnparkPCoresOnUnimportantUtility__private_IsEnabledDeviceUsageNoInline();

-          if (iVar6 == 0) {

-            in_stack_ffffffffffffff28 = CONCAT22(uVar26,uVar17);

-            PpmEventTraceHeteroResponseEx();

-          }

-          else {

-            in_stack_ffffffffffffff28 = CONCAT22(uVar26,uVar17);

-            PpmEventTraceHeteroResponseExV1

-                      (lVar18,_Base,lVar3,local_b0,in_stack_ffffffffffffff28,uVar16 | 1,local_70,

-                       uVar13);

-          }

-        }

-        local_98 = local_98 + 1;

-        uVar24 = (ulonglong)local_98;

-      } while (local_98 < PpmParkNumNodes);

-    }

-  }

-  PpmParkCalculateUnparkCount();

-  return 1;

+  uVar1 = wil_details_FeatureStateCache_GetCachedVariantState

+                    (&Feature_UnparkPCoresOnUnimportantUtility__private_featureState,

+                     &Feature_UnparkPCoresOnUnimportantUtility__private_descriptor);

+  wil_details_FeatureReporting_ReportVariantUsageToService

+            (&Feature_UnparkPCoresOnUnimportantUtility__private_descriptor,uVar1);

+  return (uint)(uVar1 >> 0xc) & 0x3f;

 }
```

## `ApiSetpGetContractKeyInfo`  (modified)

```diff
--- ApiSetpGetContractKeyInfo
+++ ApiSetpGetContractKeyInfo
@@ -1,280 +1,200 @@
 

-int ApiSetpGetContractKeyInfo

-              (longlong param_1,ulonglong param_2,undefined8 param_3,ulonglong param_4)

+ulonglong ApiSetpGetContractKeyInfo

+                    (ulonglong *param_1,ulonglong param_2,char param_3,undefined8 *param_4)

 

 {

-  byte *pbVar1;

-  uint uVar2;

-  char cVar3;

-  byte in_AL;

-  ushort uVar4;

-  undefined8 uVar5;

-  byte bVar6;

-  longlong lVar7;

+  byte bVar1;

+  char cVar2;

+  bool bVar3;

+  bool bVar4;

+  bool bVar5;

+  bool bVar6;

+  ulonglong uVar7;

   longlong lVar8;

-  longlong lVar9;

-  ulonglong uVar10;

-  byte bVar11;

-  ulonglong uVar12;

-  undefined7 uVar13;

-  int unaff_EBX;

-  longlong unaff_RBP;

-  longlong unaff_RSI;

-  longlong unaff_RDI;

-  undefined2 *puVar14;

-  undefined2 uVar15;

-  ulonglong unaff_R12;

-  longlong unaff_R13;

-  uint *puVar17;

-  longlong unaff_R14;

-  ushort uVar18;

-  int unaff_R15D;

-  bool bVar19;

-  undefined4 extraout_XMM0_Da;

-  undefined4 extraout_XMM0_Da_00;

-  undefined4 extraout_XMM0_Da_01;

-  undefined4 extraout_XMM0_Da_02;

-  uint uVar16;

+  ulonglong uVar9;

+  uint uVar10;

+  char *pcVar11;

+  ushort uVar12;

+  short sVar13;

+  longlong lVar14;

+  uint uVar15;

+  byte *pbVar16;

+  ulonglong uVar17;

+  bool bVar18;

   

-code_r0x000140660a7b:

-  uVar15 = *(undefined2 *)((param_1 - param_4) + 4 + unaff_RDI);

-  *(undefined2 *)(unaff_RBP + 0x58) = *(undefined2 *)((param_1 - param_4) + 6 + unaff_RDI);

-  *(undefined2 *)(unaff_RBP + 0x50) = uVar15;

+  uVar9 = param_2 & 0xffff;

+  uVar7 = 0;

+  *param_4 = 0;

+  param_4[1] = 0;

+  param_4[2] = 0;

+  param_4[3] = 0;

+  param_4[4] = 0;

+  if ((uint)uVar9 < 5) goto LAB_0;

+  bVar3 = false;

+  if (param_3 == '\0') {

+    lVar14 = -1;

+    do {

+      lVar8 = lVar14;

+      lVar14 = lVar8 + 1;

+    } while (*(char *)((longlong)param_1 + lVar14) != '\0');

+    uVar7 = lVar8 - 3;

+    if (uVar7 < 0xfffc) {

+      uVar7 = (ulonglong)(uint)*param_1 & 0xffdfdfdf;

+      if (uVar7 != 0x2d495041) {

+        bVar18 = uVar7 == 0x2d545845;

+        goto LAB_1;

+      }

+      goto LAB_2;

+    }

+  }

+  else {

+    uVar12 = (short)param_2 * 2;

+    uVar7 = (ulonglong)uVar12;

+    if (7 < uVar12) {

+      uVar7 = *param_1 & 0xffffffdfffdfffdf;

+      if (uVar7 != 0x2d004900500041) {

+        bVar18 = uVar7 == 0x2d005400580045;

+LAB_1:

+        bVar3 = false;

+        if (!bVar18) goto LAB_3;

+      }

+LAB_2:

+      bVar3 = true;

+    }

+  }

+LAB_3:

+  if (bVar3) {

+    bVar3 = false;

+    *param_4 = param_1;

+    *(short *)(param_4 + 1) = (short)param_2;

+    uVar7 = uVar9 * 2;

+    if (param_3 == '\0') {

+      uVar7 = uVar9;

+    }

+    *(char *)((longlong)param_4 + 10) = param_3;

+    pbVar16 = (byte *)(uVar7 + (longlong)param_1);

+    bVar4 = false;

+    bVar18 = false;

+    uVar17 = 0;

+    bVar6 = true;

+    bVar5 = true;

+    param_2 = param_2 & 0xffff;

+    lVar14 = (ulonglong)(param_3 != '\0') + 1;

+    uVar15 = 1;

+    do {

+      uVar7 = 0xffff;

+      pbVar16 = pbVar16 + -lVar14;

+      uVar12 = (short)param_2 - 1;

+      param_2 = (ulonglong)uVar12;

+      bVar1 = *pbVar16;

+      sVar13 = (short)uVar9;

+      if (bVar1 == 0x2d) {

+        if (bVar18) {

+          if (!bVar4) {

+            bVar18 = false;

+            *(short *)(param_4 + 3) = (short)uVar17;

+            uVar17 = 0;

+            *(undefined4 *)((longlong)param_4 + 0xc) = 3;

+            *(ushort *)((longlong)param_4 + 0x12) = uVar12;

+            bVar4 = true;

+            bVar5 = true;

+            goto LAB_4;

+          }

+        }

+        else {

+          *(undefined4 *)((longlong)param_4 + 0xc) = 1;

+          *(short *)((longlong)param_4 + 0x12) = sVar13;

+          param_2 = uVar9;

+        }

+LAB_5:

+        uVar12 = (ushort)param_2;

+        *(ushort *)((longlong)param_4 + 0x14) = uVar12;

+        if ((((7 < uVar12) &&

+             (pcVar11 = (char *)((-(ulonglong)(param_3 != '\0') & 4) + 4 + (longlong)param_1),

+             (*pcVar11 + 0xb3U & 0xdf) == 0)) &&

+            (pcVar11 = pcVar11 + lVar14, (*pcVar11 + 0xadU & 0xdf) == 0)) &&

+           (pcVar11[lVar14] == '-')) {

+          *(undefined4 *)((longlong)param_4 + 0x1a) = 0x60004;

+        }

+        uVar9 = (ulonglong)*(ushort *)((longlong)param_4 + 0x14);

+        uVar7 = uVar9 * 2;

+        if (param_3 == '\0') {

+          uVar7 = uVar9;

+        }

+        pcVar11 = (char *)(uVar7 + (longlong)param_1);

+        uVar15 = 0;

+        bVar3 = false;

+        goto joined_r0x000140661291;

+      }

+      if (bVar1 == 0x7e) {

+        if (!bVar4) {

+          *(short *)((longlong)param_4 + 0x12) = sVar13;

+          *(undefined4 *)((longlong)param_4 + 0xc) = 2;

+          *(ushort *)((longlong)param_4 + 0x16) = (sVar13 - uVar12) + -1;

+          goto LAB_5;

+        }

+        break;

+      }

+      if (bVar1 == 0x2e) {

+        if ((bVar4) || (bVar3)) break;

+        bVar3 = true;

+        bVar5 = true;

+        bVar18 = false;

+        uVar9 = param_2;

+      }

+      else {

+        if ((byte)(bVar1 - 0x30) < 10) {

+          if (bVar5) {

+            uVar17 = (ulonglong)(bVar1 - 0x30);

+            bVar18 = true;

+            uVar15 = 10;

+          }

+          else if (bVar18) {

+            uVar7 = uVar17 & 0xffff;

+            uVar10 = (bVar1 - 0x30) * uVar15 + (int)uVar7;

+            if (0xffff < uVar10) break;

+            uVar17 = (ulonglong)(uVar10 & 0xffff);

+            uVar15 = uVar15 * 10;

+            if (0xffff < uVar15) {

+              uVar15 = 0x10000;

+            }

+          }

+        }

+        else {

+          bVar18 = false;

+        }

+        bVar5 = false;

+      }

+LAB_4:

+      uVar7 = 0xffff;

+    } while (1 < uVar12);

+  }

 LAB_0:

-  if ((in_AL & 1) != 0) goto LAB_1;

-  do {

-    lVar9 = *(longlong *)(unaff_RSI + 0x20);

-    lVar8 = *(longlong *)(unaff_RBP + -0x40);

-    if (unaff_R15D == 2) {

-      lVar7 = ((ulonglong)*(byte *)(lVar9 + 0x40) * (param_2 & 0xffff) +

-              (ulonglong)*(uint *)(lVar9 + 0x38)) - (ulonglong)*(ushort *)(lVar9 + 0x12);

-      *(short *)(lVar7 + 4 + lVar9) = (short)unaff_R12;

-      *(undefined4 *)(lVar7 + 8 + lVar9) = *(undefined4 *)(lVar8 + 0xc + unaff_R13 * 4);

-    }

-    else {

-      lVar7 = ((ulonglong)*(byte *)(lVar9 + 0x4c) * (param_2 & 0xffff) +

-              (ulonglong)*(uint *)(lVar9 + 0x44)) - (ulonglong)*(ushort *)(lVar9 + 0x12);

-      *(short *)(lVar7 + 4 + lVar9) = (short)unaff_R12;

-      if ((*(byte *)(lVar8 + 0x11 + unaff_R13 * 4) & 4) != 0) {

-        pbVar1 = (byte *)(lVar7 + 10 + lVar9);

-        *pbVar1 = *pbVar1 | 4;

-      }

-    }

-    *(undefined8 *)(unaff_RBP + -0x50) = 0;

-    if ((*(char *)(unaff_RSI + 0x10) != '\0') && (unaff_R15D == 3)) {

-      uVar5 = ApiSetpSearchForApiSetA

-                        (*(undefined8 *)(unaff_RSI + 0x28),*(undefined8 *)(unaff_RBP + -0x30),

-                         *(undefined2 *)(unaff_RBP + -0x1e));

-      *(undefined8 *)(unaff_RBP + -0x50) = uVar5;

-    }

-    uVar18 = 0;

-    if (*(short *)(lVar8 + 10 + unaff_R13 * 4) != 0) {

-      do {

-        uVar16 = *(uint *)(lVar8 + 4 + unaff_R13 * 4);

-        lVar9 = *(longlong *)(unaff_RSI + 0x20);

-        *(undefined8 *)(unaff_RBP + -0x30) = 0;

-        *(undefined8 *)(unaff_RBP + -0x28) = 0;

-        puVar17 = (uint *)((ulonglong)uVar16 + (ulonglong)uVar18 * 0x10 + unaff_R14);

-        *(undefined8 *)(unaff_RBP + -0x10) = 0;

-        *(undefined8 *)(unaff_RBP + -0x20) = 0;

-        *(undefined8 *)(unaff_RBP + -0x18) = 0;

-        uVar2 = puVar17[2];

-        uVar16 = *puVar17;

-        *(short *)(unaff_RBP + -0x28) = (short)uVar2;

-        *(ulonglong *)(unaff_RBP + -0x30) = (ulonglong)uVar16 + unaff_R14;

-        *(short *)(unaff_RBP + -0x1e) = (short)uVar2;

-        *(undefined1 *)(unaff_RBP + -0x26) = 1;

-        uVar4 = ApiSetpSearchForSectionIndex_V7(lVar9,lVar9 + 0x5c,unaff_RBP + -0x30);

-        *(ushort *)(unaff_RBP + 0x40) = uVar4;

-        if (uVar4 == 0xffff) {

-          unaff_EBX = ApiSetSchemaExpander_InsertHostEntry

-                                (extraout_XMM0_Da_02,unaff_RBP + -0x30,unaff_RBP + 0x40);

-          if (unaff_EBX < 0) {

-            return unaff_EBX;

-          }

-          lVar9 = *(longlong *)(unaff_RSI + 0x20);

-          uVar4 = *(ushort *)(unaff_RBP + 0x40);

-        }

-        bVar19 = *(short *)((longlong)puVar17 + 10) == 0;

-        if (bVar19) {

-          uVar15 = 0xffff;

-        }

-        else {

-          uVar16 = *(uint *)(unaff_RSI + 0x9c) >> 4;

-          uVar15 = (undefined2)uVar16;

-          *(uint *)(unaff_RSI + 0x9c) = *(uint *)(unaff_RSI + 0x9c) + 0x10;

-          puVar14 = (undefined2 *)

-                    ((((ulonglong)*(ushort *)(lVar9 + 0x72) * (ulonglong)(uVar16 & 0xffff) +

-                      (ulonglong)*(uint *)(lVar9 + 0x68)) - (ulonglong)*(ushort *)(lVar9 + 0x12)) +

-                    lVar9);

-          lVar8 = ((ulonglong)*(byte *)(lVar9 + 100) * (ulonglong)*(ushort *)(unaff_RBP + 0x50) +

-                  (ulonglong)*(uint *)(lVar9 + 0x5c)) - (ulonglong)*(ushort *)(lVar9 + 0x12);

-          *(undefined4 *)(puVar14 + 4) = *(undefined4 *)(lVar8 + 4 + lVar9);

-          puVar14[7] = *(undefined2 *)(lVar8 + 8 + lVar9);

-          lVar9 = *(longlong *)(unaff_RSI + 0x20);

-          lVar9 = (ulonglong)*(uint *)(lVar9 + 0x5c) +

-                  lVar9 + ((ulonglong)*(byte *)(lVar9 + 100) * (ulonglong)uVar4 -

-                          (ulonglong)*(ushort *)(lVar9 + 0x12));

-          *(undefined4 *)(puVar14 + 2) = *(undefined4 *)(lVar9 + 4);

-          puVar14[6] = *(undefined2 *)(lVar9 + 8);

-          *puVar14 = *(undefined2 *)(unaff_RBP + 0x58);

-        }

-        lVar9 = *(longlong *)(unaff_RSI + 0x20);

-        lVar9 = (ulonglong)*(uint *)(lVar9 + 0x2c) +

-                lVar9 + ((ulonglong)*(byte *)(lVar9 + 0x34) * (unaff_R12 & 0xffff) -

-                        (ulonglong)*(ushort *)(lVar9 + 0x12));

-        *(byte *)(lVar9 + 10) = *(byte *)(lVar9 + 10) | 2;

-        *(ushort *)(lVar9 + 4) = uVar4;

-        if (!bVar19) {

-          *(short *)(lVar9 + 8) = *(short *)(lVar9 + 8) + 1;

-          *(undefined2 *)(lVar9 + 6) = uVar15;

-        }

-        if (*(longlong *)(unaff_RBP + -0x50) != 0) {

-          lVar9 = *(longlong *)(unaff_RSI + 0x20);

-          lVar7 = (ulonglong)*(uint *)(*(longlong *)(unaff_RBP + -0x50) + 0x10) +

-                  *(longlong *)(unaff_RSI + 0x28);

-          lVar8 = (ulonglong)*(uint *)(lVar9 + 0x5c) +

-                  lVar9 + ((ulonglong)*(byte *)(lVar9 + 100) * (ulonglong)uVar4 -

-                          (ulonglong)*(ushort *)(lVar9 + 0x12));

-          *(int *)(lVar7 + 0xc) = *(int *)(lVar9 + 0x24) + *(int *)(lVar8 + 4);

-          *(uint *)(lVar7 + 0x10) = (uint)*(ushort *)(lVar8 + 8) * 2;

-        }

-        unaff_R13 = *(longlong *)(unaff_RBP + -0x38);

-        uVar18 = uVar18 + 1;

-        lVar8 = *(longlong *)(unaff_RBP + -0x40);

-      } while (uVar18 < *(ushort *)(lVar8 + 10 + unaff_R13 * 4));

-    }

-LAB_1:

-    uVar18 = *(ushort *)(unaff_R14 + 0x12);

-    uVar16 = *(int *)(unaff_RBP + -0x48) + 1;

-    uVar10 = (ulonglong)uVar16;

-    *(uint *)(unaff_RBP + -0x48) = uVar16;

-    if (uVar18 <= uVar16) {

-      return unaff_EBX;

-    }

-    *(undefined8 *)(unaff_RBP + -0x10) = 0;

-    *(undefined8 *)(unaff_RBP + -0x30) = 0;

-    *(undefined8 *)(unaff_RBP + -0x28) = 0;

-    unaff_R13 = uVar10 * 5;

-    lVar9 = (ulonglong)*(uint *)(unaff_R14 + 0xc) + unaff_R14;

-    *(longlong *)(unaff_RBP + -0x38) = unaff_R13;

-    *(longlong *)(unaff_RBP + -0x40) = lVar9;

-    *(undefined8 *)(unaff_RBP + -0x20) = 0;

-    *(undefined8 *)(unaff_RBP + -0x18) = 0;

-    uVar12 = (ulonglong)*(ushort *)(lVar9 + 8 + uVar10 * 0x14);

-    cVar3 = ApiSetpGetContractKeyInfo

-                      ((ulonglong)*(uint *)(lVar9 + uVar10 * 0x14) + unaff_R14,uVar12,0,

-                       unaff_RBP + -0x30);

-    if ((cVar3 == '\0') || (unaff_R15D = *(int *)(unaff_RBP + -0x24), 1 < unaff_R15D - 2U)) {

-      return -0x3fffffcd;

-    }

-    lVar9 = *(longlong *)(unaff_RSI + 0x20);

-    uVar10 = CONCAT71((int7)(uVar12 >> 8),*(byte *)(lVar9 + 2)) & 0xffffffffffffff10;

-    bVar6 = *(byte *)(lVar9 + 2) & 8;

-    uVar13 = (undefined7)(uVar10 >> 8);

-    cVar3 = (char)uVar10;

-    if ((*(byte *)(lVar9 + 0x35) & 4) == 0) {

-      uVar16 = ApiSetpGetSearchKeyHash

-                         (unaff_RBP + -0x30,CONCAT71(uVar13,1),bVar6 != 0,cVar3 != '\0',

-                          *(undefined1 *)(lVar9 + 0x37));

-    }

-    else {

-      bVar6 = ApiSetpGetSearchKeyHash

-                        (unaff_RBP + -0x30,CONCAT71(uVar13,1),bVar6 != 0,cVar3 != '\0',

-                         *(undefined1 *)(lVar9 + 0x37));

-      uVar16 = (uint)bVar6;

-    }

-    *(uint *)(unaff_RBP + 0x50) = uVar16;

-    uVar18 = ApiSetpSearchForSectionIndex_V7(lVar9,lVar9 + 0x2c,unaff_RBP + -0x30,1);

-    unaff_R12 = (ulonglong)uVar18;

-    *(ushort *)(unaff_RBP + 0x40) = uVar18;

-    if (uVar18 == 0xffff) {

-      unaff_EBX = ApiSetSchemaExpander_InsertContractEntry

-                            (extraout_XMM0_Da,unaff_RBP + -0x30,unaff_RBP + 0x40);

-      if (unaff_EBX < 0) {

-        return unaff_EBX;

-      }

-      unaff_R15D = *(int *)(unaff_RBP + -0x24);

-      unaff_R12 = (ulonglong)*(ushort *)(unaff_RBP + 0x40);

-    }

-    else if (*(int *)((ulonglong)*(uint *)(lVar9 + 0x2c) +

-                     lVar9 + (*(byte *)(lVar9 + 0x34) * unaff_R12 -

-                             (ulonglong)*(ushort *)(lVar9 + 0x12))) != *(int *)(unaff_RBP + 0x50)) {

-      return -0x3ffffdd7;

-    }

-    unaff_RDI = *(longlong *)(unaff_RSI + 0x20);

-    *(undefined2 *)(unaff_RBP + 0x50) = 0xffff;

-    *(undefined2 *)(unaff_RBP + 0x58) = 0xffff;

-    bVar6 = *(byte *)(unaff_RDI + 2) & 8;

-    bVar11 = *(byte *)(unaff_RDI + 2) & 0x10;

-    if (unaff_R15D == 2) {

-      if ((*(byte *)(unaff_RDI + 0x41) & 4) == 0) {

-        uVar16 = ApiSetpGetSearchKeyHash

-                           (unaff_RBP + -0x30,0,bVar6 != 0,bVar11 != 0,

-                            *(undefined1 *)(unaff_RDI + 0x43));

-      }

-      else {

-        bVar6 = ApiSetpGetSearchKeyHash

-                          (unaff_RBP + -0x30,0,bVar6 != 0,bVar11 != 0,

-                           *(undefined1 *)(unaff_RDI + 0x43));

-        uVar16 = (uint)bVar6;

-      }

-      *(uint *)(unaff_RBP + -0x50) = uVar16;

-      uVar18 = ApiSetpSearchForSectionIndex_V7(unaff_RDI,unaff_RDI + 0x38,unaff_RBP + -0x30);

-      param_2 = (ulonglong)uVar18;

-      *(ushort *)(unaff_RBP + 0x40) = uVar18;

-      if (uVar18 != 0xffff) {

-        param_4 = (ulonglong)*(ushort *)(unaff_RDI + 0x12);

-        lVar9 = (*(byte *)(unaff_RDI + 0x40) * param_2 + (ulonglong)*(uint *)(unaff_RDI + 0x38)) -

-                param_4;

-        if (*(int *)(lVar9 + unaff_RDI) != *(int *)(unaff_RBP + -0x50)) {

-          return -0x3ffffdd7;

-        }

-        param_1 = (ulonglong)*(byte *)(unaff_RDI + 0x34) *

-                  (ulonglong)*(ushort *)(lVar9 + 4 + unaff_RDI) +

-                  (ulonglong)*(uint *)(unaff_RDI + 0x2c);

-        in_AL = *(byte *)(lVar9 + 6 + unaff_RDI);

-        goto code_r0x000140660a7b;

-      }

-      unaff_EBX = ApiSetSchemaExpander_InsertGroupContractEntry

-                            (extraout_XMM0_Da_00,unaff_RBP + -0x30,unaff_RBP + 0x40);

-    }

-    else {

-      if ((*(byte *)(unaff_RDI + 0x4d) & 4) == 0) {

-        uVar16 = ApiSetpGetSearchKeyHash

-                           (unaff_RBP + -0x30,0,bVar6 != 0,bVar11 != 0,

-                            *(undefined1 *)(unaff_RDI + 0x4f));

-      }

-      else {

-        bVar6 = ApiSetpGetSearchKeyHash

-                          (unaff_RBP + -0x30,0,bVar6 != 0,bVar11 != 0,

-                           *(undefined1 *)(unaff_RDI + 0x4f));

-        uVar16 = (uint)bVar6;

-      }

-      *(uint *)(unaff_RBP + -0x50) = uVar16;

-      uVar18 = ApiSetpSearchForSectionIndex_V7(unaff_RDI,unaff_RDI + 0x44,unaff_RBP + -0x30);

-      param_2 = (ulonglong)uVar18;

-      *(ushort *)(unaff_RBP + 0x40) = uVar18;

-      if (uVar18 != 0xffff) break;

-      unaff_EBX = ApiSetSchemaExpander_InsertSemverContractEntry

-                            (extraout_XMM0_Da_01,unaff_RBP + -0x30,unaff_RBP + 0x40);

-    }

-    if (unaff_EBX < 0) {

-      return unaff_EBX;

-    }

-    unaff_R15D = *(int *)(unaff_RBP + -0x24);

-    param_2 = (ulonglong)*(ushort *)(unaff_RBP + 0x40);

-  } while( true );

-  lVar9 = (*(byte *)(unaff_RDI + 0x4c) * param_2 + (ulonglong)*(uint *)(unaff_RDI + 0x44)) -

-          (ulonglong)*(ushort *)(unaff_RDI + 0x12);

-  if (*(int *)(lVar9 + unaff_RDI) != *(int *)(unaff_RBP + -0x50)) {

-    return -0x3ffffdd7;

-  }

-  lVar8 = ((ulonglong)*(byte *)(unaff_RDI + 0x34) * (ulonglong)*(ushort *)(lVar9 + 4 + unaff_RDI) +

-          (ulonglong)*(uint *)(unaff_RDI + 0x2c)) - (ulonglong)*(ushort *)(unaff_RDI + 0x12);

-  *(undefined2 *)(unaff_RBP + 0x50) = *(undefined2 *)(lVar8 + 4 + unaff_RDI);

-  *(undefined2 *)(unaff_RBP + 0x58) = *(undefined2 *)(lVar8 + 6 + unaff_RDI);

-  in_AL = *(byte *)(lVar9 + 10 + unaff_RDI);

-  goto LAB_0;

+  return uVar7 & 0xffffffffffffff00;

+joined_r0x000140661291:

+  if (uVar12 < 5) {

+LAB_6:

+    return CONCAT71((int7)(uVar9 >> 8),1);

+  }

+  pcVar11 = pcVar11 + -lVar14;

+  sVar13 = (short)param_2;

+  uVar12 = sVar13 - 1;

+  param_2 = (ulonglong)uVar12;

+  cVar2 = *pcVar11;

+  uVar9 = CONCAT71((int7)(uVar9 >> 8),cVar2 - 0x30U);

+  if (9 < (byte)(cVar2 - 0x30U)) {

+    if (((bVar3) && ((cVar2 + 0xb4U & 0xdf) == 0)) &&

+       (sVar13 = sVar13 + -2, pcVar11[-lVar14] == '-')) {

+      *(short *)((longlong)param_4 + 0x1e) = sVar13;

+      *(ushort *)(param_4 + 4) = ((char)uVar15 != '\0') + 1 + sVar13;

+    }

+    goto LAB_6;

+  }

+  bVar18 = !bVar3;

+  bVar3 = bVar6;

+  if ((bVar18) && (cVar2 == '1')) {

+    uVar15 = 1;

+  }

+  goto joined_r0x000140661291;

 }
```

## `AslpFileVerQueryBlock`  (modified)

```diff
--- AslpFileVerQueryBlock
+++ AslpFileVerQueryBlock
@@ -1,75 +1,96 @@
 

-ulonglong AslpFileVerQueryBlock(longlong param_1,undefined8 param_2,undefined8 param_3)

+int AslpFileVerQueryBlock(ushort *param_1,undefined8 param_2,undefined8 *param_3,ulonglong *param_4)

 

 {

-  undefined2 uVar1;

-  uint uVar2;

-  longlong in_RAX;

-  longlong lVar3;

-  ulonglong uVar4;

-  char cVar5;

-  ulonglong uVar6;

-  ulonglong uVar7;

-  undefined4 unaff_ESI;

+  ushort *puVar1;

+  ushort *puVar2;

+  ushort *puVar3;

+  ushort uVar4;

+  int iVar5;

+  int iVar6;

+  wchar_t *_Str1;

+  uint uVar7;

   ulonglong uVar8;

-  undefined4 uVar9;

-  undefined4 extraout_XMM0_Da;

-  undefined8 uStack_28;

-  longlong lStack_20;

-  undefined8 uStack_18;

-  undefined8 uStack_10;

+  undefined8 uVar9;

+  char *pcVar10;

+  ulonglong local_res8;

+  undefined8 local_res20;

   

-  *(undefined4 *)(in_RAX + 0x20) = unaff_ESI;

-  uVar8 = 0;

-  uStack_28 = 0;

-  uStack_18 = 0;

-  uStack_10 = 0;

-  uVar9 = RtlInitUnicodeString(&uStack_18,param_3);

-  uVar1 = uStack_18._2_2_;

-  lVar3 = AslAlloc(uVar9,uStack_18._2_2_);

-  lStack_20 = lVar3;

-  if (lVar3 == 0) {

-    uVar7 = 0xc0000017;

-    uVar9 = AslLogCallPrintf(1,"AslStringUpcaseToMultiByteN",0x41f,"Out of memory");

+  local_res20 = 0;

+  local_res8 = 0;

+  *param_4 = 0;

+  if (param_1[2] == 0) {

+    iVar5 = AslStringDuplicate(&local_res20);

+    if (iVar5 < 0) {

+      AslLogCallPrintf(1,"AslpFileVerQueryBlock",0xb2f,"AslStringDuplicate failed [%x]",iVar5);

+      goto LAB_0;

+    }

+    uVar4 = *param_1;

+    if (uVar4 < 0x8000) {

+      if (7 < uVar4) {

+        puVar2 = (ushort *)((longlong)param_1 + (ulonglong)uVar4);

+        puVar1 = puVar2 + -1;

+        uVar4 = *puVar1;

+        *puVar1 = 0;

+        _Str1 = (wchar_t *)AslpFileStringTokenize(local_res20);

+        puVar3 = puVar2;

+        while (_Str1 != (wchar_t *)0x0) {

+          uVar9 = 8;

+          uVar7 = (int)puVar2 - (int)param_1;

+          if (((uVar7 < 8) || (uVar7 < *param_1)) ||

+             (iVar5 = AslpFileVerBlockGetValueOffset(&local_res8,param_1,uVar7), iVar5 < 0)) {

+LAB_1:

+            iVar5 = -0x3ffffddb;

+            goto LAB_2;

+          }

+          local_res8 = ((ulonglong)param_1[1] + 3 & 0xfffffffffffffffc) + local_res8;

+          if (*param_1 < local_res8) goto LAB_1;

+          puVar3 = (ushort *)((ulonglong)*param_1 + (longlong)param_1);

+          param_1 = (ushort *)((longlong)param_1 + local_res8);

+          if (puVar3 <= param_1) goto LAB_1;

+          while( true ) {

+            if ((*param_1 <= (ushort)uVar9) ||

+               ((ulonglong)((longlong)puVar3 - (longlong)param_1) < (ulonglong)*param_1))

+            goto LAB_1;

+            iVar5 = _wcsicmp(_Str1,(wchar_t *)(param_1 + 3));

+            if (iVar5 == 0) break;

+            param_1 = (ushort *)((longlong)param_1 + ((ulonglong)*param_1 + 3 & 0xfffffffffffffffc))

+            ;

+            if (puVar3 <= param_1) goto LAB_1;

+            uVar9 = 8;

+          }

+          _Str1 = (wchar_t *)AslpFileStringTokenize(0);

+        }

+        iVar5 = 0;

+        iVar6 = Feature_261863737__private_IsEnabledDeviceUsageNoInline();

+        if (iVar6 == 0) {

+          uVar8 = (longlong)puVar3 - (longlong)param_1;

+        }

+        else {

+          uVar8 = (ulonglong)*param_1;

+        }

+        *param_4 = uVar8;

+        *param_3 = param_1;

+LAB_2:

+        *puVar1 = uVar4;

+        goto LAB_0;

+      }

+      pcVar10 = "VersionBlock not long enough";

+      uVar9 = 0xb40;

+    }

+    else {

+      pcVar10 = "VersionBlock is too long";

+      uVar9 = 0xb3b;

+    }

   }

   else {

-    uStack_28 = (ulonglong)CONCAT42(uStack_28._4_4_,uVar1) << 0x10;

-    uVar2 = RtlUpcaseUnicodeString(&uStack_28,&uStack_18,0);

-    lVar3 = lStack_20;

-    uVar7 = (ulonglong)uVar2;

-    if ((int)uVar2 < 0) {

-      uVar9 = AslLogCallPrintf(1,"AslStringUpcaseToMultiByteN",0x428,

-                               "RtlUpcaseUnicodeString failed [%x]",uVar2);

-      lVar3 = lStack_20;

-    }

-    else {

-      uVar7 = uVar8;

-      for (uVar6 = uVar8; uVar6 < (uStack_28 >> 1 & 0x7fff); uVar6 = uVar6 + 1) {

-        uVar1 = *(undefined2 *)(lStack_20 + uVar6 * 2);

-        *(char *)(param_1 + uVar7) = (char)uVar1;

-        uVar4 = uVar7 + 1;

-        if (0x103 < uVar4) {

+    pcVar10 = "Version block invalid";

+    uVar9 = 0xb29;

+  }

+  iVar5 = -0x3ffffff3;

+  AslLogCallPrintf(1,"AslpFileVerQueryBlock",uVar9,pcVar10);

 LAB_0:

-          uVar9 = AslLogCallPrintf(1,"AslStringUpcaseToMultiByteN",0x44e,

-                                   "Failed to convert to ANSI [%x]",0xc0000023);

-          uVar7 = 0xc0000023;

-          goto LAB_1;

-        }

-        cVar5 = (char)((ushort)uVar1 >> 8);

-        if (cVar5 != '\0') {

-          *(char *)(uVar4 + param_1) = cVar5;

-          uVar4 = uVar7 + 2;

-          if (0x103 < uVar4) goto LAB_0;

-        }

-        uVar7 = uVar4;

-      }

-      *(undefined1 *)(param_1 + uVar7) = 0;

-      uVar7 = uVar8;

-      uVar9 = extraout_XMM0_Da;

-    }

-  }

-LAB_1:

-  AslFree(uVar9,lVar3);

-  return uVar7;

+  AslFree();

+  return iVar5;

 }
```

## `PpmParkComputeUnparkMaskEx`  (modified)

```diff
--- PpmParkComputeUnparkMaskEx
+++ PpmParkComputeUnparkMaskEx
@@ -1,336 +1,520 @@
 

-/* WARNING: Instruction at (ram,0x0001405dface) overlaps instruction at (ram,0x0001405dfacc)

-    */

+/* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

 /* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

-/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

 

-undefined8

-PpmParkComputeUnparkMaskEx(longlong param_1,_KAFFINITY_EX *param_2,_KAFFINITY_EX *param_3)

+void PpmParkComputeUnparkMaskEx

+               (longlong param_1,_KAFFINITY_EX *param_2,longlong param_3,undefined8 param_4,

+               uint param_5,uint param_6,_KAFFINITY_EX *param_7,_KAFFINITY_EX *param_8,

+               _KAFFINITY_EX *param_9,ushort *param_10,uint *param_11,ulonglong *param_12,

+               undefined4 param_13,undefined1 param_14,undefined1 param_15,undefined4 param_16)

 

 {

-  byte *pbVar1;

-  _KAFFINITY_EX *p_Var2;

-  byte bVar3;

-  ushort uVar4;

+  ulonglong *puVar1;

+  byte bVar2;

+  longlong lVar3;

+  longlong lVar4;

   ushort uVar5;

-  undefined4 uVar6;

+  short sVar6;

   int iVar7;

-  ulonglong uVar8;

-  longlong lVar9;

-  ulonglong in_RAX;

-  char *pcVar10;

-  ushort uVar11;

-  uint uVar12;

-  uint uVar13;

-  uint uVar14;

-  char *unaff_RBX;

-  ulonglong uVar15;

-  ulonglong unaff_RBP;

-  ulonglong uVar16;

-  uint unaff_ESI;

-  longlong unaff_RDI;

-  uint uVar17;

-  uint unaff_R12D;

-  _KAFFINITY_EX *p_Var18;

-  _KAFFINITY_EX *unaff_R13;

-  uint unaff_R14D;

-  uint uVar19;

-  ushort *puVar20;

-  bool bVar21;

-  undefined2 uVar22;

+  uint uVar8;

+  ulong uVar9;

+  longlong lVar10;

+  ulonglong uVar11;

+  _KAFFINITY_EX *p_Var12;

+  _KAFFINITY_EX *p_Var13;

+  undefined8 uVar14;

+  _KAFFINITY_EX *p_Var15;

+  _KAFFINITY_EX *p_Var16;

+  _KAFFINITY_EX *p_Var17;

+  uint uVar18;

+  bool bVar19;

+  undefined1 auStack_2e8 [32];

+  _KAFFINITY_EX *local_2c8;

+  _KAFFINITY_EX *local_2c0;

+  _KAFFINITY_EX *local_2b8;

+  _KAFFINITY_EX *local_2b0;

+  _KAFFINITY_EX *local_2a8;

+  _KAFFINITY_EX *local_2a0;

+  _KAFFINITY_EX *local_298;

+  _KAFFINITY_EX *local_290;

+  _KAFFINITY_EX *local_288;

+  undefined8 local_280;

+  _KAFFINITY_EX *local_278;

+  char local_268;

+  char local_267;

+  char local_266;

+  char local_265;

+  char local_264;

+  uint local_260 [2];

+  _KAFFINITY_EX *local_258;

+  _KAFFINITY_EX *local_250;

+  _KAFFINITY_EX *local_248;

+  ulonglong local_240;

+  _KAFFINITY_EX *local_238;

+  _KAFFINITY_EX *local_230;

+  undefined *local_228;

+  _KAFFINITY_EX *local_220;

+  _KAFFINITY_EX *local_218;

+  _KAFFINITY_EX *local_210;

+  longlong local_208;

+  longlong local_200;

+  _KAFFINITY_EX *local_1f8;

+  ulong64 local_1f0;

+  undefined2 local_1e8;

+  undefined4 local_1e6;

+  undefined2 local_1e2;

+  uint local_1e0;

+  longlong local_1d8;

+  longlong local_1d0;

+  ushort *local_1c8;

+  _KAFFINITY_EX *local_1c0;

+  undefined8 local_1b8;

+  longlong local_1b0;

+  longlong local_1a8;

+  _KAFFINITY_EX *local_1a0;

+  ulong64 *local_198;

+  longlong local_190;

+  uint *local_188;

+  _KAFFINITY_EX *local_180;

+  _KAFFINITY_EX *local_178;

+  void *local_170;

+  void *local_168;

+  _KAFFINITY_EX *local_160;

+  _KAFFINITY_EX local_158;

+  ulonglong local_48;

   

-  pbVar1 = (byte *)(param_1 + -0x73);

-  bVar3 = *pbVar1;

-  *pbVar1 = *pbVar1 + (byte)param_1;

-  pcVar10 = (char *)(unaff_RBP & 0xffffffff);

-  uVar16 = in_RAX & 0xffffffff;

-  *unaff_RBX = (*unaff_RBX - (char)pcVar10) - CARRY1(bVar3,(byte)param_1);

-  *pcVar10 = *pcVar10 + (char)pcVar10;

-  do {

-    KeAndAffinityEx2(unaff_R13 + 6,param_2,param_3);

-    p_Var2 = unaff_R13 + 6;

-    uVar14 = unaff_R12D;

-    func_0x0001405dfd2c(unaff_RDI,p_Var2,unaff_RDI + 0x240,unaff_R13 + 4,unaff_R12D);

-    uVar22 = (undefined2)(uVar14 >> 0x10);

-    iVar7 = Feature_PpmFixContainmentCandidateListInitialization__private_IsEnabledDeviceUsageNoInline

-                      ();

-    if ((iVar7 != 0) && (*(char *)(uVar16 - 0x7b) != '\0')) {

-      *(undefined4 *)(*(longlong *)(unaff_RDI + 0x500) + 4) = *(undefined4 *)(uVar16 - 0x68);

+  local_48 = __security_cookie ^ (ulonglong)auStack_2e8;

+  local_250 = param_7;

+  local_218 = param_8;

+  local_1c8 = param_10;

+  local_188 = param_11;

+  local_248 = param_2;

+  local_200 = param_1;

+  local_1b8 = param_4;

+  local_1b0 = param_3;

+  memset(&local_158.field3_0x8,0,0x100);

+  lVar10 = PpmParkPerfCheckAffinities;

+  uVar18 = 0;

+  local_240 = (longlong)DAT_0 * 0x1e8;

+  local_1e6 = 0;

+  local_1e2 = 0;

+  local_260[0] = 0;

+  local_265 = PpmCurrentProfile[local_240 + 0x1f0];

+  local_266 = PpmCurrentProfile[local_240 + 0x1f1];

+  local_1e0 = (uint)*(ushort *)(param_1 + 0x4e4);

+  local_190 = *(longlong *)(param_1 + 0x4e8);

+  local_228 = PpmCurrentProfile;

+  local_1a8 = PpmParkPerfCheckAffinities + 0x948;

+  local_158.Count = 1;

+  local_158.Size = 0x20;

+  local_158.Reserved = 0;

+  p_Var17 = (_KAFFINITY_EX *)(PpmParkPerfCheckAffinities + 0xb58);

+  local_1d8 = PpmParkPerfCheckAffinities + 0xa50;

+  p_Var15 = (_KAFFINITY_EX *)(PpmParkPerfCheckAffinities + 0xe70);

+  local_238 = (_KAFFINITY_EX *)(PpmParkPerfCheckAffinities + 0xc60);

+  p_Var16 = (_KAFFINITY_EX *)(PpmParkPerfCheckAffinities + 0x16b0);

+  local_1d0 = PpmParkPerfCheckAffinities + 0xf78;

+  local_1a0 = (_KAFFINITY_EX *)(PpmParkPerfCheckAffinities + 0x1080);

+  local_230 = (_KAFFINITY_EX *)(PpmParkPerfCheckAffinities + 0x1290);

+  local_208 = PpmParkPerfCheckAffinities + 0x1398;

+  local_220 = (_KAFFINITY_EX *)(PpmParkPerfCheckAffinities + 0x14a0);

+  local_258 = (_KAFFINITY_EX *)(PpmParkPerfCheckAffinities + 0x15a8);

+  local_210 = (_KAFFINITY_EX *)(PpmParkPerfCheckAffinities + 0x17b8);

+  local_1c0 = p_Var15;

+  local_180 = p_Var17;

+  local_178 = p_Var16;

+  memset(&local_158.field3_0x8,0,0x100);

+  memset((void *)(lVar10 + 0x950),0,(ulonglong)*(ushort *)(lVar10 + 0x948) << 3);

+  *(undefined2 *)(lVar10 + 0x948) = 1;

+  memset((void *)(lVar10 + 0xa58),0,(ulonglong)*(ushort *)(lVar10 + 0xa50) << 3);

+  *(undefined2 *)(lVar10 + 0xa50) = 1;

+  memset((void *)(lVar10 + 0xb60),0,(ulonglong)p_Var17->Count << 3);

+  p_Var17->Count = 1;

+  local_170 = (void *)(lVar10 + 0xc68);

+  memset(local_170,0,(ulonglong)*(ushort *)(lVar10 + 0xc60) << 3);

+  *(undefined2 *)(lVar10 + 0xc60) = 1;

+  memset((void *)(lVar10 + 0xe78),0,(ulonglong)p_Var15->Count << 3);

+  p_Var15->Count = 1;

+  memset((void *)(lVar10 + 0xf80),0,(ulonglong)*(ushort *)(lVar10 + 0xf78) << 3);

+  *(undefined2 *)(lVar10 + 0xf78) = 1;

+  memset((void *)(lVar10 + 0x1088),0,(ulonglong)*(ushort *)(lVar10 + 0x1080) << 3);

+  *(undefined2 *)(lVar10 + 0x1080) = 1;

+  local_168 = (void *)(lVar10 + 0x1298);

+  memset(local_168,0,(ulonglong)*(ushort *)(lVar10 + 0x1290) << 3);

+  *(undefined2 *)(lVar10 + 0x1290) = 1;

+  memset((void *)(lVar10 + 0x13a0),0,(ulonglong)*(ushort *)(lVar10 + 0x1398) << 3);

+  *(undefined2 *)(lVar10 + 0x1398) = 1;

+  memset((void *)(lVar10 + 0x14a8),0,(ulonglong)*(ushort *)(lVar10 + 0x14a0) << 3);

+  *(undefined2 *)(lVar10 + 0x14a0) = 1;

+  local_198 = (ulong64 *)(lVar10 + 0x15b0);

+  memset(local_198,0,(ulonglong)*(ushort *)(lVar10 + 0x15a8) << 3);

+  *(undefined2 *)(lVar10 + 0x15a8) = 1;

+  memset((void *)(lVar10 + 0x16b8),0,(ulonglong)p_Var16->Count << 3);

+  p_Var16->Count = 1;

+  memset((void *)(lVar10 + 0x17c0),0,(ulonglong)*(ushort *)(lVar10 + 0x17b8) << 3);

+  *(undefined2 *)(lVar10 + 0x17b8) = 1;

+  p_Var12 = (_KAFFINITY_EX *)(lVar10 + 0xd68);

+  local_160 = p_Var12;

+  memset((void *)(lVar10 + 0xd70),0,(ulonglong)p_Var12->Count << 3);

+  p_Var12->Count = 1;

+  iVar7 = Feature_PpmFixContainmentCandidateListInitialization__private_IsEnabledDeviceUsageNoInline

+                    ();

+  if (iVar7 != 0) {

+    p_Var13 = local_248;

+    if ((PpmHeteroHgsContainmentState & 8) != 0) {

+      p_Var12->Count = 1;

+      p_Var12->Size = 0x20;

+      p_Var12->Reserved = 0;

+      memset((void *)(lVar10 + 0xd70),0,0x100);

+      p_Var13 = (_KAFFINITY_EX *)

+                (*(longlong *)(local_200 + 0x500) + 0x10 +

+                (longlong)*(int *)(*(longlong *)(local_200 + 0x500) + 4) * 0x108);

     }

-    KeSubtractAffinityEx2(p_Var2,unaff_R13 + 5,unaff_R13 + 8);

-    KeSubtractAffinityEx2(unaff_R13 + 8,unaff_R13 + 7,unaff_R13 + 8);

-    lVar9 = unaff_RDI + 0x138;

-    KeSubtractAffinityEx2(lVar9,p_Var2,unaff_RDI + 0x138);

-    KeOrAffinityEx2(lVar9,unaff_R13 + 5,lVar9);

-    KeOrAffinityEx2(lVar9,unaff_R13 + 7,lVar9);

-    lVar9 = unaff_RDI + 0x348;

-    KeSubtractAffinityEx2(lVar9,unaff_R13 + 6,lVar9);

-    KeOrAffinityEx2(lVar9,unaff_R13 + 7,lVar9);

-    iVar7 = *(int *)(uVar16 - 0x74);

-    PpmEventTraceSoftCoreParkingSelectionEx

-              (unaff_RDI,iVar7,unaff_R12D & 0xffff,unaff_ESI & 0xffff,

-               CONCAT22(uVar22,(short)unaff_R14D));

-    bVar3 = *(byte *)(unaff_RDI + 0xc);

-    p_Var2 = unaff_R13 + 1;

-    uVar14 = *(uint *)(uVar16 - 0x70);

-    uVar19 = iVar7 + 1;

-    uVar8 = (ulonglong)uVar19;

-    *(uint *)(uVar16 - 0x74) = uVar19;

-    if (uVar19 < bVar3) goto LAB_0;

-    do {

-      uVar15 = (ulonglong)*(uint *)(uVar16 - 100);

-      do {

-        do {

-          uVar14 = (int)uVar15 + 1;

-          uVar15 = (ulonglong)uVar14;

-          bVar21 = PpmParkNumNodes <= uVar14;

-          *(uint *)(uVar16 - 100) = uVar14;

-          if (bVar21) {

-            PpmParkComputeDiff();

-            uVar14 = (uint)(PpmParkLpiCap != 0);

-            if ((PpmParkLpiEngaged != uVar14) || (bVar21 = false, PpmParkLpiCapChanged != 0)) {

-              bVar21 = true;

-            }

-            PpmParkLpiCapChanged = 0;

-            PpmParkLpiEngaged = uVar14;

-            if (bVar21) {

-              PpmEventLPICoreParking();

-            }

-            return 1;

-          }

-          unaff_RDI = uVar15 * 0x510 + PpmParkNodes;

-          *(longlong *)(uVar16 - 0x38) = unaff_RDI;

-        } while ((*(byte *)(unaff_RDI + 0x4a0) & 1) != 0);

-        KiCopyAffinityEx((_KAFFINITY_EX *)(unaff_RDI + 0x240),*(ushort *)(unaff_RDI + 0x242),

-                         (_KAFFINITY_EX *)(unaff_RDI + 0x138));

-        uVar6 = *(undefined4 *)(uVar16 - 0x48);

-        *(undefined2 *)(unaff_RDI + 0x4e4) = 0;

-        *(undefined1 *)(unaff_RDI + 0x4e6) = 0;

-        uVar11 = *(ushort *)(unaff_RDI + 0x492);

-        if (*(ushort *)(unaff_RDI + 0x496) <= *(ushort *)(unaff_RDI + 0x492)) {

-          uVar11 = *(ushort *)(unaff_RDI + 0x496);

-        }

-        uVar14 = (uint)uVar11;

-        *(uint *)(uVar16 - 0x70) = uVar14;

-        PpmParkFindOverUtilizedProcessorsEx(unaff_RDI,uVar6,unaff_R13 + 3);

-        *(undefined1 *)(unaff_RDI + 0x4c8) = 0;

-        if (PpmHeteroFavoredCoreRotationTimeoutMs != 0) {

-          uVar8 = _DAT_1 / ((ulonglong)PpmHeteroFavoredCoreRotationTimeoutMs * 10000)

-          ;

-          *(ulonglong *)(unaff_RDI + 0x4b8) = uVar8;

-          if (uVar8 != *(ulonglong *)(unaff_RDI + 0x4c0)) {

-            *(undefined1 *)(unaff_RDI + 0x4c8) = 1;

-            *(ulonglong *)(unaff_RDI + 0x4c0) = uVar8;

-          }

-        }

-        uVar8 = 0;

-        *(undefined4 *)(uVar16 - 0x74) = 0;

-      } while (*(char *)(unaff_RDI + 0xc) == '\0');

-LAB_0:

-      uVar11 = unaff_R13[6].Size;

-      puVar20 = (ushort *)(uVar8 * 0x280 + *(longlong *)(unaff_RDI + 0x508));

-      *(undefined4 *)(uVar16 - 0x80) = 0;

-      KiCopyAffinityEx(unaff_R13 + 6,uVar11,(_KAFFINITY_EX *)(puVar20 + 0x14));

-      iVar7 = KeIsEmptyAffinityEx(unaff_R13 + 6);

-    } while (iVar7 != 0);

-    *(undefined4 *)(uVar16 - 0x80) = 0x100000;

-    if (PpmParkGranularity < 2) {

-      KiCopyAffinityEx(unaff_R13,unaff_R13->Size,(_KAFFINITY_EX *)(puVar20 + 0x98));

+    KiCopyAffinityEx(p_Var12,*(ushort *)(lVar10 + 0xd6a),p_Var13);

+  }

+  local_264 = local_228[local_240 + 0x1f2];

+  KeAndAffinityEx2(local_1b0,local_248,local_1d0);

+  memset(&param_9->field3_0x8,0,(ulonglong)param_9->Count << 3);

+  param_9->Count = 1;

+  memset(local_1c8 + 4,0,(ulonglong)*local_1c8 << 3);

+  *local_1c8 = 1;

+  if ((param_6 == 0) || (param_5 == 0)) {

+    KiCopyAffinityEx(param_9,param_9->Size,local_248);

+    return;

+  }

+  if (PpmParkPreferenceHandler != (code *)0x0) {

+    local_2b0 = local_210;

+    local_2b8 = local_220;

+    local_2c0 = local_218;

+    local_2c8 = local_250;

+    (*PpmParkPreferenceHandler)(0,PpmCheckTime,param_5,local_248);

+    local_2c0 = local_210;

+    local_2c8 = local_220;

+    PpmEventParkNodePreferenceEx(local_248,(undefined2)param_5,local_250,local_218);

+    memset(&local_158.field3_0x8,0,(local_158._0_8_ & 0xffff) << 3);

+    uVar5 = local_158.Size;

+    local_158.Count = 1;

+    KiOrAffinityEx(local_250,local_218,&local_158,uVar5);

+    KeSubtractAffinityEx2(local_220,&local_158);

+    KeSubtractAffinityEx2(local_210,&local_158);

+  }

+  KeSubtractAffinityEx2(local_248,local_250,local_208);

+  KeSubtractAffinityEx2(local_208,local_218);

+  KeSubtractAffinityEx2(local_208,local_220);

+  KeSubtractAffinityEx2(local_208,local_210);

+  KiCopyAffinityEx(param_9,param_9->Size,local_248);

+  iVar7 = KeAndAffinityEx2(param_9,local_218,p_Var15);

+  if (iVar7 == 0) {

+    iVar7 = KeAndAffinityEx2(param_9,local_210,p_Var15);

+    if (iVar7 == 0) {

+      if ((PpmHeteroHgsContainmentState & 8) == 0) {

+        iVar7 = KeAndAffinityEx2(param_9,local_208,p_Var15);

+        if (iVar7 == 0) {

+          iVar7 = KeAndAffinityEx2(param_9,local_220,p_Var15);

+          if (iVar7 == 0) goto LAB_1;

+          uVar18 = 0x80000;

+        }

+        else {

+          uVar18 = 0x800;

+        }

+      }

+      else {

+        iVar7 = Feature_PpmFixContainmentCandidateListInitialization__private_IsEnabledDeviceUsageNoInline

+                          ();

+        if (iVar7 == 0) {

+          p_Var12->Count = 1;

+          p_Var12->Size = 0x20;

+          p_Var12->Reserved = 0;

+          memset((void *)(lVar10 + 0xd70),0,0x100);

+          KiCopyAffinityEx(p_Var12,*(ushort *)(lVar10 + 0xd6a),

+                           (_KAFFINITY_EX *)

+                           (*(longlong *)(local_200 + 0x500) + 0x10 +

+                           (longlong)*(int *)(*(longlong *)(local_200 + 0x500) + 4) * 0x108));

+        }

+        iVar7 = KeAndAffinityEx2(param_9,p_Var12,p_Var15);

+        if (iVar7 == 0) goto LAB_1;

+        uVar18 = 0x400000;

+      }

     }

     else {

-      memset(&unaff_R13->field3_0x8,0,(ulonglong)unaff_R13->Count << 3);

-      unaff_R13->Count = 1;

-      *(undefined2 *)(uVar16 - 0x50) = 0;

-      *(undefined8 *)(uVar16 - 0x58) = *(undefined8 *)(puVar20 + 0x9c);

-      *(_KAFFINITY_EX **)(uVar16 - 0x60) = (_KAFFINITY_EX *)(puVar20 + 0x98);

-      while (iVar7 = KeEnumerateNextProcessor(uVar16 - 0x78,uVar16 - 0x60), iVar7 == 0) {

-        KeGetPrcb(*(undefined4 *)(uVar16 - 0x78));

-        KeAddGroupAffinityEx();

-      }

+      uVar18 = 0x400;

     }

-    KeAndAffinityEx2();

-    iVar7 = KeIsEmptyAffinityEx();

-    if (iVar7 == 0) {

-      *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x10000;

-    }

-    iVar7 = KeCountSetBitsAffinityEx();

-    if ((uint)*puVar20 - iVar7 <= uVar14) {

-      uVar14 = (uint)*puVar20 - iVar7;

-    }

-    memset(&unaff_R13[1].field3_0x8,0,(ulonglong)p_Var2->Count << 3);

-    bVar21 = KiClockTimerPerCpu == '\0';

-    p_Var2->Count = 1;

-    uVar6 = KiClockTimerOwner;

-    unaff_R14D = 0;

-    if (bVar21) {

-      *(undefined4 *)(uVar16 - 0x78) = KiClockTimerOwner;

-      iVar7 = KeCheckProcessorAffinityEx(unaff_R13 + 6);

-      if (((iVar7 != 0) && (unaff_R14D = 0, uVar14 != 0)) &&

-         (iVar7 = KeCheckProcessorAffinityEx(), iVar7 == 0)) {

-        lVar9 = KeGetPrcb(uVar6);

-        if (PpmParkGranularity < 2) {

-          KeAddProcessorAffinityEx(p_Var2);

+    *param_11 = *param_11 | uVar18;

+  }

+  else {

+    uVar18 = 0x200;

+    *param_11 = *param_11 | 0x200;

+  }

+LAB_1:

+  KiCopyAffinityEx(p_Var16,*(ushort *)(lVar10 + 0x16b2),p_Var15);

+  p_Var12 = local_238;

+  memset(local_170,0,(ulonglong)local_238->Count << 3);

+  p_Var13 = local_230;

+  p_Var12->Count = 1;

+  memset(local_168,0,(ulonglong)local_230->Count << 3);

+  p_Var13->Count = 1;

+  KiCopyAffinityEx(p_Var17,*(ushort *)(lVar10 + 0xb5a),p_Var16);

+  KeAndAffinityEx2(local_1d0,local_1b8,local_1a8);

+  KeSubtractAffinityEx2(local_248,local_1d0,local_1d8);

+  KeAndAffinityEx2(local_1d8,local_1b8);

+  local_267 = -1;

+  local_268 = -1;

+  local_240 = local_240 & 0xffffffff00000000;

+  local_228 = (undefined *)((ulonglong)local_228 & 0xffffffff00000000);

+  if (param_6 != 0) {

+    do {

+      iVar7 = KeIsEmptyAffinityEx(p_Var17);

+      p_Var12 = local_1a0;

+      if (iVar7 != 0) {

+        return;

+      }

+      KeAndAffinityEx2(p_Var17,local_1a8,local_1a0);

+      iVar7 = KeIsEmptyAffinityEx(p_Var12);

+      if (iVar7 == 0) {

+        *param_11 = *param_11 | 0x20000;

+        uVar18 = uVar18 | 0x20000;

+        KiCopyAffinityEx(p_Var17,p_Var17->Size,p_Var12);

+      }

+      if (((PopHeteroSystem - 3U & 0xfffffffc) == 0) && (PopHeteroSystem != 4)) {

+        *param_11 = *param_11 | 0x8000;

+        uVar18 = uVar18 | 0x8000;

+        local_2b8 = (_KAFFINITY_EX *)CONCAT44(local_2b8._4_4_,param_16);

+        local_2c0 = (_KAFFINITY_EX *)CONCAT44(local_2c0._4_4_,(uint)local_240);

+        local_2c8 = (_KAFFINITY_EX *)CONCAT44(local_2c8._4_4_,param_13);

+        PpmHeteroRestrictToFavoredClassEx(p_Var17,&local_268,param_14,param_15);

+        if (local_268 != local_267) {

+          local_267 = local_268;

+          uVar8 = KeCountSetBitsAffinityEx(p_Var17);

+          local_250 = (_KAFFINITY_EX *)CONCAT44(local_250._4_4_,uVar8);

+          uVar11 = *param_12;

+          local_1f0 = (p_Var17->field3_0x8).Bitmap[0];

+          local_1e8 = 0;

+          local_1f8 = p_Var17;

+          iVar7 = KeEnumerateNextProcessor(&local_228,&local_1f8);

+          for (uVar11 = uVar11 % (ulonglong)uVar8;

+              (iVar7 == 0 && (p_Var15 = local_1c0, uVar11 != 0)); uVar11 = uVar11 - 1) {

+            iVar7 = KeEnumerateNextProcessor(&local_228,&local_1f8);

+            p_Var15 = local_1c0;

+          }

+          PpmEventHeteroFavoredCoreRotationChange

+                    ((ulonglong)local_250 & 0xffffffff,(ulonglong)local_228 & 0xffffffff);

+          p_Var12 = local_1a0;

+        }

+      }

+      KeAndAffinityEx2(p_Var17,local_1d8,p_Var12);

+      iVar7 = KeIsEmptyAffinityEx();

+      if (iVar7 == 0) {

+        *param_11 = *param_11 | 0x1000;

+        uVar18 = uVar18 | 0x1000;

+        KiCopyAffinityEx(p_Var17,p_Var17->Size,p_Var12);

+      }

+      if ((char)param_12[2] == '\0') {

+        KeSubtractAffinityEx2(p_Var17,local_1d0,p_Var12);

+        iVar7 = KeIsEmptyAffinityEx(p_Var12);

+        if (iVar7 == 0) {

+          *param_11 = *param_11 | 0x2000;

+          uVar18 = uVar18 | 0x2000;

+          KiCopyAffinityEx(p_Var17,p_Var17->Size,p_Var12);

+        }

+      }

+      local_1f0 = (p_Var17->field3_0x8).Bitmap[0];

+      local_1e8 = 0;

+      local_1f8 = p_Var17;

+      do {

+        iVar7 = KeEnumerateNextProcessor(local_260);

+        if (iVar7 != 0) goto LAB_2;

+      } while (local_260[0] < (uint)local_228);

+      uVar8 = local_260[0];

+      if (local_260[0] == 0xffffffff) {

+LAB_2:

+        uVar8 = KeFindFirstSetRightAffinityEx(p_Var17);

+      }

+      lVar10 = KeGetPrcb(uVar8);

+      memset(local_198,0,(ulonglong)local_258->Count << 3);

+      bVar19 = PpmParkCoreMask == '\0';

+      local_258->Count = 1;

+      if (bVar19) {

+        uVar14 = *(undefined8 *)(lVar10 + 200);

+      }

+      else {

+        uVar14 = *(undefined8 *)(lVar10 + 0x8e60);

+      }

+      KeAddGroupAffinityEx(local_258,*(undefined1 *)(lVar10 + 0xd0),uVar14);

+      KeSubtractAffinityEx2(param_9,local_258);

+      if ((uint)local_240 < param_5) {

+        if ((local_190 != 0) && (*(int *)(local_200 + 0x4d0) == 3)) {

+          local_1e8 = 0;

+          local_250 = (_KAFFINITY_EX *)

+                      CONCAT44(local_250._4_4_,(param_5 - 1) + (local_1e0 - (uint)local_240));

+          local_1f0 = *local_198;

+          local_1f8 = local_258;

+          iVar7 = KeEnumerateNextProcessor(local_260,&local_1f8);

+          lVar4 = local_190;

+          lVar3 = local_200;

+          if (iVar7 == 0) {

+            uVar8 = (uint)local_250;

+            do {

+              if ((uVar8 < *(ushort *)(lVar3 + 10)) &&

+                 (*(uint *)(lVar4 + (ulonglong)uVar8 * 4) != local_260[0])) {

+                *(uint *)(lVar4 + (ulonglong)uVar8 * 4) = local_260[0];

+                *(undefined1 *)(lVar3 + 0x4e6) = 1;

+              }

+              uVar8 = uVar8 - 1;

+              iVar7 = KeEnumerateNextProcessor(local_260,&local_1f8);

+              param_11 = local_188;

+              p_Var15 = local_1c0;

+              p_Var16 = local_178;

+              p_Var17 = local_180;

+            } while (iVar7 == 0);

+          }

+          sVar6 = KeCountSetBitsAffinityEx(local_258);

+          *(short *)(local_200 + 0x4e4) = *(short *)(local_200 + 0x4e4) + sVar6;

+        }

+      }

+      else {

+        KeOrAffinityEx2(local_1c8,local_258);

+        KiCopyAffinityEx(&local_158,local_158.Size,local_258);

+        local_250 = PpmParkNewSoftParkRankList;

+        if (((PpmParkNewSoftParkRankList != (_KAFFINITY_EX *)0x0) &&

+            (local_1b0 = PpmParkOldSoftParkRankList, PpmParkOldSoftParkRankList != 0)) &&

+           (iVar7 = KeIsEmptyAffinityEx(&local_158), lVar3 = local_1b0, p_Var12 = local_250,

+           iVar7 == 0)) {

+          do {

+            local_260[0] = KeFindFirstSetRightAffinityEx(&local_158);

+            *(int *)(&p_Var12->Count + (ulonglong)local_260[0] * 2) = PpmParkSoftParkCurrentRank;

+            if (PpmParkSoftParkCurrentRank != *(int *)(lVar3 + (ulonglong)local_260[0] * 4)) {

+              PpmParkSoftParkRankListChanged = 1;

+            }

+            PpmParkSoftParkCurrentRank = PpmParkSoftParkCurrentRank + 1;

+            KeRemoveProcessorAffinityEx(&local_158);

+            iVar7 = KeIsEmptyAffinityEx(&local_158);

+            param_11 = local_188;

+            p_Var15 = local_1c0;

+            p_Var16 = local_178;

+            p_Var17 = local_180;

+          } while (iVar7 == 0);

+        }

+      }

+      iVar7 = KeCountSetBitsAffinityEx(local_258);

+      iVar7 = (uint)local_240 + iVar7;

+      local_278 = local_248;

+      local_280 = local_1b8;

+      local_298 = local_230;

+      local_2a0 = local_238;

+      local_2a8 = local_258;

+      local_2b0 = param_9;

+      local_240 = CONCAT44(local_240._4_4_,iVar7);

+      local_2c0 = (_KAFFINITY_EX *)CONCAT44(local_2c0._4_4_,uVar18);

+      local_2c8 = (_KAFFINITY_EX *)CONCAT44(local_2c8._4_4_,param_13);

+      local_2b8 = p_Var17;

+      local_290 = p_Var16;

+      local_288 = p_Var15;

+      PpmEventTraceCoreParkingSelectionEx(local_248,param_5,param_6,iVar7);

+      uVar18 = 0;

+      memset(&p_Var17->field3_0x8,0,(ulonglong)p_Var17->Count << 3);

+      p_Var17->Count = 1;

+      KeSubtractAffinityEx2(p_Var16,lVar10 + 0x8c10,p_Var16);

+      KeGetTopologySiblingAffinityForProcessor(lVar10,5,&local_158);

+      if (local_266 == '\0') {

+LAB_3:

+        memset(local_170,0,(ulonglong)local_238->Count << 3);

+        local_238->Count = 1;

+      }

+      else {

+        if (local_266 == '\x01') {

+          KiComplementAffinityEx(&local_158,local_158.Size,&local_158);

         }

         else {

-          KeAddGroupAffinityEx(p_Var2,*(undefined1 *)(lVar9 + 0xd0),*(undefined8 *)(lVar9 + 0x8e60))

-          ;

-        }

-        *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x100;

-        unaff_R14D = KeCountSetBitsAffinityEx(p_Var2);

-      }

-    }

-    memset(&unaff_R13[2].field3_0x8,0,(ulonglong)unaff_R13[2].Count << 3);

-    unaff_R13[2].Count = 1;

-    uVar19 = KeCpuSetQueryUnparkRecommendationEx();

-    *(uint *)(uVar16 - 0x6c) = uVar19 & 0xffff;

-    if ((uVar19 & 0xffff) != 0) {

-      p_Var2 = unaff_R13 + 2;

-      if (1 < PpmParkGranularity) {

-        *(undefined2 *)(uVar16 - 0x50) = 0;

-        *(undefined8 *)(uVar16 - 0x58) = **(undefined8 **)(uVar16 - 0x40);

-        *(_KAFFINITY_EX **)(uVar16 - 0x60) = p_Var2;

-        iVar7 = KeEnumerateNextProcessor(uVar16 - 0x78,uVar16 - 0x60);

-        while (iVar7 == 0) {

-          lVar9 = KeGetPrcb(*(undefined4 *)(uVar16 - 0x78));

-          KeAddGroupAffinityEx(p_Var2,*(undefined1 *)(lVar9 + 0xd0),*(undefined8 *)(lVar9 + 0x8e60))

-          ;

-          iVar7 = KeEnumerateNextProcessor(uVar16 - 0x78,uVar16 - 0x60);

-        }

-        uVar6 = KeCountSetBitsAffinityEx(p_Var2);

-        *(undefined4 *)(uVar16 - 0x6c) = uVar6;

-      }

-      p_Var18 = unaff_R13 + 1;

-      *(ulong64 *)(uVar16 - 0x58) = unaff_R13[2].field3_0x8.Bitmap[0];

-      *(undefined2 *)(uVar16 - 0x50) = 0;

-      *(_KAFFINITY_EX **)(uVar16 - 0x60) = p_Var2;

-      iVar7 = KeEnumerateNextProcessor();

-      if (iVar7 == 0) {

-        do {

-          if (unaff_R14D < uVar14) {

-            uVar6 = *(undefined4 *)(uVar16 - 0x78);

-            iVar7 = KeCheckProcessorAffinityEx();

-            if (iVar7 == 0) {

-              lVar9 = KeGetPrcb(uVar6);

-              if (PpmParkGranularity < 2) {

-                KeAddProcessorAffinityEx(p_Var18,uVar6);

+          if (local_266 != '\x02') goto LAB_3;

+          KiSubtractAffinityEx(&local_158,local_258,&local_158,local_158.Size);

+        }

+        PpmParkBuildTopologyCandidatesEx(local_238,&local_158,param_9);

+      }

+      KeGetTopologySiblingAffinityForProcessor(lVar10,2,&local_158);

+      if (local_265 == '\0') {

+LAB_4:

+        memset(local_168,0,(ulonglong)local_230->Count << 3);

+        local_230->Count = 1;

+      }

+      else {

+        if (local_265 == '\x01') {

+          KiComplementAffinityEx(&local_158,local_158.Size,&local_158);

+        }

+        else {

+          if (local_265 != '\x02') goto LAB_4;

+          KiSubtractAffinityEx(&local_158,local_258,&local_158,local_158.Size);

+        }

+        PpmParkBuildTopologyCandidatesEx(local_230,&local_158,param_9);

+      }

+      if (((local_264 == '\0') || (local_264 == '\x01')) ||

+         ((local_264 == '\x02' || (local_264 != '\x03')))) {

+        bVar2 = *(byte *)(lVar10 + 0xd0);

+        if ((ushort)bVar2 < p_Var15->Count) {

+          uVar11 = *(ulonglong *)(lVar10 + 0x8e60);

+          goto LAB_5;

+        }

+      }

+      else {

+        bVar2 = *(byte *)(lVar10 + 0xd0);

+        if ((ushort)bVar2 < p_Var15->Count) {

+          uVar11 = *(ulonglong *)(lVar10 + 200);

+LAB_5:

+          puVar1 = (ulonglong *)((longlong)&p_Var15->field3_0x8 + (ulonglong)bVar2 * 8);

+          *puVar1 = *puVar1 & ~uVar11;

+        }

+      }

+      iVar7 = KeIsEmptyAffinityEx(p_Var17);

+      if (iVar7 != 0) {

+        iVar7 = KeIsEmptyAffinityEx(p_Var16);

+        if (iVar7 != 0) {

+          iVar7 = KeIsEmptyAffinityEx(p_Var15);

+          if (iVar7 == 0) goto LAB_6;

+          iVar7 = KeAndAffinityEx2(param_9,local_218,p_Var15);

+          if (iVar7 == 0) {

+            iVar7 = KeAndAffinityEx2(param_9,local_210,p_Var15);

+            if (iVar7 != 0) {

+              uVar18 = 0x400;

+              goto LAB_7;

+            }

+            uVar18 = 0;

+            if ((PpmHeteroHgsContainmentState & 8) == 0) {

+              iVar7 = KeAndAffinityEx2(param_9,local_208,p_Var15);

+              if (iVar7 == 0) {

+                iVar7 = KeAndAffinityEx2(param_9,local_220,p_Var15);

+                if (iVar7 == 0) goto LAB_6;

+                uVar18 = 0x80000;

               }

               else {

-                KeAddGroupAffinityEx

-                          (p_Var18,*(undefined1 *)(lVar9 + 0xd0),*(undefined8 *)(lVar9 + 0x8e60));

+                uVar18 = 0x800;

               }

-              *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x10;

-              unaff_R14D = KeCountSetBitsAffinityEx(p_Var18);

+              goto LAB_7;

+            }

+            iVar7 = KeAndAffinityEx2(param_9,local_160,p_Var15);

+            if (iVar7 != 0) {

+              uVar18 = 0x400000;

+              goto LAB_7;

             }

           }

-          iVar7 = KeEnumerateNextProcessor();

-        } while (iVar7 == 0);

-        unaff_RDI = *(longlong *)(uVar16 - 0x38);

-      }

-    }

-    *(undefined1 *)(uVar16 - 0x7b) = 0;

-    *(undefined4 *)(uVar16 - 0x68) = 3;

-    iVar7 = Feature_PpmFixContainmentCandidateListInitialization__private_IsEnabledDeviceUsageNoInline

-                      ();

-    if (((iVar7 != 0) && (iVar7 = KeIsEmptyAffinityEx(), iVar7 == 0)) &&

-       ((PpmHeteroHgsContainmentState & 8) != 0)) {

-      *(undefined8 *)(uVar16 - 0x20) = 0x200001;

-      memset((void *)(uVar16 - 0x18),0,0x100);

-      KiCopyAffinityEx((_KAFFINITY_EX *)(uVar16 - 0x20),*(ushort *)(uVar16 - 0x1e),

-                       (_KAFFINITY_EX *)

-                       ((longlong)*(int *)(*(longlong *)(unaff_RDI + 0x500) + 4) * 0x108 + 0x10 +

-                       *(longlong *)(unaff_RDI + 0x500)));

-      iVar7 = KeIsSubsetAffinityEx();

-      if (iVar7 == 0) {

-        *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x2000000;

-        lVar9 = *(longlong *)(unaff_RDI + 0x500);

-        *(undefined1 *)(uVar16 - 0x7b) = 1;

-        *(undefined4 *)(uVar16 - 0x68) = *(undefined4 *)(lVar9 + 4);

-        *(undefined4 *)(lVar9 + 4) = 2;

-      }

-    }

-    uVar11 = puVar20[1];

-    if ((unaff_R14D < uVar11) && (unaff_R14D < uVar14)) {

-      unaff_R14D = uVar14;

-      if (uVar11 < uVar14) {

-        unaff_R14D = (uint)uVar11;

-      }

-      uVar19 = *(uint *)(uVar16 - 0x80) | 4;

-      *(uint *)(uVar16 - 0x80) = uVar19;

-    }

-    else {

-      uVar19 = *(uint *)(uVar16 - 0x80);

-    }

-    uVar11 = puVar20[2];

-    if ((uVar11 < uVar14) && (unaff_R14D < uVar14)) {

-      uVar19 = uVar19 | 8;

-      *(uint *)(uVar16 - 0x80) = uVar19;

-      uVar14 = (uint)uVar11;

-      if (uVar11 <= unaff_R14D) {

-        uVar14 = unaff_R14D;

-      }

-    }

-    uVar11 = 0;

-    uVar13 = PpmHeteroHgsContainmentState & 8;

-    if (uVar13 != 0) {

-      uVar11 = *(ushort *)

-                (*(longlong *)(unaff_RDI + 0x500) + 8 +

-                (longlong)*(int *)(*(longlong *)(unaff_RDI + 0x500) + 4) * 2);

-    }

-    uVar4 = *puVar20;

-    uVar5 = puVar20[3];

-    if (uVar4 <= puVar20[3]) {

-      uVar5 = uVar4;

-    }

-    uVar17 = (uint)uVar5;

-    if ((PpmCheckLatencyBoostActive != 0) &&

-       (uVar12 = ((uint)*(byte *)((ulonglong)(*(int *)(uVar16 - 0x74) != 0) + 0x89 +

-                                 *(longlong *)(uVar16 - 0x30)) * (uint)uVar4 + 0x32) / 100,

-       uVar5 < uVar12)) {

-      uVar19 = uVar19 | 0x40;

-      *(uint *)(uVar16 - 0x80) = uVar19;

-      uVar17 = uVar12;

-    }

-    if (1 < PpmParkGranularity) {

-      uVar17 = uVar17 + (PpmParkGranularity - 1);

-      uVar17 = uVar17 - uVar17 % (uint)PpmParkGranularity;

-    }

-    if (((uVar13 != 0) && (uVar11 != 0)) && (uVar11 < (ushort)uVar17)) {

-      uVar17 = (uint)uVar11;

-      *(uint *)(uVar16 - 0x80) = uVar19 | 0x400000;

-    }

-    uVar19 = *(int *)(uVar16 - 0x6c) + uVar17;

-    puVar20[4] = (ushort)uVar17;

-    if (uVar14 <= uVar19) {

-      uVar19 = uVar14;

-    }

-    unaff_R12D = unaff_R14D;

-    if (unaff_R14D < uVar19) {

-      unaff_R12D = uVar19;

-    }

-    *(int *)(uVar16 - 0x70) = *(int *)(uVar16 - 0x70) - uVar14;

-    bVar21 = PpmParkSoftParkingEnabled == '\0';

-    puVar20[5] = (ushort)unaff_R12D;

-    if (bVar21) {

-      *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x200000;

-      unaff_ESI = unaff_R12D;

-    }

-    else {

-      unaff_ESI = uVar14;

-      if (uVar13 != 0) {

-        *(uint *)(uVar16 - 0x80) = *(uint *)(uVar16 - 0x80) | 0x800000;

-        unaff_ESI = (uint)uVar11;

-        if (uVar14 < uVar11) {

-          unaff_ESI = uVar14;

-        }

-      }

-    }

-    bVar21 = PpmHeteroHgsParkingEnabled != '\0';

-    *(undefined1 *)(uVar16 - 0x7c) = 0;

-    if (bVar21) {

-      *(undefined1 *)(uVar16 - 0x7c) = *(undefined1 *)(unaff_RDI + 0x4f6);

-    }

-    param_3 = unaff_R13 + 4;

-    param_2 = unaff_R13 + 3;

-  } while( true );

+          else {

+            uVar18 = 0x200;

+LAB_7:

+            *param_11 = *param_11 | uVar18;

+          }

+LAB_6:

+          KiCopyAffinityEx(p_Var16,p_Var16->Size,p_Var15);

+          uVar9 = KiAndAffinityExNoResult(p_Var16,local_238);

+          if (uVar9 != 0) {

+            KeAndAffinityEx2(p_Var16);

+          }

+          uVar9 = KiAndAffinityExNoResult(p_Var16,local_230);

+          if (uVar9 != 0) {

+            KeAndAffinityEx2(p_Var16);

+          }

+        }

+        KiCopyAffinityEx(p_Var17,p_Var17->Size,p_Var16);

+      }

+    } while ((uint)local_240 < param_6);

+  }

+  return;

 }
```

## `EtwTraceMdlAllocationEvent`  (modified)

```diff
--- EtwTraceMdlAllocationEvent
+++ EtwTraceMdlAllocationEvent
@@ -1,187 +1,53 @@
 

-/* WARNING: Instruction at (ram,0x0001403948fa) overlaps instruction at (ram,0x0001403948f4)

-    */

-/* WARNING: Control flow encountered bad instruction data */

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

 

-void EtwTraceMdlAllocationEvent(longlong param_1,longlong param_2)

+void EtwTraceMdlAllocationEvent

+               (undefined8 param_1,undefined8 param_2,undefined8 param_3,undefined8 param_4,

+               undefined8 param_5,undefined4 param_6,undefined4 param_7,undefined8 param_8,

+               undefined8 param_9)

 

 {

-  byte *pbVar1;

-  longlong *plVar2;

-  char *pcVar3;

-  longlong lVar4;

-  undefined8 *puVar5;

-  undefined8 *puVar6;

-  byte bVar7;

-  char cVar8;

-  longlong lVar9;

-  longlong lVar10;

-  longlong unaff_RBX;

-  longlong unaff_RBP;

-  uint *unaff_RSI;

-  undefined8 *unaff_RDI;

-  undefined8 *unaff_R14;

-  bool in_CF;

-  bool in_ZF;

+  char cVar1;

+  undefined1 auStack_c8 [32];

+  undefined8 local_a8;

+  undefined8 local_a0;

+  undefined4 local_98;

+  undefined8 **local_90;

+  undefined8 local_88;

+  undefined8 local_80;

+  undefined8 local_78;

+  undefined8 local_70;

+  undefined8 local_68;

+  undefined8 local_60;

+  undefined4 local_58;

+  undefined4 local_54;

+  undefined8 local_50;

+  undefined8 *local_48;

+  undefined4 local_40;

+  undefined4 local_3c;

+  ulonglong local_38;

   

-  if (!in_CF && !in_ZF) {

-    pcVar3 = (char *)(unaff_RBP + 0x33 + param_2);

-    *pcVar3 = *pcVar3 + (char)((ulonglong)param_2 >> 8);

-    pbVar1 = (byte *)(param_1 + -0x73);

-    bVar7 = (byte)param_1 & 7;

-    *pbVar1 = *pbVar1 >> bVar7 | *pbVar1 << 8 - bVar7;

-    pbVar1 = (byte *)(param_1 + -0x47);

-    *pbVar1 = *pbVar1 << 1 | (char)*pbVar1 < '\0';

-                    /* WARNING: Bad instruction - Truncating control flow here */

-    halt_baddata();

+  local_38 = __security_cookie ^ (ulonglong)auStack_c8;

+  cVar1 = EtwEventEnabled(EtwpMemoryProvRegHandle,&KERNEL_MEM_EVENT_MDL_ALLOCATION);

+  if (cVar1 != '\0') {

+    local_88 = EtwpGetDurationSince(param_9);

+    local_3c = 0;

+    local_58 = param_6;

+    local_54 = param_7;

+    local_80 = param_5;

+    local_50 = param_8;

+    local_48 = &local_88;

+    local_90 = &local_48;

+    local_98 = 1;

+    local_a0 = 0;

+    local_a8 = 0;

+    local_40 = 0x40;

+    local_78 = param_2;

+    local_70 = param_3;

+    local_68 = param_4;

+    local_60 = param_1;

+    EtwWriteEx(EtwpMemoryProvRegHandle,&KERNEL_MEM_EVENT_MDL_ALLOCATION,0);

   }

-  do {

-    while (unaff_R14 != (undefined8 *)0x0) {

-      lVar4 = unaff_R14[3];

-      puVar6 = (undefined8 *)*unaff_R14;

-      KeAcquireSpinLockRaiseToDpc(&DAT_0);

-      if (*(char *)(lVar4 + 0x10) == '\x01') {

-        *(undefined1 *)(lVar4 + 0x11) = 1;

-      }

-      else {

-        ExFreePoolWithTag(lVar4,0);

-      }

-      KeReleaseSpinLock(&DAT_0);

-      if (*(int *)(unaff_R14 + 2) != 0) {

-        PspAdjustKeepAliveCountProcess(unaff_R14[1],0xffffffff);

-        ObfDereferenceObjectWithTag(unaff_R14[1]);

-      }

-      ExFreePoolWithTag(unaff_R14,0);

-      unaff_R14 = puVar6;

-    }

-    lVar4 = unaff_RDI[1];

-    if (lVar4 != 0) {

-      if (ObpTraceFlags != 0) {

-        ObpPushStackInfo(lVar4 + -0x30,0,1,0x746c6644);

-      }

-      LOCK();

-      plVar2 = (longlong *)(lVar4 + -0x30);

-      lVar10 = *plVar2;

-      *plVar2 = *plVar2 + -1;

-      UNLOCK();

-      lVar9 = lVar10 + -1;

-      if (lVar9 == 0 || lVar10 < 1) {

-        if (*(longlong *)(lVar4 + -0x28) != 0) {

-                    /* WARNING: Subroutine does not return */

-          KeBugCheckEx(0x18,*(undefined8 *)

-                             (&ObTypeIndexTable +

-                             (lVar4 - 0x30U >> 8 & 0xff ^ (ulonglong)*(byte *)(lVar4 + -0x18) ^

-                             (ulonglong)ObHeaderCookie) * 8),lVar4,1,*(longlong *)(lVar4 + -0x28));

-        }

-        if (-1 < lVar9) {

-          cVar8 = KeAreAllApcsDisabled();

-          lVar10 = lVar4 + -0x30;

-          if (cVar8 != '\0') goto LAB_1;

-          lVar10 = OBJECT_HEADER_TO_HANDLE_REVOCATION_INFO(lVar10);

-          if (lVar10 != 0) {

-            ObpHandleRevocationBlockRemoveObject(lVar10);

-          }

-          if (ObpTraceFlags != 0) {

-            ObpDeregisterObject(lVar4 + -0x30);

-          }

-          ObpRemoveObjectRoutine(lVar4 + -0x30);

-          ExFreePoolWithTag(*(undefined8 *)(unaff_RSI + unaff_RBX * 2 + 2));

-          goto LAB_2;

-        }

-                    /* WARNING: Subroutine does not return */

-        KeBugCheckEx(0x18,0,lVar4,2,lVar9);

-      }

-    }

-LAB_3:

-    ExFreePoolWithTag(*(undefined8 *)(unaff_RSI + unaff_RBX * 2 + 2));

-LAB_2:

-    unaff_RBX = unaff_RBX + 1;

-    if (9 < unaff_RBX) {

-      if ((*unaff_RSI & 2) != 0) {

-        IopCleanupNotifications(*(undefined8 *)(*(longlong *)(unaff_RBP + 8) + 8));

-      }

-      ExFreePoolWithTag();

-      return;

-    }

-LAB_4:

-    unaff_RDI = *(undefined8 **)(unaff_RSI + unaff_RBX * 2 + 2);

-    if (unaff_RDI == (undefined8 *)0x0) goto LAB_2;

-    if (unaff_RBX == 4) {

-      if ((undefined8 *)*unaff_RDI != unaff_RDI) {

-        FUN_1406dfe8e();

-        return;

-      }

-      goto LAB_3;

-    }

-    if (unaff_RBX == 0) {

-      if (unaff_RDI[1] == 0) goto LAB_3;

-      ObDereferenceObjectDeferDeleteWithTag();

-      ExFreePoolWithTag(*(undefined8 *)(unaff_RSI + 2));

-      goto LAB_2;

-    }

-    if (unaff_RBX == 5) {

-      FsRtlFreeExtraCreateParameter(unaff_RDI);

-      unaff_RBX = 6;

-      goto LAB_4;

-    }

-    if (unaff_RBX != 1) {

-      if (unaff_RBX == 6) {

-        ExFreeToNPagedLookasideList(&IopOplockFoExtLookasideList);

-        unaff_RBX = 7;

-        goto LAB_4;

-      }

-      if (unaff_RBX == 2) {

-        if (unaff_RDI[5] != 0) {

-          FUN_1406dfea5();

-          return;

-        }

-        goto LAB_3;

-      }

-      if (unaff_RBX != 7) {

-        if (unaff_RBX == 8) {

-          ObfDereferenceObjectWithTag(*unaff_RDI);

-        }

-        goto LAB_3;

-      }

-      if ((*(uint *)((longlong)unaff_RDI + 4) & 1) != 0) {

-        *(uint *)((longlong)unaff_RDI + 4) = *(uint *)((longlong)unaff_RDI + 4) & 0xfffffffe;

-        PsReleaseSiloHardReference(unaff_RDI[1]);

-      }

-      lVar10 = unaff_RDI[1];

-      if (ObpTraceFlags != 0) {

-        ObpPushStackInfo(lVar10 + -0x30,0,1,0x70536f49);

-      }

-      LOCK();

-      plVar2 = (longlong *)(lVar10 + -0x30);

-      lVar4 = *plVar2;

-      *plVar2 = *plVar2 + -1;

-      UNLOCK();

-      lVar9 = lVar4 + -1;

-      if (lVar9 != 0 && 0 < lVar4) goto LAB_3;

-      if (*(longlong *)(lVar10 + -0x28) != 0) {

-                    /* WARNING: Subroutine does not return */

-        KeBugCheckEx(0x18,*(undefined8 *)

-                           (&ObTypeIndexTable +

-                           (lVar10 - 0x30U >> 8 & 0xff ^ (ulonglong)*(byte *)(lVar10 + -0x18) ^

-                           (ulonglong)ObHeaderCookie) * 8),lVar10,3,*(longlong *)(lVar10 + -0x28));

-      }

-      if (lVar9 < 0) {

-                    /* WARNING: Subroutine does not return */

-        KeBugCheckEx(0x18,0,lVar10,4,lVar9);

-      }

-      lVar10 = lVar10 + -0x30;

-LAB_1:

-      ObpDeferObjectDeletion(lVar10);

-      ExFreePoolWithTag(*(undefined8 *)(unaff_RSI + unaff_RBX * 2 + 2));

-      goto LAB_2;

-    }

-    puVar6 = (undefined8 *)unaff_RDI[2];

-    while (puVar6 != (undefined8 *)0x0) {

-      puVar5 = (undefined8 *)*puVar6;

-      ExFreePoolWithTag(puVar6);

-      puVar6 = puVar5;

-    }

-    unaff_R14 = (undefined8 *)unaff_RDI[3];

-  } while( true );

+  return;

 }
```

## `KiTimerWaitTest`  (modified)

```diff
--- KiTimerWaitTest
+++ KiTimerWaitTest
@@ -1,18 +1,235 @@
 

-undefined1 KiTimerWaitTest(undefined8 param_1,undefined8 param_2,undefined8 *param_3)

+/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

+

+char * KiTimerWaitTest(longlong param_1,uint *param_2,uint *param_3)

 

 {

-  undefined4 uVar1;

-  longlong unaff_RBP;

-  undefined1 unaff_SIL;

-  undefined8 unaff_R12;

+  undefined8 *puVar1;

+  uint *puVar2;

+  code *pcVar3;

+  uint uVar4;

+  byte bVar5;

+  char cVar6;

+  uint uVar7;

+  sbyte sVar8;

+  ulonglong uVar9;

+  longlong lVar10;

+  undefined1 *puVar11;

+  ulonglong uVar12;

+  char *pcVar13;

+  ushort uVar14;

+  undefined2 uVar15;

+  byte bVar16;

+  ulonglong uVar17;

+  undefined8 uVar18;

+  byte bVar19;

+  uint *puVar20;

+  undefined1 auStack_88 [8];

+  undefined1 auStack_80 [24];

+  ulonglong local_68;

+  undefined8 local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

   

-  *param_3 = unaff_R12;

-  uVar1 = *(undefined4 *)(unaff_RBP + -0x79);

-  *(undefined4 *)(param_3 + 4) = 1;

-  *(undefined4 *)((longlong)param_3 + 0x24) = 1;

-  *(undefined4 *)((longlong)param_3 + 0x2c) = *(undefined4 *)(unaff_RBP + -0x59);

-  *(undefined4 *)(param_3 + 3) = uVar1;

-  return unaff_SIL;

+  puVar11 = auStack_88;

+  uVar17 = 0;

+  uVar4 = *param_2;

+  bVar19 = (byte)KiWaitNever & 0x3f;

+  uVar12 = ((*(ulonglong *)(param_2 + 0xc) ^ KiWaitNever) << bVar19 |

+           (*(ulonglong *)(param_2 + 0xc) ^ KiWaitNever) >> 0x40 - bVar19) ^ (ulonglong)param_2;

+  pcVar13 = (char *)((uVar12 >> 0x38 | (uVar12 & 0xff000000000000) >> 0x28 |

+                      (uVar12 & 0xff0000000000) >> 0x18 | (uVar12 & 0xff00000000) >> 8 |

+                      (uVar12 & 0xff000000) << 8 | (uVar12 & 0xff0000) << 0x18 |

+                      (uVar12 & 0xff00) << 0x28 | uVar12 << 0x38) ^ KiWaitAlways);

+  local_58 = 0;

+  uStack_50 = 0;

+  local_48 = 0;

+  bVar19 = 0xff;

+  if (param_2[0xf] != 0) {

+    lVar10 = (longlong)(int)param_2[0xf] * -10000;

+    bVar19 = 0;

+    if (*(char *)(param_1 + 0x38ba) != '\0') {

+      uVar7 = *(int *)(param_1 + 0x8664) + 1;

+      *(uint *)(param_1 + 0x8664) = uVar7;

+      if (2999 < uVar7) {

+        *(undefined4 *)(param_1 + 0x8664) = 0;

+        if (*(uint *)(param_1 + 0x8668) < 100000000) {

+          *(uint *)(param_1 + 0x8668) = *(uint *)(param_1 + 0x8668) + KeTimeIncrement;

+        }

+      }

+      lVar10 = lVar10 - (ulonglong)*(uint *)(param_1 + 0x8668);

+    }

+    if (-1 < (lVar10 - *(longlong *)(param_2 + 6)) + _DAT_0) {

+      *(longlong *)(param_2 + 6) = _DAT_0;

+    }

+    bVar5 = (byte)(*param_2 >> 8);

+    if (3 < bVar5) {

+      bVar16 = bVar5 >> 2;

+      uVar14 = 8;

+      if (bVar16 < 8) {

+        uVar14 = 0;

+      }

+      sVar8 = (bVar5 >> 5) + 2;

+      if (bVar16 < 8) {

+        sVar8 = (bVar5 >> 5) + 3;

+      }

+      uVar17 = (ulonglong)((uint)((ushort)((uVar14 | bVar16 & 7) << sVar8) >> 3) * 10000);

+    }

+    if (KiGlobalTimerResolutionRequests == 0) {

+      *(undefined2 *)((longlong)param_2 + 0x3a) = 1;

+      puVar20 = *(uint **)(param_2 + 2);

+      do {

+        puVar2 = puVar20;

+        if (puVar2 == param_2 + 2) goto LAB_1;

+        puVar20 = *(uint **)puVar2;

+      } while (((1 < (byte)puVar2[4]) ||

+               ((*(uint *)(*(longlong *)(*(longlong *)(puVar2 + 6) + 0x220) + 500) & 0x1000) == 0))

+              || ((*(uint *)(*(longlong *)(*(longlong *)(puVar2 + 6) + 0x220) + 0x5fc) & 0x4000000)

+                  != 0));

+    }

+    *(undefined2 *)((longlong)param_2 + 0x3a) = 0;

+LAB_1:

+    local_58._0_3_ = (uint3)*param_2 & 0xfffeff;

+    local_58._0_4_ = CONCAT13(0x40,(uint3)local_58);

+    local_58 = (ulonglong)(uint)local_58;

+    do {

+      *(longlong *)(param_2 + 6) = *(longlong *)(param_2 + 6) - lVar10;

+      local_68 = 0;

+      uVar12 = *(ulonglong *)(param_2 + 6) + uVar17;

+      uVar9 = 0xffffffffffffffff;

+      if (*(ulonglong *)(param_2 + 6) <= uVar12) {

+        uVar9 = uVar12;

+      }

+      local_58._0_3_ = CONCAT12((char)(uVar9 >> 0x12),(undefined2)local_58);

+      *param_2 = (uint)local_58;

+      cVar6 = KiInsertTimerTable(param_1,param_2,pcVar13);

+    } while (cVar6 == '\0');

+  }

+  uVar18 = 0;

+  puVar20 = *(uint **)(param_2 + 2);

+  param_2[1] = 1;

+  puVar2 = puVar20;

+  if ((uVar4 & 0x7f) == 8) {

+joined_r0x00014030cdf9:

+    do {

+      if (puVar20 == param_2 + 2) goto LAB_2;

+      puVar2 = *(uint **)puVar20;

+      cVar6 = (char)puVar20[4];

+      if (cVar6 == '\x01') {

+        uVar15 = *(undefined2 *)((longlong)puVar20 + 0x12);

+LAB_3:

+        *(undefined8 *)(puVar11 + -8) = 0x14030ce67;

+        KiTryUnwaitThread(param_1,puVar20,uVar15);

+      }

+      else if (cVar6 == '\x02') {

+        *(undefined1 *)((longlong)puVar20 + 0x11) = 5;

+        uVar18 = *(undefined8 *)(puVar20 + 6);

+        *(undefined8 *)(puVar11 + -8) = 0x14030ce2b;

+        KiInsertQueueInternal(uVar18,puVar20);

+      }

+      else {

+        if (cVar6 != '\x04') {

+          uVar15 = 0x100;

+          goto LAB_3;

+        }

+        *(undefined1 *)((longlong)puVar20 + 0x11) = 5;

+        param_2[1] = (uint)uVar18;

+        uVar18 = *(undefined8 *)(puVar20 + 6);

+        puVar11[0x20] = 0;

+        *(undefined8 *)(puVar11 + -8) = 0x14030ce51;

+        KiInsertQueueDpc(uVar18,param_2,puVar20,0);

+      }

+      uVar18 = 0;

+      puVar20 = puVar2;

+    } while( true );

+  }

+joined_r0x00014030cd24:

+  do {

+    puVar11 = auStack_88;

+    if (puVar2 == param_2 + 2) break;

+    uVar18 = 0;

+    puVar20 = *(uint **)puVar2;

+    if ((*(uint **)(puVar20 + 2) != puVar2) ||

+       (puVar1 = *(undefined8 **)(puVar2 + 2), (uint *)*puVar1 != puVar2)) {

+      pcVar3 = (code *)swi(0x29);

+      (*pcVar3)(3);

+      puVar11 = auStack_80;

+      goto joined_r0x00014030cdf9;

+    }

+    *puVar1 = puVar20;

+    *(undefined8 **)(puVar20 + 2) = puVar1;

+    cVar6 = (char)puVar2[4];

+    if (cVar6 == '\x01') {

+      cVar6 = KiTryUnwaitThread(param_1,puVar2,*(undefined2 *)((longlong)puVar2 + 0x12));

+      puVar2 = puVar20;

+      if (cVar6 == '\0') goto joined_r0x00014030cd24;

+      puVar2 = param_2 + 1;

+      *puVar2 = *puVar2 - 1;

+      uVar4 = *puVar2;

+    }

+    else {

+      if (cVar6 != '\x02') {

+        if (cVar6 == '\x04') {

+          *(undefined1 *)((longlong)puVar2 + 0x11) = 5;

+          param_2[1] = 0;

+          local_68 = local_68 & 0xffffffffffffff00;

+          KiInsertQueueDpc(*(undefined8 *)(puVar2 + 6),param_2,puVar2);

+          puVar2 = puVar20;

+        }

+        else {

+          KiTryUnwaitThread(param_1,puVar2,0x100);

+          puVar2 = puVar20;

+        }

+        goto joined_r0x00014030cd24;

+      }

+      *(undefined1 *)((longlong)puVar2 + 0x11) = 5;

+      KiInsertQueueInternal(*(undefined8 *)(puVar2 + 6),puVar2);

+      puVar2 = param_2 + 1;

+      *puVar2 = *puVar2 - 1;

+      uVar4 = *puVar2;

+    }

+    puVar11 = auStack_88;

+    puVar2 = puVar20;

+  } while (uVar4 != 0);

+LAB_4:

+  if (pcVar13 == (char *)0x0) {

+LAB_5:

+    LOCK();

+    *param_2 = *param_2 & ~((uint)bVar19 << 0x18 | 0x80);

+    UNLOCK();

+  }

+  else {

+    if (param_3 == (uint *)0x0) {

+      param_3 = (uint *)(puVar11 + 0x98);

+      *(ulonglong *)(puVar11 + 0x98) = _DAT_6;

+      uVar12 = _DAT_6;

+    }

+    else {

+      if (((KiSerializeTimerExpiration == 0) || (*(ushort *)(pcVar13 + 2) < 0x800)) &&

+         ((*pcVar13 != '\x1a' || (*(char *)(param_1 + 0x38b8) == '\0')))) {

+        *(char **)(param_1 + 0x3860) = pcVar13;

+        if ((*(ulonglong *)(pcVar13 + 0x10) & *(ulonglong *)(param_1 + 200)) == 0) {

+          LOCK();

+          pcVar13[((longlong)(ulonglong)*(byte *)(param_1 + 0xd1) >> 3) + 0x10] =

+               pcVar13[((longlong)(ulonglong)*(byte *)(param_1 + 0xd1) >> 3) + 0x10] |

+               '\x01' << ((ulonglong)*(byte *)(param_1 + 0xd1) & 7);

+          UNLOCK();

+        }

+        goto LAB_5;

+      }

+      uVar12 = (ulonglong)*param_3;

+    }

+    uVar4 = param_3[1];

+    puVar11[0x20] = bVar19;

+    *(undefined8 *)(puVar11 + -8) = 0x14030cf2b;

+    KiInsertQueueDpc(pcVar13,uVar12 & 0xffffffff,uVar4,param_2);

+    pcVar13 = (char *)0x0;

+  }

+  return pcVar13;

+LAB_2:

+  puVar20 = param_2 + 2;

+  *(uint **)(param_2 + 4) = puVar20;

+  *(uint **)puVar20 = puVar20;

+  goto LAB_4;

 }
```

## `IopCopyCompleteReadRequest`  (modified)

```diff
--- IopCopyCompleteReadRequest
+++ IopCopyCompleteReadRequest
@@ -1,39 +1,42 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void IopCopyCompleteReadRequest(undefined8 param_1,longlong param_2)

+void IopCopyCompleteReadRequest

+               (longlong param_1,undefined8 param_2,undefined8 param_3,longlong *param_4)

 

 {

-  byte bVar1;

-  undefined4 uVar2;

-  byte in_AL;

-  undefined7 in_register_00000001;

-  byte bVar3;

-  longlong unaff_RBX;

-  longlong unaff_RBP;

-  int *unaff_RSI;

-  undefined4 unaff_EDI;

-  undefined4 unaff_0000003c;

+  longlong lVar1;

+  longlong lVar2;

+  void *pvVar3;

+  int iVar4;

+  ulonglong uVar5;

   

-  uVar2 = *(undefined4 *)(CONCAT71(in_register_00000001,in_AL) + -0x75);

-  *(byte *)(unaff_RBX + -0x197ccb90) = *(byte *)(unaff_RBX + -0x197ccb90) | (byte)uVar2;

-  bVar3 = (byte)((uint)uVar2 >> 8);

-  cRame8cf8b1274c00000 = in_AL + bVar3;

-  bVar1 = *(byte *)(unaff_RBX + -0x7e0006);

-  *(byte *)(unaff_RBX + -0x7e0006) = bVar1 << 2 | (byte)(CONCAT11(CARRY1(in_AL,bVar3),bVar1) >> 7);

-  *(char *)CONCAT71(in_register_00000001,cRame8cf8b1274c00000) =

-       *(char *)CONCAT71(in_register_00000001,cRame8cf8b1274c00000) + cRame8cf8b1274c00000;

-  *(char *)(unaff_RBP + 0x26) = *(char *)(unaff_RBP + 0x26) << 1;

-  *unaff_RSI = *unaff_RSI + -1;

-  *(char *)CONCAT71(in_register_00000001,cRame8cf8b1274c00000) =

-       *(char *)CONCAT71(in_register_00000001,cRame8cf8b1274c00000) + cRame8cf8b1274c00000;

-  *(undefined1 *)(param_2 + -0x7f) = 0;

-  *(char *)CONCAT71(in_register_00000001,cRame8cf8b1274c00000) =

-       *(char *)CONCAT71(in_register_00000001,cRame8cf8b1274c00000) + cRame8cf8b1274c00000;

-  *(undefined1 *)

-   (CONCAT71(in_register_00000001,cRame8cf8b1274c00000) + -0x7f + CONCAT44(unaff_0000003c,unaff_EDI)

-   ) = 0;

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  pvVar3 = SystemReserved1[0xf];

+  lVar1 = param_1 + -0x78;

+  lVar2 = *param_4;

+  uVar5 = 0;

+  if ((*(uint *)(lVar2 + 0x50) & 0x4000000) == 0) {

+    KeSetEvent(lVar2 + 0x98,0,0);

+  }

+  *(undefined4 *)(lVar2 + 0x38) = *(undefined4 *)(param_1 + -0x48);

+  if ((*(uint *)(param_1 + -0x68) & 0x2000) != 0) {

+    uVar5 = *(ulonglong *)(param_1 + -0x20) & 0xfffffffffffffff9;

+  }

+  iVar4 = Feature_1042264378__private_IsEnabledDeviceUsageNoInline();

+  if (iVar4 == 0) {

+    IopProcessBufferedIoCompletion(lVar1);

+  }

+  IopUpdateIrpTransferCount(lVar1,uVar5);

+  if ((*(uint *)(param_1 + -0x68) & 0x2000) == 0) {

+    *(void **)(param_1 + 0x20) = pvVar3;

+    IopDequeueIrpFromThread(lVar1);

+  }

+  else {

+    IopDequeueIrpFromFileObject(lVar1,lVar2);

+  }

+  if (*(longlong *)(param_1 + -0x28) != 0) {

+    ObfDereferenceObjectWithTag(*(longlong *)(param_1 + -0x28),0x746c6644);

+    *(undefined8 *)(param_1 + -0x28) = 0;

+  }

+  IopDropIrp(lVar1,lVar2);

+  return;

 }
```

## `AslpFileGetVersionBlockFromResourceRoot`  (modified)

```diff
--- AslpFileGetVersionBlockFromResourceRoot
+++ AslpFileGetVersionBlockFromResourceRoot
@@ -1,59 +1,130 @@
 

-undefined4 AslpFileGetVersionBlockFromResourceRoot(void)

+int AslpFileGetVersionBlockFromResourceRoot

+              (undefined8 *param_1,ulonglong *param_2,longlong param_3,longlong param_4)

 

 {

-  ushort uVar1;

-  int iVar2;

-  uint uVar3;

-  longlong unaff_RBX;

-  longlong unaff_RBP;

-  undefined8 unaff_RDI;

-  undefined4 unaff_R13D;

-  longlong lStack0000000000000028;

+  uint uVar1;

+  undefined8 uVar2;

+  char cVar3;

+  int iVar4;

+  ushort *puVar5;

+  short *psVar6;

+  longlong lVar7;

+  ulonglong uVar8;

+  undefined8 uVar9;

+  char *pcVar10;

+  ulonglong uVar11;

+  undefined8 local_res18;

   

-  lStack0000000000000028 = unaff_RBP + 0x58;

-  iVar2 = AslpFileGetNtHeaderAttributes(unaff_RBP + -0x18);

-  uVar3 = (uint)unaff_RDI;

-  if (iVar2 < 0) {

-    *(uint *)(unaff_RBX + 600) = *(uint *)(unaff_RBX + 600) | uVar3;

+  uVar8 = (ulonglong)*(ushort *)(param_3 + 0xe);

+  uVar11 = 0;

+  uVar9 = *(undefined8 *)(param_4 + 0x20);

+  uVar2 = *(undefined8 *)(param_4 + 0x28);

+  local_res18 = 0;

+  psVar6 = (short *)((ulonglong)*(ushort *)(param_3 + 0xc) * 8 + 0x10 + param_3);

+  iVar4 = 0x10;

+  if (uVar8 != 0) {

+    do {

+      lVar7 = 8;

+      cVar3 = AslpMemoryCheckBounds(psVar6,8,uVar9,uVar2);

+      if (cVar3 == '\0') {

+        uVar9 = 0x86b;

+        goto LAB_0;

+      }

+      iVar4 = (int)lVar7 + 8;

+      if (*psVar6 == (short)iVar4) break;

+      psVar6 = (short *)((longlong)psVar6 + lVar7);

+      uVar11 = uVar11 + 1;

+    } while (uVar11 < uVar8);

   }

-  else {

-    *(ulonglong *)(unaff_RBX + 0x250) = (ulonglong)*(uint *)(unaff_RBP + -0x18);

-    *(ulonglong *)(unaff_RBX + 0x270) = (ulonglong)*(uint *)(unaff_RBP + -0x14);

-    *(ulonglong *)(unaff_RBX + 0x2d0) = (ulonglong)*(uint *)(unaff_RBP + -0x10);

-    *(ulonglong *)(unaff_RBX + 0x30) = (ulonglong)*(uint *)(unaff_RBP + -0xc);

-    *(ulonglong *)(unaff_RBX + 0x3b0) = (ulonglong)*(ushort *)(unaff_RBP + 0x50);

-    *(ulonglong *)(unaff_RBX + 0x3d0) = (ulonglong)*(ushort *)(unaff_RBP + 0x58);

-    *(ulonglong *)(unaff_RBX + 0x3f0) = (ulonglong)*(ushort *)(unaff_RBP + -0x20);

-    uVar1 = *(ushort *)(unaff_RBP + -0x1c);

-    *(uint *)(unaff_RBX + 0x240) = uVar3;

-    *(uint *)(unaff_RBX + 0x260) = uVar3;

-    *(uint *)(unaff_RBX + 0x2c0) = uVar3;

-    *(uint *)(unaff_RBX + 0x20) = uVar3;

-    *(undefined8 *)(unaff_RBX + 0x3a8) = unaff_RDI;

-    *(undefined8 *)(unaff_RBX + 0x3c8) = unaff_RDI;

-    *(undefined8 *)(unaff_RBX + 1000) = unaff_RDI;

-    *(undefined8 *)(unaff_RBX + 0x428) = unaff_RDI;

-    unaff_RDI = 1;

-    *(ulonglong *)(unaff_RBX + 0x430) = (ulonglong)uVar1;

-    *(undefined8 *)(unaff_RBX + 0x248) = 4;

-    *(uint *)(unaff_RBX + 600) = *(uint *)(unaff_RBX + 600) | 1;

-    *(undefined8 *)(unaff_RBX + 0x268) = 4;

-    *(undefined8 *)(unaff_RBX + 0x2c8) = 4;

-    *(undefined8 *)(unaff_RBX + 0x28) = 4;

-    *(undefined4 *)(unaff_RBX + 0x3a0) = 1;

-    *(undefined4 *)(unaff_RBX + 0x3c0) = 1;

-    *(undefined4 *)(unaff_RBX + 0x3e0) = 1;

-    *(undefined4 *)(unaff_RBX + 0x420) = 1;

-    uVar3 = 1;

+  if (uVar11 == uVar8) {

+    return -0x3fffff77;

   }

-  *(uint *)(unaff_RBX + 0x278) = *(uint *)(unaff_RBX + 0x278) | uVar3;

-  *(uint *)(unaff_RBX + 0x3d8) = *(uint *)(unaff_RBX + 0x3d8) | uVar3;

-  *(uint *)(unaff_RBX + 0x3b8) = *(uint *)(unaff_RBX + 0x3b8) | uVar3;

-  *(uint *)(unaff_RBX + 0x38) = *(uint *)(unaff_RBX + 0x38) | uVar3;

-  *(uint *)(unaff_RBX + 0x2d8) = *(uint *)(unaff_RBX + 0x2d8) | uVar3;

-  *(uint *)(unaff_RBX + 0x3f8) = *(uint *)(unaff_RBX + 0x3f8) | (uint)unaff_RDI;

-  *(uint *)(unaff_RBX + 0x438) = *(uint *)(unaff_RBX + 0x438) | uVar3;

-  return unaff_R13D;

+  if ((int)*(uint *)(psVar6 + 2) < 0) {

+    lVar7 = (ulonglong)(*(uint *)(psVar6 + 2) & 0x7fffffff) + param_3;

+    cVar3 = AslpMemoryCheckBounds(lVar7,iVar4,uVar9,uVar2);

+    if (cVar3 == '\0') {

+      pcVar10 = "Found resource directory out of image bounds";

+      uVar9 = 0x886;

+      goto LAB_1;

+    }

+    if ((*(short *)(lVar7 + 0xe) == 0) && (*(short *)(lVar7 + 0xc) == 0)) {

+      return -0x3fffff77;

+    }

+    psVar6 = (short *)(lVar7 + 0x10);

+    cVar3 = AslpMemoryCheckBounds(psVar6,8);

+    if (cVar3 == '\0') {

+      uVar9 = 0x890;

+LAB_0:

+      pcVar10 = "Found resource directory entry out of image bounds";

+      goto LAB_1;

+    }

+    if ((int)*(uint *)(psVar6 + 2) < 0) {

+      lVar7 = (ulonglong)(*(uint *)(psVar6 + 2) & 0x7fffffff) + param_3;

+      cVar3 = AslpMemoryCheckBounds(lVar7,0x10);

+      if (cVar3 == '\0') {

+        pcVar10 = "Found resource directory out of image bounds";

+        uVar9 = 0x89b;

+        goto LAB_1;

+      }

+      if ((*(short *)(lVar7 + 0xe) == 0) && (*(short *)(lVar7 + 0xc) == 0)) {

+        return -0x3fffff77;

+      }

+      psVar6 = (short *)(lVar7 + 0x10);

+      cVar3 = AslpMemoryCheckBounds(psVar6,8);

+      if (cVar3 == '\0') {

+        uVar9 = 0x8a5;

+        goto LAB_0;

+      }

+    }

+  }

+  uVar1 = *(uint *)(psVar6 + 2);

+  cVar3 = AslpMemoryCheckBounds((ulonglong)uVar1 + param_3,0x10,uVar9,uVar2);

+  if (cVar3 == '\0') {

+    pcVar10 = "Found resource data entry out of image bounds";

+    uVar9 = 0x8b3;

+    goto LAB_1;

+  }

+  iVar4 = AslpFileGetImageNtHeader(&local_res18,param_4);

+  if (-1 < iVar4) {

+    cVar3 = AslpMemoryCheckBounds(local_res18,8,uVar9,uVar2);

+    if (cVar3 != '\0') {

+      puVar5 = (ushort *)AslpImageRvaToVa();

+      cVar3 = AslpMemoryCheckBounds(puVar5,0x26,uVar9,uVar2);

+      if (cVar3 == '\0') {

+        pcVar10 = "Found version block root but it was out of image bounds";

+        uVar9 = 0x8c3;

+      }

+      else {

+        iVar4 = Feature_261863737__private_IsEnabledDeviceUsageNoInline();

+        if (iVar4 == 0) {

+LAB_2:

+          *param_1 = puVar5;

+          *param_2 = (ulonglong)*puVar5;

+          return 0;

+        }

+        cVar3 = AslpMemoryCheckBounds

+                          (puVar5,0x26,puVar5,*(undefined4 *)((ulonglong)uVar1 + param_3 + 4));

+        if (cVar3 == '\0') {

+          pcVar10 = "Found version block root but it was out of resource bounds";

+          uVar9 = 0x8c9;

+        }

+        else {

+          cVar3 = AslpMemoryCheckBounds();

+          if (cVar3 != '\0') goto LAB_2;

+          pcVar10 = "Found version block with invalid total length";

+          uVar9 = 0x8ce;

+        }

+      }

+LAB_1:

+      AslLogCallPrintf(1,"AslpFileGetVersionBlockFromResourceRoot",uVar9,pcVar10);

+      return -0x3ffffdd2;

+    }

+    iVar4 = -0x3ffffdd2;

+  }

+  AslLogCallPrintf(1,"AslpFileGetVersionBlockFromResourceRoot",0x8bd,

+                   "AslpFileGetImageNtHeader failed to get image headers or headers are out of bounds [%x]"

+                   ,iVar4);

+  return iVar4;

 }
```

## `MiLocateCombineBlock`  (modified)

```diff
--- MiLocateCombineBlock
+++ MiLocateCombineBlock
@@ -1,29 +1,50 @@
 

-undefined8 * MiLocateCombineBlock(ulonglong param_1,int param_2)

+undefined8 *

+MiLocateCombineBlock(longlong param_1,ulonglong param_2,uint param_3,int param_4,ulonglong *param_5)

 

 {

-  undefined1 uVar1;

-  undefined8 *puVar2;

+  undefined8 *puVar1;

+  undefined1 uVar2;

+  int iVar3;

+  undefined8 *puVar4;

+  undefined8 *puVar5;

   

-  if (param_2 == 0) {

-    uVar1 = ExAcquireSpinLockShared(&DAT_0);

-    puVar2 = DAT_1;

+  iVar3 = Feature_Servicing_Mm_LocateCombineBlockFix__private_IsEnabledDeviceUsageNoInline();

+  puVar4 = (undefined8 *)0x0;

+  puVar5 = (undefined8 *)(((ulonglong)((uint)param_2 & 0xf) + 6) * 0x10 + param_1);

+  if (param_4 == 0) {

+    uVar2 = ExAcquireSpinLockShared(puVar5 + 1);

   }

   else {

-    uVar1 = 0x11;

-    ExAcquireSpinLockSharedAtDpcLevel();

-    puVar2 = DAT_1;

+    uVar2 = 0x11;

   }

-  while (puVar2 != (undefined8 *)0x0) {

-    if ((ulonglong)puVar2[3] < param_1) {

-      puVar2 = (undefined8 *)puVar2[1];

+  puVar1 = (undefined8 *)*puVar5;

+  while (puVar1 != (undefined8 *)0x0) {

+    if ((ulonglong)puVar1[3] < param_2) {

+LAB_0:

+      puVar1 = (undefined8 *)puVar1[1];

     }

     else {

-      if ((ulonglong)puVar2[4] <= param_1) break;

-      puVar2 = (undefined8 *)*puVar2;

+      if ((ulonglong)puVar1[3] <= param_2) {

+        if (((uint)puVar1[6] & 0x1f) < param_3) goto LAB_0;

+        if (((uint)puVar1[6] & 0x1f) <= param_3) {

+          if (param_5 == (ulonglong *)0x0) break;

+          if ((ulonglong)puVar1[8] < *param_5) goto LAB_0;

+          if ((ulonglong)puVar1[8] <= *param_5) break;

+        }

+      }

+      puVar1 = (undefined8 *)*puVar1;

     }

   }

-  MiReleaseSpinLockShared(&DAT_0,uVar1);

-  return puVar2;

+  if ((iVar3 != 0) && (puVar1 != (undefined8 *)0x0)) {

+    puVar4 = (undefined8 *)(-(ulonglong)(puVar1[7] != 0) & (ulonglong)puVar1);

+  }

+  if (param_4 == 0) {

+    MiReleaseSpinLockShared(puVar5 + 1,uVar2);

+  }

+  if ((iVar3 == 0) && ((puVar1 == (undefined8 *)0x0 || (puVar4 = puVar1, puVar1[7] == 0)))) {

+    puVar4 = (undefined8 *)0x0;

+  }

+  return puVar4;

 }
```

## `IopSynchronousServiceTail`  (modified)

```diff
--- IopSynchronousServiceTail
+++ IopSynchronousServiceTail
@@ -1,20 +1,165 @@
 

-/* WARNING: Control flow encountered bad instruction data */

+/* WARNING: Function: _guard_dispatch_icall replaced with injection: guard_dispatch_icall */

 

-void IopSynchronousServiceTail(undefined8 param_1,undefined2 param_2)

+uint IopSynchronousServiceTail

+               (longlong param_1,longlong param_2,longlong param_3,char param_4,undefined1 param_5,

+               char param_6,uint param_7)

 

 {

-  char *pcVar1;

-  char in_AL;

-  undefined7 in_register_00000001;

-  longlong unaff_RDI;

+  byte *pbVar1;

+  uint *puVar2;

+  code *pcVar3;

+  char cVar4;

+  int iVar5;

+  longlong lVar6;

+  undefined8 uVar7;

+  longlong lVar8;

+  undefined8 uVar9;

+  uint uVar10;

+  ulonglong in_CR8;

+  uint local_res10 [2];

+  longlong local_res18;

+  char local_res20;

+  uint *in_stack_ffffffffffffff98;

+  undefined4 uVar12;

+  ulonglong uVar11;

+  undefined8 local_58;

+  longlong local_50;

+  undefined1 local_48 [16];

   

-  *(char *)CONCAT71(in_register_00000001,in_AL) =

-       *(char *)CONCAT71(in_register_00000001,in_AL) + in_AL;

-  pcVar1 = (char *)(unaff_RDI + 0xf + CONCAT71(in_register_00000001,in_AL) * 2);

-  *pcVar1 = *pcVar1 + (char)((ushort)param_2 >> 8);

-  in(param_2);

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  uVar7 = 0;

+  local_res10[0] = 0;

+  pbVar1 = (byte *)(param_2 + 0x47);

+  if ((*(ulonglong *)(param_2 + 0x58) & 1) != 0) {

+    *pbVar1 = *pbVar1 | 0x10;

+    *(ulonglong *)(param_2 + 0x58) = *(ulonglong *)(param_2 + 0x58) & 0xfffffffffffffffe;

+  }

+  local_50 = *(longlong *)(param_3 + 0xb0);

+  uVar10 = *(uint *)(param_2 + 0x10) & 0x200000;

+  local_res18 = param_3;

+  local_res20 = param_4;

+  iVar5 = Feature_3043197241__private_IsEnabledDeviceUsageNoInline();

+  if (iVar5 == 0) {

+    if (((param_6 == '\0') && (*(longlong *)(param_2 + 0x58) == 0)) || (uVar10 != 0)) {

+      if (uVar10 == 0) {

+        if (((*(longlong *)(param_2 + 0x60) != 0) && (*(longlong *)(param_2 + 0x50) == 0)) &&

+           (*(longlong *)(param_3 + 0xb0) != 0)) {

+          uVar9 = 1;

+          goto LAB_0;

+        }

+        if ((((*(uint *)(param_2 + 0x10) & 0x10) != 0) || (*(longlong *)(param_3 + 0xb0) != 0)) ||

+           (*(longlong *)(param_3 + 0xd0) == 0)) goto LAB_1;

+        cVar4 = IopIsIosbInLockedRange(param_3,param_2);

+      }

+      else {

+        uVar9 = 0;

+LAB_0:

+        cVar4 = IopQueueIrpToFileObject(param_2,param_3,uVar9);

+      }

+      if (cVar4 != '\0') goto LAB_2;

+    }

+    else if ((*(uint *)(param_3 + 0x50) & 2) != 0) {

+      *(byte *)(param_2 + 0x47) = *(byte *)(param_2 + 0x47) | 2;

+    }

+LAB_1:

+    IopQueueThreadIrp(param_2);

+  }

+  else if (((((((*(uint *)(param_2 + 0x10) >> 9 & 1) == 0) || ((char)*pbVar1 < '\0')) ||

+             (*(longlong *)(param_2 + 200) == 0)) ||

+            ((*(ushort *)(*(longlong *)(param_2 + 200) + 2) >> 9 & 1) == 0)) &&

+           ((IopQueueIrpForServiceTail(param_2,param_3,param_6),

+            (*(uint *)(param_2 + 0x10) & 0x100) != 0 && (-1 < *(char *)(param_2 + 0x47))))) &&

+          ((*(longlong *)(param_2 + 200) != 0 &&

+           ((*(ushort *)(*(longlong *)(param_2 + 200) + 2) >> 9 & 1) != 0)))) {

+    IopQueuePairedCopyWriteIrp(param_2);

+  }

+LAB_2:

+  if (((*(uint **)(param_3 + 0xd0) != (uint *)0x0) && ((**(uint **)(param_3 + 0xd0) & 4) != 0)) &&

+     (cVar4 = PsIsProcessAppContainer(*(undefined8 *)((longlong)SystemReserved1[0xf] + 0xb8)),

+     cVar4 != '\0')) {

+    local_res10[0] = 0xc0000910;

+    *(undefined4 *)(param_2 + 0x30) = 0xc0000910;

+    IofCompleteRequest(param_2,0);

+    lVar8 = local_res18;

+    goto LAB_3;

+  }

+  if (param_7 < 2) {

+    iVar5 = *(int *)(param_1 + 0x48);

+    if ((((iVar5 == 7) || (iVar5 == 8)) || (iVar5 == 9)) || (iVar5 == 0x24)) {

+      IoSetDiskIoAttributionFromThread(param_2,SystemReserved1[0xf]);

+    }

+    if (param_7 == 0) {

+      *(longlong *)((longlong)SystemReserved1[0xf] + 0x380) =

+           *(longlong *)((longlong)SystemReserved1[0xf] + 0x380) + 1;

+      lVar6 = 0x2edc;

+    }

+    else {

+      *(longlong *)((longlong)SystemReserved1[0xf] + 0x388) =

+           *(longlong *)((longlong)SystemReserved1[0xf] + 0x388) + 1;

+      lVar6 = 12000;

+    }

+  }

+  else {

+    *(longlong *)((longlong)SystemReserved1[0xf] + 0x390) =

+         *(longlong *)((longlong)SystemReserved1[0xf] + 0x390) + 1;

+    lVar6 = 0x2ee4;

+  }

+  lVar8 = local_res18;

+  uVar12 = (undefined4)((ulonglong)in_stack_ffffffffffffff98 >> 0x20);

+  *(int *)(lVar6 + 0xff00000000) = *(int *)(lVar6 + 0xff00000000) + 1;

+  if ((((*(uint *)(local_res18 + 0x50) & 0x800000) == 0) || (param_7 != 0)) ||

+     (((*(byte *)(*(longlong *)(local_res18 + 0x10) + 4) & 0x40) != 0 ||

+      ((*(longlong *)(local_res18 + 0x18) == 0 ||

+       ((*(byte *)(*(longlong *)(local_res18 + 0x18) + 6) & 0x20) != 0)))))) {

+LAB_4:

+    uVar11 = CONCAT44(uVar12,param_7);

+  }

+  else {

+    IopSetIrpPriorityHintFromFileObject(local_res18,param_2);

+    iVar5 = IoGetIoPriorityHint(param_2);

+    uVar12 = (undefined4)((ulonglong)in_stack_ffffffffffffff98 >> 0x20);

+    if ((iVar5 < 2) || ((DAT_5 & 4) != 0)) goto LAB_1408c1ef5;

+    lVar6 = IoGetBaseFileSystemDeviceObject(lVar8);

+    puVar2 = *(uint **)(*(longlong *)(lVar6 + 8) + 0x50);

+    if ((0xef < *puVar2) && (pcVar3 = *(code **)(puVar2 + 0x38), pcVar3 != (code *)0x0)) {

+      in_stack_ffffffffffffff98 = local_res10;

+      cVar4 = (*pcVar3)(lVar6,param_2,param_6,lVar8,in_stack_ffffffffffffff98);

+      if (cVar4 != '\0') goto LAB_3;

+    }

+    uVar11 = (ulonglong)in_stack_ffffffffffffff98 & 0xffffffff00000000;

+  }

+  local_res10[0] = IopCallDriverReference(param_1,param_2,param_6,lVar8,uVar11);

+LAB_3:

+  if ((local_res20 != '\0') && (local_res10[0] != 0x103)) {

+    if (uVar10 == 0) {

+      local_58 = 0;

+      uVar7 = 1;

+      if (KiIrqlFlags != 0) {

+        KiRaiseIrqlProcessIrqlFlags(in_CR8 & 0xff,1);

+      }

+      IopCompleteRequest(param_2 + 0x78,local_48,&local_58,&local_res18,&local_58);

+      if (KiIrqlFlags != 0) {

+        KiLowerIrqlProcessIrqlFlags(uVar7,in_CR8 & 0xff);

+      }

+    }

+    else {

+      if ((*(int *)(param_1 + 0x48) == 8) || (*(int *)(param_1 + 0x48) == 0x14)) {

+        uVar7 = 1;

+      }

+      IopIoRingCompleteIrp(param_2,lVar8,uVar7);

+    }

+  }

+  if (param_6 == '\0') {

+    if ((uVar10 != 0) || ((local_50 != 0 && ((local_res10[0] & 0xc0000000) == 0x80000000)))) {

+      local_res10[0] = 0x103;

+    }

+  }

+  else {

+    if (local_res10[0] == 0x103) {

+      local_res10[0] = IopWaitForSynchronousIo(param_2,lVar8,param_5);

+    }

+    IopReleaseFileObjectLock(lVar8);

+  }

+  return local_res10[0];

 }
```

## `KiComputeDueTime`  (modified)

```diff
--- KiComputeDueTime
+++ KiComputeDueTime
@@ -1,63 +1,59 @@
 

-undefined8 KiComputeDueTime(void)

+/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

+

+undefined8 KiComputeDueTime(uint *param_1,longlong param_2,byte param_3,uint *param_4)

 

 {

-  uint uVar1;

-  uint *puVar2;

-  char cVar3;

-  uint uVar4;

-  longlong unaff_RBX;

-  longlong unaff_RSI;

-  undefined8 unaff_RDI;

-  longlong unaff_R12;

-  ulonglong unaff_R14;

-  int unaff_R15D;

-  bool bVar5;

-  bool bVar6;

+  undefined2 uVar1;

+  uint uVar2;

+  sbyte sVar3;

+  ulonglong uVar4;

+  ulonglong uVar5;

+  ulonglong uVar6;

+  ushort uVar7;

+  byte bVar8;

+  undefined4 local_28;

   

-  bVar5 = unaff_R15D != 0;

-  if (unaff_RSI != unaff_RBX + 0x40) {

-    *(longlong *)(unaff_RSI + 0x18) = unaff_RBX;

+  uVar1 = (undefined2)(*param_1 >> 0x10);

+  local_28._0_1_ = (undefined1)*param_1;

+  local_28._0_2_ = CONCAT11(param_3,(undefined1)local_28);

+  local_28 = CONCAT22(uVar1,(undefined2)local_28);

+  if (-1 < param_2) {

+    uVar2 = CONCAT22(uVar1,CONCAT11(param_3,(undefined1)local_28)) | 0x100;

+    param_2 = _DAT_0 - param_2;

+    if (-1 < param_2) {

+      *param_1 = uVar2;

+      param_1[6] = 0;

+      param_1[7] = 0;

+      return 0;

+    }

+    local_28._1_1_ = (byte)(uVar2 >> 8);

+    param_3 = local_28._1_1_;

+    local_28 = uVar2;

   }

-  *(undefined4 *)(unaff_RSI + 0x20) = 1;

-  *(ulonglong *)(unaff_RSI + 0x10) = CONCAT71((int7)((ulonglong)unaff_RDI >> 8),bVar5) | unaff_R14;

-  ExpSaveAbHandle();

-  if (bVar5) {

-    KeAcquireSpinLockAtDpcLevel(unaff_R14 + 0x6c8);

-    ExpAddFastOwnerEntryToThreadList();

-    KxReleaseSpinLock(unaff_R14 + 0x6c8);

+  uVar5 = 0;

+  bVar8 = param_3 >> 2;

+  if (param_3 >> 2 != 0) {

+    uVar7 = 8;

+    if (bVar8 < 8) {

+      uVar7 = 0;

+    }

+    sVar3 = (param_3 >> 5) + 2;

+    if (bVar8 < 8) {

+      sVar3 = (param_3 >> 5) + 3;

+    }

+    uVar5 = (ulonglong)((uint)((ushort)((uVar7 | bVar8 & 7) << sVar3) >> 3) * 10000);

   }

-  else {

-    ExpAddFastOwnerEntryToThreadList();

+  uVar6 = _DAT_1 - param_2;

+  *(ulonglong *)(param_1 + 6) = uVar6;

+  uVar4 = 0xffffffffffffffff;

+  if (uVar6 <= uVar6 + uVar5) {

+    uVar4 = uVar6 + uVar5;

   }

-  puVar2 = *(uint **)((longlong)FiberData + 0x8eb8);

-  if (puVar2 != (uint *)0x0) {

-    uVar4 = *puVar2;

-    do {

-      LOCK();

-      uVar1 = *puVar2;

-      bVar6 = uVar4 == uVar1;

-      if (bVar6) {

-        *puVar2 = uVar4 & 0xffdfffff;

-        uVar1 = uVar4;

-      }

-      uVar4 = uVar1;

-      UNLOCK();

-    } while (!bVar6);

-    if ((uVar4 >> 0x15 & 1) != 0) {

-      KiRemoveSystemWorkPriorityKick();

-    }

-  }

-  if (bVar5) {

-    if (unaff_R12 != 0) {

-      KeAbMarkCrossThreadReleasable();

-    }

-    ObfReferenceObjectWithTag();

-  }

-  cVar3 = ExIsFastResourceHeldExclusive();

-  if (cVar3 != '\0') {

-    ExFreePoolWithTag();

-  }

+  uVar2 = local_28 >> 0x18;

+  local_28._0_3_ = CONCAT12((char)(uVar4 >> 0x12),(undefined2)local_28);

+  *param_4 = (uint)(uVar4 >> 0x12) & 0xff;

+  *param_1 = CONCAT13((char)uVar2,(undefined3)local_28) | 0x40000000;

   return 1;

 }
```

## `PopBatteryUpdateTestExempt`  (modified)

```diff
--- PopBatteryUpdateTestExempt
+++ PopBatteryUpdateTestExempt
@@ -1,27 +1,146 @@
 

-undefined4 PopBatteryUpdateTestExempt(void)

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+

+undefined8 PopBatteryUpdateTestExempt(byte param_1)

 

 {

-  undefined1 unaff_BL;

-  undefined4 unaff_ESI;

-  undefined1 unaff_DIL;

-  undefined4 unaff_R15D;

+  longlong *plVar1;

+  longlong lVar2;

+  longlong *plVar3;

+  code *pcVar4;

+  longlong *plVar5;

+  undefined8 *puVar6;

+  undefined8 *puVar7;

+  undefined1 *puVar8;

+  char cVar9;

+  undefined1 auStack_78 [8];

+  undefined1 auStack_70 [24];

+  undefined8 local_58;

+  undefined1 *local_50;

+  undefined4 local_48 [2];

+  undefined1 local_40 [32];

+  undefined4 *local_20;

+  undefined4 local_18;

+  undefined4 local_14;

+  ulonglong local_10;

   

-  LOCK();

-  PopPowerButtonSuppressionActionCount = PopPowerButtonSuppressionActionCount + 1;

-  UNLOCK();

-  PopAcquireRwLockExclusive(&PopPowerButtonSuppressionLock);

-  PopTracePowerButtonSuppressionActionUpdate

-            (DAT_0,DAT_140f088c4,DAT_140f088c8,DAT_140f088d8,

-             PopPowerButtonSuppressionActionCount);

-  PopReleaseRwLock(&PopPowerButtonSuppressionLock);

-  if (PopBsdSkipLogging == '\0') {

-    PopAcquireRwLockExclusive(&PopBsdUpdateLock);

-    DAT_1 = unaff_DIL;

-    DAT_2 = unaff_BL;

-    PopBsdHandleRequest(unaff_R15D);

-    PopReleaseRwLock(&PopBsdUpdateLock);

+  puVar8 = auStack_78;

+  local_10 = __security_cookie ^ (ulonglong)auStack_78;

+  cVar9 = '\0';

+  PopAcquireRwLockExclusive(&PopCB);

+  if (PopBatteryTestExemptPolicy != param_1) {

+    PopBatteryTestExemptPolicy = (uint)param_1;

+    PopBatteryTestExemptPolicyRegKeyAccess(1);

+    puVar6 = DAT_0;

+    puVar8 = auStack_78;

+    if (PopBatteryTestExemptPolicy == 0) {

+LAB_1:

+      for (; puVar7 = DAT_2, (undefined8 **)puVar6 != &DAT_140f0b540;

+          puVar6 = (undefined8 *)*puVar6) {

+        if (((*(uint *)(puVar6 + 0xe) & 0x10) == 0) && (puVar6[8] == 0)) {

+          *(undefined8 *)(puVar8 + -8) = 0x14075aaeb;

+          PopBatteryWaitTag(puVar6);

+          cVar9 = '\x01';

+          if (5 < DAT_3) {

+            local_48[0] = *(undefined4 *)((longlong)puVar6 + 0x6c);

+            local_14 = 0;

+            local_20 = local_48;

+            local_18 = 4;

+            *(undefined1 **)(puVar8 + 0x28) = local_40;

+            *(undefined4 *)(puVar8 + 0x20) = 3;

+            *(undefined8 *)(puVar8 + -8) = 0x14075ab3a;

+            _tlgWriteTransfer_EtwWriteTransfer(&DAT_3,&DAT_14004c56b,0,0);

+          }

+        }

+      }

+      for (; (undefined8 **)puVar7 != &DAT_2; puVar7 = (undefined8 *)*puVar7) {

+        *(undefined8 *)(puVar8 + -8) = 0x14075ab5a;

+        PopPowerAdapterReinitialize(puVar7);

+      }

+      if ((cVar9 != '\0') && ((longlong **)DAT_4 == &DAT_4)) {

+        *(undefined8 *)(puVar8 + -8) = 0x14075ab7c;

+        PopAcquirePolicyLock();

+        *(undefined8 *)(puVar8 + -8) = 0x14075ab8a;

+        PopChangeCapability(&DAT_5,1);

+        *(undefined8 *)(puVar8 + -8) = 0x14075ab8f;

+        PopReleasePolicyLock();

+        *(undefined8 *)(puVar8 + -8) = 0x14075ab94;

+        PopCadNotifyBatteryPresence();

+      }

+    }

+    else {

+      cVar9 = 'P';

+      plVar5 = DAT_4;

+      if ((longlong **)DAT_4 != &DAT_4) {

+        do {

+          plVar1 = (longlong *)*plVar5;

+          if ((*(uint *)(plVar5 + 6) & 0x10) == 0) {

+            IoCancelIrp(plVar5[-1]);

+            local_58 = 0;

+            KeWaitForMutexObject(plVar5 + 2,0);

+            lVar2 = *plVar5;

+            if ((*(longlong **)(lVar2 + 8) != plVar5) ||

+               (plVar3 = (longlong *)plVar5[1], (longlong *)*plVar3 != plVar5)) {

+              pcVar4 = (code *)swi(0x29);

+              (*pcVar4)(3);

+              puVar8 = auStack_70;

+              puVar6 = DAT_0;

+              goto LAB_1;

+            }

+            *plVar3 = lVar2;

+            *(longlong **)(lVar2 + 8) = plVar3;

+            *plVar5 = 0;

+            DAT_6 = DAT_6 + -1;

+            DAT_7 = 1;

+            if (5 < DAT_3) {

+              local_48[0] = *(undefined4 *)((longlong)plVar5 + 0x2c);

+              local_14 = 0;

+              local_20 = local_48;

+              local_18 = 4;

+              local_50 = local_40;

+              local_58 = CONCAT44(local_58._4_4_,3);

+              _tlgWriteTransfer_EtwWriteTransfer(&DAT_3,&DAT_14004c75a,0,0);

+            }

+            PopBatteryQueueWork(3);

+          }

+          else if (5 < DAT_3) {

+            local_48[0] = *(undefined4 *)((longlong)plVar5 + 0x2c);

+            local_14 = 0;

+            local_20 = local_48;

+            local_18 = 4;

+            local_50 = local_40;

+            local_58 = CONCAT44(local_58._4_4_,3);

+            _tlgWriteTransfer_EtwWriteTransfer(&DAT_3,&DAT_14004c797,0,0);

+          }

+          plVar5 = plVar1;

+        } while ((longlong **)plVar1 != &DAT_4);

+      }

+      lVar2 = DAT_8;

+      if ((DAT_8 != 0) && (*(int *)(DAT_8 + 0x80) == 1)) {

+        IoCancelIrp(*(undefined8 *)(DAT_8 + 0x38));

+        local_58 = 0;

+        KeWaitForMutexObject(lVar2 + 0x68,0,0,0);

+        DAT_8 = 0;

+        if (5 < DAT_3) {

+          local_50 = local_40;

+          local_58 = CONCAT44(local_58._4_4_,2);

+          _tlgWriteTransfer_EtwWriteTransfer(&DAT_3,&DAT_14004c7c5,0,0);

+        }

+      }

+      puVar8 = auStack_78;

+      if ((longlong **)DAT_4 == &DAT_4) {

+        PopAcquirePolicyLock();

+        PopChangeCapability(&DAT_5,0);

+        PopReleasePolicyLock();

+        puVar8 = auStack_78;

+      }

+    }

+    *(undefined8 *)(puVar8 + -8) = 0x14075ab9e;

+    PopBatteryQueueWork(8);

   }

-  return unaff_ESI;

+  *(undefined8 *)(puVar8 + -8) = 0x14075abaa;

+  PopReleaseRwLock(&PopCB);

+  *(undefined8 *)(puVar8 + -8) = 0x14075abb8;

+  return 0;

 }
```

## `IopCopyCompleteReadIrp`  (modified)

```diff
--- IopCopyCompleteReadIrp
+++ IopCopyCompleteReadIrp
@@ -1,13 +1,175 @@
 

-undefined8 IopCopyCompleteReadIrp(undefined8 param_1,undefined8 param_2)

+undefined1 IopCopyCompleteReadIrp(undefined8 *param_1,undefined8 param_2,ulonglong param_3)

 

 {

-  char *in_RAX;

-  longlong unaff_RDI;

-  char in_CF;

+  char cVar1;

+  ushort uVar2;

+  uint uVar3;

+  void *pvVar4;

+  longlong lVar5;

+  undefined8 *puVar6;

+  undefined8 *puVar7;

+  longlong lVar8;

+  longlong lVar9;

+  code *pcVar10;

+  undefined8 *puVar11;

+  undefined1 uVar12;

+  char cVar13;

+  int iVar14;

+  uint uVar15;

+  uint uVar16;

+  uint uVar17;

+  undefined1 *puVar18;

+  undefined1 *puVar19;

+  undefined1 uVar20;

+  undefined1 in_CR8;

+  undefined8 uVar21;

+  undefined8 local_res10;

+  undefined4 local_res18;

+  undefined1 local_res20;

+  undefined1 auStack_98 [8];

+  undefined1 auStack_90 [24];

+  code *local_78;

+  undefined8 local_70;

+  undefined1 local_68;

+  undefined8 local_60;

+  undefined4 local_58;

   

-  *in_RAX = *in_RAX + (char)in_RAX + in_CF;

-  *(char *)(unaff_RDI + 0xf) = *(char *)(unaff_RDI + 0xf) + (char)((ulonglong)param_2 >> 8);

-  return 0;

+  local_res18 = (undefined4)param_3;

+  puVar18 = auStack_98;

+  param_1 = (undefined8 *)*param_1;

+  uVar20 = 0;

+  param_3 = param_3 & 0xffffffff;

+  local_58 = *(undefined4 *)(param_1 + 6);

+  uVar3 = *(uint *)(param_1 + 7);

+  cVar1 = *(char *)((longlong)param_1 + 0x44);

+  pvVar4 = (void *)param_1[0x13];

+  lVar5 = param_1[0xe];

+  local_res20 = *(undefined1 *)((longlong)param_1 + 0x41);

+  local_res10 = param_2;

+  if (param_1[1] != 0) {

+    IopUnlockAndFreeMdl();

+    param_1[1] = 0;

+  }

+  iVar14 = Feature_1042264378__private_IsEnabledDeviceUsageNoInline();

+  if (iVar14 != 0) {

+    IopProcessBufferedIoCompletion(param_1);

+  }

+  if (pvVar4 != (void *)0x0) {

+    uVar12 = KeAcquireSpinLockRaiseToDpc((longlong)pvVar4 + 0x618);

+    KeReleaseSpinLock((longlong)pvVar4 + 0x618,uVar12);

+  }

+  if (((pvVar4 == SystemReserved1[0xf]) && (cVar13 = KeAreAllApcsDisabled(), cVar13 == '\0')) &&

+     (*(char *)((longlong)SystemReserved1[0xf] + 0x24a) != '\x01')) {

+    if (cVar1 == '\0') {

+      uVar21 = 1;

+      if (KiIrqlFlags != 0) {

+        KiRaiseIrqlProcessIrqlFlags(in_CR8,1);

+      }

+      local_78 = (code *)0x0;

+      IopCopyCompleteReadRequest(param_1 + 0xf,0,0,&local_res10);

+      puVar19 = auStack_98;

+      if (KiIrqlFlags != 0) {

+        KiLowerIrqlProcessIrqlFlags(uVar21,in_CR8);

+        puVar19 = auStack_98;

+      }

+      goto LAB_0;

+    }

+LAB_1:

+    uVar12 = KeAcquireQueuedSpinLock(0xb);

+    param_3 = CONCAT71((int7)(param_3 >> 8),uVar12);

+    puVar6 = IopDeadIrps;

+    do {

+      puVar11 = puVar6;

+      if ((undefined8 **)puVar11 == &IopDeadIrps) {

+        if (pvVar4 == (void *)0x0) goto LAB_2;

+        local_60 = 0;

+        local_68 = 0;

+        local_70 = 0;

+        local_78 = IopCopyAbortCopyReadRequest;

+        KeInitializeApc(param_1 + 0xf,pvVar4,(int)*(char *)((longlong)param_1 + 0x46),

+                        IopCopyCompleteReadRequest);

+        KeInsertQueueApc(param_1 + 0xf,local_res10,0,local_res18);

+        KeReleaseQueuedSpinLock(0xb,uVar12);

+        puVar19 = auStack_98;

+        goto LAB_0;

+      }

+      puVar6 = (undefined8 *)*puVar11;

+    } while (puVar11 + -4 != param_1);

+    if (((undefined8 *)puVar6[1] == puVar11) &&

+       (puVar7 = (undefined8 *)puVar11[1], (undefined8 *)*puVar7 == puVar11)) {

+      *puVar7 = puVar6;

+      puVar6[1] = puVar7;

+      puVar11[1] = puVar11;

+      *puVar11 = puVar11;

+      ObfDereferenceObjectWithTag(pvVar4,0x746c6644);

+LAB_2:

+      KeReleaseQueuedSpinLock(0xb,uVar12);

+      IopDropIrp(param_1,local_res10);

+      puVar19 = auStack_98;

+      goto LAB_0;

+    }

+    pcVar10 = (code *)swi(0x29);

+    (*pcVar10)(3);

+    puVar18 = auStack_90;

+  }

+  else if (cVar1 != '\0') goto LAB_1;

+  cVar13 = *(char *)((longlong)param_1 + 0x46);

+  *(undefined8 *)(puVar18 + 0x38) = 0;

+  puVar18[0x30] = 0;

+  *(undefined8 *)(puVar18 + 0x28) = 0;

+  *(code **)(puVar18 + 0x20) = IopCopyAbortCopyReadRequest;

+  *(undefined8 *)(puVar18 + -8) = 0x1404dc445;

+  KeInitializeApc(param_1 + 0xf,pvVar4,(int)cVar13,IopCopyCompleteReadRequest);

+  *(undefined8 *)(puVar18 + -8) = 0x1404dc45c;

+  KeInsertQueueApc(param_1 + 0xf,*(undefined8 *)(puVar18 + 0xa8),0,param_3);

+  puVar19 = puVar18;

+LAB_0:

+  iVar14 = *(int *)(puVar19 + 0x40);

+  if ((iVar14 < 0) || (cVar1 != '\0')) {

+    lVar8 = *(longlong *)(lVar5 + -0x30);

+    if ((*(ulonglong *)(lVar8 + 0x58) & 1) != 0) {

+      *(byte *)(lVar8 + 0x47) = *(byte *)(lVar8 + 0x47) | 0x10;

+      *(ulonglong *)(lVar8 + 0x58) = *(ulonglong *)(lVar8 + 0x58) & 0xfffffffffffffffe;

+    }

+    uVar12 = puVar19[0xb8];

+    *(int *)(*(longlong *)(lVar5 + -0x30) + 0x30) = iVar14;

+    *(undefined1 *)(*(longlong *)(lVar5 + -0x30) + 0x41) = uVar12;

+    uVar21 = *(undefined8 *)(lVar5 + -0x30);

+    **(undefined8 **)(puVar19 + 0xa0) = uVar21;

+    *(undefined8 *)(puVar19 + -8) = 0x1404dc54a;

+    IopFreeIrpExtension(uVar21,9,1);

+  }

+  else {

+    lVar8 = *(longlong *)(lVar5 + -0x30);

+    lVar9 = *(longlong *)(lVar8 + 0xb8);

+    uVar17 = uVar3;

+    if ((*(uint *)(*(longlong *)(lVar5 + -0x20) + 0x50) & 8) != 0) {

+      uVar17 = *(uint *)(lVar9 + -0x40);

+      uVar2 = *(ushort *)(*(longlong *)(lVar5 + -0x28) + 0x130);

+      uVar15 = (uint)uVar2;

+      if (uVar2 == 0) {

+        uVar15 = 0x1000;

+      }

+      uVar16 = (uVar17 - 1) + uVar15;

+      uVar16 = uVar16 - uVar16 % uVar15;

+      if (uVar16 < uVar17) {

+        uVar17 = uVar16;

+      }

+      if (uVar3 < uVar17) {

+        lVar8 = *(longlong *)(lVar8 + 0x70);

+        *(undefined8 *)(puVar19 + -8) = 0x1404dc4d4;

+        memset((void *)((ulonglong)uVar3 + lVar8),0,(ulonglong)(uVar17 - uVar3));

+      }

+    }

+    *(uint *)(lVar9 + -0x40) = uVar17;

+    *(code **)(lVar5 + -0x40) = IopQueueCopyWrite;

+    *(longlong **)(lVar5 + -0x38) = (longlong *)(lVar5 + -0x30);

+    *(undefined8 *)(lVar5 + -0x50) = 0;

+    *(undefined8 *)(puVar19 + -8) = 0x1404dc4fa;

+    ExQueueWorkItem(lVar5 + -0x50,0);

+    uVar20 = 1;

+  }

+  return uVar20;

 }
```

## `PopBatteryEtwCallback`  (modified)

```diff
--- PopBatteryEtwCallback
+++ PopBatteryEtwCallback
@@ -1,21 +1,12 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void PopBatteryEtwCallback(longlong param_1)

+void PopBatteryEtwCallback(undefined8 param_1,int param_2)

 

 {

-  char in_AL;

-  undefined7 in_register_00000001;

-  char unaff_BH;

-  char in_CF;

-  

-  if (param_1 == 1 || (char)(unaff_BH - in_AL) == in_CF) {

-    *(char *)CONCAT71(in_register_00000001,in_AL) =

-         *(char *)CONCAT71(in_register_00000001,in_AL) + in_AL;

-                    /* WARNING: Bad instruction - Truncating control flow here */

-    halt_baddata();

+  if (param_2 == 2) {

+    PopAcquireRwLockShared(&DAT_0);

+    PopBatteryTraceSystemBatteryStatus(1);

+    PopReleaseRwLock(&DAT_0);

   }

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  return;

 }
```

## `PspVsmLogBugCheckCallback`  (modified)

```diff
--- PspVsmLogBugCheckCallback
+++ PspVsmLogBugCheckCallback
@@ -1,18 +1,64 @@
 

-/* WARNING: Control flow encountered bad instruction data */

+/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

 

-void PspVsmLogBugCheckCallback(longlong param_1,char *param_2)

+void PspVsmLogBugCheckCallback(undefined8 param_1,undefined8 param_2,longlong param_3)

 

 {

-  char in_AL;

-  undefined7 in_register_00000001;

-  byte unaff_SIL;

+  undefined1 uVar1;

+  longlong lVar2;

+  ulonglong uVar3;

+  undefined1 *puVar4;

+  ulonglong uVar5;

+  undefined1 *puVar6;

+  ulonglong uVar7;

+  longlong lVar8;

   

-  *(byte *)CONCAT71(in_register_00000001,in_AL) =

-       *(byte *)CONCAT71(in_register_00000001,in_AL) | unaff_SIL;

-  *param_2 = *param_2 + in_AL;

-  *(char *)(param_1 + -1) = *(char *)(param_1 + -1) + in_AL;

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  uVar7 = 0;

+  if (PspIumLogBuffer != 0) {

+    *(undefined8 *)(param_3 + 0x10) = 0x4d24ab959282756a;

+    *(undefined8 *)(param_3 + 0x18) = 0xf553dec5ddec37a1;

+    *(longlong *)(param_3 + 0x20) = PspIumLogBuffer;

+    *(undefined4 *)(param_3 + 0x28) = 0x2000;

+    memset(&DAT_0,0,0x100);

+    lVar2 = PspIumLogBuffer;

+    _SkStackDumpEventLog = 0x674c6857;

+    _DAT_1 = 1;

+    _DAT_2 = 0x120;

+    _DAT_3 = 0x8000006b;

+    _DAT_4 = 0x8000006b;

+    _DAT_5 = 0x18;

+    _DAT_6 = 0x100;

+    uVar3 = uVar7;

+    while( true ) {

+      uVar5 = (ulonglong)*(uint *)(lVar2 + 0xc);

+      if (0x25 < *(uint *)(lVar2 + 0xc)) {

+        uVar5 = 0x26;

+      }

+      if (uVar5 <= uVar3) break;

+      *(undefined4 *)(&DAT_7 + uVar3 * 4) = *(undefined4 *)(lVar2 + 0x494 + uVar3 * 8);

+      (&DAT_8)[uVar3] = *(undefined1 *)(lVar2 + 0x490 + uVar3 * 8);

+      uVar3 = (ulonglong)((int)uVar3 + 1);

+    }

+    while( true ) {

+      uVar3 = (ulonglong)*(uint *)(lVar2 + 8);

+      if (7 < *(uint *)(lVar2 + 8)) {

+        uVar3 = 8;

+      }

+      if (uVar3 <= uVar7) break;

+      lVar8 = 8;

+      puVar4 = &DAT_0 + uVar7 * 8;

+      puVar6 = (undefined1 *)(lVar2 + uVar7 * 0x48 + 0x10);

+      do {

+        uVar1 = *puVar6;

+        puVar6 = puVar6 + 2;

+        *puVar4 = uVar1;

+        puVar4 = puVar4 + 1;

+        lVar8 = lVar8 + -1;

+      } while (lVar8 != 0);

+      uVar7 = (ulonglong)((int)uVar7 + 1);

+    }

+    WheaLogInternalEvent(&SkStackDumpEventLog);

+  }

+  return;

 }
```

## `KiCollectTriageDumpDataBlocks`  (modified)

```diff
--- KiCollectTriageDumpDataBlocks
+++ KiCollectTriageDumpDataBlocks
@@ -1,28 +1,99 @@
 

-undefined8

-KiCollectTriageDumpDataBlocks(undefined8 param_1,undefined8 param_2,undefined8 param_3,int param_4)

+void KiCollectTriageDumpDataBlocks(int param_1,char param_2)

 

 {

-  undefined8 uVar1;

-  char *in_RAX;

-  longlong unaff_RDI;

-  undefined8 *puVar2;

-  longlong lVar3;

-  undefined8 in_CR3;

+  char cVar1;

+  short sVar2;

+  int iVar3;

+  longlong lVar4;

+  longlong lVar5;

   

-  *in_RAX = *in_RAX + (char)in_RAX;

-  VslKernelShadowStackAssist(param_4 + 3,param_2,0);

-  if (KiKvaShadow != '\0') {

-    lVar3 = 7;

-    puVar2 = (undefined8 *)(*(longlong *)(unaff_RDI + -0x180) + 0x1430);

-    do {

-      puVar2[1] = in_CR3;

-      uVar1 = rdmsr(0xc0000101);

-      *puVar2 = uVar1;

-      puVar2 = puVar2 + 0x40;

-      lVar3 = lVar3 + -1;

-    } while (lVar3 != 0);

+  KiCollectFullProcessName(*(undefined8 *)((longlong)SystemReserved1[0xf] + 0xb8));

+  IoAddTriageDumpDataBlock(&KiBugCheckDriver,8);

+  IoAddTriageDumpDataBlock(&KiBugCheckDriverOffset,4);

+  if (KiBugCheckDriver != 0) {

+    IoAddTriageDumpDataBlock(KiBugCheckDriver,0x10);

+    IoAddTriageDumpDataBlock

+              (*(undefined8 *)(KiBugCheckDriver + 8),*(undefined2 *)(KiBugCheckDriver + 2));

   }

-  return 1;

+  if (param_2 == '\0') {

+    KiSaveCurrentEtwTraceBuffer();

+  }

+  IoAddTriageDumpDataBlock(&KseEngine,0x60);

+  iVar3 = 0x1000;

+  if (param_1 == 0xef) {

+    PopInternalAddToDumpFile(0,0,0);

+    lVar4 = PsGetCurrentServerSiloGlobals();

+    if (((*(char *)((longlong)SystemReserved1[0xf] + 0x24a) == '\x01') &&

+        (lVar5 = *(longlong *)((longlong)SystemReserved1[0xf] + 0x278), lVar5 != 0)) &&

+       (lVar5 != *(longlong *)((longlong)SystemReserved1[0xf] + 0xb8))) {

+      IoAddTriageDumpDataBlock(lVar5,0x840);

+      KiCollectFullProcessName(lVar5);

+    }

+    if (*(int *)(lVar4 + 0x558) == 0) goto LAB_0;

+    IoAddTriageDumpDataBlock(lVar4 + 0x558,0x30);

+    sVar2 = *(short *)(lVar4 + 0x568);

+    if (sVar2 == 0) goto LAB_0;

+    lVar4 = *(longlong *)(lVar4 + 0x570);

+  }

+  else {

+    if (param_1 != 0x109) {

+      if (param_1 == 0x14f) {

+        if ((DAT_1 != 4) && (DAT_1 != 100)) goto LAB_1405b0703;

+      }

+      else {

+        if (param_1 == 0x18b) {

+          if (DAT_1 == 0x18c) {

+            if (KdpBreakpointChangeCount != 0) {

+              IoAddTriageDumpDataBlock(&KdpBreakpointChangeCount,4);

+            }

+            IoAddTriageDumpDataBlock(&VslpTraceLog,0xa08);

+            if (VslpHotpatchLog != 0) {

+              IoAddTriageDumpDataBlock(&VslpHotpatchLog,8);

+              IoAddTriageDumpDataBlock(VslpHotpatchLog,0x50008);

+            }

+          }

+          if ((param_2 == '\0') || (PspIumLogBuffer == 0)) goto LAB_0;

+          IoAddTriageDumpDataBlock(&PspIumLogBuffer,8);

+          sVar2 = 0x2000;

+          lVar4 = PspIumLogBuffer;

+          goto LAB_2;

+        }

+        if (param_1 != 0x1eb) goto LAB_0;

+      }

+      IoAddTriageDumpDataBlock(&KeSwapProcessOrStackThread,8);

+      IopAddBugcheckTriageThread(KeSwapProcessOrStackThread);

+      goto LAB_0;

+    }

+    KiMarkBugCheckRegions(DAT_1,DAT_140f22b70,DAT_140f22b78,DAT_140f22b80);

+    lVar4 = DAT_3;

+    if ((DAT_4 != 0x2f) ||

+       (cVar1 = MmIsAddressValidEx(DAT_3 + 0x508,0), cVar1 == '\0')) goto LAB_1405b0703;

+    lVar4 = *(longlong *)(lVar4 + 0x508);

+    sVar2 = 0x1000;

+  }

+LAB_2:

+  IoAddTriageDumpDataBlock(lVar4,sVar2);

+LAB_0:

+  if (KiKernelCetEnabled != '\0') {

+    lVar4 = *(longlong *)((longlong)SystemReserved1[0xf] + 0x418) + -0x1000;

+    lVar5 = (*(ulonglong *)((longlong)SystemReserved1[0xf] + 0x420) & 0xfffffffffffff000) + 0x1000;

+    if ((ulonglong)(lVar4 - lVar5) < 0x1000) {

+      iVar3 = (int)lVar4 - (int)lVar5;

+    }

+    cVar1 = KiIsAddressRangeValid(lVar5,iVar3);

+    if (cVar1 != '\0') {

+      IoAddTriageDumpDataBlock(lVar5,iVar3);

+    }

+    IoAddTriageDumpDataBlock(&KeKernelCetWrssEnabledScenarios,1);

+    IoAddTriageDumpDataBlock(&KiKernelCetLogging,0x120);

+  }

+  IoAddTriageDumpDataBlock(&KiKernelCetEnabled,1);

+  IoAddTriageDumpDataBlock(&KiKernelCetAuditModeEnabled,1);

+  iVar3 = Feature_14FBugcheckMinidumpDiagnostics__private_IsEnabledDeviceUsageNoInline();

+  if (iVar3 != 0) {

+    IoAddTriageDumpDataBlock(0xfffff78000000000,0x3d8);

+  }

+  return;

 }
```

## `KeSetCoalescableTimer`  (modified)

```diff
--- KeSetCoalescableTimer
+++ KeSetCoalescableTimer
@@ -1,13 +1,73 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void KeSetCoalescableTimer(char param_1)

+void KeSetCoalescableTimer

+               (undefined8 param_1,longlong param_2,uint param_3,ulonglong param_4,

+               undefined8 param_5)

 

 {

-  longlong unaff_RBX;

+  uint uVar1;

+  byte bVar2;

+  ushort uVar3;

+  ulonglong uVar5;

+  longlong lVar6;

+  longlong lVar7;

+  byte bVar8;

+  bool bVar9;

+  ushort uVar4;

   

-  *(char *)(unaff_RBX + -0x4dd1638) = *(char *)(unaff_RBX + -0x4dd1638) + param_1;

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+                    /* 0x2b3ec0  1447  KeSetCoalescableTimer */

+  uVar5 = param_4 & 0xffffffffffffff00;

+  lVar7 = param_2;

+  if ((int)param_4 == 0) goto LAB_0;

+  uVar5 = (param_4 & 0xffffffff) * 10000;

+  if (9600000 < uVar5) {

+    lVar6 = uVar5 - 9600000;

+    if (param_2 < 0) {

+      lVar7 = param_2 - lVar6;

+      if (param_2 < lVar7) {

+        lVar7 = -0x8000000000000000;

+      }

+    }

+    else {

+      lVar7 = lVar6 + param_2;

+      if (lVar7 < param_2) {

+        lVar7 = 0x7fffffffffffffff;

+      }

+    }

+    if (param_3 != 0) {

+      uVar1 = (int)(lVar6 / 10000) + param_3;

+      bVar9 = param_3 <= uVar1;

+      param_3 = 0xffffffff;

+      if (bVar9) {

+        param_3 = uVar1;

+      }

+    }

+    uVar5 = 9600000;

+  }

+  uVar3 = (ushort)((uVar5 & 0xffffffff) / 10000);

+  if (0x3c0 < uVar3) {

+    uVar3 = 0x3c0;

+  }

+  uVar3 = uVar3 & 0x1fff;

+  uVar4 = uVar3 * 2;

+  uVar1 = 0x1f;

+  if (uVar3 != 0) {

+    for (; uVar4 >> uVar1 == 0; uVar1 = uVar1 - 1) {

+    }

+  }

+  if ((uVar3 == 0) || (uVar1 < 3)) {

+    bVar8 = 0;

+LAB_1:

+    bVar2 = (byte)(uVar4 >> 1);

+  }

+  else {

+    bVar8 = (char)uVar1 - 3;

+    uVar4 = uVar4 >> (bVar8 & 0x1f);

+    bVar2 = (byte)uVar4;

+    if (bVar8 == 0) goto LAB_1;

+  }

+  uVar5 = (ulonglong)CONCAT31((int3)(uVar1 >> 8),(bVar8 << 3 | bVar2 & 7) << 2);

+LAB_0:

+  KiSetTimerEx(param_1,lVar7,param_3,uVar5,param_5);

+  return;

 }
```

## `EtwTraceThreadAffinity`  (modified)

```diff
--- EtwTraceThreadAffinity
+++ EtwTraceThreadAffinity
@@ -1,66 +1,138 @@
 

-uint EtwTraceThreadAffinity(undefined8 param_1,uint param_2)

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+

+void EtwTraceThreadAffinity

+               (longlong param_1,undefined2 param_2,char param_3,char param_4,ushort *param_5,

+               undefined2 param_6)

 

 {

-  bool bVar1;

+  byte *pbVar1;

   bool bVar2;

-  bool bVar3;

-  char cVar4;

-  undefined8 in_RAX;

-  longlong lVar6;

-  undefined8 uVar7;

-  longlong unaff_RBX;

-  int unaff_ESI;

-  longlong lVar8;

-  longlong unaff_R13;

-  undefined4 uStack0000000000000028;

-  longlong *in_stack_00000080;

-  undefined8 *in_stack_00000088;

-  undefined8 *in_stack_00000090;

-  char *pcVar5;

+  ushort uVar3;

+  ushort uVar4;

+  ushort uVar5;

+  int iVar6;

+  byte bVar7;

+  byte bVar8;

+  undefined8 **ppuVar9;

+  ulonglong uVar10;

+  undefined8 uVar11;

+  ulonglong uVar12;

+  undefined1 auStack_b8 [32];

+  undefined4 local_98;

+  undefined8 local_88;

+  longlong lStack_80;

+  undefined8 *local_78;

+  undefined8 uStack_70;

+  undefined8 *local_68;

+  undefined8 uStack_60;

+  undefined8 *local_58;

+  undefined8 local_50;

+  undefined8 **local_48;

+  int local_40;

+  undefined4 local_3c;

+  ushort *local_38;

+  int local_30;

+  undefined4 local_2c;

+  ulonglong local_28;

   

-  cVar4 = in((short)param_2);

-  pcVar5 = (char *)CONCAT71((int7)((ulonglong)in_RAX >> 8),cVar4);

-  pcVar5[-0x75] = pcVar5[-0x75] ^ (byte)param_1;

-  lVar8 = CONCAT71((int7)((ulonglong)param_1 >> 8),0x90);

-  *pcVar5 = *pcVar5 + cVar4;

-  pcVar5 = (char *)(unaff_RBX + -0x16 + lVar8 * 4);

-  *pcVar5 = *pcVar5 + cVar4;

-  if ((*(char *)(lVar8 + 0x99) == '\0') && (param_2 < 0x11)) {

-    bVar3 = true;

+  local_28 = __security_cookie ^ (ulonglong)auStack_b8;

+  local_88 = (ulonglong)CONCAT24(param_2,*(undefined4 *)(param_1 + 0x510));

+  local_78 = (undefined8 *)0x0;

+  uStack_70 = 0;

+  iVar6 = KeIsEqualAffinityEx(param_5,&KeActiveProcessors);

+  uVar11 = 1;

+  bVar7 = local_88._6_1_;

+  if (iVar6 != 0) {

+    bVar7 = local_88._6_1_ | 1;

+    local_88 = local_88 | 0x1000000000000;

+  }

+  uVar12 = 2;

+  bVar8 = bVar7;

+  if (param_3 != '\0') {

+    bVar8 = bVar7 | 2;

+    local_88 = CONCAT17(local_88._7_1_,CONCAT16(bVar7,(undefined6)local_88)) | 0x2000000000000;

+  }

+  if (param_4 != '\0') {

+    local_88 = CONCAT17(local_88._7_1_,CONCAT16(bVar8,(undefined6)local_88)) | 0x4000000000000;

+  }

+  if (iVar6 == 0) {

+    iVar6 = Feature_AffinityLogSkipEmptyAffinity__private_IsEnabledDeviceUsageNoInline();

+    uVar3 = 0;

+    if (iVar6 == 0) {

+      KeComputeGroupMask(param_5,&local_78);

+    }

+    else {

+      bVar2 = true;

+      local_78 = (undefined8 *)0x0;

+      uStack_70 = 0;

+      if (*param_5 == 0) {

+        return;

+      }

+      do {

+        uVar10 = (ulonglong)uVar3;

+        if (*(longlong *)(param_5 + uVar10 * 4 + 4) != 0) {

+          bVar2 = false;

+          pbVar1 = (byte *)((longlong)&local_78 + ((longlong)uVar10 >> 3));

+          *pbVar1 = *pbVar1 | '\x01' << (uVar10 & 7);

+        }

+        uVar3 = uVar3 + 1;

+      } while (uVar3 < *param_5);

+      if (bVar2) {

+        return;

+      }

+    }

+    do {

+      bVar7 = (byte)uVar12;

+      if ((&lStack_80)[uVar12] != 0) break;

+      bVar8 = bVar7 - 1;

+      uVar12 = (ulonglong)bVar8;

+      bVar7 = 0;

+    } while (bVar8 != 0);

+    local_88 = CONCAT17(bVar7,(undefined7)local_88);

+    uVar3 = KeFindFirstSetRightGroupMask(&local_78);

+    local_68 = local_78;

+    uStack_60 = uStack_70;

+    uVar5 = 0;

+    uVar4 = KeCountSetBitsGroupMask(&local_68);

+    if (uVar4 != 0) {

+      uVar12 = (ulonglong)uVar4;

+      do {

+        uVar5 = KeFindFirstSetRightGroupMask(&local_68);

+        pbVar1 = (byte *)((longlong)&local_68 + ((longlong)(ulonglong)uVar5 >> 3));

+        *pbVar1 = *pbVar1 & ~('\x01' << ((ulonglong)uVar5 & 7));

+        uVar12 = uVar12 - 1;

+      } while (uVar12 != 0);

+    }

+    uVar4 = uVar3 + 1;

+    if (uVar4 < uVar5) {

+      uVar12 = (ulonglong)uVar4;

+      uVar10 = (ulonglong)(ushort)(uVar5 - uVar4);

+      do {

+        pbVar1 = (byte *)((longlong)&local_78 + ((longlong)uVar12 >> 3));

+        *pbVar1 = *pbVar1 | '\x01' << (uVar12 & 7);

+        uVar12 = uVar12 + 1;

+        uVar10 = uVar10 - 1;

+      } while (uVar10 != 0);

+    }

+    local_58 = &local_88;

+    local_50 = 8;

+    uVar11 = 3;

+    local_48 = &local_78;

+    local_3c = 0;

+    local_40 = (uint)bVar7 << 3;

+    ppuVar9 = &local_58;

+    local_30 = (uint)(ushort)((uVar5 - uVar3) + 1) << 3;

+    local_2c = 0;

+    local_38 = param_5 + (ulonglong)uVar3 * 4 + 4;

   }

   else {

-    bVar3 = false;

+    local_68 = &local_88;

+    uStack_60 = 8;

+    ppuVar9 = &local_68;

   }

-  bVar2 = false;

-  while( true ) {

-    if (unaff_ESI == -1) {

-      lVar8 = 0x1000000;

-    }

-    else {

-      lVar8 = 0;

-    }

-    bVar1 = false;

-    while( true ) {

-      uStack0000000000000028 = 0x80000000;

-      lVar6 = MmAllocateContiguousNodeMemory(unaff_R13 << 0xc,lVar8);

-      if (lVar6 != 0) {

-        uVar7 = MmGetPhysicalAddress(lVar6);

-        *in_stack_00000080 = lVar6;

-        *in_stack_00000088 = uVar7;

-        goto LAB_0;

-      }

-      if ((bVar1) || (lVar8 == 0)) break;

-      bVar1 = true;

-      lVar8 = 0;

-    }

-    if ((bVar2) || (!bVar3)) break;

-    bVar2 = true;

-    bVar3 = false;

-  }

-  param_2 = 0;

-LAB_0:

-  *in_stack_00000090 = 0;

-  return param_2;

+  local_98 = 0x601b02;

+  EtwTraceKernelEvent(ppuVar9,uVar11,0x20001000,param_6);

+  return;

 }
```

## `ApiSetSchemaExpander_InsertContractEntry`  (modified)

```diff
--- ApiSetSchemaExpander_InsertContractEntry
+++ ApiSetCompose_V7_ProcessV6Extension_Phase1
@@ -1,23 +1,227 @@
 

-undefined8

-ApiSetSchemaExpander_InsertContractEntry(longlong param_1,undefined8 param_2,short *param_3)

+int ApiSetCompose_V7_ProcessV6Extension_Phase1

+              (longlong param_1,longlong param_2,undefined8 param_3,undefined2 *param_4)

 

 {

-  short *psVar1;

-  short sVar2;

-  undefined8 uVar3;

+  ushort uVar1;

+  char cVar2;

+  short sVar3;

+  int iVar4;

+  ulonglong uVar5;

+  ulonglong uVar6;

+  byte bVar7;

+  longlong lVar8;

+  longlong lVar9;

+  byte bVar10;

+  ushort uVar11;

+  uint uVar12;

+  ulonglong uVar13;

+  undefined7 uVar14;

+  longlong lVar15;

+  uint *puVar16;

+  longlong *plVar17;

+  uint *puVar18;

+  ushort local_res8 [4];

+  ushort local_res18 [4];

+  uint local_res20;

+  uint local_88;

+  uint local_84;

+  longlong local_68;

+  undefined8 uStack_60;

+  ulonglong local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

   

-  sVar2 = *(short *)(param_1 + 0xac);

-  *param_3 = sVar2;

-  *(short *)(param_1 + 0xac) = sVar2 + 1;

-  uVar3 = ApiSetpInsertHashEntry

-                    (*(longlong *)(param_1 + 0x20),*(longlong *)(param_1 + 0x20) + 0x2c,sVar2,

-                     param_2,1);

-  if (-1 < (int)uVar3) {

-    psVar1 = (short *)(*(longlong *)(param_1 + 0x20) + 0x30);

-    *psVar1 = *psVar1 + 1;

-    uVar3 = 0;

+  uVar5 = 0;

+  iVar4 = 0;

+  local_84 = 0;

+  if (*(int *)(param_1 + 0xc) != 0) {

+    do {

+      lVar15 = (ulonglong)*(uint *)(param_1 + 0x10) + param_1;

+      local_68 = 0;

+      uStack_60 = 0;

+      lVar8 = (ulonglong)*(uint *)(lVar15 + 4 + uVar5 * 0x18) + param_1;

+      uVar12 = *(uint *)(lVar15 + 8 + uVar5 * 0x18) >> 1;

+      local_58 = 0;

+      uStack_50 = 0;

+      if ((*(uint *)(lVar15 + uVar5 * 0x18) & 4) == 0) {

+        lVar9 = *(longlong *)(param_2 + 0x20);

+        uVar11 = (ushort)uVar12;

+        local_58 = (ulonglong)uVar11 << 0x10;

+        local_48 = 0;

+        param_4 = (undefined2 *)

+                  (CONCAT71((int7)((ulonglong)param_4 >> 8),*(byte *)(lVar9 + 0x65) >> 1) &

+                  0xffffffffffffff01);

+        uStack_60 = (ulonglong)CONCAT12(1,uVar11);

+        local_68 = lVar8;

+        local_res8[0] = ApiSetpSearchForSectionIndex_V7(lVar9,lVar9 + 0x5c,&local_68,param_4);

+        if ((local_res8[0] == 0xffff) &&

+           (iVar4 = ApiSetSchemaExpander_InsertHostEntry(param_2,&local_68,local_res8), iVar4 < 0))

+        {

+          return iVar4;

+        }

+        uVar6 = 0;

+        local_88 = 0;

+        if (*(int *)(lVar15 + 0x14 + uVar5 * 0x18) != 0) {

+          do {

+            lVar8 = (ulonglong)*(uint *)(lVar15 + 0x10 + uVar5 * 0x18) + param_1;

+            local_48 = 0;

+            local_68 = 0;

+            uStack_60 = 0;

+            uVar13 = (ulonglong)(*(uint *)(lVar8 + 0x10 + uVar6 * 0x14) >> 1);

+            local_58 = 0;

+            uStack_50 = 0;

+            cVar2 = ApiSetpGetContractKeyInfo

+                              ((ulonglong)*(uint *)(lVar8 + 0xc + uVar6 * 0x14) + param_1,uVar13,1,

+                               &local_68);

+            if (cVar2 == '\0') {

+              return -0x3fffffcd;

+            }

+            if (uStack_60._4_4_ != 3) {

+              return -0x3fffffcd;

+            }

+            lVar9 = *(longlong *)(param_2 + 0x20);

+            uVar13 = CONCAT71((int7)(uVar13 >> 8),*(byte *)(lVar9 + 2)) & 0xffffffffffffff10;

+            bVar7 = *(byte *)(lVar9 + 2) & 8;

+            uVar14 = (undefined7)(uVar13 >> 8);

+            cVar2 = (char)uVar13;

+            if ((*(byte *)(lVar9 + 0x35) & 4) == 0) {

+              local_res20 = ApiSetpGetSearchKeyHash

+                                      (&local_68,CONCAT71(uVar14,1),bVar7 != 0,cVar2 != '\0',

+                                       *(undefined1 *)(lVar9 + 0x37));

+            }

+            else {

+              bVar7 = ApiSetpGetSearchKeyHash

+                                (&local_68,CONCAT71(uVar14,1),bVar7 != 0,cVar2 != '\0',

+                                 *(undefined1 *)(lVar9 + 0x37));

+              local_res20 = (uint)bVar7;

+            }

+            local_res18[0] = ApiSetpSearchForSectionIndex_V7(lVar9,lVar9 + 0x2c,&local_68,1);

+            if (local_res18[0] == 0xffff) {

+              iVar4 = ApiSetSchemaExpander_InsertContractEntry(param_2,&local_68,local_res18);

+              if (iVar4 < 0) {

+                return iVar4;

+              }

+              lVar9 = *(longlong *)(param_2 + 0x20);

+              puVar18 = (uint *)((ulonglong)*(uint *)(lVar9 + 0x2c) +

+                                lVar9 + ((ulonglong)*(byte *)(lVar9 + 0x34) *

+                                         (ulonglong)local_res18[0] -

+                                        (ulonglong)*(ushort *)(lVar9 + 0x12)));

+            }

+            else {

+              puVar18 = (uint *)((ulonglong)*(uint *)(lVar9 + 0x2c) +

+                                lVar9 + ((ulonglong)*(byte *)(lVar9 + 0x34) *

+                                         (ulonglong)local_res18[0] -

+                                        (ulonglong)*(ushort *)(lVar9 + 0x12)));

+              if (*puVar18 != local_res20) {

+                return -0x3ffffdd7;

+              }

+            }

+            uVar11 = local_res18[0];

+            bVar10 = *(byte *)(lVar9 + 2) & 0x10;

+            bVar7 = *(byte *)(lVar9 + 2) & 8;

+            if ((*(byte *)(lVar9 + 0x4d) & 4) == 0) {

+              local_res20 = ApiSetpGetSearchKeyHash

+                                      (&local_68,0,bVar7 != 0,bVar10 != 0,

+                                       *(undefined1 *)(lVar9 + 0x4f));

+            }

+            else {

+              bVar7 = ApiSetpGetSearchKeyHash

+                                (&local_68,0,bVar7 != 0,bVar10 != 0,*(undefined1 *)(lVar9 + 0x4f));

+              local_res20 = (uint)bVar7;

+            }

+            param_4 = (undefined2 *)0x0;

+            local_res18[0] = ApiSetpSearchForSectionIndex_V7(lVar9,lVar9 + 0x44,&local_68,0);

+            if (local_res18[0] == 0xffff) {

+              iVar4 = ApiSetSchemaExpander_InsertSemverContractEntry(param_2,&local_68,local_res18);

+              if (iVar4 < 0) {

+                return iVar4;

+              }

+              lVar9 = *(longlong *)(param_2 + 0x20);

+              puVar16 = (uint *)((ulonglong)*(uint *)(lVar9 + 0x44) +

+                                lVar9 + ((ulonglong)*(byte *)(lVar9 + 0x4c) *

+                                         (ulonglong)local_res18[0] -

+                                        (ulonglong)*(ushort *)(lVar9 + 0x12)));

+            }

+            else {

+              puVar16 = (uint *)((ulonglong)*(uint *)(lVar9 + 0x44) +

+                                lVar9 + ((ulonglong)*(byte *)(lVar9 + 0x4c) *

+                                         (ulonglong)local_res18[0] -

+                                        (ulonglong)*(ushort *)(lVar9 + 0x12)));

+              if (*puVar16 != local_res20) {

+                return -0x3ffffdd7;

+              }

+            }

+            uVar1 = local_res8[0];

+            *(ushort *)(puVar16 + 1) = uVar11;

+            if ((*(byte *)((longlong)puVar16 + 10) & 1) == 0) {

+              if (*(int *)(lVar8 + 4 + uVar6 * 0x14) != 0) {

+                uVar12 = *(uint *)(param_2 + 0x9c) >> 4;

+                *(uint *)(param_2 + 0x9c) = *(uint *)(param_2 + 0x9c) + 0x10;

+                lVar8 = *(longlong *)(param_2 + 0x20);

+                param_4 = (undefined2 *)

+                          ((((ulonglong)*(ushort *)(lVar8 + 0x72) * (ulonglong)(uVar12 & 0xffff) +

+                            (ulonglong)*(uint *)(lVar8 + 0x68)) -

+                           (ulonglong)*(ushort *)(lVar8 + 0x12)) + lVar8);

+                lVar9 = ((ulonglong)*(byte *)(lVar8 + 100) * (ulonglong)(ushort)puVar18[1] +

+                        (ulonglong)*(uint *)(lVar8 + 0x5c)) - (ulonglong)*(ushort *)(lVar8 + 0x12);

+                *(undefined4 *)(param_4 + 4) = *(undefined4 *)(lVar9 + 4 + lVar8);

+                param_4[7] = *(undefined2 *)(lVar9 + 8 + lVar8);

+                lVar8 = *(longlong *)(param_2 + 0x20);

+                lVar9 = (ulonglong)*(uint *)(lVar8 + 0x5c) +

+                        ((ulonglong)*(byte *)(lVar8 + 100) * (ulonglong)local_res8[0] -

+                        (ulonglong)*(ushort *)(lVar8 + 0x12));

+                *(undefined4 *)(param_4 + 2) = *(undefined4 *)(lVar8 + lVar9 + 4);

+                param_4[6] = *(undefined2 *)(lVar8 + lVar9 + 8);

+                *param_4 = *(undefined2 *)((longlong)puVar18 + 6);

+                *(short *)(puVar18 + 2) = (short)puVar18[2] + 1;

+                *(short *)((longlong)puVar18 + 6) = (short)uVar12;

+              }

+              *(byte *)((longlong)puVar18 + 10) = *(byte *)((longlong)puVar18 + 10) | 2;

+              *(ushort *)(puVar18 + 1) = local_res8[0];

+              if ((*(char *)(param_2 + 0x10) != '\0') &&

+                 (lVar8 = ApiSetpSearchForApiSet

+                                    (*(undefined8 *)(param_2 + 0x28),local_68,

+                                     local_58 >> 0x10 & 0xffff), lVar8 != 0)) {

+                lVar9 = *(longlong *)(param_2 + 0x20);

+                param_4 = (undefined2 *)

+                          ((ulonglong)*(uint *)(lVar8 + 0x10) + *(longlong *)(param_2 + 0x28));

+                lVar8 = (ulonglong)*(uint *)(lVar9 + 0x5c) +

+                        ((ulonglong)*(byte *)(lVar9 + 100) * (ulonglong)uVar1 -

+                        (ulonglong)*(ushort *)(lVar9 + 0x12));

+                *(int *)(param_4 + 6) = *(int *)(lVar9 + 0x24) + *(int *)(lVar9 + lVar8 + 4);

+                *(uint *)(param_4 + 8) = (uint)*(ushort *)(lVar9 + lVar8 + 8) * 2;

+              }

+            }

+            local_88 = local_88 + 1;

+            uVar6 = (ulonglong)local_88;

+          } while (local_88 < *(uint *)(lVar15 + 0x14 + uVar5 * 0x18));

+        }

+      }

+      else {

+        plVar17 = &local_68;

+        local_48 = 0;

+        cVar2 = ApiSetpGetExtensionNameKeyInfo(lVar8,uVar12,1,plVar17);

+        if (cVar2 == '\0') {

+          return -0x3fffffcd;

+        }

+        lVar8 = *(longlong *)(param_2 + 0x20);

+        param_4 = (undefined2 *)

+                  (CONCAT71((int7)((ulonglong)plVar17 >> 8),*(byte *)(lVar8 + 0x59) >> 1) &

+                  0xffffffffffffff01);

+        sVar3 = ApiSetpSearchForSectionIndex_V7(lVar8,lVar8 + 0x50,&local_68,param_4);

+        if (sVar3 != -1) {

+          return -0x3fffffcb;

+        }

+        iVar4 = ApiSetSchemaExpander_InsertExtensionNameEntry(param_2,&local_68);

+        if (iVar4 < 0) {

+          return iVar4;

+        }

+      }

+      local_84 = local_84 + 1;

+      uVar5 = (ulonglong)local_84;

+    } while (local_84 < *(uint *)(param_1 + 0xc));

   }

-  return uVar3;

+  return iVar4;

 }
```

## `ApiSetCompose_V7_ProcessV6Extension_Phase0`  (modified)

```diff
--- ApiSetCompose_V7_ProcessV6Extension_Phase0
+++ ApiSetCompose_V7_ProcessV6Extension_Phase0
@@ -1,45 +1,90 @@
 

-int ApiSetCompose_V7_ProcessV6Extension_Phase0(longlong param_1)

+undefined4

+ApiSetCompose_V7_ProcessV6Extension_Phase0

+          (longlong param_1,longlong param_2,undefined8 param_3,ulonglong param_4)

 

 {

-  byte bVar1;

-  char *in_RAX;

-  int iVar2;

-  longlong unaff_RBX;

-  longlong lVar3;

-  int unaff_EBP;

-  int iVar4;

-  char *unaff_RDI;

-  int iVar5;

-  int iVar6;

-  int iVar7;

-  int iVar8;

-  int unaff_R14D;

+  longlong lVar1;

+  char cVar2;

+  short sVar3;

+  ushort uVar4;

+  ulonglong uVar5;

+  ulonglong uVar6;

+  longlong lVar7;

+  longlong lVar8;

+  uint uVar9;

+  uint uVar10;

+  longlong local_68;

+  ulonglong uStack_60;

+  longlong local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

   

-  bVar1 = (byte)in_RAX;

-  *(char *)(unaff_RBX + -0x5676031b) = *(char *)(unaff_RBX + -0x5676031b) - bVar1;

-  LOCK();

-  *in_RAX = *in_RAX + bVar1;

-  UNLOCK();

-  *unaff_RDI = *unaff_RDI + (char)param_1;

-  lVar3 = CONCAT62((int6)((ulonglong)unaff_RBX >> 0x10),CONCAT11(0x43,(char)unaff_RBX));

-  *(byte *)(lVar3 + -0x50f0f739) = *(byte *)(lVar3 + -0x50f0f739) ^ bVar1 ^ 0xf;

-  iVar4 = (int)unaff_RDI + *(int *)(param_1 + 0xa8);

-  *(int *)(param_1 + 0xf8) = iVar4;

-  iVar8 = (*(byte *)(lVar3 + 0x40) + 8) * (uint)*(ushort *)(lVar3 + 0x3c) + *(int *)(param_1 + 0xb4)

-  ;

-  *(int *)(param_1 + 0xfc) = iVar8;

-  iVar7 = (*(byte *)(lVar3 + 0x4c) + 8) * (uint)*(ushort *)(lVar3 + 0x48) + *(int *)(param_1 + 0xc0)

-  ;

-  *(int *)(param_1 + 0x100) = iVar7;

-  iVar6 = (*(byte *)(lVar3 + 0x58) + 8) * (uint)*(ushort *)(lVar3 + 0x54) + *(int *)(param_1 + 0xd8)

-  ;

-  *(int *)(param_1 + 0x104) = iVar6;

-  iVar5 = (*(byte *)(lVar3 + 100) + 8) * (uint)*(ushort *)(lVar3 + 0x60) + *(int *)(param_1 + 0xcc);

-  *(int *)(param_1 + 0x108) = iVar5;

-  iVar2 = *(int *)(lVar3 + 0x6c) + *(int *)(param_1 + 0xe4);

-  *(int *)(param_1 + 0x10c) = iVar2;

-  return (-(uint)(*(char *)(param_1 + 0x10) != '\0') & 0x1c) + 0x7c + iVar2 + iVar5 + iVar6 + iVar7

-         + iVar8 + iVar4 + unaff_EBP + unaff_R14D;

+  uVar10 = 0;

+  if (*(int *)(param_1 + 0xc) != 0) {

+    do {

+      uVar5 = (ulonglong)uVar10;

+      lVar8 = (ulonglong)*(uint *)(param_1 + 0x10) + param_1;

+      if ((*(uint *)(lVar8 + uVar5 * 0x18) & 4) == 0) {

+        local_48 = 0;

+        local_68 = (ulonglong)*(uint *)(lVar8 + 4 + uVar5 * 0x18) + param_1;

+        uVar9 = *(uint *)(lVar8 + 8 + uVar5 * 0x18) >> 1;

+        lVar1 = *(longlong *)(param_2 + 8);

+        uStack_50 = 0;

+        uVar4 = (ushort)uVar9;

+        uStack_60 = (ulonglong)CONCAT12(1,uVar4);

+        param_4 = CONCAT71((int7)(param_4 >> 8),*(byte *)(lVar1 + 0x65) >> 1) & 0xffffffffffffff01;

+        local_58 = (ulonglong)uVar4 << 0x10;

+        sVar3 = ApiSetpSearchForSectionIndex_V7(lVar1,lVar1 + 0x5c,&local_68,param_4);

+        if (sVar3 == -1) {

+          *(short *)(param_2 + 200) = *(short *)(param_2 + 200) + 1;

+          *(int *)(param_2 + 0xcc) = *(int *)(param_2 + 0xcc) + 0x14;

+          *(int *)(param_2 + 0xe8) = *(int *)(param_2 + 0xe8) + (uVar9 & 0xffff) * 2;

+        }

+        uVar9 = 0;

+        if (*(int *)(lVar8 + 0x14 + uVar5 * 0x18) != 0) {

+          do {

+            uVar6 = (ulonglong)uVar9;

+            local_48 = 0;

+            local_68 = 0;

+            uStack_60 = 0;

+            lVar7 = (ulonglong)*(uint *)(lVar8 + 0x10 + uVar5 * 0x18) + param_1;

+            local_58 = 0;

+            uStack_50 = 0;

+            cVar2 = ApiSetpGetContractKeyInfo

+                              ((ulonglong)*(uint *)(lVar7 + 0xc + uVar6 * 0x14) + param_1,

+                               *(uint *)(lVar7 + 0x10 + uVar6 * 0x14) >> 1,1,&local_68);

+            if (cVar2 == '\0') {

+              return 0xc0000033;

+            }

+            param_4 = 0;

+            uVar4 = ApiSetpSearchForSectionIndex_V7(lVar1,lVar1 + 0x44,&local_68,0);

+            if (uVar4 == 0xffff) {

+              *(int *)(param_2 + 0xc0) = *(int *)(param_2 + 0xc0) + 0x14;

+              *(short *)(param_2 + 0xbc) = *(short *)(param_2 + 0xbc) + 1;

+              *(short *)(param_2 + 0xa4) = *(short *)(param_2 + 0xa4) + 1;

+              *(int *)(param_2 + 0xa8) = *(int *)(param_2 + 0xa8) + 0x14;

+LAB_0:

+              if (*(int *)(lVar7 + 4 + uVar6 * 0x14) != 0) {

+                *(short *)(param_2 + 0xe0) = *(short *)(param_2 + 0xe0) + 1;

+                *(int *)(param_2 + 0xe4) = *(int *)(param_2 + 0xe4) + 0x10;

+              }

+            }

+            else if ((*(byte *)((ulonglong)*(uint *)(lVar1 + 0x44) + 10 +

+                               lVar1 + ((ulonglong)*(byte *)(lVar1 + 0x4c) * (ulonglong)uVar4 -

+                                       (ulonglong)*(ushort *)(lVar1 + 0x12))) & 1) == 0)

+            goto LAB_0;

+            uVar9 = uVar9 + 1;

+          } while (uVar9 < *(uint *)(lVar8 + 0x14 + uVar5 * 0x18));

+        }

+      }

+      else {

+        *(short *)(param_2 + 0xd4) = *(short *)(param_2 + 0xd4) + 1;

+        *(int *)(param_2 + 0xd8) = *(int *)(param_2 + 0xd8) + 0xc;

+      }

+      uVar10 = uVar10 + 1;

+    } while (uVar10 < *(uint *)(param_1 + 0xc));

+  }

+  return 0;

 }
```

## `KiApplyProcessorErrata`  (modified)

```diff
--- KiApplyProcessorErrata
+++ KiApplyProcessorErrata
@@ -1,26 +1,47 @@
 

-void KiApplyProcessorErrata(void)

+char * KiApplyProcessorErrata(longlong param_1)

 

 {

-  undefined8 *puVar1;

-  ulong uVar2;

-  _KAFFINITY_EX *unaff_RSI;

-  longlong unaff_RDI;

-  _KAFFINITY_EX *unaff_R15;

-  undefined1 in_stack_00000060;

+  char *pcVar1;

+  ulonglong uVar2;

+  char cVar3;

+  byte bVar4;

+  char *pcVar5;

   

-  KeAcquireSpinLockAtDpcLevel(KiSystemCpuPartition + 1);

-  puVar1 = KiSystemCpuPartition;

-  KiCopyAffinityEx(unaff_RSI,unaff_RSI->Size,(_KAFFINITY_EX *)*KiSystemCpuPartition);

-  KxReleaseSpinLock(puVar1 + 1);

-  uVar2 = KiAndAffinityExNoResult(unaff_RSI,unaff_R15);

-  if (uVar2 == 0) {

-    EtwTraceCpuPartitionAffinityViolation(in_stack_00000060);

+  pcVar1 = (char *)(param_1 + 0x8d);

+  if (((*pcVar1 == '\x01') && ('\x0f' < *(char *)(param_1 + 0x40))) &&

+     (*(char *)(param_1 + 0x40) != '\x11')) {

+    cVar3 = HviIsAnyHypervisorPresent();

+    if (cVar3 == '\0') {

+      uVar2 = rdmsr(0xc0011029);

+      wrmsr(0xc0011029,uVar2 & 0xffffffff00000000 | uVar2 & 0xffffffff | 2);

+    }

   }

-  ExFreePoolWithTag();

-  if (unaff_RDI != 0) {

-    ExFreePoolWithTag();

+  if ((*pcVar1 == '\x01') && (*(char *)(param_1 + 0x40) == '\x17')) {

+    if (((byte)(*(byte *)(param_1 + 0x43) - 0x30) < 0x20) || (0x5f < *(byte *)(param_1 + 0x43))) {

+      cVar3 = HviIsAnyHypervisorPresent();

+      if (cVar3 == '\0') {

+        uVar2 = rdmsr(0xc00110e3);

+        wrmsr(0xc00110e3,uVar2 & 0xffffffff00000000 | uVar2 & 0xffffffff | 2);

+        uVar2 = rdmsr(0xc001102e);

+        wrmsr(0xc001102e,uVar2 & 0xffffffff00000000 | 0x200000000 | uVar2 & 0xffffffff);

+      }

+    }

   }

-  return;

+  pcVar5 = (char *)Feature_2875967801__private_IsEnabledNoReportingNoInline();

+  if ((((int)pcVar5 != 0) && (pcVar5 = pcVar1, *pcVar1 == '\x01')) &&

+     (*(char *)(param_1 + 0x40) == '\x17')) {

+    if ((*(byte *)(param_1 + 0x43) < 0x30) ||

+       (bVar4 = *(byte *)(param_1 + 0x43) + 0xb0,

+       pcVar5 = (char *)CONCAT71((int7)((ulonglong)pcVar1 >> 8),bVar4), bVar4 < 0x10)) {

+      pcVar5 = (char *)HviIsAnyHypervisorPresent();

+      if ((char)pcVar5 == '\0') {

+        uVar2 = rdmsr(0xc0011028);

+        pcVar5 = (char *)(uVar2 | 0x200);

+        wrmsr(0xc0011028,uVar2 & 0xffffffff00000000 | uVar2 & 0xffffffff | 0x200);

+      }

+    }

+  }

+  return pcVar5;

 }
```

## `ApiSetValidateSchemaElements_V7`  (modified)

```diff
--- ApiSetValidateSchemaElements_V7
+++ ApiSetValidateSchemaElements_V7
@@ -1,17 +1,67 @@
 

-undefined8 ApiSetValidateSchemaElements_V7(void)

+undefined4 ApiSetValidateSchemaElements_V7(longlong param_1)

 

 {

-  short sVar1;

-  undefined4 *unaff_RSI;

-  undefined4 unaff_EDI;

-  short unaff_R13W;

+  uint uVar1;

+  ushort uVar2;

+  ushort uVar3;

+  uint uVar4;

+  longlong lVar5;

+  ulonglong uVar6;

+  uint uVar7;

   

-  sVar1 = ApiSetpSearchForSectionIndex_V7();

-  if (sVar1 == unaff_R13W) {

-    unaff_EDI = 0xf1;

+  uVar2 = *(ushort *)(param_1 + 0x30);

+  uVar7 = 0;

+  if (uVar2 != 0) {

+    uVar6 = (ulonglong)*(ushort *)(param_1 + 0x12);

+    do {

+      lVar5 = ((ulonglong)uVar7 * (ulonglong)*(byte *)(param_1 + 0x34) - uVar6) +

+              (ulonglong)*(uint *)(param_1 + 0x2c);

+      if ((*(byte *)(lVar5 + 10 + param_1) & 2) != 0) {

+        uVar3 = *(ushort *)(lVar5 + 4 + param_1);

+        if (*(ushort *)(param_1 + 0x60) <= uVar3) {

+          return 0xc00000e4;

+        }

+        lVar5 = ((ulonglong)uVar3 * (ulonglong)*(byte *)(param_1 + 100) - uVar6) + param_1;

+        uVar4 = *(uint *)((ulonglong)*(uint *)(param_1 + 0x5c) + 4 + lVar5);

+        if (*(uint *)(param_1 + 0x28) < uVar4) {

+          return 0xc00000e4;

+        }

+        uVar1 = uVar4 + (uint)*(ushort *)((ulonglong)*(uint *)(param_1 + 0x5c) + 8 + lVar5) * 2;

+        if (uVar1 < uVar4) {

+          return 0;

+        }

+        if (*(uint *)(param_1 + 0x28) < uVar1) {

+          return 0xc00000e4;

+        }

+      }

+      uVar7 = uVar7 + 1;

+    } while (uVar7 < uVar2);

   }

-  *unaff_RSI = unaff_EDI;

+  uVar6 = 0;

+  if (*(ushort *)(param_1 + 0x3c) != 0) {

+    do {

+      if (uVar2 <= *(ushort *)

+                    ((uVar6 * *(byte *)(param_1 + 0x40) - (ulonglong)*(ushort *)(param_1 + 0x12)) +

+                     (ulonglong)*(uint *)(param_1 + 0x38) + 4 + param_1)) {

+        return 0xc00000e4;

+      }

+      uVar7 = (int)uVar6 + 1;

+      uVar6 = (ulonglong)uVar7;

+    } while (uVar7 < *(ushort *)(param_1 + 0x3c));

+  }

+  uVar6 = 0;

+  if (*(ushort *)(param_1 + 0x48) != 0) {

+    do {

+      if (uVar2 <= *(ushort *)

+                    ((uVar6 * *(byte *)(param_1 + 0x4c) - (ulonglong)*(ushort *)(param_1 + 0x12)) +

+                     (ulonglong)*(uint *)(param_1 + 0x44) + 4 + param_1)) {

+        return 0xc00000e4;

+      }

+      uVar7 = (int)uVar6 + 1;

+      uVar6 = (ulonglong)uVar7;

+    } while (uVar7 < *(ushort *)(param_1 + 0x48));

+  }

   return 0;

 }
```

## `MiCallCreateSectionFilters`  (modified)

```diff
--- MiCallCreateSectionFilters
+++ MiCallCreateSectionFilters
@@ -1,31 +1,64 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

-/* WARNING: Removing unreachable block (ram,0x00014098c39e) */

-/* WARNING: Removing unreachable block (ram,0x00014098c3e4) */

-/* WARNING: Removing unreachable block (ram,0x00014098c3a0) */

-/* WARNING: Removing unreachable block (ram,0x00014098c3bb) */

-/* WARNING: Removing unreachable block (ram,0x00014098c4df) */

-

-void MiCallCreateSectionFilters(void)

+ulonglong MiCallCreateSectionFilters(uint *param_1)

 

 {

-  undefined4 *unaff_RSI;

-  undefined4 *unaff_R13;

-  undefined4 unaff_R15D;

-  undefined4 uStack0000000000000150;

-  undefined4 uStack0000000000000154;

-  undefined4 uStack0000000000000158;

-  undefined4 uStack000000000000015c;

+  undefined8 uVar1;

+  uint uVar2;

+  int iVar3;

+  ulonglong uVar4;

+  uint uVar5;

+  uint local_res8 [2];

+  undefined4 local_res10 [2];

   

-  *unaff_RSI = uStack0000000000000150;

-  unaff_RSI[1] = uStack0000000000000154;

-  unaff_RSI[2] = uStack0000000000000158;

-  unaff_RSI[3] = uStack000000000000015c;

-  if (unaff_R13 != (undefined4 *)0x0) {

-    *unaff_R13 = unaff_R15D;

+  local_res8[0] = 0;

+  local_res10[0] = 0;

+  if ((*param_1 & 1) != 0) {

+    return 0;

   }

-  FUN_14098c4df();

-  return;

+  uVar1 = *(undefined8 *)(param_1 + 0xe);

+  Feature_Servicing_SecImageNoExecuteFlag__private_IsEnabledDeviceUsageNoInline();

+  uVar4 = FsRtlAcquireToCreateMappedSection(uVar1,param_1[7],0,param_1[4],local_res8,local_res10);

+  iVar3 = (int)uVar4;

+  if (iVar3 < 0) {

+    return uVar4;

+  }

+  if ((local_res8[0] & 6) == 0) goto LAB_0;

+  uVar5 = *param_1;

+  if ((uVar5 >> 0x19 & 1) != 0) {

+    FsRtlReleaseFile(uVar1);

+    return 0xc0000911;

+  }

+  if ((param_1[4] & 0x1000000) == 0) {

+    if ((local_res8[0] & 2) != 0) {

+      uVar5 = uVar5 | 0x4000;

+      goto LAB_1;

+    }

+  }

+  else {

+    *param_1 = uVar5 | 0x4000;

+    uVar2 = uVar5 | 0x4000;

+    if ((local_res8[0] & 4) == 0) {

+      *param_1 = uVar5 | 0x14000;

+      uVar2 = uVar5 | 0x14000;

+    }

+    uVar5 = uVar2;

+    if ((local_res8[0] & 8) == 0) {

+      uVar5 = uVar5 | 0x20000;

+LAB_1:

+      *param_1 = uVar5;

+    }

+  }

+  if ((local_res8[0] & 6) == 6) {

+    *param_1 = uVar5 | 0x8000;

+  }

+LAB_0:

+  if ((iVar3 == 0x12a) || (iVar3 != 299)) {

+    uVar5 = *param_1 & 0xffffffbf;

+  }

+  else {

+    uVar5 = *param_1 | 0x40;

+  }

+  *param_1 = uVar5;

+  return uVar4 & 0xffffffff;

 }
```

## `KeCancelTimerInternal`  (modified)

```diff
--- KeCancelTimerInternal
+++ KeCancelTimerInternal
@@ -1,27 +1,30 @@
 

-bool KeCancelTimerInternal(ushort *param_1,ushort *param_2)

+char KeCancelTimerInternal(uint *param_1,undefined8 *param_2,undefined4 *param_3,uint *param_4)

 

 {

-  ushort uVar1;

-  ushort *puVar2;

+  byte bVar1;

+  char cVar2;

+  uint uVar3;

   

-  uVar1 = 0;

-  puVar2 = (ushort *)register0x00000020;

-  if (param_2 != (ushort *)0x0) {

-    puVar2 = param_2;

+  cVar2 = KiCancelTimer((char)param_1,0);

+  if (cVar2 != '\0') {

+    bVar1 = *(byte *)((longlong)param_1 + 1);

+    *param_2 = *(undefined8 *)(param_1 + 6);

+    *param_3 = 2;

+    if ((bVar1 & 1) == 0) {

+      if ((bVar1 & 2) != 0) {

+        *param_3 = 3;

+      }

+    }

+    else {

+      *param_3 = 1;

+    }

+    uVar3 = KiDecodeTolerableDelayValue(bVar1 >> 2);

+    *param_4 = uVar3 / 10000;

   }

-  *puVar2 = 0x20;

-  do {

-    if (*param_1 <= uVar1) {

-      return *puVar2 != 0x20;

-    }

-    if (*(longlong *)(param_1 + (ulonglong)uVar1 * 4 + 4) != 0) {

-      if (*puVar2 != 0x20) {

-        return false;

-      }

-      *puVar2 = uVar1;

-    }

-    uVar1 = uVar1 + 1;

-  } while( true );

+  LOCK();

+  *param_1 = *param_1 & 0xffffff7f;

+  UNLOCK();

+  return cVar2;

 }
```

## `PpmHeteroHgsCpuSupportedForContainment`  (modified)

```diff
--- PpmHeteroHgsCpuSupportedForContainment
+++ PpmHeteroHgsCpuSupportedForContainment
@@ -1,68 +1,54 @@
 

-/* WARNING: Instruction at (ram,0x0001405d43a2) overlaps instruction at (ram,0x0001405d439f)

-    */

-

-void PpmHeteroHgsCpuSupportedForContainment

-               (longlong param_1,code *param_2,undefined8 param_3,undefined8 param_4)

+bool PpmHeteroHgsCpuSupportedForContainment(void)

 

 {

-  undefined8 uVar1;

-  undefined8 *puVar2;

-  undefined8 *puVar3;

-  uint unaff_EBX;

-  uint uVar4;

-  ulonglong uVar5;

-  longlong unaff_RDI;

-  char in_CF;

-  bool in_ZF;

-  unkbyte10 in_ST0;

+  void *pvVar1;

+  undefined1 extraout_AL;

+  undefined1 uVar2;

+  undefined1 extraout_AL_00;

+  byte bVar3;

+  undefined1 extraout_AH;

+  undefined1 extraout_AH_00;

+  undefined1 extraout_AH_01;

+  undefined2 extraout_var;

+  undefined2 extraout_var_00;

   

-  if (in_ZF) {

-    fcos(in_ST0);

+  Feature_PpmParkEx__private_IsEnabledNoReportingNoInline();

+  if ((CONCAT22(extraout_var,CONCAT11(extraout_AH,extraout_AL)) &

+      CONCAT22(extraout_var,CONCAT11(extraout_AH,extraout_AL))) != 0) {

+    if (1 < KiActiveGroups) {

+      return false;

+    }

+    uVar2 = KeQueryActiveNodeCount();

+    if (1 < CONCAT11(extraout_AH_00,uVar2)) {

+      return false;

+    }

+  }

+  pvVar1 = FiberData;

+  Feature_WpsExtendedFamilyContainment__private_IsEnabledDeviceUsageNoInline();

+  if ((CONCAT22(extraout_var_00,CONCAT11(extraout_AH_01,extraout_AL_00)) &

+      CONCAT22(extraout_var_00,CONCAT11(extraout_AH_01,extraout_AL_00))) == 0) {

+    if (*(char *)((longlong)pvVar1 + 0x8d) != '\x02') {

+      return false;

+    }

   }

   else {

-    *(char *)(unaff_RDI + 0x48) = (*(char *)(unaff_RDI + 0x48) - (char)param_2) - in_CF;

-    register0x00000020 = (BADSPACEBASE *)(ulonglong)((int)&stack0x00000000 - 0x20);

-    unaff_EBX = 0;

-    param_2 = PpmCheckReset;

-    param_4 = 0;

-    param_3 = 0;

-    unaff_RDI = param_1;

-    if (param_1 == 0) {

-      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1405d43e6;

-      PopExecuteOnTargetProcessors(&PpmCheckRegistered,PpmCheckReset,0,0);

-      for (puVar2 = PpmPerfDomainHead; (undefined8 **)puVar2 != &PpmPerfDomainHead;

-          puVar2 = (undefined8 *)*puVar2) {

-        uVar5 = 0;

-        if (*(int *)(puVar2 + 0x25) != 0) {

-          do {

-            puVar3 = (undefined8 *)(uVar5 * 0x4a8 + puVar2[0x27]);

-            if (*(int *)(puVar3 + 2) == 1) {

-              uVar1 = *puVar3;

-              *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1405d441e;

-              PpmResetPerfTimes(uVar1);

-            }

-            uVar4 = (int)uVar5 + 1;

-            uVar5 = (ulonglong)uVar4;

-          } while (uVar4 < *(uint *)(puVar2 + 0x25));

-        }

-      }

-      return;

+    if (*(char *)((longlong)pvVar1 + 0x8d) != '\x02') {

+      return false;

+    }

+    if ('\x0f' < *(char *)((longlong)pvVar1 + 0x40)) {

+      return true;

     }

   }

-  *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1405d43a4;

-  PopExecuteOnTargetProcessors(param_1 + 0x18,param_2,param_3,param_4);

-  if (unaff_EBX < *(uint *)(unaff_RDI + 0x128)) {

-    do {

-      puVar2 = (undefined8 *)((ulonglong)unaff_EBX * 0x4a8 + *(longlong *)(unaff_RDI + 0x138));

-      if (*(int *)(puVar2 + 2) == 1) {

-        uVar1 = *puVar2;

-        *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1405d43ce;

-        PpmResetPerfTimes(uVar1);

-      }

-      unaff_EBX = unaff_EBX + 1;

-    } while (unaff_EBX < *(uint *)(unaff_RDI + 0x128));

+  if (*(char *)((longlong)pvVar1 + 0x40) != '\x06') {

+    return false;

   }

-  return;

+  if ((*(char *)((longlong)pvVar1 + 0x43) != -0x56) &&

+     ((bVar3 = *(char *)((longlong)pvVar1 + 0x43) + 0x54, 0x21 < bVar3 ||

+      ((0x306030201U >> ((ulonglong)CONCAT22(extraout_var_00,CONCAT11(extraout_AH_01,bVar3)) & 0x3f)

+       & 1) == 0)))) {

+    return *(char *)((longlong)pvVar1 + 0x43) == -0x2b;

+  }

+  return true;

 }
```

## `ApiSetCompose_ProcessV7Extension_Phase1`  (modified)

```diff
--- ApiSetCompose_ProcessV7Extension_Phase1
+++ ApiSetCompose_ProcessV7Extension_Phase1
@@ -1,97 +1,265 @@
 

-/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

-

-ulonglong ApiSetCompose_ProcessV7Extension_Phase1(undefined8 *param_1,uint *param_2,int *param_3)

+int ApiSetCompose_ProcessV7Extension_Phase1

+              (longlong param_1,longlong param_2,undefined8 param_3,undefined8 param_4)

 

 {

-  char cVar1;

-  uint uVar2;

-  uint uVar3;

-  ulonglong uVar4;

-  int *piVar5;

+  byte *pbVar1;

+  ushort uVar2;

+  char cVar3;

+  short sVar4;

+  int iVar5;

   ulonglong uVar6;

-  int *piVar7;

-  undefined1 auStack_150 [32];

-  int aiStack_130 [4];

-  char cStack_120;

-  int *piStack_110;

-  int *piStack_108;

-  ulonglong uStack_20;

+  longlong lVar7;

+  byte bVar8;

+  uint uVar9;

+  longlong lVar10;

+  longlong lVar11;

+  byte bVar12;

+  ulonglong uVar13;

+  undefined7 uVar15;

+  ulonglong uVar14;

+  undefined2 *puVar16;

+  longlong lVar17;

+  undefined2 uVar18;

+  uint *puVar20;

+  ushort uVar21;

+  int iVar22;

+  bool bVar23;

+  ushort local_res8 [4];

+  undefined2 local_res20;

+  longlong local_88;

+  longlong local_68;

+  undefined8 uStack_60;

+  longlong local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

+  uint uVar19;

   

-  uStack_20 = __security_cookie ^ (ulonglong)auStack_150;

-  piVar5 = (int *)*param_1;

-  cVar1 = ApiSetIsSchemaSealed();

-  if ((cVar1 == '\0') &&

-     (((char)*piVar5 == '\a' ||

-      (((*piVar5 == 6 && (8 < (uint)piVar5[4])) && ((char)piVar5[7] == '\a')))))) {

-    uVar4 = ApiSetValidateSchemaFormat_V7();

-    if ((int)uVar4 < 0) {

-      return uVar4;

-    }

-    if ((*param_3 == 6) || ((char)*param_3 == '\a')) {

-      uVar4 = ApiSetValidateSchemaFormat(param_3);

-      if ((int)uVar4 < 0) {

-        return uVar4;

-      }

-      memset(aiStack_130,0,0x110);

-      ApiSetSchemaExpander_Initialize(*param_1,param_3,aiStack_130);

-      if ((char)*param_3 == '\a') {

-        uVar2 = func_0x000140660528();

+  uVar2 = *(ushort *)(param_1 + 0x10);

+  iVar5 = 0;

+  if (uVar2 != 0) {

+    local_48 = 0;

+    local_68 = (ulonglong)*(uint *)(param_1 + 8) + param_1;

+    uStack_50 = 0;

+    local_58 = (ulonglong)uVar2 << 0x10;

+    lVar7 = *(longlong *)(param_2 + 0x20);

+    uStack_60 = (ulonglong)uVar2;

+    sVar4 = ApiSetpSearchForSectionIndex_V7

+                      (lVar7,lVar7 + 0x50,&local_68,

+                       CONCAT71((int7)((ulonglong)param_4 >> 8),*(byte *)(lVar7 + 0x59) >> 1) &

+                       0xffffffffffffff01);

+    if (sVar4 != -1) {

+      return -0x3fffffcb;

+    }

+    iVar5 = ApiSetSchemaExpander_InsertExtensionNameEntry(param_2,&local_68);

+    if (iVar5 < 0) {

+      return iVar5;

+    }

+  }

+  bVar23 = *(short *)(param_1 + 0x12) != 0;

+  uVar9 = 0;

+  do {

+    if (!bVar23) {

+      return iVar5;

+    }

+    uVar6 = (ulonglong)uVar9;

+    local_48 = 0;

+    local_68 = 0;

+    uStack_60 = 0;

+    lVar7 = (ulonglong)*(uint *)(param_1 + 0xc) + param_1;

+    local_58 = 0;

+    uStack_50 = 0;

+    uVar13 = (ulonglong)*(ushort *)(lVar7 + 8 + uVar6 * 0x14);

+    cVar3 = ApiSetpGetContractKeyInfo

+                      ((ulonglong)*(uint *)(lVar7 + uVar6 * 0x14) + param_1,uVar13,0,&local_68);

+    if ((cVar3 == '\0') || (iVar22 = uStack_60._4_4_, 1 < uStack_60._4_4_ - 2U)) {

+      return -0x3fffffcd;

+    }

+    lVar11 = *(longlong *)(param_2 + 0x20);

+    uVar13 = CONCAT71((int7)(uVar13 >> 8),*(byte *)(lVar11 + 2)) & 0xffffffffffffff10;

+    bVar8 = *(byte *)(lVar11 + 2) & 8;

+    uVar15 = (undefined7)(uVar13 >> 8);

+    cVar3 = (char)uVar13;

+    if ((*(byte *)(lVar11 + 0x35) & 4) == 0) {

+      uVar19 = ApiSetpGetSearchKeyHash

+                         (&local_68,CONCAT71(uVar15,1),bVar8 != 0,cVar3 != '\0',

+                          *(undefined1 *)(lVar11 + 0x37));

+    }

+    else {

+      bVar8 = ApiSetpGetSearchKeyHash

+                        (&local_68,CONCAT71(uVar15,1),bVar8 != 0,cVar3 != '\0',

+                         *(undefined1 *)(lVar11 + 0x37));

+      uVar19 = (uint)bVar8;

+    }

+    local_res8[0] = ApiSetpSearchForSectionIndex_V7(lVar11,lVar11 + 0x2c,&local_68,1);

+    uVar13 = (ulonglong)local_res8[0];

+    if (local_res8[0] == 0xffff) {

+      iVar5 = ApiSetSchemaExpander_InsertContractEntry(param_2,&local_68,local_res8);

+      if (iVar5 < 0) {

+        return iVar5;

+      }

+      uVar13 = (ulonglong)local_res8[0];

+      iVar22 = uStack_60._4_4_;

+    }

+    else if (*(uint *)((*(byte *)(lVar11 + 0x34) * uVar13 - (ulonglong)*(ushort *)(lVar11 + 0x12)) +

+                      (ulonglong)*(uint *)(lVar11 + 0x2c) + lVar11) != uVar19) {

+      return -0x3ffffdd7;

+    }

+    lVar11 = *(longlong *)(param_2 + 0x20);

+    uVar2 = 0xffff;

+    local_res20 = 0xffff;

+    bVar8 = *(byte *)(lVar11 + 2) & 8;

+    bVar12 = *(byte *)(lVar11 + 2) & 0x10;

+    if (iVar22 == 2) {

+      if ((*(byte *)(lVar11 + 0x41) & 4) == 0) {

+        uVar19 = ApiSetpGetSearchKeyHash

+                           (&local_68,0,bVar8 != 0,bVar12 != 0,*(undefined1 *)(lVar11 + 0x43));

       }

       else {

-        uVar2 = ApiSetCompose_V7_ProcessV6Extension_Phase0(param_3,aiStack_130);

-      }

-      if ((int)uVar2 < 0) {

-        return (ulonglong)uVar2;

-      }

-      uVar2 = ApiSetSchemaExpander_GetNewSchemaSize(aiStack_130);

-      uVar4 = (ulonglong)uVar2;

-      piVar5 = (int *)ExAllocatePool2(0x100,uVar2,0x68635341);

-      if (piVar5 == (int *)0x0) {

-        return 0xc0000017;

-      }

-      memset(piVar5,0x3f,uVar4);

-      piStack_110 = piVar5;

-      if (cStack_120 != '\0') {

-        piStack_110 = piVar5 + 7;

-      }

-      piStack_108 = piVar5;

-      ApiSetSchemaExpander_ExpandSchema(aiStack_130,uVar4);

-      if (((*piVar5 != 6) || ((uint)piVar5[4] < 9)) ||

-         (piVar7 = piVar5 + 7, (char)piVar5[7] != '\a')) {

-        piVar7 = piVar5;

-      }

-      uVar3 = ApiSetValidateSchemaHeader_V7(piVar7,uVar2);

-      uVar6 = (ulonglong)uVar3;

-      if (-1 < (int)uVar3) {

-        ApiSetSchemaExpander_MigrateSchemaData(aiStack_130);

-        uVar3 = ApiSetValidateSchemaElements_V7(piVar7);

-        uVar6 = (ulonglong)uVar3;

-        if (-1 < (int)uVar3) {

-          aiStack_130[0] = aiStack_130[0] + 1;

-          if ((char)*param_3 == '\a') {

-            uVar3 = func_0x0001406607ac();

+        bVar8 = ApiSetpGetSearchKeyHash

+                          (&local_68,0,bVar8 != 0,bVar12 != 0,*(undefined1 *)(lVar11 + 0x43));

+        uVar19 = (uint)bVar8;

+      }

+      local_res8[0] = ApiSetpSearchForSectionIndex_V7(lVar11,lVar11 + 0x38,&local_68);

+      uVar14 = (ulonglong)local_res8[0];

+      if (local_res8[0] == 0xffff) {

+        iVar5 = ApiSetSchemaExpander_InsertGroupContractEntry(param_2,&local_68,local_res8);

+        goto LAB_0;

+      }

+      lVar10 = (*(byte *)(lVar11 + 0x40) * uVar14 + (ulonglong)*(uint *)(lVar11 + 0x38)) -

+               (ulonglong)*(ushort *)(lVar11 + 0x12);

+      if (*(uint *)(lVar10 + lVar11) != uVar19) {

+        return -0x3ffffdd7;

+      }

+      bVar8 = *(byte *)(lVar10 + 6 + lVar11);

+      lVar10 = ((ulonglong)*(byte *)(lVar11 + 0x34) * (ulonglong)*(ushort *)(lVar10 + 4 + lVar11) +

+               (ulonglong)*(uint *)(lVar11 + 0x2c)) - (ulonglong)*(ushort *)(lVar11 + 0x12);

+      uVar2 = *(ushort *)(lVar10 + 4 + lVar11);

+      local_res20 = *(undefined2 *)(lVar10 + 6 + lVar11);

+LAB_1:

+      if ((bVar8 & 1) == 0) goto LAB_2;

+    }

+    else {

+      if ((*(byte *)(lVar11 + 0x4d) & 4) == 0) {

+        uVar19 = ApiSetpGetSearchKeyHash

+                           (&local_68,0,bVar8 != 0,bVar12 != 0,*(undefined1 *)(lVar11 + 0x4f));

+      }

+      else {

+        bVar8 = ApiSetpGetSearchKeyHash

+                          (&local_68,0,bVar8 != 0,bVar12 != 0,*(undefined1 *)(lVar11 + 0x4f));

+        uVar19 = (uint)bVar8;

+      }

+      local_res8[0] = ApiSetpSearchForSectionIndex_V7(lVar11,lVar11 + 0x44,&local_68);

+      uVar14 = (ulonglong)local_res8[0];

+      if (local_res8[0] != 0xffff) {

+        lVar10 = (*(byte *)(lVar11 + 0x4c) * uVar14 + (ulonglong)*(uint *)(lVar11 + 0x44)) -

+                 (ulonglong)*(ushort *)(lVar11 + 0x12);

+        if (*(uint *)(lVar10 + lVar11) != uVar19) {

+          return -0x3ffffdd7;

+        }

+        lVar17 = ((ulonglong)*(byte *)(lVar11 + 0x34) * (ulonglong)*(ushort *)(lVar10 + 4 + lVar11)

+                 + (ulonglong)*(uint *)(lVar11 + 0x2c)) - (ulonglong)*(ushort *)(lVar11 + 0x12);

+        uVar2 = *(ushort *)(lVar17 + 4 + lVar11);

+        local_res20 = *(undefined2 *)(lVar17 + 6 + lVar11);

+        bVar8 = *(byte *)(lVar10 + 10 + lVar11);

+        goto LAB_1;

+      }

+      iVar5 = ApiSetSchemaExpander_InsertSemverContractEntry(param_2,&local_68,local_res8);

+LAB_0:

+      if (iVar5 < 0) {

+        return iVar5;

+      }

+      uVar14 = (ulonglong)local_res8[0];

+      iVar22 = uStack_60._4_4_;

+LAB_2:

+      lVar11 = *(longlong *)(param_2 + 0x20);

+      if (iVar22 == 2) {

+        lVar10 = (*(byte *)(lVar11 + 0x40) * uVar14 + (ulonglong)*(uint *)(lVar11 + 0x38)) -

+                 (ulonglong)*(ushort *)(lVar11 + 0x12);

+        *(short *)(lVar10 + 4 + lVar11) = (short)uVar13;

+        *(undefined4 *)(lVar10 + 8 + lVar11) = *(undefined4 *)(lVar7 + 0xc + uVar6 * 0x14);

+      }

+      else {

+        lVar10 = (*(byte *)(lVar11 + 0x4c) * uVar14 + (ulonglong)*(uint *)(lVar11 + 0x44)) -

+                 (ulonglong)*(ushort *)(lVar11 + 0x12);

+        *(short *)(lVar10 + 4 + lVar11) = (short)uVar13;

+        if ((*(byte *)(lVar7 + 0x11 + uVar6 * 0x14) & 4) != 0) {

+          pbVar1 = (byte *)(lVar10 + 10 + lVar11);

+          *pbVar1 = *pbVar1 | 4;

+        }

+      }

+      local_88 = 0;

+      if ((*(char *)(param_2 + 0x10) != '\0') && (iVar22 == 3)) {

+        local_88 = ApiSetpSearchForApiSetA(*(undefined8 *)(param_2 + 0x28),local_68);

+      }

+      uVar21 = 0;

+      if (*(short *)(lVar7 + 10 + uVar6 * 0x14) != 0) {

+        do {

+          lVar11 = *(longlong *)(param_2 + 0x20);

+          puVar20 = (uint *)((ulonglong)*(uint *)(lVar7 + 4 + uVar6 * 0x14) +

+                            (ulonglong)uVar21 * 0x10 + param_1);

+          local_48 = 0;

+          uStack_50 = 0;

+          local_68 = (ulonglong)*puVar20 + param_1;

+          local_58 = (ulonglong)(ushort)puVar20[2] << 0x10;

+          uStack_60 = (ulonglong)CONCAT12(1,(ushort)puVar20[2]);

+          local_res8[0] = ApiSetpSearchForSectionIndex_V7(lVar11,lVar11 + 0x5c,&local_68);

+          if (local_res8[0] == 0xffff) {

+            iVar5 = ApiSetSchemaExpander_InsertHostEntry(param_2,&local_68,local_res8);

+            if (iVar5 < 0) {

+              return iVar5;

+            }

+            lVar11 = *(longlong *)(param_2 + 0x20);

+          }

+          bVar23 = *(short *)((longlong)puVar20 + 10) == 0;

+          if (bVar23) {

+            uVar18 = 0xffff;

           }

           else {

-            uVar3 = ApiSetCompose_V7_ProcessV6Extension_Phase1(param_3,aiStack_130);

-          }

-          uVar6 = (ulonglong)uVar3;

-          if (-1 < (int)uVar3) {

-            uVar3 = ApiSetValidateSchemaFormat_V7(piVar5,uVar4);

-            uVar6 = (ulonglong)uVar3;

-            if (-1 < (int)uVar3) {

-              ExFreePoolWithTag(*param_1,0);

-              *param_1 = piVar5;

-              *param_2 = uVar2;

-              return uVar6;

-            }

-          }

-        }

-      }

-      ExFreePoolWithTag(piVar5,0);

-      return uVar6;

-    }

-  }

-  return 0xc000000d;

+            uVar19 = *(uint *)(param_2 + 0x9c) >> 4;

+            uVar18 = (undefined2)uVar19;

+            *(uint *)(param_2 + 0x9c) = *(uint *)(param_2 + 0x9c) + 0x10;

+            puVar16 = (undefined2 *)

+                      ((((ulonglong)*(ushort *)(lVar11 + 0x72) * (ulonglong)(uVar19 & 0xffff) +

+                        (ulonglong)*(uint *)(lVar11 + 0x68)) - (ulonglong)*(ushort *)(lVar11 + 0x12)

+                       ) + lVar11);

+            lVar10 = ((ulonglong)*(byte *)(lVar11 + 100) * (ulonglong)uVar2 +

+                     (ulonglong)*(uint *)(lVar11 + 0x5c)) - (ulonglong)*(ushort *)(lVar11 + 0x12);

+            *(undefined4 *)(puVar16 + 4) = *(undefined4 *)(lVar10 + 4 + lVar11);

+            puVar16[7] = *(undefined2 *)(lVar10 + 8 + lVar11);

+            lVar11 = *(longlong *)(param_2 + 0x20);

+            lVar11 = (ulonglong)*(uint *)(lVar11 + 0x5c) +

+                     lVar11 + ((ulonglong)*(byte *)(lVar11 + 100) * (ulonglong)local_res8[0] -

+                              (ulonglong)*(ushort *)(lVar11 + 0x12));

+            *(undefined4 *)(puVar16 + 2) = *(undefined4 *)(lVar11 + 4);

+            puVar16[6] = *(undefined2 *)(lVar11 + 8);

+            *puVar16 = local_res20;

+          }

+          lVar11 = *(longlong *)(param_2 + 0x20);

+          lVar11 = (ulonglong)*(uint *)(lVar11 + 0x2c) +

+                   lVar11 + (*(byte *)(lVar11 + 0x34) * uVar13 -

+                            (ulonglong)*(ushort *)(lVar11 + 0x12));

+          *(byte *)(lVar11 + 10) = *(byte *)(lVar11 + 10) | 2;

+          *(ushort *)(lVar11 + 4) = local_res8[0];

+          if (!bVar23) {

+            *(short *)(lVar11 + 8) = *(short *)(lVar11 + 8) + 1;

+            *(undefined2 *)(lVar11 + 6) = uVar18;

+          }

+          if (local_88 != 0) {

+            lVar11 = *(longlong *)(param_2 + 0x20);

+            lVar17 = (ulonglong)*(uint *)(local_88 + 0x10) + *(longlong *)(param_2 + 0x28);

+            lVar10 = (ulonglong)*(uint *)(lVar11 + 0x5c) +

+                     lVar11 + ((ulonglong)*(byte *)(lVar11 + 100) * (ulonglong)local_res8[0] -

+                              (ulonglong)*(ushort *)(lVar11 + 0x12));

+            *(int *)(lVar17 + 0xc) = *(int *)(lVar11 + 0x24) + *(int *)(lVar10 + 4);

+            *(uint *)(lVar17 + 0x10) = (uint)*(ushort *)(lVar10 + 8) * 2;

+          }

+          uVar21 = uVar21 + 1;

+        } while (uVar21 < *(ushort *)(lVar7 + 10 + uVar6 * 0x14));

+      }

+    }

+    uVar9 = uVar9 + 1;

+    bVar23 = uVar9 < *(ushort *)(param_1 + 0x12);

+  } while( true );

 }
```

## `ApiSetCompose_ProcessV7Extension_Phase0`  (modified)

```diff
--- ApiSetCompose_ProcessV7Extension_Phase0
+++ ApiSetCompose_ProcessV7Extension_Phase0
@@ -1,72 +1,112 @@
 

-undefined8 ApiSetCompose_ProcessV7Extension_Phase0(void)

+undefined4 ApiSetCompose_ProcessV7Extension_Phase0(longlong param_1,longlong param_2)

 

 {

-  ushort uVar1;

-  short sVar2;

-  longlong lVar3;

+  char cVar1;

+  byte bVar2;

+  ushort uVar3;

   short sVar4;

-  char cVar5;

-  uint uVar6;

-  longlong in_RAX;

-  byte bVar7;

-  longlong lVar8;

-  byte bVar9;

-  longlong unaff_RBX;

-  longlong unaff_RBP;

-  uint unaff_ESI;

-  longlong unaff_RDI;

-  uint *puVar10;

-  short *unaff_R12;

-  byte unaff_R13B;

-  byte unaff_R14B;

+  longlong lVar5;

+  longlong lVar6;

+  ulonglong uVar7;

+  uint uVar8;

+  ulonglong uVar9;

+  uint uVar10;

+  ulonglong uVar11;

+  uint *puVar12;

+  uint local_res8;

+  longlong local_68;

+  undefined8 uStack_60;

+  longlong local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

   

-  puVar10 = (uint *)(unaff_RDI + in_RAX);

-  bVar9 = *(byte *)(unaff_RBX + 2) & 0x10;

-  bVar7 = *(byte *)(unaff_RBX + 2) & 8;

-  if ((*(byte *)(unaff_RBX + 0x41) & 4) == 0) {

-    uVar6 = ApiSetpGetSearchKeyHash(unaff_RBP + -0x30,0,bVar7 != 0,bVar9 != 0);

+  if (*(short *)(param_1 + 0x10) != 0) {

+    *(short *)(param_2 + 0xd4) = *(short *)(param_2 + 0xd4) + 1;

+    *(int *)(param_2 + 0xd8) = *(int *)(param_2 + 0xd8) + 0xc;

   }

-  else {

-    bVar7 = ApiSetpGetSearchKeyHash(unaff_RBP + -0x30,0,bVar7 != 0,bVar9 != 0);

-    uVar6 = (uint)bVar7;

-  }

-  if ((*puVar10 == uVar6) &&

-     (((*(byte *)((longlong)puVar10 + 6) & 4) == 0 ||

-      ((unaff_R13B = unaff_R14B, (*(byte *)((longlong)puVar10 + 6) & 2) == 0 &&

-       ((puVar10[2] == 0 || (cVar5 = ApiSetpIsFeatureEnabled(), cVar5 != '\0')))))))) {

-    uVar1 = *(ushort *)(unaff_RBX + 0x12);

-    lVar8 = (((ulonglong)(ushort)puVar10[1] * (ulonglong)*(byte *)(unaff_RBX + 0x34) +

-             (ulonglong)*(uint *)(unaff_RBX + 0x2c)) - (ulonglong)uVar1) + unaff_RBX;

-    sVar2 = *(short *)(lVar8 + 8);

-    unaff_R13B = 1;

-    if ((*(byte *)(lVar8 + 10) >> 1 & unaff_R14B) != 0) {

-      lVar8 = ((ulonglong)*(byte *)(unaff_RBX + 100) * (ulonglong)*(ushort *)(lVar8 + 4) +

-              (ulonglong)*(uint *)(unaff_RBX + 0x5c)) - (ulonglong)uVar1;

-      if (*(byte *)(lVar8 + 10 + unaff_RBX) <= *(byte *)(unaff_RBX + 3)) {

-        lVar3 = *(longlong *)(unaff_RBP + 0x50);

-        *(ulonglong *)(unaff_R12 + 4) =

-             (ulonglong)*(uint *)(unaff_RBX + 0x24) +

-             ((ulonglong)*(uint *)(lVar8 + 4 + unaff_RBX) - (ulonglong)uVar1) + unaff_RBX;

-        sVar4 = *(short *)(lVar8 + 8 + unaff_RBX) * 2;

-        *unaff_R12 = sVar4;

-        unaff_R12[1] = sVar4;

-        if (((lVar3 != 0) && (sVar2 != 0)) &&

-           (uVar6 = ApiSetpSearchForHostOverrideIndex_V7(), uVar6 != unaff_ESI)) {

-          lVar8 = ((ulonglong)*(ushort *)(unaff_RBX + 0x72) * (ulonglong)uVar6 +

-                  (ulonglong)*(uint *)(unaff_RBX + 0x68)) - (ulonglong)*(ushort *)(unaff_RBX + 0x12)

-          ;

-          *(ulonglong *)(unaff_R12 + 4) =

-               (((ulonglong)*(uint *)(lVar8 + 8 + unaff_RBX) +

-                (ulonglong)*(uint *)(unaff_RBX + 0x24)) - (ulonglong)*(ushort *)(unaff_RBX + 0x12))

-               + unaff_RBX;

-          unaff_R12[1] = *(short *)(lVar8 + 0xe + unaff_RBX) * 2;

-          *unaff_R12 = *(short *)(lVar8 + 0xe + unaff_RBX) * 2;

+  uVar11 = 0;

+  local_res8 = 0;

+  if (*(short *)(param_1 + 0x12) != 0) {

+    do {

+      local_48 = 0;

+      local_68 = 0;

+      uStack_60 = 0;

+      lVar5 = (ulonglong)*(uint *)(param_1 + 0xc) + param_1;

+      local_58 = 0;

+      uStack_50 = 0;

+      cVar1 = ApiSetpGetContractKeyInfo

+                        ((ulonglong)*(uint *)(lVar5 + uVar11 * 0x14) + param_1,

+                         *(undefined2 *)(lVar5 + 8 + uVar11 * 0x14),0,&local_68);

+      if ((cVar1 == '\0') || (1 < uStack_60._4_4_ - 2U)) {

+        return 0xc0000033;

+      }

+      lVar6 = *(longlong *)(param_2 + 8);

+      uVar7 = 0;

+      uVar10 = (uint)uVar11;

+      if (uStack_60._4_4_ == 2) {

+        uVar3 = ApiSetpSearchForSectionIndex_V7(lVar6,lVar6 + 0x38,&local_68,0);

+        if (uVar3 == 0xffff) {

+          *(short *)(param_2 + 0xb0) = *(short *)(param_2 + 0xb0) + 1;

+          bVar2 = 0;

+          *(int *)(param_2 + 0xb4) = *(int *)(param_2 + 0xb4) + 0x14;

+          *(short *)(param_2 + 0xa4) = *(short *)(param_2 + 0xa4) + 1;

+          *(int *)(param_2 + 0xa8) = *(int *)(param_2 + 0xa8) + 0x14;

+        }

+        else {

+          bVar2 = *(byte *)((ulonglong)*(uint *)(lVar6 + 0x38) + 6 +

+                           ((ulonglong)uVar3 * (ulonglong)*(byte *)(lVar6 + 0x40) -

+                           (ulonglong)*(ushort *)(lVar6 + 0x12)) + lVar6) & 1;

+        }

+LAB_0:

+        if (bVar2 == 0) goto LAB_1;

+      }

+      else {

+        uVar3 = ApiSetpSearchForSectionIndex_V7(lVar6,lVar6 + 0x44,&local_68,0);

+        if (uVar3 != 0xffff) {

+          bVar2 = *(byte *)((ulonglong)*(uint *)(lVar6 + 0x44) + 10 +

+                           lVar6 + ((ulonglong)*(byte *)(lVar6 + 0x4c) * (ulonglong)uVar3 -

+                                   (ulonglong)*(ushort *)(lVar6 + 0x12))) & 1;

+          goto LAB_0;

+        }

+        *(int *)(param_2 + 0xc0) = *(int *)(param_2 + 0xc0) + 0x14;

+        *(short *)(param_2 + 0xbc) = *(short *)(param_2 + 0xbc) + 1;

+        *(short *)(param_2 + 0xa4) = *(short *)(param_2 + 0xa4) + 1;

+        *(int *)(param_2 + 0xa8) = *(int *)(param_2 + 0xa8) + 0x14;

+LAB_1:

+        uVar9 = 0;

+        if (*(short *)(lVar5 + 10 + uVar11 * 0x14) != 0) {

+          do {

+            uStack_50 = 0;

+            uVar7 = CONCAT71((int7)(uVar7 >> 8),*(byte *)(lVar6 + 0x65) >> 1) & 0xffffffffffffff01;

+            puVar12 = (uint *)((ulonglong)*(uint *)(lVar5 + 4 + uVar11 * 0x14) +

+                              uVar9 * 0x10 + param_1);

+            local_48 = 0;

+            local_68 = (ulonglong)*puVar12 + param_1;

+            uStack_60 = (ulonglong)CONCAT12(1,(ushort)puVar12[2]);

+            local_58 = (ulonglong)(ushort)puVar12[2] << 0x10;

+            sVar4 = ApiSetpSearchForSectionIndex_V7(lVar6,lVar6 + 0x5c,&local_68,uVar7);

+            if ((sVar4 == -1) && ((puVar12[3] & 1) == 0)) {

+              *(short *)(param_2 + 200) = *(short *)(param_2 + 200) + 1;

+              *(int *)(param_2 + 0xcc) = *(int *)(param_2 + 0xcc) + 0x14;

+              *(int *)(param_2 + 0xe8) = *(int *)(param_2 + 0xe8) + (uint)(ushort)puVar12[2] * 2;

+              *(ushort *)(puVar12 + 3) = (ushort)puVar12[3] | 1;

+              lVar6 = *(longlong *)(param_2 + 8);

+            }

+            if (*(short *)((longlong)puVar12 + 10) != 0) {

+              *(short *)(param_2 + 0xe0) = *(short *)(param_2 + 0xe0) + 1;

+              *(int *)(param_2 + 0xe4) = *(int *)(param_2 + 0xe4) + 0x10;

+            }

+            uVar8 = (int)uVar9 + 1;

+            uVar9 = (ulonglong)uVar8;

+            uVar10 = local_res8;

+          } while (uVar8 < *(ushort *)(lVar5 + 10 + uVar11 * 0x14));

         }

       }

-    }

+      local_res8 = uVar10 + 1;

+      uVar11 = (ulonglong)local_res8;

+    } while (local_res8 < *(ushort *)(param_1 + 0x12));

   }

-  **(byte **)(unaff_RBP + 0x58) = unaff_R13B;

   return 0;

 }
```

## `Pdcv2EventWrite_ACTIVATION_CLIENT_REGISTER`  (modified)

```diff
--- Pdcv2EventWrite_ACTIVATION_CLIENT_REGISTER
+++ Pdcv2EventWrite_ACTIVATION_CLIENT_RENEW_ACTIVATION
@@ -1,7 +1,101 @@
 

-void Pdcv2EventWrite_ACTIVATION_CLIENT_REGISTER(void)

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

+

+ulonglong Pdcv2EventWrite_ACTIVATION_CLIENT_RENEW_ACTIVATION

+                    (longlong param_1,longlong param_2,undefined8 param_3,longlong param_4)

 

 {

-  return;

+  undefined1 auVar1 [16];

+  ulonglong uVar2;

+  longlong lVar3;

+  longlong lVar4;

+  longlong unaff_RBX;

+  longlong *plVar5;

+  uint unaff_ESI;

+  longlong unaff_RDI;

+  longlong lVar6;

+  uint uVar7;

+  undefined4 unaff_R13D;

+  longlong unaff_R14;

+  longlong lVar8;

+  undefined8 in_stack_00000020;

+  undefined4 uVar9;

+  

+  uVar9 = (undefined4)((ulonglong)in_stack_00000020 >> 0x20);

+  uVar2 = (ulonglong)bRam44f18b4dd98b48ff;

+  plVar5 = (longlong *)(ulonglong)unaff_ESI;

+  lVar6 = unaff_RDI;

+  uVar7 = unaff_ESI;

+  if (param_2 != 0) {

+    uVar7 = *(uint *)(param_2 + 0x20);

+    lVar6 = param_2 + 0x80;

+    unaff_R13D = *(undefined4 *)(param_2 + 0x100);

+    unaff_ESI = *(uint *)(param_2 + 0x104);

+    *(uint *)(plVar5 + -0x10) = uVar7;

+  }

+  lVar8 = unaff_RDI;

+  if (unaff_RBX != 0) {

+    unaff_RDI = param_1 + 0x50;

+    *(undefined4 *)(plVar5 + -0xf) = *(undefined4 *)(param_1 + 0x48);

+    lVar8 = param_1 + 0x150;

+    auVar1._8_8_ = 0;

+    auVar1._0_8_ = _DAT_0 << 8;

+    auVar1 = auVar1 * (ZEXT416(_DAT_1) << 0x20);

+    uVar2 = auVar1._0_8_;

+    unaff_R14 = auVar1._8_8_ - *(longlong *)(unaff_RBX + 0x30);

+  }

+  lVar4 = param_4;

+  if ((DAT_2 & 0x40) != 0) {

+    do {

+      lVar4 = lVar4 + 1;

+      lVar3 = param_4;

+    } while (*(short *)(lVar6 + lVar4 * 2) != 0);

+    do {

+      lVar3 = lVar3 + 1;

+    } while (*(short *)(lVar8 + lVar3 * 2) != 0);

+    do {

+      param_4 = param_4 + 1;

+    } while (*(short *)(unaff_RDI + param_4 * 2) != 0);

+    lVar4 = unaff_RDI;

+    uVar2 = McTemplateU0qqzr1qzr3qqqxqpqqqzr13q_EtwWriteTransfer

+                      (*(undefined4 *)((longlong)plVar5 + -0x7c),0,uVar7,param_4,unaff_RDI);

+    uVar9 = (undefined4)((ulonglong)lVar4 >> 0x20);

+  }

+  if (5 < DAT_3) {

+    *(int *)(plVar5 + -0x10) = (int)plVar5[-0x10];

+    plVar5[-5] = 4;

+    plVar5[-6] = (longlong)(plVar5 + -0x10);

+    _tlgCreate1Sz_wchar_t(plVar5 + -4,unaff_RDI);

+    _tlgCreate1Sz_wchar_t(plVar5 + -2,lVar8);

+    *(undefined4 *)((longlong)plVar5 + -0x7c) = *(undefined4 *)((longlong)plVar5 + -0x7c);

+    plVar5[1] = 4;

+    *plVar5 = (longlong)plVar5 + -0x7c;

+    plVar5[2] = (longlong)(plVar5 + -0xe);

+    plVar5[4] = (longlong)plVar5 + -0x6c;

+    *(int *)(plVar5 + -0xf) = (int)plVar5[-0xf];

+    plVar5[6] = (longlong)(plVar5 + -0xf);

+    plVar5[8] = (longlong)(plVar5 + -0xc);

+    plVar5[10] = (longlong)(plVar5 + -0xb);

+    *(undefined4 *)((longlong)plVar5 + -0x74) = *(undefined4 *)((longlong)plVar5 + -0x74);

+    plVar5[0xc] = (longlong)plVar5 + -0x74;

+    plVar5[0xe] = (longlong)(plVar5 + -0xd);

+    *(uint *)(plVar5 + -0xe) = unaff_ESI;

+    plVar5[3] = 4;

+    *(undefined4 *)((longlong)plVar5 + -0x6c) = unaff_R13D;

+    plVar5[5] = 4;

+    plVar5[7] = 4;

+    plVar5[-0xc] = unaff_R14;

+    plVar5[9] = 8;

+    plVar5[-0xb] = unaff_RBX;

+    plVar5[0xb] = 8;

+    plVar5[0xd] = 4;

+    *(undefined4 *)(plVar5 + -0xd) = 2;

+    plVar5[0xf] = 4;

+    _tlgCreate1Sz_wchar_t(plVar5 + 0x10,lVar6);

+    uVar2 = _tlgWriteTransfer_EtwWriteTransfer

+                      (&DAT_3,&DAT_140051fcb,0,0,CONCAT44(uVar9,0xe));

+  }

+  return uVar2;

 }
```

## `PopBatteryTraceSystemBatteryStatus`  (modified)

```diff
--- PopBatteryTraceSystemBatteryStatus
+++ PopBatteryTraceSystemBatteryStatus
@@ -1,11 +1,122 @@
 

-void PopBatteryTraceSystemBatteryStatus(void)

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+

+void PopBatteryTraceSystemBatteryStatus(char param_1)

 

 {

-  code *pcVar1;

+  char cVar1;

+  undefined *puVar2;

+  undefined1 auStack_148 [32];

+  undefined8 local_128;

+  undefined8 local_120;

+  undefined4 local_118;

+  undefined4 **local_110;

+  undefined4 local_108;

+  undefined4 local_104;

+  undefined4 local_100;

+  undefined4 local_fc;

+  undefined4 local_f8;

+  undefined4 local_f4;

+  undefined4 local_f0;

+  undefined4 local_ec;

+  undefined4 local_e8;

+  undefined4 local_e4;

+  undefined4 local_e0;

+  undefined4 local_dc;

+  undefined4 *local_d8;

+  undefined8 local_d0;

+  undefined4 *local_c8;

+  undefined8 local_c0;

+  undefined4 *local_b8;

+  undefined8 local_b0;

+  undefined4 *local_a8;

+  undefined8 local_a0;

+  undefined4 *local_98;

+  undefined8 local_90;

+  undefined4 *local_88;

+  undefined8 local_80;

+  undefined4 *local_78;

+  undefined8 local_70;

+  undefined4 *local_68;

+  undefined8 local_60;

+  undefined4 *local_58;

+  undefined8 local_50;

+  undefined4 *local_48;

+  undefined8 local_40;

+  undefined4 *local_38;

+  undefined8 local_30;

+  undefined4 *local_28;

+  undefined8 local_20;

+  ulonglong local_18;

   

-  pcVar1 = (code *)swi(3);

-  (*pcVar1)();

+  local_18 = __security_cookie ^ (ulonglong)auStack_148;

+  puVar2 = &BATTERY_EVT_SYSTEM_BATTERY_STATUS_CHANGE;

+  if (param_1 != '\0') {

+    puVar2 = &BATTERY_EVT_SYSTEM_BATTERY_STATUS_RUNDOWN;

+  }

+  if ((PopBatteryEtwRegistered != '\0') &&

+     (cVar1 = EtwEventEnabled(PopBatteryEtwHandle), cVar1 != '\0')) {

+    if (DAT_0 == '\0') {

+      local_108 = 0;

+      local_104 = 0;

+      local_100 = 0;

+      local_fc = 0;

+      local_dc = 0xffffffff;

+      local_e0 = 0xffffffff;

+      local_ec = 0xffffffff;

+      local_f4 = 0xffffffff;

+      local_e4 = 0xffffffff;

+      local_e8 = 0xffffffff;

+      local_f8 = 0;

+      local_f0 = 0xffffffff;

+    }

+    else {

+      local_104 = DAT_1;

+      local_100 = DAT_2;

+      local_108 = 1;

+      local_dc = DAT_3;

+      local_e0 = DAT_4;

+      local_ec = DAT_5;

+      local_f4 = DAT_6;

+      local_e4 = DAT_7;

+      local_e8 = DAT_8;

+      local_f8 = DAT_9;

+      local_f0 = DAT_10;

+      local_fc = 0;

+      if (DAT_11 != 0) {

+        local_fc = (int)(((ulonglong)DAT_12 * 100000) / (ulonglong)DAT_140f0b748);

+      }

+    }

+    local_d8 = &local_108;

+    local_c8 = &local_104;

+    local_b8 = &local_100;

+    local_a8 = &local_fc;

+    local_98 = &local_f8;

+    local_88 = &local_f4;

+    local_78 = &local_f0;

+    local_68 = &local_ec;

+    local_58 = &local_e8;

+    local_48 = &local_e4;

+    local_38 = &local_e0;

+    local_28 = &local_dc;

+    local_110 = &local_d8;

+    local_118 = 0xc;

+    local_120 = 0;

+    local_128 = 0;

+    local_d0 = 4;

+    local_c0 = 4;

+    local_b0 = 4;

+    local_a0 = 4;

+    local_90 = 4;

+    local_80 = 4;

+    local_70 = 4;

+    local_60 = 4;

+    local_50 = 4;

+    local_40 = 4;

+    local_30 = 4;

+    local_20 = 4;

+    EtwWriteEx(PopBatteryEtwHandle,puVar2,0,0);

+  }

   return;

 }
```

## `PopBuildMemoryImageHeader`  (modified)

```diff
--- PopBuildMemoryImageHeader
+++ PopAcquirePolicyLock
@@ -1,10 +1,377 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void PopBuildMemoryImageHeader(void)

+void PopAcquirePolicyLock(void)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  undefined1 *puVar1;

+  byte bVar2;

+  undefined4 uVar3;

+  undefined8 uVar4;

+  undefined8 *puVar5;

+  code *pcVar6;

+  bool bVar7;

+  undefined8 *puVar8;

+  char cVar9;

+  longlong lVar10;

+  longlong lVar11;

+  longlong *plVar12;

+  longlong *plVar13;

+  longlong *plVar14;

+  longlong *plVar15;

+  longlong *unaff_RBX;

+  undefined8 *puVar16;

+  undefined8 *puVar17;

+  longlong unaff_RBP;

+  longlong *unaff_RDI;

+  longlong *in_R9;

+  longlong *in_R10;

+  longlong *in_R11;

+  undefined1 *unaff_R15;

+  undefined8 auStackX_8 [4];

+  

+  puVar17 = auStackX_8;

+  do {

+    in_R11 = (longlong *)*in_R11;

+LAB_0:

+    if (in_R11 == unaff_RBX) {

+      puVar1 = unaff_R15 + (ulonglong)*(byte *)(in_R10 + 7) * 0x48 + 0x18;

+      puVar5 = *(undefined8 **)(puVar1 + 8);

+      puVar8 = puVar17;

+      if ((undefined1 *)*puVar5 != puVar1) goto LAB_1;

+      *in_R10 = (longlong)puVar1;

+      in_R10[1] = (longlong)puVar5;

+      *puVar5 = in_R10;

+      *(longlong **)(puVar1 + 8) = in_R10;

+      do {

+        in_R9 = (longlong *)*in_R9;

+        if (in_R9 == (longlong *)0x0) {

+          in_R9 = (longlong *)*unaff_RDI;

+        }

+        else {

+          plVar14 = (longlong *)in_R9[1];

+          while (plVar12 = plVar14, plVar12 != (longlong *)0x0) {

+            in_R9 = plVar12;

+            plVar14 = (longlong *)plVar12[1];

+          }

+        }

+LAB_2:

+        if (in_R9 == IopRootDeviceNode) {

+          *(undefined8 *)((longlong)puVar17 + -8) = 0x140b69d06;

+          IopFreePoDeviceNotifyListHead(unaff_RBP + -0x10);

+          *(undefined8 **)(unaff_R15 + 8) = &IopWarmEjectPdo;

+          *unaff_R15 = 1;

+          return;

+        }

+        uVar3 = *(undefined4 *)(unaff_R15 + 0x178);

+        in_R10 = in_R9 + 0x14;

+        *(undefined8 *)((longlong)puVar17 + -8) = 0x140b69c32;

+        cVar9 = IopIsNotifyInBroadcast(uVar3,in_R10);

+        if (cVar9 != '\0') goto code_r0x000140b69c3a;

+        plVar14 = *(longlong **)(unaff_RBP + -8);

+        puVar8 = puVar17;

+        if (*plVar14 != unaff_RBP + -0x10) {

+LAB_1:

+          puVar16 = puVar8;

+          plVar14 = (longlong *)0x3;

+          pcVar6 = (code *)swi(0x29);

+          (*pcVar6)();

+          puVar17 = puVar16 + 1;

+          do {

+            plVar12 = (longlong *)*plVar14;

+            while( true ) {

+              if (plVar12 == IopRootDeviceNode) goto LAB_3;

+              plVar15 = plVar12 + 0x14;

+              *(undefined4 *)(plVar12 + 0x1f) = 0;

+              *(undefined4 *)((longlong)plVar12 + 0xfc) = 0;

+              *(undefined4 *)(plVar12 + 0x20) = 0;

+              *(undefined4 *)((longlong)plVar12 + 0x104) = 0;

+              *(undefined1 *)(plVar12 + 0x1b) = 0;

+              plVar12[0x1c] = plVar12[4];

+              lVar10 = plVar12[4];

+              *puVar16 = 0x140b6986a;

+              lVar10 = IoGetAttachedDeviceReference(lVar10);

+              plVar12[0x1a] = lVar10;

+              uVar4 = *(undefined8 *)(lVar10 + 8);

+              *puVar16 = 0x140b69877;

+              lVar11 = func_0x000140b69e00(uVar4);

+              lVar10 = plVar12[0x1a];

+              plVar12[0x1e] = lVar11;

+              *puVar16 = 0x140b69884;

+              lVar11 = func_0x000140b69e00(lVar10);

+              lVar10 = plVar12[0x1c];

+              plVar12[0x1d] = lVar11;

+              *puVar16 = 0x140b69891;

+              ObfReferenceObject(lVar10);

+              *(undefined1 *)(plVar12 + 0x1b) = 0;

+              *puVar16 = 0x140b698a2;

+              cVar9 = IopCheckDeviceFlags(plVar15,0x2000);

+              if (cVar9 != '\0') {

+                *(byte *)(plVar12 + 0x1b) = *(byte *)(plVar12 + 0x1b) | 2;

+              }

+              plVar14 = plVar12 + 2;

+              if ((((longlong *)*plVar14 == IopRootDeviceNode) && ((int)plVar12[0x38] != 0)) &&

+                 ((*(uint *)((longlong)plVar12 + 0x18c) & 4) == 0)) {

+                plVar13 = *(longlong **)(unaff_RBP + -0x18);

+                puVar8 = puVar16 + 1;

+                if (*plVar13 != unaff_RBP + -0x20) goto LAB_1;

+                plVar12[0x15] = (longlong)plVar13;

+                *plVar15 = unaff_RBP + -0x20;

+                *plVar13 = (longlong)plVar15;

+                *(longlong **)(unaff_RBP + -0x18) = plVar15;

+              }

+              plVar12 = (longlong *)*plVar12;

+              if (plVar12 == (longlong *)0x0) break;

+              plVar14 = (longlong *)plVar12[1];

+              while (plVar15 = plVar14, plVar15 != (longlong *)0x0) {

+                plVar12 = plVar15;

+                plVar14 = (longlong *)plVar15[1];

+              }

+            }

+          } while( true );

+        }

+        in_R10[1] = (longlong)plVar14;

+        *in_R10 = unaff_RBP + -0x10;

+        unaff_RDI = in_R9 + 2;

+        *plVar14 = (longlong)in_R10;

+        *(longlong **)(unaff_RBP + -8) = in_R10;

+      } while( true );

+    }

+    lVar10 = in_R11[-1];

+    uVar3 = *(undefined4 *)(unaff_R15 + 0x178);

+    *(undefined8 *)((longlong)puVar17 + -8) = 0x140b69ce8;

+    cVar9 = IopIsNotifyInBroadcast(uVar3,lVar10);

+    if (cVar9 != '\0') {

+      *(int *)(in_R10 + 0xb) = (int)in_R10[0xb] + 1;

+    }

+  } while( true );

+code_r0x000140b69c3a:

+  unaff_RDI = in_R9 + 2;

+  *(int *)(unaff_R15 + (ulonglong)*(byte *)(in_R10 + 7) * 0x48 + 0x10) =

+       *(int *)(unaff_R15 + (ulonglong)*(byte *)(in_R10 + 7) * 0x48 + 0x10) + 1;

+  plVar14 = (longlong *)*unaff_RDI;

+  if (plVar14 != IopRootDeviceNode) {

+    uVar3 = *(undefined4 *)(unaff_R15 + 0x178);

+    *(undefined8 *)((longlong)puVar17 + -8) = 0x140b69c6b;

+    cVar9 = IopIsNotifyInBroadcast(uVar3,plVar14 + 0x14);

+    if (cVar9 != '\0') {

+      *(int *)(in_R10 + 0xc) = (int)in_R10[0xc] + 1;

+      *(int *)(*unaff_RDI + 0xf8) = *(int *)(*unaff_RDI + 0xf8) + 1;

+    }

+  }

+  plVar14 = in_R10 + 4;

+  for (plVar12 = (longlong *)*plVar14; plVar12 != plVar14; plVar12 = (longlong *)*plVar12) {

+    lVar10 = plVar12[5];

+    uVar3 = *(undefined4 *)(unaff_R15 + 0x178);

+    *(undefined8 *)((longlong)puVar17 + -8) = 0x140b69ddd;

+    cVar9 = IopIsNotifyInBroadcast(uVar3,lVar10);

+    if (cVar9 != '\0') {

+      *(int *)(in_R10 + 0xc) = (int)in_R10[0xc] + 1;

+      FUN_140b72725();

+      return;

+    }

+  }

+  unaff_RBX = in_R10 + 2;

+  in_R11 = (longlong *)*unaff_RBX;

+  goto LAB_0;

+LAB_3:

+  plVar14 = *(longlong **)(unaff_RBP + -0x20);

+  if (plVar14 == (longlong *)(unaff_RBP + -0x20)) goto LAB_4;

+  puVar8 = puVar16 + 1;

+  if ((plVar14[1] != unaff_RBP + -0x20) ||

+     (lVar10 = *plVar14, puVar8 = puVar16 + 1, *(longlong **)(lVar10 + 8) != plVar14))

+  goto LAB_1;

+  *(longlong *)(unaff_RBP + -0x20) = lVar10;

+  *(longlong *)(lVar10 + 8) = unaff_RBP + -0x20;

+  *(byte *)(plVar14 + 7) = *(byte *)(plVar14 + 7) | 1;

+  plVar12 = plVar14 + -0x14;

+  for (plVar15 = (longlong *)plVar14[-0x13]; plVar15 != (longlong *)0x0;

+      plVar15 = (longlong *)plVar15[1]) {

+    plVar12 = plVar15;

+  }

+  while (plVar12 != plVar14 + -0x14) {

+    *(byte *)(plVar12 + 0x1b) = *(byte *)(plVar12 + 0x1b) | 1;

+    plVar15 = (longlong *)*plVar12;

+    if ((longlong *)*plVar12 == (longlong *)0x0) {

+      plVar12 = (longlong *)plVar12[2];

+    }

+    else {

+      do {

+        plVar12 = plVar15;

+        plVar15 = (longlong *)plVar12[1];

+      } while ((longlong *)plVar12[1] != (longlong *)0x0);

+    }

+  }

+  goto LAB_3;

+  while( true ) {

+    do {

+      if ((*(byte *)(plVar14 + 0x1b) & 2) != 0) {

+        for (plVar12 = (longlong *)plVar14[0x16]; plVar12 != plVar14 + 0x16;

+            plVar12 = (longlong *)*plVar12) {

+          bVar2 = *(byte *)(plVar12[-1] + 0x38);

+          if ((bVar2 & 2) == 0) {

+            bVar7 = true;

+            *(byte *)(plVar12[-1] + 0x38) = bVar2 | 2;

+          }

+        }

+      }

+      plVar12 = (longlong *)*plVar14;

+      if ((longlong *)*plVar14 == (longlong *)0x0) {

+        plVar14 = (longlong *)plVar14[2];

+      }

+      else {

+        do {

+          plVar14 = plVar12;

+          plVar12 = (longlong *)plVar14[1];

+        } while ((longlong *)plVar14[1] != (longlong *)0x0);

+      }

+    } while (plVar14 != IopRootDeviceNode);

+    if (!bVar7) break;

+LAB_4:

+    bVar7 = false;

+    plVar12 = (longlong *)IopRootDeviceNode[1];

+    plVar14 = IopRootDeviceNode;

+    while (plVar15 = plVar12, plVar15 != (longlong *)0x0) {

+      plVar14 = plVar15;

+      plVar12 = (longlong *)plVar15[1];

+    }

+    while (plVar14 != IopRootDeviceNode) {

+      if ((*(byte *)(plVar14 + 0x1b) & 2) != 0) {

+        plVar12 = plVar14;

+        for (plVar15 = (longlong *)plVar14[1]; plVar15 != (longlong *)0x0;

+            plVar15 = (longlong *)plVar15[1]) {

+          plVar12 = plVar15;

+        }

+        while (plVar12 != plVar14) {

+          *(byte *)(plVar12 + 0x1b) = *(byte *)(plVar12 + 0x1b) | 2;

+          plVar15 = (longlong *)*plVar12;

+          if ((longlong *)*plVar12 == (longlong *)0x0) {

+            plVar12 = (longlong *)plVar12[2];

+          }

+          else {

+            do {

+              plVar12 = plVar15;

+              plVar15 = (longlong *)plVar12[1];

+            } while ((longlong *)plVar12[1] != (longlong *)0x0);

+          }

+        }

+      }

+      plVar12 = (longlong *)*plVar14;

+      if ((longlong *)*plVar14 == (longlong *)0x0) {

+        plVar14 = (longlong *)plVar14[2];

+      }

+      else {

+        do {

+          plVar14 = plVar12;

+          plVar12 = (longlong *)plVar14[1];

+        } while ((longlong *)plVar14[1] != (longlong *)0x0);

+      }

+    }

+    plVar12 = (longlong *)IopRootDeviceNode[1];

+    plVar14 = IopRootDeviceNode;

+    while (plVar15 = plVar12, plVar15 != (longlong *)0x0) {

+      plVar14 = plVar15;

+      plVar12 = (longlong *)plVar15[1];

+    }

+    if (plVar14 == IopRootDeviceNode) break;

+  }

+  plVar12 = (longlong *)IopRootDeviceNode[1];

+  plVar14 = IopRootDeviceNode;

+  while (plVar15 = plVar12, plVar15 != (longlong *)0x0) {

+    plVar14 = plVar15;

+    plVar12 = (longlong *)plVar15[1];

+  }

+  while (plVar14 != IopRootDeviceNode) {

+    if ((*(byte *)(plVar14 + 0x1b) & 2) != 0) {

+      lVar10 = plVar14[0x1a];

+      *(byte *)(plVar14 + 0x1b) = *(byte *)(plVar14 + 0x1b) + 1;

+      *puVar16 = 0x140b69acb;

+      ObfReferenceObjectWithTag(lVar10,0x70506f50);

+      while (lVar10 != 0) {

+        if (*(int *)(lVar10 + 0x48) == 7) {

+          *puVar16 = 0x140b69d6b;

+          ObfDereferenceObjectWithTag(lVar10,0x70506f50);

+          *puVar16 = 0x140b69d78;

+          cVar9 = IopCheckDeviceFlags(plVar14 + 0x14,0x100);

+          if (cVar9 != '\0') {

+            *(undefined1 *)(plVar14 + 0x1b) = 2;

+          }

+          break;

+        }

+        *puVar16 = 0x140b69ae7;

+        lVar11 = IoGetLowerDeviceObjectWithTag();

+        *puVar16 = 0x140b69af7;

+        ObfDereferenceObjectWithTag(lVar10,0x70506f50);

+        lVar10 = lVar11;

+      }

+    }

+    plVar12 = (longlong *)*plVar14;

+    if ((longlong *)*plVar14 == (longlong *)0x0) {

+      plVar14 = (longlong *)plVar14[2];

+    }

+    else {

+      do {

+        plVar14 = plVar12;

+        plVar12 = (longlong *)plVar14[1];

+      } while ((longlong *)plVar14[1] != (longlong *)0x0);

+    }

+  }

+  do {

+    bVar7 = false;

+    plVar14 = (longlong *)IopRootDeviceNode[1];

+    plVar12 = IopRootDeviceNode;

+    while (plVar15 = plVar14, plVar15 != (longlong *)0x0) {

+      plVar12 = plVar15;

+      plVar14 = (longlong *)plVar15[1];

+    }

+    while (plVar12 != IopRootDeviceNode) {

+      plVar14 = (longlong *)plVar12[2];

+      if (plVar14 != IopRootDeviceNode) {

+        if (*(byte *)(plVar12 + 0x1b) < *(byte *)(plVar14 + 0x1b)) {

+          *(byte *)(plVar14 + 0x1b) = *(byte *)(plVar12 + 0x1b);

+          plVar14 = (longlong *)plVar12[2];

+        }

+      }

+      plVar15 = (longlong *)*plVar12;

+      plVar12 = plVar14;

+      if (plVar15 != (longlong *)0x0) {

+        plVar14 = (longlong *)plVar15[1];

+        while (plVar13 = plVar14, plVar12 = plVar15, plVar13 != (longlong *)0x0) {

+          plVar15 = plVar13;

+          plVar14 = (longlong *)plVar13[1];

+        }

+      }

+    }

+    plVar14 = IopRootDeviceNode;

+    for (plVar12 = (longlong *)IopRootDeviceNode[1]; plVar12 != (longlong *)0x0;

+        plVar12 = (longlong *)plVar12[1]) {

+      plVar14 = plVar12;

+    }

+    if (plVar14 == IopRootDeviceNode) break;

+    do {

+      for (plVar12 = (longlong *)plVar14[0x18]; plVar12 != plVar14 + 0x18;

+          plVar12 = (longlong *)*plVar12) {

+        if (*(byte *)(plVar14 + 0x1b) < *(byte *)(plVar12[5] + 0x38)) {

+          bVar7 = true;

+          *(byte *)(plVar12[5] + 0x38) = *(byte *)(plVar14 + 0x1b);

+        }

+      }

+      plVar12 = (longlong *)*plVar14;

+      if ((longlong *)*plVar14 == (longlong *)0x0) {

+        plVar14 = (longlong *)plVar14[2];

+      }

+      else {

+        do {

+          plVar14 = plVar12;

+          plVar12 = (longlong *)plVar14[1];

+        } while ((longlong *)plVar14[1] != (longlong *)0x0);

+      }

+    } while (plVar14 != IopRootDeviceNode);

+  } while (bVar7);

+  plVar14 = (longlong *)IopRootDeviceNode[1];

+  in_R9 = IopRootDeviceNode;

+  while (plVar12 = plVar14, plVar12 != (longlong *)0x0) {

+    in_R9 = plVar12;

+    plVar14 = (longlong *)plVar12[1];

+  }

+  goto LAB_2;

 }
```

## `ApiSetValidateSchemaElements_V7`  (modified)

```diff
--- ApiSetValidateSchemaElements_V7
+++ ApiSetpIsFeatureEnabled
@@ -1,67 +1,17 @@
 

-undefined4 ApiSetValidateSchemaElements_V7(longlong param_1)

+bool ApiSetpIsFeatureEnabled(int param_1)

 

 {

-  uint uVar1;

-  ushort uVar2;

-  ushort uVar3;

-  uint uVar4;

-  longlong lVar5;

-  ulonglong uVar6;

-  uint uVar7;

+  char cVar1;

+  int iVar2;

   

-  uVar2 = *(ushort *)(param_1 + 0x30);

-  uVar7 = 0;

-  if (uVar2 != 0) {

-    uVar6 = (ulonglong)*(ushort *)(param_1 + 0x12);

-    do {

-      lVar5 = ((ulonglong)uVar7 * (ulonglong)*(byte *)(param_1 + 0x34) - uVar6) +

-              (ulonglong)*(uint *)(param_1 + 0x2c);

-      if ((*(byte *)(lVar5 + 10 + param_1) & 2) != 0) {

-        uVar3 = *(ushort *)(lVar5 + 4 + param_1);

-        if (*(ushort *)(param_1 + 0x60) <= uVar3) {

-          return 0xc00000e4;

-        }

-        lVar5 = ((ulonglong)uVar3 * (ulonglong)*(byte *)(param_1 + 100) - uVar6) + param_1;

-        uVar4 = *(uint *)((ulonglong)*(uint *)(param_1 + 0x5c) + 4 + lVar5);

-        if (*(uint *)(param_1 + 0x28) < uVar4) {

-          return 0xc00000e4;

-        }

-        uVar1 = uVar4 + (uint)*(ushort *)((ulonglong)*(uint *)(param_1 + 0x5c) + 8 + lVar5) * 2;

-        if (uVar1 < uVar4) {

-          return 0;

-        }

-        if (*(uint *)(param_1 + 0x28) < uVar1) {

-          return 0xc00000e4;

-        }

-      }

-      uVar7 = uVar7 + 1;

-    } while (uVar7 < uVar2);

+  if (param_1 == 0x3a132a5) {

+    iVar2 = Feature_DriverSetup_ReofferFingerprinting_v2__private_IsEnabledDeviceUsageNoInline();

+    cVar1 = (iVar2 != 0) + '\x01';

   }

-  uVar6 = 0;

-  if (*(ushort *)(param_1 + 0x3c) != 0) {

-    do {

-      if (uVar2 <= *(ushort *)

-                    ((uVar6 * *(byte *)(param_1 + 0x40) - (ulonglong)*(ushort *)(param_1 + 0x12)) +

-                     (ulonglong)*(uint *)(param_1 + 0x38) + 4 + param_1)) {

-        return 0xc00000e4;

-      }

-      uVar7 = (int)uVar6 + 1;

-      uVar6 = (ulonglong)uVar7;

-    } while (uVar7 < *(ushort *)(param_1 + 0x3c));

+  else {

+    cVar1 = '\0';

   }

-  uVar6 = 0;

-  if (*(ushort *)(param_1 + 0x48) != 0) {

-    do {

-      if (uVar2 <= *(ushort *)

-                    ((uVar6 * *(byte *)(param_1 + 0x4c) - (ulonglong)*(ushort *)(param_1 + 0x12)) +

-                     (ulonglong)*(uint *)(param_1 + 0x44) + 4 + param_1)) {

-        return 0xc00000e4;

-      }

-      uVar7 = (int)uVar6 + 1;

-      uVar6 = (ulonglong)uVar7;

-    } while (uVar7 < *(ushort *)(param_1 + 0x48));

-  }

-  return 0;

+  return cVar1 == '\x02';

 }
```

## `ApiSetSchemaExpander_InsertSemverContractEntry`  (modified)

```diff
--- ApiSetSchemaExpander_InsertSemverContractEntry
+++ ApiSetSchemaExpander_InsertSemverContractEntry
@@ -1,10 +1,35 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void ApiSetSchemaExpander_InsertSemverContractEntry(void)

+undefined8

+ApiSetSchemaExpander_InsertSemverContractEntry(longlong param_1,undefined8 param_2,ushort *param_3)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  short *psVar1;

+  ushort uVar2;

+  char cVar3;

+  undefined8 uVar4;

+  longlong lVar5;

+  

+  uVar2 = *(ushort *)(param_1 + 0xc4);

+  *param_3 = uVar2;

+  *(ushort *)(param_1 + 0xc4) = uVar2 + 1;

+  uVar4 = ApiSetpInsertHashEntry

+                    (*(longlong *)(param_1 + 0x20),*(longlong *)(param_1 + 0x20) + 0x44,uVar2,

+                     param_2,0);

+  if (-1 < (int)uVar4) {

+    lVar5 = *(longlong *)(param_1 + 0x20);

+    lVar5 = (ulonglong)*(uint *)(lVar5 + 0x44) +

+            lVar5 + ((ulonglong)*(byte *)(lVar5 + 0x4c) * (ulonglong)*param_3 -

+                    (ulonglong)*(ushort *)(lVar5 + 0x12));

+    cVar3 = ApiSetpGetSemverKeyVersions(param_2,lVar5 + 8,lVar5 + 9);

+    if (cVar3 == '\0') {

+      uVar4 = 0xc000000d;

+    }

+    else {

+      psVar1 = (short *)(*(longlong *)(param_1 + 0x20) + 0x48);

+      *psVar1 = *psVar1 + 1;

+      uVar4 = 0;

+    }

+  }

+  return uVar4;

 }
```

## `PopNotifyPolicyDevice`  (modified)

```diff
--- PopNotifyPolicyDevice
+++ PopNotifyPolicyDevice
@@ -1,7 +1,33 @@
 

-void PopNotifyPolicyDevice(void)

+undefined8 PopNotifyPolicyDevice(longlong param_1,int param_2)

 

 {

-  return;

+  char cVar1;

+  longlong lVar2;

+  

+  lVar2 = *(longlong *)(param_1 + 4) + -0x11d046f0cb3a4005;

+  if (lVar2 == 0) {

+    lVar2 = *(longlong *)(param_1 + 0xc) + -0x3f05139760008fb0;

+  }

+  if (param_2 == 8) {

+    PopPolicyDeviceHandleWakeAlarmNotification();

+  }

+  else if (param_2 == 3) {

+    PopAcquireTransitionLock(4);

+    PopAcquirePolicyLock();

+    cVar1 = PopHiberEnabled;

+    PopEnableHiberFile(0);

+    if (cVar1 != '\0') {

+      PopEnableHiberFile(1);

+    }

+    PopReleasePolicyLock();

+    PopReleaseTransitionLock(4);

+  }

+  else if (lVar2 != 0) {

+    PopAcquireRwLockExclusive(&PopPolicyDeviceLock);

+    PopConnectToPolicyDevice(param_2,*(undefined8 *)(param_1 + 0x28));

+    PopReleaseRwLock(&PopPolicyDeviceLock);

+  }

+  return 0;

 }
```

## `Pdcv2EventWrite_ACTIVATION_CLIENT_CALLBACK`  (modified)

```diff
--- Pdcv2EventWrite_ACTIVATION_CLIENT_CALLBACK
+++ Pdcv2EventWrite_ACTIVATION_CLIENT_REGISTER
@@ -1,40 +1,7 @@
 

-/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

-

-void Pdcv2EventWrite_ACTIVATION_CLIENT_CALLBACK

-               (byte param_1,undefined8 param_2,undefined8 param_3,byte param_4)

+void Pdcv2EventWrite_ACTIVATION_CLIENT_REGISTER(void)

 

 {

-  byte *pbVar1;

-  char *in_RAX;

-  char *pcVar2;

-  char *unaff_RBX;

-  longlong unaff_RBP;

-  longlong in_R11;

-  

-  in_RAX[-0x75] = in_RAX[-0x75] & param_1;

-  *in_RAX = *in_RAX + (char)in_RAX;

-  in_RAX[-0x77] = in_RAX[-0x77] + param_1;

-  *(byte *)(in_R11 + 0xe885) = *(byte *)(in_R11 + 0xe885) ^ param_4;

-  *unaff_RBX = *unaff_RBX + (char)in_RAX;

-  pbVar1 = (byte *)(in_RAX + -0x39);

-  *pbVar1 = *pbVar1 >> 4 | *pbVar1 << 4;

-  pcVar2 = (char *)((ulonglong)in_RAX & 0xffffffffffffff68);

-  *pcVar2 = *pcVar2 + (char)pcVar2;

-  *(int *)(unaff_RBP + 0x38) = (int)pcVar2;

-  *(longlong *)(unaff_RBP + 0x40) = unaff_RBP + 0xf8;

-  *(undefined8 *)(unaff_RBP + -0x78) = 4;

-  *(undefined8 *)(unaff_RBP + -0x58) = 4;

-  *(undefined8 *)(unaff_RBP + -0x48) = 4;

-  *(undefined8 *)(unaff_RBP + -0x38) = 4;

-  *(undefined8 *)(unaff_RBP + -0x28) = 8;

-  *(undefined8 *)(unaff_RBP + -0x18) = 4;

-  *(undefined8 *)(unaff_RBP + -8) = 8;

-  *(undefined8 *)(unaff_RBP + 8) = 4;

-  *(undefined8 *)(unaff_RBP + 0x18) = 4;

-  *(undefined8 *)(unaff_RBP + 0x28) = 4;

-  *(undefined8 *)(unaff_RBP + 0x48) = 4;

-  McGenEventWrite_EtwWriteTransfer();

   return;

 }
```

## `ExpTimerPause`  (modified)

```diff
--- ExpTimerPause
+++ ExpTimerPause
@@ -1,11 +1,72 @@
 

-void ExpTimerPause(void)

+uint ExpTimerPause(uint *param_1,undefined8 param_2,ulonglong param_3,char param_4)

 

 {

-  code *pcVar1;

+  byte bVar1;

+  char cVar2;

+  uint uVar3;

+  uint uVar4;

+  char cVar5;

+  longlong lVar6;

+  ulonglong uVar7;

   

-  pcVar1 = (code *)swi(3);

-  (*pcVar1)();

-  return;

+  uVar7 = 0;

+  cVar5 = '\0';

+  if (param_4 == '\0') {

+    KeAcquireSpinLockAtDpcLevel(param_1 + 0x10);

+  }

+  bVar1 = (byte)param_1[0x4c];

+  uVar3 = (uint)bVar1;

+  if ((bVar1 & 2) == 0) {

+    *(byte *)(param_1 + 0x4c) = bVar1 | 2;

+    uVar3 = KiCancelTimer(param_1,0);

+    cVar2 = (char)uVar3;

+    if (cVar2 != '\0') {

+      bVar1 = *(byte *)((longlong)param_1 + 1);

+      uVar7 = *(ulonglong *)(param_1 + 6);

+      cVar5 = '\x01';

+      if ((bVar1 & 1) == 0) {

+        cVar5 = '\x02';

+        if ((bVar1 & 2) != 0) {

+          cVar5 = '\x03';

+        }

+      }

+      uVar4 = KiDecodeTolerableDelayValue(bVar1 >> 2);

+      uVar3 = uVar4 * -0x2e48e8a7;

+      param_1[0x50] = uVar4 / 10000;

+    }

+    LOCK();

+    *param_1 = *param_1 & 0xffffff7f;

+    UNLOCK();

+    if (cVar2 == '\0') {

+      cVar5 = '\0';

+    }

+    else if (cVar5 == '\x01') {

+      if (param_3 < uVar7) {

+        uVar3 = FUN_1406ecae4();

+        return uVar3;

+      }

+      param_1[0x4e] = 0;

+      param_1[0x4f] = 0;

+    }

+    else if (cVar5 == '\x02') {

+      if (param_3 < uVar7) {

+        lVar6 = param_3 - uVar7;

+      }

+      else {

+        lVar6 = 0;

+      }

+      *(longlong *)(param_1 + 0x4e) = lVar6;

+    }

+    else if (cVar5 == '\x03') {

+      uVar3 = FUN_1406ecae4();

+      return uVar3;

+    }

+    *(char *)(param_1 + 0x3e) = cVar5;

+  }

+  if (param_4 == '\0') {

+    uVar3 = KxReleaseSpinLock(param_1 + 0x10);

+  }

+  return uVar3;

 }
```

## `MiCreateCombineAnchor`  (modified)

```diff
--- MiCreateCombineAnchor
+++ MiCreateCombineAnchor
@@ -1,123 +1,41 @@
 

-void MiCreateCombineAnchor(void)

+undefined8 MiCreateCombineAnchor(longlong *param_1,longlong param_2,ulonglong *param_3)

 

 {

-  ulonglong *puVar1;

-  ulonglong uVar2;

-  int iVar3;

-  ulonglong uVar4;

-  void *pvVar5;

-  undefined1 uVar6;

-  int iVar7;

-  longlong lVar8;

-  ulonglong uVar9;

-  ulonglong uVar10;

-  undefined2 *unaff_RBX;

-  ulonglong unaff_RSI;

-  undefined1 unaff_R14B;

-  bool bVar11;

-  char in_CR8;

+  int *piVar1;

+  longlong lVar2;

+  longlong lVar3;

+  undefined8 *puVar4;

+  int iVar5;

+  ulonglong uVar6;

+  longlong lVar7;

+  undefined8 uVar8;

   

-  lVar8 = MiRestockOverCommit();

-  MiReleaseSpinLockExclusive(unaff_RBX + 0x20fc,unaff_R14B);

-  pvVar5 = FiberData;

-  if (lVar8 == 0) {

-    return;

-  }

-  if (unaff_RBX == &MiSystemPartition) {

-    if ((unaff_RSI & 0x10) == 0) {

-      uVar9 = (ulonglong)*(uint *)((longlong)FiberData + 0x8b98);

-      while (uVar9 + lVar8 < 0x101) {

-        iVar3 = (int)uVar9;

-        LOCK();

-        iVar7 = *(int *)((longlong)pvVar5 + 0x8b98);

-        if (iVar3 == iVar7) {

-          *(int *)((longlong)pvVar5 + 0x8b98) = iVar3 + (int)lVar8;

-          iVar7 = iVar3;

-        }

-        UNLOCK();

-        bVar11 = (longlong)iVar7 == uVar9;

-        uVar9 = (longlong)iVar7;

-        if (bVar11) {

-          return;

-        }

-      }

-LAB_0:

+  uVar8 = 0;

+  lVar2 = *param_1;

+  lVar3 = param_1[0xe];

+  lVar7 = (ulonglong)(*(uint *)(param_2 + 8) & 0xf) * 0x10 + lVar2;

+  *param_3 = 0;

+  ExAcquireSpinLockSharedAtDpcLevel(lVar7 + 0x68);

+  uVar6 = MiLocateCombineBlock

+                    (lVar2,*(undefined8 *)(param_2 + 8),*(uint *)(param_2 + 0x20) & 0x1f,1,

+                     param_2 + 0x18);

+  if (uVar6 != 0) {

+    puVar4 = *(undefined8 **)((uVar6 & 0xfffffffffffff000) + 0x10);

+    iVar5 = MiReferenceCloneProto(lVar3,*puVar4,uVar6 + 0x20,0,0);

+    if (iVar5 == 0) {

+      uVar8 = 0xc000009a;

+    }

+    else {

       LOCK();

-      *(longlong *)(unaff_RBX + 0x25c0) = *(longlong *)(unaff_RBX + 0x25c0) - lVar8;

+      piVar1 = (int *)(puVar4 + 0x31);

+      *piVar1 = *piVar1 + 1;

       UNLOCK();

+      uVar8 = 0xc000020a;

+      *param_3 = uVar6;

     }

   }

-  else if ((unaff_RSI & 0x10) == 0) goto LAB_0;

-  puVar1 = (ulonglong *)(unaff_RBX + 0x25a0);

-  LOCK();

-  uVar9 = *puVar1;

-  *puVar1 = *puVar1 - lVar8;

-  UNLOCK();

-  uVar2 = *(ulonglong *)(unaff_RBX + 0x20f0);

-  uVar10 = uVar9 - lVar8;

-  if (uVar9 < uVar10) {

-    uVar4 = uVar9;

-    uVar9 = uVar10;

-    if (uVar2 <= uVar10) goto joined_r0x0001402945fe;

-joined_r0x0001402944db:

-    if (uVar10 < *(ulonglong *)(unaff_RBX + 0x20ec)) {

-      return;

-    }

-    if (*(ulonglong *)(unaff_RBX + 0x20ec) <= uVar4) {

-      return;

-    }

-  }

-  else {

-    uVar4 = uVar10;

-    uVar10 = uVar9;

-    if (uVar9 < uVar2) goto joined_r0x0001402944db;

-joined_r0x0001402945fe:

-    uVar10 = uVar9;

-    if (uVar2 <= uVar4) goto joined_r0x0001402944db;

-  }

-  if (in_CR8 == '\x02') {

-    uVar6 = 0x11;

-    ExAcquireSpinLockExclusiveAtDpcLevel();

-  }

-  else {

-    uVar6 = ExAcquireSpinLockExclusive(unaff_RBX + 0x20fc);

-  }

-  if (*(ulonglong *)(unaff_RBX + 0x25a0) < *(ulonglong *)(unaff_RBX + 0x20ec)) {

-    if (*(int *)(*(longlong *)(unaff_RBX + 0x94) + 4) == 0) {

-      KeSetEvent(*(longlong *)(unaff_RBX + 0x94),0,0);

-    }

-    if (*(int *)(*(longlong *)(unaff_RBX + 0x98) + 4) != 1) goto LAB_1;

-    KeClearEvent();

-    lVar8 = *(longlong *)(unaff_RBX + 0x9c);

-  }

-  else {

-    lVar8 = *(longlong *)(unaff_RBX + 0x98);

-    if (*(ulonglong *)(unaff_RBX + 0x25a0) < *(ulonglong *)(unaff_RBX + 0x20f0)) {

-      if (*(int *)(lVar8 + 4) == 1) {

-        KeClearEvent();

-        KeClearEvent(*(undefined8 *)(unaff_RBX + 0x9c));

-      }

-      lVar8 = *(longlong *)(unaff_RBX + 0x94);

-      iVar7 = *(int *)(lVar8 + 4);

-    }

-    else {

-      if (*(int *)(lVar8 + 4) == 0) {

-        KeSetEvent(lVar8,0,0);

-        FUN_1406d48a6();

-        return;

-      }

-      if (*(longlong *)(unaff_RBX + 0x264c) == *(longlong *)(unaff_RBX + 0x20e4)) {

-        KeSetEvent(*(undefined8 *)(unaff_RBX + 0x9c),0,0);

-      }

-      lVar8 = *(longlong *)(unaff_RBX + 0x94);

-      iVar7 = *(int *)(lVar8 + 4);

-    }

-    if (iVar7 != 1) goto LAB_1;

-  }

-  KeClearEvent(lVar8);

-LAB_1:

-  MiReleaseSpinLockExclusive(unaff_RBX + 0x20fc,uVar6);

-  return;

+  ExReleaseSpinLockSharedFromDpcLevel(lVar7 + 0x68);

+  return uVar8;

 }
```

## `ApiSetCompose_ProcessV7Extension_Phase1`  (modified)

```diff
--- ApiSetCompose_ProcessV7Extension_Phase1
+++ ApiSetpGetSearchKeyHash
@@ -1,265 +1,52 @@
 

-int ApiSetCompose_ProcessV7Extension_Phase1

-              (longlong param_1,longlong param_2,undefined8 param_3,undefined8 param_4)

+int ApiSetpGetSearchKeyHash(longlong *param_1,char param_2,char param_3,char param_4,byte param_5)

 

 {

-  byte *pbVar1;

+  bool bVar1;

   ushort uVar2;

-  char cVar3;

-  short sVar4;

+  byte bVar3;

+  uint uVar4;

   int iVar5;

-  ulonglong uVar6;

-  longlong lVar7;

-  byte bVar8;

-  uint uVar9;

-  longlong lVar10;

-  longlong lVar11;

-  byte bVar12;

-  ulonglong uVar13;

-  undefined7 uVar15;

-  ulonglong uVar14;

-  undefined2 *puVar16;

-  longlong lVar17;

-  undefined2 uVar18;

-  uint *puVar20;

-  ushort uVar21;

-  int iVar22;

-  bool bVar23;

-  ushort local_res8 [4];

-  undefined2 local_res20;

-  longlong local_88;

-  longlong local_68;

-  undefined8 uStack_60;

-  longlong local_58;

-  undefined8 uStack_50;

-  undefined8 local_48;

-  uint uVar19;

+  byte *pbVar6;

   

-  uVar2 = *(ushort *)(param_1 + 0x10);

+  pbVar6 = (byte *)((ulonglong)*(ushort *)(param_1 + 2) + *param_1);

   iVar5 = 0;

-  if (uVar2 != 0) {

-    local_48 = 0;

-    local_68 = (ulonglong)*(uint *)(param_1 + 8) + param_1;

-    uStack_50 = 0;

-    local_58 = (ulonglong)uVar2 << 0x10;

-    lVar7 = *(longlong *)(param_2 + 0x20);

-    uStack_60 = (ulonglong)uVar2;

-    sVar4 = ApiSetpSearchForSectionIndex_V7

-                      (lVar7,lVar7 + 0x50,&local_68,

-                       CONCAT71((int7)((ulonglong)param_4 >> 8),*(byte *)(lVar7 + 0x59) >> 1) &

-                       0xffffffffffffff01);

-    if (sVar4 != -1) {

-      return -0x3fffffcb;

-    }

-    iVar5 = ApiSetSchemaExpander_InsertExtensionNameEntry(param_2,&local_68);

-    if (iVar5 < 0) {

-      return iVar5;

-    }

+  if (param_2 == '\0') {

+    uVar2 = *(ushort *)((longlong)param_1 + 0x12);

   }

-  bVar23 = *(short *)(param_1 + 0x12) != 0;

-  uVar9 = 0;

-  do {

-    if (!bVar23) {

-      return iVar5;

-    }

-    uVar6 = (ulonglong)uVar9;

-    local_48 = 0;

-    local_68 = 0;

-    uStack_60 = 0;

-    lVar7 = (ulonglong)*(uint *)(param_1 + 0xc) + param_1;

-    local_58 = 0;

-    uStack_50 = 0;

-    uVar13 = (ulonglong)*(ushort *)(lVar7 + 8 + uVar6 * 0x14);

-    cVar3 = ApiSetpGetContractKeyInfo

-                      ((ulonglong)*(uint *)(lVar7 + uVar6 * 0x14) + param_1,uVar13,0,&local_68);

-    if ((cVar3 == '\0') || (iVar22 = uStack_60._4_4_, 1 < uStack_60._4_4_ - 2U)) {

-      return -0x3fffffcd;

-    }

-    lVar11 = *(longlong *)(param_2 + 0x20);

-    uVar13 = CONCAT71((int7)(uVar13 >> 8),*(byte *)(lVar11 + 2)) & 0xffffffffffffff10;

-    bVar8 = *(byte *)(lVar11 + 2) & 8;

-    uVar15 = (undefined7)(uVar13 >> 8);

-    cVar3 = (char)uVar13;

-    if ((*(byte *)(lVar11 + 0x35) & 4) == 0) {

-      uVar19 = ApiSetpGetSearchKeyHash

-                         (&local_68,CONCAT71(uVar15,1),bVar8 != 0,cVar3 != '\0',

-                          *(undefined1 *)(lVar11 + 0x37));

-    }

-    else {

-      bVar8 = ApiSetpGetSearchKeyHash

-                        (&local_68,CONCAT71(uVar15,1),bVar8 != 0,cVar3 != '\0',

-                         *(undefined1 *)(lVar11 + 0x37));

-      uVar19 = (uint)bVar8;

-    }

-    local_res8[0] = ApiSetpSearchForSectionIndex_V7(lVar11,lVar11 + 0x2c,&local_68,1);

-    uVar13 = (ulonglong)local_res8[0];

-    if (local_res8[0] == 0xffff) {

-      iVar5 = ApiSetSchemaExpander_InsertContractEntry(param_2,&local_68,local_res8);

-      if (iVar5 < 0) {

-        return iVar5;

-      }

-      uVar13 = (ulonglong)local_res8[0];

-      iVar22 = uStack_60._4_4_;

-    }

-    else if (*(uint *)((*(byte *)(lVar11 + 0x34) * uVar13 - (ulonglong)*(ushort *)(lVar11 + 0x12)) +

-                      (ulonglong)*(uint *)(lVar11 + 0x2c) + lVar11) != uVar19) {

-      return -0x3ffffdd7;

-    }

-    lVar11 = *(longlong *)(param_2 + 0x20);

-    uVar2 = 0xffff;

-    local_res20 = 0xffff;

-    bVar8 = *(byte *)(lVar11 + 2) & 8;

-    bVar12 = *(byte *)(lVar11 + 2) & 0x10;

-    if (iVar22 == 2) {

-      if ((*(byte *)(lVar11 + 0x41) & 4) == 0) {

-        uVar19 = ApiSetpGetSearchKeyHash

-                           (&local_68,0,bVar8 != 0,bVar12 != 0,*(undefined1 *)(lVar11 + 0x43));

+  else {

+    uVar2 = *(ushort *)((longlong)param_1 + 0x14);

+  }

+  uVar4 = 0;

+  if (param_4 != '\0') {

+    uVar4 = 4;

+    pbVar6 = pbVar6 + (-(ulonglong)(*(char *)((longlong)param_1 + 10) != '\0') & 4) + 4;

+  }

+  if (uVar4 < uVar2) {

+    do {

+      bVar1 = false;

+      if (param_3 == '\0') {

+LAB_0:

+        bVar3 = *pbVar6;

+        if ((0x40 < bVar3) && (bVar3 < 0x5b)) {

+          bVar3 = bVar3 + 0x20;

+        }

+        iVar5 = (uint)bVar3 + (uint)param_5 * iVar5;

       }

       else {

-        bVar8 = ApiSetpGetSearchKeyHash

-                          (&local_68,0,bVar8 != 0,bVar12 != 0,*(undefined1 *)(lVar11 + 0x43));

-        uVar19 = (uint)bVar8;

+        if (((*(ushort *)((longlong)param_1 + 0x1a) != 0) &&

+            (*(ushort *)((longlong)param_1 + 0x1a) <= uVar4)) &&

+           (bVar1 = false, uVar4 <= *(ushort *)((longlong)param_1 + 0x1c))) {

+          bVar1 = true;

+        }

+        if ((((*(ushort *)((longlong)param_1 + 0x1e) == 0) ||

+             (uVar4 < *(ushort *)((longlong)param_1 + 0x1e))) || (*(ushort *)(param_1 + 4) < uVar4))

+           && (!bVar1)) goto LAB_0;

       }

-      local_res8[0] = ApiSetpSearchForSectionIndex_V7(lVar11,lVar11 + 0x38,&local_68);

-      uVar14 = (ulonglong)local_res8[0];

-      if (local_res8[0] == 0xffff) {

-        iVar5 = ApiSetSchemaExpander_InsertGroupContractEntry(param_2,&local_68,local_res8);

-        goto LAB_0;

-      }

-      lVar10 = (*(byte *)(lVar11 + 0x40) * uVar14 + (ulonglong)*(uint *)(lVar11 + 0x38)) -

-               (ulonglong)*(ushort *)(lVar11 + 0x12);

-      if (*(uint *)(lVar10 + lVar11) != uVar19) {

-        return -0x3ffffdd7;

-      }

-      bVar8 = *(byte *)(lVar10 + 6 + lVar11);

-      lVar10 = ((ulonglong)*(byte *)(lVar11 + 0x34) * (ulonglong)*(ushort *)(lVar10 + 4 + lVar11) +

-               (ulonglong)*(uint *)(lVar11 + 0x2c)) - (ulonglong)*(ushort *)(lVar11 + 0x12);

-      uVar2 = *(ushort *)(lVar10 + 4 + lVar11);

-      local_res20 = *(undefined2 *)(lVar10 + 6 + lVar11);

-LAB_1:

-      if ((bVar8 & 1) == 0) goto LAB_2;

-    }

-    else {

-      if ((*(byte *)(lVar11 + 0x4d) & 4) == 0) {

-        uVar19 = ApiSetpGetSearchKeyHash

-                           (&local_68,0,bVar8 != 0,bVar12 != 0,*(undefined1 *)(lVar11 + 0x4f));

-      }

-      else {

-        bVar8 = ApiSetpGetSearchKeyHash

-                          (&local_68,0,bVar8 != 0,bVar12 != 0,*(undefined1 *)(lVar11 + 0x4f));

-        uVar19 = (uint)bVar8;

-      }

-      local_res8[0] = ApiSetpSearchForSectionIndex_V7(lVar11,lVar11 + 0x44,&local_68);

-      uVar14 = (ulonglong)local_res8[0];

-      if (local_res8[0] != 0xffff) {

-        lVar10 = (*(byte *)(lVar11 + 0x4c) * uVar14 + (ulonglong)*(uint *)(lVar11 + 0x44)) -

-                 (ulonglong)*(ushort *)(lVar11 + 0x12);

-        if (*(uint *)(lVar10 + lVar11) != uVar19) {

-          return -0x3ffffdd7;

-        }

-        lVar17 = ((ulonglong)*(byte *)(lVar11 + 0x34) * (ulonglong)*(ushort *)(lVar10 + 4 + lVar11)

-                 + (ulonglong)*(uint *)(lVar11 + 0x2c)) - (ulonglong)*(ushort *)(lVar11 + 0x12);

-        uVar2 = *(ushort *)(lVar17 + 4 + lVar11);

-        local_res20 = *(undefined2 *)(lVar17 + 6 + lVar11);

-        bVar8 = *(byte *)(lVar10 + 10 + lVar11);

-        goto LAB_1;

-      }

-      iVar5 = ApiSetSchemaExpander_InsertSemverContractEntry(param_2,&local_68,local_res8);

-LAB_0:

-      if (iVar5 < 0) {

-        return iVar5;

-      }

-      uVar14 = (ulonglong)local_res8[0];

-      iVar22 = uStack_60._4_4_;

-LAB_2:

-      lVar11 = *(longlong *)(param_2 + 0x20);

-      if (iVar22 == 2) {

-        lVar10 = (*(byte *)(lVar11 + 0x40) * uVar14 + (ulonglong)*(uint *)(lVar11 + 0x38)) -

-                 (ulonglong)*(ushort *)(lVar11 + 0x12);

-        *(short *)(lVar10 + 4 + lVar11) = (short)uVar13;

-        *(undefined4 *)(lVar10 + 8 + lVar11) = *(undefined4 *)(lVar7 + 0xc + uVar6 * 0x14);

-      }

-      else {

-        lVar10 = (*(byte *)(lVar11 + 0x4c) * uVar14 + (ulonglong)*(uint *)(lVar11 + 0x44)) -

-                 (ulonglong)*(ushort *)(lVar11 + 0x12);

-        *(short *)(lVar10 + 4 + lVar11) = (short)uVar13;

-        if ((*(byte *)(lVar7 + 0x11 + uVar6 * 0x14) & 4) != 0) {

-          pbVar1 = (byte *)(lVar10 + 10 + lVar11);

-          *pbVar1 = *pbVar1 | 4;

-        }

-      }

-      local_88 = 0;

-      if ((*(char *)(param_2 + 0x10) != '\0') && (iVar22 == 3)) {

-        local_88 = ApiSetpSearchForApiSetA(*(undefined8 *)(param_2 + 0x28),local_68);

-      }

-      uVar21 = 0;

-      if (*(short *)(lVar7 + 10 + uVar6 * 0x14) != 0) {

-        do {

-          lVar11 = *(longlong *)(param_2 + 0x20);

-          puVar20 = (uint *)((ulonglong)*(uint *)(lVar7 + 4 + uVar6 * 0x14) +

-                            (ulonglong)uVar21 * 0x10 + param_1);

-          local_48 = 0;

-          uStack_50 = 0;

-          local_68 = (ulonglong)*puVar20 + param_1;

-          local_58 = (ulonglong)(ushort)puVar20[2] << 0x10;

-          uStack_60 = (ulonglong)CONCAT12(1,(ushort)puVar20[2]);

-          local_res8[0] = ApiSetpSearchForSectionIndex_V7(lVar11,lVar11 + 0x5c,&local_68);

-          if (local_res8[0] == 0xffff) {

-            iVar5 = ApiSetSchemaExpander_InsertHostEntry(param_2,&local_68,local_res8);

-            if (iVar5 < 0) {

-              return iVar5;

-            }

-            lVar11 = *(longlong *)(param_2 + 0x20);

-          }

-          bVar23 = *(short *)((longlong)puVar20 + 10) == 0;

-          if (bVar23) {

-            uVar18 = 0xffff;

-          }

-          else {

-            uVar19 = *(uint *)(param_2 + 0x9c) >> 4;

-            uVar18 = (undefined2)uVar19;

-            *(uint *)(param_2 + 0x9c) = *(uint *)(param_2 + 0x9c) + 0x10;

-            puVar16 = (undefined2 *)

-                      ((((ulonglong)*(ushort *)(lVar11 + 0x72) * (ulonglong)(uVar19 & 0xffff) +

-                        (ulonglong)*(uint *)(lVar11 + 0x68)) - (ulonglong)*(ushort *)(lVar11 + 0x12)

-                       ) + lVar11);

-            lVar10 = ((ulonglong)*(byte *)(lVar11 + 100) * (ulonglong)uVar2 +

-                     (ulonglong)*(uint *)(lVar11 + 0x5c)) - (ulonglong)*(ushort *)(lVar11 + 0x12);

-            *(undefined4 *)(puVar16 + 4) = *(undefined4 *)(lVar10 + 4 + lVar11);

-            puVar16[7] = *(undefined2 *)(lVar10 + 8 + lVar11);

-            lVar11 = *(longlong *)(param_2 + 0x20);

-            lVar11 = (ulonglong)*(uint *)(lVar11 + 0x5c) +

-                     lVar11 + ((ulonglong)*(byte *)(lVar11 + 100) * (ulonglong)local_res8[0] -

-                              (ulonglong)*(ushort *)(lVar11 + 0x12));

-            *(undefined4 *)(puVar16 + 2) = *(undefined4 *)(lVar11 + 4);

-            puVar16[6] = *(undefined2 *)(lVar11 + 8);

-            *puVar16 = local_res20;

-          }

-          lVar11 = *(longlong *)(param_2 + 0x20);

-          lVar11 = (ulonglong)*(uint *)(lVar11 + 0x2c) +

-                   lVar11 + (*(byte *)(lVar11 + 0x34) * uVar13 -

-                            (ulonglong)*(ushort *)(lVar11 + 0x12));

-          *(byte *)(lVar11 + 10) = *(byte *)(lVar11 + 10) | 2;

-          *(ushort *)(lVar11 + 4) = local_res8[0];

-          if (!bVar23) {

-            *(short *)(lVar11 + 8) = *(short *)(lVar11 + 8) + 1;

-            *(undefined2 *)(lVar11 + 6) = uVar18;

-          }

-          if (local_88 != 0) {

-            lVar11 = *(longlong *)(param_2 + 0x20);

-            lVar17 = (ulonglong)*(uint *)(local_88 + 0x10) + *(longlong *)(param_2 + 0x28);

-            lVar10 = (ulonglong)*(uint *)(lVar11 + 0x5c) +

-                     lVar11 + ((ulonglong)*(byte *)(lVar11 + 100) * (ulonglong)local_res8[0] -

-                              (ulonglong)*(ushort *)(lVar11 + 0x12));

-            *(int *)(lVar17 + 0xc) = *(int *)(lVar11 + 0x24) + *(int *)(lVar10 + 4);

-            *(uint *)(lVar17 + 0x10) = (uint)*(ushort *)(lVar10 + 8) * 2;

-          }

-          uVar21 = uVar21 + 1;

-        } while (uVar21 < *(ushort *)(lVar7 + 10 + uVar6 * 0x14));

-      }

-    }

-    uVar9 = uVar9 + 1;

-    bVar23 = uVar9 < *(ushort *)(param_1 + 0x12);

-  } while( true );

+      pbVar6 = pbVar6 + (ulonglong)(*(char *)((longlong)param_1 + 10) != '\0') + 1;

+      uVar4 = uVar4 + 1;

+    } while (uVar4 < uVar2);

+  }

+  return iVar5;

 }
```

## `ApiSetpResolveHost`  (modified)

```diff
--- ApiSetpResolveHost
+++ ApiSetpResolveHost
@@ -1,79 +1,160 @@
 

-/* WARNING: Instruction at (ram,0x00014065fb19) overlaps instruction at (ram,0x00014065fb18)

-    */

-

-uint ApiSetpResolveHost(undefined8 param_1,uint param_2,longlong param_3,ushort *param_4)

+undefined8

+ApiSetpResolveHost(longlong param_1,undefined8 param_2,undefined2 param_3,undefined8 param_4,

+                  ushort *param_5,undefined1 *param_6,short *param_7)

 

 {

-  ushort uVar1;

-  uint in_EAX;

-  uint uVar2;

-  longlong lVar3;

-  longlong unaff_RBP;

-  ulonglong unaff_RSI;

-  char *unaff_RDI;

-  ulonglong in_R10;

-  uint in_R11D;

-  longlong unaff_R14;

-  longlong unaff_R15;

+  short sVar1;

+  char cVar2;

+  ushort uVar3;

+  uint uVar4;

+  byte bVar5;

+  longlong lVar6;

+  byte bVar7;

+  ulonglong uVar8;

+  undefined7 uVar9;

+  uint *puVar10;

+  short sVar11;

+  undefined2 uVar12;

+  undefined1 uVar13;

+  ulonglong uVar14;

+  undefined2 in_stack_ffffffffffffff98;

+  undefined1 uVar15;

+  undefined8 local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

+  undefined8 uStack_40;

+  undefined8 local_38;

   

-  *unaff_RDI = *unaff_RDI + -1;

-  LOCK();

-  uVar2 = *(uint *)(unaff_RSI + 0xf000000);

-  *(uint *)(unaff_RSI + 0xf000000) = in_EAX;

-  UNLOCK();

-  while( true ) {

-    uVar2 = (uint)unaff_RDI + uVar2 * 2;

-    if (uVar2 < (uint)unaff_RDI) {

-      return param_2;

+  uVar15 = (undefined1)((ushort)in_stack_ffffffffffffff98 >> 8);

+  local_38 = 0;

+  param_7[0] = 0;

+  param_7[1] = 0;

+  param_7[2] = 0;

+  param_7[3] = 0;

+  param_7[4] = 0;

+  param_7[5] = 0;

+  param_7[6] = 0;

+  param_7[7] = 0;

+  uVar13 = 0;

+  local_58 = 0;

+  uStack_50 = 0;

+  local_48 = 0;

+  uStack_40 = 0;

+  cVar2 = ApiSetpGetContractKeyInfo(param_2,param_3,1,&local_58);

+  if (cVar2 == '\0') goto LAB_0;

+  if (uStack_50._4_4_ == 1) {

+    lVar6 = param_1 + 0x2c;

+    uVar3 = ApiSetpSearchForSectionIndex_V7(param_1,lVar6,&local_58,1);

+    if (uVar3 == 0xffff) goto LAB_0;

+    uVar14 = (ulonglong)*(ushort *)(param_1 + 0x12);

+    uVar12 = CONCAT11(uVar15,*(undefined1 *)(param_1 + 0x37));

+    puVar10 = (uint *)((ulonglong)*(uint *)(param_1 + 0x2c) +

+                      ((ulonglong)uVar3 * (ulonglong)*(byte *)(param_1 + 0x34) - uVar14) + param_1);

+    uVar8 = CONCAT71((int7)((ulonglong)lVar6 >> 8),*(byte *)(param_1 + 2)) & 0xffffffffffffff10;

+    bVar5 = *(byte *)(param_1 + 2) & 8;

+    uVar9 = (undefined7)(uVar8 >> 8);

+    cVar2 = (char)uVar8;

+    if ((*(byte *)(param_1 + 0x35) & 4) == 0) {

+      uVar4 = ApiSetpGetSearchKeyHash(&local_58,CONCAT71(uVar9,1),bVar5 != 0,cVar2 != '\0',uVar12);

     }

-    if ((uint)unaff_RSI < uVar2) {

-      return 0xc00000e4;

+    else {

+      bVar5 = ApiSetpGetSearchKeyHash(&local_58,CONCAT71(uVar9,1),bVar5 != 0,cVar2 != '\0',uVar12);

+      uVar4 = (uint)bVar5;

     }

-    do {

-      uVar2 = (int)in_R10 + 1;

-      in_R10 = (ulonglong)uVar2;

-      if (in_R11D <= uVar2) {

-        if (*(ushort *)(param_3 + 0x3c) != 0) {

-          uVar2 = param_2;

-          do {

-            if ((ushort)in_R11D <=

-                *(ushort *)

-                 (((ulonglong)uVar2 * (ulonglong)*(byte *)(param_3 + 0x40) - (ulonglong)*param_4) +

-                  (ulonglong)*(uint *)(param_3 + 0x38) + 4 + param_3)) {

-              return 0xc00000e4;

-            }

-            uVar2 = uVar2 + 1;

-          } while (uVar2 < *(ushort *)(param_3 + 0x3c));

-          param_4 = (ushort *)(param_3 + 0x12);

-        }

-        if (*(ushort *)(param_3 + 0x48) != 0) {

-          uVar2 = param_2;

-          do {

-            if ((ushort)in_R11D <=

-                *(ushort *)

-                 (((ulonglong)uVar2 * (ulonglong)*(byte *)(param_3 + 0x4c) - (ulonglong)*param_4) +

-                  (ulonglong)*(uint *)(param_3 + 0x44) + 4 + param_3)) {

-              return 0xc00000e4;

-            }

-            uVar2 = uVar2 + 1;

-          } while (uVar2 < *(ushort *)(param_3 + 0x48));

-        }

-        return param_2;

-      }

-      lVar3 = (in_R10 * unaff_R14 - unaff_RBP) + unaff_R15;

-    } while ((*(byte *)(lVar3 + 10 + param_3) & 2) == 0);

-    uVar1 = *(ushort *)(lVar3 + 4 + param_3);

-    if (*(ushort *)(param_3 + 0x60) <= uVar1) break;

-    unaff_RSI = (ulonglong)*(uint *)(param_3 + 0x28);

-    lVar3 = ((ulonglong)uVar1 * (ulonglong)*(byte *)(param_3 + 100) - unaff_RBP) + param_3;

-    uVar2 = *(uint *)((ulonglong)*(uint *)(param_3 + 0x5c) + 4 + lVar3);

-    unaff_RDI = (char *)(ulonglong)uVar2;

-    if (*(uint *)(param_3 + 0x28) < uVar2) {

-      return 0xc00000e4;

+    if (*puVar10 != uVar4) goto LAB_0;

+    sVar11 = (short)puVar10[2];

+    bVar5 = *(byte *)((longlong)puVar10 + 10);

+    uVar3 = (ushort)puVar10[1];

+    uVar12 = *(undefined2 *)((longlong)puVar10 + 6);

+  }

+  else if (uStack_50._4_4_ == 2) {

+    uVar13 = 1;

+    uVar3 = ApiSetpSearchForSectionIndex_V7(param_1,param_1 + 0x38,&local_58,0);

+    if (uVar3 == 0xffff) goto LAB_0;

+    uVar12 = CONCAT11(uVar15,*(undefined1 *)(param_1 + 0x43));

+    puVar10 = (uint *)((ulonglong)*(uint *)(param_1 + 0x38) +

+                      param_1 + ((ulonglong)*(byte *)(param_1 + 0x40) * (ulonglong)uVar3 -

+                                (ulonglong)*(ushort *)(param_1 + 0x12)));

+    bVar7 = *(byte *)(param_1 + 2) & 0x10;

+    bVar5 = *(byte *)(param_1 + 2) & 8;

+    if ((*(byte *)(param_1 + 0x41) & 4) == 0) {

+      uVar4 = ApiSetpGetSearchKeyHash(&local_58,0,bVar5 != 0,bVar7 != 0,uVar12);

     }

-    uVar2 = (uint)*(ushort *)((ulonglong)*(uint *)(param_3 + 0x5c) + 8 + lVar3);

+    else {

+      bVar5 = ApiSetpGetSearchKeyHash(&local_58,0,bVar5 != 0,bVar7 != 0,uVar12);

+      uVar4 = (uint)bVar5;

+    }

+    if (*puVar10 != uVar4) {

+      uVar13 = 0;

+      goto LAB_0;

+    }

+    if (((*(byte *)((longlong)puVar10 + 6) & 4) != 0) &&

+       (((*(byte *)((longlong)puVar10 + 6) & 2) != 0 ||

+        ((puVar10[2] != 0 && (cVar2 = ApiSetpIsFeatureEnabled(), cVar2 == '\0'))))))

+    goto LAB_0;

+    uVar14 = (ulonglong)*(ushort *)(param_1 + 0x12);

+    lVar6 = (((ulonglong)(ushort)puVar10[1] * (ulonglong)*(byte *)(param_1 + 0x34) +

+             (ulonglong)*(uint *)(param_1 + 0x2c)) - (ulonglong)*(ushort *)(param_1 + 0x12)) +

+            param_1;

+    bVar5 = *(byte *)(lVar6 + 10);

+    sVar11 = *(short *)(lVar6 + 8);

+    uVar3 = *(ushort *)(lVar6 + 4);

+    uVar12 = *(undefined2 *)(lVar6 + 6);

   }

-  return 0xc00000e4;

+  else {

+    if (uStack_50._4_4_ != 3) goto LAB_0;

+    uVar3 = ApiSetpSearchForSectionIndex_V7(param_1,param_1 + 0x44,&local_58,0);

+    if (uVar3 == 0xffff) goto LAB_0;

+    uVar14 = (ulonglong)*(ushort *)(param_1 + 0x12);

+    uVar12 = CONCAT11(uVar15,*(undefined1 *)(param_1 + 0x4f));

+    puVar10 = (uint *)((ulonglong)*(uint *)(param_1 + 0x44) +

+                      ((ulonglong)uVar3 * (ulonglong)*(byte *)(param_1 + 0x4c) - uVar14) + param_1);

+    bVar7 = *(byte *)(param_1 + 2) & 0x10;

+    bVar5 = *(byte *)(param_1 + 2) & 8;

+    if ((*(byte *)(param_1 + 0x4d) & 4) == 0) {

+      uVar4 = ApiSetpGetSearchKeyHash(&local_58,0,bVar5 != 0,bVar7 != 0,uVar12);

+    }

+    else {

+      bVar5 = ApiSetpGetSearchKeyHash(&local_58,0,bVar5 != 0,bVar7 != 0,uVar12);

+      uVar4 = (uint)bVar5;

+    }

+    if ((*puVar10 != uVar4) ||

+       (((*(byte *)((longlong)puVar10 + 10) & 4) != 0 &&

+        (*(byte *)((longlong)puVar10 + 9) < (ushort)uStack_40)))) goto LAB_0;

+    lVar6 = (((ulonglong)(ushort)puVar10[1] * (ulonglong)*(byte *)(param_1 + 0x34) +

+             (ulonglong)*(uint *)(param_1 + 0x2c)) - uVar14) + param_1;

+    sVar11 = *(short *)(lVar6 + 8);

+    bVar5 = *(byte *)(lVar6 + 10);

+    uVar3 = *(ushort *)(lVar6 + 4);

+    uVar12 = *(undefined2 *)(lVar6 + 6);

+  }

+  uVar13 = 1;

+  if (((bVar5 >> 1 & 1) != 0) &&

+     (lVar6 = ((ulonglong)*(byte *)(param_1 + 100) * (ulonglong)uVar3 +

+              (ulonglong)*(uint *)(param_1 + 0x5c)) - uVar14,

+     *(byte *)(lVar6 + 10 + param_1) <= *(byte *)(param_1 + 3))) {

+    *(ulonglong *)(param_7 + 4) =

+         (ulonglong)*(uint *)(param_1 + 0x24) + (*(uint *)(lVar6 + 4 + param_1) - uVar14) + param_1;

+    sVar1 = *(short *)(lVar6 + 8 + param_1) * 2;

+    *param_7 = sVar1;

+    param_7[1] = sVar1;

+    if ((param_5 != (ushort *)0x0) &&

+       ((sVar11 != 0 &&

+        (uVar4 = ApiSetpSearchForHostOverrideIndex_V7

+                           (param_1,uVar12,sVar11,*(undefined8 *)(param_5 + 4),*param_5 >> 1),

+        uVar4 != 0xffff)))) {

+      lVar6 = ((ulonglong)*(ushort *)(param_1 + 0x72) * (ulonglong)uVar4 +

+              (ulonglong)*(uint *)(param_1 + 0x68)) - (ulonglong)*(ushort *)(param_1 + 0x12);

+      *(ulonglong *)(param_7 + 4) =

+           (((ulonglong)*(uint *)(lVar6 + 8 + param_1) + (ulonglong)*(uint *)(param_1 + 0x24)) -

+           (ulonglong)*(ushort *)(param_1 + 0x12)) + param_1;

+      param_7[1] = *(short *)(lVar6 + 0xe + param_1) * 2;

+      *param_7 = *(short *)(lVar6 + 0xe + param_1) * 2;

+    }

+  }

+LAB_0:

+  *param_6 = uVar13;

+  return 0;

 }
```

## `PopBatteryQueryStatus`  (modified)

```diff
--- PopBatteryQueryStatus
+++ PopBatteryQueryStatus
@@ -1,34 +1,102 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-/* WARNING: Instruction at (ram,0x0001407594b9) overlaps instruction at (ram,0x0001407594b8)

-    */

-

-void PopBatteryQueryStatus(longlong param_1)

+undefined8 PopBatteryQueryStatus(longlong param_1,char param_2)

 

 {

-  char *pcVar1;

-  char in_AL;

-  undefined7 in_register_00000001;

-  byte *unaff_RBX;

-  longlong unaff_RBP;

+  undefined8 *puVar1;

+  undefined8 *puVar2;

+  longlong lVar3;

+  uint uVar4;

+  uint uVar5;

+  undefined8 uVar6;

+  uint uVar7;

+  uint uVar8;

+  uint uVar9;

+  int iVar10;

+  uint uVar11;

   

-  *unaff_RBX = *unaff_RBX << 1 | (char)*unaff_RBX < '\0';

-  *(char *)CONCAT71(in_register_00000001,in_AL) =

-       *(char *)CONCAT71(in_register_00000001,in_AL) + in_AL;

-  pcVar1 = (char *)(CONCAT71(in_register_00000001,in_AL) + -0x73);

-  *pcVar1 = *pcVar1 + (char)param_1;

-  if (param_1 != 1 && *pcVar1 != '\0') {

-    PopReleaseRwLock(&PopPowerAggregatorLock);

-    if (*(int *)(unaff_RBP + -0x20) != 0x11) {

-      *(undefined4 *)(unaff_RBP + -0x28) = 0;

-      *(undefined4 *)(unaff_RBP + -0x1c) = 0x80;

-      *(undefined4 *)(unaff_RBP + -0x30) = 3;

-      *(undefined4 *)(unaff_RBP + -0x2c) = 0x80000024;

-      PopExecutePowerAction(unaff_RBP + -0x20,0,unaff_RBP + -0x30,5,1);

+  puVar1 = (undefined8 *)(param_1 + 0xbc);

+  puVar2 = (undefined8 *)(param_1 + 0x94);

+  *puVar1 = 0;

+  *(undefined8 *)(param_1 + 0xc4) = 0;

+  *(undefined8 *)(param_1 + 0xcc) = 0;

+  *(undefined8 *)(param_1 + 0xd4) = 0;

+  *(undefined4 *)(param_1 + 0xdc) = 0;

+  *(undefined4 *)puVar1 = *(undefined4 *)(param_1 + 0x6c);

+  *(undefined1 *)(param_1 + 0xd0) = 1;

+  if (param_2 != '\0') {

+    uVar8 = *(uint *)(param_1 + 0xf8) & 1;

+    PopPrepareIoctl(*(undefined8 *)(param_1 + 0x38),0x294064,0,puVar1,uVar8 * 0x10 + 0x14,

+                    (-(uVar8 != 0) & 0x14U) + 0x10);

+    if (param_2 == '\0') {

+      lVar3 = *(longlong *)(*(longlong *)(param_1 + 0x38) + 0xb8);

+      *(code **)(lVar3 + -0x10) = PopBatteryIrpComplete;

+      *(longlong *)(lVar3 + -8) = param_1;

+      *(undefined1 *)(lVar3 + -0x45) = 0xe0;

+      IofCallDriver(*(undefined8 *)(param_1 + 0x30),*(undefined8 *)(param_1 + 0x38));

     }

-    return;

+    else {

+      uVar6 = IoSynchronousCallDriver(*(undefined8 *)(param_1 + 0x30));

+      if ((int)uVar6 < 0) {

+        return uVar6;

+      }

+      if ((*(uint *)(param_1 + 0xf8) & 1) == 0) {

+        *puVar2 = *puVar1;

+        *(undefined8 *)(param_1 + 0x9c) = *(undefined8 *)(param_1 + 0xc4);

+      }

+      else {

+        *puVar2 = *puVar1;

+        *(undefined8 *)(param_1 + 0x9c) = *(undefined8 *)(param_1 + 0xc4);

+        *(undefined8 *)(param_1 + 0xa4) = *(undefined8 *)(param_1 + 0xcc);

+        *(undefined8 *)(param_1 + 0xac) = *(undefined8 *)(param_1 + 0xd4);

+        *(undefined4 *)(param_1 + 0xb4) = *(undefined4 *)(param_1 + 0xdc);

+      }

+    }

+    return 0;

   }

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  uVar8 = *(uint *)(param_1 + 0x98);

+  *(undefined4 *)(param_1 + 0xc4) = *(undefined4 *)puVar2;

+  uVar11 = *(uint *)(param_1 + 0x88);

+  if (uVar11 < uVar8) {

+    uVar9 = uVar11 + 1;

+    uVar7 = 0xffffffff;

+  }

+  else {

+    uVar7 = *(uint *)(param_1 + 0x84);

+    if (uVar7 < uVar8) {

+      uVar9 = uVar7 + 1;

+      uVar7 = uVar11;

+    }

+    else {

+      uVar9 = 0;

+    }

+  }

+  iVar10 = 100;

+  uVar11 = *(int *)(param_1 + 0x80) * 199;

+  while( true ) {

+    uVar4 = uVar11 / 200;

+    uVar5 = uVar4 - 1;

+    if ((uVar8 <= uVar5) && (uVar5 < uVar7)) {

+      uVar7 = uVar5;

+    }

+    if (uVar4 <= uVar8) break;

+    uVar11 = uVar11 + *(int *)(param_1 + 0x80) * -2;

+    iVar10 = iVar10 + -1;

+    if (iVar10 == 0) {

+LAB_0:

+      *(undefined4 *)(param_1 + 0xc0) = 0xffffffff;

+      *(uint *)(param_1 + 0xcc) = uVar7;

+      *(uint *)(param_1 + 200) = uVar9;

+      *(undefined4 *)(param_1 + 0xd4) = PopBatteryInstantaneousPeakPowerThresholdInMW;

+      *(undefined4 *)(param_1 + 0xd8) = PopBatterySustainablePeakPowerThresholdInMW;

+      *(undefined4 *)(param_1 + 0xdc) = PopBatteryPresentRateThreshold;

+                    /* WARNING: Subroutine does not return */

+      DbgPrintEx(0x92,2,"\nBattery Triggers [%p]\n|- High = %u\n|- Low  = %u\n",param_1,uVar7,uVar9)

+      ;

+    }

+  }

+  if (uVar9 < uVar4) {

+    uVar9 = uVar4;

+  }

+  goto LAB_0;

 }
```

## `KiAdjustTimerDueTimes`  (modified)

```diff
--- KiAdjustTimerDueTimes
+++ KiAdjustTimerDueTimes
@@ -1,101 +1,156 @@
 

-void KiAdjustTimerDueTimes(void)

+void KiAdjustTimerDueTimes(longlong param_1,longlong param_2,byte *param_3)

 

 {

-  uint *puVar1;

-  longlong lVar2;

-  longlong *plVar3;

-  undefined8 uVar4;

-  code *pcVar5;

-  char cVar6;

-  longlong *in_RAX;

-  ulonglong uVar7;

-  byte bVar8;

-  sbyte sVar9;

-  ulonglong uVar10;

-  longlong unaff_RBP;

-  longlong unaff_RSI;

+  longlong ******pppppplVar1;

+  code *pcVar2;

+  longlong ******pppppplVar3;

+  char cVar4;

+  longlong *****ppppplVar5;

+  byte bVar6;

+  sbyte sVar7;

+  longlong *****ppppplVar8;

+  longlong *****ppppplVar9;

+  ulonglong *puVar10;

   ulonglong uVar11;

-  ulonglong uVar12;

-  byte bVar13;

-  ulonglong unaff_R13;

-  bool in_ZF;

+  byte bVar12;

+  ulonglong *puVar13;

+  uint uVar14;

+  uint uVar15;

+  undefined1 local_res20 [8];

+  undefined1 *puVar16;

+  undefined4 local_88 [2];

+  ulonglong *local_80;

+  longlong *****local_78;

+  longlong *****local_70;

+  undefined8 local_68;

+  undefined8 uStack_60;

+  undefined8 local_58;

   

-  if (!in_ZF) {

+  local_70 = (longlong *****)&local_78;

+  uVar15 = 0;

+  puVar13 = (ulonglong *)(param_2 + 0x200);

+  local_78 = (longlong *****)&local_78;

+  local_res20[0] = 0;

+  do {

+    uVar14 = 0;

+    puVar10 = puVar13;

     do {

-      puVar1 = (uint *)(in_RAX + -4);

-      lVar2 = *in_RAX;

-      if ((*(longlong **)(lVar2 + 8) != in_RAX) ||

-         (plVar3 = (longlong *)in_RAX[1], (longlong *)*plVar3 != in_RAX)) {

-        pcVar5 = (code *)swi(0x29);

-        (*pcVar5)(3);

-        pcVar5 = (code *)swi(3);

-        (*pcVar5)();

+      local_88[0] = 0;

+      while( true ) {

+        LOCK();

+        uVar11 = *puVar10;

+        *puVar10 = *puVar10 | 1;

+        UNLOCK();

+        if ((uVar11 & 1) == 0) break;

+        do {

+          KeYieldProcessorEx(local_88);

+        } while (*puVar10 != 0);

+      }

+      pppppplVar1 = (longlong ******)puVar10[1];

+      local_80 = puVar10;

+      while (pppppplVar3 = pppppplVar1, pppppplVar3 != (longlong ******)(puVar10 + 1)) {

+        pppppplVar1 = (longlong ******)*pppppplVar3;

+        if (((*(byte *)((longlong)pppppplVar3 + -0x1f) & 1) != *param_3) &&

+           ((*param_3 == 0 || ((*(byte *)((longlong)pppppplVar3 + -0x1f) & 2) == 0)))) {

+          KiRemoveEntryTimer(param_2,pppppplVar3 + -4,uVar14);

+          if ((longlong ******)*local_70 != &local_78) goto LAB_0;

+          pppppplVar3[1] = local_70;

+          *pppppplVar3 = (longlong *****)&local_78;

+          *local_70 = (longlong ****)pppppplVar3;

+          local_70 = (longlong *****)pppppplVar3;

+        }

+      }

+      LOCK();

+      *local_80 = 0;

+      UNLOCK();

+      uVar14 = uVar14 + 1;

+      puVar10 = puVar10 + 4;

+    } while (uVar14 < 0x100);

+    uVar15 = uVar15 + 1;

+    puVar13 = puVar13 + 0x400;

+  } while (uVar15 < 2);

+  if ((longlong ******)local_78 != &local_78) {

+    do {

+      pppppplVar1 = (longlong ******)(local_78 + -4);

+      ppppplVar8 = (longlong *****)*local_78;

+      if (((longlong *****)ppppplVar8[1] != local_78) ||

+         (ppppplVar5 = (longlong *****)local_78[1], (longlong *****)*ppppplVar5 != local_78)) {

+LAB_0:

+        pcVar2 = (code *)swi(0x29);

+        (*pcVar2)(3);

+        pcVar2 = (code *)swi(3);

+        (*pcVar2)();

         return;

       }

-      *plVar3 = lVar2;

-      *(longlong **)(lVar2 + 8) = plVar3;

-      uVar11 = in_RAX[-1];

-      uVar7 = uVar11 - *(longlong *)(unaff_RSI + 0x18);

-      if (*(longlong *)(unaff_RSI + 0x18) < 0) {

-        if (uVar7 < uVar11) {

-          uVar7 = 0xffffffffffffffff;

+      *ppppplVar5 = (longlong ****)ppppplVar8;

+      ppppplVar8[1] = (longlong ****)ppppplVar5;

+      ppppplVar8 = (longlong *****)local_78[-1];

+      ppppplVar5 = (longlong *****)((longlong)ppppplVar8 - *(longlong *)(param_3 + 0x18));

+      if (*(longlong *)(param_3 + 0x18) < 0) {

+        if (ppppplVar5 < ppppplVar8) {

+          ppppplVar5 = (longlong *****)0xffffffffffffffff;

         }

       }

-      else if (uVar11 < uVar7) {

-        uVar7 = unaff_R13;

+      else if (ppppplVar8 < ppppplVar5) {

+        ppppplVar5 = (longlong *****)0x0;

       }

-      bVar13 = (byte)KiWaitNever & 0x3f;

-      uVar11 = ((in_RAX[2] ^ KiWaitNever) << bVar13 | (in_RAX[2] ^ KiWaitNever) >> 0x40 - bVar13) ^

-               (ulonglong)puVar1;

-      bVar13 = *(byte *)((longlong)in_RAX + -0x1f) >> 2;

-      uVar12 = (uVar11 >> 0x38 | (uVar11 & 0xff000000000000) >> 0x28 |

+      bVar12 = (byte)KiWaitNever & 0x3f;

+      uVar11 = (((ulonglong)local_78[2] ^ KiWaitNever) << bVar12 |

+               ((ulonglong)local_78[2] ^ KiWaitNever) >> 0x40 - bVar12) ^ (ulonglong)pppppplVar1;

+      bVar12 = *(byte *)((longlong)local_78 + -0x1f) >> 2;

+      uVar11 = (uVar11 >> 0x38 | (uVar11 & 0xff000000000000) >> 0x28 |

                 (uVar11 & 0xff0000000000) >> 0x18 | (uVar11 & 0xff00000000) >> 8 |

                 (uVar11 & 0xff000000) << 8 | (uVar11 & 0xff0000) << 0x18 | (uVar11 & 0xff00) << 0x28

                | uVar11 << 0x38) ^ KiWaitAlways;

-      uVar11 = unaff_R13;

-      if (bVar13 != 0) {

-        bVar8 = *(byte *)((longlong)in_RAX + -0x1f) >> 5;

-        sVar9 = bVar8 + 2;

-        if (bVar13 < 8) {

-          sVar9 = bVar8 + 3;

+      ppppplVar8 = (longlong *****)0x0;

+      if (bVar12 != 0) {

+        bVar6 = *(byte *)((longlong)local_78 + -0x1f) >> 5;

+        sVar7 = bVar6 + 2;

+        if (bVar12 < 8) {

+          sVar7 = bVar6 + 3;

         }

-        uVar11 = (ulonglong)

-                 ((uint)((ushort)((~-(ushort)(bVar13 < 8) & 8 | (ushort)(bVar13 & 7)) << sVar9) >> 3

-                        ) * 10000);

+        ppppplVar8 = (longlong *****)

+                     (ulonglong)

+                     ((uint)((ushort)((~-(ushort)(bVar12 < 8) & 8 | (ushort)(bVar12 & 7)) << sVar7)

+                            >> 3) * 10000);

       }

-      uVar4 = *(undefined8 *)(unaff_RBP + 0x48);

-      in_RAX[-1] = uVar7;

-      *(undefined8 *)(unaff_RBP + -0x28) = 0;

-      *(undefined8 *)(unaff_RBP + -0x20) = 0;

-      uVar10 = 0xffffffffffffffff;

-      if (uVar7 <= uVar11 + uVar7) {

-        uVar10 = uVar11 + uVar7;

+      local_78[-1] = (longlong ****)ppppplVar5;

+      uStack_60 = 0;

+      ppppplVar9 = (longlong *****)0xffffffffffffffff;

+      if (ppppplVar5 <= (longlong *****)((longlong)ppppplVar8 + (longlong)ppppplVar5)) {

+        ppppplVar9 = (longlong *****)((longlong)ppppplVar8 + (longlong)ppppplVar5);

       }

-      *puVar1 = *puVar1 | 0x80;

-      *(undefined8 *)(unaff_RBP + -0x18) = 0;

-      *(uint *)(unaff_RBP + -0x28) = *puVar1;

-      *(char *)(unaff_RBP + -0x26) = (char)(uVar10 >> 0x12);

-      *puVar1 = *(uint *)(unaff_RBP + -0x28);

-      cVar6 = KiInsertTimerTable(uVar4,puVar1,uVar12);

-      if (cVar6 == '\0') {

-        KiTimerWaitTest(uVar4,puVar1,0);

+      *(uint *)pppppplVar1 = *(uint *)pppppplVar1 | 0x80;

+      local_58 = 0;

+      local_68._0_3_ = CONCAT12((char)((ulonglong)ppppplVar9 >> 0x12),(short)*(uint *)pppppplVar1);

+      uVar15 = CONCAT13((char)(*(uint *)pppppplVar1 >> 0x18),(undefined3)local_68);

+      local_68 = (ulonglong)uVar15;

+      *(uint *)pppppplVar1 = uVar15;

+      if (param_3[0x20] == 0) {

+        puVar16 = (undefined1 *)0x0;

       }

-      else if (((uint)DAT_0 >> 0x11 & 1) == 0) {

+      else {

+        puVar16 = local_res20;

+      }

+      cVar4 = KiInsertTimerTable(param_1,pppppplVar1,uVar11,(ulonglong)ppppplVar9 >> 0x12 & 0xff,

+                                 puVar16);

+      if (cVar4 == '\0') {

+        KiTimerWaitTest(param_1,pppppplVar1,0);

+      }

+      else if (((uint)DAT_1 >> 0x11 & 1) == 0) {

         LOCK();

-        *puVar1 = *puVar1 & 0xffffff7f;

+        *(uint *)pppppplVar1 = *(uint *)pppppplVar1 & 0xffffff7f;

         UNLOCK();

       }

       else {

-        KiTraceSetTimer(puVar1,uVar12,0);

+        KiTraceSetTimer(pppppplVar1,uVar11,0);

       }

-      in_RAX = *(longlong **)(unaff_RBP + -0x38);

-    } while (in_RAX != (longlong *)(unaff_RBP + -0x38));

+    } while ((longlong ******)local_78 != &local_78);

   }

-  if ((*(char *)(*(longlong *)(unaff_RBP + 0x48) + 0x21) != (char)unaff_R13) ||

-     (*(char *)(unaff_RSI + 0x20) != (char)unaff_R13)) {

-    KiAdjustTimer2DueTimes();

+  if ((*(char *)(param_1 + 0x21) != '\0') || (param_3[0x20] != 0)) {

+    KiAdjustTimer2DueTimes(param_3);

   }

   return;

 }
```

## `HalpApicRegisterIoUnit`  (modified)

```diff
--- HalpApicRegisterIoUnit
+++ HalpApicRegisterIoUnit
@@ -1,10 +1,133 @@
 

-/* WARNING: Control flow encountered bad instruction data */

-

-void HalpApicRegisterIoUnit(void)

+void HalpApicRegisterIoUnit(undefined8 param_1,undefined4 param_2,undefined4 param_3)

 

 {

-                    /* WARNING: Bad instruction - Truncating control flow here */

-  halt_baddata();

+  bool bVar1;

+  char cVar2;

+  int iVar3;

+  uint uVar4;

+  undefined4 uVar5;

+  char local_res8 [8];

+  char local_res10 [8];

+  char local_res18 [8];

+  undefined1 local_res20 [8];

+  undefined4 local_168;

+  undefined4 local_164;

+  code *local_160;

+  code *local_158;

+  code *local_150;

+  code *local_148;

+  code *local_140;

+  code *local_130;

+  code *local_120;

+  undefined8 local_118;

+  code *local_110;

+  code *local_108;

+  code *local_100;

+  code *local_f8;

+  code *local_f0;

+  code *local_e8;

+  code *local_e0;

+  code *local_d8;

+  code *local_c8;

+  code *local_b8;

+  undefined8 *local_90;

+  undefined4 local_88;

+  undefined4 local_84;

+  undefined4 local_80;

+  uint local_7c;

+  undefined4 local_78;

+  undefined4 local_74;

+  undefined4 local_70;

+  undefined4 local_6c;

+  undefined8 local_68;

+  undefined8 uStack_60;

+  undefined8 local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

+  undefined8 uStack_40;

+  

+  local_res18[0] = '\0';

+  local_res8[0] = '\0';

+  local_res20[0] = 0;

+  local_res10[0] = '\0';

+  bVar1 = false;

+  memset(&local_168,0,0x100);

+  local_90 = &local_68;

+  local_164 = 0x100;

+  local_68 = 0;

+  uStack_60 = 0;

+  local_58 = 0;

+  uStack_50 = 0;

+  local_168 = 1;

+  local_48 = 0;

+  uStack_40 = 0;

+  local_88 = 0x30;

+  local_84 = 2;

+  local_80 = param_2;

+  if (HalpApicX2Mode == '\0') {

+    local_74 = 4;

+    local_130 = HalpApicSetLogicalId;

+    uVar4 = local_7c | 4;

+    local_70 = 0xf;

+  }

+  else {

+    local_f0 = HalpApicConvertId;

+    uVar5 = 0xffff;

+    local_70 = 0xffff;

+    local_74 = 0x10;

+    uVar4 = local_7c;

+    if (HalpApicGuestX2Mode == '\0') {

+      uVar4 = local_7c | 0x100;

+    }

+    cVar2 = HalpApicGetCpuInfo(local_res18,local_res20,local_res8,local_res10);

+    if (cVar2 != '\0') {

+      if (local_res10[0] == '\x02') {

+        if (local_res18[0] != '\x06') goto LAB_0;

+        if (local_res8[0] == '/') {

+          uVar5 = 0xff;

+        }

+        local_70 = uVar5;

+        if (local_res8[0] != -0x2b) goto LAB_0;

+        bVar1 = true;

+      }

+      if (local_res10[0] == '\x01') {

+        HalpApicDirectedEndOfInterruptModeEnabled = 1;

+        local_b8 = HalpApicDirectedEndOfInterrupt;

+        uVar4 = uVar4 | 0x400;

+      }

+    }

+  }

+LAB_0:

+  local_6c = 0x60;

+  local_160 = HalpApicInitializeLocalUnit;

+  local_d8 = HalpApicDeinitializeLocalUnit;

+  local_158 = HalpApicInitializeIoUnit;

+  local_150 = HalpApicSetPriority;

+  local_148 = HalpApicGetLocalUnitError;

+  local_140 = HalpApicClearLocalUnitError;

+  local_120 = HalpApicWriteEndOfInterrupt;

+  local_118 = HalpApicEndOfInterrupt;

+  local_110 = HalpApicSetLineState;

+  local_108 = HalpApicRequestInterrupt;

+  local_100 = HalpApicStartProcessor;

+  local_f8 = HalpApicGenerateMessage;

+  local_e8 = HalpApicSaveLocalInterrupts;

+  local_e0 = HalpApicReplayLocalInterrupts;

+  if (bVar1) {

+    local_118 = 0;

+    local_120 = HalpApicEndOfInterruptReadIoApicIndex;

+  }

+  local_78 = 0xf;

+  local_7c = uVar4 | 0xfb;

+  local_c8 = HalpApicQueryAndGetSource;

+  uStack_60 = CONCAT44(uStack_60._4_4_,param_2);

+  uStack_50 = CONCAT44(param_3,(undefined4)uStack_50);

+  local_68 = param_1;

+  iVar3 = HalRegisterPermanentAddressUsage(param_1,0x400);

+  if (-1 < iVar3) {

+    HalpInterruptRegisterController(&local_168);

+  }

+  return;

 }
```

## `AslpFileVerStringBlockGetValue`  (modified)

```diff
--- AslpFileVerStringBlockGetValue
+++ AslpFileVerStringBlockGetValue
@@ -1,17 +1,51 @@
 

-undefined4 AslpFileVerStringBlockGetValue(void)

+ulonglong AslpFileVerStringBlockGetValue

+                    (longlong *param_1,ulonglong *param_2,longlong param_3,ulonglong param_4)

 

 {

-  int *in_RAX;

-  undefined4 unaff_EBX;

-  longlong unaff_RSI;

+  int iVar1;

+  ulonglong uVar2;

+  ulonglong uVar3;

+  short *psVar4;

+  ulonglong uVar5;

+  ulonglong local_res8;

+  ulonglong local_res10;

   

-  *in_RAX = *in_RAX + (int)in_RAX;

-  *(char *)in_RAX = (char)*in_RAX + (char)in_RAX;

-  AslLogCallPrintf();

-  if (unaff_RSI != 0) {

-    AslFree();

+  uVar3 = 0;

+  *param_1 = 0;

+  *param_2 = 0;

+  local_res8 = 0;

+  local_res10 = 0;

+  uVar5 = param_4;

+  uVar2 = AslpFileVerBlockGetValueOffset(&local_res8,param_3);

+  if ((int)uVar2 < 0) {

+    return uVar2;

   }

-  return unaff_EBX;

+  if (uVar5 < local_res8) {

+LAB_0:

+    uVar3 = 0xc000000d;

+  }

+  else {

+    if (local_res8 == uVar5) {

+      psVar4 = (short *)((local_res8 - 2) + param_3);

+      iVar1 = Feature_261863737__private_IsEnabledDeviceUsageNoInline();

+      local_res10 = uVar3;

+      if ((iVar1 != 0) && (local_res10 = 0, *psVar4 != 0)) goto LAB_0;

+    }

+    else {

+      psVar4 = (short *)(local_res8 + param_3);

+      param_4 = param_4 - local_res8;

+      iVar1 = RtlStringCbLengthW(psVar4,param_4,&local_res10);

+      if (iVar1 < 0) {

+        iVar1 = Feature_261863737__private_IsEnabledDeviceUsageNoInline();

+        if ((iVar1 != 0) && (param_4 < 2)) goto LAB_0;

+        local_res10 = param_4 - 2;

+        *(undefined2 *)((longlong)psVar4 + (local_res10 & 0xfffffffffffffffe)) = 0;

+      }

+    }

+    *param_2 = local_res10 >> 1;

+    *param_1 = (longlong)psVar4;

+  }

+  return uVar3;

 }
```

## `KiDecodeTolerableDelayValue`  (modified)

```diff
--- KiDecodeTolerableDelayValue
+++ KiDecodeTolerableDelayValue
@@ -1,13 +1,18 @@
 

-byte KiDecodeTolerableDelayValue(void)

+int KiDecodeTolerableDelayValue(byte param_1)

 

 {

-  byte *pbVar1;

-  byte in_AL;

-  undefined7 in_register_00000001;

+  byte bVar1;

+  sbyte sVar2;

+  byte bVar3;

   

-  pbVar1 = (byte *)(CONCAT71(in_register_00000001,in_AL) + -0x75);

-  *pbVar1 = *pbVar1 >> 4 | *pbVar1 << 4;

-  return in_AL & 0x58;

+  bVar3 = param_1 >> 3 & 7;

+  bVar1 = param_1 >> 3 & 7;

+  sVar2 = bVar1 + 2;

+  if (bVar3 == 0) {

+    sVar2 = bVar1 + 3;

+  }

+  return (uint)((ushort)((-(ushort)(bVar3 != 0) & 8 | (ushort)(param_1 & 7)) << sVar2) >> 3) * 10000

+  ;

 }
```

## `KiMayStealStandbyThread`  (modified)

```diff
--- KiMayStealStandbyThread
+++ KiMayStealStandbyThread
@@ -1,43 +1,50 @@
 

-/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

-

-void KiMayStealStandbyThread(char param_1)

+bool KiMayStealStandbyThread(longlong param_1,longlong param_2,ulonglong param_3)

 

 {

-  undefined8 uVar1;

-  char cVar2;

-  undefined4 uVar3;

-  undefined *puVar4;

-  longlong unaff_RBP;

+  longlong lVar1;

+  undefined1 auVar2 [16];

+  undefined1 auVar3 [16];

+  byte bVar4;

+  byte bVar5;

+  ulonglong uVar6;

   

-  *(ulonglong *)(unaff_RBP + 0x47) =

-       (ulonglong)(uint)__security_cookie ^ (ulonglong)&stack0x00000000;

-  puVar4 = &PPM_ETW_INTERRUPT_STEERING_MASK_CHANGE;

-  if (param_1 != '\0') {

-    puVar4 = &KMPnPRundownEvt_SleepStudy_ConnectionResource;

+  lVar1 = *(longlong *)(param_1 + 0x10);

+  if ((((lVar1 != 0) && (lVar1 != *(longlong *)(param_1 + 0x18))) &&

+      (lVar1 != *(longlong *)(param_1 + 0x3838))) && (lVar1 != *(longlong *)(param_1 + 0x8e80))) {

+    if (0xf < (**(byte **)(param_1 + 0x38) & 0x7f)) {

+LAB_0:

+      if ((param_2 != 0) && (KeHeteroSystem != 0)) {

+        bVar4 = *(byte *)(*(longlong *)(param_1 + 0x38) + 0x40);

+        bVar4 = KiGetProcessorClassForPolicy

+                          (param_1,(&KiDynamicHeteroCpuPolicy)

+                                   [(ulonglong)(bVar4 >> 6 & 1) + (ulonglong)(bVar4 & 7) * 2],

+                           bVar4 >> 3 & 7);

+        bVar5 = KiGetProcessorClassForPolicy(param_2);

+        return bVar4 <= bVar5;

+      }

+      return true;

+    }

+    if (((KiVelocityFlags & 0x1000000) != 0) && (*(char *)(param_1 + 7) != '\0')) {

+      if ((param_3 & 1) == 0) goto LAB_0;

+      if ((*(longlong *)(param_1 + 0x8840) != 0) &&

+         (*(int *)(*(longlong *)(param_1 + 0x8840) + 0x28) != 0)) {

+        uVar6 = (ulonglong)

+                *(uint *)((ulonglong)*(uint *)(param_1 + 0x8880) * 0x158 + 0x538 +

+                         *(longlong *)(param_1 + 0x8840));

+        if (*(byte *)(param_1 + 0xac) != 0) {

+          uVar6 = uVar6 << (*(byte *)(param_1 + 0xac) & 0x3f);

+        }

+        auVar2._8_8_ = 0;

+        auVar2._0_8_ = *(ulonglong *)(param_1 + 0xb0);

+        auVar3._8_8_ = 0;

+        auVar3._0_8_ = uVar6;

+        uVar6 = SUB168(auVar2 * auVar3,8) * 4;

+        if (*(uint *)(lVar1 + 0x54) <= uVar6 && uVar6 - *(uint *)(lVar1 + 0x54) != 0)

+        goto LAB_0;

+      }

+    }

   }

-  cVar2 = KiIntSteerEtwEventEnabled(puVar4);

-  if (cVar2 != '\0') {

-    *(undefined4 *)(unaff_RBP + 3) = 0;

-    *(undefined4 *)(unaff_RBP + 0x13) = 0;

-    *(undefined4 **)(unaff_RBP + -9) = &KiIntSteerLoadPercent;

-    *(undefined4 *)(unaff_RBP + -1) = 4;

-    *(undefined4 **)(unaff_RBP + 7) = &KiIntTrackRootCount;

-    *(undefined4 *)(unaff_RBP + 0xf) = 4;

-    uVar3 = KeCountSetBitsAffinityEx(&KiIntSteerMask);

-    *(undefined4 *)(unaff_RBP + 0x23) = 0;

-    *(undefined4 *)(unaff_RBP + 0x33) = 0;

-    *(undefined4 *)(unaff_RBP + 0x43) = 0;

-    uVar1 = KiIntSteerEtwHandle;

-    *(undefined4 *)(unaff_RBP + -0x19) = uVar3;

-    *(longlong *)(unaff_RBP + 0x17) = unaff_RBP + -0x19;

-    *(undefined **)(unaff_RBP + 0x37) = &DAT_0;

-    *(uint *)(unaff_RBP + 0x3f) = (uint)KiIntSteerMask << 3;

-    *(undefined4 *)(unaff_RBP + 0x1f) = 4;

-    *(ushort **)(unaff_RBP + 0x27) = &KiIntSteerMask;

-    *(undefined4 *)(unaff_RBP + 0x2f) = 2;

-    EtwWriteEx(uVar1,puVar4,0,0,0);

-  }

-  return;

+  return false;

 }
```

## `ApiSetpFindHashInsertionPoint_V7`  (modified)

```diff
--- ApiSetpFindHashInsertionPoint_V7
+++ ApiSetpFindHashInsertionPoint_V7
@@ -1,114 +1,91 @@
 

-/* WARNING: Instruction at (ram,0x000140662055) overlaps instruction at (ram,0x000140662054)

-    */

-

-uint ApiSetpFindHashInsertionPoint_V7(longlong param_1,undefined8 param_2,undefined8 param_3)

+undefined8

+ApiSetpFindHashInsertionPoint_V7

+          (longlong param_1,int *param_2,uint param_3,short *param_4,short *param_5,short *param_6)

 

 {

-  char *pcVar1;

-  byte bVar2;

+  ushort uVar1;

+  int iVar2;

   uint uVar3;

-  char cVar4;

-  ushort uVar5;

-  int in_EAX;

-  ulonglong uVar6;

-  longlong lVar7;

-  longlong unaff_RBX;

-  longlong unaff_RBP;

-  longlong unaff_RSI;

-  uint unaff_EDI;

-  longlong unaff_R12;

-  undefined2 uVar8;

-  uint unaff_R13D;

-  uint uVar9;

-  ulonglong unaff_R14;

-  longlong unaff_R15;

+  uint uVar4;

+  int iVar5;

+  uint uVar6;

+  ulonglong uVar7;

+  ulonglong uVar8;

+  longlong lVar9;

   

-  do {

-    pcVar1 = (char *)(unaff_RBX + -0x11 + param_1 * 4);

-    *pcVar1 = *pcVar1 + (char)in_EAX;

-    if (unaff_EDI < *(uint *)(unaff_R12 + 0x14 + unaff_R15 * 8)) {

-      do {

-        uVar6 = (ulonglong)unaff_R13D;

-        *(undefined8 *)(unaff_RBP + -0x10) = 0;

-        *(undefined8 *)(unaff_RBP + -0x30) = 0;

-        *(undefined8 *)(unaff_RBP + -0x28) = 0;

-        lVar7 = (ulonglong)*(uint *)(unaff_R12 + 0x10 + unaff_R15 * 8) + unaff_RSI;

-        *(ulonglong *)(unaff_RBP + 0x50) = uVar6 * 5;

-        *(longlong *)(unaff_RBP + 0x58) = lVar7;

-        *(undefined8 *)(unaff_RBP + -0x20) = 0;

-        *(undefined8 *)(unaff_RBP + -0x18) = 0;

-        cVar4 = ApiSetpGetContractKeyInfo

-                          ((ulonglong)*(uint *)(lVar7 + 0xc + uVar6 * 0x14) + unaff_RSI,

-                           *(uint *)(lVar7 + 0x10 + uVar6 * 0x14) >> 1,param_3,unaff_RBP + -0x30);

-        if (cVar4 == '\0') {

-          return 0xc0000033;

+  uVar1 = *(ushort *)(param_2 + 1);

+  *param_4 = 0;

+  *param_5 = 0;

+  *param_6 = 0;

+  if (uVar1 == 0) {

+    return 0;

+  }

+  uVar4 = (uint)uVar1;

+  iVar5 = 0;

+  iVar2 = uVar4 - 1;

+  if (iVar2 < 0) {

+    return 0xc00000e5;

+  }

+  uVar8 = (ulonglong)*(ushort *)(param_1 + 0x12);

+  uVar7 = (ulonglong)(*(byte *)(param_2 + 2) * uVar4 + *param_2);

+  while( true ) {

+    uVar3 = iVar5 + iVar2 >> 1;

+    lVar9 = ((longlong)(int)uVar3 * 8 - uVar8) + uVar7;

+    uVar6 = *(uint *)(lVar9 + param_1);

+    if (param_3 == uVar6) break;

+    if (iVar5 == iVar2) goto LAB_0;

+    if (param_3 < uVar6) {

+      iVar2 = uVar3 - 1;

+    }

+    else if (uVar6 < param_3) {

+      iVar5 = uVar3 + 1;

+    }

+    if (iVar2 < iVar5) {

+LAB_0:

+      if ((int)uVar3 < iVar5) {

+        if (*(uint *)(lVar9 + 8 + param_1) <= param_3) {

+          return 0xc00000e5;

         }

-        uVar5 = ApiSetpSearchForSectionIndex_V7

-                          (*(longlong *)(unaff_RBP + 0x40),*(longlong *)(unaff_RBP + 0x40) + 0x44,

-                           unaff_RBP + -0x30,0);

-        if (uVar5 == 0xffff) {

-          *(int *)(unaff_RBX + 0xc0) = *(int *)(unaff_RBX + 0xc0) + 0x14;

-          *(short *)(unaff_RBX + 0xbc) = *(short *)(unaff_RBX + 0xbc) + 1;

-          *(short *)(unaff_RBX + 0xa4) = *(short *)(unaff_RBX + 0xa4) + 1;

-          *(int *)(unaff_RBX + 0xa8) = *(int *)(unaff_RBX + 0xa8) + 0x14;

-LAB_0:

-          if (*(uint *)(*(longlong *)(unaff_RBP + 0x58) + 4 + *(longlong *)(unaff_RBP + 0x50) * 4)

-              != unaff_EDI) {

-            *(short *)(unaff_RBX + 0xe0) = *(short *)(unaff_RBX + 0xe0) + 1;

-            *(int *)(unaff_RBX + 0xe4) = *(int *)(unaff_RBX + 0xe4) + 0x10;

-          }

+        uVar3 = (uint)(ushort)((short)uVar3 + 1);

+      }

+      else if (iVar2 < (int)uVar3) {

+        if (uVar6 <= param_3) {

+          return 0xc00000e5;

         }

-        else {

-          lVar7 = *(longlong *)(unaff_RBP + 0x40);

-          if ((*(byte *)((ulonglong)*(uint *)(lVar7 + 0x44) + 10 +

-                        lVar7 + ((ulonglong)*(byte *)(lVar7 + 0x4c) * (ulonglong)uVar5 -

-                                (ulonglong)*(ushort *)(lVar7 + 0x12))) & 1) == 0)

-          goto LAB_0;

+      }

+      else {

+        if (iVar5 != iVar2) {

+          return 0xc00000e5;

         }

-        param_3 = 1;

-        unaff_R13D = unaff_R13D + 1;

-      } while (unaff_R13D < *(uint *)(unaff_R12 + 0x14 + unaff_R15 * 8));

+        if (uVar6 <= param_3) {

+          uVar3 = uVar3 + 1 & 0xffff;

+        }

+      }

+      *param_4 = (short)uVar3;

+      return 0;

     }

-    while( true ) {

-      uVar9 = (int)unaff_R14 + (int)param_3;

-      unaff_R14 = (ulonglong)uVar9;

-      if (*(uint *)(unaff_RSI + 0xc) <= uVar9) {

-        return unaff_EDI;

-      }

-      unaff_R12 = (ulonglong)*(uint *)(unaff_RSI + 0x10) + unaff_RSI;

-      unaff_R15 = unaff_R14 * 3;

-      if ((*(uint *)(unaff_R12 + unaff_R14 * 0x18) & 4) == 0) break;

-      *(short *)(unaff_RBX + 0xd4) = *(short *)(unaff_RBX + 0xd4) + (short)param_3;

-      *(int *)(unaff_RBX + 0xd8) = *(int *)(unaff_RBX + 0xd8) + 0xc;

-    }

-    uVar9 = *(uint *)(unaff_R12 + 8 + unaff_R14 * 0x18);

-    *(undefined8 *)(unaff_RBP + -0x10) = 0;

-    uVar3 = *(uint *)(unaff_R12 + 4 + unaff_R14 * 0x18);

-    *(undefined8 *)(unaff_RBP + -0x30) = 0;

-    *(undefined8 *)(unaff_RBP + -0x28) = 0;

-    uVar9 = uVar9 >> 1;

-    *(ulonglong *)(unaff_RBP + -0x30) = (ulonglong)uVar3 + unaff_RSI;

-    lVar7 = *(longlong *)(unaff_RBX + 8);

-    *(byte *)(unaff_RBP + -0x26) = (byte)param_3;

-    *(undefined8 *)(unaff_RBP + -0x20) = 0;

-    *(undefined8 *)(unaff_RBP + -0x18) = 0;

-    uVar8 = (undefined2)uVar9;

-    *(undefined2 *)(unaff_RBP + -0x28) = uVar8;

-    bVar2 = *(byte *)(lVar7 + 0x65);

-    *(undefined2 *)(unaff_RBP + -0x1e) = uVar8;

-    *(longlong *)(unaff_RBP + 0x40) = lVar7;

-    in_EAX = ApiSetpSearchForSectionIndex_V7

-                       (lVar7,lVar7 + 0x5c,unaff_RBP + -0x30,bVar2 >> 1 & (byte)param_3);

-    param_1 = 0xffff;

-    param_3 = 1;

-    unaff_R13D = unaff_EDI;

-    if ((short)in_EAX == -1) {

-      *(short *)(unaff_RBX + 200) = *(short *)(unaff_RBX + 200) + 1;

-      *(int *)(unaff_RBX + 0xcc) = *(int *)(unaff_RBX + 0xcc) + 0x14;

-      in_EAX = (uVar9 & 0xffff) * 2;

-      *(int *)(unaff_RBX + 0xe8) = *(int *)(unaff_RBX + 0xe8) + in_EAX;

-    }

-  } while( true );

+  }

+  iVar2 = uVar3 + 1;

+  uVar6 = uVar3;

+  while ((iVar2 < (int)uVar4 &&

+         (*(uint *)((((longlong)(int)uVar6 * 8 + 8) - uVar8) + uVar7 + param_1) == param_3))) {

+    iVar2 = uVar6 + 2;

+    uVar6 = uVar6 + 1;

+  }

+  uVar4 = uVar3;

+  if (0 < (int)uVar3) {

+    do {

+      uVar4 = uVar3;

+      if (*(uint *)(((longlong)(int)uVar3 * 8 - uVar8) + uVar7 + -8 + param_1) != param_3) break;

+      uVar4 = uVar3 - 1;

+      iVar2 = uVar3 - 2;

+      uVar3 = uVar4;

+    } while (-1 < iVar2);

+  }

+  *param_5 = (short)uVar4;

+  *param_4 = (short)uVar6 + 1;

+  *param_6 = ((short)uVar6 - (short)uVar4) + 1;

+  return 0;

 }
```

## `ApiSetpSearchForHostOverrideIndex_V7`  (modified)

```diff
--- ApiSetpSearchForHostOverrideIndex_V7
+++ ApiSetpFindHashInsertionPoint_V7
@@ -1,35 +1,114 @@
 

-ulonglong ApiSetpSearchForHostOverrideIndex_V7

-                    (longlong param_1,uint param_2,uint param_3,undefined8 param_4,

-                    undefined2 param_5)

+/* WARNING: Instruction at (ram,0x000140662055) overlaps instruction at (ram,0x000140662054)

+    */

+

+uint ApiSetpFindHashInsertionPoint_V7(longlong param_1,undefined8 param_2,undefined8 param_3)

 

 {

-  int iVar1;

-  ulonglong uVar2;

-  longlong lVar3;

-  uint uVar4;

+  char *pcVar1;

+  byte bVar2;

+  uint uVar3;

+  char cVar4;

+  ushort uVar5;

+  int in_EAX;

+  ulonglong uVar6;

+  longlong lVar7;

+  longlong unaff_RBX;

+  longlong unaff_RBP;

+  longlong unaff_RSI;

+  uint unaff_EDI;

+  longlong unaff_R12;

+  undefined2 uVar8;

+  uint unaff_R13D;

+  uint uVar9;

+  ulonglong unaff_R14;

+  longlong unaff_R15;

   

-  uVar2 = (ulonglong)param_2;

-  if ((param_3 != 0) && (uVar4 = 0, param_3 != 0)) {

-    do {

-      if ((uint)*(ushort *)(param_1 + 0x70) <= (uint)uVar2) {

-        return 0xffff;

+  do {

+    pcVar1 = (char *)(unaff_RBX + -0x11 + param_1 * 4);

+    *pcVar1 = *pcVar1 + (char)in_EAX;

+    if (unaff_EDI < *(uint *)(unaff_R12 + 0x14 + unaff_R15 * 8)) {

+      do {

+        uVar6 = (ulonglong)unaff_R13D;

+        *(undefined8 *)(unaff_RBP + -0x10) = 0;

+        *(undefined8 *)(unaff_RBP + -0x30) = 0;

+        *(undefined8 *)(unaff_RBP + -0x28) = 0;

+        lVar7 = (ulonglong)*(uint *)(unaff_R12 + 0x10 + unaff_R15 * 8) + unaff_RSI;

+        *(ulonglong *)(unaff_RBP + 0x50) = uVar6 * 5;

+        *(longlong *)(unaff_RBP + 0x58) = lVar7;

+        *(undefined8 *)(unaff_RBP + -0x20) = 0;

+        *(undefined8 *)(unaff_RBP + -0x18) = 0;

+        cVar4 = ApiSetpGetContractKeyInfo

+                          ((ulonglong)*(uint *)(lVar7 + 0xc + uVar6 * 0x14) + unaff_RSI,

+                           *(uint *)(lVar7 + 0x10 + uVar6 * 0x14) >> 1,param_3,unaff_RBP + -0x30);

+        if (cVar4 == '\0') {

+          return 0xc0000033;

+        }

+        uVar5 = ApiSetpSearchForSectionIndex_V7

+                          (*(longlong *)(unaff_RBP + 0x40),*(longlong *)(unaff_RBP + 0x40) + 0x44,

+                           unaff_RBP + -0x30,0);

+        if (uVar5 == 0xffff) {

+          *(int *)(unaff_RBX + 0xc0) = *(int *)(unaff_RBX + 0xc0) + 0x14;

+          *(short *)(unaff_RBX + 0xbc) = *(short *)(unaff_RBX + 0xbc) + 1;

+          *(short *)(unaff_RBX + 0xa4) = *(short *)(unaff_RBX + 0xa4) + 1;

+          *(int *)(unaff_RBX + 0xa8) = *(int *)(unaff_RBX + 0xa8) + 0x14;

+LAB_0:

+          if (*(uint *)(*(longlong *)(unaff_RBP + 0x58) + 4 + *(longlong *)(unaff_RBP + 0x50) * 4)

+              != unaff_EDI) {

+            *(short *)(unaff_RBX + 0xe0) = *(short *)(unaff_RBX + 0xe0) + 1;

+            *(int *)(unaff_RBX + 0xe4) = *(int *)(unaff_RBX + 0xe4) + 0x10;

+          }

+        }

+        else {

+          lVar7 = *(longlong *)(unaff_RBP + 0x40);

+          if ((*(byte *)((ulonglong)*(uint *)(lVar7 + 0x44) + 10 +

+                        lVar7 + ((ulonglong)*(byte *)(lVar7 + 0x4c) * (ulonglong)uVar5 -

+                                (ulonglong)*(ushort *)(lVar7 + 0x12))) & 1) == 0)

+          goto LAB_0;

+        }

+        param_3 = 1;

+        unaff_R13D = unaff_R13D + 1;

+      } while (unaff_R13D < *(uint *)(unaff_R12 + 0x14 + unaff_R15 * 8));

+    }

+    while( true ) {

+      uVar9 = (int)unaff_R14 + (int)param_3;

+      unaff_R14 = (ulonglong)uVar9;

+      if (*(uint *)(unaff_RSI + 0xc) <= uVar9) {

+        return unaff_EDI;

       }

-      lVar3 = (*(ushort *)(param_1 + 0x72) * uVar2 + (ulonglong)*(uint *)(param_1 + 0x68)) -

-              (ulonglong)*(ushort *)(param_1 + 0x12);

-      iVar1 = RtlCompareUnicodeStrings

-                        (param_4,param_5,

-                         (((ulonglong)*(uint *)(param_1 + 0x24) +

-                          (ulonglong)*(uint *)(lVar3 + 4 + param_1)) -

-                         (ulonglong)*(ushort *)(param_1 + 0x12)) + param_1,

-                         *(undefined2 *)(lVar3 + 0xc + param_1),1);

-      if (iVar1 == 0) {

-        return uVar2;

-      }

-      uVar2 = (ulonglong)*(ushort *)(lVar3 + param_1);

-      uVar4 = uVar4 + 1;

-    } while (uVar4 < param_3);

-  }

-  return 0xffff;

+      unaff_R12 = (ulonglong)*(uint *)(unaff_RSI + 0x10) + unaff_RSI;

+      unaff_R15 = unaff_R14 * 3;

+      if ((*(uint *)(unaff_R12 + unaff_R14 * 0x18) & 4) == 0) break;

+      *(short *)(unaff_RBX + 0xd4) = *(short *)(unaff_RBX + 0xd4) + (short)param_3;

+      *(int *)(unaff_RBX + 0xd8) = *(int *)(unaff_RBX + 0xd8) + 0xc;

+    }

+    uVar9 = *(uint *)(unaff_R12 + 8 + unaff_R14 * 0x18);

+    *(undefined8 *)(unaff_RBP + -0x10) = 0;

+    uVar3 = *(uint *)(unaff_R12 + 4 + unaff_R14 * 0x18);

+    *(undefined8 *)(unaff_RBP + -0x30) = 0;

+    *(undefined8 *)(unaff_RBP + -0x28) = 0;

+    uVar9 = uVar9 >> 1;

+    *(ulonglong *)(unaff_RBP + -0x30) = (ulonglong)uVar3 + unaff_RSI;

+    lVar7 = *(longlong *)(unaff_RBX + 8);

+    *(byte *)(unaff_RBP + -0x26) = (byte)param_3;

+    *(undefined8 *)(unaff_RBP + -0x20) = 0;

+    *(undefined8 *)(unaff_RBP + -0x18) = 0;

+    uVar8 = (undefined2)uVar9;

+    *(undefined2 *)(unaff_RBP + -0x28) = uVar8;

+    bVar2 = *(byte *)(lVar7 + 0x65);

+    *(undefined2 *)(unaff_RBP + -0x1e) = uVar8;

+    *(longlong *)(unaff_RBP + 0x40) = lVar7;

+    in_EAX = ApiSetpSearchForSectionIndex_V7

+                       (lVar7,lVar7 + 0x5c,unaff_RBP + -0x30,bVar2 >> 1 & (byte)param_3);

+    param_1 = 0xffff;

+    param_3 = 1;

+    unaff_R13D = unaff_EDI;

+    if ((short)in_EAX == -1) {

+      *(short *)(unaff_RBX + 200) = *(short *)(unaff_RBX + 200) + 1;

+      *(int *)(unaff_RBX + 0xcc) = *(int *)(unaff_RBX + 0xcc) + 0x14;

+      in_EAX = (uVar9 & 0xffff) * 2;

+      *(int *)(unaff_RBX + 0xe8) = *(int *)(unaff_RBX + 0xe8) + in_EAX;

+    }

+  } while( true );

 }
```

## `ApiSetpSearchForSectionIndex_V7`  (modified)

```diff
--- ApiSetpSearchForSectionIndex_V7
+++ ApiSetpInsertHashEntry
@@ -1,55 +1,10 @@
 

-undefined2

-ApiSetpSearchForSectionIndex_V7

-          (longlong param_1,longlong param_2,undefined8 param_3,undefined1 param_4)

+/* WARNING: Control flow encountered bad instruction data */

+

+void ApiSetpInsertHashEntry(void)

 

 {

-  byte bVar1;

-  byte bVar2;

-  char cVar3;

-  uint uVar4;

-  uint uVar5;

-  ulonglong uVar6;

-  undefined7 uVar7;

-  char cVar8;

-  ulonglong uVar9;

-  undefined7 uVar10;

-  byte bVar11;

-  undefined2 local_res10 [4];

-  

-  uVar9 = CONCAT71((int7)((ulonglong)param_3 >> 8),*(byte *)(param_1 + 2)) & 0xffffffffffffff10;

-  bVar1 = *(byte *)(param_1 + 2) & 8;

-  uVar6 = CONCAT71((int7)((ulonglong)param_2 >> 8),*(byte *)(param_2 + 9)) & 0xffffffffffffff02;

-  bVar11 = *(byte *)(param_2 + 9) & 4;

-  uVar10 = (undefined7)(uVar9 >> 8);

-  uVar7 = (undefined7)(uVar6 >> 8);

-  cVar8 = (char)uVar9;

-  cVar3 = (char)uVar6;

-  if (bVar11 == 0) {

-    uVar4 = ApiSetpGetSearchKeyHash

-                      (param_3,CONCAT71(uVar7,cVar3 != '\0'),CONCAT71(uVar10,bVar1 != 0),

-                       cVar8 != '\0',*(undefined1 *)(param_2 + 10));

-  }

-  else {

-    bVar2 = ApiSetpGetSearchKeyHash

-                      (param_3,CONCAT71(uVar7,cVar3 != '\0'),CONCAT71(uVar10,bVar1 != 0),

-                       cVar8 != '\0',*(undefined1 *)(param_2 + 10));

-    uVar4 = (uint)bVar2;

-  }

-  if (bVar11 == 0) {

-    uVar5 = ApiSetpGetSearchKeyHash

-                      (param_3,param_4,bVar1 != 0,cVar8 != '\0',*(undefined1 *)(param_2 + 0xb));

-  }

-  else {

-    bVar1 = ApiSetpGetSearchKeyHash

-                      (param_3,param_4,bVar1 != 0,cVar8 != '\0',*(undefined1 *)(param_2 + 0xb));

-    uVar5 = (uint)bVar1;

-  }

-  local_res10[0] = 0;

-  cVar3 = ApiSetpFindHashtableIndexAndVerify_V7(param_1,param_2,uVar4,uVar5,local_res10);

-  if (cVar3 == '\0') {

-    local_res10[0] = 0xffff;

-  }

-  return local_res10[0];

+                    /* WARNING: Bad instruction - Truncating control flow here */

+  halt_baddata();

 }
```

## `PopNetResiliencyStateChanged`  (modified)

```diff
--- PopNetResiliencyStateChanged
+++ PopNetResiliencyStateChanged
@@ -1,81 +1,10 @@
 

-ulonglong PopNetResiliencyStateChanged(void)

+void PopNetResiliencyStateChanged(undefined1 param_1)

 

 {

-  char *in_RAX;

-  ulonglong uVar1;

-  ulonglong *puVar2;

-  ulonglong *unaff_RDI;

-  ulonglong *in_R10;

-  ulonglong *puVar3;

-  longlong in_R11;

-  ulonglong uStack0000000000000040;

-  longlong in_stack_00000050;

-  undefined4 uStack0000000000000060;

-  undefined4 uStack0000000000000064;

-  undefined4 uStack0000000000000068;

-  undefined4 uStack000000000000006c;

-  undefined4 uStack0000000000000070;

-  undefined4 uStack0000000000000074;

-  char in_stack_000001a8;

-  

-  *in_RAX = *in_RAX + (char)in_RAX;

-code_r0x000140ac71b4:

-  uVar1 = -1L << ((byte)*(uint *)(in_R11 + 0x44) & 0x1f) & in_R10[1];

-  uStack0000000000000040._1_1_ = (byte)(uVar1 >> 8);

-  uStack0000000000000040._2_1_ = (byte)(uVar1 >> 0x10);

-  uStack0000000000000040._3_1_ = (byte)(uVar1 >> 0x18);

-  uStack0000000000000040._4_1_ = (byte)(uVar1 >> 0x20);

-  uStack0000000000000040._5_1_ = (byte)(uVar1 >> 0x28);

-  uStack0000000000000040._6_1_ = (byte)(uVar1 >> 0x30);

-  uStack0000000000000040._7_1_ = (byte)(uVar1 >> 0x38);

-  puVar2 = (ulonglong *)

-           (*(longlong *)(in_R11 + 0x48) +

-           (ulonglong)

-           ((*(uint *)(in_R11 + 0x44) >> 5) - 1 &

-           (uint)uStack0000000000000040._7_1_ +

-           (((((((((uint)uVar1 & 0xff) + 0xb15dcb) * 0x25 + (uint)uStack0000000000000040._1_1_) *

-                0x25 + (uint)uStack0000000000000040._2_1_) * 0x25 +

-              (uint)uStack0000000000000040._3_1_) * 0x25 + (uint)uStack0000000000000040._4_1_) *

-             0x25 + (uint)uStack0000000000000040._5_1_) * 0x25 + (uint)uStack0000000000000040._6_1_)

-           * 0x25) * 8);

-  puVar3 = in_R10;

-  do {

-    if (((puVar3 == (ulonglong *)0x0) || (puVar3 == (ulonglong *)0x0)) ||

-       (in_R10 = (ulonglong *)*puVar3, (*puVar3 & 1) != 0)) {

-      do {

-        puVar2 = puVar2 + 1;

-        in_R10 = unaff_RDI;

-        if ((ulonglong *)

-            (*(longlong *)(in_R11 + 0x48) + (ulonglong)(*(uint *)(in_R11 + 0x44) >> 5) * 8) <=

-            puVar2) break;

-        in_R10 = (ulonglong *)*puVar2;

-      } while ((*puVar2 & 1) != 0);

-    }

-    if (in_R10 == (ulonglong *)0x0) {

-      uStack0000000000000040 = uVar1;

-      PopEtEnergyTrackerCleanupAggregates(in_stack_00000050);

-      *(int *)(in_stack_00000050 + 0x260) = *(int *)(in_stack_00000050 + 0x260) + 1;

-      *(undefined4 *)(in_stack_00000050 + 600) = uStack0000000000000060;

-      *(undefined4 *)(in_stack_00000050 + 0x25c) = uStack0000000000000064;

-      *(undefined8 *)(in_stack_00000050 + 0x264) = 0;

-      *(undefined8 *)(in_stack_00000050 + 0x26c) = 0;

-      *(undefined4 *)(in_stack_00000050 + 0x274) = uStack0000000000000068;

-      *(undefined4 *)(in_stack_00000050 + 0x278) = uStack000000000000006c;

-      *(undefined4 *)(in_stack_00000050 + 0x27c) = uStack0000000000000070;

-      *(undefined4 *)(in_stack_00000050 + 0x280) = uStack0000000000000074;

-      if (in_stack_000001a8 != '\0') {

-        PopReleaseRwLock(in_stack_00000050 + 0x10);

-      }

-      if (in_stack_00000050 != 0) {

-        ObfDereferenceObjectWithTag(in_stack_00000050,0x74456f50);

-      }

-      return (ulonglong)unaff_RDI & 0xffffffff;

-    }

-    *(uint *)((longlong)in_R10 + 0x1ecU) = *(uint *)((longlong)in_R10 + 0x1ecU) & 0x7fffffff;

-    if (in_R10 != (ulonglong *)0x0) goto code_r0x000140ac71b4;

-    puVar2 = *(ulonglong **)(in_R11 + 0x48);

-    puVar3 = puVar2;

-  } while( true );

+  PopAcquirePolicyLock();

+  PopNetUpdateDsAccounting(param_1);

+  PopReleasePolicyLock();

+  return;

 }
```

## `ApiSetpIsFeatureEnabled`  (modified)

```diff
--- ApiSetpIsFeatureEnabled
+++ ApiSetSchemaExpander_InsertContractEntry
@@ -1,17 +1,58 @@
 

-bool ApiSetpIsFeatureEnabled(int param_1)

+undefined8

+ApiSetSchemaExpander_InsertContractEntry

+          (longlong *param_1,undefined8 param_2,undefined8 param_3,char *param_4)

 

 {

   char cVar1;

+  longlong in_RAX;

   int iVar2;

+  char unaff_SIL;

+  char cVar3;

+  char *pcVar4;

+  longlong lVar5;

+  char *in_R11;

   

-  if (param_1 == 0x3a132a5) {

-    iVar2 = Feature_DriverSetup_ReofferFingerprinting_v2__private_IsEnabledDeviceUsageNoInline();

-    cVar1 = (iVar2 != 0) + '\x01';

+  cVar3 = '\0';

+  iVar2 = (uint)*(ushort *)(param_1 + 1) - (int)in_RAX;

+  if (0 < iVar2) {

+    lVar5 = in_RAX * 2;

+    if (*(char *)((longlong)param_1 + 10) == '\0') {

+      lVar5 = in_RAX;

+    }

+    pcVar4 = (char *)(lVar5 + *param_1);

+    if (*pcVar4 == '-') {

+      lVar5 = (ulonglong)(*(char *)((longlong)param_1 + 10) != '\0') + 1;

+      iVar2 = iVar2 + -1;

+      if (iVar2 != 0) {

+        while ((pcVar4 = pcVar4 + lVar5, 0 < iVar2 && (cVar1 = *pcVar4, cVar1 != '-'))) {

+          if (9 < (byte)(cVar1 - 0x30U)) {

+            return 0;

+          }

+          iVar2 = iVar2 + -1;

+          unaff_SIL = cVar1 + (unaff_SIL * '\x05' + -0x18) * '\x02';

+        }

+        iVar2 = iVar2 + -1;

+        if (iVar2 != 0) {

+          while( true ) {

+            pcVar4 = pcVar4 + lVar5;

+            if (iVar2 < 1) {

+              if (in_R11 != (char *)0x0) {

+                *in_R11 = unaff_SIL;

+              }

+              if (param_4 != (char *)0x0) {

+                *param_4 = cVar3;

+              }

+              return 1;

+            }

+            if (9 < (byte)(*pcVar4 - 0x30U)) break;

+            iVar2 = iVar2 + -1;

+            cVar3 = *pcVar4 + (cVar3 * '\x05' + -0x18) * '\x02';

+          }

+        }

+      }

+    }

   }

-  else {

-    cVar1 = '\0';

-  }

-  return cVar1 == '\x02';

+  return 0;

 }
```

## `ApiSetValidateSchemaExtensionFormat_V7`  (modified)

```diff
--- ApiSetValidateSchemaExtensionFormat_V7
+++ ApiSetValidateSchemaExtensionFormat_V7
@@ -1,49 +1,94 @@
 

-undefined8 ApiSetValidateSchemaExtensionFormat_V7(void)

+undefined8 ApiSetValidateSchemaExtensionFormat_V7(longlong param_1,uint param_2)

 

 {

-  byte *pbVar1;

-  byte bVar2;

-  uint in_EAX;

-  longlong lVar3;

-  undefined1 *unaff_RBX;

-  undefined4 *unaff_RSI;

-  undefined4 unaff_EDI;

-  longlong in_R9;

-  uint *unaff_R14;

-  longlong unaff_R15;

+  uint uVar1;

+  uint uVar2;

+  uint uVar3;

+  ulonglong uVar4;

+  short sVar5;

+  uint uVar6;

+  uint uVar7;

+  ulonglong uVar8;

+  ushort uVar9;

+  ulonglong uVar10;

   

-  pbVar1 = (byte *)(in_R9 + 0xf);

-  *pbVar1 = *pbVar1 << 1 | (char)*pbVar1 < '\0';

-  *unaff_RBX = 0;

-  bVar2 = ApiSetpGetSearchKeyHash();

-  if (*unaff_R14 != (uint)bVar2) {

-    *unaff_RSI = 0xf6;

-    return 0;

-  }

-  lVar3 = ((ulonglong)(ushort)unaff_R14[1] * (ulonglong)(byte)unaff_RBX[0x34] +

-          (ulonglong)*(uint *)(unaff_RBX + 0x2c)) - unaff_R15;

-  if (*(ushort *)((ulonglong)in_EAX - 0x18) <= (ushort)*(byte *)((longlong)unaff_R14 + 9)) {

-    if ((unaff_RBX[lVar3 + 10] & 2) == 0) {

-      *unaff_RSI = 0xf2;

-      return 0;

-    }

-    if ((*(ushort *)(unaff_RBX + lVar3 + 4) < *(ushort *)(unaff_RBX + 0x60)) &&

-       (unaff_RBX +

-        (((ulonglong)(byte)unaff_RBX[100] * (ulonglong)*(ushort *)(unaff_RBX + lVar3 + 4) +

-         (ulonglong)*(uint *)(unaff_RBX + 0x5c)) - unaff_R15) != (undefined1 *)0x0)) {

-      if ((byte)unaff_RBX[3] <

-          (byte)(unaff_RBX +

-                (((ulonglong)(byte)unaff_RBX[100] * (ulonglong)*(ushort *)(unaff_RBX + lVar3 + 4) +

-                 (ulonglong)*(uint *)(unaff_RBX + 0x5c)) - unaff_R15))[10]) {

-        *unaff_RSI = 0xf4;

+  if (param_2 != 0) {

+    uVar1 = *(uint *)(param_1 + 4);

+    uVar8 = (ulonglong)uVar1;

+    if ((((uVar1 != 0) && (uVar1 <= param_2)) && (0x13 < param_2)) && (0x13 < uVar1)) {

+      if (*(ushort *)(param_1 + 0x10) != 0) {

+        uVar7 = *(uint *)(param_1 + 8);

+        if (uVar1 < uVar7) {

+          return 0xc00000e4;

+        }

+        uVar6 = uVar7 + *(ushort *)(param_1 + 0x10);

+        if (uVar6 < uVar7) {

+          return 0;

+        }

+        if (uVar1 < uVar6) {

+          return 0xc00000e4;

+        }

+      }

+      uVar10 = (ulonglong)*(ushort *)(param_1 + 0x12);

+      if (*(ushort *)(param_1 + 0x12) == 0) {

         return 0;

       }

-      *unaff_RSI = unaff_EDI;

-      return 0;

+      if ((uVar10 + 1) * 0x14 <= uVar8) {

+        uVar7 = *(uint *)(param_1 + 0xc);

+        while ((uVar4 = (ulonglong)uVar7, uVar4 <= uVar8 - 0x14 &&

+               (uVar6 = *(uint *)(uVar4 + param_1), uVar6 <= uVar1))) {

+          uVar2 = *(ushort *)(uVar4 + 8 + param_1) + uVar6;

+          if (uVar2 < uVar6) {

+            return 0;

+          }

+          if (uVar1 < uVar2) {

+            return 0xc00000e4;

+          }

+          sVar5 = *(short *)(uVar4 + 10 + param_1);

+          if (sVar5 != 0) {

+            uVar6 = *(uint *)(uVar4 + 4 + param_1);

+            do {

+              uVar4 = (ulonglong)uVar6;

+              if (uVar8 - 0x10 < uVar4) {

+                return 0xc00000e4;

+              }

+              uVar2 = *(uint *)(uVar4 + param_1);

+              if (uVar1 < uVar2) {

+                return 0xc00000e4;

+              }

+              uVar3 = *(ushort *)(uVar4 + 8 + param_1) + uVar2;

+              if (uVar3 < uVar2) {

+                return 0;

+              }

+              if (uVar1 < uVar3) {

+                return 0xc00000e4;

+              }

+              uVar2 = *(uint *)(uVar4 + 4 + param_1);

+              if (uVar1 < uVar2) {

+                return 0xc00000e4;

+              }

+              uVar3 = *(ushort *)(uVar4 + 10 + param_1) + uVar2;

+              if (uVar3 < uVar2) {

+                return 0;

+              }

+              if (uVar1 < uVar3) {

+                return 0xc00000e4;

+              }

+              uVar6 = uVar6 + 0x10;

+              sVar5 = sVar5 + -1;

+            } while (sVar5 != 0);

+          }

+          uVar7 = uVar7 + 0x14;

+          uVar9 = (short)uVar10 - 1;

+          uVar10 = (ulonglong)uVar9;

+          if (uVar9 == 0) {

+            return 0;

+          }

+        }

+      }

     }

   }

-  *unaff_RSI = 0xf1;

-  return 0;

+  return 0xc00000e4;

 }
```

## `KiRaiseIrqlProcessIrqlFlags`  (modified)

```diff
--- KiRaiseIrqlProcessIrqlFlags
+++ KiLowerIrqlProcessIrqlFlags
@@ -1,20 +1,19 @@
 

-void KiRaiseIrqlProcessIrqlFlags(byte param_1,byte param_2)

+void KiLowerIrqlProcessIrqlFlags(byte param_1,byte param_2)

 

 {

-  uint uVar1;

+  void *pvVar1;

+  uint uVar2;

   

-  if ((((KiIrqlFlags & 1) != 0) && (param_1 < 0x10)) && ((byte)(param_2 - 2) < 0xe)) {

-    if (param_1 == param_2) {

-      uVar1 = 1 << (param_2 & 0x1f);

+  pvVar1 = FiberData;

+  if (((((KiIrqlFlags & 1) != 0) && (param_1 < 0x10)) && (param_2 < 0x10)) && (1 < param_1)) {

+    uVar2 = *(uint *)(*(longlong *)((longlong)FiberData + 0x8eb8) + 0x14) &

+            ~((uint)(-1L << (param_2 + 1 & 0x3f)) & 0xffff);

+    *(uint *)(*(longlong *)((longlong)FiberData + 0x8eb8) + 0x14) = uVar2;

+    if (uVar2 == 0) {

+      KiRemoveSystemWorkPriorityKick(pvVar1);

     }

-    else {

-      uVar1 = (uint)(-1L << (param_1 + 1 & 0x3f)) & (int)(1L << (param_2 + 1 & 0x3f)) - 1U &

-              0xfffffffc;

-    }

-    *(uint *)(*(longlong *)((longlong)FiberData + 0x8eb8) + 0x14) =

-         *(uint *)(*(longlong *)((longlong)FiberData + 0x8eb8) + 0x14) | uVar1;

   }

   return;

 }
```

## `PopBatteryTraceSystemBatteryStatusV1`  (modified)

```diff
--- PopBatteryTraceSystemBatteryStatusV1
+++ EtwTraceMdlFreeEvent
@@ -1,11 +1,36 @@
 

-void PopBatteryTraceSystemBatteryStatusV1(void)

+/* WARNING: Function: __security_check_cookie replaced with injection: security_check_cookie */

+

+void EtwTraceMdlFreeEvent(undefined8 param_1,undefined8 param_2,undefined4 param_3)

 

 {

-  code *pcVar1;

+  char cVar1;

+  undefined1 auStack_78 [32];

+  undefined8 local_58;

+  undefined8 local_50;

+  undefined4 local_48;

+  undefined8 **local_40;

+  undefined8 local_38;

+  undefined8 local_30;

+  undefined4 local_28;

+  undefined8 *local_20;

+  undefined8 local_18;

+  ulonglong local_10;

   

-  pcVar1 = (code *)swi(3);

-  (*pcVar1)();

+  local_10 = __security_cookie ^ (ulonglong)auStack_78;

+  cVar1 = EtwEventEnabled(EtwpMemoryProvRegHandle,&KERNEL_MEM_EVENT_MDL_FREE);

+  if (cVar1 != '\0') {

+    local_20 = &local_38;

+    local_40 = &local_20;

+    local_48 = 1;

+    local_50 = 0;

+    local_58 = 0;

+    local_18 = 0x14;

+    local_38 = param_1;

+    local_30 = param_2;

+    local_28 = param_3;

+    EtwWriteEx(EtwpMemoryProvRegHandle,&KERNEL_MEM_EVENT_MDL_FREE,0);

+  }

   return;

 }
```

## `Feature_TestUex12__private_IsEnabledFallback`  (modified)

```diff
--- Feature_TestUex12__private_IsEnabledFallback
+++ PpmHeteroHgsCpuSupportedForContainment
@@ -1,8 +1,68 @@
 

-void Feature_TestUex12__private_IsEnabledFallback(void)

+/* WARNING: Instruction at (ram,0x0001405d43a2) overlaps instruction at (ram,0x0001405d439f)

+    */

+

+void PpmHeteroHgsCpuSupportedForContainment

+               (longlong param_1,code *param_2,undefined8 param_3,undefined8 param_4)

 

 {

-  func_0x000140668d3c();

+  undefined8 uVar1;

+  undefined8 *puVar2;

+  undefined8 *puVar3;

+  uint unaff_EBX;

+  uint uVar4;

+  ulonglong uVar5;

+  longlong unaff_RDI;

+  char in_CF;

+  bool in_ZF;

+  unkbyte10 in_ST0;

+  

+  if (in_ZF) {

+    fcos(in_ST0);

+  }

+  else {

+    *(char *)(unaff_RDI + 0x48) = (*(char *)(unaff_RDI + 0x48) - (char)param_2) - in_CF;

+    register0x00000020 = (BADSPACEBASE *)(ulonglong)((int)&stack0x00000000 - 0x20);

+    unaff_EBX = 0;

+    param_2 = PpmCheckReset;

+    param_4 = 0;

+    param_3 = 0;

+    unaff_RDI = param_1;

+    if (param_1 == 0) {

+      *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1405d43e6;

+      PopExecuteOnTargetProcessors(&PpmCheckRegistered,PpmCheckReset,0,0);

+      for (puVar2 = PpmPerfDomainHead; (undefined8 **)puVar2 != &PpmPerfDomainHead;

+          puVar2 = (undefined8 *)*puVar2) {

+        uVar5 = 0;

+        if (*(int *)(puVar2 + 0x25) != 0) {

+          do {

+            puVar3 = (undefined8 *)(uVar5 * 0x4a8 + puVar2[0x27]);

+            if (*(int *)(puVar3 + 2) == 1) {

+              uVar1 = *puVar3;

+              *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1405d441e;

+              PpmResetPerfTimes(uVar1);

+            }

+            uVar4 = (int)uVar5 + 1;

+            uVar5 = (ulonglong)uVar4;

+          } while (uVar4 < *(uint *)(puVar2 + 0x25));

+        }

+      }

+      return;

+    }

+  }

+  *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1405d43a4;

+  PopExecuteOnTargetProcessors(param_1 + 0x18,param_2,param_3,param_4);

+  if (unaff_EBX < *(uint *)(unaff_RDI + 0x128)) {

+    do {

+      puVar2 = (undefined8 *)((ulonglong)unaff_EBX * 0x4a8 + *(longlong *)(unaff_RDI + 0x138));

+      if (*(int *)(puVar2 + 2) == 1) {

+        uVar1 = *puVar2;

+        *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1405d43ce;

+        PpmResetPerfTimes(uVar1);

+      }

+      unaff_EBX = unaff_EBX + 1;

+    } while (unaff_EBX < *(uint *)(unaff_RDI + 0x128));

+  }

   return;

 }
```

## `IopIsIosbInLockedRange`  (modified)

```diff
--- IopIsIosbInLockedRange
+++ IopQueueIrpForServiceTail
@@ -1,7 +1,38 @@
 

-void IopIsIosbInLockedRange(void)

+void IopQueueIrpForServiceTail(longlong param_1,longlong param_2,char param_3)

 

 {

+  char cVar1;

+  uint uVar2;

+  undefined8 uVar3;

+  

+  uVar2 = *(uint *)(param_1 + 0x10) & 0x200000;

+  if (((param_3 != '\0') || (*(longlong *)(param_1 + 0x58) != 0)) && (uVar2 == 0)) {

+    if ((*(uint *)(param_2 + 0x50) & 2) != 0) {

+      *(byte *)(param_1 + 0x47) = *(byte *)(param_1 + 0x47) | 2;

+    }

+    goto LAB_0;

+  }

+  if (uVar2 == 0) {

+    if (((*(longlong *)(param_1 + 0x60) != 0) && (*(longlong *)(param_1 + 0x50) == 0)) &&

+       (*(longlong *)(param_2 + 0xb0) != 0)) {

+      uVar3 = 1;

+      goto LAB_1;

+    }

+    if ((((*(uint *)(param_1 + 0x10) & 0x10) != 0) || (*(longlong *)(param_2 + 0xb0) != 0)) ||

+       (*(longlong *)(param_2 + 0xd0) == 0)) goto LAB_0;

+    cVar1 = IopIsIosbInLockedRange(param_2,param_1);

+  }

+  else {

+    uVar3 = 0;

+LAB_1:

+    cVar1 = IopQueueIrpToFileObject(param_1,param_2,uVar3);

+  }

+  if (cVar1 != '\0') {

+    return;

+  }

+LAB_0:

+  IopQueueThreadIrp(param_1);

   return;

 }
```

## `ExFreePool`  (modified)

```diff
--- ExFreePool calling
+++ ExFreePool calling
@@ -14 +13,0 @@
-ConvertDevpropcompkeyToString
@@ -31,2 +30,2 @@
-FUN_140507cd0
-FUN_1405169b0
+FUN_140507ca0
+FUN_140516980
```

## `ExFreePoolWithTag`  (modified)

```diff
--- ExFreePoolWithTag calling
+++ ExFreePoolWithTag calling
@@ -746,173 +746,173 @@
-FUN_140238973
-FUN_140261ece
-FUN_14027524c
-FUN_140348428
-FUN_1403baf22
-FUN_140403e8e
-FUN_140482e41
-FUN_1404a8a4e
-FUN_1404b4658
-FUN_1404cc81c
-FUN_14065402c
-FUN_1406d0bec
-FUN_1406d353c
-FUN_1406d3ba0
-FUN_1406d3d3e
-FUN_1406d3e20
-FUN_1406dbf2a
-FUN_1406de8f8
-FUN_1406de924
-FUN_1406dff14
-FUN_1406e0215
-FUN_1406e199e
-FUN_1406e19ae
-FUN_1406e19c5
-FUN_1406e244c
-FUN_1406e274f
-FUN_1406e361c
-FUN_1406e4ab8
-FUN_1406e73fa
-FUN_1406ee076
-FUN_1406ee198
-FUN_1406eed1e
-FUN_1406f01c6
-FUN_1406f0234
-FUN_1406f02ab
-FUN_1406f138e
-FUN_1406f13f8
-FUN_1406f1e3a
-FUN_1406f1f7c
-FUN_1406f23d2
-FUN_1406f25ec
-FUN_1406f3dbc
-FUN_1406f418c
-FUN_140830f68
-FUN_140875ef4
-FUN_1408ac343
-FUN_1408c8da9
-FUN_1408f60c6
-FUN_1408f87a3
-FUN_1408fda01
-FUN_140911c5f
-FUN_140914151
-FUN_14091df20
-FUN_14091eaf0
-FUN_14092ad07
-FUN_140939045
-FUN_14095b180
-FUN_14095b5b0
-FUN_14095c440
-FUN_14097a17f
-FUN_14097a86d
-FUN_14097a8f5
-FUN_1409813ca
-FUN_14098d1eb
-FUN_140995233
-FUN_1409a4280
-FUN_1409a6fad
-FUN_1409a7722
-FUN_1409aa19a
-FUN_1409c3372
-FUN_1409cd7d4
-FUN_1409db868
-FUN_1409f4d28
-FUN_1409f5154
-FUN_1409f580c
-FUN_140a003d0
-FUN_140a2607d
-FUN_140a278cc
-FUN_140a350eb
-FUN_140a3a047
-FUN_140a409c6
-FUN_140a566b1
-FUN_140a5aeb6
-FUN_140a68ea5
-FUN_140a71c4e
-FUN_140ab32cc
-FUN_140ab56b0
-FUN_140ab5ce0
-FUN_140ab8f8c
-FUN_140ab9570
-FUN_140abb350
-FUN_140abc314
-FUN_140b070f0
-FUN_140b075cc
-FUN_140b075f4
-FUN_140b077ba
-FUN_140b0857b
-FUN_140b08e4c
-FUN_140b0a062
-FUN_140b0a0c5
-FUN_140b0bd44
-FUN_140b0bdce
-FUN_140b0c916
-FUN_140b0cd17
-FUN_140b0e144
-FUN_140b10698
-FUN_140b112a8
-FUN_140b15dc4
-FUN_140b15dfc
-FUN_140b17268
-FUN_140b172b8
-FUN_140b18978
-FUN_140b18bb4
-FUN_140b1a04a
-FUN_140b1a167
-FUN_140b1ca90
-FUN_140b1cabd
-FUN_140b1cae6
-FUN_140b1d734
-FUN_140b1d7f4
-FUN_140b1dd9f
-FUN_140b1e348
-FUN_140b1ec50
-FUN_140b20a29
-FUN_140b2112a
-FUN_140b21278
-FUN_140b21876
-FUN_140b23050
-FUN_140b230e0
-FUN_140b23228
-FUN_140b24534
-FUN_140b24640
-FUN_140b24936
-FUN_140b24943
-FUN_140b25178
-FUN_140b25396
-FUN_140b255e0
-FUN_140b258d4
-FUN_140b267a5
-FUN_140b26a5c
-FUN_140b27440
-FUN_140b282bb
-FUN_140b28ba8
-FUN_140b29ec6
-FUN_140b2a6b7
-FUN_140b2a8e8
-FUN_140b2aaa4
-FUN_140b2aae2
-FUN_140b2b880
-FUN_140b2b8c2
-FUN_140b2bb0e
-FUN_140b2bc46
-FUN_140b2cf45
-FUN_140b2d1f2
-FUN_140b2da85
-FUN_140b2ef94
-FUN_140b2f148
-FUN_140b2ff0c
-FUN_140b3015f
-FUN_140b30340
-FUN_140b30c8c
-FUN_140b3108b
-FUN_140b31fcb
-FUN_140b33144
-FUN_140b335c4
-FUN_140b33b10
-FUN_140b34507
-FUN_140b34dd4
-FUN_140b38566
-FUN_140b38a28
-FUN_140b38cb7
-FUN_140b398cc
-FUN_140b39fe7
+FUN_140238183
+FUN_14026136e
+FUN_14026a9dc
+FUN_14033dc28
+FUN_14039db62
+FUN_140406cce
+FUN_140484411
+FUN_1404a8c4e
+FUN_1404b4708
+FUN_1404cc5ec
+FUN_14065426c
+FUN_1406d148c
+FUN_1406d3b64
+FUN_1406d3c46
+FUN_1406dbd50
+FUN_1406de71e
+FUN_1406de74a
+FUN_1406dfe7e
+FUN_1406dfe8e
+FUN_1406dfea5
+FUN_1406e04cb
+FUN_1406e0524
+FUN_1406e0b2c
+FUN_1406e0b9a
+FUN_1406e0c11
+FUN_1406e1fe2
+FUN_1406e2646
+FUN_1406e2b8c
+FUN_1406e410c
+FUN_1406e4f41
+FUN_1406e54a2
+FUN_1406e8174
+FUN_1406eec26
+FUN_1406eed48
+FUN_1406ef8ce
+FUN_1406f1aa0
+FUN_1406f1b0a
+FUN_1406f2542
+FUN_1406f2684
+FUN_1406f2ada
+FUN_1406f2cf4
+FUN_1406f4dbc
+FUN_1406f518c
+FUN_140831eb8
+FUN_140876e44
+FUN_1408ad293
+FUN_1408c9a39
+FUN_1408f6d56
+FUN_1408f9433
+FUN_1408fe691
+FUN_1409128ef
+FUN_140914de1
+FUN_14091ebb0
+FUN_14091f780
+FUN_14092b997
+FUN_140939cd5
+FUN_14095b750
+FUN_14095bb80
+FUN_14095ca10
+FUN_14097a18f
+FUN_14097a87d
+FUN_14097a905
+FUN_1409813da
+FUN_14099172b
+FUN_140994f53
+FUN_1409a3fa0
+FUN_1409a6ccd
+FUN_1409a7442
+FUN_1409a9eba
+FUN_1409c3092
+FUN_1409cd864
+FUN_1409db8f8
+FUN_1409f50b8
+FUN_1409f54e4
+FUN_1409f5b9c
+FUN_140a007a0
+FUN_140a2678d
+FUN_140a27fdc
+FUN_140a34b3b
+FUN_140a39a97
+FUN_140a40036
+FUN_140a55ae1
+FUN_140a5a0f6
+FUN_140a68235
+FUN_140a7100e
+FUN_140ab1aa0
+FUN_140ab3e80
+FUN_140ab44b0
+FUN_140ab78ac
+FUN_140ab7e90
+FUN_140ab9c70
+FUN_140abac34
+FUN_140b07bb0
+FUN_140b0808c
+FUN_140b080b4
+FUN_140b0827a
+FUN_140b0903b
+FUN_140b0990c
+FUN_140b0ab22
+FUN_140b0ab85
+FUN_140b0c804
+FUN_140b0c88e
+FUN_140b0d3d6
+FUN_140b0d7d7
+FUN_140b0ec04
+FUN_140b11158
+FUN_140b11d68
+FUN_140b16884
+FUN_140b168bc
+FUN_140b17d28
+FUN_140b17d78
+FUN_140b19438
+FUN_140b19674
+FUN_140b1ab0a
+FUN_140b1ac27
+FUN_140b1d340
+FUN_140b1d36d
+FUN_140b1d396
+FUN_140b1de5a
+FUN_140b1df1a
+FUN_140b1e4c5
+FUN_140b1ea6e
+FUN_140b1f376
+FUN_140b2114f
+FUN_140b21850
+FUN_140b21fdc
+FUN_140b22522
+FUN_140b236be
+FUN_140b2374e
+FUN_140b23896
+FUN_140b24ba2
+FUN_140b24cae
+FUN_140b24fa4
+FUN_140b24fb1
+FUN_140b257e6
+FUN_140b25a04
+FUN_140b25c4e
+FUN_140b25f42
+FUN_140b26e83
+FUN_140b2713a
+FUN_140b27b1e
+FUN_140b28999
+FUN_140b29230
+FUN_140b2a54e
+FUN_140b2ad4b
+FUN_140b2af7c
+FUN_140b2b138
+FUN_140b2b176
+FUN_140b2bf14
+FUN_140b2bf56
+FUN_140b2c1a2
+FUN_140b2c2da
+FUN_140b2d5d9
+FUN_140b2d87e
+FUN_140b2e111
+FUN_140b2f620
+FUN_140b2f87c
+FUN_140b3069e
+FUN_140b308f1
+FUN_140b30ad2
+FUN_140b31414
+FUN_140b31813
+FUN_140b32753
+FUN_140b338cc
+FUN_140b33d40
+FUN_140b3428c
+FUN_140b34c83
+FUN_140b35550
+FUN_140b38cf4
+FUN_140b391b6
+FUN_140b39445
+FUN_140b3a05a
+FUN_140b3a775
@@ -2801 +2800,0 @@
-SepVerifyUIAccessChildProcessImage
```
