flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
wisepenguin 28 Jul 2006, 17:06
its push ebx edi esi
not push edx edi esi although you shouldnt need them as the proc macro already does it for you (i think, not sure) |
|||
![]() |
|
AsmER 28 Jul 2006, 17:21
Infortunatelly it doesn't fix the problem. I changed 'edx' to 'ebx', ran the program and I got the error. The same situation was even when I removed the push and pop instructions. But thanks (now I have one mistake fewer in my program
![]() |
|||
![]() |
|
wisepenguin 28 Jul 2006, 17:25
yeh i noticed it doesnt fix it too after i tried it.
i keep trying different things but it keeps crashing on me too. i think its because windows is setting some memory you havent allocated or told windows about. im checking the OPENFILENAME docs to see which members need to be set and which need to have buffers allocated |
|||
![]() |
|
wisepenguin 28 Jul 2006, 17:37
the error is in your loop that zeroes out the memory
and also, you need to double null terminate the filter string Code: FileFilter db 'Enigma Files',0, "*.*", 0, 0 DefExt db '*.AEF',0,0 and in your setup openfilename proc replace the loop with Code: push eax invoke RtlZeroMemory, eax, sizeof.OPENFILENAME pop eax |
|||
![]() |
|
wisepenguin 28 Jul 2006, 17:39
here is the working soruce for you to see and use in your own source
Code: format PE GUI 4.0 entry Start include 'win32axp.inc' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; CONTROLS & RESOURCES & MENUS IDs ;;;;;;;;;;;;;;;;;;;;; ID_MAIN_MENU equ 01h ID_FILE equ 02h ID_NEW equ 03h ID_OPEN equ 04h ID_SAVE equ 05h ID_SAVE_AS equ 06h ID_EXIT equ 07h ID_PACKAGE equ 08h ID_ADD_FOLDER equ 09h ID_REMOVE_FOLDER equ 0Ah ID_ADD_FILES equ 0Bh ID_REMOVE_FILES equ 0Ch ID_EXTRACT equ 0Dh ID_CHANGE_PASSWORD equ 0Eh ID_CHOOSE_ENCODING equ 0Fh ID_ABOUT equ 10h ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; D A T A S E C T I O N ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; section '.data' data readable writeable ;; INITIALISED DATA ;; ClassName db 'Enigma by AsmER',0 FileFilter db 'Enigma Files',0, "*.*", 0, 0 DefExt db '*.AEF',0,0 ;; UNINITIALISED DATA ;; WC WNDCLASS ? WMsg MSG ? MainWin dd ? FileBuffer db 260 dup(0) ; 100h ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; C O D E S E C T I O N ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; section '.code' code readable executable Start: invoke GetModuleHandle, 0 mov [WC.hInstance], eax mov [WC.lpfnWndProc], WinProc invoke LoadIcon, 0, IDI_APPLICATION mov [WC.hIcon], eax invoke LoadCursor, 0, IDC_ARROW mov [WC.hCursor], eax mov [WC.hbrBackground], COLOR_BTNFACE+1 mov [WC.lpszClassName], ClassName MOV [WC.lpszMenuName], ID_MAIN_MENU invoke RegisterClass, WC cmp eax, 0 je .End invoke CreateWindowEx, WS_EX_CLIENTEDGE, ClassName, ClassName, WS_VISIBLE+WS_CAPTION\ +WS_SYSMENU+WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 400, 250, 0, 0,\ [WC.hInstance], 0 mov [MainWin], eax .Main_Loop: invoke GetMessage, WMsg, 0, 0, 0 cmp eax, 0 je .End invoke TranslateMessage, WMsg invoke DispatchMessage, WMsg jmp .Main_Loop .End: invoke ExitProcess, [WMsg.wParam] ;;;;;;; W I N P R O C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; proc WinProc Hwnd:DWORD, wMsg:DWORD, wPar:DWORD, lPar:DWORD push ebx edi esi cmp [wMsg], WM_DESTROY je MSG_DESTROY cmp [wMsg], WM_COMMAND je MSG_COMMAND invoke DefWindowProc, [Hwnd], [wMsg], [wPar], [lPar] jmp _End MSG_DESTROY: invoke PostQuitMessage, 0 xor eax, eax jmp _End MSG_COMMAND: mov eax, [wPar] cmp ax, ID_NEW je .MSG_NEW cmp ax, ID_OPEN je .MSG_OPEN cmp ax, ID_SAVE je .MSG_SAVE cmp ax, ID_SAVE_AS je .MSG_SAVE_AS cmp ax, ID_EXIT je .MSG_EXIT cmp ax, ID_ADD_FOLDER je .MSG_ADD_FOLDER cmp ax, ID_REMOVE_FOLDER je .MSG_REMOVE_FOLDER cmp ax, ID_ADD_FILES je .MSG_ADD_FILES jmp _End .MSG_NEW: jmp _End_COMMAND .MSG_OPEN: jmp _End_COMMAND .MSG_SAVE: jmp _End_COMMAND .MSG_SAVE_AS: jmp _End_COMMAND .MSG_EXIT: jmp _End_COMMAND .MSG_ADD_FOLDER: jmp _End_COMMAND .MSG_REMOVE_FOLDER: jmp _End_COMMAND .MSG_ADD_FILES: call OpenFileDlg jmp _End_COMMAND _End_COMMAND: xor eax, eax jmp _End _End: pop esi edi ebx ret endp ;;;;;;; S e t u p O P E N F I L E N A M E ;;;;;;;;;;;;;;;;; proc SetupOPENFILENAME mov ecx, sizeof.OPENFILENAME .Clear_OFN: push eax invoke RtlZeroMemory, eax, sizeof.OPENFILENAME pop eax mov [eax+OPENFILENAME.lStructSize], sizeof.OPENFILENAME mov ecx, [MainWin] mov [eax+OPENFILENAME.hwndOwner], ecx mov [eax+OPENFILENAME.lpstrFilter], FileFilter mov [eax+OPENFILENAME.lpstrFile], FileBuffer mov [eax+OPENFILENAME.nMaxFile], 100h ret endp ;;;;;;; O p e n F i l e D l g ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; proc OpenFileDlg local ofn:OPENFILENAME lea eax, [ofn] call SetupOPENFILENAME mov [ofn.Flags], OFN_EXPLORER invoke GetOpenFileName, addr ofn ret endp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; I M P O R T D A T A S E C T I O N ;;;;;;;;;;;;;;;;;; section '.idata' import data readable writeable library kernel32, 'kernel32.dll',\ user32, 'user32.dll',\ comctl32, 'comctl32.dll',\ comdlg32, 'comdlg32.dll' include 'apia\kernel32.inc' include 'apia\user32.inc' include 'apia\comctl32.inc' include 'apia\comdlg32.inc' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; R E S O U R C E S E C T I O N ;;;;;;;;;;;;;;;;;;;;;;; section 'rscr' resource data readable directory RT_MENU, Menu resource Menu,\ ID_MAIN_MENU, LANG_ENGLISH, main_menu menu main_menu menuitem 'File', ID_FILE, MFR_POPUP menuitem 'New', ID_NEW menuitem 'Open', ID_OPEN menuitem 'Save', ID_SAVE menuitem 'Save As', ID_SAVE_AS menuseparator menuitem 'Exit', ID_EXIT, MFR_END menuitem 'Package', ID_PACKAGE, MFR_POPUP menuitem 'Add Folder', ID_ADD_FOLDER menuitem 'Remove Folder', ID_REMOVE_FOLDER menuseparator menuitem 'Add Files', ID_ADD_FILES menuitem 'Remove Files', ID_REMOVE_FILES menuseparator menuitem 'Extract Selected', ID_EXTRACT menuitem 'Change Password', ID_CHANGE_PASSWORD menuitem 'Choose Encoding Method', ID_CHOOSE_ENCODING, MFR_END menuitem 'About', ID_ABOUT, MFR_END |
|||
![]() |
|
AsmER 28 Jul 2006, 17:55
Actually piece of data section:
Code: FileFilter db 'Enigma Files', 0 DefExt db '*.AEF',0,0 is fine as it appears in the memory as: 'Enigma Files',0,'*.AEF',0,0 but let me get the address of file extension so I don't have to have 'FileFilter' variable and another one i.e: 'FileExtension' containing extension of my program's files (.AEF), so the program is 4 bytes smaller ![]() Code: mov [eax+OPENFILENAME.lpstrDefExt], DefExt should be: Code: mov [eax+OPENFILENAME.lpstrDefExt], DefExt+1 I corrected it after your first reply to this post. Clearing the structure (OPENFILENAME) probably would be faster using sugested by you method but as it is only 76 bytes user wont feel the difference, also my method makes my program smaller (again. small is beautifull - of course not always ![]() |
|||
![]() |
|
wisepenguin 28 Jul 2006, 18:06
i now see what you did with the FileFlter and DefExt, its nice
![]() i just didnt see it before, eyes on other things. you learn something everyday. |
|||
![]() |
|
AsmER 28 Jul 2006, 18:17
Now I know exactly what was the problem. In 'SetOPENFILENAME' procedure, clearing loop was setting to 0 also one byte after OPENFILENAME structure created on the stack. That was the problem
![]() Code: mov ecx, sizeof.OPENFILENAME-1 Thanks wisepenguin, without your sugestion about clearing memory I wont even think that it can be the problem. Thanks again |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.