ReactOS  0.4.15-dev-3302-ga37d9a4
fromraw.c File Reference
#include <ntdef.h>
#include <reactos/rossym.h>
#include "rossympriv.h"
#include <debug.h>
Include dependency graph for fromraw.c:

Go to the source code of this file.

Macros

#define NTOSAPI
 
#define NDEBUG
 

Functions

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

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file fromraw.c.

◆ NTOSAPI

#define NTOSAPI

Definition at line 10 of file fromraw.c.

Function Documentation

◆ RosSymCreateFromRaw()

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

Definition at line 19 of file fromraw.c.

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