Is there a way to get or convert a string pointer to "equ" text?
Text db "A text string",0
TXT equ offset Text
print TXT,10 ;will show "A text string"
But TXT by itself evaluates to "offset Text"
How can I get TXT to evaluate to A text string.
TXT equ <A text string> with a string pointer.
the question is a bit out of context, i think
if you show us how you intend to use the EQUate, we can give more information
but, you can make the EQUate resolve to a string
that string, however, will only have meaning at assembly-time - it cannot be referenced at run-time
MyTXT TEXTEQU <A text string>
maybe this is what you are trying to do...
MyTXT TEXTEQU <offset TXTStr>
.data
TXTStr db "A text string",13,10,0
.code
print MyTXT
the assembler simply substitutes the text "MyTXT" with "offset TXTStr", prior to assembly-time evaluation
In my Dll a string pointer to a structure name is passed.
What I need is the sizeof the structure.
sRec equ <offset Txt>
sSize equ <sizeof sRec> <-This is what I can't figure out.
I would think that sRec should
be replaced with structure name.
.data
Txt db "NONCLIENTMETRICS",0
.code
Thamks
well - you shouldn't need to use EQUates, at all
.data?
NcmStruc NONCLIENTMETRICS <>
; cbSize As Long
; iBorderWidth As Long
; iScrollWidth As Long
; iScrollHeight As Long
; iCaptionWidth As Long
; iCaptionHeight As Long
; lfCaptionFont As LOGFONT
; iSMCaptionWidth As Long
; iSMCaptionHeight As Long
; lfSMCaptionFont As LOGFONT
; iMenuWidth As Long
; iMenuHeight As Long
; lfMenuFont As LOGFONT
; lfStatusFont As LOGFONT
; lfMessageFont As LOGFONT
.code
mov NcmStruc.cbSize,sizeof NcmStruc
then pass the address of the structure as "offset NcmStruc"
notice that LOGFONT is also a structure (length of 60 bytes, i think)
"long"s are dwords in asm-speak :bg
i come up with a NONCLIENTMETRICS structure size of 340 bytes
Quote from: xroot on July 22, 2010, 08:05:22 PMWhat I need is the sizeof the structure.
Try this...
include \masm32\include\masm32rt.inc
.code
start: inkey str$(NONCLIENTMETRICS)
exit
end start
Output:
340
try it this way to get a direct pointer to data in the .DATA section.
item db "Howdy Folks",0
pitem dd item
Variable "pitem" is a pointer to the data "item". Note that you put pitem after item.
Quote from: hutch-- on July 23, 2010, 12:49:47 AM
try it this way to get a direct pointer to data in the .DATA section.
item db "Howdy Folks",0
pitem dd item
Variable "pitem" is a pointer to the data "item". Note that you put pitem after item.
I always put pitem before item, for alignment reasons. What's wrong with that?
OK, let me explain more, in my Dll the pointer can be any structure name.
So there are no hard coded db statements. This is it.
.data
aStruc dd 0
sRec equ offset aStruc
.code
GetStrucPtr proc iStruc:dword
m2m aStruc,iStruc
mov eax,sRec
ret
GetStrucPtr endp
Unfortunately it's still a code fragment, perhaps you can provide a more complete example of both ends? It's not particularly obvious what you're trying to achieve, or how iStruc or aStruc might be used in a larger context.
Couldn't you loose the whole sRec thing and use something like this?
.data
aStruc dd 0
.code
GetStrucPtr proc iStruc:dword
m2m aStruc,iStruc
lea eax,aStruc
ret
GetStrucPtr endp
If you want to have the string length use lstrlen. You cannot use equ to since equ is not a pointer.