© Jo Van Hoey 2019
J. Van HoeyBeginning x64 Assembly Programminghttps://doi.org/10.1007/978-1-4842-5076-1_43

43. Windows Files

Jo Van Hoey1 
(1)
Hamme, Belgium
 

In Linux, we used syscalls to manipulate files. In Windows, we have to follow other rules. As mentioned in previous chapters, we use the Windows API.

Listing 43-1 shows the example code.
%include "win32n.inc"
extern printf
extern CreateFileA
extern WriteFile
extern SetFilePointer
extern ReadFile
extern CloseHandle
section .data
    msg      db 'Hello, Windows World!',0
    nNumberOfBytesToWrite equ $-msg
    filename db  'mytext.txt',0
    nNumberOfBytesToRead  equ 30
    fmt      db "The result of reading the file: %s",10,0
section .bss
    fHandle                resq 1
    lpNumberOfBytesWritten resq 1
    lpNumberOfBytesRead    resq ...

Get Beginning x64 Assembly Programming: From Novice to AVX Professional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.