Hey all,

Is there a way to declare a struct within memory space you allocated with GlobalAlloc or other memory allocation function? I'm currently working with some TAPI APIs that take structs. The only problem is that the size of these structs taken by the APIs varies considerably. As a result, the only solution is to allocate memory to hold the struct and then check if the function needs more memory for the struct. Currently I don't know any way to tell the compiler that the memory space represents a struct, so I need to work with memory offsets when filling the 'structs' for the APIs.

So, to repeat myself, is there a way to have the compiler think of memory space allocated as a struct? Or do you have any other suggestions that would make the code more elegant and spare me of working with mem addresses?
Posted on 2002-03-31 15:43:43 by Lysic
Well I'd need a specific example, but if lets says eax points to the memory then you can pretend it a struct with .struct.element.
Posted on 2002-03-31 16:08:12 by Eóin
Hi Lysic

This twain capture project does pretty much what you ask.
Maybe you can get some ideas.

KetilO
Posted on 2002-03-31 16:08:44 by KetilO


; assumes eax is a pointer to the allocated memory
assume eax:PTR structurename
mov ecx, [eax].structuremember
..etc..
assume eax:nothing


This will tell masm to assume eax is a pointer to 'structurename', then you can access it's members with .membername. Of course it will work on any register.

Thomas
Posted on 2002-03-31 16:10:43 by Thomas
It works with any thing what can be base pointer.
Imm or reg. Processor just can not address if

it can address only

and so on.
that's why base wich is treated here as address of some struct
may only be reg or known value of offset.
Asm just add to base offset of member in structure.
Posted on 2002-03-31 16:18:33 by The Svin
Thanks, all. I suspected there was a better way to do this than to generate nightmarish code, i just didn't know what it was. Now I do.

:alright:
Posted on 2002-03-31 16:37:56 by Lysic