Skip to content

Commit

Permalink
Fix FindXXXFile functions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNNX authored and dz333n committed Apr 13, 2024
1 parent fa2095b commit 40fa0b8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
2 changes: 1 addition & 1 deletion COREDLL/other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
12 changes: 12 additions & 0 deletions COREDLL/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 43 additions & 4 deletions COREDLL/winbase_wcecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 40fa0b8

Please sign in to comment.