News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Compile IDA generated asm in MASM64

Started by greenozon, March 23, 2024, 07:46:27 AM

Previous topic - Next topic

greenozon

hitting most probably some kid issues like

test.exe4.asm(1473) : error A2008:syntax error : near
test.exe4.asm(2505) : error A2008:syntax error : retn

those are coming from the IDA style like generating the

sub_1400016F0   proc near 
.........

                retn

sub_1400016F0   endp


are there any easy/generic way to calm masm64 down?
as I"ve got tons of those near/retn  cases...

sinsi

near textequ <>
retn textequ <ret>
Untested, but that's what I would try.

greenozon

Good point, sinsi, thanks!

I added this at the top of my .asm

include \masm64\include64\masm64rt.inc

near textequ <>
retn textequ <ret>



but masm64 still doesn't like it:


test.exe4.asm(3) : error A2008:syntax error : near
test.exe4.asm(977) : error A2008:syntax error : near



I need smth like in C/C++
#define near   //empty macros

anymore ideas?

greenozon

it turned out "near" is a reserved keyword in MASM64...
what is the the correct usage of it?
why does IDA generate an .asm that has broken usage?..

greenozon

Another question in the IDA regard:

algn_1400025CE:                         ; DATA XREF: .pdata:000000014035D00C↓o
                align 20h


masm64 complains:


: error A2189:invalid combination with segment alignment : 32

and I've got hundreds of these kind of issues...


Interestingly, it does not bark on this one:
                align 10h

sinsi

Quote from: greenozon on March 23, 2024, 08:58:47 PMit turned out "near" is a reserved keyword in MASM64...
what is the the correct usage of it?
why does IDA generate an .asm that has broken usage?..
You could try
option nokeyword:nearThat would disable any use of near

jj2007

Quote from: sinsi on March 23, 2024, 08:34:51 AMnear textequ <>
retn textequ <ret>
Untested, but that's what I would try.

Another option is a replace all, deleting near completely and turting retn into ret. Preferably with an editor that allows full word search.

greenozon

Great! thanks for fast replies!

1) when I've added this to the top of .asm

option nokeyword:near

I've hit it as well...

test.exe4.asm(4) : error A2008:syntax error : near

so most probably the best way would be to just replace 'proc near' with 'proc'

this is not the best option (as I plan to have lots of iterations IDA -> produce .asm -> compile using masm64 -> ... again

interestingly that the retn is gone with TEXTEQU replacement :)
thanks

greenozon

#8
hm-hm
MS guys shed some light, so the initial hint was right!

https://developercommunity.visualstudio.com/t/masm-option-nokeyword-should-accept-non-keywords-f/1057286

this works like a charm:

option NoKeyword:<near>

kudos!

greenozon

Now much bigger and painful error:

its declaration of Unicode strings in data segments..
there are thousands of strings like


asc_1401AAFF8:                          ; DATA XREF: sub_1400016F0+CEF↑o
                text "UTF-16LE", ', ',0

of course masm64 chokes on this..

any ideas how easily one could align existing IDA string syntax into masm64 compatible one?
provided that strings are Unicode, not a regular ANSI ones..

sinsi

Older versions of IDA used to write a macro to take care of unicode strings, check the ASM output file.

greenozon

wow, very interesting!
do you mean Ida embeds the body of the "text" macro when creating .asm output?
it is not the case in my case... (IDA 8.3)

greenozon

masm64 also doesn't like local vars in procedures named as
Format
Size

and some others

jj2007

Write a little parser and replace all offending words with Masm64-compatible stuff. Btw reverse engineering is not allowed here :cool:

greenozon

10 years in prison or what?
do you know what I"m working on?