S
Son of Sam
Ok what does the program do:
opens a file binary, jumps to an specific offset (0x3529BC9) reads out
the string which is 7 bytes (7 chars) long (which starts at the
offset), then generates a random string 7 char long sting (string
s[7]).
Thats what I was able to do, but now I want to replace this offset by
this random string and write the patched file to back to the file. i
didnt know how do do it with vectors, also this file write operations
were not working the way i wanted it, heres my code:
Ok what does the program do:
opens a file, jumps to an specific offset reads out the string which is
7 bytes or 7 chars long, then generates a random string.
thats what i was able to do but now i want to replace this offset by
this random string and write the patched file to back to the file. i
didnt know how do do it with vectors, also this file write opertions
were not working the way i wanted it, heres my code:
#include <iostream>
#include <fstream>
#include <string>
#include <tchar.h>
#include <stdio.h>
#include <time.h>
#include <ctime>
#include <cstdlib>
#include <sstream>
#include <vector>
using namespace std;
int main(int argc, _TCHAR* argv[])
{
char _string[7];
char _filename[128];
int _offset = 0x3529BC;
if(argc == 1)
{
system("cls");
cout << "\nUsage: patch.exe
[path/filename]\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout << "Enter path and filename to your
FlashpointResistance.exe\n\n";
cout << "(eg. C:/Desktop/ofp.exe): ";
cin >> _filename;
}
else
{
strcpy(_filename, argv[1]);
}
ifstream ofp;
ofp.open(_filename, ios_base::in | ios::binary);
if(!ofp.is_open())
{
system("cls");
cout << "\nResults:\n";
cout << " File \"" << _filename << "\" not found.\n\n";
}
else
{
system("cls");
//##### Create the "random" 7 bytes long string ######
ostringstream os;
os << hex << time(0);
string s = os.str();
s.resize(7);
//###### Read the string[7] at offset 0x3529BC ######
ofp.seekg(_offset, ios::beg);
ofp.read(_string, 7);
ofp.close();
ostringstream os2;
os2 << _string;
string s2 = os2.str();
s2.resize(7);
//##### Prints the results out ##########
cout << "\nFilename: \t\t" << _filename << endl;
cout << "Random Filestring: \t" << s << endl;
cout << "Existing String: \t" << s2 << endl;
//#####Here starts the part where the string is to be replaced and
the file to be saved (overwritten) #####
ifstream ofp;
// ###### here i tryed it somehow with vectors but i have no idead
how #######
std::vector<char> v(0x3529BC);
ofp.read(&v[0],0x3529BC);
}
return 0;
}
opens a file binary, jumps to an specific offset (0x3529BC9) reads out
the string which is 7 bytes (7 chars) long (which starts at the
offset), then generates a random string 7 char long sting (string
s[7]).
Thats what I was able to do, but now I want to replace this offset by
this random string and write the patched file to back to the file. i
didnt know how do do it with vectors, also this file write operations
were not working the way i wanted it, heres my code:
Ok what does the program do:
opens a file, jumps to an specific offset reads out the string which is
7 bytes or 7 chars long, then generates a random string.
thats what i was able to do but now i want to replace this offset by
this random string and write the patched file to back to the file. i
didnt know how do do it with vectors, also this file write opertions
were not working the way i wanted it, heres my code:
#include <iostream>
#include <fstream>
#include <string>
#include <tchar.h>
#include <stdio.h>
#include <time.h>
#include <ctime>
#include <cstdlib>
#include <sstream>
#include <vector>
using namespace std;
int main(int argc, _TCHAR* argv[])
{
char _string[7];
char _filename[128];
int _offset = 0x3529BC;
if(argc == 1)
{
system("cls");
cout << "\nUsage: patch.exe
[path/filename]\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout << "Enter path and filename to your
FlashpointResistance.exe\n\n";
cout << "(eg. C:/Desktop/ofp.exe): ";
cin >> _filename;
}
else
{
strcpy(_filename, argv[1]);
}
ifstream ofp;
ofp.open(_filename, ios_base::in | ios::binary);
if(!ofp.is_open())
{
system("cls");
cout << "\nResults:\n";
cout << " File \"" << _filename << "\" not found.\n\n";
}
else
{
system("cls");
//##### Create the "random" 7 bytes long string ######
ostringstream os;
os << hex << time(0);
string s = os.str();
s.resize(7);
//###### Read the string[7] at offset 0x3529BC ######
ofp.seekg(_offset, ios::beg);
ofp.read(_string, 7);
ofp.close();
ostringstream os2;
os2 << _string;
string s2 = os2.str();
s2.resize(7);
//##### Prints the results out ##########
cout << "\nFilename: \t\t" << _filename << endl;
cout << "Random Filestring: \t" << s << endl;
cout << "Existing String: \t" << s2 << endl;
//#####Here starts the part where the string is to be replaced and
the file to be saved (overwritten) #####
ifstream ofp;
// ###### here i tryed it somehow with vectors but i have no idead
how #######
std::vector<char> v(0x3529BC);
ofp.read(&v[0],0x3529BC);
}
return 0;
}