Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Method 1 verified and works! Solution (DOSX)

posted by grompe Homepage, Russia, 30.04.2008, 12:41

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:

Back to the forum
Board view  Mix view
22755 Postings in 2121 Threads, 402 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum