flat assembler
Message board for the users of flat assembler.

Index > Windows > Struct problems

Author
Thread Post new topic Reply to topic
FrozenKnight



Joined: 24 Jun 2005
Posts: 128
FrozenKnight
i was trying to create a debug event and wrote a struct with a union inside. just when i tried to use it as a local variable it wont work. heres the code. can someone explain why?

Code:
EXCEPTION_NONCONTINUABLE = 0x1
EXCEPTION_MAXIMUM_PARAMETERS = 15

struct EXCEPTION_RECORD
  ExceptionCode        dd ?;DWORD
  ExceptionFlags       dd ?;DWORD
  ExceptionRecord      dd ?;_EXCEPTION_RECORD*
  ExceptionAddress     dd ?;PVOID
  NumberParameters     dd ?;DWORD
  ExceptionInformation dd EXCEPTION_MAXIMUM_PARAMETERS dup ?;ULONG_PTR
ends

struct CREATE_THREAD_DEBUG_INFO
  hThread               dd ?;HANDLE
  lpThreadLocalBase     dd ?;LPVOID
  lpStartAddress        dd ?;LPTHREAD_START_ROUTINE
ends

struct EXCEPTION_DEBUG_INFO
  ExceptionRecord  EXCEPTION_RECORD
  dwFirstChance    dw ? ;DWORD
ends

struct CREATE_PROCESS_DEBUG_INFO
  hFile                 dd ?;HANDLE
  hProcess              dd ?;HANDLE
  hThread               dd ?;HANDLE
  lpBaseOfImage         dd ?;LPVOID
  dwDebugInfoFileOffset dd ?;DWORD
  nDebugInfoSize        dd ?;DWORD
  lpThreadLocalBase     dd ?;LPVOID
  lpStartAddress        dd ?;LPTHREAD_START_ROUTINE
  lpImageName           dd ?;LPVOID
  fUnicode              dd ?;WORD
ends

struct EXIT_THREAD_DEBUG_INFO
  dwExitCode            dd ?;DWORD
ends

struct EXIT_PROCESS_DEBUG_INFO
  dwExitCode            dd ?;DWORD
ends

struct LOAD_DLL_DEBUG_INFO
  hFile                 dd ?;HANDLE
  lpBaseOfDll           dd ?;LPVOID
  dwDebugInfoFileOffset dd ?;DWORD
  nDebugInfoSize        dd ?;DWORD
  lpImageName           dd ?;LPVOID
  fUnicode              dw ?;WORD
ends

struct UNLOAD_DLL_DEBUG_INFO
  lpBaseOfDll           dd ?;LPVOID
ends

struct OUTPUT_DEBUG_STRING_INFO
  lpDebugStringData     dd ?;LPSTR
  fUnicode              dw ?;WORD
  nDebugStringLength    dw ?;WORD
ends

struct RIP_INFO
  dwError               dd ?;DWORD
  dwType                dd ?;DWORD
ends

macro union [def]
 { common size@union = 0
          origin@union = $
   forward virtual
            def
            if $-origin@union > size@union
             size@union = $-origin@union
            end if
           end virtual
   common rb size@union }

struct DEBUG_EVENT
  dwDebugEventCode dd ?;DWORD
  dwProcessId      dd ?;DWORD
  dwThreadId       dd ?;DWORD
   .u: ;union {
  rb 96-(3*4);reserve union size then virtual all the structs at the union location
  virtual at .u;  EXCEPTION_DEBUG_INFO Exception;
    .u.Exception EXCEPTION_DEBUG_INFO
  end virtual
  virtual at .u;  CREATE_THREAD_DEBUG_INFO CreateThread;
    .u.CreateThread CREATE_THREAD_DEBUG_INFO
  end virtual
  virtual at .u;  CREATE_PROCESS_DEBUG_INFO CreateProcessInfo;
    .u.CreateProcessInfo CREATE_PROCESS_DEBUG_INFO
  end virtual
  virtual at .u;  EXIT_THREAD_DEBUG_INFO ExitThread;
    .u.ExitThread EXIT_THREAD_DEBUG_INFO
  end virtual
  virtual at .u;  EXIT_PROCESS_DEBUG_INFO ExitProcess;
    .u.ExitProcess EXIT_PROCESS_DEBUG_INFO
  end virtual
  virtual at .u;  LOAD_DLL_DEBUG_INFO LoadDll;
    .u.LoadDll LOAD_DLL_DEBUG_INFO
  end virtual
  virtual at .u;  UNLOAD_DLL_DEBUG_INFO UnloadDll;
    .u.UnloadDll UNLOAD_DLL_DEBUG_INFO
  end virtual
  virtual at .u;  OUTPUT_DEBUG_STRING_INFO DebugString;
    .u.DebugString OUTPUT_DEBUG_STRING_INFO
  end virtual
  virtual at .u;  RIP_INFO RipInfo;
    .u.RipInfo RIP_INFO
  end virtual
  ;} u;
ends    
Post 11 Nov 2006, 03:07
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
I see a little problem here, don't know if this fixes it though. Confused

Code:
struct EXCEPTION_RECORD 
  ExceptionCode        dd ?;DWORD 
  ExceptionFlags       dd ?;DWORD 
  ExceptionRecord      dd ?;_EXCEPTION_RECORD* 
  ExceptionAddress     dd ?;PVOID 
  NumberParameters     dd ?;DWORD 
  [here] -> ExceptionInformation dd EXCEPTION_MAXIMUM_PARAMETERS dup ?;ULONG_PTR 
ends    


That line should be:
Code:
ExceptionInformation dd EXCEPTION_MAXIMUM_PARAMETERS dup(?) ;ULONG_PTR    
Post 11 Nov 2006, 05:32
View user's profile Send private message Reply with quote
FrozenKnight



Joined: 24 Jun 2005
Posts: 128
FrozenKnight
it fixed it, i just don't understand why?
Post 11 Nov 2006, 11:38
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
The way you defined it, it only defined one dword. The fix defined an array of dwords. Thats my best guess. Actually I think FasmW should have given you an error.
Post 13 Nov 2006, 08:21
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.