Skip to content

Commit

Permalink
Add natives.ixx and hook to game process
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG authored Dec 21, 2023
2 parents fc66a94 + a918047 commit 3aceb76
Show file tree
Hide file tree
Showing 3 changed files with 7,736 additions and 38 deletions.
9 changes: 8 additions & 1 deletion source/comvars.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import common;

export HWND gWnd;
export RECT gRect;
export void* (__fastcall* getNativeAddress)(uintptr_t*, uint32_t, uint32_t);
export uintptr_t* nativeHandlerPtrAddress;

class Common
{
Expand All @@ -16,7 +18,12 @@ public:
{
FusionFix::onInitEvent() += []()
{
auto pattern = hook::pattern("53 8B 59 04 85 DB");
if (!pattern.empty())
getNativeAddress = pattern.get_one().get<void* (__fastcall)(uintptr_t*, uint32_t, uint32_t)>(0);

pattern = hook::pattern("B9 ? ? ? ? E8 ? ? ? ? 85 C0 75 07");
nativeHandlerPtrAddress = *pattern.get_first<uintptr_t*>(1);
};
}
} Common;
} Common;
75 changes: 38 additions & 37 deletions source/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,49 @@ import common;
import comvars;
import settings;

//injector::hook_back<void(__cdecl*)(int)> hbCGameProcess;
//void __cdecl CGameProcessHook(int a1)
//{
// static std::once_flag of;
// std::call_once(of, []()
// {
// FusionFix::onGameInitEvent().executeAll();
// });
//
// if (CTimer__m_UserPause && CTimer__m_CodePause)
// {
// static auto oldMenuState = 0;
//
// if (!*CTimer__m_UserPause && !*CTimer__m_CodePause)
// {
// uint32_t curMenuState = false;
// if (curMenuState != oldMenuState) {
// FusionFix::onMenuExitEvent().executeAll();
// }
// oldMenuState = curMenuState;
// FusionFix::onGameProcessEvent().executeAll();
// }
// else
// {
// uint32_t curMenuState = true;
// if (curMenuState != oldMenuState) {
// FusionFix::onMenuEnterEvent().executeAll();
// }
// oldMenuState = curMenuState;
// FusionFix::onMenuDrawingEvent().executeAll();
// }
// }
//
// return hbCGameProcess.fun(a1);
//}
injector::hook_back<void(__cdecl*)()> hbCGameProcess;
void __cdecl CGameProcessHook()
{
static std::once_flag of;
std::call_once(of, []()
{
FusionFix::onGameInitEvent().executeAll();
});

//if (CTimer__m_UserPause && CTimer__m_CodePause)
//{
static auto oldMenuState = 0;

//if (!*CTimer__m_UserPause && !*CTimer__m_CodePause)
//{
uint32_t curMenuState = false;
if (curMenuState != oldMenuState)
{
FusionFix::onMenuExitEvent().executeAll();
}
oldMenuState = curMenuState;
FusionFix::onGameProcessEvent().executeAll();
//}
//else
//{
// uint32_t curMenuState = true;
// if (curMenuState != oldMenuState) {
// FusionFix::onMenuEnterEvent().executeAll();
// }
// oldMenuState = curMenuState;
// FusionFix::onMenuDrawingEvent().executeAll();
//}
//}

return hbCGameProcess.fun();
}

void Init()
{
FusionFixSettings.ReadIniSettings();

//auto pattern = hook::pattern("E8 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? B9");
//hbCGameProcess.fun = injector::MakeCALL(pattern.get_first(0), CGameProcessHook, true).get();
auto pattern = hook::pattern("E8 ? ? ? ? E8 ? ? ? ? 8B 0D ? ? ? ? 8B 15 ? ? ? ? 89 0D");
hbCGameProcess.fun = injector::MakeCALL(pattern.get_first(0), CGameProcessHook, true).get();

//static auto futures = FusionFix::onInitEventAsync().executeAllAsync();

Expand Down
Loading

0 comments on commit 3aceb76

Please sign in to comment.