flat assembler
Message board for the users of flat assembler.
Index
> Windows > Moving address of structure in FASM? |
Author |
|
itsnobody 07 Oct 2008, 03:18
I need to move the address of a NMHDR structure to the pointer in lparam....how do you do this in FASM?
|
|||
07 Oct 2008, 03:18 |
|
baldr 09 Oct 2008, 20:17
revolution,
"Address of the label" sounds funny. Labels are just constants with value equal to some value, usually current offset, aren't they? (They may have associated type info, I know) itsnobody, To "move the address" you need this address. If it is static, just mov the appropriate constant (name it using label, if you wish) into lParam, as revolution suggested. For dynamic-allocated case (be it automatic stack-frame-based or heap-based variable) you will need to calculate the address (lea exx, [localNMHDR] for stack-based or simply mov exx, [pheapNMHDR] will be enough in most cases) beforehand. |
|||
09 Oct 2008, 20:17 |
|
revolution 10 Oct 2008, 01:18
baldr wrote: "Address of the label" sounds funny. Labels are just constants with value equal to some value, usually current offset, aren't they? (They may have associated type info, I know) |
|||
10 Oct 2008, 01:18 |
|
bitRAKE 10 Oct 2008, 03:36
The address of the label is the present position of the envelope apon which the address label(s) is/are affixed. Can you imagine trying to use relative addressing on a postal letter.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
10 Oct 2008, 03:36 |
|
itsnobody 10 Oct 2008, 15:15
But it doesn't work, I've tried everything, I can't just do mov [structureName],eax or anything like that...I don't need to get the address of the structure...I just need the structureName to point to whats in lparam
So how I can make the structureName point to what's in lparam? |
|||
10 Oct 2008, 15:15 |
|
bitRAKE 10 Oct 2008, 15:19
label StructureName at lparam ?
I have a feeling you are going to need to show us some code to get to the bottom of this. If the address of the structure is in lparam then just load it into a register to use it. mov eax,[lparam] mov ecx,[eax + MyStruct.MyItem] _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
10 Oct 2008, 15:19 |
|
itsnobody 10 Oct 2008, 15:32
For some reason when I did [eax+MyStruct.MyItem] it didn't work...but when I counted where it was and did [eax+8] it did work
Oh well that works for me for now |
|||
10 Oct 2008, 15:32 |
|
LocoDelAssembly 10 Oct 2008, 15:41
Code: proc WindowProc hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_NOTIFY je .wmnotify cmp [wmsg],WM_DESTROY je .wmdestroy .defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp .finish .wmdestroy: invoke PostQuitMessage,0 xor eax,eax .finish: pop edi esi ebx ret .wmnotify: mov eax, [lparam] mov eax, [eax+NMHDR.code] jmp .defwndproc endp Compiles for me. My code is not an example of proper handling of WM_NOTIFY of course, I'm just doing a hit testing to confirm that the structure is defined in the standard package. |
|||
10 Oct 2008, 15:41 |
|
baldr 21 Oct 2008, 18:18
revolution,
revolution wrote: What is wrong with address of label? "It defines the label whose value is equal to offset of the point where it’s defined." -- excerpt from FASM.PDF. I mean that label does not have an address (say COFF ), it's value is just an offset from some base. |
|||
21 Oct 2008, 18:18 |
|
baldr 21 Oct 2008, 18:46
itsnobody,
Do you use struc directive for NMHDR? It differs from struct macroinstruction from MACRO\STRUCT.INC in many ways. This is (easily compiled) example of latter's use: Code: proc WndProc hWnd, wMsg, wParam, lParam mov eax, [lParam] virtual at eax notification NMHDR end virtual mov eax, [notification.code] |
|||
21 Oct 2008, 18:46 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.