diff --git a/Master/Nucleus.Hook/GetCursorInfoHook.cpp b/Master/Nucleus.Hook/GetCursorInfoHook.cpp new file mode 100644 index 00000000..9d8f4719 --- /dev/null +++ b/Master/Nucleus.Hook/GetCursorInfoHook.cpp @@ -0,0 +1,24 @@ +#include "pch.h" +#include "InstallHooks.h" +#include "Logging.h" + +BOOL WINAPI GetCursorInfo_Hook(PCURSORINFO pci) +{ + bool result = GetCursorInfo(pci); + if (result == true) + { + POINT nypt; + GetCursorPos(&nypt); + pci->ptScreenPos.x = nypt.x; + pci->ptScreenPos.y = nypt.y; + return true; + } + else return false; +} + +void installGetCursorInfoHook() +{ + + DEBUGLOG("Injecting GetCursorInfo hook\n"); + installHook("user32", "GetCursorInfo", GetCursorInfo_Hook); +} \ No newline at end of file diff --git a/Master/Nucleus.Hook/Hook.cpp b/Master/Nucleus.Hook/Hook.cpp index 705ac4a6..17233bd3 100644 --- a/Master/Nucleus.Hook/Hook.cpp +++ b/Master/Nucleus.Hook/Hook.cpp @@ -160,6 +160,8 @@ void __stdcall NativeInjectionEntryPoint(REMOTE_ENTRY_INFO* inRemoteInfo) Globals::options.reRegisterRawInputKeyboard = NEXTBOOL; Globals::options.HookXInput = NEXTBOOL; Globals::options.DinputToXinputTranslation = NEXTBOOL; + Globals::options.GetCursorInfoHook = NEXTBOOL; + //Globals::options.NewmadeHook = NEXTBOOL; #undef NEXTBOOL const auto pathLength = static_cast(bytesToInt(p)); p += 4; @@ -216,6 +218,8 @@ void __stdcall NativeInjectionEntryPoint(REMOTE_ENTRY_INFO* inRemoteInfo) " reRegisterRawInputKeyboard: " << Globals::options.reRegisterRawInputKeyboard << " hookXinput: " << Globals::options.HookXInput << " DinputToXinputTranslation: " << Globals::options.DinputToXinputTranslation << + " GetCursorInfo: " << Globals::options.GetCursorInfoHook << + //" Winmm: " << Globals::options.NewmadeHook << " controllerIndex: " << Controller::controllerIndex << " windowWidth: " << windowWidth << " windowHeight: " << windowHeight << @@ -261,6 +265,15 @@ void __stdcall NativeInjectionEntryPoint(REMOTE_ENTRY_INFO* inRemoteInfo) { installMessageFilterHooks(); } + //new + if (Globals::options.GetCursorInfoHook) + { + installGetCursorInfoHook(); + } + //if (Globals::options.WinmmHook) + //{ + // installNewmadeHook(); + //} #pragma endregion DEBUGLOG("Hook injection complete\n"); diff --git a/Master/Nucleus.Hook/InstallHooks.h b/Master/Nucleus.Hook/InstallHooks.h index 89bcfaa7..883ae5ee 100644 --- a/Master/Nucleus.Hook/InstallHooks.h +++ b/Master/Nucleus.Hook/InstallHooks.h @@ -20,4 +20,8 @@ void installGetKeyboardStateHook(); void installMessageFilterHooks(); -void installXInputHooks(); \ No newline at end of file +void installXInputHooks(); + +void installGetCursorInfoHook(); //new + +//void installNewmadeHook(); \ No newline at end of file diff --git a/Master/Nucleus.Hook/NewmadeHook.cpp b/Master/Nucleus.Hook/NewmadeHook.cpp new file mode 100644 index 00000000..accd977e --- /dev/null +++ b/Master/Nucleus.Hook/NewmadeHook.cpp @@ -0,0 +1,43 @@ +#include "pch.h" +#include "InstallHooks.h" +//#include "Logging.h" +//#include +//#include "controller.h" +//#pragma comment(lib, "winmm.lib") + + +//template for a new hook. search for "NewmadeHook", uncomment and rename in all these locations: + +//locations Nucleus Hook: Hook.cpp, InstallHooks.h, Options.h. +//locations Nucleus Inject: Program.cs +//locations Nucleus Gaming: GenericContext.cs, GenericGameInfo.cs, IGenericGameInfo.cs, DllsInjector.cs + + +//this template now hooks winmm.dll's joystick ID, could be it is useful, not tested yet + + + +//MMRESULT WINAPI NewmadeHook(UINT uJoyID, LPJOYINFOEX pji) +//{ + // MMRESULT resultat = + + // if (Controller::controllerIndex == 0) //MKB instance + // return joyGetPosEx(15, pji); + + // else if (Controller::controllerIndex <= 14) + // return joyGetPosEx(Controller::controllerIndex - 1, pji); +//} +//MMRESULT WINAPI NewmadeHook2(UINT uJoyID, LPJOYINFO pji) +//{ + // if (Controller::controllerIndex == 0) +// return joyGetPos(14, pji); //MAX 14 but thats alright for MKB instance + + // else if (Controller::controllerIndex <= 14) + // return joyGetPos(Controller::controllerIndex - 1, pji); +//} //also return anything above ID 14? highly unexpected error + +//void installNewmadeHook() +//{ + // installHook("winmm", "joyGetPosEx", NewmadeHook); + // installHook("winmm", "joyGetPos", NewmadeHook2); +//} \ No newline at end of file diff --git a/Master/Nucleus.Hook/Nucleus.Hook.vcxproj b/Master/Nucleus.Hook/Nucleus.Hook.vcxproj index a943beb2..7fd1c806 100644 --- a/Master/Nucleus.Hook/Nucleus.Hook.vcxproj +++ b/Master/Nucleus.Hook/Nucleus.Hook.vcxproj @@ -241,6 +241,7 @@ copy $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(TargetName).dll $(Soluti + false false @@ -269,6 +270,7 @@ copy $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(TargetName).dll $(Soluti + diff --git a/Master/Nucleus.Hook/Nucleus.Hook.vcxproj.filters b/Master/Nucleus.Hook/Nucleus.Hook.vcxproj.filters index 951a1943..12cea9a9 100644 --- a/Master/Nucleus.Hook/Nucleus.Hook.vcxproj.filters +++ b/Master/Nucleus.Hook/Nucleus.Hook.vcxproj.filters @@ -98,5 +98,11 @@ Source Files + + Source Files + + + Source Files + \ No newline at end of file diff --git a/Master/Nucleus.Hook/Options.h b/Master/Nucleus.Hook/Options.h index e305b087..2cbd20c5 100644 --- a/Master/Nucleus.Hook/Options.h +++ b/Master/Nucleus.Hook/Options.h @@ -22,4 +22,6 @@ class Options bool reRegisterRawInputKeyboard; bool HookXInput;//TODO: implement bool DinputToXinputTranslation;//TODO: implement + bool GetCursorInfoHook; + //bool NewmadeHook; }; diff --git a/Master/Nucleus.Inject/Program.cs b/Master/Nucleus.Inject/Program.cs index be305905..8036bded 100644 --- a/Master/Nucleus.Inject/Program.cs +++ b/Master/Nucleus.Inject/Program.cs @@ -404,6 +404,8 @@ private static void RuntimeHook(string[] args, int i, bool is64) bool.TryParse(args[i++], out bool reRegisterRawInputKeyboard); bool.TryParse(args[i++], out bool hookXinput); bool.TryParse(args[i++], out bool dinputToXinputTranslation); + bool.TryParse(args[i++], out bool GetCursorInfoHook); + // bool.TryParse(args[i++], out bool NewmadeHook); string writePipeName = args[i++]; string readPipeName = args[i++]; @@ -467,6 +469,8 @@ byte Bool_1_0(bool x) dataToSend[index++] = Bool_1_0(reRegisterRawInputKeyboard); dataToSend[index++] = Bool_1_0(hookXinput); dataToSend[index++] = Bool_1_0(dinputToXinputTranslation); + dataToSend[index++] = Bool_1_0(GetCursorInfoHook); + // dataToSend[index++] = Bool_1_0(NewmadeHook); dataToSend[index++] = (byte)(logPathLength >> 24); dataToSend[index++] = (byte)(logPathLength >> 16); diff --git a/Master/NucleusGaming/Coop/Generic/GenericContext.cs b/Master/NucleusGaming/Coop/Generic/GenericContext.cs index c6412ee7..435e6911 100644 --- a/Master/NucleusGaming/Coop/Generic/GenericContext.cs +++ b/Master/NucleusGaming/Coop/Generic/GenericContext.cs @@ -103,6 +103,8 @@ public class GenericContext public string[] CustomUserInstanceValues; public bool InjectHookXinput; public bool InjectDinputToXinputTranslation; + public bool GetCursorInfoHook; + // public bool NewmadeHook; public bool UseDInputBlocker; public bool BlockRawInput; public bool PreventWindowDeactivation; diff --git a/Master/NucleusGaming/Coop/Generic/GenericGameHandler.cs b/Master/NucleusGaming/Coop/Generic/GenericGameHandler.cs index 127a3aec..69e9472c 100644 --- a/Master/NucleusGaming/Coop/Generic/GenericGameHandler.cs +++ b/Master/NucleusGaming/Coop/Generic/GenericGameHandler.cs @@ -655,8 +655,8 @@ public string Play() } } } - - if (i > 0 && !gen.ProcessChangesAtEnd && (gen.HookFocus || gen.SetWindowHook || gen.HideCursor || gen.PreventWindowDeactivation || gen.SupportsMultipleKeyboardsAndMice)) + //|| gen.InjectHookXinput is missing, but i dont dare to fix it, may break some handlers. Xinput hook doesnt hook now unless any of these other conditions match + if (i > 0 && !gen.ProcessChangesAtEnd && (gen.HookFocus || gen.SetWindowHook || gen.HideCursor || gen.PreventWindowDeactivation || gen.SupportsMultipleKeyboardsAndMice || gen.GetCursorInfoHook)) { if (gen.PreventWindowDeactivation && !isPrevent) { @@ -2895,8 +2895,8 @@ public string Play() } } } - - if ((i > 0 || players.Count == 1) && (gen.HookFocus || gen.SetWindowHook || gen.HideCursor || gen.PreventWindowDeactivation || gen.SupportsMultipleKeyboardsAndMice)) + //|| gen.InjectHookXinput is missing, but i dont dare to fix it, may break some handlers. Xinput hook doesnt hook now unless any of these other conditions match + if ((i > 0 || players.Count == 1) && (gen.HookFocus || gen.SetWindowHook || gen.HideCursor || gen.PreventWindowDeactivation || gen.SupportsMultipleKeyboardsAndMice || gen.GetCursorInfoHook)) { if (gen.PreventWindowDeactivation && !isPrevent) { @@ -3156,8 +3156,8 @@ private void ProcessChangeAtEnd() var window = GlobalWindowMethods.CreateRawInputWindow(proc, players[i]); Thread.Sleep(1000); - - if (gen.HookFocus || gen.SetWindowHook || gen.HideCursor || gen.PreventWindowDeactivation || gen.SupportsMultipleKeyboardsAndMice) + //|| gen.InjectHookXinput is missing, but i dont dare to fix it, may break some handlers. Xinput hook doesnt hook now unless any of these other conditions match + if (gen.HookFocus || gen.SetWindowHook || gen.HideCursor || gen.PreventWindowDeactivation || gen.SupportsMultipleKeyboardsAndMice || gen.GetCursorInfoHook) { Log("Injecting post-launch hooks for process " + proc.ProcessName + " (pid " + proc.Id + ")"); diff --git a/Master/NucleusGaming/Coop/Generic/GenericGameInfo.cs b/Master/NucleusGaming/Coop/Generic/GenericGameInfo.cs index 0b2949cd..ba43f1bc 100644 --- a/Master/NucleusGaming/Coop/Generic/GenericGameInfo.cs +++ b/Master/NucleusGaming/Coop/Generic/GenericGameInfo.cs @@ -249,6 +249,8 @@ public bool IsUpdateAvailable(bool fetch) public bool EnableWindows; public string[] WindowStyleEndChanges; public string[] ExtWindowStyleEndChanges; + public bool GetCursorInfoHook; + // public bool NewmadeHook; public bool UseDInputBlocker; public bool IgnoreThirdPartyPrompt; public string ExecutableToLaunch; diff --git a/Master/NucleusGaming/Coop/Generic/IGenericGameInfo.cs b/Master/NucleusGaming/Coop/Generic/IGenericGameInfo.cs index 9412889f..b6cdce89 100644 --- a/Master/NucleusGaming/Coop/Generic/IGenericGameInfo.cs +++ b/Master/NucleusGaming/Coop/Generic/IGenericGameInfo.cs @@ -121,6 +121,10 @@ public interface IGenericGameInfo : IGameInfo bool InjectDinputToXinputTranslation { get; } + bool GetCursorInfoHook { get; } + + // bool NewmadeHook { get; } + bool UseDInputBlocker { get; } bool BlockRawInput { get; } diff --git a/Master/NucleusGaming/Tools/DllsInjector/DllsInjector.cs b/Master/NucleusGaming/Tools/DllsInjector/DllsInjector.cs index 8e4e5204..e19283e4 100644 --- a/Master/NucleusGaming/Tools/DllsInjector/DllsInjector.cs +++ b/Master/NucleusGaming/Tools/DllsInjector/DllsInjector.cs @@ -69,6 +69,8 @@ public static void InjectDLLs(Process proc, Window window, PlayerInfo player) handlerInstance.CurrentGameInfo.HookReRegisterRawInputKeyboard, handlerInstance.CurrentGameInfo.InjectHookXinput, handlerInstance.CurrentGameInfo.InjectDinputToXinputTranslation, + handlerInstance.CurrentGameInfo.GetCursorInfoHook, + //handlerInstance.CurrentGameInfo.NewmadeHook, windowNull ? "" : (window.HookPipe?.pipeNameWrite ?? ""), windowNull ? "" : (window.HookPipe?.pipeNameRead ?? ""),