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);