diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index fc054e6fc..6eedbf4a1 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -32,16 +32,19 @@ using namespace xe::kernel; using namespace xe::kernel::fs; using namespace xe::ui; - -Emulator::Emulator(const xechar_t* command_line) : - main_window_(0), - memory_(0), - processor_(0), - audio_system_(0), graphics_system_(0), input_system_(0), - export_resolver_(0), file_system_(0), - kernel_state_(0), xam_(0), xboxkrnl_(0) { - XEIGNORE(xestrcpy(command_line_, XECOUNT(command_line_), command_line)); -} +Emulator::Emulator(const std::wstring& command_line) + : command_line_(command_line), + main_window_(0), + memory_(0), + processor_(0), + audio_system_(0), + graphics_system_(0), + input_system_(0), + export_resolver_(0), + file_system_(0), + kernel_state_(0), + xam_(0), + xboxkrnl_(0) {} Emulator::~Emulator() { // Note that we delete things in the reverse order they were initialized. diff --git a/src/xenia/emulator.h b/src/xenia/emulator.h index 23d24bf37..0c05d3d0b 100644 --- a/src/xenia/emulator.h +++ b/src/xenia/emulator.h @@ -35,10 +35,10 @@ namespace xe { class Emulator { public: - Emulator(const xechar_t* command_line); + Emulator(const std::wstring& command_line); ~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_; } void set_main_window(ui::Window* window); @@ -69,7 +69,7 @@ class Emulator { X_STATUS CompleteLaunch(const std::wstring& path, const std::string& module_path); - xechar_t command_line_[poly::max_path]; + std::wstring command_line_; ui::Window* main_window_; diff --git a/src/xenia/gpu/d3d11/d3d11_geometry_shader.cc b/src/xenia/gpu/d3d11/d3d11_geometry_shader.cc index 071395b7e..0ab44c282 100644 --- a/src/xenia/gpu/d3d11/d3d11_geometry_shader.cc +++ b/src/xenia/gpu/d3d11/d3d11_geometry_shader.cc @@ -95,7 +95,7 @@ ID3D10Blob* D3D11GeometryShader::Compile(const char* shader_source) { if (FLAGS_dump_shaders.size()) { 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]; xesnprintfa(file_name, XECOUNT(file_name), "%s/gen_%.16llX.gs", diff --git a/src/xenia/gpu/d3d11/d3d11_profiler_display.cc b/src/xenia/gpu/d3d11/d3d11_profiler_display.cc index 8bcefd0e7..bf9774730 100644 --- a/src/xenia/gpu/d3d11/d3d11_profiler_display.cc +++ b/src/xenia/gpu/d3d11/d3d11_profiler_display.cc @@ -203,7 +203,7 @@ bool D3D11ProfilerDisplay::SetupShaders() { ID3DBlob* vs_code_blob = nullptr; ID3DBlob* vs_errors = nullptr; hr = D3DCompile( - shader_code, xestrlena(shader_code), + shader_code, strlen(shader_code), "D3D11ProfilerDisplay.vs", nullptr, nullptr, @@ -229,7 +229,7 @@ bool D3D11ProfilerDisplay::SetupShaders() { ID3DBlob* ps_code_blob = nullptr; ID3DBlob* ps_errors = nullptr; hr = D3DCompile( - shader_code, xestrlena(shader_code), + shader_code, strlen(shader_code), "D3D11ProfilerDisplay.ps", nullptr, nullptr, diff --git a/src/xenia/gpu/d3d11/d3d11_shader_resource.cc b/src/xenia/gpu/d3d11/d3d11_shader_resource.cc index 7fc40905f..f32e3f714 100644 --- a/src/xenia/gpu/d3d11/d3d11_shader_resource.cc +++ b/src/xenia/gpu/d3d11/d3d11_shader_resource.cc @@ -46,7 +46,7 @@ ID3D10Blob* D3D11ShaderCompile(XE_GPU_SHADER_TYPE type, if (FLAGS_dump_shaders.size()) { 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]; xesnprintfa(file_name, XECOUNT(file_name), "%s/gen_%.16llX.%s", diff --git a/src/xenia/kernel/fs/devices/disc_image_entry.cc b/src/xenia/kernel/fs/devices/disc_image_entry.cc index a11f98088..4bde7943f 100644 --- a/src/xenia/kernel/fs/devices/disc_image_entry.cc +++ b/src/xenia/kernel/fs/devices/disc_image_entry.cc @@ -87,10 +87,9 @@ X_STATUS DiscImageEntry::QueryDirectory( auto end = (uint8_t*)out_info + length; auto entry = *gdfx_entry_iterator_; - auto entry_name = entry->name.c_str(); - size_t entry_name_length = xestrlena(entry_name); + auto entry_name = 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(); return X_STATUS_UNSUCCESSFUL; } @@ -104,8 +103,8 @@ X_STATUS DiscImageEntry::QueryDirectory( out_info->end_of_file = entry->size; out_info->allocation_size = 2048; out_info->attributes = (X_FILE_ATTRIBUTES)entry->attributes; - out_info->file_name_length = (uint32_t)entry_name_length; - memcpy(out_info->file_name, entry_name, entry_name_length); + out_info->file_name_length = static_cast(entry_name.size()); + memcpy(out_info->file_name, entry_name.c_str(), entry_name.size()); return X_STATUS_SUCCESS; } diff --git a/src/xenia/kernel/fs/devices/stfs_container_entry.cc b/src/xenia/kernel/fs/devices/stfs_container_entry.cc index 318b11bf7..1af716c67 100644 --- a/src/xenia/kernel/fs/devices/stfs_container_entry.cc +++ b/src/xenia/kernel/fs/devices/stfs_container_entry.cc @@ -66,10 +66,9 @@ X_STATUS STFSContainerEntry::QueryDirectory( auto end = (uint8_t*)out_info + length; auto entry = *stfs_entry_iterator_; - auto entry_name = entry->name.c_str(); - size_t entry_name_length = xestrlena(entry_name); + auto entry_name = 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(); return X_STATUS_UNSUCCESSFUL; } @@ -82,8 +81,8 @@ X_STATUS STFSContainerEntry::QueryDirectory( out_info->end_of_file = entry->size; out_info->allocation_size = 4096; out_info->attributes = entry->attributes; - out_info->file_name_length = (uint32_t)entry_name_length; - memcpy(out_info->file_name, entry_name, entry_name_length); + out_info->file_name_length = static_cast(entry_name.size()); + memcpy(out_info->file_name, entry_name.c_str(), entry_name.size()); return X_STATUS_SUCCESS; } diff --git a/src/xenia/kernel/xboxkrnl_rtl.cc b/src/xenia/kernel/xboxkrnl_rtl.cc index b08b0bcf7..d2f67949a 100644 --- a/src/xenia/kernel/xboxkrnl_rtl.cc +++ b/src/xenia/kernel/xboxkrnl_rtl.cc @@ -153,7 +153,7 @@ SHIM_CALL RtlInitAnsiString_shim( if (source_ptr != 0) { 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 + 2, length + 1); } else { @@ -211,8 +211,10 @@ SHIM_CALL RtlInitUnicodeString_shim( // _In_opt_ PCWSTR SourceString 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_16(destination_ptr + 0, + static_cast(source.size() * 2)); + SHIM_SET_MEM_16(destination_ptr + 2, + static_cast((source.size() + 1) * 2)); SHIM_SET_MEM_32(destination_ptr + 4, source_ptr); } else { SHIM_SET_MEM_16(destination_ptr + 0, 0); diff --git a/src/xenia/string.h b/src/xenia/string.h index 076fded47..2a166ad78 100644 --- a/src/xenia/string.h +++ b/src/xenia/string.h @@ -18,16 +18,12 @@ #if !XE_LIKE_WIN32 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 strcat_s(dest, destLength, source) !(strcat(dest, source) == dest + (destLength*0)) #define _snprintf_s(dest, destLength, x, format, ...) snprintf(dest, destLength, format, ##__VA_ARGS__) #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 xestrlena strlen #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 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; // xestrcpy fs + module -// xestrncpya one use in xbox.h // xesnprintf many uses - only remove some? -#define xestrcpy xestrcpyw #define xesnprintf xesnprintfw #else typedef char xechar_t; -#define XE_CHAR 1 -#define xestrcpy xestrcpya #define xesnprintf xesnprintfa #endif // WIN32 diff --git a/src/xenia/xbox.h b/src/xenia/xbox.h index b3ca8dd24..8bb0c600c 100644 --- a/src/xenia/xbox.h +++ b/src/xenia/xbox.h @@ -272,8 +272,8 @@ public: if (buffer == NULL || length == 0) { return NULL; } - auto copy = (char*)xe_calloc(length+1); - xestrncpya(copy, length+1, buffer, length); + auto copy = (char*)xe_calloc(length + 1); + std::strncpy(copy, buffer, length); return copy; } };