Change values in .opf file via forms

Hi guys!

I'm working on a small app (script editor) for a game called "The Outforce". This game has a .opf file that contains some kind of cfg files, pictures, .3d model files, and plenty of different extensions such as: .cbaseclass,.unknown,.cweaponunit, cgridmember etc...
but this file (packedproject.opf) also has readable parts, that I can edit with notepad++

I decided to make a form to make file editing faster. Each "strings" in the file have one-two values. For example: "onlysingleplayerunit" "0".

Do you have any idea how to do that? Any suggestions?

I'm looking forward to your help.

What are the first two characters of the file? Are they PK by any chance?

The first line is: Outforce Packed Content & Outforce Base Project O3 Games„ The Outforce Main Project
read the whole thing in in binary, parse out the things you care about, let the user edit them, and put them back in. Do not increase the size of the text, it can only be the same or less, unless very, very careful (youll have to experiment). C-string it, they are likely zero terminated strings in binary. I advise you to do what you want to do with a hex editor, carefully and fully test what you did, and once happy, use the notes you took in this process to write an editor. If you change the file size, there may be things that lost the hard coded position, and it breaks. If you had a zero terminal followed by junk, you may be able to extend but you can't know where the string really ended and data really started after, so that is high risk. Keeping same size or less, these risks go away.

Its unclear what you want to do. do you want to get a list of the variables so you can change values?

Last edited on
I just want to search for "strings" and its values and edit them with a form or with checkbox

For example there's a command: "Cheats" "0" or OnlySinglePlayerBuild 0

I don't know how to turn unreadable characters to readable format, but it isn't important. Each commands, strings have at least 1 values. All strings, commands have its values at the same line.

here's a picture of the file:

edit them: the strings, the values, or both?
it is a BINARY file.
"Cheats" "0"
if you change that to
"Cheats" "100"
it may work, it may break. because you made the string bigger. if it breaks, shifting it 2 bytes may fix it, or it may not. Depends on how the reader works.
if you change it to
"Cheats" "5" it will likely work, odds are far better than 100: the file bytes did not move around, so if the thing supports having a 5 there, and does not validate the value and reject it, it will probably work.

if you break something, it may be subtle, and take a lot of testing to even see that it was damaged.

you can do it however you want, but what I said initially holds true... if you can locate these entries, you can change them, sure. you need to read the file (into a binary byte buffer), locate the string data, and use that to populate your gui widget, then allow user to modify in the clean interface, then back feed the changes to the file data, and write the file back out in binary mode. So far, that is fairly simple, but the trick is, again, you need to be careful about breaking the file, which means that if you make a string's size bigger than it was when you edit it, you are at risk, and need to test and play with the program to see what you can and cannot do there. That part isn't tied to c++, its tied to how the consumer of the file reacts to hackery.

Last edited on
In other words if I want not just edit the values but add new lines the game will crash at start :(
Can you upload the file somewhere and post a link here?
In other words if I want not just edit the values but add new lines the game will crash at start :(

I can't say for sure. Odds are against careless hackery working, but sometimes it does. That was part of my original point... take a hex editor, hack the way you want to, and then run your game to see if you broke it. Once you are comfortable with what you can do to your file, then you can make a tool to do the changes. Making the tool first is possible but you will be chasing your tail a bit.

--it shouldn't have to be said, but I will... keep a copy of the original file before you take the axe to it.
Last edited on
From the picture, it looks like the 2 bytes before each string are the length of the string, with the bytes in "little endian" (reversed) order.

[DC1] [NUL] DestructionMethod

DC1 is 17 (looked up in an ascii table).
NUL is 0.
The string is 17 chars long.

[TAB][NUL]Gobin4Gib (9, 0)
[BEL][NUL]Density   (7, 0)
[SOH][NUL]Q         (1, 0)
[EOT][NUL]Name      (4, 0)
[BS ][NUL]FlashBat  (8, 0)

Thank you both!

Dutch I have a question: Can I add extra lines? And how to? For example there's the "CanBuildUnit" thing. can I add: "CanBuildUnit M_RD72 after GS_constructorAdv?

I tried to add FFNULCanBuildUnit... But the game stopped working... I just want to figure out how can I add extra lines...

I uploaded another pic:
There's no such thing as "lines" in a binary file. So, no, you can't add a "line".

To add new strings then, at a minimum, you'd need to also enter the string sizes that I mentioned.
I don't know what you mean by "I tried to add FFNULCanBuildUnit...".
Obviously you can't type the characters "FFNUL" for [FF][NUL].
Those are binary values that are being displayed as ascii control character names.
You might be able to copy/paste one of the actual values that's already in the file.
That might be easy for [FF][NUL]CanBuildUnit.
You would need to add the correct one for the second string, too.
It's 6 chars long, so it would need [ACK][NUL] before the string "M_RD72".
So you would need to find an [ACK] in the file somewhere and copy that.

But this is madness! We would never do it this way. You should be using a hex editor.

Additionally, there could be section offsets that need to be adjusted. This might be a little complicated.

Finally, it's possible that there is a checksum (e.g., CRC32) that would need to be recalculated. (You can test this by changing a single number, like 0 to 1, and see if it breaks.)

But obviously you don't want to upload the file, so there's not much I can do.
Last edited on
I can upload the file for you if you want sir.
There's no such thing as "lines" in a binary file. So, no, you can't add a "line".

hes looking at it in a text editor, and every 10 or 13 is gonna make a 'line'. this may coincide with his strings, but even so, 'this is madness' about covers it.

I believe you need to take a time out, look up the difference between a binary and text file, and get a tiny bit of background.

But the game stopped working...
I tried to tell you :) You be breaking stuff doing it this way.
I can upload the file for you if you want.
Do it: a picture is nearly useless
Registered users can post here. Sign in or register to post.