From 19b4c31ee57fffef4abd305ea7c3724c68bae1f8 Mon Sep 17 00:00:00 2001 From: daem0nc0re Date: Mon, 18 Aug 2025 19:58:45 +0900 Subject: [PATCH] Fix file size issue in Restore.cpp --- Chapter12/Restore/Restore.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Chapter12/Restore/Restore.cpp b/Chapter12/Restore/Restore.cpp index d6e5480..0b81690 100644 --- a/Chapter12/Restore/Restore.cpp +++ b/Chapter12/Restore/Restore.cpp @@ -35,6 +35,8 @@ int wmain(int argc, const wchar_t* argv[]) { return Error("Failed to allocate buffer"); DWORD bytes; + FILE_END_OF_FILE_INFO info; + info.EndOfFile = size; while (size.QuadPart > 0) { if (!ReadFile(hSource, buffer, (DWORD)(min((LONGLONG)bufferSize, size.QuadPart)), &bytes, nullptr)) return Error("Failed to read data"); @@ -44,6 +46,8 @@ int wmain(int argc, const wchar_t* argv[]) { size.QuadPart -= bytes; } + SetFileInformationByHandle(hTarget, FileEndOfFileInfo, (LPVOID)&info, sizeof(info)); + printf("Restore successful!\n"); CloseHandle(hSource);