Skip to content

Commit

Permalink
Better tracing for NpcapHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
bonsaiviking committed Feb 22, 2018
1 parent ade0ea3 commit 3c78f31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packetWin7/Dll/Packet32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,13 +678,15 @@ BOOL NpcapIsAdminOnlyMode()
}
else
{
TRACE_PRINT1("RegQueryValueExA(AdminOnly) failed or not REG_DWORD: %#x\n", GetLastError());
dwAdminOnlyMode = 0;
}

RegCloseKey(hKey);
}
else
{
TRACE_PRINT1("RegOpenKeyExA(Software\\Npcap) failed: %#x\n", GetLastError());
dwAdminOnlyMode = 0;
}

Expand Down Expand Up @@ -758,12 +760,14 @@ void NpcapStartHelper()
// Check if Npcap is installed in "Admin-Only Mode".
if (!NpcapIsAdminOnlyMode())
{
TRACE_PRINT("Not admin-only mode\n");
g_bIsRunByAdmin = TRUE;
}
else
{
// Check if this process is running in Administrator mode.
g_bIsRunByAdmin = NpcapIsRunByAdmin();
TRACE_PRINT1("Admin-only mode. Already admin? %d\n", g_bIsRunByAdmin);
}

if (!g_bIsRunByAdmin)
Expand All @@ -777,12 +781,14 @@ void NpcapStartHelper()
if (g_hNpcapHelperPipe == INVALID_HANDLE_VALUE)
{
// NpcapHelper failed, let g_IsAdminMode be TRUE to avoid next requestHandleFromNpcapHelper() calls.
TRACE_PRINT("NpcapHelper returned invalid handle.\n");
g_bIsRunByAdmin = TRUE;
}
}
else
{
// NpcapHelper failed, let g_IsAdminMode be TRUE to avoid next requestHandleFromNpcapHelper() calls.
TRACE_PRINT("NpcapCreatePipe failed.\n");
g_bIsRunByAdmin = TRUE;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packetWin7/Helper/NpcapHelper/NpcapHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ DWORD WINAPI InstanceThread(LPVOID lpvParam)
DWORD cbBytesRead = 0, cbReplyBytes = 0, cbWritten = 0;
BOOL fSuccess = FALSE;
HANDLE hPipe = NULL;
TRACE_ENTER();
TRACE_ENTER("InstanceThread");

// Do some extra error checking since the app will keep running even if this
// thread fails.
Expand Down Expand Up @@ -317,7 +317,7 @@ DWORD WINAPI InstanceThread(LPVOID lpvParam)
HeapFree(hHeap, 0, pchRequest);
HeapFree(hHeap, 0, pchReply);

TRACE_EXIT();
TRACE_EXIT("InstanceThread");
terminateSelf();
return 1;
}
Expand Down

0 comments on commit 3c78f31

Please sign in to comment.