mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-11-23 05:45:37 +08:00
v8
This commit is contained in:
parent
6e571ccf84
commit
95187cd225
@ -99,39 +99,42 @@ namespace v8script
|
||||
#ifndef _WIN64
|
||||
|
||||
#define fnRequestInterrupt "?RequestInterrupt@Isolate@v8@@QAEXP6AXPAV12@PAX@Z1@Z"
|
||||
#define fnNewFromUtf8v2 "?NewFromUtf8@String@v8@@SA?AV?$MaybeLocal@VString@v8@@@2@PAVIsolate@2@PBDW4NewStringType@2@H@Z"
|
||||
#define fnNewFromUtf8v1 "?NewFromUtf8@String@v8@@SA?AV?$Local@VString@v8@@@2@PAVIsolate@2@PBDW4NewStringType@12@H@Z"
|
||||
#define fnNewFromUtf8_maybelocal "?NewFromUtf8@String@v8@@SA?AV?$MaybeLocal@VString@v8@@@2@PAVIsolate@2@PBDW4NewStringType@2@H@Z"
|
||||
#define fnNewFromUtf8_local "?NewFromUtf8@String@v8@@SA?AV?$Local@VString@v8@@@2@PAVIsolate@2@PBDW4NewStringType@12@H@Z"
|
||||
#define fnGetCurrentContext "?GetCurrentContext@Isolate@v8@@QAE?AV?$Local@VContext@v8@@@2@XZ"
|
||||
#define fnCompilev1 "?Compile@Script@v8@@SA?AV?$Local@VScript@v8@@@2@V?$Handle@VString@v8@@@2@PAVScriptOrigin@2@@Z"
|
||||
#define fnCompilev12 "?Compile@Script@v8@@SA?AV?$Local@VScript@v8@@@2@V?$Local@VString@v8@@@2@PAVScriptOrigin@2@@Z"
|
||||
#define fnRunv1 "?Run@Script@v8@@QAE?AV?$Local@VValue@v8@@@2@XZ"
|
||||
#define fnCompilev2 "?Compile@Script@v8@@SA?AV?$MaybeLocal@VScript@v8@@@2@V?$Local@VContext@v8@@@2@V?$Local@VString@v8@@@2@PAVScriptOrigin@2@@Z"
|
||||
#define fnRunv2 "?Run@Script@v8@@QAE?AV?$MaybeLocal@VValue@v8@@@2@V?$Local@VContext@v8@@@2@@Z"
|
||||
#define fnCompile_local "?Compile@Script@v8@@SA?AV?$Local@VScript@v8@@@2@V?$Handle@VString@v8@@@2@PAVScriptOrigin@2@@Z"
|
||||
#define fnCompile_local_2 "?Compile@Script@v8@@SA?AV?$Local@VScript@v8@@@2@V?$Local@VString@v8@@@2@PAVScriptOrigin@2@@Z"
|
||||
#define fnRun_local "?Run@Script@v8@@QAE?AV?$Local@VValue@v8@@@2@XZ"
|
||||
#define fnCompile_maylocal "?Compile@Script@v8@@SA?AV?$MaybeLocal@VScript@v8@@@2@V?$Local@VContext@v8@@@2@V?$Local@VString@v8@@@2@PAVScriptOrigin@2@@Z"
|
||||
#define fnRunv_maylocal "?Run@Script@v8@@QAE?AV?$MaybeLocal@VValue@v8@@@2@V?$Local@VContext@v8@@@2@@Z"
|
||||
|
||||
#else
|
||||
#define fnRequestInterrupt "?RequestInterrupt@Isolate@v8@@QEAAXP6AXPEAV12@PEAX@Z1@Z"
|
||||
#define fnNewFromUtf8v2 "?NewFromUtf8@String@v8@@SA?AV?$MaybeLocal@VString@v8@@@2@PEAVIsolate@2@PEBDW4NewStringType@2@H@Z"
|
||||
#define fnNewFromUtf8v1 "?NewFromUtf8@String@v8@@SA?AV?$Local@VString@v8@@@2@PEAVIsolate@2@PEBDW4NewStringType@12@H@Z"
|
||||
#define fnNewFromUtf8_maybelocal "?NewFromUtf8@String@v8@@SA?AV?$MaybeLocal@VString@v8@@@2@PEAVIsolate@2@PEBDW4NewStringType@2@H@Z"
|
||||
#define fnNewFromUtf8_local "?NewFromUtf8@String@v8@@SA?AV?$Local@VString@v8@@@2@PEAVIsolate@2@PEBDW4NewStringType@12@H@Z"
|
||||
#define fnGetCurrentContext "?GetCurrentContext@Isolate@v8@@QEAA?AV?$Local@VContext@v8@@@2@XZ"
|
||||
#define fnCompilev1 "?Compile@Script@v8@@SA?AV?$Local@VScript@v8@@@2@V?$Handle@VString@v8@@@2@PEAVScriptOrigin@2@@Z"
|
||||
#define fnCompilev12 fnCompilev1
|
||||
#define fnRunv1 "?Run@Script@v8@@QEAA?AV?$Local@VValue@v8@@@2@XZ"
|
||||
#define fnCompilev2 "?Compile@Script@v8@@SA?AV?$MaybeLocal@VScript@v8@@@2@V?$Local@VContext@v8@@@2@V?$Local@VString@v8@@@2@PEAVScriptOrigin@2@@Z"
|
||||
#define fnRunv2 "?Run@Script@v8@@QEAA?AV?$MaybeLocal@VValue@v8@@@2@V?$Local@VContext@v8@@@2@@Z"
|
||||
#define fnCompile_local "?Compile@Script@v8@@SA?AV?$Local@VScript@v8@@@2@V?$Handle@VString@v8@@@2@PEAVScriptOrigin@2@@Z"
|
||||
#define fnCompile_local_2 fnCompile_local
|
||||
#define fnRun_local "?Run@Script@v8@@QEAA?AV?$Local@VValue@v8@@@2@XZ"
|
||||
#define fnCompile_maylocal "?Compile@Script@v8@@SA?AV?$MaybeLocal@VScript@v8@@@2@V?$Local@VContext@v8@@@2@V?$Local@VString@v8@@@2@PEAVScriptOrigin@2@@Z"
|
||||
#define fnRunv_maylocal "?Run@Script@v8@@QEAA?AV?$MaybeLocal@VValue@v8@@@2@V?$Local@VContext@v8@@@2@@Z"
|
||||
|
||||
#endif
|
||||
typedef void *(THISCALL *GetCurrentContextt)(void *, void *);
|
||||
typedef void *(THISCALL *Runt1)(void *, void *);
|
||||
typedef void *(THISCALL *Runt2)(void *, void *, void *);
|
||||
typedef void *(THISCALL *Run_local_t)(void *, void *);
|
||||
typedef void *(THISCALL *Run_maybelocal_t)(void *, void *, void *);
|
||||
typedef void *(THISCALL *RequestInterruptt)(void *, RequestInterrupt_callback, void *);
|
||||
|
||||
typedef void *(*NewFromUtf8t)(void *, void *, const char *, int, int);
|
||||
typedef void *(*Compilet)(void *, void *, void *, void *);
|
||||
typedef void *(*Compile_local_t)(void *, void *, void *);
|
||||
typedef void *(*Compile_maybelocal_t)(void *, void *, void *, void *);
|
||||
RequestInterruptt RequestInterrupt;
|
||||
NewFromUtf8t NewFromUtf8 = 0, NewFromUtf8v2, NewFromUtf8v1;
|
||||
GetCurrentContextt GetCurrentContext;
|
||||
Compilet Compile;
|
||||
void *Run;
|
||||
Compile_local_t Compile_local;
|
||||
Compile_maybelocal_t Compile_maybelocal;
|
||||
Run_local_t Run_local;
|
||||
Run_maybelocal_t Run_maybelocal;
|
||||
void _interrupt_function(void *isolate, void *)
|
||||
{
|
||||
void *context;
|
||||
@ -141,7 +144,7 @@ namespace v8script
|
||||
ConsoleOutput("isolate %p", isolate);
|
||||
GetCurrentContext(isolate, &context);
|
||||
ConsoleOutput("context %p", context);
|
||||
if (context == 0)
|
||||
if (!context)
|
||||
return;
|
||||
int is_packed = 0;
|
||||
if (auto moduleFileName = getModuleFilename())
|
||||
@ -162,30 +165,30 @@ namespace v8script
|
||||
}
|
||||
}
|
||||
|
||||
auto lunajspatch = LoadResData(L"lunajspatch", L"JSSOURCE");
|
||||
std::string lunajspatch = LoadResData(L"lunajspatch", L"JSSOURCE");
|
||||
strReplace(lunajspatch, "IS_PACKED", std::to_string(is_packed));
|
||||
strReplace(lunajspatch, "IS_USECLIPBOARD", std::to_string(useclipboard));
|
||||
strReplace(lunajspatch, "INTERNAL_HTTP_PORT", std::to_string(usehttp_port));
|
||||
NewFromUtf8(&v8string, isolate, lunajspatch.c_str(), 1, -1);
|
||||
ConsoleOutput("v8string %p", v8string);
|
||||
if (v8string == 0)
|
||||
if (!v8string)
|
||||
return;
|
||||
if (NewFromUtf8v1)
|
||||
{
|
||||
Compile(&script, v8string, 0, 0);
|
||||
(Compile_local)(&script, v8string, 0);
|
||||
ConsoleOutput("script %p", script);
|
||||
if (script == 0)
|
||||
if (!script)
|
||||
return;
|
||||
((Runt1)Run)(script, &useless);
|
||||
(Run_local)(script, &useless);
|
||||
ConsoleOutput("useless %p", useless);
|
||||
}
|
||||
else if (NewFromUtf8v2)
|
||||
{
|
||||
Compile(&script, context, v8string, 0);
|
||||
(Compile_maybelocal)(&script, context, v8string, 0);
|
||||
ConsoleOutput("script %p", script);
|
||||
if (script == 0)
|
||||
if (!script)
|
||||
return;
|
||||
((Runt2)Run)(script, &useless, context);
|
||||
(Run_maybelocal)(script, &useless, context);
|
||||
ConsoleOutput("useless %p", useless);
|
||||
}
|
||||
}
|
||||
@ -193,34 +196,33 @@ namespace v8script
|
||||
{
|
||||
RequestInterrupt = (decltype(RequestInterrupt))GetProcAddress(hmodule, fnRequestInterrupt);
|
||||
|
||||
NewFromUtf8v2 = (decltype(NewFromUtf8))GetProcAddress(hmodule, fnNewFromUtf8v2);
|
||||
NewFromUtf8v1 = (decltype(NewFromUtf8))GetProcAddress(hmodule, fnNewFromUtf8v1);
|
||||
NewFromUtf8v2 = (decltype(NewFromUtf8))GetProcAddress(hmodule, fnNewFromUtf8_maybelocal);
|
||||
NewFromUtf8v1 = (decltype(NewFromUtf8))GetProcAddress(hmodule, fnNewFromUtf8_local);
|
||||
|
||||
GetCurrentContext = (decltype(GetCurrentContext))GetProcAddress(hmodule, fnGetCurrentContext);
|
||||
|
||||
if (!(RequestInterrupt && GetCurrentContext))
|
||||
return false;
|
||||
if (NewFromUtf8v1)
|
||||
{
|
||||
NewFromUtf8 = NewFromUtf8v1;
|
||||
Compile = (decltype(Compile))GetProcAddress(hmodule, fnCompilev1);
|
||||
if (!Compile)
|
||||
Compile = (decltype(Compile))GetProcAddress(hmodule, fnCompilev12);
|
||||
Run = (decltype(Run))GetProcAddress(hmodule, fnRunv1);
|
||||
Compile_local = (decltype(Compile_local))GetProcAddress(hmodule, fnCompile_local);
|
||||
if (!Compile_local)
|
||||
Compile_local = (decltype(Compile_local))GetProcAddress(hmodule, fnCompile_local_2);
|
||||
Run_local = (decltype(Run_local))GetProcAddress(hmodule, fnRun_local);
|
||||
if (!(Run_local && Compile_local))
|
||||
return false;
|
||||
}
|
||||
else if (NewFromUtf8v2)
|
||||
{
|
||||
NewFromUtf8 = NewFromUtf8v2;
|
||||
Compile = (decltype(Compile))GetProcAddress(hmodule, fnCompilev2);
|
||||
Run = (decltype(Run))GetProcAddress(hmodule, fnRunv2);
|
||||
Compile_maybelocal = (decltype(Compile_maybelocal))GetProcAddress(hmodule, fnCompile_maylocal);
|
||||
Run_maybelocal = (decltype(Run_maybelocal))GetProcAddress(hmodule, fnRunv_maylocal);
|
||||
if (!(Run_maybelocal && Compile_maybelocal))
|
||||
return false;
|
||||
}
|
||||
|
||||
ConsoleOutput("%p %p", NewFromUtf8v1, NewFromUtf8v2);
|
||||
ConsoleOutput("%p %p %p %p", GetCurrentContext, NewFromUtf8, Compile, Run);
|
||||
|
||||
if (!(GetCurrentContext && NewFromUtf8 && Compile && Run && RequestInterrupt))
|
||||
else
|
||||
return false;
|
||||
|
||||
if (RequestInterrupt == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool v8runscript_isolate(void *isolate)
|
||||
|
@ -21,7 +21,7 @@ function splitfonttext(transwithfont) {
|
||||
return transwithfont;
|
||||
}
|
||||
}
|
||||
function cppjsio(name, s_raw, lpsplit, embedable = true) {
|
||||
function cppjsio(name, s_raw, lpsplit, embedable) {
|
||||
if (!s_raw)
|
||||
return s_raw
|
||||
transwithfont = ''
|
||||
@ -100,7 +100,7 @@ function rpgmakerhook() {
|
||||
}
|
||||
Window_Message.prototype.startMessage = function () {
|
||||
gametext = $gameMessage.allText();
|
||||
resp = cppjsio('rpgmakermv', gametext, 0);
|
||||
resp = cppjsio('rpgmakermv', gametext, 0, true);
|
||||
$gameMessage._texts = [resp]
|
||||
this.originstartMessage();
|
||||
};
|
||||
@ -115,7 +115,7 @@ function rpgmakerhook() {
|
||||
return this.updateMessage_ori();
|
||||
};
|
||||
Window_Base.prototype.drawText = function (text, x, y, maxWidth, align) {
|
||||
text = cppjsio('rpgmakermv', text, 1)
|
||||
text = cppjsio('rpgmakermv', text, 1, true)
|
||||
return this.drawText_origin(text, x, y, maxWidth, align)
|
||||
}
|
||||
Window_Base.prototype.lastcalltime = 0
|
||||
@ -124,7 +124,7 @@ function rpgmakerhook() {
|
||||
__now = new Date().getTime()
|
||||
Window_Base.prototype.lastcalltime = __now
|
||||
if (__now - __last > 100)
|
||||
text = cppjsio('rpgmakermv', text, 2)
|
||||
text = cppjsio('rpgmakermv', text, 2, true)
|
||||
else {
|
||||
Bitmap.prototype.collectstring[2] += text;
|
||||
}
|
||||
@ -139,7 +139,7 @@ function tyranohook() {
|
||||
tyrano.plugin.kag.tag.chara_ptext.startorigin = tyrano.plugin.kag.tag.chara_ptext.start;
|
||||
tyrano.plugin.kag.tag.text.start = function (pm) {
|
||||
if (1 != this.kag.stat.is_script && 1 != this.kag.stat.is_html) {
|
||||
pm.val = cppjsio('tyranoscript', pm.val, 0);
|
||||
pm.val = cppjsio('tyranoscript', pm.val, 0, true);
|
||||
if (fontface) {
|
||||
this.kag.stat.font.face = fontface
|
||||
}
|
||||
@ -147,7 +147,7 @@ function tyranohook() {
|
||||
return this.originstart(pm)
|
||||
}
|
||||
tyrano.plugin.kag.tag.chara_ptext.start = function (pm) {
|
||||
pm.name = cppjsio('tyranoscript', pm.name, 1)
|
||||
pm.name = cppjsio('tyranoscript', pm.name, 1, true)
|
||||
return this.startorigin(pm)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user