// LegoBlobReader.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include #include #include #include #include typedef unsigned char byte; static char const* FILE_NAME = "GAMEPROGRESS.broke.blob"; byte* ReadFileToBuffer(char const* filename, size_t* file_len) { FILE* fp = nullptr; ::fopen_s(&fp, filename, "r"); if (nullptr == fp) { return nullptr; } ::fseek(fp, 0, SEEK_END); size_t eof = ::ftell(fp); ::fseek(fp, 0, SEEK_SET); byte* buffer = (byte*) ::malloc(eof); if (nullptr != buffer) { *file_len = ::fread(buffer, 1, eof, fp); } ::fclose(fp); return buffer; } static void DisplayProgress(byte* buffer, size_t len, size_t offset) { size_t bytes_to_show = len - offset; bytes_to_show = std::min(bytes_to_show, 16); printf("At %u (0x%08x) into buffer... Next %u byte(s) are...\n> ", offset, offset, bytes_to_show); for (size_t i = 0; i < bytes_to_show; ++i) { byte b = buffer[offset + i]; printf("%02X ", b); } } static void ParseBuffer(byte* buffer, size_t len) { size_t offset = 0; DisplayProgress(buffer, len, offset); } int main() { size_t file_len; byte* buffer = ReadFileToBuffer(FILE_NAME, &file_len); if (nullptr == buffer) { printf("Failed to open file.\n"); } ParseBuffer(buffer, file_len); free(buffer); printf("\n\n\n"); _getch(); } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: // 1. Use the Solution Explorer window to add/manage files // 2. Use the Team Explorer window to connect to source control // 3. Use the Output window to see build output and other messages // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file