Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include "SHA1.h"
- using namespace std;
- /* 00000136 */ char patch1[1] = {0x22};
- /* 00000148 */ char patch2[3] = {0x20, 0xA6, 0x07};
- /* 00000178 */ char patch3[3][3] =
- {
- // {0xB6, 0x75, 0xFD}, {0x00, 0x41, 0xFD}, {0x8D, 0xBE, 0xFC},
- {0x3E, 0xF9, 0xFC}, {0x88, 0xC4, 0xFC}, {0x15, 0x43, 0xFD}
- };
- /* 00F57277 */ char patch4[6] = {0xE8, 0x04, 0xFD, 0x06, 0x00, 0x90};
- /* 00F57385 */ char patch5[5] = {0xE9, 0x56, 0xFC, 0x06, 0x00};
- /* 00FC6F80 */ char patch6[149] =
- {
- 0x90, 0x50, 0x50, 0x8B, 0xC4, 0x50, 0xB8, 0x40,
- 0x00, 0x00, 0x00, 0x50, 0xB8, 0x04, 0x00, 0x00,
- 0x00, 0x50, 0x8B, 0x85, 0x0C, 0xFC, 0xFF, 0xFF,
- 0x05, 0x0C, 0x02, 0x00, 0x00, 0x50, 0xFF, 0x55,
- 0x9C, 0x8B, 0x85, 0x0C, 0xFC, 0xFF, 0xFF, 0x05,
- 0x0C, 0x02, 0x00, 0x00, 0xC6, 0x00, 0x74, 0x8B,
- 0xC4, 0x50, 0x8B, 0x44, 0x24, 0x04, 0x50, 0xB8,
- 0x04, 0x00, 0x00, 0x00, 0x50, 0x8B, 0x85, 0x0C,
- 0xFC, 0xFF, 0xFF, 0x05, 0x0C, 0x02, 0x00, 0x00,
- 0x50, 0xFF, 0x55, 0x9C, 0x58, 0x58, 0xFF, 0xA5,
- 0x0C, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x50, 0x68, 0x00, 0xA6, 0x47, 0x01, 0xFF, 0x15,
- 0xB0, 0xF0, 0xFD, 0x00, 0x58, 0x5D, 0x5F, 0x5E,
- 0x5A, 0x59, 0x5B, 0xFF, 0xE0, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x6E, 0x76, 0x73, 0x65, 0x5F, 0x73, 0x74, 0x65,
- 0x61, 0x6D, 0x5F, 0x6C, 0x6F, 0x61, 0x64, 0x65,
- 0x72, 0x2E, 0x64, 0x6C, 0x6C
- };
- /* 00FC7020 */ char patch7[39] =
- {
- 0x60, 0x68, 0xC8, 0xA6, 0x47, 0x01, 0x68, 0xE0,
- 0xA6, 0x47, 0x01, 0xFF, 0x15, 0xF4, 0xF1, 0xFD,
- 0x00, 0x68, 0xC8, 0xA6, 0x47, 0x01, 0x68, 0xD0,
- 0xA6, 0x47, 0x01, 0xFF, 0x15, 0xF4, 0xF1, 0xFD,
- 0x00, 0x61, 0xE9, 0xA7, 0xEC, 0xF8, 0xFF
- };
- /* 00FC70C8 */ char patch8[3][4] =
- {
- {0x32, 0x32, 0x33, 0x38},
- {0x32, 0x32, 0x33, 0x38},
- {0x32, 0x32, 0x34, 0x39}
- };
- /* 00FC70CC */ char patch9[31] =
- {
- 0x30, 0x00, 0x00, 0x00, 0x53, 0x74, 0x65, 0x61,
- 0x6D, 0x41, 0x70, 0x70, 0x49, 0x64, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x53, 0x74, 0x65, 0x61,
- 0x6D, 0x47, 0x61, 0x6D, 0x65, 0x49, 0x64
- };
- /* 00000148 */ char patchG1[3] = {0x90, 0xE5, 0xBD};
- /* 00000178 */ char patchG2[3] = {0xD0, 0x4B, 0xF6};
- /* 00BDD990 */ char patchG3[37] =
- {
- 0x68, 0xA0, 0xE5, 0xFD, 0x00, 0xFF, 0x15, 0xB0,
- 0xF0, 0xFD, 0x00, 0xE9, 0x3B, 0xDF, 0xEE, 0xFF,
- 0x6E, 0x76, 0x73, 0x65, 0x5F, 0x73, 0x74, 0x65,
- 0x61, 0x6D, 0x5F, 0x6C, 0x6F, 0x61, 0x64, 0x65,
- 0x72, 0x2E, 0x64, 0x6C, 0x6C
- };
- void applyPatch(char* data, unsigned long offset, char* patch, unsigned short length)
- {
- for(int i = 0; i < length; i++) data[offset + i] = patch[i];
- }
- int main(int argc, char** argv)
- {
- ifstream ifile;
- ofstream ofile;
- unsigned short version = 5;
- ifile.open("FalloutNV.exe", ios::binary);
- if(ifile.good())
- {
- CSHA1 filehash;
- char hash[41] = {};
- filehash.HashFile("FalloutNV.exe");
- filehash.Final();
- filehash.ReportHash(hash, CSHA1::REPORT_HEX_SHORT);
- if(!strcmp(hash, "D068F394521A67C6E74FE572F59BD1BE71E855F3")) version = 0;
- if(!strcmp(hash, "3980940522F0264ED9AF14AEA1773BB19F5160AB")) version = 1;
- if(!strcmp(hash, "5394B94A18FFA6FA846E1D6033AD7F81919F13AC")) version = 2;
- if(!strcmp(hash, "07AFFDA66C89F09B0876A50C77759640BC416673")) version = 0;
- if(!strcmp(hash, "F65049B0957D83E61ECCCACC730015AE77FB4C8B")) version = 1;
- if(!strcmp(hash, "ACA83D5A12A64AF8854E381752FE989692D46E04")) version = 2;
- if(!strcmp(hash, "946D2EABA04A75FF361B8617C7632B49F1EDE9D3")) version = 3;
- if(version == 5)
- {
- if( !strcmp(hash, "0021023E37B1AF143305A61B7B29A1811CC7C5FB") ||
- !strcmp(hash, "37CAE4E713B6B182311F66E31668D5005D1B9F5B") ||
- !strcmp(hash, "600CD576CDE7746FB2CD152FDD24DB97453ED135") ||
- !strcmp(hash, "34B65096CAEF9374DD6AA39AF855E43308B417F2"))
- cout << "FalloutNV.exe is already patched!" << endl;
- else cout << "INVALID EXE VERSION: " << hash << endl;
- system("pause");
- return 1;
- }
- streampos len = 0;
- len = ifile.tellg();
- ifile.seekg(0, ios::end);
- len = ifile.tellg() - len;
- cout << "Patching FalloutNV.exe [" << (version == 3 ? "GOG" : version == 2 ? "RU" : version == 1 ? "DE" : "US") << "]..." << endl;
- char* data = new char[len];
- ifile.seekg(0);
- ifile.read(data, len);
- ifile.close();
- rename("FalloutNV.exe", "FalloutNV_backup.exe");
- if(version == 3)
- {
- applyPatch(data, 0x00000148, patchG1, 3);
- applyPatch(data, 0x00000178, patchG2, 3);
- applyPatch(data, 0x00BDD990, patchG3, 37);
- }
- else
- {
- applyPatch(data, 0x00000136, patch1, 1);
- applyPatch(data, 0x00000148, patch2, 3);
- applyPatch(data, 0x00000178, patch3[version], 3);
- applyPatch(data, 0x00F57277, patch4, 6);
- applyPatch(data, 0x00F57385, patch5, 5);
- applyPatch(data, 0x00FC6F80, patch6, 149);
- applyPatch(data, 0x00FC7020, patch7, 39);
- applyPatch(data, 0x00FC70C8, patch8[version], 4);
- applyPatch(data, 0x00FC70CC, patch9, 31);
- }
- ofile.open("FalloutNV.exe", ios::binary);
- ofile.write(data, len);
- ofile.close();
- cout << "FalloutNV.exe patched!" << endl;
- } else cout << "FalloutNV.exe not found!" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement