# CVE-2026-105526 — afd.sys patch diff

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

## `Tkey_RecordRead_New`  (modified)

```diff
--- Tkey_RecordRead_New
+++ Tkey_RecordRead_New
@@ -1,55 +1,111 @@
 

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

+/* WARNING: Removing unreachable block (ram,0x00014007776d) */

 

-longlong Tkey_RecordRead_New(void)

+longlong Tkey_RecordRead_New(longlong param_1,undefined8 param_2,undefined8 param_3,byte *param_4,

+                            byte *param_5)

 

 {

-  char *pcVar1;

-  int iVar2;

-  longlong in_RAX;

+  longlong lVar1;

+  byte *pbVar2;

   ulonglong uVar3;

-  longlong lVar5;

-  longlong lVar6;

-  int iVar7;

-  uint unaff_EBX;

-  ushort unaff_SI;

-  undefined8 *unaff_RDI;

-  int unaff_R13D;

-  void *unaff_R14;

-  char unaff_R15B;

-  ulonglong uVar4;

+  void *pvVar4;

+  void *pvVar5;

+  void *_Dst;

+  ushort uVar6;

+  ushort uVar7;

+  void *pvVar8;

+  void *pvVar9;

+  byte *pbVar10;

   

-  lVar5 = -1;

-  *(void **)(in_RAX + 0x20) = unaff_R14;

-  uVar3 = (ulonglong)unaff_SI;

-  if (unaff_SI == 0) {

-    uVar4 = 0xffffffffffffffff;

-    do {

-      uVar3 = uVar4 + 1;

-      pcVar1 = &stack0x00000051 + uVar4;

-      uVar4 = uVar3;

-    } while (*pcVar1 != unaff_R15B);

+  _Dst = (void *)0x0;

+  pvVar8 = (void *)0x0;

+  pvVar9 = (void *)0x0;

+  lVar1 = Dns_AllocateRecordEx_New(0x38,0);

+  if (lVar1 == 0) {

+    return 0;

   }

-  iVar2 = (int)uVar3;

-  if (unaff_R13D == 2) {

-    iVar7 = iVar2;

-    if (iVar2 == 0) {

-      do {

-        lVar6 = lVar5 + 1;

-        pcVar1 = &stack0x00000051 + lVar5;

-        lVar5 = lVar6;

-      } while (*pcVar1 != unaff_R15B);

-      iVar7 = (int)lVar6;

+  *(undefined2 *)(lVar1 + 0x10) = 0xf9;

+  pbVar2 = Dns_SkipPacketName_New(param_4,param_5);

+  pvVar4 = pvVar8;

+  pvVar5 = pvVar9;

+  if ((pbVar2 == (byte *)0x0) || (0xff < (longlong)pbVar2 - (longlong)param_4)) {

+    if ((DAT_0 & 0x20) != 0) {

+      WPP_SF_(0x40d,0x31,&WPP_dae3796762ab3fe49897d177eaa916f1_Traceguids);

     }

-    if (((iVar7 != -1) && (iVar7 + 1U <= unaff_EBX)) && (iVar2 + 1U <= iVar7 + 1U)) {

-      memmove(unaff_R14,&stack0x00000050,uVar3 & 0xffffffff);

-      *(char *)((uVar3 & 0xffffffff) + (longlong)unaff_R14) = unaff_R15B;

-      if (iVar2 != -1) {

-        return (longlong)unaff_RDI;

+  }

+  else {

+    *(byte **)(lVar1 + 0x28) = param_4;

+    *(undefined8 *)(lVar1 + 0x20) = 0;

+    *(char *)(lVar1 + 0x50) = (char)pbVar2 - (char)param_4;

+    pvVar4 = _Dst;

+    pvVar5 = _Dst;

+    if (pbVar2 + 0x10 < param_5) {

+      *(uint *)(lVar1 + 0x40) = CONCAT31(CONCAT21(CONCAT11(*pbVar2,pbVar2[1]),pbVar2[2]),pbVar2[3]);

+      *(uint *)(lVar1 + 0x44) =

+           CONCAT31(CONCAT21(CONCAT11(pbVar2[4],pbVar2[5]),pbVar2[6]),pbVar2[7]);

+      *(ushort *)(lVar1 + 0x48) = (ushort)pbVar2[8] * 0x100 + (ushort)pbVar2[9];

+      *(ushort *)(lVar1 + 0x4a) = (ushort)pbVar2[10] * 0x100 + (ushort)pbVar2[0xb];

+      pbVar10 = pbVar2 + 0xe;

+      uVar6 = (ushort)pbVar2[0xc] * 0x100 + (ushort)pbVar2[0xd];

+      *(ushort *)(lVar1 + 0x4c) = uVar6;

+      pvVar4 = pvVar8;

+      pvVar5 = pvVar9;

+      if (pbVar2 + (ulonglong)uVar6 + 0x10 <= param_5) {

+        *(byte **)(lVar1 + 0x30) = pbVar10;

+        uVar7 = (ushort)pbVar10[uVar6] * 0x100 + (ushort)pbVar10[(ulonglong)uVar6 + 1];

+        *(ushort *)(lVar1 + 0x4e) = uVar7;

+        if (pbVar2 + (ulonglong)uVar6 + 0x10 + uVar7 <= param_5) {

+          *(ulonglong *)(lVar1 + 0x38) =

+               -(ulonglong)(uVar7 != 0) & (ulonglong)(pbVar2 + (ulonglong)uVar6 + 0x10);

+          *(undefined4 *)(lVar1 + 0x54) = 1;

+          uVar3 = Feature_2975485241__private_IsEnabledDeviceUsageNoInline();

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

+            return lVar1;

+          }

+          if (param_1 == 0) {

+            return lVar1;

+          }

+          pvVar4 = _Dst;

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

+            pvVar4 = (void *)ExAllocatePool3(0x40,*(char *)(lVar1 + 0x50),0x52736e44,

+                                             &DnsLowPriorityPool,1);

+            if (pvVar4 == (void *)0x0) goto LAB_1;

+            memmove(pvVar4,*(void **)(lVar1 + 0x28),(ulonglong)*(byte *)(lVar1 + 0x50));

+          }

+          pvVar5 = _Dst;

+          if (*(short *)(lVar1 + 0x4c) != 0) {

+            pvVar5 = (void *)ExAllocatePool3(0x40,*(short *)(lVar1 + 0x4c),0x52736e44,

+                                             &DnsLowPriorityPool,1);

+            if (pvVar5 == (void *)0x0) goto LAB_1;

+            memmove(pvVar5,*(void **)(lVar1 + 0x30),(ulonglong)*(ushort *)(lVar1 + 0x4c));

+          }

+          if (*(short *)(lVar1 + 0x4e) != 0) {

+            _Dst = (void *)ExAllocatePool3(0x40,*(short *)(lVar1 + 0x4e),0x52736e44,

+                                           &DnsLowPriorityPool,1);

+            if (_Dst == (void *)0x0) goto LAB_1;

+            memmove(_Dst,*(void **)(lVar1 + 0x38),(ulonglong)*(ushort *)(lVar1 + 0x4e));

+          }

+          *(uint *)(lVar1 + 0x14) = *(uint *)(lVar1 + 0x14) | 0x1000;

+          *(void **)(lVar1 + 0x28) = pvVar4;

+          *(void **)(lVar1 + 0x30) = pvVar5;

+          *(void **)(lVar1 + 0x38) = _Dst;

+          *(undefined4 *)(lVar1 + 0x54) = 0;

+          return lVar1;

+        }

       }

     }

   }

-  Dns_RecordFree_New(unaff_RDI);

+LAB_1:

+  uVar3 = Feature_2975485241__private_IsEnabledDeviceUsageNoInline();

+  if ((int)uVar3 != 0) {

+    if (pvVar4 != (void *)0x0) {

+      ExFreePoolWithTag(pvVar4,0x52736e44);

+    }

+    if (pvVar5 != (void *)0x0) {

+      ExFreePoolWithTag(pvVar5,0x52736e44);

+    }

+  }

+  ExFreePoolWithTag(lVar1,0x52736e44);

   return 0;

 }
```

## `AfdQueryHandles`  (modified)

```diff
--- AfdQueryHandles
+++ AfdGetInformation
@@ -1,19 +1,187 @@
 

-int AfdQueryHandles(longlong param_1,undefined8 param_2,char param_3,uint *param_4,uint param_5,

-                   undefined8 param_6,uint param_7,undefined8 *param_8)

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

+

+undefined4

+AfdGetInformation(longlong param_1,undefined8 param_2,char param_3,int *param_4,uint param_5,

+                 undefined8 param_6,uint param_7,undefined8 *param_8)

 

 {

-  undefined4 in_EAX;

-  int iVar1;

-  longlong unaff_RBX;

-  longlong unaff_RDI;

+  longlong *plVar1;

+  code *pcVar2;

+  undefined8 uVar3;

+  bool bVar4;

+  char cVar5;

+  uint uVar6;

+  longlong lVar7;

+  ulonglong uVar8;

+  undefined2 *puVar9;

+  void *_Dst;

+  undefined8 *puVar10;

+  undefined1 *puVar11;

+  ushort *unaff_RBX;

+  byte bVar12;

+  longlong unaff_RSI;

+  undefined2 *unaff_RDI;

+  ushort unaff_R12W;

+  char *unaff_R13;

+  undefined8 unaff_R14;

+  ushort unaff_R15W;

+  undefined1 auStackX_8 [24];

+  undefined8 in_stack_00000068;

+  undefined4 in_stack_000000f0;

+  undefined4 in_stack_000000f4;

+  undefined4 in_stack_000000f8;

+  undefined4 *in_stack_00000110;

+  undefined8 in_stack_00000118;

+  undefined4 in_stack_00000138;

+  undefined8 in_stack_00000140;

+  undefined8 in_stack_00000148;

+  undefined8 in_stack_00000150;

+  undefined8 in_stack_00000158;

+  undefined8 in_stack_00000160;

   

-  *(undefined4 *)(param_1 + -0x20) = in_EAX;

-  *(undefined8 *)(param_1 + -0x18) = *(undefined8 *)(unaff_RDI + 0x10);

-  *(undefined4 *)(param_1 + -0x3c) = 0x20;

-  *(undefined4 *)(param_1 + -0x40) = *(undefined4 *)(unaff_RBX + 0x40);

-  *(undefined8 *)(*(longlong *)(unaff_RBX + 0x58) + 8) = *(undefined8 *)(unaff_RBX + 0x38);

-  iVar1 = IofCallDriver(*(undefined8 *)(unaff_RDI + 0x18),*(undefined8 *)(unaff_RBX + 0x58));

-  return iVar1;

+  if (((*unaff_R13 == '\x03') && ((char)param_1 != '\0')) || (*unaff_R13 == '\x04')) {

+    if ((Feature_2056415544__private_featureState & 0x10) == 0) {

+      uVar8 = Feature_2056415544__private_IsEnabledDeviceUsageNoInline();

+      uVar6 = (uint)uVar8;

+    }

+    else {

+      uVar6 = Feature_2056415544__private_featureState & (uint)unaff_RSI;

+    }

+    if (uVar6 == 0) {

+      uVar8 = AfdIssueDeviceControl

+                        (*(undefined8 *)(unaff_RBX + 0xc),&stack0x00000058,0x10,

+                         (longlong)&stack0x00000138,4,0xc);

+      param_6._4_4_ = (int)uVar8;

+      unaff_R14 = in_stack_00000068;

+    }

+    else {

+      lVar7 = AfdGetAddressFileReference((longlong)unaff_RBX);

+      if (lVar7 == 0) {

+        param_6._4_4_ = -0x3ffffe7c;

+        unaff_R14 = in_stack_00000068;

+      }

+      else {

+        uVar8 = AfdIssueDeviceControl(lVar7,&stack0x00000058,0x10,(longlong)&stack0x00000138,4,0xc);

+        param_6._4_4_ = (int)uVar8;

+        ObfDereferenceObject(lVar7);

+        unaff_R14 = in_stack_00000068;

+      }

+    }

+  }

+  else {

+    param_6._4_4_ = -0x3ffffe7c;

+  }

+  if ((byte)param_7 != 0) {

+    AfdReallowUnbind((longlong)unaff_RBX);

+  }

+  MmUnlockPages(unaff_R14);

+  IoFreeMdl(unaff_R14);

+  if (param_6._4_4_ < (int)unaff_RDI) {

+    if ((*(uint *)(unaff_RBX + 4) >> 8 & 1) == 0) {

+      in_stack_00000140 = 0;

+      in_stack_00000148 = 0;

+      in_stack_00000150 = 0;

+      in_stack_00000158 = 0;

+      in_stack_00000160 = 0;

+      uVar8 = AfdQueryProviderInfo((longlong)&stack0x00000140,*(longlong *)(unaff_RBX + 0x88));

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

+        in_stack_00000138 = in_stack_00000140._4_4_;

+        if (*unaff_RBX == unaff_R15W) {

+          in_stack_00000138 = in_stack_00000148._4_4_;

+        }

+      }

+    }

+    else {

+      memset(&stack0x000000e0,0,0x50);

+      in_stack_000000f0 = 2;

+      in_stack_000000f4 = 0xffff;

+      in_stack_000000f8 = 0x2003;

+      in_stack_00000110 = &stack0x00000138;

+      in_stack_00000118 = 4;

+      puVar9 = unaff_RDI;

+      if (((*unaff_RBX & 0xafd2) == 0xafd2) && ((char)unaff_RBX[1] == '\x04')) {

+        puVar9 = (undefined2 *)AfdGetConnectionReferenceFromEndpoint(unaff_RBX);

+      }

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

+        if ((((*unaff_RBX != unaff_R15W) && (*unaff_RBX != unaff_R12W)) &&

+            ((bVar12 = (byte)unaff_RSI, (*(byte *)((longlong)unaff_RBX + 5) & 0x10) == 0 ||

+             (((byte)unaff_RBX[3] & bVar12) == 0)))) &&

+           ((((bVar12 & (byte)*(undefined4 *)(unaff_RBX + 4)) == 0 && ((char)unaff_RBX[1] != '\x04')

+             ) && (bVar4 = AfdPreventUnbind((longlong)unaff_RBX), param_7._0_1_ = bVar12, !bVar4))))

+        goto LAB_0;

+        LOCK();

+        *(longlong *)(unaff_RBX + 0x84) = *(longlong *)(unaff_RBX + 0x84) + unaff_RSI;

+        UNLOCK();

+        AfdTLIoControl(*(undefined **)(*(longlong *)(unaff_RBX + 0xc) + 8),

+                       *(undefined8 *)(unaff_RBX + 8),(longlong *)&stack0x000000e0,

+                       (longlong)unaff_RBX);

+        LOCK();

+        *(longlong *)(unaff_RBX + 0x84) = *(longlong *)(unaff_RBX + 0x84) + -1;

+        UNLOCK();

+        if ((byte)param_7 != 0) {

+          AfdReallowUnbind((longlong)unaff_RBX);

+        }

+      }

+      else {

+        AfdTLIoControl(*(undefined **)(*(longlong *)(puVar9 + 0xc) + 8),*(undefined8 *)(puVar9 + 8),

+                       (longlong *)&stack0x000000e0,0);

+        LOCK();

+        plVar1 = (longlong *)(puVar9 + 0x18);

+        lVar7 = *plVar1;

+        *plVar1 = *plVar1 + -1;

+        UNLOCK();

+        if (lVar7 < 2) {

+          if (lVar7 == 1) {

+            AfdCloseConnection(puVar9);

+          }

+          else {

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

+            (*pcVar2)(0xe);

+            register0x00000020 = (BADSPACEBASE *)auStackX_8;

+          }

+        }

+      }

+    }

+  }

+  if (*(int *)((longlong)register0x00000020 + 0x34) < (int)unaff_RDI) goto LAB_0;

+  *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140045075;

+  cVar5 = IoIs32bitProcess(0);

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

+    if (*(char *)((longlong)register0x00000020 + 0x30) == (char)unaff_RDI) {

+      puVar10 = *(undefined8 **)((longlong)register0x00000020 + 0x48);

+      goto LAB_1;

+    }

+    _Dst = *(void **)((longlong)register0x00000020 + 0x48);

+    if (*(void **)MmUserProbeAddress_exref <= *(void **)((longlong)register0x00000020 + 0x48)) {

+      _Dst = *(void **)MmUserProbeAddress_exref;

+    }

+    *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1400450f0;

+    RtlCopyVolatileMemory(_Dst,(undefined1 *)((longlong)register0x00000020 + 0x130),0x10);

+  }

+  else {

+    if (*(char *)((longlong)register0x00000020 + 0x30) != (char)unaff_RDI) {

+      puVar11 = *(undefined1 **)((longlong)register0x00000020 + 0x48);

+      if (((ulonglong)puVar11 & 3) != 0) {

+                    /* WARNING: Subroutine does not return */

+        *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140045096;

+        ExRaiseDatatypeMisalignment();

+      }

+      if (*(undefined1 **)MmUserProbeAddress_exref <= puVar11) {

+        puVar11 = *(undefined1 **)MmUserProbeAddress_exref;

+      }

+      *puVar11 = *puVar11;

+      puVar11[0xf] = puVar11[0xf];

+    }

+    puVar10 = *(undefined8 **)((longlong)register0x00000020 + 0x70);

+LAB_1:

+    uVar3 = *(undefined8 *)((longlong)register0x00000020 + 0x138);

+    *puVar10 = *(undefined8 *)((longlong)register0x00000020 + 0x130);

+    puVar10[1] = uVar3;

+  }

+  **(undefined8 **)((longlong)register0x00000020 + 0x78) = 0x10;

+LAB_0:

+  *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14004513c;

+  return *(undefined4 *)((longlong)register0x00000020 + 0x34);

 }
```

## `AfdGetInformation`  (modified)

```diff
--- AfdGetInformation
+++ AfdGetInformation
@@ -1,187 +1,401 @@
 

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

+/* WARNING: Removing unreachable block (ram,0x000140044ddb) */

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

 

 undefined4

 AfdGetInformation(longlong param_1,undefined8 param_2,char param_3,int *param_4,uint param_5,

                  undefined8 param_6,uint param_7,undefined8 *param_8)

 

 {

   longlong *plVar1;

-  code *pcVar2;

-  undefined8 uVar3;

-  bool bVar4;

-  char cVar5;

-  uint uVar6;

-  longlong lVar7;

-  ulonglong uVar8;

-  undefined2 *puVar9;

+  ushort *puVar2;

+  ushort uVar3;

+  int iVar4;

+  ushort *puVar5;

+  code *pcVar6;

+  undefined8 uVar7;

+  char cVar8;

+  bool bVar9;

+  bool bVar10;

+  uint uVar11;

+  undefined4 uVar12;

+  undefined2 *puVar13;

+  ulonglong uVar14;

   void *_Dst;

-  undefined8 *puVar10;

-  undefined1 *puVar11;

-  ushort *unaff_RBX;

-  byte bVar12;

-  longlong unaff_RSI;

-  undefined2 *unaff_RDI;

-  ushort unaff_R12W;

-  char *unaff_R13;

-  undefined8 unaff_R14;

-  ushort unaff_R15W;

-  undefined1 auStackX_8 [24];

-  undefined8 in_stack_00000068;

-  undefined4 in_stack_000000f0;

-  undefined4 in_stack_000000f4;

-  undefined4 in_stack_000000f8;

-  undefined4 *in_stack_00000110;

-  undefined8 in_stack_00000118;

-  undefined4 in_stack_00000138;

-  undefined8 in_stack_00000140;

-  undefined8 in_stack_00000148;

-  undefined8 in_stack_00000150;

-  undefined8 in_stack_00000158;

-  undefined8 in_stack_00000160;

+  undefined8 *puVar15;

+  longlong lVar16;

+  undefined1 *puVar17;

+  undefined1 *puVar18;

+  undefined1 auStackY_1a8 [8];

+  undefined1 auStackY_1a0 [24];

+  int local_174;

+  bool local_170;

+  ulonglong local_150;

+  ulonglong *local_148;

+  longlong local_140;

+  undefined8 local_138;

+  undefined8 *local_130;

+  ushort *local_128;

+  undefined8 local_120;

+  ushort *local_118;

+  uint *local_110;

+  ulonglong local_108;

+  undefined8 uStack_100;

+  ulonglong local_f8;

+  undefined8 uStack_f0;

+  undefined8 local_e8;

+  ulonglong local_e0;

+  longlong local_c8 [2];

+  undefined4 local_b8;

+  undefined4 local_b4;

+  undefined4 local_b0;

+  ulonglong *local_98;

+  undefined8 local_90;

+  undefined8 local_78;

+  ulonglong uStack_70;

+  undefined8 local_68;

+  undefined8 uStack_60;

+  undefined8 local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

+  ulonglong local_40;

   

-  if (((*unaff_R13 == '\x03') && ((char)param_1 != '\0')) || (*unaff_R13 == '\x04')) {

-    if ((Feature_2056415544__private_featureState & 0x10) == 0) {

-      uVar8 = Feature_2056415544__private_IsEnabledDeviceUsageNoInline();

-      uVar6 = (uint)uVar8;

-    }

-    else {

-      uVar6 = Feature_2056415544__private_featureState & (uint)unaff_RSI;

-    }

-    if (uVar6 == 0) {

-      uVar8 = AfdIssueDeviceControl

-                        (*(undefined8 *)(unaff_RBX + 0xc),&stack0x00000058,0x10,

-                         (longlong)&stack0x00000138,4,0xc);

-      param_6._4_4_ = (int)uVar8;

-      unaff_R14 = in_stack_00000068;

-    }

-    else {

-      lVar7 = AfdGetAddressFileReference((longlong)unaff_RBX);

-      if (lVar7 == 0) {

-        param_6._4_4_ = -0x3ffffe7c;

-        unaff_R14 = in_stack_00000068;

+  puVar18 = auStackY_1a8;

+  puVar17 = auStackY_1a8;

+  local_40 = __security_cookie ^ (ulonglong)auStackY_1a8;

+  local_138 = param_6;

+  local_120 = param_6;

+  local_130 = param_8;

+  puVar13 = (undefined2 *)0x0;

+  bVar10 = false;

+  local_170 = false;

+  bVar9 = false;

+  *param_8 = 0;

+  puVar5 = *(ushort **)(param_1 + 0x18);

+  uVar3 = *puVar5;

+  if (((uVar3 == 0xaafd) || (uVar3 == 0xafd)) || (uVar3 == 0xfa09)) {

+LAB_0:

+    uVar12 = 0xc000000d;

+    puVar17 = auStackY_1a8;

+    goto LAB_1;

+  }

+  local_78 = 0;

+  uStack_70 = 0;

+  if ((param_5 < 0x10) || (param_7 < 0x10)) {

+    uVar12 = 0xc0000023;

+    goto LAB_1;

+  }

+  local_128 = puVar5;

+  cVar8 = IoIs32bitProcess(0);

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

+    if ((param_3 != '\0') && (((ulonglong)param_4 & 3) != 0)) {

+                    /* WARNING: Subroutine does not return */

+      ExRaiseDatatypeMisalignment();

+    }

+  }

+  else if ((param_3 != '\0') && (((ulonglong)param_4 & 3) != 0)) {

+                    /* WARNING: Subroutine does not return */

+    ExRaiseDatatypeMisalignment();

+  }

+  iVar4 = *param_4;

+  local_78 = CONCAT44(local_78._4_4_,iVar4);

+  if (iVar4 == 3) {

+LAB_2:

+    if ((*(uint *)(puVar5 + 4) >> 8 & 1) == 0) {

+      local_68 = 0;

+      uStack_60 = 0;

+      local_58 = 0;

+      uStack_50 = 0;

+      local_48 = 0;

+      uVar14 = AfdQueryProviderInfo((longlong)&local_68,*(longlong *)(puVar5 + 0x88));

+      puVar17 = auStackY_1a8;

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

+        uVar12 = local_68._4_4_;

+        if (*puVar5 == 0xafd1) {

+          uVar12 = uStack_60._4_4_;

+        }

+        goto LAB_3;

+      }

+      goto LAB_4;

+    }

+    memset(local_c8,0,0x50);

+    local_b8 = 2;

+    local_b4 = 0xffff;

+    local_b0 = 0x2003;

+    local_98 = &uStack_70;

+    local_90 = 4;

+    if (((*puVar5 & 0xafd2) == 0xafd2) && ((char)puVar5[1] == '\x04')) {

+      puVar13 = (undefined2 *)AfdGetConnectionReferenceFromEndpoint(puVar5);

+    }

+    if (puVar13 != (undefined2 *)0x0) {

+      AfdTLIoControl(*(undefined **)(*(longlong *)(puVar13 + 0xc) + 8),*(undefined8 *)(puVar13 + 8),

+                     local_c8,0);

+      LOCK();

+      plVar1 = (longlong *)(puVar13 + 0x18);

+      lVar16 = *plVar1;

+      *plVar1 = *plVar1 + -1;

+      UNLOCK();

+joined_r0x000140044f70:

+      puVar17 = auStackY_1a8;

+      if (lVar16 < 2) {

+        if (lVar16 == 1) goto LAB_5;

+LAB_6:

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

+        (*pcVar6)(0xe);

+        puVar17 = auStackY_1a0;

+      }

+      goto LAB_4;

+    }

+    if ((((*puVar5 == 0xafd1) || (*puVar5 == 0x1afd)) ||

+        (((*(byte *)((longlong)puVar5 + 5) & 0x10) != 0 && ((puVar5[3] & 1) != 0)))) ||

+       (((*(uint *)(puVar5 + 4) & 1) != 0 || ((char)puVar5[1] == '\x04')))) {

+LAB_7:

+      LOCK();

+      *(longlong *)(puVar5 + 0x84) = *(longlong *)(puVar5 + 0x84) + 1;

+      UNLOCK();

+      AfdTLIoControl(*(undefined **)(*(longlong *)(puVar5 + 0xc) + 8),*(undefined8 *)(puVar5 + 8),

+                     local_c8,(longlong)puVar5);

+      LOCK();

+      *(longlong *)(puVar5 + 0x84) = *(longlong *)(puVar5 + 0x84) + -1;

+      UNLOCK();

+      puVar17 = auStackY_1a8;

+      if (bVar9 != false) {

+        AfdReallowUnbind((longlong)puVar5);

+        puVar17 = auStackY_1a8;

+      }

+      goto LAB_4;

+    }

+    bVar10 = AfdPreventUnbind((longlong)puVar5);

+    if (bVar10) {

+      bVar9 = true;

+      goto LAB_7;

+    }

+  }

+  else {

+    if (iVar4 == 4) {

+      if (((((*(uint *)(puVar5 + 4) >> 8 & 1) == 0) && ((*(uint *)(puVar5 + 8) & 0x200) != 0)) ||

+          ((*puVar5 & 0xafd2) != 0xafd2)) ||

+         (((char)puVar5[1] != '\x04' ||

+          (puVar13 = (undefined2 *)AfdGetConnectionReferenceFromEndpoint(puVar5),

+          puVar13 == (undefined2 *)0x0)))) {

+        uStack_70 = uStack_70 & 0xffffffff00000000;

+        puVar17 = auStackY_1a8;

       }

       else {

-        uVar8 = AfdIssueDeviceControl(lVar7,&stack0x00000058,0x10,(longlong)&stack0x00000138,4,0xc);

-        param_6._4_4_ = (int)uVar8;

-        ObfDereferenceObject(lVar7);

-        unaff_R14 = in_stack_00000068;

-      }

-    }

-  }

-  else {

-    param_6._4_4_ = -0x3ffffe7c;

-  }

-  if ((byte)param_7 != 0) {

-    AfdReallowUnbind((longlong)unaff_RBX);

-  }

-  MmUnlockPages(unaff_R14);

-  IoFreeMdl(unaff_R14);

-  if (param_6._4_4_ < (int)unaff_RDI) {

-    if ((*(uint *)(unaff_RBX + 4) >> 8 & 1) == 0) {

-      in_stack_00000140 = 0;

-      in_stack_00000148 = 0;

-      in_stack_00000150 = 0;

-      in_stack_00000158 = 0;

-      in_stack_00000160 = 0;

-      uVar8 = AfdQueryProviderInfo((longlong)&stack0x00000140,*(longlong *)(unaff_RBX + 0x88));

-      if (-1 < (int)uVar8) {

-        in_stack_00000138 = in_stack_00000140._4_4_;

-        if (*unaff_RBX == unaff_R15W) {

-          in_stack_00000138 = in_stack_00000148._4_4_;

-        }

-      }

-    }

-    else {

-      memset(&stack0x000000e0,0,0x50);

-      in_stack_000000f0 = 2;

-      in_stack_000000f4 = 0xffff;

-      in_stack_000000f8 = 0x2003;

-      in_stack_00000110 = &stack0x00000138;

-      in_stack_00000118 = 4;

-      puVar9 = unaff_RDI;

-      if (((*unaff_RBX & 0xafd2) == 0xafd2) && ((char)unaff_RBX[1] == '\x04')) {

-        puVar9 = (undefined2 *)AfdGetConnectionReferenceFromEndpoint(unaff_RBX);

-      }

-      if (puVar9 == (undefined2 *)0x0) {

-        if ((((*unaff_RBX != unaff_R15W) && (*unaff_RBX != unaff_R12W)) &&

-            ((bVar12 = (byte)unaff_RSI, (*(byte *)((longlong)unaff_RBX + 5) & 0x10) == 0 ||

-             (((byte)unaff_RBX[3] & bVar12) == 0)))) &&

-           ((((bVar12 & (byte)*(undefined4 *)(unaff_RBX + 4)) == 0 && ((char)unaff_RBX[1] != '\x04')

-             ) && (bVar4 = AfdPreventUnbind((longlong)unaff_RBX), param_7._0_1_ = bVar12, !bVar4))))

-        goto LAB_0;

+        uVar12 = *(undefined4 *)(puVar13 + 0x3e);

+LAB_8:

+        uStack_70 = CONCAT44(uStack_70._4_4_,uVar12);

         LOCK();

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

-        UNLOCK();

-        AfdTLIoControl(*(undefined **)(*(longlong *)(unaff_RBX + 0xc) + 8),

-                       *(undefined8 *)(unaff_RBX + 8),(longlong *)&stack0x000000e0,

-                       (longlong)unaff_RBX);

-        LOCK();

-        *(longlong *)(unaff_RBX + 0x84) = *(longlong *)(unaff_RBX + 0x84) + -1;

-        UNLOCK();

-        if ((byte)param_7 != 0) {

-          AfdReallowUnbind((longlong)unaff_RBX);

-        }

-      }

-      else {

-        AfdTLIoControl(*(undefined **)(*(longlong *)(puVar9 + 0xc) + 8),*(undefined8 *)(puVar9 + 8),

-                       (longlong *)&stack0x000000e0,0);

-        LOCK();

-        plVar1 = (longlong *)(puVar9 + 0x18);

-        lVar7 = *plVar1;

+        plVar1 = (longlong *)(puVar13 + 0x18);

+        lVar16 = *plVar1;

         *plVar1 = *plVar1 + -1;

         UNLOCK();

-        if (lVar7 < 2) {

-          if (lVar7 == 1) {

-            AfdCloseConnection(puVar9);

+        puVar17 = auStackY_1a8;

+        if (lVar16 < 2) {

+          if (lVar16 != 1) goto LAB_6;

+LAB_5:

+          AfdCloseConnection(puVar13);

+          puVar17 = auStackY_1a8;

+        }

+      }

+    }

+    else {

+      if (iVar4 == 5) {

+        local_110 = (uint *)(puVar5 + 4);

+        if ((((*local_110 >> 8 & 1) == 0) && (0x10 < param_5)) &&

+           (puVar2 = puVar5 + 1, local_118 = puVar2, bVar9 = false, (byte)((char)*puVar2 - 3U) < 2))

+        {

+          local_150 = local_150 & 0xffffffff;

+          local_108 = 0;

+          uStack_100 = 0;

+          local_f8 = 0;

+          uStack_f0 = 0;

+          local_e8 = 0;

+          local_e0 = local_e0 & 0xffffffff00000000;

+          lVar16 = IoAllocateMdl(param_4 + 4,param_5 - 0x10,0);

+          local_140 = lVar16;

+          if (lVar16 == 0) {

+            local_174 = -0x3fffff66;

           }

           else {

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

-            (*pcVar2)(0xe);

-            register0x00000020 = (BADSPACEBASE *)auStackX_8;

-          }

-        }

-      }

-    }

-  }

-  if (*(int *)((longlong)register0x00000020 + 0x34) < (int)unaff_RDI) goto LAB_0;

-  *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140045075;

-  cVar5 = IoIs32bitProcess(0);

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

-    if (*(char *)((longlong)register0x00000020 + 0x30) == (char)unaff_RDI) {

-      puVar10 = *(undefined8 **)((longlong)register0x00000020 + 0x48);

-      goto LAB_1;

-    }

-    _Dst = *(void **)((longlong)register0x00000020 + 0x48);

-    if (*(void **)MmUserProbeAddress_exref <= *(void **)((longlong)register0x00000020 + 0x48)) {

-      _Dst = *(void **)MmUserProbeAddress_exref;

-    }

-    *(undefined8 *)((longlong)register0x00000020 + -8) = 0x1400450f0;

-    RtlCopyVolatileMemory(_Dst,(undefined1 *)((longlong)register0x00000020 + 0x130),0x10);

-  }

-  else {

-    if (*(char *)((longlong)register0x00000020 + 0x30) != (char)unaff_RDI) {

-      puVar11 = *(undefined1 **)((longlong)register0x00000020 + 0x48);

-      if (((ulonglong)puVar11 & 3) != 0) {

+            MmProbeAndLockPages(lVar16,param_3,1);

+            if ((*(byte *)(lVar16 + 10) & 5) == 0) {

+              local_e0 = MmMapLockedPagesSpecifyCache(lVar16,0,1);

+            }

+            else {

+              local_e0 = *(ulonglong *)(lVar16 + 0x18);

+            }

+            if (local_e0 == 0) {

+              local_174 = -0x3fffff66;

+              local_170 = false;

+            }

+            else {

+              local_e8 = CONCAT44(local_e8._4_4_,param_5 - 0x10);

+              local_150 = 9;

+              local_148 = &local_108;

+              local_108 = local_108 & 0xffffffff00000000;

+              uStack_100 = 0;

+              local_f8 = local_f8 & 0xffffffff00000000;

+              uStack_f0 = 0;

+              if ((Feature_2611476794__private_featureState & 0x10) == 0) {

+                uVar14 = Feature_2611476794__private_IsEnabledDeviceUsageNoInline();

+                uVar11 = (uint)uVar14;

+              }

+              else {

+                uVar11 = Feature_2611476794__private_featureState & 1;

+              }

+              uVar3 = *puVar5;

+              if (uVar3 != 0xafd1) {

+                if (uVar11 == 0) {

+                  if (((uVar3 != 0x1afd) &&

+                      (((*(byte *)((longlong)puVar5 + 5) & 0x10) == 0 || ((puVar5[3] & 1) == 0))))

+                     && (((*local_110 & 1) == 0 && ((char)*puVar2 != '\x04')))) {

+                    bVar10 = AfdPreventUnbind((longlong)puVar5);

+                  }

+                }

+                else if (((uVar3 != 0x1afd) &&

+                         ((((*(byte *)((longlong)puVar5 + 5) & 0x10) == 0 || ((puVar5[3] & 1) == 0))

+                          && ((char)*puVar2 != '\x04')))) &&

+                        (bVar9 = AfdPreventUnbind((longlong)puVar5), bVar9)) {

+                  bVar10 = true;

+                }

+              }

+              if ((((char)*puVar2 == '\x03') && (bVar10 != false)) || ((char)*puVar2 == '\x04')) {

+                if ((Feature_2056415544__private_featureState & 0x10) == 0) {

+                  uVar14 = Feature_2056415544__private_IsEnabledDeviceUsageNoInline();

+                  uVar11 = (uint)uVar14;

+                }

+                else {

+                  uVar11 = Feature_2056415544__private_featureState & 1;

+                }

+                if (uVar11 == 0) {

+                  uVar14 = AfdIssueDeviceControl

+                                     (*(undefined8 *)(puVar5 + 0xc),&local_150,0x10,

+                                      (longlong)&uStack_70,4,0xc);

+                  local_174 = (int)uVar14;

+                  lVar16 = local_140;

+                }

+                else {

+                  lVar16 = AfdGetAddressFileReference((longlong)puVar5);

+                  if (lVar16 == 0) {

+                    local_174 = -0x3ffffe7c;

+                    lVar16 = local_140;

+                  }

+                  else {

+                    uVar14 = AfdIssueDeviceControl

+                                       (lVar16,&local_150,0x10,(longlong)&uStack_70,4,0xc);

+                    local_174 = (int)uVar14;

+                    ObfDereferenceObject(lVar16);

+                    lVar16 = local_140;

+                  }

+                }

+              }

+              else {

+                local_174 = -0x3ffffe7c;

+              }

+              local_170 = bVar10;

+              if (bVar10 != false) {

+                AfdReallowUnbind((longlong)puVar5);

+              }

+            }

+            MmUnlockPages(lVar16);

+            IoFreeMdl(lVar16);

+          }

+          puVar17 = auStackY_1a8;

+          bVar9 = local_170;

+          if (-1 < local_174) goto LAB_4;

+        }

+        goto LAB_2;

+      }

+      uVar12 = AfdReceiveWindowSize;

+      if (iVar4 != 6) {

+        if (iVar4 != 7) {

+          if (iVar4 == 8) {

+            if ((((char)puVar5[1] == '\x04') && (*puVar5 != 0xafd1)) &&

+               (puVar13 = (undefined2 *)AfdGetConnectionReferenceFromEndpoint(puVar5),

+               puVar13 != (undefined2 *)0x0)) {

+              lVar16 = SUB168(SEXT816(-0x29406b2a1a85bd43) *

+                              SEXT816(_DAT_9 - *(longlong *)(puVar13 + 0x14)),8) +

+                       (_DAT_9 - *(longlong *)(puVar13 + 0x14));

+              uStack_70 = CONCAT44(uStack_70._4_4_,(int)(lVar16 >> 0x17) - (int)(lVar16 >> 0x3f));

+              LOCK();

+              plVar1 = (longlong *)(puVar13 + 0x18);

+              lVar16 = *plVar1;

+              *plVar1 = *plVar1 + -1;

+              UNLOCK();

+              goto joined_r0x000140044f70;

+            }

+            uStack_70 = CONCAT44(uStack_70._4_4_,0xffffffff);

+            puVar17 = auStackY_1a8;

+          }

+          else if (iVar4 == 10) {

+            uStack_70 = *(ulonglong *)(puVar5 + 0xe8);

+            puVar17 = auStackY_1a8;

+          }

+          else {

+            if (iVar4 != 0xe) goto LAB_0;

+            AfdGetDeliveryStatus(puVar5,(undefined1 *)&uStack_70);

+            puVar17 = auStackY_1a8;

+          }

+          goto LAB_4;

+        }

+        uVar12 = AfdSendWindowSize;

+        if ((((*puVar5 & 0xafd2) == 0xafd2) && ((char)puVar5[1] == '\x04')) &&

+           (puVar13 = (undefined2 *)AfdGetConnectionReferenceFromEndpoint(puVar5),

+           uVar12 = AfdSendWindowSize, puVar13 != (undefined2 *)0x0)) {

+          uVar12 = *(undefined4 *)(puVar13 + 0x52);

+          goto LAB_8;

+        }

+      }

+LAB_3:

+      uStack_70 = CONCAT44(uStack_70._4_4_,uVar12);

+      puVar17 = auStackY_1a8;

+    }

+LAB_4:

+    puVar18 = puVar17;

+    if (-1 < *(int *)(puVar18 + 0x34)) {

+      *(undefined8 *)(puVar18 + -8) = 0x140045075;

+      cVar8 = IoIs32bitProcess(0);

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

+        if (puVar18[0x30] == '\0') {

+          puVar15 = *(undefined8 **)(puVar18 + 0x48);

+          goto LAB_10;

+        }

+        _Dst = *(void **)(puVar18 + 0x48);

+        if (*(void **)MmUserProbeAddress_exref <= *(void **)(puVar18 + 0x48)) {

+          _Dst = *(void **)MmUserProbeAddress_exref;

+        }

+        *(undefined8 *)(puVar18 + -8) = 0x1400450f0;

+        RtlCopyVolatileMemory(_Dst,puVar18 + 0x130,0x10);

+      }

+      else {

+        if (puVar18[0x30] != '\0') {

+          puVar17 = *(undefined1 **)(puVar18 + 0x48);

+          if (((ulonglong)puVar17 & 3) != 0) {

                     /* WARNING: Subroutine does not return */

-        *(undefined8 *)((longlong)register0x00000020 + -8) = 0x140045096;

-        ExRaiseDatatypeMisalignment();

-      }

-      if (*(undefined1 **)MmUserProbeAddress_exref <= puVar11) {

-        puVar11 = *(undefined1 **)MmUserProbeAddress_exref;

-      }

-      *puVar11 = *puVar11;

-      puVar11[0xf] = puVar11[0xf];

-    }

-    puVar10 = *(undefined8 **)((longlong)register0x00000020 + 0x70);

+            *(undefined8 *)(puVar18 + -8) = 0x140045096;

+            ExRaiseDatatypeMisalignment();

+          }

+          if (*(undefined1 **)MmUserProbeAddress_exref <= puVar17) {

+            puVar17 = *(undefined1 **)MmUserProbeAddress_exref;

+          }

+          *puVar17 = *puVar17;

+          puVar17[0xf] = puVar17[0xf];

+        }

+        puVar15 = *(undefined8 **)(puVar18 + 0x70);

+LAB_10:

+        uVar7 = *(undefined8 *)(puVar18 + 0x138);

+        *puVar15 = *(undefined8 *)(puVar18 + 0x130);

+        puVar15[1] = uVar7;

+      }

+      **(undefined8 **)(puVar18 + 0x78) = 0x10;

+    }

+  }

+  uVar12 = *(undefined4 *)(puVar18 + 0x34);

+  puVar17 = puVar18;

 LAB_1:

-    uVar3 = *(undefined8 *)((longlong)register0x00000020 + 0x138);

-    *puVar10 = *(undefined8 *)((longlong)register0x00000020 + 0x130);

-    puVar10[1] = uVar3;

-  }

-  **(undefined8 **)((longlong)register0x00000020 + 0x78) = 0x10;

-LAB_0:

-  *(undefined8 *)((longlong)register0x00000020 + -8) = 0x14004513c;

-  return *(undefined4 *)((longlong)register0x00000020 + 0x34);

+  *(undefined8 *)(puVar17 + -8) = 0x14004513c;

+  return uVar12;

 }
```

## `AfdPnpPower`  (modified)

```diff
--- AfdPnpPower
+++ AfdPnpPower
@@ -1,50 +1,77 @@
 

 ulonglong AfdPnpPower(longlong param_1,undefined8 *param_2)

 

 {

-  longlong lVar1;

-  undefined4 uVar2;

-  undefined4 uVar3;

-  undefined4 uVar4;

-  longlong in_RAX;

-  undefined8 uVar5;

-  ulonglong uVar6;

-  undefined8 *in_R8;

+  longlong *plVar1;

+  ushort uVar2;

+  ushort *puVar3;

+  code *pcVar4;

+  undefined1 uVar5;

+  bool bVar6;

+  uint uVar7;

+  undefined2 *puVar8;

+  ulonglong uVar9;

+  longlong lVar10;

   

-  uVar6 = (ulonglong)param_2 & 0xffffffff;

-  if ((*(uint *)(*(longlong *)(in_RAX + 0x18) + 8) >> 8 & 1) == 0) {

-    uVar5 = in_R8[1];

-    lVar1 = param_2[0x17];

-    *(undefined8 *)(lVar1 + -0x48) = *in_R8;

-    *(undefined8 *)(lVar1 + -0x40) = uVar5;

-    uVar5 = in_R8[3];

-    *(undefined8 *)(lVar1 + -0x38) = in_R8[2];

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

-    uVar5 = in_R8[5];

-    *(undefined8 *)(lVar1 + -0x28) = in_R8[4];

-    *(undefined8 *)(lVar1 + -0x20) = uVar5;

-    uVar2 = *(undefined4 *)((longlong)in_R8 + 0x34);

-    uVar3 = *(undefined4 *)(in_R8 + 7);

-    uVar4 = *(undefined4 *)((longlong)in_R8 + 0x3c);

-    *(undefined4 *)(lVar1 + -0x18) = *(undefined4 *)(in_R8 + 6);

-    *(undefined4 *)(lVar1 + -0x14) = uVar2;

-    *(undefined4 *)(lVar1 + -0x10) = uVar3;

-    *(undefined4 *)(lVar1 + -0xc) = uVar4;

-    *(undefined8 *)(lVar1 + -8) = in_R8[8];

-    ObfReferenceObject();

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

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

-    *(code **)(lVar1 + -0x10) = AfdRestartQueryDeviceRelation;

-    *(longlong *)(lVar1 + -8) = param_1;

-    *(undefined1 *)(lVar1 + -0x45) = 0xe0;

-    uVar5 = IoGetRelatedDeviceObject(param_1);

-    uVar6 = IofCallDriver(uVar5,uVar6);

+  if ((*(char *)((longlong)param_2 + 1) != '\a') || (*(int *)(param_2 + 1) != 4))

+  goto LAB_0;

+  puVar3 = *(ushort **)(param_2[6] + 0x18);

+  uVar2 = *puVar3;

+  if (uVar2 != 0xafd1) {

+    if (uVar2 != 0xafd2) {

+      if (uVar2 == 0xafd4) goto LAB_1;

+      if (uVar2 != 0xafd6) goto LAB_0;

+    }

+    puVar8 = (undefined2 *)AfdGetConnectionReferenceFromEndpoint(puVar3);

+    if (puVar8 != (undefined2 *)0x0) {

+      uVar9 = AfdPassQueryDeviceRelation(*(undefined8 *)(puVar8 + 8),param_1,param_2);

+      uVar9 = uVar9 & 0xffffffff;

+      LOCK();

+      plVar1 = (longlong *)(puVar8 + 0x18);

+      lVar10 = *plVar1;

+      *plVar1 = *plVar1 + -1;

+      UNLOCK();

+      if (1 < lVar10) {

+        return uVar9;

+      }

+      if (lVar10 != 1) {

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

+        (*pcVar4)(0xe);

+        return uVar9;

+      }

+      AfdCloseConnection(puVar8);

+      return uVar9;

+    }

   }

-  else {

-    *(undefined4 *)(param_2 + 6) = 0xc0000010;

-    IofCompleteRequest(uVar6,AfdPriorityBoost);

-    uVar6 = 0xc0000010;

+LAB_1:

+  if (((byte)((char)puVar3[1] - 3U) < 2) && (bVar6 = AfdPreventUnbind((longlong)puVar3), bVar6)) {

+    if ((byte)((char)puVar3[1] - 3U) < 2) {

+      if ((Feature_2056415544__private_featureState & 0x10) == 0) {

+        uVar9 = Feature_2056415544__private_IsEnabledDeviceUsageNoInline();

+        uVar7 = (uint)uVar9;

+      }

+      else {

+        uVar7 = Feature_2056415544__private_featureState & 1;

+      }

+      if (uVar7 == 0) {

+        uVar9 = AfdPassQueryDeviceRelation(*(undefined8 *)(puVar3 + 0xc),param_1,param_2);

+LAB_2:

+        AfdReallowUnbind((longlong)puVar3);

+        return uVar9 & 0xffffffff;

+      }

+      lVar10 = AfdGetAddressFileReference((longlong)puVar3);

+      if (lVar10 != 0) {

+        uVar9 = AfdPassQueryDeviceRelation(lVar10,param_1,param_2);

+        ObfDereferenceObject(lVar10);

+        goto LAB_2;

+      }

+    }

+    AfdReallowUnbind((longlong)puVar3);

   }

-  return uVar6;

+LAB_0:

+  uVar5 = AfdPriorityBoost;

+  *(undefined4 *)(param_1 + 0x30) = 0xc0000010;

+  IofCompleteRequest(param_1,uVar5);

+  return 0xc0000010;

 }
```

## `AfdGetAddress`  (modified)

```diff
--- AfdGetAddress
+++ AfdGetAddress
@@ -1,18 +1,352 @@
 

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

 

 int AfdGetAddress(ulonglong param_1,longlong param_2)

 

 {

-  int iVar1;

-  longlong unaff_RBP;

-  bool in_ZF;

+  longlong *plVar1;

+  longlong lVar2;

+  ushort uVar3;

+  ushort *puVar4;

+  code *pcVar5;

+  bool bVar6;

+  char cVar7;

+  int iVar8;

+  uint uVar9;

+  longlong lVar10;

+  undefined2 *puVar11;

+  ulonglong uVar12;

+  undefined8 uVar13;

+  undefined1 *puVar14;

+  bool bVar15;

+  undefined1 auStack_118 [8];

+  undefined1 auStack_110 [24];

+  ulonglong local_f8;

+  undefined4 local_f0;

+  int local_e8;

+  undefined1 local_e4;

+  ushort *local_e0;

+  ulonglong local_d8;

+  longlong local_d0;

+  undefined8 local_c8;

+  undefined8 uStack_c0;

+  undefined8 local_b8;

+  code *local_a8;

+  ulonglong local_a0;

+  undefined4 local_98;

+  undefined4 local_94;

+  undefined4 local_90;

+  undefined8 local_78;

+  ulonglong local_70;

+  undefined4 local_58;

+  undefined2 uStack_54;

+  undefined2 uStack_52;

+  undefined4 uStack_50;

+  undefined4 uStack_4c;

+  undefined4 uStack_48;

+  undefined4 uStack_44;

+  undefined4 uStack_40;

+  undefined2 local_3c;

+  ulonglong local_38;

   

-  if (((!in_ZF) || (Microsoft_Windows_Networking_CorrelationEnabled != 0)) &&

-     (Microsoft_Windows_Networking_CorrelationEnabled != 0)) {

-    EtwEx_tidActivityInfo(param_1,&ActivityStop,unaff_RBP + 0x1f);

+  puVar14 = auStack_118;

+  local_38 = __security_cookie ^ (ulonglong)auStack_118;

+  bVar6 = false;

+  local_e4 = 0;

+  local_e8 = 0;

+  puVar4 = *(ushort **)(*(longlong *)(param_2 + 0x30) + 0x18);

+  local_e0 = puVar4;

+  local_d8 = param_1;

+  if ((byte)((char)puVar4[1] - 3U) < 2) {

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

+    *(undefined4 *)(param_1 + 0x30) = 0;

+    uVar9 = *(uint *)(param_2 + 8);

+    if ((*(uint *)(puVar4 + 4) & 0x100) == 0) {

+      bVar15 = uVar9 < 0xc;

+    }

+    else {

+      bVar15 = uVar9 < 2;

+    }

+    if (bVar15) goto LAB_0;

+    local_f8 = param_1;

+    lVar10 = IoAllocateMdl(*(undefined8 *)(param_1 + 0x70),uVar9,0);

+    if (lVar10 == 0) {

+      local_e8 = 0xc000009a;

+      iVar8 = -0x3fffff66;

+    }

+    else {

+      MmProbeAndLockPages(*(undefined8 *)(param_1 + 8),*(undefined1 *)(param_1 + 0x40),1);

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

+      if ((*(byte *)(lVar10 + 10) & 5) == 0) {

+        local_f0 = 0x40000020;

+        local_f8 = local_f8 & 0xffffffff00000000;

+        local_d0 = MmMapLockedPagesSpecifyCache(lVar10,0,1);

+      }

+      else {

+        local_d0 = *(longlong *)(lVar10 + 0x18);

+      }

+      if (local_d0 != 0) {

+        if ((*(uint *)(puVar4 + 4) & 0x100) == 0) {

+          if ((Feature_2611476794__private_featureState & 0x10) == 0) {

+            uVar12 = Feature_2611476794__private_IsEnabledDeviceUsageNoInline();

+            uVar9 = (uint)uVar12;

+          }

+          else {

+            uVar9 = Feature_2611476794__private_featureState & 1;

+          }

+          uVar3 = *puVar4;

+          if (uVar3 != 0xafd1) {

+            if (uVar9 == 0) {

+              if ((uVar3 != 0x1afd) &&

+                 (((*(byte *)((longlong)puVar4 + 5) & 0x10) == 0 || ((puVar4[3] & 1) == 0)))) {

+                bVar15 = (*(uint *)(puVar4 + 4) & 1) == 0;

+LAB_1:

+                if (bVar15) goto LAB_2;

+              }

+            }

+            else if (uVar3 != 0x1afd) {

+              if ((*(byte *)((longlong)puVar4 + 5) & 0x10) != 0) {

+                bVar15 = (puVar4[3] & 1) == 0;

+                goto LAB_1;

+              }

+LAB_2:

+              if ((char)puVar4[1] != '\x04') {

+                bVar15 = AfdPreventUnbind((longlong)puVar4);

+                if (!bVar15) goto LAB_3;

+                bVar6 = true;

+              }

+            }

+          }

+          cVar7 = (char)puVar4[1];

+          if ((cVar7 == '\x01') || (cVar7 == '\x06')) {

+LAB_3:

+            iVar8 = -0x3ffffe7c;

+            goto LAB_4;

+          }

+          if ((((*(short *)(*(longlong *)(puVar4 + 0x78) + 6) == 0x11) || (*puVar4 != 0xafd2)) ||

+              (cVar7 != '\x04')) ||

+             (puVar11 = (undefined2 *)AfdGetConnectionReferenceFromEndpoint(puVar4),

+             puVar11 == (undefined2 *)0x0)) {

+            if (*puVar4 == 0xafd1) {

+              if ((((*(uint *)(puVar4 + 4) & 0x100) == 0) && ((*(uint *)(puVar4 + 8) & 0x8000) == 0)

+                  ) && ((char)puVar4[1] == '\x04')) {

+                lVar10 = *(longlong *)(puVar4 + 0x78);

+                local_e0 = (ushort *)((ulonglong)local_e0 & 0xffffffff00000000);

+                local_c8 = 0;

+                uStack_c0 = 0;

+                local_b8 = 0;

+                KeAcquireInStackQueuedSpinLock(puVar4 + 0x1c,&local_c8);

+                lVar2 = *(longlong *)(puVar4 + 0x54);

+                if (((lVar2 != 0) && (*(short *)(lVar2 + 6) == 0x17)) &&

+                   (*(short *)(lVar2 + 4) == 0x1a)) {

+                  local_58 = 0x17001a;

+                  uStack_50 = *(undefined4 *)(lVar2 + 0xc);

+                  uStack_4c = *(undefined4 *)(lVar2 + 0x10);

+                  uStack_48 = *(undefined4 *)(lVar2 + 0x14);

+                  uStack_54 = (undefined2)*(undefined4 *)(lVar2 + 8);

+                  uStack_52 = (undefined2)((uint)*(undefined4 *)(lVar2 + 8) >> 0x10);

+                  uStack_44 = (undefined4)*(undefined8 *)(lVar2 + 0x18);

+                  uStack_40 = (undefined4)((ulonglong)*(undefined8 *)(lVar2 + 0x18) >> 0x20);

+                  local_3c = *(undefined2 *)(lVar2 + 0x20);

+                  KeReleaseInStackQueuedSpinLock(&local_c8);

+                  iVar8 = AfdQueryCompartmentId(puVar4,(int *)&local_e0);

+                  if (-1 < iVar8) {

+                    uVar12 = AfdTcp6RoutingQuery((ushort *)&local_58,(undefined2 *)&local_58,

+                                                 local_e0._0_4_);

+                    iVar8 = (int)uVar12;

+                    uStack_54 = *(undefined2 *)(lVar10 + 8);

+                    if (iVar8 < 0) {

+                      if ((DAT_5 & 0x20) != 0) {

+                        WPP_SF_D(0x405,0x1a,&WPP_f90fa5e83ebe3a20c2ccc7b03bb2dc97_Traceguids,iVar8);

+                      }

+                    }

+                    else {

+                      if (*(uint *)(param_2 + 8) < 0x26) {

+                        if ((DAT_5 & 0x20) != 0) {

+                          WPP_SF_(0x405,0x19,&WPP_f90fa5e83ebe3a20c2ccc7b03bb2dc97_Traceguids);

+                        }

+                        goto LAB_0;

+                      }

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

+                      if ((*(byte *)(lVar10 + 10) & 5) == 0) {

+                        lVar10 = MmMapLockedPages(lVar10,0);

+                      }

+                      else {

+                        lVar10 = *(longlong *)(lVar10 + 0x18);

+                      }

+                      *(undefined4 *)(lVar10 + 4) = 1;

+                      *(ulonglong *)(lVar10 + 8) = CONCAT26(uStack_52,CONCAT24(uStack_54,local_58));

+                      *(ulonglong *)(lVar10 + 0x10) = CONCAT44(uStack_4c,uStack_50);

+                      *(ulonglong *)(lVar10 + 0x18) = CONCAT44(uStack_44,uStack_48);

+                      *(undefined4 *)(lVar10 + 0x20) = uStack_40;

+                      *(undefined2 *)(lVar10 + 0x24) = local_3c;

+                    }

+                  }

+                  goto LAB_4;

+                }

+                KeReleaseInStackQueuedSpinLock(&local_c8);

+              }

+              if (((*puVar4 != 0xafd1) || ((*(uint *)(puVar4 + 4) >> 0x16 & 1) == 0)) ||

+                 ((((*(uint *)(puVar4 + 4) >> 8 & 1) == 0 && ((*(uint *)(puVar4 + 8) & 0x8000) == 0)

+                   ) || ((*(uint *)(puVar4 + 0x58) & 0x20) == 0)))) goto LAB_6;

+              lVar10 = *(longlong *)(*(longlong *)(puVar4 + 0x8c) + 8);

+              ObfReferenceObject(lVar10);

+            }

+            else {

+LAB_6:

+              lVar10 = AfdGetAddressFileReference((longlong)puVar4);

+              if (lVar10 == 0) goto LAB_0;

+              if ((Feature_2056415544__private_featureState & 0x10) == 0) {

+                uVar12 = Feature_2056415544__private_IsEnabledDeviceUsageNoInline();

+                uVar9 = (uint)uVar12;

+              }

+              else {

+                uVar9 = Feature_2056415544__private_featureState & 1;

+              }

+              if (uVar9 == 0) {

+                lVar10 = *(longlong *)(puVar4 + 0xc);

+              }

+            }

+            uVar13 = IoGetRelatedDeviceObject(lVar10);

+          }

+          else {

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

+            uVar13 = *(undefined8 *)(puVar11 + 0xc);

+            ObfReferenceObject();

+            LOCK();

+            plVar1 = (longlong *)(puVar11 + 0x18);

+            lVar2 = *plVar1;

+            *plVar1 = *plVar1 + -1;

+            UNLOCK();

+            puVar14 = auStack_118;

+            if (lVar2 < 2) {

+              if (lVar2 == 1) {

+                AfdCloseConnection(puVar11);

+                puVar14 = auStack_118;

+              }

+              else {

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

+                (*pcVar5)(0xe);

+                puVar14 = auStack_110;

+              }

+            }

+          }

+          lVar2 = *(longlong *)(param_1 + 0xb8);

+          *(code **)(lVar2 + -0x10) = AfdRestartGetAddress;

+          *(longlong *)(lVar2 + -8) = lVar10;

+          *(undefined1 *)(lVar2 + -0x45) = 0xe0;

+          lVar2 = *(longlong *)(param_1 + 0xb8);

+          *(undefined2 *)(lVar2 + -0x48) = 0xc0f;

+          *(undefined8 *)(lVar2 + -0x20) = uVar13;

+          *(longlong *)(lVar2 + -0x18) = lVar10;

+          *(undefined4 *)(lVar2 + -0x40) = 3;

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

+          LOCK();

+          *(int *)(puVar4 + 0x7c) = *(int *)(puVar4 + 0x7c) + 1;

+          UNLOCK();

+          *(undefined8 *)(puVar14 + -8) = 0x140041013;

+          iVar8 = IofCallDriver(uVar13,param_1);

+          if (bVar6) {

+            *(undefined8 *)(puVar14 + -8) = 0x140041027;

+            AfdReallowUnbind((longlong)puVar4);

+          }

+          goto LAB_7;

+        }

+        memset(&local_a8,0,0x50);

+        local_a8 = AfdTLGetAddressComplete;

+        local_98 = 0;

+        local_94 = 0xfffd;

+        local_90 = 0x10;

+        local_78 = *(undefined8 *)(*(longlong *)(param_1 + 8) + 0x18);

+        local_70 = (ulonglong)*(uint *)(*(longlong *)(param_1 + 8) + 0x28);

+        local_a0 = param_1;

+        if (((*puVar4 == 0xafd2) && ((char)puVar4[1] == '\x04')) &&

+           (puVar11 = (undefined2 *)AfdGetConnectionReferenceFromEndpoint(puVar4),

+           puVar11 != (undefined2 *)0x0)) {

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

+          iVar8 = AfdTLIoControl(*(undefined **)(*(longlong *)(puVar11 + 0xc) + 8),

+                                 *(undefined8 *)(puVar11 + 8),(longlong *)&local_a8,0);

+          local_e8 = iVar8;

+          LOCK();

+          plVar1 = (longlong *)(puVar11 + 0x18);

+          lVar10 = *plVar1;

+          *plVar1 = *plVar1 + -1;

+          UNLOCK();

+          puVar14 = auStack_118;

+          if (lVar10 < 2) {

+            if (lVar10 == 1) {

+              AfdCloseConnection(puVar11);

+              puVar14 = auStack_118;

+            }

+            else {

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

+              (*pcVar5)(0xe);

+              puVar14 = auStack_110;

+            }

+          }

+        }

+        else {

+          if ((((*puVar4 != 0xafd1) && (*puVar4 != 0x1afd)) &&

+              (((*(byte *)((longlong)puVar4 + 5) & 0x10) == 0 || ((puVar4[3] & 1) == 0)))) &&

+             (((*(uint *)(puVar4 + 4) & 1) == 0 && ((char)puVar4[1] != '\x04')))) {

+            bVar15 = AfdPreventUnbind((longlong)puVar4);

+            if (!bVar15) goto LAB_3;

+            bVar6 = true;

+          }

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

+          LOCK();

+          *(longlong *)(puVar4 + 0x84) = *(longlong *)(puVar4 + 0x84) + 1;

+          UNLOCK();

+          iVar8 = AfdTLIoControl(*(undefined **)(*(longlong *)(puVar4 + 0xc) + 8),

+                                 *(undefined8 *)(puVar4 + 8),(longlong *)&local_a8,(longlong)puVar4)

+          ;

+          local_e8 = iVar8;

+          LOCK();

+          *(longlong *)(puVar4 + 0x84) = *(longlong *)(puVar4 + 0x84) + -1;

+          UNLOCK();

+          puVar14 = auStack_118;

+          if (bVar6) {

+            AfdReallowUnbind((longlong)puVar4);

+            puVar14 = auStack_118;

+          }

+        }

+        if (iVar8 == 0x103) {

+          *(undefined8 *)(puVar14 + -8) = 0x140040c42;

+          cVar7 = AfdTLPendRequest(param_1,*(undefined8 *)(puVar14 + 0xb0),'\x01');

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

+        }

+        else {

+LAB_8:

+          *(undefined8 *)(puVar14 + -8) = 0x140040c56;

+          IofCompleteRequest(param_1,AfdPriorityBoost);

+        }

+        iVar8 = *(int *)(puVar14 + 0x30);

+        goto LAB_7;

+      }

+      local_e8 = 0xc000009a;

+      iVar8 = -0x3fffff66;

+    }

   }

-  iVar1 = IofCompleteRequest();

-  return iVar1;

+  else {

+LAB_0:

+    iVar8 = -0x3ffffff3;

+  }

+LAB_4:

+  if (bVar6) {

+    AfdReallowUnbind((longlong)puVar4);

+  }

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

+    if ((*(byte *)(*(longlong *)(param_1 + 8) + 10) & 2) != 0) {

+      MmUnlockPages();

+    }

+    IoFreeMdl(*(undefined8 *)(param_1 + 8));

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

+  }

+  *(int *)(param_1 + 0x30) = iVar8;

+  IofCompleteRequest(param_1,AfdPriorityBoost);

+  puVar14 = auStack_118;

+LAB_7:

+  *(undefined8 *)(puVar14 + -8) = 0x1400410a4;

+  return iVar8;

 }
```

## `NTOSKRNL.EXE::ObfDereferenceObject`  (modified)

```diff
--- NTOSKRNL.EXE::ObfDereferenceObject calling
+++ NTOSKRNL.EXE::ObfDereferenceObject calling
@@ -23,0 +24 @@
+AfdGetInformation
@@ -29,0 +31 @@
+AfdPnpPower
@@ -32,0 +35 @@
+AfdQueryHandles
```

## `NTOSKRNL.EXE::ExAllocatePool3`  (modified)

```diff
--- NTOSKRNL.EXE::ExAllocatePool3 calling
+++ NTOSKRNL.EXE::ExAllocatePool3 calling
@@ -5,0 +6 @@
+Tkey_RecordRead_New
```
