This commit is contained in:
恍兮惚兮 2024-03-31 02:55:23 +08:00
parent db7beab725
commit 5055412464
3 changed files with 17 additions and 5 deletions

View File

@ -359,6 +359,15 @@ bool F01000200194AE000(void* data, size_t* len, HookParam* hp){
} }
return write_string_overwrite(data,len,s); return write_string_overwrite(data,len,s);
} }
void T0100EA001A626000(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){
auto address=emu_arg(stack)[1];
auto s=utf32_to_utf16((uint32_t*)address,u32strlen((uint32_t*)address));
s = std::regex_replace(s, std::wregex(L"[\\s]"), L"");
s = std::regex_replace(s, std::wregex(L"#KW"), L"");
s = std::regex_replace(s, std::wregex(L"#C\\(TR,0xff0000ff\\)"), L"");
s = std::regex_replace(s, std::wregex(L"#P\\(.*\\)"), L"");
write_string_new(data,len,s);
}
namespace{ namespace{
auto _=[](){ auto _=[](){
emfunctionhooks={ emfunctionhooks={
@ -395,6 +404,10 @@ auto _=[](){
{0x80557408 - 0x80004000,{"Majestic Majolical",simpleutf8getter<0>,F01000200194AE000,L"01000200194AE000",L"1.0.0"}},//name {0x80557408 - 0x80004000,{"Majestic Majolical",simpleutf8getter<0>,F01000200194AE000,L"01000200194AE000",L"1.0.0"}},//name
{0x8059ee94 - 0x80004000,{"Majestic Majolical",simpleutf8getter<3>,F01000200194AE000,L"01000200194AE000",L"1.0.0"}},//player name {0x8059ee94 - 0x80004000,{"Majestic Majolical",simpleutf8getter<3>,F01000200194AE000,L"01000200194AE000",L"1.0.0"}},//player name
{0x80557420 - 0x80004000,{"Majestic Majolical",simpleutf8getter<0>,F01000200194AE000,L"01000200194AE000",L"1.0.0"}},//dialogue {0x80557420 - 0x80004000,{"Majestic Majolical",simpleutf8getter<0>,F01000200194AE000,L"01000200194AE000",L"1.0.0"}},//dialogue
{0x8017ad54 - 0x80004000,{"Matsurika no Kei",T0100EA001A626000,0,L"0100EA001A626000",L"1.0.0"}},// text
{0x80174d4c - 0x80004000,{"Matsurika no Kei",T0100EA001A626000,0,L"0100EA001A626000",L"1.0.0"}},// name
}; };
return 1; return 1;
}(); }();

View File

@ -151,10 +151,9 @@ inline unsigned int convertUTF32ToUTF16(unsigned int cUTF32, unsigned int& h, un
unsigned int ret = ((h << 16) | (l & 0x0000FFFF)); unsigned int ret = ((h << 16) | (l & 0x0000FFFF));
return ret; return ret;
} }
std::wstring utf32_to_utf16(void* data,size_t size){ std::wstring utf32_to_utf16(uint32_t* u32str,size_t size){
std::wstring u16str; std::wstring u16str;
auto u32str=(uint32_t*)data; for(auto i=0;i<size;i++){
for(auto i=0;i<size/sizeof(uint32_t);i++){
unsigned h,l; unsigned h,l;
convertUTF32ToUTF16(u32str[i],h,l); convertUTF32ToUTF16(u32str[i],h,l);
if(h) if(h)
@ -176,7 +175,7 @@ size_t u32strlen(uint32_t* data){
std::optional<std::wstring> commonparsestring(void* data,size_t length,void* php,DWORD df){ std::optional<std::wstring> commonparsestring(void* data,size_t length,void* php,DWORD df){
auto hp=(HookParam*)php; auto hp=(HookParam*)php;
if (hp->type & CODEC_UTF16) return std::wstring((wchar_t*)data, length / sizeof(wchar_t)); if (hp->type & CODEC_UTF16) return std::wstring((wchar_t*)data, length / sizeof(wchar_t));
else if(hp->type&CODEC_UTF32)return (std::move(utf32_to_utf16(data,length))); else if(hp->type&CODEC_UTF32)return (std::move(utf32_to_utf16((uint32_t*)data,length/ sizeof(uint32_t))));
else if (auto converted = StringToWideString(std::string((char*)data, length), (hp->type&CODEC_UTF8)?CP_UTF8:(hp->codepage ? hp->codepage :df))) return (converted.value()); else if (auto converted = StringToWideString(std::string((char*)data, length), (hp->type&CODEC_UTF8)?CP_UTF8:(hp->codepage ? hp->codepage :df))) return (converted.value());
else return {}; else return {};
} }

View File

@ -22,7 +22,7 @@ bool startWith(const std::wstring& s,const std::wstring &s2);
bool endWith(const std::string& s,const std::string& s2); bool endWith(const std::string& s,const std::string& s2);
bool endWith(const std::wstring& s,const std::wstring& s2); bool endWith(const std::wstring& s,const std::wstring& s2);
std::wstring utf32_to_utf16(void* data,size_t size); std::wstring utf32_to_utf16(uint32_t* u32str,size_t size);
std::string WideStringToString(const std::wstring& text,UINT cp=CP_UTF8); std::string WideStringToString(const std::wstring& text,UINT cp=CP_UTF8);
std::wstring StringToWideString(const std::string& text); std::wstring StringToWideString(const std::string& text);
std::optional<std::wstring> StringToWideString(const std::string& text, UINT encoding); std::optional<std::wstring> StringToWideString(const std::string& text, UINT encoding);