Masm32 utility that runs under XP and Vista, but not under Win2000

Started by Rsir, December 20, 2008, 10:44:29 PM

Previous topic - Next topic

Rsir

hi,
I struggle with a problem quite a few days.
In RadASM I made a couple of utilities that are usefull for me.
All of them work nice under xp and vista, but two refuse to
start under win2000.
They all work in the same manner;
Enter some variables in edit boxes and start a calculation.
They are all smaller than 10k.
If I can manage to upload the program, is there anybody who will look at it?
And suggest what I can do to solve the problem?


[attachment deleted by admin]

MichaelW

One problem that I see is the call to StrToFloat from WndProc. StrToFloat is one of the few remaining procedures in the MASM32 library (up to and including version 10) that alters EBX/ESI/EDI without preserving them. Preserving these registers in WndProc would protect against all such problems. Within my experience Windows 2000 seems to be more sensitive to this than Windows XP.
eschew obfuscation

hutch--

It does need to be fixed but in the mean time before and after the call preserve and restore EBX ESI and EDI and it should solve the problem.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Rsir

Thank you Michael and Hutch.
Your suggestion did not do the job.
plaqnil.exe doesn't crash, it simply doesn't start in W2000.
Where other programs with the same structure and the same
parameters in RadASM do fine in W2000.
Do you have other suggestions?
I tried both to push/pop the individual registers as well as
the pushad/popad combination.
Sorry for not translating the non-english texts in the source.
The essence of the utility is to easy and fast calculate if someone
perhaps takes a dose of an anti-rheumatic medicine that will be harmfull
for his eyesight in the future.

jj2007

Your program fails for
invoke CreateDialogParam,hInstance,IDD_DIALOG,NULL,addr WndProc,NULL
(exit code null)

MichaelW

And after CreateDialogParam fails, GetLastError returns ERROR_CANNOT_FIND_WND_CLASS, and the problem is with the "msctls_statusbar32" class. This can be corrected by calling InitCommonControls somewhere above the call to CreateDialogParam. It's interesting that the code apparently works without registering the common control classes under Windows XP and Vista.
eschew obfuscation

Rsir

Thank you jj007 and Michael for tracing the source of the failure.
I have other utilities with the same phrase in WinMain Proc :

  "invoke CreateDialogParam,hInstance,IDD_DIALOG,NULL,addr WndProc,NULL"
 
They work fine in W2000.

So the next question; How to alter the parameter(s) of CreateDialogParam
The 'win32 API' helpfile doesn't bring me any further.

MichaelW

The problem is not in the CreateDialogParam parameters.

MSDN:About Common Controls
Quote
Most common controls belong to a window class defined in the common control DLL. The window class and the corresponding window procedure define the properties, appearance, and behavior of the control. To ensure that the common control DLL is loaded, include the InitCommonControlsEx function in your application. You create a common control by specifying the name of the window class when calling the CreateWindowEx function or by specifying the appropriate class name in a dialog box template.

Even though InitCommonControls is obsolete, it worked in my test and I have seen it used in a lot of working code.

So you should be able to correct the problem with a simple:

invoke InitCommonControls

Somethere above the call to CreateDialogParam, or with the more complex:

LOCAL iccex:INITCOMMONCONTROLSEX
mov iccex.dwSize, SIZEOF INITCOMMONCONTROLSEX
mov iccex.dwICC, ICC_BAR_CLASSES
invoke InitCommonControlsEx, ADDR iccex


eschew obfuscation

Rsir

Michael. You were right. My utility now works even on a W2000 machine.
Thank you very much.

jj2007

Quote from: MichaelW on December 21, 2008, 09:09:36 PM
It's interesting that the code apparently works without registering the common control classes under Windows XP and Vista.

It did not work on my XPSP2, but the invoke InitCommonControls solved the problem. I wonder if it depends on whether you run other software in parallel that uses the statusbar class... ::)

ecube

MichaelW  you're 1 of the most intelligent people on here, you think 1 day you can write down a list of things in masm32 that you think need to be fixed and/or added? maybe hutch or others can help do it. I know for verison 10 hutch seemed to have removed the com examples, some icezlion tuts and files are missing and some include files need to be updated to accommodate vista.