-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Another patches support added: 1.24e, 1.27a, 1.27b, 1.28f.
- Loading branch information
Showing
28 changed files
with
486 additions
and
1,358 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "pch.h" | ||
#include "Detours.h" | ||
|
||
namespace Detour { | ||
BOOL Install(UINT_PTR* pointer_ptr, UINT_PTR detour) { | ||
BOOL error = NO_ERROR; | ||
|
||
if ((error = DetourTransactionBegin()) != NO_ERROR) { printf("DetourTransactionBegin failed with error: %d.\n", error); } | ||
if (!error && (error = DetourUpdateThread(GetCurrentThread())) != NO_ERROR) { printf("DetourUpdateThread failed with error: %d.\n", error); } | ||
if (!error && (error = DetourAttach((PVOID*)pointer_ptr, (PVOID)detour)) != NO_ERROR) { printf("DetourAttach failed with error: %d.\n", error); } | ||
if (!error && (error = DetourTransactionCommit()) != NO_ERROR) { printf("DetourTransactionCommit failed with error: %d.\n", error); } | ||
|
||
if (error != NO_ERROR) { DetourTransactionAbort(); } | ||
|
||
return error; | ||
} | ||
|
||
BOOL Uninstall(UINT_PTR* pointer_ptr, UINT_PTR detour) { | ||
BOOL error = NO_ERROR; | ||
|
||
if ((error = DetourTransactionBegin()) != NO_ERROR) { wprintf_s(L"DetourTransactionBegin failed with error: %d.\n", error); } | ||
if (!error && (error = DetourUpdateThread(::GetCurrentThread())) != NO_ERROR) { wprintf_s(L"DetourUpdateThread failed with error: %d.\n", error); } | ||
if (!error && (error = DetourDetach((PVOID*)pointer_ptr, (PVOID)detour)) != NO_ERROR) { wprintf_s(L"DetourAttach failed with error: %d.\n", error); } | ||
if (!error && (error = DetourTransactionCommit()) != NO_ERROR) { wprintf_s(L"DetourTransactionCommit failed with error: %d.\n", error); } | ||
|
||
if (error != NO_ERROR) { DetourTransactionAbort(); } | ||
|
||
return error; | ||
} | ||
|
||
BOOL InstallEx(bool flag, UINT_PTR* pointer_ptr, UINT_PTR detour) { | ||
if (pointer_ptr && *pointer_ptr != NULL) { | ||
return flag ? Install(pointer_ptr, detour) : Uninstall(pointer_ptr, detour); | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
BOOL SetState(bool flag, UINT_PTR* pointer_ptr, UINT_PTR detour) { | ||
return flag ? Install(pointer_ptr, detour) : Uninstall(pointer_ptr, detour); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
namespace Detour { | ||
BOOL Install(UINT_PTR* pointer_ptr, UINT_PTR detour); | ||
BOOL Uninstall(UINT_PTR* pointer_ptr, UINT_PTR detour); | ||
BOOL InstallEx(bool flag, UINT_PTR* pointer_ptr, UINT_PTR detour); | ||
BOOL SetState(bool flag, UINT_PTR* pointer_ptr, UINT_PTR detour); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,68 @@ | ||
#include "pch.h" | ||
#include "Hooks.h" | ||
#include "Offsets.h" | ||
#include "LuaMachine.h" | ||
|
||
#define AttachDetour(pointer, detour) (DetourUpdateThread(GetCurrentThread()), DetourAttach(&(PVOID&)pointer, detour)) | ||
#define DetachDetour(pointer, detour) (DetourUpdateThread(GetCurrentThread()), DetourDetach(&(PVOID&)pointer, detour)) | ||
|
||
namespace Hooks { | ||
auto SetJassState = (void(__fastcall*)(BOOL jassState))((std::ptrdiff_t)gameBase + 0x2ab0e0); | ||
auto GetWarcraftID = (DWORD(__stdcall*)())((std::ptrdiff_t)gameBase + 0x537ed0); | ||
enum class EventTypes : UINT { | ||
EVENT_CNET_GAME_START = 0x4009007e, | ||
EVENT_CNET_GAME_LEAVE = 0x40090081, | ||
}; | ||
|
||
DWORD GetWarcraftIDCustom() | ||
{ | ||
return *(DWORD*)GAME_ID; | ||
} | ||
enum class ObserverRegistryTypes : UINT { | ||
GAME_START_LOADING = 0x00402000, | ||
GAME_FINISH_LOADING = 0x00140800 | ||
}; | ||
|
||
void __fastcall SetJassStateCustom(BOOL jassState) { | ||
if (jassState == TRUE) { | ||
LuaMachine::StartLua(); | ||
} | ||
typedef struct { | ||
PVOID vtable; // 0x0 | ||
size_t refCount; // 0x4 | ||
UINT* registry; // 0x8 ObserverRegistry | ||
} CObserver; | ||
|
||
typedef struct { | ||
PVOID vtable; // 0x0 | ||
UINT unk_04; // 0x4 | ||
UINT id; // 0x8 | ||
PVOID object; // 0xC | ||
DWORD data; // 0x10 | serves as keyCode for KeyEvent | ||
} CEvent; | ||
|
||
return SetJassState(jassState); | ||
BOOL CGameProcessEvent(CObserver* observer, CEvent* cevent) { | ||
return pOffsets[(UINT)Offset::CGameEventHandler] ? this_call<BOOL>(pOffsets[(UINT)Offset::CGameEventHandler], observer, cevent) : NULL; | ||
} | ||
|
||
void AttachHooks() { | ||
DetourTransactionBegin(); | ||
DWORD GetWarcraftVersionKey() { | ||
return pOffsets[(UINT)Offset::GetWarcraftVersionKey] ? std_call<DWORD>(pOffsets[(UINT)Offset::GetWarcraftVersionKey]) : NULL; | ||
} | ||
|
||
AttachDetour(SetJassState, SetJassStateCustom); | ||
AttachDetour(GetWarcraftID, GetWarcraftIDCustom); | ||
//-------------------------------------------- | ||
|
||
DetourTransactionCommit(); | ||
DWORD GetLuaVersionKey() { | ||
return *(DWORD*)GAME_ID; | ||
} | ||
|
||
void DetachHooks() { | ||
DetourTransactionBegin(); | ||
BOOL __fastcall CGameEventHandler(CObserver* observer, PVOID, CEvent* cevent) { | ||
if (observer && cevent) { | ||
switch (cevent->id) { | ||
case (UINT)EventTypes::EVENT_CNET_GAME_START: | ||
if (*observer->registry == (UINT)ObserverRegistryTypes::GAME_FINISH_LOADING) { | ||
LuaMachine::StartLua(); | ||
} | ||
|
||
break; | ||
case (UINT)EventTypes::EVENT_CNET_GAME_LEAVE: | ||
LuaMachine::DestroyLua(); | ||
|
||
DetachDetour(SetJassState, SetJassStateCustom); | ||
DetachDetour(GetWarcraftID, GetWarcraftIDCustom); | ||
break; | ||
} | ||
} | ||
|
||
return CGameProcessEvent(observer, cevent); | ||
} | ||
|
||
DetourTransactionCommit(); | ||
void SetHooksState(bool flag) { | ||
Detour::SetState(flag,&pOffsets[(UINT)Offset::CGameEventHandler], (UINT_PTR)CGameEventHandler); | ||
Detour::SetState(flag,&pOffsets[(UINT)Offset::GetWarcraftVersionKey], (UINT_PTR)GetLuaVersionKey); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#pragma once | ||
|
||
namespace Hooks { | ||
void AttachHooks(); | ||
|
||
void DetachHooks(); | ||
void SetHooksState(bool flag); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.