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?
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?
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.
Hi Lysic
This twain capture project does pretty much what you ask.
Maybe you can get some ideas.
KetilO
This twain capture project does pretty much what you ask.
Maybe you can get some ideas.
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
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.
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.
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:
:alright: