reactos/sdk/lib/rossym/fromraw.c
Hermès Bélusca-Maïto e1d334794a
[FREELDR][ROSSYM(_NEW)] Remove last vestigial references to "NTOSAPI".
This was a MinGW-specific, non-MS-DDK/WDK-compatible define, that was
used to mark NTOS kernel/hal exports, instead of NTSYSAPI etc.

We have since fixed that, and changed the way Freeldr (and rossym)
manages these, see commits:
186c8b72d (r16028), 51f0dfd30 (r17651) and 526efd2ee (r24359)
2024-03-07 13:35:08 +01:00

54 lines
1.9 KiB
C

/*
* 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)
*/
#include <ntdef.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 */