Update v8.cpp

This commit is contained in:
恍兮惚兮 2024-03-16 21:47:09 +08:00
parent 4a5d4fc977
commit 9832e7ac8a

View File

@ -153,17 +153,20 @@ bool v8runscript(HMODULE _hmodule){
if(isolate) if(isolate)
return v8runscript_isolate(isolate); return v8runscript_isolate(isolate);
#ifndef _WIN64 #ifndef _WIN64
#define isolategetter "?NewFromUtf8@String@v8@@SA?AV?$Local@VString@v8@@@2@PAVIsolate@2@PBDW4NewStringType@12@H@Z" #define fnisolategetter "?NewFromUtf8@String@v8@@SA?AV?$Local@VString@v8@@@2@PAVIsolate@2@PBDW4NewStringType@12@H@Z"
#define fnisolategetter2 fnisolategetter
#else #else
#define isolategetter "?Utf8Length@String@v8@@QEBAHPEAVIsolate@2@@Z" //旧版没有 #define fnisolategetter "?Utf8Length@String@v8@@QEBAHPEAVIsolate@2@@Z"
//??0TryCatch@v8@@QEAA@PEAVIsolate@1@@Z也可以但是有报错 #define fnisolategetter2 "?NewFromUtf8@String@v8@@SA?AV?$Local@VString@v8@@@2@PEAVIsolate@2@PEBDW4NewStringType@12@H@Z"
#endif #endif
auto stringlengthisolate=GetProcAddress(_hmodule,isolategetter); auto isolategetter=GetProcAddress(_hmodule,fnisolategetter);
if(!stringlengthisolate)return false; if(!isolategetter)
isolategetter=GetProcAddress(_hmodule,fnisolategetter2);
if(!isolategetter)return false;
hmodule=_hmodule; hmodule=_hmodule;
HookParam hp; HookParam hp;
hp.address=(uintptr_t)stringlengthisolate; hp.address=(uintptr_t)isolategetter;
hp.text_fun=v8runscript_isolate_bypass; hp.text_fun=v8runscript_isolate_bypass;
return NewHook(hp,"v8isolate"); return NewHook(hp,"v8isolate");
@ -209,6 +212,10 @@ namespace{
*len=length; *len=length;
}; };
hp.filter_fun=[](void* data, size_t* len, HookParam* hp){
if(strstr((char*)data,R"(\\?\)")!=0)return false;//过滤路径
return true;
};
return NewHook(hp,"v8::String::Length"); return NewHook(hp,"v8::String::Length");
} }
} }