The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: thomas_remkus on June 05, 2007, 04:28:49 PM

Title: why "00 DB 00" in the binaries
Post by: thomas_remkus on June 05, 2007, 04:28:49 PM
Trying to understand more of my current work in progress and I ran in through OllyDbg. The ASM is very interesting but what's more interesting is that this very small file (2k) has hundreds of lines of "00 DB 00" after what I thought was the end of the file. Why are these important?
Title: Re: why "00 DB 00" in the binaries
Post by: Vortex on June 05, 2007, 05:47:23 PM
Those padding bytes are used to align the size of files. Sections of portable executables are aligned to the standard value 512.
Title: Re: why "00 DB 00" in the binaries
Post by: thomas_remkus on June 06, 2007, 01:44:00 AM
The binary I have in question is really very small where it's related to code. Is there a switch that I can use that will make this pad as limited as possible?
Title: Re: why "00 DB 00" in the binaries
Post by: hutch-- on June 06, 2007, 02:03:35 AM
Thomas,

Its the format of a portable executable file that sets its minimum size. old DOS COM files were pure memory images so they could be very small but a 32 bit PE file has a dos header, a PE header and any section headers required. The minimum is 2 * 512 byte sections and the rest is PE specification data and any padding required to make the section the right size.
Title: Re: why "00 DB 00" in the binaries
Post by: thomas_remkus on June 06, 2007, 02:10:21 AM
Perfect. That taught me the answer. Thank you.
Title: Re: why "00 DB 00" in the binaries
Post by: jdoe on June 06, 2007, 03:11:26 AM
You can use the /ALIGN swith of link.exe to get smaller win32 PE (<1024 bytes) but it may not run on every win32 platform.
Title: Re: why "00 DB 00" in the binaries
Post by: thomas_remkus on June 06, 2007, 03:17:13 AM
Oh. Then I'll avoid this. Thanks for the information, and the warning.