From 415addef5590cbace0bc3c5a66f0f37e190de2e9 Mon Sep 17 00:00:00 2001 From: Daniel C Date: Sat, 6 Aug 2022 16:33:16 -0400 Subject: [PATCH] prettier format for printing old card flags --- src/drive-unix.c | 4 ++-- src/drive-win.c | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/drive-unix.c b/src/drive-unix.c index 9c623ba..8301d71 100644 --- a/src/drive-unix.c +++ b/src/drive-unix.c @@ -56,8 +56,8 @@ void flag_write(long int offset, char string[]) fseek(d, offset, SEEK_SET); fread(buffer, 1, strlen(string), d); - printf("Current Flag: \"%s\"\n", buffer); - printf("Writing \"%s\" at 0x%lx\n", string, offset); + printf("Current Flag: %s\n", buffer); + printf("New Flag: %s\n", string); fseek(d, offset, SEEK_SET); if (fwrite(string, 1, strlen(string), d) != strlen(string)) { diff --git a/src/drive-win.c b/src/drive-win.c index 1fc2f44..301a1b7 100644 --- a/src/drive-win.c +++ b/src/drive-win.c @@ -57,12 +57,15 @@ static int exfat_write(int location, int length, void *bytes) void flag_write(long offset, char string[]) { + char old_flag[16] = { 0 }; + SetFilePointer(d, 0, NULL, FILE_BEGIN); ReadFile(d, bootsector, SIZE, &bytesRead, NULL); - printf("Current Flag: %s\n", bootsector + offset); + memcpy(old_flag, bootsector + offset, strlen(string) % sizeof(buffer)); + printf("Current Flag: %s\n", old_flag); memcpy(bootsector + offset, string, strlen(string)); - printf("New Flag: %s\n", bootsector + offset); + printf("New Flag: %s\n", string); SetFilePointer(d, 0, NULL, FILE_BEGIN); if (!WriteFile(d, bootsector, SIZE, &bytesRead, NULL)) {