Jump to content
Sign in to follow this  
jaakko

How is the .pbo file formed?

Recommended Posts

Im sure someone can ansver this question since so many PBO-tools have been developed.

If i open a pbo (in notepad or hexedit) containing a simple script file, i see that the pbo contains the name of the scriptfile and the contents of the script as well as a few hexadecimal characters. If i now edit it a bit extending the script for example with one line the script execution in OFP terminates too early. Is some of those hexes for telling the length of the file?

Plz anybody who knows this thing tell me.

Share this post


Link to post
Share on other sites

You actually want to look at a PBO in notepad? That takes a lot of courage and tolerance for jibberish.

Share this post


Link to post
Share on other sites

Hehe, no i was just trying to figure it out and the notepad was my first view into it, hexedit after that.

Well anyway thanks to the document at OFPEC i got it all clear and was able to make a PBO-tool in Java.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

public class PBOWizard {

private File pbofile;

private File sourcedir;

private DataOutputStream dout;

private DataInputStream din;

public PBOWizard() { }

public void makePbo(File f, File dir) {

pbofile = f;

sourcedir = dir;

try {

dout = new DataOutputStream(new FileOutputStream(f));

} catch (FileNotFoundException e) { e.printStackTrace(); }

if (dout != null) {

if (sourcedir.isDirectory()) {

File[] files = sourcedir.listFiles();

try {

for (int i = 0; i < files.length; i++) {

din = new DataInputStream(new FileInputStream(files));

FDTEntry entry = new FDTEntry();

entry.fileName = (files.getName() + "\0").toCharArray();

entry.packMethod = 0x0;

entry.originalSize = 0x0;

entry.reservedForInternalUse = 0x0;

entry.dataTimeStamp = (int)(System.currentTimeMillis() / 1000);

entry.size = din.available();

din.close();

// write out to pbo

for (int j = 0; j < entry.fileName.length; j++)

dout.writeByte(entry.fileName[j]);

dout.writeInt(entry.packMethod);

dout.writeInt(entry.originalSize);

dout.writeInt(entry.reservedForInternalUse);

dout.writeInt(entry.dataTimeStamp);

dout.writeInt(entry.size);

}

FDTEntry entry = new FDTEntry();

// write out to pbo

for (int j = 0; j < entry.fileName.length; j++)

dout.writeByte(entry.fileName[j]);

dout.writeInt(entry.packMethod);

dout.writeInt(entry.originalSize);

dout.writeInt(entry.reservedForInternalUse);

dout.writeInt(entry.dataTimeStamp);

dout.writeInt(entry.size);

/*

* ------------------------------------

* proceed with writing the data itself

* ------------------------------------

*/

for (int i = 0; i < files.length; i++) {

din = new DataInputStream(new FileInputStream(files));

byte[] b = new byte[din.available()];

din.readFully(b);

dout.write(b, 0, b.length);

din.close();

}

}

catch (FileNotFoundException e) { e.printStackTrace(); }

catch (IOException e) { e.printStackTrace(); }

}

try {

dout.close();

} catch (IOException e) { e.printStackTrace(); }

}

}

}

class FDTEntry {

char[] fileName = {'\0'};

int packMethod = 0x0;

int originalSize = 0x0;

int reservedForInternalUse = 0x0;

int dataTimeStamp = 0x0;

int size = 0x0;

}

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×