xbmc
xbmc
cores
DllLoader
coffldr.h
1
/*
2
* Copyright (C) 2005-2018 Team Kodi
3
* This file is part of Kodi - https://kodi.tv
4
*
5
* SPDX-License-Identifier: GPL-2.0-or-later
6
* See LICENSES/README.md for more information.
7
*/
8
9
#pragma once
10
11
//#pragma message("including coffldr.h")
12
#include "coff.h"
13
14
#include <stdio.h>
15
16
class
CoffLoader
17
{
18
public
:
19
CoffLoader
();
20
virtual
~
CoffLoader
();
21
22
int
ParseCoff(FILE *fp);
23
int
ParseHeaders(
void
* hModule);
24
25
void
*hModule;
//standard windows HINSTANCE handle hold the whole image
26
//Pointers to somewhere in hModule, do not free these pointers
27
COFF_FileHeader_t
*CoffFileHeader;
28
OptionHeader_t
*OptionHeader;
29
WindowsHeader_t
*WindowsHeader;
30
Image_Data_Directory_t
*Directory;
31
SectionHeader_t
*SectionHeader;
32
33
protected
:
34
35
// Allocated structures... hModule now hold the master Memory handle
36
SymbolTable_t
*SymTable;
37
char
*StringTable;
38
char
**SectionData;
39
40
unsigned
long
EntryAddress;
//Initialize entry point
41
42
// Unnecessary data
43
// This is data that is used only during linking and is not necessary
44
// while the program is running in general
45
46
int
NumberOfSymbols;
47
int
SizeOfStringTable;
48
int
NumOfDirectories;
49
int
NumOfSections;
50
int
FileHeaderOffset;
51
52
// Members for printing the structures
53
static
void
PrintFileHeader(
COFF_FileHeader_t
*FileHeader);
54
static
void
PrintWindowsHeader(
WindowsHeader_t
*WinHdr);
55
static
void
PrintOptionHeader(
OptionHeader_t
*OptHdr);
56
static
void
PrintSection(
SectionHeader_t
* ScnHdr,
const
char
* data);
57
void
PrintStringTable(
void
);
58
void
PrintSymbolTable(
void
);
59
60
// Members for Loading the Different structures
61
int
LoadCoffHModule(FILE * fp);
62
int
LoadSymTable(FILE *fp);
63
int
LoadStringTable(FILE *fp);
64
int
LoadSections(FILE *fp);
65
66
// Members for access some of the Data
67
68
int
RVA2Section(
unsigned
long
RVA);
69
void
* RVA2Data(
unsigned
long
RVA);
70
unsigned
long
Data2RVA(
void
* address);
71
72
char
*GetStringTblIndex(
int
index);
73
char
*GetStringTblOff(
int
Offset);
74
char
*GetSymbolName(
SymbolTable_t
*sym);
75
char
*GetSymbolName(
int
index);
76
77
void
PerformFixups(
void
);
78
};
79
WindowsHeader_t
Definition:
coff.h:126
Image_Data_Directory_t
Definition:
coff.h:193
OptionHeader_t
Definition:
coff.h:96
COFF_FileHeader_t
Definition:
coff.h:37
SymbolTable_t
Definition:
coff.h:323
SectionHeader_t
Definition:
coff.h:225
CoffLoader
Definition:
coffldr.h:16
Generated by
1.8.13