Lets see if I can explain the problem I am having, I have made a program
to compress data, then I build a complete uncompresser PE file and add
the compressed data to the .rsrc area and update the PE. and save
the EXE file.
When I run it in Win98 it works it pops up a window
lets you pick where to install the data and installs it. but in XP it
says the file is not a PE file, so in this code below that works in
Win98, what is missing if any that would make it not run in XP?
mov esi,Setup$
assume esi:ptr IMAGE_DOS_HEADER
.if [esi].e_magic == IMAGE_DOS_SIGNATURE
add esi,[esi].e_lfanew
assume esi:ptr IMAGE_NT_HEADERS
.if [esi].Signature == IMAGE_NT_SIGNATURE
mov eax,ArchiveSize
add [esi].OptionalHeader.SizeOfImage,eax
mov ax,[esi].FileHeader.SizeOfOptionalHeader
mov OptionalheaderSize,eax
mov ax,[esi].FileHeader.NumberOfSections
movzx eax,ax
mov NumberOfSections,eax
mov ecx,eax
add esi,sizeof IMAGE_NT_HEADERS
assume esi:ptr IMAGE_SECTION_HEADER
.while ecx > 0
push ecx
invoke lstrcpyn,addr buffer,addr [esi].Name1,8
invoke lstrcmp,addr buffer,txt(".rsrc")
.if eax == 0
mov eax,ArchiveSize
add [esi].Misc.VirtualSize,eax
mov eax,ArchiveSize
add [esi].SizeOfRawData,eax
.break
.endif
pop ecx
dec ecx
add esi,sizeof IMAGE_SECTION_HEADER
.endw
.endif
.endif
assume esi:nothing
I have searched the MSDN for anything about XP and other OS's
if there is a difference or not, maybe it's something I am doing wrong
that Win98 lets pass anyways, not sure about that though.
Zcoder....
at a guess, perhaps the archive size & section size has to be section aligned in >9x os?
Size_Of_Image must be aligned at 0x1000 (aka Section alignment) and it must be calculated acordingly to some rules: add all sections Virtual_Size and add the Virtual Size of the PE headers (usually 0x1000) ...
Well, I gave it a shot, and well, I think
I just don't get it, somewhere I am
mixed up now lol
Anyone have a way to explain my problem
in more detail??
Cuz working with jumping around in
all these dam structures in the PE has
me doing the brain crash...
Zcoder....
Maybe using UpdateResource API would be another way to do it.
Make a template .exe and then use APIs to add/modify its resources.
SamiP,
thats a good idea, really it is.
but I have a problem with that I wrote my program to first
write out the exe templete then it compresses and puts it into this file untill all of the files
are compressed, then I close it and open it just to modify the PE sections.
if I use the API's I have to save the compressed data somewhere else then use the API's
to add it to the PE, this is double the copying in other words it would take extra time to
copy that stuff in a large comressed project to the PE.
but it is a good idea and if I can't fingure this out this way I may try it and see
just how long it takes to copy it to the PE using the API's in a large project.
Zcoder...