Tomas Hajny wrote: > However, I can't believe that information about this offset (i.e. size of > the stub) isn't already available somewhere in the exe file itself (either > in the general header or possibly in the COFF section headers), I just
The following simple snippet for computing "stubsize" is based on function "create_go32_stub" in file "gnu\binutl-2.14\bfd\coff-stgo32.c" from DJGPP's "bnu21?s.zip". Information is available here: <http://www.delorie.com/djgpp/doc/exe/>. 512 bytes form a page (or block) as per Microsoft's definition. "tdosheader" is from file "exeinfo.pp". *** type tdosheader = packed record e_magic : word; e_cblp : word; e_cp : word; e_crlc : word; e_cparhdr : word; e_minalloc : word; e_maxalloc : word; e_ss : word; e_sp : word; e_csum : word; e_ip : word; e_cs : word; e_lfarlc : word; e_ovno : word; e_res : array[0..3] of word; e_oemid : word; e_oeminfo : word; e_res2 : array[0..9] of word; e_lfanew : longint; end; var f: file; dosheader: tdosheader; stubsize: cardinal; /* cardinal OK here? */ begin Assign(f, ParamStr(1)); Reset(f, 1); BlockRead(f, dosheader, SizeOf(dosheader)); if dosheader.e_magic = $5a4d then begin stubsize := dosheader.e_cp * 512; if dosheader.e_cblp > 0 then stubsize := stubsize + dosheader.e_cblp - 512; WriteLn('stub size: ', stubsize); end; Close(f); end. *** Robert Riebisch -- BTTR Software http://www.bttr-software.de/ _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel