This commit is contained in:
Dr. Chat 2015-07-03 19:57:18 -05:00
parent 03ffb20a43
commit 1788ee1589
6 changed files with 20 additions and 27 deletions

View File

@ -114,7 +114,7 @@ uint32_t XexModule::GetProcAddress(uint16_t ordinal) const {
xex2_opt_data_directory* pe_export_directory = 0; xex2_opt_data_directory* pe_export_directory = 0;
if (GetOptHeader(XEX_HEADER_EXPORTS_BY_NAME, &pe_export_directory)) { if (GetOptHeader(XEX_HEADER_EXPORTS_BY_NAME, &pe_export_directory)) {
auto e = memory()->TranslateVirtual<const X_IMAGE_EXPORT_DIRECTORY*>( auto e = memory()->TranslateVirtual<const X_IMAGE_EXPORT_DIRECTORY*>(
*exe_address + pe_export_directory->offset); *exe_address + pe_export_directory->offset);
assert_not_null(e); assert_not_null(e);
uint32_t* function_table = (uint32_t*)((uint8_t*)e + e->AddressOfFunctions); uint32_t* function_table = (uint32_t*)((uint8_t*)e + e->AddressOfFunctions);

View File

@ -122,8 +122,7 @@ uint32_t KernelState::title_id() const {
assert_not_null(executable_module_); assert_not_null(executable_module_);
xex2_opt_execution_info* exec_info = 0; xex2_opt_execution_info* exec_info = 0;
executable_module_->GetOptHeader(XEX_HEADER_EXECUTION_INFO, executable_module_->GetOptHeader(XEX_HEADER_EXECUTION_INFO, &exec_info);
&exec_info);
if (exec_info) { if (exec_info) {
return exec_info->title_id; return exec_info->title_id;

View File

@ -586,11 +586,8 @@ void XThread::DeliverAPCs(void* data) {
// kernel_routine(apc_address, &normal_routine, &normal_context, // kernel_routine(apc_address, &normal_routine, &normal_context,
// &system_arg1, &system_arg2) // &system_arg1, &system_arg2)
uint64_t kernel_args[] = { uint64_t kernel_args[] = {
apc_ptr, apc_ptr, thread->scratch_address_ + 0, thread->scratch_address_ + 4,
thread->scratch_address_ + 0, thread->scratch_address_ + 8, thread->scratch_address_ + 12,
thread->scratch_address_ + 4,
thread->scratch_address_ + 8,
thread->scratch_address_ + 12,
}; };
processor->Execute(thread->thread_state(), apc->kernel_routine, processor->Execute(thread->thread_state(), apc->kernel_routine,
kernel_args, xe::countof(kernel_args)); kernel_args, xe::countof(kernel_args));

View File

@ -380,12 +380,9 @@ void XUserModule::Dump() {
auto opt_exec_info = auto opt_exec_info =
reinterpret_cast<const xex2_opt_execution_info*>(opt_header_ptr); reinterpret_cast<const xex2_opt_execution_info*>(opt_header_ptr);
printf(" Media ID: %.8X\n", printf(" Media ID: %.8X\n", (uint32_t)opt_exec_info->media_id);
(uint32_t)opt_exec_info->media_id); printf(" Title ID: %.8X\n", (uint32_t)opt_exec_info->title_id);
printf(" Title ID: %.8X\n", printf(" Savegame ID: %.8X\n", (uint32_t)opt_exec_info->title_id);
(uint32_t)opt_exec_info->title_id);
printf(" Savegame ID: %.8X\n",
(uint32_t)opt_exec_info->title_id);
printf(" Disc Number / Total: %d / %d\n", printf(" Disc Number / Total: %d / %d\n",
(uint8_t)opt_exec_info->disc_number, (uint8_t)opt_exec_info->disc_number,
(uint8_t)opt_exec_info->disc_count); (uint8_t)opt_exec_info->disc_count);
@ -422,13 +419,15 @@ void XUserModule::Dump() {
exe_address + dir->offset); exe_address + dir->offset);
// e->AddressOfX RVAs are relative to the IMAGE_EXPORT_DIRECTORY! // e->AddressOfX RVAs are relative to the IMAGE_EXPORT_DIRECTORY!
uint32_t* function_table = (uint32_t*)((uint64_t)e + e->AddressOfFunctions); uint32_t* function_table =
(uint32_t*)((uint64_t)e + e->AddressOfFunctions);
// Names relative to directory // Names relative to directory
uint32_t* name_table = (uint32_t*)((uint64_t)e + e->AddressOfNames); uint32_t* name_table = (uint32_t*)((uint64_t)e + e->AddressOfNames);
// Table of ordinals (by name) // Table of ordinals (by name)
uint16_t* ordinal_table = (uint16_t*)((uint64_t)e + e->AddressOfNameOrdinals); uint16_t* ordinal_table =
(uint16_t*)((uint64_t)e + e->AddressOfNameOrdinals);
for (uint32_t i = 0; i < e->NumberOfNames; i++) { for (uint32_t i = 0; i < e->NumberOfNames; i++) {
const char* name = (const char*)((uint8_t*)e + name_table[i]); const char* name = (const char*)((uint8_t*)e + name_table[i]);

View File

@ -27,8 +27,7 @@
#include "xenia/base/memory.h" #include "xenia/base/memory.h"
#include "xenia/base/platform.h" #include "xenia/base/platform.h"
namespace xe { namespace xe {} // namespace xe
} // namespace xe
// TODO(benvanik): remove. // TODO(benvanik): remove.
#define XEEXPECTZERO(expr) \ #define XEEXPECTZERO(expr) \
@ -247,9 +246,10 @@ int xe_xex2_read_header(const uint8_t* addr, const size_t length,
} break; } break;
case XEX_HEADER_IMPORT_LIBRARIES: { case XEX_HEADER_IMPORT_LIBRARIES: {
auto import_libraries = auto import_libraries =
reinterpret_cast<const xe::xex2_opt_import_libraries *>(pp); reinterpret_cast<const xe::xex2_opt_import_libraries*>(pp);
const uint32_t max_count = (uint32_t)xe::countof(header->import_libraries); const uint32_t max_count =
(uint32_t)xe::countof(header->import_libraries);
uint32_t count = import_libraries->library_count; uint32_t count = import_libraries->library_count;
assert_true(count <= max_count); assert_true(count <= max_count);
if (count > max_count) { if (count > max_count) {
@ -260,7 +260,7 @@ int xe_xex2_read_header(const uint8_t* addr, const size_t length,
header->import_library_count = count; header->import_library_count = count;
uint32_t string_table_size = import_libraries->string_table_size; uint32_t string_table_size = import_libraries->string_table_size;
const char *string_table[32]; // Pretend 32 is max_count const char* string_table[32]; // Pretend 32 is max_count
std::memset(string_table, 0, sizeof(string_table)); std::memset(string_table, 0, sizeof(string_table));
// Parse the string table // Parse the string table
@ -279,15 +279,14 @@ int xe_xex2_read_header(const uint8_t* addr, const size_t length,
pp += 12 + import_libraries->string_table_size; pp += 12 + import_libraries->string_table_size;
for (size_t m = 0; m < count; m++) { for (size_t m = 0; m < count; m++) {
xe_xex2_import_library_t* library = &header->import_libraries[m]; xe_xex2_import_library_t* library = &header->import_libraries[m];
auto src_library = (xe::xex2_import_library *)pp; auto src_library = (xe::xex2_import_library*)pp;
memcpy(library->digest, pp + 0x04, 20); memcpy(library->digest, pp + 0x04, 20);
library->import_id = src_library->id; library->import_id = src_library->id;
library->version.value = src_library->version.value; library->version.value = src_library->version.value;
library->min_version.value = src_library->version_min.value; library->min_version.value = src_library->version_min.value;
std::strncpy(library->name, std::strncpy(library->name, string_table[src_library->name_index],
string_table[src_library->name_index],
xe::countof(library->name)); xe::countof(library->name));
library->record_count = src_library->count; library->record_count = src_library->count;
@ -1056,7 +1055,7 @@ uint32_t xe_xex2_lookup_export(xe_xex2_ref xex, uint16_t ordinal) {
// XEX-style export table. // XEX-style export table.
if (header->loader_info.export_table) { if (header->loader_info.export_table) {
auto export_table = reinterpret_cast<const xe::xex2_export_table *>( auto export_table = reinterpret_cast<const xe::xex2_export_table*>(
xex->memory->TranslateVirtual(header->loader_info.export_table)); xex->memory->TranslateVirtual(header->loader_info.export_table));
uint32_t ordinal_count = export_table->count; uint32_t ordinal_count = export_table->count;
uint32_t ordinal_base = export_table->base; uint32_t ordinal_base = export_table->base;

View File

@ -13,8 +13,7 @@
#include "xenia/kernel/util/xex2_info.h" #include "xenia/kernel/util/xex2_info.h"
#include "xenia/memory.h" #include "xenia/memory.h"
namespace xe { namespace xe {} // namespace xe
} // namespace xe
typedef struct { int reserved; } xe_xex2_options_t; typedef struct { int reserved; } xe_xex2_options_t;