News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Re: InitCommonControlsEx() test on memory dialog.

Started by dedndave, March 19, 2011, 06:40:55 AM

Previous topic - Next topic

dedndave

i fail to see how my method has anything to do with dos
nor have you really showed how there has anything wrong with it

but - i am interested in finding out what works and what doesn't on these non-English machines
so, i will simply call you Hutch "Bloat" Hutchesson and leave you be   :lol

i say we let Jochen run it through the mill
he has enough experience writing test code - and a machine that exhibits the problem
it would be nice if he would detail the behaviour and inform us

hutch--

 :bg

When you can improve on the 4 byte orred result, let me know.  :P
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

ICC_FLAGS = ICC_WIN95_CLASSES
;comment out the ones you do not want
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

donkey

No data section structure, just the call:

push 03FFh ; all classes
push 8 ; size
invoke InitCommonControlsEx,esp
add esp,8
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

jj2007

Quote from: donkey on March 19, 2011, 06:58:26 AM
No data section structure, just the call:

push 03FFh ; all classes
push 8 ; size
invoke InitCommonControlsEx,esp
add esp,8


Thanks, Edgar - that should make both Dave and Steve B. Hutchesson happy :bg

Quote from: dedndave on March 19, 2011, 06:40:55 AM
i say we let Jochen run it through the mill
he has enough experience writing test code - and a machine that exhibits the problem

There is no problem, actually. The dialog won't work if you never mention InitCommonControls. But 1. the Ex is not needed, and 2. even this works:
.code
pop dword ptr InitCommonControls  ; pop=trying hard to provoke a GPF in AVIRA's heuristic scanner
start:
mov hInstance, FUNC(GetModuleHandle,NULL)
call main
invoke ExitProcess, eax

hutch--

Dave,

1 DWORD.


    mov icce.dwICC, 00000001h or 00000002h or 00000004h or 00000008h or 00000010h or 00000020h or \
                    00000040h or 00000080h or 000000FFh or 00000100h or 00000200h or 00000400h or \
                    00000800h or 00001000h or 00002000h or 00004000h or 00008000h


What I do need apart from the trivialities of byte cpounting is a few folks with other language Windows versions to test the test piece to see if it displays the standard controls when the style flags are set to zero.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

it is one dword - ICC_FLAGS
and - no MOV instruction

hutch--

And an initialised DATA section entry.


       .DATA
icc INITCOMMONCONTROLSEX <sizeof INITCOMMONCONTROLSEX,ICC_FLAGS>
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

that is 8 bytes for data, 10 bytes for code
18 bytes in the PE file

push sizeof INITCOMMONCONTROLSEX
pop icc.dwSize
push AnyValue
pop icc.dwICC
invoke InitCommonControlsEx,offset icc

that looks like about 26 bytes in code - and 8 bytes in uninitialized data
might be 24 bytes in code if AnyValue is small enough
and - that does not count all those OR instructions

you must have worked for microsoft in a previous life   :P

jj2007

Edgar's code is correct and does it in 16 bytes, data included.

dedndave

show me - i can't find Edgar's code - well - not the 16 byte version

i count 8 bytes for data and 10 bytes for the invoke

oh - this code
push 03FFh ; all classes
push 8 ; size
invoke InitCommonControlsEx,esp
add esp,8


so - this would be the same size, then...
ICC_FLAGS = ICC_WIN95_CLASSES
;comment out the ones you do not want
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

push ICC_FLAGS
push sizeof INITCOMMONCONTROLSEX
invoke InitCommonControlsEx,esp
add esp,8


i am gonna use it   :U
i was counting bytes wrong when i looked at doing it that way

hutch--

 :bg

Microsoft orthodoxy gives you this.


    mov icce.dwSize, SIZEOF INITCOMMONCONTROLSEX        ; set the structure size
    mov icce.dwICC, 00000001h or 00000002h or 00000004h or 00000008h or 00000010h or 00000020h or \
                    00000040h or 00000080h or 000000FFh or 00000100h or 00000200h or 00000400h or \
                    00000800h or 00001000h or 00002000h or 00004000h or 00008000h
    invoke InitCommonControlsEx,ADDR icce               ; initialise the common control library

0040101D C745E008000000         mov     dword ptr [ebp-20h],8
00401024 C745E4FFFF0000         mov     dword ptr [ebp-1Ch],0FFFFh
0040102B 8D45E0                 lea     eax,[ebp-20h]
0040102E 50                     push    eax
0040102F E898030000             call    jmp_InitCommonControlsEx

23 bytes.


You guys are worried about what you can save off 23 bytes, come on, pull the other leg.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

Quotecome on, pull the other leg

:lol

really - it's a matter of developing good practice
if you get into the habit of writing small code, it will add up in the overall size of a program

hutch--

Close range byte counting usually ends up with crappy code for no gain. Instruction count matters in some speed critical algos, the rest is accuracy and reliability.

I have been hearing guys trying to relive the old DOS days of byte counting in an 8088 where it may have mattered, on anything after an i486 is just does not matter but often the old style code is hard to read, harder to modify and maintain and slower for some trivial size gain. The humour is it tends to get lost in the procedure alignment and section alignment with the assembled binary.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

you don't wanna suck all the fun out of it   :P