Hi Again

In an example I have seen this code :



push 0h ;lpParam, extra pointer data 0=no data
push hInstance ;hInstance, handle of our program
push 0h ;hMenu, handle window menu 0=class menu
push 0h ;hWndParent, handle parent window 0=no
push 000000F8h ;
push 0000020Ah ;
push 000000A0h ;
push 000000B0h ;
push 04CA0000h ;<<---- this one
push OFFSET WindowName ;lpWindowName, pointer to window name
push OFFSET ClassName ;lpClassName, pointer to class name
push 0100h ;<<----and this one
call CreateWindowExA ;- API Function -
mov hWnd,eax ;hwnd,return value=handle of window

...

push 14h ;uStructSize,size TBBUTTON structure
push 14h ;dyBitmap,height pixels of the images
push 14h ;dxBitmap,width pixels of the images
push 0h ;dyButton,height pixels of the buttons
push 0h ;dxButton,width pixels of the buttons
push 8h ;iNumButtons,Number buttons in toolbar
push OFFSET iBitmap ;lpButtons,pointer TBBUTTON structure
push 80h ;wBMID,ID for the bitmap resource
push hInstance ;hBMInst,instance bitmap resource
push 8h ;nBitmaps, # of button images in file
push 300h ;wID,control identifier for toolbar
push 54000500h ;;<<----WooooW this one
push WP1_hWnd ;hwnd,handle owner window 0=no owner
call CreateToolbarEx ;- API Function -
mov toolbar00_hWnd,eax ;handle of toolbar child window
Posted on 2003-08-22 08:21:16 by mistronr1
It's the window style and extended style bits. Take a look at the API reference (or M$ site) on CreateWindowEx:
HWND CreateWindowEx(

DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu, or child-window identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
);

I won't post it here because it will take me forever, but you'll find the meaning of each bit all over the API reference. If you want a faster way to translate those bits you have, make a program with that code and open in with OllyDbg.

Ayway, that doesn't seem to be your own code... make sure to read the board rules.
Posted on 2003-08-22 10:18:00 by QvasiModo

The CreateWindowEx function creates an overlapped, pop-up, or child window with an extended style; otherwise, this function is identical to the CreateWindow function. For more information about creating a window and for full descriptions of the other parameters of CreateWindowEx, see CreateWindow.

HWND CreateWindowEx(

DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // pointer to registered class name
LPCTSTR lpWindowName, // pointer to window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // handle to menu, or child-window identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // pointer to window-creation data
);


edit: Note that the params are pushed in reverse order.
Posted on 2003-08-22 10:20:20 by Will
LOL, seems like we both posted at the same time :grin:
Posted on 2003-08-22 10:23:24 by QvasiModo
Ayway, that doesn't seem to be your own code... make sure to read the board rules.


wooow take it easy my friend I never said it was, it's from a tutorial I found at the Test Department's home page. I am just trying to understand it how it works.

Peace
Posted on 2003-08-22 10:57:04 by mistronr1
Yeah, I hate TD's code for that. Very difficult to understand sometimes even when the concept is very simple it can be blurred by the cr*polla "push/push/call - one long list of opcodes" coding style. The funny thing is that I have looked at TD examples and they are extremely good but almost useless to their target audience. They are in desperate need of translation into a more readable format for newcomers.
Posted on 2003-08-22 11:14:49 by donkey
Acctually the push/pop/call doesn't bother me at all, what I like to know is where did he get 54000500h from.

This is what MSDN says about it:

hInstance
Windows 95/98/Me: Handle to the instance of the module to be associated with the window.
Windows NT/2000/XP: This value is ignored.


Now do you just pick a number on top of you head, or there is som numbers you have to know by heart..
Peace
Posted on 2003-08-22 11:34:49 by mistronr1
The parameters are pushed in reverse order, that is the style not the instance handle.
HWND CreateToolbarEx(          HWND hwnd,

DWORD ws,
UINT wID,
int nBitmaps,
HINSTANCE hBMInst,
UINT_PTR wBMID,
LPCTBBUTTON lpButtons,
int iNumButtons,
int dxButton,
int dyButton,
int dxBitmap,
int dyBitmap,
UINT uStructSize
);
Posted on 2003-08-22 12:07:05 by donkey
Hi
I know that parameters are pushed in reverse order,it's STDCALL, but I still manage to get mixed, silly me.
I've asked stupid questions befor, but this one takes the cacke, sorry guys.
:stupid:

Peace
Posted on 2003-08-22 12:51:01 by mistronr1
It's not a stupid question mistronr1, it's just not a standard question or an easy one to answer without some serious digging. That dword is a combination of or'd values. You can manually play with all of the possible valid style equates for that, and or them all together till you come up with that same value. ....or you can do what Donkey said, and use olly. Most window spies show you what styles are set for a given window/control as well.

TD got those values, either by manually or'ing the style values that he wanted, or by assembling/linking and then debugging/disassembling and then entering that value in his source instead of all of the equates. I don't understand why he did it that way, as it only confuses the end user and makes it very difficult to update the code. Hardcoding those values, rather than using the equates doesn't serve any purpose at all that I can see. Maybe he thinks that it makes his coding style more 'leet' or something?

cheers,
will
Posted on 2003-08-22 13:41:05 by Will

Hi
I know that parameters are pushed in reverse order,it's STDCALL, but I still manage to get mixed, silly me.
I've asked stupid questions befor, but this one takes the cacke, sorry guys.
:stupid:

Peace

Actually it's not stupid at all, it just demonstrates exactly why I hate the push/push/call coding style. There is nothing that lends itself to bugz better than that outdated dinosaur style. Invoke will encode the call in the same way but is infinitely more readable and will perform type-checks for you with no run-time overhead. I generally discard these types of code examples as "bad code" that is nothing more than poorly written if it was intended as example code. For your own personal use I think you can do what you want but if your goal is to write examples for beginners, this type of thing is either the product of an inferior coder or just another wannabe leet.
Posted on 2003-08-22 14:52:11 by donkey



wooow take it easy my friend I never said it was, it's from a tutorial I found at the Test Department's home page. I am just trying to understand it how it works.

Peace

Sorry, quick judgment :o
It's TD fault really, their sources look so much like a disassembler's output :grin:
Posted on 2003-08-22 19:00:46 by QvasiModo