Calling DllMain, fixing ref count, and fixing module search.

This commit is contained in:
Ben Vanik
2015-05-09 00:56:42 -07:00
parent 0c646f4bc2
commit 23eb343484
11 changed files with 168 additions and 66 deletions

View File

@@ -109,10 +109,6 @@ uint32_t XThread::GetCurrentThreadId(const uint8_t* thread_state_block) {
return xe::load_and_swap<uint32_t>(thread_state_block + 0x14C);
}
uint32_t XThread::thread_state() { return thread_state_address_; }
uint32_t XThread::thread_id() { return thread_id_; }
uint32_t XThread::last_error() {
uint8_t* p = memory()->TranslateVirtual(thread_state_address_);
return xe::load_and_swap<uint32_t>(p + 0x160);
@@ -326,6 +322,9 @@ void XThread::Execute() {
thread_id_, handle(), name_.c_str(),
xe::threading::current_thread_id());
// Let the kernel know we are starting.
kernel_state()->OnThreadExecute(this);
// All threads get a mandatory sleep. This is to deal with some buggy
// games that are assuming the 360 is so slow to create threads that they
// have time to initialize shared structures AFTER CreateThread (RR).
@@ -349,6 +348,9 @@ void XThread::Execute() {
// Treat the return code as an implicit exit code.
Exit(exit_code);
}
// Let the kernel know we are exiting.
kernel_state()->OnThreadExit(this);
}
void XThread::EnterCriticalRegion() {

View File

@@ -35,8 +35,9 @@ class XThread : public XObject {
static uint32_t GetCurrentThreadHandle();
static uint32_t GetCurrentThreadId(const uint8_t* thread_state_block);
uint32_t thread_state();
uint32_t thread_id();
uint32_t thread_state_ptr() const { return thread_state_address_; }
cpu::ThreadState* thread_state() const { return thread_state_; }
uint32_t thread_id() const { return thread_id_; }
uint32_t last_error();
void set_last_error(uint32_t error_code);
const std::string& name() const { return name_; }

View File

@@ -34,7 +34,7 @@ const xe_xex2_header_t* XUserModule::xex_header() {
return xe_xex2_get_header(xex_);
}
X_STATUS XUserModule::LoadFromFile(const char* path) {
X_STATUS XUserModule::LoadFromFile(std::string path) {
X_STATUS result = X_STATUS_UNSUCCESSFUL;
XFile* file = NULL;
@@ -42,7 +42,7 @@ X_STATUS XUserModule::LoadFromFile(const char* path) {
// TODO(benvanik): make this code shared?
auto fs_entry = kernel_state()->file_system()->ResolvePath(path);
if (!fs_entry) {
XELOGE("File not found: %s", path);
XELOGE("File not found: %s", path.c_str());
return X_STATUS_NO_SUCH_FILE;
}

View File

@@ -10,9 +10,10 @@
#ifndef XENIA_KERNEL_XBOXKRNL_XUSER_MODULE_H_
#define XENIA_KERNEL_XBOXKRNL_XUSER_MODULE_H_
#include "xenia/kernel/objects/xmodule.h"
#include <string>
#include "xenia/cpu/export_resolver.h"
#include "xenia/kernel/objects/xmodule.h"
#include "xenia/kernel/util/xex2.h"
#include "xenia/xbox.h"
@@ -29,7 +30,7 @@ class XUserModule : public XModule {
uint32_t execution_info_ptr() const { return execution_info_ptr_; }
X_STATUS LoadFromFile(const char* path);
X_STATUS LoadFromFile(std::string path);
X_STATUS LoadFromMemory(const void* addr, const size_t length);
uint32_t GetProcAddressByOrdinal(uint16_t ordinal) override;