1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS kernel 4 * FILE: include/reactos/rossym.h 5 * PURPOSE: Handling of rossym symbol info 6 * 7 * PROGRAMMERS: Ge van Geldorp (gvg@reactos.com) 8 */ 9 10 #ifndef REACTOS_ROSSYM_H_INCLUDED 11 #define REACTOS_ROSSYM_H_INCLUDED 12 13 #define ROSSYM_SECTION_NAME ".rossym" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 typedef struct _ROSSYM_HEADER { 20 unsigned long SymbolsOffset; 21 unsigned long SymbolsLength; 22 unsigned long StringsOffset; 23 unsigned long StringsLength; 24 } ROSSYM_HEADER, *PROSSYM_HEADER; 25 26 typedef struct _ROSSYM_ENTRY { 27 ULONG_PTR Address; 28 ULONG FunctionOffset; 29 ULONG FileOffset; 30 ULONG SourceLine; 31 } ROSSYM_ENTRY, *PROSSYM_ENTRY; 32 33 enum _ROSSYM_REGNAME { 34 ROSSYM_X86_EAX = 0, 35 ROSSYM_X86_ECX, 36 ROSSYM_X86_EDX, 37 ROSSYM_X86_EBX, 38 ROSSYM_X86_ESP, 39 ROSSYM_X86_EBP, 40 ROSSYM_X86_ESI, 41 ROSSYM_X86_EDI, 42 43 ROSSYM_X64_RAX = 0, 44 ROSSYM_X64_RDX, 45 ROSSYM_X64_RCX, 46 ROSSYM_X64_RBX, 47 ROSSYM_X64_RSI, 48 ROSSYM_X64_RDI, 49 ROSSYM_X64_RBP, 50 ROSSYM_X64_RSP, 51 Rossym_X64_R8, 52 ROSSYM_X64_R9, 53 ROSSYM_X64_R10, 54 ROSSYM_X64_R11, 55 ROSSYM_X64_R12, 56 ROSSYM_X64_R13, 57 ROSSYM_X64_R14, 58 ROSSYM_X64_R15 59 }; 60 61 typedef struct _ROSSYM_REGISTERS { 62 ULONGLONG Registers[32]; 63 } ROSSYM_REGISTERS, *PROSSYM_REGISTERS; 64 65 typedef struct _ROSSYM_PARAMETER { 66 ULONGLONG Value; 67 char *ValueName; 68 } ROSSYM_PARAMETER, *PROSSYM_PARAMETER; 69 70 typedef enum _ROSSYM_LINEINFO_FLAGS { 71 ROSSYM_LINEINFO_HAS_REGISTERS = 1 72 } ROSSYM_LINEINFO_FLAGS; 73 74 typedef enum _ROSSYM_LINEINFO_TYPE { 75 ROSSYM_LINEINFO_UNKNOWN, 76 ROSSYM_LINEINFO_NARROW_STRING, 77 ROSSYM_LINEINFO_WIDE_STRING, 78 ROSSYM_LINEINFO_ANSI_STRING, 79 ROSSYM_LINEINFO_UNICODE_STRING, 80 ROSSYM_LINEINFO_HANDLE 81 } ROSSYM_LINEINFO_STRINGTYPE; 82 83 typedef struct _ROSSYM_LINEINFO { 84 ROSSYM_LINEINFO_FLAGS Flags; 85 ULONG LineNumber; 86 char *FileName; 87 char *FunctionName; 88 ROSSYM_REGISTERS Registers; 89 ULONG NumParams; 90 ROSSYM_PARAMETER Parameters[16]; 91 } ROSSYM_LINEINFO, *PROSSYM_LINEINFO; 92 93 typedef struct _ROSSYM_AGGREGATE_MEMBER { 94 PCHAR Name, Type; 95 ULONG BaseOffset, Size; 96 ULONG FirstBit, Bits; 97 ULONG TypeId; 98 } ROSSYM_AGGREGATE_MEMBER, *PROSSYM_AGGREGATE_MEMBER; 99 100 typedef struct _ROSSYM_AGGREGATE { 101 ULONG NumElements; 102 PROSSYM_AGGREGATE_MEMBER Elements; 103 } ROSSYM_AGGREGATE, *PROSSYM_AGGREGATE; 104 105 typedef struct _ROSSYM_CALLBACKS { 106 PVOID (*AllocMemProc)(ULONG_PTR Size); 107 VOID (*FreeMemProc)(PVOID Area); 108 BOOLEAN (*ReadFileProc)(PVOID FileContext, PVOID Buffer, ULONG Size); 109 BOOLEAN (*SeekFileProc)(PVOID FileContext, ULONG_PTR Position); 110 BOOLEAN (*MemGetProc)(PVOID FileContext, ULONG_PTR *Target, PVOID SourceMem, ULONG Size); 111 } ROSSYM_CALLBACKS, *PROSSYM_CALLBACKS; 112 113 #ifdef __ROS_DWARF__ 114 typedef struct _ROSSYM_OWN_FILECONTEXT { 115 BOOLEAN (*ReadFileProc)(PVOID FileContext, PVOID Buffer, ULONG Size); 116 BOOLEAN (*SeekFileProc)(PVOID FileContext, ULONG_PTR Position); 117 } ROSSYM_OWN_FILECONTEXT, *PROSSYM_OWN_FILECONTEXT; 118 119 struct Dwarf; 120 typedef struct Dwarf *PROSSYM_INFO; 121 #else 122 typedef struct _ROSSYM_INFO { 123 PROSSYM_ENTRY Symbols; 124 ULONG SymbolsCount; 125 PCHAR Strings; 126 ULONG StringsLength; 127 } ROSSYM_INFO, *PROSSYM_INFO; 128 #endif 129 130 VOID RosSymInit(PROSSYM_CALLBACKS Callbacks); 131 #ifndef __ROS_DWARF__ 132 VOID RosSymInitKernelMode(VOID); 133 #endif 134 VOID RosSymInitUserMode(VOID); 135 136 BOOLEAN RosSymCreateFromRaw(PVOID RawData, ULONG_PTR DataSize, 137 PROSSYM_INFO *RosSymInfo); 138 BOOLEAN RosSymCreateFromMem(PVOID ImageStart, ULONG_PTR ImageSize, 139 PROSSYM_INFO *RosSymInfo); 140 BOOLEAN RosSymCreateFromFile(PVOID FileContext, PROSSYM_INFO *RosSymInfo); 141 ULONG RosSymGetRawDataLength(PROSSYM_INFO RosSymInfo); 142 VOID RosSymGetRawData(PROSSYM_INFO RosSymInfo, PVOID RawData); 143 #ifdef __ROS_DWARF__ 144 BOOLEAN RosSymGetAddressInformation(PROSSYM_INFO RosSymInfo, 145 ULONG_PTR RelativeAddress, 146 PROSSYM_LINEINFO RosSymLineInfo); 147 #else 148 BOOLEAN RosSymGetAddressInformation(PROSSYM_INFO RosSymInfo, 149 ULONG_PTR RelativeAddress, 150 ULONG *LineNumber, 151 char *FileName, 152 char *FunctionName); 153 #endif 154 VOID RosSymFreeInfo(PROSSYM_LINEINFO RosSymLineInfo); 155 VOID RosSymDelete(PROSSYM_INFO RosSymInfo); 156 BOOLEAN 157 RosSymAggregate(PROSSYM_INFO RosSymInfo, PCHAR Type, PROSSYM_AGGREGATE Aggregate); 158 VOID RosSymFreeAggregate(PROSSYM_AGGREGATE Aggregate); 159 160 #ifdef __cplusplus 161 } 162 #endif 163 164 #endif /* REACTOS_ROSSYM_H_INCLUDED */ 165 166 /* EOF */ 167 168