ROSE
0.9.6a
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
PeSection.C
Go to the documentation of this file.
1
/* Windows PE Sections (SgAsmPESection and related classes) */
2
3
#include "
sage3basic.h
"
4
5
/* Pre-unparsing updates */
6
bool
7
SgAsmPESection::reallocate
()
8
{
9
bool
reallocated =
false
;
10
11
SgAsmPESectionTableEntry
*shdr =
get_section_entry
();
12
if
(shdr)
13
shdr->
update_from_section
(
this
);
14
15
return
reallocated;
16
}
17
21
SgAsmPESection
*
22
SgAsmPESection::init_from_section_table
(
SgAsmPESectionTableEntry
*entry,
int
id
)
23
{
24
ROSE_ASSERT(entry);
25
ROSE_ASSERT(
id
>=0);
26
27
SgAsmPEFileHeader
*fhdr =
dynamic_cast<
SgAsmPEFileHeader
*
>
(
get_header
());
28
ROSE_ASSERT(fhdr!=NULL);
29
30
set_synthesized
(
false
);
31
set_name
(
new
SgAsmBasicString
(entry->
get_name
()));
32
set_id
(
id
);
33
set_purpose
(
SP_PROGRAM
);
34
35
/* File mapping */
36
set_offset
(entry->
get_physical_offset
());
37
set_size
(entry->
get_physical_size
());
38
set_file_alignment
(fhdr->
get_e_file_align
());
39
40
/* Memory mapping */
41
if
(entry->
get_rva
() > 0) {
42
set_mapped_preferred_rva
(entry->
get_rva
());
43
set_mapped_actual_va
(0);
/*will be asigned by BinaryLoader*/
44
set_mapped_size
(entry->
get_virtual_size
());
45
set_mapped_alignment
(fhdr->
get_e_section_align
());
46
set_mapped_rperm
((entry->
get_flags
() &
SgAsmPESectionTableEntry::OF_READABLE
)
47
==
SgAsmPESectionTableEntry::OF_READABLE
);
48
set_mapped_wperm
((entry->
get_flags
() &
SgAsmPESectionTableEntry::OF_WRITABLE
)
49
==
SgAsmPESectionTableEntry::OF_WRITABLE
);
50
set_mapped_xperm
((entry->
get_flags
() &
SgAsmPESectionTableEntry::OF_EXECUTABLE
)
51
==
SgAsmPESectionTableEntry::OF_EXECUTABLE
);
52
}
else
{
53
set_mapped_preferred_rva
(0);
54
set_mapped_actual_va
(0);
/*will be assigned by Loader*/
55
set_mapped_size
(0);
56
set_mapped_rperm
(
false
);
57
set_mapped_wperm
(
false
);
58
set_mapped_xperm
(
false
);
59
set_mapped_alignment
(fhdr->
get_e_section_align
());
60
}
61
62
/* Add section table entry to section */
63
set_section_entry
(entry);
64
entry->
set_parent
(
this
);
65
66
return
this
;
67
}
68
69
/* Print some debugging info. */
70
void
71
SgAsmPESection::dump
(FILE *f,
const
char
*
prefix
, ssize_t idx)
const
72
{
73
char
p[4096];
74
if
(idx>=0) {
75
sprintf(p,
"%sPESection[%zd]."
, prefix, idx);
76
}
else
{
77
sprintf(p,
"%sPESection."
, prefix);
78
}
79
80
SgAsmGenericSection::dump
(f, p, -1);
81
if
(
p_section_entry
)
82
p_section_entry
->
dump
(f, p, -1);
83
84
if
(
variantT
() ==
V_SgAsmPESection
)
//unless a base class
85
hexdump
(f, 0, std::string(p)+
"data at "
,
p_data
);
86
}
rose-edg4x
src
frontend
BinaryFormats
PeSection.C
Generated on Mon May 5 2014 17:29:25 for ROSE by
1.8.4