Author Topic: Responding to Windows msg. WM_DESTROY  (Read 16608 times)

mcamember

  • Guest
Responding to Windows msg. WM_DESTROY
« on: September 03, 2007, 12:53:15 AM »
My question concerns responding to the Windows WM_DESTROY
message using NASM.

In Microsoft Macro Assembler the following code is used in
response to the WM_DESTROY message :

.if uMsg ==  WM_DESTROY
        invoke PostQuitMessage, NULL
        xor eax,eax
        ret
    .endif

When I port that exact code to Netwide Assembler the program
crashes on exit :

if dword argv(umsg), ==, WM_DESTROY
         invoke PostQuitMessage, NULL
         xor eax,eax
         ret
       endif

My solution has been to eliminate the RET and allow the
pointer to fall through to DefWndProc. Amazingly, this
works with no apparent problem and the program exits
gracefully and seems stable.

if dword argv(umsg), ==, WM_DESTROY
         invoke PostQuitMessage, NULL
         xor eax,eax
;         ret <---------- RET eliminated
       endif

. . . more code

DefWndProc etc.  <---- falls through to here


;------------------------------------------------------
As a test, I trapped the ESC key using VK_ESCAPE and
inserted the original code. It worked with no problems.

It seems to be only in response to WM_DESTROY that
the problem occurs.

I scanned the NASM bug reports for WM_DESTROY and
PostQuitMessage but there were no hits.
Thanks in advance.

nobody

  • Guest
Re: Responding to Windows msg. WM_DESTROY
« Reply #1 on: September 03, 2007, 01:53:28 PM »
Quote
.if uMsg == WM_DESTROY
invoke PostQuitMessage, NULL
xor eax,eax
ret
.endif

When I port that exact code to Netwide Assembler the program
crashes on exit :

if dword argv(umsg), ==, WM_DESTROY
invoke PostQuitMessage, NULL
xor eax,eax
ret
endif

"high level" of assembly = HIGH LEVEL of DANGER !!!

Just disassemble both and the bug must become ooooobviousssssss (if not found meanwhile)

mcamember

  • Guest
Re: Responding to Windows msg. WM_DESTROY
« Reply #2 on: September 03, 2007, 03:19:26 PM »
Hi,
Thanks for the quick reply and the pointers.
Austin

nobody

  • Guest
Re: Responding to Windows msg. WM_DESTROY
« Reply #3 on: September 04, 2007, 01:48:35 PM »
Hi!

> if dword argv(umsg), ==, WM_DESTROY
> ..
> endif

Sorry, I'm courious about the macros set that you are using.
What macro set are you using for control (if) constructions
and for Win32 specific code (WM_DESTOY)?

----
nmt