Rebase against e9231beb865da13941d19eca016a6ccac07cb3f4.

This commit is contained in:
Zebediah Figura 2018-12-04 20:17:06 -06:00
parent 6fb7d85916
commit 08623c69c9
15 changed files with 105 additions and 1244 deletions

View File

@ -1,28 +1,23 @@
From b4a2543264f9eb91fc259a81dea872eee3c14aba Mon Sep 17 00:00:00 2001
From 07ca5e888c3265c57c88ef1758e6c47fbea4fb07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 27 Jun 2015 19:28:51 +0200
Subject: loader: Print library paths for --check-libs on Mac OS X.
---
loader/main.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
loader/main.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/loader/main.c b/loader/main.c
index 44804e1..4d9126e 100644
index a2dc40c51c..1642fb0965 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -48,6 +48,7 @@
#include "main.h"
@@ -50,6 +50,30 @@
/* the preloader will set this variable */
const struct wine_preload_info *wine_main_preload_info = NULL;
#ifdef __APPLE__
+#ifdef __APPLE__
+#include <mach-o/dyld.h>
#ifndef __clang__
__asm__(".zerofill WINE_DOS, WINE_DOS, ___wine_dos, 0x40000000");
@@ -73,6 +74,26 @@ static inline void reserve_area( void *addr, size_t size )
wine_mmap_add_reserved_area( addr, size );
}
+
+static const char *get_macho_library_path( const char *libname )
+{
+ unsigned int path_len, libname_len = strlen( libname );
@ -30,7 +25,7 @@ index 44804e1..4d9126e 100644
+
+ for (i = 0; i < count; i++)
+ {
+ const char *path = _dyld_get_image_name( i );
+ const char *path = _dyld_get_image_name( i );
+ if (!path) continue;
+
+ path_len = strlen( path );
@ -42,11 +37,12 @@ index 44804e1..4d9126e 100644
+ }
+ return NULL;
+}
+#endif
+
#else /* __APPLE__ */
/* the preloader will set this variable */
@@ -181,7 +202,11 @@ static void check_command_line( int argc, char *argv[] )
/***********************************************************************
* check_command_line
*
@@ -146,7 +170,11 @@ static void check_command_line( int argc, char *argv[] )
else
#endif
{
@ -60,5 +56,5 @@ index 44804e1..4d9126e 100644
wine_dlclose( lib_handle, NULL, 0 );
}
--
2.4.3
2.14.1

View File

@ -1,4 +1,4 @@
From 53bf52b313245d965619802729ef59ada1806660 Mon Sep 17 00:00:00 2001
From 9774b93b25d11fe143fcf4ab7159135334916045 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 27 Aug 2014 00:31:23 +0200
Subject: configure: Also add the absolute RPATH when linking against libwine.
@ -8,11 +8,11 @@ Subject: configure: Also add the absolute RPATH when linking against libwine.
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index ff74f8d..529c209 100644
index 2222c687d9..513bdef795 100644
--- a/configure.ac
+++ b/configure.ac
@@ -966,10 +966,10 @@ ${wine_binary}_LDFLAGS = $LDEXECFLAGS -lwine \$(PTHREAD_LIBS)
[WINELOADER_LDFLAGS="-Wl,--export-dynamic"])
@@ -943,10 +943,10 @@ case $host_os in
WINEPRELOADER_LDFLAGS="-static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000"
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
- [LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
@ -25,5 +25,5 @@ index ff74f8d..529c209 100644
WINE_TRY_CFLAGS([-Wl,--enable-new-dtags],
--
2.6.1
2.14.1

View File

@ -1,803 +0,0 @@
From f6d4e6e5fe2d789d5ce21a99daf3a1864d883544 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 12 Jun 2017 00:16:08 +0200
Subject: [PATCH] loader: Implement preloader for Mac OS.
---
Makefile.in | 1 +
configure.ac | 23 ++-
dlls/ntdll/virtual.c | 2 -
libs/wine/config.c | 2 +-
loader/Makefile.in | 4 +-
loader/main.c | 44 +---
loader/preloader.c | 468 ++++++++++++++++++++++++++++++++++++++++++-
7 files changed, 491 insertions(+), 53 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 13b5a5a0536..c55655b87c0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -87,6 +87,7 @@ conf_manext = 5
WINELOADER_PROGRAMS = @WINELOADER_PROGRAMS@
WINELOADER_DEPENDS = @WINELOADER_DEPENDS@
WINELOADER_LDFLAGS = @WINELOADER_LDFLAGS@
+WINEPRELOADER_LDFLAGS = @WINEPRELOADER_LDFLAGS@
LIBWINE_SHAREDLIB = @LIBWINE_SHAREDLIB@
LIBWINE_IMPORTLIB = @LIBWINE_IMPORTLIB@
LIBWINE_LDFLAGS = @LIBWINE_LDFLAGS@
diff --git a/configure.ac b/configure.ac
index 73953cbb980..d8130ec3b87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -724,6 +724,7 @@ AC_SUBST(LDEXECFLAGS,"")
AC_SUBST(TOP_INSTALL_LIB,"")
AC_SUBST(TOP_INSTALL_DEV,"")
AC_SUBST(WINELOADER_LDFLAGS,"")
+AC_SUBST(WINEPRELOADER_LDFLAGS,"")
LIBEXT="so"
DLLEXT=".so"
IMPLIBEXT="def"
@@ -784,9 +785,17 @@ case $host_os in
AC_SUBST(APPLICATIONSERVICES_LIBS,"-framework ApplicationServices")
AC_SUBST(CORESERVICES_LIBS,"-framework CoreServices")
AC_SUBST(APPKIT_LIBS,"-framework AppKit")
- WINELOADER_LDFLAGS="-image_base 0x7bf00000 -Wl,-pagezero_size,0x1000,-segaddr,WINE_DOS,0x00001000,-segaddr,WINE_SHAREDHEAP,0x7f000000,-sectcreate,__TEXT,__info_plist,wine_info.plist"
+
+ WINELOADER_LDFLAGS="-Wl,-pie,-pagezero_size,0x1000,-sectcreate,__TEXT,__info_plist,wine_info.plist"
+ WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
+ [WINELOADER_LDFLAGS="-Wl,--export-dynamic $WINELOADER_LDFLAGS"])
+
+ WINEPRELOADER_LDFLAGS="-nostartfiles -nodefaultlibs -e _start -ldylib1.o -Wl,-image_base,0x7c400000,-pagezero_size,0x1000,-sectcreate,__TEXT,__info_plist,wine_info.plist"
+ WINE_TRY_CFLAGS([-Wl,-no_new_main -e _main],
+ [WINEPRELOADER_LDFLAGS="-Wl,-no_new_main $WINEPRELOADER_LDFLAGS"])
WINE_TRY_CFLAGS([-Wl,-no_pie],
- [WINELOADER_LDFLAGS="-Wl,-no_pie $WINELOADER_LDFLAGS"])
+ [WINEPRELOADER_LDFLAGS="-Wl,-no_pie $WINEPRELOADER_LDFLAGS"])
+
if test "$ac_cv_header_DiskArbitration_DiskArbitration_h" = "yes"
then
dnl DiskArbitration API is not public on Darwin < 8.0, use it only if header found
@@ -902,6 +911,7 @@ case $host_os in
enable_wineandroid_drv=${enable_wineandroid_drv:-yes}
WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
[WINELOADER_LDFLAGS="-Wl,--export-dynamic"])
+ WINEPRELOADER_LDFLAGS="-static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000"
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`"
LDRPATH_LOCAL="-Wl,--rpath,\\\$\$ORIGIN/\$(top_builddir)/libs/wine"],
@@ -949,6 +959,7 @@ case $host_os in
WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
[WINELOADER_LDFLAGS="-Wl,--export-dynamic"])
+ WINEPRELOADER_LDFLAGS="-static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000"
WINE_TRY_CFLAGS([-fPIC -Wl,--rpath,\$ORIGIN/../lib],
[LDRPATH_INSTALL="-Wl,--rpath,\\\$\$ORIGIN/\`\$(MAKEDEP) -R \${bindir} \${libdir}\`:\$(DESTDIR)\${libdir}"
@@ -2143,6 +2154,14 @@ case $host_os in
;;
esac
;;
+ darwin*|macosx*)
+ case $host_cpu in
+ *i[[3456789]]86*|x86_64*)
+ test "$wine_binary" = wine || WINE_IGNORE_FILE("loader/wine-preloader")
+ WINELOADER_PROGRAMS="$WINELOADER_PROGRAMS $wine_binary-preloader"
+ ;;
+ esac
+ ;;
esac
dnl **** Check for functions ****
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 7713869fe45..b200d0df7f8 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -2424,11 +2424,9 @@ void virtual_release_address_space(void)
}
else
{
-#ifndef __APPLE__ /* dyld doesn't support parts of the WINE_DOS segment being unmapped */
range.base = (char *)0x20000000;
range.limit = (char *)0x7f000000;
while (wine_mmap_enum_reserved_areas( free_reserved_memory, &range, 0 )) /* nothing */;
-#endif
}
server_leave_uninterrupted_section( &csVirtual, &sigset );
diff --git a/libs/wine/config.c b/libs/wine/config.c
index 45a7c483ab5..cba4224f537 100644
--- a/libs/wine/config.c
+++ b/libs/wine/config.c
@@ -678,7 +678,7 @@ void wine_exec_wine_binary( const char *name, char **argv, const char *env_var )
if (!name) name = argv0_name; /* no name means default loader */
-#ifdef linux
+#if defined(linux) || defined(__APPLE__)
use_preloader = !strendswith( name, "wineserver" );
#else
use_preloader = 0;
diff --git a/loader/Makefile.in b/loader/Makefile.in
index bbb1b953391..90e322bd749 100644
--- a/loader/Makefile.in
+++ b/loader/Makefile.in
@@ -24,7 +24,7 @@ wine64_DEPS = $(WINELOADER_DEPENDS)
wine64_LDFLAGS = $(WINELOADER_LDFLAGS) $(LDEXECFLAGS) -lwine $(PTHREAD_LIBS)
wine_preloader_OBJS = preloader.o
-wine_preloader_LDFLAGS = -static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000
+wine_preloader_LDFLAGS = $(WINEPRELOADER_LDFLAGS)
wine64_preloader_OBJS = preloader.o
-wine64_preloader_LDFLAGS = -static -nostartfiles -nodefaultlibs -Wl,-Ttext=0x7c400000
+wine64_preloader_LDFLAGS = $(WINEPRELOADER_LDFLAGS)
diff --git a/loader/main.c b/loader/main.c
index 39d26e61ca3..da32fc903e6 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -50,30 +50,6 @@
#ifdef __APPLE__
#include <mach-o/dyld.h>
-#ifndef __clang__
-__asm__(".zerofill WINE_DOS, WINE_DOS, ___wine_dos, 0x40000000");
-__asm__(".zerofill WINE_SHAREDHEAP, WINE_SHAREDHEAP, ___wine_shared_heap, 0x03000000");
-extern char __wine_dos[0x40000000], __wine_shared_heap[0x03000000];
-#else
-__asm__(".zerofill WINE_DOS, WINE_DOS");
-__asm__(".zerofill WINE_SHAREDHEAP, WINE_SHAREDHEAP");
-static char __wine_dos[0x40000000] __attribute__((section("WINE_DOS, WINE_DOS")));
-static char __wine_shared_heap[0x03000000] __attribute__((section("WINE_SHAREDHEAP, WINE_SHAREDHEAP")));
-#endif
-
-static const struct wine_preload_info wine_main_preload_info[] =
-{
- { __wine_dos, sizeof(__wine_dos) }, /* DOS area + PE exe */
- { __wine_shared_heap, sizeof(__wine_shared_heap) }, /* shared user data + shared heap */
- { 0, 0 } /* end of list */
-};
-
-static inline void reserve_area( void *addr, size_t size )
-{
- wine_anon_mmap( addr, size, PROT_NONE, MAP_FIXED | MAP_NORESERVE );
- wine_mmap_add_reserved_area( addr, size );
-}
-
static const char *get_macho_library_path( const char *libname )
{
unsigned int path_len, libname_len = strlen( libname );
@@ -94,18 +70,11 @@ static const char *get_macho_library_path( const char *libname )
return NULL;
}
-#else /* __APPLE__ */
+#endif /* __APPLE__ */
/* the preloader will set this variable */
const struct wine_preload_info *wine_main_preload_info = NULL;
-static inline void reserve_area( void *addr, size_t size )
-{
- wine_mmap_add_reserved_area( addr, size );
-}
-
-#endif /* __APPLE__ */
-
/***********************************************************************
* check_command_line
*
@@ -315,6 +284,13 @@ static int pre_exec(void)
return 1; /* we have a preloader on x86-64/arm64 */
}
+#elif defined(__APPLE__) && (defined(__i386__) || defined(__x86_64__))
+
+static int pre_exec(void)
+{
+ return 1; /* we have a preloader */
+}
+
#elif (defined(__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__DragonFly__))
static int pre_exec(void)
@@ -360,12 +336,10 @@ int main( int argc, char *argv[] )
}
}
-#ifndef __APPLE__
if (wine_main_preload_info)
-#endif
{
for (i = 0; wine_main_preload_info[i].size; i++)
- reserve_area( wine_main_preload_info[i].addr, wine_main_preload_info[i].size );
+ wine_mmap_add_reserved_area( wine_main_preload_info[i].addr, wine_main_preload_info[i].size );
}
wine_init( argc, argv, error, sizeof(error) );
diff --git a/loader/preloader.c b/loader/preloader.c
index 644244bc30f..f69a43955a8 100644
--- a/loader/preloader.c
+++ b/loader/preloader.c
@@ -4,6 +4,8 @@
* Copyright (C) 1995,96,97,98,99,2000,2001,2002 Free Software Foundation, Inc.
* Copyright (C) 2004 Mike McCormack for CodeWeavers
* Copyright (C) 2004 Alexandre Julliard
+ * Copyright (C) 2017 Michael Müller
+ * Copyright (C) 2017 Sebastian Lackner
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -90,15 +92,14 @@
#ifdef HAVE_SYS_LINK_H
# include <sys/link.h>
#endif
+#ifdef HAVE_MACH_O_LOADER_H
+#include <mach/thread_status.h>
+#include <mach-o/loader.h>
+#include <mach-o/dyld.h>
+#endif
#include "main.h"
-/* ELF definitions */
-#define ELF_PREFERRED_ADDRESS(loader, maplength, mapstartpref) (mapstartpref)
-#define ELF_FIXED_ADDRESS(loader, mapstart) ((void) 0)
-
-#define MAP_BASE_ADDR(l) 0
-
#ifndef MAP_COPY
#define MAP_COPY MAP_PRIVATE
#endif
@@ -108,21 +109,63 @@
static struct wine_preload_info preload_info[] =
{
+/* On macOS, we allocate the low 64k area in two steps because PAGEZERO
+ * might not always be available. Also, the top-down allocations area
+ * on x86_64 is moved because the address on Linux exceeds the maximum
+ * allowed user space limit. Please note that on Linux, it is better to
+ * allocate the low 64k as a single chunk to avoid SELinux warnings on
+ * systems with CONFIG_DEFAULT_MMAP_MIN_ADDR < CONFIG_LSM_MMAP_MIN_ADDR. */
+#ifdef __APPLE__
+#ifdef __i386__
+ { (void *)0x00000000, 0x00001000 }, /* first page */
+ { (void *)0x00001000, 0x0000f000 }, /* low 64k */
+ { (void *)0x00010000, 0x00100000 }, /* DOS area */
+ { (void *)0x00110000, 0x67ef0000 }, /* low memory area */
+ { (void *)0x7f000000, 0x03000000 }, /* top-down allocations + shared heap + virtual heap */
+#else /* __i386__ */
+ { (void *)0x000000010000, 0x00100000 }, /* DOS area */
+ { (void *)0x000000110000, 0x67ef0000 }, /* low memory area */
+ { (void *)0x00007ff00000, 0x000f0000 }, /* shared user data */
+ { (void *)0x7fff40000000, 0x01ff0000 }, /* top-down allocations + virtual heap */
+#endif /* __i386__ */
+#else /* __APPLE__ */
#ifdef __i386__
{ (void *)0x00000000, 0x00010000 }, /* low 64k */
{ (void *)0x00010000, 0x00100000 }, /* DOS area */
{ (void *)0x00110000, 0x67ef0000 }, /* low memory area */
{ (void *)0x7f000000, 0x03000000 }, /* top-down allocations + shared heap + virtual heap */
-#else
+#else /* __i386__ */
{ (void *)0x000000010000, 0x00100000 }, /* DOS area */
{ (void *)0x000000110000, 0x67ef0000 }, /* low memory area */
{ (void *)0x00007ff00000, 0x000f0000 }, /* shared user data */
{ (void *)0x7ffffe000000, 0x01ff0000 }, /* top-down allocations + virtual heap */
-#endif
+#endif /* __i386__ */
+#endif /* __APPLE__ */
{ 0, 0 }, /* PE exe range set with WINEPRELOADRESERVE */
{ 0, 0 } /* end of list */
};
+#ifdef __APPLE__
+
+#ifndef LC_MAIN
+#define LC_MAIN 0x80000028
+struct entry_point_command
+{
+ uint32_t cmd;
+ uint32_t cmdsize;
+ uint64_t entryoff;
+ uint64_t stacksize;
+};
+#endif
+
+#else /* __APPLE__ */
+
+/* ELF definitions */
+#define ELF_PREFERRED_ADDRESS(loader, maplength, mapstartpref) (mapstartpref)
+#define ELF_FIXED_ADDRESS(loader, mapstart) ((void) 0)
+
+#define MAP_BASE_ADDR(l) 0
+
/* debugging */
#undef DUMP_SEGMENTS
#undef DUMP_AUX_INFO
@@ -168,6 +211,8 @@ struct wld_auxv
} a_un;
};
+#endif /* __APPLE__ */
+
/*
* The __bb_init_func is an empty function only called when file is
* compiled with gcc flags "-fprofile-arcs -ftest-coverage". This
@@ -182,6 +227,201 @@ void *__stack_chk_guard = 0;
void __stack_chk_fail_local(void) { return; }
void __stack_chk_fail(void) { return; }
+#ifdef __APPLE__
+#ifdef __i386__
+
+static const size_t page_size = 0x1000;
+static const size_t page_mask = 0xfff;
+#define TARGET_CPU_TYPE CPU_TYPE_X86
+#define TARGET_MH_MAGIC MH_MAGIC
+#define TARGET_SEGMENT_COMMAND LC_SEGMENT
+#define target_mach_header mach_header
+#define target_segment_command segment_command
+#define target_thread_state_t i386_thread_state_t
+#ifdef __DARWIN_UNIX03
+#define target_thread_ip(x) (x)->__eip
+#else
+#define target_thread_ip(x) (x)->eip
+#endif
+
+#define SYSCALL_FUNC( name, nr ) \
+ __ASM_GLOBAL_FUNC( name, \
+ "\tmovl $" #nr ",%eax\n" \
+ "\tint $0x80\n" \
+ "\tjnb 1f\n" \
+ "\tmovl $-1,%eax\n" \
+ "1:\tret\n" )
+
+#define SYSCALL_NOERR( name, nr ) \
+ __ASM_GLOBAL_FUNC( name, \
+ "\tmovl $" #nr ",%eax\n" \
+ "\tint $0x80\n" \
+ "\tret\n" )
+
+__ASM_GLOBAL_FUNC( start,
+ __ASM_CFI("\t.cfi_undefined %eip\n")
+ /* The first 16 bytes are used as a function signature on i386 */
+ "\t.byte 0x6a,0x00\n" /* pushl $0 */
+ "\t.byte 0x89,0xe5\n" /* movl %esp,%ebp */
+ "\t.byte 0x83,0xe4,0xf0\n" /* andl $-16,%esp */
+ "\t.byte 0x83,0xec,0x10\n" /* subl $16,%esp */
+ "\t.byte 0x8b,0x5d,0x04\n" /* movl 4(%ebp),%ebx */
+ "\t.byte 0x89,0x5c,0x24,0x00\n" /* movl %ebx,0(%esp) */
+
+ "\tleal 4(%ebp),%eax\n"
+ "\tmovl %eax,0(%esp)\n" /* stack */
+ "\tleal 8(%esp),%eax\n"
+ "\tmovl %eax,4(%esp)\n" /* &is_unix_thread */
+ "\tmovl $0,(%eax)\n"
+ "\tcall _wld_start\n"
+
+ "\tmovl 4(%ebp),%edi\n"
+ "\tdecl %edi\n" /* argc */
+ "\tleal 12(%ebp),%esi\n" /* argv */
+ "\tleal 4(%esi,%edi,4),%edx\n" /* env */
+ "\tmovl %edx,%ecx\n" /* apple data */
+ "1:\tmovl (%ecx),%ebx\n"
+ "\tadd $4,%ecx\n"
+ "\torl %ebx,%ebx\n"
+ "\tjnz 1b\n"
+
+ "\tcmpl $0,8(%esp)\n"
+ "\tjne 2f\n"
+
+ /* LC_MAIN */
+ "\tmovl %edi,0(%esp)\n" /* argc */
+ "\tmovl %esi,4(%esp)\n" /* argv */
+ "\tmovl %edx,8(%esp)\n" /* env */
+ "\tmovl %ecx,12(%esp)\n" /* apple data */
+ "\tcall *%eax\n"
+ "\tmovl %eax,(%esp)\n"
+ "\tcall _wld_exit\n"
+ "\thlt\n"
+
+ /* LC_UNIXTHREAD */
+ "2:\tmovl (%ecx),%ebx\n"
+ "\tadd $4,%ecx\n"
+ "\torl %ebx,%ebx\n"
+ "\tjnz 2b\n"
+
+ "\tsubl %ebp,%ecx\n"
+ "\tsubl $8,%ecx\n"
+ "\tleal 4(%ebp),%esp\n"
+ "\tsubl %ecx,%esp\n"
+
+ "\tmovl %edi,(%esp)\n" /* argc */
+ "\tleal 4(%esp),%edi\n"
+ "\tshrl $2,%ecx\n"
+ "\tcld\n"
+ "\trep; movsd\n" /* argv, ... */
+
+ "\tmovl $0,%ebp\n"
+ "\tjmpl *%eax\n" )
+
+#elif defined(__x86_64__)
+
+static const size_t page_size = 0x1000;
+static const size_t page_mask = 0xfff;
+#define TARGET_CPU_TYPE CPU_TYPE_X86_64
+#define TARGET_MH_MAGIC MH_MAGIC_64
+#define TARGET_SEGMENT_COMMAND LC_SEGMENT_64
+#define target_mach_header mach_header_64
+#define target_segment_command segment_command_64
+#define target_thread_state_t x86_thread_state64_t
+#ifdef __DARWIN_UNIX03
+#define target_thread_ip(x) (x)->__rip
+#else
+#define target_thread_ip(x) (x)->rip
+#endif
+
+#define SYSCALL_FUNC( name, nr ) \
+ __ASM_GLOBAL_FUNC( name, \
+ "\tmovq %rcx, %r10\n" \
+ "\tmovq $(" #nr "|0x2000000),%rax\n" \
+ "\tsyscall\n" \
+ "\tjnb 1f\n" \
+ "\tmovq $-1,%rax\n" \
+ "1:\tret\n" )
+
+#define SYSCALL_NOERR( name, nr ) \
+ __ASM_GLOBAL_FUNC( name, \
+ "\tmovq %rcx, %r10\n" \
+ "\tmovq $(" #nr "|0x2000000),%rax\n" \
+ "\tsyscall\n" \
+ "\tret\n" )
+
+__ASM_GLOBAL_FUNC( start,
+ __ASM_CFI("\t.cfi_undefined %rip\n")
+ "\tpushq $0\n"
+ "\tmovq %rsp,%rbp\n"
+ "\tandq $-16,%rsp\n"
+ "\tsubq $16,%rsp\n"
+
+ "\tleaq 8(%rbp),%rdi\n" /* stack */
+ "\tmovq %rsp,%rsi\n" /* &is_unix_thread */
+ "\tmovq $0,(%rsi)\n"
+ "\tcall _wld_start\n"
+
+ "\tmovq 8(%rbp),%rdi\n"
+ "\tdec %rdi\n" /* argc */
+ "\tleaq 24(%rbp),%rsi\n" /* argv */
+ "\tleaq 8(%rsi,%rdi,8),%rdx\n" /* env */
+ "\tmovq %rdx,%rcx\n" /* apple data */
+ "1:\tmovq (%rcx),%r8\n"
+ "\taddq $8,%rcx\n"
+ "\torq %r8,%r8\n"
+ "\tjnz 1b\n"
+
+ "\tcmpl $0,0(%rsp)\n"
+ "\tjne 2f\n"
+
+ /* LC_MAIN */
+ "\taddq $16,%rsp\n"
+ "\tcall *%rax\n"
+ "\tmovq %rax,%rdi\n"
+ "\tcall _wld_exit\n"
+ "\thlt\n"
+
+ /* LC_UNIXTHREAD */
+ "2:\tmovq (%rcx),%r8\n"
+ "\taddq $8,%rcx\n"
+ "\torq %r8,%r8\n"
+ "\tjnz 2b\n"
+
+ "\tsubq %rbp,%rcx\n"
+ "\tsubq $16,%rcx\n"
+ "\tleaq 8(%rbp),%rsp\n"
+ "\tsubq %rcx,%rsp\n"
+
+ "\tmovq %rdi,(%rsp)\n" /* argc */
+ "\tleaq 8(%rsp),%rdi\n"
+ "\tshrq $3,%rcx\n"
+ "\tcld\n"
+ "\trep; movsq\n" /* argv, ... */
+
+ "\tmovq $0,%rbp\n"
+ "\tjmpq *%rax\n" )
+
+#else
+#error preloader not implemented for this CPU
+#endif
+
+void wld_exit( int code ) __attribute__((noreturn));
+SYSCALL_NOERR( wld_exit, 1 /* SYS_exit */ );
+
+ssize_t wld_write( int fd, const void *buffer, size_t len );
+SYSCALL_FUNC( wld_write, 4 /* SYS_write */ );
+
+void *wld_mmap( void *start, size_t len, int prot, int flags, int fd, off_t offset );
+SYSCALL_FUNC( wld_mmap, 197 /* SYS_mmap */ );
+
+void *wld_munmap( void *start, size_t len );
+SYSCALL_FUNC( wld_munmap, 73 /* SYS_munmap */ );
+
+int wld_mincore( void *addr, size_t length, unsigned char *vec );
+SYSCALL_FUNC( wld_mincore, 78 /* SYS_mincore */ );
+
+#else /* __APPLE__ */
#ifdef __i386__
/* data for setting up the glibc-style thread-local storage in %gs */
@@ -536,16 +776,17 @@ SYSCALL_NOERR( wld_getegid, 177 /* SYS_getegid */ );
#else
#error preloader not implemented for this CPU
#endif
+#endif /* __APPLE__ */
/* replacement for libc functions */
-static int wld_strcmp( const char *str1, const char *str2 )
+static inline int wld_strcmp( const char *str1, const char *str2 )
{
while (*str1 && (*str1 == *str2)) { str1++; str2++; }
return *str1 - *str2;
}
-static int wld_strncmp( const char *str1, const char *str2, size_t len )
+static inline int wld_strncmp( const char *str1, const char *str2, size_t len )
{
if (len <= 0) return 0;
while ((--len > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
@@ -638,6 +879,8 @@ static __attribute__((noreturn,format(printf,1,2))) void fatal_error(const char
wld_exit(1);
}
+#ifndef __APPLE__
+
#ifdef DUMP_AUX_INFO
/*
* Dump interesting bits of the ELF auxv_t structure that is passed
@@ -1120,6 +1363,8 @@ found:
return (void *)(symtab[idx].st_value + map->l_addr);
}
+#endif /* !__APPLE__ */
+
/*
* preload_reserve
*
@@ -1151,6 +1396,7 @@ static void preload_reserve( const char *str )
/* sanity checks */
if (end <= start) start = end = NULL;
+#ifndef __APPLE__
else if ((char *)end > preloader_start &&
(char *)start <= preloader_end)
{
@@ -1158,6 +1404,7 @@ static void preload_reserve( const char *str )
start, end, preloader_start, preloader_end );
start = end = NULL;
}
+#endif /* !__APPLE__ */
/* check for overlap with low memory areas */
for (i = 0; preload_info[i].size; i++)
@@ -1182,7 +1429,7 @@ error:
}
/* check if address is in one of the reserved ranges */
-static int is_addr_reserved( const void *addr )
+static inline int is_addr_reserved( const void *addr )
{
int i;
@@ -1206,6 +1453,203 @@ static void remove_preload_range( int i )
}
}
+#ifdef __APPLE__
+
+#define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL
+MAKE_FUNCPTR(dlopen);
+MAKE_FUNCPTR(dlsym);
+MAKE_FUNCPTR(_dyld_image_count);
+MAKE_FUNCPTR(_dyld_get_image_header);
+MAKE_FUNCPTR(_dyld_get_image_vmaddr_slide);
+#undef MAKE_FUNCPTR
+
+extern int _dyld_func_lookup( const char *dyld_func_name, void **address );
+
+static struct target_mach_header *find_executable( intptr_t *slide )
+{
+ struct target_mach_header *mh;
+ int i;
+
+ /* skip our own executable */
+ for (i = 1; i < p_dyld_image_count(); i++)
+ {
+ mh = (struct target_mach_header *)p_dyld_get_image_header( i );
+ if (!mh) continue;
+ if (mh->magic != TARGET_MH_MAGIC) continue;
+ if (mh->cputype != TARGET_CPU_TYPE) continue;
+ if (mh->filetype != MH_EXECUTE) continue;
+
+ *slide = p_dyld_get_image_vmaddr_slide( i );
+ return mh;
+ }
+
+ return NULL;
+}
+
+static void *get_entry_point( struct target_mach_header *mh, intptr_t slide, int *unix_thread )
+{
+ struct entry_point_command *entry;
+ target_thread_state_t *state;
+ struct load_command *cmd;
+ int i;
+
+ /* try LC_MAIN first */
+ cmd = (struct load_command *)(mh + 1);
+ for (i = 0; i < mh->ncmds; i++)
+ {
+ if (cmd->cmd == LC_MAIN)
+ {
+ *unix_thread = FALSE;
+ entry = (struct entry_point_command *)cmd;
+ return (char *)mh + entry->entryoff;
+ }
+ cmd = (struct load_command *)((char *)cmd + cmd->cmdsize);
+ }
+
+ /* then try LC_UNIXTHREAD */
+ cmd = (struct load_command *)(mh + 1);
+ for (i = 0; i < mh->ncmds; i++)
+ {
+ if (cmd->cmd == LC_UNIXTHREAD)
+ {
+ *unix_thread = TRUE;
+ state = (target_thread_state_t *)((char *)cmd + 16);
+ return (void *)(target_thread_ip(state) + slide);
+ }
+ cmd = (struct load_command *)((char *)cmd + cmd->cmdsize);
+ }
+
+ return NULL;
+};
+
+static int is_region_empty( struct wine_preload_info *info )
+{
+ unsigned char vec[1024];
+ size_t pos, size, block = 1024 * page_size;
+ int i;
+
+ for (pos = 0; pos < info->size; pos += size)
+ {
+ size = (pos + block <= info->size) ? block : (info->size - pos);
+ if (wld_mincore( (char *)info->addr + pos, size, vec ) == -1)
+ {
+ if (size <= page_size) continue;
+ block = page_size; size = 0; /* retry with smaller block size */
+ }
+ else
+ {
+ for (i = 0; i < size / page_size; i++)
+ if (vec[i] & 1) return 0;
+ }
+ }
+
+ return 1;
+}
+
+static int map_region( struct wine_preload_info *info )
+{
+ int flags = MAP_PRIVATE | MAP_ANON;
+ void *ret;
+
+ if (!info->addr) flags |= MAP_FIXED;
+
+ for (;;)
+ {
+ ret = wld_mmap( info->addr, info->size, PROT_NONE, flags, -1, 0 );
+ if (ret == info->addr) return 1;
+ if (ret != (void *)-1) wld_munmap( ret, info->size );
+ if (flags & MAP_FIXED) break;
+
+ /* Some versions of macOS ignore the address hint passed to mmap -
+ * use mincore() to check if its empty and then use MAP_FIXED */
+ if (!is_region_empty( info )) break;
+ flags |= MAP_FIXED;
+ }
+
+ /* don't warn for zero page */
+ if (info->addr >= (void *)0x1000)
+ wld_printf( "preloader: Warning: failed to reserve range %p-%p\n",
+ info->addr, (char *)info->addr + info->size );
+ return 0;
+}
+
+static inline void get_dyld_func( const char *name, void **func )
+{
+ _dyld_func_lookup( name, func );
+ if (!*func) fatal_error( "Failed to get function pointer for %s\n", name );
+}
+
+#define LOAD_POSIX_DYLD_FUNC(f) get_dyld_func( "__dyld_" #f, (void **)&p##f )
+#define LOAD_MACHO_DYLD_FUNC(f) get_dyld_func( "_" #f, (void **)&p##f )
+
+void *wld_start( void *stack, int *is_unix_thread )
+{
+ struct wine_preload_info builtin_dlls = { (void *)0x7a000000, 0x02000000 };
+ struct wine_preload_info **wine_main_preload_info;
+ char **argv, **p, *reserve = NULL;
+ struct target_mach_header *mh;
+ void *mod, *entry;
+ intptr_t slide;
+ int *pargc, i;
+
+ pargc = stack;
+ argv = (char **)pargc + 1;
+ if (*pargc < 2) fatal_error( "Usage: %s wine_binary [args]\n", argv[0] );
+
+ /* skip over the parameters */
+ p = argv + *pargc + 1;
+
+ /* skip over the environment */
+ while (*p)
+ {
+ static const char res[] = "WINEPRELOADRESERVE=";
+ if (!wld_strncmp( *p, res, sizeof(res)-1 )) reserve = *p + sizeof(res) - 1;
+ p++;
+ }
+
+ /* reserve memory that Wine needs */
+ if (reserve) preload_reserve( reserve );
+ for (i = 0; preload_info[i].size; i++)
+ {
+ if (!map_region( &preload_info[i] ))
+ {
+ remove_preload_range( i );
+ i--;
+ }
+ }
+
+ if (!map_region( &builtin_dlls ))
+ builtin_dlls.size = 0;
+
+ LOAD_POSIX_DYLD_FUNC( dlopen );
+ LOAD_POSIX_DYLD_FUNC( dlsym );
+ LOAD_MACHO_DYLD_FUNC( _dyld_image_count );
+ LOAD_MACHO_DYLD_FUNC( _dyld_get_image_header );
+ LOAD_MACHO_DYLD_FUNC( _dyld_get_image_vmaddr_slide );
+
+ /* load the main binary */
+ if (!(mod = pdlopen( argv[1], RTLD_NOW )))
+ fatal_error( "%s: could not load binary\n", argv[1] );
+
+ if (builtin_dlls.size)
+ wld_munmap( builtin_dlls.addr, builtin_dlls.size );
+
+ /* store pointer to the preload info into the appropriate main binary variable */
+ wine_main_preload_info = pdlsym( mod, "wine_main_preload_info" );
+ if (wine_main_preload_info) *wine_main_preload_info = preload_info;
+ else wld_printf( "wine_main_preload_info not found\n" );
+
+ /* there is no way to translate the dlopen handle to the mach header :-( */
+ if (!(mh = find_executable( &slide )))
+ fatal_error( "%s: could not find mach header\n", argv[1] );
+ if (!(entry = get_entry_point( mh, slide, is_unix_thread )))
+ fatal_error( "%s: could not find entry point\n", argv[1] );
+
+ return entry;
+}
+
+#else /* __APPLE__ */
+
/*
* is_in_preload_range
*
@@ -1374,3 +1818,5 @@ void* wld_start( void **stack )
return (void *)ld_so_map.l_entry;
}
+
+#endif /* __APPLE__ */
--
2.19.2

View File

@ -1,3 +0,0 @@
Fixes: [33159] Implement preloader for Mac OS
Depends: Staging
Depends: configure-Absolute_RPATH

View File

@ -1,47 +0,0 @@
From d6b343754071dbf45bfaba2895d9a3e332d99390 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 21 Mar 2017 23:27:06 +0100
Subject: [PATCH] ntdll: Add stub for RtlGetUnloadEventTraceEx.
---
dlls/ntdll/ntdll.spec | 1 +
dlls/ntdll/rtl.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 28ad231..85897b1 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -681,6 +681,7 @@
# @ stub RtlGetSetBootStatusData
@ stdcall RtlGetThreadErrorMode()
@ stdcall RtlGetUnloadEventTrace()
+@ stdcall RtlGetUnloadEventTraceEx(ptr ptr ptr)
@ stub RtlGetUserInfoHeap
@ stdcall RtlGetVersion(ptr)
@ stdcall -arch=arm,arm64,x86_64 RtlGrowFunctionTable(ptr long)
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c
index e80aa5e..16d2950 100644
--- a/dlls/ntdll/rtl.c
+++ b/dlls/ntdll/rtl.c
@@ -1688,3 +1688,17 @@ NTSTATUS WINAPI RtlQueryPackageIdentity(HANDLE token, WCHAR *fullname, SIZE_T *f
FIXME("(%p, %p, %p, %p, %p, %p): stub\n", token, fullname, fullname_size, appid, appid_size, packaged);
return STATUS_NOT_FOUND;
}
+
+/*********************************************************************
+ * RtlGetUnloadEventTraceEx [NTDLL.@]
+ */
+void WINAPI RtlGetUnloadEventTraceEx(ULONG **size, ULONG **count, VOID **trace)
+{
+ static ULONG dummy_size, dummy_count;
+
+ FIXME("(%p, %p, %p): stub!\n", size, count, trace);
+
+ if (size) *size = &dummy_size;
+ if (count) *count = &dummy_count;
+ if (trace) *trace = NULL;
+}
--
1.9.1

View File

@ -1,2 +0,0 @@
Fixes: [44897] Implement stub for ntdll.RtlGetUnloadEventTraceEx
Depends: ntdll-RtlQueryPackageIdentity

View File

@ -1,4 +1,4 @@
From e923a9b76bc2b65422bff7953be5628b6a2a93d5 Mon Sep 17 00:00:00 2001
From ed9fbc71ad357fe633abb5da5aba1ffddcd09a33 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 4 Nov 2015 07:30:36 +0100
Subject: ntdll: Block signals while executing system APCs. (v2)
@ -19,14 +19,16 @@ other process will wait on the result.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
---
dlls/kernel32/tests/sync.c | 11 ++---------
dlls/ntdll/ntdll_misc.h | 2 +-
dlls/ntdll/server.c | 21 +++++++++++++++++----
2 files changed, 19 insertions(+), 13 deletions(-)
dlls/ntdll/sync.c | 2 +-
4 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c
index 4ac6a99..53e4f81 100644
index f7be51e972..982a6ae105 100644
--- a/dlls/kernel32/tests/sync.c
+++ b/dlls/kernel32/tests/sync.c
@@ -2460,21 +2460,14 @@ static void test_apc_deadlock(void)
@@ -2604,21 +2604,14 @@ static void test_apc_deadlock(void)
result = WaitForSingleObject(event, 1000);
ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
@ -50,22 +52,35 @@ index 4ac6a99..53e4f81 100644
result = ResumeThread(pi.hThread);
ok(result == 1, "expected 1, got %u\n", result);
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 1630978f0a..3c7411e6d6 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -105,7 +105,7 @@ extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct o
data_size_t *ret_len ) DECLSPEC_HIDDEN;
extern NTSTATUS validate_open_object_attributes( const OBJECT_ATTRIBUTES *attr ) DECLSPEC_HIDDEN;
extern int wait_select_reply( void *cookie ) DECLSPEC_HIDDEN;
-extern BOOL invoke_apc( const apc_call_t *call, apc_result_t *result ) DECLSPEC_HIDDEN;
+extern BOOL invoke_apc( const apc_call_t *call, apc_result_t *result, sigset_t *user_sigset ) DECLSPEC_HIDDEN;
/* module handling */
extern LIST_ENTRY tls_links DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c
index 356d631..0450d85 100644
index 38356f4674..8944508f85 100644
--- a/dlls/ntdll/server.c
+++ b/dlls/ntdll/server.c
@@ -374,8 +374,9 @@ static int wait_select_reply( void *cookie )
@@ -385,8 +385,9 @@ int wait_select_reply( void *cookie )
* invoke_apc
*
* Invoke a single APC. Return TRUE if a user APC has been run.
+ * Optionally unblock signals while executing user APCs.
*/
-static BOOL invoke_apc( const apc_call_t *call, apc_result_t *result )
+static BOOL invoke_apc( const apc_call_t *call, apc_result_t *result, sigset_t *user_sigset )
-BOOL invoke_apc( const apc_call_t *call, apc_result_t *result )
+BOOL invoke_apc( const apc_call_t *call, apc_result_t *result, sigset_t *user_sigset )
{
BOOL user_apc = FALSE;
SIZE_T size;
@@ -390,15 +391,19 @@ static BOOL invoke_apc( const apc_call_t *call, apc_result_t *result )
@@ -401,15 +402,19 @@ BOOL invoke_apc( const apc_call_t *call, apc_result_t *result )
case APC_USER:
{
void (WINAPI *func)(ULONG_PTR,ULONG_PTR,ULONG_PTR) = wine_server_get_ptr( call->user.func );
@ -85,7 +100,7 @@ index 356d631..0450d85 100644
user_apc = TRUE;
break;
}
@@ -590,10 +595,12 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT
@@ -595,10 +600,12 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT
obj_handle_t apc_handle = 0;
apc_call_t call;
apc_result_t result;
@ -98,7 +113,7 @@ index 356d631..0450d85 100644
for (;;)
{
SERVER_START_REQ( select )
@@ -610,9 +617,14 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT
@@ -615,9 +622,14 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT
call = reply->call;
}
SERVER_END_REQ;
@ -115,7 +130,7 @@ index 356d631..0450d85 100644
{
/* if we ran a user apc we have to check once more if additional apcs are queued,
* but we don't want to wait */
@@ -625,6 +637,7 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT
@@ -630,6 +642,7 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT
if (size >= sizeof(select_op->signal_and_wait) && select_op->op == SELECT_SIGNAL_AND_WAIT)
size = offsetof( select_op_t, signal_and_wait.signal );
}
@ -123,7 +138,7 @@ index 356d631..0450d85 100644
if (ret == STATUS_TIMEOUT && user_apc) ret = STATUS_USER_APC;
@@ -663,7 +676,7 @@ unsigned int server_queue_process_apc( HANDLE process, const apc_call_t *call, a
@@ -668,7 +681,7 @@ unsigned int server_queue_process_apc( HANDLE process, const apc_call_t *call, a
if (self)
{
@ -132,6 +147,19 @@ index 356d631..0450d85 100644
}
else
{
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c
index 62cb3cd5ec..a304c9dee4 100644
--- a/dlls/ntdll/sync.c
+++ b/dlls/ntdll/sync.c
@@ -2039,7 +2039,7 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size
if (ret == STATUS_PENDING) ret = wait_select_reply( &cookie );
if (ret != STATUS_USER_APC) break;
- if (invoke_apc( &call, &result ))
+ if (invoke_apc( &call, &result, NULL ))
{
/* if we ran a user apc we have to check once more if additional apcs are queued,
* but we don't want to wait */
--
2.6.2
2.14.1

View File

@ -52,7 +52,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "0cc6233e2077c1ef679ecb8bd815d31484868294"
echo "e9231beb865da13941d19eca016a6ccac07cb3f4"
}
# Show version information
@ -172,7 +172,6 @@ patch_enable_all ()
enable_krnl386_exe16__lclose16="$1"
enable_libs_Debug_Channel="$1"
enable_libs_Unicode_Collation="$1"
enable_loader_OSX_Preloader="$1"
enable_mmsystem_dll16_MIDIHDR_Refcount="$1"
enable_mountmgr_DosDevices="$1"
enable_mscoree_CorValidateImage="$1"
@ -220,7 +219,6 @@ patch_enable_all ()
enable_ntdll_Purist_Mode="$1"
enable_ntdll_RtlCaptureStackBackTrace="$1"
enable_ntdll_RtlCreateUserThread="$1"
enable_ntdll_RtlGetUnloadEventTraceEx="$1"
enable_ntdll_RtlQueryPackageIdentity="$1"
enable_ntdll_Serial_Port_Detection="$1"
enable_ntdll_Signal_Handler="$1"
@ -672,9 +670,6 @@ patch_enable ()
libs-Unicode_Collation)
enable_libs_Unicode_Collation="$2"
;;
loader-OSX_Preloader)
enable_loader_OSX_Preloader="$2"
;;
mmsystem.dll16-MIDIHDR_Refcount)
enable_mmsystem_dll16_MIDIHDR_Refcount="$2"
;;
@ -816,9 +811,6 @@ patch_enable ()
ntdll-RtlCreateUserThread)
enable_ntdll_RtlCreateUserThread="$2"
;;
ntdll-RtlGetUnloadEventTraceEx)
enable_ntdll_RtlGetUnloadEventTraceEx="$2"
;;
ntdll-RtlQueryPackageIdentity)
enable_ntdll_RtlQueryPackageIdentity="$2"
;;
@ -1982,13 +1974,6 @@ if test "$enable_ntdll_WRITECOPY" -eq 1; then
enable_ntdll_User_Shared_Data=1
fi
if test "$enable_ntdll_RtlGetUnloadEventTraceEx" -eq 1; then
if test "$enable_ntdll_RtlQueryPackageIdentity" -gt 1; then
abort "Patchset ntdll-RtlQueryPackageIdentity disabled, but ntdll-RtlGetUnloadEventTraceEx depends on that."
fi
enable_ntdll_RtlQueryPackageIdentity=1
fi
if test "$enable_ntdll_RtlCreateUserThread" -eq 1; then
if test "$enable_ntdll_LdrInitializeThunk" -gt 1; then
abort "Patchset ntdll-LdrInitializeThunk disabled, but ntdll-RtlCreateUserThread depends on that."
@ -2088,17 +2073,6 @@ if test "$enable_ntdll_ApiSetMap" -eq 1; then
enable_ntdll_ThreadTime=1
fi
if test "$enable_loader_OSX_Preloader" -eq 1; then
if test "$enable_Staging" -gt 1; then
abort "Patchset Staging disabled, but loader-OSX_Preloader depends on that."
fi
if test "$enable_configure_Absolute_RPATH" -gt 1; then
abort "Patchset configure-Absolute_RPATH disabled, but loader-OSX_Preloader depends on that."
fi
enable_Staging=1
enable_configure_Absolute_RPATH=1
fi
if test "$enable_libs_Unicode_Collation" -eq 1; then
if test "$enable_kernel32_NormalizeString" -gt 1; then
abort "Patchset kernel32-NormalizeString disabled, but libs-Unicode_Collation depends on that."
@ -4066,25 +4040,6 @@ if test "$enable_libs_Unicode_Collation" -eq 1; then
) >> "$patchlist"
fi
# Patchset loader-OSX_Preloader
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * Staging, configure-Absolute_RPATH
# |
# | This patchset fixes the following Wine bugs:
# | * [#33159] Implement preloader for Mac OS
# |
# | Modified files:
# | * Makefile.in, configure.ac, dlls/ntdll/virtual.c, libs/wine/config.c, loader/Makefile.in, loader/main.c,
# | loader/preloader.c
# |
if test "$enable_loader_OSX_Preloader" -eq 1; then
patch_apply loader-OSX_Preloader/0002-loader-Implement-preloader-for-Mac-OS.patch
(
printf '%s\n' '+ { "Sebastian Lackner", "loader: Implement preloader for Mac OS.", 1 },';
) >> "$patchlist"
fi
# Patchset mmsystem.dll16-MIDIHDR_Refcount
# |
# | This patchset fixes the following Wine bugs:
@ -4936,24 +4891,6 @@ if test "$enable_ntdll_RtlQueryPackageIdentity" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-RtlGetUnloadEventTraceEx
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-RtlQueryPackageIdentity
# |
# | This patchset fixes the following Wine bugs:
# | * [#44897] Implement stub for ntdll.RtlGetUnloadEventTraceEx
# |
# | Modified files:
# | * dlls/ntdll/ntdll.spec, dlls/ntdll/rtl.c
# |
if test "$enable_ntdll_RtlGetUnloadEventTraceEx" -eq 1; then
patch_apply ntdll-RtlGetUnloadEventTraceEx/0001-ntdll-Add-stub-for-RtlGetUnloadEventTraceEx.patch
(
printf '%s\n' '+ { "Michael Müller", "ntdll: Add stub for RtlGetUnloadEventTraceEx.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-Serial_Port_Detection
# |
# | This patchset fixes the following Wine bugs:
@ -5111,7 +5048,7 @@ fi
# | * [#14697] Do not allow interruption of system APC in server_select
# |
# | Modified files:
# | * dlls/kernel32/tests/sync.c, dlls/ntdll/server.c
# | * dlls/kernel32/tests/sync.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/server.c, dlls/ntdll/sync.c
# |
if test "$enable_ntdll_Wait_User_APC" -eq 1; then
patch_apply ntdll-Wait_User_APC/0001-ntdll-Block-signals-while-executing-system-APCs.patch
@ -6619,26 +6556,17 @@ fi
# Patchset windowscodecs-Palette_Images
# |
# | Modified files:
# | * dlls/windowscodecs/bmpdecode.c, dlls/windowscodecs/bmpencode.c, dlls/windowscodecs/imgfactory.c,
# | dlls/windowscodecs/info.c, dlls/windowscodecs/pngformat.c, dlls/windowscodecs/regsvr.c,
# | dlls/windowscodecs/tests/converter.c, dlls/windowscodecs/tests/pngformat.c, dlls/windowscodecs/tiffformat.c
# | * dlls/windowscodecs/bmpencode.c, dlls/windowscodecs/info.c, dlls/windowscodecs/regsvr.c,
# | dlls/windowscodecs/tests/converter.c, dlls/windowscodecs/tiffformat.c
# |
if test "$enable_windowscodecs_Palette_Images" -eq 1; then
patch_apply windowscodecs-Palette_Images/0012-windowscodecs-tests-Add-tests-for-encoding-2bpp-4bpp.patch
patch_apply windowscodecs-Palette_Images/0013-windowscodecs-Use-V_UI1-instead-of-V_UNION-to-assign.patch
patch_apply windowscodecs-Palette_Images/0014-windowscodecs-Add-support-for-palette-image-formats-.patch
patch_apply windowscodecs-Palette_Images/0016-windowscodecs-Limit-number-of-colors-in-a-palette-in.patch
patch_apply windowscodecs-Palette_Images/0017-windowscodecs-Add-support-for-palette-image-formats-.patch
patch_apply windowscodecs-Palette_Images/0020-windowscodecs-find_decoder-should-return-an-error-it.patch
patch_apply windowscodecs-Palette_Images/0021-windowscodecs-PNG-decoder-should-return-WINCODEC_ERR.patch
(
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add tests for encoding 2bpp/4bpp images with a palette.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Use V_UI1() instead of V_UNION() to assign a VT_UI1 variant member.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Add support for palette image formats to TIFF encoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Limit number of colors in a palette in BMP decoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Add support for palette image formats to BMP encoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Find_decoder() should return an error it received from the decoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: PNG decoder should return WINCODEC_ERR_UNKNOWNIMAGEFORMAT when image loading fails.", 1 },';
) >> "$patchlist"
fi

View File

@ -1,4 +1,4 @@
From 4807c8a852d4e3d315bf0ddcede36344b3a2045c Mon Sep 17 00:00:00 2001
From 844c14bf47f1e3361e5524a6529f39f635e0f7ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 19 Mar 2015 01:22:34 +0100
Subject: [PATCH] server: Implement support for global and local shared memory
@ -20,22 +20,22 @@ Subject: [PATCH] server: Implement support for global and local shared memory
12 files changed, 215 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 29a92e5e0b..4ad1a825e0 100644
index fe0a37eebd..4e8cbbfcce 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -107,6 +107,7 @@ extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN;
extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret,
data_size_t *ret_len ) DECLSPEC_HIDDEN;
@@ -106,6 +106,7 @@ extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct o
extern NTSTATUS validate_open_object_attributes( const OBJECT_ATTRIBUTES *attr ) DECLSPEC_HIDDEN;
extern int wait_select_reply( void *cookie ) DECLSPEC_HIDDEN;
extern BOOL invoke_apc( const apc_call_t *call, apc_result_t *result ) DECLSPEC_HIDDEN;
+extern void *server_get_shared_memory( HANDLE thread ) DECLSPEC_HIDDEN;
/* module handling */
extern LIST_ENTRY tls_links DECLSPEC_HIDDEN;
diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c
index aca63dcd55..428d2b4d39 100644
index 38356f4674..dd8c862a39 100644
--- a/dlls/ntdll/server.c
+++ b/dlls/ntdll/server.c
@@ -1003,6 +1003,66 @@ done:
@@ -981,6 +981,66 @@ done:
}
@ -102,7 +102,7 @@ index aca63dcd55..428d2b4d39 100644
/***********************************************************************
* wine_server_fd_to_handle (NTDLL.@)
*
@@ -1537,6 +1597,10 @@ size_t server_init_thread( void *entry_point, BOOL *suspend )
@@ -1517,6 +1577,10 @@ size_t server_init_thread( void *entry_point, BOOL *suspend )
}
SERVER_END_REQ;
@ -114,10 +114,10 @@ index aca63dcd55..428d2b4d39 100644
ntdll_get_thread_data()->wow64_redir = is_wow64;
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 72031638b6..5c0497c4fc 100644
index 75b43dd653..d2b74a9cd4 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -615,6 +615,7 @@ void exit_thread( int status )
@@ -456,6 +456,7 @@ void exit_thread( int status )
void WINAPI RtlExitUserThread( ULONG status )
{
static void *prev_teb;
@ -125,7 +125,7 @@ index 72031638b6..5c0497c4fc 100644
sigset_t sigset;
TEB *teb;
@@ -639,6 +640,9 @@ void WINAPI RtlExitUserThread( ULONG status )
@@ -480,6 +481,9 @@ void WINAPI RtlExitUserThread( ULONG status )
LdrShutdownThread();
RtlFreeThreadActivationContextStack();
@ -158,10 +158,10 @@ index d573d1f7ad..9889b95aaf 100644
/* macros for server requests */
diff --git a/include/winternl.h b/include/winternl.h
index e0f3245b09..dc351de561 100644
index 9c8861334a..e7f09681af 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -395,7 +395,7 @@ typedef struct _TEB
@@ -401,7 +401,7 @@ typedef struct _TEB
PVOID Spare4; /* f7c/1750 */
PVOID ReservedForOle; /* f80/1758 */
ULONG WaitingOnLoaderLock; /* f84/1760 */
@ -171,10 +171,10 @@ index e0f3245b09..dc351de561 100644
#ifdef _WIN64
PVOID DeallocationBStore; /* /1788 */
diff --git a/server/fd.c b/server/fd.c
index 15a0b9545c..385590b167 100644
index f2d83b4d58..223bd84626 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -2616,6 +2616,33 @@ DECL_HANDLER(write)
@@ -2564,6 +2564,33 @@ DECL_HANDLER(write)
release_object( fd );
}
@ -209,10 +209,10 @@ index 15a0b9545c..385590b167 100644
DECL_HANDLER(ioctl)
{
diff --git a/server/file.h b/server/file.h
index 36d297d31f..b4b1c780ac 100644
index 6b67866d3f..4db2479eae 100644
--- a/server/file.h
+++ b/server/file.h
@@ -168,6 +168,14 @@ extern struct object *create_mailslot_device( struct object *root, const struct
@@ -165,6 +165,14 @@ extern struct object *create_mailslot_device( struct object *root, const struct
extern struct object *create_unix_device( struct object *root, const struct unicode_str *name,
const char *unix_path );
@ -240,7 +240,7 @@ index 7aed338e96..f984bfc1e3 100644
return 0;
}
diff --git a/server/mapping.c b/server/mapping.c
index 650bdc963f..4eb36ae275 100644
index bc59b21b96..e8cbb7ce10 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -29,8 +29,32 @@
@ -276,7 +276,7 @@ index 650bdc963f..4eb36ae275 100644
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
@@ -190,6 +214,10 @@ static const struct fd_ops mapping_fd_ops =
@@ -187,6 +211,10 @@ static const struct fd_ops mapping_fd_ops =
static size_t page_mask;
@ -287,7 +287,7 @@ index 650bdc963f..4eb36ae275 100644
#define ROUND_SIZE(size) (((size) + page_mask) & ~page_mask)
@@ -261,6 +289,52 @@ static int check_current_dir_for_exec(void)
@@ -258,6 +286,52 @@ static int check_current_dir_for_exec(void)
return (ret != MAP_FAILED);
}
@ -341,7 +341,7 @@ index 650bdc963f..4eb36ae275 100644
static int create_temp_file( file_pos_t size )
{
diff --git a/server/protocol.def b/server/protocol.def
index 00fb838ec2..294e176b11 100644
index 73e0868bed..805abecba6 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -69,6 +69,15 @@ struct request_max_size
@ -360,7 +360,7 @@ index 00fb838ec2..294e176b11 100644
/* debug event data */
typedef union
@@ -1275,6 +1284,12 @@ enum server_fd_type
@@ -1274,6 +1283,12 @@ enum server_fd_type
@END
@ -374,10 +374,10 @@ index 00fb838ec2..294e176b11 100644
@REQ(flush)
async_data_t async; /* async I/O parameters */
diff --git a/server/thread.c b/server/thread.c
index 31b4efd51a..e9d37c2684 100644
index 372882f7ae..1200cc1316 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -202,6 +202,8 @@ static inline void init_thread_structure( struct thread *thread )
@@ -200,6 +200,8 @@ static inline void init_thread_structure( struct thread *thread )
thread->desktop_users = 0;
thread->token = NULL;
thread->exit_poll = NULL;
@ -386,7 +386,7 @@ index 31b4efd51a..e9d37c2684 100644
thread->creation_time = current_time;
thread->exit_time = 0;
@@ -303,6 +305,8 @@ static void cleanup_thread( struct thread *thread )
@@ -328,6 +330,8 @@ static void cleanup_thread( struct thread *thread )
thread->inflight[i].client = thread->inflight[i].server = -1;
}
}
@ -395,7 +395,7 @@ index 31b4efd51a..e9d37c2684 100644
thread->req_data = NULL;
thread->reply_data = NULL;
thread->request_fd = NULL;
@@ -311,6 +315,9 @@ static void cleanup_thread( struct thread *thread )
@@ -336,6 +340,9 @@ static void cleanup_thread( struct thread *thread )
thread->context = NULL;
thread->suspend_context = NULL;
thread->desktop = 0;
@ -406,7 +406,7 @@ index 31b4efd51a..e9d37c2684 100644
/* destroy a thread when its refcount is 0 */
diff --git a/server/thread.h b/server/thread.h
index 5d6d3906a6..7351c420d6 100644
index 1b01c689b3..0fc4c8318b 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -90,6 +90,8 @@ struct thread
@ -419,5 +419,5 @@ index 5d6d3906a6..7351c420d6 100644
struct thread_snapshot
--
2.16.1
2.14.1

View File

@ -1,4 +1,4 @@
From 7e6eb1a23949bddd3538447d5393d4b66d061f1b Mon Sep 17 00:00:00 2001
From 5dcb81fa70edefd525cad861d7cac7706db47871 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 16 Oct 2016 17:34:21 +0800
Subject: windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in JPEG
@ -9,11 +9,11 @@ Subject: windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in JPEG
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/windowscodecs/jpegformat.c b/dlls/windowscodecs/jpegformat.c
index 9ec64e7..7d8beab 100644
index 451d725eb8..a060d569f8 100644
--- a/dlls/windowscodecs/jpegformat.c
+++ b/dlls/windowscodecs/jpegformat.c
@@ -1386,11 +1386,22 @@ static HRESULT WINAPI JpegEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
return E_NOTIMPL;
@@ -1392,11 +1392,22 @@ static HRESULT WINAPI JpegEncoder_GetContainerFormat(IWICBitmapEncoder *iface, G
return S_OK;
}
-static HRESULT WINAPI JpegEncoder_GetEncoderInfo(IWICBitmapEncoder *iface,
@ -40,5 +40,5 @@ index 9ec64e7..7d8beab 100644
static HRESULT WINAPI JpegEncoder_SetColorContexts(IWICBitmapEncoder *iface,
--
2.9.0
2.14.1

View File

@ -1,4 +1,4 @@
From b0dda2778cbd2c33b90f2f500013f48c6fdb0b58 Mon Sep 17 00:00:00 2001
From 00ebc80c47100fe08c13f685ecd5b75fd94c6f13 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 21 Oct 2016 14:36:21 +0800
Subject: windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in the PNG
@ -9,11 +9,11 @@ Subject: windowscodecs: Implement IWICBitmapEncoder::GetEncoderInfo in the PNG
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index 1a409ae..94253d3 100644
index c0e5a59cf9..786d8360e0 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -1936,11 +1936,22 @@ static HRESULT WINAPI PngEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
return E_NOTIMPL;
@@ -1979,11 +1979,22 @@ static HRESULT WINAPI PngEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GU
return S_OK;
}
-static HRESULT WINAPI PngEncoder_GetEncoderInfo(IWICBitmapEncoder *iface,
@ -40,5 +40,5 @@ index 1a409ae..94253d3 100644
static HRESULT WINAPI PngEncoder_SetColorContexts(IWICBitmapEncoder *iface,
--
2.9.0
2.14.1

View File

@ -1,26 +0,0 @@
From 277591557f9b5a0d175460f95bb0be9c7ed93f09 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 20 Sep 2016 17:17:42 +0800
Subject: windowscodecs: Use V_UI1() instead of V_UNION() to assign
a VT_UI1 variant member.
---
dlls/windowscodecs/tiffformat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 6fe3f19677..2238a0eaa8 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -1973,7 +1973,7 @@ static HRESULT WINAPI TiffEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
VARIANT v;
VariantInit(&v);
V_VT(&v) = VT_UI1;
- V_UNION(&v, bVal) = WICTiffCompressionDontCare;
+ V_UI1(&v) = WICTiffCompressionDontCare;
hr = IPropertyBag2_Write(*ppIEncoderOptions, 1, (PROPBAG2 *)opts, &v);
VariantClear(&v);
if (FAILED(hr))
--
2.16.2

View File

@ -1,25 +0,0 @@
From 818ad232038c7b56183f0d20ad4fa93624e09f17 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 23 Sep 2016 20:17:47 +0800
Subject: windowscodecs: Limit number of colors in a palette in BMP decoder.
---
dlls/windowscodecs/bmpdecode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/bmpdecode.c b/dlls/windowscodecs/bmpdecode.c
index 2bcb81e0d6..47f312ffcf 100644
--- a/dlls/windowscodecs/bmpdecode.c
+++ b/dlls/windowscodecs/bmpdecode.c
@@ -271,7 +271,7 @@ static HRESULT WINAPI BmpFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
if (This->bih.bV5ClrUsed == 0)
count = 1 << This->bih.bV5BitCount;
else
- count = This->bih.bV5ClrUsed;
+ count = min(This->bih.bV5ClrUsed, 1 << This->bih.bV5BitCount);
tablesize = sizeof(WICColor) * count;
wiccolors = HeapAlloc(GetProcessHeap(), 0, tablesize);
--
2.16.2

View File

@ -1,122 +0,0 @@
From 0b8859b133017e8f192e5ffb425837ea87c31ddb Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 4 Oct 2016 18:33:40 +0800
Subject: [PATCH] windowscodecs: find_decoder() should return an error it
received from the decoder.
If IWICBitmapDecoderInfo::MatchesPattern() has recognized the decoder by the pattern,
and the called IWICBitmapDecoder::Initialize() has failed, an error should be returned
right away instead of trying next codec. This allows report image format related errors
instead of WINCODEC_ERR_COMPONENTNOTFOUND.
---
dlls/windowscodecs/imgfactory.c | 42 ++++++++++++++++++---------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/dlls/windowscodecs/imgfactory.c b/dlls/windowscodecs/imgfactory.c
index dbcc5f59234..58ef1a02f68 100644
--- a/dlls/windowscodecs/imgfactory.c
+++ b/dlls/windowscodecs/imgfactory.c
@@ -130,22 +130,23 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromFilename(
return hr;
}
-static IWICBitmapDecoder *find_decoder(IStream *pIStream, const GUID *pguidVendor,
- WICDecodeOptions metadataOptions)
+static HRESULT find_decoder(IStream *pIStream, const GUID *pguidVendor,
+ WICDecodeOptions metadataOptions, IWICBitmapDecoder **decoder)
{
IEnumUnknown *enumdecoders;
IUnknown *unkdecoderinfo;
IWICBitmapDecoderInfo *decoderinfo;
- IWICBitmapDecoder *decoder = NULL;
GUID vendor;
HRESULT res;
ULONG num_fetched;
BOOL matches;
+ *decoder = NULL;
+
res = CreateComponentEnumerator(WICDecoder, WICComponentEnumerateDefault, &enumdecoders);
- if (FAILED(res)) return NULL;
+ if (FAILED(res)) return res;
- while (!decoder)
+ while (!*decoder)
{
res = IEnumUnknown_Next(enumdecoders, 1, &unkdecoderinfo, &num_fetched);
@@ -170,18 +171,21 @@ static IWICBitmapDecoder *find_decoder(IStream *pIStream, const GUID *pguidVendo
if (SUCCEEDED(res) && matches)
{
- res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, &decoder);
+ res = IWICBitmapDecoderInfo_CreateInstance(decoderinfo, decoder);
/* FIXME: should use QueryCapability to choose a decoder */
if (SUCCEEDED(res))
{
- res = IWICBitmapDecoder_Initialize(decoder, pIStream, metadataOptions);
+ res = IWICBitmapDecoder_Initialize(*decoder, pIStream, metadataOptions);
if (FAILED(res))
{
- IWICBitmapDecoder_Release(decoder);
- decoder = NULL;
+ IWICBitmapDecoder_Release(*decoder);
+ IWICBitmapDecoderInfo_Release(decoderinfo);
+ IUnknown_Release(unkdecoderinfo);
+ *decoder = NULL;
+ return res;
}
}
}
@@ -197,7 +201,7 @@ static IWICBitmapDecoder *find_decoder(IStream *pIStream, const GUID *pguidVendo
IEnumUnknown_Release(enumdecoders);
- return decoder;
+ return WINCODEC_ERR_COMPONENTNOTFOUND;
}
static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
@@ -211,9 +215,9 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
metadataOptions, ppIDecoder);
if (pguidVendor)
- decoder = find_decoder(pIStream, pguidVendor, metadataOptions);
+ res = find_decoder(pIStream, pguidVendor, metadataOptions, &decoder);
if (!decoder)
- decoder = find_decoder(pIStream, NULL, metadataOptions);
+ res = find_decoder(pIStream, NULL, metadataOptions, &decoder);
if (decoder)
{
@@ -228,17 +232,17 @@ static HRESULT WINAPI ImagingFactory_CreateDecoderFromStream(
BYTE data[4];
ULONG bytesread;
- WARN("failed to load from a stream\n");
+ WARN("failed to load from a stream %#x\n", res);
seek.QuadPart = 0;
- res = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
- if (SUCCEEDED(res))
- res = IStream_Read(pIStream, data, 4, &bytesread);
- if (SUCCEEDED(res))
- WARN("first %i bytes of stream=%x %x %x %x\n", bytesread, data[0], data[1], data[2], data[3]);
+ if (IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL) == S_OK)
+ {
+ if (IStream_Read(pIStream, data, 4, &bytesread) == S_OK)
+ WARN("first %i bytes of stream=%x %x %x %x\n", bytesread, data[0], data[1], data[2], data[3]);
+ }
}
*ppIDecoder = NULL;
- return WINCODEC_ERR_COMPONENTNOTFOUND;
+ return res;
}
}
--
2.19.0

View File

@ -1,63 +0,0 @@
From 828277c6706d2362f49c2a85b5f98ee224c0f059 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Tue, 4 Oct 2016 18:39:40 +0800
Subject: windowscodecs: PNG decoder should return
WINCODEC_ERR_UNKNOWNIMAGEFORMAT when image loading fails.
---
dlls/windowscodecs/pngformat.c | 2 +-
dlls/windowscodecs/tests/pngformat.c | 4 ----
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index 26b5fd52bc..e5ad7876aa 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -622,7 +622,7 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
ppng_destroy_read_struct(&This->png_ptr, &This->info_ptr, &This->end_info);
HeapFree(GetProcessHeap(), 0, row_pointers);
This->png_ptr = NULL;
- hr = E_FAIL;
+ hr = WINCODEC_ERR_UNKNOWNIMAGEFORMAT;
goto end;
}
ppng_set_error_fn(This->png_ptr, jmpbuf, user_error_fn, user_warning_fn);
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c
index 4b84ccebb1..3a0ea28ead 100644
--- a/dlls/windowscodecs/tests/pngformat.c
+++ b/dlls/windowscodecs/tests/pngformat.c
@@ -726,7 +726,6 @@ static void test_color_formats(void)
hr = create_decoder(buf, sizeof(buf), &decoder);
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE))
-todo_wine
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
else
todo_wine_if(td[i].todo_load)
@@ -755,7 +754,6 @@ next_1:
hr = create_decoder(buf, sizeof(buf), &decoder);
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE))
-todo_wine
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
else
todo_wine_if(td[i].todo_load)
@@ -784,7 +782,6 @@ next_2:
hr = create_decoder(buf, sizeof(buf), &decoder);
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE))
-todo_wine
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
else
todo_wine_if(td[i].todo_load)
@@ -812,7 +809,6 @@ next_3:
hr = create_decoder(buf, sizeof(buf), &decoder);
if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE))
-todo_wine
ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr);
else
todo_wine_if(td[i].todo_load)
--
2.16.2