summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-07-05 16:15:35 +0200
committerLennart Poettering <lennart@poettering.net>2024-09-12 10:02:15 +0200
commit9de565dd5d8dc768c1e9e2edb1eb5461d75505ef (patch)
treea0ca54ce8ca331fd9a4694c5fb3e498df6328a33 /src/shared
parentpe-binary: split pe_header_find_section() in two (diff)
downloadsystemd-9de565dd5d8dc768c1e9e2edb1eb5461d75505ef.tar.xz
systemd-9de565dd5d8dc768c1e9e2edb1eb5461d75505ef.zip
pe-binary: add pe_is_native() for checking if PE is native
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/pe-binary.c11
-rw-r--r--src/shared/pe-binary.h2
2 files changed, 13 insertions, 0 deletions
diff --git a/src/shared/pe-binary.c b/src/shared/pe-binary.c
index bfeaf3f1e1..3893ffaf97 100644
--- a/src/shared/pe-binary.c
+++ b/src/shared/pe-binary.c
@@ -6,6 +6,7 @@
#include "log.h"
#include "pe-binary.h"
#include "string-util.h"
+#include "uki.h"
bool pe_header_is_64bit(const PeHeader *h) {
assert(h);
@@ -273,3 +274,13 @@ bool pe_is_addon(const PeHeader *pe_header, const IMAGE_SECTION_HEADER *sections
pe_header_find_section(pe_header, sections, ".dtb") ||
pe_header_find_section(pe_header, sections, ".ucode"));
}
+
+bool pe_is_native(const PeHeader *pe_header) {
+ assert(pe_header);
+
+#ifdef _IMAGE_FILE_MACHINE_NATIVE
+ return le16toh(pe_header->pe.Machine) == _IMAGE_FILE_MACHINE_NATIVE;
+#else
+ return false;
+#endif
+}
diff --git a/src/shared/pe-binary.h b/src/shared/pe-binary.h
index 20f839e9a0..f508989185 100644
--- a/src/shared/pe-binary.h
+++ b/src/shared/pe-binary.h
@@ -145,3 +145,5 @@ int pe_read_section_data_by_name(int fd, const PeHeader *pe_header, const IMAGE_
bool pe_is_uki(const PeHeader *pe_header, const IMAGE_SECTION_HEADER *sections);
bool pe_is_addon(const PeHeader *pe_header, const IMAGE_SECTION_HEADER *sections);
+
+bool pe_is_native(const PeHeader *pe_header);