# CVE-2026-95996 — bthport.sys patch diff

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

## `L2CapCon_HandleConfigResponse`  (modified)

```diff
--- L2CapCon_HandleConfigResponse
+++ L2CapCon_HandleConfigResponse
@@ -1,130 +1,191 @@
 

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

-/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* enum _PROCESS_STATUS __cdecl L2CapCon_HandleConfigResponse(struct L2CAP_CONNECTION *

+   __ptr64,unsigned short,struct _GUID * __ptr64) */

 

 _PROCESS_STATUS __cdecl

 L2CapCon_HandleConfigResponse(L2CAP_CONNECTION *param_1,ushort param_2,_GUID *param_3)

 

 {

-  short sVar1;

-  ushort uVar2;

-  L2CAP_CONNECTION *unaff_RBX;

-  byte unaff_BPL;

-  uint uVar3;

-  uint unaff_ESI;

-  longlong unaff_RDI;

-  ushort uVar4;

-  uint uVar5;

-  uchar uVar6;

-  _CHANNEL_CONFIG_PARAMETERS_ENHANCED *in_R11;

-  _CHANNEL_CONFIG_PARAMETERS_ENHANCED *unaff_R12;

-  ushort unaff_R13W;

-  _CHANNEL_CONFIG_PARAMETERS *unaff_R14;

-  _CHANNEL_CONFIG_PARAMETERS *unaff_R15;

-  _L2CAP_CONFIG_OPTION *in_XMM0_Qa;

-  undefined8 in_XMM0_Qb;

-  _L2CAP_CONFIG_OPTION *in_XMM1_Qa;

-  undefined8 in_XMM1_Qb;

-  _PROCESS_STATUS in_stack_00000068;

+  byte bVar1;

+  short sVar2;

+  longlong lVar3;

+  _PROCESS_STATUS _Var4;

+  _CHANNEL_STATE _Var5;

+  L2CAP_CONNECTION *pLVar6;

+  int iVar7;

+  L2CAP_CONNECTION *pLVar8;

+  _SIGNAL_DATA *_Dst;

+  char cVar9;

+  undefined8 uVar10;

+  uint *puVar11;

+  byte *pbVar12;

+  byte *pbVar13;

+  bool bVar14;

+  undefined1 auStackY_178 [32];

+  byte local_128 [4];

+  ulong local_124;

+  ulong local_120;

+  ulong local_11c;

+  _GUID *local_118;

+  _CHANNEL_CONFIG_PARAMETERS_ENHANCED local_108;

+  _SIGNAL_DATA local_b8 [83];

+  undefined1 local_65;

+  ulonglong local_48;

   

-  in_R11->ExtraOptions = in_XMM0_Qa;

-  *(undefined8 *)&in_R11->Flow = in_XMM0_Qb;

-  *(_L2CAP_CONFIG_OPTION **)((longlong)&(in_R11->Flow).TokenBucketSize + 2) = in_XMM0_Qa;

-  *(undefined8 *)((longlong)&(in_R11->Flow).Latency + 2) = in_XMM0_Qb;

-  *(_L2CAP_CONFIG_OPTION **)unaff_R12 = in_XMM1_Qa;

-  *(undefined8 *)&unaff_R12->NumExtraOptions = in_XMM1_Qb;

-  unaff_R12->ExtraOptions = in_XMM1_Qa;

-  *(undefined8 *)&unaff_R12->Flow = in_XMM1_Qb;

-  *(_L2CAP_CONFIG_OPTION **)((longlong)&(unaff_R12->Flow).TokenBucketSize + 2) = in_XMM1_Qa;

-  *(undefined8 *)((longlong)&(unaff_R12->Flow).Latency + 2) = in_XMM1_Qb;

-  uVar6 = '\0';

-  L2CapCon_MergeConfigParams_V2(unaff_R14,unaff_R14,in_R11,'\0');

-  L2CapCon_MergeConfigParams_V2(unaff_R15,unaff_R15,unaff_R12,uVar6);

-  if (((unaff_BPL & (byte)*(uint *)(unaff_RBX + 0x1b0)) != 0) &&

-     (unaff_RBX[0x1de] == SUB41(unaff_ESI,0))) {

-    *(uint *)(unaff_RBX + 0x1b0) = *(uint *)(unaff_RBX + 0x1b0) & 0xffffff3f;

+  local_48 = __security_cookie ^ (ulonglong)auStackY_178;

+  local_124 = CONCAT22(local_124._2_2_,param_2);

+  local_118 = param_3;

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

+  puVar11 = (uint *)0x0;

+  _Var4 = 0;

+  bVar14 = false;

+  if (3 < param_2) {

+    _Var4 = 1;

+    goto LAB_0;

   }

-  if (((unaff_BPL & (byte)*(uint *)(unaff_RBX + 0x210)) != 0) &&

-     (unaff_RBX[0x23e] == SUB41(unaff_ESI,0))) {

-    *(uint *)(unaff_RBX + 0x210) = *(uint *)(unaff_RBX + 0x210) & 0xffffff3f;

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) == 0) ||

+     (uVar10 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+    uVar10 = 0;

   }

-  L2CapCon_ShowConnection(unaff_RBX,"");

-  sVar1 = *(short *)(unaff_RDI + 0x16);

-  uVar4 = (ushort)unaff_ESI;

-  if (((ushort)(sVar1 - 0x102U) < 2) || ((ushort)(sVar1 - 0x212U) < 2)) {

-    uVar3 = *(uint *)(unaff_RDI + 0x88);

+  WPP_RECORDER_AND_TRACE_SF_LD(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar10);

+  if (param_2 == 0) {

+    local_124 = 0;

+    local_120 = 0;

+    local_11c = 0;

+    L2CapCon_ExtractConfigOptionsFromBuffer

+              (&local_108,(_LIST_ENTRY *)(param_1 + 0xa8),&local_124,&local_120,&local_11c);

+    pLVar8 = param_1;

+    _Var4 = L2CapCon_CheckRemoteConfigResponse(param_1,&local_108);

+    if ((_Var4 != 0) ||

+       (((*(uint *)(param_1 + 0x17c) & 10) != 0 &&

+        (((local_108.NumExtraOptions != 0 || (((byte)local_108.Flags & 4) != 0)) &&

+         (pLVar8 = param_1,

+         _Var4 = L2CapCon_CallCallbackForRemoteConfigResponse

+                           (param_1,&local_108,local_124,(_LIST_ENTRY *)(param_1 + 0xa8),0),

+         _Var4 != 0)))))) goto LAB_0;

+    L2CapCon_CopyRemoteConfigResponseToBrbResult

+              (pLVar8,&local_108,

+               *(_BRB **)(*(longlong *)(*(longlong *)(param_1 + 0x3a0) + 0xb8) + 8));

+    local_128[0] = 0;

+    _Var5 = L2CapCon_SetConfigStateEx(param_1,3,0,'\x01',local_128);

+    if (_Var5 == 4) {

+      L2CapCon_CompleteSignalRequest(param_1,0,'\0');

+      goto LAB_0;

+    }

+    if (local_128[0] == 0) goto LAB_0;

+    L2CapCon_StartTimer(param_1,15000);

+  }

+  else {

+    if (param_2 != 1) {

+      if (param_2 == 2) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) == 0) ||

+           (cVar9 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+          cVar9 = '\0';

+        }

+        if ((cVar9 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+          WPP_RECORDER_AND_TRACE_SF_

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar9,

+                     *(short *)(WPP_GLOBAL_Control + 0x48) != 0,

+                     *(undefined8 *)(WPP_GLOBAL_Control + 0x40));

+        }

+      }

+      else {

+        if (param_2 != 3) goto LAB_0;

+        pLVar8 = *(L2CAP_CONNECTION **)(param_1 + 0xa8);

+        for (pLVar6 = pLVar8;

+            (iVar7 = 0, pLVar6 != param_1 + 0xa8 && (iVar7 = *(int *)(pLVar6 + 0x10), iVar7 == 0));

+            pLVar6 = *(L2CAP_CONNECTION **)pLVar6) {

+        }

+        if ((iVar7 != 0) && ((*(uint *)(param_1 + 0x17c) & 4) != 0)) {

+          for (; pLVar8 != param_1 + 0xa8; pLVar8 = *(L2CAP_CONNECTION **)pLVar8) {

+            pbVar13 = *(byte **)(pLVar8 + 0x18);

+            pbVar12 = pbVar13 + *(uint *)(pLVar8 + 0x10);

+            for (; pbVar13 < pbVar12; pbVar13 = pbVar13 + 1 + (ulonglong)local_128[0] + 1) {

+              bVar1 = *pbVar13;

+              local_128[0] = pbVar13[1];

+              Feature_772777273__private_IsEnabledDeviceUsageNoInline();

+              if ((((char)bVar1 < '\0') || (bVar1 == 1 || bVar1 == 2)) || (bVar1 == 3))

+              goto LAB_1;

+            }

+          }

+          _Var4 = L2CapCon_CallCallbackForRemoteConfigResponse

+                            (param_1,&local_108,0,(_LIST_ENTRY *)(param_1 + 0xa8),(ushort)local_124)

+          ;

+          goto LAB_2;

+        }

+      }

+LAB_1:

+      _Var4 = 1;

+      goto LAB_0;

+    }

+    local_124 = 0;

+    local_11c = 0;

+    local_120 = 0;

+    L2CapCon_ExtractConfigOptionsFromBuffer

+              (&local_108,(_LIST_ENTRY *)(param_1 + 0xa8),&local_124,&local_11c,&local_120);

+    _Var4 = L2CapCon_CheckRemoteConfigResponse(param_1,&local_108);

+    if (_Var4 != 0) goto LAB_0;

+    if (((*(uint *)(param_1 + 0x17c) & 10) != 0) &&

+       ((local_108.NumExtraOptions != 0 || (((byte)local_108.Flags & 4) != 0)))) {

+      _Var4 = L2CapCon_CallCallbackForRemoteConfigResponse

+                        (param_1,&local_108,local_124,(_LIST_ENTRY *)(param_1 + 0xa8),1);

+    }

+LAB_2:

+    bVar14 = _Var4 == 0;

+  }

+  if (!bVar14) {

 LAB_0:

-    if ((uVar3 & 0x10) != 0) {

-      if (((ushort)(sVar1 - 0x102U) < 2) || ((ushort)(sVar1 - 0x212U) < 2)) {

-        uVar2 = *(ushort *)(unaff_RDI + 0xae);

+    L2capCon_FreeConfigBuffers((_LIST_ENTRY *)(param_1 + 0xa8));

+    return _Var4;

+  }

+  if (((byte)local_108.Flags & 1) == 0) goto LAB_3;

+  lVar3 = *(longlong *)(*(longlong *)(*(longlong *)(param_1 + 0x3a0) + 0xb8) + 8);

+  sVar2 = *(short *)(lVar3 + 0x16);

+  if ((ushort)(sVar2 - 0x102U) < 2) {

+    *(ushort *)(lVar3 + 0x134) = local_108.Mtu;

+    if (1 < (ushort)(sVar2 - 0x102U)) goto LAB_4;

+    puVar11 = (uint *)(lVar3 + 0x130);

+  }

+  else {

+    if (sVar2 == 0x212 || sVar2 == 0x213) {

+      *(ushort *)(lVar3 + 0x17c) = local_108.Mtu;

+LAB_4:

+      if (sVar2 == 0x212 || sVar2 == 0x213) {

+        puVar11 = (uint *)(lVar3 + 0x178);

+        goto LAB_5;

       }

-      else if (sVar1 == -0x3ef7 || sVar1 == -0x3ef6) {

-        uVar2 = *(ushort *)(unaff_RDI + 0xb6);

-      }

-      else if ((sVar1 == -0x7f00 || sVar1 == -0x7eff) ||

-              (uVar2 = uVar4, sVar1 == -0x7efe || sVar1 == -0x7efd)) {

-        uVar2 = *(ushort *)(unaff_RDI + 0xa6);

-      }

-      *(ushort *)(unaff_RBX + 0x268) = uVar2;

-      HCI_CxnAdjustProperties

-                ((_HCI_CONNECTION *)(*(longlong *)(unaff_RBX + 0x170) + -200),

-                 (_GUID *)&stack0x00000078);

+    }

+    else if ((ushort)(sVar2 + 0x3ef7U) < 2) {

+      *(ushort *)(lVar3 + 0x184) = local_108.Mtu;

+    }

+    else if ((ushort)(sVar2 + 0x7f00U) < 2) {

+      *(ushort *)(lVar3 + 0x10c) = local_108.Mtu;

+    }

+    else if ((ushort)(sVar2 + 0x7efeU) < 2) {

+      *(ushort *)(lVar3 + 0x154) = local_108.Mtu;

+    }

+    if ((ushort)(sVar2 + 0x3ef7U) < 2) {

+      puVar11 = (uint *)(lVar3 + 0x180);

+    }

+    else if ((ushort)(sVar2 + 0x7f00U) < 2) {

+      puVar11 = (uint *)(lVar3 + 0x108);

+    }

+    else if (sVar2 == -0x7efe || sVar2 == -0x7efd) {

+      puVar11 = (uint *)(lVar3 + 0x150);

     }

   }

-  else {

-    if (sVar1 == -0x3ef7 || sVar1 == -0x3ef6) {

-      uVar3 = *(uint *)(unaff_RDI + 0x90);

-      goto LAB_0;

-    }

-    if ((sVar1 == -0x7f00 || sVar1 == -0x7eff) ||

-       (uVar3 = unaff_ESI, sVar1 == -0x7efe || sVar1 == -0x7efd)) {

-      uVar3 = *(uint *)(unaff_RDI + 0x80);

-      goto LAB_0;

-    }

-  }

-  if ((*(uint *)(unaff_RBX + 0x210) & 2) != 0) {

-    if ((unaff_R13W != *(ushort *)(unaff_RBX + 0x216)) &&

-       (uVar5 = ((uint)*(ushort *)(unaff_RBX + 0x216) * 1000) / 0x271, uVar4 = (ushort)uVar5,

-       0x7ff < uVar5)) {

-      uVar4 = 0x7ff;

-    }

-    HCI_SetAutomaticFlushTimeout

-              (*(HCI_L2CAP_DATA **)(unaff_RBX + 0x170),(HCI_CLIENT *)(unaff_RBX + 0x18),uVar4);

-  }

-  if ((uVar3 & 0x20) == 0) goto LAB_1;

-  sVar1 = *(short *)(unaff_RDI + 0x16);

-  if (sVar1 == 0x102 || sVar1 == 0x103) {

-    uVar3 = *(uint *)(unaff_RDI + 0xc4);

-    if ((sVar1 != 0x102) && (sVar1 != 0x103)) goto LAB_2;

+LAB_5:

+  *puVar11 = *puVar11 | 1;

 LAB_3:

-    unaff_ESI = (uint)*(byte *)(unaff_RDI + 0xc0);

-  }

-  else {

-    if (sVar1 == 0x212 || sVar1 == 0x213) {

-      uVar3 = *(uint *)(unaff_RDI + 0xc4);

-    }

-    else if (sVar1 == -0x3ef7 || sVar1 == -0x3ef6) {

-      uVar3 = *(uint *)(unaff_RDI + 0xcc);

-    }

-    else if ((sVar1 == -0x7f00 || sVar1 == -0x7eff) ||

-            (uVar3 = unaff_ESI, sVar1 == -0x7efe || sVar1 == -0x7efd)) {

-      uVar3 = *(uint *)(unaff_RDI + 0xbc);

-    }

-LAB_2:

-    if (sVar1 == 0x212 || sVar1 == 0x213) goto LAB_3;

-    if (sVar1 == -0x3ef7 || sVar1 == -0x3ef6) {

-      unaff_ESI = (uint)*(byte *)(unaff_RDI + 200);

-    }

-    else if ((sVar1 == -0x7f00 || sVar1 == -0x7eff) || (sVar1 == -0x7efe || sVar1 == -0x7efd)) {

-      unaff_ESI = (uint)*(byte *)(unaff_RDI + 0xb8);

-    }

-  }

-  HCI_SetConnectionQos

-            (*(HCI_L2CAP_DATA **)(unaff_RBX + 0x170),(uchar)unaff_ESI,uVar3,

-             (_GUID *)&stack0x00000078);

-LAB_1:

-  HCI_IsGuaranteedWriteEnabled

-            (*(HCI_INTERFACE **)(*(longlong *)(*(longlong *)(unaff_RBX + 0x278) + 0x50) + 0x170));

-  return in_stack_00000068;

+  _Dst = local_b8;

+  memset(_Dst,0,0x68);

+  L2CapCon_CopyNeededParametersToConfigRequest

+            ((L2CAP_CONNECTION *)_Dst,&local_108,

+             *(_BRB **)(*(longlong *)(*(longlong *)(param_1 + 0x3a0) + 0xb8) + 8),

+             (_CHANNEL_CONFIG_PARAMETERS_ENHANCED *)local_b8);

+  local_65 = 1;

+  L2CapCon_SendConfigRequest(param_1,local_b8,local_118);

+  return _Var4;

 }
```

## `HCI_CriticalCallback`  (modified)

```diff
--- HCI_CriticalCallback
+++ HCI_CriticalCallback
@@ -1,57 +1,696 @@
 

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

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl HCI_CriticalCallback(struct DEVICE_EXTENSION * __ptr64,void * __ptr64,struct

+   _HCI_CALLBACK_DATA * __ptr64) */

 

 void __cdecl

 HCI_CriticalCallback(DEVICE_EXTENSION *param_1,void *param_2,_HCI_CALLBACK_DATA *param_3)

 

 {

-  bool bVar1;

-  HciLEAlternatePhyState HVar2;

-  undefined4 uVar3;

-  void *unaff_RBX;

-  longlong unaff_RBP;

-  ulonglong unaff_RSI;

-  HCI_INTERFACE *unaff_RDI;

-  undefined *puStack0000000000000038;

-  char in_stack_00000060;

-  longlong in_stack_00000068;

+  _COUNTER *p_Var1;

+  HCI_INTERFACE *pHVar2;

+  _HCI_COMMAND *p_Var3;

+  __uint64 _Var4;

+  bool bVar5;

+  char cVar6;

+  byte bVar7;

+  uint uVar8;

+  int iVar9;

+  long lVar10;

+  ushort uVar11;

+  _tlgProvider_t *p_Var12;

+  ulonglong uVar13;

+  undefined8 uVar14;

+  ulonglong uVar15;

+  char cVar16;

+  _GUID *p_Var17;

+  wchar_t *pwVar18;

+  undefined7 uVar19;

+  byte *pbVar20;

+  _GUID *p_Var21;

+  ushort **ppuVar22;

+  undefined1 uVar23;

+  DEVICE_EXTENSION *pDVar24;

+  uint uVar25;

+  undefined1 auStackY_238 [32];

+  ulong uVar26;

+  byte local_1d8 [8];

+  DEVICE_EXTENSION *local_1d0;

+  ushort *local_1c8;

+  ushort *local_1c0;

+  long local_1b8;

+  uint local_1b4;

+  undefined8 local_1b0;

+  _HCI_COMMAND local_1a8;

+  ushort local_98 [20];

+  ushort local_70 [20];

+  ulonglong local_48;

   

-  uVar3 = SUB84(unaff_RBX,0);

-  unaff_RDI->LEEnabled = (char)uVar3;

-  unaff_RDI->LEPeripheralRoleEnabled = (char)((uint)uVar3 >> 8);

-  unaff_RDI->IsLEExtendedAdvertisingEnabled = (bool)(char)((uint)uVar3 >> 0x10);

-  unaff_RDI->IsLEPeriodicAdvertisingEnabled = (bool)(char)((uint)uVar3 >> 0x18);

-  HVar2 = SUB82(unaff_RBX,0);

-  unaff_RDI->leAlternatePhyState = HVar2;

-  (unaff_RDI->IsoInitializationState).ConnectedIsoEnabled = HVar2.IsUncoded2MPhyEnabled;

-  (unaff_RDI->IsoInitializationState).BroadcastIsoEnabled = HVar2.IsCodedPhyEnabled;

-  unaff_RDI->IsLEAutoConnectionEstablishmentProcedureEnabled = SUB81(unaff_RBX,0);

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

-    bVar1 = HciInitialization::PrepareNextInitCommand

-                      (&unaff_RDI->Initialization,(_HCI_COMMAND *)(unaff_RBP + -0x70));

-    if (!bVar1) {

-      ScoInt_PostRadioInit(unaff_RDI->DevExt->Sco,unaff_RDI->FirstTimeInit);

-      HCI_PostRadioInit(unaff_RDI);

-    }

-    if (*(short *)(unaff_RBP + -0x70) != -1) {

-      HCI_SendCommandEx(unaff_RDI,(_HCI_COMMAND_HEADER *)(unaff_RBP + -0x70),(_GUID *)0x0,

-                        HCI_CriticalCallback,unaff_RBX,(ulong)unaff_RSI,unaff_RBX);

-    }

-    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 5)) {

-      unaff_RSI = (ulonglong)unaff_RBX & 0xff;

-    }

-    if (((char)unaff_RSI != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

-      puStack0000000000000038 = &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids;

-      WPP_RECORDER_AND_TRACE_SF_iL

-                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),unaff_RSI & 0xff,

-                 *(short *)(WPP_GLOBAL_Control + 0x48) != 0,unaff_RDI->IfrLog,5);

-    }

-  }

-  else {

-    Controller::OnControllerInitializationComplete((Controller *)(in_stack_00000068 + -0x300),false)

+  local_48 = __security_cookie ^ (ulonglong)auStackY_238;

+  uVar15 = 0;

+  cVar16 = '\x01';

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+     (cVar6 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    cVar6 = '\0';

+  }

+  local_1d0 = param_1;

+  if ((cVar6 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar6,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->Hci->IfrLog);

+  }

+  pHVar2 = param_1->Hci;

+  local_1d8[0] = 0;

+  memset(&local_1a8.HciCmd.Parameter_Total_Length,0,0x100);

+  p_Var3 = param_3->Cmd;

+  local_1a8.HciCmd.Op_Code = 0xffff;

+  uVar13 = 0x1002;

+  uVar11 = (p_Var3->HciCmd).Op_Code;

+  uVar8 = 0;

+  if (uVar11 != 0x1002) {

+    uVar8 = param_3->Status;

+  }

+  uVar25 = uVar8;

+  if ((uVar11 == 0x80f) && (uVar25 = 0, -1 < (int)uVar8)) {

+    pHVar2->DefaultLinkPolicy = '\x0f';

+    uVar11 = (p_Var3->HciCmd).Op_Code;

+  }

+  if (uVar11 == 0xc01) {

+    if (((int)uVar25 < 0) && (pHVar2->SimplePairingMode == '\x01')) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (uVar13 = 0x1001, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+        uVar13 = uVar13 & 0xffffffffffffff00;

+      }

+      WPP_RECORDER_AND_TRACE_SF_

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar13,

+                 (longlong)L"ComputerName\\ActiveComputerName" + 0x31,pHVar2->IfrLog);

+      uVar11 = (p_Var3->HciCmd).Op_Code;

+    }

+    else {

+      uVar11 = 0xc01;

+      uVar25 = 0;

+    }

+  }

+  uVar8 = 0;

+  if (uVar11 != 0xc52) {

+    uVar8 = uVar25;

+  }

+  uVar13 = uVar15;

+  if (uVar11 != 0xc58) {

+    uVar13 = (ulonglong)uVar8;

+  }

+  uVar8 = (uint)uVar13;

+  if (((uVar11 == 0xc56) || (uVar11 == 0x1804)) && ((int)uVar8 < 0)) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar13 = CONCAT71((int7)(uVar13 >> 8),1), (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+      uVar13 = uVar13 & 0xffffffffffffff00;

+    }

+    WPP_RECORDER_AND_TRACE_SF_

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar13,

+               (longlong)L"ComputerName\\ActiveComputerName" + 0x31,pHVar2->IfrLog);

+    pHVar2->SimplePairingMode = '\0';

+    pHVar2->SimplePairingDebugMode = '\0';

+    uVar8 = 0;

+  }

+  if (((p_Var3->HciCmd).Op_Code == 0xc7a) && ((int)uVar8 < 0)) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+      uVar14 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,

+               (longlong)L"ComputerName\\ActiveComputerName" + 0x31,pHVar2->IfrLog);

+    pHVar2->isBRSecureConnectionEnabled = '\0';

+    uVar8 = 0;

+  }

+  uVar11 = (p_Var3->HciCmd).Op_Code;

+  if (((uVar11 == 0xc6d) ||

+      ((((ushort)(uVar11 + 0xdfff) < 0x1c &&

+        ((0x8004047U >> ((ushort)(uVar11 + 0xdfff) & 0x1f) & 1) != 0)) || (uVar11 == 0x2060)))) &&

+     ((int)uVar8 < 0)) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+      uVar14 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,

+               (longlong)L"ComputerName\\ActiveComputerName" + 0x31,pHVar2->IfrLog);

+    pHVar2->LEEnabled = '\0';

+    pHVar2->LEPeripheralRoleEnabled = '\0';

+    pHVar2->IsLEExtendedAdvertisingEnabled = false;

+    pHVar2->IsLEPeriodicAdvertisingEnabled = false;

+    (pHVar2->leAlternatePhyState).IsUncoded2MPhyEnabled = false;

+    (pHVar2->leAlternatePhyState).IsCodedPhyEnabled = false;

+    (pHVar2->IsoInitializationState).ConnectedIsoEnabled = false;

+    (pHVar2->IsoInitializationState).BroadcastIsoEnabled = false;

+    pHVar2->IsLEAutoConnectionEstablishmentProcedureEnabled = false;

+    uVar8 = 0;

+  }

+  uVar11 = (p_Var3->HciCmd).Op_Code;

+  if (((uVar11 == 0x202f) || (uVar11 == 0x2024)) && ((int)uVar8 < 0)) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar23 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+      uVar23 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_dD

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),CONCAT11((char)(uVar11 >> 8),uVar23),1,

+               pHVar2->IfrLog);

+    uVar8 = 0;

+  }

+  if ((((p_Var3->HciCmd).Op_Code == 0x2074) && ((int)uVar8 < 0)) &&

+     ((p_Var3->Cmd_Generic).Parameter[0] == ' ')) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+      uVar14 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_dD(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog)

     ;

+    (pHVar2->IsoInitializationState).ConnectedIsoEnabled = false;

+    uVar8 = 0;

+  }

+  if (((p_Var3->HciCmd).Op_Code == 0x203a) && ((int)uVar8 < 0)) {

+    WPP_RECORDER_AND_TRACE_SF_dD(*(undefined8 *)(WPP_GLOBAL_Control + 0x18));

+    pHVar2->IsLEExtendedAdvertisingEnabled = false;

+    pHVar2->IsLEPeriodicAdvertisingEnabled = false;

+    (pHVar2->leAlternatePhyState).IsCodedPhyEnabled = false;

+    uVar8 = 0;

+  }

+  if ((((pHVar2->VsMsftInfo).OpCode == (p_Var3->HciCmd).Op_Code) &&

+      ((p_Var3->Cmd_Generic).Parameter[0] == '\0')) && ((int)uVar8 < 0)) {

+    WPP_RECORDER_AND_TRACE_SF_L(*(undefined8 *)(WPP_GLOBAL_Control + 0x18));

+    (pHVar2->VsMsftInfo).InitializationState = '\x03';

+    uVar8 = 0;

+  }

+  iVar9 = Feature_56240707__private_IsEnabledDeviceUsageNoInline();

+  if ((iVar9 == 0) || ((p_Var3->HciCmd).Op_Code != 0xc63)) {

+    if (-1 < (int)uVar8) goto LAB_0;

+    LOCK();

+    p_Var1 = &pHVar2->CriticalCommandRetry;

+    iVar9 = p_Var1->Count;

+    p_Var1->Count = p_Var1->Count + 1;

+    UNLOCK();

+    if (1 < iVar9 + 1) goto LAB_1;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar14 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_dD(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog)

+    ;

+LAB_2:

+    (pHVar2->Initialization).m_lastPreparedCommandIndex = 0;

+    local_1a8.HciCmd.Op_Code = 0xc03;

+    local_1a8.HciCmd.Parameter_Total_Length = '\0';

+    goto LAB_3;

+  }

+  if ((int)uVar8 < 0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+      uVar14 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_L(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14);

+  }

+LAB_0:

+  uVar11 = (p_Var3->HciCmd).Op_Code;

+  uVar14 = 0;

+  bVar5 = false;

+  if (uVar11 < 0x2003) {

+    if (uVar11 == 0x2002) {

+      if ((pHVar2->LEEnabled != '\0') &&

+         ((pHVar2->LEBufferSize == 0 || (pHVar2->LETotalNumberOfDataPkts == 0)))) {

+        pHVar2->LEBufferSize = (ushort)pHVar2->MaxBytesPerAclDataPacket;

+        pHVar2->LEUseBRWriteCredits = '\x01';

+      }

+    }

+    else if (uVar11 == 0xc1a) {

+      if (pHVar2->DevExt->LinkKeysHandle == (void *)0x0) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar15 = 1;

+        }

+        WPP_RECORDER_AND_TRACE_SF_

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar15,1,pHVar2->IfrLog);

+        goto LAB_1;

+      }

+    }

+    else {

+      if (uVar11 != 0xc6d) {

+        if (uVar11 == 0x1001) {

+          if ((pHVar2->LocalInfo).hciVersion == '\0') {

+            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

+               (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+              uVar14 = 1;

+            }

+            WPP_RECORDER_AND_TRACE_SF_(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14);

+            BthReportError(pHVar2->DevExt,-0x3ffaffff,0,(void *)0x0,0);

+            local_1d8[0] = 1;

+          }

+          bVar7 = local_1d8[0];

+          if ((pHVar2->CompatibilityFlags & HardwareNotCompatible) != 0) {

+            BthReportError(pHVar2->DevExt,-0x3ffaffdf,0,(void *)0x0,0);

+            bVar7 = 1;

+          }

+        }

+        else {

+          if (uVar11 == 0x1002) {

+            if ((pHVar2->ExtendedFeatures & 2) == 0) {

+              local_1b8 = param_3->Status;

+              local_1b4 = (uint)param_3->BtStatus;

+              if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

+                 (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+                uVar14 = 1;

+              }

+              WPP_RECORDER_AND_TRACE_SF_dD

+                        (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,

+                         (longlong)L"ComputerName\\ActiveComputerName" + 0x31,pHVar2->IfrLog);

+              pbVar20 = (byte *)&local_1b8;

+              uVar26 = 8;

+LAB_4:

+              pDVar24 = local_1d0;

+              BthReportError(local_1d0,0x40050012,0,pbVar20,uVar26);

+            }

+            else {

+              pDVar24 = local_1d0;

+              if ((pHVar2->ExtendedFeatures & 4) == 0) {

+                if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

+                   (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+                  uVar14 = 1;

+                }

+                WPP_RECORDER_AND_TRACE_SF_ddd

+                          (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog);

+                pbVar20 = local_1d8;

+                local_1d8[0] = (pHVar2->SupportedCommandsMap).field0_0x0.RawMap[6] & 0xe0;

+                uVar26 = 1;

+                goto LAB_4;

+              }

+            }

+            if (((pHVar2->SupportedCommandsMap).field0_0x0.RawMap[0x14] & 0x10) == 0) {

+              p_Var21 = (_GUID *)0x0;

+              p_Var17 = (_GUID *)0x0;

+              BthReportError(pHVar2->DevExt,-0x7ffaffd0,0,(void *)0x0,0);

+              if (5 < (uint)DAT_5) {

+                p_Var12 = (_tlgProvider_t *)&DAT_5;

+                cVar6 = _tlgKeywordOn(&DAT_5,0x400000000000);

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

+                  local_1d0 = (DEVICE_EXTENSION *)&pDVar24->DeviceExtensionSessionId;

+                  local_1b0 = 0x3000800;

+                  _tlgWriteTemplate<long___cdecl(_tlgProvider_t_const*___ptr64,void_const*___ptr64,_GUID_const*___ptr64,_GUID_const*___ptr64,unsigned_int,_EVENT_DATA_DESCRIPTOR*___ptr64),&long___cdecl__tlgWriteTransfer_EtwWriteTransfer(struct__tlgProvider_t_const*___ptr64,void_const*___ptr64,struct__GUID_const*___ptr64,struct__GUID_const*___ptr64,unsigned_int,struct__EVENT_DATA_DESCRIPTOR*___ptr64),_GUID_const*___ptr64,_GUID_const*___ptr64>

+                  ::Write<_tlgWrapperByVal<8>,_tlgWrapperByRef<16>_>

+                            (p_Var12,&DAT_6,p_Var17,p_Var21,

+                             (_tlgWrapperByVal<8> *)&local_1b0,(_tlgWrapperByRef<16> *)&local_1d0);

+                }

+              }

+            }

+            LOCK();

+            pHVar2->ExtendedFeatures = pHVar2->ExtendedFeatures | 1;

+            UNLOCK();

+            goto LAB_7;

+          }

+          if (uVar11 != 0x1003) {

+            if (uVar11 == 0x1009) {

+              _Var4 = (pHVar2->LocalInfo).localInfo.address;

+              if (_Var4 == 0) {

+                if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

+                   (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+                  uVar15 = 1;

+                }

+                WPP_RECORDER_AND_TRACE_SF_

+                          (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+                           CONCAT71(0x14017f5,(char)uVar15),1,pHVar2->IfrLog);

+              }

+              else {

+                if ((pHVar2->AttemptedBluetoothAddressRecovery == false) ||

+                   (bVar5 = IsInvalidQualcommBluetoothAddress(pHVar2,_Var4), !bVar5))

+                goto LAB_7;

+                if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

+                   (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+                  uVar15 = 1;

+                }

+                WPP_RECORDER_AND_TRACE_SF_

+                          (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+                           CONCAT71(0x14017f5,(char)uVar15),1,pHVar2->IfrLog);

+                if (DAT_8 < _DAT_fffff7800000037c) {

+                  EtwTelemetryCoverageReport(&PTR_s_Bluetooth_Radio_Address_Recover_14019a3a8);

+                }

+              }

+              ppuVar22 = &local_1c8;

+              lVar10 = -0x3ffafffe;

+              local_1c8 = (ushort *)

+                          (CONCAT44((int)(pHVar2->LocalInfo).localInfo.address,

+                                    (int)((pHVar2->LocalInfo).localInfo.address >> 0x20)) &

+                          0xffffffff0000ffff);

+              uVar26 = 8;

+              goto LAB_9;

+            }

+            goto LAB_7;

+          }

+          uVar15 = (pHVar2->LocalInfo).radioInfo.lmpSupportedFeatures;

+          if ((((byte)uVar15 & 0xa4) != 0xa4) || ((uVar15 >> 0x25 & 1) != 0)) {

+            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

+               (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+              uVar14 = 1;

+            }

+            WPP_RECORDER_AND_TRACE_SF_

+                      (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog);

+            local_1d8[0] = 1;

+          }

+          if ((pHVar2->NonFlushablePacketBoundaryFlagEnabled != '\0') && ((uVar15 >> 0x36 & 1) == 0)

+             ) {

+            pHVar2->NonFlushablePacketBoundaryFlagEnabled = '\0';

+          }

+          if ((pHVar2->SniffSubratingEnabled == '\x01') && ((uVar15 >> 0x29 & 1) == 0)) {

+            pHVar2->SniffSubratingEnabled = '\0';

+          }

+          if (((int)pHVar2->InquirySupportLevel < 3) && ((uVar15 >> 0x30 & 1) == 0)) {

+            pHVar2->InquirySupportLevel = BthInquiryResultWithRSSISupport;

+LAB_10:

+            if ((uVar15 >> 0x1e & 1) == 0) {

+              pHVar2->InquirySupportLevel = BthInquiryResultSupport;

+            }

+          }

+          else if (pHVar2->InquirySupportLevel == BthInquiryResultWithRSSISupport)

+          goto LAB_10;

+          bVar7 = local_1d8[0];

+          if (pHVar2->LEEnabled != '\0') {

+            if ((uVar15 >> 0x26 & 1) == 0) {

+              if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+                 (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+                uVar14 = 0;

+              }

+              WPP_RECORDER_AND_TRACE_SF_(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14);

+              lVar10 = -0x7ffaffe4;

+            }

+            else {

+              if ((uVar15 >> 0x31 & 1) != 0) goto LAB_11;

+              if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+                 (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+                uVar14 = 0;

+              }

+              WPP_RECORDER_AND_TRACE_SF_(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14);

+              lVar10 = -0x7ffaffe7;

+            }

+            BthReportError(pHVar2->DevExt,lVar10,0,(void *)0x0,0);

+            pHVar2->LEEnabled = '\0';

+            pHVar2->LEPeripheralRoleEnabled = '\0';

+            pHVar2->IsLEExtendedAdvertisingEnabled = false;

+            pHVar2->IsLEPeriodicAdvertisingEnabled = false;

+            (pHVar2->leAlternatePhyState).IsUncoded2MPhyEnabled = false;

+            (pHVar2->leAlternatePhyState).IsCodedPhyEnabled = false;

+            (pHVar2->IsoInitializationState).ConnectedIsoEnabled = false;

+            (pHVar2->IsoInitializationState).BroadcastIsoEnabled = false;

+            pHVar2->IsLEAutoConnectionEstablishmentProcedureEnabled = false;

+            bVar7 = local_1d8[0];

+          }

+        }

+        goto LAB_11;

+      }

+      local_1d0->IsLESupported = '\x01';

+    }

+  }

+  else if (uVar11 == 0x2003) {

+    if (pHVar2->LEEnabled != '\0') {

+      if (pHVar2->IsLEExtendedAdvertisingEnabled == false) {

+LAB_12:

+        bVar5 = HciLEAdvertisingRequestCoordinator::IsStarted

+                          (&pHVar2->leAdvertisingRequestCoordinator);

+        if ((!bVar5) &&

+           (lVar10 = HciLEAdvertisingRequestCoordinator::Start

+                               (&pHVar2->leAdvertisingRequestCoordinator), lVar10 < 0)) {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+             (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+            uVar14 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_L(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14);

+          BthReportError(pHVar2->DevExt,lVar10,0,(void *)0x0,0);

+          local_1d8[0] = 1;

+        }

+      }

+      else if (((uint)pHVar2->LELocalSupportedFeatures >> 0xc & 1) == 0) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

+           (2 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar14 = 1;

+        }

+        WPP_RECORDER_AND_TRACE_SF_

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog);

+        pHVar2->IsLEExtendedAdvertisingEnabled = false;

+        pHVar2->IsLEPeriodicAdvertisingEnabled = false;

+        (pHVar2->leAlternatePhyState).IsCodedPhyEnabled = false;

+        goto LAB_12;

+      }

+      Feature_BluetoothLEBroadcastAudioHci__private_ReportDeviceUsage();

+      if (pHVar2->IsLEExtendedAdvertisingEnabled != false) {

+        if ((pHVar2->LELocalSupportedFeatures & 0x3002000) == 0x3002000) {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+             (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+            uVar14 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog);

+          pHVar2->IsLEPeriodicAdvertisingEnabled = true;

+        }

+        else {

+          pHVar2->IsLEPeriodicAdvertisingEnabled = false;

+          (pHVar2->IsoInitializationState).BroadcastIsoEnabled = false;

+        }

+      }

+      uVar15 = pHVar2->LELocalSupportedFeatures;

+      (pHVar2->leAlternatePhyState).IsUncoded2MPhyEnabled = (bool)((byte)(uVar15 >> 8) & 1);

+      (pHVar2->leAlternatePhyState).IsCodedPhyEnabled = (bool)((byte)(uVar15 >> 0xb) & 1);

+      if (((pHVar2->IsoInitializationState).ConnectedIsoEnabled != false) &&

+         ((uVar15 & 0x30000000) != 0x30000000)) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+          uVar14 = 0;

+        }

+        WPP_RECORDER_AND_TRACE_SF_

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog);

+        (pHVar2->IsoInitializationState).ConnectedIsoEnabled = false;

+        (pHVar2->IsoInitializationState).BroadcastIsoEnabled = false;

+      }

+      Feature_BluetoothLEBroadcastAudioHci__private_ReportDeviceUsage();

+      bVar7 = local_1d8[0];

+      if (((pHVar2->IsoInitializationState).BroadcastIsoEnabled != false) &&

+         (((pHVar2->LELocalSupportedFeatures & 0xc0000000) != 0xc0000000 ||

+          (pHVar2->IsLEPeriodicAdvertisingEnabled == false)))) {

+        if ((pHVar2->IsoInitializationState).enableBroadcastIsoDespiteMissingFeatures == false) {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+             (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+            uVar14 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog);

+          (pHVar2->IsoInitializationState).BroadcastIsoEnabled = false;

+          bVar7 = local_1d8[0];

+        }

+        else {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+             (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+            uVar14 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog);

+          bVar7 = local_1d8[0];

+        }

+      }

+LAB_11:

+      if (bVar7 != 0) {

+LAB_1:

+        Controller::OnControllerInitializationComplete

+                  ((Controller *)&local_1d0[-2].AvdtpOffload,false);

+        return;

+      }

+    }

+  }

+  else if (uVar11 == 0x200f) {

+    if ((pHVar2->LEEnabled != '\0') && (pHVar2->LEWhiteListSize < 0x19)) {

+LAB_13:

+      BthReportError(pHVar2->DevExt,-0x7ffaffe1,0,(void *)0x0,0);

+    }

+  }

+  else if (uVar11 == 0x201c) {

+    if (pHVar2->LEEnabled != '\0') {

+      local_70[0x10] = 0;

+      local_70[0x11] = 0;

+      local_70[0x12] = 0;

+      local_98[0x10] = 0;

+      local_98[0x11] = 0;

+      local_98[0x12] = 0;

+      local_1c8 = local_98;

+      local_1c0 = local_70;

+      local_70[0] = 0;

+      local_70[1] = 0;

+      local_70[2] = 0;

+      local_70[3] = 0;

+      local_70[4] = 0;

+      local_70[5] = 0;

+      local_70[6] = 0;

+      local_70[7] = 0;

+      local_70[8] = 0;

+      local_70[9] = 0;

+      local_70[10] = 0;

+      local_70[0xb] = 0;

+      local_70[0xc] = 0;

+      local_70[0xd] = 0;

+      local_70[0xe] = 0;

+      local_70[0xf] = 0;

+      local_98[0] = 0;

+      local_98[1] = 0;

+      local_98[2] = 0;

+      local_98[3] = 0;

+      local_98[4] = 0;

+      local_98[5] = 0;

+      local_98[6] = 0;

+      local_98[7] = 0;

+      local_98[8] = 0;

+      local_98[9] = 0;

+      local_98[10] = 0;

+      local_98[0xb] = 0;

+      local_98[0xc] = 0;

+      local_98[0xd] = 0;

+      local_98[0xe] = 0;

+      local_98[0xf] = 0;

+      RtlStringCchPrintfW(local_70,0x13,(ushort *)L"0x%I64x",pHVar2->LELocalSupportedStates);

+      if ((pHVar2->LELocalSupportedStates & 0x1f3fffff) == 0x1f3fffff) {

+        if ((pHVar2->LELocalSupportedStates & 0x1f7fffff) != 0x1f7fffff) {

+          pwVar18 = L"0x%I64x";

+          RtlStringCchPrintfW(local_98,0x13,(ushort *)L"0x%I64x");

+          uVar19 = (undefined7)((ulonglong)pwVar18 >> 8);

+          if (pHVar2->LEMinImportantStateException == '\0') {

+            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+               (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+              uVar14 = 0;

+            }

+            uVar26 = (ulong)CONCAT71(uVar19,1);

+            WPP_RECORDER_AND_TRACE_SF_(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14);

+            lVar10 = -0x3ffaffe2;

+            pHVar2->LEEnabled = '\0';

+            pHVar2->LEPeripheralRoleEnabled = '\0';

+            pHVar2->IsLEExtendedAdvertisingEnabled = false;

+            pHVar2->IsLEPeriodicAdvertisingEnabled = false;

+            (pHVar2->leAlternatePhyState).IsUncoded2MPhyEnabled = false;

+            (pHVar2->leAlternatePhyState).IsCodedPhyEnabled = false;

+            (pHVar2->IsoInitializationState).ConnectedIsoEnabled = false;

+            (pHVar2->IsoInitializationState).BroadcastIsoEnabled = false;

+            pHVar2->IsLEAutoConnectionEstablishmentProcedureEnabled = false;

+          }

+          else {

+            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+               (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+              uVar14 = 0;

+            }

+            uVar26 = (ulong)CONCAT71(uVar19,1);

+            WPP_RECORDER_AND_TRACE_SF_(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14);

+            lVar10 = -0x7ffaffe6;

+            pHVar2->LEWhiteListEnabled = '\0';

+          }

+          BthReportErrorEx((pHVar2->DevExt->BtDevice).FunctionalDeviceObject,lVar10,uVar26,

+                           (void *)0x0,0,2,&local_1c8);

+        }

+      }

+      else {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+          uVar14 = 0;

+        }

+        WPP_RECORDER_AND_TRACE_SF_

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog);

+        uVar26 = 0x4017f4a0;

+        RtlStringCchPrintfW(local_98,0x13,(ushort *)L"0x%I64x");

+        BthReportErrorEx((pHVar2->DevExt->BtDevice).FunctionalDeviceObject,-0x3ffaffe5,uVar26,

+                         (void *)0x0,0,2,&local_1c8);

+        pHVar2->LEEnabled = '\0';

+        pHVar2->LEPeripheralRoleEnabled = '\0';

+        pHVar2->IsLEExtendedAdvertisingEnabled = false;

+        pHVar2->IsLEPeriodicAdvertisingEnabled = false;

+        (pHVar2->leAlternatePhyState).IsUncoded2MPhyEnabled = false;

+        (pHVar2->leAlternatePhyState).IsCodedPhyEnabled = false;

+        (pHVar2->IsoInitializationState).ConnectedIsoEnabled = false;

+        (pHVar2->IsoInitializationState).BroadcastIsoEnabled = false;

+        pHVar2->IsLEAutoConnectionEstablishmentProcedureEnabled = false;

+      }

+      if (((pHVar2->LEEnabled != '\0') && (pHVar2->TestEnabled == '\0')) &&

+         ((pHVar2->LELocalSupportedStates & 0x2491f7fffff) != 0x2491f7fffff)) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+          uVar14 = 0;

+        }

+        WPP_RECORDER_AND_TRACE_SF_

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,pHVar2->IfrLog);

+        pHVar2->LEPeripheralRoleEnabled = '\0';

+        uVar26 = 0x4017f4a0;

+        RtlStringCchPrintfW(local_98,0x13,(ushort *)L"0x%I64x");

+        BthReportErrorEx((pHVar2->DevExt->BtDevice).FunctionalDeviceObject,-0x7ffaffde,uVar26,

+                         (void *)0x0,0,2,&local_1c8);

+      }

+    }

+  }

+  else if (uVar11 == 0x203b) {

+    bVar5 = HciLEAdvertisingRequestCoordinator::IsStarted(&pHVar2->leAdvertisingRequestCoordinator);

+    if ((!bVar5) &&

+       (lVar10 = HciLEAdvertisingRequestCoordinator::Start(&pHVar2->leAdvertisingRequestCoordinator)

+       , lVar10 < 0)) {

+      if (lVar10 == -0x3fffff45) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+          uVar14 = 0;

+        }

+        WPP_RECORDER_AND_TRACE_SF_

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,

+                   (longlong)L"ComputerName\\ActiveComputerName" + 0x31,pHVar2->IfrLog);

+        bVar5 = true;

+        pHVar2->IsLEExtendedAdvertisingEnabled = false;

+        pHVar2->IsLEPeriodicAdvertisingEnabled = false;

+        (pHVar2->leAlternatePhyState).IsCodedPhyEnabled = false;

+        goto LAB_14;

+      }

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+        uVar14 = 0;

+      }

+      WPP_RECORDER_AND_TRACE_SF_L(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14);

+      ppuVar22 = (ushort **)0x0;

+      uVar26 = 0;

+LAB_9:

+      BthReportError(pHVar2->DevExt,lVar10,0,ppuVar22,uVar26);

+      goto LAB_1;

+    }

+  }

+  else if (uVar11 == 0x204a) {

+    if ((pHVar2->RadioCapacity).LEPeriodicAdvertiserListSize == '\0') goto LAB_13;

+  }

+  else if (uVar11 == 0xfc14) {

+    pHVar2->AttemptedBluetoothAddressRecovery = true;

+    uVar15 = 1;

+LAB_14:

+    (pHVar2->LocalInfo).localInfo.address = 0;

+    if ((char)uVar15 != '\0') {

+      (pHVar2->Initialization).m_lastPreparedCommandIndex = 0;

+      HciInitialization::PrepareNextInitCommand(&pHVar2->Initialization,&local_1a8);

+      goto LAB_3;

+    }

+    if (!bVar5) goto LAB_3;

+    goto LAB_2;

+  }

+LAB_7:

+  bVar5 = HciInitialization::PrepareNextInitCommand(&pHVar2->Initialization,&local_1a8);

+  if (!bVar5) {

+    ScoInt_PostRadioInit(pHVar2->DevExt->Sco,pHVar2->FirstTimeInit);

+    HCI_PostRadioInit(pHVar2);

+  }

+LAB_3:

+  if (local_1a8.HciCmd.Op_Code != 0xffff) {

+    HCI_SendCommandEx(pHVar2,&local_1a8.HciCmd,(_GUID *)0x0,HCI_CriticalCallback,(void *)0x0,1,

+                      (void *)0x0);

+  }

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    cVar16 = '\0';

+  }

+  if ((cVar16 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_iL

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar16,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,pHVar2->IfrLog);

   }

   return;

 }
```

## `SdpDB_ServiceSearchRequestResponse`  (modified)

```diff
--- SdpDB_ServiceSearchRequestResponse
+++ SdpDB_ServiceSearchRequestResponse
@@ -1,15 +1,175 @@
+

+/* long __cdecl SdpDB_ServiceSearchRequestResponse(struct _SDP_DATABASE * __ptr64,struct

+   _SDP_UUID_SEARCH * __ptr64,unsigned short,unsigned long * __ptr64 * __ptr64,unsigned short *

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

 

 long __cdecl

 SdpDB_ServiceSearchRequestResponse

           (_SDP_DATABASE *param_1,_SDP_UUID_SEARCH *param_2,ushort param_3,ulong **param_4,

           ushort *param_5,ushort *param_6,uchar param_7)

 

 {

   code *pcVar1;

-  long lVar2;

+  undefined8 ******ppppppuVar2;

+  uchar uVar3;

+  ushort uVar4;

+  ushort uVar5;

+  int iVar6;

+  undefined8 *******pppppppuVar7;

+  uint *puVar8;

+  uint uVar9;

+  undefined8 *******pppppppuVar10;

+  uchar *puVar11;

+  uint7 uVar13;

+  longlong lVar12;

+  long lVar14;

+  _SDP_DATABASE *p_Var15;

+  ulonglong uVar16;

+  undefined6 in_register_00000082;

+  undefined8 ******local_48;

+  undefined8 ******local_40;

   

-  pcVar1 = (code *)swi(3);

-  lVar2 = (*pcVar1)();

-  return lVar2;

+  lVar14 = 0;

+  uVar9 = 1;

+  if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

+     ((byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    uVar9 = 0;

+  }

+  pppppppuVar10 = (undefined8 *******)(ulonglong)uVar9;

+  if (((char)uVar9 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),pppppppuVar10,

+               CONCAT71((int7)(CONCAT62(in_register_00000082,param_3) >> 8),

+                        *(short *)(WPP_GLOBAL_Control + 0x48) != 0),

+               *(undefined8 *)(WPP_GLOBAL_Control + 0x40),5,8,0x14,

+               &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids);

+  }

+  local_40 = &local_48;

+  local_48 = &local_48;

+  *param_4 = (ulong *)0x0;

+  uVar5 = 0;

+  *param_5 = 0;

+  ExAcquireFastMutex(&param_1->ServiceRecordListMutex);

+  p_Var15 = (_SDP_DATABASE *)(param_1->ServiceRecordList).Flink;

+  do {

+    iVar6 = lVar14;

+    if (p_Var15 == param_1) {

+LAB_0:

+      ExReleaseFastMutex(&param_1->ServiceRecordListMutex);

+      if ((uVar5 != 0) && (-1 < iVar6)) {

+        uVar16 = (ulonglong)uVar5;

+        puVar8 = (uint *)ExAllocatePool2(0x40,uVar16 * 4,0x50485442);

+        *param_4 = puVar8;

+        if (puVar8 == (uint *)0x0) {

+          if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

+             (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+            lVar14 = 1;

+          }

+          WPP_RECORDER_AND_TRACE_SF_

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),CONCAT71(0x140189d,(char)lVar14),1,

+                     *(undefined8 *)(WPP_GLOBAL_Control + 0x40),2,8,0x18,

+                     &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids);

+          iVar6 = -0x3fffff66;

+          uVar5 = SdpMapNtStatusToSdpError(0xc000009a);

+          *param_6 = uVar5;

+        }

+        else {

+          *param_5 = uVar5;

+          pppppppuVar10 = (undefined8 *******)local_48;

+          do {

+            uVar9 = *(uint *)(pppppppuVar10 + 2);

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

+              uVar9 = uVar9 >> 0x18 | (uVar9 & 0xff0000) >> 8 | (uVar9 & 0xff00) << 8 |

+                      uVar9 << 0x18;

+            }

+            *puVar8 = uVar9;

+            puVar8 = puVar8 + 1;

+            pppppppuVar10 = (undefined8 *******)*pppppppuVar10;

+            uVar16 = uVar16 - 1;

+          } while (uVar16 != 0);

+        }

+      }

+      while( true ) {

+        ppppppuVar2 = local_48;

+        if ((undefined8 *******)local_48 == &local_48) {

+          return iVar6;

+        }

+        lVar14 = iVar6;

+        if (((undefined8 *******)local_48[1] != &local_48) ||

+           (pppppppuVar10 = (undefined8 *******)*local_48, pppppppuVar10[1] != local_48)) break;

+        pppppppuVar10[1] = &local_48;

+        local_48 = pppppppuVar10;

+        ExFreePoolWithTag(ppppppuVar2,0);

+      }

+LAB_1:

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

+      (*pcVar1)(3);

+      return lVar14;

+    }

+    if ((param_7 == '\0') && ((*(uint *)&(p_Var15->ServiceRecordListMutex).field_0x4 & 2) != 0)) {

+      iVar6 = Feature_61512497__private_IsEnabledDeviceUsageNoInline();

+      if (iVar6 != 0) {

+        if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

+           (3 < (byte)WPP_GLOBAL_Control[0x29])) {

+          pppppppuVar10 = (undefined8 *******)&DAT_2;

+        }

+        else {

+          pppppppuVar10 = (undefined8 *******)((ulonglong)pppppppuVar10 & 0xffffffffffffff00);

+        }

+        WPP_RECORDER_AND_TRACE_SF_D_guid_(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),pppppppuVar10);

+      }

+    }

+    else {

+      puVar11 = *(uchar **)&(p_Var15->ServiceRecordListMutex).Event.Header;

+      uVar3 = SdpUS_SearchStream(param_2,puVar11,

+                                 *(ulong *)&(p_Var15->ServiceRecordListMutex).field_0x14);

+      uVar13 = (uint7)((ulonglong)puVar11 >> 8);

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

+        if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

+           (3 < (byte)WPP_GLOBAL_Control[0x29])) {

+          pppppppuVar10 = (undefined8 *******)&DAT_2;

+        }

+        else {

+          pppppppuVar10 = (undefined8 *******)((ulonglong)uVar13 << 8);

+        }

+        WPP_RECORDER_AND_TRACE_SF_L

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),pppppppuVar10,1,

+                   *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4,8,0x17,

+                   &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids,

+                   (p_Var15->ServiceRecordListMutex).Contention);

+      }

+      else {

+        if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

+           (3 < (byte)WPP_GLOBAL_Control[0x29])) {

+          lVar12 = 1;

+        }

+        else {

+          lVar12 = (ulonglong)uVar13 << 8;

+        }

+        WPP_RECORDER_AND_TRACE_SF_L

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),lVar12,1,

+                   *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4,8,0x16,

+                   &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids,

+                   (p_Var15->ServiceRecordListMutex).Contention);

+        pppppppuVar7 = (undefined8 *******)ExAllocatePool2(0x100,0x18,0x50485442);

+        if (pppppppuVar7 == (undefined8 *******)0x0) {

+          uVar4 = SdpMapNtStatusToSdpError(0xc000009a);

+          *param_6 = uVar4;

+          iVar6 = -0x3fffff66;

+          goto LAB_0;

+        }

+        *(ulong *)(pppppppuVar7 + 2) = (p_Var15->ServiceRecordListMutex).Contention;

+        if ((undefined8 *******)*local_40 != &local_48) goto LAB_1;

+        pppppppuVar7[1] = local_40;

+        pppppppuVar10 = &local_48;

+        *pppppppuVar7 = pppppppuVar10;

+        uVar5 = uVar5 + 1;

+        *local_40 = pppppppuVar7;

+        local_40 = pppppppuVar7;

+        if (uVar5 == param_3) goto LAB_0;

+      }

+    }

+    p_Var15 = (_SDP_DATABASE *)(p_Var15->ServiceRecordList).Flink;

+  } while( true );

 }
```

## `Fn_CC_LE_Set_Extended_Scan_Parameters`  (modified)

```diff
--- Fn_CC_LE_Set_Extended_Scan_Parameters
+++ Fn_CC_LE_Set_Extended_Scan_Parameters
@@ -1,54 +1,34 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl Fn_CC_LE_Set_Extended_Scan_Parameters(struct HCI_INTERFACE * __ptr64,union

+   _HCI_COMMAND * __ptr64,union _HCI_EVENT * __ptr64,struct _HCI_CONNECTION * __ptr64,struct _GUID *

+   __ptr64) */

 

 void __cdecl

 Fn_CC_LE_Set_Extended_Scan_Parameters

           (HCI_INTERFACE *param_1,_HCI_COMMAND *param_2,_HCI_EVENT *param_3,_HCI_CONNECTION *param_4

           ,_GUID *param_5)

 

 {

-  int *piVar1;

-  undefined8 uVar2;

-  undefined8 uVar3;

-  int in_EAX;

-  int iVar4;

-  longlong lVar5;

-  longlong unaff_RBX;

-  longlong unaff_RBP;

-  HCI_INTERFACE *unaff_RSI;

-  undefined1 *puVar6;

-  byte in_CF;

+  byte bVar1;

+  uchar *puVar2;

   

-  iVar4 = (in_EAX - (int)unaff_RBP) - (uint)in_CF;

-  piVar1 = (int *)((ulonglong)

-                   CONCAT22((short)((uint)iVar4 >> 0x10),CONCAT11((char)param_2,(char)iVar4)) + 0xf)

-  ;

-  *piVar1 = *piVar1 + -1;

-  uVar2 = *(undefined8 *)(*(longlong *)(unaff_RBX + 0x30) + 0x5fc);

-  uVar3 = *(undefined8 *)(*(longlong *)(unaff_RBX + 0x30) + 0x604);

-  *(undefined2 *)(unaff_RBP + -0x31) = 0x201a;

-  *(undefined2 *)(unaff_RBP + -0x2e) = *(undefined2 *)(unaff_RBX + 0x80);

-  *(undefined1 *)(unaff_RBP + -0x2f) = 0x12;

-  *(undefined8 *)(unaff_RBP + -0x2c) = uVar2;

-  *(undefined8 *)(unaff_RBP + -0x24) = uVar3;

-  HCI_SendCommandEx(unaff_RSI,(_HCI_COMMAND_HEADER *)(unaff_RBP + -0x31),

-                    *(_GUID **)(unaff_RBP + 0x7f),

-                    (_func_void_DEVICE_EXTENSION_ptr_void_ptr__HCI_CALLBACK_DATA_ptr *)0x0,

-                    (void *)0x0,2,(void *)0x0);

-  puVar6 = (undefined1 *)(unaff_RBP + -0x2c);

-  for (lVar5 = 0x10; lVar5 != 0; lVar5 = lVar5 + -1) {

-    *puVar6 = 0;

-    puVar6 = puVar6 + -1;

-  }

-  if (*(longlong *)(unaff_RBP + -0x39) != 0) {

-    ZwClose();

-  }

-  puVar6 = (undefined1 *)(unaff_RBP + -0x31);

-  for (lVar5 = 0x10; lVar5 != 0; lVar5 = lVar5 + -1) {

-    *puVar6 = 0;

-    puVar6 = puVar6 + -1;

-  }

+  puVar2 = (param_2->Cmd_Periodic_Inquiry_Mode).LAP + 2;

+  bVar1 = 0;

+  do {

+    if (bVar1 != 1) {

+      if (((param_2->Cmd_Inquiry).LAP[2] & (byte)(1 << (bVar1 & 0x1f))) == 0) {

+        RadioPerfCounters::OnLEAdvertisementScanParameterChange

+                  (&param_1->PerfCounters,(uint)bVar1,0,0);

+      }

+      else {

+        RadioPerfCounters::OnLEAdvertisementScanParameterChange

+                  (&param_1->PerfCounters,(uint)bVar1,*(ushort *)puVar2,*(ushort *)(puVar2 + -2));

+        puVar2 = puVar2 + 5;

+      }

+    }

+    bVar1 = bVar1 + 1;

+  } while (bVar1 < 3);

   return;

 }
```

## `HCI_InitDefaultLocalRadioName`  (modified)

```diff
--- HCI_InitDefaultLocalRadioName
+++ HCI_InitDefaultLocalRadioName
@@ -1,372 +1,157 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl HCI_InitDefaultLocalRadioName(struct HCI_INTERFACE * __ptr64) */

 

 void __cdecl HCI_InitDefaultLocalRadioName(HCI_INTERFACE *param_1)

 

 {

-  ulong64 *puVar1;

-  AvdtpOffload *pAVar2;

-  ulong64 uVar3;

-  uchar uVar4;

-  bool bVar5;

-  char cVar6;

-  int iVar7;

-  ulong uVar8;

-  ulonglong uVar9;

-  _BIP *p_Var10;

-  uint uVar11;

-  _SCO_INTERFACE *p_Var12;

-  DEVICE_EXTENSION *pDVar13;

-  ulong64 uVar14;

-  HCI_INTERFACE *unaff_RBX;

-  undefined4 *unaff_RBP;

-  uchar uVar15;

-  AvdtpOffload *unaff_RDI;

-  _GUID *in_R8;

-  _GUID *in_R9;

-  char unaff_R12B;

-  longlong unaff_R13;

+  char *_Dst;

+  bool bVar1;

+  int iVar2;

+  undefined8 uVar3;

+  char cVar4;

+  undefined **ppuVar5;

+  undefined1 *puVar6;

+  uint uVar7;

+  undefined1 *puVar8;

+  undefined8 in_stack_ffffffffffffff38;

+  undefined4 uVar10;

+  longlong lVar9;

+  undefined8 local_b8;

+  longlong lStack_b0;

+  undefined8 local_a8;

+  undefined1 *puStack_a0;

+  undefined1 local_98 [8];

+  undefined4 local_90;

+  undefined *local_88;

+  undefined8 *local_80;

+  undefined4 local_78;

   

-  wil::acquire_kspin_lock((__uint64 *)(unaff_RBP + -6));

-  if (unaff_RBX->ControllerState != Failed) {

-    unaff_RBX->ControllerState = (HciState)unaff_RDI;

+  uVar10 = (undefined4)((ulonglong)in_stack_ffffffffffffff38 >> 0x20);

+  local_a8 = 0;

+  puStack_a0 = (undefined1 *)0x0;

+  local_b8 = 0;

+  lStack_b0 = 0;

+  puVar6 = (undefined1 *)0x0;

+  cVar4 = '\x01';

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+     (bVar1 = true, (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    bVar1 = false;

   }

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[1] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[2] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[3] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[4] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[5] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[6] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[7] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[8] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[9] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[10] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0xb] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0xc] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0xd] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0xe] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0xf] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x10] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x11] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x12] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x13] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x14] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x15] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x16] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x17] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x18] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x19] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x1a] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x1b] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x1c] = '\0';

-  unaff_RBX->LECurrentHighPriorityAdvertisingBuffer[0x1d] = '\0';

-  *(undefined4 *)(unaff_RBX->LECurrentHighPriorityAdvertisingBuffer + 0x1e) = 0;

-  *(undefined1 *)

-   ((longlong)&(unaff_RBX->LECurrentHighPriorityAdvertisingParameters).AdvertisementInterval + 1) =

-       0;

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[1] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[2] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[3] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[4] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[5] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[6] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[7] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[8] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[9] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[10] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0xb] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0xc] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0xd] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0xe] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0xf] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x10] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x11] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x12] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x13] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x14] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x15] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x16] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x17] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x18] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x19] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x1a] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x1b] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x1c] = '\0';

-  unaff_RBX->LECurrentLowPriorityAdvertisingBuffer[0x1d] = '\0';

-  *(undefined4 *)(unaff_RBX->LECurrentLowPriorityAdvertisingBuffer + 0x1e) = 0;

-  *(undefined1 *)

-   ((longlong)&(unaff_RBX->LECurrentLowPriorityAdvertisingParameters).AdvertisementInterval + 1) = 0

-  ;

-  unaff_RBX->LECurrentScanningState = (char)(short)unaff_RDI;

-  unaff_RBX->LECurrentScanType = (char)((ushort)(short)unaff_RDI >> 8);

-  uVar15 = (uchar)unaff_RDI;

-  unaff_RBX->LECurrentScanningFilterPolicy = uVar15;

-  (unaff_RBX->LECurrentScanningParameters).ScanWindow = 0;

-  (unaff_RBX->LECurrentScanningParameters).ScanInterval = 0;

-  pDVar13 = unaff_RBX->DevExt;

-  (unaff_RBX->VsMsftFilterInfo).ControllerAdvFilterState = '\x02';

-  uVar9 = pDVar13->HostSupportedFeatures;

-  if (unaff_RBX->LEEnabled == uVar15) {

-    uVar9 = uVar9 & 0xfffffffffffffffb;

+  if ((bVar1) || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),0,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->IfrLog,5,2,0xb7,

+               &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids);

   }

-  else {

-    uVar9 = uVar9 | 4;

-  }

-  pDVar13->HostSupportedFeatures = uVar9;

-  if (((unaff_RBX->SupportedCommandsMap).field0_0x0.RawMap[0x1d] & 8) != 0) {

-    puVar1 = &unaff_RBX->DevExt->HostSupportedFeatures;

-    *puVar1 = *puVar1 | 0x20;

-  }

-  pDVar13 = unaff_RBX->DevExt;

-  p_Var12 = pDVar13->Sco;

-  uVar4 = ScoInt_IsInBandSupported(p_Var12);

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

-    uVar4 = ScoInt_IsSideBandSupported(p_Var12);

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

-      pDVar13->HostSupportedFeatures = pDVar13->HostSupportedFeatures | 0x10;

+  _Dst = param_1->defLocalName;

+  memset(_Dst,0,0xf8);

+  iVar2 = BthGetPolicyString();

+  if (iVar2 < 0) {

+    ppuVar5 = &PTR_u_ComputerName_Ac_140175488;

+    puVar8 = puVar6;

+    do {

+      if (-1 < iVar2) goto LAB_0;

+      memset(local_98,0,0x70);

+      local_88 = ppuVar5[1];

+      local_80 = &local_b8;

+      local_90 = 0x124;

+      local_78 = 0x1000001;

+      iVar2 = RtlQueryRegistryValuesEx(*(undefined4 *)(ppuVar5 + -1),*ppuVar5,local_98,0,0);

+      uVar7 = (int)puVar8 + 1;

+      puVar8 = (undefined1 *)(ulonglong)uVar7;

+      ppuVar5 = ppuVar5 + 3;

+    } while (uVar7 < 2);

+    if (iVar2 < 0) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (puVar8 = &DAT_1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+        puVar8 = puVar6;

+      }

+      WPP_RECORDER_AND_TRACE_SF_L

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),(char)puVar8,1,param_1->IfrLog,2,2,0xba,

+                 &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids,iVar2);

+      lStack_b0 = 0;

+      puVar6 = puStack_a0;

+      goto LAB_2;

     }

   }

   else {

-    pDVar13->HostSupportedFeatures = pDVar13->HostSupportedFeatures | 8;

+    iVar2 = BthReportPolicyLocalDeviceName(&local_b8);

+    if (iVar2 < 0) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) >> 0xb & 1) == 0) ||

+         (uVar3 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+        uVar3 = 0;

+      }

+      WPP_RECORDER_AND_TRACE_SF_L

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,param_1->IfrLog,3,0xc,0xb8,

+                 &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids,CONCAT44(uVar10,iVar2));

+    }

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) >> 0xb & 1) == 0) ||

+       (uVar3 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar3 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_S(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3);

   }

-  if ((unaff_RBX->DevExt->TransportCapabilities).ScoCanAlignData != uVar15) {

-    puVar1 = &unaff_RBX->DevExt->HostSupportedFeatures;

-    *puVar1 = *puVar1 | 0x40;

+LAB_0:

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+     (uVar3 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+    uVar3 = 0;

   }

-  wil::details::

-  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-  ::

-  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-              *)(unaff_RBP + -6));

-  if (((unaff_RBX->VsMsftInfo).VsMsftDebugModeOn != uVar15) ||

-     ((char)(unaff_RBX->VsMsftInfo).SupportedFeatures < '\0')) {

-    AvdtpOffload::Make();

-    pAVar2 = *(AvdtpOffload **)(unaff_RBP + 0x24);

-    if (pAVar2 == (AvdtpOffload *)0x0) {

-      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29]))

-      {

-        unaff_RDI = (AvdtpOffload *)&DAT_0;

+  lVar9 = lStack_b0;

+  WPP_RECORDER_AND_TRACE_SF_S(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3);

+  uVar10 = (undefined4)((ulonglong)lVar9 >> 0x20);

+  iVar2 = EUnicodeStringToUtf8String(&local_a8,&local_b8);

+  if (iVar2 < 0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar3 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar3 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_L

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,param_1->IfrLog,2,2,0xbc,

+               &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids,CONCAT44(uVar10,iVar2));

+  }

+  else {

+    uVar7 = (ushort)local_a8 + 1;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar3 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar3 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_L

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,

+               (longlong)L"ComputerName\\ActiveComputerName" + 0x31,param_1->IfrLog,4,2,0xbd,

+               &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids,CONCAT44(uVar10,uVar7));

+    puVar6 = puStack_a0;

+    if (uVar7 < 0xf9) {

+      memmove(_Dst,puStack_a0,(ulonglong)uVar7);

+      param_1->defLocalName[0xf7] = '\0';

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (uVar3 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+        uVar3 = 0;

       }

-      WPP_RECORDER_AND_TRACE_SF_

-                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),(ulonglong)unaff_RDI & 0xff,1,

-                 unaff_RBX->IfrLog,2);

-      Controller::OnControllerInitializationComplete

-                ((Controller *)&unaff_RBX->DevExt[-2].AvdtpOffload,false);

-      utl::

-      _UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

-      ::

-      ~_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

-                ((_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

-                  *)(unaff_RBP + 0x24));

-      return;

-    }

-    wil::acquire_kspin_lock((__uint64 *)(unaff_RBP + -10));

-    pDVar13 = unaff_RBX->DevExt;

-    if ((pDVar13->AvdtpOffload)._MyDat._MyRealVal == unaff_RDI) {

-      *(AvdtpOffload **)(unaff_RBP + 0x24) = unaff_RDI;

-      (pDVar13->AvdtpOffload)._MyDat._MyRealVal = pAVar2;

-    }

-    else {

-      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

-         (uVar4 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 4)) {

-        uVar4 = uVar15;

-      }

-      in_R9 = (_GUID *)unaff_RBX->IfrLog;

-      in_R8 = (_GUID *)CONCAT71((int7)((ulonglong)in_R8 >> 8),1);

-      WPP_RECORDER_AND_TRACE_SF_i

-                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

-                 CONCAT71((int7)((ulonglong)pDVar13 >> 8),uVar4),in_R8,in_R9,4);

-    }

-    wil::details::

-    unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-    ::

-    ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-              ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                *)(unaff_RBP + -10));

-    utl::

-    _UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

-    ::

-    ~_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

-              ((_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

-                *)(unaff_RBP + 0x24));

-  }

-  wil::acquire_kspin_lock((__uint64 *)(unaff_RBP + 10));

-  p_Var10 = HCI_GetNextCommand(unaff_RBX);

-  HCI_StartIdleTimer(unaff_RBX,'\x01');

-  wil::details::

-  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-  ::

-  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-              *)(unaff_RBP + 10));

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

-    bVar5 = PowerCoordinator::IsIdlePowerDownCapable((PowerCoordinator *)(unaff_R13 + 0x300));

-    iVar7 = Feature_56664216__private_IsEnabledDeviceUsageNoInline();

-    if (iVar7 == 0) {

-      if ((4 < (uint)DAT_1) &&

-         (cVar6 = _tlgKeywordOn(&DAT_1,0x800000000111), cVar6 != '\0')) {

-        pDVar13 = unaff_RBX->DevExt;

-        uVar14 = (unaff_RBX->LocalInfo).localInfo.address;

-        *(uchar *)(unaff_RBP + 0x24) =

-             (unaff_RBX->RadioCapacity).LESupportedMaxNumberOfAdvertisingSets;

-        uVar3 = (unaff_RBX->VsMsftInfo).SupportedFeatures;

-        *(ulong64 *)(unaff_RBP + -0xc) = uVar14;

-        *(ulong64 *)(unaff_RBP + -6) = uVar3;

-        uVar8 = ErrorRecovery::GetSupportedResetTypes(&pDVar13->ErrorRecoveryHandler);

-        uVar11 = (unaff_RBX->LocalInfo).localInfo.classOfDevice;

-        unaff_RBP[-0x17] = uVar8;

-        unaff_RBP[-0x18] = (uint)(unaff_RBX->VsMsftInfo).tlvTelemetryEnabled;

-        *(ulong64 *)(unaff_RBP + -0xe) = pDVar13->HostSupportedFeatures;

-        *(_BTH_SUPPORTED_COMMANDS_MAP **)(unaff_RBP + -2) = &unaff_RBX->SupportedCommandsMap;

-        *(void **)(unaff_RBP + 6) = unaff_RBX->SupportedCodecResult;

-        *(short *)(unaff_RBP + 8) = (short)unaff_RBX->SupportedCodecResultSize;

-        unaff_RBP[-0x1b] = (uint)(unaff_RBX->IsoInitializationState).BroadcastIsoEnabled;

-        unaff_RBP[-0x1c] = (uint)(unaff_RBX->IsoInitializationState).ConnectedIsoEnabled;

-        *(FeatureOptInFlags *)(unaff_RBP + -0x10) = unaff_RBX->OptInFeatureFlags;

-        *(ulong64 *)(unaff_RBP + -0x12) = unaff_RBX->LELocalSupportedStates;

-        *(ulong64 *)(unaff_RBP + -0x14) = unaff_RBX->LELocalSupportedFeatures;

-        *(ulong64 *)(unaff_RBP + -0x16) = (unaff_RBX->LocalInfo).radioInfo.lmpSupportedFeatures;

-        *(ushort *)(unaff_RBP + -0x1e) = (unaff_RBX->LocalInfo).radioInfo.lmpSubversion;

-        *(uchar *)(unaff_RBP + 0x26) = (unaff_RBX->LocalInfo).radioInfo.lmpVersion;

-        *(ushort *)((longlong)unaff_RBP + -0x7a) = (unaff_RBX->LocalInfo).radioInfo.mfg;

-        *(ushort *)(unaff_RBP + -0x1f) = (ushort)(uVar11 >> 2) & 0x3f;

-        unaff_RBP[-0x19] = (uint)bVar5;

-        *(ushort *)((longlong)unaff_RBP + -0x7e) = (ushort)(uVar11 >> 8) & 0x1f;

-        uVar11 = uVar11 >> 0xd & 0x7ff;

-        uVar8 = (unaff_RBX->LocalInfo).localInfo.classOfDevice;

-        *unaff_RBP = 0x40;

-        *(byte *)(unaff_RBP + 0x28) = (byte)uVar8 & 3;

-        *(ushort *)(unaff_RBP + -0x20) = (unaff_RBX->LocalInfo).hciRevision;

-        *(uchar *)(unaff_RBP + 0x2a) = (unaff_RBX->LocalInfo).hciVersion;

-        *(_GUID **)(unaff_RBP + -10) = &pDVar13->DeviceExtensionSessionId;

-        unaff_RBP[-0x1a] = (uint)(uVar14 >> 0x18) & 0xffffff;

-        unaff_RBP[-0x1d] = uVar11;

-        *(undefined8 *)(unaff_RBP + 2) = 0x3000800;

-        _tlgWriteTemplate<long___cdecl(_tlgProvider_t_const*___ptr64,void_const*___ptr64,_GUID_const*___ptr64,_GUID_const*___ptr64,unsigned_int,_EVENT_DATA_DESCRIPTOR*___ptr64),&long___cdecl__tlgWriteTransfer_EtwWriteTransfer(struct__tlgProvider_t_const*___ptr64,void_const*___ptr64,struct__GUID_const*___ptr64,struct__GUID_const*___ptr64,unsigned_int,struct__EVENT_DATA_DESCRIPTOR*___ptr64),_GUID_const*___ptr64,_GUID_const*___ptr64>

-        ::

-        Write<_tlgWrapperByVal<8>,_tlgWrapperByRef<16>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<1>,_tlgWrapperByVal<4>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperArray<1>,_tlgWrapperPtrSize,_tlgWrapperByVal<4>,_tlgWrapperByVal<8>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<1>_>

-                  ((_tlgProvider_t *)(ulonglong)uVar11,&DAT_2,(_GUID *)pDVar13,in_R9,

-                   (_tlgWrapperByVal<8> *)(unaff_RBP + 2),(_tlgWrapperByRef<16> *)(unaff_RBP + -10),

-                   (_tlgWrapperByVal<1> *)(unaff_RBP + 0x2a),

-                   (_tlgWrapperByVal<2> *)(unaff_RBP + -0x20),

-                   (_tlgWrapperByVal<1> *)(unaff_RBP + 0x28),

-                   (_tlgWrapperByVal<4> *)(unaff_RBP + -0x1d),

-                   (_tlgWrapperByVal<2> *)((longlong)unaff_RBP + -0x7e),

-                   (_tlgWrapperByVal<2> *)(unaff_RBP + -0x1f),

-                   (_tlgWrapperByVal<2> *)((longlong)unaff_RBP + -0x7a),

-                   (_tlgWrapperByVal<1> *)(unaff_RBP + 0x26),

-                   (_tlgWrapperByVal<2> *)(unaff_RBP + -0x1e),

-                   (_tlgWrapperByVal<8> *)(unaff_RBP + -0x16),

-                   (_tlgWrapperByVal<8> *)(unaff_RBP + -0x14),

-                   (_tlgWrapperByVal<8> *)(unaff_RBP + -0x12),

-                   (_tlgWrapperByVal<8> *)(unaff_RBP + -0x10),

-                   (_tlgWrapperByVal<4> *)(unaff_RBP + -0x1c),

-                   (_tlgWrapperByVal<4> *)(unaff_RBP + -0x1b),

-                   (_tlgWrapperByVal<4> *)(unaff_RBP + -0x1a),(_tlgWrapperArray<1> *)(unaff_RBP + 6)

-                   ,(_tlgWrapperPtrSize *)(unaff_RBP + -2),

-                   (_tlgWrapperByVal<4> *)(unaff_RBP + -0x19),

-                   (_tlgWrapperByVal<8> *)(unaff_RBP + -0xe),

-                   (_tlgWrapperByVal<4> *)(unaff_RBP + -0x18),

-                   (_tlgWrapperByVal<4> *)(unaff_RBP + -0x17),

-                   (_tlgWrapperByVal<8> *)(unaff_RBP + -6),(_tlgWrapperByVal<8> *)(unaff_RBP + -0xc)

-                   ,(_tlgWrapperByVal<1> *)(unaff_RBP + 0x24));

-      }

-    }

-    else if ((4 < (uint)DAT_1) &&

-            (cVar6 = _tlgKeywordOn(&DAT_1,0x800000000111), cVar6 != '\0')) {

-      pDVar13 = unaff_RBX->DevExt;

-      *(uchar *)(unaff_RBP + 0x24) =

-           (unaff_RBX->RadioCapacity).LESupportedMaxNumberOfAdvertisingSets;

-      *(ulong64 *)(unaff_RBP + -10) = (unaff_RBX->VsMsftInfo).SupportedFeatures;

-      uVar8 = ErrorRecovery::GetSupportedResetTypes(&pDVar13->ErrorRecoveryHandler);

-      unaff_RBP[-0x1d] = uVar8;

-      unaff_RBP[-0x1c] = (uint)(unaff_RBX->VsMsftInfo).tlvTelemetryEnabled;

-      *(ulong64 *)(unaff_RBP + -0x16) = pDVar13->HostSupportedFeatures;

-      *(_BTH_SUPPORTED_COMMANDS_MAP **)(unaff_RBP + 2) = &unaff_RBX->SupportedCommandsMap;

-      uVar11 = (unaff_RBX->LocalInfo).localInfo.classOfDevice;

-      *(void **)(unaff_RBP + -2) = unaff_RBX->SupportedCodecResult;

-      *(short *)unaff_RBP = (short)unaff_RBX->SupportedCodecResultSize;

-      uVar14 = (unaff_RBX->LocalInfo).localInfo.address;

-      unaff_RBP[-0x1b] = (uint)bVar5;

-      unaff_RBP[-0x1a] = (uint)(uVar14 >> 0x18) & 0xffffff;

-      unaff_RBP[-0x19] = (uint)(unaff_RBX->IsoInitializationState).BroadcastIsoEnabled;

-      unaff_RBP[-0x18] = (uint)(unaff_RBX->IsoInitializationState).ConnectedIsoEnabled;

-      *(FeatureOptInFlags *)(unaff_RBP + -0x14) = unaff_RBX->OptInFeatureFlags;

-      *(ulong64 *)(unaff_RBP + -0x12) = unaff_RBX->LELocalSupportedStates;

-      *(ulong64 *)(unaff_RBP + -0x10) = unaff_RBX->LELocalSupportedFeatures;

-      *(ulong64 *)(unaff_RBP + -0xe) = (unaff_RBX->LocalInfo).radioInfo.lmpSupportedFeatures;

-      *(ushort *)(unaff_RBP + -0x20) = (unaff_RBX->LocalInfo).radioInfo.lmpSubversion;

-      *(uchar *)(unaff_RBP + 0x26) = (unaff_RBX->LocalInfo).radioInfo.lmpVersion;

-      *(ushort *)((longlong)unaff_RBP + -0x7e) = (unaff_RBX->LocalInfo).radioInfo.mfg;

-      unaff_RBP[4] = 0x40;

-      *(ushort *)(unaff_RBP + -0x1f) = (ushort)(uVar11 >> 2) & 0x3f;

-      *(ushort *)((longlong)unaff_RBP + -0x7a) = (ushort)(uVar11 >> 8) & 0x1f;

-      uVar11 = uVar11 >> 0xd & 0x7ff;

-      uVar8 = (unaff_RBX->LocalInfo).localInfo.classOfDevice;

-      unaff_RBP[-0x17] = uVar11;

-      *(byte *)(unaff_RBP + 0x28) = (byte)uVar8 & 3;

-      *(ushort *)(unaff_RBP + -0x1e) = (unaff_RBX->LocalInfo).hciRevision;

-      *(uchar *)(unaff_RBP + 0x2a) = (unaff_RBX->LocalInfo).hciVersion;

-      *(_GUID **)(unaff_RBP + -6) = &pDVar13->DeviceExtensionSessionId;

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

-      _tlgWriteTemplate<long___cdecl(_tlgProvider_t_const*___ptr64,void_const*___ptr64,_GUID_const*___ptr64,_GUID_const*___ptr64,unsigned_int,_EVENT_DATA_DESCRIPTOR*___ptr64),&long___cdecl__tlgWriteTransfer_EtwWriteTransfer(struct__tlgProvider_t_const*___ptr64,void_const*___ptr64,struct__GUID_const*___ptr64,struct__GUID_const*___ptr64,unsigned_int,struct__EVENT_DATA_DESCRIPTOR*___ptr64),_GUID_const*___ptr64,_GUID_const*___ptr64>

-      ::

-      Write<_tlgWrapperByVal<8>,_tlgWrapperByRef<16>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<1>,_tlgWrapperByVal<4>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperArray<1>,_tlgWrapperPtrSize,_tlgWrapperByVal<4>,_tlgWrapperByVal<8>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperByVal<8>,_tlgWrapperByVal<1>_>

-                ((_tlgProvider_t *)(ulonglong)uVar11,&DAT_3,in_R8,in_R9,

-                 (_tlgWrapperByVal<8> *)(unaff_RBP + -0xc),(_tlgWrapperByRef<16> *)(unaff_RBP + -6),

-                 (_tlgWrapperByVal<1> *)(unaff_RBP + 0x2a),

-                 (_tlgWrapperByVal<2> *)(unaff_RBP + -0x1e),

-                 (_tlgWrapperByVal<1> *)(unaff_RBP + 0x28),

-                 (_tlgWrapperByVal<4> *)(unaff_RBP + -0x17),

-                 (_tlgWrapperByVal<2> *)((longlong)unaff_RBP + -0x7a),

-                 (_tlgWrapperByVal<2> *)(unaff_RBP + -0x1f),

-                 (_tlgWrapperByVal<2> *)((longlong)unaff_RBP + -0x7e),

-                 (_tlgWrapperByVal<1> *)(unaff_RBP + 0x26),

-                 (_tlgWrapperByVal<2> *)(unaff_RBP + -0x20),

-                 (_tlgWrapperByVal<8> *)(unaff_RBP + -0xe),

-                 (_tlgWrapperByVal<8> *)(unaff_RBP + -0x10),

-                 (_tlgWrapperByVal<8> *)(unaff_RBP + -0x12),

-                 (_tlgWrapperByVal<8> *)(unaff_RBP + -0x14),

-                 (_tlgWrapperByVal<4> *)(unaff_RBP + -0x18),

-                 (_tlgWrapperByVal<4> *)(unaff_RBP + -0x19),

-                 (_tlgWrapperByVal<4> *)(unaff_RBP + -0x1a),(_tlgWrapperArray<1> *)(unaff_RBP + -2),

-                 (_tlgWrapperPtrSize *)(unaff_RBP + 2),(_tlgWrapperByVal<4> *)(unaff_RBP + -0x1b),

-                 (_tlgWrapperByVal<8> *)(unaff_RBP + -0x16),

-                 (_tlgWrapperByVal<4> *)(unaff_RBP + -0x1c),

-                 (_tlgWrapperByVal<4> *)(unaff_RBP + -0x1d),(_tlgWrapperByVal<8> *)(unaff_RBP + -10)

-                 ,(_tlgWrapperByVal<1> *)(unaff_RBP + 0x24));

+      WPP_RECORDER_AND_TRACE_SF_s

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,param_1->IfrLog,4,2,0xbe,

+                 &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids,_Dst);

     }

   }

-  pDVar13 = unaff_RBX->DevExt;

-  uVar4 = ScoInt_IsInBandSupported(pDVar13->Sco);

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

-    pDVar13->HostSupportedFeatures = pDVar13->HostSupportedFeatures & 0xffffffffffffffdf;

+LAB_2:

+  if (param_1->defLocalName[0] == '\0') {

+    RtlStringCbCopyA(_Dst,0xf8,"Windows Device");

   }

-  if (p_Var10 != (_BIP *)0x0) {

-    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x40) == 0) ||

-       (uVar9 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

-      uVar9 = (ulonglong)unaff_RDI & 0xff;

-    }

-    WPP_RECORDER_AND_TRACE_SF_i

-              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar9,1,unaff_RBX->IfrLog,4);

-    HCI_WriteCommand(unaff_RBX,p_Var10);

+  if (puVar6 != (undefined1 *)0x0) {

+    ExFreePoolWithTag(puVar6,0);

   }

-  HCI_LEResetScanParameters(unaff_RBX,PostRadioInitialization,false);

-  HciLE_ResumeRandomAddressTimer(unaff_RBX);

-  if (unaff_RBX->IsLEExtendedAdvertisingEnabled == (bool)uVar15) {

-    KeSetEvent(unaff_RBX->ThreadEvents + 8,0,0);

+  if (lStack_b0 != 0) {

+    RtlFreeUnicodeString(&local_b8);

   }

-  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) && (3 < (byte)WPP_GLOBAL_Control[0x29])) {

-    unaff_RDI = (AvdtpOffload *)&DAT_0;

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    cVar4 = '\0';

   }

-  WPP_RECORDER_AND_TRACE_SF_

-            (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),(ulonglong)unaff_RDI & 0xff,1,

-             unaff_RBX->IfrLog,4);

-  Controller::OnControllerInitializationComplete

-            ((Controller *)&unaff_RBX->DevExt[-2].AvdtpOffload,true);

+  if ((cVar4 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar4,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->IfrLog,5,2,0xbf,

+               &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids);

+  }

   return;

 }
```

## `HCI_Shutdown`  (modified)

```diff
--- HCI_Shutdown
+++ HCI_Shutdown
@@ -1,14 +1,19 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl HCI_Shutdown(struct HCI_INTERFACE * __ptr64) */

 

 void __cdecl HCI_Shutdown(HCI_INTERFACE *param_1)

 

 {

-  byte *pbVar1;

-  longlong in_RAX;

+  uchar in_DL;

   

-  pbVar1 = (byte *)(in_RAX + -0x7d);

-  *pbVar1 = *pbVar1 >> 4 | *pbVar1 << 4;

+  param_1->PendingCommandTimer = (WDFTIMER__ *)0x0;

+  HCI_StopCacheCleanupTimer(param_1,in_DL);

+  HCI_DibStoreAndPurge(param_1);

+  HciLEAdv_StopTimeSlicingTimer(param_1);

+  HciLE_PauseRandomAddressTimer(param_1);

+  HCI_StopCommandCreditReturnTimer(param_1);

+  HCI_DestroyThread(param_1);

   return;

 }
```

## `HCI_DibConnectResult`  (modified)

```diff
--- HCI_DibConnectResult
+++ HCI_DibConnectResult
@@ -1,305 +1,267 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* unsigned char __cdecl HCI_DibConnectResult(struct DEVICE_INFO_BLOCK * __ptr64,unsigned char,enum

+   _HCI_PHY_TYPE,unsigned long,unsigned char) */

 

 uchar __cdecl

 HCI_DibConnectResult

           (DEVICE_INFO_BLOCK *param_1,uchar param_2,_HCI_PHY_TYPE param_3,ulong param_4,

           uchar param_5)

 

 {

-  undefined8 uVar1;

-  undefined8 uVar2;

-  ulong64 uVar3;

-  char in_AL;

-  uchar extraout_AL;

-  char *pcVar4;

-  undefined8 *puVar5;

-  uchar uVar6;

-  char *pcVar7;

-  undefined8 *puVar8;

-  _BTH_DEVICE_INFO_V2 *unaff_RBX;

-  longlong unaff_RBP;

-  longlong unaff_RSI;

-  longlong unaff_RDI;

-  uint uVar9;

+  ulong *puVar1;

+  uchar *puVar2;

+  ulong uVar3;

+  _LIST_ENTRY *p_Var4;

+  undefined1 *puVar5;

+  longlong *plVar6;

+  undefined8 uVar7;

+  RECORDER_LOG__ *pRVar8;

+  code *pcVar9;

+  uint uVar10;

+  DEVICE_INFO_BLOCK *pDVar11;

+  _LIST_ENTRY *p_Var12;

+  intrusive_list_hook *piVar13;

+  undefined7 in_register_00000011;

+  ulonglong uVar14;

+  undefined8 uVar15;

+  undefined1 *puVar16;

+  undefined1 *puVar17;

+  undefined1 uVar18;

   undefined7 in_register_00000081;

-  longlong unaff_R13;

-  longlong unaff_R14;

-  char unaff_R15B;

-  char in_CF;

+  uchar uVar19;

+  undefined1 auStack_68 [8];

+  undefined1 auStack_60 [24];

+  undefined1 local_48;

+  undefined4 local_40;

+  undefined2 local_38;

+  undefined *local_30;

+  DEVICE_INFO_BLOCK *local_28;

+  uint local_20;

   

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

-  pcVar4 = (char *)((longlong)&(param_1->RefObj).DestroyFunction + 7);

-  *pcVar4 = (*pcVar4 - in_AL) - in_CF;

-  if (*(uint *)(*(longlong *)(unaff_RDI + 0x378) + 0xbc8) <

-      (uint)(*(int *)(*(longlong *)(unaff_RDI + 0x378) + 0x968) - *(int *)(unaff_RDI + 0x360))) {

-    if ((param_4 >> 0xf & 1) != 0) {

-      *(undefined8 *)(unaff_RBP + 0x30) = _DAT_0;

-      ExSystemTimeToLocalTime(unaff_RBP + 0x30);

-      if (*(longlong *)(*(longlong *)(unaff_RDI + 0x378) + 0xf40) <

-          *(longlong *)(unaff_RBP + 0x30) - *(longlong *)(unaff_RDI + 0x670)) {

-        uVar9 = unaff_RBX->flags & 0xfd7fffff;

-      }

-      else {

-        uVar9 = unaff_RBX->flags | 0x800000;

-      }

-      goto LAB_1;

-    }

+  uVar14 = CONCAT71(in_register_00000011,param_2);

+  puVar16 = auStack_68;

+  uVar18 = 0;

+  uVar19 = '\0';

+  LOCK();

+  param_1->DibFlags = (atomic<unsigned___int64>)((ulonglong)param_1->DibFlags & 0xfffffffffffffff7);

+  UNLOCK();

+  (param_1->DeviceInfo).flags = (param_1->DeviceInfo).flags & 0xfdffffff;

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

+    puVar17 = auStack_68;

+    if (((ulonglong)param_1->DibFlags >> 8 & 1) == 0) goto LAB_0;

+    puVar17 = auStack_68;

+    if (param_1->numCreatedForConnect == 0) goto LAB_1;

+    uVar10 = param_1->numCreatedForConnect - 1;

+    param_1->numCreatedForConnect = uVar10;

+    puVar17 = auStack_68;

+    if (uVar10 != 0) goto LAB_0;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar14 = CONCAT71(in_register_00000011,1), (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar14 = uVar14 & 0xffffffffffffff00;

+    }

+    local_30 = &WPP_ad144674c127399e1f530e053018150b_Traceguids;

+    local_38 = 0x52;

+    local_40 = 2;

+    local_48 = 4;

+    local_28 = param_1;

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,CONCAT71(in_register_00000081,1),

+               param_1->IfrLog);

+    HCI_RemoveDibFromDeviceListLocked(param_1->Hci,param_1);

+    piVar13 = &param_1->DisposableListEntry;

+    puVar17 = *(undefined1 **)&piVar13->field_0x0;

+    if ((intrusive_list_hook *)puVar17 != piVar13) {

+      if (((intrusive_list_hook *)*(undefined1 **)(puVar17 + 8) != piVar13) ||

+         (plVar6 = *(longlong **)&(param_1->DisposableListEntry).field_0x8,

+         (intrusive_list_hook *)*plVar6 != piVar13)) goto LAB_2;

+      *plVar6 = (longlong)puVar17;

+      *(longlong **)(puVar17 + 8) = plVar6;

+      *(intrusive_list_hook **)&(param_1->DisposableListEntry).field_0x8 = piVar13;

+      *(intrusive_list_hook **)&piVar13->field_0x0 = piVar13;

+      uVar3 = param_1->Hci->NumberOfDisposableDevices;

+      if (uVar3 != 0) {

+        param_1->Hci->NumberOfDisposableDevices = uVar3 - 1;

+      }

+    }

+    uVar19 = '\x01';

   }

   else {

-    uVar9 = uVar9 | (uint)unaff_R14;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar14 = CONCAT71(in_register_00000011,1), (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar14 = uVar14 & 0xffffffffffffff00;

+    }

+    local_28 = (DEVICE_INFO_BLOCK *)CONCAT44(local_28._4_4_,param_4);

+    local_30 = &WPP_ad144674c127399e1f530e053018150b_Traceguids;

+    local_38 = 0x51;

+    local_40 = 2;

+    local_48 = 4;

+    local_20 = (uint)param_3;

+    WPP_RECORDER_AND_TRACE_SF_LD

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,

+               CONCAT71(in_register_00000081,param_3),param_1->IfrLog);

+    param_1->LastConnectionIdentifier = param_4;

+    if (param_3 == HciPhyTypeBR) {

+      (param_1->DeviceInfo).flags = (param_1->DeviceInfo).flags | 0x20;

+    }

+    else if (param_3 == 1) {

+      uVar10 = (param_1->DeviceInfo).flags;

+      (param_1->DeviceInfo).flags = uVar10 | 0x1000000;

+      if ((uVar10 >> 0xe & 1) == 0) {

+        (param_1->DeviceInfo).flags = uVar10 | 0x1000020;

+      }

+    }

+    LOCK();

+    param_1->DibFlags =

+         (atomic<unsigned___int64>)((ulonglong)param_1->DibFlags & 0xfffffffffffffeff);

+    UNLOCK();

+    param_1->numCreatedForConnect = 0;

+    puVar17 = auStack_68;

+    if (param_1->Hci->CacheEntryDisposableLimit == 0) goto LAB_0;

+    uVar10 = (param_1->DeviceInfo).flags;

+    if (((((uVar10 >> 0xe & 1) == 0) || (param_1->LinkedDibAddress != 0)) &&

+        ((uVar10 & 0x1030038) == 0)) &&

+       ((((ulonglong)param_1->DibFlags & 8) == 0 &&

+        ((intrusive_list_hook *)*(undefined1 **)&param_1->ListEntry != &param_1->ListEntry)))) {

+      pDVar11 = HCI_FindLinkedDib(&param_1->Hci->DeviceList,param_1);

+      if ((pDVar11 == (DEVICE_INFO_BLOCK *)0x0) ||

+         ((((uVar10 = (pDVar11->DeviceInfo).flags, (uVar10 >> 0xe & 1) == 0 ||

+            (pDVar11->LinkedDibAddress != 0)) && ((uVar10 & 0x1030038) == 0)) &&

+          (((ulonglong)pDVar11->DibFlags & 8) == 0)))) {

+        piVar13 = &param_1->DisposableListEntry;

+        puVar17 = *(undefined1 **)piVar13;

+        if ((intrusive_list_hook *)puVar17 == piVar13) {

+          puVar1 = &param_1->Hci->NumberOfDisposableDevices;

+          *puVar1 = *puVar1 + 1;

+        }

+        else {

+          if (((intrusive_list_hook *)*(undefined1 **)(puVar17 + 8) != piVar13) ||

+             (plVar6 = *(longlong **)&(param_1->DisposableListEntry).field_0x8,

+             (intrusive_list_hook *)*plVar6 != piVar13)) goto LAB_2;

+          *plVar6 = (longlong)puVar17;

+          *(longlong **)(puVar17 + 8) = plVar6;

+          *(intrusive_list_hook **)&(param_1->DisposableListEntry).field_0x8 = piVar13;

+          *(intrusive_list_hook **)piVar13 = piVar13;

+        }

+        p_Var12 = &param_1->Hci->DisposableDeviceList;

+        p_Var4 = p_Var12->Flink;

+        if (p_Var4->Blink != p_Var12) goto LAB_2;

+        *(_LIST_ENTRY **)piVar13 = p_Var4;

+        *(_LIST_ENTRY **)&(param_1->DisposableListEntry).field_0x8 = p_Var12;

+        p_Var4->Blink = (_LIST_ENTRY *)piVar13;

+        p_Var12->Flink = (_LIST_ENTRY *)piVar13;

+        puVar17 = auStack_68;

+        if (pDVar11 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_0;

+      }

+      piVar13 = &pDVar11->DisposableListEntry;

+      puVar5 = *(undefined1 **)piVar13;

+      puVar17 = auStack_68;

+      if ((intrusive_list_hook *)puVar5 == piVar13) goto LAB_0;

+      if (((intrusive_list_hook *)*(undefined1 **)(puVar5 + 8) == piVar13) &&

+         (plVar6 = *(longlong **)&(pDVar11->DisposableListEntry).field_0x8,

+         (intrusive_list_hook *)*plVar6 == piVar13)) {

+        *plVar6 = (longlong)puVar5;

+        *(longlong **)(puVar5 + 8) = plVar6;

+        *(intrusive_list_hook **)&(pDVar11->DisposableListEntry).field_0x8 = piVar13;

+        *(intrusive_list_hook **)piVar13 = piVar13;

+        p_Var12 = &pDVar11->Hci->DisposableDeviceList;

+        p_Var4 = p_Var12->Flink;

+        if (p_Var4->Blink == p_Var12) {

+          *(_LIST_ENTRY **)piVar13 = p_Var4;

+          *(_LIST_ENTRY **)&(pDVar11->DisposableListEntry).field_0x8 = p_Var12;

+          p_Var4->Blink = (_LIST_ENTRY *)piVar13;

+          p_Var12->Flink = (_LIST_ENTRY *)piVar13;

+          puVar17 = auStack_68;

+          goto LAB_0;

+        }

+      }

+    }

+    else {

+      piVar13 = &param_1->DisposableListEntry;

+      puVar17 = *(undefined1 **)piVar13;

+      if ((intrusive_list_hook *)puVar17 != piVar13) {

+        if (((intrusive_list_hook *)*(undefined1 **)(puVar17 + 8) != piVar13) ||

+           (plVar6 = *(longlong **)&(param_1->DisposableListEntry).field_0x8,

+           (intrusive_list_hook *)*plVar6 != piVar13)) goto LAB_2;

+        *plVar6 = (longlong)puVar17;

+        *(longlong **)(puVar17 + 8) = plVar6;

+        *(intrusive_list_hook **)&(param_1->DisposableListEntry).field_0x8 = piVar13;

+        *(intrusive_list_hook **)piVar13 = piVar13;

+        uVar3 = param_1->Hci->NumberOfDisposableDevices;

+        if (uVar3 != 0) {

+          param_1->Hci->NumberOfDisposableDevices = uVar3 - 1;

+        }

+      }

+      pDVar11 = HCI_FindLinkedDib(&param_1->Hci->DeviceList,param_1);

+      puVar17 = auStack_68;

+      if (pDVar11 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_0;

+      piVar13 = &pDVar11->DisposableListEntry;

+      puVar5 = *(undefined1 **)piVar13;

+      puVar17 = auStack_68;

+      if ((intrusive_list_hook *)puVar5 == piVar13) goto LAB_0;

+      if (((intrusive_list_hook *)*(undefined1 **)(puVar5 + 8) == piVar13) &&

+         (plVar6 = *(longlong **)&(pDVar11->DisposableListEntry).field_0x8,

+         (intrusive_list_hook *)*plVar6 == piVar13)) {

+        *plVar6 = (longlong)puVar5;

+        *(longlong **)(puVar5 + 8) = plVar6;

+        *(intrusive_list_hook **)&(pDVar11->DisposableListEntry).field_0x8 = piVar13;

+        *(intrusive_list_hook **)piVar13 = piVar13;

+        uVar3 = pDVar11->Hci->NumberOfDisposableDevices;

+        puVar17 = auStack_68;

+        if (uVar3 != 0) {

+          pDVar11->Hci->NumberOfDisposableDevices = uVar3 - 1;

+          puVar17 = auStack_68;

+        }

+        goto LAB_0;

+      }

+    }

+LAB_2:

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

+    (*pcVar9)(3);

+    puVar17 = auStack_60;

 LAB_1:

-    unaff_RBX->flags = uVar9;

+    puVar16 = puVar17;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar15 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar15 = 0;

+    }

+    pRVar8 = param_1->IfrLog;

+    uVar7 = *(undefined8 *)(WPP_GLOBAL_Control + 0x18);

+    *(DEVICE_INFO_BLOCK **)(puVar16 + 0x40) = param_1;

+    *(undefined **)(puVar16 + 0x38) = &WPP_ad144674c127399e1f530e053018150b_Traceguids;

+    *(undefined2 *)(puVar16 + 0x30) = 0x53;

+    *(undefined4 *)(puVar16 + 0x28) = 2;

+    puVar16[0x20] = 2;

+    *(undefined8 *)(puVar16 + -8) = 0x140054472;

+    WPP_RECORDER_AND_TRACE_SF_i(uVar7,uVar15,1,pRVar8);

+    *(undefined8 *)(puVar16 + -8) = 0x14005447e;

+    MicrosoftTelemetryAssertTriggeredMsgKM("numCreatedForConnect already 0.");

+    uVar19 = '\0';

   }

-  pcVar4 = (char *)(unaff_RDI + 0x158);

-  if (*pcVar4 == unaff_R15B) {

-    if (((*(uint *)(unaff_RDI + 0x18) & 4) == 0) || (*(byte *)(unaff_RDI + 0x5b5) == 0)) {

-      uVar9 = 0xf0;

-      *(undefined8 *)unaff_RBX->name = *(undefined8 *)(unaff_RDI + 0x2c);

-    }

-    else {

-      memmove(unaff_RBX->name,(void *)(unaff_RDI + 0x2c),(ulonglong)*(byte *)(unaff_RDI + 0x5b5));

-      uVar9 = 0xf8 - *(byte *)(unaff_RDI + 0x5b5);

-      if (uVar9 == 0) goto LAB_2;

-    }

-    memset((void *)((longlong)unaff_RBX + (0x10c - (ulonglong)uVar9)),0,(ulonglong)uVar9);

+  LOCK();

+  param_1->DibFlags = (atomic<unsigned___int64>)((ulonglong)param_1->DibFlags & 0xfffffffffffffeff);

+  UNLOCK();

+  puVar17 = puVar16;

+LAB_0:

+  if (((ulonglong)param_1->DibFlags >> 9 & 1) != 0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) && (3 < (byte)WPP_GLOBAL_Control[0x29])) {

+      uVar18 = 1;

+    }

+    pRVar8 = param_1->IfrLog;

+    uVar15 = *(undefined8 *)(WPP_GLOBAL_Control + 0x18);

+    *(undefined **)(puVar17 + 0x38) = &WPP_ad144674c127399e1f530e053018150b_Traceguids;

+    *(undefined2 *)(puVar17 + 0x30) = 0x54;

+    *(undefined4 *)(puVar17 + 0x28) = 2;

+    puVar17[0x20] = 4;

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

+    WPP_RECORDER_AND_TRACE_SF_(uVar15,uVar18,1,pRVar8);

+    puVar2 = &param_1->Hci->NumUnknownConnectRequests;

+    *puVar2 = *puVar2 + 0xff;

+    LOCK();

+    param_1->DibFlags =

+         (atomic<unsigned___int64>)((ulonglong)param_1->DibFlags & 0xfffffffffffffdff);

+    UNLOCK();

   }

-  else {

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x160);

-    *(undefined8 *)unaff_RBX->name = *(undefined8 *)pcVar4;

-    *(undefined8 *)(unaff_RBX->name + 8) = uVar1;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x170);

-    *(undefined8 *)(unaff_RBX->name + 0x10) = *(undefined8 *)(unaff_RDI + 0x168);

-    *(undefined8 *)(unaff_RBX->name + 0x18) = uVar1;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x180);

-    *(undefined8 *)(unaff_RBX->name + 0x20) = *(undefined8 *)(unaff_RDI + 0x178);

-    *(undefined8 *)(unaff_RBX->name + 0x28) = uVar1;

-    uVar1 = *(undefined8 *)(unaff_RDI + 400);

-    *(undefined8 *)(unaff_RBX->name + 0x30) = *(undefined8 *)(unaff_RDI + 0x188);

-    *(undefined8 *)(unaff_RBX->name + 0x38) = uVar1;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x1a0);

-    *(undefined8 *)(unaff_RBX->name + 0x40) = *(undefined8 *)(unaff_RDI + 0x198);

-    *(undefined8 *)(unaff_RBX->name + 0x48) = uVar1;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x1b0);

-    *(undefined8 *)(unaff_RBX->name + 0x50) = *(undefined8 *)(unaff_RDI + 0x1a8);

-    *(undefined8 *)(unaff_RBX->name + 0x58) = uVar1;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x1c0);

-    *(undefined8 *)(unaff_RBX->name + 0x60) = *(undefined8 *)(unaff_RDI + 0x1b8);

-    *(undefined8 *)(unaff_RBX->name + 0x68) = uVar1;

-    pcVar7 = unaff_RBX->name + unaff_R14;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x1d0);

-    pcVar4 = pcVar4 + unaff_R14;

-    *(undefined8 *)(pcVar7 + -0x10) = *(undefined8 *)(unaff_RDI + 0x1c8);

-    *(undefined8 *)(pcVar7 + -8) = uVar1;

-    uVar1 = *(undefined8 *)(pcVar4 + 8);

-    *(undefined8 *)pcVar7 = *(undefined8 *)pcVar4;

-    *(undefined8 *)(pcVar7 + 8) = uVar1;

-    uVar1 = *(undefined8 *)(pcVar4 + 0x18);

-    *(undefined8 *)(pcVar7 + 0x10) = *(undefined8 *)(pcVar4 + 0x10);

-    *(undefined8 *)(pcVar7 + 0x18) = uVar1;

-    uVar1 = *(undefined8 *)(pcVar4 + 0x28);

-    *(undefined8 *)(pcVar7 + 0x20) = *(undefined8 *)(pcVar4 + 0x20);

-    *(undefined8 *)(pcVar7 + 0x28) = uVar1;

-    uVar1 = *(undefined8 *)(pcVar4 + 0x38);

-    *(undefined8 *)(pcVar7 + 0x30) = *(undefined8 *)(pcVar4 + 0x30);

-    *(undefined8 *)(pcVar7 + 0x38) = uVar1;

-    uVar1 = *(undefined8 *)(pcVar4 + 0x48);

-    *(undefined8 *)(pcVar7 + 0x40) = *(undefined8 *)(pcVar4 + 0x40);

-    *(undefined8 *)(pcVar7 + 0x48) = uVar1;

-    uVar1 = *(undefined8 *)(pcVar4 + 0x58);

-    *(undefined8 *)(pcVar7 + 0x50) = *(undefined8 *)(pcVar4 + 0x50);

-    *(undefined8 *)(pcVar7 + 0x58) = uVar1;

-    uVar1 = *(undefined8 *)(pcVar4 + 0x68);

-    *(undefined8 *)(pcVar7 + 0x60) = *(undefined8 *)(pcVar4 + 0x60);

-    *(undefined8 *)(pcVar7 + 0x68) = uVar1;

-    *(undefined8 *)(pcVar7 + 0x70) = *(undefined8 *)(pcVar4 + 0x70);

-    unaff_RBX->flags = uVar9 | 4;

-  }

-LAB_2:

-  if ((*(uint *)(unaff_RDI + 0x18) >> 0xf & 1) == 0) {

-    uVar6 = 0xff;

-  }

-  else {

-    uVar6 = '\0';

-    if (*(uchar *)(unaff_RDI + 0x5b0) != 0xff) {

-      uVar6 = *(uchar *)(unaff_RDI + 0x5b0);

-    }

-  }

-  unaff_RBX->LEAddressType = uVar6;

-  unaff_RBX->RSSI = *(long *)(unaff_RDI + 0x124);

-  if (((unaff_RBX->flags & 0x30018) == 0) &&

-     ((unaff_RBX->ContainerIdSource != ContainerIdSourceGenerated ||

-      (unaff_RBX->LEContainerIdSource != LEContainerIdSourceGenerated)))) {

-    HCI_SetDefaultContainerIdsInDeviceInfoV2

-              (*(HCI_INTERFACE **)(unaff_RDI + 0x378),unaff_RBX->address,unaff_RBX);

-  }

-  else {

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x134);

-    uVar2 = *(undefined8 *)(unaff_RDI + 0x13c);

-    (unaff_RBX->ContainerId).Data1 = (int)uVar1;

-    (unaff_RBX->ContainerId).Data2 = (short)((ulonglong)uVar1 >> 0x20);

-    (unaff_RBX->ContainerId).Data3 = (short)((ulonglong)uVar1 >> 0x30);

-    *(undefined8 *)(unaff_RBX->ContainerId).Data4 = uVar2;

-    unaff_RBX->ContainerIdSource = *(_BTH_DEVICE_CONTAINER_ID_SOURCE *)(unaff_RDI + 300);

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x144);

-    uVar2 = *(undefined8 *)(unaff_RDI + 0x14c);

-    (unaff_RBX->LEContainerId).Data1 = (int)uVar1;

-    (unaff_RBX->LEContainerId).Data2 = (short)((ulonglong)uVar1 >> 0x20);

-    (unaff_RBX->LEContainerId).Data3 = (short)((ulonglong)uVar1 >> 0x30);

-    *(undefined8 *)(unaff_RBX->LEContainerId).Data4 = uVar2;

-    unaff_RBX->LEContainerIdSource = *(_BTH_LE_DEVICE_CONTAINER_ID_SOURCE *)(unaff_RDI + 0x130);

-  }

-  uVar1 = *(undefined8 *)(unaff_RDI + 600);

-  pcVar4 = unaff_RBX[1].name + 0xdc;

-  *(undefined8 *)&unaff_RBX->field_0x13d = *(undefined8 *)(unaff_RDI + 0x250);

-  *(undefined8 *)&unaff_RBX[1].field_0x5 = uVar1;

-  uVar1 = *(undefined8 *)(unaff_RDI + 0x268);

-  *(undefined8 *)((longlong)&unaff_RBX[1].address + 5) = *(undefined8 *)(unaff_RDI + 0x260);

-  *(undefined8 *)(unaff_RBX[1].name + 1) = uVar1;

-  uVar1 = *(undefined8 *)(unaff_RDI + 0x278);

-  *(undefined8 *)(unaff_RBX[1].name + 9) = *(undefined8 *)(unaff_RDI + 0x270);

-  *(undefined8 *)(unaff_RBX[1].name + 0x11) = uVar1;

-  uVar1 = *(undefined8 *)(unaff_RDI + 0x288);

-  *(undefined8 *)(unaff_RBX[1].name + 0x19) = *(undefined8 *)(unaff_RDI + 0x280);

-  *(undefined8 *)(unaff_RBX[1].name + 0x21) = uVar1;

-  uVar1 = *(undefined8 *)(unaff_RDI + 0x298);

-  *(undefined8 *)(unaff_RBX[1].name + 0x29) = *(undefined8 *)(unaff_RDI + 0x290);

-  *(undefined8 *)(unaff_RBX[1].name + 0x31) = uVar1;

-  uVar1 = *(undefined8 *)(unaff_RDI + 0x2a8);

-  *(undefined8 *)(unaff_RBX[1].name + 0x39) = *(undefined8 *)(unaff_RDI + 0x2a0);

-  *(undefined8 *)(unaff_RBX[1].name + 0x41) = uVar1;

-  uVar1 = *(undefined8 *)(unaff_RDI + 0x2b8);

-  *(undefined8 *)(unaff_RBX[1].name + 0x49) = *(undefined8 *)(unaff_RDI + 0x2b0);

-  *(undefined8 *)(unaff_RBX[1].name + 0x51) = uVar1;

-  puVar8 = (undefined8 *)(&unaff_RBX->field_0x13d + unaff_R14);

-  uVar1 = *(undefined8 *)(unaff_RDI + 0x2c8);

-  puVar5 = (undefined8 *)(unaff_RDI + 0x250 + unaff_R14);

-  puVar8[-2] = *(undefined8 *)(unaff_RDI + 0x2c0);

-  puVar8[-1] = uVar1;

-  uVar1 = puVar5[1];

-  *puVar8 = *puVar5;

-  puVar8[1] = uVar1;

-  uVar1 = puVar5[3];

-  puVar8[2] = puVar5[2];

-  puVar8[3] = uVar1;

-  uVar1 = puVar5[5];

-  puVar8[4] = puVar5[4];

-  puVar8[5] = uVar1;

-  uVar1 = puVar5[7];

-  puVar8[6] = puVar5[6];

-  puVar8[7] = uVar1;

-  uVar1 = puVar5[9];

-  puVar8[8] = puVar5[8];

-  puVar8[9] = uVar1;

-  uVar1 = puVar5[0xb];

-  puVar8[10] = puVar5[10];

-  puVar8[0xb] = uVar1;

-  uVar1 = puVar5[0xd];

-  puVar8[0xc] = puVar5[0xc];

-  puVar8[0xd] = uVar1;

-  memset(pcVar4,0,0xf8);

-  if (*(char *)(unaff_RDI + 0x158) == '\0') {

-    if (((*(uint *)(unaff_RDI + 0x18) & 0x400000) != 0) && (*(byte *)(unaff_RDI + 0x792) != 0)) {

-      memmove(pcVar4,(void *)(unaff_RDI + 0x69a),(ulonglong)*(byte *)(unaff_RDI + 0x792));

-    }

-  }

-  else {

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x160);

-    *(undefined8 *)pcVar4 = *(undefined8 *)(unaff_RDI + 0x158);

-    *(undefined8 *)(unaff_RBX[1].name + 0xe4) = uVar1;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x170);

-    *(undefined8 *)(unaff_RBX[1].name + 0xec) = *(undefined8 *)(unaff_RDI + 0x168);

-    *(undefined8 *)(unaff_RBX[1].name + 0xf4) = uVar1;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x178);

-    uVar2 = *(undefined8 *)(unaff_RDI + 0x180);

-    unaff_RBX[1].TxPower = (char)uVar1;

-    *(int3 *)&unaff_RBX[1].field_0x111 = (int3)((ulonglong)uVar1 >> 8);

-    unaff_RBX[1].ContainerIdSource = (int)((ulonglong)uVar1 >> 0x20);

-    unaff_RBX[1].LEContainerIdSource = (int)uVar2;

-    unaff_RBX[1].ContainerId.Data1 = (int)((ulonglong)uVar2 >> 0x20);

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x188);

-    uVar2 = *(undefined8 *)(unaff_RDI + 400);

-    unaff_RBX[1].ContainerId.Data2 = (short)uVar1;

-    unaff_RBX[1].ContainerId.Data3 = (short)((ulonglong)uVar1 >> 0x10);

-    unaff_RBX[1].ContainerId.Data4[0] = (char)((ulonglong)uVar1 >> 0x20);

-    unaff_RBX[1].ContainerId.Data4[1] = (char)((ulonglong)uVar1 >> 0x28);

-    unaff_RBX[1].ContainerId.Data4[2] = (char)((ulonglong)uVar1 >> 0x30);

-    unaff_RBX[1].ContainerId.Data4[3] = (char)((ulonglong)uVar1 >> 0x38);

-    *(undefined8 *)(unaff_RBX[1].ContainerId.Data4 + 4) = uVar2;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x198);

-    uVar2 = *(undefined8 *)(unaff_RDI + 0x1a0);

-    unaff_RBX[1].LEContainerId.Data2 = (short)uVar1;

-    unaff_RBX[1].LEContainerId.Data3 = (short)((ulonglong)uVar1 >> 0x10);

-    unaff_RBX[1].LEContainerId.Data4[0] = (char)((ulonglong)uVar1 >> 0x20);

-    unaff_RBX[1].LEContainerId.Data4[1] = (char)((ulonglong)uVar1 >> 0x28);

-    unaff_RBX[1].LEContainerId.Data4[2] = (char)((ulonglong)uVar1 >> 0x30);

-    unaff_RBX[1].LEContainerId.Data4[3] = (char)((ulonglong)uVar1 >> 0x38);

-    *(undefined8 *)(unaff_RBX[1].LEContainerId.Data4 + 4) = uVar2;

-    uVar3 = *(ulong64 *)(unaff_RDI + 0x1b0);

-    *(undefined8 *)(unaff_RBX + 2) = *(undefined8 *)(unaff_RDI + 0x1a8);

-    unaff_RBX[2].address = uVar3;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x1b8);

-    uVar2 = *(undefined8 *)(unaff_RDI + 0x1c0);

-    unaff_RBX[2].classOfDevice = (int)uVar1;

-    unaff_RBX[2].name[0] = (char)((ulonglong)uVar1 >> 0x20);

-    unaff_RBX[2].name[1] = (char)((ulonglong)uVar1 >> 0x28);

-    unaff_RBX[2].name[2] = (char)((ulonglong)uVar1 >> 0x30);

-    unaff_RBX[2].name[3] = (char)((ulonglong)uVar1 >> 0x38);

-    *(undefined8 *)(unaff_RBX[2].name + 4) = uVar2;

-    pcVar4 = pcVar4 + unaff_R14;

-    uVar1 = *(undefined8 *)(unaff_RDI + 0x1d0);

-    puVar5 = (undefined8 *)(unaff_RDI + 0x158 + unaff_R14);

-    *(undefined8 *)(pcVar4 + -0x10) = *(undefined8 *)(unaff_RDI + 0x1c8);

-    *(undefined8 *)(pcVar4 + -8) = uVar1;

-    uVar1 = puVar5[1];

-    *(undefined8 *)pcVar4 = *puVar5;

-    *(undefined8 *)(pcVar4 + 8) = uVar1;

-    uVar1 = puVar5[3];

-    *(undefined8 *)(pcVar4 + 0x10) = puVar5[2];

-    *(undefined8 *)(pcVar4 + 0x18) = uVar1;

-    uVar1 = puVar5[5];

-    *(undefined8 *)(pcVar4 + 0x20) = puVar5[4];

-    *(undefined8 *)(pcVar4 + 0x28) = uVar1;

-    uVar1 = puVar5[7];

-    *(undefined8 *)(pcVar4 + 0x30) = puVar5[6];

-    *(undefined8 *)(pcVar4 + 0x38) = uVar1;

-    uVar1 = puVar5[9];

-    *(undefined8 *)(pcVar4 + 0x40) = puVar5[8];

-    *(undefined8 *)(pcVar4 + 0x48) = uVar1;

-    uVar1 = puVar5[0xb];

-    *(undefined8 *)(pcVar4 + 0x50) = puVar5[10];

-    *(undefined8 *)(pcVar4 + 0x58) = uVar1;

-    uVar1 = puVar5[0xd];

-    *(undefined8 *)(pcVar4 + 0x60) = puVar5[0xc];

-    *(undefined8 *)(pcVar4 + 0x68) = uVar1;

-    uVar1 = puVar5[0xe];

-    unaff_RBX->flags = unaff_RBX->flags | 0x400000;

-    *(undefined8 *)(pcVar4 + 0x70) = uVar1;

-  }

-  *(undefined2 *)(unaff_RBX[1].name + 0xda) = *(undefined2 *)(unaff_RDI + 0x698);

-  *(undefined8 *)(unaff_RBX[2].name + 0x94) = *(undefined8 *)(unaff_RDI + 0x670);

-  *(undefined8 *)(unaff_RBX[2].name + 0x9c) = *(undefined8 *)(unaff_RDI + 0x678);

-  *(undefined2 *)(unaff_RBX[2].name + 0xa6) = *(undefined2 *)(unaff_RDI + 0x3ce);

-  *(undefined2 *)(unaff_RBX[2].name + 0xa4) = *(undefined2 *)(unaff_RDI + 0x3d4);

-  *(undefined2 *)(unaff_RBX[2].name + 0xa8) = *(undefined2 *)(unaff_RDI + 0x3d0);

-  *(undefined2 *)(unaff_RBX[2].name + 0xaa) = *(undefined2 *)(unaff_RDI + 0x3d2);

-  unaff_RBX[2].name[0xac] = *(char *)(unaff_RDI + 0x5b7);

-  unaff_RBX[2].name[0xad] = *(char *)(unaff_RDI + 0x5b8);

-  *(undefined4 *)(unaff_RBX[2].name + 0xb0) = *(undefined4 *)(unaff_RDI + 0x5bc);

-  *(undefined8 *)(unaff_RBX[2].name + 0xb4) = *(undefined8 *)(unaff_RDI + 0x8e8);

-  unaff_RBX[2].name[0xbc] = *(char *)(unaff_RDI + 0x8f0);

-  uVar1 = *(undefined8 *)(unaff_RSI + 0x530);

-  *(undefined8 *)(unaff_R13 + 0x365) = *(undefined8 *)(unaff_RSI + 0x528);

-  *(undefined8 *)(unaff_R13 + 0x36d) = uVar1;

-  *(undefined4 *)(unaff_R13 + 0x375) = *(undefined4 *)(unaff_RSI + 0x538);

-  *(undefined8 *)(unaff_R13 + 0x379) = *(undefined8 *)(unaff_RSI + 0x3f0);

-  wil::details::

-  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-  ::

-  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-              *)(unaff_RBP + -0x10));

-  return extraout_AL;

+  return uVar19;

 }
```

## `HCI_GetOrAllocateLinkedLeDibFromBrSmpDib`  (modified)

```diff
--- HCI_GetOrAllocateLinkedLeDibFromBrSmpDib
+++ HCI_GetOrAllocateLinkedLeDibFromBrSmpDib
@@ -1,68 +1,431 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* struct DEVICE_INFO_BLOCK * __ptr64 __cdecl HCI_GetOrAllocateLinkedLeDibFromBrSmpDib(struct

+   HCI_INTERFACE * __ptr64,struct DEVICE_INFO_BLOCK * __ptr64,struct SMP_DEVICE_INFO *

+   __ptr64,bool,struct _GUID * __ptr64,bool) */

 

 DEVICE_INFO_BLOCK * __cdecl

 HCI_GetOrAllocateLinkedLeDibFromBrSmpDib

           (HCI_INTERFACE *param_1,DEVICE_INFO_BLOCK *param_2,SMP_DEVICE_INFO *param_3,bool param_4,

           _GUID *param_5,bool param_6)

 

 {

-  undefined1 *puVar1;

-  byte *pbVar2;

-  longlong lVar3;

-  longlong *plVar4;

-  code *pcVar5;

-  longlong *in_RAX;

-  byte bVar6;

-  char *pcVar7;

-  longlong unaff_RBP;

-  DEVICE_INFO_BLOCK *unaff_RDI;

-  undefined7 in_register_00000089;

-  HCI_INTERFACE *unaff_R13;

-  char unaff_R14B;

-  char unaff_R15B;

+  char *pcVar1;

+  intrusive_list_hook *piVar2;

+  atomic<unsigned___int64> *paVar3;

+  ulong *puVar4;

+  short sVar5;

+  ulong uVar6;

+  uint uVar7;

+  ulong64 uVar8;

+  undefined1 *puVar9;

+  _LIST_ENTRY *p_Var10;

+  longlong *plVar11;

+  code *pcVar12;

+  undefined8 uVar13;

+  ushort uVar14;

+  ushort uVar15;

+  long lVar16;

+  int iVar17;

+  DEVICE_INFO_BLOCK *pDVar18;

+  DEVICE_INFO_BLOCK *pDVar19;

+  DEVICE_INFO_BLOCK *pDVar20;

+  char cVar21;

+  uchar uVar22;

+  uchar uVar23;

+  _LIST_ENTRY *p_Var24;

+  ulong64 *puVar25;

+  __uint64 local_res10;

+  SMP_DEVICE_INFO *local_res18;

+  char local_res20;

+  undefined2 uVar26;

+  _LIST_ENTRY *p_Var27;

+  undefined1 local_58;

+  DEVICE_INFO_BLOCK *local_50;

+  _LIST_ENTRY local_48;

   

-  puVar1 = &param_1[-1].SetRandomAddressPromise.m_sharedState.field_0x9;

-  bVar6 = (byte)param_1;

-  *puVar1 = *puVar1 + bVar6;

-  pbVar2 = (byte *)((longlong)param_1 * 5 + 0x41);

-  *pbVar2 = *pbVar2 | bVar6;

-  *(byte *)((longlong)in_RAX + -0x77) = *(byte *)((longlong)in_RAX + -0x77) | bVar6;

-  *(byte *)((longlong)in_RAX + -0x77) = *(byte *)((longlong)in_RAX + -0x77) | bVar6;

-  *(char *)((longlong)in_RAX + -0x75) = *(char *)((longlong)in_RAX + -0x75) + bVar6;

-  *(char *)in_RAX = (char)*in_RAX + (char)in_RAX;

-  pcVar7 = param_1->defLocalName + CONCAT71(in_register_00000089,param_4) + -0x24;

-  lVar3 = *(longlong *)pcVar7;

-  if (*(longlong **)(lVar3 + 8) == (longlong *)pcVar7) {

-    *in_RAX = lVar3;

-    in_RAX[1] = (longlong)pcVar7;

-    *(longlong **)(lVar3 + 8) = in_RAX;

-    *(longlong **)pcVar7 = in_RAX;

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

-      if (*(char *)(unaff_RBP + 0x68) != unaff_R15B) {

-        HCI_DibProcessDisposableListLocked(unaff_R13,(_LIST_ENTRY *)(unaff_RBP + -0x10));

-      }

-      KeReleaseSpinLock(&unaff_R13->HciLock,*(undefined1 *)(unaff_RBP + -0x20));

-      if (*(char *)(unaff_RBP + 0x68) != unaff_R15B) {

-        while (plVar4 = *(longlong **)(unaff_RBP + -0x10), plVar4 != (longlong *)(unaff_RBP + -0x10)

-              ) {

-          if ((plVar4[1] != unaff_RBP + -0x10) ||

-             (lVar3 = *plVar4, *(longlong **)(lVar3 + 8) != plVar4)) goto LAB_0;

-          *(longlong *)(unaff_RBP + -0x10) = lVar3;

-          *(longlong *)(lVar3 + 8) = unaff_RBP + -0x10;

-          plVar4[1] = (longlong)plVar4;

-          *plVar4 = (longlong)plVar4;

-          RefObj_ReleaseEx(plVar4 + -0x68,plVar4 + -0x68,0x1f1d,

-                           "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\HCIp.h");

-        }

-      }

-    }

-  }

-  else {

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+     (cVar21 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    cVar21 = '\0';

+  }

+  local_res18 = param_3;

+  local_res20 = param_4;

+  if ((cVar21 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_iqdd

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar21,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0);

+  }

+  puVar25 = &(param_2->DeviceInfo).address;

+  local_58 = 0;

+  if (!param_4) {

+    local_58 = KeAcquireSpinLockRaiseToDpc(&param_1->HciLock);

+  }

+  local_50 = (DEVICE_INFO_BLOCK *)0x0;

+  local_res10 = local_res10 & 0xffffffffffffff00;

+  lVar16 = HCI_FindDeviceInfoBlockByAddressLocked

+                     (param_1,puVar25,(uchar *)&local_res10,(DEVICE_INFO_BLOCK **)0x0,&local_50);

+  pDVar18 = local_50;

+  if ((-1 < lVar16) && (p_Var10 = &param_1->DeviceList, local_50 == (DEVICE_INFO_BLOCK *)0x0)) {

+    for (p_Var24 = p_Var10->Flink; param_4 = (bool)local_res20, p_Var24 != p_Var10;

+        p_Var24 = p_Var24->Flink) {

+      pDVar19 = (DEVICE_INFO_BLOCK *)(p_Var24 + -0x34);

+      pDVar20 = local_50;

+      if (((ulonglong)p_Var24[-0x33].Blink & 0x8000) != 0) {

+        cVar21 = '\0';

+        if (*(char *)&p_Var24[0x27].Flink != -1) {

+          cVar21 = *(char *)&p_Var24[0x27].Flink;

+        }

+        if ((cVar21 == '\x01') &&

+           (((ulonglong)p_Var24[-0x32].Flink & 0xc00000000000) == 0x400000000000)) {

+          local_res10 = (ulonglong)local_res10._1_7_ << 8;

+          iVar17 = BthLELib_SMPResolvePrivateAddressAtDispatch

+                             (param_1->DevExt->Smp->BCryptResolveAddressHandle);

+          pDVar20 = local_50;

+          if ((-1 < iVar17) && ((char)local_res10 != '\0')) {

+            if (pDVar18 == (DEVICE_INFO_BLOCK *)0x0) {

+              if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+                 (cVar21 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+                cVar21 = '\0';

+              }

+              sVar5 = *(short *)(WPP_GLOBAL_Control + 0x48);

+              if ((cVar21 != '\0') || (pDVar18 = pDVar19, pDVar20 = pDVar19, sVar5 != 0)) {

+                p_Var27 = p_Var24[-0x32].Flink;

+                uVar26 = 0x37;

 LAB_0:

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

-    (*pcVar5)(3);

-  }

-  return unaff_RDI;

+                WPP_RECORDER_AND_TRACE_SF_i

+                          (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar21,sVar5 != 0,

+                           param_1->IfrLog,5,2,uVar26,

+                           &WPP_ad144674c127399e1f530e053018150b_Traceguids,p_Var27);

+                pDVar18 = pDVar19;

+                pDVar20 = pDVar19;

+              }

+            }

+            else if ((pDVar18->LastSeenTimestamp).QuadPart < (longlong)p_Var24[0x33].Flink) {

+              if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+                 (cVar21 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+                cVar21 = '\0';

+              }

+              sVar5 = *(short *)(WPP_GLOBAL_Control + 0x48);

+              if ((cVar21 != '\0') || (pDVar18 = pDVar19, pDVar20 = pDVar19, sVar5 != 0)) {

+                p_Var27 = p_Var24[-0x32].Flink;

+                uVar26 = 0x38;

+                goto LAB_0;

+              }

+            }

+          }

+        }

+      }

+      local_50 = pDVar20;

+    }

+    if (pDVar18 == (DEVICE_INFO_BLOCK *)0x0) {

+      local_res10 = (ulonglong)local_res10._1_7_ << 8;

+      pDVar18 = HCI_DibCreate(param_1,puVar25,(uchar *)&local_res10);

+      local_50 = pDVar18;

+      if (pDVar18 != (DEVICE_INFO_BLOCK *)0x0) {

+        (pDVar18->DeviceInfo).flags = (pDVar18->DeviceInfo).flags | 0x8000;

+        HCI_DibPopulateDefaultContainerIds(pDVar18);

+        if (param_5 == (_GUID *)0x0) {

+          (pDVar18->ActivityId).Data1 = 0;

+          (pDVar18->ActivityId).Data2 = 0;

+          (pDVar18->ActivityId).Data3 = 0;

+          (pDVar18->ActivityId).Data4[0] = '\0';

+          (pDVar18->ActivityId).Data4[1] = '\0';

+          (pDVar18->ActivityId).Data4[2] = '\0';

+          (pDVar18->ActivityId).Data4[3] = '\0';

+          (pDVar18->ActivityId).Data4[4] = '\0';

+          (pDVar18->ActivityId).Data4[5] = '\0';

+          (pDVar18->ActivityId).Data4[6] = '\0';

+          (pDVar18->ActivityId).Data4[7] = '\0';

+        }

+        else {

+          uVar14 = param_5->Data2;

+          uVar15 = param_5->Data3;

+          uVar13 = *(undefined8 *)param_5->Data4;

+          (pDVar18->ActivityId).Data1 = param_5->Data1;

+          (pDVar18->ActivityId).Data2 = uVar14;

+          (pDVar18->ActivityId).Data3 = uVar15;

+          *(undefined8 *)(pDVar18->ActivityId).Data4 = uVar13;

+        }

+        param_1->NumDevices = param_1->NumDevices + 1;

+        piVar2 = &pDVar18->ListEntry;

+        p_Var24 = (param_1->DeviceList).Blink;

+        if (p_Var24->Flink != p_Var10) goto LAB_1;

+        *(_LIST_ENTRY **)&piVar2->field_0x0 = p_Var10;

+        *(_LIST_ENTRY **)&(pDVar18->ListEntry).field_0x8 = p_Var24;

+        p_Var24->Flink = (_LIST_ENTRY *)piVar2;

+        (param_1->DeviceList).Blink = (_LIST_ENTRY *)piVar2;

+      }

+    }

+  }

+  uVar22 = '\0';

+  local_48.Blink = &local_48;

+  local_48.Flink = &local_48;

+  if ((-1 < lVar16) && (pDVar18 != (DEVICE_INFO_BLOCK *)0x0)) {

+    if (param_4 == false) {

+      RefObj_AddRefEx(pDVar18,HCI_GetOrAllocateLinkedLeDibFromBrSmpDib,0xc03,

+                      "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\hcidib.cpp");

+    }

+    uVar6 = (param_2->DeviceInfo).classOfDevice;

+    if ((uVar6 != 0) && ((pDVar18->DeviceInfo).classOfDevice == 0)) {

+      (pDVar18->DeviceInfo).classOfDevice = uVar6;

+      HCI_DibUpdateCod(pDVar18,(uchar *)0x0);

+    }

+    if (((param_2->DeviceInfo).flags & 4) == 0) {

+      HCI_AssignDibNumber(pDVar18);

+    }

+    else {

+      pcVar1 = (param_2->DeviceInfo).name;

+      local_res10 = 0;

+      lVar16 = RtlStringCbLengthA(pcVar1,0xf8,&local_res10);

+      if (-1 < lVar16) {

+        uVar23 = (char)local_res10 + '\x01';

+        HCI_DibUpdateName(pDVar18,pcVar1,uVar23);

+        HCI_DibUpdateLEName(pDVar18,pcVar1,uVar23);

+      }

+      param_4 = (bool)local_res20;

+      if (((param_2->DeviceInfo).flags & 0x40) != 0) {

+        (pDVar18->DeviceInfo).flags = (pDVar18->DeviceInfo).flags | 0x40;

+      }

+    }

+    if (param_2->LinkedDibAddress == 0) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (cVar21 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+        cVar21 = '\0';

+      }

+      if ((cVar21 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+        WPP_RECORDER_AND_TRACE_SF_qq

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar21,

+                   *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->IfrLog,5,2,0x39,

+                   &WPP_ad144674c127399e1f530e053018150b_Traceguids,(param_2->DeviceInfo).address,

+                   (pDVar18->DeviceInfo).address);

+      }

+    }

+    if (pDVar18->LinkedDibAddress == 0) {

+LAB_2:

+      if (param_2->LinkedDibAddress != 0) {

+        if (param_2->LinkedDibAddress == (pDVar18->DeviceInfo).address) {

+          if (((pDVar18->DeviceInfo).flags & 0x8000) == 0) {

+            uVar23 = 0xff;

+          }

+          else {

+            uVar23 = uVar22;

+            if (pDVar18->LEOriginalAddressType != 0xff) {

+              uVar23 = pDVar18->LEOriginalAddressType;

+            }

+          }

+          if (param_2->LinkedDibAddressType == uVar23) goto LAB_3;

+        }

+        pDVar19 = HCI_FindLinkedDib(&param_1->DeviceList,param_2);

+        param_2->LinkedDibAddress = 0;

+        param_2->LinkedDibAddressType = '\0';

+        if (pDVar19 != (DEVICE_INFO_BLOCK *)0x0) {

+          pDVar19->LinkedDibAddress = 0;

+          pDVar19->LinkedDibAddressType = '\0';

+        }

+      }

+LAB_3:

+      pDVar18->LinkedDibAddress = (param_2->DeviceInfo).address;

+      if (((param_2->DeviceInfo).flags & 0x8000) == 0) {

+        uVar23 = 0xff;

+      }

+      else {

+        uVar23 = uVar22;

+        if (param_2->LEOriginalAddressType != 0xff) {

+          uVar23 = param_2->LEOriginalAddressType;

+        }

+      }

+      uVar8 = (pDVar18->DeviceInfo).address;

+      pDVar18->LinkedDibAddressType = uVar23;

+      param_2->LinkedDibAddress = uVar8;

+      if (((pDVar18->DeviceInfo).flags & 0x8000) == 0) {

+        uVar22 = 0xff;

+      }

+      else if (pDVar18->LEOriginalAddressType != 0xff) {

+        uVar22 = pDVar18->LEOriginalAddressType;

+      }

+      param_2->LinkedDibAddressType = uVar22;

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (cVar21 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+        cVar21 = '\0';

+      }

+      if ((cVar21 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+        WPP_RECORDER_AND_TRACE_SF_qq

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar21,

+                   *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->IfrLog,5,2,0x3a,

+                   &WPP_ad144674c127399e1f530e053018150b_Traceguids,param_2,pDVar18);

+      }

+    }

+    else {

+      if (pDVar18->LinkedDibAddress != (param_2->DeviceInfo).address) {

+LAB_4:

+        pDVar19 = HCI_FindLinkedDib(&param_1->DeviceList,pDVar18);

+        pDVar18->LinkedDibAddress = 0;

+        pDVar18->LinkedDibAddressType = '\0';

+        if (pDVar19 != (DEVICE_INFO_BLOCK *)0x0) {

+          pDVar19->LinkedDibAddress = 0;

+          pDVar19->LinkedDibAddressType = '\0';

+        }

+        goto LAB_2;

+      }

+      if (((param_2->DeviceInfo).flags & 0x8000) == 0) {

+        uVar23 = 0xff;

+      }

+      else {

+        uVar23 = uVar22;

+        if (param_2->LEOriginalAddressType != 0xff) {

+          uVar23 = param_2->LEOriginalAddressType;

+        }

+      }

+      if (((pDVar18->LinkedDibAddressType != uVar23) || (param_2->LinkedDibAddress == 0)) ||

+         (param_2->LinkedDibAddress != (pDVar18->DeviceInfo).address)) {

+LAB_5:

+        if (((param_2->DeviceInfo).flags & 0x8000) == 0) {

+          uVar23 = 0xff;

+        }

+        else {

+          uVar23 = uVar22;

+          if (param_2->LEOriginalAddressType != 0xff) {

+            uVar23 = param_2->LEOriginalAddressType;

+          }

+        }

+        if (pDVar18->LinkedDibAddressType == uVar23) goto LAB_2;

+        goto LAB_4;

+      }

+      if (((pDVar18->DeviceInfo).flags & 0x8000) == 0) {

+        uVar23 = 0xff;

+      }

+      else {

+        uVar23 = uVar22;

+        if (pDVar18->LEOriginalAddressType != 0xff) {

+          uVar23 = pDVar18->LEOriginalAddressType;

+        }

+      }

+      if (param_2->LinkedDibAddressType != uVar23) goto LAB_5;

+    }

+    pDVar19 = local_50;

+    if (param_1->CacheEntryDisposableLimit != 0) {

+      uVar7 = (pDVar18->DeviceInfo).flags;

+      if (((((uVar7 >> 0xe & 1) == 0) || (pDVar18->LinkedDibAddress != 0)) &&

+          ((uVar7 & 0x1030038) == 0)) &&

+         ((paVar3 = &pDVar18->DibFlags, pDVar18 = local_50, ((ulonglong)*paVar3 & 8) == 0 &&

+          ((intrusive_list_hook *)*(undefined1 **)&local_50->ListEntry != &local_50->ListEntry)))) {

+        pDVar20 = HCI_FindLinkedDib(&local_50->Hci->DeviceList,local_50);

+        pDVar18 = pDVar19;

+        if ((pDVar20 == (DEVICE_INFO_BLOCK *)0x0) ||

+           ((((uVar7 = (pDVar20->DeviceInfo).flags, (uVar7 >> 0xe & 1) == 0 ||

+              (pDVar20->LinkedDibAddress != 0)) && ((uVar7 & 0x1030038) == 0)) &&

+            (pDVar18 = local_50, ((ulonglong)pDVar20->DibFlags & 8) == 0)))) {

+          piVar2 = &pDVar18->DisposableListEntry;

+          puVar9 = *(undefined1 **)piVar2;

+          if ((intrusive_list_hook *)puVar9 == piVar2) {

+            puVar4 = &pDVar18->Hci->NumberOfDisposableDevices;

+            *puVar4 = *puVar4 + 1;

+          }

+          else {

+            if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar2) ||

+               (plVar11 = *(longlong **)&(pDVar18->DisposableListEntry).field_0x8,

+               (intrusive_list_hook *)*plVar11 != piVar2)) goto LAB_1;

+            *plVar11 = (longlong)puVar9;

+            *(longlong **)(puVar9 + 8) = plVar11;

+            *(intrusive_list_hook **)&(pDVar18->DisposableListEntry).field_0x8 = piVar2;

+            *(intrusive_list_hook **)piVar2 = piVar2;

+          }

+          p_Var24 = &pDVar18->Hci->DisposableDeviceList;

+          p_Var10 = p_Var24->Flink;

+          if (p_Var10->Blink != p_Var24) goto LAB_1;

+          *(_LIST_ENTRY **)piVar2 = p_Var10;

+          *(_LIST_ENTRY **)&(pDVar18->DisposableListEntry).field_0x8 = p_Var24;

+          p_Var10->Blink = (_LIST_ENTRY *)piVar2;

+          p_Var24->Flink = (_LIST_ENTRY *)piVar2;

+          if (pDVar20 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_6;

+        }

+        piVar2 = &pDVar20->DisposableListEntry;

+        puVar9 = *(undefined1 **)piVar2;

+        if ((intrusive_list_hook *)puVar9 != piVar2) {

+          if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar2) ||

+             (plVar11 = *(longlong **)&(pDVar20->DisposableListEntry).field_0x8,

+             (intrusive_list_hook *)*plVar11 != piVar2)) {

+LAB_1:

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

+            (*pcVar12)(3);

+            return pDVar18;

+          }

+          *plVar11 = (longlong)puVar9;

+          *(longlong **)(puVar9 + 8) = plVar11;

+          *(intrusive_list_hook **)&(pDVar20->DisposableListEntry).field_0x8 = piVar2;

+          *(intrusive_list_hook **)piVar2 = piVar2;

+          p_Var24 = &pDVar20->Hci->DisposableDeviceList;

+          p_Var10 = p_Var24->Flink;

+          if (p_Var10->Blink != p_Var24) goto LAB_1;

+          *(_LIST_ENTRY **)piVar2 = p_Var10;

+          *(_LIST_ENTRY **)&(pDVar20->DisposableListEntry).field_0x8 = p_Var24;

+          p_Var10->Blink = (_LIST_ENTRY *)piVar2;

+          p_Var24->Flink = (_LIST_ENTRY *)piVar2;

+        }

+      }

+      else {

+        piVar2 = &pDVar18->DisposableListEntry;

+        puVar9 = *(undefined1 **)piVar2;

+        if ((intrusive_list_hook *)puVar9 != piVar2) {

+          if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar2) ||

+             (plVar11 = *(longlong **)&(pDVar18->DisposableListEntry).field_0x8,

+             (intrusive_list_hook *)*plVar11 != piVar2)) goto LAB_1;

+          *plVar11 = (longlong)puVar9;

+          *(longlong **)(puVar9 + 8) = plVar11;

+          *(intrusive_list_hook **)&(pDVar18->DisposableListEntry).field_0x8 = piVar2;

+          *(intrusive_list_hook **)piVar2 = piVar2;

+          uVar6 = pDVar18->Hci->NumberOfDisposableDevices;

+          if (uVar6 != 0) {

+            pDVar18->Hci->NumberOfDisposableDevices = uVar6 - 1;

+          }

+        }

+        pDVar19 = HCI_FindLinkedDib(&pDVar18->Hci->DeviceList,pDVar18);

+        if (pDVar19 != (DEVICE_INFO_BLOCK *)0x0) {

+          piVar2 = &pDVar19->DisposableListEntry;

+          puVar9 = *(undefined1 **)piVar2;

+          if ((intrusive_list_hook *)puVar9 != piVar2) {

+            if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar2) ||

+               (plVar11 = *(longlong **)&(pDVar19->DisposableListEntry).field_0x8,

+               (intrusive_list_hook *)*plVar11 != piVar2)) goto LAB_1;

+            *plVar11 = (longlong)puVar9;

+            *(longlong **)(puVar9 + 8) = plVar11;

+            *(intrusive_list_hook **)&(pDVar19->DisposableListEntry).field_0x8 = piVar2;

+            *(intrusive_list_hook **)piVar2 = piVar2;

+            uVar6 = pDVar19->Hci->NumberOfDisposableDevices;

+            if (uVar6 != 0) {

+              pDVar19->Hci->NumberOfDisposableDevices = uVar6 - 1;

+            }

+          }

+        }

+      }

+LAB_6:

+      if (param_4 != false) {

+        return pDVar18;

+      }

+      if (param_6) {

+        HCI_DibProcessDisposableListLocked(param_1,&local_48);

+      }

+      goto LAB_7;

+    }

+  }

+  if (param_4 != false) {

+    return pDVar18;

+  }

+LAB_7:

+  KeReleaseSpinLock(&param_1->HciLock,local_58);

+  if (param_6) {

+    while (local_48.Flink != &local_48) {

+      if (((local_48.Flink)->Blink != &local_48) ||

+         (p_Var10 = (local_48.Flink)->Flink, p_Var10->Blink != local_48.Flink)) goto LAB_1;

+      p_Var10->Blink = &local_48;

+      p_Var24 = local_48.Flink + -0x34;

+      (local_48.Flink)->Blink = local_48.Flink;

+      (local_48.Flink)->Flink = local_48.Flink;

+      local_48.Flink = p_Var10;

+      RefObj_ReleaseEx(p_Var24,p_Var24,0x1f1d,

+                       "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\HCIp.h");

+    }

+  }

+  return pDVar18;

 }
```

## `L2capCon_FormatConfigResponseOptions`  (modified)

```diff
--- L2capCon_FormatConfigResponseOptions
+++ L2capCon_FormatConfigResponseOptions
@@ -1,54 +1,144 @@
 

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

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

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

-/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl L2capCon_FormatConfigResponseOptions(struct L2CAP_CONNECTION * __ptr64,union

+   _L2CAP_SIGNAL * __ptr64,unsigned short,union _SIGNAL_DATA * __ptr64) */

 

 void __cdecl

 L2capCon_FormatConfigResponseOptions

           (L2CAP_CONNECTION *param_1,_L2CAP_SIGNAL *param_2,ushort param_3,_SIGNAL_DATA *param_4)

 

 {

-  char unaff_100000ec;

-  long lVar1;

-  char unaff_BPL;

-  L2CAP_CONNECTION *unaff_RDI;

-  uchar uVar2;

-  int unaff_R12D;

-  char unaff_R13B;

-  char in_stack_00000098;

-  uchar in_stack_000000a0;

-  _GUID *in_stack_000000b8;

+  _SIGNAL_DATA *p_Var1;

+  longlong lVar2;

+  uchar uVar3;

+  byte bVar4;

+  short sVar5;

+  bool bVar6;

+  int iVar7;

+  int iVar8;

+  void *_Src;

+  ulonglong uVar9;

+  uint uVar10;

+  _L2CAP_SIGNAL *_Dst;

+  undefined8 *puVar11;

+  longlong lVar12;

+  uchar *puVar13;

+  uchar *puVar14;

+  uchar *_Src_00;

+  undefined8 *puVar15;

+  _L2CAP_SIGNAL *p_Var16;

+  undefined2 local_res18 [4];

+  undefined8 *local_res20;

   

-  WPP_RECORDER_AND_TRACE_SF_L(*(undefined8 *)(param_1 + 0x18));

-  KeReleaseSpinLock();

-  HCI_PurgeConnectionUpdates

-            (*(HCI_L2CAP_DATA **)(unaff_RDI + 0x170),(HCI_CLIENT *)(unaff_RDI + 0x18));

-  HCI_PurgeQueryUpdateConnection

-            (*(HCI_L2CAP_DATA **)(unaff_RDI + 0x170),(HCI_CLIENT *)(unaff_RDI + 0x18));

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

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

-      L2CapInt_SendSignalEx

-                ((L2CAP_INTERFACE *)0x0,unaff_RDI,(HCI_L2CAP_DATA *)0x0,'\a',0,

-                 (long *)(unaff_RDI + 0x208),(_SIGNAL_DATA *)0x0,in_stack_000000b8,1);

+  _Dst = param_2 + 10;

+  sVar5 = *(short *)(param_2 + 8);

+  p_Var1 = param_4 + 4;

+  iVar8 = (uint)param_3 + (int)_Dst;

+  uVar9 = 0;

+  if (sVar5 == 0) {

+    if (((byte)*p_Var1 & 1) != 0) {

+      Feature_772777273__private_IsEnabledDeviceUsageNoInline();

+      *(undefined2 *)_Dst = 0x201;

+      *(undefined2 *)(param_2 + 0xc) = *(undefined2 *)(param_4 + 8);

+      _Dst = param_2 + 0xe;

+    }

+    if (((byte)*p_Var1 & 0x40) != 0) {

+      Feature_772777273__private_IsEnabledDeviceUsageNoInline();

+      *(undefined2 *)_Dst = 0x904;

+      *(undefined8 *)(_Dst + 2) = *(undefined8 *)(param_4 + 0x32);

+      _Dst[10] = *(_L2CAP_SIGNAL *)(param_4 + 0x3a);

     }

   }

-  else {

-    lVar1 = L2CapCon_L2capSendDisconnectRequest(unaff_RDI,in_stack_000000a0,in_stack_000000b8);

-    unaff_BPL = '\x01';

-    if (-1 < lVar1) {

-      unaff_BPL = unaff_100000ec;

+  else if (sVar5 == 1) {

+    p_Var16 = (_L2CAP_SIGNAL *)&DAT_0;

+    lVar12 = 7;

+    do {

+      if ((*(uint *)p_Var1 & *(uint *)(p_Var16 + 3)) != 0) {

+        Feature_772777273__private_IsEnabledDeviceUsageNoInline();

+        *_Dst = p_Var16[-1];

+        _Dst[1] = *p_Var16;

+        memmove(_Dst + 2,p_Var1 + *(longlong *)(p_Var16 + 7),(ulonglong)(byte)*p_Var16);

+        _Dst = _Dst + 2 + (byte)*p_Var16;

+      }

+      p_Var16 = p_Var16 + 0x10;

+      lVar12 = lVar12 + -1;

+    } while (lVar12 != 0);

+    if (((byte)*p_Var1 & 8) != 0) {

+      if (*(int *)(param_4 + 0xc) != 0) {

+        do {

+          lVar12 = *(longlong *)(param_4 + 0x14);

+          Feature_772777273__private_IsEnabledDeviceUsageNoInline();

+          *_Dst = *(_L2CAP_SIGNAL *)(lVar12 + uVar9 * 0x18);

+          _Dst[1] = *(_L2CAP_SIGNAL *)(lVar12 + 1 + uVar9 * 0x18);

+          if ((*(byte *)(lVar12 + 0x14 + uVar9 * 0x18) & 1) == 0) {

+            _Src = (void *)(lVar12 + 0x10 + uVar9 * 0x18);

+          }

+          else {

+            _Src = *(void **)(lVar12 + 8 + uVar9 * 0x18);

+          }

+          memmove(_Dst + 2,_Src,(ulonglong)*(byte *)(lVar12 + 1 + uVar9 * 0x18));

+          lVar2 = uVar9 * 0x18;

+          uVar10 = (int)uVar9 + 1;

+          uVar9 = (ulonglong)uVar10;

+          _Dst = _Dst + 2 + *(byte *)(lVar12 + 1 + lVar2);

+        } while (uVar10 < *(uint *)(param_4 + 0xc));

+      }

+      L2CapCon_EnhancedFreeClientExtraOptions(param_1,(_CHANNEL_CONFIG_PARAMETERS_ENHANCED *)p_Var1)

+      ;

     }

   }

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

-    if (unaff_R12D < 0) {

-      uVar2 = 0xff;

+  else if (sVar5 == 3) {

+    puVar11 = *(undefined8 **)(param_4 + 0x56);

+    local_res20 = puVar11;

+    if (puVar11 == (undefined8 *)0x0) {

+      lVar12 = *(longlong *)(param_4 + 0x5e);

+      if (*(short *)(param_4 + 0x54) != 0) {

+        do {

+          uVar10 = (int)uVar9 + 1;

+          *_Dst = *(_L2CAP_SIGNAL *)(lVar12 + uVar9 * 0x18);

+          _Dst = _Dst + 1;

+          uVar9 = (ulonglong)uVar10;

+        } while (uVar10 < *(ushort *)(param_4 + 0x54));

+      }

+      ExFreePoolWithTag(lVar12,0);

     }

     else {

-      uVar2 = '\0';

+      for (puVar15 = (undefined8 *)*puVar11; puVar15 != puVar11; puVar15 = (undefined8 *)*puVar15) {

+        puVar14 = (uchar *)puVar15[3];

+        puVar13 = puVar14 + *(uint *)(puVar15 + 2);

+        if (puVar14 < puVar13) {

+          do {

+            uVar3 = *puVar14;

+            bVar4 = puVar14[1];

+            local_res18[0] = *(undefined2 *)puVar14;

+            uVar9 = (ulonglong)bVar4;

+            _Src_00 = puVar14 + 2;

+            iVar7 = Feature_772777273__private_IsEnabledDeviceUsageNoInline();

+            if (iVar7 == 0) {

+              if (((-1 < (char)uVar3) && (1 < (byte)(uVar3 - 1))) && (uVar3 != '\x03')) {

+                puVar11 = local_res20;

+                if (bVar4 + 2 <= (uint)(iVar8 - (int)_Dst)) {

+                  memmove(_Dst,local_res18,uVar9 + 2);

+                  goto LAB_1;

+                }

+                break;

+              }

+            }

+            else if ((-1 < (char)uVar3) && (bVar6 = IsKnownConfigOptionType(uVar3), !bVar6)) {

+              puVar11 = local_res20;

+              if ((uint)(iVar8 - (int)_Dst) < bVar4 + 2) break;

+              *(undefined2 *)_Dst = local_res18[0];

+              memmove(_Dst + 2,_Src_00,uVar9);

+LAB_1:

+              _Dst = _Dst + uVar9 + 2;

+            }

+            puVar14 = _Src_00 + uVar9;

+            puVar11 = local_res20;

+            if ((puVar14 < _Src_00) || (puVar13 <= puVar14)) break;

+          } while( true );

+        }

+      }

     }

-    L2CapCon_DeleteConnectionEx(unaff_RDI,unaff_R12D,uVar2,'\x01',in_stack_000000b8);

   }

   return;

 }
```

## `SdpDB_ServiceSearchAttributeResponse`  (modified)

```diff
--- SdpDB_ServiceSearchAttributeResponse
+++ SdpDB_ServiceSearchAttributeResponse
@@ -1,113 +1,158 @@
 

-/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* long __cdecl SdpDB_ServiceSearchAttributeResponse(struct _SDP_DATABASE * __ptr64,struct

+   _SDP_UUID_SEARCH * __ptr64,struct _SDP_ATTRIB_SEARCH * __ptr64,unsigned char * __ptr64 *

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

 

 long __cdecl

 SdpDB_ServiceSearchAttributeResponse

           (_SDP_DATABASE *param_1,_SDP_UUID_SEARCH *param_2,_SDP_ATTRIB_SEARCH *param_3,

           uchar **param_4,ulong *param_5,ushort *param_6,uchar param_7)

 

 {

-  char in_AL;

-  _BTH_SDP_CONNECT _Var1;

-  long lVar2;

-  long lVar3;

-  _SDP_CLIENT_CONNECTION *p_Var4;

-  ulonglong uVar5;

-  undefined1 *unaff_RBX;

-  _IRP *unaff_RBP;

-  _BTH_SDP_CONNECT *unaff_RDI;

-  _SDP_INTERFACE *unaff_R13;

-  undefined4 *unaff_R14;

-  longlong unaff_R15;

-  _SDP_CLIENT_CONNECTION *p_Stack0000000000000040;

-  longlong lStack0000000000000048;

-  uint uStack0000000000000050;

+  code *pcVar1;

+  undefined8 ******ppppppuVar2;

+  uchar uVar3;

+  byte bVar4;

+  ushort uVar5;

+  int iVar6;

+  long lVar7;

+  uint uVar8;

+  uchar *puVar9;

+  void *_Dst;

+  undefined8 uVar10;

+  uint7 uVar12;

+  longlong lVar11;

+  _SDP_DATABASE *p_Var13;

+  uint uVar14;

+  undefined8 *******pppppppuVar15;

+  undefined1 uVar16;

+  _SDP_STREAM_ENTRY *local_res8;

+  _SDP_UUID_SEARCH *local_res10;

+  _SDP_ATTRIB_SEARCH *local_res18;

+  uchar **local_res20;

+  _SDP_STREAM_ENTRY **pp_Var17;

+  ushort *puVar18;

+  undefined8 ******local_58;

+  _SDP_STREAM_ENTRY *local_50;

   

-  if (((in_AL == '\0') || ((byte)(in_AL - 10U) < 0x24)) &&

-     ((*(uint *)(unaff_RDI + 8) & 0xfffffff8) == 0)) {

-    if ((*(uint *)(unaff_RDI + 8) & 1) == 0) {

-      p_Var4 = SdpClient_Create();

-      if (p_Var4 == (_SDP_CLIENT_CONNECTION *)0x0) {

-        lVar2 = -0x3fffff66;

-      }

-      else {

-        lStack0000000000000048 = *(longlong *)(unaff_R15 + 0x30);

-        if (lStack0000000000000048 == 0) {

-          lStack0000000000000048 = *(longlong *)(unaff_R15 + 0x28);

-        }

-        *(longlong *)(p_Var4 + 0x20) = lStack0000000000000048;

-        uStack0000000000000050 = 0x1e;

-        if (unaff_RDI[0x14] != (_BTH_SDP_CONNECT)0x0) {

-          uStack0000000000000050 = (uint)(byte)unaff_RDI[0x14];

-        }

-        *(uint *)(p_Var4 + 0x38) = uStack0000000000000050;

-        if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

-           (_Var1 = (_BTH_SDP_CONNECT)0x1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

-          _Var1 = SUB81(unaff_RBX,0);

-        }

-        p_Stack0000000000000040 = p_Var4;

-        WPP_RECORDER_AND_TRACE_SF_qqd

-                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),_Var1,1,

-                   *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4);

-        lVar2 = SdpConnectionHandleMgr::CreateHandle

-                          (&unaff_R13->sdpConnectionHandleMgr,p_Var4,(void **)&stack0x00000098);

-        if (lVar2 < 0) {

-          if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

-             (1 < (byte)WPP_GLOBAL_Control[0x29])) {

-            unaff_RBX = &DAT_0;

-          }

-          lStack0000000000000048 = CONCAT44(lStack0000000000000048._4_4_,lVar2);

-          p_Stack0000000000000040 = p_Var4;

-          WPP_RECORDER_AND_TRACE_SF_iL

-                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),(ulonglong)unaff_RBX & 0xff,

-                     &DAT_1,*(undefined8 *)(WPP_GLOBAL_Control + 0x40),2);

-          RefObj_ReleaseEx(p_Var4,p_Var4,0x376,

-                           "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\sdpinterface.cpp"

-                          );

+  lVar7 = 0;

+  *param_4 = (uchar *)0x0;

+  uVar14 = 0;

+  *param_5 = 0;

+  local_50 = (_SDP_STREAM_ENTRY *)&local_58;

+  local_58 = &local_58;

+  local_res10 = param_2;

+  local_res18 = param_3;

+  local_res20 = param_4;

+  ExAcquireFastMutex(&param_1->ServiceRecordListMutex);

+  uVar16 = 1;

+  for (p_Var13 = (_SDP_DATABASE *)(param_1->ServiceRecordList).Flink; p_Var13 != param_1;

+      p_Var13 = (_SDP_DATABASE *)(p_Var13->ServiceRecordList).Flink) {

+    if ((param_7 == '\0') && ((*(uint *)&(p_Var13->ServiceRecordListMutex).field_0x4 & 2) != 0)) {

+      iVar6 = Feature_61512497__private_IsEnabledDeviceUsageNoInline();

+      if (iVar6 != 0) {

+        if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

+           (3 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar10 = 1;

         }

         else {

-          *(undefined1 **)(p_Var4 + 0x178) = unaff_RBX;

-          lVar2 = SdpL2cap_Connect(unaff_R13,p_Var4,unaff_RBP,(__uint64 *)unaff_RDI,

-                                   ~(byte)(*(uint *)(unaff_RDI + 8) >> 1) & 1);

-          if (lVar2 < 0) {

-            lVar3 = SdpConnectionHandleMgr::CloseHandle

-                              (&unaff_R13->sdpConnectionHandleMgr,unaff_RBX,(void **)0x0);

-            if (lVar3 < 0) {

-              if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

-                 (uVar5 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

-                uVar5 = (ulonglong)unaff_RBX & 0xff;

-              }

-              lStack0000000000000048 = CONCAT44(lStack0000000000000048._4_4_,lVar3);

-              p_Stack0000000000000040 = p_Var4;

-              WPP_RECORDER_AND_TRACE_SF_iL

-                        (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar5,&DAT_1,

-                         *(undefined8 *)(WPP_GLOBAL_Control + 0x40),2);

+          uVar10 = 0;

+        }

+        WPP_RECORDER_AND_TRACE_SF_D_guid_(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar10);

+      }

+    }

+    else {

+      uVar3 = SdpUS_SearchStream(local_res10,

+                                 *(uchar **)&(p_Var13->ServiceRecordListMutex).Event.Header,

+                                 *(ulong *)&(p_Var13->ServiceRecordListMutex).field_0x14);

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

+        local_res8 = (_SDP_STREAM_ENTRY *)0x0;

+        pp_Var17 = &local_res8;

+        puVar18 = param_6;

+        lVar7 = SdpFindAttributeInStreamInternal

+                          (*(uchar **)&(p_Var13->ServiceRecordListMutex).Event.Header,

+                           *(ulong *)&(p_Var13->ServiceRecordListMutex).field_0x14,

+                           *(SdpAttributeRange **)local_res18,*(ulong *)(local_res18 + 8),pp_Var17,

+                           param_6);

+        if (lVar7 < 0) break;

+        if (local_res8 != (_SDP_STREAM_ENTRY *)0x0) {

+          if (*(undefined8 ********)local_50 != &local_58) goto LAB_0;

+          *(_SDP_STREAM_ENTRY **)(local_res8 + 8) = local_50;

+          *(undefined8 ********)local_res8 = &local_58;

+          *(_SDP_STREAM_ENTRY **)local_50 = local_res8;

+          local_50 = local_res8;

+          uVar8 = *(int *)(local_res8 + 0x10) + uVar14;

+          if (uVar8 < uVar14) {

+            uVar14 = 0xffffffff;

+            lVar7 = -0x3fffff6b;

+            uVar12 = (uint7)((ulonglong)&local_58 >> 8);

+            if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

+               (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+              lVar11 = CONCAT71(uVar12,1);

             }

-            *unaff_R14 = (int)unaff_RBX;

-            RefObj_ReleaseEx(p_Var4,p_Var4,0x399,

-                             "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\sdpinterface.cpp"

-                            );

+            else {

+              lVar11 = (ulonglong)uVar12 << 8;

+            }

+            WPP_RECORDER_AND_TRACE_SF_LLd

+                      (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),lVar11,*(int *)(local_res8 + 0x10)

+                       ,*(undefined8 *)(WPP_GLOBAL_Control + 0x40),pp_Var17,puVar18,0x22);

+            break;

           }

-          else if (lVar2 != 0x103) {

-            *(undefined1 **)unaff_RDI = unaff_RBX;

-            *(int *)(unaff_RDI + 8) = (int)unaff_RBX;

-            unaff_RDI[0x14] = SUB81(unaff_RBX,0);

-            *(undefined1 **)(unaff_RDI + 0xc) = unaff_RBX;

-            *unaff_R14 = 0x15;

-          }

+          lVar7 = 0;

+          uVar14 = uVar8;

         }

       }

     }

+  }

+  ExReleaseFastMutex(&param_1->ServiceRecordListMutex);

+  if (-1 < lVar7) {

+    bVar4 = SdpGetContainerHeaderSize(uVar14);

+    uVar8 = bVar4 + uVar14;

+    if (uVar8 < uVar14) {

+      lVar7 = -0x3fffff6b;

+      if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

+         ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

+        uVar16 = 0;

+      }

+      WPP_RECORDER_AND_TRACE_SF_LLd

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar16,bVar4,

+                 *(undefined8 *)(WPP_GLOBAL_Control + 0x40));

+    }

     else {

-      lVar2 = SdpInt_ConnectCached((_SDP_INTERFACE *)param_1,(_IRP *)param_2,unaff_RDI);

-      if (-1 < lVar2) {

-        *unaff_R14 = 0x15;

+      lVar7 = 0;

+      puVar9 = (uchar *)ExAllocatePool2(0x40,uVar8,0x50485442);

+      if (puVar9 != (uchar *)0x0) {

+        *local_res20 = puVar9;

+        *param_5 = uVar8;

+        _Dst = (void *)SdpWriteVariableSizeToStream(6,uVar14,puVar9);

+        for (pppppppuVar15 = (undefined8 *******)local_58; pppppppuVar15 != &local_58;

+            pppppppuVar15 = (undefined8 *******)*pppppppuVar15) {

+          memmove(_Dst,(void *)((longlong)pppppppuVar15 + 0x14),

+                  (ulonglong)*(uint *)(pppppppuVar15 + 2));

+          _Dst = (void *)((longlong)_Dst + (ulonglong)*(uint *)(pppppppuVar15 + 2));

+        }

+        goto LAB_1;

       }

+      lVar7 = -0x3fffff66;

     }

   }

-  else {

-    lVar2 = -0x3ffffff3;

+  uVar5 = SdpMapNtStatusToSdpError(lVar7);

+  *param_6 = uVar5;

+LAB_1:

+  while( true ) {

+    ppppppuVar2 = local_58;

+    if ((undefined8 *******)local_58 == &local_58) {

+      return lVar7;

+    }

+    if (((undefined8 *******)local_58[1] != &local_58) ||

+       (pppppppuVar15 = (undefined8 *******)*local_58, pppppppuVar15[1] != local_58)) break;

+    pppppppuVar15[1] = &local_58;

+    local_58 = pppppppuVar15;

+    ExFreePoolWithTag(ppppppuVar2,0);

   }

-  return lVar2;

+LAB_0:

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

+  (*pcVar1)(3);

+  return lVar7;

 }
```

## `HCI_GetOrAllocateLinkedBrDibInternal`  (modified)

```diff
--- HCI_GetOrAllocateLinkedBrDibInternal
+++ HCI_GetOrAllocateLinkedBrDibInternal
@@ -1,44 +1,413 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* struct DEVICE_INFO_BLOCK * __ptr64 __cdecl HCI_GetOrAllocateLinkedBrDibInternal(struct

+   HCI_INTERFACE * __ptr64,unsigned __int64 const & __ptr64,struct DEVICE_INFO_BLOCK *

+   __ptr64,bool,struct _GUID * __ptr64,bool,void * __ptr64) */

 

 DEVICE_INFO_BLOCK * __cdecl

 HCI_GetOrAllocateLinkedBrDibInternal

           (HCI_INTERFACE *param_1,__uint64 *param_2,DEVICE_INFO_BLOCK *param_3,bool param_4,

           _GUID *param_5,bool param_6,void *param_7)

 

 {

-  longlong *plVar1;

-  longlong lVar2;

-  code *pcVar3;

-  longlong in_RAX;

-  char unaff_BL;

-  longlong unaff_RBP;

-  DEVICE_INFO_BLOCK *unaff_RDI;

-  undefined7 in_register_00000089;

-  char unaff_R13B;

-  longlong unaff_R15;

-  byte in_CF;

+  intrusive_list_hook *piVar1;

+  atomic<unsigned___int64> *paVar2;

+  ulong *puVar3;

+  ulong uVar4;

+  uint uVar5;

+  ulonglong uVar6;

+  _LIST_ENTRY *p_Var7;

+  ulong64 uVar8;

+  undefined1 *puVar9;

+  longlong *plVar10;

+  code *pcVar11;

+  undefined8 uVar12;

+  ushort uVar13;

+  ushort uVar14;

+  long lVar15;

+  DEVICE_INFO_BLOCK *pDVar16;

+  DEVICE_INFO_BLOCK *pDVar17;

+  _LIST_ENTRY *p_Var18;

+  DEVICE_INFO_BLOCK *pDVar19;

+  uchar uVar20;

+  DEVICE_INFO_BLOCK **ppDVar21;

+  DEVICE_INFO_BLOCK **ppDVar22;

+  char cVar23;

+  char *pcVar24;

+  undefined1 local_res10;

+  DEVICE_INFO_BLOCK *local_res18 [2];

+  DEVICE_INFO_BLOCK *local_58;

+  _LIST_ENTRY local_50;

   

-  func_0x000128d5a2fe((int)param_1 + *(int *)(in_RAX + -0x73) + (uint)in_CF,param_2,param_3,

-                      CONCAT71(in_register_00000089,param_4));

-  if ((unaff_R13B == '\0') &&

-     (KeReleaseSpinLock(unaff_R15 + 0x7b0,*(undefined1 *)(unaff_RBP + 0x48)),

-     *(char *)(unaff_RBP + 0x68) != unaff_BL)) {

-    while (plVar1 = *(longlong **)(unaff_RBP + -0x18), plVar1 != (longlong *)(unaff_RBP + -0x18)) {

-      if ((plVar1[1] != unaff_RBP + -0x18) || (lVar2 = *plVar1, *(longlong **)(lVar2 + 8) != plVar1)

-         ) {

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

-        (*pcVar3)(3);

-        return unaff_RDI;

-      }

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

-      *(longlong *)(lVar2 + 8) = unaff_RBP + -0x18;

-      plVar1[1] = (longlong)plVar1;

-      *plVar1 = (longlong)plVar1;

-      RefObj_ReleaseEx(plVar1 + -0x68,plVar1 + -0x68,0x1f1d,

+  ppDVar22 = (DEVICE_INFO_BLOCK **)0x0;

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+     (cVar23 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    cVar23 = '\0';

+  }

+  local_res18[0] = param_3;

+  if ((cVar23 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_iqdd

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar23,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->IfrLog);

+  }

+  uVar6 = *param_2;

+  if ((uVar6 == 0) || ((uVar6 & 0xffff000000000000) != 0)) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+      ppDVar22 = (DEVICE_INFO_BLOCK **)&DAT_0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+               CONCAT71((int7)(uVar6 >> 8),(char)ppDVar22),1,param_1->IfrLog,2,2,0x3c,

+               &WPP_ad144674c127399e1f530e053018150b_Traceguids,uVar6);

+    return (DEVICE_INFO_BLOCK *)0x0;

+  }

+  local_res10 = 0;

+  if (!param_4) {

+    local_res10 = KeAcquireSpinLockRaiseToDpc(&param_1->HciLock);

+  }

+  local_58 = (DEVICE_INFO_BLOCK *)0x0;

+  param_7 = (void *)((ulonglong)param_7 & 0xffffffffffffff00);

+  ppDVar21 = local_res18;

+  if (param_3 != (DEVICE_INFO_BLOCK *)0x0) {

+    ppDVar21 = ppDVar22;

+  }

+  lVar15 = HCI_FindDeviceInfoBlockByAddressLocked

+                     (param_1,param_2,(uchar *)&param_7,&local_58,ppDVar21);

+  pDVar16 = local_58;

+  if (((-1 < lVar15) && (local_58 == (DEVICE_INFO_BLOCK *)0x0)) &&

+     (pDVar16 = HCI_DibCreate(param_1,param_2,(uchar *)0x0), local_58 = pDVar16,

+     pDVar16 != (DEVICE_INFO_BLOCK *)0x0)) {

+    (pDVar16->DeviceInfo).flags = (pDVar16->DeviceInfo).flags | 0x4000;

+    HCI_DibPopulateDefaultContainerIds(pDVar16);

+    if (param_5 == (_GUID *)0x0) {

+      (pDVar16->ActivityId).Data1 = 0;

+      (pDVar16->ActivityId).Data2 = 0;

+      (pDVar16->ActivityId).Data3 = 0;

+      (pDVar16->ActivityId).Data4[0] = '\0';

+      (pDVar16->ActivityId).Data4[1] = '\0';

+      (pDVar16->ActivityId).Data4[2] = '\0';

+      (pDVar16->ActivityId).Data4[3] = '\0';

+      (pDVar16->ActivityId).Data4[4] = '\0';

+      (pDVar16->ActivityId).Data4[5] = '\0';

+      (pDVar16->ActivityId).Data4[6] = '\0';

+      (pDVar16->ActivityId).Data4[7] = '\0';

+    }

+    else {

+      uVar13 = param_5->Data2;

+      uVar14 = param_5->Data3;

+      uVar12 = *(undefined8 *)param_5->Data4;

+      (pDVar16->ActivityId).Data1 = param_5->Data1;

+      (pDVar16->ActivityId).Data2 = uVar13;

+      (pDVar16->ActivityId).Data3 = uVar14;

+      *(undefined8 *)(pDVar16->ActivityId).Data4 = uVar12;

+    }

+    param_1->NumDevices = param_1->NumDevices + 1;

+    p_Var7 = (param_1->DeviceList).Blink;

+    piVar1 = &pDVar16->ListEntry;

+    if (p_Var7->Flink != &param_1->DeviceList) goto LAB_1;

+    *(_LIST_ENTRY **)&piVar1->field_0x0 = &param_1->DeviceList;

+    *(_LIST_ENTRY **)&(pDVar16->ListEntry).field_0x8 = p_Var7;

+    p_Var7->Flink = (_LIST_ENTRY *)piVar1;

+    (param_1->DeviceList).Blink = (_LIST_ENTRY *)piVar1;

+  }

+  local_50.Blink = &local_50;

+  local_50.Flink = &local_50;

+  if ((-1 < lVar15) && (pDVar16 != (DEVICE_INFO_BLOCK *)0x0)) {

+    if (!param_4) {

+      RefObj_AddRefEx(pDVar16,HCI_GetOrAllocateLinkedBrDibFromLeDib,0xc98,

+                      "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\hcidib.cpp");

+    }

+    pDVar19 = local_res18[0];

+    if (local_res18[0] == (DEVICE_INFO_BLOCK *)0x0) {

+      HCI_AssignDibNumber(pDVar16);

+    }

+    else {

+      uVar4 = (local_res18[0]->DeviceInfo).classOfDevice;

+      if ((uVar4 != 0) && ((pDVar16->DeviceInfo).classOfDevice == 0)) {

+        (pDVar16->DeviceInfo).classOfDevice = uVar4;

+        HCI_DibUpdateCod(pDVar16,(uchar *)0x0);

+      }

+      uVar5 = (pDVar19->DeviceInfo).flags;

+      param_7 = (void *)0x0;

+      if ((uVar5 >> 0x16 & 1) == 0) {

+        if (((uVar5 & 4) != 0) &&

+           (lVar15 = RtlStringCbLengthA((pDVar19->DeviceInfo).name,0xf8,(__uint64 *)&param_7),

+           -1 < lVar15)) {

+          pcVar24 = (pDVar19->DeviceInfo).name;

+          goto LAB_2;

+        }

+      }

+      else {

+        pcVar24 = pDVar19->LEName;

+        lVar15 = RtlStringCbLengthA(pcVar24,0xf8,(__uint64 *)&param_7);

+        if (-1 < lVar15) {

+LAB_2:

+          HCI_DibUpdateName(pDVar16,pcVar24,(char)param_7 + '\x01');

+        }

+      }

+      if (((pDVar19->DeviceInfo).flags & 0x40) != 0) {

+        (pDVar16->DeviceInfo).flags = (pDVar16->DeviceInfo).flags | 0x40;

+      }

+    }

+    if ((pDVar19 != (DEVICE_INFO_BLOCK *)0x0) && (pDVar19->LinkedDibAddress == 0)) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (cVar23 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+        cVar23 = '\0';

+      }

+      if ((cVar23 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+        WPP_RECORDER_AND_TRACE_SF_qq

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar23,

+                   *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->IfrLog,5,2,0x3d,

+                   &WPP_ad144674c127399e1f530e053018150b_Traceguids,(pDVar19->DeviceInfo).address,

+                   (pDVar16->DeviceInfo).address);

+      }

+    }

+    p_Var7 = &param_1->DeviceList;

+    if (pDVar19 == (DEVICE_INFO_BLOCK *)0x0) {

+      if (pDVar16->LinkedDibAddress != 0) {

+        pDVar17 = HCI_FindLinkedDib(p_Var7,pDVar16);

+        pDVar16->LinkedDibAddress = 0;

+        pDVar16->LinkedDibAddressType = '\0';

+        if (pDVar17 != (DEVICE_INFO_BLOCK *)0x0) {

+          pDVar17->LinkedDibAddress = 0;

+          pDVar17->LinkedDibAddressType = '\0';

+        }

+        goto LAB_3;

+      }

+    }

+    else {

+      if (pDVar19->LinkedDibAddress != 0) {

+        if (pDVar19->LinkedDibAddress == (pDVar16->DeviceInfo).address) {

+          if (((pDVar16->DeviceInfo).flags & 0x8000) == 0) {

+            uVar20 = 0xff;

+          }

+          else {

+            ppDVar21 = ppDVar22;

+            if (pDVar16->LEOriginalAddressType != 0xff) {

+              ppDVar21 = (DEVICE_INFO_BLOCK **)(ulonglong)pDVar16->LEOriginalAddressType;

+            }

+            uVar20 = (uchar)ppDVar21;

+          }

+          if (((pDVar19->LinkedDibAddressType == uVar20) && (pDVar16->LinkedDibAddress != 0)) &&

+             (pDVar16->LinkedDibAddress == (pDVar19->DeviceInfo).address)) {

+            if (((pDVar19->DeviceInfo).flags & 0x8000) == 0) {

+              uVar20 = 0xff;

+            }

+            else {

+              ppDVar21 = ppDVar22;

+              if (pDVar19->LEOriginalAddressType != 0xff) {

+                ppDVar21 = (DEVICE_INFO_BLOCK **)(ulonglong)pDVar19->LEOriginalAddressType;

+              }

+              uVar20 = (uchar)ppDVar21;

+            }

+            if (pDVar16->LinkedDibAddressType == uVar20) goto LAB_4;

+          }

+          if (((pDVar16->DeviceInfo).flags & 0x8000) == 0) {

+            uVar20 = 0xff;

+          }

+          else {

+            ppDVar21 = ppDVar22;

+            if (pDVar16->LEOriginalAddressType != 0xff) {

+              ppDVar21 = (DEVICE_INFO_BLOCK **)(ulonglong)pDVar16->LEOriginalAddressType;

+            }

+            uVar20 = (uchar)ppDVar21;

+          }

+          if (pDVar19->LinkedDibAddressType == uVar20) goto LAB_5;

+        }

+        pDVar17 = HCI_FindLinkedDib(p_Var7,pDVar19);

+        pDVar19->LinkedDibAddress = 0;

+        pDVar19->LinkedDibAddressType = '\0';

+        if (pDVar17 != (DEVICE_INFO_BLOCK *)0x0) {

+          pDVar17->LinkedDibAddress = 0;

+          pDVar17->LinkedDibAddressType = '\0';

+        }

+      }

+LAB_5:

+      if (pDVar16->LinkedDibAddress != 0) {

+        if (pDVar16->LinkedDibAddress == (pDVar19->DeviceInfo).address) {

+          if (((pDVar19->DeviceInfo).flags & 0x8000) == 0) {

+            uVar20 = 0xff;

+          }

+          else {

+            ppDVar21 = ppDVar22;

+            if (pDVar19->LEOriginalAddressType != 0xff) {

+              ppDVar21 = (DEVICE_INFO_BLOCK **)(ulonglong)pDVar19->LEOriginalAddressType;

+            }

+            uVar20 = (uchar)ppDVar21;

+          }

+          if (pDVar16->LinkedDibAddressType == uVar20) goto LAB_6;

+        }

+        pDVar17 = HCI_FindLinkedDib(p_Var7,pDVar16);

+        pDVar16->LinkedDibAddress = 0;

+        pDVar16->LinkedDibAddressType = '\0';

+        if (pDVar17 != (DEVICE_INFO_BLOCK *)0x0) {

+          pDVar17->LinkedDibAddress = 0;

+          pDVar17->LinkedDibAddressType = '\0';

+        }

+      }

+LAB_6:

+      pDVar19->LinkedDibAddress = (pDVar16->DeviceInfo).address;

+      if (((pDVar16->DeviceInfo).flags >> 0xf & 1) == 0) {

+        uVar20 = 0xff;

+      }

+      else {

+        ppDVar21 = ppDVar22;

+        if (pDVar16->LEOriginalAddressType != 0xff) {

+          ppDVar21 = (DEVICE_INFO_BLOCK **)(ulonglong)pDVar16->LEOriginalAddressType;

+        }

+        uVar20 = (uchar)ppDVar21;

+      }

+      uVar8 = (pDVar19->DeviceInfo).address;

+      pDVar19->LinkedDibAddressType = uVar20;

+      pDVar16->LinkedDibAddress = uVar8;

+      if (((pDVar19->DeviceInfo).flags >> 0xf & 1) == 0) {

+        uVar20 = 0xff;

+      }

+      else {

+        if (pDVar19->LEOriginalAddressType != 0xff) {

+          ppDVar22 = (DEVICE_INFO_BLOCK **)(ulonglong)pDVar19->LEOriginalAddressType;

+        }

+        uVar20 = (uchar)ppDVar22;

+      }

+      pDVar16->LinkedDibAddressType = uVar20;

+LAB_3:

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (cVar23 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+        cVar23 = '\0';

+      }

+      if ((cVar23 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+        WPP_RECORDER_AND_TRACE_SF_qq

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar23,

+                   *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->IfrLog,5,2,0x3e,

+                   &WPP_ad144674c127399e1f530e053018150b_Traceguids,pDVar16,pDVar19);

+      }

+    }

+LAB_4:

+    pDVar19 = local_58;

+    if (param_1->CacheEntryDisposableLimit != 0) {

+      uVar5 = (pDVar16->DeviceInfo).flags;

+      if (((((uVar5 >> 0xe & 1) == 0) || (pDVar16->LinkedDibAddress != 0)) &&

+          ((uVar5 & 0x1030038) == 0)) &&

+         ((paVar2 = &pDVar16->DibFlags, pDVar16 = local_58, ((ulonglong)*paVar2 & 8) == 0 &&

+          ((intrusive_list_hook *)*(undefined1 **)&local_58->ListEntry != &local_58->ListEntry)))) {

+        pDVar17 = HCI_FindLinkedDib(&local_58->Hci->DeviceList,local_58);

+        pDVar16 = pDVar19;

+        if ((pDVar17 == (DEVICE_INFO_BLOCK *)0x0) ||

+           (((uVar5 = (pDVar17->DeviceInfo).flags, (uVar5 >> 0xe & 1) == 0 ||

+             (pDVar17->LinkedDibAddress != 0)) &&

+            (((uVar5 & 0x1030038) == 0 &&

+             (pDVar16 = local_58, ((ulonglong)pDVar17->DibFlags & 8) == 0)))))) {

+          piVar1 = &pDVar16->DisposableListEntry;

+          puVar9 = *(undefined1 **)piVar1;

+          if ((intrusive_list_hook *)puVar9 == piVar1) {

+            puVar3 = &pDVar16->Hci->NumberOfDisposableDevices;

+            *puVar3 = *puVar3 + 1;

+          }

+          else {

+            if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

+               (plVar10 = *(longlong **)&(pDVar16->DisposableListEntry).field_0x8,

+               (intrusive_list_hook *)*plVar10 != piVar1)) goto LAB_1;

+            *plVar10 = (longlong)puVar9;

+            *(longlong **)(puVar9 + 8) = plVar10;

+            *(intrusive_list_hook **)&(pDVar16->DisposableListEntry).field_0x8 = piVar1;

+            *(intrusive_list_hook **)piVar1 = piVar1;

+          }

+          p_Var18 = &pDVar16->Hci->DisposableDeviceList;

+          p_Var7 = p_Var18->Flink;

+          if (p_Var7->Blink != p_Var18) goto LAB_1;

+          *(_LIST_ENTRY **)piVar1 = p_Var7;

+          *(_LIST_ENTRY **)&(pDVar16->DisposableListEntry).field_0x8 = p_Var18;

+          p_Var7->Blink = (_LIST_ENTRY *)piVar1;

+          p_Var18->Flink = (_LIST_ENTRY *)piVar1;

+          if (pDVar17 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_7;

+        }

+        piVar1 = &pDVar17->DisposableListEntry;

+        puVar9 = *(undefined1 **)piVar1;

+        if ((intrusive_list_hook *)puVar9 != piVar1) {

+          if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

+             (plVar10 = *(longlong **)&(pDVar17->DisposableListEntry).field_0x8,

+             (intrusive_list_hook *)*plVar10 != piVar1)) {

+LAB_1:

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

+            (*pcVar11)(3);

+            return pDVar16;

+          }

+          *plVar10 = (longlong)puVar9;

+          *(longlong **)(puVar9 + 8) = plVar10;

+          *(intrusive_list_hook **)&(pDVar17->DisposableListEntry).field_0x8 = piVar1;

+          *(intrusive_list_hook **)piVar1 = piVar1;

+          p_Var18 = &pDVar17->Hci->DisposableDeviceList;

+          p_Var7 = p_Var18->Flink;

+          if (p_Var7->Blink != p_Var18) goto LAB_1;

+          *(_LIST_ENTRY **)piVar1 = p_Var7;

+          *(_LIST_ENTRY **)&(pDVar17->DisposableListEntry).field_0x8 = p_Var18;

+          p_Var7->Blink = (_LIST_ENTRY *)piVar1;

+          p_Var18->Flink = (_LIST_ENTRY *)piVar1;

+        }

+      }

+      else {

+        piVar1 = &pDVar16->DisposableListEntry;

+        puVar9 = *(undefined1 **)piVar1;

+        if ((intrusive_list_hook *)puVar9 != piVar1) {

+          if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

+             (plVar10 = *(longlong **)&(pDVar16->DisposableListEntry).field_0x8,

+             (intrusive_list_hook *)*plVar10 != piVar1)) goto LAB_1;

+          *plVar10 = (longlong)puVar9;

+          *(longlong **)(puVar9 + 8) = plVar10;

+          *(intrusive_list_hook **)&(pDVar16->DisposableListEntry).field_0x8 = piVar1;

+          *(intrusive_list_hook **)piVar1 = piVar1;

+          uVar4 = pDVar16->Hci->NumberOfDisposableDevices;

+          if (uVar4 != 0) {

+            pDVar16->Hci->NumberOfDisposableDevices = uVar4 - 1;

+          }

+        }

+        pDVar19 = HCI_FindLinkedDib(&pDVar16->Hci->DeviceList,pDVar16);

+        if (pDVar19 != (DEVICE_INFO_BLOCK *)0x0) {

+          piVar1 = &pDVar19->DisposableListEntry;

+          puVar9 = *(undefined1 **)piVar1;

+          if ((intrusive_list_hook *)puVar9 != piVar1) {

+            if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

+               (plVar10 = *(longlong **)&(pDVar19->DisposableListEntry).field_0x8,

+               (intrusive_list_hook *)*plVar10 != piVar1)) goto LAB_1;

+            *plVar10 = (longlong)puVar9;

+            *(longlong **)(puVar9 + 8) = plVar10;

+            *(intrusive_list_hook **)&(pDVar19->DisposableListEntry).field_0x8 = piVar1;

+            *(intrusive_list_hook **)piVar1 = piVar1;

+            uVar4 = pDVar19->Hci->NumberOfDisposableDevices;

+            if (uVar4 != 0) {

+              pDVar19->Hci->NumberOfDisposableDevices = uVar4 - 1;

+            }

+          }

+        }

+      }

+LAB_7:

+      if (param_4) {

+        return pDVar16;

+      }

+      if (param_6) {

+        HCI_DibProcessDisposableListLocked(param_1,&local_50);

+      }

+      goto LAB_8;

+    }

+  }

+  if (param_4) {

+    return pDVar16;

+  }

+LAB_8:

+  KeReleaseSpinLock(&param_1->HciLock,local_res10);

+  if (param_6) {

+    while (local_50.Flink != &local_50) {

+      if (((local_50.Flink)->Blink != &local_50) ||

+         (p_Var7 = (local_50.Flink)->Flink, p_Var7->Blink != local_50.Flink)) goto LAB_1;

+      p_Var7->Blink = &local_50;

+      p_Var18 = local_50.Flink + -0x34;

+      (local_50.Flink)->Blink = local_50.Flink;

+      (local_50.Flink)->Flink = local_50.Flink;

+      local_50.Flink = p_Var7;

+      RefObj_ReleaseEx(p_Var18,p_Var18,0x1f1d,

                        "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\HCIp.h");

     }

   }

-  return unaff_RDI;

+  return pDVar16;

 }
```

## `L2CapCon_ExtractConfigOptionsFromBuffer`  (modified)

```diff
--- L2CapCon_ExtractConfigOptionsFromBuffer
+++ L2CapCon_ExtractConfigOptionsFromBuffer
@@ -1,153 +1,63 @@
 

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

-/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl L2CapCon_ExtractConfigOptionsFromBuffer(struct _CHANNEL_CONFIG_PARAMETERS_ENHANCED *

+   __ptr64,struct _LIST_ENTRY * __ptr64,unsigned long * __ptr64,unsigned long * __ptr64,unsigned

+   long * __ptr64) */

 

 void __cdecl

 L2CapCon_ExtractConfigOptionsFromBuffer

           (_CHANNEL_CONFIG_PARAMETERS_ENHANCED *param_1,_LIST_ENTRY *param_2,ulong *param_3,

           ulong *param_4,ulong *param_5)

 

 {

-  uint *puVar1;

-  short sVar2;

-  ushort uVar3;

-  byte bVar4;

-  uint uVar5;

-  byte bVar6;

-  L2CAP_CONNECTION *unaff_RBX;

-  byte unaff_BPL;

-  L2CAP_CONNECTION LVar7;

-  uint uVar8;

-  ulonglong unaff_RSI;

-  longlong unaff_RDI;

-  ushort uVar9;

-  uint uVar10;

-  uchar uVar11;

-  L2CAP_CONNECTION in_R10B;

-  _CHANNEL_CONFIG_PARAMETERS_ENHANCED *unaff_R12;

-  _CHANNEL_CONFIG_PARAMETERS_ENHANCED *unaff_R13;

-  _CHANNEL_CONFIG_PARAMETERS_ENHANCED *unaff_R14;

-  _CHANNEL_CONFIG_PARAMETERS_ENHANCED *unaff_R15;

+  char cVar1;

+  byte bVar2;

+  uint uVar3;

+  _LIST_ENTRY *p_Var4;

+  _LIST_ENTRY **pp_Var5;

+  uint uVar6;

+  ulonglong uVar7;

+  void *_Src;

+  _LIST_ENTRY *p_Var8;

   

-  uVar5 = (uint)param_1;

-  puVar1 = (uint *)(unaff_RSI * 2 + 0x4c9831a);

-  *puVar1 = *puVar1 << 5 | *puVar1 >> 0x1b;

-  bVar6 = (byte)param_2;

-  *(byte *)(unaff_RDI + 0x19) = bVar6;

-  unaff_R15->Flags = uVar5;

-  (unaff_R15->Flow).TokenRate = (int)unaff_RSI;

-  (unaff_R15->Flow).TokenBucketSize = (int)(unaff_RSI >> 0x20);

-  uVar8 = (uint)unaff_RSI;

-  (unaff_R15->Flow).PeakBandwidth = uVar8;

-  (unaff_R15->Flow).Latency = (ulong)param_3;

-  (unaff_R15->Flow).DelayVariation = (ulong)param_3;

-  bVar4 = (byte)param_1;

-  LVar7 = SUB81(unaff_RSI,0);

-  if (((unaff_BPL & bVar4) == 0) ||

-     ((L2CAP_CONNECTION)(unaff_R15->RetransmissionAndFlow).Mode == LVar7)) {

-    if ((bVar6 & bVar4) != 0) {

-      uVar5 = uVar5 & (uint)param_4;

-      goto LAB_0;

+  *param_3 = 0;

+  *param_4 = 0;

+  p_Var4 = param_2->Flink;

+  *param_5 = 0;

+  do {

+    if (p_Var4 == param_2) {

+      return;

     }

-  }

-  else if ((bVar6 & bVar4) == 0) {

-    uVar5 = uVar5 | (uint)param_2;

-    unaff_R15->Fcs = (uchar)in_R10B;

-LAB_0:

-    unaff_R15->Flags = uVar5;

-  }

-  if (((bVar6 & (byte)unaff_R14->Flags & (byte)uVar5) != 0) &&

-     (unaff_RBX[0x1e7] != unaff_RBX[0x247])) {

-    unaff_RBX[0x247] = in_R10B;

-    unaff_RBX[0x1e7] = in_R10B;

-  }

-  memset(unaff_R12,0,0x50);

-  memset(unaff_R13,0,0x50);

-  uVar11 = '\0';

-  L2CapCon_MergeConfigParams_V4(unaff_R14,unaff_R14,unaff_R12,'\0');

-  L2CapCon_MergeConfigParams_V4(unaff_R15,unaff_R15,unaff_R13,uVar11);

-  if (((unaff_BPL & (byte)*(uint *)(unaff_RBX + 0x1b0)) != 0) && (unaff_RBX[0x1de] == LVar7)) {

-    *(uint *)(unaff_RBX + 0x1b0) = *(uint *)(unaff_RBX + 0x1b0) & 0xffffff3f;

-  }

-  if (((unaff_BPL & (byte)*(uint *)(unaff_RBX + 0x210)) != 0) && (unaff_RBX[0x23e] == LVar7)) {

-    *(uint *)(unaff_RBX + 0x210) = *(uint *)(unaff_RBX + 0x210) & 0xffffff3f;

-  }

-  L2CapCon_ShowConnection(unaff_RBX,"");

-  sVar2 = *(short *)(unaff_RDI + 0x16);

-  uVar9 = (ushort)unaff_RSI;

-  if (((ushort)(sVar2 - 0x102U) < 2) || ((ushort)(sVar2 - 0x212U) < 2)) {

-    uVar5 = *(uint *)(unaff_RDI + 0x88);

-LAB_1:

-    if ((uVar5 & 0x10) != 0) {

-      if (((ushort)(sVar2 - 0x102U) < 2) || ((ushort)(sVar2 - 0x212U) < 2)) {

-        uVar3 = *(ushort *)(unaff_RDI + 0xae);

+    p_Var8 = p_Var4[1].Blink;

+    uVar3 = *(uint *)&p_Var4[1].Flink;

+    pp_Var5 = &p_Var8->Flink;

+    while (p_Var8 < (_LIST_ENTRY *)((longlong)pp_Var5 + (ulonglong)uVar3)) {

+      cVar1 = *(char *)&p_Var8->Flink;

+      bVar2 = *(byte *)((longlong)&p_Var8->Flink + 1);

+      _Src = (void *)((longlong)&p_Var8->Flink + 2);

+      uVar7 = 0;

+      while( true ) {

+        uVar6 = (uint)uVar7;

+        if (6 < uVar6) break;

+        if ((&DAT_0)[uVar7 * 0x10] == cVar1) {

+          param_1->Flags = param_1->Flags | (&DAT_1)[uVar7 * 4];

+          memmove((void *)((longlong)&param_1->Flags + (&DAT_2)[uVar7 * 2]),_Src,

+                  (ulonglong)bVar2);

+          goto LAB_3;

+        }

+        uVar7 = (ulonglong)(uVar6 + 1);

       }

-      else if (sVar2 == -0x3ef7 || sVar2 == -0x3ef6) {

-        uVar3 = *(ushort *)(unaff_RDI + 0xb6);

+      if (uVar6 == 7) {

+        param_1->NumExtraOptions = param_1->NumExtraOptions + 1;

+        *param_3 = *param_3 + (uint)bVar2;

+        if (cVar1 < '\0') {

+          *param_4 = *param_4 + 1;

+          *param_5 = *param_5 + (uint)bVar2;

+        }

       }

-      else if ((sVar2 == -0x7f00 || sVar2 == -0x7eff) ||

-              (uVar3 = uVar9, sVar2 == -0x7efe || sVar2 == -0x7efd)) {

-        uVar3 = *(ushort *)(unaff_RDI + 0xa6);

-      }

-      *(ushort *)(unaff_RBX + 0x268) = uVar3;

-      HCI_CxnAdjustProperties

-                ((_HCI_CONNECTION *)(*(longlong *)(unaff_RBX + 0x170) + -200),

-                 (_GUID *)&stack0x00000078);

+LAB_3:

+      p_Var8 = (_LIST_ENTRY *)((longlong)_Src + (ulonglong)bVar2);

     }

-  }

-  else {

-    if (sVar2 == -0x3ef7 || sVar2 == -0x3ef6) {

-      uVar5 = *(uint *)(unaff_RDI + 0x90);

-      goto LAB_1;

-    }

-    if ((sVar2 == -0x7f00 || sVar2 == -0x7eff) ||

-       (uVar5 = uVar8, sVar2 == -0x7efe || sVar2 == -0x7efd)) {

-      uVar5 = *(uint *)(unaff_RDI + 0x80);

-      goto LAB_1;

-    }

-  }

-  if ((*(uint *)(unaff_RBX + 0x210) & 2) != 0) {

-    if ((*(ushort *)(unaff_RBX + 0x216) != 0xffff) &&

-       (uVar10 = ((uint)*(ushort *)(unaff_RBX + 0x216) * 1000) / 0x271, uVar9 = (ushort)uVar10,

-       0x7ff < uVar10)) {

-      uVar9 = 0x7ff;

-    }

-    HCI_SetAutomaticFlushTimeout

-              (*(HCI_L2CAP_DATA **)(unaff_RBX + 0x170),(HCI_CLIENT *)(unaff_RBX + 0x18),uVar9);

-  }

-  if ((uVar5 & 0x20) == 0) goto LAB_2;

-  sVar2 = *(short *)(unaff_RDI + 0x16);

-  if (sVar2 == 0x102 || sVar2 == 0x103) {

-    uVar8 = *(uint *)(unaff_RDI + 0xc4);

-    if ((sVar2 != 0x102) && (sVar2 != 0x103)) goto LAB_3;

-LAB_4:

-    unaff_RSI = (ulonglong)*(byte *)(unaff_RDI + 0xc0);

-  }

-  else {

-    if (sVar2 == 0x212 || sVar2 == 0x213) {

-      uVar8 = *(uint *)(unaff_RDI + 0xc4);

-    }

-    else if (sVar2 == -0x3ef7 || sVar2 == -0x3ef6) {

-      uVar8 = *(uint *)(unaff_RDI + 0xcc);

-    }

-    else if ((sVar2 == -0x7f00 || sVar2 == -0x7eff) || (sVar2 == -0x7efe || sVar2 == -0x7efd)) {

-      uVar8 = *(uint *)(unaff_RDI + 0xbc);

-    }

-LAB_3:

-    if (sVar2 == 0x212 || sVar2 == 0x213) goto LAB_4;

-    if (sVar2 == -0x3ef7 || sVar2 == -0x3ef6) {

-      unaff_RSI = (ulonglong)*(byte *)(unaff_RDI + 200);

-    }

-    else if ((sVar2 == -0x7f00 || sVar2 == -0x7eff) || (sVar2 == -0x7efe || sVar2 == -0x7efd)) {

-      unaff_RSI = (ulonglong)*(byte *)(unaff_RDI + 0xb8);

-    }

-  }

-  HCI_SetConnectionQos

-            (*(HCI_L2CAP_DATA **)(unaff_RBX + 0x170),(uchar)unaff_RSI,uVar8,

-             (_GUID *)&stack0x00000078);

-LAB_2:

-  HCI_IsGuaranteedWriteEnabled

-            (*(HCI_INTERFACE **)(*(longlong *)(*(longlong *)(unaff_RBX + 0x278) + 0x50) + 0x170));

-  return;

+    p_Var4 = p_Var4->Flink;

+  } while( true );

 }
```

## `BthCreateAuthenticateClient`  (modified)

```diff
--- BthCreateAuthenticateClient
+++ BthCreateAuthenticateClient
@@ -1,42 +1,60 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* struct _BTH_AUTHENTICATE_CLIENT * __ptr64 __cdecl BthCreateAuthenticateClient(struct

+   DEVICE_EXTENSION * __ptr64,struct _IRP * __ptr64,struct _IRP * __ptr64,unsigned int) */

 

 _BTH_AUTHENTICATE_CLIENT * __cdecl

 BthCreateAuthenticateClient(DEVICE_EXTENSION *param_1,_IRP *param_2,_IRP *param_3,uint param_4)

 

 {

-  uint uVar1;

-  _BTH_AUTHENTICATE_CLIENT *p_Var2;

-  int unaff_EBX;

-  _IRP *unaff_RBP;

-  _BRB *unaff_RSI;

-  longlong unaff_RDI;

-  int unaff_R14D;

-  PDO_EXTENSION *unaff_R15;

+  _REF_OBJ *p_Var1;

+  undefined1 uVar2;

+  _REF_OBJ *_Dst;

+  _REF_OBJ_DEBUG_INFO **pp_Var3;

+  _REF_OBJ *p_Var4;

   

-  if ((unaff_EBX == 6) || (unaff_EBX == 7)) {

-    uVar1 = ScoInt_HandleSignalRequest

-                      (*(_SCO_INTERFACE **)(unaff_RDI + 0x188),unaff_RBP,unaff_RSI,unaff_R15);

-LAB_0:

-    p_Var2 = (_BTH_AUTHENTICATE_CLIENT *)(ulonglong)uVar1;

-    if (uVar1 == 0x103) {

-      return (_BTH_AUTHENTICATE_CLIENT *)0x103;

+  _Dst = (_REF_OBJ *)ExAllocatePool2(0x40,0xa8,0x50485442);

+  p_Var4 = (_REF_OBJ *)0x0;

+  if (_Dst != (_REF_OBJ *)0x0) {

+    memset(_Dst,0,0xa8);

+    p_Var1 = _Dst + 1;

+    _Dst[2].DestroyFunction = (_func___cdecl_void__REF_OBJ_ptr *)0x0;

+    _Dst[2].DebugInfo = (_REF_OBJ_DEBUG_INFO *)0x0;

+    *(undefined8 *)(_Dst + 3) = 0;

+    _Dst[3].DestroyFunction = (_func___cdecl_void__REF_OBJ_ptr *)0x0;

+    _Dst[3].DebugInfo = (_REF_OBJ_DEBUG_INFO *)0x0;

+    *(undefined8 *)(_Dst + 4) = 0;

+    _Dst[4].DestroyFunction = (_func___cdecl_void__REF_OBJ_ptr *)0x0;

+    *(undefined2 *)&_Dst[4].DebugInfo = 0;

+    *(undefined1 *)((longlong)&_Dst[4].DebugInfo + 2) = 0;

+    *(undefined4 *)((longlong)&_Dst[4].DebugInfo + 4) = 0;

+    *(undefined8 *)(_Dst + 5) = 0;

+    _Dst[5].DestroyFunction = (_func___cdecl_void__REF_OBJ_ptr *)0x0;

+    _Dst[1].DestroyFunction = (_func___cdecl_void__REF_OBJ_ptr *)p_Var1;

+    *(_REF_OBJ **)p_Var1 = p_Var1;

+    pp_Var3 = &_Dst[1].DebugInfo;

+    *(_REF_OBJ_DEBUG_INFO ***)(_Dst + 2) = pp_Var3;

+    *pp_Var3 = (_REF_OBJ_DEBUG_INFO *)pp_Var3;

+    uVar2 = BthLib_RefObjDebugEnabled;

+    _Dst[5].DebugInfo = (_REF_OBJ_DEBUG_INFO *)param_2;

+    *(_IRP **)(_Dst + 6) = param_3;

+    _Dst[6].DestroyFunction = (_func___cdecl_void__REF_OBJ_ptr *)param_1;

+    RefObj_InitEx(_Dst,BthAuthenticateClientDestroy,_Dst,0x91b,

+                  "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\devext.cpp",uVar2);

+    HCI_InitClientEx((HCI_CLIENT *)(_Dst + 1),BthAuthenticateConnectCallback,

+                     (_func_void_HCI_CLIENT_ptr_HCI_L2CAP_DATA_ptr *)0x0,

+                     (_func_long_HCI_CLIENT_ptr_HCI_L2CAP_DATA_ptr__LINK_PROPERTY_TYPE_uchar_void_ptr

+                      *)0x0,(__uint64 *)0x0,_Dst,TypeAuthenticate,param_4 | 0x1004,0,'\0',0);

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x10) != 0) && (3 < (byte)WPP_GLOBAL_Control[0x29])

+       ) {

+      p_Var4 = (_REF_OBJ *)&DAT_0;

     }

-    if (-1 < (int)uVar1) goto LAB_1;

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),p_Var4,1,

+               *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4,5,0x40,

+               &WPP_b01968a2c4b23feb992a1f1f965de22e_Traceguids,_Dst);

+    p_Var4 = _Dst;

   }

-  else {

-    if ((unaff_EBX == 8) || (unaff_EBX == 9)) {

-      uVar1 = L2CapInt_HandleSignalRequest

-                        (*(L2CAP_INTERFACE **)(unaff_RDI + 0x178),unaff_RBP,unaff_RSI,unaff_R15);

-      goto LAB_0;

-    }

-    p_Var2 = (_BTH_AUTHENTICATE_CLIENT *)0xc00000bb;

-  }

-  if (*(int *)(unaff_RSI + 0x1c) < unaff_R14D) {

-    return p_Var2;

-  }

-LAB_1:

-  *(int *)(unaff_RSI + 0x1c) = (int)p_Var2;

-  return p_Var2;

+  return (_BTH_AUTHENTICATE_CLIENT *)p_Var4;

 }
```

## `HCI_SetCPReferenceForDeviceEx`  (modified)

```diff
--- HCI_SetCPReferenceForDeviceEx
+++ HCI_SetCPReferenceForDeviceEx
@@ -1,68 +1,172 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* long __cdecl HCI_SetCPReferenceForDeviceEx(void * __ptr64,unsigned __int64,unsigned char,enum

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

 

 long __cdecl

 HCI_SetCPReferenceForDeviceEx

           (void *param_1,__uint64 param_2,uchar param_3,_LE_CLIENT_PRESENCE_ACTION param_4,

           uchar param_5,uchar param_6,uchar param_7,uchar *param_8)

 

 {

-  _HCI_PHY_TYPE _Var1;

-  uchar *puVar2;

-  uint uVar3;

-  uchar uVar4;

-  long lVar5;

-  int iVar6;

-  int *in_RAX;

-  longlong unaff_RBP;

-  undefined7 in_register_00000081;

-  byte in_CF;

-  ulong64 uStackX_20;

-  undefined3 in_stack_00000031;

-  undefined7 in_stack_00000039;

+  bool bVar1;

+  DEVICE_INFO_BLOCK *pDVar2;

+  wchar_t *pwVar3;

+  undefined8 uVar4;

+  undefined1 uVar5;

+  long lVar6;

+  char cVar7;

+  undefined1 uVar8;

+  __uint64 *local_res10;

+  uchar local_res18 [16];

+  __uint64 *p_Var9;

+  ulong uVar10;

+  ulong uVar11;

+  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+  local_48 [16];

   

-  *(ulonglong *)(unaff_RBP + 0x270) =

-       (ulonglong)((int)in_RAX + *in_RAX + (uint)in_CF) ^ (ulonglong)&stack0x00000000;

-  uStackX_20 = CONCAT71(in_register_00000081,param_3);

-  memset(&param_6,0,0x340);

-  _Var1 = *(_HCI_PHY_TYPE *)(unaff_RBP + 0x2c0);

-  _param_7 = CONCAT71(in_register_00000081,param_3);

-  lVar5 = HCI_GetStoredInfo(param_1,&uStackX_20,_Var1,(_BTH_DEVICE_INFO *)&param_6);

-  if (lVar5 < 0) {

-    iVar6 = 0;

+  uVar5 = 0;

+  bVar1 = false;

+  if (param_8 != (uchar *)0x0) {

+    *param_8 = '\0';

+  }

+  local_res10 = (__uint64 *)param_2;

+  wil::acquire_kspin_lock((__uint64 *)local_48);

+  cVar7 = '\x01';

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+     (uVar8 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+    uVar8 = 0;

+  }

+  pwVar3 = L"AddRef";

+  if (param_4 != LE_CLIENT_PRESENCE_ACTION_ADDREF) {

+    pwVar3 = L"Release";

+  }

+  p_Var9 = local_res10;

+  WPP_RECORDER_AND_TRACE_SF_Si

+            (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+             CONCAT71((int7)((ulonglong)pwVar3 >> 8),uVar8));

+  local_res18[0] = param_3 != '\0';

+  pDVar2 = HCI_FindDeviceInfoBlockByBasebandLocked(param_1,(__uint64 *)&local_res10,HciPhyTypeLE);

+  if (pDVar2 == (DEVICE_INFO_BLOCK *)0x0) {

+    if ((param_4 == LE_CLIENT_PRESENCE_ACTION_ADDREF) && (param_5 != '\0')) {

+      pDVar2 = HCI_UpdateOrAllocateDibEx

+                         (param_1,(__uint64 *)&local_res10,local_res18,

+                          (_func_ulong_HCI_INTERFACE_ptr_DEVICE_INFO_BLOCK_ptr__HCI_PHY_TYPE_void_ptr_LinkedDibAction_ptr

+                           *)0x0,(void *)0x0,(uchar *)0x0,'\0','\x01',HciPhyTypeLE,(_GUID *)0x0,'\0'

+                         );

+      if (pDVar2 != (DEVICE_INFO_BLOCK *)0x0) {

+        LOCK();

+        pDVar2->DibFlags =

+             (atomic<unsigned___int64>)((ulonglong)pDVar2->DibFlags & 0xfffffffffffffff7);

+        UNLOCK();

+        goto LAB_0;

+      }

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29]))

+      {

+        uVar5 = 1;

+      }

+      WPP_RECORDER_AND_TRACE_SF_i

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar5,1,

+                 *(undefined8 *)((longlong)param_1 + 0x10b0),2,2,0xd5,

+                 &WPP_ad144674c127399e1f530e053018150b_Traceguids,local_res10);

+      lVar6 = -0x3fffff66;

+    }

+    else {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29]))

+      {

+        uVar5 = 1;

+      }

+      WPP_RECORDER_AND_TRACE_SF_i

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar5,1,

+                 *(undefined8 *)((longlong)param_1 + 0x10b0),2,2,0xd6,

+                 &WPP_ad144674c127399e1f530e053018150b_Traceguids,local_res10,p_Var9);

+      lVar6 = -0x3ffffddb;

+    }

+    wil::details::

+    unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+    ::

+    ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+              (local_48);

   }

   else {

-    uVar3 = _param_6;

-    puVar2 = param_8;

-    if (_Var1 == HciPhyTypeBR) {

-      uVar4 = HCI_GetStoredEir(&uStackX_20,(uchar *)(unaff_RBP + 0x6d));

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

-        _param_6 = _param_6 | 0x2000;

+LAB_0:

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

+      HCI_DibUpdateLastOutOfBandAddress(pDVar2,(__uint64)local_res10,local_res18[0]);

+    }

+    LOCK();

+    pDVar2->DibFlags = (atomic<unsigned___int64>)((ulonglong)pDVar2->DibFlags & 0xfffffffffffffeff);

+    UNLOCK();

+    pDVar2->numCreatedForConnect = 0;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar4 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar4 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_qidd(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar4);

+    if (param_4 == LE_CLIENT_PRESENCE_ACTION_ADDREF) {

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

+        pDVar2->LEClientPresenceRefCount = pDVar2->LEClientPresenceRefCount + 1;

       }

-      uVar3 = _param_6;

-      puVar2 = param_8;

-      if ((param_4 < LE_CLIENT_PRESENCE_ACTION_RELEASE) && (uVar3 = _param_6 | 0x10, param_4 == 0))

-      {

-        uVar3 = _param_6 | 0x18;

+      else {

+        pDVar2->LEClientPresenceRefCountWithoutAcceptList =

+             pDVar2->LEClientPresenceRefCountWithoutAcceptList + 1;

+      }

+      if (((pDVar2->LEClientPresenceRefCount == 1) &&

+          (pDVar2->LEClientPresenceRefCountWithoutAcceptList == 0)) ||

+         ((pDVar2->LEClientPresenceRefCountWithoutAcceptList == 1 &&

+          (pDVar2->LEClientPresenceRefCount == 0)))) {

+        bVar1 = true;

       }

     }

-    _param_6 = uVar3;

-    param_8._4_4_ = (undefined4)((ulonglong)puVar2 >> 0x20);

-    param_8._0_4_ = SUB84(puVar2,0);

-    if ((_param_6 & 2) == 0) {

-      _param_6 = _param_6 | 2;

-      param_8._0_4_ = 0;

+    else if (param_4 == LE_CLIENT_PRESENCE_ACTION_RELEASE) {

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

+        pDVar2->LEClientPresenceRefCount =

+             -(uint)(pDVar2->LEClientPresenceRefCount != 0) & pDVar2->LEClientPresenceRefCount - 1;

+      }

+      else {

+        pDVar2->LEClientPresenceRefCountWithoutAcceptList =

+             -(uint)(pDVar2->LEClientPresenceRefCountWithoutAcceptList != 0) &

+             pDVar2->LEClientPresenceRefCountWithoutAcceptList - 1;

+      }

+      if ((pDVar2->LEClientPresenceRefCount == 0) &&

+         (pDVar2->LEClientPresenceRefCountWithoutAcceptList == 0)) {

+        bVar1 = true;

+      }

     }

-    if (param_4 == LE_CLIENT_PRESENCE_ACTION_RELEASE) {

-      HCI_AddStoredSecondaryDeviceToList(param_1,(_BTH_DEVICE_INFO_V3 *)&param_6,_Var1);

-      iVar6 = 1;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar4 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar4 = 0;

     }

-    else {

-      uVar4 = HCI_AddStoredDeviceToList(param_1,(_BTH_DEVICE_INFO_V3 *)&param_6,_Var1,param_4);

-      iVar6 = (uVar4 != '\0') + 1;

+    uVar11 = pDVar2->LEClientPresenceRefCountWithoutAcceptList;

+    uVar10 = pDVar2->LEClientPresenceRefCount;

+    p_Var9 = local_res10;

+    WPP_RECORDER_AND_TRACE_SF_qidd(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar4);

+    wil::details::

+    unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+    ::

+    ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+              (local_48);

+    if (bVar1) {

+      if (param_8 == (uchar *)0x0) {

+        *(undefined4 *)((longlong)param_1 + 0x118c) = 6;

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           ((byte)WPP_GLOBAL_Control[0x29] < 5)) {

+          cVar7 = '\0';

+        }

+        if ((cVar7 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+          WPP_RECORDER_AND_TRACE_SF_L

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar7,

+                     *(short *)(WPP_GLOBAL_Control + 0x48) != 0,

+                     *(undefined8 *)((longlong)param_1 + 0x10b0),5,2,0xd9,

+                     &WPP_ad144674c127399e1f530e053018150b_Traceguids,6,p_Var9,uVar10,uVar11);

+        }

+        HCI_ThreadSignalEvent(param_1,HCI_EVENT_PROCESS_LE_WHITE_LIST);

+      }

+      else {

+        *param_8 = '\x01';

+      }

     }

+    lVar6 = 0;

   }

-  return iVar6;

+  return lVar6;

 }
```

## `L2CapCon_BuildExtraOptionsArray`  (modified)

```diff
--- L2CapCon_BuildExtraOptionsArray
+++ L2CapCon_BuildExtraOptionsArray
@@ -1,344 +1,59 @@
+

+/* struct _L2CAP_CONFIG_OPTION * __ptr64 __cdecl L2CapCon_BuildExtraOptionsArray(unsigned

+   long,unsigned long,struct _LIST_ENTRY * __ptr64) */

 

 _L2CAP_CONFIG_OPTION * __cdecl

 L2CapCon_BuildExtraOptionsArray(ulong param_1,ulong param_2,_LIST_ENTRY *param_3)

 

 {

-  char cVar1;

-  short sVar2;

-  longlong lVar3;

-  short sVar4;

-  short sVar5;

-  uint uVar6;

-  char cVar7;

-  ushort uVar8;

-  ushort *puVar9;

-  longlong unaff_RBX;

-  ushort unaff_BP;

-  uint uVar10;

-  longlong unaff_RDI;

-  ushort uVar11;

-  uint uVar12;

-  uint uVar13;

-  longlong in_R9;

-  uint *in_R10;

-  char cVar14;

-  short unaff_R12W;

-  byte bVar15;

-  ushort uVar16;

-  uint uVar17;

-  undefined8 unaff_R14;

-  char cVar18;

-  ushort *unaff_R15;

+  uchar uVar1;

+  byte bVar2;

+  uint uVar3;

+  _LIST_ENTRY *p_Var4;

+  _CO_HEADER _Var5;

+  _LIST_ENTRY **pp_Var6;

+  bool bVar7;

+  int iVar8;

+  _L2CAP_CONFIG_OPTION *p_Var9;

+  void *_Src;

+  _LIST_ENTRY *p_Var10;

+  _L2CAP_CONFIG_OPTION *_Dst;

+  _L2CAP_CONFIG_OPTION *p_Var11;

   

-  sVar4 = (short)unaff_RDI + 1;

-  sVar5 = (short)unaff_RDI + -1;

-  lVar3 = *(longlong *)(in_R9 + 8);

-  sVar2 = *(short *)(lVar3 + 0x16);

-  uVar16 = (ushort)unaff_R14;

-  uVar6 = (uint)unaff_R15;

-  if (uVar16 < (ushort)(sVar2 - unaff_R12W)) {

-    if (uVar16 < (ushort)(sVar2 - 0x212U)) {

-      if (uVar16 < (ushort)(sVar2 + 0x3ef7U)) {

-        if (uVar16 < (ushort)(sVar4 + sVar2)) {

-          uVar17 = uVar6;

-          if ((ushort)(sVar5 + sVar2) <= uVar16) {

-            uVar17 = *(uint *)(lVar3 + 0xe8);

+  p_Var9 = (_L2CAP_CONFIG_OPTION *)ExAllocatePool2(0x40,param_2 + param_1 * 0x18,0x50485442);

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

+    _Dst = p_Var9 + param_1;

+    p_Var11 = p_Var9;

+    for (p_Var4 = param_3->Flink; p_Var4 != param_3; p_Var4 = p_Var4->Flink) {

+      p_Var10 = p_Var4[1].Blink;

+      uVar3 = *(uint *)&p_Var4[1].Flink;

+      pp_Var6 = &p_Var10->Flink;

+      while (p_Var10 < (_LIST_ENTRY *)((longlong)pp_Var6 + (ulonglong)uVar3)) {

+        uVar1 = *(uchar *)&p_Var10->Flink;

+        bVar2 = *(byte *)((longlong)&p_Var10->Flink + 1);

+        _Var5 = *(_CO_HEADER *)&p_Var10->Flink;

+        _Src = (void *)((longlong)&p_Var10->Flink + 2);

+        iVar8 = Feature_772777273__private_IsEnabledDeviceUsageNoInline();

+        if (iVar8 == 0) {

+          if (2 < (byte)(uVar1 - 1)) {

+LAB_0:

+            p_Var11->Header = _Var5;

+            p_Var11->Flags = 1;

+            p_Var11->DynamicBuffer = _Dst;

+            p_Var11 = p_Var11 + 1;

+            memmove(_Dst,_Src,(ulonglong)bVar2);

+            _Dst = (_L2CAP_CONFIG_OPTION *)(_Dst->FixedBuffer + ((ulonglong)bVar2 - 0x10));

+            if (p_Var9 + param_1 == p_Var11) break;

           }

         }

         else {

-          uVar17 = *(uint *)(lVar3 + 0xc0);

+          bVar7 = IsKnownConfigOptionType(uVar1);

+          if (!bVar7) goto LAB_0;

         }

-      }

-      else {

-        uVar17 = *(uint *)(lVar3 + 0xf8);

+        p_Var10 = (_LIST_ENTRY *)((longlong)_Src + (ulonglong)bVar2);

       }

     }

-    else {

-      uVar17 = *(uint *)(lVar3 + 0xf0);

-    }

-LAB_0:

-    if ((ushort)(sVar2 - 0x212U) <= uVar16) goto LAB_1;

-    if (uVar16 < (ushort)(sVar2 + 0x3ef7U)) {

-      if (((ushort)(sVar4 + sVar2) <= uVar16) || (uVar10 = uVar6, (ushort)(sVar5 + sVar2) <= uVar16)

-         ) {

-        uVar10 = *(uint *)(lVar3 + 0x80);

-      }

-    }

-    else {

-      uVar10 = *(uint *)(lVar3 + 0x90);

-    }

   }

-  else {

-    uVar17 = *(uint *)(lVar3 + 200);

-    if ((sVar2 != unaff_R12W) && (sVar2 != (short)(unaff_R12W + 1))) goto LAB_0;

-LAB_1:

-    uVar10 = *(uint *)(lVar3 + 0x88);

-  }

-  if ((uVar17 & 2) != 0) {

-    if (uVar16 < (ushort)(sVar2 - 0x102U)) {

-      if (uVar16 < (ushort)(sVar2 - 0x212U)) {

-        if (uVar16 < (ushort)(sVar2 + 0x3ef7U)) {

-          if (uVar16 < (ushort)(sVar2 + 0x7f00U)) {

-            puVar9 = (ushort *)(lVar3 + 0xf2);

-            if (uVar16 < (ushort)(sVar2 + 0x7efeU)) {

-              puVar9 = unaff_R15;

-            }

-          }

-          else {

-            puVar9 = (ushort *)(lVar3 + 0xca);

-          }

-        }

-        else {

-          puVar9 = (ushort *)(lVar3 + 0x102);

-        }

-      }

-      else {

-        puVar9 = (ushort *)(lVar3 + 0xfa);

-      }

-    }

-    else {

-      puVar9 = (ushort *)(lVar3 + 0xd2);

-    }

-    uVar17 = *in_R10;

-    uVar11 = 0xffff;

-    if ((uVar17 & 2) == 0) {

-      if ((*(uint *)(unaff_RDI + 0x1b0) & 2) != 0) {

-        uVar11 = *(ushort *)(unaff_RDI + 0x1b6);

-      }

-    }

-    else {

-      uVar11 = *(ushort *)((longlong)in_R10 + 6);

-    }

-    if (uVar11 < *puVar9) {

-      *in_R10 = uVar17 & 0xfffffffd;

-      uVar11 = *puVar9;

-LAB_2:

-      *(uint *)(unaff_RBX + 4) = *(uint *)(unaff_RBX + 4) | 2;

-      *(ushort *)(unaff_RBX + 10) = uVar11;

-    }

-    else if (puVar9[1] < uVar11) {

-      *in_R10 = uVar17 & 0xfffffffd;

-      uVar11 = puVar9[1];

-      goto LAB_2;

-    }

-    if ((*(byte *)(unaff_RBX + 4) & 2) != 0) {

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

-      unaff_BP = 4;

-    }

-  }

-  cVar18 = (char)unaff_R15;

-  bVar15 = (byte)unaff_R14;

-  if ((uVar10 & 0x40) == 0) {

-    if ((*(uint *)(unaff_RDI + 0x210) & 0x40) != 0) {

-      cVar14 = *(char *)(unaff_RDI + 0x23e);

-      goto LAB_3;

-    }

-LAB_4:

-    *in_R10 = *in_R10 & 0xffffff7f;

-    cVar7 = cVar18;

-  }

-  else {

-    sVar2 = *(short *)(lVar3 + 0x16);

-    cVar14 = cVar18;

-    if (uVar16 < (ushort)(sVar2 - 0x212U)) {

-      if ((ushort)(sVar2 + 0x3ef7U) <= uVar16) {

-        uVar17 = *(uint *)(lVar3 + 0xd0);

-        goto LAB_5;

-      }

-      uVar17 = uVar6;

-      uVar13 = uVar6;

-      uVar12 = uVar6;

-      if ((ushort)(sVar2 + 0x7efeU) <= uVar16) {

-        uVar17 = *(uint *)(lVar3 + 0xc0);

-        goto LAB_5;

-      }

-    }

-    else {

-      uVar17 = *(uint *)(lVar3 + 200);

-LAB_5:

-      uVar13 = uVar17 & 4;

-      uVar12 = uVar17 & 2;

-      if (uVar13 == 0) {

-        if (uVar12 != 0) {

-          cVar14 = '\x03';

-        }

-      }

-      else {

-        cVar14 = '\x04';

-      }

-    }

-    if ((*in_R10 & 0x40) == 0) {

-      if ((bVar15 & (byte)uVar17) == 0) goto LAB_3;

-LAB_6:

-      cVar14 = cVar18;

-LAB_3:

-      cVar18 = cVar14;

-      cVar7 = cVar18;

-      if (cVar18 == '\0') goto LAB_4;

-    }

-    else {

-      cVar1 = *(char *)((longlong)in_R10 + 0x2e);

-      if (cVar1 == cVar14) {

-LAB_7:

-        cVar7 = cVar14;

-        if (cVar14 == '\x03') {

-LAB_8:

-          if ((*(uint *)(unaff_RDI + 0x430) & 8) == 0) goto LAB_6;

-        }

-      }

-      else {

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

-          if ((bVar15 & (byte)uVar17) != 0) goto LAB_4;

-          goto LAB_7;

-        }

-        cVar7 = '\x03';

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

-          if (uVar12 == 0) goto LAB_7;

-          goto LAB_8;

-        }

-        cVar7 = '\x04';

-        if ((cVar1 != '\x04') || (uVar13 == 0)) goto LAB_7;

-      }

-      cVar14 = cVar7;

-      if (cVar7 != '\x04') goto LAB_3;

-      if ((*(uint *)(unaff_RDI + 0x430) & 0x10) == 0) goto LAB_6;

-    }

-  }

-  if ((*in_R10 & 0x40) == 0) {

-    if (cVar7 != '\0') goto LAB_9;

-  }

-  else if (*(char *)((longlong)in_R10 + 0x2e) != cVar7) {

-LAB_9:

-    *in_R10 = *in_R10 & 0xffffffbf;

-    if (uVar6 < *(uint *)(lVar3 + 0x30)) {

-      *(undefined2 *)(unaff_RBX + 2) = 0xfff;

-    }

-    else {

-      *(uint *)(unaff_RBX + 4) = *(uint *)(unaff_RBX + 4) | 0x40;

-      unaff_BP = unaff_BP + 0xb;

-      *(undefined8 *)(lVar3 + 0x30) = unaff_R14;

-      *(char *)(unaff_RBX + 0x32) = cVar7;

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

-    }

-  }

-  uVar11 = (ushort)unaff_R15;

-  if ((*in_R10 & 0x80) != 0) {

-    if ((uVar10 & 0x80) == 0) {

-      uVar8 = uVar16;

-      if ((*(uint *)(unaff_RDI + 0x1b0) & 0x80) != 0) {

-        uVar8 = (ushort)*(byte *)(unaff_RDI + 0x1e7);

-      }

-    }

-    else {

-      sVar2 = *(short *)(lVar3 + 0x16);

-      if (uVar16 < (ushort)(sVar2 - 0x212U)) {

-        if (uVar16 < (ushort)(sVar2 + 0x3ef7U)) {

-          uVar8 = uVar11;

-          if ((ushort)(sVar2 + 0x7efeU) <= uVar16) {

-            uVar8 = *(ushort *)(lVar3 + 0xd0);

-          }

-        }

-        else {

-          uVar8 = *(ushort *)(lVar3 + 0xe0);

-        }

-      }

-      else {

-        uVar8 = *(ushort *)(lVar3 + 0xd8);

-      }

-    }

-    if (*(byte *)((longlong)in_R10 + 0x37) != uVar8) {

-      *(byte *)((longlong)in_R10 + 0x37) = bVar15;

-    }

-  }

-  if ((bVar15 & (byte)uVar10) != 0) {

-    sVar2 = *(short *)(lVar3 + 0x16);

-    if ((uVar16 < (ushort)(sVar2 - 0x102U)) && (uVar16 < (ushort)(sVar2 - 0x212U))) {

-      if (uVar16 < (ushort)(sVar2 + 0x3ef7U)) {

-        if (((ushort)(sVar2 + 0x7f00U) <= uVar16) || ((ushort)(sVar2 + 0x7efeU) <= uVar16)) {

-          unaff_R15 = (ushort *)(lVar3 + 0x84);

-        }

-      }

-      else {

-        unaff_R15 = (ushort *)(lVar3 + 0x94);

-      }

-    }

-    else {

-      unaff_R15 = (ushort *)(lVar3 + 0x8c);

-    }

-    uVar6 = *in_R10;

-    uVar8 = 0x2a0;

-    if ((bVar15 & (byte)uVar6) == 0) {

-      if ((bVar15 & (byte)*(undefined4 *)(unaff_RDI + 0x210)) != 0) {

-        uVar8 = *(ushort *)(unaff_RDI + 0x214);

-      }

-    }

-    else {

-      uVar8 = (ushort)in_R10[1];

-    }

-    uVar17 = (uint)unaff_R14;

-    if (uVar8 < *unaff_R15) {

-      *(uint *)(unaff_RBX + 4) = *(uint *)(unaff_RBX + 4) | uVar17;

-      *in_R10 = uVar6 & 0xfffffffe;

-      unaff_BP = unaff_BP + 4;

-      *(ushort *)(unaff_RBX + 8) = *unaff_R15;

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

-    }

-    else {

-      if (*(ushort *)(unaff_RBX + 2) != uVar11) goto LAB_10;

-      if (uVar8 < unaff_R15[2]) {

-        if (uVar8 < unaff_R15[1]) goto LAB_11;

-        *in_R10 = uVar6 | uVar17;

-        uVar16 = unaff_R15[1];

-      }

-      else {

-        *in_R10 = uVar6 | uVar17;

-        uVar16 = unaff_R15[2];

-      }

-      *(ushort *)(in_R10 + 1) = uVar16;

-    }

-  }

-LAB_11:

-  if (*(ushort *)(unaff_RBX + 2) != uVar11) goto LAB_10;

-  uVar6 = *in_R10;

-  if ((((((byte)uVar6 & 0x42) == 2) && ((*(uint *)(unaff_RDI + 0x210) & 0x40) != 0)) &&

-      (*(char *)(unaff_RDI + 0x23e) == '\x03')) &&

-     (*(short *)((longlong)in_R10 + 6) != *(short *)(unaff_RDI + 0x1b6))) {

-    uVar6 = uVar6 | 0x40;

-    *in_R10 = uVar6;

-  }

-  if (((uVar6 & 0x40) == 0) || (cVar7 != '\x03')) goto LAB_10;

-  uVar16 = 2000;

-  if ((uVar6 & 2) == 0) {

-    if ((*(uint *)(unaff_RDI + 0x1b0) & 2) != 0) {

-      uVar16 = *(ushort *)(unaff_RDI + 0x1b6);

-      goto LAB_12;

-    }

-  }

-  else {

-    uVar11 = *(ushort *)((longlong)in_R10 + 6);

-    if (uVar11 == 0xffff) {

-      if ((*(byte *)(unaff_RBX + 4) & 2) == 0) goto LAB_13;

-LAB_14:

-      uVar16 = *(ushort *)(unaff_RBX + 10);

-LAB_12:

-      uVar6 = (uint)uVar16 * 3;

-    }

-    else {

-      if ((*(byte *)(unaff_RBX + 4) & 2) != 0) goto LAB_14;

-      uVar6 = (uint)uVar11 + (uint)uVar11 * 2;

-    }

-    uVar11 = 0xfffe;

-    if (uVar6 < 0xffff) {

-      uVar16 = 1000;

-      uVar11 = (ushort)uVar6;

-      if ((ushort)uVar6 < 1000) goto LAB_13;

-    }

-    uVar16 = uVar11;

-  }

-LAB_13:

-  *(undefined2 *)((longlong)in_R10 + 0x33) = 12000;

-  *(ushort *)((longlong)in_R10 + 0x31) = uVar16;

-LAB_10:

-  return (_L2CAP_CONFIG_OPTION *)(ulonglong)unaff_BP;

+  return p_Var9;

 }
```

## `L2CapInt_ValidateExtraOptions`  (modified)

```diff
--- L2CapInt_ValidateExtraOptions
+++ L2CapInt_ValidateExtraOptions
@@ -1,21 +1,119 @@
+

+/* unsigned char __cdecl L2CapInt_ValidateExtraOptions(struct _L2CAP_CONFIG_OPTION *

+   __ptr64,unsigned long) */

 

 uchar __cdecl L2CapInt_ValidateExtraOptions(_L2CAP_CONFIG_OPTION *param_1,ulong param_2)

 

 {

-  char *pcVar1;

-  uchar uVar2;

-  uint *in_RAX;

-  longlong unaff_RBP;

-  undefined1 *puStack0000000000000028;

-  undefined8 uStack0000000000000030;

-  ulonglong uStack0000000000000038;

+  ushort uVar1;

+  byte bVar2;

+  uchar uVar3;

+  int iVar4;

+  undefined1 uVar5;

+  uint uVar6;

+  uchar *puVar7;

+  undefined8 uVar8;

+  uint uVar9;

+  undefined2 uVar10;

   

-  pcVar1 = (char *)(unaff_RBP + 0xd + (longlong)param_1 * 4);

-  *pcVar1 = *pcVar1 + (char)param_1;

-  uStack0000000000000038 = (ulonglong)((uint)in_RAX | *in_RAX);

-  puStack0000000000000028 = &stack0x000000a0;

-  uStack0000000000000030 = 4;

-  uVar2 = WppAutoLogTrace();

-  return uVar2;

+  uVar6 = 0;

+  if ((param_1 == (_L2CAP_CONFIG_OPTION *)0x0) || (param_2 == 0)) {

+LAB_0:

+    uVar3 = '\0';

+  }

+  else {

+    puVar7 = &(param_1->Header).Length;

+    uVar9 = uVar6;

+    do {

+      uVar1 = *(ushort *)(puVar7 + 0x13);

+      if ((uVar1 & 0xfffc) != 0) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar6 = 1;

+        }

+        WPP_RECORDER_AND_TRACE_SF_L

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),(char)uVar6,1,

+                   *(undefined8 *)(WPP_GLOBAL_Control + 0x40),2,3,0x54,

+                   &WPP_1325d1c833fb350b81be7e41dac47189_Traceguids,uVar1);

+        goto LAB_0;

+      }

+      if ((uVar1 & 3) == 3) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar6 = 1;

+        }

+        uVar5 = (undefined1)uVar6;

+        uVar10 = 0x55;

+LAB_1:

+        WPP_RECORDER_AND_TRACE_SF_

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar5,1,

+                   *(undefined8 *)(WPP_GLOBAL_Control + 0x40),2,3,uVar10,

+                   &WPP_1325d1c833fb350b81be7e41dac47189_Traceguids);

+        goto LAB_0;

+      }

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

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar6 = 1;

+        }

+        uVar5 = (undefined1)uVar6;

+        uVar10 = 0x56;

+        goto LAB_1;

+      }

+      if (((uVar1 & 2) != 0) && (4 < *puVar7)) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar6 = 1;

+        }

+        WPP_RECORDER_AND_TRACE_SF_dD

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar6,1,

+                   *(undefined8 *)(WPP_GLOBAL_Control + 0x40),2,3,0x57,

+                   &WPP_1325d1c833fb350b81be7e41dac47189_Traceguids,*puVar7,4);

+        goto LAB_0;

+      }

+      if ((((uVar1 & 1) != 0) && (*puVar7 != 0)) && (*(longlong *)(puVar7 + 7) == 0)) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar6 = 1;

+        }

+        uVar5 = (undefined1)uVar6;

+        uVar10 = 0x58;

+        goto LAB_1;

+      }

+      iVar4 = Feature_772777273__private_IsEnabledDeviceUsageNoInline();

+      bVar2 = ((_CO_HEADER *)(puVar7 + -1))->Type - 1;

+      if (iVar4 == 0) {

+        if (bVar2 < 3) {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) &&

+             (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+            uVar6 = 1;

+          }

+          uVar5 = (undefined1)uVar6;

+          uVar10 = 0x5a;

+          goto LAB_1;

+        }

+      }

+      else if (bVar2 < 3) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar6 = 1;

+        }

+        uVar5 = (undefined1)uVar6;

+        uVar10 = 0x59;

+        goto LAB_1;

+      }

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) == 0) ||

+         (uVar8 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+        uVar8 = 0;

+      }

+      WPP_RECORDER_AND_TRACE_SF_sDDD

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar8,uVar1,

+                 *(undefined8 *)(WPP_GLOBAL_Control + 0x40));

+      uVar9 = uVar9 + 1;

+      puVar7 = puVar7 + 0x18;

+    } while (uVar9 < param_2);

+    uVar3 = '\x01';

+  }

+  return uVar3;

 }
```

## `BthVerifyControl`  (modified)

```diff
--- BthVerifyControl
+++ BthVerifyControl
@@ -1,16 +1,58 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* long __cdecl BthVerifyControl(struct DEVICE_EXTENSION * __ptr64,struct _IRP * __ptr64) */

 

 long __cdecl BthVerifyControl(DEVICE_EXTENSION *param_1,_IRP *param_2)

 

 {

-  long lVar1;

-  undefined1 *puStack0000000000000028;

-  ulonglong uStack0000000000000038;

+  uint uVar1;

+  void *pvVar2;

+  char cVar3;

+  long lVar4;

+  ulonglong uVar5;

+  ulonglong uVar6;

+  undefined1 uVar7;

   

-  uStack0000000000000038 = (ulonglong)&stack0x000000d8 & 0xffffffff;

-  puStack0000000000000028 = &stack0x000000d0;

-  lVar1 = WppAutoLogTrace();

-  return lVar1;

+  pvVar2 = (param_2->Tail).Apc.SystemArgument1;

+  uVar6 = 0;

+  uVar7 = 1;

+  uVar5 = uVar6;

+  while( true ) {

+    if (0x47 < (uint)uVar5) {

+      return -0x3fffff45;

+    }

+    if (*(int *)(&DAT_0 + uVar5 * 0x10) == *(int *)((longlong)pvVar2 + 0x18)) break;

+    uVar5 = (ulonglong)((uint)uVar5 + 1);

+  }

+  uVar1 = *(uint *)(&DAT_1 + uVar5 * 0x10);

+  if (((uVar1 != 0) && (*(uint *)((longlong)pvVar2 + 8) < uVar1)) ||

+     ((*(uint *)(&DAT_2 + uVar5 * 0x10) != 0 &&

+      (*(uint *)((longlong)pvVar2 + 0x10) < *(uint *)(&DAT_2 + uVar5 * 0x10))))) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x10) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 4)

+       ) {

+      uVar7 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_Ldddd

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),CONCAT31((int3)(uVar1 >> 8),uVar7),

+               WPP_GLOBAL_Control,*(undefined8 *)(WPP_GLOBAL_Control + 0x40));

+    return -0x3ffffdfa;

+  }

+  if ((&DAT_3)[uVar5 * 0x10] == '\0') {

+    return 0;

+  }

+  cVar3 = KeGetCurrentIrql();

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

+    return 0;

+  }

+  lVar4 = BthQueueIrpOnWorkerThread(param_1,param_2,BthHandleControlDispatch,(void *)0x0);

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x10) != 0) && (3 < (byte)WPP_GLOBAL_Control[0x29]))

+  {

+    uVar6 = 1;

+  }

+  WPP_RECORDER_AND_TRACE_SF_iL

+            (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar6,1,

+             *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4,5,0x18,

+             &WPP_b01968a2c4b23feb992a1f1f965de22e_Traceguids,param_2,lVar4);

+  return lVar4;

 }
```

## `L2CapCon_PurgeReads`  (modified)

```diff
--- L2CapCon_PurgeReads
+++ L2CapCon_PurgeReads
@@ -1,129 +1,52 @@
 

-/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl L2CapCon_PurgeReads(struct L2CAP_CONNECTION * __ptr64) */

 

 void __cdecl L2CapCon_PurgeReads(L2CAP_CONNECTION *param_1)

 

 {

-  undefined4 uVar1;

+  undefined1 uVar1;

   int iVar2;

-  _tlgProvider_t *p_Var3;

+  _IRP *p_Var3;

   char cVar4;

-  uint uVar5;

-  char *in_RAX;

-  _HCI_CONNECTION *p_Var7;

-  longlong lVar8;

-  ulonglong uVar9;

-  uchar uVar10;

-  ulonglong unaff_RBX;

-  longlong unaff_RBP;

-  int unaff_ESI;

-  undefined1 *unaff_RDI;

-  int in_R8D;

-  _GUID *p_Var11;

-  char *pcVar12;

-  int unaff_R14D;

-  uint uStack0000000000000048;

-  char *pcStack0000000000000050;

-  undefined4 uStack0000000000000068;

-  int iStack0000000000000070;

-  int *piVar6;

+  char cVar5;

+  long local_res8 [2];

+  _LIST_ENTRY local_38;

   

-  cVar4 = (char)in_RAX + *in_RAX;

-  piVar6 = (int *)CONCAT71((int7)((ulonglong)in_RAX >> 8),cVar4);

-  pcVar12 = (char *)(CONCAT71((int7)((ulonglong)param_1 >> 8),0x90) + -0x48);

-  *pcVar12 = *pcVar12 + cVar4;

-  uVar5 = (int)piVar6 + *piVar6;

-  *(char *)(ulonglong)uVar5 = *(char *)(ulonglong)uVar5 + (char)uVar5;

-  lVar8 = *(longlong *)(unaff_RBP + 0x5f);

-  uVar1 = *(undefined4 *)(lVar8 + 0x288);

-  uVar10 = (uchar)unaff_RBX;

-  if ((*(int *)(lVar8 + 0x294) == in_R8D) && (*(int *)(lVar8 + 0x290) == in_R8D)) {

-    *(undefined4 *)(lVar8 + 0x288) = 4;

-    pcVar12 = "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\l2capcxn.cpp";

-    lVar8 = *(longlong *)(unaff_RBP + 0x5f);

-    p_Var11 = (_GUID *)0x769;

-    *(undefined4 *)(unaff_RBP + 0x7f) = *(undefined4 *)(lVar8 + 0x1a0);

-    *(short *)(unaff_RBP + 0x83) = (short)((ulonglong)*(undefined8 *)(lVar8 + 0x1a0) >> 0x20);

-    p_Var7 = HCI_GetConnectionFromBdAddrEx2

-                       (*(HCI_INTERFACE **)

-                         (*(longlong *)(*(longlong *)(lVar8 + 0x278) + 0x50) + 0x170),

-                        (_BDADDR *)(unaff_RBP + 0x7f),0x769,

-                        "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\l2capcxn.cpp",

-                        L2CapCon_SetConfigStateEx,uVar10,uVar10);

-    if (p_Var7 != (_HCI_CONNECTION *)0x0) {

-      if (5 < (uint)DAT_0) {

-        cVar4 = _tlgKeywordOn(&DAT_0,0x400000000000);

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

-          p_Var3 = *(_tlgProvider_t **)(*(longlong *)(unaff_RBP + 0x5f) + 0x1a0);

-          *(longlong *)(unaff_RBP + -1) = unaff_RBP + 0x5f;

-          *(_GUID **)(unaff_RBP + 7) = &p_Var7->HciConnectionSessionId;

-          *(_tlgProvider_t **)(unaff_RBP + 0x7f) = p_Var3;

-          *(undefined8 *)(unaff_RBP + 0xf) = 0x2000800;

-          _tlgWriteTemplate<long___cdecl(_tlgProvider_t_const*___ptr64,void_const*___ptr64,_GUID_const*___ptr64,_GUID_const*___ptr64,unsigned_int,_EVENT_DATA_DESCRIPTOR*___ptr64),&long___cdecl__tlgWriteTransfer_EtwWriteTransfer(struct__tlgProvider_t_const*___ptr64,void_const*___ptr64,struct__GUID_const*___ptr64,struct__GUID_const*___ptr64,unsigned_int,struct__EVENT_DATA_DESCRIPTOR*___ptr64),_GUID_const*___ptr64,_GUID_const*___ptr64>

-          ::Write<_tlgWrapperByVal<8>,_tlgWrapperByRef<16>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>_>

-                    (p_Var3,&DAT_1,p_Var11,(_GUID *)pcVar12,

-                     (_tlgWrapperByVal<8> *)(unaff_RBP + 0xf),

-                     (_tlgWrapperByRef<16> *)(unaff_RBP + 7),(_tlgWrapperByVal<8> *)(unaff_RBP + -1)

-                     ,(_tlgWrapperByVal<8> *)(unaff_RBP + 0x7f));

-        }

-      }

-      RefObj_ReleaseEx(&p_Var7->RefObj,L2CapCon_SetConfigStateEx,0x77a,

-                       "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\l2capcxn.cpp");

-    }

+  cVar5 = '\x01';

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) == 0) ||

+     (cVar4 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    cVar4 = '\0';

   }

-  else {

-    if ((unaff_RDI == (undefined1 *)0x0) ||

-       (((unaff_ESI != 0 || (unaff_R14D != in_R8D)) || (*(int *)(lVar8 + 0x294) != 0))))

-    goto LAB_2;

-    *unaff_RDI = 1;

-    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) == 0) ||

-       (uVar9 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

-      uVar9 = unaff_RBX & 0xff;

-    }

+  if ((cVar4 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

     WPP_RECORDER_AND_TRACE_SF_i

-              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar9,1,

-               *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4);

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar4,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,*(undefined8 *)(WPP_GLOBAL_Control + 0x40)

+               ,5,3,0xb,&WPP_31fb460c087339b03badd953fa46e994_Traceguids,param_1);

   }

-  lVar8 = *(longlong *)(unaff_RBP + 0x5f);

-LAB_2:

-  iVar2 = *(int *)(lVar8 + 0x288);

-  *(ulonglong *)(unaff_RBP + 0xf) = unaff_RBX;

-  *(uchar *)(unaff_RBP + 0x17) = uVar10;

-  *(undefined8 *)(unaff_RBP + 0xf) = *(undefined8 *)(unaff_RBP + 0xf);

-  *(undefined8 *)(unaff_RBP + 0x17) = *(undefined8 *)(unaff_RBP + 0x17);

-  wil::details::

-  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-  ::reset((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-           *)(unaff_RBP + 0x1f),(kspin_lock_saved_irql *)(unaff_RBP + 0xf));

-  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) == 0) ||

-     (uVar9 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

-    uVar9 = unaff_RBX & 0xff;

+  local_38.Blink = &local_38;

+  local_res8[0] = -0x3fffff63;

+  local_38.Flink = &local_38;

+  uVar1 = KeAcquireSpinLockRaiseToDpc(param_1 + 0x3c0);

+  while( true ) {

+    p_Var3 = (_IRP *)IrpList_DequeueLocked(param_1 + 0x3b0);

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

+    L2Cap_AddReadIrpToList(p_Var3,&local_38,local_res8);

   }

-  pcStack0000000000000050 = "In";

-  if (unaff_ESI != 1) {

-    pcStack0000000000000050 = "Out";

+  iVar2 = Feature_61512497__private_IsEnabledDeviceUsageNoInline();

+  if (iVar2 != 0) {

+    param_1[1000] = (L2CAP_CONNECTION)0x1;

   }

-  uStack0000000000000048 = (uint)*(ushort *)(*(longlong *)(unaff_RBP + 0x5f) + 0x200);

-  uStack0000000000000068 = uVar1;

-  iStack0000000000000070 = iVar2;

-  WPP_RECORDER_AND_TRACE_SF_qDsLLdd

-            (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar9,*(longlong *)(unaff_RBP + 0x5f),

-             *(undefined8 *)(WPP_GLOBAL_Control + 0x40));

-  if (iVar2 == 4) {

-    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) && (3 < (byte)WPP_GLOBAL_Control[0x29])) {

-      unaff_RBX = 1;

-    }

-    uStack0000000000000048 = (uint)*(ushort *)(*(longlong *)(unaff_RBP + 0x5f) + 0x260);

-    WPP_RECORDER_AND_TRACE_SF_dD

-              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),CONCAT71(0x140184f,(char)unaff_RBX),1,

-               *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4);

+  KeReleaseSpinLock(param_1 + 0x3c0,uVar1);

+  L2Cap_CompleteReadIrpList(param_1,&local_38);

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    cVar5 = '\0';

   }

-  wil::details::

-  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-  ::

-  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-              *)(unaff_RBP + 0x1f));

+  if ((cVar5 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar5,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,*(undefined8 *)(WPP_GLOBAL_Control + 0x40)

+               ,5,3,0xc,&WPP_31fb460c087339b03badd953fa46e994_Traceguids,param_1);

+  }

   return;

 }
```

## `SdpDB_ServiceAttributeRequestResponse`  (modified)

```diff
--- SdpDB_ServiceAttributeRequestResponse
+++ SdpDB_ServiceAttributeRequestResponse
@@ -1,51 +1,172 @@
+

+/* long __cdecl SdpDB_ServiceAttributeRequestResponse(struct _SDP_DATABASE * __ptr64,unsigned

+   long,struct _SDP_ATTRIB_SEARCH * __ptr64,unsigned char * __ptr64 * __ptr64,unsigned long *

+   __ptr64,void * __ptr64 * __ptr64,unsigned short * __ptr64,unsigned char) */

 

 long __cdecl

 SdpDB_ServiceAttributeRequestResponse

           (_SDP_DATABASE *param_1,ulong param_2,_SDP_ATTRIB_SEARCH *param_3,uchar **param_4,

           ulong *param_5,void **param_6,ushort *param_7,uchar param_8)

 

 {

-  ulonglong uVar1;

-  undefined8 uVar2;

-  uint unaff_EBX;

-  longlong unaff_RDI;

-  uint7 uVar3;

-  uint uVar4;

+  bool bVar1;

+  ushort uVar2;

+  int iVar3;

+  long lVar4;

+  uchar *puVar5;

+  undefined8 uVar6;

+  _SDP_STREAM_ENTRY *p_Var7;

+  _SDP_STREAM_ENTRY *p_Var8;

+  _SDP_DATABASE *p_Var9;

+  undefined8 in_stack_ffffffffffffff90;

+  undefined4 uVar12;

+  undefined8 uVar10;

+  ushort *puVar11;

+  _SDP_STREAM_ENTRY *local_48;

+  _FAST_MUTEX *local_40;

   

-  *(uint *)&(param_1->ServiceRecordList).Flink = unaff_EBX;

-  *(uint *)&(param_1->ServiceRecordList).Blink = unaff_EBX;

-  if (unaff_EBX < *(uint *)((longlong)&(param_1->ServiceRecordList).Flink + 4)) {

-    do {

-      uVar1 = (ulonglong)param_4 & 0xffffffff;

-      uVar4 = (int)param_4 + 1;

-      param_4 = (uchar **)(ulonglong)uVar4;

-      *(char *)(unaff_RDI + 0x1c + uVar1 * 0x14) = (char)unaff_EBX;

-    } while (uVar4 < *(uint *)(unaff_RDI + 4));

-  }

-  SdpWalkStream();

-  uVar4 = unaff_EBX;

-  while( true ) {

-    uVar3 = (uint7)(uint3)(*(uint *)(unaff_RDI + 4) >> 8);

-    if (*(uint *)(unaff_RDI + 4) <= uVar4) {

-      if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

-         (3 < (byte)WPP_GLOBAL_Control[0x29])) {

-        unaff_EBX = 1;

+  uVar12 = (undefined4)((ulonglong)in_stack_ffffffffffffff90 >> 0x20);

+  p_Var7 = (_SDP_STREAM_ENTRY *)0x0;

+  local_40 = &param_1->ServiceRecordListMutex;

+  bVar1 = false;

+  local_48 = (_SDP_STREAM_ENTRY *)0x0;

+  ExAcquireFastMutex(local_40);

+  p_Var9 = (_SDP_DATABASE *)(param_1->ServiceRecordList).Flink;

+  lVar4 = -0x3fffffff;

+  do {

+    p_Var8 = p_Var7;

+    if (p_Var9 == param_1) {

+LAB_0:

+      ExReleaseFastMutex(local_40);

+      if (bVar1) {

+        if (lVar4 < 0) {

+          if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

+             (uVar6 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+            uVar6 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_L

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar6,1,

+                     *(undefined8 *)(WPP_GLOBAL_Control + 0x40),3,CONCAT44(uVar12,8),0x1d,

+                     &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids,lVar4);

+          if (p_Var8 != (_SDP_STREAM_ENTRY *)0x0) {

+            ExFreePoolWithTag(p_Var8,0);

+          }

+          *param_4 = (uchar *)0x0;

+          *param_5 = 0;

+        }

+        else if (p_Var8 == (_SDP_STREAM_ENTRY *)0x0) {

+          if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

+             (uVar6 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+            uVar6 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar6,1,

+                     *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4,CONCAT44(uVar12,8),0x1f,

+                     &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids);

+          puVar5 = (uchar *)ExAllocatePool2(0x40,2,0x50485442);

+          *param_4 = puVar5;

+          if (puVar5 == (uchar *)0x0) {

+            lVar4 = -0x3fffff66;

+            uVar2 = SdpMapNtStatusToSdpError(0xc000009a);

+            *param_7 = uVar2;

+          }

+          else {

+            *param_6 = puVar5;

+            *param_4 = puVar5;

+            *param_5 = 2;

+            SdpWriteVariableSizeToStream(6,0,puVar5);

+          }

+        }

+        else {

+          if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

+             (3 < (byte)WPP_GLOBAL_Control[0x29])) {

+            p_Var7 = (_SDP_STREAM_ENTRY *)&DAT_1;

+          }

+          WPP_RECORDER_AND_TRACE_SF_L

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),(ulonglong)p_Var7 & 0xff,1,

+                     *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4,CONCAT44(uVar12,8),0x1e,

+                     &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids,*(undefined4 *)(p_Var8 + 0x10)

+                    );

+          *param_4 = (uchar *)(p_Var8 + 0x14);

+          *param_5 = *(ulong *)(p_Var8 + 0x10);

+          *param_6 = p_Var8;

+        }

       }

-      uVar2 = WPP_RECORDER_AND_TRACE_SF_

-                        (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),unaff_EBX & 0xff,

-                         CONCAT71(uVar3,1),*(undefined8 *)(WPP_GLOBAL_Control + 0x40),4);

-      return (long)CONCAT71((int7)((ulonglong)uVar2 >> 8),1);

+      else {

+        if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

+           (3 < (byte)WPP_GLOBAL_Control[0x29])) {

+          p_Var7 = (_SDP_STREAM_ENTRY *)&DAT_1;

+        }

+        WPP_RECORDER_AND_TRACE_SF_L

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),(ulonglong)p_Var7 & 0xff,1,

+                   *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4,CONCAT44(uVar12,8),0x20,

+                   &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids,param_2);

+        *param_7 = 2;

+        lVar4 = -0x3fffffff;

+      }

+      return lVar4;

     }

-    if (*(char *)(unaff_RDI + 0x1c + (ulonglong)uVar4 * 0x14) != '\x01') break;

-    uVar4 = uVar4 + 1;

-  }

-  if (((char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c) < '\0') &&

-     (2 < (byte)WPP_GLOBAL_Control[0x29])) {

-    unaff_EBX = 1;

-  }

-  uVar4 = WPP_RECORDER_AND_TRACE_SF_L

-                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),unaff_EBX & 0xff,CONCAT71(uVar3,1),

-                     *(undefined8 *)(WPP_GLOBAL_Control + 0x40),3);

-  return uVar4 & 0xffffff00;

+    if ((p_Var9->ServiceRecordListMutex).Contention == param_2) {

+      if ((param_8 == '\0') && ((*(uint *)&(p_Var9->ServiceRecordListMutex).field_0x4 & 2) != 0)) {

+        iVar3 = Feature_61512497__private_IsEnabledDeviceUsageNoInline();

+        if (iVar3 == 0) {

+          if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

+             (uVar6 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+            uVar6 = 0;

+          }

+          uVar10 = CONCAT44(uVar12,8);

+          WPP_RECORDER_AND_TRACE_SF_L

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar6,1,

+                     *(undefined8 *)(WPP_GLOBAL_Control + 0x40),2,uVar10,0x1a,

+                     &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids,param_2);

+          uVar12 = (undefined4)((ulonglong)uVar10 >> 0x20);

+        }

+        else {

+          if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

+             (uVar6 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+            uVar6 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_D_guid_(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar6);

+          p_Var8 = (_SDP_STREAM_ENTRY *)0x0;

+        }

+      }

+      else {

+        if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

+           (uVar6 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+          uVar6 = 0;

+        }

+        WPP_RECORDER_AND_TRACE_SF_L

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar6,1,

+                   *(undefined8 *)(WPP_GLOBAL_Control + 0x40),4,CONCAT44(uVar12,8),0x1b,

+                   &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids,param_2);

+        bVar1 = true;

+        puVar11 = param_7;

+        lVar4 = SdpFindAttributeInStreamInternal

+                          (*(uchar **)&(p_Var9->ServiceRecordListMutex).Event.Header,

+                           *(ulong *)&(p_Var9->ServiceRecordListMutex).field_0x14,

+                           *(SdpAttributeRange **)param_3,*(ulong *)(param_3 + 8),&local_48,param_7)

+        ;

+        uVar12 = (undefined4)((ulonglong)puVar11 >> 0x20);

+        p_Var8 = local_48;

+        if (lVar4 < 0) {

+          if ((-1 < (char)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) ||

+             (uVar6 = 1, (byte)WPP_GLOBAL_Control[0x29] < 3)) {

+            uVar6 = 0;

+          }

+          uVar10 = CONCAT44(uVar12,8);

+          WPP_RECORDER_AND_TRACE_SF_L

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar6,1,

+                     *(undefined8 *)(WPP_GLOBAL_Control + 0x40),3,uVar10,0x1c,

+                     &WPP_338064c0d57d338a8d70171ba7bd94b4_Traceguids,lVar4);

+          uVar12 = (undefined4)((ulonglong)uVar10 >> 0x20);

+          uVar2 = SdpMapNtStatusToSdpError(lVar4);

+          *param_7 = uVar2;

+          p_Var8 = local_48;

+        }

+      }

+      goto LAB_0;

+    }

+    p_Var9 = (_SDP_DATABASE *)(p_Var9->ServiceRecordList).Flink;

+  } while( true );

 }
```

## `HCI_DibProcessDisposableListLocked`  (modified)

```diff
--- HCI_DibProcessDisposableListLocked
+++ HCI_DibProcessDisposableListLocked
@@ -1,42 +1,118 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl HCI_DibProcessDisposableListLocked(struct HCI_INTERFACE * __ptr64,struct _LIST_ENTRY

+   * __ptr64) */

 

 void __cdecl HCI_DibProcessDisposableListLocked(HCI_INTERFACE *param_1,_LIST_ENTRY *param_2)

 

 {

-  int iVar1;

-  longlong unaff_RBX;

-  byte unaff_SIL;

-  uint unaff_EDI;

+  DEVICE_INFO_BLOCK *pDVar1;

+  uint uVar2;

+  ulong uVar3;

+  _LIST_ENTRY *p_Var4;

+  _LIST_ENTRY *p_Var5;

+  undefined1 *puVar6;

+  longlong *plVar7;

+  _LIST_ENTRY *p_Var8;

+  code *pcVar9;

+  DEVICE_INFO_BLOCK *pDVar10;

+  undefined8 uVar11;

+  intrusive_list_hook *piVar12;

   

-  RefObj_AddRefEx((ulonglong)*(uint *)(unaff_RBX + 0x378) + 8,HCI_DibRefDestroy,0xdf,

-                  "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\hcidib.cpp");

-  iVar1 = IoAcquireRemoveLockEx

-                    (*(longlong *)(*(longlong *)(unaff_RBX + 0x378) + 0x4a8) + 0x38,

-                     HCI_DibRefDestroy,

-                     "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\hcidib.cpp",0xe1,0x20

-                    );

-  if (iVar1 < 0) {

-    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 5)) {

-      unaff_EDI = (uint)unaff_SIL;

-    }

-    if (((char)unaff_EDI != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

-      WPP_RECORDER_AND_TRACE_SF_i

-                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),(char)unaff_EDI,

-                 *(short *)(WPP_GLOBAL_Control + 0x48) != 0,

-                 *(undefined8 *)(*(longlong *)(unaff_RBX + 0x378) + 0x10b0),5);

-    }

+  if (param_1->CacheEntryDisposableLimit < param_1->NumberOfDisposableDevices) {

+    do {

+      p_Var4 = (param_1->DisposableDeviceList).Blink;

+      if ((p_Var4->Flink != &param_1->DisposableDeviceList) ||

+         (p_Var5 = p_Var4->Blink, p_Var5->Flink != p_Var4)) goto LAB_0;

+      (param_1->DisposableDeviceList).Blink = p_Var5;

+      p_Var5->Flink = &param_1->DisposableDeviceList;

+      p_Var4->Blink = p_Var4;

+      p_Var4->Flink = p_Var4;

+      if (param_1->NumberOfDisposableDevices != 0) {

+        param_1->NumberOfDisposableDevices = param_1->NumberOfDisposableDevices - 1;

+      }

+      pDVar1 = (DEVICE_INFO_BLOCK *)(p_Var4 + -0x35);

+      if (((((*(uint *)&p_Var4[-0x34].Blink >> 0xe & 1) == 0) ||

+           (p_Var4[0x59].Blink != (_LIST_ENTRY *)0x0)) &&

+          ((*(uint *)&p_Var4[-0x34].Blink & 0x1030038) == 0)) &&

+         ((((ulonglong)p_Var4[1].Blink & 8) == 0 && (p_Var5 = p_Var4 + -1, p_Var5->Flink != p_Var5))

+         )) {

+        pDVar10 = HCI_FindLinkedDib(&param_1->DeviceList,pDVar1);

+        if (pDVar10 != (DEVICE_INFO_BLOCK *)0x0) {

+          uVar2 = (pDVar10->DeviceInfo).flags;

+          if ((((uVar2 >> 0xe & 1) != 0) && (pDVar10->LinkedDibAddress == 0)) ||

+             (((uVar2 & 0x1030038) != 0 || (((ulonglong)pDVar10->DibFlags & 8) != 0)))) {

+            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+               ((byte)WPP_GLOBAL_Control[0x29] < 4)) {

+              uVar11 = 0;

+            }

+            else {

+              uVar11 = 1;

+            }

+            WPP_RECORDER_AND_TRACE_SF_

+                      (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar11,"ent link detected",

+                       param_1->IfrLog,4,2,0x29,&WPP_ad144674c127399e1f530e053018150b_Traceguids);

+            goto LAB_1;

+          }

+          piVar12 = &pDVar10->DisposableListEntry;

+          puVar6 = *(undefined1 **)piVar12;

+          if ((intrusive_list_hook *)puVar6 != piVar12) {

+            if (((intrusive_list_hook *)*(undefined1 **)(puVar6 + 8) != piVar12) ||

+               (plVar7 = *(longlong **)&(pDVar10->DisposableListEntry).field_0x8,

+               (intrusive_list_hook *)*plVar7 != piVar12)) goto LAB_0;

+            *plVar7 = (longlong)puVar6;

+            *(longlong **)(puVar6 + 8) = plVar7;

+            *(intrusive_list_hook **)&(pDVar10->DisposableListEntry).field_0x8 = piVar12;

+            *(intrusive_list_hook **)piVar12 = piVar12;

+            uVar3 = pDVar10->Hci->NumberOfDisposableDevices;

+            if (uVar3 != 0) {

+              pDVar10->Hci->NumberOfDisposableDevices = uVar3 - 1;

+            }

+          }

+          HCI_RemoveDibFromDeviceListLocked(param_1,pDVar10);

+          p_Var8 = param_2->Blink;

+          piVar12 = &pDVar10->ListEntry;

+          if (p_Var8->Flink != param_2) goto LAB_0;

+          *(_LIST_ENTRY **)&piVar12->field_0x0 = param_2;

+          *(_LIST_ENTRY **)&(pDVar10->ListEntry).field_0x8 = p_Var8;

+          p_Var8->Flink = (_LIST_ENTRY *)piVar12;

+          param_2->Blink = (_LIST_ENTRY *)piVar12;

+        }

+        HCI_RemoveDibFromDeviceListLocked(param_1,pDVar1);

+        p_Var8 = param_2->Blink;

+        if (p_Var8->Flink != param_2) {

+LAB_0:

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

+          (*pcVar9)(3);

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

+          (*pcVar9)();

+          return;

+        }

+        p_Var5->Flink = param_2;

+        p_Var4[-1].Blink = p_Var8;

+        p_Var8->Flink = p_Var5;

+        param_2->Blink = p_Var5;

+      }

+      else {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

+          uVar11 = 0;

+        }

+        else {

+          uVar11 = 1;

+        }

+        WPP_RECORDER_AND_TRACE_SF_i

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar11,"ent link detected",

+                   param_1->IfrLog,2,2,0x2a,&WPP_ad144674c127399e1f530e053018150b_Traceguids,pDVar1)

+        ;

+        MicrosoftTelemetryAssertTriggeredMsgKM

+                  (

+                  "The entry to be disposed is immune to disposal based on current state or not in the DeviceList."

+                  );

+      }

+LAB_1:

+    } while (param_1->CacheEntryDisposableLimit < param_1->NumberOfDisposableDevices);

   }

-  else {

-    IoQueueWorkItem(*(undefined8 *)(*(longlong *)(unaff_RBX + 0x378) + 0x8d8),

-                    HCI_DibDestructionWorkerCallback,unaff_EDI,*(longlong *)(unaff_RBX + 0x378));

-  }

-  wil::details::

-  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-  ::

-  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-              *)&stack0x00000060);

   return;

 }
```

## `HCI_UpdateOrAllocateDibEx`  (modified)

```diff
--- HCI_UpdateOrAllocateDibEx
+++ HCI_UpdateOrAllocateDibEx
@@ -1,790 +1,1051 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* struct DEVICE_INFO_BLOCK * __ptr64 __cdecl HCI_UpdateOrAllocateDibEx(struct HCI_INTERFACE *

+   __ptr64,unsigned __int64 * __ptr64,unsigned char const * __ptr64,unsigned long (__cdecl*)(struct

+   HCI_INTERFACE * __ptr64,struct DEVICE_INFO_BLOCK * __ptr64,enum _HCI_PHY_TYPE,void * __ptr64,enum

+   LinkedDibAction * __ptr64),void * __ptr64,unsigned char * __ptr64,unsigned char,unsigned

+   char,enum _HCI_PHY_TYPE,struct _GUID * __ptr64,unsigned char) */

 

 DEVICE_INFO_BLOCK * __cdecl

 HCI_UpdateOrAllocateDibEx

           (HCI_INTERFACE *param_1,__uint64 *param_2,uchar *param_3,

           _func_ulong_HCI_INTERFACE_ptr_DEVICE_INFO_BLOCK_ptr__HCI_PHY_TYPE_void_ptr_LinkedDibAction_ptr

           *param_4,void *param_5,uchar *param_6,uchar param_7,uchar param_8,_HCI_PHY_TYPE param_9,

           _GUID *param_10,uchar param_11)

 

 {

-  intrusive_list_hook *piVar1;

-  ulong *puVar2;

-  char *pcVar3;

-  atomic<unsigned___int64> *paVar4;

-  int iVar5;

-  uint uVar6;

-  ulong uVar7;

-  longlong *plVar8;

-  undefined1 *puVar9;

-  undefined8 *puVar10;

-  ulong64 uVar11;

-  ulong64 uVar12;

-  undefined8 uVar13;

-  code *pcVar14;

-  undefined8 uVar15;

-  byte bVar16;

-  uint uVar17;

-  longlong in_RAX;

-  DEVICE_INFO_BLOCK **ppDVar18;

-  DEVICE_INFO_BLOCK *pDVar19;

-  DEVICE_INFO_BLOCK *pDVar20;

-  ulonglong uVar21;

-  longlong lVar22;

-  uchar uVar23;

+  ulong *puVar1;

+  atomic<unsigned___int64> *paVar2;

+  int iVar3;

+  ulonglong uVar4;

+  longlong lVar5;

+  longlong *plVar6;

+  ulong64 uVar7;

+  _DEVICE_OBJECT *p_Var8;

+  code *pcVar9;

+  undefined4 uVar10;

+  undefined4 uVar11;

+  ushort uVar12;

+  ushort uVar13;

+  _HCI_PHY_TYPE _Var14;

+  byte bVar15;

+  uint uVar16;

+  ulong uVar17;

+  uint uVar18;

+  DEVICE_INFO_BLOCK **ppDVar19;

+  intrusive_list_hook *piVar20;

+  HCI_INTERFACE *pHVar21;

+  DEVICE_INFO_BLOCK *pDVar22;

+  DEVICE_INFO_BLOCK *pDVar23;

   _LIST_ENTRY *p_Var24;

-  HCI_INTERFACE *unaff_RBX;

-  _LIST_ENTRY *p_Var25;

-  longlong unaff_RBP;

-  uchar uVar26;

-  DEVICE_INFO_BLOCK **unaff_RDI;

-  DEVICE_INFO_BLOCK **ppDVar27;

-  char cVar28;

-  HCI_INTERFACE *unaff_R12;

-  ulong unaff_R13D;

-  DEVICE_INFO_BLOCK *unaff_R14;

-  undefined1 *unaff_R15;

-  undefined1 local_res8 [24];

+  DEVICE_INFO_BLOCK *pDVar25;

+  DEVICE_INFO_BLOCK *pDVar26;

+  uchar uVar27;

+  HCI_INTERFACE *pHVar28;

+  HCI_INTERFACE *pHVar29;

+  undefined8 uVar30;

+  _LIST_ENTRY *p_Var31;

+  undefined1 *puVar32;

+  ulong uVar33;

+  DEVICE_INFO_BLOCK **ppDVar34;

+  HCI_INTERFACE *pHVar35;

+  char cVar36;

+  HCI_INTERFACE *pHVar37;

+  ulong uVar38;

+  bool bVar39;

+  uint local_res10;

+  undefined1 auStackY_118 [8];

+  undefined1 auStackY_110 [24];

+  DEVICE_INFO_BLOCK *local_98;

+  undefined1 local_90 [8];

+  undefined1 local_88 [12];

+  LinkedDibAction local_7c;

+  ulong local_78;

+  undefined4 local_74;

+  _LIST_ENTRY local_70;

+  ulong64 local_60;

+  ulong64 local_58;

+  DEVICE_INFO_BLOCK **local_50;

+  uchar **local_48;

+  undefined1 *local_40;

   

-  unaff_RBX->defLocalName[(longlong)param_1 * 4 + -0x24] =

-       unaff_RBX->defLocalName[(longlong)param_1 * 4 + -0x24] + (char)param_1;

-  uVar26 = (uchar)unaff_RDI;

-  if ((*(longlong *)(param_3 + 8) == in_RAX) &&

-     (plVar8 = *(longlong **)(in_RAX + 8), *plVar8 == in_RAX)) {

-    *plVar8 = (longlong)param_3;

-    unaff_RBX = (HCI_INTERFACE *)&unaff_R12->DeviceList;

-    *(longlong **)(param_3 + 8) = plVar8;

-    p_Var24 = (_LIST_ENTRY *)(param_2 + 0x68);

-    p_Var25 = ((_LIST_ENTRY *)unaff_RBX)->Flink;

-    if ((HCI_INTERFACE *)p_Var25->Blink != unaff_RBX) goto LAB_0;

-    p_Var24->Flink = p_Var25;

-    param_2[0x69] = (__uint64)unaff_RBX;

-    p_Var25->Blink = p_Var24;

-    pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-    ((_LIST_ENTRY *)unaff_RBX)->Flink = p_Var24;

-    if (*(uchar *)(unaff_RBP + 0x4f) != uVar26) {

-      HCI_AssignDibNumber(pDVar19);

-      pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-    }

-    unaff_R14 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49);

-    uVar17 = (uint)unaff_RDI;

-    if (unaff_R14 == (DEVICE_INFO_BLOCK *)0x0) {

-      ppDVar18 = unaff_RDI;

-      if ((pDVar19 != (DEVICE_INFO_BLOCK *)0x0) &&

-         (((DEVICE_INFO_BLOCK **)pDVar19->LELastAdvertisementAddress == (DEVICE_INFO_BLOCK **)0x0 ||

-          (ppDVar18 = (DEVICE_INFO_BLOCK **)pDVar19->LELastAdvertisementAddress,

-          pDVar19->LELastAdvertisementAddressType != uVar26)))) {

-        ppDVar18 = (DEVICE_INFO_BLOCK **)(pDVar19->DeviceInfo).address;

-        if ((ppDVar18 != (DEVICE_INFO_BLOCK **)0x0) && (((pDVar19->DeviceInfo).flags & 0x8000) != 0)

-           ) {

-          uVar23 = uVar26;

-          if (pDVar19->LEOriginalAddressType != 0xff) {

-            uVar23 = pDVar19->LEOriginalAddressType;

-          }

-          if (uVar23 == '\0') goto LAB_1;

-        }

-        ppDVar18 = unaff_RDI;

-        if ((((pDVar19->SmpDevInfo).Flag & 8) != 0) &&

-           ((pDVar19->SmpDevInfo).AddressInformationType == uVar26)) {

-          ppDVar18 = (DEVICE_INFO_BLOCK **)(pDVar19->SmpDevInfo).AddressInformation;

-        }

-      }

-LAB_1:

-      *(DEVICE_INFO_BLOCK ***)(unaff_RBP + -0x21) = ppDVar18;

-      *(uchar *)(unaff_RBP + -0x41) = uVar26;

-      if (ppDVar18 != (DEVICE_INFO_BLOCK **)0x0) {

-        ppDVar18 = (DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49);

-        if (*(char *)(unaff_RBP + 0x87) != '\0') {

-          ppDVar18 = unaff_RDI;

-        }

-        ppDVar27 = (DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49);

-        if (*(char *)(unaff_RBP + 0x87) != '\x01') {

-          ppDVar27 = unaff_RDI;

-        }

-        HCI_FindDeviceInfoBlockByAddressLocked

-                  (unaff_R12,(__uint64 *)(unaff_RBP + -0x21),(uchar *)(unaff_RBP + -0x41),ppDVar27,

-                   ppDVar18);

-        unaff_R14 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49);

-        pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-        if (unaff_R14 != (DEVICE_INFO_BLOCK *)0x0) goto LAB_2;

-      }

-    }

-    else {

+  _Var14 = param_9;

+  uVar27 = param_7;

+  pHVar29 = (HCI_INTERFACE *)0x0;

+  local_98 = (DEVICE_INFO_BLOCK *)0x0;

+  local_90[0] = 0;

+  local_74 = 0;

+  local_78 = 0;

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+     (cVar36 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    cVar36 = '\0';

+  }

+  uVar38 = (ulong)param_7;

+  if ((cVar36 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_iDqqdddd

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar36,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->IfrLog);

+  }

+  uVar4 = *param_2;

+  local_70.Blink = &local_70;

+  local_70.Flink = &local_70;

+  uVar18 = local_res10 >> 8;

+  local_res10 = local_res10 & 0xffffff00;

+  if ((uVar4 == 0) || ((uVar4 & 0xffff000000000000) != 0)) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+      pHVar29 = (HCI_INTERFACE *)&DAT_0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),CONCAT71((int7)(uVar4 >> 8),(char)pHVar29)

+               ,1,param_1->IfrLog);

+    return (DEVICE_INFO_BLOCK *)0x0;

+  }

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

+    local_90[0] = KeAcquireSpinLockRaiseToDpc(&param_1->HciLock);

+  }

+  local_88._0_8_ = (DEVICE_INFO_BLOCK *)0x0;

+  ppDVar19 = (DEVICE_INFO_BLOCK **)local_88;

+  if (_Var14 == HciPhyTypeLE) {

+    ppDVar19 = &local_98;

+  }

+  ppDVar34 = (DEVICE_INFO_BLOCK **)local_88;

+  if (_Var14 == HciPhyTypeBR) {

+    ppDVar34 = &local_98;

+  }

+  uVar16 = HCI_FindDeviceInfoBlockByAddressLocked(param_1,param_2,(uchar *)0x0,ppDVar34,ppDVar19);

+  pHVar37 = (HCI_INTERFACE *)(ulonglong)uVar16;

+  pDVar25 = (DEVICE_INFO_BLOCK *)CONCAT71((int7)((ulonglong)param_1 >> 8),4);

+  uVar33 = 0;

+  if (((int)uVar16 < 0) || (local_98 != (DEVICE_INFO_BLOCK *)0x0)) goto LAB_1;

+  if ((uVar27 != '\0') &&

+     ((param_5 == (void *)0x0 &&

+      (param_1->MaxUnknownConnectRequests <= param_1->NumUnknownConnectRequests)))) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+       (uVar30 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar30 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_dD(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar30,1);

 LAB_2:

-      if ((DEVICE_INFO_BLOCK **)unaff_R14->LinkedDibAddress == unaff_RDI) {

-        if (((byte)((byte)unaff_R15 & (byte)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) == 0) ||

-           (uVar21 = 1, (byte)WPP_GLOBAL_Control[0x29] < 5)) {

-          uVar21 = (ulonglong)unaff_RDI & 0xff;

-        }

-        if (((char)uVar21 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

-          WPP_RECORDER_AND_TRACE_SF_qq

-                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar21,

-                     *(short *)(WPP_GLOBAL_Control + 0x48) != 0,unaff_R12->IfrLog,5);

-          pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-        }

-      }

-      if (pDVar19 == (DEVICE_INFO_BLOCK *)0x0) {

-        if ((DEVICE_INFO_BLOCK **)unaff_R14->LinkedDibAddress == unaff_RDI) goto LAB_3;

-        pDVar19 = HCI_FindLinkedDib((_LIST_ENTRY *)unaff_RBX,unaff_R14);

-        unaff_R14->LinkedDibAddress = (ulong64)unaff_RDI;

-        unaff_R14->LinkedDibAddressType = uVar26;

-        if (pDVar19 != (DEVICE_INFO_BLOCK *)0x0) {

-          pDVar19->LinkedDibAddress = (ulong64)unaff_RDI;

-          pDVar19->LinkedDibAddressType = uVar26;

+    param_3 = &DAT_3;

+    local_7c = None;

+    if (local_98 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_4;

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

+      RefObj_AddRefEx(local_98,HCI_UpdateOrAllocateDib,0xdc3,

+                      "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\hcidib.cpp");

+    }

+    _Var14 = param_9;

+    pHVar37 = param_1;

+    if ((param_4 ==

+         (_func_ulong_HCI_INTERFACE_ptr_DEVICE_INFO_BLOCK_ptr__HCI_PHY_TYPE_void_ptr_LinkedDibAction_ptr

+          *)0x0) || (param_5 == (void *)0x0)) {

+      pHVar28 = (HCI_INTERFACE *)(ulonglong)param_9;

+      if ((uVar27 == '\0') || ((char)local_res10 != '\0')) {

+LAB_5:

+        if (((local_98->DeviceInfo).flags & 0x20) == 0) {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+             (uVar30 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+            uVar30 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_i

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar30,1,local_98->IfrLog);

+          LOCK();

+          local_98->DibFlags = (atomic<unsigned___int64>)((ulonglong)local_98->DibFlags | 8);

+          UNLOCK();

+        }

+        else {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+             (cVar36 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+            cVar36 = '\0';

+          }

+          if ((cVar36 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+            WPP_RECORDER_AND_TRACE_SF_i

+                      (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar36,

+                       *(short *)(WPP_GLOBAL_Control + 0x48) != 0,local_98->IfrLog);

+          }

+        }

+        uVar17 = (local_98->DeviceInfo).classOfDevice;

+        HCI_DibUpdateCod(local_98,param_6);

+        if ((local_98->DeviceInfo).classOfDevice != uVar17) {

+          HCI_DibUpdateExFlagsForCodLocked(param_1,local_98);

+        }

+        if (_Var14 == HciPhyTypeBR) {

+          (local_98->DeviceInfo).flags = (local_98->DeviceInfo).flags | 0x4000;

+          bVar15 = (byte)local_74;

+          goto LAB_6;

+        }

+        if (_Var14 == HciPhyTypeLE) {

+          (local_98->DeviceInfo).flags = (local_98->DeviceInfo).flags | 0x8000;

+        }

+        goto LAB_7;

+      }

+      if (param_9 == HciPhyTypeBR) {

+        uVar18 = (local_98->DeviceInfo).flags;

+        if ((uVar18 & 0x4000) != 0) goto LAB_5;

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           (uVar30 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+          uVar30 = 0;

         }

       }

       else {

-        if (unaff_R14->LinkedDibAddress != 0) {

-          if (unaff_R14->LinkedDibAddress == (pDVar19->DeviceInfo).address) {

-            if (((pDVar19->DeviceInfo).flags & 0x8000) == 0) {

-              uVar23 = 0xff;

-            }

-            else {

-              uVar23 = uVar26;

-              if (pDVar19->LEOriginalAddressType != 0xff) {

-                uVar23 = pDVar19->LEOriginalAddressType;

-              }

-            }

-            if (((unaff_R14->LinkedDibAddressType == uVar23) && (pDVar19->LinkedDibAddress != 0)) &&

-               (pDVar19->LinkedDibAddress == (unaff_R14->DeviceInfo).address)) {

-              if (((unaff_R14->DeviceInfo).flags & 0x8000) == 0) {

-                uVar23 = 0xff;

+        if ((param_9 != HciPhyTypeLE) ||

+           (uVar18 = (local_98->DeviceInfo).flags, (uVar18 & 0x8000) != 0)) goto LAB_5;

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           (uVar30 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+          uVar30 = 0;

+        }

+      }

+      WPP_RECORDER_AND_TRACE_SF_dD

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar30,

+                 CONCAT71((uint7)((uint3)(uVar18 >> 8) & 0xc0),1));

+      pHVar37 = (HCI_INTERFACE *)0x0;

+      local_98 = (DEVICE_INFO_BLOCK *)0x0;

+      pDVar25 = (DEVICE_INFO_BLOCK *)local_88._0_8_;

+      uVar38 = local_res10;

+      goto LAB_8;

+    }

+    local_78 = (local_98->DeviceInfo).flags;

+    uVar18 = (local_98->DeviceInfo).classOfDevice;

+    pHVar28 = (HCI_INTERFACE *)(ulonglong)uVar18;

+    uVar17 = (*param_4)(param_1,local_98,param_9,param_5,&local_7c);

+    bVar15 = (byte)uVar17;

+    if ((local_98->DeviceInfo).classOfDevice != uVar18) {

+      HCI_DibUpdateExFlagsForCodLocked(param_1,local_98);

+    }

+    local_98->LastConnectionStatus = 0xff;

+    local_98->LastInquiryScan = param_1->CountInquiryScan;

+    if (param_9 != HciPhyTypeBR) {

+LAB_7:

+      piVar20 = &local_98->ListEntry;

+      lVar5 = *(longlong *)piVar20;

+      if (((intrusive_list_hook *)*(undefined1 **)(lVar5 + 8) != piVar20) ||

+         (plVar6 = *(longlong **)&(local_98->ListEntry).field_0x8,

+         (intrusive_list_hook *)*plVar6 != piVar20)) goto LAB_9;

+      *plVar6 = lVar5;

+      pHVar28 = (HCI_INTERFACE *)&param_1->DeviceList;

+      *(longlong **)(lVar5 + 8) = plVar6;

+      piVar20 = &local_98->ListEntry;

+      p_Var31 = ((_LIST_ENTRY *)pHVar28)->Flink;

+      if ((HCI_INTERFACE *)p_Var31->Blink != pHVar28) goto LAB_9;

+      *(_LIST_ENTRY **)piVar20 = p_Var31;

+      *(HCI_INTERFACE **)&(local_98->ListEntry).field_0x8 = pHVar28;

+      p_Var31->Blink = (_LIST_ENTRY *)piVar20;

+      ((_LIST_ENTRY *)pHVar28)->Flink = (_LIST_ENTRY *)piVar20;

+LAB_10:

+      pHVar28 = (HCI_INTERFACE *)&param_1->DeviceList;

+      if ((char)local_res10 != '\0') {

+        HCI_AssignDibNumber(local_98);

+      }

+      if ((DEVICE_INFO_BLOCK *)local_88._0_8_ == (DEVICE_INFO_BLOCK *)0x0) {

+        if (local_98 == (DEVICE_INFO_BLOCK *)0x0) {

+LAB_11:

+          local_60 = 0;

+        }

+        else {

+          local_60 = local_98->LELastAdvertisementAddress;

+          if ((local_60 == 0) || (local_98->LELastAdvertisementAddressType != '\0')) {

+            local_60 = (local_98->DeviceInfo).address;

+            if ((local_60 != 0) && (((local_98->DeviceInfo).flags & 0x8000) != 0)) {

+              uVar27 = '\0';

+              if (local_98->LEOriginalAddressType != 0xff) {

+                uVar27 = local_98->LEOriginalAddressType;

+              }

+              if (uVar27 == '\0') goto LAB_12;

+            }

+            if ((((local_98->SmpDevInfo).Flag & 8) == 0) ||

+               ((local_98->SmpDevInfo).AddressInformationType != '\0')) goto LAB_11;

+            local_60 = (local_98->SmpDevInfo).AddressInformation;

+          }

+        }

+LAB_12:

+        local_88[8] = 0;

+        pDVar25 = (DEVICE_INFO_BLOCK *)local_88._0_8_;

+        if (local_60 != 0) {

+          pHVar21 = (HCI_INTERFACE *)local_88;

+          if (param_9 != HciPhyTypeBR) {

+            pHVar21 = pHVar29;

+          }

+          pHVar35 = (HCI_INTERFACE *)local_88;

+          if (param_9 != HciPhyTypeLE) {

+            pHVar35 = pHVar29;

+          }

+          HCI_FindDeviceInfoBlockByAddressLocked

+                    (param_1,&local_60,local_88 + 8,(DEVICE_INFO_BLOCK **)pHVar35,

+                     (DEVICE_INFO_BLOCK **)pHVar21);

+          pDVar25 = (DEVICE_INFO_BLOCK *)local_88._0_8_;

+          if ((DEVICE_INFO_BLOCK *)local_88._0_8_ != (DEVICE_INFO_BLOCK *)0x0) goto LAB_13;

+        }

+      }

+      else {

+LAB_13:

+        pDVar25 = (DEVICE_INFO_BLOCK *)local_88._0_8_;

+        if (*(ulong64 *)(local_88._0_8_ + 0x8e8) == 0) {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+             (cVar36 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+            cVar36 = '\0';

+          }

+          if ((cVar36 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+            WPP_RECORDER_AND_TRACE_SF_qq

+                      (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar36,

+                       *(short *)(WPP_GLOBAL_Control + 0x48) != 0);

+          }

+        }

+        pDVar22 = local_98;

+        if (local_98 == (DEVICE_INFO_BLOCK *)0x0) {

+          if (*(ulong64 *)((longlong)pDVar25 + 0x8e8) == 0) goto LAB_14;

+          pDVar22 = HCI_FindLinkedDib((_LIST_ENTRY *)pHVar28,pDVar25);

+          *(ulong64 *)((longlong)pDVar25 + 0x8e8) = 0;

+          *(uchar *)((longlong)pDVar25 + 0x8f0) = '\0';

+          if (pDVar22 != (DEVICE_INFO_BLOCK *)0x0) {

+            pDVar22->LinkedDibAddress = 0;

+            pDVar22->LinkedDibAddressType = '\0';

+          }

+        }

+        else {

+          if (*(ulong64 *)((longlong)pDVar25 + 0x8e8) != 0) {

+            if (*(ulong64 *)((longlong)pDVar25 + 0x8e8) == (local_98->DeviceInfo).address) {

+              if (((local_98->DeviceInfo).flags & 0x8000) == 0) {

+                uVar27 = 0xff;

               }

               else {

-                uVar23 = uVar26;

-                if (unaff_R14->LEOriginalAddressType != 0xff) {

-                  uVar23 = unaff_R14->LEOriginalAddressType;

+                pHVar21 = pHVar29;

+                if (local_98->LEOriginalAddressType != 0xff) {

+                  pHVar21 = (HCI_INTERFACE *)(ulonglong)local_98->LEOriginalAddressType;

                 }

-              }

-              if (pDVar19->LinkedDibAddressType == uVar23) goto LAB_3;

-            }

-            if (((pDVar19->DeviceInfo).flags & 0x8000) == 0) {

-              uVar23 = 0xff;

-            }

-            else {

-              uVar23 = uVar26;

-              if (pDVar19->LEOriginalAddressType != 0xff) {

-                uVar23 = pDVar19->LEOriginalAddressType;

-              }

-            }

-            if (unaff_R14->LinkedDibAddressType == uVar23) goto LAB_4;

-          }

-          pDVar20 = HCI_FindLinkedDib((_LIST_ENTRY *)unaff_RBX,unaff_R14);

-          unaff_R14->LinkedDibAddress = (ulong64)unaff_RDI;

-          unaff_R14->LinkedDibAddressType = uVar26;

-          if (pDVar20 != (DEVICE_INFO_BLOCK *)0x0) {

-            pDVar20->LinkedDibAddress = (ulong64)unaff_RDI;

-            pDVar20->LinkedDibAddressType = uVar26;

-          }

-        }

-LAB_4:

-        if (pDVar19->LinkedDibAddress != 0) {

-          if (pDVar19->LinkedDibAddress == (unaff_R14->DeviceInfo).address) {

-            if (((unaff_R14->DeviceInfo).flags & 0x8000) == 0) {

-              uVar23 = 0xff;

-            }

-            else {

-              uVar23 = uVar26;

-              if (unaff_R14->LEOriginalAddressType != 0xff) {

-                uVar23 = unaff_R14->LEOriginalAddressType;

-              }

-            }

-            if (pDVar19->LinkedDibAddressType == uVar23) goto LAB_5;

-          }

-          pDVar20 = HCI_FindLinkedDib((_LIST_ENTRY *)unaff_RBX,pDVar19);

-          pDVar19->LinkedDibAddress = (ulong64)unaff_RDI;

-          pDVar19->LinkedDibAddressType = uVar26;

-          if (pDVar20 != (DEVICE_INFO_BLOCK *)0x0) {

-            pDVar20->LinkedDibAddress = (ulong64)unaff_RDI;

-            pDVar20->LinkedDibAddressType = uVar26;

-          }

-        }

-LAB_5:

-        unaff_R14->LinkedDibAddress = (pDVar19->DeviceInfo).address;

-        if (((pDVar19->DeviceInfo).flags >> 0xf & 1) == 0) {

-          uVar23 = 0xff;

-        }

-        else {

-          uVar23 = uVar26;

-          if (pDVar19->LEOriginalAddressType != 0xff) {

-            uVar23 = pDVar19->LEOriginalAddressType;

-          }

-        }

-        uVar11 = (unaff_R14->DeviceInfo).address;

-        unaff_R14->LinkedDibAddressType = uVar23;

-        pDVar19->LinkedDibAddress = uVar11;

-        if (((unaff_R14->DeviceInfo).flags >> 0xf & 1) == 0) {

-          uVar23 = 0xff;

-        }

-        else {

-          uVar23 = uVar26;

-          if (unaff_R14->LEOriginalAddressType != 0xff) {

-            uVar23 = unaff_R14->LEOriginalAddressType;

-          }

-        }

-        pDVar19->LinkedDibAddressType = uVar23;

-      }

-      if (((byte)((byte)unaff_R15 & (byte)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) == 0) ||

-         (uVar21 = 1, (byte)WPP_GLOBAL_Control[0x29] < 5)) {

-        uVar21 = (ulonglong)unaff_RDI & 0xff;

-      }

-      if (((char)uVar21 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

-        WPP_RECORDER_AND_TRACE_SF_qq

-                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar21,

-                   *(short *)(WPP_GLOBAL_Control + 0x48) != 0,unaff_R12->IfrLog,5);

-      }

-      pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-    }

-LAB_3:

-    if ((uVar17 < unaff_R12->CacheEntryDisposableLimit) &&

-       (*(DEVICE_INFO_BLOCK ***)(unaff_RBP + 0x67) != unaff_RDI)) {

-      uVar6 = (pDVar19->DeviceInfo).flags;

-      if ((((uVar6 >> 0xe & 1) == 0) ||

-          ((DEVICE_INFO_BLOCK **)pDVar19->LinkedDibAddress != unaff_RDI)) &&

-         (unaff_R15 = &DAT_6, (uVar6 & 0x1030038) == 0)) {

-        if ((((ulonglong)pDVar19->DibFlags & 8) != 0) ||

-           ((intrusive_list_hook *)*(undefined1 **)&pDVar19->ListEntry == &pDVar19->ListEntry)) {

-          unaff_R14 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49);

-          goto LAB_7;

-        }

-        pDVar20 = HCI_FindLinkedDib(&pDVar19->Hci->DeviceList,pDVar19);

-        if ((pDVar20 == (DEVICE_INFO_BLOCK *)0x0) ||

-           ((((uVar6 = (pDVar20->DeviceInfo).flags, (uVar6 >> 0xe & 1) == 0 ||

-              ((DEVICE_INFO_BLOCK **)pDVar20->LinkedDibAddress != unaff_RDI)) &&

-             ((uVar6 & 0x1030038) == 0)) && (((ulonglong)pDVar20->DibFlags & 8) == 0)))) {

-          piVar1 = &pDVar19->DisposableListEntry;

-          puVar9 = *(undefined1 **)piVar1;

-          if ((intrusive_list_hook *)puVar9 == piVar1) {

-            puVar2 = &pDVar19->Hci->NumberOfDisposableDevices;

-            *puVar2 = *puVar2 + 1;

-          }

-          else {

-            if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

-               (plVar8 = *(longlong **)&(pDVar19->DisposableListEntry).field_0x8,

-               (intrusive_list_hook *)*plVar8 != piVar1)) goto LAB_0;

-            *plVar8 = (longlong)puVar9;

-            *(longlong **)(puVar9 + 8) = plVar8;

-            *(intrusive_list_hook **)&(pDVar19->DisposableListEntry).field_0x8 = piVar1;

-            *(intrusive_list_hook **)piVar1 = piVar1;

-          }

-          p_Var24 = &pDVar19->Hci->DisposableDeviceList;

-          p_Var25 = p_Var24->Flink;

-          if (p_Var25->Blink != p_Var24) goto LAB_0;

-          *(_LIST_ENTRY **)piVar1 = p_Var25;

-          *(_LIST_ENTRY **)&(pDVar19->DisposableListEntry).field_0x8 = p_Var24;

-          p_Var25->Blink = (_LIST_ENTRY *)piVar1;

-          p_Var24->Flink = (_LIST_ENTRY *)piVar1;

-          if (pDVar20 != (DEVICE_INFO_BLOCK *)0x0) goto LAB_8;

-        }

-        else {

-LAB_8:

-          piVar1 = &pDVar20->DisposableListEntry;

-          puVar9 = *(undefined1 **)piVar1;

-          if ((intrusive_list_hook *)puVar9 != piVar1) {

-            if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) == piVar1) &&

-               (plVar8 = *(longlong **)&(pDVar20->DisposableListEntry).field_0x8,

-               (intrusive_list_hook *)*plVar8 == piVar1)) {

-              *plVar8 = (longlong)puVar9;

-              *(longlong **)(puVar9 + 8) = plVar8;

-              *(intrusive_list_hook **)&(pDVar20->DisposableListEntry).field_0x8 = piVar1;

-              *(intrusive_list_hook **)piVar1 = piVar1;

-              p_Var24 = &pDVar20->Hci->DisposableDeviceList;

-              p_Var25 = p_Var24->Flink;

-              if (p_Var25->Blink == p_Var24) {

-                *(_LIST_ENTRY **)piVar1 = p_Var25;

-                *(_LIST_ENTRY **)&(pDVar20->DisposableListEntry).field_0x8 = p_Var24;

-                p_Var25->Blink = (_LIST_ENTRY *)piVar1;

-                p_Var24->Flink = (_LIST_ENTRY *)piVar1;

-                goto LAB_9;

-              }

-            }

-            goto LAB_0;

-          }

-        }

-LAB_9:

-        unaff_R14 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49);

-      }

-      else {

-LAB_7:

-        piVar1 = &pDVar19->DisposableListEntry;

-        puVar9 = *(undefined1 **)piVar1;

-        if ((intrusive_list_hook *)puVar9 != piVar1) {

-          if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

-             (plVar8 = *(longlong **)&(pDVar19->DisposableListEntry).field_0x8,

-             (intrusive_list_hook *)*plVar8 != piVar1)) goto LAB_0;

-          *plVar8 = (longlong)puVar9;

-          *(longlong **)(puVar9 + 8) = plVar8;

-          *(intrusive_list_hook **)&(pDVar19->DisposableListEntry).field_0x8 = piVar1;

-          *(intrusive_list_hook **)piVar1 = piVar1;

-          uVar7 = pDVar19->Hci->NumberOfDisposableDevices;

-          if (uVar7 != 0) {

-            pDVar19->Hci->NumberOfDisposableDevices = uVar7 - 1;

-          }

-        }

-        pDVar19 = HCI_FindLinkedDib(&pDVar19->Hci->DeviceList,pDVar19);

-        if (pDVar19 != (DEVICE_INFO_BLOCK *)0x0) {

-          piVar1 = &pDVar19->DisposableListEntry;

-          puVar9 = *(undefined1 **)piVar1;

-          if ((intrusive_list_hook *)puVar9 != piVar1) {

-            if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

-               (plVar8 = *(longlong **)&(pDVar19->DisposableListEntry).field_0x8,

-               (intrusive_list_hook *)*plVar8 != piVar1)) goto LAB_0;

-            *plVar8 = (longlong)puVar9;

-            *(longlong **)(puVar9 + 8) = plVar8;

-            *(intrusive_list_hook **)&(pDVar19->DisposableListEntry).field_0x8 = piVar1;

-            *(intrusive_list_hook **)piVar1 = piVar1;

-            uVar7 = pDVar19->Hci->NumberOfDisposableDevices;

-            if (uVar7 != 0) {

-              pDVar19->Hci->NumberOfDisposableDevices = uVar7 - 1;

-            }

-          }

-        }

-      }

-      if ((*(uchar *)(unaff_RBP + 0x7f) == uVar26) && (*(char *)(unaff_RBP + 0x97) == '\x01')) {

-        HCI_DibProcessDisposableListLocked(unaff_R12,(_LIST_ENTRY *)(unaff_RBP + -0x31));

-      }

-      pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-    }

-    unaff_R12 = (HCI_INTERFACE *)((ulonglong)unaff_RDI & 0xff);

-    unaff_R13D = uVar17;

-    if ((*(byte *)(unaff_RBP + -0x3d) & 3) == 0) {

-LAB_10:

-      if (*(uchar *)(unaff_RBP + 0x7f) != uVar26) {

-        return (DEVICE_INFO_BLOCK *)pDVar19;

-      }

-    }

-    else {

-      if ((unaff_R14 == (DEVICE_INFO_BLOCK *)0x0) && ((*(byte *)(unaff_RBP + -0x3d) & 2) != 0)) {

-        ppDVar18 = unaff_RDI;

-        if ((pDVar19 != (DEVICE_INFO_BLOCK *)0x0) &&

-           (((DEVICE_INFO_BLOCK **)pDVar19->LELastAdvertisementAddress == (DEVICE_INFO_BLOCK **)0x0

-            || (ppDVar18 = (DEVICE_INFO_BLOCK **)pDVar19->LELastAdvertisementAddress,

-               pDVar19->LELastAdvertisementAddressType != uVar26)))) {

-          ppDVar18 = (DEVICE_INFO_BLOCK **)(pDVar19->DeviceInfo).address;

-          if ((ppDVar18 != (DEVICE_INFO_BLOCK **)0x0) &&

-             (((pDVar19->DeviceInfo).flags & 0x8000) != 0)) {

-            uVar23 = uVar26;

-            if (pDVar19->LEOriginalAddressType != 0xff) {

-              uVar23 = pDVar19->LEOriginalAddressType;

-            }

-            if (uVar23 == '\0') goto LAB_11;

-          }

-          ppDVar18 = unaff_RDI;

-          if ((((pDVar19->SmpDevInfo).Flag & 8) != 0) &&

-             ((pDVar19->SmpDevInfo).AddressInformationType == uVar26)) {

-            ppDVar18 = (DEVICE_INFO_BLOCK **)(pDVar19->SmpDevInfo).AddressInformation;

-          }

-        }

-LAB_11:

-        unaff_RBX = *(HCI_INTERFACE **)(unaff_RBP + 0x47);

-        *(DEVICE_INFO_BLOCK ***)(unaff_RBP + -0x19) = ppDVar18;

-        ppDVar18 = (DEVICE_INFO_BLOCK **)(unaff_RBP + -0x40);

-        if (*(uchar *)(unaff_RBP + 0x87) != uVar26) {

-          ppDVar18 = unaff_RDI;

-        }

-        *(uchar *)(unaff_RBP + -0x40) = uVar26;

-        unaff_R14 = HCI_DibCreate(unaff_RBX,(__uint64 *)(unaff_RBP + -0x19),(uchar *)ppDVar18);

-        *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49) = unaff_R14;

-        if (unaff_R14 != (DEVICE_INFO_BLOCK *)0x0) {

-          HCI_DibPopulateDefaultContainerIds(unaff_R14);

-          puVar10 = *(undefined8 **)(unaff_RBP + 0x8f);

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

-            (unaff_R14->ActivityId).Data1 = 0;

-            (unaff_R14->ActivityId).Data2 = 0;

-            (unaff_R14->ActivityId).Data3 = 0;

-            (unaff_R14->ActivityId).Data4[0] = '\0';

-            (unaff_R14->ActivityId).Data4[1] = '\0';

-            (unaff_R14->ActivityId).Data4[2] = '\0';

-            (unaff_R14->ActivityId).Data4[3] = '\0';

-            (unaff_R14->ActivityId).Data4[4] = '\0';

-            (unaff_R14->ActivityId).Data4[5] = '\0';

-            (unaff_R14->ActivityId).Data4[6] = '\0';

-            (unaff_R14->ActivityId).Data4[7] = '\0';

-          }

-          else {

-            uVar13 = *puVar10;

-            uVar15 = puVar10[1];

-            (unaff_R14->ActivityId).Data1 = (int)uVar13;

-            (unaff_R14->ActivityId).Data2 = (short)((ulonglong)uVar13 >> 0x20);

-            (unaff_R14->ActivityId).Data3 = (short)((ulonglong)uVar13 >> 0x30);

-            *(undefined8 *)(unaff_R14->ActivityId).Data4 = uVar15;

-          }

-          unaff_RBX->NumDevices = unaff_RBX->NumDevices + 1;

-          p_Var25 = (unaff_RBX->DeviceList).Blink;

-          piVar1 = &unaff_R14->ListEntry;

-          if (p_Var25->Flink != &unaff_RBX->DeviceList) goto LAB_0;

-          *(_LIST_ENTRY **)&piVar1->field_0x0 = &unaff_RBX->DeviceList;

-          unaff_R12 = (HCI_INTERFACE *)&DAT_12;

-          *(_LIST_ENTRY **)&(unaff_R14->ListEntry).field_0x8 = p_Var25;

-          p_Var25->Flink = (_LIST_ENTRY *)piVar1;

-          (unaff_RBX->DeviceList).Blink = (_LIST_ENTRY *)piVar1;

-        }

-        pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-      }

-      else {

-        unaff_RBX = *(HCI_INTERFACE **)(unaff_RBP + 0x47);

-      }

-      unaff_R15 = (undefined1 *)((ulonglong)unaff_RDI & 0xffffffff);

-      if (unaff_R14 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_10;

-      if ((((*(byte *)(unaff_RBP + -0x3d) & 1) != 0) &&

-          (*(code **)(unaff_RBP + 0x5f) != (code *)0x0)) && (*(longlong *)(unaff_RBP + 0x67) != 0))

-      {

-        uVar7 = (unaff_R14->DeviceInfo).classOfDevice;

-        unaff_R13D = (unaff_R14->DeviceInfo).flags;

-        uVar21 = (**(code **)(unaff_RBP + 0x5f))

-                           (*(undefined8 *)(unaff_RBP + 0x47),unaff_R14,

-                            *(uchar *)(unaff_RBP + 0x87) == uVar26);

-        unaff_R15 = (undefined1 *)(uVar21 & 0xffffffff);

-        unaff_RBX = *(HCI_INTERFACE **)(unaff_RBP + 0x47);

-        if ((unaff_R14->DeviceInfo).classOfDevice != uVar7) {

-          HCI_DibUpdateExFlagsForCodLocked(unaff_RBX,unaff_R14);

-        }

-        unaff_R14->LastConnectionStatus = 0xff;

-        unaff_R14->LastInquiryScan = unaff_RBX->CountInquiryScan;

-        pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-      }

-      if ((char)unaff_R12 != '\0') {

-        pcVar3 = (char *)(unaff_RBP + 0x87);

-        cVar28 = *pcVar3;

-        *pcVar3 = -*pcVar3;

-        (unaff_R14->DeviceInfo).flags =

-             (unaff_R14->DeviceInfo).flags | (-(uint)(cVar28 != '\0') & 0xffffc000) + 0x8000;

-        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

-           (uVar21 = 1, (byte)WPP_GLOBAL_Control[0x29] < 5)) {

-          uVar21 = (ulonglong)unaff_RDI & 0xff;

-        }

-        if (((char)uVar21 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

-          WPP_RECORDER_AND_TRACE_SF_qq

-                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar21,

-                     *(short *)(WPP_GLOBAL_Control + 0x48) != 0,unaff_RBX->IfrLog,5);

-        }

-        pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-        p_Var25 = &unaff_RBX->DeviceList;

-        if (pDVar19 == (DEVICE_INFO_BLOCK *)0x0) {

-          if ((DEVICE_INFO_BLOCK **)unaff_R14->LinkedDibAddress == unaff_RDI) {

-LAB_13:

-            unaff_RBX = *(HCI_INTERFACE **)(unaff_RBP + 0x47);

-            goto LAB_14;

-          }

-          pDVar19 = HCI_FindLinkedDib(p_Var25,unaff_R14);

-          unaff_R14->LinkedDibAddress = (ulong64)unaff_RDI;

-          unaff_R14->LinkedDibAddressType = uVar26;

-          if (pDVar19 != (DEVICE_INFO_BLOCK *)0x0) {

-            pDVar19->LinkedDibAddress = (ulong64)unaff_RDI;

-            pDVar19->LinkedDibAddressType = uVar26;

-          }

-        }

-        else {

-          if (unaff_R14->LinkedDibAddress != 0) {

-            if (unaff_R14->LinkedDibAddress == (pDVar19->DeviceInfo).address) {

-              if (((pDVar19->DeviceInfo).flags & 0x8000) == 0) {

-                uVar23 = 0xff;

-              }

-              else {

-                uVar23 = uVar26;

-                if (pDVar19->LEOriginalAddressType != 0xff) {

-                  uVar23 = pDVar19->LEOriginalAddressType;

-                }

-              }

-              if (((unaff_R14->LinkedDibAddressType == uVar23) && (pDVar19->LinkedDibAddress != 0))

-                 && (pDVar19->LinkedDibAddress == (unaff_R14->DeviceInfo).address)) {

-                if (((unaff_R14->DeviceInfo).flags & 0x8000) == 0) {

-                  uVar23 = 0xff;

+                uVar27 = (uchar)pHVar21;

+              }

+              if (((*(uchar *)((longlong)pDVar25 + 0x8f0) == uVar27) &&

+                  (local_98->LinkedDibAddress != 0)) &&

+                 (local_98->LinkedDibAddress ==

+                  ((_BTH_DEVICE_INFO_V2 *)((longlong)pDVar25 + 0x18))->address)) {

+                if ((((_BTH_DEVICE_INFO_V2 *)((longlong)pDVar25 + 0x18))->flags & 0x8000) == 0) {

+                  uVar27 = 0xff;

                 }

                 else {

-                  uVar23 = uVar26;

-                  if (unaff_R14->LEOriginalAddressType != 0xff) {

-                    uVar23 = unaff_R14->LEOriginalAddressType;

+                  pHVar21 = pHVar29;

+                  if (*(uchar *)((longlong)pDVar25 + 0x5b0) != 0xff) {

+                    pHVar21 = (HCI_INTERFACE *)(ulonglong)*(uchar *)((longlong)pDVar25 + 0x5b0);

                   }

+                  uVar27 = (uchar)pHVar21;

                 }

-                if (pDVar19->LinkedDibAddressType == uVar23) goto LAB_13;

-              }

-              if (((pDVar19->DeviceInfo).flags & 0x8000) == 0) {

-                uVar23 = 0xff;

+                if (local_98->LinkedDibAddressType == uVar27) goto LAB_14;

+              }

+              if (((local_98->DeviceInfo).flags & 0x8000) == 0) {

+                uVar27 = 0xff;

               }

               else {

-                uVar23 = uVar26;

-                if (pDVar19->LEOriginalAddressType != 0xff) {

-                  uVar23 = pDVar19->LEOriginalAddressType;

+                pHVar21 = pHVar29;

+                if (local_98->LEOriginalAddressType != 0xff) {

+                  pHVar21 = (HCI_INTERFACE *)(ulonglong)local_98->LEOriginalAddressType;

                 }

-              }

-              if (unaff_R14->LinkedDibAddressType == uVar23) goto LAB_15;

+                uVar27 = (uchar)pHVar21;

+              }

+              if (*(uchar *)((longlong)pDVar25 + 0x8f0) == uVar27) goto LAB_15;

+            }

+            pDVar26 = HCI_FindLinkedDib((_LIST_ENTRY *)pHVar28,pDVar25);

+            *(ulong64 *)((longlong)pDVar25 + 0x8e8) = 0;

+            *(uchar *)((longlong)pDVar25 + 0x8f0) = '\0';

+            if (pDVar26 != (DEVICE_INFO_BLOCK *)0x0) {

+              pDVar26->LinkedDibAddress = 0;

+              pDVar26->LinkedDibAddressType = '\0';

+            }

+          }

+LAB_15:

+          if (pDVar22->LinkedDibAddress != 0) {

+            if (pDVar22->LinkedDibAddress ==

+                ((_BTH_DEVICE_INFO_V2 *)((longlong)pDVar25 + 0x18))->address) {

+              if ((((_BTH_DEVICE_INFO_V2 *)((longlong)pDVar25 + 0x18))->flags & 0x8000) == 0) {

+                uVar27 = 0xff;

+              }

+              else {

+                pHVar21 = pHVar29;

+                if (*(uchar *)((longlong)pDVar25 + 0x5b0) != 0xff) {

+                  pHVar21 = (HCI_INTERFACE *)(ulonglong)*(uchar *)((longlong)pDVar25 + 0x5b0);

+                }

+                uVar27 = (uchar)pHVar21;

+              }

+              if (pDVar22->LinkedDibAddressType == uVar27) goto LAB_16;

+            }

+            pDVar26 = HCI_FindLinkedDib((_LIST_ENTRY *)pHVar28,pDVar22);

+            pDVar22->LinkedDibAddress = 0;

+            pDVar22->LinkedDibAddressType = '\0';

+            if (pDVar26 != (DEVICE_INFO_BLOCK *)0x0) {

+              pDVar26->LinkedDibAddress = 0;

+              pDVar26->LinkedDibAddressType = '\0';

+            }

+          }

+LAB_16:

+          *(ulong64 *)((longlong)pDVar25 + 0x8e8) = (pDVar22->DeviceInfo).address;

+          if (((pDVar22->DeviceInfo).flags >> 0xf & 1) == 0) {

+            uVar27 = 0xff;

+          }

+          else {

+            pHVar21 = pHVar29;

+            if (pDVar22->LEOriginalAddressType != 0xff) {

+              pHVar21 = (HCI_INTERFACE *)(ulonglong)pDVar22->LEOriginalAddressType;

+            }

+            uVar27 = (uchar)pHVar21;

+          }

+          uVar7 = ((_BTH_DEVICE_INFO_V2 *)((longlong)pDVar25 + 0x18))->address;

+          *(uchar *)((longlong)pDVar25 + 0x8f0) = uVar27;

+          pDVar22->LinkedDibAddress = uVar7;

+          if ((((_BTH_DEVICE_INFO_V2 *)((longlong)pDVar25 + 0x18))->flags >> 0xf & 1) == 0) {

+            uVar27 = 0xff;

+          }

+          else {

+            pHVar21 = pHVar29;

+            if (*(uchar *)((longlong)pDVar25 + 0x5b0) != 0xff) {

+              pHVar21 = (HCI_INTERFACE *)(ulonglong)*(uchar *)((longlong)pDVar25 + 0x5b0);

+            }

+            uVar27 = (uchar)pHVar21;

+          }

+          pDVar22->LinkedDibAddressType = uVar27;

+        }

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           (cVar36 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+          cVar36 = '\0';

+        }

+        if ((cVar36 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+          WPP_RECORDER_AND_TRACE_SF_qq

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar36,

+                     *(short *)(WPP_GLOBAL_Control + 0x48) != 0);

+        }

+      }

+LAB_14:

+      pDVar22 = local_98;

+      pDVar26 = pDVar25;

+      if ((param_1->CacheEntryDisposableLimit != 0) && (param_5 != (void *)0x0)) {

+        uVar18 = (local_98->DeviceInfo).flags;

+        if ((((uVar18 >> 0xe & 1) == 0) || (local_98->LinkedDibAddress != 0)) &&

+           (((param_3 = &DAT_17, (uVar18 & 0x1030038) == 0 &&

+             (pDVar26 = (DEVICE_INFO_BLOCK *)local_88._0_8_,

+             ((ulonglong)local_98->DibFlags & 8) == 0)) &&

+            ((intrusive_list_hook *)*(undefined1 **)&local_98->ListEntry != &local_98->ListEntry))))

+        {

+          pDVar23 = HCI_FindLinkedDib(&local_98->Hci->DeviceList,local_98);

+          pDVar26 = (DEVICE_INFO_BLOCK *)local_88._0_8_;

+          if ((pDVar23 == (DEVICE_INFO_BLOCK *)0x0) ||

+             ((((uVar18 = (pDVar23->DeviceInfo).flags, (uVar18 >> 0xe & 1) == 0 ||

+                (pDVar23->LinkedDibAddress != 0)) && ((uVar18 & 0x1030038) == 0)) &&

+              (((ulonglong)pDVar23->DibFlags & 8) == 0)))) {

+            piVar20 = &pDVar22->DisposableListEntry;

+            puVar32 = *(undefined1 **)piVar20;

+            if ((intrusive_list_hook *)puVar32 == piVar20) {

+              puVar1 = &pDVar22->Hci->NumberOfDisposableDevices;

+              *puVar1 = *puVar1 + 1;

             }

             else {

-              *(undefined1 *)(unaff_RBP + 0x4f) = *(undefined1 *)(unaff_RBP + 0x4f);

-            }

-            pDVar20 = HCI_FindLinkedDib(p_Var25,unaff_R14);

-            unaff_R14->LinkedDibAddress = (ulong64)unaff_RDI;

-            unaff_R14->LinkedDibAddressType = uVar26;

-            if (pDVar20 != (DEVICE_INFO_BLOCK *)0x0) {

-              pDVar20->LinkedDibAddress = (ulong64)unaff_RDI;

-              pDVar20->LinkedDibAddressType = uVar26;

-            }

-          }

-LAB_15:

-          if (pDVar19->LinkedDibAddress != 0) {

-            if (pDVar19->LinkedDibAddress == (unaff_R14->DeviceInfo).address) {

-              if (((unaff_R14->DeviceInfo).flags & 0x8000) == 0) {

-                uVar23 = 0xff;

+              if (((intrusive_list_hook *)*(undefined1 **)(puVar32 + 8) != piVar20) ||

+                 (plVar6 = *(longlong **)&(pDVar22->DisposableListEntry).field_0x8,

+                 (intrusive_list_hook *)*plVar6 != piVar20)) goto LAB_9;

+              *plVar6 = (longlong)puVar32;

+              *(longlong **)(puVar32 + 8) = plVar6;

+              *(intrusive_list_hook **)&(pDVar22->DisposableListEntry).field_0x8 = piVar20;

+              *(intrusive_list_hook **)piVar20 = piVar20;

+            }

+            p_Var24 = &pDVar22->Hci->DisposableDeviceList;

+            p_Var31 = p_Var24->Flink;

+            if (p_Var31->Blink != p_Var24) goto LAB_9;

+            *(_LIST_ENTRY **)piVar20 = p_Var31;

+            *(_LIST_ENTRY **)&(pDVar22->DisposableListEntry).field_0x8 = p_Var24;

+            p_Var31->Blink = (_LIST_ENTRY *)piVar20;

+            p_Var24->Flink = (_LIST_ENTRY *)piVar20;

+            if (pDVar23 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_18;

+          }

+          piVar20 = &pDVar23->DisposableListEntry;

+          puVar32 = *(undefined1 **)piVar20;

+          if ((intrusive_list_hook *)puVar32 != piVar20) {

+            if (((intrusive_list_hook *)*(undefined1 **)(puVar32 + 8) == piVar20) &&

+               (plVar6 = *(longlong **)&(pDVar23->DisposableListEntry).field_0x8,

+               (intrusive_list_hook *)*plVar6 == piVar20)) {

+              *plVar6 = (longlong)puVar32;

+              *(longlong **)(puVar32 + 8) = plVar6;

+              *(intrusive_list_hook **)&(pDVar23->DisposableListEntry).field_0x8 = piVar20;

+              *(intrusive_list_hook **)piVar20 = piVar20;

+              p_Var24 = &pDVar23->Hci->DisposableDeviceList;

+              p_Var31 = p_Var24->Flink;

+              if (p_Var31->Blink == p_Var24) {

+                *(_LIST_ENTRY **)piVar20 = p_Var31;

+                *(_LIST_ENTRY **)&(pDVar23->DisposableListEntry).field_0x8 = p_Var24;

+                p_Var31->Blink = (_LIST_ENTRY *)piVar20;

+                p_Var24->Flink = (_LIST_ENTRY *)piVar20;

+                goto LAB_18;

+              }

+            }

+            goto LAB_9;

+          }

+        }

+        else {

+          pDVar25 = pDVar26;

+          piVar20 = &local_98->DisposableListEntry;

+          puVar32 = *(undefined1 **)piVar20;

+          if ((intrusive_list_hook *)puVar32 != piVar20) {

+            if (((intrusive_list_hook *)*(undefined1 **)(puVar32 + 8) != piVar20) ||

+               (plVar6 = *(longlong **)&(local_98->DisposableListEntry).field_0x8,

+               (intrusive_list_hook *)*plVar6 != piVar20)) goto LAB_9;

+            *plVar6 = (longlong)puVar32;

+            *(longlong **)(puVar32 + 8) = plVar6;

+            *(intrusive_list_hook **)&(local_98->DisposableListEntry).field_0x8 = piVar20;

+            *(intrusive_list_hook **)piVar20 = piVar20;

+            uVar17 = local_98->Hci->NumberOfDisposableDevices;

+            if (uVar17 != 0) {

+              local_98->Hci->NumberOfDisposableDevices = uVar17 - 1;

+            }

+          }

+          pDVar22 = HCI_FindLinkedDib(&local_98->Hci->DeviceList,local_98);

+          pDVar26 = pDVar25;

+          if (pDVar22 != (DEVICE_INFO_BLOCK *)0x0) {

+            piVar20 = &pDVar22->DisposableListEntry;

+            puVar32 = *(undefined1 **)piVar20;

+            if ((intrusive_list_hook *)puVar32 != piVar20) {

+              if (((intrusive_list_hook *)*(undefined1 **)(puVar32 + 8) != piVar20) ||

+                 (plVar6 = *(longlong **)&(pDVar22->DisposableListEntry).field_0x8,

+                 (intrusive_list_hook *)*plVar6 != piVar20)) goto LAB_9;

+              *plVar6 = (longlong)puVar32;

+              *(longlong **)(puVar32 + 8) = plVar6;

+              *(intrusive_list_hook **)&(pDVar22->DisposableListEntry).field_0x8 = piVar20;

+              *(intrusive_list_hook **)piVar20 = piVar20;

+              uVar38 = pDVar22->Hci->NumberOfDisposableDevices;

+              if (uVar38 != 0) {

+                pDVar22->Hci->NumberOfDisposableDevices = uVar38 - 1;

+              }

+            }

+          }

+        }

+LAB_18:

+        if ((param_8 == '\0') && (param_11 == '\x01')) {

+          HCI_DibProcessDisposableListLocked(param_1,&local_70);

+        }

+      }

+      goto LAB_19;

+    }

+LAB_6:

+    if ((((ulonglong)local_98->DibFlags & 1) == 0) && (((local_98->DeviceInfo).flags & 4) == 0))

+    goto LAB_7;

+    if (((ulonglong)local_98->DibFlags & 0x100000006) != 0) {

+LAB_20:

+      if (((((param_4 !=

+              (_func_ulong_HCI_INTERFACE_ptr_DEVICE_INFO_BLOCK_ptr__HCI_PHY_TYPE_void_ptr_LinkedDibAction_ptr

+               *)0x0) || (uVar27 != '\0')) && ((bVar15 & 4) == 0)) &&

+          ((uVar18 = (local_98->DeviceInfo).flags, (uVar18 >> 0xd & 1) == 0 && ((uVar18 & 4) != 0)))

+          ) && (((ulonglong)local_98->DibFlags & 1) == 0)) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           (uVar30 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+          uVar30 = 0;

+        }

+        WPP_RECORDER_AND_TRACE_SF_i(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar30,1);

+        LOCK();

+        local_98->DibFlags = (atomic<unsigned___int64>)((ulonglong)local_98->DibFlags | 0x800000);

+        UNLOCK();

+      }

+      goto LAB_10;

+    }

+    piVar20 = &local_98->ListEntry;

+    lVar5 = *(longlong *)piVar20;

+    if (((intrusive_list_hook *)*(undefined1 **)(lVar5 + 8) == piVar20) &&

+       (plVar6 = *(longlong **)&(local_98->ListEntry).field_0x8,

+       (intrusive_list_hook *)*plVar6 == piVar20)) {

+      *plVar6 = lVar5;

+      piVar20 = &local_98->ListEntry;

+      *(longlong **)(lVar5 + 8) = plVar6;

+      p_Var31 = (param_1->DeviceList).Blink;

+      if (p_Var31->Flink == &param_1->DeviceList) {

+        *(_LIST_ENTRY **)&piVar20->field_0x0 = &param_1->DeviceList;

+        *(_LIST_ENTRY **)&(local_98->ListEntry).field_0x8 = p_Var31;

+        p_Var31->Flink = (_LIST_ENTRY *)piVar20;

+        (param_1->DeviceList).Blink = (_LIST_ENTRY *)piVar20;

+        goto LAB_20;

+      }

+    }

+    goto LAB_9;

+  }

+  local_98 = HCI_DibCreate(param_1,param_2,param_3);

+  if (local_98 != (DEVICE_INFO_BLOCK *)0x0) {

+    HCI_DibPopulateDefaultContainerIds(local_98);

+    if (param_10 == (_GUID *)0x0) {

+      (local_98->ActivityId).Data1 = 0;

+      (local_98->ActivityId).Data2 = 0;

+      (local_98->ActivityId).Data3 = 0;

+      (local_98->ActivityId).Data4[0] = '\0';

+      (local_98->ActivityId).Data4[1] = '\0';

+      (local_98->ActivityId).Data4[2] = '\0';

+      (local_98->ActivityId).Data4[3] = '\0';

+      (local_98->ActivityId).Data4[4] = '\0';

+      (local_98->ActivityId).Data4[5] = '\0';

+      (local_98->ActivityId).Data4[6] = '\0';

+      (local_98->ActivityId).Data4[7] = '\0';

+    }

+    else {

+      uVar12 = param_10->Data2;

+      uVar13 = param_10->Data3;

+      uVar10 = *(undefined4 *)param_10->Data4;

+      uVar11 = *(undefined4 *)(param_10->Data4 + 4);

+      (local_98->ActivityId).Data1 = param_10->Data1;

+      (local_98->ActivityId).Data2 = uVar12;

+      (local_98->ActivityId).Data3 = uVar13;

+      *(undefined4 *)(local_98->ActivityId).Data4 = uVar10;

+      *(undefined4 *)((local_98->ActivityId).Data4 + 4) = uVar11;

+    }

+    param_1->NumDevices = param_1->NumDevices + 1;

+    p_Var31 = (param_1->DeviceList).Blink;

+    piVar20 = &local_98->ListEntry;

+    pHVar28 = param_1;

+    if (p_Var31->Flink == &param_1->DeviceList) {

+      *(_LIST_ENTRY **)&piVar20->field_0x0 = &param_1->DeviceList;

+      *(_LIST_ENTRY **)&(local_98->ListEntry).field_0x8 = p_Var31;

+      p_Var31->Flink = (_LIST_ENTRY *)piVar20;

+      (param_1->DeviceList).Blink = (_LIST_ENTRY *)piVar20;

+      local_res10 = CONCAT31((int3)uVar18,1);

+      if (param_5 == (void *)0x0) {

+        LOCK();

+        local_98->DibFlags = (atomic<unsigned___int64>)((ulonglong)local_98->DibFlags | 0x100);

+        UNLOCK();

+        param_3 = &DAT_3;

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+           (p_Var31 = (_LIST_ENTRY *)CONCAT71((int7)((ulonglong)p_Var31 >> 8),1),

+           (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+          p_Var31 = (_LIST_ENTRY *)((ulonglong)p_Var31 & 0xffffffffffffff00);

+        }

+        WPP_RECORDER_AND_TRACE_SF_i(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),p_Var31,1);

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

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+             (uVar30 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+            uVar30 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar30,1);

+          param_1->NumUnknownConnectRequests = param_1->NumUnknownConnectRequests + '\x01';

+          LOCK();

+          local_98->DibFlags = (atomic<unsigned___int64>)((ulonglong)local_98->DibFlags | 0x200);

+          UNLOCK();

+          goto LAB_2;

+        }

+      }

+      goto LAB_1;

+    }

+    goto LAB_9;

+  }

+LAB_1:

+  if (-1 < (int)uVar16) goto LAB_2;

+LAB_4:

+  local_7c = None;

+  pDVar26 = (DEVICE_INFO_BLOCK *)local_88._0_8_;

+LAB_19:

+  pHVar37 = (HCI_INTERFACE *)0x0;

+  pDVar25 = pDVar26;

+  uVar38 = uVar33;

+  if ((local_7c & (Create|Update)) == None) {

+LAB_8:

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

+      return local_98;

+    }

+  }

+  else {

+    if ((pDVar26 == (DEVICE_INFO_BLOCK *)0x0) && ((local_7c & Create) != None)) {

+      if (local_98 == (DEVICE_INFO_BLOCK *)0x0) {

+LAB_21:

+        local_58 = 0;

+      }

+      else {

+        local_58 = local_98->LELastAdvertisementAddress;

+        if ((local_58 == 0) || (local_98->LELastAdvertisementAddressType != '\0')) {

+          local_58 = (local_98->DeviceInfo).address;

+          if ((local_58 != 0) && (((local_98->DeviceInfo).flags & 0x8000) != 0)) {

+            uVar27 = '\0';

+            if (local_98->LEOriginalAddressType != 0xff) {

+              uVar27 = local_98->LEOriginalAddressType;

+            }

+            if (uVar27 == '\0') goto LAB_22;

+          }

+          if ((((local_98->SmpDevInfo).Flag & 8) == 0) ||

+             ((local_98->SmpDevInfo).AddressInformationType != '\0')) goto LAB_21;

+          local_58 = (local_98->SmpDevInfo).AddressInformation;

+        }

+      }

+LAB_22:

+      pHVar28 = (HCI_INTERFACE *)(local_88 + 9);

+      if (param_9 != HciPhyTypeBR) {

+        pHVar28 = pHVar29;

+      }

+      local_88[9] = 0;

+      pDVar25 = HCI_DibCreate(param_1,&local_58,(uchar *)pHVar28);

+      local_88._0_8_ = pDVar25;

+      if (pDVar25 != (DEVICE_INFO_BLOCK *)0x0) {

+        HCI_DibPopulateDefaultContainerIds(pDVar25);

+        if (param_10 == (_GUID *)0x0) {

+          (pDVar25->ActivityId).Data1 = 0;

+          (pDVar25->ActivityId).Data2 = 0;

+          (pDVar25->ActivityId).Data3 = 0;

+          (pDVar25->ActivityId).Data4[0] = '\0';

+          (pDVar25->ActivityId).Data4[1] = '\0';

+          (pDVar25->ActivityId).Data4[2] = '\0';

+          (pDVar25->ActivityId).Data4[3] = '\0';

+          (pDVar25->ActivityId).Data4[4] = '\0';

+          (pDVar25->ActivityId).Data4[5] = '\0';

+          (pDVar25->ActivityId).Data4[6] = '\0';

+          (pDVar25->ActivityId).Data4[7] = '\0';

+        }

+        else {

+          uVar12 = param_10->Data2;

+          uVar13 = param_10->Data3;

+          uVar30 = *(undefined8 *)param_10->Data4;

+          (pDVar25->ActivityId).Data1 = param_10->Data1;

+          (pDVar25->ActivityId).Data2 = uVar12;

+          (pDVar25->ActivityId).Data3 = uVar13;

+          *(undefined8 *)(pDVar25->ActivityId).Data4 = uVar30;

+        }

+        param_1->NumDevices = param_1->NumDevices + 1;

+        p_Var31 = (param_1->DeviceList).Blink;

+        piVar20 = &pDVar25->ListEntry;

+        pHVar28 = param_1;

+        uVar38 = 0;

+        if (p_Var31->Flink != &param_1->DeviceList) goto LAB_9;

+        *(_LIST_ENTRY **)&piVar20->field_0x0 = &param_1->DeviceList;

+        pHVar37 = (HCI_INTERFACE *)&DAT_0;

+        *(_LIST_ENTRY **)&(pDVar25->ListEntry).field_0x8 = p_Var31;

+        p_Var31->Flink = (_LIST_ENTRY *)piVar20;

+        (param_1->DeviceList).Blink = (_LIST_ENTRY *)piVar20;

+      }

+    }

+    uVar38 = uVar33;

+    if (pDVar25 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_8;

+    param_3 = (uchar *)pHVar29;

+    if ((((local_7c & Update) != None) &&

+        (param_3 = (uchar *)(HCI_INTERFACE *)0x0,

+        param_4 !=

+        (_func_ulong_HCI_INTERFACE_ptr_DEVICE_INFO_BLOCK_ptr__HCI_PHY_TYPE_void_ptr_LinkedDibAction_ptr

+         *)0x0)) && (param_5 != (void *)0x0)) {

+      uVar33 = (pDVar25->DeviceInfo).classOfDevice;

+      uVar38 = (pDVar25->DeviceInfo).flags;

+      uVar17 = (*param_4)(param_1,pDVar25,param_9 == HciPhyTypeBR,param_5,(LinkedDibAction *)0x0);

+      param_3 = (uchar *)(ulonglong)uVar17;

+      if ((pDVar25->DeviceInfo).classOfDevice != uVar33) {

+        HCI_DibUpdateExFlagsForCodLocked(param_1,pDVar25);

+      }

+      pDVar25->LastConnectionStatus = 0xff;

+      pDVar25->LastInquiryScan = param_1->CountInquiryScan;

+    }

+    if ((char)pHVar37 != '\0') {

+      bVar39 = param_9 != HciPhyTypeBR;

+      param_9 = -param_9;

+      (pDVar25->DeviceInfo).flags =

+           (pDVar25->DeviceInfo).flags | (-(uint)bVar39 & 0xffffc000) + 0x8000;

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (cVar36 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+        cVar36 = '\0';

+      }

+      if ((cVar36 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+        WPP_RECORDER_AND_TRACE_SF_qq

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar36,

+                   *(short *)(WPP_GLOBAL_Control + 0x48) != 0,param_1->IfrLog);

+      }

+      pDVar22 = local_98;

+      p_Var31 = &param_1->DeviceList;

+      if (local_98 == (DEVICE_INFO_BLOCK *)0x0) {

+        if (pDVar25->LinkedDibAddress == 0) goto LAB_23;

+        pDVar22 = HCI_FindLinkedDib(p_Var31,pDVar25);

+        pDVar25->LinkedDibAddress = 0;

+        pDVar25->LinkedDibAddressType = '\0';

+        if (pDVar22 != (DEVICE_INFO_BLOCK *)0x0) {

+          pDVar22->LinkedDibAddress = 0;

+          pDVar22->LinkedDibAddressType = '\0';

+        }

+      }

+      else {

+        if (pDVar25->LinkedDibAddress != 0) {

+          if (pDVar25->LinkedDibAddress == (local_98->DeviceInfo).address) {

+            if (((local_98->DeviceInfo).flags & 0x8000) == 0) {

+              uVar27 = 0xff;

+            }

+            else {

+              pHVar28 = pHVar29;

+              if (local_98->LEOriginalAddressType != 0xff) {

+                pHVar28 = (HCI_INTERFACE *)(ulonglong)local_98->LEOriginalAddressType;

+              }

+              uVar27 = (uchar)pHVar28;

+            }

+            if (((pDVar25->LinkedDibAddressType == uVar27) && (local_98->LinkedDibAddress != 0)) &&

+               (local_98->LinkedDibAddress == (pDVar25->DeviceInfo).address)) {

+              if (((pDVar25->DeviceInfo).flags & 0x8000) == 0) {

+                uVar27 = 0xff;

               }

               else {

-                uVar23 = uVar26;

-                if (unaff_R14->LEOriginalAddressType != 0xff) {

-                  uVar23 = unaff_R14->LEOriginalAddressType;

+                pHVar28 = pHVar29;

+                if (pDVar25->LEOriginalAddressType != 0xff) {

+                  pHVar28 = (HCI_INTERFACE *)(ulonglong)pDVar25->LEOriginalAddressType;

                 }

-              }

-              if (pDVar19->LinkedDibAddressType == uVar23) goto LAB_16;

-            }

-            pDVar20 = HCI_FindLinkedDib(p_Var25,pDVar19);

-            pDVar19->LinkedDibAddress = (ulong64)unaff_RDI;

-            pDVar19->LinkedDibAddressType = uVar26;

-            if (pDVar20 != (DEVICE_INFO_BLOCK *)0x0) {

-              pDVar20->LinkedDibAddress = (ulong64)unaff_RDI;

-              pDVar20->LinkedDibAddressType = uVar26;

-            }

-          }

-LAB_16:

-          unaff_R14->LinkedDibAddress = (pDVar19->DeviceInfo).address;

-          if (((pDVar19->DeviceInfo).flags >> 0xf & 1) == 0) {

-            uVar23 = 0xff;

-          }

-          else {

-            uVar23 = uVar26;

-            if (pDVar19->LEOriginalAddressType != 0xff) {

-              uVar23 = pDVar19->LEOriginalAddressType;

-            }

-          }

-          uVar11 = (unaff_R14->DeviceInfo).address;

-          unaff_R14->LinkedDibAddressType = uVar23;

-          pDVar19->LinkedDibAddress = uVar11;

-          if (((unaff_R14->DeviceInfo).flags >> 0xf & 1) == 0) {

-            uVar23 = 0xff;

-          }

-          else {

-            uVar23 = uVar26;

-            if (unaff_R14->LEOriginalAddressType != 0xff) {

-              uVar23 = unaff_R14->LEOriginalAddressType;

-            }

-          }

-          pDVar19->LinkedDibAddressType = uVar23;

-        }

-        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

-           (uVar21 = 1, (byte)WPP_GLOBAL_Control[0x29] < 5)) {

-          uVar21 = (ulonglong)unaff_RDI & 0xff;

-        }

-        if (((char)uVar21 == '\0') && (*(short *)(WPP_GLOBAL_Control + 0x48) == 0)) {

-          unaff_RBX = *(HCI_INTERFACE **)(unaff_RBP + 0x47);

+                uVar27 = (uchar)pHVar28;

+              }

+              if (local_98->LinkedDibAddressType == uVar27) goto LAB_23;

+            }

+            if (((local_98->DeviceInfo).flags & 0x8000) == 0) {

+              uVar27 = 0xff;

+            }

+            else {

+              pHVar28 = pHVar29;

+              if (local_98->LEOriginalAddressType != 0xff) {

+                pHVar28 = (HCI_INTERFACE *)(ulonglong)local_98->LEOriginalAddressType;

+              }

+              uVar27 = (uchar)pHVar28;

+            }

+            if (pDVar25->LinkedDibAddressType == uVar27) goto LAB_24;

+          }

+          pDVar26 = HCI_FindLinkedDib(p_Var31,pDVar25);

+          pDVar25->LinkedDibAddress = 0;

+          pDVar25->LinkedDibAddressType = '\0';

+          if (pDVar26 != (DEVICE_INFO_BLOCK *)0x0) {

+            pDVar26->LinkedDibAddress = 0;

+            pDVar26->LinkedDibAddressType = '\0';

+          }

+        }

+LAB_24:

+        if (pDVar22->LinkedDibAddress != 0) {

+          if (pDVar22->LinkedDibAddress == (pDVar25->DeviceInfo).address) {

+            if (((pDVar25->DeviceInfo).flags & 0x8000) == 0) {

+              uVar27 = 0xff;

+            }

+            else {

+              pHVar28 = pHVar29;

+              if (pDVar25->LEOriginalAddressType != 0xff) {

+                pHVar28 = (HCI_INTERFACE *)(ulonglong)pDVar25->LEOriginalAddressType;

+              }

+              uVar27 = (uchar)pHVar28;

+            }

+            if (pDVar22->LinkedDibAddressType == uVar27) goto LAB_25;

+          }

+          pDVar26 = HCI_FindLinkedDib(p_Var31,pDVar22);

+          pDVar22->LinkedDibAddress = 0;

+          pDVar22->LinkedDibAddressType = '\0';

+          if (pDVar26 != (DEVICE_INFO_BLOCK *)0x0) {

+            pDVar26->LinkedDibAddress = 0;

+            pDVar26->LinkedDibAddressType = '\0';

+          }

+        }

+LAB_25:

+        pDVar25->LinkedDibAddress = (pDVar22->DeviceInfo).address;

+        if (((pDVar22->DeviceInfo).flags >> 0xf & 1) == 0) {

+          uVar27 = 0xff;

         }

         else {

-          unaff_RBX = *(HCI_INTERFACE **)(unaff_RBP + 0x47);

-          WPP_RECORDER_AND_TRACE_SF_qq

-                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar21,

-                     *(short *)(WPP_GLOBAL_Control + 0x48) != 0,unaff_RBX->IfrLog,5);

-        }

-        pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-      }

-LAB_14:

-      if (((int)unaff_R15 == 0) || (unaff_RBX->CacheEntryDisposableLimit <= uVar17))

-      goto LAB_10;

-      uVar17 = (unaff_R14->DeviceInfo).flags;

-      if ((((uVar17 >> 0xe & 1) == 0) ||

-          ((DEVICE_INFO_BLOCK **)unaff_R14->LinkedDibAddress != unaff_RDI)) &&

-         (((unaff_R15 = &DAT_6, (uVar17 & 0x1030038) == 0 &&

-           (paVar4 = &unaff_R14->DibFlags, unaff_R14 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49),

-           ((ulonglong)*paVar4 & 8) == 0)) &&

-          ((intrusive_list_hook *)*(undefined1 **)&unaff_R14->ListEntry != &unaff_R14->ListEntry))))

-      {

-        pDVar19 = HCI_FindLinkedDib(&unaff_R14->Hci->DeviceList,unaff_R14);

-        if ((pDVar19 == (DEVICE_INFO_BLOCK *)0x0) ||

-           ((((uVar17 = (pDVar19->DeviceInfo).flags, (uVar17 >> 0xe & 1) == 0 ||

-              ((DEVICE_INFO_BLOCK **)pDVar19->LinkedDibAddress != unaff_RDI)) &&

-             ((uVar17 & 0x1030038) == 0)) &&

-            (unaff_R14 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49),

-            ((ulonglong)pDVar19->DibFlags & 8) == 0)))) {

-          piVar1 = &unaff_R14->DisposableListEntry;

-          puVar9 = *(undefined1 **)piVar1;

-          if ((intrusive_list_hook *)puVar9 == piVar1) {

-            puVar2 = &unaff_R14->Hci->NumberOfDisposableDevices;

-            *puVar2 = *puVar2 + 1;

-          }

-          else {

-            if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

-               (puVar10 = *(undefined8 **)&(unaff_R14->DisposableListEntry).field_0x8,

-               (intrusive_list_hook *)*puVar10 != piVar1)) goto LAB_0;

-            *puVar10 = puVar9;

-            *(undefined8 **)(puVar9 + 8) = puVar10;

-            *(intrusive_list_hook **)&(unaff_R14->DisposableListEntry).field_0x8 = piVar1;

-            *(intrusive_list_hook **)piVar1 = piVar1;

-          }

-          p_Var24 = &unaff_R14->Hci->DisposableDeviceList;

-          p_Var25 = p_Var24->Flink;

-          if (p_Var25->Blink != p_Var24) goto LAB_0;

-          *(_LIST_ENTRY **)piVar1 = p_Var25;

-          *(_LIST_ENTRY **)&(unaff_R14->DisposableListEntry).field_0x8 = p_Var24;

-          p_Var25->Blink = (_LIST_ENTRY *)piVar1;

-          p_Var24->Flink = (_LIST_ENTRY *)piVar1;

-          if (pDVar19 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_17;

-        }

-        piVar1 = &pDVar19->DisposableListEntry;

-        puVar9 = *(undefined1 **)piVar1;

-        if ((intrusive_list_hook *)puVar9 != piVar1) {

-          if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) == piVar1) &&

-             (plVar8 = *(longlong **)&(pDVar19->DisposableListEntry).field_0x8,

-             (intrusive_list_hook *)*plVar8 == piVar1)) {

-            *plVar8 = (longlong)puVar9;

-            *(longlong **)(puVar9 + 8) = plVar8;

-            *(intrusive_list_hook **)&(pDVar19->DisposableListEntry).field_0x8 = piVar1;

-            *(intrusive_list_hook **)piVar1 = piVar1;

-            p_Var24 = &pDVar19->Hci->DisposableDeviceList;

-            p_Var25 = p_Var24->Flink;

-            if (p_Var25->Blink == p_Var24) {

-              *(_LIST_ENTRY **)piVar1 = p_Var25;

-              *(_LIST_ENTRY **)&(pDVar19->DisposableListEntry).field_0x8 = p_Var24;

-              p_Var25->Blink = (_LIST_ENTRY *)piVar1;

-              p_Var24->Flink = (_LIST_ENTRY *)piVar1;

-              goto LAB_17;

-            }

-          }

-          goto LAB_0;

+          pHVar28 = pHVar29;

+          if (pDVar22->LEOriginalAddressType != 0xff) {

+            pHVar28 = (HCI_INTERFACE *)(ulonglong)pDVar22->LEOriginalAddressType;

+          }

+          uVar27 = (uchar)pHVar28;

+        }

+        uVar7 = (pDVar25->DeviceInfo).address;

+        pDVar25->LinkedDibAddressType = uVar27;

+        pDVar22->LinkedDibAddress = uVar7;

+        if (((pDVar25->DeviceInfo).flags >> 0xf & 1) == 0) {

+          uVar27 = 0xff;

+        }

+        else {

+          if (pDVar25->LEOriginalAddressType != 0xff) {

+            pHVar29 = (HCI_INTERFACE *)(ulonglong)pDVar25->LEOriginalAddressType;

+          }

+          uVar27 = (uchar)pHVar29;

+        }

+        pDVar22->LinkedDibAddressType = uVar27;

+      }

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (cVar36 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+        cVar36 = '\0';

+      }

+      if ((cVar36 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+        WPP_RECORDER_AND_TRACE_SF_qq

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar36,

+                   *(short *)(WPP_GLOBAL_Control + 0x48) != 0);

+      }

+    }

+LAB_23:

+    uVar30 = local_88._0_8_;

+    if (((int)param_3 == 0) || (param_1->CacheEntryDisposableLimit == 0)) goto LAB_8;

+    uVar18 = (pDVar25->DeviceInfo).flags;

+    if ((((uVar18 >> 0xe & 1) == 0) || (pDVar25->LinkedDibAddress != 0)) &&

+       (((param_3 = &DAT_17, (uVar18 & 0x1030038) == 0 &&

+         (paVar2 = &pDVar25->DibFlags, pDVar25 = (DEVICE_INFO_BLOCK *)local_88._0_8_,

+         ((ulonglong)*paVar2 & 8) == 0)) &&

+        ((intrusive_list_hook *)*(undefined1 **)(local_88._0_8_ + 0x340) !=

+         (intrusive_list_hook *)(local_88._0_8_ + 0x340))))) {

+      pDVar22 = HCI_FindLinkedDib(&(*(HCI_INTERFACE **)(local_88._0_8_ + 0x378))->DeviceList,

+                                  (DEVICE_INFO_BLOCK *)local_88._0_8_);

+      pDVar25 = (DEVICE_INFO_BLOCK *)uVar30;

+      if ((pDVar22 == (DEVICE_INFO_BLOCK *)0x0) ||

+         ((((uVar18 = (pDVar22->DeviceInfo).flags, (uVar18 >> 0xe & 1) == 0 ||

+            (pDVar22->LinkedDibAddress != 0)) && ((uVar18 & 0x1030038) == 0)) &&

+          (pDVar25 = (DEVICE_INFO_BLOCK *)local_88._0_8_, ((ulonglong)pDVar22->DibFlags & 8) == 0)))

+         ) {

+        piVar20 = &pDVar25->DisposableListEntry;

+        puVar32 = *(undefined1 **)piVar20;

+        if ((intrusive_list_hook *)puVar32 == piVar20) {

+          puVar1 = &pDVar25->Hci->NumberOfDisposableDevices;

+          *puVar1 = *puVar1 + 1;

+        }

+        else {

+          pHVar28 = param_1;

+          if (((intrusive_list_hook *)*(undefined1 **)(puVar32 + 8) != piVar20) ||

+             (plVar6 = *(longlong **)&(pDVar25->DisposableListEntry).field_0x8,

+             (intrusive_list_hook *)*plVar6 != piVar20)) goto LAB_9;

+          *plVar6 = (longlong)puVar32;

+          *(longlong **)(puVar32 + 8) = plVar6;

+          *(intrusive_list_hook **)&(pDVar25->DisposableListEntry).field_0x8 = piVar20;

+          *(intrusive_list_hook **)piVar20 = piVar20;

+        }

+        p_Var24 = &pDVar25->Hci->DisposableDeviceList;

+        p_Var31 = p_Var24->Flink;

+        pHVar28 = param_1;

+        if (p_Var31->Blink == p_Var24) {

+          *(_LIST_ENTRY **)piVar20 = p_Var31;

+          *(_LIST_ENTRY **)&(pDVar25->DisposableListEntry).field_0x8 = p_Var24;

+          p_Var31->Blink = (_LIST_ENTRY *)piVar20;

+          p_Var24->Flink = (_LIST_ENTRY *)piVar20;

+          if (pDVar22 == (DEVICE_INFO_BLOCK *)0x0) goto LAB_26;

+          goto LAB_27;

         }

       }

       else {

-        piVar1 = &unaff_R14->DisposableListEntry;

-        puVar9 = *(undefined1 **)piVar1;

-        if ((intrusive_list_hook *)puVar9 != piVar1) {

-          if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

-             (plVar8 = *(longlong **)&(unaff_R14->DisposableListEntry).field_0x8,

-             (intrusive_list_hook *)*plVar8 != piVar1)) goto LAB_0;

-          *plVar8 = (longlong)puVar9;

-          *(longlong **)(puVar9 + 8) = plVar8;

-          *(intrusive_list_hook **)&(unaff_R14->DisposableListEntry).field_0x8 = piVar1;

-          *(intrusive_list_hook **)piVar1 = piVar1;

-          uVar7 = unaff_R14->Hci->NumberOfDisposableDevices;

-          if (uVar7 != 0) {

-            unaff_R14->Hci->NumberOfDisposableDevices = uVar7 - 1;

-          }

-        }

-        pDVar19 = HCI_FindLinkedDib(&unaff_R14->Hci->DeviceList,unaff_R14);

-        if (pDVar19 != (DEVICE_INFO_BLOCK *)0x0) {

-          piVar1 = &pDVar19->DisposableListEntry;

-          puVar9 = *(undefined1 **)piVar1;

-          if ((intrusive_list_hook *)puVar9 != piVar1) {

-            if (((intrusive_list_hook *)*(undefined1 **)(puVar9 + 8) != piVar1) ||

-               (plVar8 = *(longlong **)&(pDVar19->DisposableListEntry).field_0x8,

-               (intrusive_list_hook *)*plVar8 != piVar1)) goto LAB_0;

-            *plVar8 = (longlong)puVar9;

-            *(longlong **)(puVar9 + 8) = plVar8;

-            *(intrusive_list_hook **)&(pDVar19->DisposableListEntry).field_0x8 = piVar1;

-            *(intrusive_list_hook **)piVar1 = piVar1;

-            uVar7 = pDVar19->Hci->NumberOfDisposableDevices;

-            if (uVar7 != 0) {

-              pDVar19->Hci->NumberOfDisposableDevices = uVar7 - 1;

-            }

-          }

-        }

-      }

-LAB_17:

-      if (*(uchar *)(unaff_RBP + 0x7f) != uVar26) goto LAB_18;

-      if (*(uchar *)(unaff_RBP + 0x97) != uVar26) {

-        HCI_DibProcessDisposableListLocked(unaff_RBX,(_LIST_ENTRY *)(unaff_RBP + -0x31));

-        pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-        goto LAB_10;

-      }

-    }

-    cVar28 = (char)unaff_R12;

-    *(longlong *)(unaff_RBP + -0x11) = unaff_RBP + -0x59;

-    *(longlong *)(unaff_RBP + -9) = unaff_RBP + 0x6f;

-    *(longlong *)(unaff_RBP + -1) = unaff_RBP + -0x51;

-    bVar16 = <lambda_2f6ada26788a492a80764fb6f2f9f8fb>::operator()(unaff_RBP + -0x11);

-    unaff_R15 = *(undefined1 **)(unaff_RBP + 0x47);

-    unaff_RBX = (HCI_INTERFACE *)(ulonglong)bVar16;

-    KeReleaseSpinLock(unaff_R15 + 0x7b0);

-    if (*(uchar *)(unaff_RBP + 0x97) != uVar26) {

-      while (plVar8 = *(longlong **)(unaff_RBP + -0x31), plVar8 != (longlong *)(unaff_RBP + -0x31))

-      {

-        if ((plVar8[1] != unaff_RBP + -0x31) ||

-           (lVar22 = *plVar8, *(longlong **)(lVar22 + 8) != plVar8)) goto LAB_0;

-        *(longlong *)(unaff_RBP + -0x31) = lVar22;

-        *(longlong *)(lVar22 + 8) = unaff_RBP + -0x31;

-        plVar8[1] = (longlong)plVar8;

-        *plVar8 = (longlong)plVar8;

-        RefObj_ReleaseEx(plVar8 + -0x68,plVar8 + -0x68,0x1f1d);

-      }

-    }

-  }

-  else {

-LAB_0:

-    cVar28 = (char)unaff_R12;

-    bVar16 = (byte)unaff_RBX;

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

-    (*pcVar14)(3);

-    register0x00000020 = (BADSPACEBASE *)local_res8;

-  }

-  pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-  if (pDVar19 == (DEVICE_INFO_BLOCK *)0x0) {

-LAB_19:

-    lVar22 = *(longlong *)(unaff_RBP + 0x67);

-  }

-  else {

-    if (bVar16 != 0) {

-      uVar12 = ((_BTH_DEVICE_INFO_V2 *)&pDVar19->DeviceInfo)->address;

-      uVar13 = *(undefined8 *)(*(longlong *)(unaff_R15 + 0x4a8) + 8);

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

-      uVar17 = BthQueryDeviceCompatFlags(uVar12,0,uVar13);

-      if ((uVar17 & 0x7fb) != 0) {

-        *(uint *)(*(longlong *)(unaff_RBP + -0x59) + 0x28) =

-             *(uint *)(*(longlong *)(unaff_RBP + -0x59) + 0x28) & 0xff001fff | uVar17 << 0xd;

-      }

-      pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-    }

-    if (*(longlong *)(unaff_RBP + 0x67) != 0) {

-      if (*(uchar *)(unaff_RBP + 0x4f) == uVar26) {

-        uVar7 = *(ulong *)(unaff_RBP + -0x39);

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

-        HCI_DibReportDeviceChange(pDVar19,uVar7,true,false);

-        pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

+LAB_27:

+        piVar20 = &pDVar22->DisposableListEntry;

+        puVar32 = *(undefined1 **)piVar20;

+        if ((intrusive_list_hook *)puVar32 == piVar20) goto LAB_26;

+        pHVar28 = param_1;

+        if (((intrusive_list_hook *)*(undefined1 **)(puVar32 + 8) == piVar20) &&

+           (plVar6 = *(longlong **)&(pDVar22->DisposableListEntry).field_0x8,

+           (intrusive_list_hook *)*plVar6 == piVar20)) {

+          *plVar6 = (longlong)puVar32;

+          *(longlong **)(puVar32 + 8) = plVar6;

+          *(intrusive_list_hook **)&(pDVar22->DisposableListEntry).field_0x8 = piVar20;

+          *(intrusive_list_hook **)piVar20 = piVar20;

+          p_Var24 = &pDVar22->Hci->DisposableDeviceList;

+          p_Var31 = p_Var24->Flink;

+          if (p_Var31->Blink == p_Var24) {

+            *(_LIST_ENTRY **)piVar20 = p_Var31;

+            *(_LIST_ENTRY **)&(pDVar22->DisposableListEntry).field_0x8 = p_Var24;

+            p_Var31->Blink = (_LIST_ENTRY *)piVar20;

+            p_Var24->Flink = (_LIST_ENTRY *)piVar20;

+            goto LAB_26;

+          }

+        }

+      }

+LAB_9:

+      cVar36 = (char)pHVar37;

+      bVar15 = (byte)pHVar28;

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

+      (*pcVar9)(3);

+      puVar32 = auStackY_110;

+      param_1 = (HCI_INTERFACE *)param_3;

+      goto LAB_28;

+    }

+    piVar20 = &pDVar25->DisposableListEntry;

+    puVar32 = *(undefined1 **)piVar20;

+    if ((intrusive_list_hook *)puVar32 != piVar20) {

+      pHVar28 = param_1;

+      if (((intrusive_list_hook *)*(undefined1 **)(puVar32 + 8) != piVar20) ||

+         (plVar6 = *(longlong **)&(pDVar25->DisposableListEntry).field_0x8,

+         (intrusive_list_hook *)*plVar6 != piVar20)) goto LAB_9;

+      *plVar6 = (longlong)puVar32;

+      *(longlong **)(puVar32 + 8) = plVar6;

+      *(intrusive_list_hook **)&(pDVar25->DisposableListEntry).field_0x8 = piVar20;

+      *(intrusive_list_hook **)piVar20 = piVar20;

+      uVar33 = pDVar25->Hci->NumberOfDisposableDevices;

+      if (uVar33 != 0) {

+        pDVar25->Hci->NumberOfDisposableDevices = uVar33 - 1;

+      }

+    }

+    pDVar22 = HCI_FindLinkedDib(&pDVar25->Hci->DeviceList,pDVar25);

+    if (pDVar22 != (DEVICE_INFO_BLOCK *)0x0) {

+      piVar20 = &pDVar22->DisposableListEntry;

+      puVar32 = *(undefined1 **)piVar20;

+      if ((intrusive_list_hook *)puVar32 != piVar20) {

+        pHVar28 = param_1;

+        if (((intrusive_list_hook *)*(undefined1 **)(puVar32 + 8) != piVar20) ||

+           (plVar6 = *(longlong **)&(pDVar22->DisposableListEntry).field_0x8,

+           (intrusive_list_hook *)*plVar6 != piVar20)) goto LAB_9;

+        *plVar6 = (longlong)puVar32;

+        *(longlong **)(puVar32 + 8) = plVar6;

+        *(intrusive_list_hook **)&(pDVar22->DisposableListEntry).field_0x8 = piVar20;

+        *(intrusive_list_hook **)piVar20 = piVar20;

+        uVar33 = pDVar22->Hci->NumberOfDisposableDevices;

+        if (uVar33 != 0) {

+          pDVar22->Hci->NumberOfDisposableDevices = uVar33 - 1;

+        }

+      }

+    }

+LAB_26:

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

+      return local_98;

+    }

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

+      HCI_DibProcessDisposableListLocked(param_1,&local_70);

+      goto LAB_8;

+    }

+  }

+  cVar36 = (char)pHVar37;

+  local_50 = &local_98;

+  local_48 = &param_6;

+  local_40 = local_90;

+  bVar15 = <lambda_2f6ada26788a492a80764fb6f2f9f8fb>::operator()(&local_50);

+  KeReleaseSpinLock(&param_1->HciLock);

+  puVar32 = auStackY_118;

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

+    while (puVar32 = auStackY_118, local_70.Flink != &local_70) {

+      pHVar28 = (HCI_INTERFACE *)(ulonglong)bVar15;

+      param_3 = (uchar *)param_1;

+      if (((local_70.Flink)->Blink != &local_70) ||

+         (p_Var31 = (local_70.Flink)->Flink, p_Var31->Blink != local_70.Flink)) goto LAB_9;

+      p_Var31->Blink = &local_70;

+      p_Var24 = local_70.Flink + -0x34;

+      (local_70.Flink)->Blink = local_70.Flink;

+      (local_70.Flink)->Flink = local_70.Flink;

+      local_70.Flink = p_Var31;

+      RefObj_ReleaseEx(p_Var24,p_Var24,0x1f1d);

+    }

+  }

+LAB_28:

+  if (local_98 != (DEVICE_INFO_BLOCK *)0x0) {

+    if (bVar15 != 0) {

+      uVar7 = (local_98->DeviceInfo).address;

+      p_Var8 = (param_1->DevExt->BtDevice).FunctionalDeviceObject;

+      *(undefined8 *)(puVar32 + -8) = 0x140067024;

+      uVar18 = BthQueryDeviceCompatFlags(uVar7,0,p_Var8);

+      if ((uVar18 & 0x7fb) != 0) {

+        (local_98->DeviceInfo).classOfDevice =

+             (local_98->DeviceInfo).classOfDevice & 0xff001fff | uVar18 << 0xd;

+      }

+    }

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

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

+        *(undefined8 *)(puVar32 + -8) = 0x1400670c5;

+        HCI_DibReportDeviceChange(local_98,local_78,true,false);

       }

       else {

         LOCK();

-        iVar5 = pDVar19->DeviceChangeStatus;

-        pDVar19->DeviceChangeStatus = 2;

+        iVar3 = local_98->DeviceChangeStatus;

+        local_98->DeviceChangeStatus = 2;

         UNLOCK();

-        if (iVar5 == 1) {

-          pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

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

-          HCI_DibReportDeviceChange(pDVar19,0,true,false);

-          pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-          unaff_R14 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49);

-        }

-        else {

-          pDVar19 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

-          unaff_R14 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49);

-        }

-      }

-      goto LAB_19;

-    }

-    lVar22 = 0;

-  }

-  if (unaff_R14 == (DEVICE_INFO_BLOCK *)0x0) {

-    return (DEVICE_INFO_BLOCK *)pDVar19;

-  }

-  if (lVar22 == 0) {

-    return (DEVICE_INFO_BLOCK *)pDVar19;

-  }

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

-    LOCK();

-    iVar5 = unaff_R14->DeviceChangeStatus;

-    unaff_R14->DeviceChangeStatus = 2;

-    UNLOCK();

-    if (iVar5 != 1) goto LAB_18;

-    unaff_R14 = *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x49);

-    unaff_R13D = 0;

-  }

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

-  HCI_DibReportDeviceChange(unaff_R14,unaff_R13D,true,false);

-LAB_18:

-  return *(DEVICE_INFO_BLOCK **)(unaff_RBP + -0x59);

+        pDVar25 = (DEVICE_INFO_BLOCK *)local_88._0_8_;

+        if (iVar3 == 1) {

+          *(undefined8 *)(puVar32 + -8) = 0x140067076;

+          HCI_DibReportDeviceChange(local_98,0,true,false);

+          pDVar25 = (DEVICE_INFO_BLOCK *)local_88._0_8_;

+        }

+      }

+    }

+  }

+  if ((pDVar25 != (DEVICE_INFO_BLOCK *)0x0) && (param_5 != (void *)0x0)) {

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

+      LOCK();

+      iVar3 = pDVar25->DeviceChangeStatus;

+      pDVar25->DeviceChangeStatus = 2;

+      UNLOCK();

+      if (iVar3 != 1) {

+        return local_98;

+      }

+      uVar38 = 0;

+      pDVar25 = (DEVICE_INFO_BLOCK *)local_88._0_8_;

+    }

+    *(undefined8 *)(puVar32 + -8) = 0x1400670e3;

+    HCI_DibReportDeviceChange(pDVar25,uVar38,true,false);

+  }

+  return local_98;

 }
```

## `HCI_PostRadioInit`  (modified)

```diff
--- HCI_PostRadioInit
+++ HCI_PostRadioInit
@@ -1,488 +1,400 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl HCI_PostRadioInit(struct HCI_INTERFACE * __ptr64) */

 

 void __cdecl HCI_PostRadioInit(HCI_INTERFACE *param_1)

 

 {

-  _BTH_INQUIRY_SUPPORT_LEVEL _Var1;

-  DEVICE_EXTENSION *pDVar2;

-  undefined4 uVar3;

-  undefined4 uVar4;

-  undefined4 uVar5;

-  undefined4 uVar6;

-  undefined1 uVar7;

-  ushort uVar8;

-  long lVar9;

-  _BTH_SECURITY_LEVEL _Var10;

-  int iVar11;

-  void *pvVar12;

-  ulonglong uVar13;

-  int in_EDX;

-  undefined8 uVar14;

-  ulonglong uVar15;

-  uchar *puVar16;

-  undefined1 uVar17;

-  ulong64 *puVar18;

-  ulonglong uVar19;

-  HCI_INTERFACE *unaff_RDI;

-  longlong in_R8;

-  longlong unaff_R14;

-  bool in_ZF;

-  uchar uVar20;

-  char in_SF;

-  char in_OF;

-  uint uStack0000000000000040;

+  ulong64 *puVar1;

+  uint uVar2;

+  AvdtpOffload *pAVar3;

+  uchar uVar4;

+  char cVar5;

+  bool bVar6;

+  char cVar7;

+  int iVar8;

+  ulonglong uVar9;

+  _BIP *p_Var10;

+  _SCO_INTERFACE *p_Var11;

+  DEVICE_EXTENSION *pDVar12;

+  DEVICE_EXTENSION *pDVar13;

+  ulong64 uVar14;

+  undefined8 uVar15;

+  undefined1 uVar16;

+  _GUID *in_R8;

+  _GUID *in_R9;

+  AvdtpOffload *local_res8;

+  _tlgWrapperByVal<1> local_res10 [8];

+  _tlgWrapperByVal<1> local_res18 [8];

+  _tlgWrapperByVal<1> local_res20 [8];

+  undefined8 in_stack_fffffffffffffe20;

+  undefined4 uVar17;

+  ulonglong in_stack_fffffffffffffe28;

+  ushort local_108;

+  ushort local_106;

+  ushort local_104;

+  ushort local_102;

+  ushort local_100 [2];

+  ulong local_fc;

+  uint local_f8;

+  uint local_f4;

+  uint local_f0;

+  uint local_ec;

+  uint local_e8;

+  ulong local_e4;

+  ulong64 local_e0;

+  FeatureOptInFlags local_d8;

+  ulong64 local_d0;

+  FeatureOptInFlags local_c8;

+  ulong64 local_c0;

+  ulong64 local_b8;

+  _GUID *local_b0 [2];

+  _GUID *local_a0 [2];

+  _tlgWrapperPtrSize local_90;

+  _tlgWrapperPtrSize local_80;

+  void *local_70;

+  undefined2 local_68;

+  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+  local_60 [32];

   

-  if (in_ZF || in_OF != in_SF) {

-    if (!in_ZF) {

-      if (in_EDX < 0xc1b) {

-        if (in_EDX == 0xc1a) {

-          uVar20 = '\0';

-          if (param_1->DevExt->LinkKeysHandle == (void *)0x0) {

-            pvVar12 = SecDB_GetLocalRadioLinkKeyHandle

-                                ((_SECURITY_DATABASE *)param_1,

-                                 &(param_1->LocalInfo).localInfo.address);

-            unaff_RDI->DevExt->LinkKeysHandle = pvVar12;

-            pDVar2 = unaff_RDI->DevExt;

-            if (pDVar2->LinkKeysHandle == (void *)0x0) {

-              if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

-                 (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

-                uVar14 = 0;

-              }

-              WPP_RECORDER_AND_TRACE_SF_

-                        (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,unaff_RDI->IfrLog,2);

-            }

-            else {

-              if ((unaff_RDI->LEEnabled != '\0') && (pDVar2->IsSmpEnabled != '\0')) {

-                lVar9 = SMPInt_RegUpdateLEMasterIRKOverride(pDVar2->Smp);

-                pDVar2 = unaff_RDI->DevExt;

-                if (lVar9 < 0) {

-                  lVar9 = SMPInt_RegUpdateLEMasterIRK(pDVar2->Smp,pDVar2->LinkKeysHandle);

-                  (unaff_RDI->DevExt->Smp->IRKInfo).IRKState = (uint)(-1 < lVar9);

-                }

-                else {

-                  (pDVar2->Smp->IRKInfo).IRKState = SMP_MASTER_IRK_STATE_OVERRIDE;

-                }

-              }

-              HCI_AddStoredDevices(unaff_RDI);

-            }

-          }

-          if (unaff_RDI->PageScanEnableCount != 0) {

-            uVar20 = (unaff_RDI->InquiryScanEnableCount != 0) + '\x02';

-          }

-          *(uchar *)(unaff_R14 + 3) = uVar20;

-          unaff_RDI->CurrentScanEnabled = uVar20;

-          return;

-        }

-        if (in_EDX == 0x80f) {

-          if (((param_1->SupportedCommandsMap).field0_0x0.RawMap[5] & 0x10) == 0) {

-            return;

-          }

-          *(undefined2 *)(in_R8 + 3) = 0xf;

-          return;

-        }

-        if (in_EDX == 0xc01) {

-          uVar15 = 0x400000000000;

-          uVar13 = (-(ulonglong)(param_1->NonFlushablePacketBoundaryFlagEnabled != '\0') &

-                   0x100000000000000) + 0x1fffffffffff;

-          uVar19 = uVar13 | 0x400000000000;

-          if (unaff_RDI->InquirySupportLevel != BthInquiryResultExtendedSupport) {

-            uVar19 = uVar13;

-          }

-          if (unaff_RDI->SimplePairingMode == '\x01') {

-            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

-               (uVar15 = 0x400000000001, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

-              uVar15 = uVar15 & 0xffffffffffffff00;

-            }

-            WPP_RECORDER_AND_TRACE_SF_

-                      (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar15,1,unaff_RDI->IfrLog,4);

-            uVar19 = uVar19 | 0x1dbf800000000000;

-          }

-          uVar13 = uVar19 | 0x200000000000;

-          if (unaff_RDI->SniffSubratingEnabled == '\0') {

-            uVar13 = uVar19;

-          }

-          uVar19 = uVar13 | 0x2000000000000000;

-          if (unaff_RDI->LEEnabled == '\0') {

-            uVar19 = uVar13;

-          }

-          *(ulonglong *)(unaff_R14 + 3) = uVar19;

-          return;

-        }

-        if (in_EDX == 0xc03) {

-          return;

-        }

-        if (in_EDX != 0xc13) {

-          if (in_EDX != 0xc18) {

-            return;

-          }

-          *(undefined2 *)(in_R8 + 3) = 0x2000;

-          return;

-        }

-        puVar18 = &param_1->HciLock;

-        uVar7 = KeAcquireSpinLockRaiseToDpc(puVar18);

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 8);

-        *(undefined8 *)(unaff_R14 + 3) = *(undefined8 *)(unaff_RDI->LocalInfo).localInfo.name;

-        *(undefined8 *)(unaff_R14 + 0xb) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x18);

-        *(undefined8 *)(unaff_R14 + 0x13) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x10);

-        *(undefined8 *)(unaff_R14 + 0x1b) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x28);

-        *(undefined8 *)(unaff_R14 + 0x23) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x20);

-        *(undefined8 *)(unaff_R14 + 0x2b) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x38);

-        *(undefined8 *)(unaff_R14 + 0x33) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x30);

-        *(undefined8 *)(unaff_R14 + 0x3b) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x48);

-        *(undefined8 *)(unaff_R14 + 0x43) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x40);

-        *(undefined8 *)(unaff_R14 + 0x4b) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x58);

-        *(undefined8 *)(unaff_R14 + 0x53) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x50);

-        *(undefined8 *)(unaff_R14 + 0x5b) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x68);

-        *(undefined8 *)(unaff_R14 + 99) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x60);

-        *(undefined8 *)(unaff_R14 + 0x6b) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x78);

-        *(undefined8 *)(unaff_R14 + 0x73) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x70);

-        *(undefined8 *)(unaff_R14 + 0x7b) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x88);

-        *(undefined8 *)(unaff_R14 + 0x83) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x80);

-        *(undefined8 *)(unaff_R14 + 0x8b) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x98);

-        *(undefined8 *)(unaff_R14 + 0x93) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0x90);

-        *(undefined8 *)(unaff_R14 + 0x9b) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0xa8);

-        *(undefined8 *)(unaff_R14 + 0xa3) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0xa0);

-        *(undefined8 *)(unaff_R14 + 0xab) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0xb8);

-        *(undefined8 *)(unaff_R14 + 0xb3) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0xb0);

-        *(undefined8 *)(unaff_R14 + 0xbb) = uVar14;

-        uVar14 = *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 200);

-        *(undefined8 *)(unaff_R14 + 0xc3) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0xc0);

-        *(undefined8 *)(unaff_R14 + 0xcb) = uVar14;

-        uVar3 = *(undefined4 *)((unaff_RDI->LocalInfo).localInfo.name + 0xd4);

-        uVar4 = *(undefined4 *)((unaff_RDI->LocalInfo).localInfo.name + 0xd8);

-        uVar5 = *(undefined4 *)((unaff_RDI->LocalInfo).localInfo.name + 0xdc);

-        *(undefined4 *)(unaff_R14 + 0xd3) =

-             *(undefined4 *)((unaff_RDI->LocalInfo).localInfo.name + 0xd0);

-        *(undefined4 *)(unaff_R14 + 0xd7) = uVar3;

-        *(undefined4 *)(unaff_R14 + 0xdb) = uVar4;

-        *(undefined4 *)(unaff_R14 + 0xdf) = uVar5;

-        uVar3 = *(undefined4 *)((unaff_RDI->LocalInfo).localInfo.name + 0xe4);

-        uVar4 = *(undefined4 *)((unaff_RDI->LocalInfo).localInfo.name + 0xe8);

-        uVar5 = *(undefined4 *)((unaff_RDI->LocalInfo).localInfo.name + 0xec);

-        *(undefined4 *)(unaff_R14 + 0xe3) =

-             *(undefined4 *)((unaff_RDI->LocalInfo).localInfo.name + 0xe0);

-        *(undefined4 *)(unaff_R14 + 0xe7) = uVar3;

-        *(undefined4 *)(unaff_R14 + 0xeb) = uVar4;

-        *(undefined4 *)(unaff_R14 + 0xef) = uVar5;

-        *(undefined8 *)(unaff_R14 + 0xf3) =

-             *(undefined8 *)((unaff_RDI->LocalInfo).localInfo.name + 0xf0);

-        uVar14 = CONCAT71((int7)((ulonglong)(unaff_R14 + 0x83) >> 8),uVar7);

-LAB_0:

-        KeReleaseSpinLock(puVar18,uVar14);

-        return;

+  uVar17 = (undefined4)((ulonglong)in_stack_fffffffffffffe20 >> 0x20);

+  pDVar13 = param_1->DevExt;

+  uVar16 = 0;

+  LOCK();

+  (param_1->CriticalCommandRetry).Count = 0;

+  UNLOCK();

+  cVar7 = '\0';

+  if (param_1->FirstTimeInit != '\0') {

+    in_R9 = (_GUID *)0x200;

+    cVar7 = '\x01';

+    uVar15 = CONCAT44(uVar17,0x54494348);

+    uVar2 = param_1->MaxBytesPerAclDataPacket;

+    if (param_1->MaxBytesPerAclDataPacket <= (uint)param_1->LEBufferSize) {

+      uVar2 = (uint)param_1->LEBufferSize;

+    }

+    in_R8 = (_GUID *)0x0;

+    ExInitializeNPagedLookasideList

+              (&param_1->WritePacketLookasideList,0,0,0x200,uVar2 + 4,uVar15,

+               in_stack_fffffffffffffe28 & 0xffffffffffff0000);

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

+    param_1->LookasideListInitialized = '\x01';

+    HCI_CacheDeviceAddress(param_1);

+    HCI_LoadRadioCompatibilitySettings(param_1);

+    HCI_StampLocalRadioProperties(param_1);

+    pDVar13->Hci->FirstTimeInit = '\0';

+  }

+  wil::acquire_kspin_lock((__uint64 *)local_a0);

+  if (param_1->ControllerState != Failed) {

+    param_1->ControllerState = Started;

+  }

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[1] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[2] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[3] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[4] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[5] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[6] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[7] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[8] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[9] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[10] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0xb] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0xc] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0xd] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0xe] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0xf] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x10] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x11] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x12] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x13] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x14] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x15] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x16] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x17] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x18] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x19] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x1a] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x1b] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x1c] = '\0';

+  param_1->LECurrentHighPriorityAdvertisingBuffer[0x1d] = '\0';

+  *(undefined4 *)(param_1->LECurrentHighPriorityAdvertisingBuffer + 0x1e) = 0;

+  *(undefined1 *)

+   ((longlong)&(param_1->LECurrentHighPriorityAdvertisingParameters).AdvertisementInterval + 1) = 0;

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[1] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[2] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[3] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[4] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[5] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[6] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[7] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[8] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[9] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[10] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0xb] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0xc] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0xd] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0xe] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0xf] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x10] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x11] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x12] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x13] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x14] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x15] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x16] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x17] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x18] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x19] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x1a] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x1b] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x1c] = '\0';

+  param_1->LECurrentLowPriorityAdvertisingBuffer[0x1d] = '\0';

+  *(undefined4 *)(param_1->LECurrentLowPriorityAdvertisingBuffer + 0x1e) = 0;

+  *(undefined1 *)

+   ((longlong)&(param_1->LECurrentLowPriorityAdvertisingParameters).AdvertisementInterval + 1) = 0;

+  param_1->LECurrentScanningState = '\0';

+  param_1->LECurrentScanType = '\0';

+  param_1->LECurrentScanningFilterPolicy = '\0';

+  (param_1->LECurrentScanningParameters).ScanWindow = 0;

+  (param_1->LECurrentScanningParameters).ScanInterval = 0;

+  pDVar12 = param_1->DevExt;

+  (param_1->VsMsftFilterInfo).ControllerAdvFilterState = '\x02';

+  uVar9 = pDVar12->HostSupportedFeatures;

+  if (param_1->LEEnabled == '\0') {

+    uVar9 = uVar9 & 0xfffffffffffffffb;

+  }

+  else {

+    uVar9 = uVar9 | 4;

+  }

+  pDVar12->HostSupportedFeatures = uVar9;

+  if (((param_1->SupportedCommandsMap).field0_0x0.RawMap[0x1d] & 8) != 0) {

+    puVar1 = &param_1->DevExt->HostSupportedFeatures;

+    *puVar1 = *puVar1 | 0x20;

+  }

+  pDVar12 = param_1->DevExt;

+  p_Var11 = pDVar12->Sco;

+  uVar4 = ScoInt_IsInBandSupported(p_Var11);

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

+    uVar4 = ScoInt_IsSideBandSupported(p_Var11);

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

+      pDVar12->HostSupportedFeatures = pDVar12->HostSupportedFeatures | 0x10;

+    }

+  }

+  else {

+    pDVar12->HostSupportedFeatures = pDVar12->HostSupportedFeatures | 8;

+  }

+  if ((param_1->DevExt->TransportCapabilities).ScoCanAlignData != '\0') {

+    puVar1 = &param_1->DevExt->HostSupportedFeatures;

+    *puVar1 = *puVar1 | 0x40;

+  }

+  wil::details::

+  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+  ::

+  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+              *)local_a0);

+  if (((param_1->VsMsftInfo).VsMsftDebugModeOn != '\0') ||

+     ((char)(param_1->VsMsftInfo).SupportedFeatures < '\0')) {

+    AvdtpOffload::Make();

+    pAVar3 = local_res8;

+    if (local_res8 == (AvdtpOffload *)0x0) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29]))

+      {

+        uVar16 = 1;

       }

-      if (in_EDX == 0xc1c) {

-        param_1->CurrentPageScanInterval = param_1->PassivePageScanInterval;

-        *(ushort *)(in_R8 + 3) = param_1->PassivePageScanInterval;

-        uVar8 = param_1->PassivePageScanWindow;

-        param_1->CurrentPageScanWindow = uVar8;

+      WPP_RECORDER_AND_TRACE_SF_

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar16,1,param_1->IfrLog,2,2,0x82,

+                 &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids);

+      Controller::OnControllerInitializationComplete

+                ((Controller *)&param_1->DevExt[-2].AvdtpOffload,false);

+      utl::

+      _UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+      ::

+      ~_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+                ((_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+                  *)&local_res8);

+      return;

+    }

+    wil::acquire_kspin_lock((__uint64 *)local_b0);

+    pDVar12 = param_1->DevExt;

+    if ((pDVar12->AvdtpOffload)._MyDat._MyRealVal == (AvdtpOffload *)0x0) {

+      local_res8 = (AvdtpOffload *)0x0;

+      (pDVar12->AvdtpOffload)._MyDat._MyRealVal = pAVar3;

+    }

+    else {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

+         (cVar5 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+        cVar5 = '\0';

       }

-      else {

-        if (in_EDX != 0xc1e) {

-          if (in_EDX != 0xc20) {

-            if (in_EDX == 0xc24) {

-              *(short *)(in_R8 + 3) = (short)(param_1->LocalInfo).localInfo.classOfDevice;

-              *(undefined1 *)(in_R8 + 5) =

-                   *(undefined1 *)((longlong)&(param_1->LocalInfo).localInfo.classOfDevice + 2);

-              return;

-            }

-            if (in_EDX != 0xc33) {

-              return;

-            }

-            *(ushort *)(in_R8 + 3) = param_1->MaxHostBytesPerAclDataPacket;

-            uVar20 = param_1->MaxHostBytesPerScoDataPacket;

-            *(undefined4 *)(in_R8 + 6) = 0xffffffff;

-            *(uchar *)(in_R8 + 5) = uVar20;

-            return;

-          }

-          _Var10 = SecDB_UpdateSecurityLevel(_Globals);

-          uVar20 = _Var10 == 2;

-          goto LAB_1;

-        }

-        *(ushort *)(in_R8 + 3) = param_1->InquiryScanInterval;

-        uVar8 = param_1->InquiryScanWindow;

+      in_R9 = (_GUID *)param_1->IfrLog;

+      in_R8 = (_GUID *)CONCAT71((int7)((ulonglong)in_R8 >> 8),1);

+      WPP_RECORDER_AND_TRACE_SF_i

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+                 CONCAT71((int7)((ulonglong)pDVar12 >> 8),cVar5),in_R8,in_R9,4,CONCAT44(uVar17,2),

+                 0x83,&WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids,pDVar12);

+    }

+    wil::details::

+    unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+    ::

+    ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+              ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+                *)local_b0);

+    utl::

+    _UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+    ::

+    ~_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+              ((_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+                *)&local_res8);

+  }

+  wil::acquire_kspin_lock((__uint64 *)local_60);

+  p_Var10 = HCI_GetNextCommand(param_1);

+  HCI_StartIdleTimer(param_1,'\x01');

+  wil::details::

+  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+  ::

+  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+            (local_60);

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

+    bVar6 = PowerCoordinator::IsIdlePowerDownCapable

+                      ((PowerCoordinator *)&pDVar13[1].BtDevice.PhysicalDeviceObject);

+    iVar8 = Feature_56664216__private_IsEnabledDeviceUsageNoInline();

+    if (iVar8 == 0) {

+      if ((4 < (uint)DAT_0) &&

+         (cVar7 = _tlgKeywordOn(&DAT_0,0x800000000111), cVar7 != '\0')) {

+        pDVar13 = param_1->DevExt;

+        uVar14 = (param_1->LocalInfo).localInfo.address;

+        local_res8 = (AvdtpOffload *)

+                     CONCAT71(local_res8._1_7_,

+                              (param_1->RadioCapacity).LESupportedMaxNumberOfAdvertisingSets);

+        local_a0[0] = (_GUID *)(param_1->VsMsftInfo).SupportedFeatures;

+        local_b8 = uVar14;

+        local_e4 = ErrorRecovery::GetSupportedResetTypes(&pDVar13->ErrorRecoveryHandler);

+        uVar2 = (param_1->LocalInfo).localInfo.classOfDevice;

+        local_e8 = (uint)(param_1->VsMsftInfo).tlvTelemetryEnabled;

+        local_c0 = pDVar13->HostSupportedFeatures;

+        local_90.Ptr = &param_1->SupportedCommandsMap;

+        local_70 = param_1->SupportedCodecResult;

+        local_68 = (undefined2)param_1->SupportedCodecResultSize;

+        local_f4 = (uint)(param_1->IsoInitializationState).BroadcastIsoEnabled;

+        local_f8 = (uint)(param_1->IsoInitializationState).ConnectedIsoEnabled;

+        local_c8 = param_1->OptInFeatureFlags;

+        local_d0 = param_1->LELocalSupportedStates;

+        local_d8 = param_1->LELocalSupportedFeatures;

+        local_e0 = (param_1->LocalInfo).radioInfo.lmpSupportedFeatures;

+        local_100[0] = (param_1->LocalInfo).radioInfo.lmpSubversion;

+        local_res10[0] = (_tlgWrapperByVal<1>)(param_1->LocalInfo).radioInfo.lmpVersion;

+        local_102 = (param_1->LocalInfo).radioInfo.mfg;

+        local_104 = (ushort)(uVar2 >> 2) & 0x3f;

+        local_f0 = (uint)(uVar14 >> 0x18) & 0xffffff;

+        local_106 = (ushort)(uVar2 >> 8) & 0x1f;

+        local_fc = uVar2 >> 0xd & 0x7ff;

+        local_res18[0] =

+             (_tlgWrapperByVal<1>)((byte)(param_1->LocalInfo).localInfo.classOfDevice & 3);

+        local_90.Size = 0x40;

+        local_108 = (param_1->LocalInfo).hciRevision;

+        local_res20[0] = (_tlgWrapperByVal<1>)(param_1->LocalInfo).hciVersion;

+        local_b0[0] = &pDVar13->DeviceExtensionSessionId;

+        local_80.Ptr = (_BTH_SUPPORTED_COMMANDS_MAP *)0x3000800;

+        local_ec = (uint)bVar6;

+        _tlgWriteTemplate<long___cdecl(_tlgProvider_t_const*___ptr64,void_const*___ptr64,_GUID_const*___ptr64,_GUID_const*___ptr64,unsigned_int,_EVENT_DATA_DESCRIPTOR*___ptr64),&long___cdecl__tlgWriteTransfer_EtwWriteTransfer(struct__tlgProvider_t_const*___ptr64,void_const*___ptr64,struct__GUID_const*___ptr64,struct__GUID_const*___ptr64,unsigned_int,struct__EVENT_DATA_DESCRIPTOR*___ptr64),_GUID_const*___ptr64,_GUID_const*___ptr64>

+        ::

+        Write<_tlgWrapperByVal<8>,_tlgWrapperByRef<16>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<1>,_tlgWrapperByVal<4>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperArray<1>,_tlgWrapperPtrSize,_tlgWrapperByVal<4>,_tlgWrapperByVal<8>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<1>_>

+                  ((_tlgProvider_t *)(ulonglong)local_fc,&DAT_1,(_GUID *)pDVar13,in_R9,

+                   (_tlgWrapperByVal<8> *)&local_80,(_tlgWrapperByRef<16> *)local_b0,local_res20,

+                   (_tlgWrapperByVal<2> *)&local_108,local_res18,(_tlgWrapperByVal<4> *)&local_fc,

+                   (_tlgWrapperByVal<2> *)&local_106,(_tlgWrapperByVal<2> *)&local_104,

+                   (_tlgWrapperByVal<2> *)&local_102,local_res10,(_tlgWrapperByVal<2> *)local_100,

+                   (_tlgWrapperByVal<8> *)&local_e0,(_tlgWrapperByVal<8> *)&local_d8,

+                   (_tlgWrapperByVal<8> *)&local_d0,(_tlgWrapperByVal<8> *)&local_c8,

+                   (_tlgWrapperByVal<4> *)&local_f8,(_tlgWrapperByVal<4> *)&local_f4,

+                   (_tlgWrapperByVal<4> *)&local_f0,(_tlgWrapperArray<1> *)&local_70,&local_90,

+                   (_tlgWrapperByVal<4> *)&local_ec,(_tlgWrapperByVal<8> *)&local_c0,

+                   (_tlgWrapperByVal<4> *)&local_e8,(_tlgWrapperByVal<4> *)&local_e4,

+                   (_tlgWrapperByVal<8> *)local_a0,(_tlgWrapperByVal<8> *)&local_b8,

+                   (_tlgWrapperByVal<1> *)&local_res8);

       }

-      *(ushort *)(in_R8 + 5) = uVar8;

-      return;

-    }

-    if (((param_1->ExtendedFeatures & 2) == 0) ||

-       (((param_1->SupportedCommandsMap).field0_0x0.RawMap[0xc] & 0x20) == 0)) {

-      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 4))

-      {

-        uVar7 = 0;

-      }

-      else {

-        uVar7 = 1;

-      }

-      goto LAB_2;

-    }

-    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 4)) {

-      uVar7 = 0;

-    }

-    else {

-      uVar7 = 1;

-    }

-    uStack0000000000000040 = (uint)unaff_RDI->InquiryScanType;

-    WPP_RECORDER_AND_TRACE_SF_L

-              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar7,1,unaff_RDI->IfrLog,4);

-    uVar20 = unaff_RDI->InquiryScanType;

-  }

-  else {

-    if (in_EDX < 0xc64) {

-      if (in_EDX == 0xc63) {

-        iVar11 = Feature_56240707__private_IsEnabledDeviceUsageNoInline();

-        if (iVar11 == 0) {

-          return;

-        }

-        if (((unaff_RDI->SupportedCommandsMap).field0_0x0.RawMap[0x16] & 4) == 0) {

-          return;

-        }

-        if ((unaff_RDI->LocalInfo).hciVersion < 0xc) {

-          return;

-        }

-        *(undefined8 *)(unaff_R14 + 3) = 0x2000000;

-        return;

-      }

-      if (in_EDX == 0xc45) {

-        _Var1 = param_1->InquirySupportLevel;

-        uVar7 = 0;

-        if (_Var1 != BthInquiryResultSupport) {

-          if (_Var1 == BthInquiryResultWithRSSISupport) {

-            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

-               (3 < (byte)WPP_GLOBAL_Control[0x29])) {

-              uVar7 = 1;

-            }

-            uVar17 = 1;

-LAB_3:

-            WPP_RECORDER_AND_TRACE_SF_

-                      (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar7,1,unaff_RDI->IfrLog,4);

-            *(undefined1 *)(unaff_R14 + 3) = uVar17;

-            return;

-          }

-          if (_Var1 == BthInquiryResultExtendedSupport) {

-            uVar17 = 2;

-            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

-               (3 < (byte)WPP_GLOBAL_Control[0x29])) {

-              uVar7 = 1;

-            }

-            goto LAB_3;

-          }

-        }

-        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) &&

-           (3 < (byte)WPP_GLOBAL_Control[0x29])) {

-          uVar7 = 1;

-        }

-      }

-      else if (in_EDX == 0xc47) {

-        if (((param_1->ExtendedFeatures & 2) != 0) &&

-           (((param_1->SupportedCommandsMap).field0_0x0.RawMap[0xd] & 2) != 0)) {

-          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

-             ((byte)WPP_GLOBAL_Control[0x29] < 4)) {

-            uVar7 = 0;

-          }

-          else {

-            uVar7 = 1;

-          }

-          uStack0000000000000040 = (uint)unaff_RDI->PassivePageScanType;

-          WPP_RECORDER_AND_TRACE_SF_L

-                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar7,1,unaff_RDI->IfrLog,4);

-          uVar20 = unaff_RDI->PassivePageScanType;

-          unaff_RDI->CurrentPageScanType = uVar20;

-          goto LAB_1;

-        }

-        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

-           ((byte)WPP_GLOBAL_Control[0x29] < 4)) {

-          uVar7 = 0;

-        }

-        else {

-          uVar7 = 1;

-        }

-      }

-      else {

-        if (in_EDX != 0xc52) {

-          if (in_EDX != 0xc56) {

-            return;

-          }

-          if (((param_1->LocalInfo).radioInfo.lmpSupportedFeatures >> 0x33 & 1) == 0) {

-            return;

-          }

-          if (param_1->SimplePairingMode != '\x01') {

-            return;

-          }

-          if (((param_1->SupportedCommandsMap).field0_0x0.RawMap[0x11] & 0x40) == 0) {

-            return;

-          }

-          goto LAB_4;

-        }

-        if (param_1->InquirySupportLevel == BthInquiryResultExtendedSupport) {

-          if (param_1->FirstTimeInit != '\0') {

-            HCI_EirInitData((HCI_INTERFACE *)param_1);

-          }

-          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

-             (uVar14 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

-            uVar14 = 0;

-          }

-          WPP_RECORDER_AND_TRACE_SF_

-                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,unaff_RDI->IfrLog,4);

-          puVar18 = &unaff_RDI->HciLock;

-          uVar7 = KeAcquireSpinLockRaiseToDpc(puVar18);

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 8);

-          *(undefined8 *)(unaff_R14 + 4) = *(undefined8 *)(unaff_RDI->EirInfo).EirRecordData;

-          *(undefined8 *)(unaff_R14 + 0xc) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x18);

-          *(undefined8 *)(unaff_R14 + 0x14) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x10);

-          *(undefined8 *)(unaff_R14 + 0x1c) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x28);

-          *(undefined8 *)(unaff_R14 + 0x24) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x20);

-          *(undefined8 *)(unaff_R14 + 0x2c) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x38);

-          *(undefined8 *)(unaff_R14 + 0x34) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x30);

-          *(undefined8 *)(unaff_R14 + 0x3c) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x48);

-          *(undefined8 *)(unaff_R14 + 0x44) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x40);

-          *(undefined8 *)(unaff_R14 + 0x4c) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x58);

-          *(undefined8 *)(unaff_R14 + 0x54) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x50);

-          *(undefined8 *)(unaff_R14 + 0x5c) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x68);

-          *(undefined8 *)(unaff_R14 + 100) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x60);

-          *(undefined8 *)(unaff_R14 + 0x6c) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x78);

-          puVar16 = (unaff_RDI->EirInfo).EirRecordData + 0x80;

-          *(undefined8 *)(unaff_R14 + 0x74) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x70);

-          *(undefined8 *)(unaff_R14 + 0x7c) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x88);

-          *(undefined8 *)(unaff_R14 + 0x84) = *(undefined8 *)puVar16;

-          *(undefined8 *)(unaff_R14 + 0x8c) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x98);

-          *(undefined8 *)(unaff_R14 + 0x94) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0x90);

-          *(undefined8 *)(unaff_R14 + 0x9c) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0xa8);

-          *(undefined8 *)(unaff_R14 + 0xa4) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0xa0);

-          *(undefined8 *)(unaff_R14 + 0xac) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0xb8);

-          *(undefined8 *)(unaff_R14 + 0xb4) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0xb0);

-          *(undefined8 *)(unaff_R14 + 0xbc) = uVar14;

-          uVar14 = *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 200);

-          *(undefined8 *)(unaff_R14 + 0xc4) =

-               *(undefined8 *)((unaff_RDI->EirInfo).EirRecordData + 0xc0);

-          *(undefined8 *)(unaff_R14 + 0xcc) = uVar14;

-          uVar3 = *(undefined4 *)((unaff_RDI->EirInfo).EirRecordData + 0xd4);

-          uVar4 = *(undefined4 *)((unaff_RDI->EirInfo).EirRecordData + 0xd8);

-          uVar5 = *(undefined4 *)((unaff_RDI->EirInfo).EirRecordData + 0xdc);

-          *(undefined4 *)(unaff_R14 + 0xd4) =

-               *(undefined4 *)((unaff_RDI->EirInfo).EirRecordData + 0xd0);

-          *(undefined4 *)(unaff_R14 + 0xd8) = uVar3;

-          *(undefined4 *)(unaff_R14 + 0xdc) = uVar4;

-          *(undefined4 *)(unaff_R14 + 0xe0) = uVar5;

-          uVar3 = *(undefined4 *)((unaff_RDI->EirInfo).EirRecordData + 0xe0);

-          uVar4 = *(undefined4 *)((unaff_RDI->EirInfo).EirRecordData + 0xe4);

-          uVar5 = *(undefined4 *)((unaff_RDI->EirInfo).EirRecordData + 0xe8);

-          uVar6 = *(undefined4 *)((unaff_RDI->EirInfo).EirRecordData + 0xec);

-          *(undefined1 *)(unaff_R14 + 3) = 0;

-          uVar14 = CONCAT71((int7)((ulonglong)puVar16 >> 8),uVar7);

-          *(undefined4 *)(unaff_R14 + 0xe4) = uVar3;

-          *(undefined4 *)(unaff_R14 + 0xe8) = uVar4;

-          *(undefined4 *)(unaff_R14 + 0xec) = uVar5;

-          *(undefined4 *)(unaff_R14 + 0xf0) = uVar6;

-          goto LAB_0;

-        }

-        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) ||

-           ((byte)WPP_GLOBAL_Control[0x29] < 4)) {

-          uVar7 = 0;

-        }

-        else {

-          uVar7 = 1;

-        }

-      }

-LAB_2:

-      WPP_RECORDER_AND_TRACE_SF_

-                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar7,1,unaff_RDI->IfrLog,4);

-      return;

-    }

-    if (in_EDX == 0xc6d) {

-      if (param_1->LEEnabled == '\0') {

-        return;

-      }

-      *(undefined2 *)(in_R8 + 3) = 0x101;

-      return;

-    }

-    if (in_EDX == 0xc7a) {

-      if ((((param_1->SupportedCommandsMap).field0_0x0.RawMap[0x20] & 8) == 0) ||

-         (param_1->isBRSecureConnectionEnabled == '\0')) {

-        param_1->isBRSecureConnectionEnabled = '\0';

-        return;

-      }

-      uVar19 = BthQueryRadioCompatFlags(param_1,(param_1->DevExt->BtDevice).FunctionalDeviceObject);

-      if (((((unaff_RDI->LocalRadioSimplePairingOptions & 1) == 0) &&

-           (((unaff_RDI->VsMsftInfo).SupportedFeatures & 0x10) == 0)) && ((uVar19 >> 8 & 1) == 0))

-         && (unaff_RDI->AssumeBRSCKeysAreValidated == '\0')) {

-        unaff_RDI->isBRSecureConnectionEnabled = '\0';

-        return;

-      }

-LAB_4:

-      *(undefined1 *)(unaff_R14 + 3) = 1;

-      return;

-    }

-    if (in_EDX == 0xc82) {

-      if (((param_1->SupportedCommandsMap).field0_0x0.RawMap[0x2d] & 2) == 0) {

-        return;

-      }

-      *(undefined2 *)(in_R8 + 3) = 6;

-      return;

-    }

-    if (in_EDX != 0xc84) {

-      return;

-    }

-    iVar11 = Feature_56240707__private_IsEnabledDeviceUsageNoInline();

-    if (iVar11 == 0) {

-      return;

-    }

-    if (-1 < (char)(unaff_RDI->SupportedCommandsMap).field0_0x0.RawMap[0x2d]) {

-      return;

-    }

-    if (unaff_RDI->EnableMinimumEncryptionKeySize == '\0') {

-      return;

-    }

-    uVar20 = unaff_RDI->MinimumEncryptionKeySize;

-  }

-LAB_1:

-  *(uchar *)(unaff_R14 + 3) = uVar20;

+    }

+    else if ((4 < (uint)DAT_0) &&

+            (cVar7 = _tlgKeywordOn(&DAT_0,0x800000000111), cVar7 != '\0')) {

+      pDVar13 = param_1->DevExt;

+      local_res8 = (AvdtpOffload *)

+                   CONCAT71(local_res8._1_7_,

+                            (param_1->RadioCapacity).LESupportedMaxNumberOfAdvertisingSets);

+      local_b0[0] = (_GUID *)(param_1->VsMsftInfo).SupportedFeatures;

+      local_fc = ErrorRecovery::GetSupportedResetTypes(&pDVar13->ErrorRecoveryHandler);

+      local_f8 = (uint)(param_1->VsMsftInfo).tlvTelemetryEnabled;

+      local_e0 = pDVar13->HostSupportedFeatures;

+      local_80.Ptr = &param_1->SupportedCommandsMap;

+      local_90.Ptr = param_1->SupportedCodecResult;

+      uVar2 = (param_1->LocalInfo).localInfo.classOfDevice;

+      local_90.Size = CONCAT22(local_90.Size._2_2_,(short)param_1->SupportedCodecResultSize);

+      local_f0 = (uint)((param_1->LocalInfo).localInfo.address >> 0x18) & 0xffffff;

+      local_ec = (uint)(param_1->IsoInitializationState).BroadcastIsoEnabled;

+      local_e8 = (uint)(param_1->IsoInitializationState).ConnectedIsoEnabled;

+      local_d8 = param_1->OptInFeatureFlags;

+      local_d0 = param_1->LELocalSupportedStates;

+      local_c8 = param_1->LELocalSupportedFeatures;

+      local_c0 = (param_1->LocalInfo).radioInfo.lmpSupportedFeatures;

+      local_108 = (param_1->LocalInfo).radioInfo.lmpSubversion;

+      local_res10[0] = (_tlgWrapperByVal<1>)(param_1->LocalInfo).radioInfo.lmpVersion;

+      local_106 = (param_1->LocalInfo).radioInfo.mfg;

+      local_104 = (ushort)(uVar2 >> 2) & 0x3f;

+      local_80.Size = 0x40;

+      local_102 = (ushort)(uVar2 >> 8) & 0x1f;

+      local_e4 = uVar2 >> 0xd & 0x7ff;

+      local_res18[0] = (_tlgWrapperByVal<1>)((byte)(param_1->LocalInfo).localInfo.classOfDevice & 3)

+      ;

+      local_100[0] = (param_1->LocalInfo).hciRevision;

+      local_res20[0] = (_tlgWrapperByVal<1>)(param_1->LocalInfo).hciVersion;

+      local_a0[0] = &pDVar13->DeviceExtensionSessionId;

+      local_b8 = 0x3000800;

+      local_f4 = (uint)bVar6;

+      _tlgWriteTemplate<long___cdecl(_tlgProvider_t_const*___ptr64,void_const*___ptr64,_GUID_const*___ptr64,_GUID_const*___ptr64,unsigned_int,_EVENT_DATA_DESCRIPTOR*___ptr64),&long___cdecl__tlgWriteTransfer_EtwWriteTransfer(struct__tlgProvider_t_const*___ptr64,void_const*___ptr64,struct__GUID_const*___ptr64,struct__GUID_const*___ptr64,unsigned_int,struct__EVENT_DATA_DESCRIPTOR*___ptr64),_GUID_const*___ptr64,_GUID_const*___ptr64>

+      ::

+      Write<_tlgWrapperByVal<8>,_tlgWrapperByRef<16>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<1>,_tlgWrapperByVal<4>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperArray<1>,_tlgWrapperPtrSize,_tlgWrapperByVal<4>,_tlgWrapperByVal<8>,_tlgWrapperByVal<4>,_tlgWrapperByVal<4>,_tlgWrapperByVal<8>,_tlgWrapperByVal<1>_>

+                ((_tlgProvider_t *)(ulonglong)local_e4,&DAT_2,in_R8,in_R9,

+                 (_tlgWrapperByVal<8> *)&local_b8,(_tlgWrapperByRef<16> *)local_a0,local_res20,

+                 (_tlgWrapperByVal<2> *)local_100,local_res18,(_tlgWrapperByVal<4> *)&local_e4,

+                 (_tlgWrapperByVal<2> *)&local_102,(_tlgWrapperByVal<2> *)&local_104,

+                 (_tlgWrapperByVal<2> *)&local_106,local_res10,(_tlgWrapperByVal<2> *)&local_108,

+                 (_tlgWrapperByVal<8> *)&local_c0,(_tlgWrapperByVal<8> *)&local_c8,

+                 (_tlgWrapperByVal<8> *)&local_d0,(_tlgWrapperByVal<8> *)&local_d8,

+                 (_tlgWrapperByVal<4> *)&local_e8,(_tlgWrapperByVal<4> *)&local_ec,

+                 (_tlgWrapperByVal<4> *)&local_f0,(_tlgWrapperArray<1> *)&local_90,&local_80,

+                 (_tlgWrapperByVal<4> *)&local_f4,(_tlgWrapperByVal<8> *)&local_e0,

+                 (_tlgWrapperByVal<4> *)&local_f8,(_tlgWrapperByVal<4> *)&local_fc,

+                 (_tlgWrapperByVal<8> *)local_b0,(_tlgWrapperByVal<1> *)&local_res8);

+    }

+  }

+  pDVar13 = param_1->DevExt;

+  uVar4 = ScoInt_IsInBandSupported(pDVar13->Sco);

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

+    pDVar13->HostSupportedFeatures = pDVar13->HostSupportedFeatures & 0xffffffffffffffdf;

+  }

+  if (p_Var10 != (_BIP *)0x0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x40) == 0) ||

+       (uVar15 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar15 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar15,1,param_1->IfrLog,4,7,0x84,

+               &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids,p_Var10);

+    HCI_WriteCommand(param_1,p_Var10);

+  }

+  HCI_LEResetScanParameters(param_1,PostRadioInitialization,false);

+  HciLE_ResumeRandomAddressTimer(param_1);

+  if (param_1->IsLEExtendedAdvertisingEnabled == false) {

+    KeSetEvent(param_1->ThreadEvents + 8,0,0);

+  }

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) != 0) && (3 < (byte)WPP_GLOBAL_Control[0x29])) {

+    uVar16 = 1;

+  }

+  WPP_RECORDER_AND_TRACE_SF_

+            (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar16,1,param_1->IfrLog,4,2,0x85,

+             &WPP_e71c6142f55736d6f687a1491a09f4fa_Traceguids);

+  Controller::OnControllerInitializationComplete

+            ((Controller *)&param_1->DevExt[-2].AvdtpOffload,true);

   return;

 }
```

## `BthLogStartDeviceTelemetry`  (modified)

```diff
--- BthLogStartDeviceTelemetry
+++ BthLogStartDeviceTelemetry
@@ -1,33 +1,180 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* void __cdecl BthLogStartDeviceTelemetry(struct DEVICE_EXTENSION * __ptr64) */

 

 void __cdecl BthLogStartDeviceTelemetry(DEVICE_EXTENSION *param_1)

 

 {

-  RECORDER_LOG__ *pRVar1;

+  bool bVar1;

+  char cVar2;

+  int iVar3;

   Fdo *this;

-  longlong in_R10;

-  undefined8 *unaff_R14;

-  undefined4 uStack0000000000000028;

-  undefined2 uStack0000000000000030;

-  undefined *puStack0000000000000038;

-  undefined8 uStack0000000000000040;

+  Driver *this_00;

+  _GUID *p_Var4;

+  _GUID *p_Var5;

+  undefined4 local_res8 [2];

+  undefined4 local_res10 [2];

+  uint local_res18 [2];

+  undefined8 local_res20;

+  undefined8 in_stack_fffffffffffffda8;

+  undefined4 uVar6;

+  undefined8 local_1d8;

+  _tlgWrapSz<unsigned_short> local_1d0;

+  _tlgWrapSz<unsigned_short> local_1c8;

+  _tlgWrapSz<unsigned_short> local_1c0;

+  _tlgWrapSz<unsigned_short> local_1b8;

+  _GENERAL_LOOKASIDE_POOL_u_48 local_1b0;

+  _tlgWrapSz<unsigned_short> local_1a8;

+  _GENERAL_LOOKASIDE_POOL_u_48 local_1a0;

+  _GENERAL_LOOKASIDE_POOL_u_48 local_198;

+  _GENERAL_LOOKASIDE_POOL_u_48 local_190;

+  _GENERAL_LOOKASIDE_POOL_u_48 local_188;

+  undefined8 local_180;

+  undefined8 local_178;

+  _GUID *local_170;

+  undefined8 local_168;

+  undefined1 local_160 [32];

+  undefined1 local_140 [32];

+  undefined1 local_120 [32];

+  undefined1 local_100 [32];

+  undefined1 local_e0 [32];

+  _GENERAL_LOOKASIDE_POOL_u_48 local_c0;

+  _GENERAL_LOOKASIDE_POOL_u_56 local_b8;

+  _GENERAL_LOOKASIDE_POOL_u_48 local_a0;

+  _GENERAL_LOOKASIDE_POOL_u_56 local_98;

+  _GENERAL_LOOKASIDE_POOL_u_48 local_80;

+  _RTL_RB_TREE_u_8 local_78;

+  _GENERAL_LOOKASIDE_POOL_u_48 local_60;

+  _RTL_RB_TREE_u_8 local_58;

+  _GENERAL_LOOKASIDE_POOL_u_48 local_40;

+  _RTL_RB_TREE_u_8 local_38;

   

-  this = (Fdo *)*unaff_R14;

-  pRVar1 = Fdo::GetRecorderLog(this);

-  uStack0000000000000040 = *(undefined8 *)this;

-  puStack0000000000000038 = &WPP_537babcb72103abd0c349940e2acb52a_Traceguids;

-  uStack0000000000000030 = 0x11;

-  uStack0000000000000028 = 1;

-  WPP_RECORDER_AND_TRACE_SF_iL

-            (*(undefined8 *)(in_R10 + 0x18),

-             CONCAT71((int7)((ulonglong)uStack0000000000000040 >> 8),1),1,pRVar1,2);

-  wil::details::

-  unique_storage<wil::details::resource_policy<WDFDEVICE__*___ptr64,void_(__cdecl*)(void*___ptr64),&void___cdecl_WdfObjectDelete(void*___ptr64),wistd::integral_constant<unsigned___int64,0>,WDFDEVICE__*___ptr64,WDFDEVICE__*___ptr64,0,std::nullptr_t>_>

-  ::

-  ~unique_storage<wil::details::resource_policy<WDFDEVICE__*___ptr64,void_(__cdecl*)(void*___ptr64),&void___cdecl_WdfObjectDelete(void*___ptr64),wistd::integral_constant<unsigned___int64,0>,WDFDEVICE__*___ptr64,WDFDEVICE__*___ptr64,0,std::nullptr_t>_>

-            ((unique_storage<wil::details::resource_policy<WDFDEVICE__*___ptr64,void_(__cdecl*)(void*___ptr64),&void___cdecl_WdfObjectDelete(void*___ptr64),wistd::integral_constant<unsigned___int64,0>,WDFDEVICE__*___ptr64,WDFDEVICE__*___ptr64,0,std::nullptr_t>_>

-              *)&stack0x00000050);

+  uVar6 = (undefined4)((ulonglong)in_stack_fffffffffffffda8 >> 0x20);

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)&local_40,(_DEVPROPKEY *)param_1);

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)&local_60,(_DEVPROPKEY *)param_1);

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)&local_80,(_DEVPROPKEY *)param_1);

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)&local_a0,(_DEVPROPKEY *)param_1);

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)(local_e0 + 0x20),(_DEVPROPKEY *)param_1);

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)local_e0,(_DEVPROPKEY *)param_1);

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)local_100,(_DEVPROPKEY *)param_1);

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)local_120,(_DEVPROPKEY *)param_1);

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)local_140,(_DEVPROPKEY *)param_1);

+  local_res10[0] = 0;

+  local_res8[0] = 0;

+  local_1d8 = 0;

+  iVar3 = IoGetDevicePropertyData

+                    ((param_1->BtDevice).PhysicalDeviceObject,&DEVPKEY_Device_DriverDate,0,0,

+                     CONCAT44(uVar6,8),&local_1d8,local_res10,local_res8);

+  if (iVar3 < 0) {

+    local_1d8 = 0;

+  }

+  local_res20 = 0;

+  p_Var5 = (_GUID *)0x0;

+  iVar3 = IoGetDevicePropertyData

+                    ((param_1->BtDevice).PhysicalDeviceObject,&DEVPKEY_Device_InstallDate,0,0,8,

+                     &local_res20,local_res10,local_res8);

+  if (iVar3 < 0) {

+    local_res20 = 0;

+  }

+  this = Fdo::FromDevExt(param_1);

+  this_00 = (Driver *)Fdo::GetPowerCoordinator(this);

+  bVar1 = Driver::IsRestrictedTestModeOn(this_00);

+  p_Var4 = (_GUID *)&DEVPKEY_Device_Service;

+  BthGetDeviceStringProperty((DEVICE_EXTENSION *)local_160,(_DEVPROPKEY *)param_1);

+  if (4 < (uint)DAT_0) {

+    cVar2 = _tlgKeywordOn(&DAT_0,0x800000000121);

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

+      local_res18[0] = (uint)bVar1;

+      local_1d0.Psz = L"Unknown";

+      if (local_160._0_8_ != local_160._8_8_) {

+        local_1d0.Psz = (wchar_t *)local_160._0_8_;

+      }

+      local_168 = 0x3000800;

+      local_1c8.Psz = L"Unknown";

+      if (local_120._0_8_ != local_120._8_8_) {

+        local_1c8.Psz = (wchar_t *)local_120._0_8_;

+      }

+      local_1c0.Psz = L"Unknown";

+      if (local_100._0_8_ != local_100._8_8_) {

+        local_1c0.Psz = (wchar_t *)local_100._0_8_;

+      }

+      local_1b8.Psz = L"Unknown";

+      if (local_e0._0_8_ != local_e0._8_8_) {

+        local_1b8.Psz = (wchar_t *)local_e0._0_8_;

+      }

+      local_1b0 = (_GENERAL_LOOKASIDE_POOL_u_48)L"Unknown";

+      if (local_c0.AllocateEx !=

+          (_func___cdecl_void_ptr__POOL_TYPE_ulong64_ulong__LOOKASIDE_LIST_EX_ptr *)local_b8.FreeEx)

+      {

+        local_1b0 = local_c0;

+      }

+      local_1a8.Psz = L"Unknown";

+      if (local_140._0_8_ != local_140._8_8_) {

+        local_1a8.Psz = (wchar_t *)local_140._0_8_;

+      }

+      local_1a0 = (_GENERAL_LOOKASIDE_POOL_u_48)L"Unknown";

+      if (local_a0.AllocateEx !=

+          (_func___cdecl_void_ptr__POOL_TYPE_ulong64_ulong__LOOKASIDE_LIST_EX_ptr *)local_98.FreeEx)

+      {

+        local_1a0 = local_a0;

+      }

+      local_198 = (_GENERAL_LOOKASIDE_POOL_u_48)L"Unknown";

+      if ((_RTL_BALANCED_NODE *)local_80.AllocateEx != local_78.Min) {

+        local_198 = local_80;

+      }

+      local_190 = (_GENERAL_LOOKASIDE_POOL_u_48)L"Unknown";

+      if ((_RTL_BALANCED_NODE *)local_60.AllocateEx != local_58.Min) {

+        local_190 = local_60;

+      }

+      local_188 = (_GENERAL_LOOKASIDE_POOL_u_48)L"Unknown";

+      if ((_RTL_BALANCED_NODE *)local_40.AllocateEx != local_38.Min) {

+        local_188 = local_40;

+      }

+      local_180 = local_res20;

+      local_178 = local_1d8;

+      local_170 = &param_1->DeviceExtensionSessionId;

+      _tlgWriteTemplate<long___cdecl(_tlgProvider_t_const*___ptr64,void_const*___ptr64,_GUID_const*___ptr64,_GUID_const*___ptr64,unsigned_int,_EVENT_DATA_DESCRIPTOR*___ptr64),&long___cdecl__tlgWriteTransfer_EtwWriteTransfer(struct__tlgProvider_t_const*___ptr64,void_const*___ptr64,struct__GUID_const*___ptr64,struct__GUID_const*___ptr64,unsigned_int,struct__EVENT_DATA_DESCRIPTOR*___ptr64),_GUID_const*___ptr64,_GUID_const*___ptr64>

+      ::

+      Write<_tlgWrapperByVal<8>,_tlgWrapperByRef<16>,_tlgWrapperByVal<8>,_tlgWrapperByVal<8>,_tlgWrapSz<unsigned_short>,_tlgWrapSz<unsigned_short>,_tlgWrapSz<unsigned_short>,_tlgWrapSz<unsigned_short>,_tlgWrapSz<unsigned_short>,_tlgWrapSz<unsigned_short>,_tlgWrapSz<unsigned_short>,_tlgWrapSz<unsigned_short>,_tlgWrapSz<unsigned_short>,_tlgWrapSz<unsigned_short>,_tlgWrapperByVal<4>_>

+                ((_tlgProvider_t *)local_190.AllocateEx,&DAT_1,p_Var4,p_Var5,

+                 (_tlgWrapperByVal<8> *)&local_168,(_tlgWrapperByRef<16> *)&local_170,

+                 (_tlgWrapperByVal<8> *)&local_178,(_tlgWrapperByVal<8> *)&local_180,

+                 (_tlgWrapSz<unsigned_short> *)&local_188,(_tlgWrapSz<unsigned_short> *)&local_190,

+                 (_tlgWrapSz<unsigned_short> *)&local_198,(_tlgWrapSz<unsigned_short> *)&local_1a0,

+                 &local_1a8,(_tlgWrapSz<unsigned_short> *)&local_1b0,&local_1b8,&local_1c0,

+                 &local_1c8,&local_1d0,(_tlgWrapperByVal<4> *)local_res18);

+    }

+  }

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)local_160);

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)local_140);

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)local_120);

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)local_100);

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)local_e0);

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)(local_e0 + 0x20));

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)&local_a0);

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)&local_80);

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)&local_60);

+  utl::basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+  ::_Uninit((basic_string<unsigned_short,utl::char_traits<unsigned_short>,utl::allocator<unsigned_short>_>

+             *)&local_40);

   return;

 }
```

## `L2CapCon_ProcessReadIrp`  (modified)

```diff
--- L2CapCon_ProcessReadIrp
+++ L2CapCon_ProcessReadIrp
@@ -1,15 +1,183 @@
 

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

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

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

+/* long __cdecl L2CapCon_ProcessReadIrp(struct L2CAP_CONNECTION * __ptr64,struct _IRP * __ptr64) */

 

 long __cdecl L2CapCon_ProcessReadIrp(L2CAP_CONNECTION *param_1,_IRP *param_2)

 

 {

-  char in_AL;

-  undefined7 in_register_00000001;

+  longlong lVar1;

+  longlong *****ppppplVar2;

+  longlong ****pppplVar3;

+  longlong *****ppppplVar4;

+  undefined8 uVar5;

+  code *pcVar6;

+  ulong uVar7;

+  int iVar8;

+  long lVar9;

+  void *pvVar10;

+  L2CAP_CONNECTION *pLVar11;

+  undefined8 uVar12;

+  undefined1 uVar13;

+  undefined1 *puVar14;

+  L2CAP_CONNECTION *pLVar15;

+  undefined1 local_res10;

+  uchar local_res18 [8];

+  uchar local_res20 [8];

+  undefined1 auStackY_a8 [8];

+  undefined1 local_a0 [24];

+  longlong *****local_48;

+  longlong *****local_40;

   

-  *(char *)CONCAT71(in_register_00000001,in_AL) =

-       *(char *)CONCAT71(in_register_00000001,in_AL) + in_AL;

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

-  halt_baddata();

+  puVar14 = auStackY_a8;

+  local_40 = (longlong *****)&local_48;

+  local_48 = (longlong *****)&local_48;

+  lVar1 = *(longlong *)((longlong)(param_2->Tail).Apc.SystemArgument1 + 8);

+  if ((*(uint *)(lVar1 + 0x80) & 4) == 0) {

+    pvVar10 = (void *)0x0;

+  }

+  else {

+    pvVar10 = (void *)ExAllocatePool2(0x40,0xb0,0x50485442);

+    uVar13 = 0;

+    if (pvVar10 == (void *)0x0) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29]))

+      {

+        uVar13 = 1;

+      }

+      WPP_RECORDER_AND_TRACE_SF_qq

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar13,1,

+                 *(undefined8 *)(WPP_GLOBAL_Control + 0x40));

+      return -0x3fffff66;

+    }

+    RefObj_InitEx(pvVar10,L2capCon_TimeoutRefDestroy,pvVar10,0x484);

+    KeInitializeTimerEx((longlong)pvVar10 + 0x58,0);

+    KeInitializeDpc((longlong)pvVar10 + 0x18,L2CapCon_ReadTimeoutDpc,0);

+    *(L2CAP_CONNECTION **)((longlong)pvVar10 + 0xa0) = param_1;

+    uVar7 = RefObj_AddRefEx(param_1,pvVar10,0x48d,

+                            "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\l2cap.cpp");

+    L2CapRefTrace(0,param_1,pvVar10,uVar7);

+  }

+  local_res10 = KeAcquireSpinLockRaiseToDpc(param_1 + 0x3c0);

+  iVar8 = Feature_61512497__private_IsEnabledDeviceUsageNoInline();

+  uVar13 = 0;

+  if ((iVar8 == 0) || (param_1[1000] == (L2CAP_CONNECTION)0x0)) {

+    pLVar15 = param_1 + 0x3f0;

+    pLVar11 = *(L2CAP_CONNECTION **)pLVar15;

+    if (pLVar11 == pLVar15) {

+      lVar9 = IrpList_EnqueueLocked(param_1 + 0x3b0,param_2);

+      if (lVar9 == 0x103) {

+        uVar7 = RefObj_AddRefEx(param_1,L2CapCon_ProcessReadIrp,0x4e4,

+                                "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\l2cap.cpp"

+                               );

+        L2CapRefTrace(0,param_1,L2CapCon_ProcessReadIrp,uVar7);

+LAB_0:

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

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) == 0) ||

+             (uVar12 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+            uVar12 = 0;

+          }

+          WPP_RECORDER_AND_TRACE_SF_qq

+                    (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar12,1,

+                     *(undefined8 *)(WPP_GLOBAL_Control + 0x40));

+          RefObj_AddRefEx(pvVar10,L2CapCon_ReadIrpCancel,0x4ef,

+                          "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\l2cap.cpp");

+          RefObj_AddRefEx(pvVar10,L2CapCon_ReadTimeoutDpc,0x4f4,

+                          "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\l2cap.cpp");

+          *(_IRP **)((longlong)pvVar10 + 0x98) = param_2;

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

+          KeSetTimer((longlong)pvVar10 + 0x58,*(undefined8 *)(lVar1 + 0x98),(longlong)pvVar10 + 0x18

+                    );

+        }

+      }

+    }

+    else if ((*(uint *)(param_1 + 0x1b0) & 0x40) == 0) {

+      local_res18[0] = '\0';

+      do {

+        local_res20[0] = '\x01';

+        lVar9 = L2CapCon_CopyReadBipToReadIrpEx

+                          (param_1,(_BIP *)(pLVar11 + -0x58),param_2,local_res18,local_res20);

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

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

+          ppppplVar2 = *(longlong ******)pLVar15;

+          if (((L2CAP_CONNECTION *)ppppplVar2[1] != pLVar15) ||

+             (pppplVar3 = *ppppplVar2, (longlong *****)pppplVar3[1] != ppppplVar2))

+          goto LAB_1;

+          *(longlong *****)pLVar15 = pppplVar3;

+          pppplVar3[1] = (longlong ***)pLVar15;

+          if ((longlong ******)*local_40 != &local_48) goto LAB_1;

+          ppppplVar2[1] = (longlong ****)local_40;

+          *ppppplVar2 = (longlong ****)&local_48;

+          *local_40 = (longlong ****)ppppplVar2;

+          local_40 = ppppplVar2;

+        }

+        pLVar11 = *(L2CAP_CONNECTION **)pLVar15;

+        if (pLVar11 == pLVar15) {

+          iVar8 = 0x103;

+          if ((lVar9 == 0x103) &&

+             (lVar9 = IrpList_EnqueueLocked(param_1 + 0x3b0,param_2), lVar9 == iVar8)) {

+            uVar7 = RefObj_AddRefEx(param_1,L2CapCon_ProcessReadIrp,0x4d7,

+                                    "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\l2cap.cpp"

+                                   );

+            L2CapRefTrace(0,param_1,L2CapCon_ProcessReadIrp,uVar7);

+            goto LAB_2;

+          }

+          break;

+        }

+      } while (lVar9 == 0x103);

+    }

+    else {

+      KeReleaseSpinLock(param_1 + 0x3c0,local_res10);

+      lVar9 = L2CapCon_EnhancedCompleteReadBip(param_1,param_2,0);

+      local_res10 = KeAcquireSpinLockRaiseToDpc(param_1 + 0x3c0);

+LAB_2:

+      if (lVar9 == 0x103) goto LAB_0;

+    }

+  }

+  else {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) == 0) ||

+       (uVar12 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar12 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_qq

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar12,1,

+               *(undefined8 *)(WPP_GLOBAL_Control + 0x40));

+    lVar9 = -0x3fffff63;

+  }

+  pLVar15 = (L2CAP_CONNECTION *)&WPP_acbb2f3775473fab3548517aa9079135_Traceguids;

+  KeReleaseSpinLock(param_1 + 0x3c0,local_res10);

+  while (ppppplVar2 = local_48, (longlong ******)local_48 != &local_48) {

+    if (((longlong ******)local_48[1] != &local_48) ||

+       (ppppplVar4 = (longlong *****)*local_48, (longlong *****)ppppplVar4[1] != local_48))

+    goto LAB_1;

+    ppppplVar4[1] = (longlong ****)&local_48;

+    local_48[1] = (longlong ****)local_48;

+    *local_48 = (longlong ****)local_48;

+    local_48 = ppppplVar4;

+    (*(code *)ppppplVar2[7])();

+  }

+LAB_3:

+  if ((lVar9 != 0x103) && (pvVar10 != (void *)0x0)) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 4) != 0) && (3 < (byte)WPP_GLOBAL_Control[0x29])) {

+      uVar13 = 1;

+    }

+    uVar12 = *(undefined8 *)(WPP_GLOBAL_Control + 0x40);

+    uVar5 = *(undefined8 *)(WPP_GLOBAL_Control + 0x18);

+    *(void **)(puVar14 + 0x40) = pvVar10;

+    *(L2CAP_CONNECTION **)(puVar14 + 0x38) = pLVar15;

+    *(undefined2 *)(puVar14 + 0x30) = 0x32;

+    *(undefined4 *)(puVar14 + 0x28) = 3;

+    puVar14[0x20] = 4;

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

+    WPP_RECORDER_AND_TRACE_SF_i(uVar5,uVar13,1,uVar12);

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

+    RefObj_ReleaseEx(pvVar10,pvVar10,0x511,

+                     "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\l2cap.cpp");

+  }

+  return lVar9;

+LAB_1:

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

+  (*pcVar6)(3);

+  puVar14 = local_a0;

+  goto LAB_3;

 }
```

## `ScanRequestProgrammer::SendLESetScanParametersHciCommand`  (modified)

```diff
--- ScanRequestProgrammer::SendLESetScanParametersHciCommand
+++ ScanRequestProgrammer::SendLESetScanParametersHciCommand
@@ -1,12 +1,45 @@
 

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

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: void __cdecl ScanRequestProgrammer::SendLESetScanParametersHciCommand(void) __ptr64 */

 

 void __thiscall

-ScanRequestParameters::SendLESetScanParametersHciCommand(ScanRequestProgrammer *this)

+ScanRequestProgrammer::SendLESetScanParametersHciCommand(ScanRequestProgrammer *this)

 

 {

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

-  halt_baddata();

+  undefined8 uVar1;

+  undefined1 auStackY_78 [32];

+  _HCI_COMMAND_HEADER local_28;

+  undefined1 local_25;

+  undefined2 local_24;

+  undefined2 local_22;

+  undefined1 local_20;

+  undefined1 local_1f;

+  ulonglong local_18;

+  

+  local_18 = __security_cookie ^ (ulonglong)auStackY_78;

+  local_28.Parameter_Total_Length = '\a';

+  local_28.Op_Code = 0x200b;

+  local_20 = *(undefined1 *)&this->m_computedScanParameters;

+  local_1f = (this->m_computedScanParameters).field_0x1;

+  if (((this->m_computedScanParameters).field_0x2 & 1) == 0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar1 = 0;

+    }

+    else {

+      uVar1 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar1,1,this->m_fdo->m_recorderLog);

+    MicrosoftTelemetryAssertTriggeredMsgKM

+              ("1M Uncoded PHY parameters must be present for legacy command");

+  }

+  local_25 = (this->m_computedScanParameters).field_0x3;

+  local_24 = *(undefined2 *)&(this->m_computedScanParameters).field_0x4;

+  local_22 = *(undefined2 *)&(this->m_computedScanParameters).field_0x6;

+  HCI_SendCommandEx((this->m_fdo->m_devExt).Hci,&local_28,(_GUID *)0x0,

+                    <lambda_0d4a64d3c559bbc10c569e8d2bfe875b>::<lambda_invoker_cdecl>,this,0,

+                    (void *)0x0);

+  return;

 }
```

## `BroadcastIsochronousGroupImpl::~BroadcastIsochronousGroupImpl`  (modified)

```diff
--- BroadcastIsochronousGroupImpl::~BroadcastIsochronousGroupImpl
+++ BroadcastIsochronousGroupImpl::~BroadcastIsochronousGroupImpl
@@ -1,2 +1,125 @@
-Failed to decompile bthport.sys - .ProgramDB BroadcastIsochronousGroupImpl::~BroadcastIsochronousGroupImpl : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* public: virtual __cdecl BroadcastIsochronousGroupImpl::~BroadcastIsochronousGroupImpl(void)

+   __ptr64 */

+

+void __thiscall

+BroadcastIsochronousGroupImpl::~BroadcastIsochronousGroupImpl(BroadcastIsochronousGroupImpl *this)

+

+{

+  BroadcastIsochronousGroupImpl BVar1;

+  bool bVar2;

+  undefined8 uVar3;

+  

+  *(undefined ***)this = &_vftable_;

+  bVar2 = wil::details::kernel_event_t<0>::is_signaled((kernel_event_t<0> *)(this + 0x40));

+  if (!bVar2) {

+    LOCK();

+    BVar1 = this[0x88];

+    this[0x88] = (BroadcastIsochronousGroupImpl)0x1;

+    UNLOCK();

+    if (BVar1 == (BroadcastIsochronousGroupImpl)0x0) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2))

+      {

+        uVar3 = 0;

+      }

+      else {

+        uVar3 = 1;

+      }

+      WPP_RECORDER_AND_TRACE_SF_i

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,

+                 (*(undefined8 **)(this + 0x28))[4],2,1,10,

+                 &WPP_524b11a325ae3d150adb2f715246fb98_Traceguids,**(undefined8 **)(this + 0x28));

+      MicrosoftTelemetryAssertTriggeredMsgKM("Central BIG: PrepareForDestroy() not invoked.");

+      SmFx::StateMachineEngine::StateMachineEngineImpl::EnqueueEvent

+                (*(StateMachineEngineImpl **)(this + 8),3);

+    }

+    else {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2))

+      {

+        uVar3 = 0;

+      }

+      else {

+        uVar3 = 1;

+      }

+      WPP_RECORDER_AND_TRACE_SF_i

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,

+                 (*(undefined8 **)(this + 0x28))[4],2,1,0xb,

+                 &WPP_524b11a325ae3d150adb2f715246fb98_Traceguids,**(undefined8 **)(this + 0x28));

+      MicrosoftTelemetryAssertTriggeredMsgKM("Central BIG: PrepareForDestroy() not completed.");

+    }

+    wil::details::kernel_event_t<0>::wait_for_single_object

+              ((kernel_event_t<0> *)(this + 0x40),(_LARGE_INTEGER *)0x0);

+  }

+  if (this[0x200] != (BroadcastIsochronousGroupImpl)0x0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar3 = 0;

+    }

+    else {

+      uVar3 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,(*(undefined8 **)(this + 0x28))[4]

+               ,2,1,0xc,&WPP_524b11a325ae3d150adb2f715246fb98_Traceguids,

+               **(undefined8 **)(this + 0x28));

+    MicrosoftTelemetryAssertTriggeredMsgKM("m_createBigRequest not completed.");

+  }

+  if (this[0x2c8] != (BroadcastIsochronousGroupImpl)0x0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar3 = 0;

+    }

+    else {

+      uVar3 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,(*(undefined8 **)(this + 0x28))[4]

+               ,2,1,0xd,&WPP_524b11a325ae3d150adb2f715246fb98_Traceguids,

+               **(undefined8 **)(this + 0x28));

+    MicrosoftTelemetryAssertTriggeredMsgKM("m_terminateBigRequest not completed.");

+  }

+  if (this[0x390] != (BroadcastIsochronousGroupImpl)0x0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar3 = 0;

+    }

+    else {

+      uVar3 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,(*(undefined8 **)(this + 0x28))[4]

+               ,2,1,0xe,&WPP_524b11a325ae3d150adb2f715246fb98_Traceguids,

+               **(undefined8 **)(this + 0x28));

+    MicrosoftTelemetryAssertTriggeredMsgKM("m_resetBigRequest not completed.");

+  }

+  if (*(longlong *)(this + 0x78) != 0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar3 = 0;

+    }

+    else {

+      uVar3 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,(*(undefined8 **)(this + 0x28))[4]

+               ,2,1,0xf,&WPP_524b11a325ae3d150adb2f715246fb98_Traceguids,

+               **(undefined8 **)(this + 0x28));

+    MicrosoftTelemetryAssertTriggeredMsgKM("m_powerReference still active.");

+  }

+  utl::_OptionalData1<BroadcastIsochronousGroupImpl::BigRequest,0>::

+  ~_OptionalData1<BroadcastIsochronousGroupImpl::BigRequest,0>

+            ((_OptionalData1<BroadcastIsochronousGroupImpl::BigRequest,0> *)(this + 0x2d0));

+  utl::_OptionalData1<BroadcastIsochronousGroupImpl::BigRequest,0>::

+  ~_OptionalData1<BroadcastIsochronousGroupImpl::BigRequest,0>

+            ((_OptionalData1<BroadcastIsochronousGroupImpl::BigRequest,0> *)(this + 0x208));

+  utl::_OptionalData1<BroadcastIsochronousGroupImpl::BigRequest,0>::

+  ~_OptionalData1<BroadcastIsochronousGroupImpl::BigRequest,0>

+            ((_OptionalData1<BroadcastIsochronousGroupImpl::BigRequest,0> *)(this + 0x140));

+  operation_guard_async_wait::~operation_guard_async_wait

+            ((operation_guard_async_wait *)(this + 0xa8));

+  if (*(_RefCountBase **)(this + 0xa0) != (_RefCountBase *)0x0) {

+    utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(this + 0xa0));

+  }

+  PowerCoordinator::PowerReference::Reset((PowerReference *)(this + 0x78));

+  utl::vector<unsigned___int64,utl::allocator<unsigned___int64>_>::_Uninit

+            ((vector<unsigned___int64,utl::allocator<unsigned___int64>_> *)(this + 0x58));

+  return;

+}

+
```

## `FileObject::OnCreate`  (modified)

```diff
--- FileObject::OnCreate
+++ FileObject::OnCreate
@@ -1,46 +1,117 @@
 

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

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

+/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* public: static long __cdecl FileObject::OnCreate(struct WDFFILEOBJECT__ * __ptr64,struct

+   WDFREQUEST__ * __ptr64) */

 

-long __cdecl FdoDefaultIoQueue::OnCreate(WDFFILEOBJECT__ *param_1,WDFREQUEST__ *param_2)

+long __cdecl FileObject::OnCreate(WDFFILEOBJECT__ *param_1,WDFREQUEST__ *param_2)

 

 {

-  long lVar1;

-  char unaff_BL;

-  longlong unaff_RDI;

-  undefined4 uStack0000000000000028;

-  undefined2 uStack0000000000000030;

-  long lStack0000000000000048;

-  undefined8 uStack0000000000000050;

-  undefined8 uStack0000000000000058;

-  undefined8 uStack0000000000000060;

-  undefined8 uStack0000000000000068;

-  undefined8 uStack0000000000000070;

-  undefined8 uStack0000000000000078;

-  undefined8 uStack0000000000000080;

+  longlong lVar1;

+  CallerIdentityFlags CVar2;

+  char cVar3;

+  int iVar4;

+  WDFDEVICE__ *pWVar5;

+  Fdo *this;

+  longlong lVar6;

+  Fdo *pFVar7;

+  FileObject *pFVar8;

+  undefined1 uVar9;

+  CallerIdentityFlags CVar10;

+  undefined *puVar11;

+  undefined1 auStack_d8 [64];

+  undefined8 local_98;

+  int local_90;

+  undefined8 local_88;

+  char local_78;

+  undefined8 local_70;

+  undefined8 local_68 [3];

+  undefined8 local_50;

+  undefined8 uStack_48;

+  ulonglong local_40;

   

-  in(0xff);

-  uStack0000000000000050 = 0;

-  uStack0000000000000058 = 0;

-  uStack0000000000000080 = 0;

-  uStack0000000000000060 = 0;

-  uStack0000000000000068 = 0;

-  uStack0000000000000070 = 0;

-  uStack0000000000000078 = 0;

-  DS_Init((_DEVICE_STRING *)&stack0x00000050,(__uint64 *)(unaff_RDI + 0x20));

-  lVar1 = ZwDeleteValueKey(*(undefined8 *)

-                            (*(longlong *)(*(longlong *)(unaff_RDI + 0x378) + 0x4a8) + 0xd8),

-                           &stack0x00000078);

-  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 2) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 5)) {

-    unaff_BL = '\0';

+  local_40 = __security_cookie ^ (ulonglong)auStack_d8;

+  pWVar5 = (WDFDEVICE__ *)(**(code **)(WdfFunctions_01031 + 0x458))(WdfDriverGlobals,param_1);

+  this = Fdo::FromWdfDevice(pWVar5);

+  CVar10 = None;

+  lVar6 = (**(code **)(WdfFunctions_01031 + 0x8e8))(WdfDriverGlobals,param_2);

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

+  if ((*(char *)(lVar6 + 0x40) != '\x01') ||

+     (pFVar7 = (Fdo *)IoGetInitiatorProcess(*(undefined8 *)(lVar1 + 0x30)), pFVar7 == (Fdo *)0x0)) {

+    pFVar7 = (Fdo *)PsGetCurrentProcess();

   }

-  if ((unaff_BL != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

-    uStack0000000000000030 = 0xb0;

-    uStack0000000000000028 = 2;

-    lStack0000000000000048 = lVar1;

-    WPP_RECORDER_AND_TRACE_SF_iL

-              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),unaff_BL,

-               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,*(undefined8 *)(unaff_RDI + 0x838),5);

+  GetProcessCommandLine((_EPROCESS *)&local_70,pFVar7);

+  local_50 = 0;

+  uStack_48 = 0;

+  IoGetActivityIdIrp(lVar6);

+  if ((Microsoft_Windows_BTH_BTHPORTEnableBits & 2) != 0) {

+    McTemplateK0p_EtwWriteTransfer();

   }

-  return lVar1;

+  local_78 = '\0';

+  uVar9 = 1;

+  if (*(char *)(lVar6 + 0x40) == '\x01') {

+    iVar4 = QueryIsAppContainer(pFVar7);

+    if (iVar4 < 0) {

+      puVar11 = WPP_GLOBAL_Control;

+      Fdo::GetRecorderLog(this);

+      local_88 = local_70;

+      local_98 = *(undefined8 *)this;

+      local_90 = iVar4;

+      WPP_RECORDER_AND_TRACE_SF_qdZ(*(undefined8 *)(puVar11 + 0x18));

+      pFVar8 = FromWdfFileObject(param_1);

+      if (pFVar8 != (FileObject *)0x0) {

+        local_68[0] = local_70;

+        local_70 = 0;

+        FileObject(pFVar8,this,None,

+                   (unique_ptr<_UNICODE_STRING,utl::default_delete<_UNICODE_STRING>_>)local_68);

+      }

+      goto LAB_0;

+    }

+    CVar10 = (CallerIdentityFlags)(local_78 != '\0');

+    if (local_78 == '\0') goto LAB_1;

+  }

+  else {

+LAB_1:

+    local_68[0] = 10;

+    if ((*(byte *)(lVar1 + 2) & 1) == 0) {

+      uVar9 = *(undefined1 *)(lVar6 + 0x40);

+    }

+    cVar3 = SeSinglePrivilegeCheck(10,uVar9);

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

+       ((*(char *)(lVar6 + 0x40) == '\x01' &&

+        (cVar3 = IsCallingProcess(&`IsCallingProcessUserModeDriverHost'::__l2::

+                                   s_sdUserModeDriverHost,1), cVar3 != '\0')))) {

+      CVar10 = CVar10 | HasBthServicePrivilege;

+    }

+    if (*(char *)(lVar6 + 0x40) == '\x01') {

+      cVar3 = IsCallingProcess(&`IsCallingProcessBthservEx'::__l2::s_sdBthserv,1);

+      CVar2 = CVar10 | IsBthServ;

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

+        CVar2 = CVar10;

+      }

+      CVar10 = CVar2;

+      cVar3 = IsCallingProcess(&`IsCallingProcessBluetoothAudioService'::__l2::s_sdBthAvctpSvc,1);

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

+        CVar10 = CVar10 | IsBthAvctpSvc;

+      }

+    }

+  }

+  iVar4 = 0;

+  pFVar8 = FromWdfFileObject(param_1);

+  if (pFVar8 != (FileObject *)0x0) {

+    local_68[0] = local_70;

+    local_70 = 0;

+    FileObject(pFVar8,this,CVar10,

+               (unique_ptr<_UNICODE_STRING,utl::default_delete<_UNICODE_STRING>_>)local_68);

+  }

+LAB_0:

+  utl::

+  _UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+  ::

+  ~_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+            ((_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+              *)&local_70);

+  return iVar4;

 }
```

## `HciLELegacyAdvertisingRequestCoordinator::EvtMachineDestroyed`  (modified)

```diff
--- HciLELegacyAdvertisingRequestCoordinator::EvtMachineDestroyed
+++ HciLELegacyAdvertisingRequestCoordinator::EvtMachineDestroyed
@@ -1,2 +1,34 @@
-Failed to decompile bthport.sys - .ProgramDB HciLELegacyAdvertisingRequestCoordinator::EvtMachineDestroyed : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* private: void __cdecl HciLELegacyAdvertisingRequestCoordinator::EvtMachineDestroyed(void) __ptr64

+    */

+

+void __thiscall

+HciLELegacyAdvertisingRequestCoordinator::EvtMachineDestroyed

+          (HciLELegacyAdvertisingRequestCoordinator *this)

+

+{

+  undefined1 uVar1;

+  undefined8 local_res8 [4];

+  

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x1000) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 4)

+     ) {

+    uVar1 = 0;

+  }

+  else {

+    uVar1 = 1;

+  }

+  WPP_RECORDER_AND_TRACE_SF_i

+            (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar1,1,

+             *(undefined8 *)(*(longlong *)(this + 0xf8) + 0x10b0),4,0xd,0x3a,

+             &WPP_778b421db6673a1b7f4f235689701828_Traceguids,this);

+  local_res8[0] = *(undefined8 *)(this + 0x150);

+  *(undefined8 *)(this + 0x150) = 0;

+  wil::details::

+  unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+  ::

+  ~unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+            ((unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+              *)local_res8);

+  return;

+}

+
```

## `BroadcastIsoGroupControllerModule::HandleTerminateBig`  (modified)

```diff
--- BroadcastIsoGroupControllerModule::HandleTerminateBig
+++ BroadcastIsoGroupControllerModule::HandleTerminateBig
@@ -1,2 +1,160 @@
-Failed to decompile bthport.sys - .ProgramDB BroadcastIsoGroupControllerModule::HandleTerminateBig : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

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

+/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: void __cdecl BroadcastIsoGroupControllerModule::HandleTerminateBig(class

+   wil::wdf_request_completer,unsigned __int64,unsigned __int64) __ptr64 */

+

+void __thiscall

+BroadcastIsoGroupControllerModule::HandleTerminateBig

+          (BroadcastIsoGroupControllerModule *this,wdf_request_completer *param_1,__uint64 param_2,

+          __uint64 param_3)

+

+{

+  int iVar1;

+  FileObject *this_00;

+  wdf_request_completer *pwVar2;

+  RECORDER_LOG__ *pRVar3;

+  void *pvVar4;

+  Fdo *pFVar5;

+  TerminateBigResult *__return_storage_ptr__;

+  undefined8 uVar6;

+  undefined *puVar7;

+  undefined1 uVar8;

+  undefined1 uVar9;

+  undefined2 uVar10;

+  WDFREQUEST__ *pWVar11;

+  longlong local_38;

+  ulong *local_30;

+  TerminateBigResult local_28;

+  

+  uVar9 = 0;

+  local_38 = 0;

+  pwVar2 = param_1;

+  iVar1 = Feature_56664216__private_IsEnabledDeviceUsageNoInline();

+  if (iVar1 != 0) {

+    this_00 = FileObject::FromWdfRequest(param_1->m_wdfRequest);

+    pwVar2 = (wdf_request_completer *)FileObject::AcquireCleanupGuard(this_00);

+    wil::

+    unique_any_t<wil::details::unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>_>

+    ::operator=((unique_any_t<wil::details::unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>_>

+                 *)&local_38,

+                (unique_any_t<class_wil::details::unique_storage<struct_wil::details::resource_policy<class_wil::operation_guard*___ptr64,void_(__cdecl*)(class_wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),struct_wistd::integral_constant<unsigned___int64,1>,class_wil::operation_guard*___ptr64,class_wil::operation_guard*___ptr64,0,std::nullptr_t>_>_>

+                 *)pwVar2);

+    wil::details::

+    unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+    ::

+    ~unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+              ((unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+                *)&local_28);

+    if (local_38 == 0) {

+      uVar8 = 1;

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+         (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+        uVar9 = 1;

+      }

+      pFVar5 = *(Fdo **)(this + 0x10);

+      puVar7 = WPP_GLOBAL_Control;

+      pRVar3 = Fdo::GetIORecorderLog(pFVar5);

+      __return_storage_ptr__ = (TerminateBigResult *)CONCAT71((int7)((ulonglong)pwVar2 >> 8),uVar9);

+      WPP_RECORDER_AND_TRACE_SF_qq

+                (*(undefined8 *)(puVar7 + 0x18),__return_storage_ptr__,

+                 CONCAT71((int7)((ulonglong)*(undefined8 *)pFVar5 >> 8),uVar8),pRVar3,2,0x10,0x1a,

+                 &WPP_d95ac27b8bc9386a37e59c4507bba476_Traceguids,*(undefined8 *)pFVar5,

+                 param_1->m_wdfRequest);

+      param_1->m_status = -0x3fffffaa;

+      goto LAB_0;

+    }

+  }

+  if (param_3 == 4) {

+    if (param_2 == 0) {

+      local_30 = (ulong *)0x0;

+      iVar1 = (**(code **)(WdfFunctions_01031 + 0x868))

+                        (WdfDriverGlobals,param_1->m_wdfRequest,4,&local_30,0);

+      if (iVar1 < 0) {

+        uVar8 = 1;

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar9 = 1;

+        }

+        pFVar5 = *(Fdo **)(this + 0x10);

+        puVar7 = WPP_GLOBAL_Control;

+        pRVar3 = Fdo::GetIORecorderLog(pFVar5);

+        pWVar11 = param_1->m_wdfRequest;

+        uVar6 = *(undefined8 *)pFVar5;

+        uVar10 = 0x1d;

+      }

+      else {

+        pvVar4 = (void *)(**(code **)(WdfFunctions_01031 + 0x8a8))

+                                   (WdfDriverGlobals,param_1->m_wdfRequest);

+        __return_storage_ptr__ = &local_28;

+        BroadcastIsoRegistrar::TerminateBig

+                  ((BroadcastIsoRegistrar *)(this + 0x18),__return_storage_ptr__,*local_30,pvVar4);

+        if (-1 < local_28.RequestStatus) {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) == 0) ||

+             (__return_storage_ptr__ =

+                   (TerminateBigResult *)CONCAT71((int7)((ulonglong)__return_storage_ptr__ >> 8),1),

+             (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+            __return_storage_ptr__ =

+                 (TerminateBigResult *)((ulonglong)__return_storage_ptr__ & 0xffffffffffffff00);

+          }

+          puVar7 = WPP_GLOBAL_Control;

+          Fdo::GetIORecorderLog(*(Fdo **)(this + 0x10));

+          WPP_RECORDER_AND_TRACE_SF_qq(*(undefined8 *)(puVar7 + 0x18));

+          param_1->m_status = 0;

+          goto LAB_0;

+        }

+        uVar8 = 1;

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar9 = 1;

+        }

+        pFVar5 = *(Fdo **)(this + 0x10);

+        puVar7 = WPP_GLOBAL_Control;

+        pRVar3 = Fdo::GetIORecorderLog(pFVar5);

+        pWVar11 = param_1->m_wdfRequest;

+        uVar6 = *(undefined8 *)pFVar5;

+        uVar10 = 0x1e;

+        iVar1 = local_28.RequestStatus;

+      }

+      __return_storage_ptr__ = (TerminateBigResult *)CONCAT71((int7)((ulonglong)uVar6 >> 8),uVar9);

+      WPP_RECORDER_AND_TRACE_SF_qqd

+                (*(undefined8 *)(puVar7 + 0x18),__return_storage_ptr__,uVar8,pRVar3,2,0x10,uVar10,

+                 &WPP_d95ac27b8bc9386a37e59c4507bba476_Traceguids,uVar6,pWVar11,iVar1);

+      param_1->m_status = iVar1;

+      goto LAB_0;

+    }

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) == 0) ||

+       (uVar9 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar9 = 0;

+    }

+    pFVar5 = *(Fdo **)(this + 0x10);

+    puVar7 = WPP_GLOBAL_Control;

+    pRVar3 = Fdo::GetIORecorderLog(pFVar5);

+    __return_storage_ptr__ = (TerminateBigResult *)CONCAT71((int7)((ulonglong)pwVar2 >> 8),uVar9);

+    WPP_RECORDER_AND_TRACE_SF_qqI

+              (*(undefined8 *)(puVar7 + 0x18),__return_storage_ptr__,*(undefined8 *)pFVar5,pRVar3);

+  }

+  else {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) == 0) ||

+       (uVar9 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar9 = 0;

+    }

+    pFVar5 = *(Fdo **)(this + 0x10);

+    puVar7 = WPP_GLOBAL_Control;

+    Fdo::GetIORecorderLog(pFVar5);

+    __return_storage_ptr__ =

+         (TerminateBigResult *)CONCAT71((int7)((ulonglong)*(undefined8 *)pFVar5 >> 8),uVar9);

+    WPP_RECORDER_AND_TRACE_SF_qqPP(*(undefined8 *)(puVar7 + 0x18));

+  }

+  param_1->m_status = -0x3ffffdfa;

+LAB_0:

+  wil::details::

+  unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+  ::

+  ~unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+            ((unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+              *)&local_38);

+  wil::wdf_request_completer::reset(param_1,(WDFREQUEST__ *)__return_storage_ptr__);

+  return;

+}

+
```

## `BroadcastIsoRegistrar::TerminateBig`  (modified)

```diff
--- BroadcastIsoRegistrar::TerminateBig
+++ BroadcastIsoRegistrar::SetupDataPath
@@ -1,42 +1,30 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

 

-TerminateBigResult * __thiscall

-BroadcastIsoGroupSyncManager::TerminateBig

-          (BroadcastIsoRegistrar *this,TerminateBigResult *__return_storage_ptr__,ulong param_1,

-          void *param_2)

+long __thiscall

+BroadcastIsoGroupSyncManager::SetupDataPath

+          (BroadcastIsoRegistrar *this,ulong param_1,uchar param_2,IsoDataPathConfig *param_3,

+          void *param_4)

 

 {

-  _TreeNode<utl::pair<unsigned_long_const_,ConnectedIsoRegistrar::CentralCisState>_> *p_Var1;

-  TerminateBigResult *unaff_RBX;

-  undefined8 *unaff_RSI;

-  ulonglong unaff_RDI;

-  undefined4 in_register_00000084;

+  undefined8 *puVar1;

+  longlong lVar2;

+  undefined8 uVar3;

+  undefined4 in_register_00000014;

+  longlong unaff_RBP;

+  longlong unaff_RDI;

   

-  p_Var1 = utl::

-           _Tree<unsigned_long,utl::pair<unsigned_long_const_,ConnectedIsoRegistrar::CentralCisState>,utl::less<unsigned_long>,utl::allocator<utl::pair<unsigned_long_const_,ConnectedIsoRegistrar::CentralCisState>_>,0>

-           ::_NewNodeConstruct<utl::_PairMapTag,unsigned_long_const&___ptr64>

-                     ((_Tree<unsigned_long,utl::pair<unsigned_long_const_,ConnectedIsoRegistrar::CentralCisState>,utl::less<unsigned_long>,utl::allocator<utl::pair<unsigned_long_const_,ConnectedIsoRegistrar::CentralCisState>_>,0>

-                       *)this,(_PairMapTag *)__return_storage_ptr__,

-                      (ulong *)CONCAT44(in_register_00000084,param_1));

-  if (p_Var1 == (_TreeNode<utl::pair<unsigned_long_const_,ConnectedIsoRegistrar::CentralCisState>_>

-                 *)0x0) {

-    p_Var1 = (_TreeNode<utl::pair<unsigned_long_const_,ConnectedIsoRegistrar::CentralCisState>_> *)

-             (unaff_RDI & 0xffffffff);

+  puVar1 = (undefined8 *)((longlong)(this->m_bigHciHandleFactory).m_buffer + unaff_RBP + -0x24);

+  lVar2 = puVar1[1];

+  uVar3 = *puVar1;

+  *(undefined8 *)CONCAT44(in_register_00000014,param_1) = uVar3;

+  *(longlong *)(CONCAT44(in_register_00000014,param_1) + 8) = lVar2;

+  if (lVar2 != 0) {

+    LOCK();

+    *(int *)(lVar2 + 8) = *(int *)(lVar2 + 8) + 1;

+    UNLOCK();

   }

-  else {

-    unaff_RDI = 1;

-    *(ulonglong *)p_Var1 = (ulonglong)unaff_RSI | 1;

-    *(void ***)(p_Var1 + 8) = &utl::_TreeSentinel;

-    *(void ***)(p_Var1 + 0x10) = &utl::_TreeSentinel;

-    *unaff_RSI = p_Var1;

-    unaff_RSI[1] = p_Var1;

-    unaff_RSI[2] = p_Var1;

-    unaff_RSI[3] = unaff_RSI[3] + 1;

-  }

-  *(_TreeNode<utl::pair<unsigned_long_const_,ConnectedIsoRegistrar::CentralCisState>_> **)unaff_RBX

-       = p_Var1;

-  (unaff_RBX->TerminatedIndication).field_0x2 = (char)unaff_RDI;

-  return unaff_RBX;

+  *(longlong *)(unaff_RDI + 8) = *(longlong *)(unaff_RDI + 8) + 0x10;

+  return (long)CONCAT71((int7)((ulonglong)uVar3 >> 8),1);

 }
```

## `HciLEExtendedAdvertisingRequestCoordinator::EnableAdvertisingSetCommandComplete`  (modified)

```diff
--- HciLEExtendedAdvertisingRequestCoordinator::EnableAdvertisingSetCommandComplete
+++ HciLEExtendedAdvertisingRequestCoordinator::EnableAdvertisingSetCommandComplete
@@ -1,2 +1,35 @@
-Failed to decompile bthport.sys - .ProgramDB HciLEExtendedAdvertisingRequestCoordinator::EnableAdvertisingSetCommandComplete : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: void __cdecl

+   HciLEExtendedAdvertisingRequestCoordinator::EnableAdvertisingSetCommandComplete(struct

+   _HCI_CALLBACK_DATA const & __ptr64) __ptr64 */

+

+void __thiscall

+HciLEExtendedAdvertisingRequestCoordinator::EnableAdvertisingSetCommandComplete

+          (HciLEExtendedAdvertisingRequestCoordinator *this,_HCI_CALLBACK_DATA *param_1)

+

+{

+  longlong *plVar1;

+  

+  StoreHciCommandCompleteResults(this,param_1);

+  if ((-1 < param_1->Status) && (param_1->BtStatus == '\0')) {

+    if ((param_1->Cmd->Cmd_Generic).Parameter[0] == '\0') {

+      plVar1 = (longlong *)GetCurrentAdvertisingSet(this);

+      *(uint *)(*plVar1 + 0x10) = *(uint *)(*plVar1 + 0x10) & 0xfffffffe;

+      plVar1 = (longlong *)GetCurrentAdvertisingSet(this);

+      AdvertisingHandlePerformanceCounterToken::OnAdvertisingSetDisabled

+                ((AdvertisingHandlePerformanceCounterToken *)(*plVar1 + 0x60));

+    }

+    else {

+      plVar1 = (longlong *)GetCurrentAdvertisingSet(this);

+      *(uint *)(*plVar1 + 0x10) = *(uint *)(*plVar1 + 0x10) | 1;

+      plVar1 = (longlong *)GetCurrentAdvertisingSet(this);

+      AdvertisingHandlePerformanceCounterToken::OnAdvertisingSetEnabled

+                ((AdvertisingHandlePerformanceCounterToken *)(*plVar1 + 0x60));

+    }

+  }

+  AdvertisingStateManagerStateMachine<AdvertisingStateManager>::EnqueueEvent

+            ((AdvertisingStateManagerStateMachine<AdvertisingStateManager> *)(this + 8),8);

+  return;

+}

+
```

## `AdvertisingRequestProgrammer::SendHciCommandToRemoveAdvertisingSet`  (modified)

```diff
--- AdvertisingRequestProgrammer::SendHciCommandToRemoveAdvertisingSet
+++ AdvertisingRequestProgrammer::SendHciCommandToRemoveAdvertisingSet
@@ -1,18 +1,49 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: void __cdecl AdvertisingRequestProgrammer::SendHciCommandToRemoveAdvertisingSet(void)

+   __ptr64 */

 

 void __thiscall

-AdvertisingRequestControllerModule::SendHciCommandToRemoveAdvertisingSet

+AdvertisingRequestProgrammer::SendHciCommandToRemoveAdvertisingSet

           (AdvertisingRequestProgrammer *this)

 

 {

-  int *piVar1;

-  uint in_EAX;

+  undefined8 *puVar1;

+  undefined1 *puVar2;

+  _HCI_COMMAND_HEADER local_res8;

+  undefined1 local_resb;

   

-  piVar1 = (int *)((ulonglong)((in_EAX & 0xffffff20) + 0xf7a12de8) - 0x7d);

-  *piVar1 = *piVar1 + -1;

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

-  halt_baddata();

+  puVar2 = (undefined1 *)0x0;

+  puVar1 = *(undefined8 **)&this->m_inProgressProgrammingRequestList;

+  while( true ) {

+    if ((list<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>,utl::allocator<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>_>_>

+         *)puVar1 == &this->m_inProgressProgrammingRequestList) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29]))

+      {

+        puVar2 = &DAT_0;

+      }

+      WPP_RECORDER_AND_TRACE_SF_i

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+                 CONCAT71((int7)((ulonglong)puVar1 >> 8),(char)puVar2),1,this->m_fdo->m_recorderLog,

+                 2,1,0x35,&WPP_fab93d68af813c68f3a528574d26bb64_Traceguids,

+                 *(undefined8 *)this->m_fdo);

+      MicrosoftTelemetryAssertTriggeredMsgKM("Could not find set whose removal was attempted.");

+      return;

+    }

+    if (*(char *)(puVar1[2] + 0xe0) == '\0') break;

+    puVar1 = (undefined8 *)*puVar1;

+  }

+  *(undefined1 *)(puVar1[2] + 0xe0) = 1;

+  AdvertisingHandlePerformanceCounterToken::Reset

+            ((AdvertisingHandlePerformanceCounterToken *)(puVar1[2] + 0x108));

+  local_res8.Op_Code = 0x203c;

+  local_res8.Parameter_Total_Length = '\x01';

+  local_resb = *(undefined1 *)(*(longlong *)puVar1[2] + 0x10);

+  this->m_hciRequestStatus = -0x3fffffff;

+  this->m_hciCommandStatus = 0xff;

+  HCI_SendCommandEx((this->m_fdo->m_devExt).Hci,&local_res8,(_GUID *)0x0,

+                    <lambda_188f630be6399ad18ef8928e8ca7bcd3>::<lambda_invoker_cdecl>,this,

+                    (ulong)puVar2,puVar2);

+  return;

 }
```

## `_HCI_CONNECTION::_HCI_CONNECTION`  (modified)

```diff
--- _HCI_CONNECTION::_HCI_CONNECTION
+++ _HCI_CONNECTION::_HCI_CONNECTION
@@ -1,14 +1,31 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* public: __cdecl _HCI_CONNECTION::_HCI_CONNECTION(void) __ptr64 */

 

-void __thiscall WppByteBuffer::_HCI_CONNECTION(_HCI_CONNECTION *this)

+_HCI_CONNECTION * __thiscall _HCI_CONNECTION::_HCI_CONNECTION(_HCI_CONNECTION *this)

 

 {

-  undefined2 in_DX;

+  intrusive_list_hook *piVar1;

   

-  in(in_DX);

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

-  halt_baddata();

+  piVar1 = &this->DisconnectListEntry;

+  *(intrusive_list_hook **)&(this->DisconnectListEntry).field_0x8 = piVar1;

+  *(intrusive_list_hook **)piVar1 = piVar1;

+  *(undefined8 *)&(this->LERemoteConnectionParameters).field_0x1 = 0;

+  *(undefined1 *)&this->LERemoteConnectionParameters = 0;

+  *(undefined2 *)&(this->LERemoteConnectionParameters).field_0x8 = 0;

+  *(undefined8 *)&(this->LERequestedConnectionParameters).field_0x1 = 0;

+  (this->LERequestedConnectionParameters).field_0x8 = 0;

+  (this->SleepstudyCxnComponent).m_libraryHandle = (SS_LIBRARY__ *)0x0;

+  (this->SleepstudyCxnComponent).m_handle = (SS_COMPONENT__ *)0x0;

+  (this->SleepstudyCxnComponent).m_state = Unregistered;

+  KeInitializeSpinLock(&(this->SleepstudyCxnComponent).m_lock);

+  (this->QosParameters).MaximumLatency = 0xffffffff;

+  this->ActivePeripheralBroadcastPacketsDropped = (atomic<unsigned_long>)0x0;

+  (this->AuthenticatedPayloadTimeoutFired)._MyVal = '\0';

+  this->LEDataLengthChangeCount = 0;

+  (this->LEPhyStats).changeEventCount = 0;

+  (this->LEPhyStats).txPhys = 0;

+  (this->LEPhyStats).rxPhys = 0;

+  return this;

 }
```

## `AdvertisingRequestProgrammer::FindAndMarkAdvertisingEnableStoppedForRequestLocked`  (modified)

```diff
--- AdvertisingRequestProgrammer::FindAndMarkAdvertisingEnableStoppedForRequestLocked
+++ AdvertisingRequestProgrammer::FindAndMarkAdvertisingEnableStoppedForRequestLocked
@@ -1,64 +1,58 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: bool __cdecl

+   AdvertisingRequestProgrammer::FindAndMarkAdvertisingEnableStoppedForRequestLocked(class

+   utl::list<class utl::unique_ptr<struct

+   AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,struct

+   utl::default_delete<struct AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>

+   >,class utl::allocator<class utl::unique_ptr<struct

+   AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,struct

+   utl::default_delete<struct AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext> >

+   > > & __ptr64,struct EnableRequestResult const & __ptr64,unsigned char,enum

+   AdvertisingStateManager::EnableRequestAdvertisingType) __ptr64 */

 

 bool __thiscall

-AdvertisingRequestControllerModule::FindAndMarkAdvertisingEnableStoppedForRequestLocked

+AdvertisingRequestProgrammer::FindAndMarkAdvertisingEnableStoppedForRequestLocked

           (AdvertisingRequestProgrammer *this,

           list<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>,utl::allocator<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>_>_>

           *param_1,EnableRequestResult *param_2,uchar param_3,EnableRequestAdvertisingType param_4)

 

 {

-  undefined1 extraout_AL;

-  char *in_RAX;

-  byte unaff_BL;

-  undefined8 *unaff_RSI;

-  byte unaff_DIL;

-  undefined7 in_register_00000089;

-  uint *unaff_R14;

-  undefined8 uStack0000000000000040;

-  uint uStack0000000000000050;

+  longlong *plVar1;

+  uint uVar2;

+  list<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>,utl::allocator<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>_>_>

+  *plVar3;

+  longlong lVar4;

+  undefined8 *puVar5;

   

-  *in_RAX = *in_RAX + (char)in_RAX;

-  MicrosoftTelemetryAssertTriggeredMsgKM

-            ("Attempted to mark advertising for set as stopped but could not find set",param_1,

-             (char)param_2,CONCAT71(in_register_00000089,param_3));

-  wil::details::

-  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-  ::

-  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-              *)&stack0x00000060);

-  uStack0000000000000050 = *unaff_R14;

-  if (uStack0000000000000050 == 4) {

-    if (((unaff_BL & (byte)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) != 0) &&

-       (1 < (byte)WPP_GLOBAL_Control[0x29])) {

-      unaff_DIL = unaff_BL;

+  plVar3 = *(list<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>,utl::allocator<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>_>_>

+             **)param_1;

+  while( true ) {

+    if (plVar3 == param_1) {

+      return false;

     }

-    uStack0000000000000050 = (uint)(byte)unaff_R14[2];

-    uStack0000000000000040 = *(undefined8 *)unaff_RSI[1];

-    WPP_RECORDER_AND_TRACE_SF_qDL(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),unaff_DIL);

+    plVar1 = *(longlong **)(plVar3 + 0x10);

+    if (*(uchar *)(*plVar1 + 0x10) == param_3) break;

+    plVar3 = *(list<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>,utl::allocator<utl::unique_ptr<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext,utl::default_delete<AdvertisingRequestProgrammer::AdvertisingProgrammingRequestContext>_>_>_>

+               **)plVar3;

   }

-  else if (uStack0000000000000050 == 5) {

-    if (((unaff_BL & (byte)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) != 0) &&

-       (1 < (byte)WPP_GLOBAL_Control[0x29])) {

-      unaff_DIL = unaff_BL;

-    }

-    uStack0000000000000050 = unaff_R14[1];

-    uStack0000000000000040 = *(undefined8 *)unaff_RSI[1];

-    WPP_RECORDER_AND_TRACE_SF_qDD(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),unaff_DIL);

+  uVar2 = 0xc5;

+  if (param_4 != Periodic) {

+    uVar2 = 0x75;

   }

-  else {

-    if (((unaff_BL & (byte)*(undefined4 *)(WPP_GLOBAL_Control + 0x2c)) == 0) ||

-       ((byte)WPP_GLOBAL_Control[0x29] < 4)) {

-      unaff_BL = unaff_DIL;

-    }

-    uStack0000000000000040 = *(undefined8 *)unaff_RSI[1];

-    WPP_RECORDER_AND_TRACE_SF_qDExtAdvEnableSetReqStatus

-              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

-               CONCAT31((int3)(uStack0000000000000050 >> 8),unaff_BL));

+  lVar4 = 0xb0;

+  if (param_4 != Periodic) {

+    lVar4 = 0x60;

   }

-  SmFx::StateMachineEngine::StateMachineEngineImpl::EnqueueEvent

-            ((StateMachineEngineImpl *)*unaff_RSI,3);

-  return (bool)extraout_AL;

+  puVar5 = (undefined8 *)(lVar4 + (longlong)plVar1);

+  *puVar5 = *(undefined8 *)param_2;

+  *(undefined4 *)(puVar5 + 1) = *(undefined4 *)&param_2->HciErrorStatus;

+  if (*(char *)((longlong)puVar5 + 0xc) == '\0') {

+    *(undefined1 *)((longlong)puVar5 + 0xc) = 1;

+  }

+  *(undefined1 *)((ulonglong)uVar2 + (longlong)plVar1) = 1;

+  AdvertisingHandlePerformanceCounterToken::OnAdvertisingSetDisabled

+            ((AdvertisingHandlePerformanceCounterToken *)(*(longlong *)(plVar3 + 0x10) + 0x108));

+  return true;

 }
```

## `BroadcastIsochronousGroupStateMachine<BroadcastIsochronousGroupImpl>::EntryFuncs::NotifyingDestroyEntry`  (modified)

```diff
--- BroadcastIsochronousGroupStateMachine<BroadcastIsochronousGroupImpl>::EntryFuncs::NotifyingDestroyEntry
+++ BroadcastIsochronousGroupStateMachine<BroadcastIsochronousGroupImpl>::EntryFuncs::NotifyingDestroyEntry
@@ -1,2 +1,20 @@
-Failed to decompile bthport.sys - .ProgramDB BroadcastIsochronousGroupStateMachine<BroadcastIsochronousGroupImpl>::EntryFuncs::NotifyingDestroyEntry : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* public: static unsigned short __cdecl BroadcastIsochronousGroupStateMachine<class

+   BroadcastIsochronousGroupImpl>::EntryFuncs::NotifyingDestroyEntry(void * __ptr64) */

+

+ushort __cdecl

+BroadcastIsochronousGroupStateMachine<BroadcastIsochronousGroupImpl>::EntryFuncs::

+NotifyingDestroyEntry(void *param_1)

+

+{

+  Event EVar1;

+  BroadcastIsochronousGroupImpl *this;

+  

+  this = (BroadcastIsochronousGroupImpl *)

+         (-(ulonglong)(param_1 != (void *)0x0) & (longlong)param_1 - 8U);

+  PowerCoordinator::PowerReference::Reset((PowerReference *)(this + 0x78));

+  EVar1 = BroadcastIsochronousGroupImpl::NotifyTerminate(this);

+  return (ushort)EVar1;

+}

+
```

## `BroadcastIsoRegistrar::SetupDataPath`  (modified)

```diff
--- BroadcastIsoRegistrar::SetupDataPath
+++ BroadcastIsoRegistrar::SetupDataPath
@@ -1,30 +1,57 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* public: long __cdecl BroadcastIsoRegistrar::SetupDataPath(unsigned long,unsigned char,struct

+   IsoDataPathConfig & __ptr64,void * __ptr64) __ptr64 */

 

 long __thiscall

-BroadcastIsoGroupSyncManager::SetupDataPath

+BroadcastIsoRegistrar::SetupDataPath

           (BroadcastIsoRegistrar *this,ulong param_1,uchar param_2,IsoDataPathConfig *param_3,

           void *param_4)

 

 {

-  undefined8 *puVar1;

+  long lVar1;

+  undefined4 in_register_00000014;

+  uint7 uVar4;

   longlong lVar2;

   undefined8 uVar3;

-  undefined4 in_register_00000014;

-  longlong unaff_RBP;

-  longlong unaff_RDI;

+  undefined7 in_register_00000081;

+  longlong *local_18;

+  _RefCountBase *local_10;

   

-  puVar1 = (undefined8 *)((longlong)(this->m_bigHciHandleFactory).m_buffer + unaff_RBP + -0x24);

-  lVar2 = puVar1[1];

-  uVar3 = *puVar1;

-  *(undefined8 *)CONCAT44(in_register_00000014,param_1) = uVar3;

-  *(longlong *)(CONCAT44(in_register_00000014,param_1) + 8) = lVar2;

-  if (lVar2 != 0) {

-    LOCK();

-    *(int *)(lVar2 + 8) = *(int *)(lVar2 + 8) + 1;

-    UNLOCK();

+  uVar4 = (uint7)(CONCAT44(in_register_00000014,param_1) >> 8);

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 4)) {

+    lVar2 = (ulonglong)uVar4 << 8;

   }

-  *(longlong *)(unaff_RDI + 8) = *(longlong *)(unaff_RDI + 8) + 0x10;

-  return (long)CONCAT71((int7)((ulonglong)uVar3 >> 8),1);

+  else {

+    lVar2 = CONCAT71(uVar4,1);

+  }

+  WPP_RECORDER_AND_TRACE_SF_qDD

+            (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),lVar2,CONCAT71(in_register_00000081,1),

+             this->m_fdo->m_recorderLog,4,1,0x30,&WPP_cb68e6af7750347b176838067ba960d9_Traceguids,

+             *(undefined8 *)this->m_fdo,param_1,param_2);

+  FindBig(this,(shared_ptr<BroadcastIsochronousGroup> *)&local_18,param_1,param_4);

+  if (local_18 == (longlong *)0x0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar3 = 0;

+    }

+    else {

+      uVar3 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar3,1,this->m_fdo->m_recorderLog,2,1,

+               0x31,&WPP_cb68e6af7750347b176838067ba960d9_Traceguids,*(undefined8 *)this->m_fdo);

+    if (local_10 != (_RefCountBase *)0x0) {

+      utl::_RefCountBase::_DecStrong(local_10);

+    }

+    lVar1 = -0x3ffffff3;

+  }

+  else {

+    lVar1 = (**(code **)(*local_18 + 0x28))(local_18,param_2,param_3);

+    if (local_10 != (_RefCountBase *)0x0) {

+      utl::_RefCountBase::_DecStrong(local_10);

+    }

+  }

+  return lVar1;

 }
```

## `BroadcastIsochronousGroupImpl::HandlePowerManagementUpdateRequest`  (modified)

```diff
--- BroadcastIsochronousGroupImpl::HandlePowerManagementUpdateRequest
+++ BroadcastIsochronousGroupImpl::HandlePowerManagementUpdateRequest
@@ -1,2 +1,59 @@
-Failed to decompile bthport.sys - .ProgramDB BroadcastIsochronousGroupImpl::HandlePowerManagementUpdateRequest : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: void __cdecl BroadcastIsochronousGroupImpl::HandlePowerManagementUpdateRequest(void)

+   __ptr64 */

+

+void __thiscall

+BroadcastIsochronousGroupImpl::HandlePowerManagementUpdateRequest

+          (BroadcastIsochronousGroupImpl *this)

+

+{

+  PowerReference *this_00;

+  BroadcastIsochronousGroupImpl BVar1;

+  PowerReference *pPVar2;

+  char cVar3;

+  undefined1 uVar4;

+  PowerReference local_18;

+  

+  wil::acquire_kspin_lock((__uint64 *)&local_18);

+  BVar1 = this[0x70];

+  wil::details::

+  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+  ::

+  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+              *)&local_18);

+  uVar4 = 0;

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+     (cVar3 = '\x01', (byte)WPP_GLOBAL_Control[0x29] < 5)) {

+    cVar3 = '\0';

+  }

+  if ((cVar3 != '\0') || (*(short *)(WPP_GLOBAL_Control + 0x48) != 0)) {

+    WPP_RECORDER_AND_TRACE_SF_ql

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),cVar3,

+               *(short *)(WPP_GLOBAL_Control + 0x48) != 0,

+               *(undefined8 *)(*(longlong *)(this + 0x28) + 0x20));

+  }

+  this_00 = (PowerReference *)(this + 0x78);

+  if (BVar1 == (BroadcastIsochronousGroupImpl)0x0) {

+    PowerCoordinator::PowerReference::Reset(this_00);

+  }

+  else if (this_00->m_powerCoordinator == (PowerCoordinator *)0x0) {

+    pPVar2 = PowerCoordinator::AcquirePowerReference

+                       ((PowerCoordinator *)(*(longlong *)(this + 0x28) + 0x630),&local_18,Bis);

+    PowerCoordinator::PowerReference::operator=(this_00,pPVar2);

+    PowerCoordinator::PowerReference::Reset(&local_18);

+    if (this_00->m_powerCoordinator == (PowerCoordinator *)0x0) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29]))

+      {

+        uVar4 = 1;

+      }

+      WPP_RECORDER_AND_TRACE_SF_i

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar4,1,

+                 (*(undefined8 **)(this + 0x28))[4],2,1,0x2f,

+                 &WPP_524b11a325ae3d150adb2f715246fb98_Traceguids,**(undefined8 **)(this + 0x28));

+    }

+  }

+  return;

+}

+
```

## `ScanRequestControllerModule::OnScanRequest`  (modified)

```diff
--- ScanRequestControllerModule::OnScanRequest
+++ ScanRequestControllerModule::OnScanRequest
@@ -1,42 +1,213 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: void __cdecl ScanRequestControllerModule::OnScanRequest(struct WDFREQUEST__ *

+   __ptr64,unsigned __int64,unsigned __int64) __ptr64 */

 

 void __thiscall

-ScanProgrammingRequestResult::OnScanRequest

+ScanRequestControllerModule::OnScanRequest

           (ScanRequestControllerModule *this,WDFREQUEST__ *param_1,__uint64 param_2,__uint64 param_3

           )

 

 {

-  int *piVar1;

-  uint uVar2;

-  undefined8 in_RAX;

-  longlong lVar3;

-  undefined1 unaff_BL;

-  longlong unaff_RBP;

-  undefined8 unaff_R13;

-  longlong unaff_R14;

+  ushort uVar1;

+  ushort uVar2;

+  undefined4 uVar3;

+  undefined4 uVar4;

+  bool bVar5;

+  char cVar6;

+  int iVar7;

+  _BTHLE_SCAN_FILTER_POLICY _Var8;

+  FileObject *pFVar9;

+  ScanWdfRequest *pSVar10;

+  _GUID *p_Var11;

+  uint uVar12;

+  undefined1 uVar13;

+  undefined1 uVar14;

+  _GUID *p_Var15;

+  Fdo *pFVar16;

+  _tlgProvider_t *p_Var17;

+  uint uVar18;

+  undefined8 uVar19;

+  undefined8 uVar20;

+  _tlgWrapperByVal<1> local_48;

+  _tlgWrapperByVal<1> local_47;

+  undefined2 local_46;

+  undefined2 local_44 [2];

+  _tlgProvider_t *local_40;

+  _GUID local_38;

+  GUID *local_28;

+  _GUID *local_20;

   

-  lVar3 = CONCAT71((int7)((ulonglong)in_RAX >> 8),(char)in_RAX + -10);

-  piVar1 = (int *)(lVar3 * 9 + -0x48f0818c);

-  *piVar1 = *piVar1 + 1;

-  uVar2 = *(uint *)(param_2 - 0x73);

-  *(short *)(unaff_RBP + -0x13) = (short)lVar3 + -0x362e;

-  *(undefined2 *)(unaff_RBP + -0x15) = *(undefined2 *)(unaff_RBP + 0x25);

-  *(undefined1 *)(unaff_RBP + -0x17) = *(undefined1 *)(unaff_RBP + 0x1f);

-  lVar3 = *(longlong *)(unaff_R14 + 8);

-  *(undefined1 *)(unaff_RBP + -0x19) = unaff_BL;

-  *(longlong *)(unaff_RBP + -1) = lVar3 + 0x600;

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

-  *(undefined8 *)(unaff_RBP + -0x11) = 0x2000800;

-  _tlgWriteTemplate<long___cdecl(_tlgProvider_t_const*___ptr64,void_const*___ptr64,_GUID_const*___ptr64,_GUID_const*___ptr64,unsigned_int,_EVENT_DATA_DESCRIPTOR*___ptr64),&long___cdecl__tlgWriteTransfer_EtwWriteTransfer(struct__tlgProvider_t_const*___ptr64,void_const*___ptr64,struct__GUID_const*___ptr64,struct__GUID_const*___ptr64,unsigned_int,struct__EVENT_DATA_DESCRIPTOR*___ptr64),_GUID_const*___ptr64,_GUID_const*___ptr64>

-  ::

-  Write<_tlgWrapperByVal<8>,_tlgWrapperByRef<16>,_tlgWrapperByRef<16>,_tlgWrapperByVal<1>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>_>

-            ((_tlgProvider_t *)this,param_1,(_GUID *)param_2,

-             (_GUID *)(ulonglong)((uint)param_3 & uVar2),(_tlgWrapperByVal<8> *)(unaff_RBP + -0x11),

-             (_tlgWrapperByRef<16> *)(unaff_RBP + -1),(_tlgWrapperByRef<16> *)(unaff_RBP + 0xf),

-             (_tlgWrapperByVal<1> *)(unaff_RBP + -0x19),(_tlgWrapperByVal<1> *)(unaff_RBP + -0x17),

-             (_tlgWrapperByVal<2> *)(unaff_RBP + -0x15),(_tlgWrapperByVal<2> *)(unaff_RBP + -0x13));

-  func_0x0001400a0d80();

+  pFVar9 = FileObject::FromWdfRequest(param_1);

+  uVar14 = 0;

+  if (pFVar9 == (FileObject *)0x0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+       (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+      uVar14 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_qq

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,this->m_fdo->m_ioRecorderLog,2,

+               0x10,0x19,&WPP_2e6552709e133ba3701105413e946a79_Traceguids,*(undefined8 *)this->m_fdo

+               ,param_1);

+    iVar7 = -0x3fffffde;

+    goto LAB_0;

+  }

+  uVar13 = 0;

+  if (param_2 != 0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+       (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+      uVar13 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_qqI(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar13);

+    iVar7 = -0x3ffffdfa;

+    goto LAB_0;

+  }

+  if (param_3 == 0x10) {

+    local_40 = (_tlgProvider_t *)0x0;

+    iVar7 = (**(code **)(WdfFunctions_01031 + 0x868))(WdfDriverGlobals,param_1,0x10,&local_40,0);

+    if (iVar7 < 0) {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+         (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+        uVar13 = 1;

+      }

+      WPP_RECORDER_AND_TRACE_SF_qqdPP

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar13,WPP_GLOBAL_Control,

+                 this->m_fdo->m_ioRecorderLog);

+      goto LAB_0;

+    }

+    uVar12 = local_40->LevelPlus1;

+    if ((uVar12 & 0xfffffffe) == 0) {

+      uVar1 = *(ushort *)((longlong)&local_40->ProviderMetadataPtr + 4);

+      uVar18 = (uint)uVar1;

+      uVar2 = *(ushort *)((longlong)&local_40->ProviderMetadataPtr + 6);

+      uVar12 = (uint)uVar2;

+      p_Var17 = local_40;

+      bVar5 = ScanningPhyParameters::ValidateScanParameters(uVar1,uVar2);

+      if (!bVar5) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar14 = 1;

+        }

+        WPP_RECORDER_AND_TRACE_SF_qqDD

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,this->m_fdo->m_ioRecorderLog,

+                   2,0x10,0x1e,&WPP_2e6552709e133ba3701105413e946a79_Traceguids,

+                   *(undefined8 *)this->m_fdo,param_1,uVar12,uVar18);

+        goto LAB_1;

+      }

+      uVar12 = *(uint *)&p_Var17->field_0x4;

+      if (uVar12 < 2) {

+        iVar7 = ScanWdfRequest::Make(param_1);

+        if (-1 < iVar7) {

+          p_Var15 = (_GUID *)PTR__WDF_ScanWdfRequest_TYPE_INFO_14019a4c8;

+          pSVar10 = (ScanWdfRequest *)

+                    (**(code **)(WdfFunctions_01031 + 0x650))(WdfDriverGlobals,param_1);

+          p_Var11 = Microsoft::Bluetooth::Foundation::ActivityIdFactory::GetNextId(&local_38);

+          uVar1 = p_Var11->Data2;

+          uVar2 = p_Var11->Data3;

+          uVar20 = *(undefined8 *)p_Var11->Data4;

+          (pSVar10->ValidatedParameters).RequestId.Data1 = p_Var11->Data1;

+          (pSVar10->ValidatedParameters).RequestId.Data2 = uVar1;

+          (pSVar10->ValidatedParameters).RequestId.Data3 = uVar2;

+          *(undefined8 *)(pSVar10->ValidatedParameters).RequestId.Data4 = uVar20;

+          if ((local_40->LevelPlus1 & 1) == 0) {

+            _Var8 = AcceptAllFilterPolicy;

+          }

+          else {

+            _Var8 = *(_BTHLE_SCAN_FILTER_POLICY *)&local_40->ProviderMetadataPtr;

+          }

+          (pSVar10->ValidatedParameters).FilterPolicy = _Var8;

+          local_38.Data4[0] = '\x01';

+          uVar4 = local_38.Data4._0_4_;

+          uVar3 = *(undefined4 *)((longlong)&local_40->ProviderMetadataPtr + 4);

+          local_38.Data2 = (short)uVar3;

+          local_38.Data3 = (short)((uint)uVar3 >> 0x10);

+          local_38.Data1 = *(ulong *)&local_40->field_0x4;

+          uVar20 = local_38._0_8_;

+          local_38.Data2 = (ushort)uVar3;

+          local_38.Data3 = (ushort)((uint)uVar3 >> 0x10);

+          *(ulong *)&(pSVar10->ValidatedParameters).Uncoded1MPhyParameters.field_0x0 =

+               *(ulong *)&local_40->field_0x4;

+          *(ushort *)&(pSVar10->ValidatedParameters).Uncoded1MPhyParameters.field_0x4 =

+               local_38.Data2;

+          *(ushort *)&(pSVar10->ValidatedParameters).Uncoded1MPhyParameters.field_0x6 =

+               local_38.Data3;

+          (pSVar10->ValidatedParameters).Uncoded1MPhyParameters.field_0x8 = '\x01';

+          (pSVar10->ValidatedParameters).Uncoded1MPhyParameters.field_0x9 = local_38.Data4[1];

+          (pSVar10->ValidatedParameters).Uncoded1MPhyParameters.field_0xa = local_38.Data4[2];

+          (pSVar10->ValidatedParameters).Uncoded1MPhyParameters.field_0xb = local_38.Data4[3];

+          if ((pSVar10->ValidatedParameters).Uncoded1MPhyParameters.field_0xc == '\0') {

+            (pSVar10->ValidatedParameters).Uncoded1MPhyParameters.field_0xc = 1;

+          }

+          (pSVar10->ValidatedParameters).Source = ClientScanRequest;

+          local_38._0_8_ = uVar20;

+          local_38.Data4._0_4_ = uVar4;

+          if ((5 < (uint)DAT_2) &&

+             (cVar6 = _tlgKeywordOn(&DAT_2,0x400000000000), cVar6 != '\0')) {

+            local_46 = *(undefined2 *)((longlong)&local_40->ProviderMetadataPtr + 4);

+            local_44[0] = *(undefined2 *)((longlong)&local_40->ProviderMetadataPtr + 6);

+            local_48 = (_tlgWrapperByVal<1>)local_40->field_0x4;

+            local_28 = &`public:_bool___cdecl_SmpSecureKey<16,1>::IsValid(void)const___ptr64'::__l2

+                        ::emptyKey;

+            local_20 = &(this->m_fdo->m_devExt).DeviceExtensionSessionId;

+            local_47 = (_tlgWrapperByVal<1>)0x0;

+            local_38.Data1 = 0x2000800;

+            local_38.Data2 = 0;

+            local_38.Data3 = 0;

+            _tlgWriteTemplate<long___cdecl(_tlgProvider_t_const*___ptr64,void_const*___ptr64,_GUID_const*___ptr64,_GUID_const*___ptr64,unsigned_int,_EVENT_DATA_DESCRIPTOR*___ptr64),&long___cdecl__tlgWriteTransfer_EtwWriteTransfer(struct__tlgProvider_t_const*___ptr64,void_const*___ptr64,struct__GUID_const*___ptr64,struct__GUID_const*___ptr64,unsigned_int,struct__EVENT_DATA_DESCRIPTOR*___ptr64),_GUID_const*___ptr64,_GUID_const*___ptr64>

+            ::

+            Write<_tlgWrapperByVal<8>,_tlgWrapperByRef<16>,_tlgWrapperByRef<16>,_tlgWrapperByVal<1>,_tlgWrapperByVal<1>,_tlgWrapperByVal<2>,_tlgWrapperByVal<2>_>

+                      (local_40,&DAT_3,p_Var15,(_GUID *)p_Var17,

+                       (_tlgWrapperByVal<8> *)&local_38,(_tlgWrapperByRef<16> *)&local_20,

+                       (_tlgWrapperByRef<16> *)&local_28,&local_47,&local_48,

+                       (_tlgWrapperByVal<2> *)local_44,(_tlgWrapperByVal<2> *)&local_46);

+          }

+          ProgramRequest(this,pSVar10);

+          return;

+        }

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+           (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+          uVar14 = 1;

+        }

+        WPP_RECORDER_AND_TRACE_SF_qqd

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar14,1,this->m_fdo->m_ioRecorderLog,

+                   2,0x10,0x20,&WPP_2e6552709e133ba3701105413e946a79_Traceguids,

+                   *(undefined8 *)this->m_fdo,param_1,iVar7);

+        goto LAB_0;

+      }

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+         (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+        uVar14 = 1;

+      }

+      pFVar16 = this->m_fdo;

+      uVar20 = *(undefined8 *)pFVar16;

+      uVar19 = 0x1f;

+    }

+    else {

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+         (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+        uVar14 = 1;

+      }

+      pFVar16 = this->m_fdo;

+      uVar20 = *(undefined8 *)pFVar16;

+      uVar19 = 0x1d;

+    }

+    WPP_RECORDER_AND_TRACE_SF_qqd

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),CONCAT31((int3)(uVar12 >> 8),uVar14),1,

+               pFVar16->m_ioRecorderLog,2,0x10,uVar19,

+               &WPP_2e6552709e133ba3701105413e946a79_Traceguids,uVar20,param_1,uVar12);

+  }

+  else {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x8000) != 0) &&

+       (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+      uVar13 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_qqPP(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar13);

+  }

+LAB_1:

+  iVar7 = -0x3ffffff3;

+LAB_0:

+  (**(code **)(WdfFunctions_01031 + 0x838))(WdfDriverGlobals,param_1,iVar7);

   return;

 }
```

## `HciLEExtendedAdvertisingRequestCoordinator::RemoveAdvertisingSetCommandComplete`  (modified)

```diff
--- HciLEExtendedAdvertisingRequestCoordinator::RemoveAdvertisingSetCommandComplete
+++ HciLEExtendedAdvertisingRequestCoordinator::RemoveAdvertisingSetCommandComplete
@@ -1,2 +1,36 @@
-Failed to decompile bthport.sys - .ProgramDB HciLEExtendedAdvertisingRequestCoordinator::RemoveAdvertisingSetCommandComplete : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: void __cdecl

+   HciLEExtendedAdvertisingRequestCoordinator::RemoveAdvertisingSetCommandComplete(struct

+   _HCI_CALLBACK_DATA const & __ptr64) __ptr64 */

+

+void __thiscall

+HciLEExtendedAdvertisingRequestCoordinator::RemoveAdvertisingSetCommandComplete

+          (HciLEExtendedAdvertisingRequestCoordinator *this,_HCI_CALLBACK_DATA *param_1)

+

+{

+  longlong *plVar1;

+  HciLEExtendedAdvertisingRequestCoordinator *this_00;

+  undefined4 uVar2;

+  

+  this_00 = this;

+  StoreHciCommandCompleteResults(this,param_1);

+  uVar2 = 0;

+  if ((-1 < param_1->Status) && (param_1->BtStatus == '\0')) {

+    plVar1 = (longlong *)GetCurrentAdvertisingSet(this);

+    if ((*(uint *)(*plVar1 + 0x10) & 2) != 0) {

+      LOCK();

+      *(int *)(this_00 + 0x40) = *(int *)(this_00 + 0x40) + -1;

+      UNLOCK();

+    }

+    plVar1 = (longlong *)GetCurrentAdvertisingSet(this_00);

+    *(undefined4 *)(*plVar1 + 0x10) = uVar2;

+    plVar1 = (longlong *)GetCurrentAdvertisingSet(this_00);

+    AdvertisingHandlePerformanceCounterToken::OnAdvertisingHandleRemoved

+              ((AdvertisingHandlePerformanceCounterToken *)(*plVar1 + 0x60));

+  }

+  AdvertisingStateManagerStateMachine<AdvertisingStateManager>::EnqueueEvent

+            ((AdvertisingStateManagerStateMachine<AdvertisingStateManager> *)(this_00 + 8),8);

+  return;

+}

+
```

## `Fdo::~Fdo`  (modified)

```diff
--- Fdo::~Fdo
+++ Fdo::~Fdo
@@ -1,11 +1,130 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: __cdecl Fdo::~Fdo(void) __ptr64 */

 

-void __thiscall EtwLogger::~Fdo(Fdo *this)

+void __thiscall Fdo::~Fdo(Fdo *this)

 

 {

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

-  halt_baddata();

+  _LIST_ENTRY *p_Var1;

+  _IO_REMOVE_LOCK *p_Var2;

+  DEVICE_EXTENSION *this_00;

+  HCI_INTERFACE *pHVar3;

+  _LIST_ENTRY *p_Var4;

+  _LIST_ENTRY *p_Var5;

+  _SDP_DATABASE *p_Var6;

+  _SDP_INTERFACE *p_Var7;

+  _SMP_INTERFACE *p_Var8;

+  L2CAP_INTERFACE *pLVar9;

+  _SCO_INTERFACE *p_Var10;

+  code *pcVar11;

+  default_delete<_SDP_DATABASE> *this_01;

+  undefined *puVar12;

+  unique_storage<wil::details::resource_policy<_FAST_MUTEX*___ptr64,void___cdecl(_FAST_MUTEX*___ptr64)_noexcept,&void___cdecl_wil::details::release_fast_mutex_with_critical_region(struct__FAST_MUTEX*___ptr64),wistd::integral_constant<unsigned___int64,2>,_FAST_MUTEX*___ptr64,_FAST_MUTEX*___ptr64,0,std::nullptr_t>_>

+  local_res8 [8];

+  

+  puVar12 = WPP_GLOBAL_Control;

+  GetRecorderLog(this);

+  WPP_RECORDER_AND_TRACE_SF_i(*(undefined8 *)(puVar12 + 0x18));

+  LOCK();

+  if ((this->m_devExt).BtDevice.FunctionalDeviceObject == DAT_0) {

+    DAT_0 = (_DEVICE_OBJECT *)0x0;

+  }

+  UNLOCK();

+  LogDriverRemoveEvent(this);

+  BthSetPolicyChangedCallback(0,0);

+  if ((this->m_devExt).CsHandle != (void *)0x0) {

+    PoUnregisterPowerSettingCallback();

+    (this->m_devExt).CsHandle = (void *)0x0;

+  }

+  pHVar3 = (this->m_devExt).Hci;

+  if (pHVar3 != (HCI_INTERFACE *)0x0) {

+    HCI_Shutdown(pHVar3);

+  }

+  SleepStudyComponent::Uninitialize(&(this->m_devExt).SleepstudyFdoComponent);

+  ErrorRecovery::Uninitialize(&(this->m_devExt).ErrorRecoveryHandler);

+  p_Var2 = &(this->m_devExt).RemoveLock;

+  IoAcquireRemoveLockEx

+            (p_Var2,"EvtObjectContextCleanup",

+             "onecore\\drivers\\wdm\\bluetooth\\drivers\\bthport\\src\\fdo.cpp",0x1ff,0x20);

+  IoReleaseRemoveLockAndWaitEx(p_Var2,"EvtObjectContextCleanup",0x20);

+  wil::acquire_fast_mutex_with_critical_region((_FAST_MUTEX *)local_res8);

+  p_Var1 = &this->m_driverGlobalListEntry;

+  p_Var4 = p_Var1->Flink;

+  if ((p_Var4->Blink == p_Var1) &&

+     (p_Var5 = (this->m_driverGlobalListEntry).Blink, p_Var5->Flink == p_Var1)) {

+    p_Var5->Flink = p_Var4;

+    p_Var4->Blink = p_Var5;

+    (this->m_driverGlobalListEntry).Blink = p_Var1;

+    p_Var1->Flink = p_Var1;

+    wil::details::

+    unique_storage<wil::details::resource_policy<_FAST_MUTEX*___ptr64,void___cdecl(_FAST_MUTEX*___ptr64)_noexcept,&void___cdecl_wil::details::release_fast_mutex_with_critical_region(struct__FAST_MUTEX*___ptr64),wistd::integral_constant<unsigned___int64,2>,_FAST_MUTEX*___ptr64,_FAST_MUTEX*___ptr64,0,std::nullptr_t>_>

+    ::

+    ~unique_storage<wil::details::resource_policy<_FAST_MUTEX*___ptr64,void___cdecl(_FAST_MUTEX*___ptr64)_noexcept,&void___cdecl_wil::details::release_fast_mutex_with_critical_region(struct__FAST_MUTEX*___ptr64),wistd::integral_constant<unsigned___int64,2>,_FAST_MUTEX*___ptr64,_FAST_MUTEX*___ptr64,0,std::nullptr_t>_>

+              (local_res8);

+    this_00 = &this->m_devExt;

+    this_01 = (default_delete<_SDP_DATABASE> *)this_00;

+    BthCleanUpFakePdoExtensions(this_00);

+    p_Var6 = (this->m_devExt).SdpDB._MyDat._MyRealVal;

+    if (p_Var6 != (_SDP_DATABASE *)0x0) {

+      (this->m_devExt).SdpDB._MyDat._MyRealVal = (_SDP_DATABASE *)0x0;

+      utl::default_delete<_SDP_DATABASE>::operator()(this_01,p_Var6);

+    }

+    p_Var7 = (this->m_devExt).Sdp;

+    if (p_Var7 != (_SDP_INTERFACE *)0x0) {

+      SdpInt_Destroy(p_Var7);

+      (this->m_devExt).Sdp = (_SDP_INTERFACE *)0x0;

+    }

+    p_Var8 = (this->m_devExt).Smp;

+    if (p_Var8 != (_SMP_INTERFACE *)0x0) {

+      SMPInt_Destroy(p_Var8);

+      (this->m_devExt).Smp = (_SMP_INTERFACE *)0x0;

+    }

+    pLVar9 = (this->m_devExt).L2cap;

+    if (pLVar9 != (L2CAP_INTERFACE *)0x0) {

+      L2CapInt_Release(pLVar9);

+      (this->m_devExt).L2cap = (L2CAP_INTERFACE *)0x0;

+    }

+    p_Var10 = (this->m_devExt).Sco;

+    if (p_Var10 != (_SCO_INTERFACE *)0x0) {

+      ScoInt_Release(p_Var10);

+      (this->m_devExt).Sco = (_SCO_INTERFACE *)0x0;

+    }

+    pHVar3 = (this->m_devExt).Hci;

+    if (pHVar3 != (HCI_INTERFACE *)0x0) {

+      HCI_VS_MSFT_TrackedFiltersCleanup(pHVar3);

+      HCI_DibDrainDestructionList((this->m_devExt).Hci);

+      pHVar3 = (this->m_devExt).Hci;

+      HCI_Release(pHVar3,pHVar3);

+      (this->m_devExt).Hci = (HCI_INTERFACE *)0x0;

+    }

+    PowerCoordinator::PowerReference::Reset

+              (&(this->m_powerCoordinator).m_idleDisabledPowerReference);

+    DEVICE_EXTENSION::~DEVICE_EXTENSION(this_00);

+    wil::details::

+    unique_storage<wil::details::resource_policy<WDFDEVICE__*___ptr64,void_(__cdecl*)(void*___ptr64),&void___cdecl_WdfObjectDelete(void*___ptr64),wistd::integral_constant<unsigned___int64,0>,WDFDEVICE__*___ptr64,WDFDEVICE__*___ptr64,0,std::nullptr_t>_>

+    ::

+    ~unique_storage<wil::details::resource_policy<WDFDEVICE__*___ptr64,void_(__cdecl*)(void*___ptr64),&void___cdecl_WdfObjectDelete(void*___ptr64),wistd::integral_constant<unsigned___int64,0>,WDFDEVICE__*___ptr64,WDFDEVICE__*___ptr64,0,std::nullptr_t>_>

+              ((unique_storage<wil::details::resource_policy<WDFDEVICE__*___ptr64,void_(__cdecl*)(void*___ptr64),&void___cdecl_WdfObjectDelete(void*___ptr64),wistd::integral_constant<unsigned___int64,0>,WDFDEVICE__*___ptr64,WDFDEVICE__*___ptr64,0,std::nullptr_t>_>

+                *)&this->m_deviceInterfaceSymbolicLink);

+    Controller::~Controller(&this->m_controller);

+    wil::details::

+    unique_storage<wil::details::resource_policy<RECORDER_LOG__*___ptr64,void_(__cdecl*)(RECORDER_LOG__*___ptr64),&void___cdecl_WppRecorderLogCloseFunction(struct_RECORDER_LOG__*___ptr64),wistd::integral_constant<unsigned___int64,0>,RECORDER_LOG__*___ptr64,RECORDER_LOG__*___ptr64,0,std::nullptr_t>_>

+    ::

+    ~unique_storage<wil::details::resource_policy<RECORDER_LOG__*___ptr64,void_(__cdecl*)(RECORDER_LOG__*___ptr64),&void___cdecl_WppRecorderLogCloseFunction(struct_RECORDER_LOG__*___ptr64),wistd::integral_constant<unsigned___int64,0>,RECORDER_LOG__*___ptr64,RECORDER_LOG__*___ptr64,0,std::nullptr_t>_>

+              ((unique_storage<wil::details::resource_policy<RECORDER_LOG__*___ptr64,void_(__cdecl*)(RECORDER_LOG__*___ptr64),&void___cdecl_WppRecorderLogCloseFunction(struct_RECORDER_LOG__*___ptr64),wistd::integral_constant<unsigned___int64,0>,RECORDER_LOG__*___ptr64,RECORDER_LOG__*___ptr64,0,std::nullptr_t>_>

+                *)&this->m_ioRecorderLog);

+    wil::details::

+    unique_storage<wil::details::resource_policy<RECORDER_LOG__*___ptr64,void_(__cdecl*)(RECORDER_LOG__*___ptr64),&void___cdecl_WppRecorderLogCloseFunction(struct_RECORDER_LOG__*___ptr64),wistd::integral_constant<unsigned___int64,0>,RECORDER_LOG__*___ptr64,RECORDER_LOG__*___ptr64,0,std::nullptr_t>_>

+    ::

+    ~unique_storage<wil::details::resource_policy<RECORDER_LOG__*___ptr64,void_(__cdecl*)(RECORDER_LOG__*___ptr64),&void___cdecl_WppRecorderLogCloseFunction(struct_RECORDER_LOG__*___ptr64),wistd::integral_constant<unsigned___int64,0>,RECORDER_LOG__*___ptr64,RECORDER_LOG__*___ptr64,0,std::nullptr_t>_>

+              ((unique_storage<wil::details::resource_policy<RECORDER_LOG__*___ptr64,void_(__cdecl*)(RECORDER_LOG__*___ptr64),&void___cdecl_WppRecorderLogCloseFunction(struct_RECORDER_LOG__*___ptr64),wistd::integral_constant<unsigned___int64,0>,RECORDER_LOG__*___ptr64,RECORDER_LOG__*___ptr64,0,std::nullptr_t>_>

+                *)&this->m_recorderLog);

+    return;

+  }

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

+  (*pcVar11)(3);

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

+  (*pcVar11)();

+  return;

 }
```

## `AdvertisementMonitorProgrammer::OnHciEvent`  (modified)

```diff
--- AdvertisementMonitorProgrammer::OnHciEvent
+++ AdvertisementMonitorProgrammer::OnHciEvent
@@ -1,494 +1,179 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* public: void __cdecl AdvertisementMonitorProgrammer::OnHciEvent(struct

+   _HCI_EVENT_VS_MSFT_LE_Monitor_Device const & __ptr64) __ptr64 */

 

 void __thiscall

-AdvertisementMonitorParameters::OnHciEvent

+AdvertisementMonitorProgrammer::OnHciEvent

           (AdvertisementMonitorProgrammer *this,_HCI_EVENT_VS_MSFT_LE_Monitor_Device *param_1)

 

 {

-  longlong *plVar1;

-  int *piVar2;

-  list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

-  *this_00;

-  void *pvVar3;

-  vector<utl::byte,utl::allocator<utl::byte>_> *pvVar4;

-  longlong lVar5;

+  int *piVar1;

+  ulong *puVar2;

+  ulong uVar3;

+  int iVar4;

+  RadioPerfCounters *this_00;

+  bool bVar5;

   undefined8 uVar6;

-  undefined8 uVar7;

-  AdvertisementMonitorProgrammer *this_01;

-  Fdo *pFVar8;

-  unique_any_t<wil::details::unique_storage<wil::details::resource_policy<RECORDER_LOG___*,void_(__cdecl*)(RECORDER_LOG___*),&void___cdecl_WppRecorderLogCloseFunction(RECORDER_LOG___*),wistd::integral_constant<unsigned___int64,0>,RECORDER_LOG___*,RECORDER_LOG___*,0,std::nullptr_t>_>_>

-  uVar9;

-  AdvertisementMonitorParameters *this_02;

-  HCI_INTERFACE *pHVar10;

-  code *pcVar11;

-  bool bVar12;

-  char cVar13;

-  longlong in_RAX;

-  undefined8 *puVar14;

-  char *pcVar15;

-  ulonglong *puVar16;

-  _RefCountBase *p_Var17;

-  ulonglong uVar18;

-  undefined8 uVar19;

-  intrusive_list_hook *piVar20;

-  undefined8 *puVar21;

-  undefined1 *puVar22;

-  undefined1 *puVar23;

-  undefined1 *puVar24;

-  _RefCountBase *p_Var25;

-  _RefCountBase *this_03;

-  _HCI_COMMAND_HEADER *p_Var26;

-  longlong in_R8;

-  longlong lVar27;

-  _RefCountBase *p_Var28;

-  _RefCountBase *p_Var29;

-  __uint64 _Size;

-  AdvertisementMonitor *pAVar30;

-  AdvertisementMonitor *pAVar31;

-  undefined1 auStackY_128 [8];

-  undefined1 auStackY_120 [24];

-  undefined1 in_stack_fffffffffffffef8;

-  undefined7 in_stack_fffffffffffffef9;

+  undefined8 *puVar7;

+  ulonglong uVar8;

+  undefined8 *puVar9;

+  undefined1 uVar10;

+  undefined2 *puVar12;

+  uchar uVar13;

+  uchar local_res18 [8];

+  ulonglong local_res20;

+  __uint64 local_98;

+  undefined1 local_90 [8];

+  longlong local_88;

+  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+  local_80 [16];

+  undefined2 *local_70;

+  void *pvStack_68;

+  undefined8 local_60;

+  undefined **local_58;

+  ulonglong local_50;

+  uchar local_48;

+  uchar uVar11;

   

-  *(int *)(in_RAX + 0x18) = (int)in_RAX;

-  *(AdvertisementMonitorProgrammer **)(in_RAX + 8) = this;

-  puVar24 = auStackY_128;

-  puVar23 = auStackY_128;

-  puVar22 = auStackY_128;

-  p_Var28 = (_RefCountBase *)0x0;

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

-  utl::

-  _SharedAlloc<Microsoft::Bluetooth::Foundation::SharedState<AdvertisementMonitorProgrammingResult>,utl::allocator<int>,0>

-  ::

-  _Create<utl::shared_ptr<Microsoft::Bluetooth::Foundation::SharedState<AdvertisementMonitorProgrammingResult>_>_>

-            ((_SharedAlloc<Microsoft::Bluetooth::Foundation::SharedState<AdvertisementMonitorProgrammingResult>,utl::allocator<int>,0>

-              *)(in_RAX + -0x78));

-  utl::

-  _UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

-  ::

-  ~_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

-            ((_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

-              *)(in_RAX + -0x78));

-  Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>::Promise<UpdateRequestResult>

-            ((Promise<UpdateRequestResult> *)(in_RAX + -0xb8),

-             (shared_ptr<Microsoft::Bluetooth::Foundation::SharedState<UpdateRequestResult>_> *)

-             (in_RAX + -0xd8));

-  p_Var17 = *(_RefCountBase **)(in_RAX + -0xb0);

-  if (p_Var17 == (_RefCountBase *)0x0) {

-    param_1->MsftEvent = '\0';

-    param_1->AddressType = '\0';

-    (param_1->BD_ADDR).field0_0x0 = (_BDADDR_u_0)0x0;

-    (param_1->BD_ADDR).NAP = 0;

-    *(undefined8 *)&param_1->MonitorHandle = 0;

-LAB_0:

-    p_Var25 = *(_RefCountBase **)(in_RAX + -0xa8);

-    puVar22 = puVar24;

-  }

-  else {

-    p_Var25 = *(_RefCountBase **)(in_RAX + -0xa8);

-    p_Var29 = p_Var28;

-    if (*(char *)(in_RAX + -0xb8) == '\0') {

-      *(undefined1 *)(in_RAX + -0xb8) = 1;

-      p_Var28 = p_Var17;

-      p_Var29 = (_RefCountBase *)0x0;

-      if (p_Var25 != (_RefCountBase *)0x0) {

-        LOCK();

-        p_Var25->_MyStrong = p_Var25->_MyStrong + 1;

-        UNLOCK();

-        p_Var25 = *(_RefCountBase **)(in_RAX + -0xa8);

-        p_Var28 = *(_RefCountBase **)(in_RAX + -0xb0);

-        p_Var29 = p_Var25;

-        p_Var17 = p_Var28;

+  local_60 = 0xffffffffffffffff;

+  local_70 = (undefined2 *)0xffffffffffffffff;

+  pvStack_68 = (void *)0xffffffffffffffff;

+  bVar5 = utl::vector<utl::byte,utl::allocator<utl::byte>_>::reserve

+                    ((vector<utl::byte,utl::allocator<utl::byte>_> *)&local_70,0x14d);

+  uVar11 = '\0';

+  uVar10 = 0;

+  if (bVar5) {

+    memset(pvStack_68,0,0x14d);

+    puVar12 = local_70;

+    pvStack_68 = (void *)((longlong)local_70 + 0x14d);

+    if (param_1->MonitorState < 2) {

+      *(undefined4 *)(local_70 + 0x10) = 0xffffffff;

+      *local_70 = 1;

+      *(undefined8 *)(local_70 + 2) = 0x43772cafcfb4397c;

+      *(undefined8 *)(local_70 + 6) = 0x1b74893e30c17ead;

+      *(uchar *)((longlong)local_70 + 0x2d) = param_1->MonitorState;

+      uVar13 = param_1->AddressType;

+      uVar8 = (ulonglong)(uint6)param_1->BD_ADDR;

+      local_res20 = uVar8;

+      if ((this->m_fdo->m_devExt).IsSmpEnabled != '\0') {

+        local_98 = 0;

+        local_res18[0] = '\x01';

+        bVar5 = HCI_ResolveAddressIfIrkPresent

+                          ((this->m_fdo->m_devExt).Hci,&local_res20,uVar13,&local_98,local_res18);

+        if (bVar5) {

+          local_res20 = local_98;

+          uVar8 = local_98;

+          uVar13 = local_res18[0];

+        }

       }

-    }

-    utl::vector<IsoCisStatus,utl::allocator<IsoCisStatus>_>::

-    vector<IsoCisStatus,utl::allocator<IsoCisStatus>_>

-              ((vector<IsoCisStatus,utl::allocator<IsoCisStatus>_> *)(in_RAX + -0x90));

-    *(undefined8 *)(in_RAX + -0x88) = *(undefined8 *)(in_RAX + -0x90);

-    _Size = *(longlong *)(in_R8 + 0x68) - *(longlong *)(in_R8 + 0x60);

-    bVar12 = utl::vector<utl::byte,utl::allocator<utl::byte>_>::reserve

-                       ((vector<utl::byte,utl::allocator<utl::byte>_> *)(in_RAX + -0x90),_Size);

-    if (bVar12) {

-      pvVar3 = *(void **)(in_RAX + -0x88);

-      memmove(pvVar3,*(void **)(*(longlong *)(in_RAX + 0x18) + 0x60),_Size);

-      *(__uint64 *)(in_RAX + -0x88) = (longlong)pvVar3 + _Size;

-      pvVar4 = *(vector<utl::byte,utl::allocator<utl::byte>_> **)(in_RAX + 8);

-      utl::

-      make_shared<AdvertisementMonitor,AdvertisementMonitorProgrammer&___ptr64,utl::vector<utl::byte,utl::allocator<utl::byte>_>,AdvertisementMonitorParameters::HciCommandVersion_const&___ptr64,AdvertisementMonitor::PassKey,Fdo&___ptr64>

-                ((AdvertisementMonitorProgrammer *)(in_RAX + -0xa0),pvVar4,

-                 (HciCommandVersion *)(in_RAX + -0x90),*(PassKey **)(in_RAX + 0x18),

-                 (Fdo *)CONCAT71(in_stack_fffffffffffffef9,in_stack_fffffffffffffef8));

-      pAVar30 = *(AdvertisementMonitor **)(in_RAX + -0xa0);

-      if (pAVar30 == (AdvertisementMonitor *)0x0) {

-        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

-           ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

-          uVar19 = 0;

+      local_50 = uVar8 & 0xffffffffffff;

+      local_58 = &Microsoft::Bluetooth::BluetoothBRAddress::_vftable_;

+      local_48 = uVar13;

+      _HCI_FindLEDeviceInfoBlock__YA_AV__RefObjReference_UDEVICE_INFO_BLOCK___0A__M__T0A__M__T0A___PEAUHCI_INTERFACE__AEBVBluetoothLEAddress_Bluetooth_Microsoft__PEAX_Z

+                (local_90,(this->m_fdo->m_devExt).Hci,&local_58,this);

+      if (local_88 != 0) {

+        uVar8 = *(ulonglong *)(local_88 + 0x20);

+        local_res20 = uVar8;

+        if ((*(uint *)(local_88 + 0x18) & 0x8000) == 0) {

+          uVar13 = 0xff;

         }

         else {

-          uVar19 = 1;

+          uVar13 = uVar11;

+          if (*(uchar *)(local_88 + 0x5b0) != 0xff) {

+            uVar13 = *(uchar *)(local_88 + 0x5b0);

+          }

         }

-        lVar27 = *(longlong *)(pvVar4 + 8);

       }

-      else {

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

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

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

-        cVar13 = utl::

-                 list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

-                 ::push_back(&pAVar30->pendingResults,

-                             (Promise<AdvertisementMonitorProgrammingResult> *)(in_RAX + -0x50));

-        *(char *)(in_RAX + 0x20) = cVar13;

-        if (*(_RefCountBase **)(in_RAX + -0x40) != (_RefCountBase *)0x0) {

-          utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(in_RAX + -0x40));

-          cVar13 = *(char *)(in_RAX + 0x20);

-        }

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

-          wil::acquire_kspin_lock((__uint64 *)(in_RAX + -0x68));

-          puVar14 = (undefined8 *)

-                    (-(ulonglong)

-                      (pvVar4 != (vector<utl::byte,utl::allocator<utl::byte>_> *)0xffffffffffffffd8)

-                    & (ulonglong)(pvVar4 + 0x18));

-          *(undefined8 **)(in_RAX + -0x58) = puVar14;

-          for (puVar21 = (undefined8 *)*puVar14; puVar21 != puVar14;

-              puVar21 = (undefined8 *)*puVar21) {

-            plVar1 = puVar21 + -2;

-            pcVar15 = *(char **)&pAVar30->originalRequest;

-            if ((longlong)*(char **)&pAVar30->field_0x28 - (longlong)pcVar15 ==

-                puVar21[3] - puVar21[2]) {

-              lVar27 = puVar21[2] - (longlong)pcVar15;

-              for (; pcVar15 != *(char **)&pAVar30->field_0x28; pcVar15 = pcVar15 + 1) {

-                if (*pcVar15 != pcVar15[lVar27]) goto LAB_1;

-              }

-              lVar27 = *plVar1;

-              p_Var25 = (_RefCountBase *)0x0;

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

-              p_Var17 = p_Var25;

-              if (lVar27 != 0) {

-                LOCK();

-                piVar2 = (int *)(lVar27 + 0xc);

-                *piVar2 = *piVar2 + 1;

-                UNLOCK();

-                p_Var17 = (_RefCountBase *)*plVar1;

-                pAVar30 = *(AdvertisementMonitor **)(in_RAX + -0xa0);

-                *(longlong **)(in_RAX + 0x20) = plVar1;

-              }

-              if (((p_Var17 != (_RefCountBase *)0x0) &&

-                  (bVar12 = utl::_RefCountBase::_TryIncStrong(p_Var17), this_03 = p_Var17, bVar12))

-                 || (*(_RefCountBase **)(in_RAX + 0x20) = p_Var25, this_03 = p_Var25,

-                    p_Var17 != (_RefCountBase *)0x0)) {

-                utl::_RefCountBase::_DecWeak(p_Var17);

-                if (*(longlong *)(in_RAX + 0x20) != 0) {

-                  this_00 = (list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

-                             *)(puVar21 + 6);

-                  if (*(list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

-                        **)this_00 == this_00) {

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

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

-                    *(undefined8 *)(in_RAX + -0xd8) = *(undefined8 *)(in_RAX + -0x78);

-                    *(undefined8 *)(in_RAX + -0xd0) = *(undefined8 *)(in_RAX + -0x70);

-                    wil::details::

-                    unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                    ::reset((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                             *)(in_RAX + -0x68),(kspin_lock_saved_irql *)(in_RAX + -0xd8));

-                    *(undefined4 *)(in_RAX + -0xd8) = 0;

-                    *(undefined4 *)(in_RAX + -0xd4) = 0;

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

-                    *(_RefCountBase **)(in_RAX + -200) = this_03;

-                    Microsoft::Bluetooth::Foundation::

-                    SharedState<AdvertisementMonitorProgrammingResult>::

-                    SetResult<AdvertisementMonitorProgrammingResult>

-                              (*(SharedState<AdvertisementMonitorProgrammingResult> **)

-                                (in_RAX + -0xb0),

-                               (AdvertisementMonitorProgrammingResult *)(in_RAX + -0xd8));

-                    if (*(_RefCountBase **)(in_RAX + -200) != (_RefCountBase *)0x0) {

-                      utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(in_RAX + -200));

-                    }

-                    *(_RefCountBase **)param_1 = p_Var28;

-                    *(_RefCountBase **)&param_1->MonitorHandle = p_Var29;

-                  }

-                  else {

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

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

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

-                    bVar12 = utl::

-                             list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

-                             ::push_back(this_00,(Promise<AdvertisementMonitorProgrammingResult> *)

-                                                 (in_RAX + -0xd8));

-                    if (*(_RefCountBase **)(in_RAX + -200) != (_RefCountBase *)0x0) {

-                      utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(in_RAX + -200));

-                    }

-                    if (bVar12) {

-                      Microsoft::Bluetooth::Foundation::Promise<SetCigParametersResult>::operator=

-                                ((Promise<SetCigParametersResult> *)(puVar21[7] + 0x10),

-                                 (Promise<struct_SetCigParametersResult> *)(in_RAX + -0xb8));

-                    }

-                    else {

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

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

-                      *(undefined8 *)(in_RAX + -0xd8) = *(undefined8 *)(in_RAX + -0x78);

-                      *(undefined8 *)(in_RAX + -0xd0) = *(undefined8 *)(in_RAX + -0x70);

-                      wil::details::

-                      unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                      ::reset((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                               *)(in_RAX + -0x68),(kspin_lock_saved_irql *)(in_RAX + -0xd8));

-                      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

-                         ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

-                        uVar19 = 0;

-                      }

-                      else {

-                        uVar19 = 1;

-                      }

-                      WPP_RECORDER_AND_TRACE_SF_i

-                                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar19,1,

-                                 *(undefined8 *)

-                                  (*(longlong *)(*(longlong *)(in_RAX + 8) + 8) + 0x20));

-                      *(undefined4 *)(in_RAX + -0xd8) = 0xc000009a;

-                      *(undefined4 *)(in_RAX + -0xd4) = 0;

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

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

-                      Microsoft::Bluetooth::Foundation::

-                      SharedState<AdvertisementMonitorProgrammingResult>::

-                      SetResult<AdvertisementMonitorProgrammingResult>

-                                (*(SharedState<AdvertisementMonitorProgrammingResult> **)

-                                  (in_RAX + -0xb0),

-                                 (AdvertisementMonitorProgrammingResult *)(in_RAX + -0xd8));

-                      if (*(_RefCountBase **)(in_RAX + -200) != (_RefCountBase *)0x0) {

-                        utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(in_RAX + -200));

-                      }

-                    }

-                    *(_RefCountBase **)&param_1->MonitorHandle = p_Var29;

-                    *(_RefCountBase **)param_1 = p_Var28;

-                    if (this_03 != (_RefCountBase *)0x0) {

-                      utl::_RefCountBase::_DecStrong(this_03);

-                    }

-                  }

-                  wil::details::

-                  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                  ::

-                  ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                              *)(in_RAX + -0x68));

-                  p_Var17 = *(_RefCountBase **)(in_RAX + -0x98);

-                  puVar24 = auStackY_128;

-                  goto joined_r0x00014006cb3a;

-                }

-                if (this_03 != (_RefCountBase *)0x0) {

-                  utl::_RefCountBase::_DecStrong(this_03);

-                }

-              }

+      _Reset___RefObjReference_UDEVICE_INFO_BLOCK___0A__M__T0A__M__T0A___QEAAXPEAUDEVICE_INFO_BLOCK__PEBX_Z

+                (local_90);

+      *(uchar *)(puVar12 + 0x12) = uVar13;

+      *(ulonglong *)((longlong)puVar12 + 0x25) = uVar8;

+      wil::acquire_kspin_lock((__uint64 *)local_80);

+      puVar7 = (undefined8 *)

+               (-(ulonglong)(this != (AdvertisementMonitorProgrammer *)0xffffffffffffffd8) &

+               (ulonglong)&this->m_monitors);

+      for (puVar9 = (undefined8 *)*puVar7; puVar9 != puVar7; puVar9 = (undefined8 *)*puVar9) {

+        if (((undefined8 *)puVar9[6] == puVar9 + 6) &&

+           (*(uchar *)(puVar9 + 0xb) == param_1->MonitorHandle)) {

+          memmove(puVar12 + 0x17,(void *)puVar9[2],puVar9[3] - (longlong)puVar9[2]);

+          puVar12[1] = (*(short *)(puVar9 + 3) - *(short *)(puVar9 + 2)) + 0x2e;

+          if (param_1->MonitorState == '\x01') {

+            this_00 = (RadioPerfCounters *)puVar9[0xc];

+            LOCK();

+            puVar2 = &(this_00->m_counters).DeviceTrackersCount;

+            uVar3 = *puVar2;

+            *puVar2 = *puVar2 + 1;

+            UNLOCK();

+            RadioPerfCounters::UpdateMaxValue<unsigned_long>

+                      (this_00,uVar3 + 1,&this_00->m_maxDeviceTrackers);

+            LOCK();

+            *(int *)(puVar9 + 0xd) = *(int *)(puVar9 + 0xd) + 1;

+            UNLOCK();

+            puVar12 = local_70;

+          }

+          else if (param_1->MonitorState == '\0') {

+            LOCK();

+            piVar1 = (int *)(puVar9 + 0xd);

+            iVar4 = *piVar1;

+            *piVar1 = *piVar1 + -1;

+            UNLOCK();

+            puVar12 = local_70;

+            if (0 < iVar4) {

+              LOCK();

+              *(int *)(puVar9[0xc] + 0x98) = *(int *)(puVar9[0xc] + 0x98) + -1;

+              UNLOCK();

             }

-LAB_1:

-            puVar14 = *(undefined8 **)(in_RAX + -0x58);

           }

-          lVar27 = *(longlong *)(in_RAX + 8);

-          piVar20 = &pAVar30->listHook;

-          uVar18 = -(ulonglong)(lVar27 + 0x28 != 0) & lVar27 + 0x18U;

-          puVar16 = *(ulonglong **)(uVar18 + 8);

-          if (*puVar16 != uVar18) {

-            uVar18 = 3;

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

-            puVar16 = (ulonglong *)(*pcVar11)(3,piVar20,-(lVar27 + 0x28));

-            puVar23 = auStackY_120;

-          }

-          *(ulonglong *)piVar20 = uVar18;

-          *(ulonglong **)&piVar20->field_0x8 = puVar16;

-          *puVar16 = (ulonglong)piVar20;

-          *(intrusive_list_hook **)(uVar18 + 8) = piVar20;

-          lVar5 = *(longlong *)&pAVar30->field_0x48;

-          *(undefined8 *)(puVar23 + -8) = 0x14006cc9c;

-          Microsoft::Bluetooth::Foundation::Promise<SetCigParametersResult>::operator=

-                    ((Promise<SetCigParametersResult> *)(lVar5 + 0x10),

-                     (Promise<struct_SetCigParametersResult> *)(in_RAX + -0xb8));

-          p_Var17 = (_RefCountBase *)0x0;

-          pAVar31 = pAVar30;

-          if (*(longlong *)(in_RAX + -0x98) != 0) {

-            LOCK();

-            piVar2 = (int *)(*(longlong *)(in_RAX + -0x98) + 8);

-            *piVar2 = *piVar2 + 1;

-            UNLOCK();

-            p_Var17 = *(_RefCountBase **)(in_RAX + -0x98);

-            pAVar31 = *(AdvertisementMonitor **)(in_RAX + -0xa0);

-          }

-          *(AdvertisementMonitor **)&pAVar30->selfRef = pAVar31;

-          p_Var25 = *(_RefCountBase **)&pAVar30->field_0x60;

-          *(_RefCountBase **)&pAVar30->field_0x60 = p_Var17;

-          if (p_Var25 != (_RefCountBase *)0x0) {

-            *(undefined8 *)(puVar23 + -8) = 0x14006ccca;

-            utl::_RefCountBase::_DecStrong(p_Var25);

-          }

-          *(undefined8 *)(puVar23 + -8) = 0x14006ccd3;

           wil::details::

           unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

           ::

           ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                    ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-                      *)(in_RAX + -0x68));

-          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

-             ((byte)WPP_GLOBAL_Control[0x29] < 4)) {

-            uVar19 = 0;

-          }

-          else {

-            uVar19 = 1;

-          }

-          puVar21 = *(undefined8 **)(lVar27 + 8);

-          uVar6 = *(undefined8 *)(WPP_GLOBAL_Control + 0x18);

-          *(AdvertisementMonitor **)(puVar23 + 0x48) = pAVar31;

-          uVar7 = puVar21[4];

-          *(undefined8 *)(puVar23 + 0x40) = *puVar21;

-          *(undefined **)(puVar23 + 0x38) = &WPP_dfd97a3672ff3baf534fe59bf8090c07_Traceguids;

-          *(undefined2 *)(puVar23 + 0x30) = 0xe;

-          *(undefined4 *)(puVar23 + 0x28) = 1;

-          puVar23[0x20] = 4;

-          *(undefined8 *)(puVar23 + -8) = 0x14006cd2e;

-          WPP_RECORDER_AND_TRACE_SF_qq(uVar6,uVar19,1,uVar7);

-          *(undefined8 *)(puVar23 + -8) = 0x14006cd37;

-          utl::vector<IsoCisStatus,utl::allocator<IsoCisStatus>_>::

-          vector<IsoCisStatus,utl::allocator<IsoCisStatus>_>

-                    ((vector<IsoCisStatus,utl::allocator<IsoCisStatus>_> *)(in_RAX + -0xd8));

-          p_Var26 = *(_HCI_COMMAND_HEADER **)(in_RAX + -0xd8);

-          uVar18 = *(longlong *)(in_RAX + -0xd0) - (longlong)p_Var26;

-          *(ulonglong *)(in_RAX + 0x20) = uVar18;

-          puVar24 = puVar23;

-          if (uVar18 < 0x102) {

-            *(undefined8 *)(puVar23 + -8) = 0x14006cd61;

-            bVar12 = utl::vector<utl::byte,utl::allocator<utl::byte>_>::reserve

-                               ((vector<utl::byte,utl::allocator<utl::byte>_> *)(in_RAX + -0xd8),

-                                0x102);

-            if (bVar12) {

-              lVar27 = *(longlong *)(in_RAX + 0x20);

-              pvVar3 = *(void **)(in_RAX + -0xd0);

-              *(undefined8 *)(puVar23 + -8) = 0x14006ce0f;

-              memset(pvVar3,0,0x102 - lVar27);

-              p_Var26 = *(_HCI_COMMAND_HEADER **)(in_RAX + -0xd8);

-              goto LAB_2;

-            }

-            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

-               ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

-              uVar19 = 0;

-            }

-            else {

-              uVar19 = 1;

-            }

-            this_01 = *(AdvertisementMonitorProgrammer **)(in_RAX + 8);

-            uVar6 = *(undefined8 *)(WPP_GLOBAL_Control + 0x18);

-            pFVar8 = this_01->m_fdo;

-            uVar9 = pFVar8->m_recorderLog;

-            *(undefined8 *)(puVar23 + 0x40) = *(undefined8 *)pFVar8;

-            *(undefined **)(puVar23 + 0x38) = &WPP_dfd97a3672ff3baf534fe59bf8090c07_Traceguids;

-            *(undefined2 *)(puVar23 + 0x30) = 0xf;

-            *(undefined4 *)(puVar23 + 0x28) = 1;

-            puVar23[0x20] = 2;

-            *(undefined8 *)(puVar23 + -8) = 0x14006cdc3;

-            WPP_RECORDER_AND_TRACE_SF_i(uVar6,uVar19,1,uVar9);

-            puVar23[0x20] = 0;

-            *(undefined8 *)(puVar23 + -8) = 0x14006cddc;

-            AdvertisementMonitorProgrammer::OnProgramMonitorCommandComplete

-                      (this_01,pAVar31,-0x3fffff66,0xff,puVar23[0x20]);

-            *(_RefCountBase **)param_1 = p_Var28;

-            *(_RefCountBase **)&param_1->MonitorHandle = p_Var29;

-            *(undefined8 *)(puVar23 + -8) = 0x14006cdec;

-            utl::vector<unsigned___int64,utl::allocator<unsigned___int64>_>::_Uninit

-                      ((vector<unsigned___int64,utl::allocator<unsigned___int64>_> *)

-                       (in_RAX + -0xd8));

-          }

-          else {

-LAB_2:

-            lVar27 = *(longlong *)(in_RAX + 8);

-            this_02 = *(AdvertisementMonitorParameters **)(in_RAX + 0x18);

-            *(_HCI_COMMAND_HEADER **)(in_RAX + -0xd0) = p_Var26 + 0x56;

-            pHVar10 = *(HCI_INTERFACE **)(*(longlong *)(lVar27 + 8) + 0x4a0);

-            *(undefined8 *)(puVar23 + -8) = 0x14006ce39;

-            BuildHciCommand(this_02,pHVar10,(byte *)p_Var26);

-            lVar27 = *(longlong *)(lVar27 + 8);

-            *(undefined8 *)(puVar23 + 0x30) = 0;

-            *(undefined4 *)(puVar23 + 0x28) = 0;

-            *(AdvertisementMonitor **)(puVar23 + 0x20) = pAVar31;

-            pHVar10 = *(HCI_INTERFACE **)(lVar27 + 0x4a0);

-            *(undefined8 *)(puVar23 + -8) = 0x14006ce66;

-            HCI_SendCommandEx(pHVar10,p_Var26,(_GUID *)0x0,

-                              <lambda_9033e6ff56794b920087c36f2622637b>::<lambda_invoker_cdecl>,

-                              *(void **)(puVar23 + 0x20),*(ulong *)(puVar23 + 0x28),

-                              *(void **)(puVar23 + 0x30));

-            *(undefined8 *)(puVar23 + -8) = 0x14006ce6f;

-            utl::vector<unsigned___int64,utl::allocator<unsigned___int64>_>::_Uninit

-                      ((vector<unsigned___int64,utl::allocator<unsigned___int64>_> *)

-                       (in_RAX + -0xd8));

-            *(_RefCountBase **)param_1 = p_Var28;

-            *(_RefCountBase **)&param_1->MonitorHandle = p_Var29;

-          }

-joined_r0x00014006cb3a:

-          if (p_Var17 != (_RefCountBase *)0x0) {

-            *(undefined8 *)(puVar24 + -8) = 0x14006cb41;

-            utl::_RefCountBase::_DecStrong(p_Var17);

-          }

-          *(undefined8 *)(puVar24 + -8) = 0x14006cb4a;

-          utl::vector<unsigned___int64,utl::allocator<unsigned___int64>_>::_Uninit

-                    ((vector<unsigned___int64,utl::allocator<unsigned___int64>_> *)(in_RAX + -0x90))

-          ;

+                    (local_80);

+          uVar6 = (**(code **)(WdfFunctions_01031 + 0x108))

+                            (WdfDriverGlobals,*(undefined8 *)this->m_fdo);

+          IoReportTargetDeviceChangeAsynchronous(uVar6,puVar12,0,0);

           goto LAB_0;

         }

-        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

-           ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

-          uVar19 = 0;

-        }

-        else {

-          uVar19 = 1;

-        }

-        lVar27 = *(longlong *)(pvVar4 + 8);

       }

-      WPP_RECORDER_AND_TRACE_SF_i

-                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar19,1,*(undefined8 *)(lVar27 + 0x20))

-      ;

-      *(undefined4 *)(in_RAX + -0xd8) = 0xc000009a;

-      *(undefined4 *)(in_RAX + -0xd4) = 0;

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

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

-      Microsoft::Bluetooth::Foundation::SharedState<AdvertisementMonitorProgrammingResult>::

-      SetResult<AdvertisementMonitorProgrammingResult>

-                ((SharedState<AdvertisementMonitorProgrammingResult> *)p_Var17,

-                 (AdvertisementMonitorProgrammingResult *)(in_RAX + -0xd8));

-      if (*(_RefCountBase **)(in_RAX + -200) != (_RefCountBase *)0x0) {

-        utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(in_RAX + -200));

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) != 0) && (3 < (byte)WPP_GLOBAL_Control[0x29]))

+      {

+        uVar11 = '\x01';

       }

-      p_Var17 = *(_RefCountBase **)(in_RAX + -0x98);

-      *(_RefCountBase **)param_1 = p_Var28;

-      *(_RefCountBase **)&param_1->MonitorHandle = p_Var29;

-      if (p_Var17 != (_RefCountBase *)0x0) {

-        utl::_RefCountBase::_DecStrong(p_Var17);

-      }

+      WPP_RECORDER_AND_TRACE_SF_iL

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+                 CONCAT71((int7)((ulonglong)puVar7 >> 8),uVar11),1,this->m_fdo->m_recorderLog,4,1,

+                 0x17,&WPP_dfd97a3672ff3baf534fe59bf8090c07_Traceguids,*(undefined8 *)this->m_fdo,

+                 param_1->MonitorHandle);

+      wil::details::

+      unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+      ::

+      ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+                (local_80);

     }

     else {

-      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2))

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29]))

       {

-        uVar19 = 0;

+        uVar11 = '\x01';

       }

-      else {

-        uVar19 = 1;

-      }

-      WPP_RECORDER_AND_TRACE_SF_i

-                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar19,1,this->m_fdo->m_recorderLog);

-      *(undefined4 *)(in_RAX + -0xd8) = 0xc000009a;

-      *(undefined4 *)(in_RAX + -0xd4) = 0;

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

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

-      Microsoft::Bluetooth::Foundation::SharedState<AdvertisementMonitorProgrammingResult>::

-      SetResult<AdvertisementMonitorProgrammingResult>

-                ((SharedState<AdvertisementMonitorProgrammingResult> *)p_Var17,

-                 (AdvertisementMonitorProgrammingResult *)(in_RAX + -0xd8));

-      if (*(_RefCountBase **)(in_RAX + -200) != (_RefCountBase *)0x0) {

-        utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(in_RAX + -200));

-      }

-      *(_RefCountBase **)param_1 = p_Var28;

-      *(_RefCountBase **)&param_1->MonitorHandle = p_Var29;

+      WPP_RECORDER_AND_TRACE_SF_iL

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar11,1,this->m_fdo->m_recorderLog,2,1,

+                 0x16,&WPP_dfd97a3672ff3baf534fe59bf8090c07_Traceguids,*(undefined8 *)this->m_fdo,

+                 param_1->MonitorState);

     }

-    utl::vector<unsigned___int64,utl::allocator<unsigned___int64>_>::_Uninit

-              ((vector<unsigned___int64,utl::allocator<unsigned___int64>_> *)(in_RAX + -0x90));

   }

-  if (p_Var25 != (_RefCountBase *)0x0) {

-    *(undefined8 *)(puVar22 + -8) = 0x14006cece;

-    utl::_RefCountBase::_DecStrong(p_Var25);

+  else {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+      uVar10 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar10,1,this->m_fdo->m_recorderLog,2,1,

+               0x15,&WPP_dfd97a3672ff3baf534fe59bf8090c07_Traceguids,*(undefined8 *)this->m_fdo);

   }

+LAB_0:

+  utl::vector<unsigned___int64,utl::allocator<unsigned___int64>_>::_Uninit

+            ((vector<unsigned___int64,utl::allocator<unsigned___int64>_> *)&local_70);

   return;

 }
```

## `AdvertisementMonitorProgrammer::OnProgramMonitorCommandComplete`  (modified)

```diff
--- AdvertisementMonitorProgrammer::OnProgramMonitorCommandComplete
+++ AdvertisementMonitorProgrammer::OnProgramMonitorCommandComplete
@@ -1,48 +1,200 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: void __cdecl AdvertisementMonitorProgrammer::OnProgramMonitorCommandComplete(struct

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

 

 void __thiscall

-AdvertisementMonitorParameters::OnProgramMonitorCommandComplete

+AdvertisementMonitorProgrammer::OnProgramMonitorCommandComplete

           (AdvertisementMonitorProgrammer *this,AdvertisementMonitor *param_1,long param_2,

           uchar param_3,uchar param_4)

 

 {

-  undefined8 in_RAX;

-  longlong unaff_RBP;

-  _RefCountBase *unaff_RSI;

-  undefined8 *unaff_RDI;

-  undefined8 unaff_R12;

-  undefined8 unaff_R13;

+  ulong *puVar1;

+  ulong uVar2;

+  _RefCountBase *this_00;

+  longlong *plVar3;

+  RadioPerfCounters *this_01;

+  SharedState<AdvertisementMonitorProgrammingResult> *pSVar4;

+  _RefCountBase *p_Var5;

+  _ContainerBase<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_>_>

+  *this_02;

+  longlong lVar6;

+  undefined1 *puVar7;

+  char cVar8;

+  undefined8 uVar9;

+  undefined8 uVar10;

+  list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

+  *plVar11;

+  undefined4 uVar12;

+  undefined1 local_res8 [8];

+  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+  local_98 [16];

+  kspin_lock_saved_irql local_88;

+  kspin_lock_saved_irql local_78;

+  _RefCountBase *local_68;

+  _DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_> *local_58;

+  undefined8 uStack_50;

+  undefined8 local_48;

+  undefined8 local_40;

+  undefined8 local_38;

+  _RefCountBase *local_30;

   

-  *(int *)(unaff_RBP + -0x75) = (int)CONCAT71((int7)((ulonglong)in_RAX >> 8),(char)in_RAX * '\x02');

-  *(undefined8 *)(unaff_RBP + -0x71) = 0;

-  *(undefined8 *)(unaff_RBP + -0x69) = 0;

-  Microsoft::Bluetooth::Foundation::SharedState<AdvertisementMonitorProgrammingResult>::

-  SetResult<AdvertisementMonitorProgrammingResult>

-            ((SharedState<AdvertisementMonitorProgrammingResult> *)this,

-             (AdvertisementMonitorProgrammingResult *)param_1);

-  if (*(_RefCountBase **)(unaff_RBP + -0x69) != (_RefCountBase *)0x0) {

-    utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(unaff_RBP + -0x69));

-  }

-  unaff_RDI[1] = unaff_R13;

-  *unaff_RDI = unaff_R12;

-  if (unaff_RSI != (_RefCountBase *)0x0) {

-    utl::_RefCountBase::_DecStrong(unaff_RSI);

+  wil::acquire_kspin_lock((__uint64 *)local_98);

+  cVar8 = _contains___base_list_impl_U__intrusive_member_hook_traits__MPEQAdvertisementMonitor__Vintrusive_list_hook_Foundation_Bluetooth_Microsoft__0BA__Foundation_Bluetooth_Microsoft__V__intrusive_list_t_U__intrusive_member_hook_traits__MPEQAdvertisementMonitor__Vintrusive_list_hook_Foundation_Bluetooth_Microsoft__0BA__Foundation_Bluetooth_Microsoft___234__Details_Foundation_Bluetooth_Microsoft__QEBA_NAEBUAdvertisementMonitor___Z

+                    (&this->m_pausedForControllerResetGuard,param_1);

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

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+       (uVar9 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar9 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar9,1,this->m_fdo->m_recorderLog,2,1,

+               0x10,&WPP_dfd97a3672ff3baf534fe59bf8090c07_Traceguids,*(undefined8 *)this->m_fdo);

+    MicrosoftTelemetryAssertTriggeredMsgKM("Monitor unexpectedly missing from list.");

+  }

+  uVar9 = *(undefined8 *)&param_1->selfRef;

+  this_00 = *(_RefCountBase **)&param_1->field_0x60;

+  *(undefined8 *)&param_1->selfRef = 0;

+  *(undefined8 *)&param_1->field_0x60 = 0;

+  if (param_2 < 0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+       (uVar9 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar9 = 0;

+    }

+    uVar12 = WPP_RECORDER_AND_TRACE_SF_qqdL(*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar9);

+    _erase___list_impl_U__intrusive_member_hook_traits__MPEQAdvertisementMonitor__Vintrusive_list_hook_Foundation_Bluetooth_Microsoft__0BA__Foundation_Bluetooth_Microsoft__V__intrusive_list_t_U__intrusive_member_hook_traits__MPEQAdvertisementMonitor__Vintrusive_list_hook_Foundation_Bluetooth_Microsoft__0BA__Foundation_Bluetooth_Microsoft___234__Details_Foundation_Bluetooth_Microsoft__QEAA_AV__iterator_t_U__intrusive_member_hook_traits__MPEQAdvertisementMonitor__Vintrusive_list_hook_Foundation_Bluetooth_Microsoft__0BA__Foundation_Bluetooth_Microsoft___0A__2345_AEAUAdvertisementMonitor___Z

+              (uVar12,local_res8,param_1);

+    local_88.spinLock = (ulong64 *)0x0;

+    local_88._8_8_ = local_88._8_8_ & 0xffffffffffffff00;

+    local_78.spinLock = (ulong64 *)0x0;

+    local_78.savedIrql = local_88.savedIrql;

+    local_78._9_7_ = local_88._9_7_;

+    wil::details::

+    unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+    ::reset(local_98,&local_78);

+    plVar11 = &param_1->pendingResults;

+    while (puVar7 = *(undefined1 **)plVar11,

+          (list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

+           *)puVar7 != plVar11) {

+      pSVar4 = *(SharedState<AdvertisementMonitorProgrammingResult> **)(puVar7 + 0x18);

+      p_Var5 = *(_RefCountBase **)(puVar7 + 0x20);

+      *(undefined8 *)(puVar7 + 0x18) = 0;

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

+      puVar7[0x10] = 0;

+      utl::

+      list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

+      ::pop_front(plVar11);

+      local_78.spinLock = (ulong64 *)(ulonglong)(uint)param_2;

+      local_78._8_8_ = 0;

+      local_68 = (_RefCountBase *)0x0;

+      Microsoft::Bluetooth::Foundation::SharedState<AdvertisementMonitorProgrammingResult>::

+      SetResult<AdvertisementMonitorProgrammingResult>

+                (pSVar4,(AdvertisementMonitorProgrammingResult *)&local_78);

+      if (local_68 != (_RefCountBase *)0x0) {

+        utl::_RefCountBase::_DecStrong(local_68);

+      }

+      if (p_Var5 != (_RefCountBase *)0x0) {

+        utl::_RefCountBase::_DecStrong(p_Var5);

+      }

+    }

+  }

+  else {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+       (uVar10 = 1, (byte)WPP_GLOBAL_Control[0x29] < 4)) {

+      uVar10 = 0;

+    }

+    WPP_RECORDER_AND_TRACE_SF_qqd

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar10,1,this->m_fdo->m_recorderLog,4,1,

+               0x11,&WPP_dfd97a3672ff3baf534fe59bf8090c07_Traceguids,*(undefined8 *)this->m_fdo,

+               param_1,param_4);

+    param_1->monitorHandle = param_4;

+    plVar11 = &param_1->pendingResults;

+    plVar3 = *(longlong **)&param_1->field_0x48;

+    *(_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_> ***)

+     (*(longlong *)plVar11 + 8) = &local_58;

+    *plVar3 = (longlong)&local_58;

+    local_58 = *(_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_> **)

+                plVar11;

+    uStack_50 = *(undefined8 *)&param_1->field_0x48;

+    *(list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

+      **)plVar11 = plVar11;

+    *(list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

+      **)&param_1->field_0x48 = plVar11;

+    local_48 = *(undefined8 *)&param_1->field_0x50;

+    *(undefined8 *)&param_1->field_0x50 = 0;

+    this_01 = (param_1->perfCountToken).m_perfCounters;

+    LOCK();

+    puVar1 = &(this_01->m_counters).AdvertisementMonitorsCount;

+    uVar2 = *puVar1;

+    *puVar1 = *puVar1 + 1;

+    UNLOCK();

+    RadioPerfCounters::UpdateMaxValue<unsigned_long>

+              (this_01,uVar2 + 1,&this_01->m_maxAdvertisementMonitors);

+    (param_1->perfCountToken).m_activeMonitor = (atomic<bool>)0x1;

+    local_88._8_8_ = local_88._8_8_ & 0xffffffffffffff00;

+    local_88.spinLock = (ulong64 *)0x0;

+    wil::details::

+    unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+    ::reset(local_98,&local_88);

+    while (local_58 !=

+           (_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_> *)&local_58)

+    {

+      pSVar4 = *(SharedState<AdvertisementMonitorProgrammingResult> **)(local_58 + 0x18);

+      p_Var5 = *(_RefCountBase **)(local_58 + 0x20);

+      *(_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_> **)

+       (local_58 + 0x18) =

+           (_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_> *)0x0;

+      *(_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_> **)

+       (local_58 + 0x20) =

+           (_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_> *)0x0;

+      local_58[0x10] =

+           (_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_>)0x0;

+      utl::

+      list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

+      ::pop_front((list<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<AdvertisementMonitorProgrammingResult>_>_>

+                   *)&local_58);

+      if (this_00 != (_RefCountBase *)0x0) {

+        LOCK();

+        this_00->_MyStrong = this_00->_MyStrong + 1;

+        UNLOCK();

+      }

+      local_40 = 0;

+      local_38 = uVar9;

+      local_30 = this_00;

+      Microsoft::Bluetooth::Foundation::SharedState<AdvertisementMonitorProgrammingResult>::

+      SetResult<AdvertisementMonitorProgrammingResult>

+                (pSVar4,(AdvertisementMonitorProgrammingResult *)&local_40);

+      if (local_30 != (_RefCountBase *)0x0) {

+        utl::_RefCountBase::_DecStrong(local_30);

+      }

+      if (p_Var5 != (_RefCountBase *)0x0) {

+        utl::_RefCountBase::_DecStrong(p_Var5);

+      }

+    }

+    while (local_58 !=

+           (_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_> *)&local_58)

+    {

+      this_02 = *(_ContainerBase<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_>_>

+                  **)(local_58 + 8);

+      lVar6 = *(longlong *)local_58;

+      *(longlong *)this_02 = lVar6;

+      *(_ContainerBase<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_>_>

+        **)(lVar6 + 8) = this_02;

+      utl::

+      _ContainerBase<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>,utl::allocator<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_>_>

+      ::

+      _DeleteNode<utl::_DlistNode<Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>_>_>

+                (this_02,local_58);

+    }

+  }

+  if (this_00 != (_RefCountBase *)0x0) {

+    utl::_RefCountBase::_DecStrong(this_00);

   }

   wil::details::

   unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

   ::

   ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-            ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

-              *)(unaff_RBP + -9));

-  if (*(_RefCountBase **)(unaff_RBP + -0x39) != (_RefCountBase *)0x0) {

-    utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(unaff_RBP + -0x39));

-  }

-  utl::vector<unsigned___int64,utl::allocator<unsigned___int64>_>::_Uninit

-            ((vector<unsigned___int64,utl::allocator<unsigned___int64>_> *)(unaff_RBP + -0x31));

-  if (*(_RefCountBase **)(unaff_RBP + -0x49) != (_RefCountBase *)0x0) {

-    utl::_RefCountBase::_DecStrong(*(_RefCountBase **)(unaff_RBP + -0x49));

-  }

+            (local_98);

   return;

 }
```

## `HciLEExtendedAdvertisingRequestCoordinator::EvtMachineDestroyed`  (modified)

```diff
--- HciLEExtendedAdvertisingRequestCoordinator::EvtMachineDestroyed
+++ HciLEExtendedAdvertisingRequestCoordinator::EvtMachineDestroyed
@@ -1,2 +1,34 @@
-Failed to decompile bthport.sys - .ProgramDB HciLEExtendedAdvertisingRequestCoordinator::EvtMachineDestroyed : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* private: void __cdecl HciLEExtendedAdvertisingRequestCoordinator::EvtMachineDestroyed(void)

+   __ptr64 */

+

+void __thiscall

+HciLEExtendedAdvertisingRequestCoordinator::EvtMachineDestroyed

+          (HciLEExtendedAdvertisingRequestCoordinator *this)

+

+{

+  undefined1 uVar1;

+  undefined8 local_res8 [4];

+  

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 0x1000) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 4)

+     ) {

+    uVar1 = 0;

+  }

+  else {

+    uVar1 = 1;

+  }

+  WPP_RECORDER_AND_TRACE_SF_i

+            (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar1,1,

+             *(undefined8 *)(*(longlong *)(this + 0xe0) + 0x10b0),4,0xd,0x3c,

+             &WPP_c4e0069faea33e1ebcaee10308af665f_Traceguids,this);

+  local_res8[0] = *(undefined8 *)(this + 0x128);

+  *(undefined8 *)(this + 0x128) = 0;

+  wil::details::

+  unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+  ::

+  ~unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+            ((unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+              *)local_res8);

+  return;

+}

+
```

## `ScanRequestProgrammer::SubmitScanProgrammingRequest`  (modified)

```diff
--- ScanRequestProgrammer::SubmitScanProgrammingRequest
+++ ScanRequestProgrammer::SubmitScanProgrammingRequest
@@ -1,17 +1,293 @@
 

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* public: class Microsoft::Bluetooth::Foundation::Future<struct ScanProgrammingRequestResult>

+   __cdecl ScanRequestProgrammer::SubmitScanProgrammingRequest(struct ScanRequestParameters const &

+   __ptr64) __ptr64 */

 

 Future<ScanProgrammingRequestResult> * __thiscall

-ScanRequestParameters::SubmitScanProgrammingRequest

+ScanRequestProgrammer::SubmitScanProgrammingRequest

           (ScanRequestProgrammer *this,Future<ScanProgrammingRequestResult> *__return_storage_ptr__,

           ScanRequestParameters *param_1)

 

 {

-  code *pcVar1;

-  Future<ScanProgrammingRequestResult> *pFVar2;

+  int *piVar1;

+  Fdo *pFVar2;

+  HCI_INTERFACE *pHVar3;

+  longlong lVar4;

+  _RefCountBase *this_00;

+  StateMachineEngineImpl *this_01;

+  code *pcVar5;

+  bool bVar6;

+  ulonglong *puVar7;

+  undefined8 uVar8;

+  ulonglong uVar9;

+  undefined1 uVar10;

+  undefined1 *puVar11;

+  undefined1 *puVar12;

+  longlong lVar13;

+  longlong lVar14;

+  _RefCountBase *p_Var15;

+  ulonglong *puVar16;

+  _RefCountBase *p_Var17;

+  _RefCountBase *this_02;

+  longlong local_res20;

+  undefined1 auStack_178 [8];

+  undefined1 auStack_170 [24];

+  undefined1 local_158;

+  undefined4 local_150;

+  undefined2 local_148;

+  undefined *local_140;

+  undefined8 local_138;

+  undefined1 local_118 [16];

+  Promise<UpdateRequestResult> local_108 [8];

+  _RefCountBase *local_100;

+  _RefCountBase *local_f8;

+  undefined8 *local_f0;

+  ScanRequestProgrammer *local_e8;

+  undefined8 uStack_e0;

+  undefined8 uStack_d8;

+  undefined8 local_d0 [2];

+  _RefCountBase *local_c0;

+  _RefCountBase *local_b8;

+  undefined8 local_b0 [2];

+  undefined1 local_a0 [8];

+  type local_98;

+  type *local_30;

   

-  pcVar1 = (code *)swi(3);

-  pFVar2 = (Future<ScanProgrammingRequestResult> *)(*pcVar1)();

-  return pFVar2;

+  puVar12 = auStack_178;

+  puVar11 = auStack_178;

+  p_Var15 = (_RefCountBase *)0x0;

+  local_d0[0] = 0;

+  utl::

+  _SharedAlloc<Microsoft::Bluetooth::Foundation::SharedState<PeriodicAdvertiserList::ClientRequestCompletionResults>,utl::allocator<int>,0>

+  ::

+  _Create<utl::shared_ptr<Microsoft::Bluetooth::Foundation::SharedState<PeriodicAdvertiserList::ClientRequestCompletionResults>_>_>

+            ((_SharedAlloc<Microsoft::Bluetooth::Foundation::SharedState<PeriodicAdvertiserList::ClientRequestCompletionResults>,utl::allocator<int>,0>

+              *)local_d0);

+  utl::

+  _UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+  ::

+  ~_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+            ((_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+              *)local_d0);

+  local_108[0] = (Promise<UpdateRequestResult>)0x0;

+  local_100 = local_c0;

+  local_f8 = local_b8;

+  if (local_c0 == (_RefCountBase *)0x0) {

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+       (uVar8 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+      uVar8 = 0;

+    }

+    local_138 = *(undefined8 *)this->m_fdo;

+    local_140 = &WPP_b36e6216b07b3579f1890b2c11c6d274_Traceguids;

+    local_148 = 0xd;

+    local_150 = 1;

+    local_158 = 2;

+    WPP_RECORDER_AND_TRACE_SF_i

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar8,1,this->m_fdo->m_recorderLog);

+    *(undefined8 *)&__return_storage_ptr__->m_sharedState = 0;

+    *(undefined8 *)&(__return_storage_ptr__->m_sharedState).field_0x8 = 0;

+  }

+  else {

+    local_b0[0] = 0;

+    utl::_SharedAlloc<ScanRequestProgrammer::ScanProgrammingRequest,utl::allocator<int>,0>::

+    _Create<utl::shared_ptr<ScanRequestProgrammer::ScanProgrammingRequest>,ScanRequestParameters_const&___ptr64>

+              ((_SharedAlloc<ScanRequestProgrammer::ScanProgrammingRequest,utl::allocator<int>,0> *)

+               local_b0,(shared_ptr<ScanRequestProgrammer::ScanProgrammingRequest> *)local_118,

+               param_1);

+    utl::

+    _UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+    ::

+    ~_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+              ((_UninitializedAllocation<utl::allocator<utl::_DlistNode<LinkManagerLELogicalTransportAclManager::RejectedHciConnectionContext>_>_>

+                *)local_b0);

+    lVar13 = local_118._0_8_;

+    if (local_118._0_8_ == 0) {

+      local_150 = 1;

+      if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+         (uVar8 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+        uVar8 = 0;

+      }

+      local_138 = *(undefined8 *)this->m_fdo;

+      local_140 = &WPP_b36e6216b07b3579f1890b2c11c6d274_Traceguids;

+      local_148 = 0xe;

+      local_158 = 2;

+      WPP_RECORDER_AND_TRACE_SF_i

+                (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar8,1,this->m_fdo->m_recorderLog);

+      *(undefined8 *)&__return_storage_ptr__->m_sharedState = 0;

+      *(undefined8 *)&(__return_storage_ptr__->m_sharedState).field_0x8 = 0;

+    }

+    else {

+      wil::operation_guard::acquire(*(operation_guard **)&this->m_lifetimeGuard);

+      if (local_res20 == 0) {

+        if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+           (uVar8 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+          uVar8 = 0;

+        }

+        local_138 = *(undefined8 *)this->m_fdo;

+        local_140 = &WPP_b36e6216b07b3579f1890b2c11c6d274_Traceguids;

+        local_148 = 0xf;

+        local_150 = 1;

+        local_158 = 2;

+        WPP_RECORDER_AND_TRACE_SF_i

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar8,1,this->m_fdo->m_recorderLog);

+        MicrosoftTelemetryAssertTriggeredMsgKM

+                  ("Module already destroying when SubmitScanProgrammingRequest is called.");

+      }

+      else {

+        pFVar2 = this->m_fdo;

+        pHVar3 = (pFVar2->m_devExt).Hci;

+        if ((pHVar3->IsLEExtendedAdvertisingEnabled == false) && (*(char *)(lVar13 + 0x28) == '\0'))

+        {

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+             (uVar8 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+            uVar8 = 0;

+          }

+          local_138 = *(undefined8 *)pFVar2;

+          local_148 = 0x10;

+        }

+        else {

+          if (((pHVar3->leAlternatePhyState).IsCodedPhyEnabled != false) ||

+             (*(char *)(lVar13 + 0x38) == '\0')) {

+            local_f0 = (undefined8 *)(lVar13 + 8);

+            uStack_e0 = *local_f0;

+            uStack_d8 = *(undefined8 *)(lVar13 + 0x10);

+            local_98.__align = (ulong64)&PTR__scalar_deleting_destructor__140170ae8;

+            local_30 = &local_98;

+            local_e8 = this;

+            local_98._8_8_ = this;

+            local_98._16_8_ = uStack_e0;

+            local_98._24_8_ = uStack_d8;

+            bVar6 = Microsoft::Bluetooth::Foundation::Promise<UpdateRequestResult>::

+                    SetCancelFunction(local_108,(function<void___cdecl(void)> *)local_a0);

+            if (!bVar6) {

+              MicrosoftTelemetryAssertTriggeredMsgKM

+                        (

+                        "Since the future wasn\'t returned yet it couldn\'t have been already canceled"

+                        );

+            }

+            local_res20 = 0;

+            uVar10 = 1;

+            p_Var17 = p_Var15;

+            if ((local_108[0] == (Promise<UpdateRequestResult>)0x0) &&

+               (local_108[0] = (Promise<UpdateRequestResult>)0x1, p_Var15 = local_f8,

+               p_Var17 = local_100, local_f8 != (_RefCountBase *)0x0)) {

+              LOCK();

+              local_f8->_MyStrong = local_f8->_MyStrong + 1;

+              UNLOCK();

+              lVar13 = local_118._0_8_;

+            }

+            wil::acquire_kspin_lock((__uint64 *)&local_e8);

+            puVar16 = (ulonglong *)(lVar13 + 0x68);

+            uVar9 = -(ulonglong)(this != (ScanRequestProgrammer *)0xffffffffffffffa8) &

+                    (ulonglong)&this->m_programmingRequestList;

+            puVar7 = *(ulonglong **)(uVar9 + 8);

+            if (*puVar7 != uVar9) {

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

+              puVar7 = (ulonglong *)(*pcVar5)(3);

+              puVar12 = auStack_170;

+            }

+            *puVar16 = uVar9;

+            puVar16[1] = (ulonglong)puVar7;

+            *puVar7 = (ulonglong)puVar16;

+            *(ulonglong **)(uVar9 + 8) = puVar16;

+            *(undefined8 *)(puVar12 + -8) = 0x1400a3785;

+            utl::

+            shared_ptr<Microsoft::Bluetooth::Foundation::SharedState<Microsoft::Bluetooth::Foundation::Future<CentralConnectedStream::EstablishedStatus>_>_>

+            ::operator=((shared_ptr<Microsoft::Bluetooth::Foundation::SharedState<Microsoft::Bluetooth::Foundation::Future<CentralConnectedStream::EstablishedStatus>_>_>

+                         *)(lVar13 + 0x50),

+                        (shared_ptr<class_Microsoft::Bluetooth::Foundation::SharedState<class_Microsoft::Bluetooth::Foundation::Future<struct_CentralConnectedStream::EstablishedStatus>_>_>

+                         *)(puVar12 + 0x78));

+            lVar4 = *(longlong *)(puVar12 + 0x68);

+            *(undefined1 *)(lVar13 + 0x48) = puVar12[0x70];

+            this_02 = (_RefCountBase *)0x0;

+            lVar14 = lVar13;

+            if (lVar4 != 0) {

+              LOCK();

+              piVar1 = (int *)(lVar4 + 8);

+              *piVar1 = *piVar1 + 1;

+              UNLOCK();

+              this_02 = *(_RefCountBase **)(puVar12 + 0x68);

+              lVar14 = *(longlong *)(puVar12 + 0x60);

+            }

+            this_00 = *(_RefCountBase **)(lVar13 + 0x80);

+            *(longlong *)(lVar13 + 0x78) = lVar14;

+            *(_RefCountBase **)(lVar13 + 0x80) = this_02;

+            if (this_00 != (_RefCountBase *)0x0) {

+              *(undefined8 *)(puVar12 + -8) = 0x1400a37be;

+              utl::_RefCountBase::_DecStrong(this_00);

+            }

+            this->m_programmingRequestsChanged = true;

+            if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+               ((byte)WPP_GLOBAL_Control[0x29] < 4)) {

+              uVar10 = 0;

+            }

+            pFVar2 = this->m_fdo;

+            uVar8 = *(undefined8 *)(WPP_GLOBAL_Control + 0x18);

+            *(undefined4 *)(puVar12 + 0x50) = *(undefined4 *)(lVar14 + 0x3c);

+            *(undefined8 **)(puVar12 + 0x48) = local_f0;

+            *(undefined8 *)(puVar12 + 0x40) = *(undefined8 *)pFVar2;

+            *(undefined8 *)(puVar12 + -8) = 0x1400a3806;

+            WPP_RECORDER_AND_TRACE_SF_q_guid_ScanReqSource(uVar8,uVar10);

+            *(undefined8 *)(puVar12 + -8) = 0x1400a380f;

+            wil::details::

+            unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+            ::

+            ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+                      ((unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+                        *)&local_e8);

+            this_01 = *(StateMachineEngineImpl **)this;

+            *(undefined8 *)(puVar12 + -8) = 0x1400a381c;

+            SmFx::StateMachineEngine::StateMachineEngineImpl::EnqueueEvent(this_01,7);

+            *(_RefCountBase **)&__return_storage_ptr__->m_sharedState = p_Var17;

+            *(_RefCountBase **)&(__return_storage_ptr__->m_sharedState).field_0x8 = p_Var15;

+            *(undefined8 *)(puVar12 + -8) = 0x1400a3831;

+            wil::details::

+            unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+            ::

+            ~unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+                      ((unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+                        *)&local_res20);

+            puVar11 = puVar12;

+            local_b8 = local_f8;

+            if (this_02 != (_RefCountBase *)0x0) {

+              *(undefined8 *)(puVar12 + -8) = 0x1400a383e;

+              utl::_RefCountBase::_DecStrong(this_02);

+              local_b8 = local_f8;

+            }

+            goto joined_r0x0001400a3845;

+          }

+          if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) ||

+             (uVar8 = 1, (byte)WPP_GLOBAL_Control[0x29] < 2)) {

+            uVar8 = 0;

+          }

+          local_138 = *(undefined8 *)pFVar2;

+          local_148 = 0x11;

+        }

+        local_140 = &WPP_b36e6216b07b3579f1890b2c11c6d274_Traceguids;

+        local_150 = 1;

+        local_158 = 2;

+        WPP_RECORDER_AND_TRACE_SF_i

+                  (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),uVar8,1,pFVar2->m_recorderLog);

+      }

+      *(undefined8 *)&__return_storage_ptr__->m_sharedState = 0;

+      *(undefined8 *)&(__return_storage_ptr__->m_sharedState).field_0x8 = 0;

+      wil::details::

+      unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+      ::

+      ~unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+                ((unique_storage<wil::details::resource_policy<wil::operation_guard*___ptr64,void_(__cdecl*)(wil::operation_guard*___ptr64)_noexcept,&void___cdecl_wil::details::release_operation_guard_reference(class_wil::operation_guard*___ptr64),wistd::integral_constant<unsigned___int64,1>,wil::operation_guard*___ptr64,wil::operation_guard*___ptr64,0,std::nullptr_t>_>

+                  *)&local_res20);

+    }

+    if ((_RefCountBase *)local_118._8_8_ != (_RefCountBase *)0x0) {

+      utl::_RefCountBase::_DecStrong((_RefCountBase *)local_118._8_8_);

+    }

+  }

+joined_r0x0001400a3845:

+  if (local_b8 != (_RefCountBase *)0x0) {

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

+    utl::_RefCountBase::_DecStrong(local_b8);

+  }

+  return __return_storage_ptr__;

 }
```

## `AdvertisingRequestProgrammer::ProcessAdvertisingSetEnableConfirmation`  (modified)

```diff
--- AdvertisingRequestProgrammer::ProcessAdvertisingSetEnableConfirmation
+++ AdvertisingRequestProgrammer::ProcessAdvertisingSetEnableConfirmation
@@ -1,64 +1,107 @@
 

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

 /* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: enum AdvertisingProgrammerStateMachine<class AdvertisingRequestProgrammer>::Event

+   __cdecl AdvertisingRequestProgrammer::ProcessAdvertisingSetEnableConfirmation(void) __ptr64 */

 

 Event __thiscall

-AdvertisingRequestControllerModule::ProcessAdvertisingSetEnableConfirmation

+AdvertisingRequestProgrammer::ProcessAdvertisingSetEnableConfirmation

           (AdvertisingRequestProgrammer *this)

 

 {

-  HCI_INTERFACE *pHVar1;

-  code *pcVar2;

-  long lVar3;

-  longlong lVar4;

-  longlong unaff_RBX;

-  undefined8 unaff_RSI;

-  longlong unaff_RDI;

-  int in_R8D;

-  ulonglong in_R9;

-  short in_R10W;

-  void *in_R11;

-  ulonglong unaff_R14;

-  undefined1 local_res8 [32];

-  undefined1 uStack0000000000000046;

+  int iVar1;

+  longlong lVar2;

+  longlong lVar3;

+  uint uVar4;

+  undefined1 uVar5;

+  longlong *plVar6;

+  undefined1 uVar7;

+  undefined4 uVar8;

+  undefined4 uStack_90;

+  undefined1 local_88 [8];

+  undefined **local_80;

+  undefined8 local_78;

+  undefined8 uStack_70;

+  __base<void___cdecl(EnableRequestResult)> *local_18;

   

-  uStack0000000000000046 = SUB81(this,0);

-  lVar4 = **(longlong **)(unaff_RDI + 0x10);

-  if (*(char *)(lVar4 + 0xa0) == (char)unaff_RSI) {

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

-    (*pcVar2)();

-    register0x00000020 = (BADSPACEBASE *)local_res8;

+  lVar2 = *(longlong *)&this->m_inProgressProgrammingRequestList;

+  uVar5 = 0;

+  lVar3 = *(longlong *)(lVar2 + 0x10);

+  uVar7 = 1;

+  iVar1 = *(int *)(lVar3 + 200);

+  uVar4 = 0x80;

+  if (iVar1 != 1) {

+    uVar4 = 0x30;

   }

-  if (unaff_R14 < (ulonglong)(*(longlong *)(lVar4 + 0x90) - *(longlong *)(lVar4 + 0x88))) {

-    if (in_R10W == 0) {

-      *(undefined1 *)((longlong)register0x00000020 + 0x44) = 1;

+  plVar6 = (longlong *)((ulonglong)uVar4 + lVar3);

+  *(undefined4 *)(plVar6 + 9) = 0;

+  if (*plVar6 == 0) {

+    *(undefined4 *)(plVar6 + 8) = 0xc000009a;

+    *(undefined1 *)((longlong)plVar6 + 0x44) = 0xff;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+      uVar5 = 1;

     }

-    else {

-      *(byte *)((longlong)register0x00000020 + 0x44) =

-           (0 < (int)(in_R8D - ((uint)in_R9 & 0xff))) - 1U & 2;

+    WPP_RECORDER_AND_TRACE_SF_qHciLEAdvertisingStateManagerAdvTypeD

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+               CONCAT71((int7)((ulonglong)**(undefined8 **)(lVar2 + 0x10) >> 8),uVar5),1,

+               this->m_fdo->m_recorderLog,2);

+    return Error;

+  }

+  if ((*(int *)(*plVar6 + 8) - 2U & 0xfffffffd) != 0) {

+    *(undefined4 *)(plVar6 + 8) = 0xc0000001;

+    *(undefined1 *)((longlong)plVar6 + 0x44) = 0xff;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+      uVar5 = 1;

     }

+    WPP_RECORDER_AND_TRACE_SF_qHciLEAdvertisingStateManagerAdvTypeD

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+               CONCAT71((int7)((ulonglong)**(undefined8 **)(lVar2 + 0x10) >> 8),uVar5),1,

+               this->m_fdo->m_recorderLog,2);

+    MicrosoftTelemetryAssertTriggeredMsgKM("Token unexpectedly not available for advertising");

+    return Error;

+  }

+  uVar8 = 0;

+  if (plVar6[4] != 0) {

+    *(undefined4 *)(plVar6 + 8) = 0;

+    *(undefined1 *)((longlong)plVar6 + 0x44) = 0;

+    if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) != 0) && (1 < (byte)WPP_GLOBAL_Control[0x29])) {

+      uVar5 = 1;

+    }

+    WPP_RECORDER_AND_TRACE_SF_qHciLEAdvertisingStateManagerAdvTypeD

+              (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+               CONCAT71((int7)((ulonglong)lVar3 >> 8),uVar5),1,this->m_fdo->m_recorderLog,2);

+    uStack_90 = CONCAT31(uStack_90._1_3_,*(undefined1 *)(**(longlong **)(lVar2 + 0x10) + 0x10));

+    uStack_70 = CONCAT44((iVar1 != 1) + 1,uStack_90);

+    local_80 = &PTR__scalar_deleting_destructor__14016f7b0;

+    local_18 = (__base<void___cdecl(EnableRequestResult)> *)&local_80;

+    local_78 = this;

+    AsyncResetToken<UpdateRequestResult,EnableRequestResult>::Then

+              ((AsyncResetToken<UpdateRequestResult,EnableRequestResult> *)(plVar6 + 2),

+               (function<void___cdecl(EnableRequestResult)> *)local_88);

+    AdvertisingHandlePerformanceCounterToken::OnAdvertisingSetEnabled

+              ((AdvertisingHandlePerformanceCounterToken *)(*(longlong *)(lVar2 + 0x10) + 0x108));

+    return Done;

+  }

+  if ((int)plVar6[2] == 2) {

+    uVar8 = 0xc0000240;

   }

   else {

-    *(undefined1 *)((longlong)register0x00000020 + 0x44) = 3;

+    if ((int)plVar6[2] == 4) {

+      uVar5 = (undefined1)plVar6[3];

+      goto LAB_0;

+    }

+    uVar8 = *(undefined4 *)((longlong)plVar6 + 0x14);

   }

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

-  memmove((undefined1 *)((longlong)register0x00000020 + 0x47),in_R11,in_R9 & 0xff);

-  *(short *)(unaff_RBX + 0xec) =

-       *(short *)(unaff_RBX + 0xec) + (ushort)*(byte *)((longlong)register0x00000020 + 0x46);

-  *(undefined4 *)(unaff_RBX + 0xe0) = 0xc0000001;

-  *(undefined1 *)(unaff_RBX + 0xe4) = 0xff;

-  pHVar1 = *(HCI_INTERFACE **)(*(longlong *)(unaff_RBX + 8) + 0x4a0);

-  *(undefined8 *)((longlong)register0x00000020 + 0x30) = unaff_RSI;

-  *(int *)((longlong)register0x00000020 + 0x28) = (int)unaff_RSI;

-  *(longlong *)((longlong)register0x00000020 + 0x20) = unaff_RBX;

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

-  lVar3 = HCI_SendCommandEx(pHVar1,(_HCI_COMMAND_HEADER *)((longlong)register0x00000020 + 0x40),

-                            (_GUID *)0x0,

-                            <lambda_188f630be6399ad18ef8928e8ca7bcd3>::<lambda_invoker_cdecl>,

-                            *(void **)((longlong)register0x00000020 + 0x20),

-                            *(ulong *)((longlong)register0x00000020 + 0x28),

-                            *(void **)((longlong)register0x00000020 + 0x30));

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

-  return (Event)lVar3;

+  uVar5 = 0xff;

+LAB_0:

+  *(undefined4 *)(plVar6 + 8) = uVar8;

+  *(undefined1 *)((longlong)plVar6 + 0x44) = uVar5;

+  if (((*(uint *)(WPP_GLOBAL_Control + 0x2c) & 1) == 0) || ((byte)WPP_GLOBAL_Control[0x29] < 2)) {

+    uVar7 = 0;

+  }

+  WPP_RECORDER_AND_TRACE_SF_qHciLEAdvertisingStateManagerAdvTypeDdL

+            (*(undefined8 *)(WPP_GLOBAL_Control + 0x18),

+             CONCAT71((int7)((ulonglong)**(undefined8 **)(lVar2 + 0x10) >> 8),uVar7),uVar5,

+             this->m_fdo->m_recorderLog);

+  return Error;

 }
```

## `HciLEExtendedAdvertisingRequestCoordinator::SetAdvertisingParametersCommandComplete`  (modified)

```diff
--- HciLEExtendedAdvertisingRequestCoordinator::SetAdvertisingParametersCommandComplete
+++ HciLEExtendedAdvertisingRequestCoordinator::SetAdvertisingParametersCommandComplete
@@ -1,2 +1,64 @@
-Failed to decompile bthport.sys - .ProgramDB HciLEExtendedAdvertisingRequestCoordinator::SetAdvertisingParametersCommandComplete : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* private: void __cdecl

+   HciLEExtendedAdvertisingRequestCoordinator::SetAdvertisingParametersCommandComplete(struct

+   _HCI_CALLBACK_DATA const & __ptr64) __ptr64 */

+

+void __thiscall

+HciLEExtendedAdvertisingRequestCoordinator::SetAdvertisingParametersCommandComplete

+          (HciLEExtendedAdvertisingRequestCoordinator *this,_HCI_CALLBACK_DATA *param_1)

+

+{

+  uint uVar1;

+  _HCI_COMMAND *p_Var2;

+  longlong lVar3;

+  _HCI_EVENT *p_Var4;

+  ulonglong uVar5;

+  HciLEExtendedAdvertisingRequestCoordinator *pHVar6;

+  unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+  local_18 [16];

+  

+  pHVar6 = this;

+  StoreHciCommandCompleteResults(this,param_1);

+  if ((-1 < param_1->Status) && (param_1->BtStatus == '\0')) {

+    *(uint *)(*(longlong *)(pHVar6 + 0x48) + 0x10) =

+         *(uint *)(*(longlong *)(pHVar6 + 0x48) + 0x10) | 0x20;

+    p_Var2 = param_1->Cmd;

+    lVar3 = *(longlong *)(pHVar6 + 0x48);

+    p_Var4 = param_1->Event;

+    uVar1 = *(uint *)(lVar3 + 0x10);

+    if (((p_Var2->Cmd_Inquiry).LAP[1] & 1) == 0) {

+      if ((uVar1 & 2) != 0) {

+        *(uint *)(lVar3 + 0x10) = uVar1 & 0xfffffffd;

+        LOCK();

+        *(int *)(this + 0x40) = *(int *)(this + 0x40) + -1;

+        UNLOCK();

+      }

+    }

+    else if ((uVar1 & 2) == 0) {

+      *(uint *)(lVar3 + 0x10) = uVar1 | 2;

+      LOCK();

+      *(int *)(this + 0x40) = *(int *)(this + 0x40) + 1;

+      UNLOCK();

+    }

+    *(uchar *)(*(longlong *)(this + 0x48) + 0x28) = (p_Var4->Event_Generic).Event_Parameter[4];

+    if ((p_Var2->Cmd_Link_Key_Request_Reply).Link_Key[4] == '\0') {

+      wil::acquire_kspin_lock((__uint64 *)local_18);

+      lVar3 = *(longlong *)(this + 0x48);

+      uVar5 = *(ulonglong *)(*(longlong *)(this + 0xe0) + 0x124);

+      *(undefined1 *)(lVar3 + 0x50) = 0;

+      *(ulonglong *)(lVar3 + 0x48) = uVar5 & 0xffffffffffff;

+      wil::details::

+      unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+      ::

+      ~unique_storage<wil::details::resource_policy<unsigned___int64*___ptr64,void___cdecl(wil::details::kspin_lock_saved_irql_const&___ptr64),&public:_static_void___cdecl_wil::details::kspin_lock_saved_irql::Release(struct_wil::details::kspin_lock_saved_irql_const&___ptr64),wistd::integral_constant<unsigned___int64,2>,wil::details::kspin_lock_saved_irql,unsigned___int64*___ptr64,0,std::nullptr_t>_>

+                (local_18);

+    }

+    AdvertisingHandlePerformanceCounterToken::OnAdvertisingHandleAllocated

+              ((AdvertisingHandlePerformanceCounterToken *)(*(longlong *)(this + 0x48) + 0x60));

+  }

+  SmFx::StateMachineEngine::StateMachineEngineImpl::EnqueueEvent

+            (*(StateMachineEngineImpl **)(this + 8),8);

+  return;

+}

+
```

## `Controller::CanHandleIrp`  (modified)

```diff
--- Controller::CanHandleIrp
+++ Controller::CanHandleIrp
@@ -1,37 +1,87 @@
 

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

-/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* public: static bool __cdecl Controller::CanHandleIrp(struct _IRP * __ptr64) */

 

-bool __cdecl ConnectedStreamEstablishmentOperationQueue::CanHandleIrp(_IRP *param_1)

+bool __cdecl Controller::CanHandleIrp(_IRP *param_1)

 

 {

-  undefined1 extraout_AL;

-  longlong in_RAX;

-  undefined8 uVar1;

-  longlong lVar2;

-  wdf_request_completer *pwVar3;

-  undefined8 unaff_RBX;

-  longlong unaff_RBP;

-  __uint64 unaff_RDI;

-  __uint64 in_R8;

+  uint uVar1;

+  char *pcVar2;

+  int iVar3;

+  bool bVar4;

   

-  uVar1 = (**(code **)(in_RAX + 0x4e8))((undefined4)WdfDriverGlobals);

-  lVar2 = (**(code **)(WdfFunctions_01031 + 0x650))

-                    (CONCAT44(WdfDriverGlobals._4_4_,(undefined4)WdfDriverGlobals),uVar1,

-                     PTR__WDF_Fdo_TYPE_INFO_14019a1e0);

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

-  pwVar3 = (wdf_request_completer *)(unaff_RBP + -0x30);

-  *(undefined2 *)(unaff_RBP + -0x1c) = 0;

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

-  *(undefined8 *)(unaff_RBP + -0x10) = 0;

-  *(undefined2 *)(unaff_RBP + -4) = 0;

-  *(undefined8 *)(unaff_RBP + -0x30) = unaff_RBX;

-  *(undefined4 *)(unaff_RBP + -0x20) = 0xc0000001;

-  *(undefined4 *)(unaff_RBP + -8) = 0xc0000001;

-  Controller::OnRequest

-            ((Controller *)(lVar2 + 0x30),pwVar3,in_R8,unaff_RDI,*(ulong *)(unaff_RBP + 0x30));

-  wil::wdf_request_completer::reset

-            ((wdf_request_completer *)(unaff_RBP + -0x18),(WDFREQUEST__ *)pwVar3);

-  return (bool)extraout_AL;

+  pcVar2 = (param_1->Tail).Apc.SystemArgument1;

+  if (*pcVar2 == '\x0e') {

+    uVar1 = *(uint *)(pcVar2 + 0x18);

+    if (uVar1 < 0x4112a5) {

+      if (uVar1 != 0x4112a4) {

+        if (0x411270 < uVar1) {

+          if (uVar1 < 0x41128d) {

+            if ((uVar1 == 0x41128c) || (uVar1 == 0x411274)) goto LAB_0;

+            iVar3 = uVar1 - 0x411278;

+            bVar4 = iVar3 == 0;

+          }

+          else {

+            iVar3 = uVar1 - 0x411290;

+            bVar4 = iVar3 == 0;

+          }

+          goto LAB_1;

+        }

+        if (uVar1 != 0x411270) {

+          if (0x411258 < uVar1) {

+            iVar3 = uVar1 - 0x41125c;

+            bVar4 = iVar3 == 0;

+            goto LAB_1;

+          }

+          if (((uVar1 == 0x411258) || (uVar1 == 0x41118c)) || (uVar1 == 0x4111c4))

+          goto LAB_0;

+          iVar3 = uVar1 - 0x411248;

+          goto LAB_2;

+        }

+      }

+    }

+    else if (uVar1 < 0x4112dd) {

+      if (uVar1 != 0x4112dc) {

+        if (uVar1 < 0x4112c5) {

+          if ((uVar1 == 0x4112c4) || (uVar1 == 0x4112a8)) goto LAB_0;

+          iVar3 = uVar1 - 0x4112b0;

+          bVar4 = iVar3 == 0;

+        }

+        else {

+          iVar3 = uVar1 - 0x4112c8;

+          bVar4 = iVar3 == 0;

+        }

+LAB_1:

+        if (!bVar4) {

+          iVar3 = iVar3 + -4;

+LAB_2:

+          if ((iVar3 != 0) && (iVar3 = iVar3 + -4, iVar3 != 0)) {

+LAB_3:

+            if ((iVar3 != 4) && (iVar3 != 8)) goto LAB_4;

+          }

+        }

+      }

+    }

+    else if (uVar1 < 0x4112f5) {

+      if (((uVar1 != 0x4112f4) && (uVar1 != 0x4112e0)) && (uVar1 != 0x4112e4)) {

+        iVar3 = uVar1 - 0x4112e8;

+        if (iVar3 != 0) goto LAB_3;

+        Feature_BluetoothLEBroadcastAudioHci__private_ReportDeviceUsage();

+      }

+    }

+    else if (((uVar1 != 0x4112f8) && (uVar1 != 0x4112fc)) && (uVar1 != 0x411300)) {

+      if ((uVar1 == 0x411304) || (uVar1 == 0x411308)) {

+        iVar3 = Feature_56664216__private_IsEnabledDeviceUsageNoInline();

+        return iVar3 != 0;

+      }

+      goto LAB_4;

+    }

+LAB_0:

+    bVar4 = true;

+  }

+  else {

+LAB_4:

+    bVar4 = false;

+  }

+  return bVar4;

 }
```

## `LinkManagerConnectRequestToken::~LinkManagerConnectRequestToken`  (modified)

```diff
--- LinkManagerConnectRequestToken::~LinkManagerConnectRequestToken
+++ HCI_CLIENT::~HCI_CLIENT
@@ -1,8 +1,33 @@
 

-void __thiscall

-LinkManagerConnectRequest::~LinkManagerConnectRequestToken(LinkManagerConnectRequestToken *this)

+/* public: __cdecl HCI_CLIENT::~HCI_CLIENT(void) __ptr64 */

+

+void __thiscall HCI_CLIENT::~HCI_CLIENT(HCI_CLIENT *this)

 

 {

+  code *pcVar1;

+  int iVar2;

+  undefined1 *puVar3;

+  undefined8 uStack_30;

+  undefined1 auStack_28 [8];

+  undefined1 auStack_20 [24];

+  

+  puVar3 = auStack_28;

+  iVar2 = Feature_29442873__private_IsEnabledDeviceUsageNoInline();

+  if (iVar2 != 0) {

+    puVar3 = auStack_28;

+    if ((HCI_CLIENT *)(this->ListEntry).Flink != this) {

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

+      (*pcVar1)();

+      puVar3 = auStack_20;

+    }

+    if ((this->MoveEntry).Flink != &this->MoveEntry) {

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

+      (*pcVar1)();

+      puVar3 = puVar3 + 8;

+    }

+  }

+  *(undefined8 *)(puVar3 + -8) = 0x14001c419;

+  LinkManagerConnectRequestToken::~LinkManagerConnectRequestToken(&this->ConnectionRequest);

   return;

 }
```

## `BroadcastIsochronousGroupImpl::ClearPowerManagementState`  (modified)

```diff
--- BroadcastIsochronousGroupImpl::ClearPowerManagementState
+++ PowerCoordinator::PowerReference::Reset
@@ -1,2 +1,14 @@
-Failed to decompile bthport.sys - .ProgramDB BroadcastIsochronousGroupImpl::ClearPowerManagementState : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* WARNING: Enum "_POOL_TYPE": Some values do not have unique names */

+/* public: void __cdecl PowerCoordinator::PowerReference::Reset(void) __ptr64 */

+

+void __thiscall PowerCoordinator::PowerReference::Reset(PowerReference *this)

+

+{

+  if (this->m_powerCoordinator != (PowerCoordinator *)0x0) {

+    ReleasePowerReference(this->m_powerCoordinator,this->m_reason);

+    this->m_powerCoordinator = (PowerCoordinator *)0x0;

+  }

+  return;

+}

+
```

## `AdvertisingHandlePerformanceCounterToken::~AdvertisingHandlePerformanceCounterToken`  (modified)

```diff
--- AdvertisingHandlePerformanceCounterToken::~AdvertisingHandlePerformanceCounterToken
+++ AdvertisingHandlePerformanceCounterToken::Reset
@@ -1,13 +1,33 @@
+

+/* private: void __cdecl AdvertisingHandlePerformanceCounterToken::Reset(void) __ptr64 */

 

 void __thiscall

-AdvertisingHandleAllocator::~AdvertisingHandlePerformanceCounterToken

-          (AdvertisingHandlePerformanceCounterToken *this)

+AdvertisingHandlePerformanceCounterToken::Reset(AdvertisingHandlePerformanceCounterToken *this)

 

 {

-  undefined2 uStack0000000000000030;

+  ulong *puVar1;

+  atomic<bool> aVar2;

   

-  uStack0000000000000030 = 0x3f;

-  WPP_RECORDER_AND_TRACE_SF_iL();

+  LOCK();

+  aVar2 = this->m_advertisingSetEnabled;

+  this->m_advertisingSetEnabled = (atomic<bool>)0x0;

+  UNLOCK();

+  if (aVar2 != (atomic<bool>)0x0) {

+    LOCK();

+    puVar1 = &(this->m_perfCounters->m_counters).EnabledAdvertisingSetCount;

+    *puVar1 = *puVar1 - 1;

+    UNLOCK();

+  }

+  LOCK();

+  aVar2 = this->m_advertisingHandleAllocated;

+  this->m_advertisingHandleAllocated = (atomic<bool>)0x0;

+  UNLOCK();

+  if (aVar2 != (atomic<bool>)0x0) {

+    LOCK();

+    puVar1 = &(this->m_perfCounters->m_counters).AllocatedAdvertisingHandleCount;

+    *puVar1 = *puVar1 - 1;

+    UNLOCK();

+  }

   return;

 }
```
