diff --git a/ValvePlug.rc b/ValvePlug.rc index 8aa968a..f90a1cd 100644 Binary files a/ValvePlug.rc and b/ValvePlug.rc differ diff --git a/dllmain.cpp b/dllmain.cpp index cb11c96..d3435d1 100644 --- a/dllmain.cpp +++ b/dllmain.cpp @@ -3,6 +3,7 @@ #include "pch.h" #include "config.h" #include +#include #pragma comment (lib, "shlwapi.lib") @@ -15,6 +16,48 @@ config_s config; volatile LONG __VP_DLL_Refs = 0UL; +using GetCommandLineW_pfn = LPWSTR (WINAPI *)(void); +using GetCommandLineA_pfn = LPSTR (WINAPI *)(void); + +GetCommandLineW_pfn GetCommandLineW_Original = nullptr; +GetCommandLineA_pfn GetCommandLineA_Original = nullptr; + +LPWSTR +WINAPI +GetCommandLineW_Detour (void) +{ + static std::wstring cmd_line; + + if (cmd_line.empty ()) + { + cmd_line = + GetCommandLineW_Original (); + + cmd_line += L" -nojoy"; + } + + return (wchar_t *)cmd_line.c_str (); +} + +LPSTR +WINAPI +GetCommandLineA_Detour (void) +{ + static std::string cmd_line; + + if (cmd_line.empty ()) + { + cmd_line = + GetCommandLineA_Original (); + + cmd_line += " -nojoy"; + } + + return (char *)cmd_line.c_str (); +} + +using GetCommandLineA_pfn = LPSTR (WINAPI *)(void); + static CreateFileA_pfn CreateFileA_Original = nullptr; static CreateFileW_pfn CreateFileW_Original = nullptr; static CreateFile2_pfn CreateFile2_Original = nullptr; @@ -609,6 +652,16 @@ ValvePlug_InitThread (LPVOID) XInputGetCapabilities9_1_0_Detour, (void **)(&XInputGetCapabilities9_1_0_Original), nullptr ); + SK_CreateDLLHook2 ( L"kernel32.dll", + "GetCommandLineW", + GetCommandLineW_Detour, + (void **)(&GetCommandLineW_Original), nullptr ); + + SK_CreateDLLHook2 ( L"kernel32.dll", + "GetCommandLineA", + GetCommandLineA_Detour, + (void **)(&GetCommandLineA_Original), nullptr ); + MH_ApplyQueued (); }