Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Nov 26, 2023
0 parents commit 426db11
Show file tree
Hide file tree
Showing 175 changed files with 1,200,236 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dump/build
sc3tools-main/target
sc3tools-main_pack/target
unpack/vMES
unpack/vTXT
unpack/vTXTu8
pack/CriPakTools-master/.vs
pack/CriPakTools-master/CriPakTools/bin
pack/CriPakTools-master/CriPakTools/obj
patch/build
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
この世の果てで恋を唄う少女YU-NO

移植汉化,未汉化部分(10%左右)用机翻补全

<img src="effect.jpg">
77 changes: 77 additions & 0 deletions dump/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"files.associations": {
"iosfwd": "cpp",
"istream": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iostream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"memory": "cpp",
"new": "cpp",
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocinfo": "cpp",
"xlocnum": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xutility": "cpp",
"string": "cpp",
"vector": "cpp",
"algorithm": "cpp",
"array": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"deque": "cpp",
"filesystem": "cpp",
"format": "cpp",
"forward_list": "cpp",
"functional": "cpp",
"iomanip": "cpp",
"list": "cpp",
"locale": "cpp",
"mutex": "cpp",
"optional": "cpp",
"ratio": "cpp",
"regex": "cpp",
"sstream": "cpp",
"stop_token": "cpp",
"thread": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"xhash": "cpp",
"xlocbuf": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xloctime": "cpp",
"xtree": "cpp",
"xmemory0": "cpp"
}
}
11 changes: 11 additions & 0 deletions dump/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.16)

project(dump)


add_executable(injector injector.cpp)

include_directories(.)
add_library(dumper MODULE dumper.cpp )

target_link_libraries(dumper )
201 changes: 201 additions & 0 deletions dump/dumper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
#include <Windows.h>
#include<vector>
#include<string>
#include<fstream>
//signed int __thiscall sub_71901720(_DWORD *this, int a2, int a3, int a4, signed int a5)
//int __usercall sub_719043E0@<eax>(int a1@<ebx>, const CHAR *lpMultiByteStr, CHAR *a3, int cbMultiByte, char a5)

typedef signed int (*sub_71901720_t)(DWORD *thisptr, int a2, int a3, int a4, signed int a5);
typedef int (*sub_719043E0_t)(int a1 , const CHAR *lpMultiByteStr, CHAR *a3, int cbMultiByte, char a5);
auto sub_71901720=(sub_71901720_t)((DWORD)GetModuleHandleW(L"AI5CHS.DLL")+0x1720);
auto sub_719043E0=(sub_719043E0_t)((DWORD)GetModuleHandleW(L"AI5CHS.DLL")+0x43E0);
auto dword_71908894=(DWORD)GetModuleHandleW(L"AI5CHS.DLL")+0x8894;

std::vector<std::string> strSplit(const std::string& s, const std::string delim)
{
std::string item;
std::vector<std::string> tokens;

// Copy the input string so that we can modify it
std::string str = s;

size_t pos = 0;
while ((pos = str.find(delim)) != std::string::npos) {
item = str.substr(0, pos);
tokens.push_back(item);
str.erase(0, pos + delim.length());
}
tokens.push_back(str);

return tokens;
}
std::wstring StringToWideString(const std::string& text, UINT encoding)
{
std::vector<wchar_t> buffer(text.size() + 1);

if (int length = MultiByteToWideChar(encoding, 0, text.c_str(), text.size() + 1, buffer.data(), buffer.size()))
return std::wstring(buffer.data(), length - 1);
return {};

}
std::string WideStringToString(const std::wstring& text,UINT cp=CP_UTF8)
{
std::vector<char> buffer((text.size() + 1) * 4);

WideCharToMultiByte(cp, 0, text.c_str(), -1, buffer.data(), buffer.size(), nullptr, nullptr);
return buffer.data();
}
int sub_71432530(unsigned __int8 *a1, char *Buffer)
{
return sprintf(
Buffer,
"//%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02"
"X%02X%02X%02X%02X%02X",
*a1,
a1[1],
a1[2],
a1[3],
a1[4],
a1[5],
a1[6],
a1[7],
a1[8],
a1[9],
a1[10],
a1[11],
a1[12],
a1[13],
a1[14],
a1[15],
a1[16],
a1[17],
a1[18],
a1[19],
a1[20],
a1[21],
a1[22],
a1[23],
a1[24],
a1[25],
a1[26],
a1[27],
a1[28],
a1[29],
a1[30],
a1[31]);
}

BOOL WINAPI DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
//#define ALL
#ifndef ALL
std::ifstream ifs(R"(C:\Users\wcy\Documents\GitHub\YU-NO-Re\unpack\vunknown.txt)");
std::ifstream getfrommes(R"(C:\Users\wcy\Documents\GitHub\YU-NO-Re\unpack\vprefix.txt)");
std::ofstream ofs(R"(C:\Users\wcy\Documents\GitHub\YU-NO-Re\unpack\vtext_trans2.txt)");
#else
std::ifstream ifs(R"(C:\Users\wcy\Documents\GitHub\YU-NO-Re\unpack\vtext.txt)");
std::ifstream getfrommes(R"(C:\Users\wcy\Documents\GitHub\YU-NO-Re\unpack\vprefix.txt)");
std::ofstream ofs(R"(C:\Users\wcy\Documents\GitHub\YU-NO-Re\unpack\vtext_trans.txt)");
#endif
std::string content((std::istreambuf_iterator<char>(ifs)),
(std::istreambuf_iterator<char>()));
std::string content_getfrommes((std::istreambuf_iterator<char>(getfrommes)),
(std::istreambuf_iterator<char>()));
auto strings=strSplit(content,"\n");
auto strings_getfrommes=strSplit(content_getfrommes,"\n");
for(auto u8str:strings){
if(u8str.size()==0)continue;
auto u16str=StringToWideString(u8str,65001);
auto shiftjisstr=WideStringToString(u16str,932);
wchar_t WideCharStr[1000];
CHAR MultiByteStr[1568];
auto v8 = u8str.size();
int ok=0;

//这个后缀跟在shiftjis原句后面,理论上和vMES相同,然而存在部分无法对应。
ofs.write(u8str.c_str(),u8str.size());
ofs.write("\n",1);
auto prefix="//000D0BFF000D0AFF0202FF0205A000FF0206A000FF0207A000FF0208A000FF00";
strcpy(MultiByteStr,u8str.c_str());
strcat(MultiByteStr,prefix);
auto arg3=strlen(MultiByteStr);
int reteax;
__asm{
mov ecx,dword_71908894
mov ecx, [ecx]
mov eax, [ecx]
mov eax, [eax+0Ch]
push 620h
lea edx,MultiByteStr
push edx
push arg3
lea edx,MultiByteStr
push edx
call eax
mov reteax,eax
}

if(reteax>=0){
ofs.write(MultiByteStr,reteax);
ok=1;
}
else{
std::string u8str1="\xe3\x80\x91\xef\xbc\x88\xe7\x9b\xae\xe3\x81\xae\xe5\x89\x8d\xe3\x81\xab\xe3\x81\xaf\xe3\x82\xa2\xe3\x83\x9e\xe3\x83\xb3\xe3\x83\x80\xe3\x81\xa3\xe3\x81\xa6\xe5\xa5\xb3\xe6\x80\xa7\xe3\x81\x8c\xe3\x81\x84\xe3\x82\x8b\xe2\x80\xa5\xe2\x80\xa5\xe3\x80\x82\xef\xbc\x89";

for(int i=0;i<strings_getfrommes.size();i++){
if(strings_getfrommes[i]==u8str){
// if(u8str==u8str1)
// MessageBoxA(0,u8str1.c_str(),"",0);
for(int j=i+1;strings_getfrommes[j].size()&&(strings_getfrommes[j][0]=='/');j++){
auto prefix=strings_getfrommes[j].c_str();

strcpy(MultiByteStr,u8str.c_str());
strcat(MultiByteStr,prefix);
auto arg3=strlen(MultiByteStr);
int reteax;
__asm{
mov ecx,dword_71908894
mov ecx, [ecx]
mov eax, [ecx]
mov eax, [eax+0Ch]
push 620h
lea edx,MultiByteStr
push edx
push arg3
lea edx,MultiByteStr
push edx
call eax
mov reteax,eax
}
// if(u8str==u8str1)
// MessageBoxA(0,prefix,std::to_string(reteax).c_str(), 0);
if(reteax>=0){
ofs.write(MultiByteStr,reteax);
ok=1;
break;
}
}
break;

}
}
}
if(ok==0){
ofs.write("UNKNOWN",strlen("UNKNOWN"));
}
ofs.write("\n\n",2);
//MessageBoxW(0,StringToWideString(MultiByteStr,65001).c_str(),std::to_wstring(reteax).c_str(),0);


}
ofs.close();
}
break;

return TRUE;
}
}
80 changes: 80 additions & 0 deletions dump/injector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include <Windows.h>
#include<iostream>
BOOL InjectDLL(DWORD dwProcessId, const char* pszDLLPath)
{
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
if (hProcess == NULL)
{
return FALSE;
}

LPVOID pRemoteBuf = VirtualAllocEx(hProcess, NULL, strlen(pszDLLPath) + 1, MEM_COMMIT, PAGE_READWRITE);
if (pRemoteBuf == NULL)
{
CloseHandle(hProcess);
return FALSE;
}

if (!WriteProcessMemory(hProcess, pRemoteBuf, (LPVOID)pszDLLPath, strlen(pszDLLPath) + 1, NULL))
{
VirtualFreeEx(hProcess, pRemoteBuf, 0, MEM_RELEASE);
CloseHandle(hProcess);
return FALSE;
}

HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
LPTHREAD_START_ROUTINE pfnThreadProc = (LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32, "LoadLibraryA");
if (pfnThreadProc == NULL)
{
VirtualFreeEx(hProcess, pRemoteBuf, 0, MEM_RELEASE);
CloseHandle(hProcess);
return FALSE;
}

HANDLE hRemoteThread = CreateRemoteThread(hProcess, NULL, 0, pfnThreadProc, pRemoteBuf, 0, NULL);
if (hRemoteThread == NULL)
{
VirtualFreeEx(hProcess, pRemoteBuf, 0, MEM_RELEASE);
CloseHandle(hProcess);
return FALSE;
}

WaitForSingleObject(hRemoteThread, INFINITE);

VirtualFreeEx(hProcess, pRemoteBuf, 0, MEM_RELEASE);
CloseHandle(hRemoteThread);
CloseHandle(hProcess);

return TRUE;
}
#include<string>
#include <tlhelp32.h>

DWORD GetProcessIdByName(const char* processName) {
DWORD processId = 0;
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (snapshot != INVALID_HANDLE_VALUE) {
PROCESSENTRY32 processEntry;
processEntry.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(snapshot, &processEntry)) {
do {
if (strcmp(processEntry.szExeFile, processName) == 0) {
processId = processEntry.th32ProcessID;
break;
}
} while (Process32Next(snapshot, &processEntry));
}
CloseHandle(snapshot);
}
return processId;
}

int main(int argc)
{

const char* pszDLLPath = R"(C:\Users\wcy\Documents\GitHub\YU-NO-Re\dump\build\Debug\dumper.dll)";
auto pid=GetProcessIdByName("AI5CHS.EXE");
std::cout<<InjectDLL(pid, pszDLLPath);

return 0;
}
Binary file added effect.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 426db11

Please sign in to comment.