-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver_moduleLogger.c
46 lines (35 loc) · 970 Bytes
/
driver_moduleLogger.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
void ModuleLogger( DWORD processID )
{
HMODULE hMods[1024];
HANDLE hProcess;
DWORD cbNeeded;
unsigned int i;
unsigned int numModule=0;
// Print the process identifier.
//printf("\nProcess ID: %u\n", processID);
// Get a handle to the process.
hProcess = OpenProcess(PROCESS_ALL_ACCESS,
FALSE, processID);
if (NULL == hProcess)
return;
// Get a list of all the modules in this process.
if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
{
for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
{
TCHAR szModName[MAX_PATH];
// Get the full path to the module's file.
if (GetModuleFileNameEx(hProcess, hMods[i], szModName,
sizeof(szModName) / sizeof(TCHAR)))
{
// Print the module name and handle value.
numModule += 1;
//_tprintf(TEXT("\t%s (0x%08X)\n"), szModName, hMods[i]);
}
}
//_tprintf(TEXT("%d "), numModule);
}
// Release the handle to the process.
CloseHandle(hProcess);
return;
}