flat assembler
Message board for the users of flat assembler.

Index > Windows > Hello world on x64

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 02 Oct 2014, 08:59
flatH wrote:
It's kinda hard to find a sample for x64 and console (no message box)...
Here is one without any GUI, just the console:
Code:
format pe64 console
entry start

STD_OUTPUT_HANDLE       = -11

section '.text' code readable executable

start:
        sub     rsp,8*7         ; reserve stack for API use and make stack dqword aligned
        mov     rcx,STD_OUTPUT_HANDLE
        call    [GetStdHandle]
        mov     rcx,rax
        lea     rdx,[message]
        mov     r8d,message_length
        lea     r9,[rsp+4*8]
        mov     qword[rsp+4*8],0
        call    [WriteFile]
        mov     ecx,eax
        call    [ExitProcess]

section '.data' data readable writeable

message         db 'Hello World!',0
message_length  = $ - message

section '.idata' import data readable writeable

        dd      0,0,0,RVA kernel_name,RVA kernel_table
        dd      0,0,0,0,0

kernel_table:
        ExitProcess     dq RVA _ExitProcess
        GetStdHandle    dq RVA _GetStdHandle
        WriteFile       dq RVA _WriteFile
                        dq 0

kernel_name     db 'KERNEL32.DLL',0
user_name       db 'USER32.DLL',0

_ExitProcess    db 0,0,'ExitProcess',0
_GetStdHandle   db 0,0,'GetStdHandle',0
_WriteFile      db 0,0,'WriteFile',0    
Post 02 Oct 2014, 08:59
View user's profile Send private message Visit poster's website Reply with quote
flatH



Joined: 30 Sep 2014
Posts: 11
flatH 02 Oct 2014, 09:40
I get "Error: undefined symbol 'GetStdHandle'.
Instruction: "call[getStdHandle]"
Post 02 Oct 2014, 09:40
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 02 Oct 2014, 10:11
Did you copy the entire source? Scroll down to see more of it.
Post 02 Oct 2014, 10:11
View user's profile Send private message Visit poster's website Reply with quote
flatH



Joined: 30 Sep 2014
Posts: 11
flatH 02 Oct 2014, 10:25
Oh, lol Very Happy Thanks for your code example Smile
Post 02 Oct 2014, 10:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.