Difference between revisions of "Windows Tiny Intro"
Line 9: | Line 9: | ||
So whilst it is perfectly possible to do a small graphical effect within thatn 268 byte limit by re-using part of the header, doing anything smaller than this lower limit is only possible on older Windows versions like Windows XP. | So whilst it is perfectly possible to do a small graphical effect within thatn 268 byte limit by re-using part of the header, doing anything smaller than this lower limit is only possible on older Windows versions like Windows XP. | ||
− | == PE Header Structure == | + | ==== PE Header Structure ==== |
Here is the windows header structure: | Here is the windows header structure: | ||
+ | {| | ||
+ | ! Offset || Length || Description || Status |- | ||
+ | } | ||
+ | DW 'MZ' ; 00. e_magic | ||
+ | DW 0 ; 02. e_cblp ;UNUSED | ||
+ | DD 'PE' ; 04. Signature | ||
+ | DW 014CH ; 08. Target Machine (Intel 386) | ||
+ | DW 0 ; 0A. NumberOfSections (use 1 for 1 overlapping section) | ||
+ | DW 0,0 ; 0C. TimeDateStamp ; UNUSED | ||
+ | DW 0,0 ; 10. PointerToSymbolTable ; UNUSED | ||
+ | DW 0,0 ; 14. NumberOfSymbols ; UNUSED | ||
+ | DW 8 ; 18. Size Of Optional Header | ||
+ | DW 2 ; 1A. Characteristics (2 = IMAGE_FILE_EXECUTABLE_IMAGE) | ||
+ | DW 010BH ; 1C. Magic (PE32 32bit EXE) | ||
+ | DW 0 ; 1E. Major+MinorLinkerVersion ; UNUSED | ||
+ | DW 0,0 ; 20.SizeOfCode ; UNUSED | ||
+ | DW 0,0 ; 24.SizeOfInitializedData ; UNUSED | ||
+ | DW 0,0 ; 28.SizeOfUninitializedData ; UNUSED | ||
+ | DD start-BASE ; 2C.AddressOfEntryPoint | ||
+ | DD 0 ; 30.BaseOfCode | ||
+ | edit: DD 'edit' ; 34.BaseOfData | ||
+ | DD BASE ; 38.ImageBase | ||
+ | DD 4 ; 3C.SectionAlignment (.e_lfanew) | ||
+ | DD 4 ; 40.FileAlignment | ||
+ | DD 0 ; 44.Major+MinorOperatingSystemVersion ; UNUSED | ||
+ | DD 0 ; 48.Major+MinorImageVersion ; UNUSED | ||
+ | DW 4 ; 4C.MajorSubsystemVersion (use 3 of 4) | ||
+ | DW 0 ; 4E.MinorSubsystemVersion ; UNUSED | ||
+ | DD 0 ; 50.Win32VersionValue ; UNUSED | ||
+ | DD 0 ; 54.SizeOfImage (malloc) ; UNUSED | ||
+ | DD 30H ; 58.SizeOfHeaders | ||
+ | DD 0 ; 5C.CheckSum ; UNUSED/UNCHECKED | ||
+ | DW 2 ; 60.Subsystem 2->gui | ||
+ | DW 0 ; 62.DllCharacteristics | ||
+ | start: ; 64.SizeOfStackReserve | ||
− | === Importing Functions === | + | ; Padding to 268 bytes (minimal exe file length for Win7+) |
+ | </code> | ||
+ | |||
+ | ==== Importing Functions ==== | ||
An important part of doing your own Windows Header management is that you will need to import functions manually. | An important part of doing your own Windows Header management is that you will need to import functions manually. | ||
This can be done via header import, Import by Ordinal (specific to a windows version) or Import by hash. | This can be done via header import, Import by Ordinal (specific to a windows version) or Import by hash. |
Revision as of 05:00, 13 April 2024
Contents
Introduction
This category is for the tiniest Windows-32 intros, that often use custom Windows PE header in combination with CPU software rendering.
Tools
Assembler: NASM
Re-using Windows Header
The minimum Windows PE Header size on modern systems (Windows7 and up) is 268 bytes, even though part of this header is useless padding. So whilst it is perfectly possible to do a small graphical effect within thatn 268 byte limit by re-using part of the header, doing anything smaller than this lower limit is only possible on older Windows versions like Windows XP.
PE Header Structure
Here is the windows header structure:
Offset | Length | Description | -
} DW 'MZ' ; 00. e_magic DW 0 ; 02. e_cblp ;UNUSED DD 'PE' ; 04. Signature DW 014CH ; 08. Target Machine (Intel 386) DW 0 ; 0A. NumberOfSections (use 1 for 1 overlapping section) DW 0,0 ; 0C. TimeDateStamp ; UNUSED DW 0,0 ; 10. PointerToSymbolTable ; UNUSED DW 0,0 ; 14. NumberOfSymbols ; UNUSED DW 8 ; 18. Size Of Optional Header DW 2 ; 1A. Characteristics (2 = IMAGE_FILE_EXECUTABLE_IMAGE) DW 010BH ; 1C. Magic (PE32 32bit EXE) DW 0 ; 1E. Major+MinorLinkerVersion ; UNUSED DW 0,0 ; 20.SizeOfCode ; UNUSED DW 0,0 ; 24.SizeOfInitializedData ; UNUSED DW 0,0 ; 28.SizeOfUninitializedData ; UNUSED DD start-BASE ; 2C.AddressOfEntryPoint DD 0 ; 30.BaseOfCode edit: DD 'edit' ; 34.BaseOfData DD BASE ; 38.ImageBase DD 4 ; 3C.SectionAlignment (.e_lfanew) DD 4 ; 40.FileAlignment DD 0 ; 44.Major+MinorOperatingSystemVersion ; UNUSED DD 0 ; 48.Major+MinorImageVersion ; UNUSED DW 4 ; 4C.MajorSubsystemVersion (use 3 of 4) DW 0 ; 4E.MinorSubsystemVersion ; UNUSED DD 0 ; 50.Win32VersionValue ; UNUSED DD 0 ; 54.SizeOfImage (malloc) ; UNUSED DD 30H ; 58.SizeOfHeaders DD 0 ; 5C.CheckSum ; UNUSED/UNCHECKED DW 2 ; 60.Subsystem 2->gui DW 0 ; 62.DllCharacteristics start: ; 64.SizeOfStackReserve
</code> Importing FunctionsAn important part of doing your own Windows Header management is that you will need to import functions manually. This can be done via header import, Import by Ordinal (specific to a windows version) or Import by hash. GraphicsFor 512 bytes, there are 2 ways to go about rendering graphics:
SoundThere are a few ways to producing sound/music in Tiny Windows Intros. Win32 Single Note MIDIUsing the built-in MIDI, this requires just 2 calls
For a full list of Midi commands, check out this webpage: https://computermusicresource.com/MIDI.Commands.html Win32 MIDI PlayerDepending on the sound budget, you can think about including a small MIDI tune instead. Similar to the single note MIDI approach, but playing multiple notes from data on 1 or more different channels. Bytebeat softsynthAn alternative option is to use a very simple Bytebeat softsynth (Check out https://bytebeat.demozoo.org if you are not familiar with the concept). This requires an additional setup of the Win32 WaveOut callback, which can then be played and filled realtime with data. For a taste of what is possible with small (<256 character) bytebeats formulas, check out one of the Bytebeat Music competitions from the Lovebyte parties, for example https://demozoo.org/parties/4760/#competition_18623 CompressionCompression for the smaller Windows Tiny Intros are tricky, but there have been some experiments using the Windows Cabinet Decompressor calls These functions allow for MSZIP (deflate) and MSLZ content to be loaded from the binary as payload at the cost of a a few more win32 function imports. Well this might be a good solution for 512 byte intros, the tipping point for Crinkler compression at the moment lies at the 800-850 bytes mark give or take. From cabinet library:
512 byte intros for Windows
256 / 268 byte intros for WindowsOther Resources |
---|