Code archives/Miscellaneous/small exe builder

This code has been declared by its author to be Public Domain code.

Download source code

small exe builder by Kev2004
writes exe file structure
exename$ = RequestFile("Save .Exe As...","exe",True)

CreateExecutable(exename$)

If exename$ <> "" Then
Notify "Finished!"
EndIf

Function CreateExecutable(exefilename$)

	outfile = WriteFile(exefilename$)
	If outfile = 0 Then Return 0
	
	bank = CreateBank($200)

	;
	Restore EXE_BANK_DATA
	Repeat
		Read e_data
		If e_data = 999 Then Exit
		PokeByte bank,next_entry_data,e_data
		next_entry_data = next_entry_data + 1	
	Forever
				
	For loop=0 To BankSize(bank)
		WriteByte outfile,PeekByte(bank,loop)
	Next
	
	CloseFile outfile
	
End Function

.EXE_BANK_DATA
Data $4D ,$5A ,$80 ,$00 ,$01 ,$00 ,$00 ,$00  ;MZ€....
Data $04 ,$00 ,$10 ,$00 ,$FF ,$FF ,$00 ,$00  ;..ÿÿ..
Data $40 ,$01 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;@......
Data $40 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;@.......
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$80 ,$00 ,$00 ,$00  ;....€...
Data $0E ,$1F ,$BA ,$0E ,$00 ,$B4 ,$09 ,$CD  ;º.´.Í
Data $21 ,$B8 ,$01 ,$4C ,$CD ,$21 ,$00 ,$00  ;!¸LÍ!..
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $50 ,$45 ,$00 ,$00 ,$4C ,$01 ,$01 ,$00  ;PE..L.
Data $F7 ,$25 ,$15 ,$3E ,$00 ,$00 ,$00 ,$00  ;÷%>....
Data $00 ,$00 ,$00 ,$00 ,$E0 ,$00 ,$8E ,$81  ;....à.Ž?
Data $0B ,$01 ,$01 ,$2B ,$00 ,$00 ,$00 ,$00  ;+....
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$10 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;.......
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$40 ,$00  ;......@.
Data $00 ,$10 ,$00 ,$00 ,$00 ,$02 ,$00 ,$00  ;......
Data $01 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;.......
Data $04 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;.......
Data $01 ,$10 ,$00 ,$00 ,$00 ,$02 ,$00 ,$00  ;.....
Data $59 ,$AE ,$00 ,$00 ,$02 ,$00 ,$00 ,$00  ;Y®.....
Data $00 ,$10 ,$00 ,$00 ,$00 ,$10 ,$00 ,$00  ;......
Data $00 ,$00 ,$01 ,$00 ,$00 ,$00 ,$00 ,$00  ;.......
Data $00 ,$00 ,$00 ,$00 ,$10 ,$00 ,$00 ,$00  ;.......
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $2E ,$53 ,$65 ,$63 ,$74 ,$00 ,$00 ,$00  ;.Sect...
Data $01 ,$00 ,$00 ,$00 ,$00 ,$10 ,$00 ,$00  ;......
Data $01 ,$00 ,$00 ,$00 ,$00 ,$02 ,$00 ,$00  ;......
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$60 ,$00 ,$00 ,$E0  ;....`..à
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00 ,$00  ;........
Data $C3                      				 ; Ã

;
Data 999

Comments

Neuro2004
So...how does this work and how would I use this?


Clyde2004
Neato Kev! :)
Reminds me alot of the Action Replay Machine Code Monitor on the Commodore64!


Kev2004
Neuro, theres several uses for the exe builder. i suggest reading some general tutorials/information on the pe executable format. its a vast subject.

i use the builder to wrap blitz executable with anti cracking code. it could also be used for a bytecode assembler/compiler.


Code Archives Forum