From ccfe1c9f56d705d2f9ba6dc68fcbccd979f08a96 Mon Sep 17 00:00:00 2001 From: Gaku Date: Sat, 21 Mar 2020 00:08:11 +0900 Subject: [PATCH] Some fix --- axwrpdf.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/axwrpdf.cpp b/axwrpdf.cpp index c5e7e94..ba735c5 100644 --- a/axwrpdf.cpp +++ b/axwrpdf.cpp @@ -319,13 +319,14 @@ inline SIZE_T GetPdfPageSize(IPdfPage* page) inline void PdfPageToFileInfo(IPdfPage* page, UINT index, fileInfo& fileInfo, LPCSTR ext, SIZE_T filesize) noexcept { - memcpy(fileInfo.method, "PDF", 3); + memcpy(fileInfo.method, "PDF\0", 4); fileInfo.position = index; fileInfo.compsize = filesize; fileInfo.filesize = filesize; fileInfo.timestamp = static_cast(std::time(nullptr)); sprintf_s(fileInfo.filename, "%08u%s", index, ext); fileInfo.crc = 0; + fileInfo.path[0] = NULL; } template @@ -483,11 +484,14 @@ HRESULT GetFileInfoInternal(LPCSTR buf, LONG_PTR len, LPCSTR filename, unsigned { UINT count; CHECK_HR(doc->get_PageCount(&count)); - if (len >= count) + + UINT index = count; + sscanf_s(PathFindFileNameA(filename), "%08u", &index); + + if (index >= count) { return E_INVALIDARG; } - UINT index = len; ComPtr page; CHECK_HR(doc->GetPage(index, &page));