-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
makipl
committed
Jun 21, 2022
1 parent
0d54bb6
commit 313aea6
Showing
2 changed files
with
55 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,45 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <sstream> | ||
#include <vector> | ||
#include <iterator> | ||
#include <windows.h> | ||
#include <filesystem> | ||
|
||
int main() | ||
{ | ||
HMODULE mod= LoadLibraryA("FFVIII_JP.dll"); | ||
FARPROC prc = GetProcAddress(mod, "runGame"); | ||
prc(); | ||
std::filesystem::path pt("FFVIII.exe"); | ||
if(!std::filesystem::exists(pt)) | ||
{ | ||
MessageBoxW(NULL, L"FFVIII.exe ファイルが見つかりません", | ||
L"エラー", MB_OK); | ||
return ERROR_FILE_NOT_FOUND; | ||
} | ||
std::ifstream ifs; | ||
ifs.open(L"FFVIII.exe", std::ios::binary | std::ios::in); | ||
if(!ifs.is_open()) | ||
{ | ||
MessageBoxW(NULL, L"FFVIII.exe ファイルは存在しますが開けません", | ||
L"エラー", MB_OK); | ||
return ERROR_FILE_CORRUPT; | ||
} | ||
|
||
std::vector<unsigned char> buffer; | ||
buffer.assign(std::istreambuf_iterator<char>(ifs), | ||
std::istreambuf_iterator<char>()); | ||
|
||
ifs.close(); | ||
|
||
buffer[0x94B] = 0x89; | ||
buffer[0x94B+1] = 0xC8; | ||
buffer[0x94B+2] = 0x90; | ||
|
||
std::ofstream ofs; | ||
ofs.open(L"FFVIII_JP.exe", std::ios::binary | std::ios::out | std::ios::trunc); | ||
ofs.write((const char*) & buffer[0], buffer.size()); | ||
ofs.close(); | ||
|
||
MessageBoxW(NULL, L"やった! パッチは「FFVIII_JP.exe」という名前の新しいファイルを作成しました. ファイルを実行してみてください", L"YATTA!", MB_OK); | ||
|
||
return 0; | ||
} |