How is the .pbo file formed?

WrpTool island creator utility

Moderators: Lone Wolf, Snake Man

Post Reply
jaakko
Newbie
Posts: 3
Joined: 2004-10-18 05:12:14

How is the .pbo file formed?

Post by jaakko » 2004-10-18 00:20:52

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

If i open a pbo (in notepad) 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. :'(

Dschulle
Captain
Posts: 162
Joined: 2003-05-18 02:00:14
Contact:

Re: How is the .pbo file formed?

Post by Dschulle » 2004-10-18 15:58:08

Are you trying to modify the script direct inside the pbo  :o
Don't do so  ;)
Use one of the exisiting tools to depbo (PboX for example). Modify the script(s) and pbo the whole directory again.

If you are interested in the structure of pbo's look @ Ofpec.com or find pboTool which includes source code for uncompressed pbo's.
Last edited by Dschulle on 1970-01-01 00:00:00, edited 1 time in total.

jaakko
Newbie
Posts: 3
Joined: 2004-10-18 05:12:14

Re: How is the .pbo file formed?

Post by jaakko » 2004-10-19 22:08:54

Yeah, i was interested in the latter.
I did find that doc at ofpec, and now i have made my own pbotool in java. :)

User avatar
joekidds
Recruit
Posts: 49
Joined: 2004-03-13 21:12:12
Contact:

Re: How is the .pbo file formed?

Post by joekidds » 2004-10-20 04:52:45

thats pretty cool
I uploaded the PMC Fury Radio voices, missions 1-53! get it here: http://www.freewebs.com/joekidds/pmcfuryradio1-11.rar (11mb)

VTE moddb profile:
http://mods.moddb.com/5240/

Mike
1st Lt
Posts: 146
Joined: 2003-04-05 05:36:13
Contact:

Re: How is the .pbo file formed?

Post by Mike » 2005-05-10 05:49:55

i have made my own pbotool in java.
jaakko is there any chance you can turn that into a dll or applet that I could access via visual basic? I don't want to go down the STL template tunnel.

jaakko
Newbie
Posts: 3
Joined: 2004-10-18 05:12:14

Re: How is the .pbo file formed?

Post by jaakko » 2005-05-10 06:38:18

I can give you the Java source if you want.
Im not sure how to turn it into a dll bundle, if you give me advice on that mybe i can do it as well...

jaakko
Newbie
Posts: 3
Joined: 2004-10-18 05:12:14

Re: How is the .pbo file formed?

Post by jaakko » 2005-05-10 06:49:39

Code: Select all

<br>/*<br> *  PBOWizard<br> *  Created on Oct 17, 2004 by Jaakko Holopainen<br> *<br> * This code is written based on the pbo fileformat description by OFPInternals<br> * It can be found at www.ofpec.com , but it is so short that i will include it here in the comments.<br> *<br>  ------------------------------------------------------------------------------------------------------------<br>       Pbo file format description by OFPInternals<br><br>      (495 total words in this text)<br>      (48 Reads)<br><br><br>      PBO - Program Bank (I don't know what is it 'O'. May be "Objects"? May be old version of OFP uses pbo for p3d-models storage?). OFP load all files in directory %flashpoint%\\DTA by mask '*.pb?'. I.e. it will be *.pbo, *.pbx, *.pb_ etc.<br><br>      File contains Files Description Table (FDT) and Raw Data (RD, or File Stream). FDT contains entries for each file in archive (bank). Last entry is empty.<br><br>      Look at the FDT entry:<br><br>      struct FDTEntry {<br>      NullTerminatedString FileName;<br>      s4 PackMethod;<br>      s4 OriginalSize;<br>      s4 ReservedForInternalUse;<br>      s4 DataTimeStamp;<br>      s4 Size;<br>      };<br><br>      Here:<br>      - FileName: the file name. Last entry have empty string ('\\0' char only). Other fields in last entry is filled by zero bytes.<br>      - PackMethod: 0x0 - not packed, 0x43707273 - packed by mission editor.<br>      - OriginalSize: 0x0 - if file not packed or size of unpacked (origianal) file;<br>      - ReservedForInternalUse: must be always 0x0.<br>      - DataTimeStamp: last write filetime. It is the difference, measured in seconds (not the milliseconds!), between the datetime of file modification and the standard base time known as "the epoch," 00:00:00 GMT on January 1, 1970. In case of overflow/underflow this field mast be -1 (0xffffffff). Some of tools write here 0x0. It's wrong.<br>      - Size: file stream size in folowing raw data. Same for packed and unpacked files.<br><br>      Raw Data begins after last FDT entry (empty entry). Seek position of selected file is calculates by adding sizes of files in the all previous entries in FDT.<br><br>      Packed files contains packed data and 4-bytes of sheck sum for unpack verifying.<br><br>      Notes 1: Some of tools (like StuffPbo) write its copyright data after RawData. Is it good? WrpEdit and other tool show warning message "waste data detected" when pbo file like this will be loaded. May be in the next version of OFP pb-file format will contains some extra data at the end of file (after Raw Data), end this stuffpbo-files will not reads correctly.<br><br>      Notes 2: Your pb-extracting tool must always unpack packed files directly when you extract it from archive. Instead of use util like unpack-sqm.exe after.<br><br>      Notes 3: Files like config.bin, mission.sqm from campaign not packed! It's just binary representation of class. See additional info abount binary files in the old forum topic.<br><br>      P.S. Notation:<br><br>      s1 - signed 8-bit<br>      s2 - signed 16-bit<br>      s4 - signed 32-bit<br>      u1 - unsigned 8-bit<br>      u2 - unsigned 16 -bit<br>      u4 - unsigned 32-bit<br>      float - single precision float, 32-bit<br>      double - double precision float, 64-bit<br>      NullTerminatedString - array of char with zero byte at the end.<br>  ------------------------------------------------------------------------------------------------------------<br> *<br> *<br> */<br><br>package pbo;<br><br>import java.io.*;<br><br>/**<br> * @author Jaakko Holopainen<br> */<br>public class PBOWizard {<br><br>    private File pbofile;<br>    private File sourcedir;<br><br>    private DataOutputStream dout;<br>    private DataInputStream din;<br><br>    public PBOWizard() {}<br><br>    public void makePbo(File f, File dir) {<br>        pbofile = f;<br>        sourcedir = dir;<br><br>        try {<br>            dout = new DataOutputStream(new FileOutputStream(f));<br>        } catch (FileNotFoundException e) { e.printStackTrace(); }<br><br>        if (dout != null) {<br>            if (sourcedir.isDirectory()) {<br>                File[] files = sourcedir.listFiles();<br><br>                try {<br>                      for (int i = 0; i < files.length; i++) {<br>                        din = new DataInputStream(new FileInputStream(files[i]));<br><br>                          FDTEntry entry = new FDTEntry();<br>                          entry.fileName = (files[i].getName() + "\0").toCharArray();<br>                          entry.packMethod = 0x0;<br>                          entry.originalSize = 0x0;<br>                          entry.reservedForInternalUse = 0x0;<br>                          entry.dataTimeStamp = (int)(System.currentTimeMillis() / 1000);<br>                          entry.size = din.available();<br><br>                          din.close();<br><br>                          // write out to pbo<br>                          for (int j = 0; j < entry.fileName.length; j++)<br>                              dout.writeByte(entry.fileName[j]);<br>                          dout.writeInt(entry.packMethod);<br>                          dout.writeInt(entry.originalSize);<br>                          dout.writeInt(entry.reservedForInternalUse);<br>                          dout.writeInt(entry.dataTimeStamp);<br>                          dout.writeInt(entry.size);<br>                      }<br>                      FDTEntry entry = new FDTEntry();<br>                      // write out to pbo<br>                      for (int j = 0; j < entry.fileName.length; j++)<br>                          dout.writeByte(entry.fileName[j]);<br>                      dout.writeInt(entry.packMethod);<br>                      dout.writeInt(entry.originalSize);<br>                      dout.writeInt(entry.reservedForInternalUse);<br>                      dout.writeInt(entry.dataTimeStamp);<br>                      dout.writeInt(entry.size);<br><br>                      // proceed with writing the data itself<br><br>                      for (int i = 0; i < files.length; i++) {<br>                          din = new DataInputStream(new FileInputStream(files[i]));<br><br>                          byte[] b = new byte[din.available()];<br>                          din.readFully(b);<br><br>                             dout.write(b, 0, b.length);<br><br>                             din.close();<br>                      }<br>                }<br>                catch (FileNotFoundException e) { e.printStackTrace(); }<br>                catch (IOException e) { e.printStackTrace(); }<br>            }<br>            try {<br>                dout.close();<br>            } catch (IOException e) { e.printStackTrace(); }<br>        }<br>    }<br><br>    public static void main(String[] args) {<br>        // take arguments to filename and sourcedirectory<br>        if (args.length == 3) {<br>            if (args[0].equals("-c")) {<br>                File target = new File(args[1]);<br>                File source = new File(args[2]);<br>                PBOWizard wiz = new PBOWizard();<br>                wiz.makePbo(target,source);<br>            } else {<br>                System.out.println("Unknown command " + args[0]);<br>            }<br>        } else {<br>            System.out.println("PBOWizard");<br>            System.out.println("Create pbo: java PBOWizard -c [target] [source directory]");<br>        }<br>    }<br>}<br><br>class FDTEntry {<br>    char[] fileName = {'\0'};<br>    int packMethod = 0x0;<br>    int originalSize = 0x0;<br>    int reservedForInternalUse = 0x0;<br>    int dataTimeStamp = 0x0;<br>    int size = 0x0;<br>}<br>

Mike
1st Lt
Posts: 146
Joined: 2003-04-05 05:36:13
Contact:

Re: How is the .pbo file formed?

Post by Mike » 2005-05-10 22:03:41

ahh bum. Your source is great, but in the opposite direction to what I want, grrrrrrrrrrrrr

Will have a look and if I get a dll out of this will keep you posted, thank you for this.

Edit:

have sent this thru to OFPEC and credited you as the source
Last edited by Mike on 1970-01-01 00:00:00, edited 1 time in total.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests