mirror of
https://github.com/nigelbarink/R3c0v3r.git
synced 2026-02-14 02:10:50 +00:00
started openening and reading file. Added copy instruction to premake file. TODO: correctly add premake copy instruction as a build step
This commit is contained in:
@@ -18,6 +18,7 @@ solution "Rec0ver_H4rv4rd"
|
||||
configuration "Debug"
|
||||
defines {"DEBUG"}
|
||||
symbols "On"
|
||||
os.copyfile("rsc/card.raw" , "build/debug/card.raw")
|
||||
|
||||
configuration "Release"
|
||||
defines {"NDEBUG"}
|
||||
|
||||
@@ -32,3 +32,7 @@ Usage: ./recover image
|
||||
$ ./recover card.raw
|
||||
```
|
||||
|
||||
## Resources
|
||||
**Harvard CS50 exercise:** [https://cs50.harvard.edu/x/2020/psets/4/recover/#:~:text=y%20card,%20but%20t](https://cs50.harvard.edu/x/2020/psets/4/recover/#:~:text=y%20card,%20but%20t)
|
||||
|
||||
|
||||
|
||||
@@ -3,5 +3,38 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("Hello world!");
|
||||
FILE* file = fopen("G:\\Users\\Nigel\\Code\\Rec0ver_H4rv4rd\\rsc\\card.raw", "rb");
|
||||
if (!file) {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
const char* ReadBuffer = malloc(sizeof(char) * 512);
|
||||
if (ReadBuffer == NULL) {
|
||||
exit(-2);
|
||||
}
|
||||
|
||||
|
||||
int read = 0 ;
|
||||
int total_read = 0;
|
||||
do {
|
||||
read = fread(ReadBuffer, sizeof(char), 512, file);
|
||||
total_read += read;
|
||||
printf("==============Begin Block==============\n");
|
||||
for (int i = 0; i < 512 ; i++)
|
||||
{
|
||||
if ( i % 50 == 0){
|
||||
printf("\n");
|
||||
}
|
||||
printf("%x", ReadBuffer[i]);
|
||||
}
|
||||
printf("==============End Block===============\n");
|
||||
|
||||
printf("Bytes read total : %X\n", total_read);
|
||||
|
||||
} while (read != 0);
|
||||
|
||||
printf("Total read: %i bytes\n", total_read);
|
||||
|
||||
free(ReadBuffer);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user