News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

acces union var in structure

Started by FastLife, June 12, 2014, 06:57:24 AM

Previous topic - Next topic

FastLife

hello masm32 forum

i want to retrieve a value in a union structure.
its about the IMAGE_RESOURCE_DIRECTORY_ENTRY STRUCT structure. i want to acces NameIsString value.
But this doesn't work because it says "undefined symbol".


lea edx, ResDirectoryEntry
assume edx : ptr IMAGE_RESOURCE_DIRECTORY_ENTRY
mov al, byte ptr ds:[edx].NameIsString ; ERROR HERE > undefined symbol

jj2007

1. Have a closer look at the definition of IMAGE_RESOURCE_DIRECTORY_ENTRY
2. Read the forum rules

qWord

NameIsString and NameOffset are bit fields and a corresponding RECORD type (DWORD sized) has been declared in windows.inc. To access the bits, use the union-member Name1 (also a DWORD) and the MASK operator:
; get boolean value NameIsString
xor eax,eax
test [edx].Name1, MASK NameIsString
setnz al

; get NameOffset
mov ecx, [edx].Name1 ; copy DWORD
and ecx, MASK NameOffset ; mask bits
MREAL macros - when you need floating point arithmetic while assembling!

FastLife

thank you very much qWord, works perfect! :t