Skip to content

Commit

Permalink
prettier format for printing old card flags
Browse files Browse the repository at this point in the history
  • Loading branch information
petabyt committed Aug 6, 2022
1 parent a702ea7 commit 415adde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/drive-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
7 changes: 5 additions & 2 deletions src/drive-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 415adde

Please sign in to comment.