Incbin "index.html"

BlitzMax Forums/BlitzMax Beginners Area/Incbin "index.html"

time-killer-games(Posted 2012) [#1]
I'd like to convert an an html game I made to a windows exe, mac app, and linux program with blitz. Though I came a across some issues...

I know how to make a maximized window that embeds my html content via htmlview, but I'd strongly preffer to have my Html files embeded in the exe using Incbin, so they won't be external resources. Html is very easy to modify, thus making it easy for users to steal my work, which I don't want.

Is there a way to load the incbin "directory" to access its embedded files in the exe?

I know this can be done with images, LoadImage for example or LoadSound for wav files...

Is there any way to do this with an embedded Incbin html data file?
Thanks!
TKG


ImaginaryHuman(Posted 2012) [#2]
With incbin there is no hierarchical structure like in a file system and each resource is kind of isolated and loaded individually. Since htmlview probably implement a webkit window or whatever provided by the o/s which in turn loads additional files etc by itself (I presume) it won't likely look at or speak to your incbin files. You can probably do a single plain html file but with no other references.


ima747(Posted 2012) [#3]
To add to what ImaginaryHuman said, the controller for the HTML does all the file loading, as a result it can't access incbin'd data as it is just raw data blocks, not files.

If you wanted to get really fancy you could write an file request handler in your app, or in a helper app that would serve the file data out, and you could parse the HTML to direct it's file calls through that, but it's still pretty insecure as anything HTML is, in that if the HTML can ask for the file so can anything or anyone else.

There's no way to protect you data on a user's machine, and that's compounded by HTML being inherently easy to strip since it's not compiled or obfuscated in any way.

Another approach would be to extract the resources to a temp location or cache folder and parse the HTML to load the resources from that location. This would still be exposed to the user but at least it would be buried away a bit and you could delete it at the end of execution. FAR from fool proof, but again, you can't make it properly secure so how far do you really want to go? Do you want to dissuade the casual "what's in this" user, or are you trying to confuse a determined hacker (not going to happen).

Security is an illusion. It is the art of putting up one more wall than your attacker is willing/capable of climbing. The problem is the attackers are the ones with all the time, energy and practice. You have to figure out what's good enough for you because there isn't anything that's truly good enough. If there was everyone would use that, and every attacker in the world would be targeting it and then it too would fall :0)


ImaginaryHuman(Posted 2012) [#4]
One option is to create an `web page archive` IF the browser you want it to open in is compatible with the format of the archive. ... you know, like when you `save` a web page and it includes all images etc but as an archive file... not sure if it was IE or whatever that used to do that.. then it'd be one file.

Another option is to include all files in your incbin, and then before you view the web page in your game/app, extract them and save them to disk in a temporary folder, and then launch the web page.


time-killer-games(Posted 2012) [#5]
I already knew how to do that stuff, I was just seeing if there was a more secure alternative. Looks like there isnt. I'm probably just gonna re-code the game in blitz. Thanks anyway. :)


Henri(Posted 2012) [#6]
I had a code snipet to incbin html file and use it without saving anything to temp folder. Might not work in your case, but...

Import MaxGui.Drivers

Incbin "test.htm"

Local p:Byte Ptr=IncbinPtr("test.htm")
Local bytes=IncbinLen("test.htm")
Global s:String
s = s.FromBytes(p,bytes)

Local window:TGadget
Local htmlview:TGadget


SaveText(s,"tester.htm")

window=CreateWindow("My Window",30,20,600,440,,15|WINDOW_ACCEPTFILES)

htmlview=CreateHTMLView(0,0,ClientWidth(window),ClientHeight(window),window)
SetGadgetLayout htmlview,1,1,1,1 

HtmlViewGo (htmlview,"C:\BlitzMax\tmp\tester.htm")

While WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
	End Select
Wend


EDIT:
Whoops. I was too hasty. It's actually saving the html file in a temp folder.

Last edited 2012