News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Win64 Console Application in 608 bytes!

Started by learn64bit, August 09, 2022, 06:12:52 PM

Previous topic - Next topic

learn64bit

If you want my masm64 folder, I can email it to you.
btw: It is "14.7 MB" in size.


old
########################################
How to:
  win7sp1 64bit -> Command Prompt:
     cd/d d:\testFolder
     asm2.bat tut_06cX

Have fun!
Don't fighting me, I know I'm not the author, I'm just copy & past. All the fun based on "Mikl__" 's source codes.

Vortex

Hello,

I have doubts about your executable, will it run on every 64-bit version of Windows?

jj2007

Congrats :thumbsup:

Impossibile trovare il percorso specificato.
Premere un tasto per continuare . . .
Impossibile trovare il percorso specificato.
Premere un tasto per continuare . . .
Impossibile trovare C:\Masm32\Members\learn64bit\FF2\tut_06cX.obj
Premere un tasto per continuare . . .

hutch--

I agree with Erol, PE in either 32 or 64 bit is a specification which means 2 512 byte sections which equals 1024 bytes. You can tweak them smaller but they cease to be spec PE files. They may run on one OS version but fail on another.

HSE

Equations in Assembly: SmplMath

TimoVJL

That was a linker test, but it still have two sections, .text and .idata
May the source be with you

Mikl__

Hi, learn64bit!
I am Mikl___
It is necessary that the program, in addition to its tiny size, also has a payload
This PE-exe is 268 bytes in size, but it can display a MessageBox on the screen
format binary as "exe"
include "d:\fasm\include\win64a.inc"
struc dbs [data]
{
  common
  . db data
  .size = $ - .
}

IMAGE_DOS_SIGNATURE equ 5A4Dh
IMAGE_NT_SIGNATURE equ 00004550h
PROCESSOR_AMD_X8664 equ 8664h
IMAGE_SCN_CNT_CODE equ 00000020h
IMAGE_SCN_MEM_WRITE equ 80000000h
IMAGE_SCN_MEM_READ equ 40000000h
IMAGE_SCN_CNT_INITIALIZED_DATA equ 00000040h
IMAGE_SUBSYSTEM_WINDOWS_GUI equ 2
IMAGE_NT_OPTIONAL_HDR64_MAGIC equ 20Bh
IMAGE_FILE_RELOCS_STRIPPED equ 1
IMAGE_FILE_EXECUTABLE_IMAGE equ 2
IMAGE_BASE equ 0x400000
align1 equ 4
use64
org 0
;--------DOS-stub-------------------------------
Signature dw IMAGE_DOS_SIGNATURE,0
;-------PE-заголовок--------------------------------------------------
ntHeader dd IMAGE_NT_SIGNATURE;4;'PE'
;image_header----
Machine dw PROCESSOR_AMD_X8664
Count_of_section dw 0
TimeStump dd 0
Symbol_table_offset dd 0
Symbol_table_count dd 0
Size_of_optional_header dw begin-optional_header
Characteristics dw IMAGE_FILE_RELOCS_STRIPPED or IMAGE_FILE_EXECUTABLE_IMAGE
;-------NT
optional_header:
Magic_optional_header dw IMAGE_NT_OPTIONAL_HDR64_MAGIC
Linker_version_major_and_minor db 14,11
Size_of_code dd Import_Table-begin
Size_of_init_data dd 0x70
Size_of_uninit_data dd 0
entry_point dd start
base_of_code dd begin
;-----------------------------------------------------
image_base dq IMAGE_BASE
section_alignment dd align1
file_alignment dd ntHeader
OS_version_major_minor dw 6,0
image_version_major_minor dd 0
subsystem_version_major_minor dw 6,0
Win32_version dd 0
size_of_image dd end_import
size_of_header dd begin
checksum dd 0
subsystem dw IMAGE_SUBSYSTEM_WINDOWS_GUI
DLL_flag dw 8100h;62h;IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE
Stack_allocation dq 0x100000
Stack_commit dq 0x1000
Heap_allocation dq 0x100000
Heap_commit dq 0x1000
loader_flag dd 0
number_of_dirs dd 2
export_RVA_size dq 0
import_RVA_size dd _import,0x3C;end_import-import
;--------data and code-----------------------------------------
begin: ;9Ch
MsgBoxText dbs "Win64 Assembly is Great!",0;9Ch
MsgCaption db "Uncle R",0
start:
push rbp    
mov edx,MsgBoxText+IMAGE_BASE
lea r8d,[rdx+MsgBoxText.size]
xor ecx,ecx      
xor r9d,r9d      
call [MessageBox]      
pop rbp      
retn      
;---------import section---------------------------------------
Import_Table:
user32_table:
MessageBox  dq _MessageBox
_import:
dd 0,0,0,user32_dll,user32_table,0
user32_dll db "user32"
dd 0
_MessageBox db 0,0,"MessageBoxA",0
end_import:

jj2007

In any case, dear learn64bit, any attempt to build it fails with numerous error messages. No good :cool:

Your batch file is utterly confused, and your source has an "include win64a.inc" that would either need this include file in the same folder, or it would require the user to set an environment variable to its path (which is a horrible thing to do - the Masm SDKs do not require any environment variables, for good reasons).

Note the Campus is meant to help beginners, not to prove that you are a beginner.

TimoVJL

For beginners :biggrin:extern ExitProcess : proc
.code
WinMainCRTStartup proc
;  invoke RtlExitUserProcess,NULL
  mov ecx, 0
  call ExitProcess
WinMainCRTStartup endp
end
from beginner :tongue:
May the source be with you

learn64bit

Cool, Mikl___'s 268 bytes 64-bit Windows GUI Application, and it is x64dbg friendly!

hutch--

learn64bit,

I think you should come back when you have learnt how to write code.