I want to be able to append the raw data value '1' to the end of the exe file "c:/test.exe". Then i want the test.exe file when it is run to output the following message "hello world, the value is 1." If the raw data value was then edited to '2' the test.exe file when ran would say "hello world, the value is 2".
This is the coding for the editing program so far (this isnt the test.exe code).
It compiles fine, but when ran it crashes. Whats wrong? Also how would i go about coding the test.exe file so it reads the the value 1 from the end of itself?Code:fstream binary_file2("c:/test.exe",ios::binary|ios::in); int length; binary_file2.seekg (0, ios::end); length = binary_file2.tellg(); binary_file2.seekg (0, ios::beg); char * FileBuf = new char[length]; binary_file2.read (FileBuf, length); length += 4; //this is to accomodate for the below line int temp = 1; FileBuf = (char *)realloc( FileBuf, length ); memcpy(FileBuf, reinterpret_char<char *>(temp), 4); binary_file2.write(FileBuf, length); binary_file2.close();