Hey.
how woudl i go about creating a variable...such as:
PIMAGE_DOS_HEADER
in masm?
thx.
Posted on 2004-08-31 22:22:23 by ReVeR
Ok, might get a post for the faq section...

There are two types of variables: initialized and uninitialized.
In MASM we do this the following:



.data ;Initialized data
var1 dd 0h
var2 dd 100d
structexample WNDCLASSEX <0h, ..., ...>
;or structex WNDCLASSEX <0h>

.data? ;Uninitialized data
var3 dd ?
structex2 WNDCLASSEX <?>
;or structex2 PIMAGE_DOS_HEADER <?>


It is also possible to allocate memory. This method is quite nice for creating initialized memory with a specific size. Use the following snippet:



.code
...
invoke GlobalAlloc, GMEM_FIXED or GMEM_ZEROINIT, 1024d ;1kb
mov pointer, eax


If you remove the GMEM_ZEROINIT flag the memory is not initialized any more. Don't forget to release it at the end of your program:



invoke GlobalFree, pointer

The pointer variable is a simple dword, containing the start address of your memory...

There are two other API functions that do just the same: HeapAlloc & HeapFree

Dom
Posted on 2004-09-01 00:20:44 by Dom
Hey.
how woudl i go about creating a variable...such as:
PIMAGE_DOS_HEADER
in masm?
thx.


define the struct in MASM, and create a var with the type of PIMAGE_DOS_HEADER

i.e:



RECT STRUC
dd x1 0
dd x2 0
dd y1 0
dd y2 0
RECT ENDS

.data
myRect RECT <>
Posted on 2004-09-01 00:40:34 by wizzra
PIMAGE_DOS_HEADER is a pointer to IMAGE_DOS_HEADER structure, which is already defined in windows.inc
any pointer is really a dword, so your variable is dd
Posted on 2004-09-01 00:51:56 by comrade