RDFU
1.0
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Te.c
Go to the documentation of this file.
1
12
#include "
EfiScannerHeaders.h
"
13
14
15
29
EFI_STATUS
DumpTEFile
(
C_PTR
BaseAddr)
30
{
31
CHAR16 DmpFilePath[512];
32
TE_IMAGE_HEADER
*TEHeader;
33
EFI_IMAGE_SECTION_HEADER
*TESec;
34
UINT32 Size;
35
UINTN i;
36
37
38
TEHeader = (
TE_IMAGE_HEADER
*)BaseAddr;
39
40
41
#if DEBUG_ON == 1
42
LogFullAscii
(
"%a: trying to dump %016lx.\r\n"
, __FUNCTION__, (
MAX_PTR
)BaseAddr);
43
#endif
44
45
46
if
(TEHeader->
Signature
!=
TE_SIGNATURE
)
47
{
48
#if DEBUG_ON == 1
49
LogFullAscii
(
"%a: invalid TE file signature at %016lx, sig = %08x\r\n"
,
50
__FUNCTION__, (
MAX_PTR
)BaseAddr, TEHeader->
Signature
);
51
#endif
52
return
EFI_NOT_FOUND;
53
}
54
55
56
// add some additional checks for subsystem
57
// (it should be EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) but
58
// lets write down all the possibilities
59
60
if
((TEHeader->
Subsystem
!=
EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
) &&
61
(TEHeader->
Subsystem
!=
EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
))
62
{
63
#if DEBUG_ON == 1
64
LogFullAscii
(
"%a: invalid TE subsystem %d\r\n"
,
65
__FUNCTION__, TEHeader->
Subsystem
);
66
#endif
67
return
EFI_NOT_FOUND;
68
}
69
70
71
// calculate total size
72
Size =
sizeof
(
TE_IMAGE_HEADER
) +
73
((
sizeof
(
EFI_IMAGE_SECTION_HEADER
)*TEHeader->
NumberOfSections
)) + 16;
// (plus pad)
74
75
76
TESec = (
EFI_IMAGE_SECTION_HEADER
*)(BaseAddr +
sizeof
(
TE_IMAGE_HEADER
));
77
78
for
(i = 0; i < TEHeader->
NumberOfSections
; i++, TESec++)
79
Size += TESec->
SizeOfRawData
;
80
81
// at this point maybe it would be nice to check the correctness
82
// of the format. on the other hand everyone who can load
83
// their image on the UEFI system has a total control of the
84
// system, so it is kinda not necessary
85
86
87
UnicodeSPrint(DmpFilePath,
sizeof
(DmpFilePath)-1, L
"bdump\\%p.dmp"
, BaseAddr);
88
89
#if DEBUG_ON == 1
90
LogFullAscii
(
"%a: Dumping to %s (CalculatedSize=%08x)\r\n"
,
91
__FUNCTION__, DmpFilePath, Size);
92
#endif
93
94
// dump the file
95
DumpMemoryToFile
(BaseAddr, Size, DmpFilePath, FALSE);
96
97
98
#if DEBUG_ON == 1
99
LogFullAscii
(
"%a: TE memory dumped correctly.\r\n"
, __FUNCTION__);
100
#endif
101
102
103
return
EFI_SUCCESS;
104
}
105
Te.c
Generated on Thu Apr 18 2013 10:57:17 for RDFU by
1.8.3.1