From: root Date: Mon, 13 Jun 2016 18:37:25 +0000 (-0400) Subject: Commit shit X-Git-Tag: v0.0.10~9^2 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=a60622d67d8ea8e03ba67fe1d4a4f84fe2286ee1;p=corbenik%2Fcorbenik.git Commit shit --- diff --git a/source/patch/module.c b/source/patch/module.c index 61ede7c..702eede 100644 --- a/source/patch/module.c +++ b/source/patch/module.c @@ -70,7 +70,6 @@ PATCH(modules) 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); } diff --git a/source/patcher.c b/source/patcher.c index 066cc10..a5a77fa 100644 --- a/source/patcher.c +++ b/source/patcher.c @@ -61,6 +61,8 @@ patch_firm_all() { execb(PATH_LOADER_CACHE "/BOOT", 0); + fprintf(stderr, "VM exited without issue\n"); + // Replace loader? if (config.options[OPTION_LOADER]) { if (patch_modules()) { diff --git a/source/std/draw.c b/source/std/draw.c index 2ef41ce..bdfedc4 100644 --- a/source/std/draw.c +++ b/source/std/draw.c @@ -277,7 +277,7 @@ putc(void *buf, const int c) #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]++; @@ -298,8 +298,8 @@ puts(void *buf, const char *string) char *ref = (char *)string; - while (*ref != '\0') { - putc(buf, *ref); + while (ref[0] != 0) { + putc(buf, ref[0]); ref++; } } @@ -438,50 +438,50 @@ vfprintf(void *channel, const char *format, va_list ap) 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: @@ -526,14 +526,14 @@ vfprintf(void *channel, const char *format, va_list ap) 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; } diff --git a/source/std/fs.c b/source/std/fs.c index 0f5f04b..079c054 100644 --- a/source/std/fs.c +++ b/source/std/fs.c @@ -26,7 +26,8 @@ rrmdir_back(char *fpath) if (f_opendir(&pdir, fpath) != FR_OK) return 1; - *(fname++) = '/'; + fname[0] = '/'; + fname++; fno.lfname = fname; fno.lfsize = fpath + 255 - fname; @@ -42,7 +43,8 @@ rrmdir_back(char *fpath) } f_closedir(&pdir); - *(--fname) = '\0'; + --fname; + fname[0] = 0; } return f_unlink(fpath); @@ -84,7 +86,7 @@ fumount(void) 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; @@ -99,7 +101,7 @@ fopen(const char *filename, const char *mode) 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; diff --git a/source/std/memory.c b/source/std/memory.c index dab6997..56c4900 100644 --- a/source/std/memory.c +++ b/source/std/memory.c @@ -7,7 +7,7 @@ size_t strlen(const char *string) { char *string_end = (char *)string; - while (*string_end) + while (string_end[0]) string_end++; return string_end - string; } @@ -37,9 +37,8 @@ memcpy(void *dest, const void *src, size_t size) 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]; } } @@ -56,8 +55,8 @@ memmove(void *dest, const void *src, size_t size) 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]; } } @@ -66,19 +65,9 @@ memset(void *dest, const int filler, size_t size) { 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; } } @@ -138,8 +127,8 @@ int 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++; }