Is it possible to pass an argument as a ptr (like in C i think). Ex : I defined a struct and i call a function invoke func, ADDR structname want i wanted to do is defined func as this func proc &mystruct so i can do mov eax, mystruct.first_element I don't think i'm clear, but if someone understood what i said and could help me...
Posted on 2000-11-15 10:05:00 by scalp
Yeah, you're pretty clear to me. I think what you're looking to do is this: invoke func, addr structname func proc lpStruct:DWORD mov edi,lpStruct assume edi:ptr (your struct name here) mov eax,.first_element ... assume edi:nothing (VERY IMPORTANT!!) There's no way that I know of that's more clear cut than this way, but if I'm wrong, I'll happily admit it.
Posted on 2000-11-15 11:32:00 by Racso
What the...? Gah, Iczelion!! :) Sorry about that. Let me do it over. invoke func,addr structname func proc lpStruct:DWORD mov edi,lpStruct assume edi: PTR (your struct name here) mov eax,.first_element ... assume edi:nothing (VERY IMPORTANT!!) PS: Iczelion, you might wanna go back and check the emoticons for leading and trailing spaces, so that this doesn't happen again. :)
Posted on 2000-11-15 11:35:00 by Racso
that looks good, thanx what does assume really do ? does this work : mov eax, lpStruct mov ecx, .element ??
Posted on 2000-11-15 12:37:00 by scalp
Not directly, no. Assume is a precompiler (or pre-assembler?) directive which tells the assembler that edi isn't a 32 bit value anymore. (This means it doesn't generate unwanted assembler code, too!) Instead, it's a pointer to a data type. You don't have to use assume, but the code you used would generate errors. The only way without assume would be: mov eax,lpStruct mov ecx,(YourStruct PTR ).first_element which not only looks confusing, but eax is a heavily changed register, while edi isn't. :) Either method you choose will get the job done, but I prefer two simple lines of code (ie: assume) as opposed to the data redirection (StructName ptr) for every element. But that's me. :)
Posted on 2000-11-15 12:56:00 by Racso
First let me state that I do a lot of low lever COM stuff, and without some heavy duty structures to keep things organized I'd go mad. Some of these structs point to other structs, and sometimes I go a-walking from one to another, and the cast of a register changes every line. This is an exceptionally heavy usage of structs. Rasco is 100% correct in what he says, but I do the exact opposite. I explicitly cast each register pointer to whatever structure I'm using at the moment. The reson for this is "ASSUME" means action at a distance. I might rememeber to cast a register as some type at the start of a routine, and later on eyeball back to see I actually remembered, BUT, without a careful line ny line scan, I may miss another re-cast of the same register, and get weird hard to find bugs. Yes, it means more typing, but I prefer to code in ways that catch the weakest link in any program: the programmer.
Posted on 2000-11-16 01:07:00 by TTom