Executing a block of data as an application?

BlitzMax Forums/BlitzMax Programming/Executing a block of data as an application?

Retimer(Posted 2008) [#1]
I have high doubts that this is possible - figure i'de ask anyways.

Is it possible to load a chunk of data into memory, and run the block as an application, instead of having to save it as an exe on the drive?

If not, alternatively, is it possible to run a random file extension as an application, rather then the operating system attempting to run the program with a default affiliation? (ex: txt opens notepad by default, how could I, via blitzmax code, get it to run as an application instead?)

I'm trying to get a lobby together to be able to group several games within the lobby - all having seperate 'client' applications for each game through my engine, but going through the lobby is required to log in and so on. I just want to be able to hide each application as a data file (within a data package, actually), so users don't get confused, thinking they can run the application to start the game and skip the lobby scenario.

Edit: I also need whatever method, if possible, to work the same for mac


Jesse(Posted 2008) [#2]
I have not tried it but wouldn't it be possible to do it through incbin?


plash(Posted 2008) [#3]
I have not tried it but wouldn't it be possible to do it through incbin?
I doubt it.

You should try creating a process to an executable that does not - or has an incorrect - extension.


Retimer(Posted 2008) [#4]
Thanks for the responses.

I have not tried it but wouldn't it be possible to do it through incbin?


Would be the same as loading it from any other file I would assume, and unfortunately that won't work with updates and such, along with bloat. I should have mentioned the lobby is not an offline application - nor are any of the games.

You should try creating a process to an executable that does not - or has an incorrect - extension.


How would I do this?


plash(Posted 2008) [#5]
Calling..
SuperStrict

Framework brl.standardio
Import pub.freeprocess

Local process:TProcess = CreateProcess("myprogram.radishes", 0)

While process.Status() <> 0
	
	Delay 10
	
Wend

process.Close()


And the program (build, then rename to myprogram.radishes):
SuperStrict

Framework brl.system

Proceed("Got radishes?")

End


This also works: system_("myprogram.radishes")

I believe installers may use stuff like this (I've seen processes called '*.tmp' before in taskmanager.)

Mac should be the same; and you should consider making the game and the 'lobby' communicate to verify authenticity.


xlsior(Posted 2008) [#6]
Is it possible to load a chunk of data into memory, and run the block as an application, instead of having to save it as an exe on the drive?


one probably wrench into the whole system is DEP (Data Execution Prevention), a feature on all of the newer CPU's that is enabled by default that prevent the execution of data blocks in memory of your computer.

(designed to prevent virusses that manage to sneak in through buffer overflows in programs from managing to execute themselves)


ziggy(Posted 2008) [#7]
You can start a process from a file with ANY extension. Also, you can use scrpit code.


Retimer(Posted 2008) [#8]
Thanks plash, this will work.

Mac should be the same; and you should consider making the game and the 'lobby' communicate to verify authenticity.


Yeah i'm way ahead on that ;). The server gives each client a unique key after logging into the lobby. When they join a game, the lobby server contacts the game server for the game they choose, giving it the userid and their ip - the game server responds with a randomly generated key to the lobby, the lobby gives the key and the game server ip to the client. When the client connects it compares the key to whatever username was just registered to it and authenticates them that way.

So a client couldn't just run the app with username/password arguments, but the point of this solution you gave me was mainly just to prevent users from getting confused.

one probably wrench into the whole system is DEP (Data Execution Prevention), a feature on all of the newer CPU's that is enabled by default that prevent the execution of data blocks in memory of your computer.


Thanks, wasn't sure about that. I suppose in a grand way, that's a good thing.