Reverse Engineering the Source Code from .gblorb

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.

Gblorbs are not zip packages so that won’t work.

If it’s not too much trouble, would you mind submitting the revised executable to the IF Archive? It would be great to have an up-to-date version there.

I don’t think it’s quite ready yet. The thing is, running it on any gblorb now gives

mrifk: Mrifk_strings.hs:(99,5)-(102,30): Non-exhaustive patterns in case

This indicates that we probably have 0xe2 as a code somewhere. It appears to extract 32-bit data.

github.com/jcmf/glulx-strings/b … strings.py gives some insight as to how to do that. And in fact it is more useful cross-platform for text extraction because it is a webpage and not a compiled executable. But this might be neat to have for full disassembly.

I have a feeling we just need to add a few lines of code. l’ll see if I can translate the python into haskell. It loks like a good but nontrivial exercise.

1 Like