Skip to content
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
24 changes: 24 additions & 0 deletions Master/Nucleus.Hook/GetCursorInfoHook.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 13 additions & 0 deletions Master/Nucleus.Hook/Hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t>(bytesToInt(p)); p += 4;
Expand Down Expand Up @@ -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 <<
Expand Down Expand Up @@ -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");
Expand Down
6 changes: 5 additions & 1 deletion Master/Nucleus.Hook/InstallHooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ void installGetKeyboardStateHook();

void installMessageFilterHooks();

void installXInputHooks();
void installXInputHooks();

void installGetCursorInfoHook(); //new

//void installNewmadeHook();
43 changes: 43 additions & 0 deletions Master/Nucleus.Hook/NewmadeHook.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "pch.h"
#include "InstallHooks.h"
//#include "Logging.h"
//#include <mmsystem.h>
//#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);
//}
2 changes: 2 additions & 0 deletions Master/Nucleus.Hook/Nucleus.Hook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ copy $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(TargetName).dll $(Soluti
</ItemGroup>
<ItemGroup>
<ClCompile Include="Controller.cpp" />
<ClCompile Include="GetCursorInfoHook.cpp" />
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
Expand Down Expand Up @@ -269,6 +270,7 @@ copy $(SolutionDir)$(PlatformTarget)\$(Configuration)\$(TargetName).dll $(Soluti
<ClCompile Include="Piping.cpp" />
<ClCompile Include="RawInputReRegister.cpp" />
<ClCompile Include="SetWindowHook.cpp" />
<ClCompile Include="NewmadeHook.cpp" />
<ClCompile Include="XInputHooks.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
6 changes: 6 additions & 0 deletions Master/Nucleus.Hook/Nucleus.Hook.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,11 @@
<ClCompile Include="Controller.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GetCursorInfoHook.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NewmadeHook.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions Master/Nucleus.Hook/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ class Options
bool reRegisterRawInputKeyboard;
bool HookXInput;//TODO: implement
bool DinputToXinputTranslation;//TODO: implement
bool GetCursorInfoHook;
//bool NewmadeHook;
};
4 changes: 4 additions & 0 deletions Master/Nucleus.Inject/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++];
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Master/NucleusGaming/Coop/Generic/GenericContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions Master/NucleusGaming/Coop/Generic/GenericGameHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 + ")");

Expand Down
2 changes: 2 additions & 0 deletions Master/NucleusGaming/Coop/Generic/GenericGameInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Master/NucleusGaming/Coop/Generic/IGenericGameInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public interface IGenericGameInfo : IGameInfo

bool InjectDinputToXinputTranslation { get; }

bool GetCursorInfoHook { get; }

// bool NewmadeHook { get; }

bool UseDInputBlocker { get; }

bool BlockRawInput { get; }
Expand Down
2 changes: 2 additions & 0 deletions Master/NucleusGaming/Tools/DllsInjector/DllsInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? ""),
Expand Down