Directly check PEB for IsDebuggerAttached

Add constexpr getters to magicdiv class so it can be used from jitted x64/dxbc
Track the guest return address as well for guest/host sync, if multiple entries have the same guest stack find the first one with a matching guest retaddr. this fixes epic mickey 2 (which the previous guest-stack change had allowed to go ingame for a bit) and potentially also a crash in fable3.
Break if under debugger when stackpoints are overflowed

Add much more useful output for host exceptions, print out xenia_canary.exe relative offsets if exception is in module, formatmessage for ntstatus/win32err, strerror

Minor d3d12 microoptimization, instead of doing SetEventOnCompletion + WaitForSingleObject do SetEventOnCompletion w/ nullptr so that the wait happens in kernel mode, avoiding two extra context switches

add unimplemented kernel functions:
ExAllocatePoolWithTag
ObReferenceObject

ObDereferenceObject has no return value.
Log a message when ObDereferenceObject/Reference receive unregistered guest kernel objects
gave ObLookupThreadByThreadId its correct error status
hoist object_types initialization out of ObReferenceObjectByHandle
Fix out parameter values on error for a few kernel funcs
add note about msr to KeSetCurrentStackPointers
add X_STATUS_OBJECT_TYPE_MISMATCH check for xeNtSetEvent
add msr_mask field to X_KPCR
This commit is contained in:
chss95cs@gmail.com
2022-12-04 12:38:19 -08:00
parent 1eb61aa9ab
commit a63f424c0a
18 changed files with 412 additions and 105 deletions

View File

@@ -11,6 +11,7 @@
#include "xenia/base/assert.h"
#include "xenia/base/byte_order.h"
#include "xenia/base/cvar.h"
#include "xenia/base/memory.h"
#include "xenia/base/profiling.h"
#include "xenia/base/reset_scope.h"
@@ -22,6 +23,10 @@
#include "xenia/cpu/ppc/ppc_opcode_info.h"
#include "xenia/cpu/ppc/ppc_scanner.h"
#include "xenia/cpu/processor.h"
#include "xenia/cpu/xex_module.h"
DEFINE_bool(dump_translated_hir_functions, false, "dumps translated hir",
"CPU");
namespace xe {
namespace cpu {
@@ -107,10 +112,44 @@ class HirBuilderScope {
~HirBuilderScope() {
if (builder_) {
builder_->RemoveCurrent();
}
}
}
};
void PPCTranslator::DumpHIR(GuestFunction* function, PPCHIRBuilder* builder) {
if (cvars::dump_translated_hir_functions) {
StringBuffer buffer{};
builder_->Dump(&buffer);
XexModule* mod = dynamic_cast<XexModule*>(function->module());
std::wstring folder_name = L"hirdump";
if (mod) {
xex2_opt_execution_info* opt_exec_info = nullptr;
if (mod->GetOptHeader(XEX_HEADER_EXECUTION_INFO, &opt_exec_info)) {
folder_name =
L"hirdump_title_" + std::to_wstring(opt_exec_info->title_id);
}
}
std::filesystem::path folder_path{folder_name};
if (!std::filesystem::exists(folder_path)) {
std::filesystem::create_directory(folder_path);
}
{
wchar_t tmpbuf[64];
_snwprintf(tmpbuf, 64, L"%X", function->address());
folder_path.append(&tmpbuf[0]);
}
FILE* f = fopen(folder_path.generic_u8string().c_str(), "w");
if (f) {
fputs(buffer.buffer(), f);
fclose(f);
}
}
}
bool PPCTranslator::Translate(GuestFunction* function,
uint32_t debug_info_flags) {
SCOPE_profile_cpu_f("cpu");
@@ -203,6 +242,8 @@ bool PPCTranslator::Translate(GuestFunction* function,
string_buffer_.Reset();
}
DumpHIR(function, builder_.get());
// Assemble to backend machine code.
if (!assembler_->Assemble(function, builder_.get(), debug_info_flags,
std::move(debug_info))) {

View File

@@ -31,7 +31,9 @@ class PPCTranslator {
~PPCTranslator();
bool Translate(GuestFunction* function, uint32_t debug_info_flags);
void DumpHIR(GuestFunction* function, PPCHIRBuilder* builder);
void Reset();
private:
void DumpSource(GuestFunction* function, StringBuffer* string_buffer);