# CVE-2020-0607 — win32kbase.sys patch diff

`win32kbase.sys` 10.0.18362.535 -> 10.0.18362.592 (ghidriff).

## `RIMAddInjectionDeviceOfType`  (modified)

```diff
--- RIMAddInjectionDeviceOfType
+++ RIMAddNonPnpDeviceOfTypeUsingSuppliedFileHandle
@@ -1,204 +1,140 @@
 

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

-

-int RIMAddInjectionDeviceOfType

-              (undefined8 param_1,uint *param_2,undefined4 param_3,undefined8 *param_4,int param_5,

+int RIMAddNonPnpDeviceOfTypeUsingSuppliedFileHandle

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

               undefined8 *param_6)

 

 {

-  int iVar1;

-  uint uVar2;

-  longlong lVar3;

-  ulonglong uVar4;

-  undefined8 uVar5;

-  undefined1 auStack_178 [32];

-  undefined *local_158;

-  undefined8 *local_150;

-  undefined8 **local_148;

-  int local_138;

-  undefined4 local_134;

-  longlong local_130;

-  undefined8 *local_128;

-  undefined4 local_120;

-  undefined4 local_118;

-  uint *local_110;

-  undefined8 local_108;

-  longlong local_100;

-  ulonglong local_f8;

-  ulonglong local_f0;

-  undefined8 *local_e8;

-  undefined8 local_d8;

-  ulonglong 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;

-  undefined4 uStack_68;

-  undefined4 uStack_64;

-  undefined4 uStack_60;

-  undefined4 uStack_5c;

-  undefined8 uStack_58;

-  undefined8 uStack_50;

-  ulonglong local_48;

+  uint *puVar1;

+  int iVar2;

+  uint uVar3;

+  longlong lVar4;

+  ulonglong uVar5;

+  undefined8 uVar6;

+  undefined *in_stack_ffffffffffffff78;

+  undefined8 in_stack_ffffffffffffff80;

+  undefined4 uVar7;

+  ushort uStack_62;

+  longlong local_60;

+  uint *local_58;

+  undefined8 *local_50;

+  undefined8 local_48;

+  longlong local_40;

+  ulonglong local_38;

+  ulonglong local_30;

   

-                    /* 0x138a00  1827  RIMAddInjectionDeviceOfType */

-  local_48 = __security_cookie ^ (ulonglong)auStack_178;

-  local_e8 = param_6;

-  local_134 = param_3;

-  local_118 = param_3;

-  memset(&local_d8,0,0x90);

+                    /* 0x139390  1831  RIMAddNonPnpDeviceOfTypeUsingSuppliedFileHandle */

+  uVar7 = (undefined4)((ulonglong)in_stack_ffffffffffffff80 >> 0x20);

   if ((undefined **)WPP_RECORDER_INITIALIZED != &WPP_RECORDER_INITIALIZED) {

-    local_158 = &WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids;

-    WPP_RECORDER_SF_(gRimLog,4,1);

+    in_stack_ffffffffffffff78 = &WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids;

+    WPP_RECORDER_SF_(gRimLog,4,1,0x22,&WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids);

   }

-  if (param_4 == (undefined8 *)0x0) {

+  if (param_4 == 0) {

     if ((undefined **)WPP_RECORDER_INITIALIZED != &WPP_RECORDER_INITIALIZED) {

-      local_158 = &WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids;

-      WPP_RECORDER_SF_(gRimLog,3,1,0x28);

+      WPP_RECORDER_SF_D(gRimLog,4,1,0x23,&WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids,0xc000000d

+                       );

     }

     return -0x3ffffff3;

   }

-  iVar1 = RawInputManagerObjectResolveHandle(param_1,3,0,&local_130);

-  lVar3 = local_130;

-  local_138 = iVar1;

-  if (iVar1 < 0) goto LAB_0;

-  CInpPushLock::LockExclusive((CInpPushLock *)(local_130 + 0x68));

-  if ((*(char *)(lVar3 + 0x51) == '\0') && (*(char *)(lVar3 + 0x52) == '\0')) {

-    uVar2 = DeviceTypeToRimInputType(local_134);

-    if ((*(uint *)(lVar3 + 0x54) & uVar2) == 0) {

-      iVar1 = -0x3fffff45;

+  iVar2 = RawInputManagerObjectResolveHandle(param_1,3,1,&local_60);

+  lVar4 = local_60;

+  if (iVar2 < 0) goto LAB_0;

+  CInpPushLock::LockExclusive((CInpPushLock *)(local_60 + 0x68));

+  if ((*(char *)(lVar4 + 0x51) == '\0') && (*(char *)(lVar4 + 0x52) == '\0')) {

+    uVar3 = DeviceTypeToRimInputType(param_3);

+    if ((*(uint *)(lVar4 + 0x54) & uVar3) == 0) {

+      iVar2 = -0x3fffff45;

       if ((undefined **)WPP_RECORDER_INITIALIZED != &WPP_RECORDER_INITIALIZED) {

-        uVar5 = 0x29;

+        uVar6 = 0x24;

         goto LAB_1;

       }

     }

     else {

-      local_f8 = 0;

-      local_f0 = 0;

-      local_110 = (uint *)0x0;

-      local_108 = 0;

-      local_100 = 0;

-      if (param_5 == 0) {

-        local_d8 = *param_4;

-        uStack_d0 = param_4[1];

-        local_c8 = param_4[2];

-        uStack_c0 = param_4[3];

-        local_b8 = param_4[4];

-        uStack_b0 = param_4[5];

-        local_a8 = param_4[6];

-        uStack_a0 = param_4[7];

-        local_98 = param_4[8];

-        uStack_90 = param_4[9];

-        local_88 = param_4[10];

-        uStack_80 = param_4[0xb];

-        local_78 = param_4[0xc];

-        uStack_70 = param_4[0xd];

-        uStack_68 = *(undefined4 *)(param_4 + 0xe);

-        uStack_64 = *(undefined4 *)((longlong)param_4 + 0x74);

-        uStack_60 = *(undefined4 *)(param_4 + 0xf);

-        uStack_5c = *(undefined4 *)((longlong)param_4 + 0x7c);

-        uStack_58 = param_4[0x10];

-        uStack_50 = param_4[0x11];

-        local_110 = param_2;

-      }

-      else {

+      local_38 = 0;

+      local_30 = 0;

+      local_58 = (uint *)0x0;

+      local_48 = 0;

+      local_40 = 0;

+      puVar1 = param_2;

+      if (param_5 != 0) {

         if (*(uint **)MmUserProbeAddress_exref <= param_2) {

           param_2 = *(uint **)MmUserProbeAddress_exref;

         }

-        uVar2 = *param_2;

-        local_f8 = (ulonglong)uVar2;

-        local_f0 = *(ulonglong *)(param_2 + 2);

-        local_120 = uVar2;

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

+        uVar3 = *param_2;

+        local_38 = (ulonglong)uVar3;

+        local_30 = *(ulonglong *)(param_2 + 2);

+        if ((local_30 & 1) != 0) {

                     /* WARNING: Subroutine does not return */

           ExRaiseDatatypeMisalignment();

         }

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

-          uVar4 = local_f0 + 2 + ((ulonglong)uVar2 & 0xffff);

-          if (((*(ulonglong *)MmUserProbeAddress_exref <= uVar4) ||

-              (local_120._2_2_ = (ushort)(uVar2 >> 0x10), local_120._2_2_ < (ushort)uVar2)) ||

-             (uVar4 <= local_f0)) {

+        if ((uVar3 & 1) == 0) {

+          uVar5 = local_30 + 2 + ((ulonglong)uVar3 & 0xffff);

+          if (((*(ulonglong *)MmUserProbeAddress_exref <= uVar5) ||

+              (uStack_62 = (ushort)(uVar3 >> 0x10), uStack_62 < (ushort)uVar3)) ||

+             (uVar5 <= local_30)) {

             **(undefined1 **)MmUserProbeAddress_exref = 0;

           }

         }

         else {

           MicrosoftTelemetryAssertTriggeredNoArgsKM();

         }

-        local_108 = CONCAT62(CONCAT42(local_108._4_4_,(undefined2)local_f8),(undefined2)local_f8);

-        local_100 = Win32AllocPool(local_f8 & 0xffff,0x706d7452);

-        if (local_100 == 0) {

-          local_138 = -0x3fffffe9;

-          lVar3 = local_130;

-          iVar1 = local_138;

+        local_48 = CONCAT62(CONCAT42(local_48._4_4_,(undefined2)local_38),(undefined2)local_38);

+        local_40 = Win32AllocPool(local_38 & 0xffff,0x706d7452);

+        if (local_40 == 0) {

+          iVar2 = -0x3fffffe9;

+          lVar4 = local_60;

+          puVar1 = local_58;

         }

         else {

-          RtlCopyUnicodeString(&local_108,&local_f8);

-          local_110 = (uint *)&local_108;

-          lVar3 = local_130;

-          iVar1 = local_138;

+          RtlCopyUnicodeString(&local_48,&local_38);

+          lVar4 = local_60;

+          puVar1 = (uint *)&local_48;

         }

       }

-      if (-1 < iVar1) {

-        local_148 = &local_128;

-        local_150 = &local_d8;

-        local_158 = (undefined *)CONCAT44(local_158._4_4_,1);

-        iVar1 = RIMCreateDev(lVar3,local_134,local_110,0);

-        local_138 = iVar1;

-        if (-1 < iVar1) {

-          if (param_5 == 0) {

-            if ((uStack_d0 & 0x400000000) == 0) {

-              uVar5 = local_128[2];

+      local_58 = puVar1;

+      if (-1 < iVar2) {

+        uVar7 = 0;

+        iVar2 = RIMCreateDev(lVar4,param_3,local_58,1,

+                             (ulonglong)in_stack_ffffffffffffff78 & 0xffffffff00000000,0,&local_50);

+        if (-1 < iVar2) {

+          *(uint *)(local_50 + 0x17) = *(uint *)(local_50 + 0x17) | 1;

+          iVar2 = rimOnPnpArrived(lVar4,local_50,param_4);

+          if ((-1 < iVar2) && (rimDoRimDevChange(lVar4,local_50,2), param_6 != (undefined8 *)0x0)) {

+            if (param_5 == 0) {

+              *param_6 = local_50[2];

             }

             else {

-              uVar5 = local_128[3];

+              if (*(undefined8 **)MmUserProbeAddress_exref <= param_6) {

+                param_6 = *(undefined8 **)MmUserProbeAddress_exref;

+              }

+              *param_6 = local_50[2];

             }

-            *param_6 = uVar5;

           }

-          else {

-            if (*(undefined8 **)MmUserProbeAddress_exref <= param_6) {

-              param_6 = *(undefined8 **)MmUserProbeAddress_exref;

-            }

-            *param_6 = local_128[2];

-          }

-          if (iVar1 < 0) {

-            RIMFreeDev(lVar3,local_128);

-          }

-          else if ((*(longlong *)(lVar3 + 0x280) != 0) || (*(int *)(lVar3 + 0x360) != 0)) {

-            *(uint *)(local_128 + 0x17) = *(uint *)(local_128 + 0x17) | 0x20000;

+          if (iVar2 < 0) {

+            RIMFreeDev(lVar4,local_50);

           }

         }

       }

-      if (local_100 != 0) {

-        Win32FreePool(local_100);

+      if (local_40 != 0) {

+        Win32FreePool(local_40);

       }

     }

   }

   else {

-    iVar1 = -0x3fffff45;

+    iVar2 = -0x3fffff45;

     if ((undefined **)WPP_RECORDER_INITIALIZED != &WPP_RECORDER_INITIALIZED) {

-      uVar5 = 0x2a;

+      uVar6 = 0x25;

 LAB_1:

-      iVar1 = -0x3fffff45;

-      local_158 = &WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids;

-      WPP_RECORDER_SF_(gRimLog,3,1,uVar5);

+      iVar2 = -0x3fffff45;

+      WPP_RECORDER_SF_(gRimLog,3,1,uVar6,&WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids);

     }

   }

-  CInpPushLock::UnLockExclusive((CInpPushLock *)(lVar3 + 0x68));

-  ObfDereferenceObject(lVar3);

+  CInpPushLock::UnLockExclusive((CInpPushLock *)(lVar4 + 0x68));

+  ObfDereferenceObject(lVar4);

 LAB_0:

   if ((undefined **)WPP_RECORDER_INITIALIZED != &WPP_RECORDER_INITIALIZED) {

-    local_150 = (undefined8 *)CONCAT44(local_150._4_4_,iVar1);

-    local_158 = &WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids;

-    WPP_RECORDER_SF_D(gRimLog,4,1);

+    WPP_RECORDER_SF_D(gRimLog,4,1,0x26,&WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids,

+                      CONCAT44(uVar7,iVar2));

   }

-  return iVar1;

+  return iVar2;

 }
```

## `RIMAddNonPnpDeviceOfType`  (modified)

```diff
--- RIMAddNonPnpDeviceOfType
+++ RIMAddNonPnpDeviceOfType
@@ -1,98 +1,132 @@
 

-int RIMAddNonPnpDeviceOfType(void)

+int RIMAddNonPnpDeviceOfType

+              (undefined8 param_1,uint *param_2,undefined4 param_3,int param_4,undefined8 *param_5)

 

 {

   uint *puVar1;

-  undefined8 *puVar2;

-  int unaff_EBX;

-  longlong unaff_RDI;

-  ulonglong uVar3;

-  undefined *unaff_R12;

-  int unaff_R13D;

-  uint *unaff_R14;

-  ulonglong in_stack_00000020;

-  int in_stack_00000040;

-  ushort uStack0000000000000046;

-  longlong in_stack_00000048;

-  uint *in_stack_00000050;

-  longlong in_stack_00000058;

-  undefined2 uStack0000000000000060;

-  undefined2 uStack0000000000000062;

-  longlong in_stack_00000068;

-  undefined2 uStack0000000000000070;

-  ulonglong in_stack_00000078;

-  undefined4 in_stack_000000c0;

-  undefined8 *in_stack_000000d0;

+  int iVar2;

+  uint uVar3;

+  longlong lVar4;

+  ulonglong uVar5;

+  undefined8 uVar6;

+  undefined *in_stack_ffffffffffffff78;

+  undefined8 in_stack_ffffffffffffff80;

+  undefined4 uVar7;

+  ushort uStack_62;

+  longlong local_60;

+  uint *local_58;

+  undefined8 *local_50;

+  undefined8 local_48;

+  longlong local_40;

+  ulonglong local_38;

+  ulonglong local_30;

   

-  puVar1 = unaff_R14;

-  if (unaff_R13D != 0) {

-    if (*(uint **)MmUserProbeAddress_exref <= unaff_R14) {

-      unaff_R14 = *(uint **)MmUserProbeAddress_exref;

-    }

-    _uStack0000000000000070 = *unaff_R14;

-    in_stack_00000078 = *(ulonglong *)(unaff_R14 + 2);

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

-                    /* WARNING: Subroutine does not return */

-      ExRaiseDatatypeMisalignment();

-    }

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

-      uVar3 = in_stack_00000078 + 2 + ((ulonglong)_uStack0000000000000070 & 0xffff);

-      if (((*(ulonglong *)MmUserProbeAddress_exref <= uVar3) ||

-          (uStack0000000000000046 = (ushort)(_uStack0000000000000070 >> 0x10),

-          uStack0000000000000046 < (ushort)_uStack0000000000000070)) || (uVar3 <= in_stack_00000078)

-         ) {

-        **(undefined1 **)MmUserProbeAddress_exref = 0;

+                    /* 0x139040  1830  RIMAddNonPnpDeviceOfType */

+  uVar7 = (undefined4)((ulonglong)in_stack_ffffffffffffff80 >> 0x20);

+  if ((undefined **)WPP_RECORDER_INITIALIZED != &WPP_RECORDER_INITIALIZED) {

+    in_stack_ffffffffffffff78 = &WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids;

+    WPP_RECORDER_SF_(gRimLog,4,1,0x1e,&WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids);

+  }

+  iVar2 = RawInputManagerObjectResolveHandle(param_1,3,1,&local_60);

+  lVar4 = local_60;

+  if (iVar2 < 0) goto LAB_0;

+  CInpPushLock::LockExclusive((CInpPushLock *)(local_60 + 0x68));

+  if ((*(char *)(lVar4 + 0x51) == '\0') && (*(char *)(lVar4 + 0x52) == '\0')) {

+    uVar3 = DeviceTypeToRimInputType(param_3);

+    if ((*(uint *)(lVar4 + 0x54) & uVar3) == 0) {

+      iVar2 = -0x3fffff45;

+      if ((undefined **)WPP_RECORDER_INITIALIZED != &WPP_RECORDER_INITIALIZED) {

+        uVar6 = 0x1f;

+        goto LAB_1;

       }

     }

     else {

-      MicrosoftTelemetryAssertTriggeredNoArgsKM();

-    }

-    uStack0000000000000062 = uStack0000000000000070;

-    uStack0000000000000060 = uStack0000000000000070;

-    in_stack_00000068 = Win32AllocPool(uStack0000000000000070,0x706d7452);

-    unaff_RDI = in_stack_00000048;

-    if (in_stack_00000068 == 0) {

-      unaff_EBX = -0x3fffffe9;

-      puVar1 = in_stack_00000050;

-    }

-    else {

-      RtlCopyUnicodeString(&stack0x00000060,&stack0x00000070);

-      unaff_EBX = in_stack_00000040;

-      puVar1 = (uint *)&stack0x00000060;

-    }

-  }

-  in_stack_00000050 = puVar1;

-  if (-1 < unaff_EBX) {

-    unaff_EBX = RIMCreateDev(unaff_RDI,in_stack_000000c0,in_stack_00000050,1,

-                             in_stack_00000020 & 0xffffffff00000000);

-    if (-1 < unaff_EBX) {

-      *(uint *)(in_stack_00000058 + 0xb8) = *(uint *)(in_stack_00000058 + 0xb8) | 1;

-      unaff_EBX = rimOnPnpArrived(unaff_RDI,in_stack_00000058,0xffffffffffffffff);

-      if (-1 < unaff_EBX) {

-        if (unaff_R13D == 0) {

-          *in_stack_000000d0 = *(undefined8 *)(in_stack_00000058 + 0x10);

+      local_38 = 0;

+      local_30 = 0;

+      local_58 = (uint *)0x0;

+      local_48 = 0;

+      local_40 = 0;

+      puVar1 = param_2;

+      if (param_4 != 0) {

+        if (*(uint **)MmUserProbeAddress_exref <= param_2) {

+          param_2 = *(uint **)MmUserProbeAddress_exref;

+        }

+        uVar3 = *param_2;

+        local_38 = (ulonglong)uVar3;

+        local_30 = *(ulonglong *)(param_2 + 2);

+        if ((local_30 & 1) != 0) {

+                    /* WARNING: Subroutine does not return */

+          ExRaiseDatatypeMisalignment();

+        }

+        if ((uVar3 & 1) == 0) {

+          uVar5 = local_30 + 2 + ((ulonglong)uVar3 & 0xffff);

+          if (((*(ulonglong *)MmUserProbeAddress_exref <= uVar5) ||

+              (uStack_62 = (ushort)(uVar3 >> 0x10), uStack_62 < (ushort)uVar3)) ||

+             (uVar5 <= local_30)) {

+            **(undefined1 **)MmUserProbeAddress_exref = 0;

+          }

         }

         else {

-          puVar2 = in_stack_000000d0;

-          if (*(undefined8 **)MmUserProbeAddress_exref <= in_stack_000000d0) {

-            puVar2 = *(undefined8 **)MmUserProbeAddress_exref;

-          }

-          *puVar2 = *(undefined8 *)(in_stack_00000058 + 0x10);

+          MicrosoftTelemetryAssertTriggeredNoArgsKM();

+        }

+        local_48 = CONCAT62(CONCAT42(local_48._4_4_,(undefined2)local_38),(undefined2)local_38);

+        local_40 = Win32AllocPool(local_38 & 0xffff,0x706d7452);

+        if (local_40 == 0) {

+          iVar2 = -0x3fffffe9;

+          lVar4 = local_60;

+          puVar1 = local_58;

+        }

+        else {

+          RtlCopyUnicodeString(&local_48,&local_38);

+          lVar4 = local_60;

+          puVar1 = (uint *)&local_48;

         }

       }

-      if (unaff_EBX < 0) {

-        RIMFreeDev(unaff_RDI,in_stack_00000058);

+      local_58 = puVar1;

+      if (-1 < iVar2) {

+        uVar7 = 0;

+        iVar2 = RIMCreateDev(lVar4,param_3,local_58,1,

+                             (ulonglong)in_stack_ffffffffffffff78 & 0xffffffff00000000,0,&local_50);

+        if (-1 < iVar2) {

+          *(uint *)(local_50 + 0x17) = *(uint *)(local_50 + 0x17) | 1;

+          iVar2 = rimOnPnpArrived(lVar4,local_50,0xffffffffffffffff);

+          if (-1 < iVar2) {

+            if (param_4 == 0) {

+              *param_5 = local_50[2];

+            }

+            else {

+              if (*(undefined8 **)MmUserProbeAddress_exref <= param_5) {

+                param_5 = *(undefined8 **)MmUserProbeAddress_exref;

+              }

+              *param_5 = local_50[2];

+            }

+          }

+          if (iVar2 < 0) {

+            RIMFreeDev(lVar4,local_50);

+          }

+        }

+      }

+      if (local_40 != 0) {

+        Win32FreePool(local_40);

       }

     }

   }

-  if (in_stack_00000068 != 0) {

-    Win32FreePool(in_stack_00000068);

+  else {

+    iVar2 = -0x3fffff45;

+    if ((undefined **)WPP_RECORDER_INITIALIZED != &WPP_RECORDER_INITIALIZED) {

+      uVar6 = 0x20;

+LAB_1:

+      iVar2 = -0x3fffff45;

+      WPP_RECORDER_SF_(gRimLog,3,1,uVar6,&WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids);

+    }

   }

-  CInpPushLock::UnLockExclusive((CInpPushLock *)(unaff_RDI + 0x68));

-  ObfDereferenceObject(unaff_RDI);

-  if (WPP_RECORDER_INITIALIZED != unaff_R12) {

-    WPP_RECORDER_SF_D(gRimLog,4,1);

+  CInpPushLock::UnLockExclusive((CInpPushLock *)(lVar4 + 0x68));

+  ObfDereferenceObject(lVar4);

+LAB_0:

+  if ((undefined **)WPP_RECORDER_INITIALIZED != &WPP_RECORDER_INITIALIZED) {

+    WPP_RECORDER_SF_D(gRimLog,4,1,0x21,&WPP_2d6ecbd811d03edf33b26cf20b4442f4_Traceguids,

+                      CONCAT44(uVar7,iVar2));

   }

-  return unaff_EBX;

+  return iVar2;

 }
```

## `EtwTraceAuditApiSetWindowsHookEx`  (modified)

```diff
--- EtwTraceAuditApiSetWindowsHookEx
+++ EtwTraceAuditApiSetWindowsHookEx
@@ -1,68 +1,81 @@
 

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

-/* WARNING: This function may have set the stack pointer */

 

-void EtwTraceAuditApiSetWindowsHookEx(undefined8 param_1,ulonglong param_2,byte param_3)

+void EtwTraceAuditApiSetWindowsHookEx

+               (undefined4 param_1,uint *param_2,undefined8 param_3,undefined8 param_4,

+               undefined4 param_5)

 

 {

   uint uVar1;

   ushort *puVar2;

-  byte bVar3;

-  uint in_EAX;

-  undefined8 uVar4;

-  uint *unaff_RBX;

-  undefined8 unaff_RSI;

-  ushort *puVar5;

-  undefined8 unaff_R14;

+  bool bVar3;

+  ushort *puVar4;

+  undefined1 auStack_2c8 [32];

+  ushort *local_2a8;

+  undefined8 local_2a0;

+  undefined8 local_298;

+  undefined4 local_290;

+  undefined4 local_288;

+  undefined4 local_280;

+  ushort *local_278;

+  undefined8 local_270;

+  undefined8 local_268;

+  ulonglong local_260;

+  ushort *local_258;

+  ushort local_248 [264];

+  ulonglong local_38;

   

-  if ((((uint)param_2 & in_EAX) == 0) ||

-     (bVar3 = param_3, (DAT_0 & param_2) != DAT_0)) {

-    bVar3 = 0;

-  }

-  uVar4 = 0;

-  if (bVar3 != 0) {

-    uRam0000000048001048 = 0;

-    if (unaff_RBX != (uint *)0x0) {

-      if (*(uint **)MmUserProbeAddress_exref <= unaff_RBX) {

-        unaff_RBX = *(uint **)MmUserProbeAddress_exref;

+                    /* 0x10fae0  770  EtwTraceAuditApiSetWindowsHookEx */

+  local_38 = __security_cookie ^ (ulonglong)auStack_2c8;

+  if ((W32kEtwEnabledKeyword & 0x400) != 0) {

+    if ((((byte)(DAT_0 - 1U) < 3) || ((DAT_1c020f400 & 0x400) == 0)) ||

+       ((DAT_1 & 0x400) != DAT_1)) {

+      bVar3 = false;

+    }

+    else {

+      bVar3 = true;

+    }

+    if (bVar3) {

+      local_278 = (ushort *)0x0;

+      local_280 = param_1;

+      local_270 = param_3;

+      local_268 = param_4;

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

+        if (*(uint **)MmUserProbeAddress_exref <= param_2) {

+          param_2 = *(uint **)MmUserProbeAddress_exref;

+        }

+        uVar1 = *param_2;

+        local_260 = (ulonglong)uVar1;

+        puVar2 = *(ushort **)(param_2 + 2);

+        local_288 = uVar1;

+        local_258 = puVar2;

+        if (((ulonglong)puVar2 & 1) != 0) {

+                    /* WARNING: Subroutine does not return */

+          ExRaiseDatatypeMisalignment();

+        }

+        if ((uVar1 & 1) == 0) {

+          puVar4 = (ushort *)((longlong)puVar2 + ((ulonglong)uVar1 & 0xffff) + 2);

+          if (((*(ushort **)MmUserProbeAddress_exref <= puVar4) ||

+              (local_288._2_2_ = (ushort)(uVar1 >> 0x10), local_288._2_2_ < (ushort)uVar1)) ||

+             (puVar4 <= puVar2)) {

+            **(undefined1 **)MmUserProbeAddress_exref = 0;

+          }

+        }

+        else {

+          MicrosoftTelemetryAssertTriggeredNoArgsKM();

+        }

+        RtlStringCchCopyW(local_248,0x104,puVar2);

+        local_278 = local_248;

       }

-      uVar1 = *unaff_RBX;

-      uRam0000000048001060 = (ulonglong)uVar1;

-      puVar2 = *(ushort **)(unaff_RBX + 2);

-      uRam0000000048001038 = uVar1;

-      puRam0000000048001068 = puVar2;

-      if ((param_3 & (byte)puVar2) != 0) {

-                    /* WARNING: Subroutine does not return */

-        uRam0000000048000ff0 = 0x1c010fbb9;

-        ExRaiseDatatypeMisalignment();

+      if ((DAT_2 & 8) != 0) {

+        local_290 = param_5;

+        local_2a8 = local_278;

+        local_2a0 = param_3;

+        local_298 = param_4;

+        McTemplateK0qzppq();

       }

-      if ((param_3 & (byte)uVar1) == 0) {

-        puVar5 = (ushort *)((longlong)puVar2 + ((ulonglong)uVar1 & 0xffff) + 2);

-        if (((*(ushort **)MmUserProbeAddress_exref <= puVar5) ||

-            (uRam0000000048001038._2_2_ = (ushort)(uVar1 >> 0x10),

-            uRam0000000048001038._2_2_ < (ushort)uVar1)) || (puVar5 <= puVar2)) {

-          **(undefined1 **)MmUserProbeAddress_exref = 0;

-        }

-      }

-      else {

-        uRam0000000048000ff0 = 0x1c010fbc8;

-        MicrosoftTelemetryAssertTriggeredNoArgsKM();

-      }

-      uRam0000000048000ff0 = 0x1c010fc06;

-      RtlStringCchCopyW((ushort *)0x48001078,0x104,puVar2);

-      uVar4 = 0x48001078;

-      uRam0000000048001048 = 0x48001078;

-    }

-    if ((DAT_1 & 8) != 0) {

-      uRam0000000048001030 = uRam00000000480012e8;

-      uRam0000000048000ff0 = 0x1c010fc53;

-      uRam0000000048001018 = uVar4;

-      uRam0000000048001020 = unaff_RSI;

-      uRam0000000048001028 = unaff_R14;

-      McTemplateK0qzppq();

     }

   }

-  uRam0000000048000ff0 = 0x1c010fc63;

   return;

 }
```

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

```diff
--- NTOSKRNL.EXE::PsGetCurrentProcess calling
+++ NTOSKRNL.EXE::PsGetCurrentProcess calling
@@ -61,5 +61,5 @@
-FUN_1c005a129
-FUN_1c007a0af
-FUN_1c007a34f
-FUN_1c00ca5b4
-FUN_1c0101e8a
+FUN_1c005a889
+FUN_1c007a80f
+FUN_1c007aaaf
+FUN_1c00caf34
+FUN_1c0101e2c
@@ -190 +189,0 @@
-xxxDestroyThreadInfo
```

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

```diff
--- NTOSKRNL.EXE::RtlTestBit calling
+++ NTOSKRNL.EXE::RtlTestBit calling
@@ -1,0 +2 @@
+NSInstrumentation::CSectionBitmapAllocator<28672,112>::CheckAllocationStatus
```

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

```diff
--- NTOSKRNL.EXE::RtlClearBit calling
+++ NTOSKRNL.EXE::RtlClearBit calling
@@ -2,0 +3 @@
+NSInstrumentation::CSectionBitmapAllocator<28672,112>::Free
```
