clang-format on most of kernel/
This commit is contained in:
@@ -17,15 +17,11 @@
|
||||
#include <xenia/kernel/util/shim_utils.h>
|
||||
#include <xenia/kernel/util/xex2.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
|
||||
// TODO: clean me up!
|
||||
SHIM_CALL vsprintf_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
|
||||
SHIM_CALL vsprintf_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t arg_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -63,10 +59,7 @@ SHIM_CALL vsprintf_shim(
|
||||
end = format;
|
||||
|
||||
// skip flags
|
||||
while (*end == '-' ||
|
||||
*end == '+' ||
|
||||
*end == ' ' ||
|
||||
*end == '#' ||
|
||||
while (*end == '-' || *end == '+' || *end == ' ' || *end == '#' ||
|
||||
*end == '0') {
|
||||
++end;
|
||||
}
|
||||
@@ -81,8 +74,7 @@ SHIM_CALL vsprintf_shim(
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
arg_extras++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
@@ -99,8 +91,7 @@ SHIM_CALL vsprintf_shim(
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
++arg_extras;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
@@ -120,28 +111,23 @@ SHIM_CALL vsprintf_shim(
|
||||
if (*end == 'h') {
|
||||
++end;
|
||||
}
|
||||
}
|
||||
else if (*end == 'l') {
|
||||
} else if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 4;
|
||||
if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 8;
|
||||
}
|
||||
}
|
||||
else if (*end == 'j') {
|
||||
} else if (*end == 'j') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'z') {
|
||||
} else if (*end == 'z') {
|
||||
arg_size = 4;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 't') {
|
||||
} else if (*end == 't') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'L') {
|
||||
} else if (*end == 'L') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
@@ -150,21 +136,10 @@ SHIM_CALL vsprintf_shim(
|
||||
break;
|
||||
}
|
||||
|
||||
if (*end == 'd' ||
|
||||
*end == 'i' ||
|
||||
*end == 'u' ||
|
||||
*end == 'o' ||
|
||||
*end == 'x' ||
|
||||
*end == 'X' ||
|
||||
*end == 'f' ||
|
||||
*end == 'F' ||
|
||||
*end == 'e' ||
|
||||
*end == 'E' ||
|
||||
*end == 'g' ||
|
||||
*end == 'G' ||
|
||||
*end == 'a' ||
|
||||
*end == 'A' ||
|
||||
*end == 'c') {
|
||||
if (*end == 'd' || *end == 'i' || *end == 'u' || *end == 'o' ||
|
||||
*end == 'x' || *end == 'X' || *end == 'f' || *end == 'F' ||
|
||||
*end == 'e' || *end == 'E' || *end == 'g' || *end == 'G' ||
|
||||
*end == 'a' || *end == 'A' || *end == 'c') {
|
||||
char local[512];
|
||||
local[0] = '\0';
|
||||
strncat(local, start, end + 1 - start);
|
||||
@@ -172,58 +147,52 @@ SHIM_CALL vsprintf_shim(
|
||||
assert_true(arg_size == 8 || arg_size == 4);
|
||||
if (arg_size == 8) {
|
||||
if (arg_extras == 0) {
|
||||
uint64_t value = SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint64_t value = SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
int result = sprintf(b, local, value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else if (arg_size == 4) {
|
||||
} else if (arg_size == 4) {
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
int result = sprintf(b, local, value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*end == 'n')
|
||||
{
|
||||
} else if (*end == 'n') {
|
||||
assert_true(arg_size == 4);
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
SHIM_SET_MEM_32(value, (uint32_t)((b - buffer) / sizeof(char)));
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
SHIM_SET_MEM_32(value, (uint32_t)((b - buffer) / sizeof(char)));
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else if (*end == 's' ||
|
||||
*end == 'p') {
|
||||
} else if (*end == 's' || *end == 'p') {
|
||||
char local[512];
|
||||
local[0] = '\0';
|
||||
strncat(local, start, end + 1 - start);
|
||||
|
||||
assert_true(arg_size == 4);
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
const void* pointer = (const void*)SHIM_MEM_ADDR(value);
|
||||
int result = sprintf(b, local, pointer);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
break;
|
||||
}
|
||||
@@ -233,11 +202,8 @@ SHIM_CALL vsprintf_shim(
|
||||
SHIM_SET_RETURN_32((uint32_t)(b - buffer));
|
||||
}
|
||||
|
||||
|
||||
// TODO: clean me up!
|
||||
SHIM_CALL _vsnprintf_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
|
||||
SHIM_CALL _vsnprintf_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t count = SHIM_GET_ARG_32(1);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -248,7 +214,9 @@ SHIM_CALL _vsnprintf_shim(
|
||||
return;
|
||||
}
|
||||
|
||||
char* buffer = (char*)SHIM_MEM_ADDR(buffer_ptr); // TODO: ensure it never writes past the end of the buffer (count)...
|
||||
char* buffer = (char*)SHIM_MEM_ADDR(buffer_ptr); // TODO: ensure it never
|
||||
// writes past the end of
|
||||
// the buffer (count)...
|
||||
const char* format = (const char*)SHIM_MEM_ADDR(format_ptr);
|
||||
|
||||
int arg_index = 0;
|
||||
@@ -276,10 +244,7 @@ SHIM_CALL _vsnprintf_shim(
|
||||
end = format;
|
||||
|
||||
// skip flags
|
||||
while (*end == '-' ||
|
||||
*end == '+' ||
|
||||
*end == ' ' ||
|
||||
*end == '#' ||
|
||||
while (*end == '-' || *end == '+' || *end == ' ' || *end == '#' ||
|
||||
*end == '0') {
|
||||
++end;
|
||||
}
|
||||
@@ -294,8 +259,7 @@ SHIM_CALL _vsnprintf_shim(
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
arg_extras++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
@@ -312,8 +276,7 @@ SHIM_CALL _vsnprintf_shim(
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
++arg_extras;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
@@ -333,28 +296,23 @@ SHIM_CALL _vsnprintf_shim(
|
||||
if (*end == 'h') {
|
||||
++end;
|
||||
}
|
||||
}
|
||||
else if (*end == 'l') {
|
||||
} else if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 4;
|
||||
if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 8;
|
||||
}
|
||||
}
|
||||
else if (*end == 'j') {
|
||||
} else if (*end == 'j') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'z') {
|
||||
} else if (*end == 'z') {
|
||||
arg_size = 4;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 't') {
|
||||
} else if (*end == 't') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'L') {
|
||||
} else if (*end == 'L') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
@@ -363,21 +321,10 @@ SHIM_CALL _vsnprintf_shim(
|
||||
break;
|
||||
}
|
||||
|
||||
if (*end == 'd' ||
|
||||
*end == 'i' ||
|
||||
*end == 'u' ||
|
||||
*end == 'o' ||
|
||||
*end == 'x' ||
|
||||
*end == 'X' ||
|
||||
*end == 'f' ||
|
||||
*end == 'F' ||
|
||||
*end == 'e' ||
|
||||
*end == 'E' ||
|
||||
*end == 'g' ||
|
||||
*end == 'G' ||
|
||||
*end == 'a' ||
|
||||
*end == 'A' ||
|
||||
*end == 'c') {
|
||||
if (*end == 'd' || *end == 'i' || *end == 'u' || *end == 'o' ||
|
||||
*end == 'x' || *end == 'X' || *end == 'f' || *end == 'F' ||
|
||||
*end == 'e' || *end == 'E' || *end == 'g' || *end == 'G' ||
|
||||
*end == 'a' || *end == 'A' || *end == 'c') {
|
||||
char local[512];
|
||||
local[0] = '\0';
|
||||
strncat(local, start, end + 1 - start);
|
||||
@@ -385,58 +332,52 @@ SHIM_CALL _vsnprintf_shim(
|
||||
assert_true(arg_size == 8 || arg_size == 4);
|
||||
if (arg_size == 8) {
|
||||
if (arg_extras == 0) {
|
||||
uint64_t value = SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint64_t value = SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
int result = sprintf(b, local, value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else if (arg_size == 4) {
|
||||
} else if (arg_size == 4) {
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
int result = sprintf(b, local, value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*end == 'n')
|
||||
{
|
||||
} else if (*end == 'n') {
|
||||
assert_true(arg_size == 4);
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
SHIM_SET_MEM_32(value, (uint32_t)((b - buffer) / sizeof(char)));
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
SHIM_SET_MEM_32(value, (uint32_t)((b - buffer) / sizeof(char)));
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else if (*end == 's' ||
|
||||
*end == 'p') {
|
||||
} else if (*end == 's' || *end == 'p') {
|
||||
char local[512];
|
||||
local[0] = '\0';
|
||||
strncat(local, start, end + 1 - start);
|
||||
|
||||
assert_true(arg_size == 4);
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
const void* pointer = (const void*)SHIM_MEM_ADDR(value);
|
||||
int result = sprintf(b, local, pointer);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
break;
|
||||
}
|
||||
@@ -446,11 +387,8 @@ SHIM_CALL _vsnprintf_shim(
|
||||
SHIM_SET_RETURN_32((uint32_t)(b - buffer));
|
||||
}
|
||||
|
||||
|
||||
// TODO: clean me up!
|
||||
SHIM_CALL _vswprintf_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
|
||||
SHIM_CALL _vswprintf_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t arg_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -460,14 +398,17 @@ SHIM_CALL _vswprintf_shim(
|
||||
return;
|
||||
}
|
||||
|
||||
wchar_t*buffer = (wchar_t*)SHIM_MEM_ADDR(buffer_ptr); // TODO: ensure it never writes past the end of the buffer (count)...
|
||||
wchar_t* buffer =
|
||||
(wchar_t*)SHIM_MEM_ADDR(buffer_ptr); // TODO: ensure it never writes past
|
||||
// the end of the buffer (count)...
|
||||
const wchar_t* format = (const wchar_t*)SHIM_MEM_ADDR(format_ptr);
|
||||
|
||||
// this will work since a null is the same regardless of endianness
|
||||
size_t format_length = wcslen(format);
|
||||
|
||||
// swap the format buffer
|
||||
wchar_t* swapped_format = (wchar_t*)xe_malloc((format_length + 1) * sizeof(wchar_t));
|
||||
wchar_t* swapped_format =
|
||||
(wchar_t*)xe_malloc((format_length + 1) * sizeof(wchar_t));
|
||||
for (size_t i = 0; i < format_length; ++i) {
|
||||
swapped_format[i] = poly::byte_swap(format[i]);
|
||||
}
|
||||
@@ -480,7 +421,7 @@ SHIM_CALL _vswprintf_shim(
|
||||
|
||||
wchar_t* b = buffer;
|
||||
for (; *format != '\0'; ++format) {
|
||||
const wchar_t *start = format;
|
||||
const wchar_t* start = format;
|
||||
|
||||
if (*format != '%') {
|
||||
*b++ = *format;
|
||||
@@ -501,10 +442,7 @@ SHIM_CALL _vswprintf_shim(
|
||||
end = format;
|
||||
|
||||
// skip flags
|
||||
while (*end == '-' ||
|
||||
*end == '+' ||
|
||||
*end == ' ' ||
|
||||
*end == '#' ||
|
||||
while (*end == '-' || *end == '+' || *end == ' ' || *end == '#' ||
|
||||
*end == '0') {
|
||||
++end;
|
||||
}
|
||||
@@ -519,8 +457,7 @@ SHIM_CALL _vswprintf_shim(
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
arg_extras++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
@@ -537,8 +474,7 @@ SHIM_CALL _vswprintf_shim(
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
++arg_extras;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
@@ -558,28 +494,23 @@ SHIM_CALL _vswprintf_shim(
|
||||
if (*end == 'h') {
|
||||
++end;
|
||||
}
|
||||
}
|
||||
else if (*end == 'l') {
|
||||
} else if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 4;
|
||||
if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 8;
|
||||
}
|
||||
}
|
||||
else if (*end == 'j') {
|
||||
} else if (*end == 'j') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'z') {
|
||||
} else if (*end == 'z') {
|
||||
arg_size = 4;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 't') {
|
||||
} else if (*end == 't') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'L') {
|
||||
} else if (*end == 'L') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
@@ -588,21 +519,10 @@ SHIM_CALL _vswprintf_shim(
|
||||
break;
|
||||
}
|
||||
|
||||
if (*end == 'd' ||
|
||||
*end == 'i' ||
|
||||
*end == 'u' ||
|
||||
*end == 'o' ||
|
||||
*end == 'x' ||
|
||||
*end == 'X' ||
|
||||
*end == 'f' ||
|
||||
*end == 'F' ||
|
||||
*end == 'e' ||
|
||||
*end == 'E' ||
|
||||
*end == 'g' ||
|
||||
*end == 'G' ||
|
||||
*end == 'a' ||
|
||||
*end == 'A' ||
|
||||
*end == 'c') {
|
||||
if (*end == 'd' || *end == 'i' || *end == 'u' || *end == 'o' ||
|
||||
*end == 'x' || *end == 'X' || *end == 'f' || *end == 'F' ||
|
||||
*end == 'e' || *end == 'E' || *end == 'g' || *end == 'G' ||
|
||||
*end == 'a' || *end == 'A' || *end == 'c') {
|
||||
wchar_t local[512];
|
||||
local[0] = '\0';
|
||||
wcsncat(local, start, end + 1 - start);
|
||||
@@ -610,67 +530,64 @@ SHIM_CALL _vswprintf_shim(
|
||||
assert_true(arg_size == 8 || arg_size == 4);
|
||||
if (arg_size == 8) {
|
||||
if (arg_extras == 0) {
|
||||
uint64_t value = SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint64_t value = SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
int result = wsprintf(b, local, value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else if (arg_size == 4) {
|
||||
} else if (arg_size == 4) {
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
int result = wsprintf(b, local, value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*end == 'n')
|
||||
{
|
||||
} else if (*end == 'n') {
|
||||
assert_true(arg_size == 4);
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
SHIM_SET_MEM_32(value, (uint32_t)((b - buffer) / sizeof(wchar_t)));
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
SHIM_SET_MEM_32(value, (uint32_t)((b - buffer) / sizeof(wchar_t)));
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else if (*end == 'p') {
|
||||
} else if (*end == 'p') {
|
||||
wchar_t local[512];
|
||||
local[0] = '\0';
|
||||
wcsncat(local, start, end + 1 - start);
|
||||
|
||||
assert_true(arg_size == 4);
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
const void* pointer = (void*)SHIM_MEM_ADDR(value);
|
||||
int result = wsprintf(b, local, pointer);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else if (*end == 's') {
|
||||
} else if (*end == 's') {
|
||||
wchar_t local[512];
|
||||
local[0] = '\0';
|
||||
wcsncat(local, start, end + 1 - start);
|
||||
|
||||
assert_true(arg_size == 4);
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
uint32_t value = (uint32_t)SHIM_MEM_64(
|
||||
arg_ptr + (arg_index * 8)); // TODO: check if this is correct...
|
||||
const wchar_t* data = (const wchar_t*)SHIM_MEM_ADDR(value);
|
||||
size_t data_length = wcslen(data);
|
||||
wchar_t* swapped_data = (wchar_t*)xe_malloc((data_length + 1) * sizeof(wchar_t));
|
||||
wchar_t* swapped_data =
|
||||
(wchar_t*)xe_malloc((data_length + 1) * sizeof(wchar_t));
|
||||
for (size_t i = 0; i < data_length; ++i) {
|
||||
swapped_data[i] = poly::byte_swap(data[i]);
|
||||
}
|
||||
@@ -679,12 +596,10 @@ SHIM_CALL _vswprintf_shim(
|
||||
xe_free(swapped_data);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert_true(false);
|
||||
break;
|
||||
}
|
||||
@@ -695,19 +610,16 @@ SHIM_CALL _vswprintf_shim(
|
||||
xe_free(swapped_format);
|
||||
|
||||
// swap the result buffer
|
||||
for (wchar_t* swap = buffer; swap != b; ++swap)
|
||||
{
|
||||
for (wchar_t* swap = buffer; swap != b; ++swap) {
|
||||
*swap = poly::byte_swap(*swap);
|
||||
}
|
||||
|
||||
SHIM_SET_RETURN_32((uint32_t)((b - buffer) / sizeof(wchar_t)));
|
||||
}
|
||||
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xboxkrnl::RegisterStringExports(
|
||||
ExportResolver* export_resolver, KernelState* state) {
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", vsprintf, state);
|
||||
|
||||
Reference in New Issue
Block a user