# CVE-2020-0639 — clfs.sys patch diff

`clfs.sys` 10.0.18362.356 -> 10.0.18362.592 (ghidriff).

## `ClfsEncodeBlockPrivate`  (modified)

```diff
--- ClfsEncodeBlockPrivate
+++ ClfsEncodeBlockPrivate
@@ -1,9 +1,61 @@
+

+/* long __cdecl ClfsEncodeBlockPrivate(struct _CLFS_LOG_BLOCK_HEADER * __ptr64,unsigned

+   long,unsigned char,unsigned char) */

 

 long __cdecl

 ClfsEncodeBlockPrivate(_CLFS_LOG_BLOCK_HEADER *param_1,ulong param_2,uchar param_3,uchar param_4)

 

 {

-                    /* WARNING: Subroutine does not return */

-  KeBugCheckEx();

+  ushort uVar1;

+  byte bVar2;

+  long lVar3;

+  uint uVar4;

+  byte bVar5;

+  uint uVar6;

+  _CLFS_LOG_BLOCK_HEADER *p_Var7;

+  short local_res8;

+  ulong local_18 [4];

+  

+  uVar1 = *(ushort *)(param_1 + 4);

+  local_18[0] = 0;

+  if (((uVar1 != 0) && (uVar1 <= *(ushort *)(param_1 + 6))) && ((uint)uVar1 << 9 <= param_2)) {

+    if ((0x10 < param_4) || ((0x10111U >> (param_4 & 0x1f) & 1) == 0)) {

+      return -0x3ffffff3;

+    }

+    uVar4 = *(uint *)(param_1 + 0x10);

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

+      uVar6 = *(uint *)(param_1 + 0x68);

+      param_1[2] = (_CLFS_LOG_BLOCK_HEADER)param_3;

+      local_res8 = (ushort)param_3 << 8;

+      p_Var7 = param_1 + uVar6;

+      lVar3 = ULongAdd(uVar6,(param_2 >> 9) * 2,local_18);

+      if (((-1 < lVar3) && (uVar6 <= local_18[0])) &&

+         (((uVar6 & 7) == 0 && (local_18[0] <= param_2)))) {

+        uVar6 = 0;

+        if (param_2 >> 9 != 0) {

+          do {

+            bVar5 = 0x20;

+            if (*(ushort *)(param_1 + 4) - 1 != uVar6) {

+              bVar5 = 0;

+            }

+            bVar2 = 0x40;

+            if (uVar6 != 0) {

+              bVar2 = 0;

+            }

+            uVar4 = uVar6 << 9;

+            local_res8 = CONCAT11(local_res8._1_1_,bVar5 | bVar2 | param_4);

+            uVar6 = uVar6 + 1;

+            *(undefined2 *)p_Var7 = *(undefined2 *)(param_1 + (ulonglong)uVar4 + 0x1fe);

+            *(short *)(param_1 + (ulonglong)uVar4 + 0x1fe) = local_res8;

+            p_Var7 = p_Var7 + 2;

+          } while (uVar6 < param_2 >> 9);

+          uVar4 = *(uint *)(param_1 + 0x10);

+        }

+        *(uint *)(param_1 + 0x10) = uVar4 & 0xfffffffd | 1;

+        return 0;

+      }

+    }

+  }

+  return -0x3fe5fff6;

 }
```

## `ClfsDecodeBlockPrivate`  (modified)

```diff
--- ClfsDecodeBlockPrivate
+++ ClfsDecodeBlockPrivate
@@ -1,320 +1,88 @@
 

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

-/* WARNING: Variable defined which should be unmapped: param_5 */

+/* long __cdecl ClfsDecodeBlockPrivate(struct _CLFS_LOG_BLOCK_HEADER * __ptr64,unsigned

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

 

 long __cdecl

 ClfsDecodeBlockPrivate

           (_CLFS_LOG_BLOCK_HEADER *param_1,ulong param_2,uchar param_3,uchar param_4,ulong *param_5)

 

 {

-  CClfsLogFcbCommon *pCVar1;

-  char cVar2;

-  uchar uVar3;

-  uint uVar4;

-  longlong lVar5;

-  undefined4 *puVar6;

-  _FILE_OBJECT *p_Var7;

-  __uint64 _Var8;

-  uchar *puVar9;

-  undefined8 *puVar10;

-  undefined8 uVar11;

-  ulong unaff_ESI;

-  ulonglong uVar12;

-  __int64 *p_Var13;

-  _CLS_LSN *unaff_R12;

-  uint uVar14;

-  CClfsLogFcbCommon *unaff_R14;

-  char cVar15;

-  _CLS_LSN *unaff_R15;

-  char in_stack_00000050;

-  int iStack0000000000000054;

-  char in_stack_00000058;

-  char in_stack_00000059;

-  byte in_stack_0000005b;

-  _CLS_LSN *in_stack_00000068;

-  ulong in_stack_00000074;

-  _FILE_OBJECT *in_stack_00000078;

-  _CLS_LSN *in_stack_00000088;

-  undefined8 in_stack_00000098;

-  longlong in_stack_000000a0;

-  longlong in_stack_000000a8;

-  longlong in_stack_000000b0;

-  __uint64 in_stack_000000b8;

-  CClfsLogFcbCommon *in_stack_00000148;

-  undefined8 in_stack_00000150;

-  uint in_stack_00000158;

-  undefined4 in_stack_00000160;

-  longlong in_stack_00000168;

-  char in_stack_00000178;

-  _FILE_OBJECT *in_stack_00000180;

-  int iVar16;

+  _CLFS_LOG_BLOCK_HEADER _Var1;

+  uint uVar2;

+  byte bVar3;

+  long lVar4;

+  uint uVar5;

+  byte bVar6;

+  ulonglong uVar7;

+  int iVar8;

+  uint uVar9;

+  _CLFS_LOG_BLOCK_HEADER *p_Var10;

+  ulonglong uVar11;

+  ulong local_res10 [2];

   

-  *(uint *)(unaff_R14 + 0x15c) = *(uint *)(unaff_R14 + 0x15c) | 0x40;

-  uVar14 = 0xffffffff;

-  CClfsBaseFile::ReleaseClientContext

-            (*(CClfsBaseFile **)(unaff_R14 + 0x2a8),(_CLFS_CLIENT_CONTEXT **)&stack0x00000068);

-  lVar5 = ExAllocatePoolWithTag(0x200,0x10,unaff_ESI);

-  *(longlong *)(unaff_R14 + 0x388) = lVar5;

-  cVar15 = (char)unaff_R15;

-  iVar16 = (int)unaff_R15;

-  if (lVar5 != 0) {

-    *(longlong *)(lVar5 + 8) = lVar5;

-    *(longlong *)lVar5 = lVar5;

-    lVar5 = ExAllocatePoolWithTag(0x200,8,unaff_ESI);

-    *(longlong *)(unaff_R14 + 0x390) = lVar5;

-    if (lVar5 != 0) {

-      KeInitializeSpinLock(lVar5);

-      lVar5 = ExAllocatePoolWithTag(0x200,8,unaff_ESI);

-      *(longlong *)(unaff_R14 + 0x3b0) = lVar5;

-      if (lVar5 != 0) {

-        KeInitializeSpinLock(lVar5);

-        puVar6 = (undefined4 *)ExAllocatePoolWithTag(0x200,0x38,unaff_ESI);

-        *(undefined4 **)(unaff_R14 + 0x410) = puVar6;

-        if (puVar6 != (undefined4 *)0x0) {

-          *puVar6 = 1;

-          *(_CLS_LSN **)(puVar6 + 2) = unaff_R15;

-          puVar6[4] = iVar16;

-          KeInitializeEvent(puVar6 + 6,1,0);

-          cVar2 = (**(code **)(*(longlong *)unaff_R14 + 0x138))();

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

+  local_res10[0] = 0;

+  uVar11 = (ulonglong)param_2;

+  if (param_2 == 0) {

 LAB_0:

-            in_stack_00000148 = unaff_R14 + 0x38;

-            *(CClfsLogFcbCommon **)(in_stack_00000180 + 0x18) = in_stack_00000148;

-            in_stack_00000074 =

-                 CClfsBaseFile::ContainerCount(*(CClfsBaseFile **)(unaff_R14 + 0x2a8));

-            (**(code **)(*(longlong *)(unaff_R14 + 0x250) + 0x40))();

-            iStack0000000000000054 =

-                 CClfsBaseFilePersisted::LoadContainerQ

-                           (*(CClfsBaseFilePersisted **)(unaff_R14 + 0x2a8),unaff_R14 + 0x558);

-            if (-1 < iStack0000000000000054) {

-              uVar12 = (ulonglong)in_stack_00000074;

-              if (in_stack_00000074 != 0) {

-                in_stack_00000050 = '\x01';

-                *(undefined8 *)(unaff_R14 + 0x298) = in_stack_00000098;

-              }

-              if ((in_stack_0000005b & 8) == 0) {

-                if (in_stack_00000074 != 0) {

-                  p_Var7 = (_FILE_OBJECT *)

-                           IoCreateStreamFileObjectLite(0,*(undefined8 *)(unaff_R14 + 0x220));

-                  in_stack_00000078 = p_Var7;

-                  if (iStack0000000000000054 < 0) goto LAB_1;

-                  *(CClfsLogFcbCommon **)(p_Var7 + 0x18) = in_stack_00000148;

-                  *(_CLS_LSN **)(p_Var7 + 0x20) = unaff_R15;

-                  uVar11 = (**(code **)(*(longlong *)unaff_R14 + 0x30))();

-                  *(undefined8 *)(p_Var7 + 0x28) = uVar11;

-                  (**(code **)(*(longlong *)unaff_R14 + 0x40))();

-                  iStack0000000000000054 = (*(code *)**(undefined8 **)unaff_R14)();

-                  if (iStack0000000000000054 < 0) goto LAB_1;

-                  in_stack_00000058 = '\x01';

-                  in_stack_000000a0 = uVar12 * *(longlong *)(unaff_R14 + 0x298);

-                  p_Var13 = &stack0x000000a0;

-                  in_stack_000000a8 = in_stack_000000a0;

-                  iStack0000000000000054 =

-                       CClfsLogFcbPhysical::SetCacheFileSizes

-                                 ((CClfsLogFcbPhysical *)unaff_R14,p_Var7,&stack0x000000a8,p_Var13);

-                  uVar3 = (uchar)p_Var13;

-                  if ((iStack0000000000000054 < 0) ||

-                     (iStack0000000000000054 =

-                           CClfsLogFcbPhysical::RecoverTruncateLog

-                                     ((CClfsLogFcbPhysical *)unaff_R14,p_Var7),

-                     iStack0000000000000054 < 0)) goto LAB_1;

-                  cVar2 = (**(code **)(*(longlong *)unaff_R14 + 0x138))();

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

-                    if (((*(uint *)(unaff_R14 + 0x15c) & 0x40) == 0) &&

-                       (iStack0000000000000054 =

-                             CClfsLogFcbPhysical::FindEndOfLog

-                                       ((CClfsLogFcbPhysical *)unaff_R14,p_Var7,

-                                        (_CLS_LSN *)(unaff_R14 + 0x1d8)), iStack0000000000000054 < 0

-                       )) goto LAB_1;

-                    puVar10 = (undefined8 *)(**(code **)(*(longlong *)unaff_R14 + 0x160))();

-                    pCVar1 = unaff_R14 + 0x528;

-                    *(undefined8 *)pCVar1 = *puVar10;

-                    uVar4 = uVar14;

-                    if (pCVar1 != (CClfsLogFcbCommon *)0x0) {

-                      uVar4 = *(uint *)pCVar1 & 0x1ff;

-                    }

-                    if (uVar4 != 0) {

-                      uVar4 = 0xffffffff;

-                      if ((pCVar1 != (CClfsLogFcbCommon *)0x0) &&

-                         (uVar4 = *(uint *)pCVar1 & 0xfffffe00, uVar14 = 0xffffffff,

-                         pCVar1 != (CClfsLogFcbCommon *)0x0)) {

-                        uVar14 = *(uint *)(unaff_R14 + 0x52c);

-                      }

-                      uVar11 = ClfsLsnCreate(uVar14,uVar4,0);

-                      *(undefined8 *)pCVar1 = uVar11;

-                    }

-                  }

-                  else {

-                    iStack0000000000000054 =

-                         CClfsLogFcbPhysical::RebuildOwnerPage

-                                   ((CClfsLogFcbPhysical *)unaff_R14,p_Var7);

-                    if (iStack0000000000000054 < 0) goto LAB_1;

-                    puVar10 = (undefined8 *)(**(code **)(*(longlong *)unaff_R14 + 0x160))();

-                    pCVar1 = unaff_R14 + 0x528;

-                    *(undefined8 *)pCVar1 = *puVar10;

-                    uVar4 = 0xffffffff;

-                    if (pCVar1 != (CClfsLogFcbCommon *)0x0) {

-                      uVar4 = *(uint *)pCVar1 & 0x1ff;

-                    }

-                    if (uVar4 != 0) {

-                      uVar4 = 0xffffffff;

-                      if ((pCVar1 != (CClfsLogFcbCommon *)0x0) &&

-                         (uVar4 = *(uint *)pCVar1 & 0xfffffe00, uVar14 = 0xffffffff,

-                         pCVar1 != (CClfsLogFcbCommon *)0x0)) {

-                        uVar14 = *(uint *)(unaff_R14 + 0x52c);

-                      }

-                      uVar11 = ClfsLsnCreate(uVar14,uVar4,0);

-                      *(undefined8 *)pCVar1 = uVar11;

-                    }

-                    CClfsLogFcbPhysical::PurgeCacheSection

-                              ((CClfsLogFcbPhysical *)unaff_R14,(_CLS_LSN *)&CLFS_LSN_NULL,

-                               (_CLS_LSN *)&CLFS_LSN_NULL,uVar3);

-                  }

-                  *(ulonglong *)(unaff_R14 + 0x1b8) = uVar12 * *(longlong *)(unaff_R14 + 0x298);

-                  _Var8 = CClfsLogFcbPhysical::CalculateAvailableFreeSpace

-                                    ((CClfsLogFcbPhysical *)unaff_R14);

-                  *(__uint64 *)(unaff_R14 + 0x1c0) = _Var8;

-                  in_stack_000000b0 = uVar12 * *(longlong *)(unaff_R14 + 0x298);

-                  in_stack_000000b8 =

-                       CClfsLogFcbPhysical::LsnToCacheOffset

-                                 ((CClfsLogFcbPhysical *)unaff_R14,(_CLS_LSN *)(unaff_R14 + 0x1d0));

-                  iStack0000000000000054 =

-                       CClfsLogFcbPhysical::SetCacheFileSizes

-                                 ((CClfsLogFcbPhysical *)unaff_R14,p_Var7,

-                                  (__int64 *)&stack0x000000b8,&stack0x000000b0);

-                  if (iStack0000000000000054 < 0) goto LAB_1;

-                }

-                uVar3 = CClfsLogFcbCommon::IsReadOnly(unaff_R14);

-                if ((uVar3 == '\0') && ((*(uint *)(unaff_R14 + 0x15c) & 0x40) != 0)) {

-                  iStack0000000000000054 = (**(code **)(*(longlong *)unaff_R14 + 0x70))();

-                  if (iStack0000000000000054 < 0) goto LAB_1;

-                  *(uint *)(unaff_R14 + 0x15c) = *(uint *)(unaff_R14 + 0x15c) & 0xffffffbf;

-                }

-                p_Var7 = in_stack_00000180;

-                pCVar1 = unaff_R14 + 0x250;

-                cVar2 = (**(code **)(*(longlong *)pCVar1 + 0x40))(pCVar1);

-                if ((cVar2 == '\0') ||

-                   (iStack0000000000000054 =

-                         (**(code **)(*(longlong *)pCVar1 + 400))

-                                   (pCVar1,in_stack_00000150,in_stack_00000158,

-                                    *(undefined4 *)(in_stack_00000168 + 0x14),in_stack_00000168),

-                   unaff_R12 = unaff_R15, -1 < iStack0000000000000054)) {

-                  uVar3 = CClfsLogFcbCommon::IsReadOnly(unaff_R14);

-                  if ((uVar3 == '\0') || ((in_stack_00000158 & 0x10006) == 0)) {

-                    cVar2 = (**(code **)(*(longlong *)unaff_R14 + 0x158))();

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

-                      IoSetShareAccess(in_stack_00000158,in_stack_00000160,p_Var7,unaff_R14 + 0x140)

-                      ;

-                      unaff_R12 = unaff_R15;

-                      iStack0000000000000054 = iVar16;

-                    }

-                    else {

-                      iStack0000000000000054 = IoCheckShareAccess();

-                      unaff_R12 = unaff_R15;

-                    }

-                  }

-                  else {

-                    iStack0000000000000054 = -0x3fffffde;

-                    unaff_R12 = unaff_R15;

-                  }

-                }

-              }

-              else {

-                CClfsLogFcbPhysical::DeleteBaseFileAndContainers((CClfsLogFcbPhysical *)unaff_R14);

-                iStack0000000000000054 = -0x3ffffedd;

-                in_stack_00000050 = cVar15;

-              }

+    lVar4 = -0x3ffffff3;

+  }

+  else {

+    if ((*param_1 != (_CLFS_LOG_BLOCK_HEADER)0x15) || (param_1[1] != (_CLFS_LOG_BLOCK_HEADER)0x0)) {

+      return -0x3fe5fff7;

+    }

+    if (*(ushort *)(param_1 + 4) <= param_2) {

+      if ((0x10 < param_4) || ((0x10111U >> (param_4 & 0x1f) & 1) == 0)) goto LAB_0;

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

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

+        uVar9 = param_2 << 9;

+        uVar7 = (ulonglong)uVar2;

+        p_Var10 = param_1;

+        lVar4 = ULongAdd(uVar2,param_2 * 2,local_res10);

+        if (((-1 < lVar4) && ((uVar7 & 7) == 0)) && (local_res10[0] <= uVar9)) {

+          uVar7 = uVar11 & 0xffffffff;

+          while( true ) {

+            iVar8 = (int)uVar7;

+            uVar9 = iVar8 - 1;

+            bVar6 = 0x20;

+            if ((int)uVar11 != iVar8) {

+              bVar6 = 0;

             }

-            goto LAB_1;

-          }

-          if (*(longlong *)(unaff_R14 + 0x2a0) != 0) {

-                    /* WARNING: Subroutine does not return */

-            KeBugCheckEx(0xc1f5,0x2f);

-          }

-          puVar9 = (uchar *)ExAllocateFromPagedLookasideList(0x1c001fc40);

-          *(uchar **)(unaff_R14 + 0x2a0) = puVar9;

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

-            ClfsInitializeOwnerPage(puVar9,*(ulong *)(*(longlong *)(unaff_R14 + 0x2a8) + 0x90));

-            *(undefined4 *)(unaff_R14 + 0x4f0) = 0x3f8;

-            unaff_R12 = (_CLS_LSN *)ExAllocatePoolWithTag(1,0x3e0);

-            if (unaff_R12 != (_CLS_LSN *)0x0) {

-              iStack0000000000000054 =

-                   CClfsBaseFile::LoadClientBaseLsn

-                             (*(CClfsBaseFile **)(unaff_R14 + 0x2a8),unaff_R12,unaff_ESI,

-                              (ulong *)&stack0x00000090);

-              if (iStack0000000000000054 < 0) goto LAB_1;

-              iStack0000000000000054 =

-                   CDynamicLsnQ::Initialize

-                             ((CDynamicLsnQ *)(unaff_R14 + 0x1590),unaff_R12,unaff_ESI);

-              if (iStack0000000000000054 < 0) goto LAB_1;

-              ExFreePoolWithTag(unaff_R12,0);

-              unaff_R12 = unaff_R15;

-              if (*(int *)(unaff_R14 + 0x1598) != iVar16) {

-                puVar10 = (undefined8 *)CDynamicLsnQ::TopLsn((CDynamicLsnQ *)(unaff_R14 + 0x1590));

-                *(undefined8 *)(unaff_R14 + 0x1d8) = *puVar10;

-              }

-              goto LAB_0;

+            bVar3 = 0x40;

+            if (uVar9 != 0) {

+              bVar3 = 0;

+            }

+            uVar5 = uVar9 * 0x200;

+            bVar6 = bVar6 | bVar3 | param_4;

+            _Var1 = p_Var10[(ulonglong)uVar5 + 0x1fe];

+            if ((char)_Var1 < '\0') {

+              *param_5 = iVar8 - 1;

+              return -0x3fe5fffd;

+            }

+            if (p_Var10[(ulonglong)uVar5 + 0x1ff] != (_CLFS_LOG_BLOCK_HEADER)param_3) {

+              *param_5 = iVar8 - 1;

+              return -0x3fe5fffe;

+            }

+            if (((((((param_4 & 4) != 0) && (((byte)_Var1 & 4) == 0)) ||

+                  (((bVar6 & 0x40) != 0 && (((byte)_Var1 & 0x40) == 0)))) ||

+                 (((bVar6 & 0x20) != 0 && (((byte)_Var1 & 0x20) == 0)))) ||

+                (((param_4 & 8) != 0 && (((byte)_Var1 & 8) == 0)))) ||

+               (((param_4 & 0x10) != 0 && (((byte)_Var1 & 0x10) == 0)))) break;

+            uVar7 = (ulonglong)uVar9;

+            *(undefined2 *)(p_Var10 + (ulonglong)uVar5 + 0x1fe) =

+                 *(undefined2 *)(param_1 + (ulonglong)uVar9 * 2 + (ulonglong)uVar2);

+            if (uVar9 == 0) {

+              *(uint *)(p_Var10 + 0x10) = *(uint *)(p_Var10 + 0x10) & 0xfffffffe | 2;

+              *param_5 = 0;

+              return 0;

             }

           }

+          *param_5 = iVar8 - 1;

+          return -0x3fe5ffff;

         }

       }

     }

+    lVar4 = -0x3fe5fff6;

   }

-  iStack0000000000000054 = -0x3fffff66;

-LAB_1:

-  if (-1 < iStack0000000000000054) {

-    CClfsLogFcbCommon::AddHandleRef(unaff_R14);

-  }

-  if (in_stack_00000088 != unaff_R15) {

-    CClfsLogFcbPhysical::DestroyBaseFileName((_UNICODE_STRING *)&stack0x00000080);

-  }

-  if (-1 < iStack0000000000000054) {

-    (*(code *)**(undefined8 **)unaff_R14)();

-  }

-  p_Var7 = in_stack_00000078;

-  if (in_stack_00000078 != (_FILE_OBJECT *)0x0) {

-    if (in_stack_00000058 != cVar15) {

-      (**(code **)(*(longlong *)unaff_R14 + 8))();

-    }

-    ObfDereferenceObject(p_Var7);

-  }

-  if (iStack0000000000000054 < 0) {

-    if (iStack0000000000000054 == -0x3ffffd92) {

-      *(uint *)(unaff_R14 + 0x15c) = *(uint *)(unaff_R14 + 0x15c) | 0x1000;

-      if (*(int *)(unaff_R14 + 0x244) == iVar16) {

-        *(undefined4 *)(unaff_R14 + 0x244) = 1;

-        *(undefined4 *)(unaff_R14 + 0x248) = 0xc000026e;

-      }

-      if (((undefined8 **)WPP_GLOBAL_Control != &WPP_GLOBAL_Control) &&

-         ((*(uint *)((longlong)WPP_GLOBAL_Control + 0x2c) & 0x8000000) != 0)) {

-        WPP_SF_sdiD(WPP_GLOBAL_Control[3],0xe,&WPP_b14231366ae935f75801df6103bd3312_Traceguids,

-                    "CClfsLogFcbPhysical::Initialize");

-      }

-    }

-    if (in_stack_00000059 != cVar15) {

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

-        CClfsLogFcbPhysical::CloseContainers((CClfsLogFcbPhysical *)unaff_R14);

-      }

-      CClfsBaseFile::Release(*(CClfsBaseFile **)(unaff_R14 + 0x2a8));

-      *(_CLS_LSN **)(unaff_R14 + 0x2a8) = unaff_R15;

-    }

-    if (unaff_R14 + 0x38 == *(CClfsLogFcbCommon **)(in_stack_00000180 + 0x18)) {

-      CClfsLogFcbPhysical::TearDownOpen((CClfsLogFcbPhysical *)unaff_R14,in_stack_00000180);

-    }

-  }

-  else {

-    *(uint *)(unaff_R14 + 0x15c) = *(uint *)(unaff_R14 + 0x15c) & 0xfffffffe | 4;

-  }

-  if (unaff_R12 != (_CLS_LSN *)0x0) {

-    ExFreePoolWithTag(unaff_R12,0);

-  }

-  if (in_stack_00000068 != unaff_R15) {

-    CClfsBaseFile::ReleaseClientContext

-              (*(CClfsBaseFile **)(unaff_R14 + 0x2a8),(_CLFS_CLIENT_CONTEXT **)&stack0x00000068);

-  }

-  if (in_stack_00000178 != cVar15) {

-    ExReleaseResourceForThreadLite(unaff_R14 + 0xb8,SystemReserved1[0xf]);

-  }

-  return iStack0000000000000054;

+  return lVar4;

 }
```

## `CClfsBaseFile::OffsetToAddr`  (modified)

```diff
--- CClfsBaseFile::OffsetToAddr
+++ CClfsBaseFile::OffsetToAddr
@@ -1,2 +1,22 @@
-Failed to decompile clfs.sys - .ProgramDB CClfsBaseFile::OffsetToAddr : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* protected: void * __ptr64 __cdecl CClfsBaseFile::OffsetToAddr(unsigned long) __ptr64 */

+

+void * __thiscall CClfsBaseFile::OffsetToAddr(CClfsBaseFile *this,ulong param_1)

+

+{

+  _CLFS_BASE_RECORD_HEADER *p_Var1;

+  ulonglong uVar2;

+  

+  uVar2 = (ulonglong)param_1;

+  p_Var1 = GetBaseLogRecord(this);

+  if ((p_Var1 == (_CLFS_BASE_RECORD_HEADER *)0x0) ||

+     ((uint)*(ushort *)(*(longlong *)(*(longlong *)(this + 0x30) + 0x30) + 4) << 9 <=

+      (uint)(*(int *)(*(longlong *)(*(longlong *)(this + 0x30) + 0x30) + 0x28) + (int)uVar2))) {

+    p_Var1 = (_CLFS_BASE_RECORD_HEADER *)0x0;

+  }

+  else {

+    p_Var1 = p_Var1 + uVar2;

+  }

+  return p_Var1;

+}

+
```

## `CClfsDriver::SetIrpFunctions`  (modified)

```diff
--- CClfsDriver::SetIrpFunctions
+++ CClfsDriver::SetIrpFunctions
@@ -1,2 +1,45 @@
-Failed to decompile clfs.sys - .ProgramDB CClfsDriver::SetIrpFunctions : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* private: long __cdecl CClfsDriver::SetIrpFunctions(void) __ptr64 */

+

+long __thiscall CClfsDriver::SetIrpFunctions(CClfsDriver *this)

+

+{

+  long lVar1;

+  undefined4 *_Dst;

+  longlong lVar2;

+  

+  *(undefined8 *)(*(longlong *)(this + 8) + 0x68) = 0;

+  *(code **)(*(longlong *)(this + 8) + 0x70) = LogIoDispatch;

+  *(code **)(*(longlong *)(this + 8) + 0x80) = LogIoDispatch;

+  lVar2 = 0x110;

+  *(code **)(*(longlong *)(this + 8) + 0xe0) = LogIoDispatch;

+  do {

+    *(code **)(lVar2 + *(longlong *)(this + 8)) = LogIoDispatch;

+    lVar2 = lVar2 + 8;

+  } while (lVar2 < 0x120);

+  lVar2 = 0x88;

+  *(code **)(*(longlong *)(this + 8) + 0x98) = LogIoDispatch;

+  do {

+    *(code **)(lVar2 + *(longlong *)(this + 8)) = LogIoDispatch;

+    lVar2 = lVar2 + 8;

+  } while (lVar2 < 0x98);

+  *(code **)(*(longlong *)(this + 8) + 0xa0) = LogIoDispatch;

+  *(code **)(*(longlong *)(this + 8) + 0xf0) = LogIoDispatch;

+  *(code **)(*(longlong *)(this + 8) + 0x100) = LogIoDispatch;

+  *(code **)(*(longlong *)(this + 8) + 0xd8) = LogIoDispatch;

+  _Dst = (undefined4 *)ExAllocatePoolWithTag(0x200,0xe0,0x6f696c43);

+  if (_Dst == (undefined4 *)0x0) {

+    lVar1 = -0x3fffff66;

+  }

+  else {

+    memset(_Dst,0,0xe0);

+    *_Dst = 0xe0;

+    *(code **)(_Dst + 2) = ClfsFastIoRead;

+    *(code **)(_Dst + 4) = ClfsFastIoRead;

+    *(code **)(_Dst + 6) = ClfsFastIoRead;

+    *(undefined4 **)(*(longlong *)(this + 8) + 0x50) = _Dst;

+    lVar1 = 0;

+  }

+  return lVar1;

+}

+
```

## `CClfsBaseFile::GetSymbol`  (modified)

```diff
--- CClfsBaseFile::GetSymbol
+++ CClfsBaseFile::GetSymbol
@@ -1,2 +1,42 @@
-Failed to decompile clfs.sys - .ProgramDB CClfsBaseFile::GetSymbol : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* public: long __cdecl CClfsBaseFile::GetSymbol(long,unsigned long,struct _CLFS_CONTAINER_CONTEXT *

+   __ptr64 * __ptr64) __ptr64 */

+

+long __thiscall

+CClfsBaseFile::GetSymbol

+          (CClfsBaseFile *this,long param_1,ulong param_2,_CLFS_CONTAINER_CONTEXT **param_3)

+

+{

+  char cVar1;

+  _CLFS_BASE_RECORD_HEADER *p_Var2;

+  undefined4 in_register_00000014;

+  longlong lVar3;

+  long local_28;

+  

+  local_28 = 0;

+  *param_3 = (_CLFS_CONTAINER_CONTEXT *)0x0;

+  cVar1 = ExAcquireResourceSharedLite

+                    (*(undefined8 *)(this + 0x20),

+                     CONCAT71((int7)(CONCAT44(in_register_00000014,param_1) >> 8),1));

+  lVar3 = *(longlong *)(*(longlong *)(this + 0x30) + 0x30);

+  p_Var2 = GetBaseLogRecord(this);

+  if (((p_Var2 != (_CLFS_BASE_RECORD_HEADER *)0x0) &&

+      ((uint)(param_1 + *(int *)(lVar3 + 0x28)) < (uint)*(ushort *)(lVar3 + 4) << 9)) &&

+     (p_Var2 = p_Var2 + (uint)param_1, p_Var2 != (_CLFS_BASE_RECORD_HEADER *)0x0)) {

+    if (*(int *)(p_Var2 + -0xc) != param_1) {

+      local_28 = -0x3ffffff8;

+      goto LAB_0;

+    }

+    if (*(ulong *)(p_Var2 + 0x10) == param_2) {

+      *param_3 = (_CLFS_CONTAINER_CONTEXT *)p_Var2;

+      goto LAB_0;

+    }

+  }

+  local_28 = -0x3fe5fff3;

+LAB_0:

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

+    ExReleaseResourceForThreadLite(*(undefined8 *)(this + 0x20),SystemReserved1[0xf]);

+  }

+  return local_28;

+}

+
```

## `CClfsLogFcbPhysical::FlushLog`  (modified)

```diff
--- CClfsLogFcbPhysical::FlushLog
+++ CClfsLogFcbPhysical::FlushLog
@@ -1,2 +1,319 @@
-Failed to decompile clfs.sys - .ProgramDB CClfsLogFcbPhysical::FlushLog : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

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

+/* public: virtual long __cdecl CClfsLogFcbPhysical::FlushLog(union _CLS_LSN & __ptr64,struct

+   IClfsRequestAsync * __ptr64,unsigned long,unsigned long & __ptr64) __ptr64 */

+

+long __thiscall

+CClfsLogFcbPhysical::FlushLog

+          (CClfsLogFcbPhysical *this,_CLS_LSN *param_1,IClfsRequestAsync *param_2,ulong param_3,

+          ulong *param_4)

+

+{

+  _CLS_LSN *p_Var1;

+  CClfsLogFcbPhysical *pCVar2;

+  int iVar3;

+  longlong lVar4;

+  bool bVar5;

+  bool bVar6;

+  bool bVar7;

+  undefined1 uVar8;

+  uchar uVar9;

+  long lVar10;

+  undefined4 uVar11;

+  ulonglong uVar12;

+  undefined8 uVar13;

+  CClfsContainer *pCVar14;

+  uint uVar15;

+  undefined8 *puVar16;

+  bool bVar17;

+  char local_78;

+  int local_74;

+  uint local_68;

+  CClfsContainer *local_60;

+  ulong local_58 [2];

+  __uint64 local_50;

+  undefined4 local_48;

+  undefined4 local_44;

+  CClfsLogFcbPhysical *local_40;

+  undefined8 local_38;

+  longlong local_30;

+  

+  local_60 = (CClfsContainer *)0x0;

+  local_40 = (CClfsLogFcbPhysical *)0x0;

+  local_38 = 0;

+  local_74 = 0;

+  local_68 = 0;

+  bVar17 = false;

+  bVar7 = false;

+  bVar6 = false;

+  local_58[0] = 0xffffffff;

+  if ((param_3 & 0xfffffff8) != 0) {

+                    /* WARNING: Subroutine does not return */

+    KeBugCheckEx(0xc1f5,0x36,param_3,this,0);

+  }

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

+    if ((param_3 & 2) != 0) {

+                    /* WARNING: Subroutine does not return */

+      KeBugCheckEx(0xc1f5,0x37,param_3,this,0);

+    }

+    if (((param_3 & 1) != 0) && (param_2 != (IClfsRequestAsync *)0x0)) {

+      lVar10 = FUN_1c000e826();

+      return lVar10;

+    }

+  }

+  if (((param_3 & 4) != 0) && (param_2 != (IClfsRequestAsync *)0x0)) {

+    lVar10 = FUN_1c000e848();

+    return lVar10;

+  }

+  *param_4 = 0;

+  local_78 = ExAcquireResourceSharedLite(this + 0xb8,1);

+  pCVar2 = this + 0x1e8;

+  bVar5 = bVar17;

+  if (pCVar2 != (CClfsLogFcbPhysical *)0x0) {

+    bVar5 = *(longlong *)pCVar2 == 0;

+  }

+  if (bVar5) {

+    if (param_1 != (_CLS_LSN *)0x0) {

+      bVar17 = *(longlong *)param_1 == 0;

+    }

+    if (bVar17) {

+LAB_0:

+      bVar7 = false;

+      local_74 = 0;

+      goto LAB_1;

+    }

+    uVar11 = 0xc000000d;

+    local_74 = -0x3ffffff3;

+    if (*(int *)(this + 0x234) != 0) goto LAB_1;

+    *(undefined4 *)(this + 0x234) = 1;

+  }

+  else {

+    uVar12 = ClfsLsnGreater((uint *)param_1,(uint *)pCVar2);

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

+      while( true ) {

+        bVar7 = false;

+        if (local_74 < 0) break;

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

+          local_78 = ExAcquireResourceSharedLite(this + 0xb8,1);

+        }

+        uVar15 = param_3 & 4;

+        if ((uVar15 != 0) && (local_68 < 5)) {

+          if (local_68 == 4) {

+            LOCK();

+            *(undefined4 *)(this + 0x510) = 0;

+            UNLOCK();

+            bVar6 = true;

+          }

+          *(undefined8 *)param_1 = 0;

+        }

+        if ((param_1 == (_CLS_LSN *)0x0) || (*(longlong *)param_1 != 0)) {

+          pCVar2 = this + 0x1e8;

+          if ((pCVar2 == (CClfsLogFcbPhysical *)0x0) || (param_1 == (_CLS_LSN *)0x0)) {

+            bVar17 = false;

+          }

+          else {

+            bVar17 = *(longlong *)pCVar2 == *(longlong *)param_1;

+          }

+          if (bVar17) {

+            if ((pCVar2 == (CClfsLogFcbPhysical *)0x0) ||

+               (this + 0x1d0 == (CClfsLogFcbPhysical *)0x0)) {

+              bVar17 = false;

+            }

+            else {

+              bVar17 = *(longlong *)pCVar2 == *(longlong *)(this + 0x1d0);

+            }

+            if ((!bVar17) || (uVar15 != 0)) goto LAB_2;

+            goto LAB_0;

+          }

+        }

+        else {

+LAB_2:

+          *(undefined8 *)param_1 = *(undefined8 *)(this + 0x530);

+        }

+        pCVar2 = this + 0x1d0;

+        uVar12 = ClfsLsnLess((uint *)param_1,(uint *)pCVar2);

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

+          *(undefined8 *)param_1 = *(undefined8 *)pCVar2;

+          break;

+        }

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

+          if ((param_1 == (_CLS_LSN *)0x0) || (pCVar2 == (CClfsLogFcbPhysical *)0x0)) {

+            bVar17 = false;

+          }

+          else {

+            bVar17 = *(longlong *)param_1 == *(longlong *)pCVar2;

+          }

+          if (!bVar17) goto LAB_3;

+          uVar13 = *(undefined8 *)pCVar2;

+LAB_4:

+          *(undefined8 *)param_1 = uVar13;

+          local_74 = 0;

+          break;

+        }

+LAB_3:

+        if (((local_68 != 0) && ((*(uint *)(this + 0x15c) & 0x1000) != 0)) && (uVar15 == 0)) {

+          *(undefined8 *)param_1 = *(undefined8 *)pCVar2;

+          uVar11 = 0xc01a0028;

+          local_74 = -0x3fe5ffd8;

+          if (*(int *)(this + 0x234) == 0) {

+            *(undefined4 *)(this + 0x234) = 3;

+            goto LAB_5;

+          }

+          break;

+        }

+        local_68 = local_68 + 1;

+        if (199 < local_68) {

+                    /* WARNING: Subroutine does not return */

+          KeBugCheckEx(0xc1f5,0x3a,local_68,this,0);

+        }

+        uVar8 = KeAcquireSpinLockRaiseToDpc(*(undefined8 *)(this + 0x390));

+        LOCK();

+        *(int *)(this + 0x4ec) = *(int *)(this + 0x4ec) + 1;

+        UNLOCK();

+        (**(code **)(*(longlong *)this + 0x40))(this);

+        bVar7 = true;

+        LOCK();

+        iVar3 = *(int *)(this + 0x504);

+        *(int *)(this + 0x504) = 1;

+        UNLOCK();

+        bVar17 = false;

+        if (iVar3 == 0) {

+          bVar17 = true;

+          bVar5 = true;

+          KeClearEvent(*(undefined8 *)(this + 0x520));

+          *(ulong *)(this + 0x508) = param_3 & 2;

+          if ((param_2 == (IClfsRequestAsync *)0x0) && (!bVar6)) {

+            *(CClfsLogFcbPhysical ***)(this + 0x518) = &local_40;

+          }

+        }

+        else {

+          bVar5 = false;

+        }

+        KeReleaseSpinLock(*(undefined8 *)(this + 0x390),uVar8);

+        if (bVar17) {

+          for (puVar16 = (undefined8 *)**(undefined8 **)(this + 0x388);

+              puVar16 != *(undefined8 **)(this + 0x388); puVar16 = (undefined8 *)*puVar16) {

+            local_50 = 0;

+            lVar4 = puVar16[3];

+            p_Var1 = (_CLS_LSN *)(lVar4 + 0x28);

+            local_30 = lVar4;

+            if (((param_3 & 1) != 0) &&

+               (uVar12 = ClfsLsnLess((uint *)p_Var1,(uint *)param_1), (char)uVar12 == '\0')) break;

+            *(code **)(lVar4 + 0x78) = CClfsFlushElt::AsyncIoCompletion;

+            *(undefined4 *)(lVar4 + 0x24) = 0;

+            *(int *)(lVar4 + 0x20) = *(int *)(lVar4 + 0x20) + 1;

+            local_74 = GetContainerForLsn(this,&local_60,local_58,p_Var1);

+            if (local_74 < 0) {

+              if (*(int *)(this + 0x234) == 0) {

+                *(undefined4 *)(this + 0x234) = 5;

+                *(int *)(this + 0x238) = local_74;

+              }

+              goto LAB_1;

+            }

+            KeAcquireSpinLockRaiseToDpc(*(undefined8 *)(this + 0x390));

+            *(byte *)(lVar4 + 8) = *(byte *)(lVar4 + 8) | 2;

+            *(byte *)(lVar4 + 8) = *(byte *)(lVar4 + 8) & 0xef;

+            KeReleaseSpinLock(*(undefined8 *)(this + 0x390));

+            if (((param_3 & 1) == 0) && ((*(uint *)(this + 0x15c) & 0x1000) == 0)) {

+              LOCK();

+              *(int *)(this + 0x4ec) = *(int *)(this + 0x4ec) + 1;

+              UNLOCK();

+              (**(code **)(*(longlong *)this + 0x40))(this);

+              lVar4 = local_30;

+              (**(code **)**(undefined8 **)(local_30 + 0x80))();

+              pCVar14 = local_60;

+              uVar15 = 0xffffffff;

+              if (p_Var1 != (_CLS_LSN *)0x0) {

+                uVar15 = *(uint *)p_Var1 & 0xfffffe00;

+              }

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

+              lVar10 = CClfsContainer::WriteSector

+                                 (local_60,(_KEVENT *)0x0,(_CLFS_IO_WORKITEM *)(lVar4 + 0x60),

+                                  *(void **)(lVar4 + 0x10),*(ulong *)(lVar4 + 0x18),&local_50);

+              if (lVar10 != 0x103) {

+                    /* WARNING: Subroutine does not return */

+                KeBugCheckEx(0xc1f5,0x3c,(longlong)lVar10,this,0);

+              }

+            }

+            else {

+              *(byte *)(lVar4 + 8) = *(byte *)(lVar4 + 8) | 8;

+              *(undefined4 *)(lVar4 + 0x24) = 1;

+              pCVar14 = local_60;

+            }

+            (**(code **)(*(longlong *)pCVar14 + 8))(pCVar14);

+            local_60 = (CClfsContainer *)0x0;

+          }

+        }

+        else if ((param_3 & 1) != 0) {

+          local_74 = -0x3ffffe77;

+          if (*(int *)(this + 0x234) == 0) {

+            *(undefined4 *)(this + 0x234) = 4;

+            *(undefined4 *)(this + 0x238) = 0xc0000189;

+          }

+          break;

+        }

+        if (bVar6) break;

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

+          (*(code *)**(undefined8 **)param_2)(param_2);

+          (**(code **)(*(longlong *)param_2 + 0xb8))(param_2,param_1);

+          local_74 = (**(code **)(*(longlong *)(this + 0x250) + 0x198))(this + 0x250,param_2);

+          if (local_74 == -0x3ffffe77) {

+            (**(code **)(*(longlong *)param_2 + 8))(param_2);

+            uVar13 = *(undefined8 *)(this + 0x1d0);

+            goto LAB_4;

+          }

+          if (local_74 == 0) {

+            local_74 = 0x103;

+          }

+          else {

+            if (*(int *)(this + 0x234) == 0) {

+              *(undefined4 *)(this + 0x234) = 6;

+              *(int *)(this + 0x238) = local_74;

+            }

+            (**(code **)(*(longlong *)param_2 + 8))(param_2);

+          }

+          break;

+        }

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

+                    /* WARNING: Subroutine does not return */

+          KeBugCheckEx(0xc1f5,0x3d,this,0,0);

+        }

+        ExReleaseResourceForThreadLite(this + 0xb8,SystemReserved1[0xf]);

+        local_78 = '\0';

+        ReleaseFlushRef(this);

+        local_74 = KeWaitForSingleObject(*(undefined8 *)(this + 0x520),0,0,0,0);

+        if (bVar5) {

+          local_74 = (int)local_40;

+          *param_4 = (ulong)local_38;

+          if ((local_74 < 0) && ((param_3 & 4) != 0)) {

+            local_68 = 4;

+          }

+          uVar9 = IsRetryableFlushError(local_40,local_74);

+          if ((uVar9 != '\0') && (local_68 < 10)) {

+            local_48 = 0xfffe7960;

+            local_44 = 0xffffffff;

+            KeDelayExecutionThread(0,0);

+            local_74 = 0;

+          }

+        }

+      }

+      goto LAB_1;

+    }

+    uVar11 = 0xc000000d;

+    local_74 = -0x3ffffff3;

+    if (*(int *)(this + 0x234) != 0) goto LAB_1;

+    *(undefined4 *)(this + 0x234) = 2;

+  }

+LAB_5:

+  bVar7 = false;

+  *(undefined4 *)(this + 0x238) = uVar11;

+LAB_1:

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

+    ExReleaseResourceForThreadLite(this + 0xb8,SystemReserved1[0xf]);

+  }

+  if (bVar7) {

+    ReleaseFlushRef(this);

+  }

+  return local_74;

+}

+
```

## `CClfsBaseFile::FindSymbol`  (modified)

```diff
--- CClfsBaseFile::FindSymbol
+++ CClfsBaseFile::FindSymbol
@@ -1,2 +1,115 @@
-Failed to decompile clfs.sys - .ProgramDB CClfsBaseFile::FindSymbol : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

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

+/* protected: static long __cdecl CClfsBaseFile::FindSymbol(struct _UNICODE_STRING * __ptr64,struct

+   _CLFSHASHTBL * __ptr64,unsigned char,unsigned long,struct _CLFSHASHSYM * __ptr64 * __ptr64) */

+

+long __cdecl

+CClfsBaseFile::FindSymbol

+          (_UNICODE_STRING *param_1,_CLFSHASHTBL *param_2,uchar param_3,ulong param_4,

+          _CLFSHASHSYM **param_5)

+

+{

+  ushort uVar1;

+  CClfsBaseFile *pCVar2;

+  _CLFSHASHSYM *p_Var3;

+  ulong uVar4;

+  int iVar5;

+  _CLFS_BASE_RECORD_HEADER *p_Var6;

+  _CLFS_BASE_RECORD_HEADER *p_Var7;

+  int *piVar8;

+  _CLFSHASHSYM *p_Var9;

+  void *pvVar10;

+  longlong lVar11;

+  _CLFSHASHSYM *p_Var12;

+  short *psVar13;

+  uint uVar14;

+  uint uVar15;

+  _CLFSHASHSYM *local_res8;

+  

+  uVar1 = *(ushort *)param_1;

+  local_res8 = (_CLFSHASHSYM *)0x0;

+  if (param_5 == (_CLFSHASHSYM **)0x0) {

+    return -0x3ffffff3;

+  }

+  *param_5 = (_CLFSHASHSYM *)0x0;

+  uVar4 = ClfsHashPJW(param_1);

+  uVar15 = param_4 + 0x37 & 0xfffffff8;

+  p_Var9 = (_CLFSHASHSYM *)

+           (*(longlong *)param_2 + ((ulonglong)uVar4 % (ulonglong)*(uint *)(param_2 + 8)) * 8);

+  if (*(longlong *)p_Var9 != 0) {

+    pCVar2 = *(CClfsBaseFile **)(param_2 + 0x10);

+    do {

+      p_Var9 = OffsetToAddr(pCVar2,*(ulong *)p_Var9);

+      if (p_Var9 == (_CLFSHASHSYM *)0x0) {

+        return -0x3fe5fff3;

+      }

+      if ((uVar4 == *(ulong *)(p_Var9 + 8)) && (uVar15 == *(uint *)(p_Var9 + 0xc))) {

+        psVar13 = *(short **)(param_1 + 8);

+        pvVar10 = OffsetToAddr(pCVar2,*(ulong *)(p_Var9 + 0x20));

+        if (pvVar10 == (void *)0x0) {

+          return -0x3fe5fff3;

+        }

+        uVar15 = 0;

+        if (*(ushort *)param_1 >> 1 == 0) goto LAB_0;

+        lVar11 = (longlong)pvVar10 - (longlong)psVar13;

+        goto LAB_1;

+      }

+      p_Var9 = p_Var9 + (-(ulonglong)(uVar15 < *(uint *)(p_Var9 + 0xc)) & 0xfffffffffffffff8) + 0x18

+      ;

+    } while (*(longlong *)p_Var9 != 0);

+  }

+  uVar14 = 0xfffffff8;

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

+    iVar5 = -0x3ffffddb;

+  }

+  else {

+    pCVar2 = *(CClfsBaseFile **)(param_2 + 0x10);

+    p_Var6 = GetBaseLogRecord(pCVar2);

+    iVar5 = (**(code **)(*(longlong *)pCVar2 + 0x18))

+                      (pCVar2,(uVar1 + 9 & 0xfffffff8) + 0x30 + (param_4 + 7 & uVar14),&local_res8);

+    p_Var3 = local_res8;

+    if (-1 < iVar5) {

+      p_Var12 = local_res8 + ((ulonglong)(param_4 + 7) & 0xfffffff8);

+      *(uint *)(local_res8 + 0xc) = uVar15;

+      *(undefined8 *)(local_res8 + 0x18) = 0;

+      *(undefined8 *)(local_res8 + 0x10) = 0;

+      *(undefined4 *)local_res8 = 0xc1fdf006;

+      *(undefined4 *)(local_res8 + 4) = 0x30;

+      *(ulong *)(local_res8 + 8) = uVar4;

+      p_Var7 = GetBaseLogRecord(pCVar2);

+      *(int *)(p_Var3 + 0x24) = ((int)p_Var3 - (int)p_Var7) + 0x30;

+      p_Var7 = GetBaseLogRecord(pCVar2);

+      *(int *)(p_Var3 + 0x20) = ((int)p_Var12 + 0x30) - (int)p_Var7;

+      memcpy(p_Var12 + 0x30,*(void **)(param_1 + 8),(ulonglong)*(ushort *)param_1);

+      *(undefined2 *)(p_Var12 + (ulonglong)(*(ushort *)param_1 >> 1) * 2 + 0x30) = 0;

+      piVar8 = OffsetToAddr(pCVar2,(int)p_Var9 - (int)p_Var6);

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

+        p_Var6 = GetBaseLogRecord(pCVar2);

+        *piVar8 = (int)p_Var3 - (int)p_Var6;

+        *param_5 = p_Var3;

+        return 0;

+      }

+      return -0x3fe5fff3;

+    }

+  }

+  *param_5 = (_CLFSHASHSYM *)0x0;

+  return iVar5;

+  while( true ) {

+    uVar15 = uVar15 + 1;

+    psVar13 = psVar13 + 1;

+    if (*(ushort *)param_1 >> 1 <= uVar15) break;

+LAB_1:

+    if (*psVar13 != *(short *)(lVar11 + (longlong)psVar13)) break;

+  }

+LAB_0:

+  *param_5 = p_Var9;

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

+    return -(uint)(p_Var9[0x28] != (_CLFSHASHSYM)0x0) & 0xc0000225;

+  }

+  if (p_Var9[0x28] != (_CLFSHASHSYM)0x0) {

+    p_Var9[0x28] = (_CLFSHASHSYM)0x0;

+    return 0;

+  }

+  return -0x3fffff43;

+}

+
```

## `CClfsBaseFilePersisted::AcquireTruncateContext`  (modified)

```diff
--- CClfsBaseFilePersisted::AcquireTruncateContext
+++ CClfsBaseFilePersisted::AcquireTruncateContext
@@ -1,2 +1,54 @@
-Failed to decompile clfs.sys - .ProgramDB CClfsBaseFilePersisted::AcquireTruncateContext : Error: Decompile error: 
-Marshaling error: Did not see expected closing element+

+/* public: long __cdecl CClfsBaseFilePersisted::AcquireTruncateContext(unsigned long &

+   __ptr64,struct _CLFS_TRUNCATE_CONTEXT * __ptr64 & __ptr64,unsigned char * __ptr64 &

+   __ptr64,unsigned long & __ptr64) __ptr64 */

+

+long __thiscall

+CClfsBaseFilePersisted::AcquireTruncateContext

+          (CClfsBaseFilePersisted *this,ulong *param_1,_CLFS_TRUNCATE_CONTEXT **param_2,

+          uchar **param_3,ulong *param_4)

+

+{

+  longlong lVar1;

+  bool bVar2;

+  char cVar3;

+  uint uVar4;

+  int local_34;

+  _CLFS_CONTROL_RECORD *local_30;

+  

+  local_30 = (_CLFS_CONTROL_RECORD *)0x0;

+  bVar2 = false;

+  *param_2 = (_CLFS_TRUNCATE_CONTEXT *)0x0;

+  cVar3 = ExAcquireResourceExclusiveLite(*(undefined8 *)(this + 0x20),1,param_2,param_3,0);

+  local_34 = CClfsBaseFile::GetControlRecord((CClfsBaseFile *)this,&local_30);

+  if ((-1 < local_34) &&

+     (local_34 = CClfsBaseFile::AcquireMetadataBlock((CClfsBaseFile *)this,4), -1 < local_34)) {

+    bVar2 = true;

+    lVar1 = *(longlong *)(*(longlong *)(this + 0x30) + 0x60);

+    uVar4 = *(int *)(lVar1 + 0x68) - *(int *)(lVar1 + 0x28);

+    *param_4 = uVar4;

+    if (uVar4 < *param_1) {

+      local_34 = -0x3fffffdd;

+    }

+    else {

+      *param_3 = (uchar *)((ulonglong)*(uint *)(lVar1 + 0x28) +

+                          *(longlong *)(*(longlong *)(this + 0x30) + 0x60));

+      *param_2 = (_CLFS_TRUNCATE_CONTEXT *)(local_30 + 0x28);

+      *(_CLFS_CONTROL_RECORD **)(this + 0x1b0) = local_30;

+      local_34 = 0;

+    }

+  }

+  if (local_34 < 0) {

+    if (bVar2) {

+      CClfsBaseFile::ReleaseMetadataBlock((CClfsBaseFile *)this,4);

+    }

+    if (local_30 != (_CLFS_CONTROL_RECORD *)0x0) {

+      CClfsBaseFile::ReleaseMetadataBlock((CClfsBaseFile *)this,0);

+    }

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

+      ExReleaseResourceForThreadLite(*(undefined8 *)(this + 0x20),SystemReserved1[0xf]);

+    }

+  }

+  return local_34;

+}

+
```

## ``CClfsBaseFilePersisted::AcquireTruncateContext'::__l1::fin$0`  (modified)

```diff
--- `CClfsBaseFilePersisted::AcquireTruncateContext'::__l1::fin$0
+++ `CClfsBaseFilePersisted::AcquireTruncateContext'::__l1::fin$0
@@ -1,10 +1,21 @@
 

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

-

-void `CClfsBaseFilePersisted::AddClient'::fin_0(undefined8 param_1,longlong param_2)

+void `CClfsBaseFilePersisted::AcquireTruncateContext'::__l1::fin_0(char param_1,longlong param_2)

 

 {

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

-  halt_baddata();

+  if ((*(int *)(param_2 + 0x24) < 0) || (param_1 != '\0')) {

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

+      CClfsBaseFile::ReleaseMetadataBlock(*(CClfsBaseFile **)(param_2 + 0x60),4);

+      *(undefined1 *)(param_2 + 0x20) = 0;

+    }

+    if (*(longlong *)(param_2 + 0x28) != 0) {

+      CClfsBaseFile::ReleaseMetadataBlock(*(CClfsBaseFile **)(param_2 + 0x60),0);

+    }

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

+      ExReleaseResourceForThreadLite

+                (*(undefined8 *)(*(longlong *)(param_2 + 0x60) + 0x20),SystemReserved1[0xf]);

+      *(undefined1 *)(param_2 + 0x21) = 0;

+    }

+  }

+  return;

 }
```

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

```diff
--- NTOSKRNL.EXE::ExAllocatePoolWithTag calling
+++ NTOSKRNL.EXE::ExAllocatePoolWithTag calling
@@ -18,0 +19 @@
+CClfsDriver::SetIrpFunctions
```
