fprintf(stderr, "Module: Injecting %llu\n", module->programID);
// Copy the module into the firm
memcpy(sysmodule, module, module->contentSize * 0x200);
- break;
}
sysmodule = (ncch_h *)((uintptr_t)sysmodule + sysmodule->contentSize * 0x200);
}
{
execb(PATH_LOADER_CACHE "/BOOT", 0);
+ fprintf(stderr, "VM exited without issue\n");
+
// Replace loader?
if (config.options[OPTION_LOADER]) {
if (patch_modules()) {
#else
if (buf == BOTTOM_SCREEN)
text_buffer_bottom[cursor_y[0] * width + cursor_x[0]] = c;
- draw_character(screen, c, cursor_x[0], cursor_y[0], colors[(*color >> 4) & 0xF], colors[*color & 0xF]);
+ draw_character(screen, c, cursor_x[0], cursor_y[0], colors[(color[0] >> 4) & 0xF], colors[color[0] & 0xF]);
#endif
cursor_x[0]++;
char *ref = (char *)string;
- while (*ref != '\0') {
- putc(buf, *ref);
+ while (ref[0] != 0) {
+ putc(buf, ref[0]);
ref++;
}
}
else if (channel == TOP_SCREEN)
color = &color_bottom;
- while (*ref != '\0') {
- if (*ref == 0x1B && *(++ref) == '[' && (channel == stdout || channel == stderr)) {
+ while (ref[0] != '\0') {
+ if (ref[0] == 0x1B && (++ref)[0] == '[' && (channel == stdout || channel == stderr)) {
ansi_codes:
// Ansi escape code.
++ref;
// [30-37] Set text color
- if (*ref == '3') {
+ if (ref[0] == '3') {
++ref;
- if (*ref >= '0' && *ref <= '7') {
+ if (ref[0] >= '0' && ref[0] <= '7') {
// Valid FG color.
- *color &= 0x0f; // Remove fg color.
- *color |= (*ref - '0') << 4;
+ color[0] &= 0x0f; // Remove fg color.
+ color[0] |= (ref[0] - '0') << 4;
}
}
// [40-47] Set bg color
- else if (*ref == '4') {
+ else if (ref[0] == '4') {
++ref;
- if (*ref >= '0' && *ref <= '7') {
+ if (ref[0] >= '0' && ref[0] <= '7') {
// Valid BG color.
- *color &= 0xf0; // Remove bg color.
- *color |= *ref - '0';
+ color[0] &= 0xf0; // Remove bg color.
+ color[0] |= ref[0] - '0';
}
- } else if (*ref == '0') {
+ } else if (ref[0] == '0') {
// Reset.
- *color = 0xf0;
+ color[0] = 0xf0;
}
++ref;
- if (*ref == ';') {
+ if (ref[0] == ';') {
goto ansi_codes; // Another code.
}
// Loop until the character is somewhere 0x40 - 0x7E, which
// terminates an ANSI sequence
- while (!(*ref >= 0x40 && *ref <= 0x7E))
+ while (!(ref[0] >= 0x40 && ref[0] <= 0x7E))
ref++;
- } else if (*ref == '%' && !disable_format) {
+ } else if (ref[0] == '%' && !disable_format) {
int type_size = 0;
int length = -1;
check_format:
// Format string.
++ref;
- switch (*ref) {
+ switch (ref[0]) {
case 'd':
switch (type_size) {
case 2:
put_hexdump(channel, va_arg(ap, unsigned int));
break;
default:
- if (*ref >= '0' && *ref <= '9') {
- length = *ref - '0';
+ if (ref[0] >= '0' && ref[0] <= '9') {
+ length = ref[0] - '0';
goto check_format;
}
break;
}
} else {
- putc(channel, *ref);
+ putc(channel, ref[0]);
}
++ref;
}
if (f_opendir(&pdir, fpath) != FR_OK)
return 1;
- *(fname++) = '/';
+ fname[0] = '/';
+ fname++;
fno.lfname = fname;
fno.lfsize = fpath + 255 - fname;
}
f_closedir(&pdir);
- *(--fname) = '\0';
+ --fname;
+ fname[0] = 0;
}
return f_unlink(fpath);
FILE *
fopen(const char *filename, const char *mode)
{
- if (*mode != 'r' && *mode != 'w' && *mode != 'a')
+ if (mode[0] != 'r' && mode[0] != 'w' && mode[0] != 'a')
return NULL; // Mode not valid.
FILE *fp;
if (i == MAX_FILES_OPEN)
return NULL; // Out of handles.
- fp->mode = (*mode == 'r' ? FA_READ : (FA_WRITE | FA_OPEN_ALWAYS));
+ fp->mode = (mode[0] == 'r' ? FA_READ : (FA_WRITE | FA_OPEN_ALWAYS));
if (f_open(&(fp->handle), filename, fp->mode))
return NULL;
strlen(const char *string)
{
char *string_end = (char *)string;
- while (*string_end)
+ while (string_end[0])
string_end++;
return string_end - string;
}
uint8_t *destc = (uint8_t *)dest;
const uint8_t *srcc = (const uint8_t *)src;
- // Finish by copying the leftovers
- while (size--) {
- *destc++ = *srcc++;
+ for(size_t i=0; i < size; i++) {
+ destc[i] = srcc[i];
}
}
const uint8_t *srcc = (const uint8_t *)src;
// Finish by copying the leftovers
- while (size--) {
- destc[size] = srcc[size];
+ for(size_t i=size; i > 0; i--) {
+ destc[i-1] = srcc[i-1];
}
}
{
char *destc = (char *)dest;
- // Align dest to 4 bytes
- while ((uintptr_t)destc % sizeof(size_t) && size--) {
- *destc++ = filler;
- }
-
- // Set 32 bytes at a time
- for (; size >= sizeof(size_t); size -= sizeof(size_t), destc += sizeof(size_t)) {
- *(size_t *)destc = filler;
- }
-
// Finish
- while (size--) {
- *destc++ = filler;
+ for(size_t i = 0; i < size; i++) {
+ destc[i] = filler;
}
}
atoi(const char *str)
{
int res = 0;
- while (*str && *str >= '0' && *str <= '9') {
- res = *str - '0' + res * 10;
+ while (str[0] && str[0] >= '0' && str[0] <= '9') {
+ res = str[0] - '0' + res * 10;
str++;
}