Hi guys !!

I'm having a real problem here !!! I have coded a little application on XP and it works fine, but when its run on ME it crashes !?!?! I have no clue to what causes the crash. I dont have ME installed on my PC and therefore I have a hard time debugging the source code..... If somebody could please tell me whats wrong with the code I would be gratefull. The application runs fine on Win9x too. Its crashes right after performing the code in wParam == IDC_CALC. The stack is preserved as far as I can see when debugging it on XP !!

I'm clueless .... Hope someone can help !?!?!

invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam, hInstance, IDD_MAINDLG, NULL, addr DlgFunc, NULL
invoke ExitProcess, NULL

DlgFunc proc hDlg:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg == WM_CLOSE
invoke EndDialog,hDlg,NULL
.elseif uMsg == WM_INITDIALOG
invoke GetWindowRect, hDlg, offset DlgRect
invoke GetDesktopWindow
invoke GetWindowRect, eax, offset DesktopRect
push NULL
mov eax, DlgRect.bottom
sub eax, DlgRect.top
mov DlgHeight, eax
push eax
mov eax, DlgRect.right
sub eax, DlgRect.left
mov DlgWidth, eax
push eax
mov eax, DesktopRect.bottom
sub eax, DlgHeight
shr eax, 1
push eax
mov eax, DesktopRect.right
sub eax, DlgWidth
shr eax, 1
push eax
push hDlg
call MoveWindow
.elseif uMsg == WM_COMMAND
.if wParam == IDC_EXIT
invoke SendMessage, hDlg, WM_CLOSE, 0, 0
.elseif wParam == IDC_CALC
invoke GetDlgItemText, hDlg, IDC_NAME, addr TypedName, 20
.... some code ....



mov eax, FALSE
mov eax, TRUE

DlgFunc endp

end start

:( Catch 22
Posted on 2003-06-17 11:46:51 by catch 22
Quoted from win32.hlp for WM_COMMAND
Return Values

If an application processes this message, it should return zero.

Your dlgproc should return zero after WM_COMMAND is processed.
Posted on 2003-06-17 13:06:18 by roticv
There is a known issue with register preservation moving from NT to 9x, always preserve the esi,edi and ebx registers. Not doing so will present the problem you have shown. The return zero of WM_COMMAND only applies to Windows, with dialogs you are doing it correctly as you have it shown. Add the following:

DlgFunc proc uses esi edi ebx hDlg:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
Posted on 2003-06-17 13:27:19 by donkey
Hi donkey,

But I doubt he used edi, esi and ebx in his code.
Posted on 2003-06-17 13:29:56 by roticv
Hi roticv,

I have had code that hasn't used them and was trashed by not preserving them when moving to ME, I think it might have to do with certain dialog oriented API calls not properly preserving the registers in 9x. He is calling the API there and we are not sure what he is doing to the data after it has been extracted. In general this is the first thing I check when moving to a 9x based platform.
Posted on 2003-06-17 13:48:32 by donkey
A quick test of wrapping the code with a pusha and popa, will determine that.

Regards, P1 :cool:
Posted on 2003-06-17 13:53:02 by Pone
Hi guys

and thanks for the quick replies !!!

I do indeed use both EDI and ESI in my code ... But does this error only occur on ME or ... ??? As I said I have no problems on either XP or win9x. And I do not PUSHA/POPA at the begining/end of my code.

My problem is, as I said, that I dont run ME so I'm having a hard time trying your guys theories until the dude that reported the bug can report back !!

Anyway, thanks alot for your quick replies !!!

:grin: Catch 22
Posted on 2003-06-17 15:14:55 by catch 22
If you're going to do alot of multi-platform code you should think about getting Connectix VirtualPC , I use a VPC with 98SE installed to test on the 9x platform. The register preservation issue exists on all versions of 9x I have tried.
Posted on 2003-06-17 15:24:46 by donkey
Thanks !!

Sounds like a very good tool for programmers ... I?ll look into it !!!
Posted on 2003-06-18 05:08:07 by catch 22

Your dlgproc should return zero after WM_COMMAND is processed.
It's the reverse for dialog procs. Dialog procs should return zero if a message is not processed. (There are about a dozen messages for which this is not true.) The WM_COMMAND handler should return zero when it is processed in a standard window proc.
Posted on 2003-06-18 15:42:37 by tenkey