# CVE-2026-95989 — vhdmp.sys patch diff

`vhdmp.sys` 10.0.26100.9818 -> 10.0.26100.9974 (ghidriff).

## `VhdmpiIoctlQueueCancelWorkItem`  (modified)

```diff
--- VhdmpiIoctlQueueCancelWorkItem
+++ VhdmpiIoctlQueueCancelWorkItem
@@ -1,112 +1,113 @@
 

 void VhdmpiIoctlQueueCancelWorkItem(longlong param_1,undefined8 param_2,undefined8 param_3)

 

 {

   longlong lVar1;

   _IRP *p_Var2;

   longlong lVar3;

   longlong lVar4;

   longlong *plVar5;

   code *pcVar6;

   char cVar7;

-  _VHD_SURFACE *p_Var8;

-  longlong lVar9;

-  undefined1 *puVar10;

-  longlong *plVar11;

+  undefined8 uVar8;

+  _VHD_SURFACE *p_Var9;

+  longlong lVar10;

+  undefined1 *puVar11;

+  longlong *plVar12;

   undefined1 auStackY_58 [8];

   undefined1 auStackY_50 [24];

   

-  puVar10 = auStackY_58;

+  puVar11 = auStackY_58;

   if (5 < DAT_0) {

     cVar7 = _tlgKeywordOn(0x1400876d0,2);

     if (cVar7 != '\0') {

       param_3 = 5;

       TraceEvents("VhdmpiIoctlQueueCancelWorkItem",399,5,2,

                   "VhdmpiIoctlQueueCancelWorkItem: enter...");

     }

   }

   lVar1 = param_1 + -0x18;

   KeAcquireSpinLockRaiseToDpc(lVar1);

-  plVar11 = (longlong *)(param_1 + -0x10);

+  plVar12 = (longlong *)(param_1 + -0x10);

   while( true ) {

-    plVar5 = (longlong *)*plVar11;

-    lVar9 = *plVar5;

-    if (((longlong *)plVar5[1] != plVar11) || ((longlong *)*(longlong *)(lVar9 + 8) != plVar5))

+    plVar5 = (longlong *)*plVar12;

+    lVar10 = *plVar5;

+    if (((longlong *)plVar5[1] != plVar12) || ((longlong *)*(longlong *)(lVar10 + 8) != plVar5))

     break;

-    *plVar11 = lVar9;

-    *(longlong **)(lVar9 + 8) = plVar11;

+    *plVar12 = lVar10;

+    *(longlong **)(lVar10 + 8) = plVar12;

     KeReleaseSpinLock(lVar1);

-    if (plVar5 == plVar11) goto LAB_1;

+    if (plVar5 == plVar12) goto LAB_1;

     p_Var2 = (_IRP *)(plVar5 + -0x15);

-    lVar9 = plVar5[2];

-    lVar3 = *(longlong *)(*(longlong *)(lVar9 + 0x30) + 0x20);

+    lVar10 = plVar5[2];

+    lVar3 = *(longlong *)(*(longlong *)(lVar10 + 0x30) + 0x20);

     lVar4 = *(longlong *)(lVar3 + 0x38);

-    cVar7 = func_0x00014002eb2c(*(undefined4 *)(lVar9 + 0x18));

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

-      if (*(int *)(lVar9 + 0x18) == 0x2d191c) {

+    uVar8 = VhdmpiIsAsyncIoctlCode(*(int *)(lVar10 + 0x18));

+    if ((char)uVar8 == '\0') {

+      if (*(int *)(lVar10 + 0x18) == 0x2d191c) {

         if (4 < DAT_0) {

           cVar7 = _tlgKeywordOn(0x1400876d0,2);

           if (cVar7 != '\0') {

             param_3 = 4;

             TraceEvents("VhdmpiIoctlQueueCancelWorkItem",0x1cf,4,2,

                         "VhdmpiIoctlQueueCancelWorkItem: canceling surface, Irp=0x%p");

           }

         }

-        lVar9 = lVar4;

-        p_Var8 = (_VHD_SURFACE *)VhdmpiAddRefSurfaceByVirtualDisk(lVar4);

+        lVar10 = lVar4;

+        p_Var9 = (_VHD_SURFACE *)VhdmpiAddRefSurfaceByVirtualDisk(lVar4);

         if ((Microsoft_Windows_VHDMPEnableBits & 2) != 0) {

           McTemplateK0zp_EtwWriteTransfer

-                    (lVar9,&VhdSurfaceCancellation,param_3,

+                    (lVar10,&VhdSurfaceCancellation,param_3,

                      *(wchar_t **)(*(longlong *)(lVar4 + 0x90) + 0x78));

         }

-        if (p_Var8 != (_VHD_SURFACE *)0x0) {

-          VhdmpiHaltSurfaceOrWait(p_Var8,0,param_3);

+        if (p_Var9 != (_VHD_SURFACE *)0x0) {

+          VhdmpiHaltSurfaceOrWait(p_Var9,0,param_3);

           VhdmpiAcquirePassiveLock(lVar4 + 0xb8);

           *(int *)(lVar4 + 0xd0) = *(int *)(lVar4 + 0xd0) + -1;

           VhdmpiReleasePassiveLock(lVar4 + 0xb8);

-          VhdmpiReleaseSurface((longlong)p_Var8);

+          VhdmpiReleaseSurface((longlong)p_Var9);

         }

       }

-      else if (*(int *)(lVar9 + 0x18) == 0x2d1a80) {

+      else if (*(int *)(lVar10 + 0x18) == 0x2d1a80) {

         if (4 < DAT_0) {

           cVar7 = _tlgKeywordOn(0x1400876d0,2);

           if (cVar7 != '\0') {

             param_3 = 4;

             TraceEvents("VhdmpiIoctlQueueCancelWorkItem",0x1f2,4,2,

                         "VhdmpiIoctlQueueCancelWorkItem: canceling recovery, Irp=0x%p");

           }

         }

         VhdmpiCancelVirtualDiskRecoveryV2(lVar3,(longlong)p_Var2);

       }

     }

     else {

       if (4 < DAT_0) {

         cVar7 = _tlgKeywordOn(0x1400876d0,2);

         if (cVar7 != '\0') {

           param_3 = 4;

           TraceEvents("VhdmpiIoctlQueueCancelWorkItem",0x1c1,4,2,

                       "VhdmpiIoctlQueueCancelWorkItem: canceling async op, Irp=0x%p");

         }

       }

       VhdmpiCancelDequeuedAsyncOp(p_Var2);

     }

     ExReleaseRundownProtection(lVar3 + 0x108);

     IofCompleteRequest(p_Var2,0);

     KeAcquireSpinLockRaiseToDpc(lVar1);

   }

   pcVar6 = (code *)swi(0x29);

   (*pcVar6)(3);

-  puVar10 = auStackY_50;

+  puVar11 = auStackY_50;

 LAB_1:

   if (5 < DAT_0) {

-    *(undefined8 *)(puVar10 + -8) = 0x14002eadd;

+    *(undefined8 *)(puVar11 + -8) = 0x14002eadd;

     cVar7 = _tlgKeywordOn(0x1400876d0,2);

     if (cVar7 != '\0') {

-      *(char **)(puVar10 + 0x20) = "VhdmpiIoctlQueueCancelWorkItem: leaving...";

-      *(undefined8 *)(puVar10 + -8) = 0x14002eb07;

-      TraceEvents("VhdmpiIoctlQueueCancelWorkItem",0x203,5,2,*(char **)(puVar10 + 0x20));

+      *(char **)(puVar11 + 0x20) = "VhdmpiIoctlQueueCancelWorkItem: leaving...";

+      *(undefined8 *)(puVar11 + -8) = 0x14002eb07;

+      TraceEvents("VhdmpiIoctlQueueCancelWorkItem",0x203,5,2,*(char **)(puVar11 + 0x20));

     }

   }

   return;

 }
```

## `VhdmpiCancelAllQueuedIoctlsOnDisk`  (modified)

```diff
--- VhdmpiCancelAllQueuedIoctlsOnDisk
+++ VhdmpiCancelAllQueuedIoctlsOnDisk
@@ -1,7 +1,51 @@
 

 void VhdmpiCancelAllQueuedIoctlsOnDisk(longlong param_1)

 

 {

+  longlong lVar1;

+  longlong lVar2;

+  char cVar3;

+  undefined8 uVar4;

+  _IRP *p_Var5;

+  

+  if (5 < DAT_0) {

+    cVar3 = _tlgKeywordOn(0x1400876d0,0x10);

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

+      TraceEvents("VhdmpiCancelAllQueuedIoctlsOnDisk",0x335,5,0x10,

+                  "VhdmpiCancelAllQueuedIoctlsOnDisk: enter... VirtualDisk=0x%p");

+    }

+  }

+  while( true ) {

+    p_Var5 = (_IRP *)VhdmpiDequeueControlDeviceIoctl(param_1,0);

+    if (p_Var5 == (_IRP *)0x0) break;

+    lVar1 = *(longlong *)(p_Var5 + 0xb8);

+    lVar2 = *(longlong *)(*(longlong *)(lVar1 + 0x30) + 0x20);

+    *(undefined8 *)(p_Var5 + 0x38) = 0;

+    *(undefined4 *)(p_Var5 + 0x30) = 0xc0000120;

+    uVar4 = VhdmpiIsAsyncIoctlCode(*(int *)(lVar1 + 0x18));

+    if ((char)uVar4 == '\0') {

+      if (*(int *)(lVar1 + 0x18) == 0x2d191c) {

+        VhdmpiAcquirePassiveLock(param_1 + 0xb8);

+        *(int *)(param_1 + 0xd0) = *(int *)(param_1 + 0xd0) + -1;

+        VhdmpiReleasePassiveLock(param_1 + 0xb8);

+      }

+      else if (*(int *)(lVar1 + 0x18) == 0x2d1a80) {

+        VhdmpiCancelVirtualDiskRecoveryV2(lVar2,(longlong)p_Var5);

+      }

+    }

+    else {

+      VhdmpiCancelDequeuedAsyncOp(p_Var5);

+    }

+    ExReleaseRundownProtection(lVar2 + 0x108);

+    IofCompleteRequest(p_Var5);

+  }

+  if (5 < DAT_0) {

+    cVar3 = _tlgKeywordOn(0x1400876d0,0x10);

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

+      TraceEvents("VhdmpiCancelAllQueuedIoctlsOnDisk",0x367,5,0x10,

+                  "VhdmpiCancelAllQueuedIoctlsOnDisk: leaving...");

+    }

+  }

   return;

 }
```

## `VhdmpiVhd2GetPayloadBlockScsiLbaState`  (modified)

```diff
--- VhdmpiVhd2GetPayloadBlockScsiLbaState
+++ VhdmpiVhd2GetPayloadBlockScsiLbaState
@@ -1,107 +1,142 @@
+

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

+/* long __cdecl VhdmpiVhd2GetPayloadBlockScsiLbaState(struct _VHD_BACKING_STORE_HEADER *

+   __ptr64,unsigned long,unsigned char,unsigned char * __ptr64) */

 

 long __cdecl

 VhdmpiVhd2GetPayloadBlockScsiLbaState

           (_VHD_BACKING_STORE_HEADER *param_1,ulong param_2,uchar param_3,uchar *param_4)

 

 {

-  char cVar1;

-  int iVar2;

-  longlong in_RAX;

+  uint uVar1;

+  uint uVar2;

   uint uVar3;

-  undefined8 *puVar4;

-  undefined4 unaff_ESI;

-  uint uVar5;

-  undefined8 unaff_RDI;

-  _VHD_BACKING_STORE_HEADER *p_Var6;

-  undefined4 uVar7;

-  undefined7 in_register_00000081;

-  longlong lStack_148;

-  longlong *plStack_140;

-  undefined8 uStack_138;

-  undefined8 *puStack_130;

-  undefined8 uStack_128;

-  undefined2 uStack_120;

-  undefined1 uStack_11e;

-  undefined4 uStack_11d;

-  undefined1 uStack_119;

-  undefined8 uStack_118;

-  undefined8 uStack_110;

-  undefined8 uStack_108;

-  undefined8 uStack_100;

+  _BLOCK_STATE _Var4;

+  char cVar5;

+  uchar uVar6;

+  long lVar7;

+  uint uVar8;

+  _VHD_BACKING_STORE_HEADER *p_Var9;

+  ulonglong uVar10;

+  ulong uVar11;

+  uint uVar12;

+  uint uVar13;

+  undefined1 auStackY_d8 [32];

+  _BLOCK_STATE local_a8;

+  uint local_a4;

+  uint local_a0;

+  uint local_9c;

+  uint local_98;

+  ulong local_94;

+  undefined8 local_90;

+  undefined8 uStack_88;

+  uint local_80;

+  _VHD2_BACKING_STORE *local_78;

+  uchar *local_70;

+  undefined8 local_68;

+  undefined8 uStack_60;

+  undefined8 local_58;

+  undefined8 uStack_50;

+  ulonglong local_48;

   

-  *(undefined4 *)(in_RAX + 0x18) = unaff_ESI;

-  *(undefined8 *)(in_RAX + 0x20) = unaff_RDI;

-  uStack_118 = 0;

-  uStack_110 = 0;

-  *(undefined8 *)(in_RAX + -0xe8) = 0;

-  uStack_108 = 0;

-  uStack_100 = 0;

-  *(undefined8 *)(in_RAX + -0xf8) = 0;

-  *(undefined8 *)(in_RAX + -0xf0) = 0;

-  VhdmpiAeInitializeSynchronousCompletion((longlong)&uStack_118);

-  *(undefined8 *)(in_RAX + 8) = 0;

-  plStack_140 = &lStack_148;

-  uStack_11d = 0;

-  uStack_128 = 0;

-  lStack_148 = 0;

-  uStack_138 = 0;

-  p_Var6 = param_1 + 0x8c0;

-  puStack_130 = &uStack_138;

-  uStack_119 = 0;

-  uStack_120 = 1;

-  uStack_11e = 1;

-  memset((void *)(in_RAX + -0xd8),0,0xb8);

-  puVar4 = &uStack_118;

-  AeUseCompletion((longlong)p_Var6,(longlong)puVar4);

-  *(undefined8 **)(in_RAX + -0xb8) = &uStack_118;

-  if (param_2 == 0) {

-    uVar3 = *(uint *)(param_1 + 0x1314);

-  }

-  else {

-    uVar3 = *(uint *)(param_1 + 0x1318);

-  }

-  uVar5 = (uint)CONCAT71(in_register_00000081,param_3);

-  if (uVar5 < uVar3) {

-    puVar4 = (undefined8 *)(ulonglong)param_2;

-    cVar1 = Vhd2iTryGetBlockMapping

-                      ((longlong)p_Var6,(ulonglong)puVar4,uVar5,(ulonglong *)(in_RAX + 8));

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

-      *(undefined1 *)(in_RAX + -0xcc) = 0;

-      *(code **)(in_RAX + -200) = Vhd2iAeCompletionTrampoline;

-      *(code **)(in_RAX + -0xc0) = Vhd2iGotBlockMappingForGetBlockState;

-      Vhd2iGetBlockMappingAsync

-                ((longlong)p_Var6,(undefined8 *)(in_RAX + -0xb0),param_2,uVar5,

-                 (undefined8 *)(in_RAX + -0xd8),(longlong)&lStack_148);

-      iVar2 = 0x103;

-      goto LAB_0;

-    }

-    uVar3 = (uint)*(ulonglong *)(in_RAX + 8);

-    *(uint *)(in_RAX + -0x30) = uVar3 & 7;

-    if ((ulonglong)(uVar3 & 7) - 6 < 2) {

-      *(ulonglong *)(in_RAX + -0x28) = *(ulonglong *)(in_RAX + 8) & 0xfffffffffff00000;

+  local_48 = __security_cookie ^ (ulonglong)auStackY_d8;

+  local_a8 = 0;

+  local_68 = 0;

+  uStack_60 = 0;

+  local_58 = 0;

+  uStack_50 = 0;

+  local_90 = 0;

+  uStack_88 = 0;

+  uVar11 = param_2;

+  local_94 = param_2;

+  local_70 = param_4;

+  p_Var9 = (_VHD_BACKING_STORE_HEADER *)VhdmpiVhd2BackingStore(param_1);

+  lVar7 = VhdmpiVhd2GetBlockState((_VHD2_BACKING_STORE *)p_Var9,0,uVar11,&local_a8,(__uint64 *)0x0);

+  if (-1 < lVar7) {

+    if ((param_3 == '\0') && (local_a8 == 5)) {

+      uVar1 = *(uint *)(p_Var9 + 0x12e8);

+      uVar6 = '\x01';

+      RtlInitializeBitMap(&local_90,&local_68,0x100);

+      RtlClearAllBits(&local_90);

+      uVar10 = Feature_3912390970__private_IsEnabledDeviceUsageNoInline();

+      if (((int)uVar10 != 0) && (0x10000000 < (uVar1 & 0xfff00000))) {

+        return -0x3ffffff3;

+      }

+      local_80 = uVar1 >> 0x14;

+      RtlSetBits(&local_90,0,local_80);

+      while (p_Var9 = *(_VHD_BACKING_STORE_HEADER **)(p_Var9 + 0x478),

+            p_Var9 != (_VHD_BACKING_STORE_HEADER *)0x0) {

+        local_78 = VhdmpiVhd2BackingStore(p_Var9);

+        uVar2 = *(uint *)(local_78 + 0x12e8);

+        if (uVar2 < uVar1) {

+          uVar8 = uVar1 / uVar2;

+          local_98 = uVar8 * param_2;

+          if (uVar8 != 0) goto LAB_0;

+        }

+        else {

+          uVar8 = 1;

+          local_98 = (uint)((ulonglong)param_2 / ((ulonglong)uVar2 / (ulonglong)uVar1));

+LAB_0:

+          uVar13 = uVar2 >> 0x14;

+          local_9c = 0;

+          local_a4 = uVar13;

+          local_a0 = local_98;

+          do {

+            uVar12 = local_9c >> 0x14;

+            uVar10 = Feature_3912390970__private_IsEnabledDeviceUsageNoInline();

+            if ((int)uVar10 == 0) {

+              uVar3 = uVar2 << 0x14;

+            }

+            else {

+              if (0xff < uVar12) {

+                return -0x3ffffff3;

+              }

+              uVar3 = uVar13;

+              if (0x100 < uVar13 + uVar12) {

+                return -0x3ffffff3;

+              }

+            }

+            cVar5 = RtlAreBitsClear(&local_90,uVar12,uVar3);

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

+              if ((ulonglong)local_a0 * (ulonglong)uVar2 < *(ulonglong *)(local_78 + 0x960)) {

+                lVar7 = VhdmpiVhd2GetBlockState(local_78,0,local_a0,&local_a8,(__uint64 *)0x0);

+                if (lVar7 < 0) {

+                  return lVar7;

+                }

+              }

+              else {

+                local_a8 = 0;

+              }

+              _Var4 = local_a8;

+              uVar13 = local_a4;

+              if (local_a8 != 5) {

+                uVar10 = Feature_3912390970__private_IsEnabledDeviceUsageNoInline();

+                if ((int)uVar10 == 0) {

+                  uVar12 = local_9c >> 0x14;

+                }

+                RtlClearBits(&local_90,uVar12,local_a4);

+                uVar6 = VhdmpiVhd2BlockStateToScsiLbaStatus(_Var4);

+                param_2 = local_94;

+                uVar13 = local_a4;

+                if (uVar6 != '\x01') break;

+              }

+            }

+            local_a0 = local_a0 + 1;

+            local_9c = local_9c + uVar2;

+            param_2 = local_94;

+          } while (local_a0 - local_98 < uVar8);

+        }

+        cVar5 = RtlAreBitsClear(&local_90,0,local_80);

+        if ((cVar5 != '\0') || (uVar6 != '\x01')) break;

+      }

+      *local_70 = uVar6;

     }

     else {

-      *(undefined8 *)(in_RAX + -0x28) = 0;

+      uVar6 = VhdmpiVhd2BlockStateToScsiLbaStatus(local_a8);

+      *param_4 = uVar6;

     }

-    uVar7 = 0;

+    lVar7 = 0;

   }

-  else {

-    uVar7 = 0xc000000d;

-  }

-  iVar2 = AeSynchronousCompletion((longlong)p_Var6,puVar4,uVar7);

-LAB_0:

-  AeProcessTodo((longlong)p_Var6,&lStack_148);

-  if (iVar2 == 0x103) {

-    iVar2 = VhdmpiAeWaitForSynchronousCompletion((longlong)&uStack_118);

-  }

-  if (-1 < iVar2) {

-    if (param_4 != (uchar *)0x0) {

-      *(undefined4 *)param_4 = *(undefined4 *)(in_RAX + -0x30);

-    }

-    if (*(undefined8 **)(in_RAX + 0x28) != (undefined8 *)0x0) {

-      **(undefined8 **)(in_RAX + 0x28) = *(undefined8 *)(in_RAX + -0x28);

-    }

-  }

-  return iVar2;

+  return lVar7;

 }
```

## `VhdmpiCancelAllQueuedIoctlsOnHandle`  (modified)

```diff
--- VhdmpiCancelAllQueuedIoctlsOnHandle
+++ VhdmpiCancelAllQueuedIoctlsOnHandle
@@ -1,18 +1,53 @@
 

 void VhdmpiCancelAllQueuedIoctlsOnHandle(longlong param_1)

 

 {

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

-    HvipApertureDetectParameters();

+  int *piVar1;

+  int iVar2;

+  longlong lVar3;

+  char cVar4;

+  undefined8 uVar5;

+  _IRP *p_Var6;

+  

+  if (5 < DAT_0) {

+    cVar4 = _tlgKeywordOn(0x1400876d0,0x10);

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

+      TraceEvents("VhdmpiCancelAllQueuedIoctlsOnHandle",0x3de,5,0x10,

+                  "VhdmpiCancelAllQueuedIoctlsOnHandle: enter... HandleContext=0x%p");

+    }

   }

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

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

-      HvipApertureDirectHypercall();

+  while( true ) {

+    p_Var6 = (_IRP *)VhdmpiDequeueControlDeviceIoctl(param_1,0);

+    if (p_Var6 == (_IRP *)0x0) break;

+    lVar3 = *(longlong *)(p_Var6 + 0xb8);

+    *(undefined8 *)(p_Var6 + 0x38) = 0;

+    *(undefined4 *)(p_Var6 + 0x30) = 0xc0000120;

+    uVar5 = VhdmpiIsAsyncIoctlCode(*(int *)(lVar3 + 0x18));

+    if ((char)uVar5 == '\0') {

+      iVar2 = *(int *)(lVar3 + 0x18);

+      if (iVar2 == 0x2d191c) {

+        VhdmpiAcquirePassiveLock(*(longlong *)(param_1 + 0x38) + 0xb8);

+        piVar1 = (int *)(*(longlong *)(param_1 + 0x38) + 0xd0);

+        *piVar1 = *piVar1 + -1;

+        VhdmpiReleasePassiveLock(*(longlong *)(param_1 + 0x38) + 0xb8);

+      }

+      else if (iVar2 == 0x2d1a80) {

+        VhdmpiCancelVirtualDiskRecoveryV2(param_1,(longlong)p_Var6);

+      }

     }

     else {

-      HvipApertureVmfuncSwitchEptp();

+      VhdmpiCancelDequeuedAsyncOp(p_Var6);

+    }

+    ExReleaseRundownProtection(param_1 + 0x108);

+    IofCompleteRequest(p_Var6);

+  }

+  if (5 < DAT_0) {

+    cVar4 = _tlgKeywordOn(0x1400876d0,0x10);

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

+      TraceEvents("VhdmpiCancelAllQueuedIoctlsOnHandle",0x40f,5,0x10,

+                  "VhdmpiCancelAllQueuedIoctlsOnDisk: leaving...");

     }

   }

   return;

 }
```

## `VhdmpiCancelAllQueuedIoctlsOnAdapter`  (modified)

```diff
--- VhdmpiCancelAllQueuedIoctlsOnAdapter
+++ VhdmpiCancelAllQueuedIoctlsOnDisk
@@ -1,53 +1,7 @@
 

-void VhdmpiCancelAllQueuedIoctlsOnAdapter(void)

+void VhdmpiCancelAllQueuedIoctlsOnDisk(longlong param_1)

 

 {

-  longlong lVar1;

-  longlong lVar2;

-  uint uVar3;

-  char cVar4;

-  undefined4 in_EAX;

-  undefined8 uVar5;

-  _IRP *p_Var6;

-  __uint64 in_RDX;

-  longlong unaff_RSI;

-  ulonglong unaff_R15;

-  undefined8 in_stack_00000020;

-  

-  uVar3 = (uint)unaff_R15;

-  TraceEvents("VhdmpiCancelAllQueuedIoctlsOnDisk",in_RDX,uVar3 - 0xb,uVar3,

-              (char *)CONCAT44((int)((ulonglong)in_stack_00000020 >> 0x20),in_EAX));

-  while( true ) {

-    p_Var6 = (_IRP *)VhdmpiDequeueControlDeviceIoctl(unaff_RSI,0);

-    if (p_Var6 == (_IRP *)0x0) break;

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

-    lVar2 = *(longlong *)(*(longlong *)(lVar1 + 0x30) + 0x20);

-    *(undefined8 *)(p_Var6 + 0x38) = 0;

-    *(undefined4 *)(p_Var6 + 0x30) = 0xc0000120;

-    uVar5 = VhdmpiIsAsyncIoctlCode(*(int *)(lVar1 + 0x18));

-    if ((char)uVar5 == '\0') {

-      if (*(int *)(lVar1 + 0x18) == 0x2d191c) {

-        VhdmpiAcquirePassiveLock(unaff_RSI + 0xb8);

-        *(int *)(unaff_RSI + 0xd0) = *(int *)(unaff_RSI + 0xd0) + -1;

-        VhdmpiReleasePassiveLock(unaff_RSI + 0xb8);

-      }

-      else if (*(int *)(lVar1 + 0x18) == 0x2d1a80) {

-        VhdmpiCancelVirtualDiskRecoveryV2(lVar2,(longlong)p_Var6);

-      }

-    }

-    else {

-      VhdmpiCancelDequeuedAsyncOp(p_Var6);

-    }

-    ExReleaseRundownProtection(lVar2 + 0x108);

-    IofCompleteRequest(p_Var6);

-  }

-  if (5 < DAT_0) {

-    cVar4 = _tlgKeywordOn(0x1400876d0,unaff_R15);

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

-      TraceEvents("VhdmpiCancelAllQueuedIoctlsOnDisk",0x367,5,uVar3,

-                  "VhdmpiCancelAllQueuedIoctlsOnDisk: leaving...");

-    }

-  }

   return;

 }
```

## `VhdmpiDequeueControlDeviceIoctl`  (modified)

```diff
--- VhdmpiDequeueControlDeviceIoctl
+++ VhdmpiIsAsyncIoctlCode
@@ -1,26 +1,27 @@
 

-undefined8 VhdmpiDequeueControlDeviceIoctl(undefined8 param_1,undefined4 param_2)

+undefined8 VhdmpiIsAsyncIoctlCode(int param_1)

 

 {

-  char cVar1;

-  undefined8 uVar2;

-  uint uVar3;

-  undefined8 local_18;

-  undefined4 local_10;

-  undefined4 local_c;

+  uint uVar1;

+  ulonglong uVar2;

+  ulonglong uVar3;

+  undefined1 uVar4;

   

-  local_c = 0;

-  local_18 = param_1;

-  local_10 = param_2;

-  uVar2 = IoCsqRemoveNextIrp(VhdmpControlExtension + 8,&local_18);

-  if (5 < DAT_0) {

-    uVar3 = 0x10;

-    cVar1 = _tlgKeywordOn(0x1400876d0,0x10);

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

-      TraceEvents("VhdmpiDequeueControlDeviceIoctl",0x2e2,uVar3 - 0xb,uVar3,

-                  "VhdmpiDequeueControlDeviceIoctl: returning Irp: 0x%p, Ioctl: 0x%04x");

-    }

+  uVar2 = Feature_2812695866__private_IsEnabledDeviceUsageNoInline();

+  uVar4 = 0;

+  uVar1 = param_1 - 0x2d1924;

+  uVar3 = (ulonglong)uVar1;

+  if ((int)uVar2 == 0) {

+    if (((0x34 < uVar1) || ((0x11111000000001U >> (uVar3 & 0x3f) & 1) == 0)) &&

+       ((0xc < param_1 - 0x2d1a54U ||

+        (uVar3 = 0x1101, (0x1101U >> (param_1 - 0x2d1a54U & 0x1f) & 1) == 0)))) goto LAB_0;

   }

-  return uVar2;

+  else if ((((0x34 < uVar1) || ((0x11111000000001U >> (uVar3 & 0x3f) & 1) == 0)) &&

+           ((0xc < param_1 - 0x2d1a54U ||

+            (uVar3 = 0x1101, (0x1101U >> (param_1 - 0x2d1a54U & 0x1f) & 1) == 0)))) &&

+          (param_1 != 0x2d1994)) goto LAB_0;

+  uVar4 = 1;

+LAB_0:

+  return CONCAT71((int7)(uVar3 >> 8),uVar4);

 }
```
