| | |
Win32 functions in NASM
![]() |
•
•
Join Date: Oct 2006
Posts: 3
Reputation:
Solved Threads: 0
Hello. I was wondering if someone here could tell me what is needed to call a win32 function from NASM. I thought I could declare MessageBox for example with EXTERN and then use LINK to link my object module with user32.lib (from visual studio) but I get "unresolved symbol MessageBox" error when linking. Any ideas what I'm missing or what I'm doing wrong here?
Here's a link to a forum with someone with a similar problem.
http://www.nabble.com/How-to-call-Me...d23420607.html
For this kind of problem, posting code would be more beneficial!
http://www.nabble.com/How-to-call-Me...d23420607.html
For this kind of problem, posting code would be more beneficial!
•
•
Join Date: Oct 2006
Posts: 3
Reputation:
Solved Threads: 0
Thank you for the link. I had to rename the function to _MessageBoxA@16 in my source and it worked. Now I wonder why functions are named like this in the visual studio libraries. Is it a requirement of the linker? How would one go about writing their own routine in assembly to import a function directly from a DLL?
An alternative is to use the Alink downloads:
http://alink.sourceforge.net/download.html
http://alink.sourceforge.net/download.html
Assembly Syntax (Toggle Plain Text)
; To assemble: nasm -f obj hw.asm ; To link: alink -oPE hw .obj win32.lib extern MessageBoxA extern ExitProcess segment .data USE32 title db 'My First Win32 ASM Program', 0 message db 'Hello, World!', 0 segment .text USE32 ..start push dword 0Eh push dword title push dword message push dword 0 call MessageBoxA push dword 0 call ExitProcess
while (CPU is present) {some assembly required}
•
•
Join Date: Oct 2006
Posts: 3
Reputation:
Solved Threads: 0
Thanks for the responses! I'm still confused though as to why functions are named like that. You say its because of multi-language - could you elaborate on that? Also, Microsoft's linker requires the entry point label to begin with an underscore but not other global names I put in my code. Could someone explain why that is?
![]() |
Similar Threads
- Send data on a serial port (C++)
- Using Win32 functions in Visual FoxPro (Website Reviews)
- mouse functions for DOS (C++)
- Win32 vs standard library functions (C++)
- software i developed (Pascal and Delphi)
- Coressponding Linux function/library out of Win32... (C++)
- MFC or no MFC that is the question (C++)
- Which of the .NET Framework Languages Is Best? (ASP.NET)
- Calendar Creator (C)
Other Threads in the Assembly Forum
- Previous Thread: Question on kernel and bootloader written in assembly.
- Next Thread: Assembly wierdness
| Thread Tools | Search this Thread |





