Reverse Engineering the Source Code from .gblorb

Hello my friends,

I am doubtful that there is a positive answer to this: Is there some software or method of retrieving the I7 source code of an IF (the .ni file) from the .gblorb file? My hard drive died, and I lost some things, including the source code to an IF I had completed; fortunately, I had uploaded it to the Archive, so I have the .gblorb.

Thanks.

There is a way to disassemble a game into (pretty much incomprehensible) Inform 6, but Inform 7 is too high-level.

Nope. The source is not stored in the compiled output. It might be a good idea to also release source to the IF Archive next time :wink:

You mean one can go from .gblorb to I6? Wouldnā€™t I6 contain all the same information (plus some) contained in the I7 .ni file, just in a different language?

If I can get it in I6, I can learn I6. How can I disassemble the .gblorb into I6?

EDIT: What Iā€™m most interested in is the text. Itā€™s a small thing, and the mechanics are simple and easily re-made.

You can try, but I7 -> Glulx -> I6 will be even harder to read than normal disassembled I6. I doubt it will even compile right after disassembly.

If you want the text, I know some interpreters can just dump all the text from the file. Rezrov, for example, but it doesnā€™t do gblorbs.

How do I go I7 ā†’ Glulx ā†’ I6? All these file types and interpreters and virtual machines have me mixed up. The only file I have is the .gblorb, compiled by I7.

Right, so youā€™ve compiled I7 into Glulx. Now you need to extract the .ulx file from the blorb packaging, then run it through the Inform 6 disassembler (itā€™s called Disinform or Uninform or something like that).

Please, Draconis, I appreciate that you are trying to help me, but I think it should be obvious that I donā€™t know how to unwrap a blorb. So:

How do I extract the .ulx from the .gblorb?

Iā€™ve never actually done this, but I think some of these Z-machine blorb tools can open gblorbs too.
inform-fiction.org/zmachine/blorb.html

To remove the Glulx story file from the blorb file, Iā€™d recommend using ifarchive.org/if-archive/program ā€¦ gblorb.zip

This contains a Glulx file which lets you manipulate blorb files in various ways, including extraction. It shouldnā€™t be too hard to figure out. Once youā€™ve extracted all the data from the blorb file, you should have a file called STORY0 (or something like that). This is your Glulx file which you need to disassemble to get at the text.

I found a glulx disassembler called Mrifk which seems to work pretty well, but the website it was on is gone, so Iā€™ve stuck copies of the files at:
frobnitz.co.uk/mrifk_2_050524.zip (source code)
frobnitz.co.uk/mrifk_2_050524_linux.tar.gz (linux binaries)
frobnitz.co.uk/mrifk_2_050524_win32.zip (windows binaries)

When I ran the windows binaries, it worked fine, but it just outputs the source to the console, so youā€™ll need to redirect it to a file. The command for that would be something like

And then you should have inform 6 source code for your game in a file called ā€˜sourcecode.infā€™.

Thaks so much, Marvin! This helped me figure out the last thing to do in a game I was trying to do a walkthrough for.

(Luster, IFComp, 2011, if anyone is curious. I also made a Trizbort map.)

I was thinking something more like the Babel suiteā€¦ Iā€™m now quietly amazed at a compiled GBlorb ā€œgameā€ that is able to perform blorb operations.

I know that this is a bit later than when this was started, but I tried doing this myself and mrifk keeps saying that there is an invalid opcode 181. is there anyway to fix this?

mrifk hasnā€™t been updated in about a decade, from the look of it, so itā€™s missing a lot of more recent opcodes. The only way to fix this would be to edit the source code and compile a new version. No idea how hard that would be, but the source code for mrifk is available on the if-archive.

If all you need is text, toastball.net/glulx-strings/ should be able to do it, without needing to install anything.

This is something thatā€™s been poking at me on and offā€¦

Iā€™ve never used Haskell before, but I suspect that you need to add these two lines:

Mrifk_disasm.hs

Thereā€™s nothing below 0x163 in this file.

To get rid of the immediate error, this seems right.

(0x180,(ā€œaccelfuncā€, 2,0,0, OCallI))
(0x181,(ā€œaccelparamā€, 2,0,0, OCallI))

(1st # = # of Lā€™s, 2nd = # of Sā€™s)

The rest seems like it could also be cribbed from

eblong.com/zarf/glulx/glulx-spec_2.html

Does anyone have knowledge of Haskell or how to compile on it? If not, I could figure it out eventually. Iā€™d be glad to add the updated Mrifk_disasm.hs as well for all the new-ish opcodes, if someone can compile. Then we could have a working mrifk.

Also this thread finally got me to read Eye of Argon. Yay.

Aschulz, thanks for the pointer! I tried this last night and succeeded.

  1. Download the compiler from here: haskell.org/ghc/
    I used version 6.10 because it was smallerā€¦

  2. set a path to wherever you install the compiler
    ie; path G:\ghc\ghc-6.10.1\bin

  3. Modify the Mrifk_disasm.hs file and add the opcodes you want. The spacing in this file IS important.
    I had to add these to decompile a game:
    (0x73,(ā€œstreamunicharā€, 1,0,0, OStreamStr)),
    (0x178,(ā€œmallocā€, 1,1,0, OSpecial)),
    (0x179,(ā€œmfreeā€, 1,0,0, OSpecial)),
    (0x180,(ā€œaccelfuncā€, 2,0,0, OCallI)),
    (0x181,(ā€œaccelparamā€, 2,0,0, OCallI))]

  4. Compile with: ghc --make -fglasgow-exts -o $@ Mrifk.hs
    Enjoy the new .exe!

This is tangential, but here are a couple of free online Haskell books (also available in print editions) for people who are interested:

Learn You a Haskell for Great Good!
Real World Haskell (Oā€™Reilly)

Savituro, your instructions worked great!

Now, though, my current gblorb balked on double byte characters. I need to figure out a way to deal with

decodeString =
do type_ <- getUByte
case type_ of
0xE0 -> getCString
0xE1 -> huffDecode

I added
0xE2 -> getCString

Just to get it to compile and run, but obviously itā€™s be nice to read in a unicode string properly.

This feels like it should be trivial. Once I do that Iā€™d love to submit a new version with your instructions.

VLaviano, thanks for the links. They should help with the new issue I found.

Have you tried renaming something.gblorb to something.zip and then extracting?
I have found this to work with quite a few file formats.