mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:13:06 +00:00
Create a branch for header work.
svn path=/branches/header-work/; revision=45691
This commit is contained in:
parent
14fe274b1c
commit
9ea495ba33
19538 changed files with 0 additions and 1063950 deletions
55
lib/rossym/fromraw.c
Normal file
55
lib/rossym/fromraw.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: lib/rossym/frommem.c
|
||||
* PURPOSE: Creating rossym info from an in-memory image
|
||||
*
|
||||
* PROGRAMMERS: Ge van Geldorp (gvg@reactos.com)
|
||||
*/
|
||||
|
||||
#define NTOSAPI
|
||||
#include <ntddk.h>
|
||||
#include <reactos/rossym.h>
|
||||
#include "rossympriv.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
BOOLEAN
|
||||
RosSymCreateFromRaw(PVOID RawData, ULONG_PTR DataSize, PROSSYM_INFO *RosSymInfo)
|
||||
{
|
||||
PROSSYM_HEADER RosSymHeader;
|
||||
|
||||
RosSymHeader = (PROSSYM_HEADER) RawData;
|
||||
if (RosSymHeader->SymbolsOffset < sizeof(ROSSYM_HEADER)
|
||||
|| RosSymHeader->StringsOffset < RosSymHeader->SymbolsOffset + RosSymHeader->SymbolsLength
|
||||
|| DataSize < RosSymHeader->StringsOffset + RosSymHeader->StringsLength
|
||||
|| 0 != (RosSymHeader->SymbolsLength % sizeof(ROSSYM_ENTRY)))
|
||||
{
|
||||
DPRINT1("Invalid ROSSYM_HEADER\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Copy */
|
||||
*RosSymInfo = RosSymAllocMem(sizeof(ROSSYM_INFO) + RosSymHeader->SymbolsLength
|
||||
+ RosSymHeader->StringsLength + 1);
|
||||
if (NULL == *RosSymInfo)
|
||||
{
|
||||
DPRINT1("Failed to allocate memory for rossym\n");
|
||||
return FALSE;
|
||||
}
|
||||
(*RosSymInfo)->Symbols = (PROSSYM_ENTRY)((char *) *RosSymInfo + sizeof(ROSSYM_INFO));
|
||||
(*RosSymInfo)->SymbolsCount = RosSymHeader->SymbolsLength / sizeof(ROSSYM_ENTRY);
|
||||
(*RosSymInfo)->Strings = (PCHAR) *RosSymInfo + sizeof(ROSSYM_INFO) + RosSymHeader->SymbolsLength;
|
||||
(*RosSymInfo)->StringsLength = RosSymHeader->StringsLength;
|
||||
memcpy((*RosSymInfo)->Symbols, (char *) RosSymHeader + RosSymHeader->SymbolsOffset,
|
||||
RosSymHeader->SymbolsLength);
|
||||
memcpy((*RosSymInfo)->Strings, (char *) RosSymHeader + RosSymHeader->StringsOffset,
|
||||
RosSymHeader->StringsLength);
|
||||
/* Make sure the last string is null terminated, we allocated an extra byte for that */
|
||||
(*RosSymInfo)->Strings[(*RosSymInfo)->StringsLength] = '\0';
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* EOF */
|
Loading…
Add table
Add a link
Reference in a new issue