flat assembler
Message board for the users of flat assembler.

Index > Main > can't debug exe file

Author
Thread Post new topic Reply to topic
moriman



Joined: 01 Apr 2006
Posts: 55
Location: Northern Ireland
moriman
Hi,

The code below compiles fine with fasm and I can load it into OllyDbg without any problem. However, 7 lines from line 210 are commented ';' out. These lines refer to a dialog resource. If I uncomment these lines I can still compile it with fasm but both OllyDbg and W32Dasm report
Quote:

The MDI.EXE file appears to be corrupt.
Reinstall the file, and then try again.


Anyone any ideas as to what is happening? Confused

Code:
;file mdi.asm
format PE GUI 4.0

include '%fasminc%\win32a.inc'

entry start

section '.code' code readable executable
start:
        invoke  InitCommonControls
        invoke  GetModuleHandle, NULL
        mov     [hInstance], eax
        mov     dword [MainClass.hInstance], eax
        mov     dword [MDIClass.hInstance], eax
        invoke  LoadIcon, NULL, IDI_APPLICATION
        mov     [MainClass.hIcon], eax
        mov     [MainClass.hIconSm], eax
        mov     [MDIClass.hIcon], eax
        mov     [MDIClass.hIconSm], eax
        invoke  LoadCursor, NULL, IDC_ARROW
        mov     [MainClass.hCursor], eax
        mov     [MDIClass.hCursor], eax
        invoke  RegisterClassEx, MainClass
        or      eax, eax
        jne     @f
        invoke  MessageBox, NULL, WndRegErrStr, ErrStr, MB_ICONEXCLAMATION+MB_OK
        jmp     TerminateApp
    @@:
        invoke  RegisterClassEx, MDIClass
        or      eax, eax
        jnz     @f
        invoke  MessageBox, 0, ChildRegFail, ErrStr, MB_ICONEXCLAMATION+MB_OK
        jmp     TerminateApp
    @@:
        invoke  CreateWindowEx, 0, MainClassName, AppTitle, WS_VISIBLE+WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 480, 320, NULL, NULL, [hInstance], NULL
        or      eax, eax
        jnz     @f
        invoke  MessageBox, NULL, WndCreateErrStr, ErrStr, MB_ICONEXCLAMATION+MB_OK
        jmp     TerminateApp
    @@:
        mov     [hWndMain], eax
        invoke  DrawMenuBar, [hWndMain]
    MsgLoop:
        invoke  GetMessage, Msg, NULL, 0, 0
        or      eax, eax
        je      TerminateApp
        invoke  TranslateMDISysAccel, [MDIhWnd], Msg
        or      eax, eax
        jnz     MsgLoop
        invoke  TranslateMessage, Msg
        invoke  DispatchMessage, Msg
        jmp     MsgLoop
    TerminateApp:
        invoke  FreeLibrary,[hRichEditDll]
        invoke  ExitProcess, 0
;------------------------------------------------------------------------------------------------------------
proc CreateNewMDIChild, hMDIClient
        push    [hInstance]
        pop     [mcs.hOwner]
        ret
endp
;------------------------------------------------------------------------------------------------------------
proc MainProc, hwnd, msg, wParam, lParam
        push    ebx esi edi
        cmp     [msg], WM_CREATE
        je      .wmCREATE
        cmp     [msg], WM_CLOSE
        je      .wmCLOSE
        cmp     [msg], WM_DESTROY
        je      .wmDESTROY
        cmp     [msg], WM_COMMAND
        je      .wmCOMMAND
    .wmDEFAULT:
        invoke  DefFrameProc, [hwnd], [MDIhWnd], [msg], [wParam], [lParam]
        jmp     .wmFINISH
    .wmCREATE:
        invoke  GetMenu, [hwnd]
        invoke  GetSubMenu, eax, 2
        mov     [ccs.hWindowMenu], eax
        mov     [ccs.idFirstChild], ID_MDI_FIRSTCHILD
        invoke  CreateWindowEx, WS_EX_CLIENTEDGE, MDICLIENT, NULL,WS_CHILD+WS_CLIPCHILDREN+WS_VSCROLL+WS_HSCROLL+WS_VISIBLE,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,[hwnd], IDC_MAIN_MDI, [hInstance], ccs
        mov     [MDIhWnd], eax
        or      eax, eax
        jne     @f
        invoke  MessageBox, [hwnd], CreateMDIErrStr, ErrStr, MB_OK+MB_ICONERROR
    @@:
        jmp     .wmBYE
    .wmSIZE:
        invoke  GetClientRect, [hwnd], rcClient
        invoke  SetWindowPos, [hMDI], NULL, 0, 0, [rcClient.right], [rcClient.bottom], SWP_NOZORDER
        jmp     .wmBYE
    .wmCLOSE:
        invoke  DestroyWindow, [hwnd]
        jmp     .wmBYE
    .wmDESTROY:
        invoke  PostQuitMessage, 0
        jmp     .wmBYE
    .wmCOMMAND:
                        mov     eax, [wParam]
                        and     eax, 0FFFFh
                        cmp     eax, ID_NEW_SS
                        je      .id_new_ss
                    .idDEFAULT:
                        cmp     eax, ID_MDI_FIRSTCHILD
                        jl      .j1
                        invoke  DefFrameProc, [hwnd], [MDIhWnd], WM_COMMAND, [wParam], [lParam]
                        jmp     .wmFINISH
                    .j1:
                        invoke  SendMessage, [MDIhWnd], WM_MDIGETACTIVE,0,0
                        mov     [hChild], eax
                        or      eax, eax
                        je      @f
                        invoke  SendMessage, [hChild], WM_COMMAND, [wParam], [lParam]
                    @@:
                        jmp     .wmBYE
                    .id_new_ss:
                        mov     [mcs.lParam], ID_NEW_SS
                        stdcall CreateNewMDIChild, [MDIhWnd]
                        jmp     .wmBYE
    .wmBYE:
        xor     eax, eax
    .wmFINISH:
        pop     edi esi ebx
        ret
endp
;------------------------------------------------------------------------------------------------------------
proc MDIChildWndProc, hwnd, msg, wParam, lParam
                push    ebx esi edi
                cmp     [msg], WM_CREATE
                je      .wmCREATE
                cmp     [msg], WM_SIZE
                je      .wmSIZE
            .wmDEFAULT:
                invoke  DefMDIChildProc, [hwnd], [msg], [wParam], [lParam]
                jmp     .wmFINISH
            .wmCREATE:
                int3
                invoke  CreateDialogParam, [hInstance], IDD_MYDLG, [hwnd], MyProc, 0
            .wmSIZE:
                invoke  GetClientRect, [hwnd], rcClient
                invoke  GetDlgItem, [hwnd], IDC_CHILD_EDIT
                mov     [hEdit], eax
                invoke  SetWindowPos, [hEdit], NULL, 0, 0, [rcClient.right], [rcClient.bottom], SWP_NOZORDER
                jmp     .wmDEFAULT
            .wmBYE:
                xor     eax, eax
            .wmFINISH:
                pop     edi esi ebx
                ret
endp
;------------------------------------------------------------------------------------------------------------
proc MyProc, hdlg, msg, wparam, lparam
endp
;______________________________________________________________________________________________________________

section '.data' data readable writeable

AppTitle                db ' MDI Test Module', 00
ccs                     CLIENTCREATESTRUCT
ChildRegFail            db 'Could Not Register Child Window', 00
CreateMDIErrStr         db 'Could not create MDI client.', 00
ErrStr                  db 'Error!', 00
hChild                  dd ?
hEdit                   dd ?
hInstance               dd ?
hMDI                    dd ?
hRichEditDll            dd ?
hWndMain                dd ?
IDC_CHILD_EDIT          = 101
IDC_MAIN_MDI            = 101
MainClass               WNDCLASSEX      sizeof.WNDCLASSEX, 0, MainProc, 0, 0, 0, 0, 0, COLOR_BTNFACE+1, IDR_MAINMENU, MainClassName, 0
MainClassName           db 'MainClass', 0
mcs                     MDICREATESTRUCT MDIClassName, McsTitle, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, MDIS_ALLCHILDSTYLES, 0
McsTitle                db 'Untitled', 00
MDIClass                WNDCLASSEX      sizeof.WNDCLASSEX, CS_HREDRAW+CS_VREDRAW, MDIChildWndProc, 0, 0, 0, 0, 0, COLOR_BTNFACE+1, NULL, MDIClassName, 0
MDIClassName            db 'MDIClass', 0
MDICLIENT               db 'MDICLIENT', 00
MDIhWnd                 dd ?
Msg                     MSG
rcClient                RECT
WndCreateErrStr         db 'Window Creation Failed!', 00
WndRegErrStr            db 'Window Registration Failed!', 00
;______________________________________________________________________________________________________________

section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',\
        user32,  'USER32.DLL',\
        gdi32,   'GDI32.DLL',\
        comdlg32,'COMDLG32.DLL',\
        advapi32,'ADVAPI32.DLL',\
        comctl32,'COMCTL32.DLL'

include '%fasminc%\apia\Kernel32.inc'
include '%fasminc%\apia\User32.inc'
include '%fasminc%\apia\Gdi32.inc'
include '%fasminc%\apia\Comdlg32.inc'
include '%fasminc%\apia\Advapi32.inc'
include '%fasminc%\apia\Comctl32.inc'
;______________________________________________________________________________________________________________

section '.rsrc' resource data readable

IDR_MAINMENU            = 102
ID_MDI_FIRSTCHILD       = 50000
ID_NEW_SS               = 50001
IDD_MYDLG               = 50010
ID_DP                   = 50011

directory \
        RT_MENU, menus          ;,\
                                ;RT_DIALOG, dialogs

resource menus,\
        IDR_MAINMENU, LANG_ENGLISH + SUBLANG_DEFAULT, main_menu

;resource dialogs,\
;        IDD_MYDLG, LANG_ENGLISH + SUBLANG_DEFAULT, MyDlg

menu main_menu
        menuitem '&File',0,MFR_POPUP+MFR_END
        menuitem        '&New', ID_NEW_SS, MFR_END

;dialog  MyDlg, 'Dialog', 20, 20, 214, 80, WS_CHILD + WS_VISIBLE, 0, 0, 'MS Shell Dlg', 8
;        dialogitem 'EDIT', '', ID_DP, 58, 8, 108, 12, WS_BORDER+WS_VISIBLE+ES_NUMBER
;enddialog
    
Post 24 Jun 2006, 01:00
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.