how to get a bytecode file ?

Started by
5 comments, last by carr 15 years, 5 months ago
hello, geniuses: To run a script file , angelscript takes two steps. first, compile the source file into bytecode, second, run it. all happpen at run time. I want to separate the two steps. e.g. compile source before run time to get a bytecode file. Then , load the bytecode file and run , i think, it's faster when running, and source code can't be seen, it's safe. so ,what's the APIs to compile the script and save it ?? thanks.
Advertisement
You can save and load byte code with the functions asIScriptEngine::SaveByteCode() and asIScriptEngine::LoadByteCode().
If you want security then you should not use precompiled bytecode. Use encryption instead.

The problem with the precompiled scripts is that it bypasses most of the compile time checks that the compile performs. So if you load a precompiled bytecode that have been manipulated by some hacker, you may actually open up your application to exploitations, such as buffer overruns, etc.

Now if you want to avoid the delay caused by compilations while loading scripts, but don't care about the potential security problem of hacked bytecode, then precompiled bytecode is the way to go. The security problem may be diminished somewhat by adding check-sums and other similar techniques to the precompiled bytecode.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I remeber you motioned that the precompiled byte code is not platform independent, isn't it, Angel?
So think about this issue before you decide to use it.
Well remembered. The saved bytecode is indeed highly platform dependent, as it is compiled to be compatible with the host application. Things such as pointer sizes and size of booleans (PPC use 4 bytes for a boolean) changes the bytecode.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Quote:Original post by dxj19831029
I remeber you motioned that the precompiled byte code is not platform independent, isn't it, Angel?
So think about this issue before you decide to use it.


perhaps you could compile the source code to byte code the first time the app is run on a machine, then store it in an encrypted archive of some kind.
I appreciate your help.

thank you.

This topic is closed to new replies.

Advertisement