flat assembler
Message board for the users of flat assembler.

Index > Windows > [fasmg] w64g03.asm, uses gets_s and printf

Author
Thread Post new topic Reply to topic
yeohhs



Joined: 19 Jan 2004
Posts: 195
Location: N 5.43564° E 100.3091°
yeohhs 12 Jan 2018, 12:05
Code:
;===============================================================================
;Program : w64g03
;Version : 0.0.1
;Author  : Yeoh HS
;Date    : 7 January 2018
;Purpose : A Win64 console program that uses gets_s and printf
;fasmg   : i17sx
;===============================================================================
include 'format/format.inc'

format PE64 Console
entry start

section '.text' code readable executable

  start:
        sub         rsp,8*5
    
        lea     rdx, [Prompt]
        lea     rcx, [FormatString]
        call    [printf]
    
        mov     rdx, 80
        lea     rcx, [UserInput]
        call    [gets_s]

        lea     rdx, [UserInput]
        lea     rcx, [Welcome]
        call    [printf]    
    
        xor     ecx, ecx
        call    [ExitProcess]

section '.data' data readable writeable
  FormatString db '%s',0
  Prompt         db 'Enter a string and press Enter: ',0
  Welcome      db 'You entered: %s',0
  UserInput      rb 80

section '.idata' import data readable writeable

  dd 0,0,0,RVA kernel_name,RVA kernel_table
  dd 0,0,0,RVA msvcrt_name,RVA msvcrt_table
  dd 0,0,0,0,0

  kernel_table:
    ExitProcess dq RVA _ExitProcess
    dq 0
  
  msvcrt_table:
    printf         dq RVA _printf
    gets_s       dq RVA _gets_s
    dq 0
    
  kernel_name db 'Kernel32.dll',0
  msvcrt_name db 'msvcr100.dll',0
  
  _ExitProcess dw 0
    db 'ExitProcess',0
  _printf dw 0
    db 'printf',0
  _gets_s dw 0
    db 'gets_s',0
    
Post 12 Jan 2018, 12:05
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.