Update yuzusuyu.cpp

1

fix
This commit is contained in:
恍兮惚兮 2024-03-22 14:23:39 +08:00
parent 6ef70a3eff
commit 0e62cc8e58
4 changed files with 82 additions and 11 deletions

View File

@ -77,6 +77,14 @@ struct emfuncinfo{
};
std::unordered_map<uintptr_t,emfuncinfo>emfunctionhooks;
std::unordered_set<uintptr_t>breakpoints;
bool checkiscurrentgame(const emfuncinfo& em){
auto wininfos=get_proc_windows();
for(auto&& info:wininfos){
if(info.title.find(em._id)!=info.title.npos)return true;
}
return false;
}
}
bool hookPPSSPPDoJit(){
ConsoleOutput("[Compatibility] PPSSPP 1.12.3-867 -> v1.16.1-35");
@ -91,6 +99,8 @@ bool hookPPSSPPDoJit(){
if(emfunctionhooks.find(em_address)==emfunctionhooks.end())return;
if(!(checkiscurrentgame(emfunctionhooks.at(em_address))))return;
HookParam hpinternal;
hpinternal.user_value=em_address;
hpinternal.address=stack->retaddr;
@ -104,8 +114,6 @@ bool hookPPSSPPDoJit(){
auto em_address=hp->user_value;
auto op=emfunctionhooks.at(em_address);
DWORD _;
VirtualProtect((LPVOID)ret,0x10,PAGE_EXECUTE_READWRITE,&_);
HookParam hpinternal;
hpinternal.address=ret;
hpinternal.user_value=em_address;

View File

@ -81,11 +81,20 @@ public:
struct emfuncinfo{
const char* hookname;
void* hookfunc;
void* filterfun;
const wchar_t* _id;
const wchar_t* _version;
};
std::unordered_map<uintptr_t,emfuncinfo>emfunctionhooks;
bool checkiscurrentgame(const emfuncinfo& em){
auto wininfos=get_proc_windows();
for(auto&& info:wininfos){
if(info.title.find(em._version)!=info.title.npos)return true;
}
return false;
}
}
bool yuzusuyu::attach_function()
{
@ -101,15 +110,14 @@ bool yuzusuyu::attach_function()
auto em_address = *(uintptr_t*)descriptor;
em_address-=0x80004000;
if(emfunctionhooks.find(em_address)==emfunctionhooks.end() || !entrypoint)return;
auto op=emfunctionhooks.at(em_address);
if(!(checkiscurrentgame(op)))return;
DWORD _;
VirtualProtect((LPVOID)entrypoint,0x10,PAGE_EXECUTE_READWRITE,&_);
HookParam hpinternal;
hpinternal.address=entrypoint;
hpinternal.type=CODEC_UTF16|USING_STRING|NO_CONTEXT;
hpinternal.text_fun=(decltype(hpinternal.text_fun))op.hookfunc;
hpinternal.filter_fun=(decltype(hpinternal.filter_fun))op.filterfun;
NewHook(hpinternal,op.hookname);
};
@ -125,11 +133,34 @@ void _0100978013276000(hook_stack* stack, HookParam* hp, uintptr_t* data, uintpt
auto s=mages::readString(emu_arg(stack)[0],0);
write_string_new(data,len,s);
}
// @name [0100A460141B8000] Shiro to Kuro no Alice
// @version 1.0.0
// @author Koukdw
// @description
// * Kogado Girls Project
// * Idea Factory (アイディアファクトリー) & Otomate
// * AliceNX_MPA (string inside binary)
// *
void _0100A460141B8000(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
auto address=emu_arg(stack)[0];
hp->type=USING_STRING|CODEC_UTF8|NO_CONTEXT;
*data=address;*len=strlen((char*)address);
}
namespace{
auto _=[](){
emfunctionhooks={
{0x8003eeac - 0x80004000,{"Memories Off",_0100978013276000,L"0100978013276000",L"1.0.0"}},
{0x8003eebc - 0x80004000,{"Memories Off",_0100978013276000,L"0100978013276000",L"1.0.1"}},
{0x8003eeac - 0x80004000,{"Memories Off",_0100978013276000,0,L"0100978013276000",L"1.0.0"}},
{0x8003eebc - 0x80004000,{"Memories Off",_0100978013276000,0,L"0100978013276000",L"1.0.1"}},
// Shiro to Kuro no Alice
{0x80013f20 - 0x80004000,{"Shiro to Kuro no Alice",_0100A460141B8000,NewLineCharFilterW,L"0100A460141B8000",L"1.0.0"}},
{0x80013f94 - 0x80004000,{"Shiro to Kuro no Alice",_0100A460141B8000,NewLineCharFilterW,L"0100A460141B8000",L"1.0.0"}},
{0x8001419c - 0x80004000,{"Shiro to Kuro no Alice",_0100A460141B8000,NewLineCharFilterW,L"0100A460141B8000",L"1.0.0"}},
// Shiro to Kuro no Alice -Twilight line-
{0x80014260 - 0x80004000,{"Shiro to Kuro no Alice -Twilight line-",_0100A460141B8000,NewLineCharFilterW,L"0100A460141B8000",L"1.0.0"}},
{0x800142d4 - 0x80004000,{"Shiro to Kuro no Alice -Twilight line-",_0100A460141B8000,NewLineCharFilterW,L"0100A460141B8000",L"1.0.0"}},
{0x800144dc - 0x80004000,{"Shiro to Kuro no Alice -Twilight line-",_0100A460141B8000,NewLineCharFilterW,L"0100A460141B8000",L"1.0.0"}},
};
return 1;
}();

View File

@ -605,3 +605,28 @@ void write_string_new(uintptr_t* data, size_t* len,const std::string& s){write_s
bool write_string_overwrite(void* data, size_t* len,const std::wstring& s){return write_string_overwrite_impl<wchar_t>(data,len,s);}
bool write_string_overwrite(void* data, size_t* len,const std::string& s){return write_string_overwrite_impl<char>(data,len,s);}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) {
std::vector<WindowInfo>* windowList = reinterpret_cast<std::vector<WindowInfo>*>(lParam);
DWORD processId;
GetWindowThreadProcessId(hwnd, &processId);
if (processId == GetCurrentProcessId()) {
auto length=GetWindowTextLengthW(hwnd);
auto title=std::vector<WCHAR>(length+1);
GetWindowTextW(hwnd, title.data(), title.size());
WindowInfo windowInfo;
windowInfo.handle = hwnd;
windowInfo.title = title.data();
windowList->push_back(windowInfo);
}
return TRUE;
}
std::vector<WindowInfo>get_proc_windows(){
std::vector<WindowInfo> windows;
EnumWindows(EnumWindowsProc, reinterpret_cast<LPARAM>(&windows));
return windows;
}

View File

@ -81,3 +81,10 @@ void write_string_new(uintptr_t* data, size_t* len,const std::wstring& s);
void write_string_new(uintptr_t* data, size_t* len,const std::string& s);
bool write_string_overwrite(void* data, size_t* len,const std::wstring& s);
bool write_string_overwrite(void* data, size_t* len,const std::string& s);
struct WindowInfo {
HWND handle;
std::wstring title;
};
std::vector<WindowInfo>get_proc_windows();