Re: Is MASM32 an evil Microsoft plot?

From: hutch-- (hutch_at_movsd.com)
Date: 11/13/04


Date: 13 Nov 2004 00:09:59 -0800

Now lets have a look at this can of worms.

> WndProc:
> CMP dword ptr[ESP+8],WM_DESTROY ;Destroy window?
> JNZ DefWindowProcA ;No, pass msg to default msg handler
> PUSH 0
> CALL PostQuitMessage ;Send WM_QUIT message
> XOR EAX,EAX ;Return code
> RET 16

First you make a direct jump into the guts of an API call without
having a clue about what goes on inside the system code, a
particularly dangerous coding practice that risks falling down around
your ears if Microsoft change any of the internals of how the function
works.

What you are assuming here is the architecture of old DOS junk where
byte level size optimisation was supposed to matter but any script
kiddie already knows that procedure alignment trashes most of the so
called advantages of doing so.

Now your next blunder is to call the default windows message handler
when you are following it with a PostQuitMessage() function call. Now
if you had bothered to track down what actually happens when the
PostQuitMessage() sends the WM_QUIT message you would have found out
that the WM_QUIT message is documented to do the following.

WIN32.HLP
======================
Return Values

This message does not have a return value, because it causes the
message loop to terminate before the message is sent to the
application's window procedure.
======================
A classic example of a redundant function call by a highly self
acclaimed leading assembler guru who has all of 5 minutes experience
at programming windows code.

> If you're going to brag about how small the code can be with MASM, at least
> write small code. Nobody is going to believe the propaganda on your site
> until you do. The problem is that you will have to give up all the PROC,
> PROTO and LOCAL nonsense that makes MASM such a travesty to assembly. Then
> you could use most any assembler and the whole advocacy for MASM disappears.

It seems that there is the assumption that you are the only person
around who knows how to manually lay out a procedure.

label:
  ; your code
  retn

Lets do it in HEX to please the kiddies.

;; label:
;; your code to be added
C3 ;; retn

Is there supposed to be some profundity at addressing the stack
manually or is it supposed to be some form of hidden knowledge that a
stack address without a stack frame begins at [esp+4] ?

> Thanks for proving my point.

Not even divine intervention could help you here.

Regards,

hutch at movsd dot com



Relevant Pages

  • Re: Video Mode 13h in windows XP ... impossible?
    ... there is NO problem using mode 13h under XP...if you write a DOS ... terminates so does the "DOS box" and you return to the Windows desktop ... A dedicated assembler (most of which are completely free and available ... NASM, this is _certainty_ that it's okay for you to do so...the people ...
    (alt.lang.asm)
  • Re: Segmentation in real mode
    ... Except that Windows does have its "prohibition" on "direct hardware ... what you're saying about 32-bit programming is still ... Linux is often ignored in this context but it's actually arguably the best ... a "portable assembler", so, you know, it's not really got anything ...
    (alt.lang.asm)
  • Re: singe thread per connection
    ... process is about 2000, with the practical maximum somewhat lower, and performance suffering significantly before that. ... If you use a different stack size than the default, or don't actually allocate one OS thread per Java thread, then the actual limit would be different. ... But in Windows, both in the regular Win32 API and under .NET, there are i/o mechanisms that can be used that allow a single thread to service an arbitrarily large number of i/o tasks. ... This allows a program to create just enough threads to keep all the CPU cores busy, and the Windows scheduler knows to treat those threads specially so that if the only other runnable thread is one that would do the same thing that the currently running thread would do, the currently running thread is allowed to just keep running, rather than being preempted for no good reason. ...
    (comp.lang.java.programmer)
  • Re: ASM noob - couple of questions
    ... comes to Windows programming. ... When you talk of "tutorials for beginners", ... The Visual Tuts? ... learn and unlearn later when using another assembler. ...
    (alt.lang.asm)
  • Re: Iczelions tutorials revisited.
    ... By "local" variables on the stack I assume something like this? ... access parameters and locals that way. ... The Windows API uses "stdcall" in which "callee cleans up stack" - the Windows functions end with "ret N". ... Being an old dos-head, I'm used to using cx as a "counter", and it annoys me that calling libc or the Windows API is allowed to trash it, but that's life... ...
    (alt.lang.asm)