Method 1 verified and works! Solution (DOSX)
Method 1 verified and works!
I missed "pages in file" and "bytes on last page" values in MZ header.
It has nothing to do with memory, by mistake only part of the stub was loaded into memory.
So, here's a full solution to make executables valid for HX DOS Extender and Windows XP:
1. Compile the program
2. Process it with pestub without -s option*
3. Move PE header from after the end of DOS stub to at 40h in file
4. Validate pointer to PE header at 3Ch by setting it to 40h
5. Validate "paragraphs in header" value at 8h by increasing it by "PE header size" / 16
6. Validate "relocation address" value at 18h by increasing it by "PE header size"
7. Validate "pages in file" (at 4h) and "bytes on last page" (at 2h):
"pages in file" += "PE header size" / 512
"bytes on last page" += "PE header size" % 512
if "bytes on last page" gets larger than or equal to 512 (200h), subtract 512 from it and add one to "pages in file" value.
Note: we assume here that PE header size is multiply of 16.
If it's smaller, just round it to the next bigger value.
Note 2: all values are word size except pointer to PE header (dword).
* Btw, -s option is totally useless now.
Complete thread:
- pestub + large stub = invalid executable for WinXP - grompe, 28.04.2008, 11:44
![Open in board view [Board]](img/board_d.gif)
![Open in mix view [Mix]](img/mix_d.gif)
- pestub + large stub = invalid executable for WinXP - Japheth, 28.04.2008, 11:55
- The -s option doesn't help with large stub - grompe, 28.04.2008, 12:02
- pestub + large stub = invalid executable for WinXP - DOS386, 01.05.2008, 05:19
- Thanks, but there's no need to search for another solution - grompe, 01.05.2008, 17:48
- Thanks, but there's no need to search for another solution - DOS386, 02.05.2008, 21:43
- Thanks, but there's no need to search for another solution - grompe, 01.05.2008, 17:48
- pestub + large stub = invalid executable for WinXP - Japheth, 28.04.2008, 12:29
- DOS data is just a stub without MZ header - grompe, 28.04.2008, 12:37
- Method 1 verified and works! Solution - grompe, 30.04.2008, 12:41
- pestub + large stub = invalid executable for WinXP - Rugxulo, 01.05.2008, 05:48
- Sigh... Still not fixed - grompe, 28.01.2009, 20:51
- Sigh... Still not fixed - Japheth, 30.01.2009, 17:28
- Sigh... Still not fixed - ecm, 30.01.2009, 17:56
- Miscounted, don't take it seriously. - grompe, 30.01.2009, 22:42
- Sigh... Still not fixed - Japheth, 30.01.2009, 17:28
- pestub + large stub = invalid executable for WinXP - Japheth, 28.04.2008, 11:55
Mix view