Click here to Skip to main content
15,885,880 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I've been playing around with files in C++, i've been reading an XBE (xbox exectuable) into a struct.

I've followed the structure here, which is working pretty well but i'm stuck on the pointer.

http://www.xboxhackz.com/downloads/xbe.pdf

How do i declare that in a struct?

My code so far:
C++
// XBEInfo.cpp : main project file.

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include "time.h"

using namespace std;

struct XBE{
        unsigned long MagicNumber;
        unsigned char DigitalSignature[256];
        unsigned long BaseAddress;
        unsigned long HeaderSize;
        unsigned long ImageSize;
        unsigned long ImageHeaderSize;
        unsigned long DateTimeStamp;
};

int main(){
        XBE info;
        fstream binary_file("c:\\test.xbe", ios::binary|ios::in);
        binary_file.read(reinterpret_cast<char *>(&info), sizeof(XBE));
        binary_file.close();

        cout<< "\nMagic Number: 0x" << hex << (info.MagicNumber) << " - XBEH" <<endl;
        cout<<"Digital Signature: " << info.DigitalSignature << endl;
        cout << "Base Address: 0x" << hex << info.BaseAddress << endl;
        cout << "Header Size: " << info.HeaderSize << " bytes" << endl;
        cout << "Image Size: " << dec << info.ImageSize << " bytes" << endl;
        cout << "Image Header Size: " << info.ImageHeaderSize << " bytes" << endl;
        cout << "Date/Time stamp: " <<  info.DateTimeStamp << endl;
        cout << "Certificate Address: " <<

        return 0;
}
Posted
Updated 2-Apr-10 4:41am
v2

What does "stuck on the pointer" mean?

Nobody is going to look at that pdf file, or go to an external link to look at your code. Put the relevant information into your question, and you'll have a better chance of getting an answer.
 
Share this answer
 
When dealing with executable image files, the term pointer stay for offset from the beginning of the file (note that a value equal to zero is used if the correspondant item is not present inside the image file).
 
Share this answer
 
Change to
int main(){
    XBE info = {0};
    //  ...
    cout << "Certificate Address: " << endl;

    return 0;
}


This compiles and should run OK with a correct file.

However you should first read the MagicNumber and test it against your spec before further reading.

cheers,
AR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900