News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

option prologue/epilogue

Started by cobold, May 26, 2009, 08:13:30 AM

Previous topic - Next topic

fearless

With the debug.lib i use to print the string of the function name, this seemed to work, i just put it in the function after all the local declarations, like this example:


MyFunc PROC SomeParameter:DWORD
LOCAL SomeLocalVar:DWORD

%echo testing xprocname
.data
%xxproc db "&xprocname&",0
.code
PrintString xxproc
ƒearless

dedndave

if you create an exe and look inside, the names of all the API functions are in there
there must be a way to access those strings for error handling
it would be nice if we could make use of them (once)
it would be nice if we didn't have to declare them (a second time)

labelA: INVOKE  WriteFile,
                StdOutHandle,
                addr Buffer,
                WriteCount,
                addr WrittenCount,
                NULL
        or      eax,eax
        jnz     labelB

        INVOKE  GetLastError
        push    eax
        print   chr$('Error: ')
        pop     eax
        call    Hex32
        print   edi
        print   chr$(' in Function: WriteFile at Address: ')
        mov     eax,labelA
        call    Hex32
        print   edi
        print   chr$(13,10)
        stc
        ret

labelB:


it would be great if i could make a generic handler routine that would do this for all function calls

Jimg

Jochen-

As you know, to have a var be substituted into a quoted string, it has to have an & prepended.  Also, it often needs a % at the start of the line to force substitution.  chr$ does not have the %, so we need a new chr$ if you are going to pass macro strings.

Try this-

chrx$ MACRO any_text:VARARG
    LOCAL txtname
    .data
        %txtname db any_text,0,0,0,0
    .code
    EXITM <OFFSET txtname>
ENDM

invoke MyTest, 0, 0, 0, chrx$("Hello...");addr hlo


MyTest proc hwnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
xTitle CATSTR <chrx$("&xprocname")>
    % echo TITLE_IN_PROC: xprocname

  invoke MessageBox, 0, lParam, xTitle, MB_YESNOCANCEL


This works for me.

jj2007

Bloody hell, it works ::)

I had tried all sorts of combinations. If you like surprises, substitute chrx$ with good ol' chr$. It doesn't work.
The culprit is here:
Quote     chr$ MACRO any_text:VARARG
        LOCAL txtname
        .data
          % txtname db any_text,0
        .code
        EXITM <OFFSET txtname>
      ENDM

Without the %, it won't work.

Attached a variant for debugging, showing the proc and the first arg but no more than 3 times:
MyTest__B            arg1=1001
MyTest___C           arg1=2002
MyTest___C           arg1=2003
MyTest____D          arg1=3004
MyTest____D          arg1=3005
MyTest____D          arg1=3006
MyTest_A             arg1=100
MyTest_A             arg1=99
MyTest_A             arg1=98
MyTest____D          arg1=3010
MyTest____D          arg1=3011

[attachment deleted by admin]

UtillMasm

 :U
oh my fo! this below Macro function is case sensitive. :wink
@InStr