More string swapping and cleaning up main().
This commit is contained in:
@@ -59,7 +59,7 @@ Entry* DiscImageDevice::ResolvePath(const char* path) {
|
||||
char remaining[poly::max_path];
|
||||
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), path));
|
||||
while (remaining[0]) {
|
||||
char* next_slash = xestrchra(remaining, '\\');
|
||||
char* next_slash = strchr(remaining, '\\');
|
||||
if (next_slash == remaining) {
|
||||
// Leading slash - shift
|
||||
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), remaining + 1));
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <xenia/kernel/fs/devices/host_path_device.h>
|
||||
|
||||
#include <xenia/core/path.h>
|
||||
#include <xenia/kernel/fs/devices/host_path_entry.h>
|
||||
#include <xenia/kernel/objects/xfile.h>
|
||||
|
||||
@@ -30,27 +29,9 @@ Entry* HostPathDevice::ResolvePath(const char* path) {
|
||||
|
||||
XELOGFS("HostPathDevice::ResolvePath(%s)", path);
|
||||
|
||||
#if XE_WCHAR
|
||||
xechar_t rel_path[poly::max_path];
|
||||
XEIGNORE(xestrwiden(rel_path, XECOUNT(rel_path), path));
|
||||
#else
|
||||
const xechar_t* rel_path = path;
|
||||
#endif
|
||||
|
||||
xechar_t full_path[poly::max_path];
|
||||
xe_path_join(local_path_.c_str(), rel_path, full_path, XECOUNT(full_path));
|
||||
|
||||
// Swap around path separators.
|
||||
if (poly::path_separator != '\\') {
|
||||
for (size_t n = 0; n < XECOUNT(full_path); n++) {
|
||||
if (full_path[n] == 0) {
|
||||
break;
|
||||
}
|
||||
if (full_path[n] == '\\') {
|
||||
full_path[n] = poly::path_separator;
|
||||
}
|
||||
}
|
||||
}
|
||||
auto rel_path = poly::to_wstring(path);
|
||||
auto full_path = poly::join_paths(local_path_, rel_path);
|
||||
full_path = poly::fix_path_separators(full_path);
|
||||
|
||||
// TODO(benvanik): get file info
|
||||
// TODO(benvanik): fail if does not exit
|
||||
|
||||
@@ -59,7 +59,7 @@ Entry* STFSContainerDevice::ResolvePath(const char* path) {
|
||||
char remaining[poly::max_path];
|
||||
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), path));
|
||||
while (remaining[0]) {
|
||||
char* next_slash = xestrchra(remaining, '\\');
|
||||
char* next_slash = strchr(remaining, '\\');
|
||||
if (next_slash == remaining) {
|
||||
// Leading slash - shift
|
||||
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), remaining + 1));
|
||||
|
||||
@@ -17,19 +17,20 @@ using namespace xe::cpu;
|
||||
using namespace xe::kernel;
|
||||
|
||||
|
||||
XModule::XModule(KernelState* kernel_state, const char* path) :
|
||||
XObject(kernel_state, kTypeModule) {
|
||||
XEIGNORE(xestrcpya(path_, XECOUNT(path_), path));
|
||||
const char* slash = xestrrchra(path, '/');
|
||||
if (!slash) {
|
||||
slash = xestrrchra(path, '\\');
|
||||
XModule::XModule(KernelState* kernel_state, const std::string& path) :
|
||||
XObject(kernel_state, kTypeModule), path_(path) {
|
||||
auto last_slash = path.find_last_of('/');
|
||||
if (last_slash == path.npos) {
|
||||
last_slash = path.find_last_of('\\');
|
||||
}
|
||||
if (slash) {
|
||||
XEIGNORE(xestrcpya(name_, XECOUNT(name_), slash + 1));
|
||||
if (last_slash == path.npos) {
|
||||
name_ = path_;
|
||||
} else {
|
||||
name_ = path_.substr(last_slash + 1);
|
||||
}
|
||||
char* dot = xestrrchra(name_, '.');
|
||||
if (dot) {
|
||||
*dot = 0;
|
||||
auto dot = name_.find_last_of('.');
|
||||
if (dot != name_.npos) {
|
||||
name_ = name_.substr(0, dot);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_XMODULE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_XMODULE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <xenia/kernel/xobject.h>
|
||||
|
||||
#include <xenia/xbox.h>
|
||||
@@ -21,11 +23,11 @@ namespace kernel {
|
||||
|
||||
class XModule : public XObject {
|
||||
public:
|
||||
XModule(KernelState* kernel_state, const char* path);
|
||||
XModule(KernelState* kernel_state, const std::string& path);
|
||||
virtual ~XModule();
|
||||
|
||||
const char* path() const { return path_; }
|
||||
const char* name() const { return name_; }
|
||||
const std::string& path() const { return path_; }
|
||||
const std::string& name() const { return name_; }
|
||||
|
||||
virtual void* GetProcAddressByOrdinal(uint16_t ordinal) = 0;
|
||||
virtual X_STATUS GetSection(
|
||||
@@ -35,8 +37,8 @@ public:
|
||||
protected:
|
||||
void OnLoad();
|
||||
|
||||
char name_[256];
|
||||
char path_[poly::max_path];
|
||||
std::string name_;
|
||||
std::string path_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -200,19 +200,19 @@ SHIM_CALL RtlInitUnicodeString_shim(
|
||||
uint32_t destination_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t source_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
const wchar_t* source =
|
||||
source_ptr ? (const wchar_t*)SHIM_MEM_ADDR(source_ptr) : NULL;
|
||||
XELOGD("RtlInitUnicodeString(%.8X, %.8X = %ls)",
|
||||
destination_ptr, source_ptr, source ? source : L"<null>");
|
||||
auto source =
|
||||
source_ptr ? poly::load_and_swap<std::wstring>(SHIM_MEM_ADDR(source_ptr))
|
||||
: L"";
|
||||
XELOGD("RtlInitUnicodeString(%.8X, %.8X = %ls)", destination_ptr, source_ptr,
|
||||
source.empty() ? L"<null>" : source.c_str());
|
||||
|
||||
// VOID
|
||||
// _Out_ PUNICODE_STRING DestinationString,
|
||||
// _In_opt_ PCWSTR SourceString
|
||||
|
||||
if (source) {
|
||||
uint16_t length = (uint16_t)xestrlenw(source);
|
||||
SHIM_SET_MEM_16(destination_ptr + 0, length * 2);
|
||||
SHIM_SET_MEM_16(destination_ptr + 2, (length + 1) * 2);
|
||||
if (source.size()) {
|
||||
SHIM_SET_MEM_16(destination_ptr + 0, source.size() * 2);
|
||||
SHIM_SET_MEM_16(destination_ptr + 2, (source.size() + 1) * 2);
|
||||
SHIM_SET_MEM_32(destination_ptr + 4, source_ptr);
|
||||
} else {
|
||||
SHIM_SET_MEM_16(destination_ptr + 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user