The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
March 23, 2023, 08:56:17 AM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  Project Support Forums
| |-+  MASM32
| | |-+  Memory dialogs revisited.
« previous next »
Pages: 1 2 [3] Print
Author Topic: Memory dialogs revisited.  (Read 23944 times)
dedndave
Member
*****
Posts: 12523


Re: Memory dialogs revisited.
« Reply #30 on: March 18, 2011, 01:03:08 PM »

Code:
   mov icce.dwSize, SIZEOF INITCOMMONCONTROLSEX
   xor eax, eax
   or eax, ICC_ANIMATE_CLASS
   or eax, ICC_BAR_CLASSES
   or eax, ICC_COOL_CLASSES
   or eax, ICC_DATE_CLASSES
   or eax, ICC_HOTKEY_CLASS
   or eax, ICC_INTERNET_CLASSES
   or eax, ICC_LISTVIEW_CLASSES
   or eax, ICC_PAGESCROLLER_CLASS
   or eax, ICC_PROGRESS_CLASS
   or eax, ICC_TAB_CLASSES
   or eax, ICC_TREEVIEW_CLASSES
   or eax, ICC_UPDOWN_CLASS
   or eax, ICC_USEREX_CLASSES
   or eax, ICC_WIN95_CLASSES
   mov icce.dwICC, eax
   invoke InitCommonControlsEx,ADDR icce

yikes !

how about.....
Code:
ICC_FLAGS = ICC_WIN95_CLASSES
ICC_FLAGS = ICC_FLAGS or ICC_ANIMATE_CLASS
ICC_FLAGS = ICC_FLAGS or ICC_BAR_CLASSES
ICC_FLAGS = ICC_FLAGS or ICC_COOL_CLASSES
ICC_FLAGS = ICC_FLAGS or ICC_DATE_CLASSES
ICC_FLAGS = ICC_FLAGS or ICC_HOTKEY_CLASS
ICC_FLAGS = ICC_FLAGS or ICC_INTERNET_CLASSES
ICC_FLAGS = ICC_FLAGS or ICC_LISTVIEW_CLASSES
ICC_FLAGS = ICC_FLAGS or ICC_PAGESCROLLER_CLASS
ICC_FLAGS = ICC_FLAGS or ICC_PROGRESS_CLASS
ICC_FLAGS = ICC_FLAGS or ICC_TAB_CLASSES
ICC_FLAGS = ICC_FLAGS or ICC_TREEVIEW_CLASSES
ICC_FLAGS = ICC_FLAGS or ICC_UPDOWN_CLASS
ICC_FLAGS = ICC_FLAGS or ICC_USEREX_CLASSES

       .DATA
icc INITCOMMONCONTROLSEX <sizeof INITCOMMONCONTROLSEX,ICC_FLAGS>

       .CODE
       INVOKE  InitCommonControlsEx,offset icc
total size ~ 18 bytes

Hutch - i doubt there is any harm in initializing controls you don't use
although, it may use memory unnecessarily
the problem i see is that if you don't initialize the ones you do use....
.... it has to be tested on a platform that exhibits the problem   Cry
Logged
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: Memory dialogs revisited.
« Reply #31 on: March 18, 2011, 01:31:05 PM »

Dave,

Apart from the MASM line length limit there is nothing to stop you from orring the whole lot together so that you only had 4 bytes but size is not the problem, I am trying to quantify why initialising all of the controls works on some Windows versions but not others and by versions I mean the language version. I cannot duplicte the problem with any of my US English versions.

I have the OR list for convenience of being able to comment them in and out, not for minimum size even though their memory usage is trivial.
Logged

Regards,



Download site for MASM32
http://www.masm32.com
dedndave
Member
*****
Posts: 12523


Re: Memory dialogs revisited.
« Reply #32 on: March 18, 2011, 01:35:04 PM »

that's why i listed them seperately, as well - so you can comment them out

i see a lot of uninitialied structures - initialized in code
if you initialize a dword in code, it usually takes at least 5 bytes   dazzled
why not just pre-initialize the data - execution time = 0 - and it is smaller
(it might make sense if much of the structure need not be initialized)
Logged
Antariy
Member
*****
Gender: Male
Posts: 1041


Re: Memory dialogs revisited.
« Reply #33 on: March 18, 2011, 01:56:26 PM »

Alex,

I have no doubt that many read you post, its just that I remembered it.  ThumbsUp

Thank you, Hutch! BigGrin
Logged
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: Memory dialogs revisited.
« Reply #34 on: March 18, 2011, 02:07:49 PM »

Dave,

The assumption that the size matters is one we don't share, this type of stuff most probably would not line up to the next 512 byte section. I am far more interested in getting it to work on multiple language versions.
Logged

Regards,



Download site for MASM32
http://www.masm32.com
Antariy
Member
*****
Gender: Male
Posts: 1041


Re: Memory dialogs revisited.
« Reply #35 on: March 18, 2011, 02:10:24 PM »

Jochen:
Code:
call InitCommonControlsEx ; this will never be called, but

wink this is right, the dll just should be statically linked. On my system InitCommonControls code is just a RET as first instruction of the "function". Very funny.
What it is on other systems?
Logged
Vortex
Raider of the lost code
Member
*****
Gender: Male
Posts: 3460



Re: Memory dialogs revisited.
« Reply #36 on: March 18, 2011, 06:49:52 PM »

Hi Hutch,

Thanks for the new version of the example. It works fine. InitCommonControls solved the problem.

Hi Antariy,

I remembered for your posting, thanks.
Logged

Ramon Sala
Easy Code programmer
Member
*****
Gender: Male
Posts: 425


Re: Memory dialogs revisited.
« Reply #37 on: March 18, 2011, 07:39:18 PM »

Hi Hutch,

This is my report for catalan and spanish versions of Windows:

Win2K3 Server and Win7 32-64 bit: The dialog works fine without initializing common controls.

WinXp SP3: The dialog just works if common controls are initialized. However, calling InitCommonControls is enough (no need to call InitCommonControlsEx).

Regards.
Logged

Greetings from Catalonia
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: Memory dialogs revisited.
« Reply #38 on: March 18, 2011, 07:53:08 PM »

wink this is right, the dll just should be statically linked. On my system InitCommonControls code is just a RET as first instruction of the "function". Very funny.
What it is on other systems?

Win XP SP2, Italian edition: InitCommonControls is just a retn, and static linking without actually calling it makes the dialog work Roll Eyes
InitCommonControlsEx has the same positive effect, but when you call it, there is a bit more than just a retn. It starts with the intelligent opcode mov edi, edi ;-)
Logged

dedndave
Member
*****
Posts: 12523


Re: Memory dialogs revisited.
« Reply #39 on: March 18, 2011, 11:24:40 PM »

perhaps there is more to it than meets the eye
it may be that pulling the function in also pulls in some other code and/or data that is not readily obvious
Logged
Pages: 1 2 [3] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!