Mail Archives: cygwin/2005/12/30/02:17:16
Sam Steingold wrote:
> CLISP consists of a run time (a normal executable lisp.exe, 2.5M)
> and a memory image (a binary data file lispinit.mem 2MB-10GB).
> It is normally invoked as "lisp.exe -M lispinit.mem", i.e., the
> application consists of two files instead of a single executable which
> is generally not considered desirable by the users, one of whom
> suggested the following:
> copy /y /b lisp.exe + marker.txt + lispinit.mem myapp.exe
[snip]
> This should work, but I would rather not search the executable for the
> marker text (for performance reasons - I do not want to increase the
> start-up time), I would prefer to know where the executable ends right
> away.
>=20
> Is it possible?
Yes.
> simply put, it it possible to write something like this:
>=20
> int main () {
> size_t my_length;
> <some magic>
> printf("exe size=3D%lld\n",my_length);
> return 0;
> }
>=20
> so that when it is compiled, my_length contains the length of the
> executable file as it was created by the compiler.
> e.g.:
> $ ./myprog.exe
> exe size=3D1234567
> $ copy /y /b myprog.exe + myprog.exe myprog2.exe
> $ ./myprog2.exe
> exe size=3D1234567
> -- and not 2469134
>=20
> one of the main requirements is portability.
> (nothing woe32-specific or cygwin-specific &c)
Portable? The only problem I can think of is an OS with enough security th=
at
checks executable file size vs. file header specified size (in Windows the =
exe
header does contain the file size in blocks, but Windows doesn't check; I d=
on't
know if other operating systems / executable formats are set up to do this =
kind
of check).
> the only idea I have had so far is this:
>=20
> char string[]=3D"this is a buffer into which I will be writing my stuf=
f";
> size_t my_length =3D atol(string);
>=20
> and then have a post-processor edit lisp.exe and replace the contents of
> string with the actual lisp.exe file length (I need the long initial
> junk there so that the post-processor will be able to find where it is to
> write the length).
>=20
> any suggestions?
Your idea works, I used to do something similar for copy protection purpose=
s.
The steps would be something like:
1. Compile program, say "gcc -mwindows h.c -o h";
2. Record file size;
3. Concatenate program and data, say "cat h.exe h.data > longh.exe";
4. Run through post-processor (with longh.exe and size as parameter).
Of course a smarter post-processor could do steps 2 through 4 itself, no ne=
ed
for parameters except perhaps the target string.
--=20
Ren=E9 Berber
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -