Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
403 results
Show changes
Commits on Source (27)
Showing
with 993 additions and 165 deletions
......@@ -417,9 +417,6 @@ AS_IF([test "${SYS}" = "mingw32"],[
AS_IF([test "${enable_winstore_app}" = "yes"], [
vlc_winstore_app=1
LIBCOM="-loleaut32"
AX_APPEND_FLAG([-DWINSTORECOMPAT],[CFLAGS])
AX_APPEND_FLAG([-DWINSTORECOMPAT],[CPPFLAGS])
AX_APPEND_FLAG([-DWINSTORECOMPAT],[CXXFLAGS])
LDFLAGS="${LDFLAGS} -lwindowsappcompat"
VLC_ADD_LIBS([libvlccore], [-lruntimeobject])
AC_LIBOBJ([gai_strerror])
......
From 090616d80ee58c334647877ab8e9f4d04f4fde1a Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 23 May 2023 12:24:46 +0200
Subject: [PATCH] w32pthread: fix signature of WinRT version of thread worker
The callback passed to CreateThread is not the same as with _beginthreadex().
This WinRT check could be removed if Win8 WinRT is not maintained
as _beginthreadex() is now available [1]
[1] https://learn.microsoft.com/en-us/cpp/cppcx/crt-functions-not-supported-in-universal-windows-platform-apps?view=msvc-160#windows-8x-store-apps-and-windows-phone-8x-apps
---
compat/w32pthreads.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index 6405e72b64..364eebfe4e 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -66,7 +66,11 @@ typedef CONDITION_VARIABLE pthread_cond_t;
#define PTHREAD_CANCEL_ENABLE 1
#define PTHREAD_CANCEL_DISABLE 0
+#if HAVE_WINRT
+static av_unused DWORD WINAPI attribute_align_arg win32thread_worker(void *arg)
+#else
static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)
+#endif
{
pthread_t *h = (pthread_t*)arg;
h->ret = h->func(h->arg);
--
2.37.3.windows.1
......@@ -228,6 +228,7 @@ ffmpeg: ffmpeg-$(FFMPEG_VERSION).tar.xz .sum-ffmpeg
$(APPLY) $(SRC)/ffmpeg/0001-ffmpeg-add-target_os-support-for-emscripten.patch
$(APPLY) $(SRC)/ffmpeg/0001-vulkan-Fix-win-i386-calling-convention.patch
$(APPLY) $(SRC)/ffmpeg/0002-lavu-vulkan-fix-handle-type-for-32-bit-targets.patch
$(APPLY) $(SRC)/ffmpeg/0001-w32pthread-fix-signature-of-WinRT-version-of-thread-.patch
$(MOVE)
.ffmpeg: ffmpeg
......
From fd842b6a3bacac9e47504ca4d4fb611fab014fa2 Mon Sep 17 00:00:00 2001
From: DK <dmitrykos@neutroncode.com>
Date: Tue, 9 May 2023 15:37:57 +0300
Subject: [PATCH] Fixed compilation of get_utf8_argv() for Windows UWP
Fixed compilation in Win32 environment.
Use FLAC_WINDOWS_APP define to check between UWP app and Win32 for more consistency.
---
src/share/win_utf8_io/win_utf8_io.c | 41 ++++++++++++++++++++---------
1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c
index 65b56997..18921748 100644
--- a/src/share/win_utf8_io/win_utf8_io.c
+++ b/src/share/win_utf8_io/win_utf8_io.c
@@ -39,9 +39,12 @@
#define UTF8_BUFFER_SIZE 32768
-#if !defined(WINAPI_FAMILY_PARTITION)
-#define WINAPI_FAMILY_PARTITION(x) x
-#define WINAPI_PARTITION_DESKTOP 1
+/* detect whether it is Windows APP (UWP) or standard Win32 envionment */
+#if defined(WINAPI_FAMILY_PARTITION) &&\
+ WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+ #define FLAC_WINDOWS_APP 1
+#else
+ #define FLAC_WINDOWS_APP 0
#endif
static int local_vsnprintf(char *str, size_t size, const char *fmt, va_list va)
@@ -106,15 +109,22 @@ static wchar_t *wchar_from_utf8(const char *str)
/* retrieve WCHAR commandline, expand wildcards and convert everything to UTF-8 */
int get_utf8_argv(int *argc, char ***argv)
{
+#if !FLAC_WINDOWS_APP
typedef int (__cdecl *wgetmainargs_t)(int*, wchar_t***, wchar_t***, int, int*);
wgetmainargs_t wgetmainargs;
HMODULE handle;
+#endif // !FLAC_WINDOWS_APP
int wargc;
wchar_t **wargv;
wchar_t **wenv;
char **utf8argv;
int ret, i;
+#if FLAC_WINDOWS_APP
+ wargc = __argc;
+ wargv = __wargv;
+ wenv = _wenviron;
+#else // !FLAC_WINDOWS_APP
if ((handle = LoadLibraryW(L"msvcrt.dll")) == NULL) return 1;
if ((wgetmainargs = (wgetmainargs_t)GetProcAddress(handle, "__wgetmainargs")) == NULL) {
FreeLibrary(handle);
@@ -126,8 +136,11 @@ int get_utf8_argv(int *argc, char ***argv)
FreeLibrary(handle);
return 1;
}
+#endif // !FLAC_WINDOWS_APP
if ((utf8argv = (char **)calloc(wargc, sizeof(char*))) == NULL) {
+ #if !FLAC_WINDOWS_APP
FreeLibrary(handle);
+ #endif // !FLAC_WINDOWS_APP
return 1;
}
@@ -139,7 +152,9 @@ int get_utf8_argv(int *argc, char ***argv)
}
}
+#if !FLAC_WINDOWS_APP
FreeLibrary(handle); /* do not free it when wargv or wenv are still in use */
+#endif // !FLAC_WINDOWS_APP
if (ret == 0) {
*argc = wargc;
@@ -160,9 +175,9 @@ HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWO
HANDLE handle = INVALID_HANDLE_VALUE;
if ((wname = wchar_from_utf8(lpFileName)) != NULL) {
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if !FLAC_WINDOWS_APP
handle = CreateFileW(wname, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
-#else // !WINAPI_PARTITION_DESKTOP
+#else // FLAC_WINDOWS_APP
CREATEFILE2_EXTENDED_PARAMETERS params;
params.dwSize = sizeof(params);
params.dwFileAttributes = dwFlagsAndAttributes & 0xFFFF;
@@ -171,7 +186,7 @@ HANDLE WINAPI CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWO
params.lpSecurityAttributes = lpSecurityAttributes;
params.hTemplateFile = hTemplateFile;
handle = CreateFile2(wname, dwDesiredAccess, dwShareMode, dwCreationDisposition, &params);
-#endif // !WINAPI_PARTITION_DESKTOP
+#endif // FLAC_WINDOWS_APP
free(wname);
}
@@ -193,19 +208,19 @@ size_t strlen_utf8(const char *str)
int win_get_console_width(void)
{
int width = 80;
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if !FLAC_WINDOWS_APP
CONSOLE_SCREEN_BUFFER_INFO csbi;
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if(hOut != INVALID_HANDLE_VALUE && hOut != NULL)
if (GetConsoleScreenBufferInfo(hOut, &csbi) != 0)
width = csbi.dwSize.X;
-#endif // WINAPI_PARTITION_DESKTOP
+#endif // !FLAC_WINDOWS_APP
return width;
}
/* print functions */
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if !FLAC_WINDOWS_APP
static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
{
DWORD out;
@@ -235,7 +250,7 @@ static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
return ret;
return len;
}
-#endif // WINAPI_PARTITION_DESKTOP
+#endif // !FLAC_WINDOWS_APP
int printf_utf8(const char *format, ...)
{
@@ -276,12 +291,12 @@ int vfprintf_utf8(FILE *stream, const char *format, va_list argptr)
ret = -1;
break;
}
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if !FLAC_WINDOWS_APP
ret = wprint_console(stream, wout, wcslen(wout));
-#else // !WINAPI_PARTITION_DESKTOP
+#else // FLAC_WINDOWS_APP
OutputDebugStringW(wout);
ret = 0;
-#endif // !WINAPI_PARTITION_DESKTOP
+#endif // FLAC_WINDOWS_APP
} while(0);
free(utmp);
--
2.37.3.windows.1
......@@ -15,6 +15,7 @@ $(TARBALLS)/flac-$(FLAC_VERSION).tar.xz:
flac: flac-$(FLAC_VERSION).tar.xz .sum-flac
$(UNPACK)
$(APPLY) $(SRC)/flac/0001-Fixed-compilation-of-get_utf8_argv-for-Windows-UWP.patch
# disable building a tool we don't use
sed -e 's,add_subdirectory("microbench"),#add_subdirectory("microbench"),' -i.orig $(UNPACK_DIR)/CMakeLists.txt
$(call pkg_static,"src/libFLAC/flac.pc.in")
......
--- gcrypt/compat/libcompat.h.orig 2019-06-23 17:35:08.000000000 +0200
+++ gcrypt/compat/libcompat.h 2023-05-23 14:09:47.426668700 +0200
@@ -26,6 +26,13 @@ const char *_gcry_compat_identification
#ifndef HAVE_GETPID
pid_t _gcry_getpid (void);
#define getpid() _gcry_getpid ()
+#elif defined(_WIN32)
+#include <winapifamily.h>
+# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+# include <windows.h>
+ /* getpid is incorrectly detected, it's not available in this case */
+# define getpid() GetCurrentProcessId ()
+# endif
#endif
#ifndef HAVE_CLOCK
......@@ -19,6 +19,10 @@ gcrypt: libgcrypt-$(GCRYPT_VERSION).tar.bz2 .sum-gcrypt
$(APPLY) $(SRC)/gcrypt/0001-compat-provide-a-getpid-replacement-that-works-on-Wi.patch
$(APPLY) $(SRC)/gcrypt/0007-random-don-t-use-API-s-that-are-forbidden-in-UWP-app.patch
$(APPLY) $(SRC)/gcrypt/0008-random-only-use-wincrypt-in-UWP-builds-if-WINSTORECO.patch
# don't use getpid in UWP as it's not actually available
$(APPLY) $(SRC)/gcrypt/gcrypt-uwp-getpid.patch
$(MOVE)
DEPS_gcrypt = gpg-error $(DEPS_gpg-error)
......
From 8425c77fe89d66cd8d5411d0ccd14c688de1416a Mon Sep 17 00:00:00 2001
From a74b2ef0f17b300c7cdf2f0d45a2d78a6b4c52d8 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 16 May 2023 09:40:34 +0200
Subject: [PATCH] Use CreateFile2 in UWP builds
Subject: [PATCH 1/3] Use CreateFile2 in UWP builds
CreateFileA and CreateFileW are forbidden calls in UWP.
CreateFile2 is close enough, some parameters are passed in a structure
......@@ -12,18 +12,20 @@ using CP_ACP [2].
[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions
[2] https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar#parameters
---
lib/stat.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
lib/spawni.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
lib/stat.c | 35 +++++++++++++++++++++++++++++++++++
lib/utime.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 120 insertions(+)
diff --git a/gl/stat.c b/gl/stat.c
index 7987e26583..f0e95a27dc 100644
index 7987e26583..d25f632967 100644
--- a/gl/stat.c
+++ b/gl/stat.c
@@ -197,6 +197,7 @@ rpl_stat (char const *name, struct stat *buf)
{
/* Approach based on the file. */
+# if !defined WINAPI_FAMILY || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+# if !(_WIN32_WINNT >= _WIN32_WINNT_WIN8)
/* Open a handle to the file.
CreateFile
<https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilea>
......@@ -31,7 +33,7 @@ index 7987e26583..f0e95a27dc 100644
filesystem operations. */
FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */,
NULL);
+# else
+# else /* _WIN32_WINNT_WIN8 */
+ /* Only CreateFile2 is available in UWP builds.
+ <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfile2>
+ <https://learn.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-core-file-l1-2-1dll> */
......@@ -50,7 +52,7 @@ index 7987e26583..f0e95a27dc 100644
+ /* FILE_FLAG_POSIX_SEMANTICS (treat file names that differ only
+ in case as different) makes sense only when applied to *all*
+ filesystem operations. */
+ createExParams.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
+ createExParams.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
......@@ -64,7 +66,7 @@ index 7987e26583..f0e95a27dc 100644
+ freea(wrname);
+ }
+ }
+# endif
+# endif /* _WIN32_WINNT_WIN8 */
if (h != INVALID_HANDLE_VALUE)
{
ret = _gl_fstat_by_handle (h, rname, buf);
......
......@@ -47,7 +47,7 @@ endif
$(APPLY) $(SRC)/gnutls/0001-windows-Avoid-Wint-conversion-errors.patch
# use CreateFile2 instead of CreateFile in UWP
# use CreateFile2 in Win8 as CreateFileW is forbidden in UWP
$(APPLY) $(SRC)/gnutls/0001-Use-CreateFile2-in-UWP-builds.patch
$(UPDATE_AUTOCONFIG)
......@@ -70,6 +70,10 @@ GNUTLS_CONF := \
--with-included-unistring
DEPS_gnutls = nettle $(DEPS_nettle)
ifdef HAVE_WINSTORE
# gnulib uses GetFileInformationByHandle
DEPS_gnutls += alloweduwp $(DEPS_alloweduwp)
endif
ifdef HAVE_ANDROID
GNUTLS_ENV := gl_cv_header_working_stdint_h=yes
......
--- libgpg-error/src/estream.c.uwp 2023-05-23 09:53:33.222246200 +0200
+++ libgpg-error/src/estream.c 2023-05-22 12:00:18.105186500 +0200
@@ -4561,6 +4561,17 @@ tmpfd (void)
#else
strcpy (p, ".tmp");
#endif
+#if _WIN32_WINNT >= 0x0602 // _WIN32_WINNT_WIN8
+ CREATEFILE2_EXTENDED_PARAMETERS params;
+ memset (&params, 0, sizeof params);
+ params.dwSize = sizeof(params);
+ params.dwFileFlags = FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE;
+ file = CreateFile2 (buffer,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ CREATE_NEW,
+ &params);
+#else
file = CreateFile (buffer,
GENERIC_READ | GENERIC_WRITE,
0,
@@ -4568,6 +4579,7 @@ tmpfd (void)
CREATE_NEW,
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
NULL);
+#endif
if (file != INVALID_HANDLE_VALUE)
{
#ifdef HAVE_W32CE_SYSTEM
--- libgpg-error/src/w32-gettext.c.uwp 2023-05-23 09:53:33.184247600 +0200
+++ libgpg-error/src/w32-gettext.c 2023-05-22 11:45:24.077340000 +0200
@@ -53,7 +53,7 @@
#include "init.h"
#include "gpg-error.h"
-#if defined(HAVE_W32CE_SYSTEM) || WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP)
+#if defined(HAVE_W32CE_SYSTEM) || !WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
/* Forward declaration. */
static wchar_t *utf8_to_wchar (const char *string, size_t length, size_t *retlen);
@@ -72,9 +72,22 @@ MyCreateFileA (LPCSTR lpFileName, DWORD
if (!filename)
return INVALID_HANDLE_VALUE;
+#if !WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = dwFlagsAndAttributes & 0xFFFF;
+ createExParams.dwFileFlags = dwFlagsAndAttributes & 0xFFF00000;
+ createExParams.dwSecurityQosFlags = dwFlagsAndAttributes & 0x000F0000;
+ createExParams.lpSecurityAttributes = lpSecurityAttributes;
+ createExParams.hTemplateFile = hTemplateFile;
+
+ result = CreateFile2 (filename, dwDesiredAccess, dwSharedMode,
+ dwCreationDisposition, &createExParams);
+#else
result = CreateFileW (filename, dwDesiredAccess, dwSharedMode,
lpSecurityAttributes, dwCreationDisposition,
dwFlagsAndAttributes, hTemplateFile);
+#endif
err = GetLastError ();
free (filename);
--- libgpg-error/src/w32-gettext.c.uwp 2023-05-23 09:53:33.184247600 +0200
+++ libgpg-error/src/w32-gettext.c 2023-05-22 11:45:24.077340000 +0200
@@ -1240,7 +1253,15 @@ load_domain (const char *filename)
if (fh == INVALID_HANDLE_VALUE)
return NULL;
+#if !WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+ FILE_STANDARD_INFO fStdInfo;
+ if (GetFileInformationByHandleEx(fh, FileStandardInfo, (LPVOID)&fStdInfo, sizeof(fStdInfo)))
+ size = fStdInfo.EndOfFile.LowPart;
+ else
+ size = INVALID_FILE_SIZE;
+#else
size = GetFileSize (fh, NULL);
+#endif
if (size == INVALID_FILE_SIZE)
{
CloseHandle (fh);
......@@ -13,12 +13,8 @@ endif
libgpg-error: libgpg-error-$(GPGERROR_VERSION).tar.bz2 .sum-gpg-error
$(UNPACK)
ifdef HAVE_WIN32
$(APPLY) $(SRC)/gpg-error/windres-make.patch
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/gpg-error/winrt.patch
endif
endif
$(APPLY) $(SRC)/gpg-error/missing-unistd-include.patch
$(APPLY) $(SRC)/gpg-error/win32-unicode.patch
$(APPLY) $(SRC)/gpg-error/version-bump-gawk-5.patch
......@@ -32,6 +28,13 @@ endif
cp -f -- "$(UNPACK_DIR)/src/syscfg/lock-obj-pub.mingw32.h" \
"$(UNPACK_DIR)/src/syscfg/lock-obj-pub.mingw32uwp.h"
$(APPLY) $(SRC)/gpg-error/gpg-error-uwp-fix.patch
# use CreateFile2 in Win8 as CreateFileW is forbidden in UWP
$(APPLY) $(SRC)/gpg-error/gpg-error-createfile2.patch
# don't use GetFileSize on UWP
$(APPLY) $(SRC)/gpg-error/gpg-error-uwp-GetFileSize.patch
$(MOVE)
GPGERROR_CONF := \
......
From 8425c77fe89d66cd8d5411d0ccd14c688de1416a Mon Sep 17 00:00:00 2001
From a74b2ef0f17b300c7cdf2f0d45a2d78a6b4c52d8 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 16 May 2023 09:40:34 +0200
Subject: [PATCH] Use CreateFile2 in UWP builds
Subject: [PATCH 1/3] Use CreateFile2 in UWP builds
CreateFileA and CreateFileW are forbidden calls in UWP.
CreateFile2 is close enough, some parameters are passed in a structure
......@@ -12,18 +12,20 @@ using CP_ACP [2].
[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions
[2] https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar#parameters
---
lib/stat.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
lib/spawni.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
lib/stat.c | 35 +++++++++++++++++++++++++++++++++++
lib/utime.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 120 insertions(+)
diff --git a/srclib/stat.c b/srclib/stat.c
index 7987e26583..f0e95a27dc 100644
index 7987e26583..d25f632967 100644
--- a/srclib/stat.c
+++ b/srclib/stat.c
@@ -197,6 +197,7 @@ rpl_stat (char const *name, struct stat *buf)
{
/* Approach based on the file. */
+# if !defined WINAPI_FAMILY || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+# if !(_WIN32_WINNT >= _WIN32_WINNT_WIN8)
/* Open a handle to the file.
CreateFile
<https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilea>
......@@ -31,7 +33,7 @@ index 7987e26583..f0e95a27dc 100644
filesystem operations. */
FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */,
NULL);
+# else
+# else /* _WIN32_WINNT_WIN8 */
+ /* Only CreateFile2 is available in UWP builds.
+ <https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfile2>
+ <https://learn.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-core-file-l1-2-1dll> */
......@@ -50,7 +52,7 @@ index 7987e26583..f0e95a27dc 100644
+ /* FILE_FLAG_POSIX_SEMANTICS (treat file names that differ only
+ in case as different) makes sense only when applied to *all*
+ filesystem operations. */
+ createExParams.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
+ createExParams.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
......@@ -64,7 +66,7 @@ index 7987e26583..f0e95a27dc 100644
+ freea(wrname);
+ }
+ }
+# endif
+# endif /* _WIN32_WINNT_WIN8 */
if (h != INVALID_HANDLE_VALUE)
{
ret = _gl_fstat_by_handle (h, rname, buf);
......
......@@ -15,6 +15,12 @@ endif
endif
endif
DEPS_iconv :=
ifdef HAVE_WINSTORE
# gnulib uses GetFileInformationByHandle
DEPS_iconv += alloweduwp $(DEPS_alloweduwp)
endif
$(TARBALLS)/libiconv-$(LIBICONV_VERSION).tar.gz:
$(call download_pkg,$(LIBICONV_URL),iconv)
......@@ -24,7 +30,7 @@ iconv: libiconv-$(LIBICONV_VERSION).tar.gz .sum-iconv
$(UNPACK)
$(APPLY) $(SRC)/iconv/bins.patch
# use CreateFile2 instead of CreateFile in UWP
# use CreateFile2 in Win8 as CreateFileW is forbidden in UWP
$(APPLY) $(SRC)/iconv/0001-Use-CreateFile2-in-UWP-builds.patch
# fix forbidden UWP call which can't be upstreamed as they won't
......
--- libarchive/libarchive/archive_digest.c.orig 2022-04-08 13:40:26.000000000 +0200
+++ libarchive/libarchive/archive_digest.c 2023-05-12 15:35:03.525598300 +0200
@@ -30,6 +30,13 @@
#include "archive.h"
#include "archive_digest_private.h"
+#ifdef WINSTORECOMPAT
+WINIMPM WINBOOL WINAPI CryptCreateHash (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash);
+WINIMPM WINBOOL WINAPI CryptHashData (HCRYPTHASH hHash, CONST BYTE *pbData, DWORD dwDataLen, DWORD dwFlags);
+WINIMPM WINBOOL WINAPI CryptGetHashParam (HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags);
+WINIMPM WINBOOL WINAPI CryptDestroyHash (HCRYPTHASH hHash);
+#endif
+
/* In particular, force the configure probe to break if it tries
* to test a combination of OpenSSL and libmd. */
#if defined(ARCHIVE_CRYPTO_OPENSSL) && defined(ARCHIVE_CRYPTO_LIBMD)
......@@ -31,8 +31,6 @@ endif
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/libarchive/winrt.patch
endif
# fallback to Winstore Compat versions of Crypt API's
$(APPLY) $(SRC)/libarchive/libarchive-winstorecompat-crypt.patch
$(call pkg_static,"build/pkgconfig/libarchive.pc.in")
$(MOVE)
......
From 54904e02380cd05191458f4b99bef92308ca12c7 Mon Sep 17 00:00:00 2001
From 2594486c32fd71ca63d0eea10b7266034f703eb0 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Fri, 27 Mar 2020 16:25:36 +0100
Subject: [PATCH] WIP fix compilation for Universal Windows
---
libarchive/archive_check_magic.c | 3 +-
libarchive/archive_entry.h | 2 +-
libarchive/archive_entry_copy_bhfi.c | 2 +-
libarchive/archive_read_disk_windows.c | 9 ++++++
.../archive_read_support_filter_bzip2.c | 4 +++
.../archive_read_support_filter_grzip.c | 4 +++
.../archive_read_support_filter_lrzip.c | 4 +++
libarchive/archive_read_support_filter_lz4.c | 4 +++
libarchive/archive_read_support_filter_lzop.c | 4 +++
.../archive_read_support_filter_program.c | 14 ++++++---
libarchive/archive_read_support_filter_xz.c | 12 +++++++
libarchive/archive_read_support_filter_zstd.c | 4 +++
.../archive_read_support_format_mtree.c | 10 ++++++
libarchive/archive_digest.c | 50 +++++++++++-
libarchive/archive_digest_private.h | 9 +++
libarchive/archive_random.c | 7 ++
libarchive/archive_read_disk_windows.c | 80 +++++++++++++++++++
.../archive_read_support_filter_bzip2.c | 4 +
.../archive_read_support_filter_grzip.c | 4 +
.../archive_read_support_filter_lrzip.c | 4 +
libarchive/archive_read_support_filter_lz4.c | 4 +
libarchive/archive_read_support_filter_lzop.c | 4 +
.../archive_read_support_filter_program.c | 12 ++-
libarchive/archive_read_support_filter_xz.c | 12 +++
libarchive/archive_read_support_filter_zstd.c | 4 +
.../archive_read_support_format_mtree.c | 10 +++
libarchive/archive_string.c | 2 +-
libarchive/archive_util.c | 9 +++++-
libarchive/archive_windows.c | 31 ++++++++++++++++++-
libarchive/archive_windows.h | 6 ++++
libarchive/filter_fork_windows.c | 8 +++++
18 files changed, 121 insertions(+), 11 deletions(-)
libarchive/archive_util.c | 9 ++-
libarchive/archive_windows.c | 31 ++++++-
libarchive/archive_windows.h | 4 +
libarchive/archive_write_disk_windows.c | 78 ++++++++++++++++++
libarchive/filter_fork_windows.c | 8 ++
19 files changed, 327 insertions(+), 9 deletions(-)
diff --git a/libarchive/archive_check_magic.c b/libarchive/archive_check_magic.c
index 288ce233..3b3b9bc7 100644
--- a/libarchive/archive_check_magic.c
+++ b/libarchive/archive_check_magic.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_check_magic.c 201089 2009-12-28
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <windows.h>
#include <winbase.h>
+#include <winapifamily.h>
#endif
diff --git a/libarchive/archive_digest.c b/libarchive/archive_digest.c
index a7bd5f02..02dd27ee 100644
--- a/libarchive/archive_digest.c
+++ b/libarchive/archive_digest.c
@@ -48,6 +48,19 @@
/*
* Initialize a Message digest.
*/
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+static int
+win_crypto_init(Digest_CTX *ctx, const WCHAR *algo)
+{
+ ctx->valid = 0;
+
+ BCryptOpenAlgorithmProvider(&ctx->algo_handle, algo, NULL, 0);
+ BCryptCreateHash(ctx->algo_handle, &ctx->hash, NULL, 0, NULL, 0, 0);
+
+ ctx->valid = 1;
+ return (ARCHIVE_OK);
+}
+#else
static int
win_crypto_init(Digest_CTX *ctx, ALG_ID algId)
{
@@ -70,6 +83,7 @@ win_crypto_init(Digest_CTX *ctx, ALG_ID algId)
ctx->valid = 1;
return (ARCHIVE_OK);
}
+#endif
/*
* Update a Message digest.
@@ -81,23 +95,35 @@ win_crypto_Update(Digest_CTX *ctx, const unsigned char *buf, size_t len)
if (!ctx->valid)
return (ARCHIVE_FAILED);
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+ BCryptHashData(ctx->hash,
+ (PUCHAR) buf,
+ len, 0);
+#else
CryptHashData(ctx->hash,
(unsigned char *)(uintptr_t)buf,
(DWORD)len, 0);
+#endif
return (ARCHIVE_OK);
}
#include "archive_private.h"
@@ -65,7 +66,7 @@ errmsg(const char *m)
static __LA_DEAD void
diediedie(void)
static int
win_crypto_Final(unsigned char *buf, size_t bufsize, Digest_CTX *ctx)
{
-#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
+#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG) && WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
/* Cause a breakpoint exception */
DebugBreak();
#endif
diff --git a/libarchive/archive_entry.h b/libarchive/archive_entry.h
index 42af2086..cff6e55a 100644
--- a/libarchive/archive_entry.h
+++ b/libarchive/archive_entry.h
@@ -303,7 +303,7 @@ __LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
__LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long);
__LA_DECL void archive_entry_unset_atime(struct archive_entry *);
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *);
#endif
__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long);
diff --git a/libarchive/archive_entry_copy_bhfi.c b/libarchive/archive_entry_copy_bhfi.c
index 77bf38e4..22f9702c 100644
--- a/libarchive/archive_entry_copy_bhfi.c
+++ b/libarchive/archive_entry_copy_bhfi.c
@@ -29,7 +29,7 @@ __FBSDID("$FreeBSD$");
#include "archive_private.h"
#include "archive_entry.h"
- DWORD siglen = (DWORD)bufsize;
-
if (!ctx->valid)
return (ARCHIVE_FAILED);
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+ BCryptFinishHash(ctx->hash, buf, (ULONG)bufsize, 0);
+ BCryptDestroyHash(ctx->hash);
+ BCryptCloseAlgorithmProvider(ctx->algo_handle, 0);
+#else
+ DWORD siglen = (DWORD)bufsize;
+
CryptGetHashParam(ctx->hash, HP_HASHVAL, buf, &siglen, 0);
CryptDestroyHash(ctx->hash);
CryptReleaseContext(ctx->cryptProv, 0);
+#endif
ctx->valid = 0;
return (ARCHIVE_OK);
}
@@ -276,7 +302,11 @@ __archive_md5final(archive_md5_ctx *ctx, void *md)
static int
__archive_md5init(archive_md5_ctx *ctx)
{
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+ return (win_crypto_init(ctx, BCRYPT_MD5_ALGORITHM));
+#else
return (win_crypto_init(ctx, CALG_MD5));
+#endif
}
static int
@@ -659,7 +689,11 @@ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
static int
__archive_sha1init(archive_sha1_ctx *ctx)
{
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+ return (win_crypto_init(ctx, BCRYPT_SHA1_ALGORITHM));
+#else
return (win_crypto_init(ctx, CALG_SHA1));
+#endif
}
#define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000)
static int
@@ -919,7 +953,11 @@ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
static int
__archive_sha256init(archive_sha256_ctx *ctx)
{
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+ return (win_crypto_init(ctx, BCRYPT_SHA256_ALGORITHM));
+#else
return (win_crypto_init(ctx, CALG_SHA_256));
+#endif
}
static int
@@ -1155,7 +1193,11 @@ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
static int
__archive_sha384init(archive_sha384_ctx *ctx)
{
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+ return (win_crypto_init(ctx, BCRYPT_SHA384_ALGORITHM));
+#else
return (win_crypto_init(ctx, CALG_SHA_384));
+#endif
}
static int
@@ -1415,7 +1457,11 @@ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
static int
__archive_sha512init(archive_sha512_ctx *ctx)
{
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+ return (win_crypto_init(ctx, BCRYPT_SHA512_ALGORITHM));
+#else
return (win_crypto_init(ctx, CALG_SHA_512));
+#endif
}
static int
diff --git a/libarchive/archive_digest_private.h b/libarchive/archive_digest_private.h
index 9b3bd662..8082059c 100644
--- a/libarchive/archive_digest_private.h
+++ b/libarchive/archive_digest_private.h
@@ -165,11 +165,20 @@
defined(ARCHIVE_CRYPTO_SHA384_WIN) ||\
defined(ARCHIVE_CRYPTO_SHA512_WIN)
#include <windows.h>
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+#include <bcrypt.h>
+#else
#include <wincrypt.h>
+#endif
typedef struct {
int valid;
+#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+ BCRYPT_ALG_HANDLE algo_handle;
+ BCRYPT_HASH_HANDLE hash;
+#else
HCRYPTPROV cryptProv;
HCRYPTHASH hash;
+#endif
} Digest_CTX;
#endif
diff --git a/libarchive/archive_random.c b/libarchive/archive_random.c
index 9d1aa493..e63ffbfa 100644
--- a/libarchive/archive_random.c
+++ b/libarchive/archive_random.c
@@ -75,6 +75,12 @@ int
archive_random(void *buf, size_t nbytes)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
+# if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+ BCRYPT_ALG_HANDLE algo_handle;
+ BCryptOpenAlgorithmProvider(&algo_handle, BCRYPT_RNG_ALGORITHM, NULL, 0);
+ BCryptGenRandom(algo_handle, buf, nbytes, 0);
+ BCryptCloseAlgorithmProvider(algo_handle, 0);
+# else
HCRYPTPROV hProv;
BOOL success;
@@ -92,6 +98,7 @@ archive_random(void *buf, size_t nbytes)
}
/* TODO: Does this case really happen? */
return ARCHIVE_FAILED;
+# endif
#else
arc4random_buf(buf, nbytes);
return ARCHIVE_OK;
diff --git a/libarchive/archive_read_disk_windows.c b/libarchive/archive_read_disk_windows.c
index fdd376f9..85215326 100644
index ea32e2aa..7dd2e8a8 100644
--- a/libarchive/archive_read_disk_windows.c
+++ b/libarchive/archive_read_disk_windows.c
@@ -715,7 +715,11 @@ start_next_async_read(struct archive_read_disk *a, struct tree *t)
@@ -418,8 +418,19 @@ la_linkname_from_pathw(const wchar_t *path, wchar_t **outbuf, int *linktype)
FILE_FLAG_OPEN_REPARSE_POINT;
int ret;
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = 0;
+ createExParams.dwFileFlags = flag;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ h = CreateFile2(path, 0, FILE_SHARE_READ, OPEN_EXISTING, &createExParams);
+#else
h = CreateFileW(path, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, flag,
NULL);
+#endif
if (h == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
return (-1);
@@ -707,7 +718,11 @@ start_next_async_read(struct archive_read_disk *a, struct tree *t)
if (olp->buff == NULL) {
void *p;
size_t s = (size_t)align_num_per_sector(t, READ_BUFFER_SIZE);
......@@ -87,7 +241,28 @@ index fdd376f9..85215326 100644
if (p == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Couldn't allocate memory");
@@ -1512,7 +1516,12 @@ setup_current_filesystem(struct archive_read_disk *a)
@@ -1072,8 +1087,20 @@ next_entry(struct archive_read_disk *a, struct tree *t,
flags |= FILE_FLAG_NO_BUFFERING;
else
flags |= FILE_FLAG_SEQUENTIAL_SCAN;
+#if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = 0;
+ createExParams.dwFileFlags = flags;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ t->entry_fh = CreateFile2(tree_current_access_path(t),
+ GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, &createExParams);
+#else
t->entry_fh = CreateFileW(tree_current_access_path(t),
GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, flags, NULL);
+#endif
if (t->entry_fh == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
archive_set_error(&a->archive, errno,
@@ -1506,7 +1533,12 @@ setup_current_filesystem(struct archive_read_disk *a)
t->current_filesystem->synthetic = -1;/* Not supported */
path = safe_path_for_statfs(t);
......@@ -100,11 +275,95 @@ index fdd376f9..85215326 100644
free(path);
t->current_filesystem->remote = -1;
t->current_filesystem->bytesPerSector = 0;
@@ -1557,8 +1589,20 @@ close_and_restore_time(HANDLE h, struct tree *t, struct restore_time *rt)
if ((t->flags & needsRestoreTimes) == 0)
return (r);
+#if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = FILE_SHARE_READ;
+ createExParams.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ handle = CreateFile2(rt->full_path, FILE_WRITE_ATTRIBUTES,
+ 0, OPEN_EXISTING, &createExParams);
+#else
handle = CreateFileW(rt->full_path, FILE_WRITE_ATTRIBUTES,
0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+#endif
if (handle == INVALID_HANDLE_VALUE) {
errno = EINVAL;
return (-1);
@@ -2046,8 +2090,20 @@ tree_current_file_information(struct tree *t, BY_HANDLE_FILE_INFORMATION *st,
if (sim_lstat && tree_current_is_physical_link(t))
flag |= FILE_FLAG_OPEN_REPARSE_POINT;
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = 0;
+ createExParams.dwFileFlags = flag;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ h = CreateFile2(tree_current_access_path(t), 0, FILE_SHARE_READ,
+ OPEN_EXISTING, &createExParams);
+#else
h = CreateFileW(tree_current_access_path(t), 0, FILE_SHARE_READ, NULL,
OPEN_EXISTING, flag, NULL);
+#endif
if (h == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
t->tree_errno = errno;
@@ -2275,8 +2331,20 @@ archive_read_disk_entry_from_file(struct archive *_a,
} else
desiredAccess = GENERIC_READ;
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = 0;
+ createExParams.dwFileFlags = flag;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ h = CreateFile2(path, desiredAccess, FILE_SHARE_READ,
+ OPEN_EXISTING, &createExParams);
+#else
h = CreateFileW(path, desiredAccess, FILE_SHARE_READ, NULL,
OPEN_EXISTING, flag, NULL);
+#endif
if (h == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
archive_set_error(&a->archive, errno,
@@ -2337,8 +2405,20 @@ archive_read_disk_entry_from_file(struct archive *_a,
if (fd >= 0) {
h = (HANDLE)_get_osfhandle(fd);
} else {
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = 0;
+ createExParams.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ h = CreateFile2(path, GENERIC_READ, FILE_SHARE_READ,
+ OPEN_EXISTING, &createExParams);
+#else
h = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+#endif
if (h == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
archive_set_error(&a->archive, errno,
diff --git a/libarchive/archive_read_support_filter_bzip2.c b/libarchive/archive_read_support_filter_bzip2.c
index 3885a7cf..d2e8b001 100644
index 793d605c..57a84eba 100644
--- a/libarchive/archive_read_support_filter_bzip2.c
+++ b/libarchive/archive_read_support_filter_bzip2.c
@@ -169,6 +169,7 @@ bzip2_reader_bid(struct archive_read_filter_bidder *self, struct archive_read_fi
@@ -159,6 +159,7 @@ bzip2_reader_bid(struct archive_read_filter_bidder *self, struct archive_read_fi
static int
bzip2_reader_init(struct archive_read_filter *self)
{
......@@ -112,7 +371,7 @@ index 3885a7cf..d2e8b001 100644
int r;
r = __archive_read_program(self, "bzip2 -d");
@@ -178,6 +179,9 @@ bzip2_reader_init(struct archive_read_filter *self)
@@ -168,6 +169,9 @@ bzip2_reader_init(struct archive_read_filter *self)
self->code = ARCHIVE_FILTER_BZIP2;
self->name = "bzip2";
return (r);
......@@ -123,10 +382,10 @@ index 3885a7cf..d2e8b001 100644
diff --git a/libarchive/archive_read_support_filter_grzip.c b/libarchive/archive_read_support_filter_grzip.c
index 84c86aeb..66c32b4b 100644
index d4d1737c..7660b392 100644
--- a/libarchive/archive_read_support_filter_grzip.c
+++ b/libarchive/archive_read_support_filter_grzip.c
@@ -109,6 +109,7 @@ grzip_bidder_bid(struct archive_read_filter_bidder *self,
@@ -100,6 +100,7 @@ grzip_bidder_bid(struct archive_read_filter_bidder *self,
static int
grzip_bidder_init(struct archive_read_filter *self)
{
......@@ -134,7 +393,7 @@ index 84c86aeb..66c32b4b 100644
int r;
r = __archive_read_program(self, "grzip -d");
@@ -118,4 +119,7 @@ grzip_bidder_init(struct archive_read_filter *self)
@@ -109,4 +110,7 @@ grzip_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_FILTER_GRZIP;
self->name = "grzip";
return (r);
......@@ -143,10 +402,10 @@ index 84c86aeb..66c32b4b 100644
+#endif
}
diff --git a/libarchive/archive_read_support_filter_lrzip.c b/libarchive/archive_read_support_filter_lrzip.c
index c82a8e2f..b4100b9a 100644
index a2389894..562e37e0 100644
--- a/libarchive/archive_read_support_filter_lrzip.c
+++ b/libarchive/archive_read_support_filter_lrzip.c
@@ -120,6 +120,7 @@ lrzip_bidder_bid(struct archive_read_filter_bidder *self,
@@ -110,6 +110,7 @@ lrzip_bidder_bid(struct archive_read_filter_bidder *self,
static int
lrzip_bidder_init(struct archive_read_filter *self)
{
......@@ -154,7 +413,7 @@ index c82a8e2f..b4100b9a 100644
int r;
r = __archive_read_program(self, "lrzip -d -q");
@@ -129,4 +130,7 @@ lrzip_bidder_init(struct archive_read_filter *self)
@@ -119,4 +120,7 @@ lrzip_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_FILTER_LRZIP;
self->name = "lrzip";
return (r);
......@@ -163,10 +422,10 @@ index c82a8e2f..b4100b9a 100644
+#endif
}
diff --git a/libarchive/archive_read_support_filter_lz4.c b/libarchive/archive_read_support_filter_lz4.c
index 43ee6c2b..5d3baf91 100644
index ae0b0800..3f7fc14e 100644
--- a/libarchive/archive_read_support_filter_lz4.c
+++ b/libarchive/archive_read_support_filter_lz4.c
@@ -204,6 +204,7 @@ lz4_reader_bid(struct archive_read_filter_bidder *self,
@@ -194,6 +194,7 @@ lz4_reader_bid(struct archive_read_filter_bidder *self,
static int
lz4_reader_init(struct archive_read_filter *self)
{
......@@ -174,7 +433,7 @@ index 43ee6c2b..5d3baf91 100644
int r;
r = __archive_read_program(self, "lz4 -d -q");
@@ -213,6 +214,9 @@ lz4_reader_init(struct archive_read_filter *self)
@@ -203,6 +204,9 @@ lz4_reader_init(struct archive_read_filter *self)
self->code = ARCHIVE_FILTER_LZ4;
self->name = "lz4";
return (r);
......@@ -185,10 +444,10 @@ index 43ee6c2b..5d3baf91 100644
diff --git a/libarchive/archive_read_support_filter_lzop.c b/libarchive/archive_read_support_filter_lzop.c
index a1c392f4..191688f4 100644
index afd2d4d0..7dd80c0b 100644
--- a/libarchive/archive_read_support_filter_lzop.c
+++ b/libarchive/archive_read_support_filter_lzop.c
@@ -160,6 +160,7 @@ lzop_bidder_bid(struct archive_read_filter_bidder *self,
@@ -158,6 +158,7 @@ lzop_bidder_bid(struct archive_read_filter_bidder *self,
static int
lzop_bidder_init(struct archive_read_filter *self)
{
......@@ -196,7 +455,7 @@ index a1c392f4..191688f4 100644
int r;
r = __archive_read_program(self, "lzop -d");
@@ -169,6 +170,9 @@ lzop_bidder_init(struct archive_read_filter *self)
@@ -167,6 +168,9 @@ lzop_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_FILTER_LZOP;
self->name = "lzop";
return (r);
......@@ -205,9 +464,9 @@ index a1c392f4..191688f4 100644
+#endif
}
#else
/*
diff --git a/libarchive/archive_read_support_filter_program.c b/libarchive/archive_read_support_filter_program.c
index b8bf1288..2197ed41 100644
index 885b2c20..4015cea2 100644
--- a/libarchive/archive_read_support_filter_program.c
+++ b/libarchive/archive_read_support_filter_program.c
@@ -82,6 +82,8 @@ archive_read_support_filter_program(struct archive *a, const char *cmd)
......@@ -219,7 +478,7 @@ index b8bf1288..2197ed41 100644
/*
* The bidder object stores the command and the signature to watch for.
* The 'inhibit' entry here is used to ensure that unchecked filters never
@@ -105,7 +107,7 @@ static int program_bidder_free(struct archive_read_filter_bidder *);
@@ -105,7 +107,7 @@ static void program_bidder_free(struct archive_read_filter_bidder *);
*/
struct program_filter {
struct archive_string description;
......@@ -228,7 +487,7 @@ index b8bf1288..2197ed41 100644
HANDLE child;
#else
pid_t child;
@@ -254,7 +256,7 @@ child_stop(struct archive_read_filter *self, struct program_filter *state)
@@ -243,7 +245,7 @@ child_stop(struct archive_read_filter *self, struct program_filter *state)
state->waitpid_return
= waitpid(state->child, &state->exit_status, 0);
} while (state->waitpid_return == -1 && errno == EINTR);
......@@ -237,7 +496,7 @@ index b8bf1288..2197ed41 100644
CloseHandle(state->child);
#endif
state->child = 0;
@@ -309,7 +311,7 @@ child_read(struct archive_read_filter *self, char *buf, size_t buf_len)
@@ -298,7 +300,7 @@ child_read(struct archive_read_filter *self, char *buf, size_t buf_len)
struct program_filter *state = self->data;
ssize_t ret, requested, avail;
const char *p;
......@@ -246,7 +505,7 @@ index b8bf1288..2197ed41 100644
HANDLE handle = (HANDLE)_get_osfhandle(state->child_stdout);
#endif
@@ -317,7 +319,7 @@ child_read(struct archive_read_filter *self, char *buf, size_t buf_len)
@@ -306,7 +308,7 @@ child_read(struct archive_read_filter *self, char *buf, size_t buf_len)
for (;;) {
do {
......@@ -255,17 +514,17 @@ index b8bf1288..2197ed41 100644
/* Avoid infinity wait.
* Note: If there is no data in the pipe, ReadFile()
* called in read() never returns and so we won't
@@ -516,3 +518,5 @@ program_filter_close(struct archive_read_filter *self)
@@ -494,3 +496,5 @@ program_filter_close(struct archive_read_filter *self)
return (e);
}
+
+#endif // !_WIN32 || WINAPI_PARTITION_DESKTOP
diff --git a/libarchive/archive_read_support_filter_xz.c b/libarchive/archive_read_support_filter_xz.c
index 11807cf6..856e08a5 100644
index 32ae0be9..a521548f 100644
--- a/libarchive/archive_read_support_filter_xz.c
+++ b/libarchive/archive_read_support_filter_xz.c
@@ -754,6 +754,7 @@ xz_filter_close(struct archive_read_filter *self)
@@ -749,6 +749,7 @@ xz_filter_close(struct archive_read_filter *self)
static int
lzma_bidder_init(struct archive_read_filter *self)
{
......@@ -273,7 +532,7 @@ index 11807cf6..856e08a5 100644
int r;
r = __archive_read_program(self, "lzma -d -qq");
@@ -763,11 +764,15 @@ lzma_bidder_init(struct archive_read_filter *self)
@@ -758,11 +759,15 @@ lzma_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_FILTER_LZMA;
self->name = "lzma";
return (r);
......@@ -289,7 +548,7 @@ index 11807cf6..856e08a5 100644
int r;
r = __archive_read_program(self, "xz -d -qq");
@@ -777,11 +782,15 @@ xz_bidder_init(struct archive_read_filter *self)
@@ -772,11 +777,15 @@ xz_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_FILTER_XZ;
self->name = "xz";
return (r);
......@@ -305,7 +564,7 @@ index 11807cf6..856e08a5 100644
int r;
r = __archive_read_program(self, "lzip -d -q");
@@ -791,6 +800,9 @@ lzip_bidder_init(struct archive_read_filter *self)
@@ -786,6 +795,9 @@ lzip_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_FILTER_LZIP;
self->name = "lzip";
return (r);
......@@ -316,10 +575,10 @@ index 11807cf6..856e08a5 100644
#endif /* HAVE_LZMA_H */
diff --git a/libarchive/archive_read_support_filter_zstd.c b/libarchive/archive_read_support_filter_zstd.c
index c8bb36be..84859211 100644
index 39f25f1b..15bec661 100644
--- a/libarchive/archive_read_support_filter_zstd.c
+++ b/libarchive/archive_read_support_filter_zstd.c
@@ -143,6 +143,7 @@ zstd_bidder_bid(struct archive_read_filter_bidder *self,
@@ -144,6 +144,7 @@ zstd_bidder_bid(struct archive_read_filter_bidder *self,
static int
zstd_bidder_init(struct archive_read_filter *self)
{
......@@ -327,7 +586,7 @@ index c8bb36be..84859211 100644
int r;
r = __archive_read_program(self, "zstd -d -qq");
@@ -152,6 +153,9 @@ zstd_bidder_init(struct archive_read_filter *self)
@@ -153,6 +154,9 @@ zstd_bidder_init(struct archive_read_filter *self)
self->code = ARCHIVE_FILTER_ZSTD;
self->name = "zstd";
return (r);
......@@ -338,10 +597,10 @@ index c8bb36be..84859211 100644
#else
diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c
index 332944ac..8c647131 100644
index 4a281632..e398625a 100644
--- a/libarchive/archive_read_support_format_mtree.c
+++ b/libarchive/archive_read_support_format_mtree.c
@@ -57,6 +57,8 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_mtree.c 2011
@@ -58,6 +58,8 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_mtree.c 2011
#include "archive_string.h"
#include "archive_pack_dev.h"
......@@ -350,7 +609,7 @@ index 332944ac..8c647131 100644
#ifndef O_BINARY
#define O_BINARY 0
#endif
@@ -2023,3 +2025,11 @@ readline(struct archive_read *a, struct mtree *mtree, char **start,
@@ -2138,3 +2140,11 @@ readline(struct archive_read *a, struct mtree *mtree, char **start,
find_off = u - mtree->line.s;
}
}
......@@ -363,7 +622,7 @@ index 332944ac..8c647131 100644
+}
+#endif
diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c
index c77dcf52..7942ff8b 100644
index d7f2c46b..60daeafe 100644
--- a/libarchive/archive_string.c
+++ b/libarchive/archive_string.c
@@ -1323,7 +1323,7 @@ free_sconv_object(struct archive_string_conv *sc)
......@@ -376,7 +635,7 @@ index c77dcf52..7942ff8b 100644
my_atoi(const char *p)
{
diff --git a/libarchive/archive_util.c b/libarchive/archive_util.c
index 659665a8..d526497f 100644
index b1582edb..2efff38a 100644
--- a/libarchive/archive_util.c
+++ b/libarchive/archive_util.c
@@ -209,7 +209,7 @@ __archive_errx(int retvalue, const char *msg)
......@@ -388,7 +647,7 @@ index 659665a8..d526497f 100644
/*
* Do not use Windows tmpfile() function.
* It will make a temporary file under the root directory
@@ -378,6 +378,13 @@ exit_tmpfile:
@@ -379,6 +379,13 @@ exit_tmpfile:
archive_wstring_free(&temp_name);
return (fd);
}
......@@ -403,7 +662,7 @@ index 659665a8..d526497f 100644
int
__archive_mktemp(const char *tmpdir)
diff --git a/libarchive/archive_windows.c b/libarchive/archive_windows.c
index 624e2700..828a8543 100644
index 624e2700..ede0269a 100644
--- a/libarchive/archive_windows.c
+++ b/libarchive/archive_windows.c
@@ -235,6 +235,7 @@ la_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode,
......@@ -421,7 +680,7 @@ index 624e2700..828a8543 100644
+#else /* !WINAPI_PARTITION_DESKTOP */
+ wpath = __la_win_permissive_name(path);
+ if (wpath == NULL)
+ return (handle);
+ return INVALID_HANDLE_VALUE;
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = dwFlagsAndAttributes & 0xFFFF;
......@@ -450,23 +709,23 @@ index 624e2700..828a8543 100644
NULL);
+#else /* !WINAPI_PARTITION_DESKTOP */
+ if (ws != NULL) {
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = FILE_ATTRIBUTE_READONLY;
+ createExParams.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ handle = CreateFile2(ws, 0, 0, OPEN_EXISTING, &createExParams);
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = FILE_ATTRIBUTE_READONLY;
+ createExParams.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ handle = CreateFile2(ws, 0, 0, OPEN_EXISTING, &createExParams);
+ }
+ else
+ handle = INVALID_HANDLE_VALUE;
+ handle = INVALID_HANDLE_VALUE;
+#endif /* !WINAPI_PARTITION_DESKTOP */
free(ws);
if (handle == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
diff --git a/libarchive/archive_windows.h b/libarchive/archive_windows.h
index 47b7cb8e..9743f310 100644
index 47b7cb8e..4aad8199 100644
--- a/libarchive/archive_windows.h
+++ b/libarchive/archive_windows.h
@@ -106,9 +106,11 @@
......@@ -481,7 +740,7 @@ index 47b7cb8e..9743f310 100644
#if !defined(__BORLANDC__) && !defined(__WATCOMC__)
#define setmode _setmode
#endif
@@ -276,8 +280,10 @@ extern int __la_stat(const char *path, struct stat *st);
@@ -276,8 +278,10 @@ extern int __la_stat(const char *path, struct stat *st);
extern pid_t __la_waitpid(HANDLE child, int *status, int option);
extern ssize_t __la_write(int fd, const void *buf, size_t nbytes);
......@@ -492,10 +751,176 @@ index 47b7cb8e..9743f310 100644
/* for status returned by la_waitpid */
#define WIFEXITED(sts) ((sts & 0x100) == 0)
#define WEXITSTATUS(sts) (sts & 0x0FF)
diff --git a/libarchive/archive_write_disk_windows.c b/libarchive/archive_write_disk_windows.c
index 1b12a299..f90861b0 100644
--- a/libarchive/archive_write_disk_windows.c
+++ b/libarchive/archive_write_disk_windows.c
@@ -290,14 +290,31 @@ file_information(struct archive_write_disk *a, wchar_t *path,
(findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK)))
flag |= FILE_FLAG_OPEN_REPARSE_POINT;
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = 0;
+ createExParams.dwFileFlags = flag;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ h = CreateFile2(a->name, 0, 0,
+ OPEN_EXISTING, &createExParams);
+#else
h = CreateFileW(a->name, 0, 0, NULL,
OPEN_EXISTING, flag, NULL);
+#endif
if (h == INVALID_HANDLE_VALUE &&
GetLastError() == ERROR_INVALID_NAME) {
wchar_t *full;
full = __la_win_permissive_name_w(path);
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ h = CreateFile2(full, 0, 0,
+ OPEN_EXISTING, &createExParams);
+#else
h = CreateFileW(full, 0, 0, NULL,
OPEN_EXISTING, flag, NULL);
+#endif
free(full);
}
if (h == INVALID_HANDLE_VALUE) {
@@ -559,6 +576,7 @@ la_mktemp(struct archive_write_disk *a)
return (fd);
}
+#if _WIN32_WINNT < _WIN32_WINNT_VISTA
static void *
la_GetFunctionKernel32(const char *name)
{
@@ -574,6 +592,7 @@ la_GetFunctionKernel32(const char *name)
}
return (void *)GetProcAddress(lib, name);
}
+#endif
static int
la_CreateHardLinkW(wchar_t *linkname, wchar_t *target)
@@ -582,10 +601,19 @@ la_CreateHardLinkW(wchar_t *linkname, wchar_t *target)
static int set;
BOOL ret;
+#if _WIN32_WINNT < _WIN32_WINNT_XP
+/* CreateHardLinkW is available since XP and always loaded */
if (!set) {
set = 1;
f = la_GetFunctionKernel32("CreateHardLinkW");
}
+#else
+# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+ f = CreateHardLinkW;
+# else
+ f = NULL;
+# endif
+#endif
if (!f) {
errno = ENOTSUP;
return (0);
@@ -632,10 +660,19 @@ la_CreateSymbolicLinkW(const wchar_t *linkname, const wchar_t *target,
DWORD newflags = 0;
BOOL ret = 0;
+#if _WIN32_WINNT < _WIN32_WINNT_VISTA
+/* CreateSymbolicLinkW is available since Vista and always loaded */
if (!set) {
set = 1;
f = la_GetFunctionKernel32("CreateSymbolicLinkW");
}
+#else
+# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+ f = CreateSymbolicLinkW;
+# else
+ f = NULL;
+# endif
+#endif
if (!f)
return (0);
@@ -1718,8 +1755,20 @@ create_filesystem_object(struct archive_write_disk *a)
a->todo = 0;
a->deferred = 0;
} else if (r == 0 && a->filesize > 0) {
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
+ createExParams.dwFileFlags = 0;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ a->fh = CreateFile2(namefull, GENERIC_WRITE, 0,
+ TRUNCATE_EXISTING, &createExParams);
+#else
a->fh = CreateFileW(namefull, GENERIC_WRITE, 0, NULL,
TRUNCATE_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+#endif
if (a->fh == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
r = errno;
@@ -1782,14 +1831,31 @@ create_filesystem_object(struct archive_write_disk *a)
a->tmpname = NULL;
fullname = a->name;
/* O_WRONLY | O_CREAT | O_EXCL */
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
+ createExParams.dwFileFlags = 0;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ a->fh = CreateFile2(fullname, GENERIC_WRITE, 0,
+ CREATE_NEW, &createExParams);
+#else
a->fh = CreateFileW(fullname, GENERIC_WRITE, 0, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+#endif
if (a->fh == INVALID_HANDLE_VALUE &&
GetLastError() == ERROR_INVALID_NAME &&
fullname == a->name) {
fullname = __la_win_permissive_name_w(a->name);
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ a->fh = CreateFile2(fullname, GENERIC_WRITE, 0,
+ CREATE_NEW, &createExParams);
+#else
a->fh = CreateFileW(fullname, GENERIC_WRITE, 0, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+#endif
}
if (a->fh == INVALID_HANDLE_VALUE) {
if (GetLastError() == ERROR_ACCESS_DENIED) {
@@ -2551,8 +2617,20 @@ set_times(struct archive_write_disk *a,
ws = __la_win_permissive_name_w(name);
if (ws == NULL)
goto settimes_failed;
+# if _WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8 */
+ CREATEFILE2_EXTENDED_PARAMETERS createExParams;
+ createExParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
+ createExParams.dwFileAttributes = 0;
+ createExParams.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
+ createExParams.dwSecurityQosFlags = 0;
+ createExParams.lpSecurityAttributes = NULL;
+ createExParams.hTemplateFile = NULL;
+ hw = CreateFile2(ws, FILE_WRITE_ATTRIBUTES, 0,
+ OPEN_EXISTING, &createExParams);
+#else
hw = CreateFileW(ws, FILE_WRITE_ATTRIBUTES,
0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+#endif
free(ws);
if (hw == INVALID_HANDLE_VALUE)
goto settimes_failed;
diff --git a/libarchive/filter_fork_windows.c b/libarchive/filter_fork_windows.c
index ad271fe6..0414d6f4 100644
--- a/libarchive/filter_fork_windows.c.orig 2020-12-26 02:29:38.000000000 +0100
+++ b/libarchive/filter_fork_windows.c 2021-04-21 17:17:42.651099766 +0200
index 0b963975..fc9c0f55 100644
--- a/libarchive/filter_fork_windows.c
+++ b/libarchive/filter_fork_windows.c
@@ -31,6 +31,13 @@
#include "filter_fork.h"
......@@ -507,10 +932,10 @@ index ad271fe6..0414d6f4 100644
+ return ARCHIVE_FAILED;
+}
+#else /* WINAPI_PARTITION_DESKTOP */
int
__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout,
HANDLE *out_child)
@@ -187,6 +194,7 @@
/* There are some editions of Windows ("nano server," for example) that
* do not host user32.dll. If we want to keep running on those editions,
* we need to delay-load WaitForInputIdle. */
@@ -224,6 +231,7 @@ fail:
__archive_cmdline_free(acmd);
return ARCHIVE_FAILED;
}
......@@ -518,3 +943,6 @@ index ad271fe6..0414d6f4 100644
void
__archive_check_child(int in, int out)
--
2.37.3.windows.1
From 5cbbac2ca7b7f4a190582ab757a388fd28fc8a02 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 23 May 2023 09:57:47 +0200
Subject: [PATCH] use GetCurrentProcessId for the process ID on Windows
getpid is not available in UWP even though it's detected.
---
src/smb_message.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/smb_message.c b/src/smb_message.c
index d7717a6..d9b7d28 100644
--- a/src/smb_message.c
+++ b/src/smb_message.c
@@ -79,7 +79,11 @@ smb_message *smb_message_new(uint8_t cmd)
for (unsigned i = 0; i < 4; i++)
msg->packet->header.magic[i] = magic[i];
msg->packet->header.command = cmd;
+#ifdef _WIN32
+ msg->packet->header.pid = GetCurrentProcessId();
+#else
msg->packet->header.pid = getpid();
+#endif
return msg;
}
--
2.37.3.windows.1
......@@ -15,6 +15,7 @@ $(TARBALLS)/libdsm-$(LIBDSM_VERSION).tar.xz:
libdsm: libdsm-$(LIBDSM_VERSION).tar.xz .sum-libdsm
$(UNPACK)
$(APPLY) $(SRC)/libdsm/0001-Avoid-relying-on-implicit-function-declarations.patch
$(APPLY) $(SRC)/libdsm/0001-use-GetCurrentProcessId-for-the-process-ID-on-Window.patch
$(MOVE)
DEPS_libdsm = libtasn1 $(DEPS_libtasn1) iconv $(DEPS_iconv)
......
From e30f5842045c3894d9f46f1122c1702ba7925536 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Tue, 23 May 2023 14:58:11 +0200
Subject: [PATCH 1/2] Use bcrypt on Windows Vista+
wincrypt is deprecated and not available in UWP.
---
contrib/mbedtls/library/CMakeLists.txt | 2 +-
contrib/mbedtls/library/entropy_poll.c | 23 ++++++++++++++++++++++-
meson.build | 2 +-
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/contrib/mbedtls/library/CMakeLists.txt b/contrib/mbedtls/library/CMakeLists.txt
index c7542b5..8ad7fb3 100644
--- a/contrib/mbedtls/library/CMakeLists.txt
+++ b/contrib/mbedtls/library/CMakeLists.txt
@@ -119,7 +119,7 @@ if(CMAKE_COMPILER_IS_CLANG)
endif(CMAKE_COMPILER_IS_CLANG)
if(WIN32)
- set(libs ${libs} ws2_32)
+ set(libs ${libs} ws2_32 bcrypt)
endif(WIN32)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
diff --git a/contrib/mbedtls/library/entropy_poll.c b/contrib/mbedtls/library/entropy_poll.c
index 2c1e093..bb276bb 100644
--- a/contrib/mbedtls/library/entropy_poll.c
+++ b/contrib/mbedtls/library/entropy_poll.c
@@ -56,15 +56,35 @@
#define _WIN32_WINNT 0x0400
#endif
#include <windows.h>
+#if _WIN32_WINNT >= 0x0600 /* _WIN32_WINNT_VISTA */
+#include <ntstatus.h>
+#include <bcrypt.h>
+#else
#include <wincrypt.h>
+#endif
int mbedtls_platform_entropy_poll( void *data, unsigned char *output, size_t len,
size_t *olen )
{
- HCRYPTPROV provider;
((void) data);
*olen = 0;
+#if _WIN32_WINNT >= 0x0600 /* _WIN32_WINNT_VISTA */
+ BCRYPT_ALG_HANDLE algo_handle;
+ if( BCryptOpenAlgorithmProvider( &algo_handle, BCRYPT_RNG_ALGORITHM, NULL,
+ 0 ) != STATUS_SUCCESS )
+ {
+ return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
+ }
+ if( BCryptGenRandom(algo_handle, output, len, 0) != STATUS_SUCCESS )
+ {
+ BCryptCloseAlgorithmProvider( algo_handle, 0 );
+ return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
+ }
+
+ BCryptCloseAlgorithmProvider( algo_handle, 0 );
+#else
+ HCRYPTPROV provider;
if( CryptAcquireContext( &provider, NULL, NULL,
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT ) == FALSE )
{
@@ -78,6 +98,7 @@ int mbedtls_platform_entropy_poll( void *data, unsigned char *output, size_t len
}
CryptReleaseContext( provider, 0 );
+#endif
*olen = len;
return( 0 );
diff --git a/meson.build b/meson.build
index f8ec49b..c06be2c 100755
--- a/meson.build
+++ b/meson.build
@@ -63,7 +63,7 @@ have_clock_gettime = false
threads = []
test_args = []
if host_machine.system() == 'windows'
- deps += [ cc.find_library('ws2_32') ]
+ deps += [ cc.find_library('ws2_32'), cc.find_library('bcrypt') ]
add_project_arguments(['-D_WIN32_WINNT=0x0601'], language: 'c')
if get_option('default_library') != 'static'
add_project_arguments(['-DLIBRIST_BUILDING_DLL'], language: 'c')
--
2.37.3.windows.1