-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts/client: Remove uses of Autohook from
scriptbrowserhooks.cpp
(…
…#833) * Manually hook OpenExternalWebBrowser * Remove AUTOHOOK_INIT and AUTOHOOK_DISPATCH
- Loading branch information
1 parent
feab262
commit 1045478
Showing
1 changed file
with
5 additions
and
8 deletions.
There are no files selected for viewing
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,25 +1,22 @@ | ||
|
||
AUTOHOOK_INIT() | ||
|
||
bool* bIsOriginOverlayEnabled; | ||
|
||
// clang-format off | ||
AUTOHOOK(OpenExternalWebBrowser, engine.dll + 0x184E40, | ||
void, __fastcall, (char* pUrl, char flags)) | ||
// clang-format on | ||
static void(__fastcall* o_pOpenExternalWebBrowser)(char* pUrl, char flags) = nullptr; | ||
static void __fastcall h_OpenExternalWebBrowser(char* pUrl, char flags) | ||
{ | ||
bool bIsOriginOverlayEnabledOriginal = *bIsOriginOverlayEnabled; | ||
bool isHttp = !strncmp(pUrl, "http://", 7) || !strncmp(pUrl, "https://", 8); | ||
if (flags & 2 && isHttp) // custom force external browser flag | ||
*bIsOriginOverlayEnabled = false; // if this bool is false, game will use an external browser rather than the origin overlay one | ||
|
||
OpenExternalWebBrowser(pUrl, flags); | ||
o_pOpenExternalWebBrowser(pUrl, flags); | ||
*bIsOriginOverlayEnabled = bIsOriginOverlayEnabledOriginal; | ||
} | ||
|
||
ON_DLL_LOAD_CLIENT("engine.dll", ScriptExternalBrowserHooks, (CModule module)) | ||
{ | ||
AUTOHOOK_DISPATCH() | ||
o_pOpenExternalWebBrowser = module.Offset(0x184E40).RCast<decltype(o_pOpenExternalWebBrowser)>(); | ||
HookAttach(&(PVOID&)o_pOpenExternalWebBrowser, (PVOID)h_OpenExternalWebBrowser); | ||
|
||
bIsOriginOverlayEnabled = module.Offset(0x13978255).RCast<bool*>(); | ||
} |