flat assembler
Message board for the users of flat assembler.
Index
> Main > Problem creating a wrapper with "macro" instructio |
Author |
|
revolution 12 Oct 2013, 01:12
fasm does not support inline macros. The parser does not do macro substitution within argument parameters. 'GetCmd' is not substituted unless you define it with equ or fix.
|
|||
12 Oct 2013, 01:12 |
|
Sasha 12 Oct 2013, 01:20
But 'invoke' is a macroinstruction. How does it work?
|
|||
12 Oct 2013, 01:20 |
|
revolution 12 Oct 2013, 02:14
The invoke macro has special support for nested invoke's inside of it. This does not extend to just any random macro instruction unless you specifically alter the invoke macro code to detect them.
|
|||
12 Oct 2013, 02:14 |
|
Sasha 12 Oct 2013, 10:23
And what about 'unexpected instruction' error? I can define a macro with the same name as imported function, but I can not define a macro with the same name as my own function. Is the solution in exporting my functions to dll?
|
|||
12 Oct 2013, 10:23 |
|
revolution 12 Oct 2013, 11:38
If we look at the proc macro we see how it will try to define the procedure name:
Code: if used Error Error: ;expanded to ---> stdcall Error,: ;... end if Note that if the macro is defined after the label name then it will compile: Code: if used Error Error: ;defines the label name end if macro Error Msg {stdcall Error,Msg} Error "Error Message" |
|||
12 Oct 2013, 11:38 |
|
Sasha 12 Oct 2013, 14:34
In other words, I need to define macroses after the procedures. But procedures are defined in the code segment and are used in the code segment. So the macroses have to be defined in the code segment, too. But it is not the common way! Generally, the macroses are defined at the begining of the source file. So what's the solution? Modify the 'proc' macro to remove this check?
|
|||
12 Oct 2013, 14:34 |
|
revolution 12 Oct 2013, 14:51
Perhaps you can try using the label directive in the proc macro:
Code: ;... if used name label name ;try with this instead of 'name:' ;.,. |
|||
12 Oct 2013, 14:51 |
|
Sasha 13 Oct 2013, 10:24
Thanks, it seems working on this example. I'm going to test it on my project.
|
|||
13 Oct 2013, 10:24 |
|
Sasha 13 Oct 2013, 15:12
You've seen, that defining a macro with the same name as imported function, works. Look at 'GetCommandLine'.
But there is something wrong with ExitProcess. Using standard headers or modified gives the same result. Code: include 'win32ax.inc' macro ExitProcess ExitCode{invoke ExitProcess,ExitCode} .code start: ExitProcess 0 .end start ;<<Error: Invalid operand. Instruction: push dd RVA _label?Uj Defining ExitProcess without an exitcode operand leads to this: Code: include 'win32ax.inc' macro ExitProcess{invoke ExitProcess,0} .code start: ExitProcess .end start ;<<Error: Invalid macro arguments |
|||
13 Oct 2013, 15:12 |
|
revolution 13 Oct 2013, 15:38
This occurs for all APIs. Look at the IMPORT32.INC file and you see this:
Code: label dd RVA _label Code: ExitProcess dd RVA _label Code: invoke ExitProcess,dd RVA _label |
|||
13 Oct 2013, 15:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.