Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

Added CreateToolhelp32Snapshot, Process32First, Process32Next, Module32F... #30

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cuckoomon.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ static hook_t g_hooks[] = {

HOOK(msvcrt, system),

HOOK(kernel32, CreateToolhelp32Snapshot),
HOOK(kernel32, Process32First),
HOOK(kernel32, Process32Next),
HOOK(kernel32, Module32First),
HOOK(kernel32, Module32Next),

//
// Thread Hooks
//
Expand Down
55 changes: 55 additions & 0 deletions hook_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,58 @@ HOOKDEF(int, CDECL, system,
LOQ("s", "Command", command);
return ret;
}

HOOKDEF(HANDLE, WINAPI, CreateToolhelp32Snapshot,
__in DWORD dwFlags,
__in DWORD th32ProcessID
) {
IS_SUCCESS_HANDLE();

HANDLE ret = Old_CreateToolhelp32Snapshot(dwFlags, th32ProcessID);
LOQ("ll", "Flags", dwFlags, "ProcessId", th32ProcessID);
return ret;
}

HOOKDEF(BOOL, WINAPI, Process32First,
__in HANDLE hSnapshot,
__inout LPVOID lppe
) {
IS_SUCCESS_BOOL();

BOOL ret = Old_Process32First(hSnapshot, lppe);
LOQ("pp", "SnapshotHandle", hSnapshot, "ProcessEntry", lppe);
return ret;
}

HOOKDEF(BOOL, WINAPI, Process32Next,
__in HANDLE hSnapshot,
__inout LPVOID lppe
) {
IS_SUCCESS_BOOL();

BOOL ret = Old_Process32Next(hSnapshot, lppe);
LOQ("pp", "SnapshotHandle", hSnapshot, "ProcessEntry", lppe);
return ret;
}

HOOKDEF(BOOL, WINAPI, Module32First,
__in HANDLE hSnapshot,
__inout LPVOID lpme
) {
IS_SUCCESS_BOOL();

BOOL ret = Old_Module32First(hSnapshot, lpme);
LOQ("pp", "SnapshotHandle", hSnapshot, "ModuleEntry", lpme);
return ret;
}

HOOKDEF(BOOL, WINAPI, Module32Next,
__in HANDLE hSnapshot,
__inout LPVOID lpme
) {
IS_SUCCESS_BOOL();

BOOL ret = Old_Module32Next(hSnapshot, lpme);
LOQ("pp", "SnapshotHandle", hSnapshot, "ModuleEntry", lpme);
return ret;
}
25 changes: 25 additions & 0 deletions hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,31 @@ extern HOOKDEF(int, CDECL, system,
const char *command
);

extern HOOKDEF(HANDLE, WINAPI, CreateToolhelp32Snapshot,
__in DWORD dwFlags,
__in DWORD th32ProcessID
);

extern HOOKDEF(BOOL, WINAPI, Process32First,
__in HANDLE hSnapshot,
__inout LPVOID lppe
);

extern HOOKDEF(BOOL, WINAPI, Process32Next,
__in HANDLE hSnapshot,
__inout LPVOID lppe
);

extern HOOKDEF(BOOL, WINAPI, Module32First,
__in HANDLE hSnapshot,
__inout LPVOID lpme
);

extern HOOKDEF(BOOL, WINAPI, Module32Next,
__in HANDLE hSnapshot,
__inout LPVOID lpme
);

//
// Thread Hooks
//
Expand Down