From 40fa0b865b39f8f07dcecc5c82eb28d9f8115621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Sat, 13 Apr 2024 19:15:48 +0200 Subject: [PATCH] Fix FindXXXFile functions --- COREDLL/other.cpp | 2 +- COREDLL/stdafx.h | 12 ++++++++++ COREDLL/winbase_wcecl.cpp | 47 +++++++++++++++++++++++++++++++++++---- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/COREDLL/other.cpp b/COREDLL/other.cpp index 4d8172f..065ddee 100644 --- a/COREDLL/other.cpp +++ b/COREDLL/other.cpp @@ -84,7 +84,7 @@ LCID WINAPI ConvertDefaultLocale_WCECL(LCID Locale) int _snwprintf_WCECL(wchar_t * buf, size_t bufCount, const wchar_t * fmt, ...) { #pragma warning( push ) -#pragma warning( disable: 4995 ) +#pragma warning( disable: 4995 4996) va_list args; va_start(args, fmt); diff --git a/COREDLL/stdafx.h b/COREDLL/stdafx.h index 7425020..60cc224 100644 --- a/COREDLL/stdafx.h +++ b/COREDLL/stdafx.h @@ -40,6 +40,18 @@ typedef struct tagWNDCLASSW_WCECL { LPCWSTR lpszClassName; } WNDCLASSW_WCECL, *PWNDCLASSW_WCECL, *LPWNDCLASSW_WCECL; +typedef struct tagWIN32_FIND_DATA_WCECL +{ + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + DWORD dwOID; + TCHAR cFileName[MAX_PATH]; +} WIN32_FIND_DATA_WCECL, *PWIN32_FIND_DATA_WCECL, *LPWIN32_FIND_DATA_WCECL; + // MACROS #undef RasHangUp #undef RasDial diff --git a/COREDLL/winbase_wcecl.cpp b/COREDLL/winbase_wcecl.cpp index d787df7..2d2444e 100644 --- a/COREDLL/winbase_wcecl.cpp +++ b/COREDLL/winbase_wcecl.cpp @@ -367,20 +367,59 @@ BOOL WINAPI DeleteFileW_WCECL(LPCWSTR lpFileName) auto result = DeleteFileW(lpFileName); return result; } +static void ConvertFindDataToWcecl( + LPWIN32_FIND_DATA_WCECL lpWceclData, + LPWIN32_FIND_DATAW lpFindData) +{ + wcscpy_s(lpWceclData->cFileName, + sizeof(lpWceclData->cFileName) / sizeof(*lpWceclData->cFileName), + lpFindData->cFileName); + lpWceclData->dwFileAttributes = lpFindData->dwFileAttributes; + lpWceclData->dwOID = lpFindData->dwReserved0; + lpWceclData->ftCreationTime = lpFindData->ftCreationTime; + lpWceclData->ftLastAccessTime = lpFindData->ftLastAccessTime; + lpWceclData->ftLastWriteTime = lpFindData->ftLastWriteTime; + lpWceclData->nFileSizeHigh = lpFindData->nFileSizeHigh; + lpWceclData->nFileSizeLow = lpFindData->nFileSizeLow; +} + +static void ConvertFindDataFromWcecl( + LPWIN32_FIND_DATAW lpFindData, + LPWIN32_FIND_DATA_WCECL lpWceclData) +{ + wcscpy_s(lpFindData->cFileName, + sizeof(lpFindData->cFileName) / sizeof(*lpFindData->cFileName), + lpWceclData->cFileName); + lpFindData->dwFileAttributes = lpWceclData->dwFileAttributes; + lpFindData->dwReserved0 = lpWceclData->dwOID; + lpFindData->ftCreationTime = lpWceclData->ftCreationTime; + lpFindData->ftLastAccessTime = lpWceclData->ftLastAccessTime; + lpFindData->ftLastWriteTime = lpWceclData->ftLastWriteTime; + lpFindData->nFileSizeHigh = lpWceclData->nFileSizeHigh; + lpFindData->nFileSizeLow = lpWceclData->nFileSizeLow; +} HANDLE WINAPI FindFirstFileW_WCECL( LPCWSTR lpFileName, - LPWIN32_FIND_DATAW lpFindFileData) + LPWIN32_FIND_DATA_WCECL lpFindFileData) { - auto result = FindFirstFileW(lpFileName, lpFindFileData); + WIN32_FIND_DATAW findData; + + ConvertFindDataFromWcecl(&findData, lpFindFileData); + auto result = FindFirstFileW(lpFileName, &findData); + ConvertFindDataToWcecl(lpFindFileData, &findData); return result; } BOOL WINAPI FindNextFileW_WCECL( HANDLE hFindFile, - LPWIN32_FIND_DATAW lpFindFileData) + LPWIN32_FIND_DATA_WCECL lpFindFileData) { - auto result = FindNextFileW(hFindFile, lpFindFileData); + WIN32_FIND_DATAW findData; + + ConvertFindDataFromWcecl(&findData, lpFindFileData); + auto result = FindNextFileW(hFindFile, &findData); + ConvertFindDataToWcecl(lpFindFileData, &findData); return result; }