Pelles C forum

Assembly language => Assembly discussions => Topic started by: Jokaste on October 30, 2017, 11:12:36 AM

Title: InitCommonControlsEx
Post by: Jokaste on October 30, 2017, 11:12:36 AM
This code is bad:
Code: [Select]

                     call   InitCommonControlsEx
                     call   InitCommonControls

it would have been written like this:

Code: [Select]
                     mov      rax,OFFSET SomeWhere
                     push   rax
                     mov      rax,OFFSET InitCommonControls
                     push   rax
                     jmp      InitCommonControlsEx
SomeWhere :


"InitCommonControlsEx" must be the last because I initialize RCX register with a pointer on a structure.
In theory it's good, but in practice it crashes without me having any idea of the cause! So if anyone has an idea I accept it.
Title: Re: InitCommonControlsEx
Post by: jj2007 on October 30, 2017, 11:39:54 AM
InitCommonControlsEx takes one parameter, a pointer to the structure, and in 64-bit code you must pass it in rcx, not on the stack.
Title: Re: InitCommonControlsEx
Post by: Jokaste on October 30, 2017, 12:12:53 PM
The RCX register is initialized before any push
I suppose the RSP register is not in the form the function is waiting for.
Title: Re: InitCommonControlsEx
Post by: TimoVJL on October 30, 2017, 12:24:44 PM
What for is that InitCommonControls() when InitCommonControlsEx() was used?
InitCommonControls() only load that COMCTL32.dll ?
Title: Re: InitCommonControlsEx
Post by: Jokaste on October 30, 2017, 12:27:03 PM
For common controls and for themes.


Quote
Registers and initializes certain common control window classes. This function is obsolete. New applications should use the InitCommonControlsEx (https://msdn.microsoft.com/en-us/library/windows/desktop/bb775697(v=vs.85).aspx)
Title: Re: InitCommonControlsEx
Post by: TimoVJL on October 30, 2017, 12:47:45 PM
InitCommonControls() is only a stub function for reference comctl32.dll.
You don't have to call it, if that dll is already referenced by import library.

Code: [Select]
InitCommonControls:
ret
nop
nop
...