XUserModule::GetOptHeader

This commit is contained in:
Dr. Chat
2015-06-27 22:41:09 -05:00
parent cdbf736241
commit 8a6c620fe7
5 changed files with 54 additions and 32 deletions

View File

@@ -29,7 +29,26 @@
namespace xe {
namespace kernel {
uint32_t xex2_get_header_size(const xex2_header* header) {
uint8_t* xex2_get_opt_header(const xex2_header* header, uint32_t key) {
for (uint32_t i = 0; i < header->header_count; i++) {
const xex2_opt_header& opt_header = header->headers[i];
if (opt_header.key != key) {
continue;
}
if ((opt_header.key & 0xFF) == 0x01) {
// Data is stored in the opt header
return (uint8_t*)&opt_header.value;
} else {
// Data stored at offset.
return ((uint8_t*)&header->headers[0] + opt_header.offset);
}
}
return nullptr;
}
uint32_t xex2_get_header_size(const xex2_header *header) {
return header->exe_offset;
}
} // namespace kernel

View File

@@ -15,29 +15,11 @@
namespace xe {
namespace kernel {
template <typename T>
T* xex2_get_opt_header(const xex2_header* header, uint32_t key) {
for (uint32_t i = 0; i < header->header_count; i++) {
const xex2_opt_header& opt_header = header->headers[i];
if (opt_header.key != key) {
continue;
}
if ((opt_header.key & 0xFF) == 0x01) {
// Data is stored in the opt header
return (T*)&opt_header.value;
} else {
// Data stored at offset.
return (T*)((uint8_t*)&header->headers[0] + opt_header.offset);
}
}
return nullptr;
}
uint8_t* xex2_get_opt_header(const xex2_header* header, uint32_t key);
uint32_t xex2_get_header_size(const xex2_header* header);
} // namespace kernel
} // namespace xe
} // namespace kernel
} // namespace xe
typedef struct { int reserved; } xe_xex2_options_t;