Related Projects > NASMX

Which include file(s) from NASM-X to use for 64-bit?


I have a simple program using GetStdHandle and WriteFile from windows.h.  I downloaded the NASM-X files to get the NASM include version of windows.h. 

My program is 64-bit. There is a in the win32 folder, but when I use it ("%include ""), I get a long list of errors.  That appears to be because it's only for 32-bit and my program is 64-bit. 

When I include the file (%include ""), I get only the error that GetStdHandle, WriteFile are not defined in the object file.  GetStdHandle and WriteFile are very basic Windows API commands, so I would think they would be included. 

So my question is, which include file from NASM-X should I use for 64-bit NASM?  Do I need to use more than one?  The docs are not clear on this point. 

Here is the code:

%include ""

global main
extern GetStdHandle
extern WriteFile

section .text
    mov     rcx, 0fffffff5h
    call    GetStdHandle

    mov     rcx, rax
    mov     rdx, NtlpBuffer
    mov     r8, [NtnNBytesToWrite]
    mov     r9, NtlpNBytesWritten
    sub     rsp, 40
    mov     dword [rsp + 32], 00h
    call    WriteFile
    add     rsp, 40
    xor     eax, eax

section .data
NtlpBuffer:        db    'Hello, World!', 00h
NtnNBytesToWrite:  dq    0eh

section .bss
NtlpNBytesWritten: resd  01h

I'm using GoLink as the linker. 

Thanks for any info. 

I answered this question.  Using GoLink, just include kernel32.dll in the command string (following the /dll switch):

GoLink Win_API_Program.obj /dll msvcrt.dll kernel32.dll

and it works. 

Frank Kotler:
Good! I haven't written anything for Windows since Win98 was current, and don't have any experience with 64-bit code of any flavor, so listen to dreamCoder's advice, not mine!

NASMX is not well documented. The fantasy is that the demos will guide you in its use. I see demos in the "win64" directory including files with "32" in the names. Can that be right? I dunno.

This particular code doesn't need an include file at all, as dreamCoder advises. This is an easy answer. If you do need an include file, you'll get errors about "undefined" symbols. Look in the include files you've got to see where it's defined. Then either include that file, or define it in your own source code.

Glad to hear you got it working!



[0] Message Index

Go to full version