How to open a created game without using Blitz?

Community Forums/General Help/How to open a created game without using Blitz?

needfulart(Posted 2013) [#1]
Hey,

Is there any way you can open a created game other than using Blitz?


GfK(Posted 2013) [#2]
Erm, you mean, extract code from a compiled executable?

You can't.

If that's not what you meant, please explain.


needfulart(Posted 2013) [#3]
kinda just a way to play the game you creat without having need to open blitz..


GfK(Posted 2013) [#4]
Oh.

Blitz (any version of it) does not run interpreted code. Every time you run your program an executable is created (usually in the same folder as your source code). You can just run that executable directly from Windows at any time.


Yasha(Posted 2013) [#5]
GfK's comment is right for BlitzMax - for BlitzPlus and Blitz3D, you need to choose "Create Executable" from the "Program" menu, and it will save the standalone .exe for you to a location of your choice. This executable will then run without the need for Blitz. (Remember that it will still need any external files - images and the like - that the program was written for, though!)

BlitzMax is quite different from the other two in several ways (this is the least of them) so it's important to say which one you're using.


GfK(Posted 2013) [#6]
GfK's comment is right for BlitzMax - for BlitzPlus and Blitz3D, you need to choose "Create Executable" from the "Program" menu, and it will save the standalone .exe for you to a location of your choice. This executable will then run without the need for Blitz.
Really? Haven't used either for 6 or 7 years so I'll take your word for it.


Yasha(Posted 2013) [#7]
Yep, +/3D generate their program in-memory when you just "run" from the IDE, using what I assume is some kind of JIT system. There's no actual application left anywhere on disk.

I assume the reason Max doesn't do this is somehow tied into relying on FASM from assembly source (which is a good idea), rather than generating its own machine code, and thus there needs to be an intermediate step even when you aren't building for keeps.


big10p(Posted 2013) [#8]
I suspect B3D simply compiles a temp exe when running in the IDE, and then deletes it after execution.


Imperium(Posted 2013) [#9]
You can try using a decompiler but don't expect it to generate anything usable. Any comments will also likely be gone. If you're trying to hack into someones work just don't. Learn from the thousands of examples archived here instead.


virtlands(Posted 2013) [#10]
Even an average Blitz3D program (*.BB-->*.exe) seems to contain millions of lines of code, and is apparently very hard to decipher.

I tried loading one of my own programs (*.exe) into various
disassemblers and could never find any organized pattern that I understood
which relates back to the original BB code, (so I gave up on that).

I've often wondered if the Blitz3D compiler includes some form of
software obfuscation (that it applies every time).

Obfuscation : https://en.wikipedia.org/wiki/Obfuscation_%28software%29


Yasha(Posted 2013) [#11]
Actually B3D's generated code is very simple, if you can find your functions in the mess of generated stuff.

Here's a neat hack:

; Define an unusual constant, e.g. your birthday in hex, or something:
Const PLACEMARKER = $19861207

; Add a dedicated variable to your function to act as the marker
Function MyInterestingFunc(a, b, c)
    Local marked = PLACEMARKER    ; Assign to it at the start

    ;.... interesting machine code

    marked = PLACEMARKER    ;...and at the end
End Function


The body of your function will now appear between two instances of your unusual constant, which will have been pasted literally into the machine code.

Now either:

1) Open the exe up in an editor like XVI32 and do a hex search for your constant. The stranger the number, the less likely there are to be false positives. When you find two occurrences relatively near each other, copy the code (and a large chunk to either side for the prologue/epilogue) and paste it into your favourite disassembler (e.g. ODAweb).

2) If you have a disassembler installed locally (e.g. objdump), run it over your whole exe and do a text search for the hex constant in the assembly version.

Either way, you can view the B3D-generated code for a user-defined function.


virtlands(Posted 2013) [#12]
Nice idea from Yash; I just now browsed the Online Disassembler.

http://www.onlinedisassembler.com/odaweb/

Concerning that magic number (or unusual constant), one can do a statistical study
of the .EXE to try 'n' find an INT that occurs zero times or infrequently,

and also toggle that between little-endian and big-endian, just in case.

The ODA is limited to 500k file uploads.


Blitzplotter(Posted 2013) [#13]
I was interested in trying to decompile my own B3D exes out of curiousity a while ago, interesting thread - although decompiling other folks stuff ain't nice.