The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Player_0 on April 19, 2007, 08:28:57 PM

Title: Help using a structure
Post by: Player_0 on April 19, 2007, 08:28:57 PM
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?
Title: Re: Help using a structure
Post by: Jimg on April 19, 2007, 08:54:52 PM
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
Title: Re: Help using a structure
Post by: Player_0 on April 20, 2007, 12:34:24 AM
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.
Title: Re: Help using a structure
Post by: Jimg on April 20, 2007, 01:09:49 AM
It's because the definition in MasmApiStruct.vaa is incorrect.  I'll ask over in the WinAsm Studio forum.
Title: Re: Help using a structure
Post by: MichaelW on April 20, 2007, 01:43:49 AM
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;

Title: Re: Help using a structure
Post by: Jimg on April 20, 2007, 02:20:33 AM
is that C?
Title: Re: Help using a structure
Post by: MichaelW on April 20, 2007, 06:03:33 AM
Yes, it's the Microsoft structure definition from WinNT.h in the Platform SDK.
Title: Re: Help using a structure
Post by: Jimg on April 20, 2007, 01:08:52 PM
So, Hutch, just out of curiosity, was there some reason for the current definition in Windows.inc?