News:

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

Why wont this INVOKE work?

Started by Trope, March 25, 2005, 12:21:16 AM

Previous topic - Next topic

Trope

This has to do with creating a dialog box as main.

This is NOT my code, I am just tearing through it to study it.

Ok, this is HIS code:



call GetModuleHandleA ; module base
mov hInst, eax ; save it

sub edx,edx

push edx ; lParam WM_INITDIALOG
push offset _dlgproc ; dialog proc
push edx ; parent handle
push IDD_DIALOG1 ; ID
push eax ; module base
call DialogBoxParamA

      jmp _normal_exit            ; Only here when dialog is closed



and I wanted to simplify it to this:



call GetModuleHandleA ; module base
mov hInst, eax ; save it

        invoke DialogBoxParamA,  NULL, addr _dlgproc, NULL, IDD_DIALOG1, hInst




and it don't work. Says invalid argument 2.

Any ideas why this is happening?


hutch--

Giovanni,

Try this from the MASM32 example code. Its in example2\resdlg2 .


    .code

start:

      invoke GetModuleHandle, NULL
      mov hInstance, eax
     
      ; -------------------------------------------
      ; Call the dialog box stored in resource file
      ; -------------------------------------------
      invoke DialogBoxParam,hInstance,ADDR dlgname,0,ADDR WndProc,0

      invoke ExitProcess,eax

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

raymond

Trope

When you use the invoke, the parameters are pushed in the reverse order; i.e. the last parameter is pushed first, followed by the second-to-last, etc.., the first parameter being pushed last.

When you look at the description of an API in the Win32 Programmer's Reference, the parameters would be listed in the sequence they should appear following invoke. And the last parameter listed would be the first one pushed.

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com