The MASM Forum

General => The Campus => Topic started by: BolterVi on March 16, 2016, 03:15:42 AM

Title: MASM Macro Text Code Line
Post by: BolterVi on March 16, 2016, 03:15:42 AM
Hello,

I was wondering if it's possible to receive the text of a specific code line with macros as string.

As example (Just random code):

1. mov eax, 4
2. cmp eax, 5
3. jb @F
4. sub eax, 1
5. ...


and with a macro i can receive the code line as text like

m1 macro
    LOCAL t
    t CATSTR <Line 4:>, $-X
    echo t
endm


where $-X stands for the desired line.
The output should be something like:

Line 4:sub eax, 1


Just wondering if something like that is possible, if not it's okay.

Regards,
BolterVi
Title: Re: MASM Macro Text Code Line
Post by: jj2007 on March 16, 2016, 03:24:49 AM
Hi BolterVi,

Welcome to the forum :icon14:

To my knowledge, that is not possible. But if your goal is to display certain lines of your source, or to analyse your sources, there are plenty of other ways to do it. Simple example:

include \masm32\MasmBasic\MasmBasic.inc      ; download (http://masm32.com/board/index.php?topic=94.0)
  Init
  Recall (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1172) "MySource.asm", L$()      ; load a textfile into a string array
  Inkey "Line 4: ", L$(4)          ; print line 4 and wait for a key
EndOfCode


What exactly do you want to achieve?
Title: Re: MASM Macro Text Code Line
Post by: BolterVi on March 16, 2016, 03:49:22 AM
Hey!

Thanks for your fast reply. :)

I thought about creating a small packer/obfusactor by using macros.
As example there would be mutation macros

MUTATION_START
;Example code here:
xor ecx, ecx
@@:
;something here..
inc ecx
cmp ecx, 5
jb @B
MUTATION_END


and the code between those macros is getting mutated.
This was just an idea flying around in my head :)