I'm at my wits end. (Started a new thread.) (Solved. Stupid comma.)

Started by Shooter, December 17, 2010, 05:40:33 PM

Previous topic - Next topic

Shooter

So, does this code:

Tab1Proc FRAME hWin,uMsg,wParam,lParam

cmp D[uMsg],WM_INITDIALOG
jne >.EndTab1Proc
mov eax,TRUE
ret
.EndTab1Proc
mov eax, FALSE
ret

endf


do the same thing as the original MASM32 code:
Tab1Proc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

.if uMsg==WM_INITDIALOG
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

Tab1Proc endp
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Gunner

Not too sure on GoASM syntax...

should be something like:
    cmp   uiMsg, WM_INITDIALOG
   ; its the initdialog message, handle it
   je   _INITDIALOG
   ; all other messages, fall through
PassThrough:   
   xor   eax, eax
   ret
   
_INITDIALOG:
; Do something
   mov   eax, TRUE
   ret
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

I am curious as to why the original code:

Tab1Proc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg==WM_INITDIALOG
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
Tab2Proc endp


wouldn't have been written like this:

Tab1Proc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg==WM_INITDIALOG
mov eax,TRUE
ret
.else
mov eax,FALSE
ret
.endif
Tab1Proc endp


I mean, the first example seems confusing if the second example works.

Secondly, in GoASM is there a difference between FRAME and PROC??
Tab1Proc FRAME hWin,uMsg,wParam,lParam
cmp D[uMsg],WM_INITDIALOG
jne >.EndTab1Proc
mov eax,TRUE
ret
.EndTab1Proc
mov eax,FALSE
ret
endf

Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Gunner

You could write it both ways.... I guess... but after you process the initdialog, it falls through the .if/endif and executes what is after the .endif
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

Quote from: Gunner on December 19, 2010, 03:10:46 AM
You could write it both ways.... I guess... but after you process the initdialog, it falls through the .if/endif and executes what is after the .endif
Unless it hits a return statement, right?
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Shooter

Here's something that's interesting.

This (GoASM):
Tab1Proc FRAME hwnd,uMsg,wParam,lParam
cmp D[uMsg],WM_INITDIALOG
jne >.EndTab1Proc
mov eax,TRUE
ret
.EndTab1Proc
mov eax,FALSE
ret
endf


Translates to this in OllyDbg:
CPU Disasm
Address   Hex dump          Command                          Comments
00401030  |$  55            PUSH EBP                         ; Tab1Proc FRAME hwnd,uMsg,wParam,lParam
00401031  |.  89E5          MOV EBP,ESP
00401033  |.  817D 0C 10010 CMP DWORD PTR SS:[EBP+0C],110
0040103A  |.  75 09         JNE SHORT 00401045
0040103C  |.  B8 01000000   MOV EAX,1
00401041  |.  5D            POP EBP
00401042  |.  C2 1000       RETN 10
00401045  |>  B8 00000000   MOV EAX,0
0040104A  |.  5D            POP EBP
0040104B  \.  C2 1000       RETN 10



Whereas, this (Masm32):
Tab1Proc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg==WM_INITDIALOG
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
Tab2Proc endp


Translates into:
CPU Disasm
Address   Hex dump          Command                                  Comments
00401030  |$  55            PUSH EBP             ;Tab1Proc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
00401031  |.  8BEC          MOV EBP,ESP
00401033  |.  817D 0C 10010 CMP DWORD PTR SS:[EBP+0C],110
0040103A  |.  75 02         JNE SHORT 0040103E
0040103C  |.  EB 09         JMP SHORT 00401047
0040103E  |>  B8 00000000   MOV EAX,0
00401043  |.  C9            LEAVE
00401044  |.  C2 1000       RETN 10
00401047  |>  B8 01000000   MOV EAX,1
0040104C  |.  C9            LEAVE
0040104D  \.  C2 1000       RETN 10


Other than the "POP EBP" vs. "LEAVE" stack changers, they are practically the same code, assuming the RETN 10 does it's job correctly in the GoASM sample. That is, unless the coffee has worn out and my eyes are crossed. :eek
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Shooter

Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.