void __fastcall ProtectSystemThread(PVOID StartContext)
{
unsigned int v2; // edi
char v3; // r12
int v4; // r13d
char v5; // bp
unsigned int CurrentIrql; // ebx
HANDLE CurrentThreadId; // rax
unsigned int v8; // eax
int v9; // ebx
unsigned int v10; // eax
int v11; // ebx
unsigned int v12; // eax
unsigned int v13; // eax
int v14; // ebx
unsigned int v15; // eax
unsigned int v16; // ebx
unsigned int v17; // eax
int v18; // ebx
unsigned int v19; // eax
unsigned int v20; // eax
struct _IO_STATUS_BLOCK IoStatusBlock; // [rsp+50h] [rbp-48h] BYREF
unsigned int v22; // [rsp+A8h] [rbp+10h] BYREF
HANDLE KeyHandle; // [rsp+B0h] [rbp+18h] BYREF
union _LARGE_INTEGER Timeout; // [rsp+B8h] [rbp+20h] BYREF
v2 = 0;
v3 = 1;
v4 = 0;
KeyHandle = 0i64;
v5 = 0;
Timeout.QuadPart = -3000000000i64;
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [----] [%08x]\n", StartContext);
while ( 1 )
{
if ( KeGetCurrentIrql() && byte_1A390 )
{
CurrentIrql = KeGetCurrentIrql();
CurrentThreadId = PsGetCurrentThreadId();
DbgPrint("[THlpDrv] [THWorkerStart] [IRQL] [!!!!] [t: %08x, i: %08x]\n", CurrentThreadId, CurrentIrql);
}
if ( !KeyHandle )
{
v8 = OpenKey(&KeyHandle, 0x2001Fu, L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\.winhlpsvr");
v9 = v8;
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [Key] [k: %08x, s: %08x]\n", KeyHandle, v8);
if ( v9 < 0 || !KeyHandle )
{
v2 = 1;
goto LABEL_57;
}
}
if ( v4 != dword_1A218 )
{
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [Change] [####]\n");
v4 = dword_1A218;
v3 = 1;
}
if ( dword_1A218 == 1 )
{
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [--START--]\n");
if ( v3 )
{
v3 = 0;
v22 = 0;
v10 = QueryValueKey(KeyHandle, (__int64)L"Start", &v22);
v11 = v10;
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [--START--] [Enforce] [Query] [d: %08x] [s: %08x]\n", v22, v10);
if ( v11 >= 0 && v22 != 2 )
{
v12 = SetValueKey(KeyHandle, L"Start", 2);
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [--START--] [Enforce] [Set] [####] [d: %08x] [s: %08x]\n", 2i64, v12);
}
}
if ( !v5 )
{
v13 = ZwNotifyChangeKey(KeyHandle, Handle, 0i64, 0i64, &IoStatusBlock, 5u, 1u, 0i64, 0, 1u);
v14 = v13;
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [--START--] [Notify] [Register] [s: %08x]\n", v13);
if ( v14 < 0 )
goto LABEL_56;
v5 = 1;
}
v15 = ZwWaitForSingleObject(Handle, 0, &Timeout);
v16 = v15;
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [--START--] [Notify] [Wait] [s: %08x]\n", v15);
if ( v16 == 258 )
{
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [--START--] [Notify] [TIMEOUT] [s: %08x]\n", 258i64);
}
else
{
if ( v16 )
{
v2 = 3;
goto LABEL_57;
}
v5 = 0;
v22 = 0;
v17 = QueryValueKey(KeyHandle, (__int64)L"Start", &v22);
v18 = v17;
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [--START--] [Notify] [SUCCESS] [Query] [d: %08x] [s: %08x]\n", v22, v17);
if ( v18 == -1073741444 )
{
ZwClose(KeyHandle);
KeyHandle = 0i64;
sub_12BB4();
}
else if ( v18 >= 0 && v22 != 2 )
{
v19 = SetValueKey(KeyHandle, L"Start", 2);
if ( byte_1A390 )
DbgPrint(
"[THlpDrv] [THWorkerStart] [--START--] [Notify] [SUCCESS] [Set] [####] [d: %08x] [s: %08x]\n",
2i64,
v19);
}
}
goto LABEL_50;
}
if ( dword_1A218 == 2 )
{
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [##PAUSE##]\n");
v20 = ZwWaitForSingleObject(Handle, 0, &Timeout);
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [##PAUSE##] [Wait] [s: %08x]\n", v20);
goto LABEL_50;
}
if ( dword_1A218 == 3 )
break;
LABEL_50:
if ( !byte_1A392 )
goto LABEL_57;
}
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [!!STOP!!]\n");
LABEL_56:
v2 = 2;
LABEL_57:
if ( KeyHandle )
{
ZwClose(KeyHandle);
KeyHandle = 0i64;
}
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [====] [%08x] [e: %08x]\n", StartContext, v2);
PsTerminateSystemThread(0);
if ( byte_1A390 )
DbgPrint("[THlpDrv] [THWorkerStart] [====] 2 [%08x]\n", StartContext);
} |