Skip to content

Commit

Permalink
cleanup debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
jxy-s committed Sep 19, 2024
1 parent 72858c2 commit 9931511
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 158 deletions.
22 changes: 11 additions & 11 deletions vfdynf/delayld.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ BOOLEAN NTAPI AVrfpDelayLoad(
status = LdrLoadDll(NULL, NULL, &dllEntry->DllName, &baseAddress);
if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to delay load %wZ (0x%08x)\n",
&dllEntry->DllName,
status);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"failed to delay load %wZ (0x%08x)",
&dllEntry->DllName,
status);

goto Exit;
}

Expand All @@ -110,12 +110,12 @@ BOOLEAN NTAPI AVrfpDelayLoad(
entry->Store);
if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to delay load %wZ!%wZ (0x%08x)\n",
&dllEntry->DllName,
&entry->ProcedureName,
status);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"failed to delay load %wZ!%hZ (0x%08x)",
&dllEntry->DllName,
&entry->ProcedureName,
status);

__debugbreak();
goto Exit;
}
Expand Down
57 changes: 25 additions & 32 deletions vfdynf/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,8 @@ VOID AVrfpRefreshLoadedModuleList(
module = RtlAllocateHeap(RtlProcessHeap(), 0, size);
if (!module)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to allocate module entry\n");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "failed to allocate module entry");

__debugbreak();
continue;
}
Expand Down Expand Up @@ -852,9 +851,9 @@ BOOLEAN AVrfpProviderProcessVerifier(
desc = (PRTL_VERIFIER_PROVIDER_DESCRIPTOR*)Reserved;
if (!desc)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: expected descriptor output parameter is null");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL,
"expected descriptor output parameter is null");

return FALSE;
}

Expand All @@ -863,10 +862,10 @@ BOOLEAN AVrfpProviderProcessVerifier(
status = VerifierRegisterProvider(Module, &AVrfpProviderDescriptor);
if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: provider registration failed (0x%08x)",
status);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"provider registration failed (0x%08x)",
status);

return FALSE;
}

Expand All @@ -885,10 +884,10 @@ BOOLEAN AVrfpProviderProcessAttach(
0);
if (err != ERROR_SUCCESS)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: layer registration failed (%lu)",
err);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"layer registration failed (%lu)",
err);

return FALSE;
}

Expand All @@ -906,54 +905,48 @@ BOOLEAN AVrfpProviderProcessAttach(

if (!AVrfLinkHooks())
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to link hooks");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "failed to link hooks");

__debugbreak();
return FALSE;
}

if (!AVrfSymProcessAttach())
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to setup symbol provider");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "failed to setup symbol provider");

__debugbreak();
return FALSE;
}

if (!AVrfStopProcessAttach())
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to setup stop handling");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "failed to setup stop handling");

__debugbreak();
return FALSE;
}

if (!AVrfFuzzProcessAttach())
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to setup fuzzing");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "failed to setup fuzzing");

__debugbreak();
return FALSE;
}

if (!AVrfExceptProcessAttach())
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to set exception handler");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "failed to set exception handler");

__debugbreak();
return FALSE;
}

if (!AVrfFaultProcessAttach())
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to setup fault injection");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "failed to setup fault injection");

__debugbreak();
return FALSE;
}
Expand Down
5 changes: 2 additions & 3 deletions vfdynf/except.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ VOID AVrfGuardToConvertToInPageError(
}
else
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: out of guard page slots!");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "out of guard page slots");

__debugbreak();
}

Expand Down
81 changes: 29 additions & 52 deletions vfdynf/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ BOOLEAN AVrfpInitExclusionsRegexInternal(
count * sizeof(PCRE2_HANDLE));
if (!Exclusion->Regex)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to allocate exclusion regex!\n");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "failed to allocate exclusion regex");

__debugbreak();
return FALSE;
}
Expand All @@ -137,10 +136,10 @@ BOOLEAN AVrfpInitExclusionsRegexInternal(
status = Pcre2Compile(&regex, &pattern);
if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed processing regex! (0x%08x)\n",
status);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"regex failed to compile (0x%08x)",
status);

__debugbreak();
return FALSE;
}
Expand Down Expand Up @@ -198,10 +197,10 @@ BOOLEAN AVrfpInitIncludeRegex(
status = Pcre2Compile(&AVrfpFaultContext.IncludeRegex, &pattern);
if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed processing regex! (0x%08x)\n",
status);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"regex failed to compile (0x%08x)",
status);

__debugbreak();
return FALSE;
}
Expand All @@ -219,10 +218,10 @@ BOOLEAN AVrfpInitIncludeRegex(
status = Pcre2Compile(&AVrfpFaultContext.TypeIncludeRegex[i], &pattern);
if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed processing regex! (0x%08x)\n",
status);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"regex failed to compile (0x%08x)",
status);

__debugbreak();
return FALSE;
}
Expand Down Expand Up @@ -340,19 +339,11 @@ BOOLEAN AVrfIsCallerIncluded(

if (!AVrfpFaultContext.Initialized)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_WARNING_LEVEL,
"AVRF: fault injection not yet initialized\n");

return FALSE;
}

if (!CallerAddress)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_WARNING_LEVEL,
"AVRF: caller address is null\n");

return FALSE;
}

Expand Down Expand Up @@ -486,9 +477,7 @@ VOID AVrfpCacheFaultInjectResult(
StackHash);
if (!stackEntry)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to insert new stack entry!\n");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "failed to insert new stack entry");

goto Exit;
}
Expand Down Expand Up @@ -526,19 +515,11 @@ BOOLEAN AVrfShouldFaultInject(

if (!AVrfpFaultContext.Initialized)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_WARNING_LEVEL,
"AVRF: fault injection not yet initialized\n");

goto Exit;
}

if (!CallerAddress)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_WARNING_LEVEL,
"AVRF: caller address is null\n");

goto Exit;
}

Expand Down Expand Up @@ -609,10 +590,9 @@ BOOLEAN AVrfShouldFaultInject(
&AVrfpFaultContext.SymTimeout);
if (status != STATUS_SUCCESS)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: AVrfSymGetSymbol failed (0x%08x)\n",
status);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"AVrfSymGetSymbol failed (0x%08x)",
status);

goto Exit;
}
Expand Down Expand Up @@ -677,9 +657,9 @@ BOOLEAN AVrfFaultProcessAttach(

if (!AVrfpInitRegex())
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to initialized exclusions regex!\n");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL,
"failed to initialize exclusions regex");

__debugbreak();
return FALSE;
}
Expand All @@ -688,10 +668,10 @@ BOOLEAN AVrfFaultProcessAttach(
&AVrfpFaultContext.TypeBase);
if (err != ERROR_SUCCESS)
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to register fault injection provider (%lu)\n",
err);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"failed to register fault injection provider (%lu)",
err);

return FALSE;
}

Expand Down Expand Up @@ -757,10 +737,9 @@ BOOLEAN AVrfFaultProcessAttach(
seed = HandleToULong(NtCurrentThreadId()) ^ NtGetTickCount();
rand = RtlRandomEx(&seed);

DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_INFO_LEVEL,
"AVRF: generated and using random fault injection seed %lu\n",
rand);
AVrfDbgPrint(DPFLTR_INFO_LEVEL,
"generated and using random fault injection seed %lu",
rand);

VerifierSetFaultInjectionSeed(rand);
}
Expand All @@ -771,9 +750,7 @@ BOOLEAN AVrfFaultProcessAttach(

AVrfInitializeCriticalSection(&AVrfpFaultContext.CriticalSection);

DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_INFO_LEVEL,
"AVRF: dynamic fault injection initialized\n");
AVrfDbgPuts(DPFLTR_INFO_LEVEL, "dynamic fault injection initialized");

AVrfpFaultContext.Initialized = TRUE;
return TRUE;
Expand Down
12 changes: 5 additions & 7 deletions vfdynf/fuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ BOOLEAN NTAPI AVrfpFuzzRunOnceRoutine(

if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed to initialize fuzz vector (0x%08x)\n",
status);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"failed to initialize fuzz vector (0x%08x)",
status);

__debugbreak();
return FALSE;
}
Expand Down Expand Up @@ -607,9 +607,7 @@ PVOID AVrfFuzzMemoryMapping(
}
else
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: out of fuzzing mmap slots!");
AVrfDbgPuts(DPFLTR_ERROR_LEVEL, "out of fuzzing mmap slots");
__debugbreak();

RtlFreeHeap(RtlProcessHeap(), 0, baseAddress);
Expand Down
8 changes: 4 additions & 4 deletions vfdynf/stop.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ BOOLEAN AVrfStopProcessAttach(
status = Pcre2Compile(&AVrfpStopRegex, &pattern);
if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_VERIFIER_ID,
DPFLTR_ERROR_LEVEL,
"AVRF: failed processing regex! (0x%08x)\n",
status);
AVrfDbgPrint(DPFLTR_ERROR_LEVEL,
"regex failed to compile (0x%08x)",
status);

__debugbreak();
return FALSE;
}
Expand Down
Loading

0 comments on commit 9931511

Please sign in to comment.