Merge pull request #436 from DrChat/misc_changes

Misc changes
This commit is contained in:
Ben Vanik
2015-10-17 01:15:20 -07:00
13 changed files with 132 additions and 26 deletions

View File

@@ -189,6 +189,7 @@ Function* Processor::ResolveFunction(uint32_t address) {
// Grab symbol declaration.
auto function = LookupFunction(address);
if (!function) {
entry->status = Entry::STATUS_FAILED;
return nullptr;
}
@@ -317,10 +318,21 @@ uint64_t Processor::Execute(ThreadState* thread_state, uint32_t address,
SCOPE_profile_cpu_f("cpu");
PPCContext* context = thread_state->context();
assert_true(arg_count <= 5);
for (size_t i = 0; i < arg_count; ++i) {
for (size_t i = 0; i < std::min(arg_count, 8ull); ++i) {
context->r[3 + i] = args[i];
}
if (arg_count > 7) {
// Rest of the arguments go on the stack.
// FIXME: This assumes arguments are 32 bits!
auto stack_arg_base =
memory()->TranslateVirtual((uint32_t)context->r[1] + 0x54 - (64 + 112));
for (size_t i = 0; i < arg_count - 8; i++) {
xe::store_and_swap<uint32_t>(stack_arg_base + (i * 8),
(uint32_t)args[i + 8]);
}
}
if (!Execute(thread_state, address)) {
return 0xDEADBABE;
}

View File

@@ -55,6 +55,9 @@ bool RawModule::LoadFile(uint32_t base_address, const std::wstring& path) {
low_address_ = base_address;
high_address_ = base_address + file_length;
// Notify backend about executable code.
processor_->backend()->CommitExecutableRange(low_address_, high_address_);
return true;
}