[SDK][KERNELBASE][PATHCCH] Compile a collection of PathCch libraries (#8085)

CORE-12686

This collection of libraries consist in:

- a down-level `pathcch_static` PathCch library, to be used for programs
  that need to run on Windows 7 and below;

- Windows 8+ compatible libraries importing from either kernelbase.dll
  (`pathcch_kernelbase`), or from the corresponding APISET
  api-ms-win-core-path-l1-1-0.dll (`pathcch`, which is Win8+ PSDK
  compatible).

The down-level static library is compiled by reusing the newly-introduced
kernelbase's path.c, instead of using a specific pathcch.c.
Unrelated functions are excluded from compilation by putting them into
`#ifndef STATIC_PATHCCH ..... #endif` blocks.
This commit is contained in:
Hermès Bélusca-Maïto 2025-06-03 17:55:44 +02:00
parent 8ed6ec437b
commit db96138813
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
4 changed files with 91 additions and 1100 deletions

View file

@ -23,6 +23,8 @@
#include <string.h>
#include <wchar.h>
#ifndef STATIC_PATHCCH
#include "windef.h"
#include "winbase.h"
#include "pathcch.h"
@ -39,6 +41,54 @@
WINE_DEFAULT_DEBUG_CHANNEL(path);
#else // STATIC_PATHCCH
#ifdef __REACTOS__
/* This is the static implementation of the PathCch library */
#include <windef.h>
#include <winbase.h>
/* The PathCch functions use size_t, but Wine's implementation uses SIZE_T,
* so temporarily change the define'd SIZE_T type to the compatible one... */
#undef SIZE_T
#define SIZE_T size_t
#include <pathcch.h>
#include <strsafe.h>
#define TRACE(...)
#if (_WIN32_WINNT < _WIN32_WINNT_VISTA) || (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA)
/* wcsnlen is an NT6+ function. To cover all cases, use a private implementation */
static inline size_t compat_wcsnlen(const wchar_t* str, size_t size)
{
StringCchLengthW(str, size, &size);
return size;
}
#define wcsnlen compat_wcsnlen
#endif /* _WIN32_WINNT || DLL_EXPORT_VERSION */
// Implementation from string.c copied here in order not
// to depend on the whole file just for the PathCch library.
WCHAR * WINAPI StrRChrW(const WCHAR *str, const WCHAR *end, WORD ch)
{
WCHAR *ret = NULL;
if (!str) return NULL;
if (!end) end = str + lstrlenW(str);
while (str < end)
{
if (*str == ch) ret = (WCHAR *)str;
str++;
}
return ret;
}
#endif /* __REACTOS__ */
#endif // STATIC_PATHCCH
#ifndef STATIC_PATHCCH
static const char hexDigits[] = "0123456789ABCDEF";
static const unsigned char hashdata_lookup[256] =
@ -131,15 +181,19 @@ static BOOL is_drive_specA( const char *str )
return isalpha( str[0] ) && str[1] == ':';
}
#endif // !STATIC_PATHCCH
static BOOL is_drive_spec( const WCHAR *str )
{
return isalpha( str[0] ) && str[1] == ':';
}
#ifndef STATIC_PATHCCH
static BOOL is_escaped_drive_spec( const WCHAR *str )
{
return isalpha( str[0] ) && (str[1] == ':' || str[1] == '|');
}
#endif // !STATIC_PATHCCH
static BOOL is_prefixed_unc(const WCHAR *string)
{
@ -946,6 +1000,9 @@ BOOL WINAPI PathIsUNCEx(const WCHAR *path, const WCHAR **server)
return !!result;
}
#ifndef STATIC_PATHCCH
/* Other functions not part of the PathCch library */
BOOL WINAPI PathIsUNCA(const char *path)
{
TRACE("%s\n", wine_dbgstr_a(path));
@ -5248,3 +5305,5 @@ BOOL WINAPI IsInternetESCEnabled(void)
FIXME(": stub\n");
return FALSE;
}
#endif // !STATIC_PATHCCH

View file

@ -1,3 +1,11 @@
add_library(pathcch pathcch.c)
add_dependencies(pathcch xdk)
# Down-level static PathCch library, to be used for
# programs that need to run on Windows 7 and below.
add_library(pathcch_static STATIC ${REACTOS_SOURCE_DIR}/dll/win32/kernelbase/wine/path.c)
add_dependencies(pathcch_static xdk)
target_compile_definitions(pathcch_static PRIVATE wcsnicmp=_wcsnicmp STATIC_PATHCCH)
# Windows 8+ compatible libraries, importing from either
# kernelbase.dll or api-ms-win-core-path-l1-1-0.dll
generate_import_lib(pathcch_kernelbase kernelbase.dll pathcch.spec "--version=${DLL_EXPORT_VERSION}" "")
generate_import_lib(pathcch api-ms-win-core-path-l1-1-0.dll pathcch.spec "--version=${DLL_EXPORT_VERSION}" "")

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,22 @@
@ stdcall PathAllocCanonicalize(wstr long ptr)
@ stdcall PathAllocCombine(wstr wstr long ptr)
@ stdcall PathCchAddBackslash(wstr long)
@ stdcall PathCchAddBackslashEx(wstr long ptr ptr)
@ stdcall PathCchAddExtension(wstr long wstr)
@ stdcall PathCchAppend(wstr long wstr)
@ stdcall PathCchAppendEx(wstr long wstr long)
@ stdcall PathCchCanonicalize(ptr long wstr)
@ stdcall PathCchCanonicalizeEx(ptr long wstr long)
@ stdcall PathCchCombine(ptr long wstr wstr)
@ stdcall PathCchCombineEx(ptr long wstr wstr long)
@ stdcall PathCchFindExtension(wstr long ptr)
@ stdcall PathCchIsRoot(wstr)
@ stdcall PathCchRemoveBackslash(wstr long)
@ stdcall PathCchRemoveBackslashEx(wstr long ptr ptr)
@ stdcall PathCchRemoveExtension(wstr long)
@ stdcall PathCchRemoveFileSpec(wstr long)
@ stdcall PathCchRenameExtension(wstr long wstr)
@ stdcall PathCchSkipRoot(wstr ptr)
@ stdcall PathCchStripPrefix(wstr long)
@ stdcall PathCchStripToRoot(wstr long)
@ stdcall PathIsUNCEx(wstr ptr)