Script update: redirect in-game browser, support more versions of HSR
HSR 0.56 tested and supported now Embedded browser is being redirected now, so you can use in-game register window to create an account.
This commit is contained in:
parent
6a491658aa
commit
cafcbffcdd
1 changed files with 52 additions and 14 deletions
|
@ -5,26 +5,64 @@ function main(stage, parameters) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SystemDll = Il2cppApiWrap.GetImageByName("System.dll");
|
// Redirect http requests
|
||||||
|
const UnityWebRequestSetUrlPtr = Helpers.FindMethodImpl("UnityEngine.UnityWebRequestModule.dll", "UnityEngine.Networking", "UnityWebRequest", "set_url", 1);
|
||||||
|
const UriCtorPtr = Helpers.FindMethodImpl("System.dll", "System", "Uri", ".ctor", 1);
|
||||||
|
|
||||||
|
console.log("Found UnityWebRequest::set_url at " + UnityWebRequestSetUrlPtr);
|
||||||
|
console.log("Found Uri::ctor at " + UriCtorPtr);
|
||||||
|
|
||||||
|
RedirectCallback.targetHost = parameters.redirectHost;
|
||||||
|
Interceptor.attach(UnityWebRequestSetUrlPtr, RedirectCallback);
|
||||||
|
Interceptor.attach(UriCtorPtr, RedirectCallback);
|
||||||
|
|
||||||
const SystemUriClass = Il2cppApiWrap.GetClassByName(SystemDll, "System", "Uri");
|
console.log("Attached successfully, will redirect all requests to: " + parameters.redirectHost);
|
||||||
const SystemUriCtor = Il2cppApiWrap.GetClassMethodByName(SystemUriClass, ".ctor", 1);
|
|
||||||
|
// Hook ZFGameBrowser to redirect in-game WebView
|
||||||
console.log("Found System.Uri.ctor(System.String) at " + SystemUriCtor.readPointer());
|
const BrowserLoadURL = Helpers.FindMethodImpl("ZFBrowser.dll", "ZenFulcrum.EmbeddedBrowser", "Browser", "LoadURL", 2);
|
||||||
|
|
||||||
Interceptor.attach(SystemUriCtor.readPointer(), {
|
if (BrowserLoadURL) {
|
||||||
onEnter(args) {
|
Interceptor.attach(BrowserLoadURL, {
|
||||||
var requestUrl = args[1].readCSharpString();
|
onEnter(args) {
|
||||||
if (requestUrl.startsWith("http://") || requestUrl.startsWith("https://")) {
|
var requestUrl = args[1].readCSharpString();
|
||||||
var prefix = requestUrl.split('/', 3).join('/');
|
var prefix = requestUrl.split('/', 3).join('/');
|
||||||
args[1] = Il2cppApiWrap.AllocateString(requestUrl.replace(prefix, parameters.redirectHost));
|
args[1] = Il2cppApiWrap.AllocateString(requestUrl.replace(prefix, parameters.redirectHost));
|
||||||
|
|
||||||
console.log("redirected: " + args[1].readCSharpString());
|
console.log("EmbeddedBrowser redirected: " + args[1].readCSharpString());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("Successfully hooked EmbeddedBrowser");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const RedirectCallback = {
|
||||||
|
onEnter(args) {
|
||||||
|
var requestUrl = args[1].readCSharpString();
|
||||||
|
if (requestUrl.startsWith("http://") || requestUrl.startsWith("https://")) {
|
||||||
|
if (requestUrl.includes(RedirectCallback.targetHost)) return; // already redirected
|
||||||
|
|
||||||
|
var prefix = requestUrl.split('/', 3).join('/');
|
||||||
|
args[1] = Il2cppApiWrap.AllocateString(requestUrl.replace(prefix, RedirectCallback.targetHost));
|
||||||
|
|
||||||
|
console.log("redirected: " + args[1].readCSharpString());
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
};
|
||||||
console.log("Attached successfully, will redirect all requests to: " + parameters.redirectHost);
|
|
||||||
|
const Helpers = {
|
||||||
|
FindMethodImpl(moduleName, namespace, className, methodName, argCount) {
|
||||||
|
const module = Il2cppApiWrap.GetImageByName(moduleName);
|
||||||
|
if (module.equals(ptr(0))) return null;
|
||||||
|
|
||||||
|
const il2cppClass = Il2cppApiWrap.GetClassByName(module, namespace, className);
|
||||||
|
if (il2cppClass.equals(ptr(0))) return null;
|
||||||
|
|
||||||
|
const il2cppMethod = Il2cppApiWrap.GetClassMethodByName(il2cppClass, methodName, argCount);
|
||||||
|
if (il2cppMethod.equals(ptr(0))) return null;
|
||||||
|
|
||||||
|
return il2cppMethod.readPointer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Il2cppApiWrap = {
|
const Il2cppApiWrap = {
|
||||||
|
|
Loading…
Reference in a new issue