Skip to content

Commit

Permalink
Remove FindFirstFile, FindNextFile and FindClose from PAL (#110797)
Browse files Browse the repository at this point in the history
* Remove FindFirstFile, FindNextFile and FindClose from PAL

Also remove the related tests

* Modify superpmi mcs tool to not to use Find*File on Unix

* Fix access after free for string in error path
  • Loading branch information
janvorli authored Dec 18, 2024
1 parent 4152f62 commit 3e5b44a
Show file tree
Hide file tree
Showing 27 changed files with 197 additions and 5,197 deletions.
3 changes: 0 additions & 3 deletions src/coreclr/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ nativeStringResourceTable_mscorrc
#DeleteCriticalSection
#DuplicateHandle
#EnterCriticalSection
#FindClose
#FindFirstFileW
#FindNextFileW
#FlushFileBuffers
#FlushInstructionCache
#FormatMessageW
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/inc/holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,6 @@ using FieldNuller = SpecializedWrapper<_TYPE, detail::ZeroMem<_TYPE>::Invoke>;
FORCEINLINE void VoidCloseHandle(HANDLE h) { if (h != NULL) CloseHandle(h); }
// (UINT_PTR) -1 is INVALID_HANDLE_VALUE
FORCEINLINE void VoidCloseFileHandle(HANDLE h) { if (h != ((HANDLE)((LONG_PTR) -1))) CloseHandle(h); }
FORCEINLINE void VoidFindClose(HANDLE h) { FindClose(h); }
FORCEINLINE void VoidUnmapViewOfFile(void *ptr) { UnmapViewOfFile(ptr); }

template <typename TYPE>
Expand All @@ -1125,7 +1124,6 @@ FORCEINLINE void TypeUnmapViewOfFile(TYPE *ptr) { UnmapViewOfFile(ptr); }
//@TODO: Dangerous default value. Some Win32 functions return INVALID_HANDLE_VALUE, some return NULL (such as CreatEvent).
typedef Wrapper<HANDLE, DoNothing<HANDLE>, VoidCloseHandle, (UINT_PTR) -1> HandleHolder;
typedef Wrapper<HANDLE, DoNothing<HANDLE>, VoidCloseFileHandle, (UINT_PTR) -1> FileHandleHolder;
typedef Wrapper<HANDLE, DoNothing<HANDLE>, VoidFindClose, (UINT_PTR) -1> FindHandleHolder;

typedef Wrapper<void *, DoNothing, VoidUnmapViewOfFile> MapViewHolder;

Expand Down
68 changes: 0 additions & 68 deletions src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,74 +541,6 @@ CopyFileW(
#define CopyFile CopyFileA
#endif

typedef struct _WIN32_FIND_DATAA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
CHAR cFileName[ MAX_PATH_FNAME ];
CHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;

typedef struct _WIN32_FIND_DATAW {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
WCHAR cFileName[ MAX_PATH_FNAME ];
WCHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW;

#ifdef UNICODE
typedef WIN32_FIND_DATAW WIN32_FIND_DATA;
typedef PWIN32_FIND_DATAW PWIN32_FIND_DATA;
typedef LPWIN32_FIND_DATAW LPWIN32_FIND_DATA;
#else
typedef WIN32_FIND_DATAA WIN32_FIND_DATA;
typedef PWIN32_FIND_DATAA PWIN32_FIND_DATA;
typedef LPWIN32_FIND_DATAA LPWIN32_FIND_DATA;
#endif

PALIMPORT
HANDLE
PALAPI
FindFirstFileW(
IN LPCWSTR lpFileName,
OUT LPWIN32_FIND_DATAW lpFindFileData);

#ifdef UNICODE
#define FindFirstFile FindFirstFileW
#else
#define FindFirstFile FindFirstFileA
#endif

PALIMPORT
BOOL
PALAPI
FindNextFileW(
IN HANDLE hFindFile,
OUT LPWIN32_FIND_DATAW lpFindFileData);

#ifdef UNICODE
#define FindNextFile FindNextFileW
#else
#define FindNextFile FindNextFileA
#endif

PALIMPORT
BOOL
PALAPI
FindClose(
IN OUT HANDLE hFindFile);

PALIMPORT
DWORD
PALAPI
Expand Down
14 changes: 0 additions & 14 deletions src/coreclr/pal/inc/palprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@ CreateDirectoryW(
IN LPCWSTR lpPathName,
IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);

PALIMPORT
HANDLE
PALAPI
FindFirstFileA(
IN LPCSTR lpFileName,
OUT LPWIN32_FIND_DATAA lpFindFileData);

PALIMPORT
BOOL
PALAPI
FindNextFileA(
IN HANDLE hFindFile,
OUT LPWIN32_FIND_DATAA lpFindFileData);

PALIMPORT
DWORD
PALAPI
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ set(SOURCES
file/directory.cpp
file/file.cpp
file/filetime.cpp
file/find.cpp
file/path.cpp
handlemgr/handleapi.cpp
handlemgr/handlemgr.cpp
Expand Down
Loading

0 comments on commit 3e5b44a

Please sign in to comment.