More string switching.
This commit is contained in:
parent
7c5fa88661
commit
ead74f2cdb
|
@ -32,16 +32,19 @@ using namespace xe::kernel;
|
||||||
using namespace xe::kernel::fs;
|
using namespace xe::kernel::fs;
|
||||||
using namespace xe::ui;
|
using namespace xe::ui;
|
||||||
|
|
||||||
|
Emulator::Emulator(const std::wstring& command_line)
|
||||||
Emulator::Emulator(const xechar_t* command_line) :
|
: command_line_(command_line),
|
||||||
main_window_(0),
|
main_window_(0),
|
||||||
memory_(0),
|
memory_(0),
|
||||||
processor_(0),
|
processor_(0),
|
||||||
audio_system_(0), graphics_system_(0), input_system_(0),
|
audio_system_(0),
|
||||||
export_resolver_(0), file_system_(0),
|
graphics_system_(0),
|
||||||
kernel_state_(0), xam_(0), xboxkrnl_(0) {
|
input_system_(0),
|
||||||
XEIGNORE(xestrcpy(command_line_, XECOUNT(command_line_), command_line));
|
export_resolver_(0),
|
||||||
}
|
file_system_(0),
|
||||||
|
kernel_state_(0),
|
||||||
|
xam_(0),
|
||||||
|
xboxkrnl_(0) {}
|
||||||
|
|
||||||
Emulator::~Emulator() {
|
Emulator::~Emulator() {
|
||||||
// Note that we delete things in the reverse order they were initialized.
|
// Note that we delete things in the reverse order they were initialized.
|
||||||
|
|
|
@ -35,10 +35,10 @@ namespace xe {
|
||||||
|
|
||||||
class Emulator {
|
class Emulator {
|
||||||
public:
|
public:
|
||||||
Emulator(const xechar_t* command_line);
|
Emulator(const std::wstring& command_line);
|
||||||
~Emulator();
|
~Emulator();
|
||||||
|
|
||||||
const xechar_t* command_line() const { return command_line_; }
|
const std::wstring& command_line() const { return command_line_; }
|
||||||
|
|
||||||
ui::Window* main_window() const { return main_window_; }
|
ui::Window* main_window() const { return main_window_; }
|
||||||
void set_main_window(ui::Window* window);
|
void set_main_window(ui::Window* window);
|
||||||
|
@ -69,7 +69,7 @@ class Emulator {
|
||||||
X_STATUS CompleteLaunch(const std::wstring& path,
|
X_STATUS CompleteLaunch(const std::wstring& path,
|
||||||
const std::string& module_path);
|
const std::string& module_path);
|
||||||
|
|
||||||
xechar_t command_line_[poly::max_path];
|
std::wstring command_line_;
|
||||||
|
|
||||||
ui::Window* main_window_;
|
ui::Window* main_window_;
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ ID3D10Blob* D3D11GeometryShader::Compile(const char* shader_source) {
|
||||||
if (FLAGS_dump_shaders.size()) {
|
if (FLAGS_dump_shaders.size()) {
|
||||||
base_path = FLAGS_dump_shaders.c_str();
|
base_path = FLAGS_dump_shaders.c_str();
|
||||||
}
|
}
|
||||||
uint64_t hash = xe_hash64(shader_source, xestrlena(shader_source)); // ?
|
uint64_t hash = xe_hash64(shader_source, strlen(shader_source)); // ?
|
||||||
char file_name[poly::max_path];
|
char file_name[poly::max_path];
|
||||||
xesnprintfa(file_name, XECOUNT(file_name),
|
xesnprintfa(file_name, XECOUNT(file_name),
|
||||||
"%s/gen_%.16llX.gs",
|
"%s/gen_%.16llX.gs",
|
||||||
|
|
|
@ -203,7 +203,7 @@ bool D3D11ProfilerDisplay::SetupShaders() {
|
||||||
ID3DBlob* vs_code_blob = nullptr;
|
ID3DBlob* vs_code_blob = nullptr;
|
||||||
ID3DBlob* vs_errors = nullptr;
|
ID3DBlob* vs_errors = nullptr;
|
||||||
hr = D3DCompile(
|
hr = D3DCompile(
|
||||||
shader_code, xestrlena(shader_code),
|
shader_code, strlen(shader_code),
|
||||||
"D3D11ProfilerDisplay.vs",
|
"D3D11ProfilerDisplay.vs",
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
@ -229,7 +229,7 @@ bool D3D11ProfilerDisplay::SetupShaders() {
|
||||||
ID3DBlob* ps_code_blob = nullptr;
|
ID3DBlob* ps_code_blob = nullptr;
|
||||||
ID3DBlob* ps_errors = nullptr;
|
ID3DBlob* ps_errors = nullptr;
|
||||||
hr = D3DCompile(
|
hr = D3DCompile(
|
||||||
shader_code, xestrlena(shader_code),
|
shader_code, strlen(shader_code),
|
||||||
"D3D11ProfilerDisplay.ps",
|
"D3D11ProfilerDisplay.ps",
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
|
|
@ -46,7 +46,7 @@ ID3D10Blob* D3D11ShaderCompile(XE_GPU_SHADER_TYPE type,
|
||||||
if (FLAGS_dump_shaders.size()) {
|
if (FLAGS_dump_shaders.size()) {
|
||||||
base_path = FLAGS_dump_shaders.c_str();
|
base_path = FLAGS_dump_shaders.c_str();
|
||||||
}
|
}
|
||||||
size_t hash = xe_hash64(disasm_source, xestrlena(disasm_source)); // ?
|
size_t hash = xe_hash64(disasm_source, strlen(disasm_source)); // ?
|
||||||
char file_name[poly::max_path];
|
char file_name[poly::max_path];
|
||||||
xesnprintfa(file_name, XECOUNT(file_name),
|
xesnprintfa(file_name, XECOUNT(file_name),
|
||||||
"%s/gen_%.16llX.%s",
|
"%s/gen_%.16llX.%s",
|
||||||
|
|
|
@ -87,10 +87,9 @@ X_STATUS DiscImageEntry::QueryDirectory(
|
||||||
auto end = (uint8_t*)out_info + length;
|
auto end = (uint8_t*)out_info + length;
|
||||||
|
|
||||||
auto entry = *gdfx_entry_iterator_;
|
auto entry = *gdfx_entry_iterator_;
|
||||||
auto entry_name = entry->name.c_str();
|
auto entry_name = entry->name;
|
||||||
size_t entry_name_length = xestrlena(entry_name);
|
|
||||||
|
|
||||||
if (((uint8_t*)&out_info->file_name[0]) + entry_name_length > end) {
|
if (((uint8_t*)&out_info->file_name[0]) + entry_name.size() > end) {
|
||||||
gdfx_entry_iterator_ = gdfx_entry_->children.end();
|
gdfx_entry_iterator_ = gdfx_entry_->children.end();
|
||||||
return X_STATUS_UNSUCCESSFUL;
|
return X_STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
@ -104,8 +103,8 @@ X_STATUS DiscImageEntry::QueryDirectory(
|
||||||
out_info->end_of_file = entry->size;
|
out_info->end_of_file = entry->size;
|
||||||
out_info->allocation_size = 2048;
|
out_info->allocation_size = 2048;
|
||||||
out_info->attributes = (X_FILE_ATTRIBUTES)entry->attributes;
|
out_info->attributes = (X_FILE_ATTRIBUTES)entry->attributes;
|
||||||
out_info->file_name_length = (uint32_t)entry_name_length;
|
out_info->file_name_length = static_cast<uint32_t>(entry_name.size());
|
||||||
memcpy(out_info->file_name, entry_name, entry_name_length);
|
memcpy(out_info->file_name, entry_name.c_str(), entry_name.size());
|
||||||
|
|
||||||
return X_STATUS_SUCCESS;
|
return X_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,9 @@ X_STATUS STFSContainerEntry::QueryDirectory(
|
||||||
auto end = (uint8_t*)out_info + length;
|
auto end = (uint8_t*)out_info + length;
|
||||||
|
|
||||||
auto entry = *stfs_entry_iterator_;
|
auto entry = *stfs_entry_iterator_;
|
||||||
auto entry_name = entry->name.c_str();
|
auto entry_name = entry->name;
|
||||||
size_t entry_name_length = xestrlena(entry_name);
|
|
||||||
|
|
||||||
if (((uint8_t*)&out_info->file_name[0]) + entry_name_length > end) {
|
if (((uint8_t*)&out_info->file_name[0]) + entry_name.size() > end) {
|
||||||
stfs_entry_iterator_ = stfs_entry_->children.end();
|
stfs_entry_iterator_ = stfs_entry_->children.end();
|
||||||
return X_STATUS_UNSUCCESSFUL;
|
return X_STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
@ -82,8 +81,8 @@ X_STATUS STFSContainerEntry::QueryDirectory(
|
||||||
out_info->end_of_file = entry->size;
|
out_info->end_of_file = entry->size;
|
||||||
out_info->allocation_size = 4096;
|
out_info->allocation_size = 4096;
|
||||||
out_info->attributes = entry->attributes;
|
out_info->attributes = entry->attributes;
|
||||||
out_info->file_name_length = (uint32_t)entry_name_length;
|
out_info->file_name_length = static_cast<uint32_t>(entry_name.size());
|
||||||
memcpy(out_info->file_name, entry_name, entry_name_length);
|
memcpy(out_info->file_name, entry_name.c_str(), entry_name.size());
|
||||||
|
|
||||||
return X_STATUS_SUCCESS;
|
return X_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ SHIM_CALL RtlInitAnsiString_shim(
|
||||||
|
|
||||||
if (source_ptr != 0) {
|
if (source_ptr != 0) {
|
||||||
const char* source = (char*)SHIM_MEM_ADDR(source_ptr);
|
const char* source = (char*)SHIM_MEM_ADDR(source_ptr);
|
||||||
uint16_t length = (uint16_t)xestrlena(source);
|
uint16_t length = (uint16_t)strlen(source);
|
||||||
SHIM_SET_MEM_16(destination_ptr + 0, length);
|
SHIM_SET_MEM_16(destination_ptr + 0, length);
|
||||||
SHIM_SET_MEM_16(destination_ptr + 2, length + 1);
|
SHIM_SET_MEM_16(destination_ptr + 2, length + 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -211,8 +211,10 @@ SHIM_CALL RtlInitUnicodeString_shim(
|
||||||
// _In_opt_ PCWSTR SourceString
|
// _In_opt_ PCWSTR SourceString
|
||||||
|
|
||||||
if (source.size()) {
|
if (source.size()) {
|
||||||
SHIM_SET_MEM_16(destination_ptr + 0, source.size() * 2);
|
SHIM_SET_MEM_16(destination_ptr + 0,
|
||||||
SHIM_SET_MEM_16(destination_ptr + 2, (source.size() + 1) * 2);
|
static_cast<uint16_t>(source.size() * 2));
|
||||||
|
SHIM_SET_MEM_16(destination_ptr + 2,
|
||||||
|
static_cast<uint16_t>((source.size() + 1) * 2));
|
||||||
SHIM_SET_MEM_32(destination_ptr + 4, source_ptr);
|
SHIM_SET_MEM_32(destination_ptr + 4, source_ptr);
|
||||||
} else {
|
} else {
|
||||||
SHIM_SET_MEM_16(destination_ptr + 0, 0);
|
SHIM_SET_MEM_16(destination_ptr + 0, 0);
|
||||||
|
|
|
@ -18,16 +18,12 @@
|
||||||
#if !XE_LIKE_WIN32
|
#if !XE_LIKE_WIN32
|
||||||
int strncpy_s(char* dest, size_t destLength, const char* source, size_t count);
|
int strncpy_s(char* dest, size_t destLength, const char* source, size_t count);
|
||||||
#define strcpy_s(dest, destLength, source) !(strcpy(dest, source) == dest + (destLength*0))
|
#define strcpy_s(dest, destLength, source) !(strcpy(dest, source) == dest + (destLength*0))
|
||||||
#define strcat_s(dest, destLength, source) !(strcat(dest, source) == dest + (destLength*0))
|
|
||||||
#define _snprintf_s(dest, destLength, x, format, ...) snprintf(dest, destLength, format, ##__VA_ARGS__)
|
#define _snprintf_s(dest, destLength, x, format, ...) snprintf(dest, destLength, format, ##__VA_ARGS__)
|
||||||
#endif // !WIN32
|
#endif // !WIN32
|
||||||
|
|
||||||
#define xestrcpyw(dest, destLength, source) (wcscpy_s(dest, destLength, source) == 0)
|
|
||||||
#define xesnprintfw(buffer, bufferCount, format, ...) _snwprintf_s(buffer, bufferCount, (bufferCount) ? (bufferCount - 1) : 0, format, ##__VA_ARGS__)
|
#define xesnprintfw(buffer, bufferCount, format, ...) _snwprintf_s(buffer, bufferCount, (bufferCount) ? (bufferCount - 1) : 0, format, ##__VA_ARGS__)
|
||||||
|
|
||||||
#define xestrlena strlen
|
|
||||||
#define xestrcpya(dest, destLength, source) (strcpy_s(dest, destLength, source) == 0)
|
#define xestrcpya(dest, destLength, source) (strcpy_s(dest, destLength, source) == 0)
|
||||||
#define xestrncpya(dest, destLength, source, count) (strncpy_s(dest, destLength, source, count) == 0)
|
|
||||||
#define xesnprintfa(buffer, bufferCount, format, ...) _snprintf_s(buffer, bufferCount, bufferCount, format, ##__VA_ARGS__)
|
#define xesnprintfa(buffer, bufferCount, format, ...) _snprintf_s(buffer, bufferCount, bufferCount, format, ##__VA_ARGS__)
|
||||||
#define xevsnprintfa(buffer, bufferCount, format, args) vsnprintf(buffer, bufferCount, format, args)
|
#define xevsnprintfa(buffer, bufferCount, format, args) vsnprintf(buffer, bufferCount, format, args)
|
||||||
|
|
||||||
|
@ -36,18 +32,14 @@ int strncpy_s(char* dest, size_t destLength, const char* source, size_t count);
|
||||||
typedef wchar_t xechar_t;
|
typedef wchar_t xechar_t;
|
||||||
|
|
||||||
// xestrcpy fs + module
|
// xestrcpy fs + module
|
||||||
// xestrncpya one use in xbox.h
|
|
||||||
// xesnprintf many uses - only remove some?
|
// xesnprintf many uses - only remove some?
|
||||||
|
|
||||||
#define xestrcpy xestrcpyw
|
|
||||||
#define xesnprintf xesnprintfw
|
#define xesnprintf xesnprintfw
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
typedef char xechar_t;
|
typedef char xechar_t;
|
||||||
#define XE_CHAR 1
|
|
||||||
|
|
||||||
#define xestrcpy xestrcpya
|
|
||||||
#define xesnprintf xesnprintfa
|
#define xesnprintf xesnprintfa
|
||||||
|
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
|
@ -272,8 +272,8 @@ public:
|
||||||
if (buffer == NULL || length == 0) {
|
if (buffer == NULL || length == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
auto copy = (char*)xe_calloc(length+1);
|
auto copy = (char*)xe_calloc(length + 1);
|
||||||
xestrncpya(copy, length+1, buffer, length);
|
std::strncpy(copy, buffer, length);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue