windows - How to link kernel32.lib and user32.lib using a combination of `nasm` and `alink`? -


how link kernel32.lib , user32.lib using combination of nasm , alink?

i'm following tutorials on assembly programming , guide wants me execute following commands:

nasm  -fobj hello.asm                                     alink -ope hello \lib\kernel32.lib \lib\user32.lib 

the first command executes expected, second command fails.

to link .lib files, i've copied them

c:\program files (x86)\microsoft sdks\windows\v7.1a\lib 

into current folder.

the error messages when executing second command is:

loading file hello.obj loading file kernel32.lib 2327 symbols loaded first linker member loading file user32.lib 1385 symbols loaded first linker member matched externs matched comdefs unresolved external messageboxa unresolved external exitprocess 

now, i've 2 questions:

1) kernel32.lib , user32.lib located?

2) how can link these library files properly?

the operating system windows 10 (64-bit).

update:

; coded nasm                                           ; ; nasm  -fobj hello.asm                                    ; ; alink -ope hello \lib\kernel32.lib \lib\user32.lib       ;                                                            ; extern messageboxa              ; apis used                ; extern exitprocess              ; in file             ;                                                            ; [section code use32 class=code] ; code section             ; ..start:                        ; linker           ;                                                            ;     push byte 0                 ; buttons 'ok'    ;      push dword caption          ; caption of box       ;     push dword text             ; text in box          ;     push byte 0                 ; handle of box        ;       call messageboxa          ; print box on screen      ;                                                            ;     push byte 0                 ;                          ;       call exitprocess          ; exit                     ;                                                            ;     caption db "your first win32 programm",0               ;     text db "hello",0                                      ;                                                            ; end                             ; linker 

i haven' found kernel.lib or user.lib can used alink. may due format of needed .obj files, while windows .obj's formatted in coff alink wants feeded omf.

a suitable win32.lib here. includes messageboxa not exitprocess. it's not recommended terminate pure windows program simple ret.

however, nasm can job if not better:

; import needed win32 api functions.- http://www.nasm.us/doc/nasmdoc7.html#section-7.4.4 import exitprocess kernel32.dll import messageboxa user32.dll  ; still needed declared external extern exitprocess, messageboxa  [section code use32 class=code] ; code section ..start:     push 0                  ; buttons 'ok'     push dword caption      ; caption of box     push dword text         ; text in box      push 0                  ; handle of box     call [messageboxa]      ; print box on screen      push 0     call [exitprocess]      caption db "your first win32 programm",0     text db "hello",0 

please note functions decorated brackets when being called. furthermore, it's better place variables in separate data section.

if plan huge project bunch of import's bunch of .dll's tahe @ nasmx project.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -