1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
/* Copyright 2017 R. Thomas
* Copyright 2017 Quarkslab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "pyPE.hpp"
#include "LIEF/PE/hash.hpp"
#include "LIEF/PE/LoadConfigurations.hpp"
#include <string>
#include <sstream>
namespace LIEF {
namespace PE {
template<class T>
using getter_t = T (LoadConfiguration::*)(void) const;
template<class T>
using setter_t = void (LoadConfiguration::*)(T);
template<>
void create<LoadConfiguration>(py::module& m) {
py::class_<LoadConfiguration, LIEF::Object>(m, "LoadConfiguration",
"Class modeling the default PE's ``LoadConfiguration``\n\n"
"It's the base class for any future version of the structure"
)
.def(py::init<>())
.def_property_readonly("version",
&LoadConfiguration::version,
"(SDK) Version of the structure. (" RST_CLASS_REF(lief.PE.WIN_VERSION) ")")
.def_property("characteristics",
static_cast<getter_t<uint32_t>>(&LoadConfiguration::characteristics),
static_cast<setter_t<uint32_t>>(&LoadConfiguration::characteristics),
"Characteristics of the structure.")
.def_property("timedatestamp",
static_cast<getter_t<uint32_t>>(&LoadConfiguration::timedatestamp),
static_cast<setter_t<uint32_t>>(&LoadConfiguration::timedatestamp),
"Date and time stamp value")
.def_property("major_version",
static_cast<getter_t<uint16_t>>(&LoadConfiguration::major_version),
static_cast<setter_t<uint16_t>>(&LoadConfiguration::major_version),
"Major Version")
.def_property("minor_version",
static_cast<getter_t<uint16_t>>(&LoadConfiguration::minor_version),
static_cast<setter_t<uint16_t>>(&LoadConfiguration::minor_version),
"Minor version")
.def_property("global_flags_clear",
static_cast<getter_t<uint32_t>>(&LoadConfiguration::global_flags_clear),
static_cast<setter_t<uint32_t>>(&LoadConfiguration::global_flags_clear),
"The global loader flags to clear for this process as the loader start the process.")
.def_property("global_flags_set",
static_cast<getter_t<uint32_t>>(&LoadConfiguration::global_flags_set),
static_cast<setter_t<uint32_t>>(&LoadConfiguration::global_flags_set),
"The global loader flags to set for this process as the loader starts the process.")
.def_property("critical_section_default_timeout",
static_cast<getter_t<uint32_t>>(&LoadConfiguration::critical_section_default_timeout),
static_cast<setter_t<uint32_t>>(&LoadConfiguration::critical_section_default_timeout),
"The default timeout value to use for is process’s critical sections that are abandoned.")
.def_property("decommit_free_block_threshold",
static_cast<getter_t<uint64_t>>(&LoadConfiguration::decommit_free_block_threshold),
static_cast<setter_t<uint64_t>>(&LoadConfiguration::decommit_free_block_threshold),
"Memory that must be freed before it is returned to the system, in bytes.")
.def_property("decommit_total_free_threshold",
static_cast<getter_t<uint64_t>>(&LoadConfiguration::decommit_total_free_threshold),
static_cast<setter_t<uint64_t>>(&LoadConfiguration::decommit_total_free_threshold),
"Total amount of free memory, in bytes")
.def_property("lock_prefix_table",
static_cast<getter_t<uint64_t>>(&LoadConfiguration::lock_prefix_table),
static_cast<setter_t<uint64_t>>(&LoadConfiguration::lock_prefix_table),
"The **VA** of a list of addresses where the ``LOCK`` prefix "
"is used so that they can be replaced with ``NOP`` on single processor machines.")
.def_property("maximum_allocation_size",
static_cast<getter_t<uint64_t>>(&LoadConfiguration::maximum_allocation_size),
static_cast<setter_t<uint64_t>>(&LoadConfiguration::maximum_allocation_size),
"Maximum allocation size, in bytes.")
.def_property("virtual_memory_threshold",
static_cast<getter_t<uint64_t>>(&LoadConfiguration::virtual_memory_threshold),
static_cast<setter_t<uint64_t>>(&LoadConfiguration::virtual_memory_threshold),
"Maximum virtual memory size, in bytes.")
.def_property("process_affinity_mask",
static_cast<getter_t<uint64_t>>(&LoadConfiguration::process_affinity_mask),
static_cast<setter_t<uint64_t>>(&LoadConfiguration::process_affinity_mask),
"Setting this field to a non-zero value is equivalent to calling "
"``SetProcessAffinityMask`` with this value during process startup (.exe only)")
.def_property("process_heap_flags",
static_cast<getter_t<uint32_t>>(&LoadConfiguration::process_heap_flags),
static_cast<setter_t<uint32_t>>(&LoadConfiguration::process_heap_flags),
"Process heap flags that correspond to the first argument of the "
"``HeapCreate`` function. These flags apply to the process heap that is "
"created during process startup.")
.def_property("csd_version",
static_cast<getter_t<uint16_t>>(&LoadConfiguration::csd_version),
static_cast<setter_t<uint16_t>>(&LoadConfiguration::csd_version),
"The service pack version identifier.")
.def_property("reserved1",
static_cast<getter_t<uint16_t>>(&LoadConfiguration::reserved1),
static_cast<setter_t<uint16_t>>(&LoadConfiguration::reserved1),
"Must be zero.")
.def_property("editlist",
static_cast<getter_t<uint32_t>>(&LoadConfiguration::editlist),
static_cast<setter_t<uint32_t>>(&LoadConfiguration::editlist),
"Reserved for use by the system.")
.def_property("security_cookie",
static_cast<getter_t<uint32_t>>(&LoadConfiguration::security_cookie),
static_cast<setter_t<uint32_t>>(&LoadConfiguration::security_cookie),
"A pointer to a cookie that is used by Visual C++ or GS implementation.")
.def("__eq__", &LoadConfiguration::operator==)
.def("__ne__", &LoadConfiguration::operator!=)
.def("__hash__",
[] (const LoadConfiguration& config) {
return Hash::hash(config);
})
.def("__str__", [] (const LoadConfiguration& config)
{
std::ostringstream stream;
stream << config;
std::string str = stream.str();
return str;
});
}
}
}
|