| | |
Reading/Writing to Executable
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2005
Posts: 4
Reputation:
Solved Threads: 0
Hi everyone. I am working on a project which has to change the value of a variable in the executable. Specifically, writing this program:
I have to go into the executable and change the value of "a" into the executable. Let me not extend this too much, and show you what i have done. At this moment I do not know why this is not working. I am trying to make sure that I am looking at the right place before I try to change the value. Thanks for any help you can give me.
<< moderator edit: added
C++ Syntax (Toggle Plain Text)
int a = -1; int b = 3; int c = a + b;
I have to go into the executable and change the value of "a" into the executable. Let me not extend this too much, and show you what i have done. At this moment I do not know why this is not working. I am trying to make sure that I am looking at the right place before I try to change the value. Thanks for any help you can give me.
C++ Syntax (Toggle Plain Text)
#include<iostream.h> #include<fstream> #include<stdio.h> #include<string> using namespace std; int main() { ifstream myFile; ofstream fout; char temp1; myFile.open("C:/Documents and Settings/Angel/Desktop/Virus/Hex/Debug/Hex.exe"); if ( !myFile ) //(myFile.is_open()) { cout << "File could not be opened.\n"; myFile.close(); } else { myFile.seekg(0x0000158B); //Seeks the positon of variable a in the binary file / executable. myFile.read(temp1,1); cout << "Value is " << temp1 << endl; myFile.close(); } return 0; }
[code][/code] tags >> Last edited by Dave Sinkula; Nov 7th, 2005 at 6:00 pm.
![]() |
Similar Threads
- Reading Binary Files in VB (Visual Basic 4 / 5 / 6)
- Reading or writing a double into a bin file (C++)
- Reading and Writing Data to a File (Visual Basic 4 / 5 / 6)
- Reading binary data from a file and writing it (Visual Basic 4 / 5 / 6)
- Need help with my console database app, program reading or writing incorrectly (C++)
- Read and writing strings from structures (C++)
Other Threads in the C++ Forum
- Previous Thread: Vector of strings (warnings) ? ?
- Next Thread: Default values for STL container function arguments?
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





