From 4c31b16a17e3ce0efbdfea6723c70a9082e925e8 Mon Sep 17 00:00:00 2001 From: Kevin O'Reilly Date: Fri, 2 Dec 2022 11:42:32 +0000 Subject: [PATCH] Add hook for GetCommandLineA --- hook_misc.c | 8 ++++++++ hooks.c | 1 + hooks.h | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/hook_misc.c b/hook_misc.c index 2abaef9a..46d22ea1 100644 --- a/hook_misc.c +++ b/hook_misc.c @@ -1758,6 +1758,14 @@ HOOKDEF(int, WINAPI, WideCharToMultiByte, return Old_WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar); } +HOOKDEF(LPSTR, WINAPI, GetCommandLineA, + void +) { + LPSTR ret = Old_GetCommandLineA(); + LOQ_nonnull("misc", "s", "CommandLine", ret); + return ret; +} + HOOKDEF(LPWSTR, WINAPI, GetCommandLineW, void ) { diff --git a/hooks.c b/hooks.c index fa62536c..e82704f8 100644 --- a/hooks.c +++ b/hooks.c @@ -318,6 +318,7 @@ hook_t full_hooks[] = { #endif HOOK(msvcrt, memcpy), //HOOK(ntdll, RtlMoveMemory), + HOOK(kernel32, GetCommandLineA), HOOK(kernel32, GetCommandLineW), HOOK(kernel32, OutputDebugStringA), HOOK(kernel32, OutputDebugStringW), diff --git a/hooks.h b/hooks.h index 6b1583e8..28317956 100644 --- a/hooks.h +++ b/hooks.h @@ -3393,6 +3393,10 @@ HOOKDEF(int, WINAPI, WideCharToMultiByte, __out_opt LPBOOL lpUsedDefaultChar ); +HOOKDEF(LPSTR, WINAPI, GetCommandLineA, + void +); + HOOKDEF(LPWSTR, WINAPI, GetCommandLineW, void );