Hi guys,
This is my first post on these nice forums :O
I am using nasmx..



%include "C:\nasmx\inc\nasmx.inc"
%include "C:\nasmx\inc\win32\windows.inc"
%include "C:\nasmx\inc\win32\kernel32.inc"
%include "C:\nasmx\inc\win32\user32.inc"


var db "OMG", 0



uvar resb 256



mov eax,
push 0
call ExitProcess


It says ExitProcess is undeclared but it should be declared in kernel32.inc (i think)
When I remove it it compiles fine, but it gives a linker warning that there is no valid entrypoint.
Sorry for being noobish I don't have a lot of experience with asm.


Posted on 2008-02-04 12:59:35 by ASMFreak
NASMX has to do some macro magic to wrap up those external function calls that have extra formatting symbols and whatnot.

What you are looking for is to use invoke for those particular calls, not call...


invoke ExitProcess, DWORD 0


HtH ;)
Posted on 2008-02-04 14:58:18 by SpooK
You problem is you havn't defined the starting point in your program. I havn't studied the nasmx macros, but try:



%include "C:\nasmx\inc\nasmx.inc"
%include "C:\nasmx\inc\win32\windows.inc"
%include "C:\nasmx\inc\win32\kernel32.inc"
%include "C:\nasmx\inc\win32\user32.inc"

global start


var db "OMG", 0



uvar resb 256


start:
mov eax,
push dword 0
call ExitProcess


this should get you to assemble atleast
Posted on 2008-02-04 15:39:56 by jakor
Nice catch jakor, as "global start" would solve the other half of his problem by satisfy liking requirements.

However, invoke is still needed, so take a look at the following code and adapt accordingly...




%include "C:\nasmx\inc\nasmx.inc"
%include "C:\nasmx\inc\win32\windows.inc"
%include "C:\nasmx\inc\win32\kernel32.inc"
%include "C:\nasmx\inc\win32\user32.inc"

global start


var db "OMG", 0


uvar resb 256


start:
mov eax, DWORD
invoke ExitProcess, DWORD 0


HtH ;)
Posted on 2008-02-04 16:25:25 by SpooK
but invoke would just be a macro to handle the parameters.
push dword 0 ; = 0x00000000
call ExitProcess ; = 0x00000000
; = Return Address
;now a "long jump" is made to ExitProcess
;which takes care of cleaning everything up
Posted on 2008-02-04 17:15:54 by jakor

but invoke would just be a macro to handle the parameters.


To what extent are you familiar with the actual invoke macro? Handling the parameters is only half of what invoke does.

If you look at the naming (mangling) conventions in Kernel32.dll, you will notice that ExitProcess is actually _ExitProcess@4. This, or something like this, is the case for almost every other function/variable found in the DLLs... and really most other linked code developed/used in a higher level language.

Invoke encapsulates the full symbolic library name so that you don't have to deal with junk symbols. Secondly, invoke tracks library call declarations and ensures EXTERN is issued appropriately, only once, and only if needed.
Posted on 2008-02-04 18:23:17 by SpooK
ah... got it, I was using a different macro which let me name my imports, and figured that the kernel32.inc he had renamed them to their standard names. interesting information though!
Posted on 2008-02-04 20:51:02 by jakor
If you want to use CALL with the new NASMX system (since things have changed from NASM32) you can use this new CALL macro.

%imacro CALL 1
%push call
%ifdef __imp_defined_%1
%ifndef __imp_declared_%1
EXTERN __imp_defined_%1
%define __imp_declared_%1
%endif
call __imp_defined_%1
%else
call %1
%endif
%pop
%endmacro


I've put it in my BKMACROS.INC file for when I use my "NASMX_COMPATIBLITY" mode, but you could add it straight to your NASMX.INC file so you wouldn't have to add any extra includes later on. Below is a rewrite of DEMO1.ASM using the above macro located in NASMX.INC

%include '..\..\..\inc\nasmx.inc'
%include '..\..\..\inc\win32\windows.inc'
%include '..\..\..\inc\win32\kernel32.inc'
%include '..\..\..\inc\win32\user32.inc'

entry    demo1


proc    demo1

    push      dword szTitleTwo
    push      dword szContentTwo
    call      my_p

    push      dword MB_OK
    push      dword szTitle
    push      dword szContent
    push      dword NULL
    call      MessageBoxA

    xor      EAX, EAX
    push      EAX
    call      ExitProcess
    ret

endproc

proc    my_p
sz_Content    argd
sz_Title      argd

    push      dword MB_OK
    push      dword argv(sz_Title)
    push      dword argv(sz_Content)
    push      dword NULL
    call      MessageBoxA
    ret

endproc

_data
    szTitle:      db  'Demo1', 0x0
    szTitleTwo:    db  'Demo1 Procedure', 0x0
    szContent:    db  'Hello from the Application!', 0x0
    szContentTwo:  db  'Hello from the Procedure!', 0x0


Hopefully this helps you do what you want with NASMX. This wasn't added to NASM32 because there wasn't a high enough demand for it and we wanted to keep overloading of opcodes to a minimum. IIRC there was also one or two bugs that occured due to how the old system worked with doing this (I think it was the argument counting or something like that) it's been a while.. that doesn't apply anymore with the NASMX versions.

Regards,
Bryant Keller
Posted on 2008-02-04 22:26:03 by Synfire
Thanks alot guys, I have it working :D

Ps. Expect some more questions from me :P
Posted on 2008-02-05 01:20:33 by ASMFreak