ReactOS 0.4.16-dev-297-gc569aee
rossym.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ROSSYM_HEADER
 
struct  _ROSSYM_ENTRY
 
struct  _ROSSYM_REGISTERS
 
struct  _ROSSYM_PARAMETER
 
struct  _ROSSYM_LINEINFO
 
struct  _ROSSYM_AGGREGATE_MEMBER
 
struct  _ROSSYM_AGGREGATE
 
struct  _ROSSYM_CALLBACKS
 
struct  _ROSSYM_INFO
 

Macros

#define ROSSYM_SECTION_NAME   ".rossym"
 

Typedefs

typedef struct _ROSSYM_HEADER ROSSYM_HEADER
 
typedef struct _ROSSYM_HEADERPROSSYM_HEADER
 
typedef struct _ROSSYM_ENTRY ROSSYM_ENTRY
 
typedef struct _ROSSYM_ENTRYPROSSYM_ENTRY
 
typedef struct _ROSSYM_REGISTERS ROSSYM_REGISTERS
 
typedef struct _ROSSYM_REGISTERSPROSSYM_REGISTERS
 
typedef struct _ROSSYM_PARAMETER ROSSYM_PARAMETER
 
typedef struct _ROSSYM_PARAMETERPROSSYM_PARAMETER
 
typedef enum _ROSSYM_LINEINFO_FLAGS ROSSYM_LINEINFO_FLAGS
 
typedef enum _ROSSYM_LINEINFO_TYPE ROSSYM_LINEINFO_STRINGTYPE
 
typedef struct _ROSSYM_LINEINFO ROSSYM_LINEINFO
 
typedef struct _ROSSYM_LINEINFOPROSSYM_LINEINFO
 
typedef struct _ROSSYM_AGGREGATE_MEMBER ROSSYM_AGGREGATE_MEMBER
 
typedef struct _ROSSYM_AGGREGATE_MEMBERPROSSYM_AGGREGATE_MEMBER
 
typedef struct _ROSSYM_AGGREGATE ROSSYM_AGGREGATE
 
typedef struct _ROSSYM_AGGREGATEPROSSYM_AGGREGATE
 
typedef struct _ROSSYM_CALLBACKS ROSSYM_CALLBACKS
 
typedef struct _ROSSYM_CALLBACKSPROSSYM_CALLBACKS
 
typedef struct _ROSSYM_INFO ROSSYM_INFO
 
typedef struct _ROSSYM_INFOPROSSYM_INFO
 

Enumerations

enum  _ROSSYM_REGNAME {
  ROSSYM_X86_EAX = 0 , ROSSYM_X86_ECX , ROSSYM_X86_EDX , ROSSYM_X86_EBX ,
  ROSSYM_X86_ESP , ROSSYM_X86_EBP , ROSSYM_X86_ESI , ROSSYM_X86_EDI ,
  ROSSYM_X64_RAX = 0 , ROSSYM_X64_RDX , ROSSYM_X64_RCX , ROSSYM_X64_RBX ,
  ROSSYM_X64_RSI , ROSSYM_X64_RDI , ROSSYM_X64_RBP , ROSSYM_X64_RSP ,
  Rossym_X64_R8 , ROSSYM_X64_R9 , ROSSYM_X64_R10 , ROSSYM_X64_R11 ,
  ROSSYM_X64_R12 , ROSSYM_X64_R13 , ROSSYM_X64_R14 , ROSSYM_X64_R15
}
 
enum  _ROSSYM_LINEINFO_FLAGS { ROSSYM_LINEINFO_HAS_REGISTERS = 1 }
 
enum  _ROSSYM_LINEINFO_TYPE {
  ROSSYM_LINEINFO_UNKNOWN , ROSSYM_LINEINFO_NARROW_STRING , ROSSYM_LINEINFO_WIDE_STRING , ROSSYM_LINEINFO_ANSI_STRING ,
  ROSSYM_LINEINFO_UNICODE_STRING , ROSSYM_LINEINFO_HANDLE
}
 

Functions

VOID RosSymInit (PROSSYM_CALLBACKS Callbacks)
 
VOID RosSymInitKernelMode (VOID)
 
VOID RosSymInitUserMode (VOID)
 
BOOLEAN RosSymCreateFromRaw (PVOID RawData, ULONG_PTR DataSize, PROSSYM_INFO *RosSymInfo)
 
BOOLEAN RosSymCreateFromMem (PVOID ImageStart, ULONG_PTR ImageSize, PROSSYM_INFO *RosSymInfo)
 
BOOLEAN RosSymCreateFromFile (PVOID FileContext, PROSSYM_INFO *RosSymInfo)
 
ULONG RosSymGetRawDataLength (PROSSYM_INFO RosSymInfo)
 
VOID RosSymGetRawData (PROSSYM_INFO RosSymInfo, PVOID RawData)
 
BOOLEAN RosSymGetAddressInformation (PROSSYM_INFO RosSymInfo, ULONG_PTR RelativeAddress, ULONG *LineNumber, char *FileName, char *FunctionName)
 
VOID RosSymFreeInfo (PROSSYM_LINEINFO RosSymLineInfo)
 
VOID RosSymDelete (PROSSYM_INFO RosSymInfo)
 
BOOLEAN RosSymAggregate (PROSSYM_INFO RosSymInfo, PCHAR Type, PROSSYM_AGGREGATE Aggregate)
 
VOID RosSymFreeAggregate (PROSSYM_AGGREGATE Aggregate)
 

Macro Definition Documentation

◆ ROSSYM_SECTION_NAME

#define ROSSYM_SECTION_NAME   ".rossym"

Definition at line 13 of file rossym.h.

Typedef Documentation

◆ PROSSYM_AGGREGATE

◆ PROSSYM_AGGREGATE_MEMBER

◆ PROSSYM_CALLBACKS

◆ PROSSYM_ENTRY

◆ PROSSYM_HEADER

◆ PROSSYM_INFO

◆ PROSSYM_LINEINFO

◆ PROSSYM_PARAMETER

◆ PROSSYM_REGISTERS

◆ ROSSYM_AGGREGATE

◆ ROSSYM_AGGREGATE_MEMBER

◆ ROSSYM_CALLBACKS

◆ ROSSYM_ENTRY

◆ ROSSYM_HEADER

◆ ROSSYM_INFO

◆ ROSSYM_LINEINFO

◆ ROSSYM_LINEINFO_FLAGS

◆ ROSSYM_LINEINFO_STRINGTYPE

◆ ROSSYM_PARAMETER

◆ ROSSYM_REGISTERS

Enumeration Type Documentation

◆ _ROSSYM_LINEINFO_FLAGS

Enumerator
ROSSYM_LINEINFO_HAS_REGISTERS 

Definition at line 70 of file rossym.h.

70 {
@ ROSSYM_LINEINFO_HAS_REGISTERS
Definition: rossym.h:71
enum _ROSSYM_LINEINFO_FLAGS ROSSYM_LINEINFO_FLAGS

◆ _ROSSYM_LINEINFO_TYPE

Enumerator
ROSSYM_LINEINFO_UNKNOWN 
ROSSYM_LINEINFO_NARROW_STRING 
ROSSYM_LINEINFO_WIDE_STRING 
ROSSYM_LINEINFO_ANSI_STRING 
ROSSYM_LINEINFO_UNICODE_STRING 
ROSSYM_LINEINFO_HANDLE 

Definition at line 74 of file rossym.h.

74 {
@ ROSSYM_LINEINFO_ANSI_STRING
Definition: rossym.h:78
@ ROSSYM_LINEINFO_WIDE_STRING
Definition: rossym.h:77
@ ROSSYM_LINEINFO_NARROW_STRING
Definition: rossym.h:76
@ ROSSYM_LINEINFO_UNICODE_STRING
Definition: rossym.h:79
@ ROSSYM_LINEINFO_UNKNOWN
Definition: rossym.h:75
@ ROSSYM_LINEINFO_HANDLE
Definition: rossym.h:80
enum _ROSSYM_LINEINFO_TYPE ROSSYM_LINEINFO_STRINGTYPE

◆ _ROSSYM_REGNAME

Enumerator
ROSSYM_X86_EAX 
ROSSYM_X86_ECX 
ROSSYM_X86_EDX 
ROSSYM_X86_EBX 
ROSSYM_X86_ESP 
ROSSYM_X86_EBP 
ROSSYM_X86_ESI 
ROSSYM_X86_EDI 
ROSSYM_X64_RAX 
ROSSYM_X64_RDX 
ROSSYM_X64_RCX 
ROSSYM_X64_RBX 
ROSSYM_X64_RSI 
ROSSYM_X64_RDI 
ROSSYM_X64_RBP 
ROSSYM_X64_RSP 
Rossym_X64_R8 
ROSSYM_X64_R9 
ROSSYM_X64_R10 
ROSSYM_X64_R11 
ROSSYM_X64_R12 
ROSSYM_X64_R13 
ROSSYM_X64_R14 
ROSSYM_X64_R15 

Definition at line 33 of file rossym.h.

33 {
42
59};
@ ROSSYM_X64_RBP
Definition: rossym.h:49
@ ROSSYM_X64_R12
Definition: rossym.h:55
@ Rossym_X64_R8
Definition: rossym.h:51
@ ROSSYM_X86_ESI
Definition: rossym.h:40
@ ROSSYM_X64_R13
Definition: rossym.h:56
@ ROSSYM_X64_RAX
Definition: rossym.h:43
@ ROSSYM_X86_EBX
Definition: rossym.h:37
@ ROSSYM_X64_RCX
Definition: rossym.h:45
@ ROSSYM_X64_R14
Definition: rossym.h:57
@ ROSSYM_X86_EAX
Definition: rossym.h:34
@ ROSSYM_X64_RSP
Definition: rossym.h:50
@ ROSSYM_X64_R15
Definition: rossym.h:58
@ ROSSYM_X64_RSI
Definition: rossym.h:47
@ ROSSYM_X64_R9
Definition: rossym.h:52
@ ROSSYM_X86_EDX
Definition: rossym.h:36
@ ROSSYM_X64_RDX
Definition: rossym.h:44
@ ROSSYM_X86_ECX
Definition: rossym.h:35
@ ROSSYM_X86_EDI
Definition: rossym.h:41
@ ROSSYM_X64_R11
Definition: rossym.h:54
@ ROSSYM_X64_RBX
Definition: rossym.h:46
@ ROSSYM_X86_ESP
Definition: rossym.h:38
@ ROSSYM_X64_RDI
Definition: rossym.h:48
@ ROSSYM_X86_EBP
Definition: rossym.h:39
@ ROSSYM_X64_R10
Definition: rossym.h:53

Function Documentation

◆ RosSymAggregate()

BOOLEAN RosSymAggregate ( PROSSYM_INFO  RosSymInfo,
PCHAR  Type,
PROSSYM_AGGREGATE  Aggregate 
)

Definition at line 137 of file find.c.

138{
139 char *tchar;
140 ulong unit, typeoff = 0;
141 DwarfSym type = { };
142 // Get the first unit
143 if (dwarfaddrtounit(RosSymInfo, RosSymInfo->pe->codestart + RosSymInfo->pe->imagebase, &unit) == -1)
144 return FALSE;
145
146 if (Type[0] == '#') {
147 for (tchar = Type + 1; *tchar; tchar++) {
148 typeoff *= 10;
149 typeoff += *tchar - '0';
150 }
151 if (dwarfseeksym(RosSymInfo, unit, typeoff, &type) == -1)
152 return FALSE;
153 } else if (dwarflookupnameinunit(RosSymInfo, unit, Type, &type) != 0 ||
154 (type.attrs.tag != TagStructType && type.attrs.tag != TagUnionType))
155 return FALSE;
156
157 DwarfSym element = { }, inner = { };
158 int count = 0;
159
160 werrstr("type %s (want %s) type %x\n", type.attrs.name, Type, type.attrs.type);
161
162 if (type.attrs.have.type) {
163 if (dwarfseeksym(RosSymInfo, unit, type.attrs.type, &inner) == -1)
164 return FALSE;
165 type = inner;
166 }
167
168 werrstr("finding members %d\n", type.attrs.haskids);
169 while (dwarfnextsymat(RosSymInfo, &type, &element) != -1) {
170 if (element.attrs.have.name)
171 werrstr("%x %s\n", element.attrs.tag, element.attrs.name);
172 if (element.attrs.tag == TagMember) count++;
173 }
174
175 werrstr("%d members\n", count);
176
177 if (!count) return FALSE;
178 memset(&element, 0, sizeof(element));
179 Aggregate->NumElements = count;
180 Aggregate->Elements = malloc(sizeof(ROSSYM_AGGREGATE_MEMBER) * count);
181 count = 0;
182 werrstr("Enumerating %s\n", Type);
183 while (dwarfnextsymat(RosSymInfo, &type, &element) != -1) {
184 memset(&Aggregate->Elements[count], 0, sizeof(*Aggregate->Elements));
185 if (element.attrs.tag == TagMember) {
186 if (element.attrs.have.name) {
187 Aggregate->Elements[count].Name = malloc(strlen(element.attrs.name) + 1);
188 strcpy(Aggregate->Elements[count].Name, element.attrs.name);
189 }
190 Aggregate->Elements[count].TypeId = element.attrs.type;
191 // Seek our range in loc
192 DwarfBuf locbuf;
193 DwarfBuf instream = { };
194
195 locbuf.d = RosSymInfo;
196 locbuf.addrsize = RosSymInfo->addrsize;
197
198 if (element.attrs.have.datamemberloc) {
199 instream = locbuf;
200 instream.p = element.attrs.datamemberloc.b.data;
201 instream.ep = element.attrs.datamemberloc.b.data + element.attrs.datamemberloc.b.len;
202 werrstr("datamemberloc type %x %p:%x\n",
203 element.attrs.have.datamemberloc,
204 element.attrs.datamemberloc.b.data, element.attrs.datamemberloc.b.len);
205 }
206
207 if (dwarfgetarg(RosSymInfo, element.attrs.name, &instream, 0, NULL, &Aggregate->Elements[count].BaseOffset) == -1)
208 Aggregate->Elements[count].BaseOffset = -1;
209 werrstr("tag %x name %s base %x type %x\n",
210 element.attrs.tag, element.attrs.name,
211 Aggregate->Elements[count].BaseOffset,
212 Aggregate->Elements[count].TypeId);
213 count++;
214 }
215 }
216 for (count = 0; count < Aggregate->NumElements; count++) {
217 memset(&type, 0, sizeof(type));
218 memset(&inner, 0, sizeof(inner));
219 werrstr("seeking type %x (%s) from %s\n",
220 Aggregate->Elements[count].TypeId,
221 Aggregate->Elements[count].Type,
222 Aggregate->Elements[count].Name);
223 dwarfseeksym(RosSymInfo, unit, Aggregate->Elements[count].TypeId, &type);
224 while (type.attrs.have.type && type.attrs.tag != TagPointerType) {
225 if (dwarfseeksym(RosSymInfo, unit, type.attrs.type, &inner) == -1)
226 return FALSE;
227 type = inner;
228 }
229 //dwarfdumpsym(RosSymInfo, &type);
230 if (type.attrs.have.name) {
231 Aggregate->Elements[count].Type = malloc(strlen(type.attrs.name) + 1);
232 strcpy(Aggregate->Elements[count].Type, type.attrs.name);
233 } else {
234 char strbuf[128] = {'#'}, *bufptr = strbuf + 1;
235 ulong idcopy = Aggregate->Elements[count].TypeId;
236 ulong mult = 1;
237 while (mult * 10 < idcopy) mult *= 10;
238 while (mult > 0) {
239 *bufptr++ = '0' + ((idcopy / mult) % 10);
240 mult /= 10;
241 }
242 Aggregate->Elements[count].Type = malloc(strlen(strbuf) + 1);
243 strcpy(Aggregate->Elements[count].Type, strbuf);
244 }
245 if (type.attrs.tag == TagPointerType)
246 Aggregate->Elements[count].Size = RosSymInfo->addrsize;
247 else
248 Aggregate->Elements[count].Size = type.attrs.bytesize;
249 if (type.attrs.have.bitsize)
250 Aggregate->Elements[count].Bits = type.attrs.bitsize;
251 if (type.attrs.have.bitoffset)
252 Aggregate->Elements[count].FirstBit = type.attrs.bitoffset;
253 }
254 return TRUE;
255}
Type
Definition: Type.h:7
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long ulong
Definition: linux.h:275
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
static IStream instream
Definition: saxreader.c:2106
png_const_structrp png_const_inforp int * unit
Definition: png.h:2159
#define tchar
Definition: safestr.h:13
#define werrstr(str,...)
Definition: compat.h:34
#define memset(x, y, z)
Definition: compat.h:39
int dwarfseeksym(Dwarf *, ulong, ulong, DwarfSym *)
Definition: dwarfinfo.c:170
int dwarflookupnameinunit(Dwarf *, ulong, char *, DwarfSym *)
Definition: dwarfinfo.c:125
@ TagStructType
Definition: dwarf.h:26
@ TagUnionType
Definition: dwarf.h:29
@ TagMember
Definition: dwarf.h:21
@ TagPointerType
Definition: dwarf.h:22
int dwarfaddrtounit(Dwarf *, ulong, ulong *)
Definition: dwarfaranges.c:16
int dwarfnextsymat(Dwarf *, DwarfSym *, int)
Definition: dwarfinfo.c:292
int dwarfgetarg(Dwarf *d, const char *name, DwarfBuf *locbuf, ulong cfa, PROSSYM_REGISTERS registers, ulong *value)
Definition: dwarfinfo.c:658
uint addrsize
Definition: dwarf.h:212
Dwarf * d
Definition: dwarf.h:209
ULONG NumElements
Definition: rossym.h:101
PROSSYM_AGGREGATE_MEMBER Elements
Definition: rossym.h:102
unsigned int len
Definition: writer.c:90
static unsigned int bufptr
Definition: tncon.cpp:77

◆ RosSymCreateFromFile()

BOOLEAN RosSymCreateFromFile ( PVOID  FileContext,
PROSSYM_INFO RosSymInfo 
)

Definition at line 19 of file fromfile.c.

20{
21 IMAGE_DOS_HEADER DosHeader;
22 IMAGE_NT_HEADERS NtHeaders;
23 PIMAGE_SECTION_HEADER SectionHeaders, SectionHeader;
24 unsigned SectionIndex;
25 char SectionName[IMAGE_SIZEOF_SHORT_NAME];
26 ROSSYM_HEADER RosSymHeader;
27
28 /* Load DOS header */
29 if (! RosSymReadFile(FileContext, &DosHeader, sizeof(IMAGE_DOS_HEADER)))
30 {
31 DPRINT1("Failed to read DOS header\n");
32 return FALSE;
33 }
34 if (! ROSSYM_IS_VALID_DOS_HEADER(&DosHeader))
35 {
36 DPRINT1("Image doesn't have a valid DOS header\n");
37 return FALSE;
38 }
39
40 /* Load NT headers */
41 if (! RosSymSeekFile(FileContext, DosHeader.e_lfanew))
42 {
43 DPRINT1("Failed seeking to NT headers\n");
44 return FALSE;
45 }
46 if (! RosSymReadFile(FileContext, &NtHeaders, sizeof(IMAGE_NT_HEADERS)))
47 {
48 DPRINT1("Failed to read NT headers\n");
49 return FALSE;
50 }
51 if (! ROSSYM_IS_VALID_NT_HEADERS(&NtHeaders))
52 {
53 DPRINT1("Image doesn't have a valid PE header\n");
54 return FALSE;
55 }
56
57 /* Load section headers */
58 if (! RosSymSeekFile(FileContext, (char *) IMAGE_FIRST_SECTION(&NtHeaders) -
59 (char *) &NtHeaders + DosHeader.e_lfanew))
60 {
61 DPRINT1("Failed seeking to section headers\n");
62 return FALSE;
63 }
64 SectionHeaders = RosSymAllocMem(NtHeaders.FileHeader.NumberOfSections
65 * sizeof(IMAGE_SECTION_HEADER));
66 if (NULL == SectionHeaders)
67 {
68 DPRINT1("Failed to allocate memory for %u section headers\n",
70 return FALSE;
71 }
72 if (! RosSymReadFile(FileContext, SectionHeaders,
74 * sizeof(IMAGE_SECTION_HEADER)))
75 {
76 RosSymFreeMem(SectionHeaders);
77 DPRINT1("Failed to read section headers\n");
78 return FALSE;
79 }
80
81 /* Search for the section header */
83 SectionHeader = SectionHeaders;
84 for (SectionIndex = 0; SectionIndex < NtHeaders.FileHeader.NumberOfSections; SectionIndex++)
85 {
86 if (0 == memcmp(SectionName, SectionHeader->Name, IMAGE_SIZEOF_SHORT_NAME))
87 {
88 break;
89 }
90 SectionHeader++;
91 }
92 if (NtHeaders.FileHeader.NumberOfSections <= SectionIndex)
93 {
94 RosSymFreeMem(SectionHeaders);
95 DPRINT("No %s section found\n", ROSSYM_SECTION_NAME);
96 return FALSE;
97 }
98
99 /* Load rossym header */
100 if (! RosSymSeekFile(FileContext, SectionHeader->PointerToRawData))
101 {
102 RosSymFreeMem(SectionHeaders);
103 DPRINT1("Failed seeking to section data\n");
104 return FALSE;
105 }
106 RosSymFreeMem(SectionHeaders);
107 if (! RosSymReadFile(FileContext, &RosSymHeader, sizeof(ROSSYM_HEADER)))
108 {
109 DPRINT1("Failed to read rossym header\n");
110 return FALSE;
111 }
112 if (RosSymHeader.SymbolsOffset < sizeof(ROSSYM_HEADER)
113 || RosSymHeader.StringsOffset < RosSymHeader.SymbolsOffset + RosSymHeader.SymbolsLength
114 || 0 != (RosSymHeader.SymbolsLength % sizeof(ROSSYM_ENTRY)))
115 {
116 DPRINT1("Invalid ROSSYM_HEADER\n");
117 return FALSE;
118 }
119
120 *RosSymInfo = RosSymAllocMem(sizeof(ROSSYM_INFO) - sizeof(ROSSYM_HEADER)
121 + RosSymHeader.StringsOffset + RosSymHeader.StringsLength + 1);
122 if (NULL == *RosSymInfo)
123 {
124 DPRINT1("Failed to allocate memory for rossym\n");
125 return FALSE;
126 }
127 (*RosSymInfo)->Symbols = (PROSSYM_ENTRY)((char *) *RosSymInfo + sizeof(ROSSYM_INFO)
128 - sizeof(ROSSYM_HEADER) + RosSymHeader.SymbolsOffset);
129 (*RosSymInfo)->SymbolsCount = RosSymHeader.SymbolsLength / sizeof(ROSSYM_ENTRY);
130 (*RosSymInfo)->Strings = (PCHAR) *RosSymInfo + sizeof(ROSSYM_INFO) - sizeof(ROSSYM_HEADER)
131 + RosSymHeader.StringsOffset;
132 (*RosSymInfo)->StringsLength = RosSymHeader.StringsLength;
133 if (! RosSymReadFile(FileContext, *RosSymInfo + 1,
134 RosSymHeader.StringsOffset + RosSymHeader.StringsLength
135 - sizeof(ROSSYM_HEADER)))
136 {
137 DPRINT1("Failed to read rossym headers\n");
138 return FALSE;
139 }
140 /* Make sure the last string is null terminated, we allocated an extra byte for that */
141 (*RosSymInfo)->Strings[(*RosSymInfo)->StringsLength] = '\0';
142
143 return TRUE;
144}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define DPRINT1
Definition: precomp.h:8
_In_ PFCB _In_ PCD_NAME _In_ BOOLEAN _Inout_ PFILE_ENUM_CONTEXT FileContext
Definition: cdprocs.h:442
if(dx< 0)
Definition: linetemp.h:194
#define PCHAR
Definition: match.c:90
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
#define IMAGE_SIZEOF_SHORT_NAME
Definition: pedump.c:277
#define RosSymSeekFile(FileContext, Position)
Definition: rossympriv.h:17
#define RosSymAllocMem(Size)
Definition: rossympriv.h:14
#define RosSymFreeMem(Area)
Definition: rossympriv.h:15
#define RosSymReadFile(FileContext, Buffer, Size)
Definition: rossympriv.h:16
#define ROSSYM_IS_VALID_NT_HEADERS(NtHeaders)
Definition: rossympriv.h:24
#define ROSSYM_IS_VALID_DOS_HEADER(DosHeader)
Definition: rossympriv.h:22
#define ROSSYM_SECTION_NAME
Definition: rossym.h:13
struct _ROSSYM_ENTRY * PROSSYM_ENTRY
struct _ROSSYM_ENTRY ROSSYM_ENTRY
struct _ROSSYM_HEADER ROSSYM_HEADER
struct _ROSSYM_INFO ROSSYM_INFO
#define DPRINT
Definition: sndvol32.h:73
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
DWORD PointerToRawData
Definition: pedump.c:290
BYTE Name[IMAGE_SIZEOF_SHORT_NAME]
Definition: pedump.c:281
Definition: rossym.h:26
unsigned long SymbolsOffset
Definition: rossym.h:20
unsigned long SymbolsLength
Definition: rossym.h:21
unsigned long StringsLength
Definition: rossym.h:23
unsigned long StringsOffset
Definition: rossym.h:22

Referenced by LoadSymbolsRoutine().

◆ RosSymCreateFromMem()

BOOLEAN RosSymCreateFromMem ( PVOID  ImageStart,
ULONG_PTR  ImageSize,
PROSSYM_INFO RosSymInfo 
)

Definition at line 19 of file frommem.c.

20{
21 PIMAGE_DOS_HEADER DosHeader;
22 PIMAGE_NT_HEADERS NtHeaders;
23 PIMAGE_SECTION_HEADER SectionHeader;
24 ULONG SectionIndex;
25 BOOLEAN RosSymSectionFound = FALSE;
26 CHAR SectionName[IMAGE_SIZEOF_SHORT_NAME];
27
28 /* Check if MZ header is valid */
29 DosHeader = (PIMAGE_DOS_HEADER) ImageStart;
30 if (ImageSize < sizeof(IMAGE_DOS_HEADER)
31 || ! ROSSYM_IS_VALID_DOS_HEADER(DosHeader))
32 {
33 DPRINT1("Image doesn't have a valid DOS header\n");
34 return FALSE;
35 }
36
37 /* Locate NT header */
38 NtHeaders = (PIMAGE_NT_HEADERS)((char *) ImageStart + DosHeader->e_lfanew);
39 if (ImageSize < DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS)
40 || ! ROSSYM_IS_VALID_NT_HEADERS(NtHeaders))
41 {
42 DPRINT1("Image doesn't have a valid PE header\n");
43 return FALSE;
44 }
45
46 /* Search for the section header */
47 SectionHeader = IMAGE_FIRST_SECTION(NtHeaders);
48 if (ImageSize < (ULONG_PTR)((char *) (SectionHeader + NtHeaders->FileHeader.NumberOfSections)
49 - (char *) ImageStart))
50 {
51 DPRINT1("Image doesn't have valid section headers\n");
52 return FALSE;
53 }
55 for (SectionIndex = 0; SectionIndex < NtHeaders->FileHeader.NumberOfSections; SectionIndex++)
56 {
57 if (0 == memcmp(SectionName, SectionHeader->Name, IMAGE_SIZEOF_SHORT_NAME))
58 {
59 RosSymSectionFound = TRUE;
60 break;
61 }
62 SectionHeader++;
63 }
64
65 if (!RosSymSectionFound)
66 {
67 DPRINT("No %s section found\n", ROSSYM_SECTION_NAME);
68 return FALSE;
69 }
70
71 /* Locate the section itself */
72 if (ImageSize < SectionHeader->PointerToRawData + SectionHeader->SizeOfRawData
73 || SectionHeader->SizeOfRawData < sizeof(ROSSYM_HEADER))
74 {
75 DPRINT("Invalid %s section\n", ROSSYM_SECTION_NAME);
76 return FALSE;
77 }
78
79 if (SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize > ImageSize)
80 {
81 DPRINT("Bad %s section virtual size!\n", ROSSYM_SECTION_NAME);
82 return FALSE;
83 }
84
85 /* Load it */
86 return RosSymCreateFromRaw((char *) ImageStart + SectionHeader->VirtualAddress,
87 SectionHeader->SizeOfRawData, RosSymInfo);
88}
unsigned char BOOLEAN
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
DWORD e_lfanew
Definition: crypt.c:1156
BOOLEAN RosSymCreateFromRaw(PVOID RawData, ULONG_PTR DataSize, PROSSYM_INFO *RosSymInfo)
Definition: fromraw.c:18
union _IMAGE_SECTION_HEADER::@1571 Misc
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
char CHAR
Definition: xmlstorage.h:175

Referenced by KdbSymProcessSymbols().

◆ RosSymCreateFromRaw()

BOOLEAN RosSymCreateFromRaw ( PVOID  RawData,
ULONG_PTR  DataSize,
PROSSYM_INFO RosSymInfo 
)

Definition at line 18 of file fromraw.c.

19{
20 PROSSYM_HEADER RosSymHeader;
21
22 RosSymHeader = (PROSSYM_HEADER) RawData;
23 if (RosSymHeader->SymbolsOffset < sizeof(ROSSYM_HEADER)
24 || RosSymHeader->StringsOffset < RosSymHeader->SymbolsOffset + RosSymHeader->SymbolsLength
25 || DataSize < RosSymHeader->StringsOffset + RosSymHeader->StringsLength
26 || 0 != (RosSymHeader->SymbolsLength % sizeof(ROSSYM_ENTRY)))
27 {
28 DPRINT1("Invalid ROSSYM_HEADER\n");
29 return FALSE;
30 }
31
32 /* Copy */
33 *RosSymInfo = RosSymAllocMem(sizeof(ROSSYM_INFO) + RosSymHeader->SymbolsLength
34 + RosSymHeader->StringsLength + 1);
35 if (NULL == *RosSymInfo)
36 {
37 DPRINT1("Failed to allocate memory for rossym\n");
38 return FALSE;
39 }
40 (*RosSymInfo)->Symbols = (PROSSYM_ENTRY)((char *) *RosSymInfo + sizeof(ROSSYM_INFO));
41 (*RosSymInfo)->SymbolsCount = RosSymHeader->SymbolsLength / sizeof(ROSSYM_ENTRY);
42 (*RosSymInfo)->Strings = (PCHAR) *RosSymInfo + sizeof(ROSSYM_INFO) + RosSymHeader->SymbolsLength;
43 (*RosSymInfo)->StringsLength = RosSymHeader->StringsLength;
44 memcpy((*RosSymInfo)->Symbols, (char *) RosSymHeader + RosSymHeader->SymbolsOffset,
45 RosSymHeader->SymbolsLength);
46 memcpy((*RosSymInfo)->Strings, (char *) RosSymHeader + RosSymHeader->StringsOffset,
47 RosSymHeader->StringsLength);
48 /* Make sure the last string is null terminated, we allocated an extra byte for that */
49 (*RosSymInfo)->Strings[(*RosSymInfo)->StringsLength] = '\0';
50
51 return TRUE;
52}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
struct _ROSSYM_HEADER * PROSSYM_HEADER

Referenced by RosSymCreateFromMem().

◆ RosSymDelete()

VOID RosSymDelete ( PROSSYM_INFO  RosSymInfo)

Definition at line 15 of file delete.c.

16{
17 RosSymFreeMem(RosSymInfo);
18}

Referenced by KdbSymProcessSymbols().

◆ RosSymFreeAggregate()

VOID RosSymFreeAggregate ( PROSSYM_AGGREGATE  Aggregate)

Definition at line 126 of file find.c.

127{
128 int i;
129 for (i = 0; i < Aggregate->NumElements; i++) {
130 free(Aggregate->Elements[i].Name);
131 free(Aggregate->Elements[i].Type);
132 }
133 free(Aggregate->Elements);
134}
#define free
Definition: debug_ros.c:5
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

◆ RosSymFreeInfo()

VOID RosSymFreeInfo ( PROSSYM_LINEINFO  RosSymLineInfo)

Definition at line 398 of file dwarfpc.c.

399{
400 int i;
401 free(LineInfo->FileName);
402 LineInfo->FileName = NULL;
403 free(LineInfo->FunctionName);
404 LineInfo->FunctionName = NULL;
405 for (i = 0; i < sizeof(LineInfo->Parameters)/sizeof(LineInfo->Parameters[0]); i++)
406 free(LineInfo->Parameters[i].ValueName);
407}

◆ RosSymGetAddressInformation()

BOOLEAN RosSymGetAddressInformation ( PROSSYM_INFO  RosSymInfo,
ULONG_PTR  RelativeAddress,
ULONG LineNumber,
char FileName,
char FunctionName 
)

Definition at line 94 of file find.c.

99{
100 PROSSYM_ENTRY RosSymEntry;
101
102 DPRINT("RelativeAddress = 0x%08x\n", RelativeAddress);
103
104 if (RosSymInfo->Symbols == NULL || RosSymInfo->SymbolsCount == 0 ||
105 RosSymInfo->Strings == NULL || RosSymInfo->StringsLength == 0)
106 {
107 DPRINT1("Uninitialized RosSymInfo\n");
108 return FALSE;
109 }
110
112
113 /* find symbol entry for function */
114 RosSymEntry = FindEntry(RosSymInfo, RelativeAddress);
115
116 if (NULL == RosSymEntry)
117 {
118 DPRINT("None of the requested information was found!\n");
119 return FALSE;
120 }
121
122 if (LineNumber != NULL)
123 {
124 *LineNumber = RosSymEntry->SourceLine;
125 }
126 if (FileName != NULL)
127 {
128 PCSTR Name = "";
129 if (RosSymEntry->FileOffset != 0)
130 {
131 Name = (PCHAR) RosSymInfo->Strings + RosSymEntry->FileOffset;
132 }
134 }
135 if (FunctionName != NULL)
136 {
137 PCSTR Name = "";
138 if (RosSymEntry->FunctionOffset != 0)
139 {
140 Name = (PCHAR) RosSymInfo->Strings + RosSymEntry->FunctionOffset;
141 }
143 }
144
145 return TRUE;
146}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1220
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1279
#define ASSERT(a)
Definition: mode.c:44
static PROSSYM_ENTRY FindEntry(IN PROSSYM_INFO RosSymInfo, IN ULONG_PTR RelativeAddress)
Definition: find.c:46
ULONG SourceLine
Definition: rossym.h:30
ULONG FileOffset
Definition: rossym.h:29
ULONG FunctionOffset
Definition: rossym.h:28
ULONG SymbolsCount
Definition: rossym.h:124
ULONG StringsLength
Definition: rossym.h:126
PROSSYM_ENTRY Symbols
Definition: rossym.h:123
PCHAR Strings
Definition: rossym.h:125
const char * PCSTR
Definition: typedefs.h:52

Referenced by KdbSymPrintAddress().

◆ RosSymGetRawData()

VOID RosSymGetRawData ( PROSSYM_INFO  RosSymInfo,
PVOID  RawData 
)

Definition at line 23 of file getraw.c.

24{
25 PROSSYM_HEADER RosSymHeader;
26
27 RosSymHeader = (PROSSYM_HEADER) RawData;
28 RosSymHeader->SymbolsOffset = sizeof(ROSSYM_HEADER);
29 RosSymHeader->SymbolsLength = RosSymInfo->SymbolsCount * sizeof(ROSSYM_ENTRY);
30 RosSymHeader->StringsOffset = RosSymHeader->SymbolsOffset + RosSymHeader->SymbolsLength;
31 RosSymHeader->StringsLength = RosSymInfo->StringsLength;
32
33 memcpy((char *) RawData + RosSymHeader->SymbolsOffset, RosSymInfo->Symbols,
34 RosSymHeader->SymbolsLength);
35 memcpy((char *) RawData + RosSymHeader->StringsOffset, RosSymInfo->Strings,
36 RosSymHeader->StringsLength);
37}

◆ RosSymGetRawDataLength()

ULONG RosSymGetRawDataLength ( PROSSYM_INFO  RosSymInfo)

Definition at line 15 of file getraw.c.

16{
17 return sizeof(ROSSYM_HEADER)
18 + RosSymInfo->SymbolsCount * sizeof(ROSSYM_ENTRY)
19 + RosSymInfo->StringsLength;
20}

◆ RosSymInit()

VOID RosSymInit ( PROSSYM_CALLBACKS  Callbacks)

Definition at line 17 of file init.c.

18{
20}
const struct winhelp_callbacks Callbacks
Definition: callback.c:161
ROSSYM_CALLBACKS RosSymCallbacks
Definition: init.c:14

Referenced by RosSymInitKernelMode(), and RosSymInitUserMode().

◆ RosSymInitKernelMode()

VOID RosSymInitKernelMode ( VOID  )

Definition at line 32 of file initkm.c.

33{
34 static ROSSYM_CALLBACKS KmCallbacks =
35 {
40 };
41
42 RosSymInit(&KmCallbacks);
43}
static PVOID RosSymAllocMemKM(ULONG_PTR Size)
Definition: initkm.c:20
static VOID RosSymFreeMemKM(PVOID Area)
Definition: initkm.c:26
BOOLEAN RosSymZwReadFile(PVOID FileContext, PVOID Buffer, ULONG Size)
Definition: zwfile.c:15
BOOLEAN RosSymZwSeekFile(PVOID FileContext, ULONG_PTR Position)
Definition: zwfile.c:31
VOID RosSymInit(PROSSYM_CALLBACKS Callbacks)
Definition: init.c:17

Referenced by KdbSymInit().

◆ RosSymInitUserMode()

VOID RosSymInitUserMode ( VOID  )

Definition at line 29 of file initum.c.

30{
31 static ROSSYM_CALLBACKS KmCallbacks =
32 {
37 };
38
39 RosSymInit(&KmCallbacks);
40}
static PVOID RosSymAllocMemUM(ULONG_PTR Size)
Definition: initum.c:17
static VOID RosSymFreeMemUM(PVOID Area)
Definition: initum.c:23