News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Help using a structure

Started by Player_0, April 19, 2007, 08:28:57 PM

Previous topic - Next topic

Player_0

Hello!

Im trying to use the CONTEXT structure thats defined in windows.inc.
ASSUME eax:ptr CONTEXT
mov ebx,[eax]._Dr0
and I get undefined symbol as an error for _Dr0 or any of the other symbols.
I just started using structures with assembly but Im not getting the error using a structure like RECT so please help me out. Thank you in advance!

Also, does this structure get automatically filled out at runtime by the system?

Jimg

from Windows.inc
CONTEXT STRUCT
  ContextFlags  DWORD      ?
  iDr0          DWORD      ?
  iDr1          DWORD      ?
  iDr2          DWORD      ?
  iDr3          DWORD      ?
  iDr6          DWORD      ?
  iDr7          DWORD      ?
  FloatSave     FLOATING_SAVE_AREA <>
  regGs         DWORD      ?
  regFs         DWORD      ?
  regEs         DWORD      ?
  regDs         DWORD      ?
  regEdi        DWORD      ?
  regEsi        DWORD      ?
  regEbx        DWORD      ?
  regEdx        DWORD      ?
  regEcx        DWORD      ?
  regEax        DWORD      ?
  regEbp        DWORD      ?
  regEip        DWORD      ?
  regCs         DWORD      ?
  regFlag       DWORD      ?
  regEsp        DWORD      ?
  regSs         DWORD      ?
  ExtendedRegisters db MAXIMUM_SUPPORTED_EXTENSION dup(?)
CONTEXT ENDS


Try
mov ebx,[eax].iDr0

Player_0

Ok, the problem was that under winasm when i put a period it comes up with a list of possibilities and instead of the preceding "i" it had an underscore. Anyone know why?
And when I declare a struct like this: con CONTEXT <>
It doesn't automatically give a possible list of members while you're typing out the struct.

Jimg

It's because the definition in MasmApiStruct.vaa is incorrect.  I'll ask over in the WinAsm Studio forum.

MichaelW

Most of the names in the original structure needed to be changed, and apparently there was some disagreement on how they should be changed.

typedef struct _CONTEXT {
    DWORD ContextFlags;
    DWORD   Dr0;
    DWORD   Dr1;
    DWORD   Dr2;
    DWORD   Dr3;
    DWORD   Dr6;
    DWORD   Dr7;
    FLOATING_SAVE_AREA FloatSave;
    DWORD   SegGs;
    DWORD   SegFs;
    DWORD   SegEs;
    DWORD   SegDs;
    DWORD   Edi;
    DWORD   Esi;
    DWORD   Ebx;
    DWORD   Edx;
    DWORD   Ecx;
    DWORD   Eax;
    DWORD   Ebp;
    DWORD   Eip;
    DWORD   SegCs;
    DWORD   EFlags;
    DWORD   Esp;
    DWORD   SegSs;
    BYTE    ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
} CONTEXT;

eschew obfuscation

Jimg


MichaelW

Yes, it's the Microsoft structure definition from WinNT.h in the Platform SDK.
eschew obfuscation

Jimg

So, Hutch, just out of curiosity, was there some reason for the current definition in Windows.inc?