Thread: Reading in hex values from a specific segment and offset.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    100

    Reading in hex values from a specific segment and offset.

    Hi all,

    If I wanted to read in the hex values found at a specific point in a binary file, how would i go about doing this? Would it need to be converted to decimal or binary? This is what ive got so far

    Code:
    	char beh[11];
    	ifstream updatedat("c:/sol.exe", ios::hex | ios::in);
    	updatedat.seekg(10,ios::end);
    	updatedat.read(beh,10);
    	MessageBox(NULL,beh,"here it is", MB_OK);
    	updatedat.close();
    Im trying to read in 10 hex values and store them in the char array beh. I set seekg to 10 as this is the position that i want to start reading from.

    When the MessageBox pops up it shows strange characters where as my hex editor shows it in hex (obviously).

    Is the code correct but the problem being the hex stored in the char array? If so then how should i store it to show the actual hex values rather than symbols?

    Thanks

    Thanks
    Last edited by cloudy; 01-23-2006 at 05:11 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Relocation in .obj -files
    By willkoh in forum C++ Programming
    Replies: 6
    Last Post: 04-06-2005, 01:59 PM