From: Chris L. <cli...@gm...> - 2004-12-15 02:34:52
|
Chris Liechti wrote: > Thomas Heller wrote: > >> Chris Liechti <cli...@gm...> writes: >> >>> Thomas Heller wrote: >>> >>>> Yet another idea for single-file executables is to try to load >>>> extension >>>> modules directly from a zip-archive. I found some code on the net >>>> which >>>> *simulates* LoadLibrary, and so maybe could be used to do this. The >>> ... >> Well, Joachim's code scans the import table of the dll to load, and >> patches it manually. So it *could* work at least... yep. partial success! :-)) i modified my py2exe-pyco sources. my exe has now 3 parts. exe header, pyco packed python.dll and start script, zipfile with the modules collected by py2exe. the pyco part could be thrown out if one implements reading a zip file in C/C++. what i have so far is that the exe unpacks the python dll into memory and directly loads it from there with MemoryLoadLibrary. then it initializes the python interpreter and starts a loader script with PyRun_SimpleString. pyds are not yet found, means we have to patch the python.dlls LoadLibrary, so that it first checks for memory loaded dlls before asking the system. that's this part of the job: > BuildImportTable() uses LoadLibrary and GetProcAddress it should > probably check the Memory* version before trying to load from the > system, and yes, it should be able to redirect these same calls in the > loaded module. actualy it might turn out much easier than i thought :-) i'm not sure if LoadLibrary function is used to load different things too, like resources, so the patched function should probably return normal windows handles. the GetProcAddress needs then to check if it is a handle to a OS loaded library or to one of our memory loaded ones. heh, if ctypes could be inserted (imported) by the C layer, then we could implement the patched LoadLibrary function in Python... maybe... chris |