├── .gitattributes ├── .gitignore ├── emulators ├── kegworks │ └── Portfile ├── wine-devel │ ├── files │ │ ├── 0009-ntdll-CW-HACK-25719.patch │ │ ├── 1001-kernelbase-CW-HACK-19610.patch │ │ ├── 0013-ntdll-CW-HACK-22435.patch │ │ ├── 0012-kernelbase-CW-HACK-13322-17315-21883.patch │ │ ├── 0008-ntdll-CW-HACK-24945.patch │ │ ├── 0004-ntdll-CW-HACK-22131.patch │ │ ├── 0015-winemetal-new-stub.patch │ │ ├── 0006-ntdll-CW-Hack-24256.patch │ │ ├── 0007-ntdll-CW-HACK-24265.patch │ │ ├── 0001-ntdll-CW-HACK-18947.patch │ │ ├── 0011-kernelbase-HACK-Add-hack_append_command_line.patch │ │ ├── 0010-ntdll-HACK-Winehq-Bug-56441.patch │ │ ├── 0005-ntdll-CW-HACK-23427.patch │ │ ├── 0002-ntdll-CW-HACK-20186.patch │ │ ├── 0014-winemac-DXMT-export.patch │ │ └── 0003-wow64cpu-CW-HACK-20760.patch │ └── Portfile ├── crossovertricks │ ├── Portfile │ └── files │ │ └── crossovertricks ├── sikarugir │ └── Portfile ├── winetricks │ └── Portfile ├── wine-stable │ ├── files │ │ ├── MR7328.diff │ │ ├── MR6866.diff │ │ └── 0001-winehq_macos_hacks.diff │ └── Portfile └── crossover │ └── Portfile ├── devel ├── game-porting-toolkit │ ├── files │ │ ├── gameportingtoolkit-no-hud │ │ ├── gameportingtoolkit-no-esync │ │ ├── gameportingtoolkit │ │ ├── 1002-ntdll-d3dmetal-env.diff │ │ ├── 1001-configure-remove-cross_compiling-check.diff │ │ └── 1003-build_fixes.diff │ └── Portfile ├── libinotify │ └── Portfile └── MacOSX.sdk │ └── Portfile ├── .github └── FUNDING.yml ├── multimedia ├── gstreamer.framework │ └── Portfile ├── gstreamer-development │ └── Portfile └── gstreamer-runtime │ └── Portfile ├── README.md └── cross ├── mingw-w64-pkgconfig └── Portfile ├── mingw-w64-wine-gecko └── _Portfile └── mingw-w64-wine-mono └── Portfile /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /PortIndex 2 | /PortIndex.quick 3 | 4 | */*/work 5 | 6 | Portfile~ 7 | *.tcl~ 8 | *.diff~ 9 | *.patch~ 10 | *.DS_Store 11 | -------------------------------------------------------------------------------- /emulators/kegworks/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup obsolete 1.0 5 | 6 | name kegworks 7 | version 2.0.4 8 | revision 1 9 | replaced_by sikarugir 10 | categories emulators 11 | -------------------------------------------------------------------------------- /devel/game-porting-toolkit/files/gameportingtoolkit-no-hud: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | if [ -z "$1" ]; then 4 | echo "Usage: $0 " 5 | exit 1 6 | fi 7 | 8 | exe_path="cmd.exe" 9 | if [ ! -z "$2" ]; then 10 | exe_path="$2" 11 | fi 12 | 13 | export WINEDLLPATH_PREPEND="@@PREFIX@@/libexec/d3dmetal/wine" 14 | export WINEESYNC="1" 15 | export WINEPREFIX="$1" 16 | exec @@PREFIX@@/libexec/game-porting-toolkit/bin/wine64 "$exe_path" 2>&1 | grep "D3DM" 17 | exit 1 18 | -------------------------------------------------------------------------------- /devel/game-porting-toolkit/files/gameportingtoolkit-no-esync: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | if [ -z "$1" ]; then 4 | echo "Usage: $0 " 5 | exit 1 6 | fi 7 | 8 | exe_path="cmd.exe" 9 | if [ ! -z "$2" ]; then 10 | exe_path="$2" 11 | fi 12 | 13 | export WINEDLLPATH_PREPEND="@@PREFIX@@/libexec/d3dmetal/wine" 14 | export MTL_HUD_ENABLED="1" 15 | export WINEPREFIX="$1" 16 | exec @@PREFIX@@/libexec/game-porting-toolkit/bin/wine64 "$exe_path" 2>&1 | grep "D3DM" 17 | exit 1 18 | -------------------------------------------------------------------------------- /devel/game-porting-toolkit/files/gameportingtoolkit: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | if [ -z "$1" ]; then 4 | echo "Usage: $0 " 5 | exit 1 6 | fi 7 | 8 | exe_path="cmd.exe" 9 | if [ ! -z "$2" ]; then 10 | exe_path="$2" 11 | fi 12 | 13 | export WINEDLLPATH_PREPEND="@@PREFIX@@/libexec/d3dmetal/wine" 14 | export MTL_HUD_ENABLED=1 15 | export WINEESYNC=1 16 | export WINEPREFIX="$1" 17 | exec @@PREFIX@@/libexec/game-porting-toolkit/bin/wine64 "$exe_path" 2>&1 | grep "D3DM" 18 | exit 1 19 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | #github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | #patreon: # Replace with a single Patreon username 5 | #open_collective: # Replace with a single Open Collective username 6 | #ko_fi: # Replace with a single Ko-fi username 7 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | #liberapay: # Replace with a single Liberapay username 10 | #issuehunt: # Replace with a single IssueHunt username 11 | #otechie: # Replace with a single Otechie username 12 | custom: paypal.me/gcenx 13 | ko_fi: gcenx 14 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0009-ntdll-CW-HACK-25719.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c 2 | index 94d48c0fb47..9598e6523f7 100644 3 | --- a/dlls/ntdll/unix/virtual.c 4 | +++ b/dlls/ntdll/unix/virtual.c 5 | @@ -4589,6 +4589,16 @@ NTSTATUS virtual_handle_fault( EXCEPTION_RECORD *rec, void *stack ) 6 | ret = STATUS_SUCCESS; 7 | goto done; 8 | } 9 | + 10 | + /* CW Hack 25719 */ 11 | + if (err == EXCEPTION_EXECUTE_FAULT && (get_unix_prot( vprot ) & PROT_EXEC)) 12 | + { 13 | + FIXME( "HACK: exec fault on executable page, addr %p\n", addr ); 14 | + mprotect_range( page, page_size, 0, VPROT_EXEC ); 15 | + mprotect_range( page, page_size, VPROT_EXEC, 0 ); 16 | + ret = STATUS_SUCCESS; 17 | + goto done; 18 | + } 19 | #endif 20 | 21 | if (!is_inside_signal_stack( stack ) && (vprot & VPROT_GUARD)) 22 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/1001-kernelbase-CW-HACK-19610.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c 2 | index 8394182e7ff..ef47ed2946f 100644 3 | --- a/dlls/kernelbase/process.c 4 | +++ b/dlls/kernelbase/process.c 5 | @@ -511,6 +511,9 @@ static const WCHAR *hack_append_command_line( const WCHAR *cmd, const WCHAR *cmd 6 | * CROSSOVER HACK: bug 21883 7 | * Insert --disable-gpu as well. 8 | */ 9 | + /* CROSSOVER HACK: bug 19610 10 | + * Add --in-process-gpu to Battle.net. 11 | + */ 12 | 13 | static const struct 14 | { 15 | @@ -522,6 +525,7 @@ static const WCHAR *hack_append_command_line( const WCHAR *cmd, const WCHAR *cmd 16 | options[] = 17 | { 18 | {L"steamwebhelper.exe", L" --no-sandbox --in-process-gpu --disable-gpu", NULL, L"--type=crashpad-handler"}, 19 | + {L"Battle.net.exe", L" --in-process-gpu --use-gl=swiftshader", NULL, NULL}, 20 | }; 21 | unsigned int i; 22 | -------------------------------------------------------------------------------- /emulators/crossovertricks/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | 5 | name crossovertricks 6 | version 0.0.2 7 | categories emulators 8 | maintainers {@gcenx} 9 | 10 | supported_archs noarch 11 | description A wrapper that does winetricks things for CrossOver 12 | 13 | long_description ${description} 14 | 15 | distfiles 16 | patchfiles 17 | use_configure no 18 | depends_run port:crossover \ 19 | port:winetricks 20 | 21 | build { 22 | copy ${filespath}/crossovertricks ${workpath}/crossovertricks 23 | reinplace -q s|@@APPLICATIONS@@|${applications_dir}|g ${workpath}/crossovertricks 24 | } 25 | 26 | destroot { 27 | copy ${workpath}/crossovertricks ${destroot}${prefix}/bin/crossovertricks 28 | } 29 | 30 | livecheck.type none 31 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0013-ntdll-CW-HACK-22435.patch: -------------------------------------------------------------------------------- 1 | extracted from crossover-sources-23.5.0 2 | 3 | diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c 4 | index cb700dd80e8..a6222009f5a 100644 5 | --- a/dlls/ntdll/unix/loader.c 6 | +++ b/dlls/ntdll/unix/loader.c 7 | @@ -361,13 +361,22 @@ static WORD get_alt_machine( WORD machine ) 8 | static void set_dll_path(void) 9 | { 10 | char *p, *path = getenv( "WINEDLLPATH" ); 11 | + char *path_prepend = getenv( "WINEDLLPATH_PREPEND" ); 12 | int i, count = 0; 13 | 14 | - if (path) for (p = path, count = 1; *p; p++) if (*p == ':') count++; 15 | + if (path) for (p = path, count++; *p; p++) if (*p == ':') count++; 16 | + if (path_prepend) for (p = path_prepend, count++; *p; p++) if (*p == ':') count++; 17 | 18 | dll_paths = malloc( (count + 2) * sizeof(*dll_paths) ); 19 | count = 0; 20 | 21 | + if (path_prepend) 22 | + { 23 | + path_prepend = strdup( path_prepend ); 24 | + for (p = strtok( path_prepend, ":" ); p; p = strtok( NULL, ":" )) dll_paths[count++] = strdup( p ); 25 | + free( path_prepend ); 26 | + } 27 | + 28 | if (!build_dir) dll_paths[count++] = dll_dir; 29 | 30 | if (path) 31 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0012-kernelbase-CW-HACK-13322-17315-21883.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c 2 | index 4bec68a0af3..8394182e7ff 100644 3 | --- a/dlls/kernelbase/process.c 4 | +++ b/dlls/kernelbase/process.c 5 | @@ -502,6 +502,16 @@ done: 6 | 7 | static const WCHAR *hack_append_command_line( const WCHAR *cmd, const WCHAR *cmd_line ) 8 | { 9 | + /* CROSSOVER HACK: bug 13322 (winehq bug 39403) 10 | + * Insert --no-sandbox in command line of Steam's web helper process to 11 | + * work around rendering problems. 12 | + * CROSSOVER HACK: bug 17315 13 | + * Insert --in-process-gpu in command line of Steam's web helper process to 14 | + * work around page rendering problems. 15 | + * CROSSOVER HACK: bug 21883 16 | + * Insert --disable-gpu as well. 17 | + */ 18 | + 19 | static const struct 20 | { 21 | const WCHAR *exe_name; 22 | @@ -511,6 +521,7 @@ static const WCHAR *hack_append_command_line( const WCHAR *cmd, const WCHAR *cmd 23 | } 24 | options[] = 25 | { 26 | + {L"steamwebhelper.exe", L" --no-sandbox --in-process-gpu --disable-gpu", NULL, L"--type=crashpad-handler"}, 27 | }; 28 | unsigned int i; 29 | 30 | -------------------------------------------------------------------------------- /devel/game-porting-toolkit/files/1002-ntdll-d3dmetal-env.diff: -------------------------------------------------------------------------------- 1 | dlls/ntdll/unix/loader.c | 11 ++++++++++- 2 | 1 file changed, 10 insertions(+), 1 deletion(-) 3 | 4 | diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c 5 | index d5901d86..676799c9 100644 6 | --- a/dlls/ntdll/unix/loader.c 7 | +++ b/dlls/ntdll/unix/loader.c 8 | @@ -596,13 +596,22 @@ static const char *get_pe_dir( WORD machine ) 9 | static void set_dll_path(void) 10 | { 11 | char *p, *path = getenv( "WINEDLLPATH" ); 12 | + char *path_prepend = getenv( "WINEDLLPATH_PREPEND" ); 13 | int i, count = 0; 14 | 15 | - if (path) for (p = path, count = 1; *p; p++) if (*p == ':') count++; 16 | + if (path) for (p = path, count++; *p; p++) if (*p == ':') count++; 17 | + if (path_prepend) for (p = path_prepend, count++; *p; p++) if (*p == ':') count++; 18 | 19 | dll_paths = malloc( (count + 2) * sizeof(*dll_paths) ); 20 | count = 0; 21 | 22 | + if (path_prepend) 23 | + { 24 | + path_prepend = strdup( path_prepend ); 25 | + for (p = strtok( path_prepend, ":" ); p; p = strtok( NULL, ":" )) dll_paths[count++] = strdup( p ); 26 | + free( path_prepend ); 27 | + } 28 | + 29 | if (!build_dir) dll_paths[count++] = dll_dir; 30 | 31 | if (path) 32 | -------------------------------------------------------------------------------- /devel/libinotify/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup github 1.0 5 | PortGroup muniversal 1.1 6 | 7 | github.setup libinotify-kqueue libinotify-kqueue 20240724 8 | github.tarball_from archive 9 | # Version must use the following scheme YYYYMMDD 10 | version 20240724 11 | name libinotify 12 | 13 | categories graphics 14 | maintainers {@gcenx} 15 | license MIT 16 | 17 | description Inotify shim for macOS and BSD 18 | long_description {*}${description} 19 | 20 | checksums rmd160 fd1cd0d82b4e0f8e013a67cc27802616535709fd \ 21 | sha256 120398ff95336d04f3ce7ac820e0490059625976264100dcc9af9d11e992b0ca \ 22 | size 77857 23 | 24 | use_autoreconf yes 25 | 26 | configure.checks.implicit_function_declaration.whitelist-append \ 27 | pthread_barrier_init \ 28 | pthread_barrier_wait \ 29 | pthread_barrier_destroy 30 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0008-ntdll-CW-HACK-24945.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c 2 | index 964ce7bcf68..94d48c0fb47 100644 3 | --- a/dlls/ntdll/unix/virtual.c 4 | +++ b/dlls/ntdll/unix/virtual.c 5 | @@ -4578,6 +4578,17 @@ NTSTATUS virtual_handle_fault( EXCEPTION_RECORD *rec, void *stack ) 6 | WARN( "treating read fault in a readable page as a write fault, addr %p\n", addr ); 7 | err = EXCEPTION_WRITE_FAULT; 8 | } 9 | + 10 | + /* CW Hack 24945 */ 11 | + if (err == EXCEPTION_WRITE_FAULT && 12 | + ((get_unix_prot( vprot ) & (PROT_WRITE | PROT_EXEC)) == (PROT_WRITE | PROT_EXEC))) 13 | + { 14 | + FIXME( "HACK: write fault on a w|x page, addr %p\n", addr ); 15 | + mprotect_range( page, page_size, 0, VPROT_EXEC ); 16 | + mprotect_range( page, page_size, VPROT_EXEC, 0 ); 17 | + ret = STATUS_SUCCESS; 18 | + goto done; 19 | + } 20 | #endif 21 | 22 | if (!is_inside_signal_stack( stack ) && (vprot & VPROT_GUARD)) 23 | @@ -4614,6 +4625,10 @@ NTSTATUS virtual_handle_fault( EXCEPTION_RECORD *rec, void *stack ) 24 | ret = STATUS_SUCCESS; 25 | } 26 | } 27 | + 28 | +#ifdef __APPLE__ 29 | +done: 30 | +#endif 31 | mutex_unlock( &virtual_mutex ); 32 | rec->ExceptionCode = ret; 33 | return ret; 34 | -------------------------------------------------------------------------------- /multimedia/gstreamer.framework/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup github 1.0 5 | 6 | github.setup Sikarugir-App gstreamer 1.26.8 7 | github.tarball_from releases 8 | revision 0 9 | 10 | name ${github.project}.framework 11 | categories multimedia 12 | maintainers {@Gcenx} 13 | description GStreamer is a streaming media framework 14 | long_description {*}${description} 15 | 16 | supported_archs x86_64 17 | platforms {darwin >= 17} 18 | license LGPL-2+ 19 | 20 | homepage https://gstreamer.freedesktop.org 21 | dist_subdir ${github.project} 22 | 23 | distname ${name}-1.0-${github.version}-x86_64 24 | use_xz yes 25 | 26 | checksums rmd160 0715c1a8a8c5549760705f909d8bce33ca3b283d \ 27 | sha256 589fe931511aa25a4156cb05cd2391626a4ea6c0d9622da8bb1a21a1c4e91f8f \ 28 | size 154783124 29 | 30 | use_configure no 31 | build {} 32 | 33 | destroot { 34 | copy ${workpath}/GStreamer.framework ${destroot}${frameworks_dir} 35 | system -W ${destroot}${frameworks_dir} \ 36 | "codesign --force --deep --sign - GStreamer.framework" 37 | } 38 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0004-ntdll-CW-HACK-22131.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c 2 | index 7cdf148488d..74ae5273941 100644 3 | --- a/dlls/ntdll/unix/signal_x86_64.c 4 | +++ b/dlls/ntdll/unix/signal_x86_64.c 5 | @@ -1148,7 +1148,11 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) 6 | ret = set_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_AMD64 ); 7 | #ifdef __APPLE__ 8 | if ((flags & CONTEXT_DEBUG_REGISTERS) && (ret == STATUS_UNSUCCESSFUL)) 9 | - WARN_(seh)( "Setting debug registers is not supported under Rosetta\n" ); 10 | + { 11 | + /* CW HACK 22131 */ 12 | + WARN_(seh)( "Setting debug registers is not supported under Rosetta, faking success\n" ); 13 | + ret = STATUS_SUCCESS; 14 | + } 15 | #endif 16 | if (ret || !self) return ret; 17 | if (flags & CONTEXT_DEBUG_REGISTERS) 18 | @@ -1371,6 +1375,14 @@ NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size ) 19 | if (!self) 20 | { 21 | NTSTATUS ret = set_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_I386 ); 22 | +#ifdef __APPLE__ 23 | + if ((flags & CONTEXT_DEBUG_REGISTERS) && (ret == STATUS_UNSUCCESSFUL)) 24 | + { 25 | + /* CW HACK 22131 */ 26 | + WARN_(seh)( "Setting debug registers is not supported under Rosetta, faking success\n" ); 27 | + ret = STATUS_SUCCESS; 28 | + } 29 | +#endif 30 | if (ret || !self) return ret; 31 | if (flags & CONTEXT_I386_DEBUG_REGISTERS) 32 | { 33 | -------------------------------------------------------------------------------- /emulators/sikarugir/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup github 1.0 5 | 6 | github.setup Sikarugir-App Creator 1.0 v 7 | github.tarball_from releases 8 | revision 0 9 | name sikarugir 10 | platforms {darwin >= 19} 11 | # Winery is LGPL-2.1 but will be changed later once the new codebase it finished 12 | license LGPL-2.1 13 | categories emulators 14 | 15 | supported_archs x86_64 16 | maintainers {@Gcenx} 17 | homepage https://github.com/Sikarugir-App/Sikarugir/ 18 | 19 | description ${name} is a user-friendly tool used to make ports of Microsoft Windows software to Apple's macOS. 20 | long_description {*}${description} 21 | 22 | distname Creator-v${version} 23 | use_xz yes 24 | 25 | checksums rmd160 621334417ff0480174168073248450b2bb5cbf3d \ 26 | sha256 f98d737bf4d1b5274e4a74102b8995ab57fcbb408343cb5d631a09cc4d96cb0f \ 27 | size 1462908 28 | 29 | use_configure no 30 | build {} 31 | 32 | destroot { 33 | move "${workpath}/Creator.app" "${destroot}${applications_dir}/Sikarugir Creator.app" 34 | system -W ${destroot}${applications_dir} "/usr/bin/codesign --deep --force --sign - 'Sikarugir Creator.app'" 35 | } 36 | 37 | pre-activate { 38 | if {${os.major} == 19 && ${os.minor} < 4 && ${os.platform} eq "darwin"} { 39 | ui_error "You must first update to macOS 10.15.4." 40 | return -code error "You must first update to macOS 10.15.4." 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /emulators/crossovertricks/files/crossovertricks: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Wrapper script for winetricks compatability 4 | # 5 | # Copyright (C) 2021 Dean M Greer 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2.1 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 | # 21 | 22 | 23 | export CX_INSTALL="@@APPLICATIONS@@/CrossOver.app" 24 | export CX_PATH="${CX_INSTALL}/Contents/SharedSupport/CrossOver" 25 | export CX_BOTTLE="${CX_BOTTLE:-default}" 26 | export CX_BOTTLE_PATH="${CX_BOTTLE_PATH:-$HOME/Library/Application Support/CrossOver/Bottles}" 27 | 28 | if [ ! -d "${CX_BOTTLE_PATH}/${CX_BOTTLE}" ]; then 29 | echo "" 30 | echo "Please set \$CX_BOTTLE env to your CrossOver Bottle" 31 | echo "Or set your desired bottle to default from the CrossOver UI" 32 | exit 33 | fi 34 | 35 | export WINE="${CX_PATH}/bin/wine" 36 | export WINESERVER="${WINE}server" 37 | export WINEPREFIX="${CX_BOTTLE_PATH}/${CX_BOTTLE}" 38 | export WINETRICKS_WINE_VERSION=$(sed -n '2p' "${CX_PATH}/share/wine/wine.inf" | tr ' ' '\a' | awk -F'\a' '{print $4}') 39 | export WINEDEBUG=-all 40 | 41 | exec winetricks "${@}" 42 | -------------------------------------------------------------------------------- /emulators/winetricks/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup github 1.0 5 | 6 | github.setup Sikarugir-App winetricks 20251121 7 | github.tarball_from archive 8 | 9 | revision 0 10 | platforms {darwin any} 11 | categories emulators 12 | license LGPL-2.1+ 13 | supported_archs noarch 14 | maintainers {@gcenx} 15 | homepage http://www.winetricks.org/ 16 | 17 | description downloads and installs various redistributable \ 18 | runtime libraries 19 | 20 | long_description ${subport} can help you prepare your system for Windows \ 21 | applications that mistakenly assume all users' \ 22 | systems have all the needed redistributable runtime \ 23 | libraries or fonts. 24 | 25 | checksums rmd160 e5542f14cbc8a1ac194c87114350013bb7be9ad6 \ 26 | sha256 72b95406a8cd615ea06916aaec01db49233042823be17eb0134a26a08ff28540 \ 27 | size 688756 28 | 29 | depends_run bin:curl:curl \ 30 | port:cabextract \ 31 | path:bin/openssl:openssl \ 32 | port:p7zip \ 33 | bin:unzip:unzip 34 | 35 | use_configure no 36 | build {} 37 | 38 | destroot.args PREFIX=${prefix} 39 | 40 | post-destroot { 41 | set docdir ${prefix}/share/doc/${subport} 42 | xinstall -d ${destroot}${docdir} 43 | xinstall -m 0644 -W ${worksrcpath} COPYING README.md ${destroot}${docdir} 44 | } 45 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0015-winemetal-new-stub.patch: -------------------------------------------------------------------------------- 1 | diff --git a/configure b/configure 2 | index f282bb34d91..6d90a87985a 100755 3 | --- a/configure 4 | +++ b/configure 5 | @@ -1544,6 +1544,7 @@ enable_winegstreamer 6 | enable_winehid_sys 7 | enable_winemac_drv 8 | enable_winemapi 9 | +enable_winemetal 10 | enable_wineoss_drv 11 | enable_wineps_drv 12 | enable_winepulse_drv 13 | @@ -23213,6 +23214,7 @@ wine_fn_config_makefile dlls/winegstreamer enable_winegstreamer 14 | wine_fn_config_makefile dlls/winehid.sys enable_winehid_sys 15 | wine_fn_config_makefile dlls/winemac.drv enable_winemac_drv 16 | wine_fn_config_makefile dlls/winemapi enable_winemapi 17 | +wine_fn_config_makefile dlls/winemetal enable_winemetal 18 | wine_fn_config_makefile dlls/wineoss.drv enable_wineoss_drv 19 | wine_fn_config_makefile dlls/wineps.drv enable_wineps_drv 20 | wine_fn_config_makefile dlls/wineps16.drv16 enable_win16 21 | diff --git a/configure.ac b/configure.ac 22 | index 624e6ce6b6b..8514c579a5d 100644 23 | --- a/configure.ac 24 | +++ b/configure.ac 25 | @@ -3358,6 +3358,7 @@ WINE_CONFIG_MAKEFILE(dlls/winegstreamer) 26 | WINE_CONFIG_MAKEFILE(dlls/winehid.sys) 27 | WINE_CONFIG_MAKEFILE(dlls/winemac.drv) 28 | WINE_CONFIG_MAKEFILE(dlls/winemapi) 29 | +WINE_CONFIG_MAKEFILE(dlls/winemetal) 30 | WINE_CONFIG_MAKEFILE(dlls/wineoss.drv) 31 | WINE_CONFIG_MAKEFILE(dlls/wineps.drv) 32 | WINE_CONFIG_MAKEFILE(dlls/wineps16.drv16) 33 | diff --git a/dlls/winemetal/Makefile.in b/dlls/winemetal/Makefile.in 34 | new file mode 100644 35 | index 00000000000..5f8ab6f673a 36 | --- /dev/null 37 | +++ b/dlls/winemetal/Makefile.in 38 | @@ -0,0 +1 @@ 39 | +MODULE = winemetal.dll 40 | diff --git a/dlls/winemetal/winemetal.spec b/dlls/winemetal/winemetal.spec 41 | new file mode 100644 42 | index 00000000000..9ccfb1a000b 43 | --- /dev/null 44 | +++ b/dlls/winemetal/winemetal.spec 45 | @@ -0,0 +1 @@ 46 | +@ stub WineMetalEntry 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # macports-wine 2 | A MacPorts overlay that provides recent versions of wine. 3 | 4 |
5 | 6 | ## This repository provides 7 | - `CrossOver` *(v25.1.1)* 8 | - `crossovertricks` *(winetricks wrapper for CrossOver)* 9 | - `game-porting-toolkit` *(v1.1)* 10 | - `gstreamer.framework` *(v1.26.8)* 11 | - `gstreamer-runtime` *(v1.26.8)* 12 | - `gstreamer-development` *(v1.26.8)* 13 | - `libinotify` *(v20240724)* 14 | - `MacOSX.sdk` *(Multiple MacOSX SDKs)* 15 | - `mingw-w64-pkgconfig` 16 | - `wine-stable` *(v10.0)* 17 | - `wine-devel` *(v11.0-rc3)* 18 | - `wine-staging` *(v11.0-rc3)* 19 | - `winetricks` *(v20251121)* 20 | - `sikarugir` *(v1.0)* 21 | 22 |
23 | 24 | ## How to use this repository 25 | After installing MacPorts you need a modern version of `git`\ 26 | git clone the repository into /opt then follow [4.6. Local Portfile Repositories](https://guide.macports.org/#development.local-repositories)\ 27 | Next run `port -v sync` you can now install any of the provided Ports. 28 | 29 |
30 | 31 | ### macOS Mojave 32 | Add the following into `/opt/local/etc/macports/macports.conf` 33 | ``` 34 | macosx_deployment_target 10.13 35 | macosx_sdk_version 10.13 36 | ``` 37 | This enables the `i386` & `x86_64` architectures thus enabling the `+universal` flag\ 38 | Next place a copy of the `MacOSX10.13.sdk` into `/Library/Developer/CommandLineTools/SDKs/` 39 | 40 |
41 | 42 | ### Apple Silicon systems, force x86_64 43 | Due to macports-ports bugs we need to force MacPorts to only install for x86_64 44 | > echo "build_arch x86_64" | sudo tee -a /opt/local/etc/macports/macports.conf >/dev/null 45 | 46 |
47 | 48 | ### Prior project history 49 | You can find the prior commit history [here](https://github.com/Gcenx/macports-wine/tree/master) 50 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0006-ntdll-CW-Hack-24256.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c 2 | index d298afe05de..82c9821a949 100644 3 | --- a/dlls/ntdll/unix/signal_x86_64.c 4 | +++ b/dlls/ntdll/unix/signal_x86_64.c 5 | @@ -89,6 +89,10 @@ WINE_DECLARE_DEBUG_CHANNEL(seh); 6 | #include "dwarf.h" 7 | 8 | #ifdef __APPLE__ 9 | +/* CW Hack 24256 */ 10 | +#include 11 | +static BOOL is_rosetta2; 12 | + 13 | /* CW Hack 23427 */ 14 | static BOOL sequoia_or_later = FALSE; 15 | #endif 16 | @@ -1013,6 +1017,13 @@ static void save_context( struct xcontext *xcontext, const ucontext_t *sigcontex 17 | 18 | context->ContextFlags |= CONTEXT_FLOATING_POINT; 19 | memcpy( &context->FltSave, FPU_sig(sigcontext), sizeof(context->FltSave) ); 20 | +#ifdef __APPLE__ 21 | + /* CW Hack 24256: mxcsr in signal contexts is incorrect in Rosetta. 22 | + In Rosetta only, the actual value of the register from within the 23 | + handler is correct (on Intel it has some default value). */ 24 | + if (is_rosetta2) 25 | + __asm__ volatile( "stmxcsr %0" : "=m" (context->FltSave.MxCsr) ); 26 | +#endif 27 | context->MxCsr = context->FltSave.MxCsr; 28 | if (xstate_extended_features && (xs = XState_sig(FPU_sig(sigcontext)))) 29 | { 30 | @@ -2845,6 +2856,17 @@ void signal_init_process(void) 31 | signal_alloc_thread( NtCurrentTeb() ); 32 | 33 | #ifdef __APPLE__ 34 | + /* CW Hack 24256: We need the value of sysctl.proc_translated in signal 35 | + handlers but sysctl[byname] is not signal-safe. */ 36 | + { 37 | + int ret = 0; 38 | + size_t size = sizeof(ret); 39 | + if (sysctlbyname( "sysctl.proc_translated", &ret, &size, NULL, 0 ) == -1) 40 | + is_rosetta2 = 0; 41 | + else 42 | + is_rosetta2 = ret; 43 | + } 44 | + 45 | /* CW Hack 23427: __builtin_available presumably isn't signal-safe. */ 46 | if (__builtin_available( macOS 15.0, * )) 47 | sequoia_or_later = TRUE; 48 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0007-ntdll-CW-HACK-24265.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c 2 | index 82c9821a949..1d0a1461fb2 100644 3 | --- a/dlls/ntdll/unix/signal_x86_64.c 4 | +++ b/dlls/ntdll/unix/signal_x86_64.c 5 | @@ -2678,6 +2678,15 @@ static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 6 | 7 | 8 | #ifdef __APPLE__ 9 | +/* CW Hack 24265 */ 10 | +extern void __restore_mxcsr_thunk(void); 11 | +__ASM_GLOBAL_FUNC( __restore_mxcsr_thunk, 12 | + "pushq %rcx\n\t" 13 | + "movq %gs:0x30,%rcx\n\t" 14 | + "ldmxcsr 0x33c(%rcx)\n\t" /* amd64_thread_data()->mxcsr */ 15 | + "popq %rcx\n\t" 16 | + "jmp " __ASM_LOCAL_LABEL("__wine_syscall_dispatcher_prolog_end") ); 17 | + 18 | /********************************************************************** 19 | * sigsys_handler 20 | * 21 | @@ -2705,6 +2714,27 @@ static void sigsys_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 22 | frame->restore_flags |= CONTEXT_CONTROL; 23 | } 24 | RIP_sig(ucontext) = (ULONG64)__wine_syscall_dispatcher_prolog_end_ptr; 25 | + 26 | + /* CW Hack 24265 */ 27 | + if (is_rosetta2 && FPU_sig(ucontext)) 28 | + { 29 | + XMM_SAVE_AREA32 fpu; 30 | + unsigned int direct_mxcsr; 31 | + __asm__ volatile( "stmxcsr %0" : "=m" (direct_mxcsr) ); 32 | + memcpy( &fpu, FPU_sig(ucontext), sizeof(fpu) ); 33 | + 34 | + if (direct_mxcsr != fpu.MxCsr) 35 | + { 36 | + fpu.MxCsr = direct_mxcsr; 37 | + memcpy( FPU_sig(ucontext), &fpu, sizeof(fpu) ); 38 | + 39 | + /* On the M3, Rosetta will restore mxcsr to the initial, incorrect 40 | + value from the sigcontext, even if we change it. So we jump to a 41 | + thunk that restores the value from amd64_thread_data. */ 42 | + amd64_thread_data()->mxcsr = direct_mxcsr; 43 | + RIP_sig(ucontext) = (ULONG64)__restore_mxcsr_thunk; 44 | + } 45 | + } 46 | } 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /multimedia/gstreamer-development/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup gitlab 1.0 5 | 6 | gitlab.setup gstreamer gstreamer 1.26.8 7 | gitlab.instance https://gitlab.freedesktop.org/gstreamer 8 | revision 0 9 | 10 | name ${gitlab.project}-development 11 | categories multimedia 12 | maintainers {@Gcenx} 13 | description GStreamer is a streaming media framework 14 | long_description {*}${description} 15 | 16 | supported_archs arm64 x86_64 17 | platforms {darwin >= 17} 18 | license LGPL-2+ 19 | 20 | homepage https://gstreamer.freedesktop.org 21 | master_sites ${homepage}/data/pkg/osx/${version}/ 22 | 23 | dist_subdir ${gitlab.project} 24 | distname gstreamer-1.0-devel-${version}-universal 25 | extract.suffix .pkg 26 | 27 | checksums rmd160 8dc64ef2ca9709f7a7714d92411629ee1a373da2 \ 28 | sha256 ef5bb48607d10be6a9a7e1f6632bc690369185d8b920f4883a64a9806d8fb6e4 \ 29 | size 394569627 30 | 31 | depends_lib port:gstreamer-runtime 32 | 33 | extract {} 34 | use_configure no 35 | build {} 36 | 37 | destroot { 38 | set docdir ${destroot}${prefix}/share/doc/${subport} 39 | xinstall -d ${docdir} 40 | system "echo ${subport} is a stub port > ${docdir}/README" 41 | } 42 | 43 | activate { 44 | portactivate::activate_main 45 | elevateToRoot "installer" 46 | ui_msg "---> Installing ${distname}${extract.suffix}" 47 | system -W ${distpath} "installer -pkg ${distname}${extract.suffix} -target /" 48 | system "xattr -drs com.apple.quarantine /Library/Frameworks/GStreamer.framework" 49 | system "codesign --force --deep --sign - /Library/Frameworks/GStreamer.framework" 50 | } 51 | 52 | variant universal {} 53 | configure.universal_archs {*}${supported_archs} 54 | default_variants +universal 55 | variant_set universal 56 | -------------------------------------------------------------------------------- /cross/mingw-w64-pkgconfig/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | 5 | name mingw-w64-pkgconfig 6 | version 0.0.1 7 | categories cross 8 | maintainers {@gcenx} 9 | 10 | supported_archs noarch 11 | description pkg-config, a system for managing library compile and \ 12 | link flags 13 | 14 | long_description The pkg-config program is used to retrieve information \ 15 | about installed libraries in the system. It is typically \ 16 | used to compile and link against one or more libraries. 17 | 18 | if {${subport} eq ${name}} { 19 | PortGroup stub 1.0 20 | depends_run port:i686-w64-mingw32-pkgconfig \ 21 | port:x86_64-w64-mingw32-pkgconfig 22 | 23 | post-deactivate { 24 | # When this port is deactivated, i686-w64-mingw32-pkgconfig should also be. 25 | if {![catch {set installed [lindex [registry_active i686-w64-mingw32-pkgconfig] 0]}]} { 26 | registry_deactivate_composite i686-w64-mingw32-pkgconfig "" [list ports_nodepcheck 1] 27 | } 28 | 29 | # When this port is deactivated, x86_64-w64-mingw32-pkgconfig should also be. 30 | if {![catch {set installed [lindex [registry_active x86_64-w64-mingw32-pkgconfig] 0]}]} { 31 | registry_deactivate_composite x86_64-w64-mingw32-pkgconfig "" [list ports_nodepcheck 1] 32 | } 33 | } 34 | } 35 | 36 | subport i686-w64-mingw32-pkgconfig { 37 | set mingw_target i686-w64-mingw32 38 | } 39 | 40 | subport x86_64-w64-mingw32-pkgconfig { 41 | set mingw_target x86_64-w64-mingw32 42 | } 43 | 44 | distfiles 45 | patchfiles 46 | use_configure no 47 | depends_run port:pkgconfig 48 | 49 | build {} 50 | 51 | destroot { 52 | set pkg [open "${destroot}${prefix}/bin/${mingw_target}-pkg-config" w 0755] 53 | puts ${pkg} "#!/bin/sh" 54 | puts ${pkg} "export PKG_CONFIG_LIBDIR=${prefix}/${mingw_target}/lib/pkgconfig:${prefix}/${mingw_target}/share/pkgconfig" 55 | puts ${pkg} "export PKG_CONFIG_PATH=\$\{PKG_CONFIG_PATH_CUSTOM\}:${prefix}/${mingw_target}/lib/pkgconfig:${prefix}/${mingw_target}/share/pkgconfig\}" 56 | puts ${pkg} "${prefix}/bin/pkg-config \$\{\@\}" 57 | close ${pkg} 58 | } 59 | -------------------------------------------------------------------------------- /multimedia/gstreamer-runtime/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup gitlab 1.0 5 | 6 | gitlab.setup gstreamer gstreamer 1.26.8 7 | gitlab.instance https://gitlab.freedesktop.org/gstreamer 8 | revision 0 9 | 10 | name ${gitlab.project}-runtime 11 | categories multimedia 12 | maintainers {@Gcenx} 13 | description GStreamer is a streaming media framework 14 | long_description {*}${description} 15 | 16 | supported_archs arm64 x86_64 17 | platforms {darwin >= 17} 18 | license LGPL-2+ 19 | 20 | homepage https://gstreamer.freedesktop.org 21 | master_sites ${homepage}/data/pkg/osx/${version}/ 22 | 23 | dist_subdir ${gitlab.project} 24 | distname gstreamer-1.0-${version}-universal 25 | extract.suffix .pkg 26 | 27 | checksums rmd160 f4ebc7b77d0a1f4460815764bce2b1913a605123 \ 28 | sha256 cbf02848ea1cfd742e34089da5d5ab693869de55b4a6e6ced57b2270bc40f0e7 \ 29 | size 183481616 30 | 31 | extract {} 32 | use_configure no 33 | 34 | build {} 35 | 36 | destroot { 37 | set docdir ${destroot}${prefix}/share/doc/${subport} 38 | xinstall -d ${docdir} 39 | system "echo ${subport} is a stub port > ${docdir}/README" 40 | } 41 | 42 | activate { 43 | portactivate::activate_main 44 | elevateToRoot "installer" 45 | ui_msg "---> Installing ${distname}${extract.suffix}" 46 | system -W ${distpath} "installer -pkg ${distname}${extract.suffix} -target /" 47 | system "xattr -drs com.apple.quarantine /Library/Frameworks/GStreamer.framework" 48 | system "codesign --force --deep --sign - /Library/Frameworks/GStreamer.framework" 49 | } 50 | 51 | deactivate { 52 | portdeactivate::deactivate_main 53 | if {![catch {set installed [lindex [registry_active gstreamer-development] 0]}]} { 54 | registry_deactivate_composite gstreamer-development "" [list ports_nodepcheck 1] 55 | } 56 | if {[file exists /Library/Frameworks/GStreamer.framework ]} { 57 | ui_msg "---> Removing GStreamer.framework" 58 | delete -force /Library/Frameworks/GStreamer.framework 59 | } 60 | } 61 | 62 | variant universal {} 63 | configure.universal_archs {*}${supported_archs} 64 | default_variants +universal 65 | variant_set universal 66 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0001-ntdll-CW-HACK-18947.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c 2 | index a564af6e6f9..964ce7bcf68 100644 3 | --- a/dlls/ntdll/unix/virtual.c 4 | +++ b/dlls/ntdll/unix/virtual.c 5 | @@ -6738,6 +6738,56 @@ NTSTATUS WINAPI NtReadVirtualMemory( HANDLE process, const void *addr, void *buf 6 | return status; 7 | } 8 | 9 | +#ifdef __APPLE__ 10 | +static int is_apple_silicon(void) 11 | +{ 12 | + static int apple_silicon_status, did_check = 0; 13 | + if (!did_check) 14 | + { 15 | + /* returns 0 for native process or on error, 1 for translated */ 16 | + int ret = 0; 17 | + size_t size = sizeof(ret); 18 | + if (sysctlbyname( "sysctl.proc_translated", &ret, &size, NULL, 0 ) == -1) 19 | + apple_silicon_status = 0; 20 | + else 21 | + apple_silicon_status = ret; 22 | + 23 | + did_check = 1; 24 | + } 25 | + 26 | + return apple_silicon_status; 27 | +} 28 | + 29 | +/* CW HACK 18947 30 | + * If mach_vm_write() is used to modify code cross-process (which is how we implement 31 | + * NtWriteVirtualMemory), Rosetta won't notice the change and will execute the "old" code. 32 | + * 33 | + * To work around this, after the write completes, 34 | + * toggle the executable bit (from inside the target process) on/off for any executable 35 | + * pages that were modified, to force Rosetta to re-translate it. 36 | + */ 37 | +static void toggle_executable_pages_for_rosetta( HANDLE process, void *addr, SIZE_T size ) 38 | +{ 39 | + MEMORY_BASIC_INFORMATION info; 40 | + NTSTATUS status; 41 | + SIZE_T ret; 42 | + 43 | + if (!is_apple_silicon()) 44 | + return; 45 | + 46 | + status = NtQueryVirtualMemory( process, addr, MemoryBasicInformation, &info, sizeof(info), &ret ); 47 | + 48 | + if (!status && (info.AllocationProtect & 0xf0)) 49 | + { 50 | + DWORD origprot, noexec; 51 | + noexec = info.AllocationProtect & ~0xf0; 52 | + if (!noexec) noexec = PAGE_NOACCESS; 53 | + 54 | + NtProtectVirtualMemory( process, &addr, &size, noexec, &origprot ); 55 | + NtProtectVirtualMemory( process, &addr, &size, origprot, &noexec ); 56 | + } 57 | +} 58 | +#endif 59 | 60 | /*********************************************************************** 61 | * NtWriteVirtualMemory (NTDLL.@) 62 | @@ -6759,6 +6809,10 @@ NTSTATUS WINAPI NtWriteVirtualMemory( HANDLE process, void *addr, const void *bu 63 | size = reply->written; 64 | } 65 | SERVER_END_REQ; 66 | + 67 | +#ifdef __APPLE__ 68 | + toggle_executable_pages_for_rosetta( process, addr, size ); 69 | +#endif 70 | } 71 | else 72 | { 73 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0011-kernelbase-HACK-Add-hack_append_command_line.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c 2 | index d89b2f1405a..4bec68a0af3 100644 3 | --- a/dlls/kernelbase/process.c 4 | +++ b/dlls/kernelbase/process.c 5 | @@ -500,6 +500,35 @@ done: 6 | return ret; 7 | } 8 | 9 | +static const WCHAR *hack_append_command_line( const WCHAR *cmd, const WCHAR *cmd_line ) 10 | +{ 11 | + static const struct 12 | + { 13 | + const WCHAR *exe_name; 14 | + const WCHAR *append; 15 | + const WCHAR *required_args; 16 | + const WCHAR *forbidden_args; 17 | + } 18 | + options[] = 19 | + { 20 | + }; 21 | + unsigned int i; 22 | + 23 | + if (!cmd) return NULL; 24 | + 25 | + for (i = 0; i < ARRAY_SIZE(options); ++i) 26 | + { 27 | + if (wcsstr( cmd, options[i].exe_name ) 28 | + && (!options[i].required_args || wcsstr(cmd_line, options[i].required_args)) 29 | + && (!options[i].forbidden_args || !wcsstr(cmd_line, options[i].forbidden_args))) 30 | + { 31 | + FIXME( "HACK: appending %s to command line.\n", debugstr_w(options[i].append) ); 32 | + return options[i].append; 33 | + } 34 | + } 35 | + return NULL; 36 | +} 37 | + 38 | /********************************************************************** 39 | * CreateProcessInternalW (kernelbase.@) 40 | */ 41 | @@ -516,6 +545,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW( HANDLE token, const WCHAR 42 | RTL_USER_PROCESS_PARAMETERS *params = NULL; 43 | RTL_USER_PROCESS_INFORMATION rtl_info = { 0 }; 44 | HANDLE parent = 0, debug = 0; 45 | + const WCHAR *append; 46 | ULONG nt_flags = 0; 47 | USHORT machine = 0; 48 | NTSTATUS status; 49 | @@ -541,6 +571,20 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW( HANDLE token, const WCHAR 50 | app_name = name; 51 | } 52 | 53 | + /* CROSSOVER HACK */ 54 | + if ((append = hack_append_command_line( app_name, tidy_cmdline ))) 55 | + { 56 | + WCHAR *new_cmdline = RtlAllocateHeap( GetProcessHeap(), 0, 57 | + sizeof(WCHAR) * (lstrlenW(cmd_line) + lstrlenW(append) + 1) ); 58 | + lstrcpyW(new_cmdline, tidy_cmdline); 59 | + lstrcatW(new_cmdline, append); 60 | + if (tidy_cmdline != cmd_line) RtlFreeHeap( GetProcessHeap(), 0, tidy_cmdline ); 61 | + tidy_cmdline = new_cmdline; 62 | + } 63 | + /* end CROSSOVER HACK */ 64 | + 65 | + TRACE( "app %s cmdline %s after all hacks\n", debugstr_w(app_name), debugstr_w(tidy_cmdline) ); 66 | + 67 | /* Warn if unsupported features are used */ 68 | 69 | if (flags & (IDLE_PRIORITY_CLASS | HIGH_PRIORITY_CLASS | REALTIME_PRIORITY_CLASS | 70 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0010-ntdll-HACK-Winehq-Bug-56441.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c 2 | index 1d0a1461fb2..dd27df88990 100644 3 | --- a/dlls/ntdll/unix/signal_x86_64.c 4 | +++ b/dlls/ntdll/unix/signal_x86_64.c 5 | @@ -2056,6 +2056,67 @@ static inline BOOL emulate_xgetbv( ucontext_t *sigcontext, CONTEXT *context ) 6 | TRACE_(seh)( "emulated an XGETBV instruction\n" ); 7 | return TRUE; 8 | } 9 | + 10 | +/*********************************************************************** 11 | + * handle_fndisi 12 | + * 13 | + * Check if the fault location is an x87 FNDISI instruction that should be treated as a NOP. 14 | + */ 15 | +static inline BOOL handle_fndisi( ucontext_t *sigcontext, CONTEXT *context ) 16 | +{ 17 | + BYTE instr[16]; 18 | + unsigned int i, prefix_count = 0; 19 | + unsigned int len = virtual_uninterrupted_read_memory( (BYTE *)context->Rip, instr, sizeof(instr) ); 20 | + 21 | + for (i = 0; i < len; i++) switch (instr[i]) 22 | + { 23 | + /* instruction prefixes */ 24 | + case 0x2e: /* %cs: */ 25 | + case 0x36: /* %ss: */ 26 | + case 0x3e: /* %ds: */ 27 | + case 0x26: /* %es: */ 28 | + case 0x40: /* rex */ 29 | + case 0x41: /* rex */ 30 | + case 0x42: /* rex */ 31 | + case 0x43: /* rex */ 32 | + case 0x44: /* rex */ 33 | + case 0x45: /* rex */ 34 | + case 0x46: /* rex */ 35 | + case 0x47: /* rex */ 36 | + case 0x48: /* rex */ 37 | + case 0x49: /* rex */ 38 | + case 0x4a: /* rex */ 39 | + case 0x4b: /* rex */ 40 | + case 0x4c: /* rex */ 41 | + case 0x4d: /* rex */ 42 | + case 0x4e: /* rex */ 43 | + case 0x4f: /* rex */ 44 | + case 0x64: /* %fs: */ 45 | + case 0x65: /* %gs: */ 46 | + case 0x66: /* opcode size */ 47 | + case 0x67: /* addr size */ 48 | + case 0xf0: /* lock */ 49 | + case 0xf2: /* repne */ 50 | + case 0xf3: /* repe */ 51 | + if (++prefix_count >= 15) return FALSE; 52 | + continue; 53 | + 54 | + case 0xdb: 55 | + if (i == len - 1) return 0; 56 | + switch (instr[i + 1]) 57 | + { 58 | + case 0xe1: 59 | + /* RDSSPD/RDSSPQ: (prefixes) DB E1 */ 60 | + RIP_sig(sigcontext) += prefix_count + 2; 61 | + TRACE_(seh)( "skipped FNDISI instruction\n" ); 62 | + return TRUE; 63 | + } 64 | + break; 65 | + default: 66 | + return FALSE; 67 | + } 68 | + return FALSE; 69 | +} 70 | #endif 71 | 72 | /*********************************************************************** 73 | @@ -2407,6 +2468,8 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 74 | if (handle_cet_nop( ucontext, &context.c )) return; 75 | /* CW HACK 23427 */ 76 | if (emulate_xgetbv( ucontext, &context.c )) return; 77 | + /* Winehq Bug 56441 */ 78 | + if (handle_fndisi( ucontext, &context.c )) return; 79 | #endif 80 | rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; 81 | break; 82 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0005-ntdll-CW-HACK-23427.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c 2 | index 74ae5273941..d298afe05de 100644 3 | --- a/dlls/ntdll/unix/signal_x86_64.c 4 | +++ b/dlls/ntdll/unix/signal_x86_64.c 5 | @@ -88,6 +88,11 @@ WINE_DECLARE_DEBUG_CHANNEL(seh); 6 | 7 | #include "dwarf.h" 8 | 9 | +#ifdef __APPLE__ 10 | +/* CW Hack 23427 */ 11 | +static BOOL sequoia_or_later = FALSE; 12 | +#endif 13 | + 14 | static USHORT cs32_sel; /* selector for %cs in 32-bit mode */ 15 | static USHORT cs64_sel; /* selector for %cs in 64-bit mode */ 16 | static USHORT ds64_sel; /* selector for %ds/%es/%ss in 64-bit mode */ 17 | @@ -2005,6 +2010,41 @@ static inline BOOL handle_cet_nop( ucontext_t *sigcontext, CONTEXT *context ) 18 | } 19 | return FALSE; 20 | } 21 | + 22 | +/*********************************************************************** 23 | + * emulate_xgetbv 24 | + * 25 | + * Check if the fault location is an Intel XGETBV instruction for xcr0 and 26 | + * emulate it if so. Actual Intel hardware supports this instruction, so this 27 | + * will only take effect under Rosetta. 28 | + * CW HACK 23427 29 | + */ 30 | +static inline BOOL emulate_xgetbv( ucontext_t *sigcontext, CONTEXT *context ) 31 | +{ 32 | + BYTE instr[3]; 33 | + unsigned int len = virtual_uninterrupted_read_memory( (BYTE *)context->Rip, instr, sizeof(instr) ); 34 | + 35 | + /* Prefixed xgetbv is illegal, so no need to check. */ 36 | + if (len < 3 || instr[0] != 0x0f || instr[1] != 0x01 || instr[2] != 0xd0 || 37 | + (RCX_sig(sigcontext) & 0xffffffff) != 0 /* only handling xcr0 (ecx==0) */) 38 | + { 39 | + return FALSE; 40 | + } 41 | + 42 | + RDX_sig(sigcontext) = 0; 43 | + if (sequoia_or_later) 44 | + { 45 | + /* Arguably we should only claim AVX support if ROSETTA_ADVERTISE_AVX is 46 | + set, but presumably apps will also check cpuid. */ 47 | + RAX_sig(sigcontext) = 0xe7; /* fpu/mmx, sse, avx, full avx-512 */ 48 | + } 49 | + else 50 | + RAX_sig(sigcontext) = 0x07; /* fpu/mmx, sse */ 51 | + 52 | + RIP_sig(sigcontext) += 3; 53 | + TRACE_(seh)( "emulated an XGETBV instruction\n" ); 54 | + return TRUE; 55 | +} 56 | #endif 57 | 58 | /*********************************************************************** 59 | @@ -2354,6 +2394,8 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 60 | #ifdef __APPLE__ 61 | /* CW HACK 20186 */ 62 | if (handle_cet_nop( ucontext, &context.c )) return; 63 | + /* CW HACK 23427 */ 64 | + if (emulate_xgetbv( ucontext, &context.c )) return; 65 | #endif 66 | rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; 67 | break; 68 | @@ -2802,6 +2844,12 @@ void signal_init_process(void) 69 | 70 | signal_alloc_thread( NtCurrentTeb() ); 71 | 72 | +#ifdef __APPLE__ 73 | + /* CW Hack 23427: __builtin_available presumably isn't signal-safe. */ 74 | + if (__builtin_available( macOS 15.0, * )) 75 | + sequoia_or_later = TRUE; 76 | +#endif 77 | + 78 | sig_act.sa_mask = server_block_set; 79 | sig_act.sa_flags = SA_SIGINFO | SA_RESTART | SA_ONSTACK; 80 | 81 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0002-ntdll-CW-HACK-20186.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c 2 | index 8c7c6cdc8d6..7cdf148488d 100644 3 | --- a/dlls/ntdll/unix/signal_x86_64.c 4 | +++ b/dlls/ntdll/unix/signal_x86_64.c 5 | @@ -1930,6 +1930,70 @@ NTSTATUS WINAPI NtCallbackReturn( void *ret_ptr, ULONG ret_len, NTSTATUS status 6 | user_mode_callback_return( ret_ptr, ret_len, status, NtCurrentTeb() ); 7 | } 8 | 9 | +#ifdef __APPLE__ 10 | +/*********************************************************************** 11 | + * handle_cet_nop 12 | + * 13 | + * Check if the fault location is an Intel CET instruction that should be treated as a NOP. 14 | + * Rosetta on Big Sur throws an exception for this, but is fixed in Monterey. 15 | + * CW HACK 20186 16 | + */ 17 | +static inline BOOL handle_cet_nop( ucontext_t *sigcontext, CONTEXT *context ) 18 | +{ 19 | + BYTE instr[16]; 20 | + unsigned int i, prefix_count = 0; 21 | + unsigned int len = virtual_uninterrupted_read_memory( (BYTE *)context->Rip, instr, sizeof(instr) ); 22 | + 23 | + for (i = 0; i < len; i++) switch (instr[i]) 24 | + { 25 | + /* instruction prefixes */ 26 | + case 0x2e: /* %cs: */ 27 | + case 0x36: /* %ss: */ 28 | + case 0x3e: /* %ds: */ 29 | + case 0x26: /* %es: */ 30 | + case 0x40: /* rex */ 31 | + case 0x41: /* rex */ 32 | + case 0x42: /* rex */ 33 | + case 0x43: /* rex */ 34 | + case 0x44: /* rex */ 35 | + case 0x45: /* rex */ 36 | + case 0x46: /* rex */ 37 | + case 0x47: /* rex */ 38 | + case 0x48: /* rex */ 39 | + case 0x49: /* rex */ 40 | + case 0x4a: /* rex */ 41 | + case 0x4b: /* rex */ 42 | + case 0x4c: /* rex */ 43 | + case 0x4d: /* rex */ 44 | + case 0x4e: /* rex */ 45 | + case 0x4f: /* rex */ 46 | + case 0x64: /* %fs: */ 47 | + case 0x65: /* %gs: */ 48 | + case 0x66: /* opcode size */ 49 | + case 0x67: /* addr size */ 50 | + case 0xf0: /* lock */ 51 | + case 0xf2: /* repne */ 52 | + case 0xf3: /* repe */ 53 | + if (++prefix_count >= 15) return FALSE; 54 | + continue; 55 | + 56 | + case 0x0f: /* extended instruction */ 57 | + if (i == len - 1) return 0; 58 | + switch (instr[i + 1]) 59 | + { 60 | + case 0x1E: 61 | + /* RDSSPD/RDSSPQ: (prefixes) 0F 1E (modrm) */ 62 | + RIP_sig(sigcontext) += prefix_count + 3; 63 | + TRACE_(seh)( "skipped RDSSPD/RDSSPQ instruction\n" ); 64 | + return TRUE; 65 | + } 66 | + break; 67 | + default: 68 | + return FALSE; 69 | + } 70 | + return FALSE; 71 | +} 72 | +#endif 73 | 74 | /*********************************************************************** 75 | * is_privileged_instr 76 | @@ -2275,6 +2339,10 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 77 | rec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED; 78 | break; 79 | case TRAP_x86_PRIVINFLT: /* Invalid opcode exception */ 80 | +#ifdef __APPLE__ 81 | + /* CW HACK 20186 */ 82 | + if (handle_cet_nop( ucontext, &context.c )) return; 83 | +#endif 84 | rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; 85 | break; 86 | case TRAP_x86_STKFLT: /* Stack fault */ 87 | -------------------------------------------------------------------------------- /devel/game-porting-toolkit/files/1001-configure-remove-cross_compiling-check.diff: -------------------------------------------------------------------------------- 1 | From 318a091dd4a122735ef5df09875d59d07d64874f Mon Sep 17 00:00:00 2001 2 | From: Dean M Greer <38226388+Gcenx@users.noreply.github.com> 3 | Date: Thu, 22 Dec 2022 11:22:05 -0500 4 | Subject: [PATCH] remove cross_compiling check 5 | 6 | --- 7 | configure | 6 +++--- 8 | configure.ac | 6 +++--- 9 | 2 files changed, 6 insertions(+), 6 deletions(-) 10 | 11 | diff --git a/configure b/configure 12 | index 9c937f61..2d25a600 100755 13 | --- a/configure 14 | +++ b/configure 15 | @@ -6227,7 +6227,7 @@ esac 16 | 17 | case $host in 18 | x86_64*|amd64*) 19 | - if test "x$enable_win64" != "xyes" -a "x$enable_win32on64" != "xyes" -a "$cross_compiling" != "yes" 20 | + if test "x$enable_win64" != "xyes" -a "x$enable_win32on64" != "xyes" 21 | then 22 | CC="$CC -m32" 23 | CXX="$CXX -m32" 24 | @@ -6269,7 +6269,7 @@ printf "%s\n" "$wine_cv_cc_m32" >&6; } 25 | export PKG_CONFIG_PATH 26 | enable_win16=${enable_win16:-yes} 27 | with_unwind=${with_unwind:-no} 28 | - elif test "x$enable_win64" != "xyes" -a "x$enable_win32on64" = "xyes" -a "$cross_compiling" != "yes" 29 | + elif test "x$enable_win64" != "xyes" -a "x$enable_win32on64" = "xyes" 30 | then 31 | if test "x${GCC}" = "xyes" 32 | then 33 | @@ -19657,7 +19657,7 @@ then : 34 | fi 35 | fi 36 | 37 | - if test "x$enable_win64" != "xyes" -a "x$enable_win32on64" = "xyes" -a "$cross_compiling" != "yes" 38 | + if test "x$enable_win64" != "xyes" -a "x$enable_win32on64" = "xyes" 39 | then 40 | { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Werror=extra-tokens" >&5 41 | printf %s "checking whether the compiler supports -Werror=extra-tokens... " >&6; } 42 | diff --git a/configure.ac b/configure.ac 43 | index 480f673e..ee890f6a 100644 44 | --- a/configure.ac 45 | +++ b/configure.ac 46 | @@ -127,7 +127,7 @@ AC_SUBST(HOSTSTACK_CFLAGS) 47 | AC_SUBST(TARGETFLAGS) 48 | case $host in 49 | x86_64*|amd64*) 50 | - if test "x$enable_win64" != "xyes" -a "x$enable_win32on64" != "xyes" -a "$cross_compiling" != "yes" 51 | + if test "x$enable_win64" != "xyes" -a "x$enable_win32on64" != "xyes" 52 | then 53 | CC="$CC -m32" 54 | CXX="$CXX -m32" 55 | @@ -142,7 +142,7 @@ case $host in 56 | export PKG_CONFIG_PATH 57 | enable_win16=${enable_win16:-yes} 58 | with_unwind=${with_unwind:-no} 59 | - elif test "x$enable_win64" != "xyes" -a "x$enable_win32on64" = "xyes" -a "$cross_compiling" != "yes" 60 | + elif test "x$enable_win64" != "xyes" -a "x$enable_win32on64" = "xyes" 61 | then 62 | if test "x${GCC}" = "xyes" 63 | then 64 | @@ -2001,7 +2001,7 @@ int a(int b, ...) { __builtin_ms_va_list list; __builtin_ms_va_start(list,b); }] 65 | fi 66 | 67 | dnl Extra errors for 32-on-64-bit mode, to catch address space issues 68 | - if test "x$enable_win64" != "xyes" -a "x$enable_win32on64" = "xyes" -a "$cross_compiling" != "yes" 69 | + if test "x$enable_win64" != "xyes" -a "x$enable_win32on64" = "xyes" 70 | then 71 | WINE_TRY_CFLAGS([-Werror=extra-tokens],[EXTRACFLAGS="$EXTRACFLAGS -Werror=extra-tokens"]) 72 | WINE_TRY_CFLAGS([-Werror=implicit-function-declaration],[EXTRACFLAGS="$EXTRACFLAGS -Werror=implicit-function-declaration"]) 73 | -- 74 | 2.37.1 (Apple Git-137.1) 75 | 76 | -------------------------------------------------------------------------------- /devel/game-porting-toolkit/files/1003-build_fixes.diff: -------------------------------------------------------------------------------- 1 | diff --git a/include/Makefile.in b/include/Makefile.in 2 | index 99d74bae..4d8a59e5 100644 3 | --- a/include/Makefile.in 4 | +++ b/include/Makefile.in 5 | @@ -506,6 +506,7 @@ SOURCES = \ 6 | msvcrt/setjmp.h \ 7 | msvcrt/share.h \ 8 | msvcrt/signal.h \ 9 | + msvcrt/stdarg.h \ 10 | msvcrt/stdbool.h \ 11 | msvcrt/stddef.h \ 12 | msvcrt/stdint.h \ 13 | @@ -521,6 +522,7 @@ SOURCES = \ 14 | msvcrt/time.h \ 15 | msvcrt/uchar.h \ 16 | msvcrt/unistd.h \ 17 | + msvcrt/vadefs.h \ 18 | msvcrt/wchar.h \ 19 | msvcrt/wctype.h \ 20 | mswsock.h \ 21 | diff --git a/include/msvcrt/stdarg.h b/include/msvcrt/stdarg.h 22 | new file mode 100644 23 | index 00000000..6c6b6048 24 | --- /dev/null 25 | +++ b/include/msvcrt/stdarg.h 26 | @@ -0,0 +1,31 @@ 27 | +/* 28 | + * Variable argument definitions 29 | + * 30 | + * Copyright 2022 Jacek Caban 31 | + * 32 | + * This library is free software; you can redistribute it and/or 33 | + * modify it under the terms of the GNU Lesser General Public 34 | + * License as published by the Free Software Foundation; either 35 | + * version 2.1 of the License, or (at your option) any later version. 36 | + * 37 | + * This library is distributed in the hope that it will be useful, 38 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of 39 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 40 | + * Lesser General Public License for more details. 41 | + * 42 | + * You should have received a copy of the GNU Lesser General Public 43 | + * License along with this library; if not, write to the Free Software 44 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 45 | + */ 46 | + 47 | +#ifndef _INC_STDARG 48 | +#define _INC_STDARG 49 | + 50 | +#include 51 | + 52 | +#define va_start(v,l) _crt_va_start(v,l) 53 | +#define va_arg(v,l) _crt_va_arg(v,l) 54 | +#define va_end(v) _crt_va_end(v) 55 | +#define va_copy(d,s) _crt_va_copy(d,s) 56 | + 57 | +#endif /* _INC_STDARG */ 58 | diff --git a/include/msvcrt/vadefs.h b/include/msvcrt/vadefs.h 59 | new file mode 100644 60 | index 00000000..2a612fc0 61 | --- /dev/null 62 | +++ b/include/msvcrt/vadefs.h 63 | @@ -0,0 +1,52 @@ 64 | +/* 65 | + * Variable argument definitions 66 | + * 67 | + * Copyright 2022 Jacek Caban 68 | + * 69 | + * This library is free software; you can redistribute it and/or 70 | + * modify it under the terms of the GNU Lesser General Public 71 | + * License as published by the Free Software Foundation; either 72 | + * version 2.1 of the License, or (at your option) any later version. 73 | + * 74 | + * This library is distributed in the hope that it will be useful, 75 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of 76 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 77 | + * Lesser General Public License for more details. 78 | + * 79 | + * You should have received a copy of the GNU Lesser General Public 80 | + * License along with this library; if not, write to the Free Software 81 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 82 | + */ 83 | + 84 | +#ifndef _INC_VADEFS 85 | +#define _INC_VADEFS 86 | + 87 | +#ifdef __cplusplus 88 | +#define _ADDRESSOF(v) (&reinterpret_cast(v)) 89 | +#else 90 | +#define _ADDRESSOF(v) (&(v)) 91 | +#endif 92 | + 93 | +#if defined(__GNUC__) || defined(__clang__) 94 | + 95 | +typedef __builtin_va_list va_list; 96 | +#define _crt_va_start(v,l) __builtin_va_start(v,l) 97 | +#define _crt_va_arg(v,l) __builtin_va_arg(v,l) 98 | +#define _crt_va_end(v) __builtin_va_end(v) 99 | +#define _crt_va_copy(d,s) __builtin_va_copy(d,s) 100 | + 101 | +#else 102 | + 103 | +typedef char *va_list; 104 | + 105 | +#if defined(__i386__) 106 | +#define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1)) 107 | +#define _crt_va_start(v,l) ((v) = (va_list)_ADDRESSOF(l) + _INTSIZEOF(l)) 108 | +#define _crt_va_arg(v,l) (*(l *)(((v) += _INTSIZEOF(l)) - _INTSIZEOF(l))) 109 | +#define _crt_va_end(v) ((v) = (va_list)0) 110 | +#define _crt_va_copy(d,s) ((d) = (s)) 111 | +#endif 112 | + 113 | +#endif 114 | + 115 | +#endif /* _INC_VADEFS */ 116 | -------------------------------------------------------------------------------- /emulators/wine-stable/files/MR7328.diff: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c 2 | index 3872f2b237b71efe7ef148853f00e9d97b2c2427..5be6e44435f6e029eda40e47edf66542bae3d29e 100644 3 | --- a/dlls/ntdll/loader.c 4 | +++ b/dlls/ntdll/loader.c 5 | @@ -3739,7 +3739,7 @@ void* WINAPI LdrResolveDelayLoadedAPI( void* base, const IMAGE_DELAYLOAD_DESCRIP 6 | HMODULE *phmod; 7 | NTSTATUS nts; 8 | FARPROC fp; 9 | - DWORD id; 10 | + INT_PTR id; 11 | 12 | TRACE( "(%p, %p, %p, %p, %p, 0x%08lx)\n", base, desc, dllhook, syshook, addr, flags ); 13 | 14 | diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c 15 | index 6aee0fa98f83c4e4d38ae47afc805df0588bd98e..9a635a8e8f7fe89ef40329af3c6a57fb8c7ba6f3 100644 16 | --- a/tools/winebuild/import.c 17 | +++ b/tools/winebuild/import.c 18 | @@ -1331,6 +1331,16 @@ static void build_dlltool_import_lib( const char *lib_name, DLLSPEC *spec, struc 19 | if (files.count) output_static_lib( output_file_name, files, 0 ); 20 | } 21 | 22 | +static void output_import_section( int index, int is_delay ) 23 | +{ 24 | + if (!is_delay) 25 | + output( "\n\t.section .idata$%d\n", index ); 26 | + else if (index == 5) 27 | + output( "\n\t.section .data$didat%d\n", index ); 28 | + else 29 | + output( "\n\t.section .rdata$didat%d\n", index ); 30 | +} 31 | + 32 | /* create a Windows-style import library */ 33 | static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struct strarray files ) 34 | { 35 | @@ -1454,20 +1464,20 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struc 36 | output( "\t.long 0\n" ); /* UnloadInformationTableRVA */ 37 | output( "\t.long 0\n" ); /* TimeDateStamp */ 38 | 39 | - output( "\n\t.section .idata$5\n" ); 40 | + output_import_section( 5, is_delay ); 41 | output( "\t%s 0\n", get_asm_ptr_keyword() ); /* FirstThunk tail */ 42 | output( ".L__wine_import_addrs:\n" ); 43 | 44 | - output( "\n\t.section .idata$4\n" ); 45 | + output_import_section( 4, is_delay ); 46 | output( "\t%s 0\n", get_asm_ptr_keyword() ); /* OriginalFirstThunk tail */ 47 | output( ".L__wine_import_names:\n" ); 48 | 49 | /* required to avoid internal linker errors with some binutils versions */ 50 | - output( "\n\t.section .idata$2\n" ); 51 | + output_import_section( 2, is_delay ); 52 | } 53 | else 54 | { 55 | - output( "\n\t.section .idata$2\n" ); 56 | + output_import_section( 2, is_delay ); 57 | output( "%s\n", asm_globl( import_desc ) ); 58 | output_rva( ".L__wine_import_names" ); /* OriginalFirstThunk */ 59 | output( "\t.long 0\n" ); /* TimeDateStamp */ 60 | @@ -1475,10 +1485,10 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struc 61 | output_rva( "%s", asm_name( import_name ) ); /* Name */ 62 | output_rva( ".L__wine_import_addrs" ); /* FirstThunk */ 63 | 64 | - output( "\n\t.section .idata$4\n" ); 65 | + output_import_section( 4, is_delay ); 66 | output( ".L__wine_import_names:\n" ); /* OriginalFirstThunk head */ 67 | 68 | - output( "\n\t.section .idata$5\n" ); 69 | + output_import_section( 5, is_delay ); 70 | output( ".L__wine_import_addrs:\n" ); /* FirstThunk head */ 71 | } 72 | 73 | @@ -1489,11 +1499,11 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struc 74 | 75 | new_output_as_file(); 76 | 77 | - output( "\n\t.section .idata$4\n" ); 78 | + output_import_section( 4, is_delay ); 79 | output( "\t%s 0\n", get_asm_ptr_keyword() ); /* OriginalFirstThunk tail */ 80 | - output( "\n\t.section .idata$5\n" ); 81 | + output_import_section( 5, is_delay ); 82 | output( "\t%s 0\n", get_asm_ptr_keyword() ); /* FirstThunk tail */ 83 | - output( "\n\t.section .idata$7\n" ); 84 | + output_import_section( 7, is_delay ); 85 | output( "%s\n", asm_globl( import_name ) ); 86 | output( "\t%s \"%s\"\n", get_asm_string_keyword(), spec->file_name ); 87 | 88 | @@ -1584,10 +1594,10 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struc 89 | break; 90 | } 91 | 92 | - output( "\n\t.section .idata$4\n" ); 93 | + output_import_section( 4, is_delay ); 94 | output_thunk_rva( by_name ? -1 : odp->ordinal, ".L__wine_import_name" ); 95 | 96 | - output( "\n\t.section .idata$5\n" ); 97 | + output_import_section( 5, is_delay ); 98 | output( "%s\n", asm_globl( imp_name ) ); 99 | if (is_delay) 100 | output( "\t%s .L__wine_delay_import\n", get_asm_ptr_keyword() ); 101 | @@ -1596,14 +1606,14 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struc 102 | 103 | if (by_name) 104 | { 105 | - output( "\n\t.section .idata$6\n" ); 106 | + output_import_section( 6, is_delay ); 107 | output( ".L__wine_import_name:\n" ); 108 | output( "\t.short %d\n", odp->hint ); 109 | output( "\t%s \"%s\"\n", get_asm_string_keyword(), name ); 110 | } 111 | 112 | /* reference head object to always pull its sections */ 113 | - output( "\n\t.section .idata$7\n" ); 114 | + output_import_section( 7, is_delay ); 115 | output_rva( "%s", asm_name( import_desc ) ); 116 | 117 | free( imp_name ); 118 | -------------------------------------------------------------------------------- /cross/mingw-w64-wine-gecko/_Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | 5 | name mingw-w64-wine-gecko 6 | categories cross 7 | maintainers {@gcenx} 8 | license MPL 9 | supported_archs noarch 10 | use_xz yes 11 | description Wine's built-in replacement for Microsoft's Internet Explorer 12 | long_description ${name} ${description} 13 | 14 | use_configure no 15 | build {} 16 | 17 | if {${subport} eq ${name}} { 18 | PortGroup stub 1.0 19 | version 2.47.4 20 | revision 0 21 | depends_run port:mingw-w64-wine-gecko-${version} 22 | 23 | post-deactivate { 24 | # When this port is deactivated, mingw-w64-wine-gecko-${version} should also be. 25 | if {![catch {set installed [lindex [registry_active mingw-w64-wine-gecko-${version}] 0]}]} { 26 | registry_deactivate_composite mingw-w64-wine-gecko-${version} "" [list ports_nodepcheck 1] 27 | } 28 | } 29 | } 30 | 31 | subport ${name}-2.47.4 { 32 | version 2.47.4 33 | revision 0 34 | 35 | distname wine-gecko-${version} 36 | set wine_gecko_distfile ${distname}-x86.tar.xz 37 | set wine_gecko64_distfile ${distname}-x86_64.tar.xz 38 | 39 | master_sites http://dl.winehq.org/wine/wine-gecko/${version}/:winegecko 40 | 41 | distfiles ${wine_gecko_distfile}:winegecko \ 42 | ${wine_gecko64_distfile}:winegecko 43 | 44 | extract.only ${wine_gecko_distfile} \ 45 | ${wine_gecko64_distfile} 46 | 47 | checksums ${wine_gecko_distfile} \ 48 | rmd160 4d2e02818520ab24c9ead1ec7c9098a217b17ece \ 49 | sha256 2cfc8d5c948602e21eff8a78613e1826f2d033df9672cace87fed56e8310afb6 \ 50 | size 43025064 \ 51 | ${wine_gecko64_distfile} \ 52 | rmd160 73ca5f2c80dad6998491d04d831e13e2e63606e7 \ 53 | sha256 fd88fc7e537d058d7a8abf0c1ebc90c574892a466de86706a26d254710a82814 \ 54 | size 41935496 55 | } 56 | 57 | subport ${name}-2.47.3 { 58 | version 2.47.3 59 | revision 0 60 | 61 | distname wine-gecko-${version} 62 | set wine_gecko_distfile ${distname}-x86.tar.xz 63 | set wine_gecko64_distfile ${distname}-x86_64.tar.xz 64 | 65 | master_sites http://dl.winehq.org/wine/wine-gecko/${version}/:winegecko 66 | 67 | distfiles ${wine_gecko_distfile}:winegecko \ 68 | ${wine_gecko64_distfile}:winegecko 69 | 70 | extract.only ${wine_gecko_distfile} \ 71 | ${wine_gecko64_distfile} 72 | 73 | checksums ${wine_gecko_distfile} \ 74 | rmd160 7b456b3b58d5116429eae1c0db78024eb46a88d6 \ 75 | sha256 08d318f3dd6440a8a777cf044ccab039b0d9c8809991d2180eb3c9f903135db3 \ 76 | size 43291212 \ 77 | ${wine_gecko64_distfile} \ 78 | rmd160 e7ed01bbfbf9dca6df471bc90fc233151ead790e \ 79 | sha256 0beac419c20ee2e68a1227b6e3fa8d59fec0274ed5e82d0da38613184716ef75 \ 80 | size 42325312 81 | } 82 | 83 | subport ${name}-2.47.2 { 84 | version 2.47.2 85 | revision 0 86 | 87 | distname wine-gecko-${version} 88 | set wine_gecko_distfile ${distname}-x86.tar.xz 89 | set wine_gecko64_distfile ${distname}-x86_64.tar.xz 90 | 91 | master_sites http://dl.winehq.org/wine/wine-gecko/${version}/:winegecko 92 | 93 | distfiles ${wine_gecko_distfile}:winegecko \ 94 | ${wine_gecko64_distfile}:winegecko 95 | 96 | extract.only ${wine_gecko_distfile} \ 97 | ${wine_gecko64_distfile} 98 | 99 | checksums ${wine_gecko_distfile} \ 100 | rmd160 2a148648e523fba9f68913d458da5242b1e52a11 \ 101 | sha256 8fab46ea2110b2b0beed414e3ebb4e038a3da04900e7a28492ca3c3ccf9fea94 \ 102 | size 45556880 \ 103 | ${wine_gecko64_distfile} \ 104 | rmd160 1853836ef0868383259c201542a7345d0ffcf77f \ 105 | sha256 b4476706a4c3f23461da98bed34f355ff623c5d2bb2da1e2fa0c6a310bc33014 \ 106 | size 43025348 107 | } 108 | 109 | subport ${name}-2.47.1 { 110 | version 2.47.1 111 | revision 0 112 | 113 | distname wine-gecko-${version} 114 | set wine_gecko_distfile ${distname}-x86.tar.bz2 115 | set wine_gecko64_distfile ${distname}-x86_64.tar.bz2 116 | 117 | master_sites https://github.com/Gcenx/macports-wine/releases/download/${version}/:winegecko 118 | 119 | distfiles ${wine_gecko_distfile}:winegecko \ 120 | ${wine_gecko64_distfile}:winegecko 121 | 122 | extract.only ${wine_gecko_distfile} \ 123 | ${wine_gecko64_distfile} 124 | 125 | checksums ${wine_gecko_distfile} \ 126 | rmd160 0eaa4b8928f5663e64085899af472b74fb63a61d \ 127 | sha256 06a00cedf391ee07bbca0b3282e5c8ad9d950446d50648d2ff417716816fd1ab \ 128 | size 45761076 \ 129 | ${wine_gecko64_distfile} \ 130 | rmd160 42a25c47aa5f0a39edd8f0352cdb64b34add173c \ 131 | sha256 faf7a56e42fe60943e2074940f4c4ef55791747bca7f34f08fed7c185611a4fb \ 132 | size 46392514 133 | 134 | use_bzip2 yes 135 | } 136 | 137 | destroot { 138 | file mkdir ${destroot}${prefix}/share/wine/gecko 139 | file copy ${workpath}/wine-gecko-${version}-x86 ${destroot}${prefix}/share/wine/gecko 140 | file copy ${workpath}/wine-gecko-${version}-x86_64 ${destroot}${prefix}/share/wine/gecko 141 | } 142 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0014-winemac-DXMT-export.patch: -------------------------------------------------------------------------------- 1 | based on cw hack 22435 from crossover-sources-20251106 2 | 3 | diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h 4 | index ac2a7853652..6c51eefadd2 100644 5 | --- a/dlls/winemac.drv/macdrv.h 6 | +++ b/dlls/winemac.drv/macdrv.h 7 | @@ -172,6 +172,7 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p 8 | extern BOOL macdrv_ProcessEvents(DWORD mask); 9 | extern void macdrv_ThreadDetach(void); 10 | 11 | +struct macdrv_client_surface; 12 | 13 | /* macdrv private window data */ 14 | struct macdrv_win_data 15 | @@ -189,6 +190,8 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p 16 | unsigned int per_pixel_alpha : 1; /* is window using per-pixel alpha? */ 17 | unsigned int minimized : 1; /* is window minimized? */ 18 | unsigned int fullscreen : 1; /* is the window visible rect fullscreen? (unrelated to native AppKit/Cocoa fullscreen) */ 19 | + 20 | + struct macdrv_client_surface *dxmt_client_surface; 21 | }; 22 | 23 | struct macdrv_client_surface 24 | diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c 25 | index ed913834255..775c3c9c5cf 100644 26 | --- a/dlls/winemac.drv/macdrv_main.c 27 | +++ b/dlls/winemac.drv/macdrv_main.c 28 | @@ -637,4 +637,126 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] = 29 | 30 | C_ASSERT( ARRAYSIZE(__wine_unix_call_wow64_funcs) == unix_funcs_count ); 31 | 32 | + 33 | +struct macdrv_functions_t 34 | +{ 35 | + void (*macdrv_init_display_devices)(BOOL); 36 | + struct dxmt_macdrv_win_data* (*get_win_data)(HWND hwnd); 37 | + void (*release_win_data)(struct dxmt_macdrv_win_data *data); 38 | + macdrv_window(*macdrv_get_cocoa_window)(HWND hwnd, BOOL require_on_screen); 39 | + macdrv_metal_device (*macdrv_create_metal_device)(void); 40 | + void (*macdrv_release_metal_device)(macdrv_metal_device d); 41 | + macdrv_metal_view (*macdrv_view_create_metal_view)(macdrv_view v, macdrv_metal_device d); 42 | + macdrv_metal_layer (*macdrv_view_get_metal_layer)(macdrv_metal_view v); 43 | + void (*macdrv_view_release_metal_view)(macdrv_metal_view v); 44 | + void (*on_main_thread)(dispatch_block_t b); 45 | +}; 46 | +C_ASSERT(sizeof(struct macdrv_functions_t) == 80); 47 | + 48 | +struct dxmt_macdrv_win_data 49 | +{ 50 | + HWND hwnd; 51 | + macdrv_window cocoa_window; 52 | + macdrv_view cocoa_view; 53 | + macdrv_view client_cocoa_view; 54 | + RECT window_rect; /* USER window rectangle relative to parent */ 55 | + RECT whole_rect; /* Mac window rectangle for the whole window relative to parent */ 56 | + RECT client_rect; /* client area relative to parent */ 57 | + int pixel_format; /* pixel format for GL */ 58 | + COLORREF color_key; /* color key for layered window; CLR_INVALID is not color keyed */ 59 | + HANDLE drag_event; /* event to signal that Cocoa-driven window dragging has ended */ 60 | + unsigned int on_screen : 1; /* is window ordered in? (minimized or not) */ 61 | + unsigned int shaped : 1; /* is window using a custom region shape? */ 62 | + unsigned int layered : 1; /* is window layered and with valid attributes? */ 63 | + unsigned int ulw_layered : 1; /* has UpdateLayeredWindow() been called for window? */ 64 | + unsigned int per_pixel_alpha : 1; /* is window using per-pixel alpha? */ 65 | + unsigned int minimized : 1; /* is window minimized? */ 66 | + void * padding[2]; /* used to be struct window_surface* surface/unminimized_surface */ 67 | +}; 68 | + 69 | +C_ASSERT(sizeof(struct dxmt_macdrv_win_data) == 120); 70 | + 71 | +static struct dxmt_macdrv_win_data *my_get_win_data(HWND hwnd) 72 | +{ 73 | + struct macdrv_win_data *data; 74 | + struct dxmt_macdrv_win_data *dxmt_data; 75 | + TRACE("get_win_data %p\n", hwnd); 76 | + 77 | + data = get_win_data(hwnd); 78 | + if (!data) 79 | + return NULL; 80 | + 81 | + if (!data->client_view) 82 | + data->dxmt_client_surface = macdrv_client_surface_create(hwnd); 83 | + 84 | + dxmt_data = calloc(1, sizeof(*dxmt_data)); 85 | + 86 | + dxmt_data->cocoa_window = data->cocoa_window; 87 | + dxmt_data->client_cocoa_view = data->client_view; 88 | + dxmt_data->padding[0] = data; 89 | + 90 | + return dxmt_data; 91 | +} 92 | + 93 | +static void my_release_win_data(struct dxmt_macdrv_win_data *data) 94 | +{ 95 | + TRACE("release_win_data %p\n", data); 96 | + 97 | + if (!data) 98 | + return; 99 | + 100 | + release_win_data(data->padding[0]); 101 | + free(data); 102 | +} 103 | + 104 | +static macdrv_window my_macdrv_get_cocoa_window(HWND hwnd, BOOL require_on_screen) 105 | +{ 106 | + TRACE("macdrv_get_cocoa_window %p %d\n", hwnd, require_on_screen); 107 | + return macdrv_get_cocoa_window(hwnd, require_on_screen); 108 | +} 109 | + 110 | +static macdrv_metal_device my_macdrv_create_metal_device(void) 111 | +{ 112 | + TRACE("macdrv_create_metal_device\n"); 113 | + return macdrv_create_metal_device(); 114 | +} 115 | + 116 | +static void my_macdrv_release_metal_device(macdrv_metal_device d) 117 | +{ 118 | + TRACE("macdrv_release_metal_device %p\n", d); 119 | + macdrv_release_metal_device(d); 120 | +} 121 | + 122 | +static macdrv_metal_view my_macdrv_view_create_metal_view(macdrv_view v, macdrv_metal_device d) 123 | +{ 124 | + TRACE("macdrv_view_create_metal_view %p %p\n", v, d); 125 | + return macdrv_view_create_metal_view(v, d); 126 | +} 127 | + 128 | +static macdrv_metal_layer my_macdrv_view_get_metal_layer(macdrv_metal_view v) 129 | +{ 130 | + TRACE("macdrv_view_get_metal_layer %p\n", v); 131 | + return macdrv_view_get_metal_layer(v); 132 | +} 133 | + 134 | +static void my_macdrv_view_release_metal_view(macdrv_metal_view v) 135 | +{ 136 | + TRACE("macdrv_view_release_metal_view %p\n", v); 137 | + return macdrv_view_release_metal_view(v); 138 | +} 139 | + 140 | +DECLSPEC_EXPORT struct macdrv_functions_t macdrv_functions = 141 | +{ 142 | + NULL, 143 | + &my_get_win_data, 144 | + &my_release_win_data, 145 | + &my_macdrv_get_cocoa_window, 146 | + &my_macdrv_create_metal_device, 147 | + &my_macdrv_release_metal_device, 148 | + &my_macdrv_view_create_metal_view, 149 | + &my_macdrv_view_get_metal_layer, 150 | + &my_macdrv_view_release_metal_view, 151 | + NULL 152 | +}; 153 | + 154 | #endif /* _WIN64 */ 155 | diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c 156 | index acb90420bcd..0f6191601b9 100644 157 | --- a/dlls/winemac.drv/window.c 158 | +++ b/dlls/winemac.drv/window.c 159 | @@ -1252,6 +1252,9 @@ void macdrv_DestroyWindow(HWND hwnd) 160 | 161 | destroy_cocoa_window(data); 162 | 163 | + if (data->dxmt_client_surface) 164 | + client_surface_release(&data->dxmt_client_surface->client); 165 | + 166 | CFDictionaryRemoveValue(win_datas, hwnd); 167 | release_win_data(data); 168 | free(data); 169 | -------------------------------------------------------------------------------- /devel/MacOSX.sdk/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup github 1.0 5 | 6 | name MacOSX.sdk 7 | categories devel 8 | platforms {darwin >= 12} 9 | maintainers {@Gcenx} 10 | license Restrictive Nomirror 11 | installs_libs no 12 | homepage https://developer.apple.com/macos/ 13 | dist_subdir MacOSX.sdk 14 | use_bzip2 yes 15 | set sdk_dir ${prefix}/Developer/SDKs 16 | 17 | use_configure no 18 | build {} 19 | 20 | subport MacOSX15.sdk { 21 | github.setup gcenx macos-sdk 15.5 22 | set macos_name {macOS Sequoia} 23 | set xcode_vers 16.4 24 | revision 0 25 | supported_archs arm64 x86_64 26 | homepage https://developer.apple.com/documentation/Xcode-Release-Notes/xcode-16_4-release-notes 27 | 28 | distname MacOSX${version} 29 | checksums rmd160 06eb1bf497d8b2923b83b97c07d9eb665b8c3578 \ 30 | sha256 ed6c699c840f27bf0f3bdfb4ee83977c2baf830fa66680226b0c1ce9eae48e81 \ 31 | size 75733323 32 | 33 | post-build { 34 | xinstall -d ${destroot}${sdk_dir} 35 | ln -sf ${sdk_dir}/MacOSX15.5.sdk ${destroot}${sdk_dir}/MacOSX15.sdk 36 | } 37 | } 38 | 39 | subport MacOSX14.sdk { 40 | github.setup gcenx macos-sdk 14.5 41 | set macos_name {macOS Sonoma} 42 | set xcode_vers 15.4 43 | revision 0 44 | supported_archs arm64 x86_64 45 | homepage https://developer.apple.com/documentation/Xcode-Release-Notes/xcode-15_4-release-notes 46 | 47 | distname MacOSX${version} 48 | checksums rmd160 139e70af8afdd602bbae1eddcdb7f35263e985bf \ 49 | sha256 0aa945fa4f3f0e8d53c791f4468b61d35ac36dbc10753544c5d066596fb39fbc \ 50 | size 79527486 51 | 52 | post-build { 53 | xinstall -d ${destroot}${sdk_dir} 54 | ln -sf ${sdk_dir}/MacOSX14.5.sdk ${destroot}${sdk_dir}/MacOSX14.sdk 55 | } 56 | } 57 | 58 | subport MacOSX13.sdk { 59 | github.setup gcenx macos-sdk 13.3 60 | set macos_name {macOS Ventura} 61 | set xcode_vers 14.3 62 | revision 0 63 | supported_archs arm64 x86_64 64 | homepage https://developer.apple.com/documentation/macos-release-notes/macos-13_3-release-notes 65 | 66 | distname MacOSX${version} 67 | checksums rmd160 66a2ea8860bac4eda3d85f2789540b3228e7898c \ 68 | sha256 e6608c69387b19840d2b38a77b2f43edbda8024c892fe4fa34d48f7447b07f8a \ 69 | size 69926087 70 | 71 | post-build { 72 | xinstall -d ${destroot}${sdk_dir} 73 | ln -sf ${sdk_dir}/MacOSX13.3.sdk ${destroot}${sdk_dir}/MacOSX13.sdk 74 | } 75 | } 76 | 77 | subport MacOSX12.sdk { 78 | github.setup gcenx macos-sdk 12.3 79 | set macos_name {macOS Montery} 80 | set xcode_vers 13.3 81 | revision 0 82 | supported_archs arm64 x86_64 83 | homepage https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes 84 | 85 | distname MacOSX${version} 86 | checksums rmd160 a461015180833f888df142ed184b9c09f7a0d189 \ 87 | sha256 e951a52b9a1d3304f85aa93a45bbbe2237e0634efdb37d16a5bcbaaff8d4b210 \ 88 | size 67238967 89 | 90 | post-build { 91 | xinstall -d ${destroot}${sdk_dir} 92 | ln -sf ${sdk_dir}/MacOSX12.3.sdk ${destroot}${sdk_dir}/MacOSX12.sdk 93 | } 94 | } 95 | 96 | subport MacOSX11.sdk { 97 | github.setup gcenx macos-sdk 11.3 98 | set macos_name {macOS Big Sur} 99 | set xcode_vers 12.5 100 | revision 0 101 | supported_archs arm64 x86_64 102 | homepage https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_3-release-notes 103 | 104 | distname MacOSX${version} 105 | checksums rmd160 3868c756a2ed1d778016b7fa5d6b2950d2c246af \ 106 | sha256 d6604578f4ee3090d1c3efce1e5c336ecfd7be345d046c729189d631ea3b8ec6 \ 107 | size 75910500 108 | 109 | post-build { 110 | xinstall -d ${destroot}${sdk_dir} 111 | ln -sf ${sdk_dir}/MacOSX11.3.sdk ${destroot}${sdk_dir}/MacOSX11.sdk 112 | } 113 | } 114 | 115 | subport MacOSX10.15.sdk { 116 | github.setup gcenx macos-sdk 10.15 117 | set macos_name {macOS Catalina} 118 | set xcode_vers 12 119 | revision 0 120 | supported_archs x86_64 121 | homepage https://developer.apple.com/documentation/macos-release-notes/macos-catalina-10_15-release-notes 122 | 123 | distname MacOSX${version} 124 | checksums rmd160 580ec054e9d38fe846ce597a0f775d3fc46526b5 \ 125 | sha256 bb548125ebf5cf4ae6c80d226f40ad39e155564ca78bc00554a2e84074d0180e \ 126 | size 41636648 127 | } 128 | 129 | subport MacOSX10.14.sdk { 130 | github.setup gcenx macos-sdk 10.14 131 | set macos_name {macOS Mojave} 132 | set xcode_vers 10.3 133 | revision 0 134 | supported_archs x86_64 135 | homepage https://developer.apple.com/documentation/macos-release-notes/macos-mojave-10_14-release-notes 136 | 137 | distname MacOSX${version} 138 | checksums rmd160 7684478f171e30842274fafb784b91a8e79485dd \ 139 | sha256 e0a9747ae9838aeac70430c005f9757587aa055c690383d91165cf7b4a80401d \ 140 | size 31704241 141 | } 142 | 143 | subport MacOSX10.13.sdk { 144 | github.setup gcenx macos-sdk 10.13 145 | set macos_name {macOS High Sierra} 146 | set xcode_vers 9.3 147 | revision 0 148 | supported_archs i386 x86_64 149 | homepage https://developer.apple.com/library/archive/releasenotes/General/RN-macOSSDK-10.13 150 | 151 | distname MacOSX${version} 152 | checksums rmd160 255ee173939065c9d1b7433f287163cdd00e0033 \ 153 | sha256 27943fb63c35e262b2da1cb4cc60d7427702a40caf20ec15c9d773919c6e409b \ 154 | size 32183283 155 | } 156 | 157 | # Earlier SDKs contain only binaries not .tbd stubs (rev-upgrade) 158 | 159 | pre-destroot { 160 | xinstall -d ${destroot}${sdk_dir} 161 | } 162 | 163 | if {${subport} eq ${name}} { 164 | version 15 165 | revision 0 166 | description latest macOS SDK 167 | long_description This port installs a symlink to the latest macOS SDK. 168 | distfiles 169 | supported_archs noarch 170 | depends_run-append port:MacOSX${version}.sdk 171 | destroot { 172 | ln -s MacOSX${version}.sdk ${destroot}${sdk_dir}/MacOSX.sdk 173 | } 174 | } else { 175 | github.tarball_from releases 176 | set macos_version [lindex [split ${version} -] 0] 177 | set macos_build [lindex [split ${version} -] 1] 178 | set macos_major [join [lrange [split ${macos_version} .] 0 1] .] 179 | 180 | description ${macos_name} v${macos_version} (${macos_build}) SDK 181 | long_description This port installs the ${macos_name} v${macos_version} (${macos_build}) SDK. 182 | destroot { 183 | move ${workpath}/MacOSX${version}.sdk ${destroot}${sdk_dir} 184 | } 185 | livecheck none 186 | } 187 | 188 | if {[llength ${supported_archs}] > 1} { 189 | configure.universal_archs {*}${supported_archs} 190 | variant universal {} 191 | default_variants +universal 192 | variant_set universal 193 | } 194 | -------------------------------------------------------------------------------- /emulators/wine-devel/files/0003-wow64cpu-CW-HACK-20760.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/wow64cpu/cpu.c b/dlls/wow64cpu/cpu.c 2 | index 4a49989ee57..7c89fc34364 100644 3 | --- a/dlls/wow64cpu/cpu.c 4 | +++ b/dlls/wow64cpu/cpu.c 5 | @@ -40,10 +40,35 @@ struct thunk_32to64 6 | DWORD addr; 7 | WORD cs; 8 | }; 9 | +struct thunk_32to64_rosetta2_workaround 10 | +{ 11 | + BYTE lcall; /* call far, absolute indirect */ 12 | + BYTE modrm; /* address=disp32, opcode=3 */ 13 | + DWORD op; 14 | + DWORD addr; 15 | + WORD cs; 16 | + 17 | + BYTE add; 18 | + BYTE add_modrm; 19 | + BYTE add_op; 20 | + 21 | + BYTE jmp; 22 | + BYTE jmp_modrm; 23 | + DWORD jmp_op; 24 | + ULONG64 jmp_addr; 25 | +}; 26 | struct thunk_opcodes 27 | { 28 | - struct thunk_32to64 syscall_thunk; 29 | - struct thunk_32to64 unix_thunk; 30 | + union 31 | + { 32 | + struct thunk_32to64 syscall_thunk; 33 | + struct thunk_32to64_rosetta2_workaround syscall_thunk_rosetta; 34 | + }; 35 | + union 36 | + { 37 | + struct thunk_32to64 unix_thunk; 38 | + struct thunk_32to64_rosetta2_workaround unix_thunk_rosetta; 39 | + }; 40 | }; 41 | #pragma pack(pop) 42 | 43 | @@ -58,6 +83,19 @@ static USHORT fs32_sel; 44 | 45 | void **__wine_unix_call_dispatcher = NULL; 46 | 47 | +BOOL use_rosetta2_workaround; 48 | + 49 | +static BOOL is_rosetta2(void) 50 | +{ 51 | + char buffer[64]; 52 | + NTSTATUS status = NtQuerySystemInformation( SystemProcessorBrandString, buffer, sizeof(buffer), NULL ); 53 | + 54 | + if (status || !strstr( buffer, "VirtualApple" )) 55 | + return FALSE; 56 | + 57 | + return TRUE; 58 | +} 59 | + 60 | BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, void *reserved ) 61 | { 62 | if (reason == DLL_PROCESS_ATTACH) LdrDisableThreadCalloutsForDll( inst ); 63 | @@ -211,7 +249,21 @@ __ASM_GLOBAL_FUNC( syscall_32to64, 64 | "movl %edx,4(%rsp)\n\t" 65 | "movl 0xc4(%r13),%r14d\n\t" /* context->Esp */ 66 | "xchgq %r14,%rsp\n\t" 67 | - "ljmp *(%r14)\n" 68 | + 69 | + /* CW HACK 20760: 70 | + * When running under Rosetta 2, use lretq instead of ljmp to work around a SIGUSR1 race condition. 71 | + */ 72 | + "cmpl $0, " __ASM_NAME("use_rosetta2_workaround") "\n\t" 73 | + "jne syscall_32to64_rosetta2_workaround\n\t" 74 | + "ljmp *(%r14)\n\t" 75 | + "syscall_32to64_rosetta2_workaround:\n\t" 76 | + "subq $0x10,%rsp\n\t" 77 | + "movl 4(%r14),%edx\n\t" 78 | + "movq %rdx,0x8(%rsp)\n\t" 79 | + "movl 0(%r14),%edx\n\t" 80 | + "movq %rdx,(%rsp)\n\t" 81 | + "lretq\n" 82 | + 83 | ".Lsyscall_32to64_return:\n\t" 84 | "movq %rsp,%r14\n\t" 85 | "movl 0xa8(%r13),%edx\n\t" /* context->Edx */ 86 | @@ -271,7 +323,20 @@ __ASM_GLOBAL_FUNC( unix_call_32to64, 87 | "movl %edx,4(%rsp)\n\t" 88 | "movl 0xc4(%r13),%r14d\n\t" /* context->Esp */ 89 | "xchgq %r14,%rsp\n\t" 90 | - "ljmp *(%r14)" ) 91 | + 92 | + /* CW HACK 20760: 93 | + * When running under Rosetta 2, use lretq instead of ljmp to work around a SIGUSR1 race condition. 94 | + */ 95 | + "cmpl $0, " __ASM_NAME("use_rosetta2_workaround") "\n\t" 96 | + "jne unix_call_32to64_rosetta2_workaround\n\t" 97 | + "ljmp *(%r14)\n\t" 98 | + "unix_call_32to64_rosetta2_workaround:\n\t" 99 | + "subq $0x10,%rsp\n\t" 100 | + "movl 4(%r14),%edx\n\t" 101 | + "movq %rdx,0x8(%rsp)\n\t" 102 | + "movl 0(%r14),%edx\n\t" 103 | + "movq %rdx,(%rsp)\n\t" 104 | + "lretq" ) 105 | 106 | 107 | /********************************************************************** 108 | @@ -322,6 +387,8 @@ NTSTATUS WINAPI BTCpuProcessInit(void) 109 | 110 | wow64info->CpuFlags |= WOW64_CPUFLAGS_MSFT64; 111 | 112 | + use_rosetta2_workaround = is_rosetta2(); 113 | + 114 | LdrGetDllHandle( NULL, 0, &str, &module ); 115 | p__wine_unix_call_dispatcher = RtlFindExportedRoutineByName( module, "__wine_unix_call_dispatcher" ); 116 | __wine_unix_call_dispatcher = *p__wine_unix_call_dispatcher; 117 | @@ -336,17 +403,65 @@ NTSTATUS WINAPI BTCpuProcessInit(void) 118 | cs32_sel = context_i386.SegCs; 119 | ss32_sel = context_i386.SegSs; 120 | 121 | - thunk->syscall_thunk.ljmp = 0xff; 122 | - thunk->syscall_thunk.modrm = 0x2d; 123 | - thunk->syscall_thunk.op = PtrToUlong( &thunk->syscall_thunk.addr ); 124 | - thunk->syscall_thunk.addr = PtrToUlong( syscall_32to64 ); 125 | - thunk->syscall_thunk.cs = cs64_sel; 126 | - 127 | - thunk->unix_thunk.ljmp = 0xff; 128 | - thunk->unix_thunk.modrm = 0x2d; 129 | - thunk->unix_thunk.op = PtrToUlong( &thunk->unix_thunk.addr ); 130 | - thunk->unix_thunk.addr = PtrToUlong( unix_call_32to64 ); 131 | - thunk->unix_thunk.cs = cs64_sel; 132 | + /* CW HACK 20760 */ 133 | + if (use_rosetta2_workaround) 134 | + { 135 | + thunk->syscall_thunk_rosetta.lcall = 0xff; 136 | + thunk->syscall_thunk_rosetta.modrm = 0x1d; 137 | + thunk->syscall_thunk_rosetta.op = PtrToUlong( &thunk->syscall_thunk_rosetta.addr ); 138 | + thunk->syscall_thunk_rosetta.addr = PtrToUlong( &thunk->syscall_thunk_rosetta.add ); 139 | + thunk->syscall_thunk_rosetta.cs = cs64_sel; 140 | + 141 | + /* We are now in 64-bit. */ 142 | + /* add $0x08,%esp to remove the addr/segment pushed on the stack by the lcall */ 143 | + thunk->syscall_thunk_rosetta.add = 0x83; 144 | + thunk->syscall_thunk_rosetta.add_modrm = 0xc4; 145 | + thunk->syscall_thunk_rosetta.add_op = 0x08; 146 | + 147 | + /* jmp to syscall_32to64 */ 148 | + thunk->syscall_thunk_rosetta.jmp = 0xff; 149 | + thunk->syscall_thunk_rosetta.jmp_modrm = 0x25; 150 | + thunk->syscall_thunk_rosetta.jmp_op = 0x00; 151 | + thunk->syscall_thunk_rosetta.jmp_addr = PtrToUlong( syscall_32to64 ); 152 | + } 153 | + else 154 | + { 155 | + thunk->syscall_thunk.ljmp = 0xff; 156 | + thunk->syscall_thunk.modrm = 0x2d; 157 | + thunk->syscall_thunk.op = PtrToUlong( &thunk->syscall_thunk.addr ); 158 | + thunk->syscall_thunk.addr = PtrToUlong( syscall_32to64 ); 159 | + thunk->syscall_thunk.cs = cs64_sel; 160 | + } 161 | + 162 | + /* CW HACK 20760 */ 163 | + if (use_rosetta2_workaround) 164 | + { 165 | + thunk->unix_thunk_rosetta.lcall = 0xff; 166 | + thunk->unix_thunk_rosetta.modrm = 0x1d; 167 | + thunk->unix_thunk_rosetta.op = PtrToUlong( &thunk->unix_thunk_rosetta.addr ); 168 | + thunk->unix_thunk_rosetta.addr = PtrToUlong( &thunk->unix_thunk_rosetta.add ); 169 | + thunk->unix_thunk_rosetta.cs = cs64_sel; 170 | + 171 | + /* We are now in 64-bit. */ 172 | + /* add $0x08,%esp to remove the addr/segment pushed on the stack by the lcall */ 173 | + thunk->unix_thunk_rosetta.add = 0x83; 174 | + thunk->unix_thunk_rosetta.add_modrm = 0xc4; 175 | + thunk->unix_thunk_rosetta.add_op = 0x08; 176 | + 177 | + /* jmp to unix_call_32to64 */ 178 | + thunk->unix_thunk_rosetta.jmp = 0xff; 179 | + thunk->unix_thunk_rosetta.jmp_modrm = 0x25; 180 | + thunk->unix_thunk_rosetta.jmp_op = 0x00; 181 | + thunk->unix_thunk_rosetta.jmp_addr = PtrToUlong( unix_call_32to64 ); 182 | + } 183 | + else 184 | + { 185 | + thunk->unix_thunk.ljmp = 0xff; 186 | + thunk->unix_thunk.modrm = 0x2d; 187 | + thunk->unix_thunk.op = PtrToUlong( &thunk->unix_thunk.addr ); 188 | + thunk->unix_thunk.addr = PtrToUlong( unix_call_32to64 ); 189 | + thunk->unix_thunk.cs = cs64_sel; 190 | + } 191 | 192 | NtProtectVirtualMemory( GetCurrentProcess(), (void **)&thunk, &size, PAGE_EXECUTE_READ, &old_prot ); 193 | return STATUS_SUCCESS; 194 | -------------------------------------------------------------------------------- /cross/mingw-w64-wine-mono/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | 5 | name mingw-w64-wine-mono 6 | categories cross 7 | maintainers {@Gcenx} 8 | homepage https://github.com/madewokherd/wine-mono 9 | license GPL LGPL-2.1 MPL 10 | platforms any 11 | supported_archs noarch 12 | description Wine's built-in replacement for Microsoft's .NET Framework 13 | long_description ${subport} is a package containing Mono and other projects, \ 14 | intended as a replacement for the .NET runtime and class \ 15 | libraries in Wine. It works in conjunction with Wine's \ 16 | builtin mscoree.dll, and it is not intended to be useful \ 17 | for any other purpose. 18 | 19 | use_configure no 20 | build {} 21 | 22 | if {${subport} eq ${name}} { 23 | PortGroup stub 1.0 24 | version 10.4.0 25 | revision 0 26 | depends_run port:mingw-w64-wine-mono-${version} 27 | 28 | post-deactivate { 29 | # When this port is deactivated, mingw-w64-wine-mono-${version} should also be. 30 | if {![catch {set installed [lindex [registry_active mingw-w64-wine-mono-${version}] 0]}]} { 31 | registry_deactivate_composite mingw-w64-wine-mono-${version} "" [list ports_nodepcheck 1] 32 | } 33 | } 34 | } 35 | 36 | # wine-devel (11.0-rc1) 37 | subport ${name}-10.4.0 { 38 | version 10.4.0 39 | revision 0 40 | distname wine-mono-${version}-x86 41 | checksums rmd160 41430810def0e0ad11cdf8659f8de2af641e59b6 \ 42 | sha256 2ca7b7083b52357f09c84a577709e65bba54c6c356ec052fbfab6003ecb2012a \ 43 | size 41326992 44 | use_xz yes 45 | } 46 | 47 | # wine-devel (10.17) 48 | subport ${name}-10.3.0 { 49 | version 10.3.0 50 | revision 0 51 | distname wine-mono-${version}-x86 52 | checksums rmd160 581e1773107ca7da05475a301bce6634b662fd10 \ 53 | sha256 009651c4baa2c5010c70aa28728a85e24a04485ff0e22b8cd5eea4eb8959e72e \ 54 | size 39584548 55 | use_xz yes 56 | } 57 | 58 | # wine-devel (10.14) 59 | subport ${name}-10.2.0 { 60 | version 10.2.0 61 | revision 0 62 | distname wine-mono-${version}-x86 63 | checksums rmd160 6b1e0ad2fbf4589daf6990da2486a0efa03b46e6 \ 64 | sha256 ba12894e566944be8a04fdae62e0ebe0908a159020ab9a4e72ac4db774732de0 \ 65 | size 39565980 66 | use_xz yes 67 | } 68 | 69 | # wine-devel (10.10) 70 | subport ${name}-10.1.0 { 71 | version 10.1.0 72 | revision 0 73 | distname wine-mono-${version}-x86 74 | checksums rmd160 4524af91ef4ae8b429194322cbbae3db33988a0d \ 75 | sha256 7f4763edd350503a3a70b1bbbdbff944f1f4bb1552f0731957363d162ce2589a \ 76 | size 41299152 77 | use_xz yes 78 | } 79 | 80 | # wine-devel (10.5) 81 | subport ${name}-10.0.0 { 82 | version 10.0.0 83 | revision 0 84 | distname wine-mono-${version}-x86 85 | checksums rmd160 839cb0a17b4f6c9961c13c8ceb65b7e6b50ec0d8 \ 86 | sha256 b487c444415789a8b25b3a6542afa668a6b6d6067c648626f323884443f7b70d \ 87 | size 38907080 88 | use_xz yes 89 | } 90 | 91 | # wine-devel (10.0-rc1) 92 | subport ${name}-9.4.0 { 93 | version 9.4.0 94 | revision 0 95 | distname wine-mono-${version}-x86 96 | checksums rmd160 2e06c050350f7723a4989f551303b3f50b12c4ee \ 97 | sha256 fd772219aacf46b825fa891a647af4a9ddf8439320101c231918b2037bf13858 \ 98 | size 43941584 99 | use_xz yes 100 | } 101 | 102 | # wine-devel (9.17) 103 | subport ${name}-9.3.0 { 104 | version 9.3.0 105 | revision 0 106 | distname wine-mono-${version}-x86 107 | checksums rmd160 e7f87fe3ecb4b9b84bcbfd63b5d2725e000bf7dd \ 108 | sha256 c23deb9e3217a574f242b78d74cb94c4948a37d1f2715941b803a02e535854a6 \ 109 | size 43906032 110 | use_xz yes 111 | } 112 | 113 | # wine-devel (9.12) 114 | subport ${name}-9.2.0 { 115 | version 9.2.0 116 | revision 0 117 | distname wine-mono-${version}-x86 118 | checksums rmd160 89291549e683e4d22e5f92240d9518aefbde92ec \ 119 | sha256 59b35dfe525f32c581884b6c7865496e13b3cd200c5ed267c43fb4663e0cd757 \ 120 | size 43901320 121 | use_xz yes 122 | } 123 | 124 | # wine-devel (9.8) 125 | subport ${name}-9.1.0 { 126 | version 9.1.0 127 | revision 0 128 | distname wine-mono-${version}-x86 129 | checksums rmd160 650ab69c60a2ead85937fb32d7b62c4d779deaff \ 130 | sha256 601169d0203b291fbfd946b356a9538855e01de22abd470ded73baf312c88767 \ 131 | size 43820028 132 | use_xz yes 133 | } 134 | 135 | # wine-devel (9.2) 136 | subport ${name}-9.0.0 { 137 | version 9.0.0 138 | revision 0 139 | distname wine-mono-${version}-x86 140 | checksums rmd160 ea5a5c85b464fbdded518cacadfe26f063d299cb \ 141 | sha256 d73d440c08ebd67c93fbd6534f4f1b4e98aa07342f9c7d98c8aaeb74755eb9cf \ 142 | size 40970928 143 | use_xz yes 144 | } 145 | 146 | # wine-stable (9.0) 147 | subport ${name}-8.1.0 { 148 | version 8.1.0 149 | revision 0 150 | distname wine-mono-${version}-x86 151 | checksums rmd160 530ca1616f719c6171c55ad0fedcae4dd8c5561b \ 152 | sha256 4e3e8a40729e4c9e3e9e651cebe4f1aed8f9a4d22e991e6cd24608687f0eedd4 \ 153 | size 40854944 154 | use_xz yes 155 | } 156 | 157 | # game-porting-toolkit 158 | subport ${name}-7.4.1 { 159 | version 7.4.1 160 | revision 0 161 | distname wine-mono-${version}-x86 162 | checksums rmd160 53d7dddb324ce92f85321c54e2995121c5ed7729 \ 163 | sha256 1286afc67b0a329f5e2d98d9e803ca5906a841ad5486e9b3b1fefa1124b15622 \ 164 | size 44433444 165 | use_xz yes 166 | } 167 | 168 | # wine-devel (7.22) 169 | subport ${name}-7.4.0 { 170 | version 7.4.0 171 | revision 0 172 | distname wine-mono-${version}-x86 173 | checksums rmd160 8df357ccd7e98c841b13a1eabfe8561f4a4900b8 \ 174 | sha256 9249ece664bcf2fecb1308ea1d2542c72923df9fe3df891986f137b2266a9ba3 \ 175 | size 45404344 176 | use_xz yes 177 | } 178 | 179 | # wine-stable (7.6) 180 | subport ${name}-7.2.0 { 181 | version 7.2.0 182 | revision 0 183 | distname wine-mono-${version}-x86 184 | checksums rmd160 9d0e730bd0c34590b6398c05e63bb594e9c19359 \ 185 | sha256 25a4d08fee9197be83307e65553da450b6d4446cc9188d0a85212cc2cee2660d \ 186 | size 42477712 187 | use_xz yes 188 | } 189 | 190 | # wine-stable (7.0.2) 191 | subport ${name}-7.0.0 { 192 | version 7.0.0 193 | revision 0 194 | distname wine-mono-${version}-x86 195 | checksums rmd160 96f7316927cef5ea35197389e425c54b0dccc3fb \ 196 | sha256 2a047893f047b4f0f5b480f1947b7dda546cee3fec080beb105bf5759c563cd3 \ 197 | size 45085800 198 | use_xz yes 199 | } 200 | 201 | # wine-devel (6.8) 202 | subport ${name}-6.1.1 { 203 | version 6.1.1 204 | revision 0 205 | distname wine-mono-${version}-x86 206 | checksums rmd160 a27137adc908a4eb1a262cc0502ef73d5a1894e2 \ 207 | sha256 c3bab46c3e69ecdda61532c28c6a94a78aef9c750cc18dbb60151e0697714d6d \ 208 | size 45702072 209 | use_xz yes 210 | } 211 | 212 | # wine-stable (6.0.4) 213 | subport ${name}-5.1.1 { 214 | version 5.1.1 215 | revision 0 216 | distname wine-mono-${version}-x86 217 | checksums rmd160 9f3b7597ee1d71d9adb656033fea173b964ebd6e \ 218 | sha256 b17ac815afbf5eef768c4e8d50800be02af75c8b230d668e239bad99616caa82 \ 219 | size 44710604 220 | use_xz yes 221 | } 222 | 223 | master_sites http://dl.winehq.org/wine/wine-mono/${version} \ 224 | https://github.com/madewokherd/wine-mono/releases/download/wine-mono-${version} 225 | 226 | destroot { 227 | xinstall -d ${destroot}${prefix}/share/wine/mono 228 | file copy ${workpath}/wine-mono-${version} ${destroot}${prefix}/share/wine/mono 229 | } 230 | 231 | livecheck none 232 | -------------------------------------------------------------------------------- /devel/game-porting-toolkit/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup github 1.0 5 | PortGroup muniversal 1.1 6 | 7 | # Using custom mirror to avoid embedding huge patchfiles 8 | github.setup gcenx wine 3a8755fc3e6067fb55b5156812b7418696ef0407 9 | github.tarball_from archive 10 | name game-porting-toolkit 11 | version 1.1 12 | revision 7 13 | platforms {darwin any >= 23} 14 | license LGPL-2.1+ 15 | categories devel 16 | supported_archs x86_64 17 | maintainers {@Gcenx} 18 | homepage https://developer.apple.com/games 19 | dist_subdir wine 20 | 21 | description Game Porting Toolkit ${version} 22 | long_description Use the game porting toolkit to eliminate months of up-front work and \ 23 | evaluate how well your game could run on Mac before writing any code. 24 | 25 | checksums \ 26 | rmd160 505178f6a42b53fe1c7297ba7ba2249fbf7d0b99 \ 27 | sha256 972ff467cc73dcd3d69448f6baf013693c5841d28107959c266504058651c8c0 \ 28 | size 46810271 29 | 30 | depends_build \ 31 | port:bison \ 32 | bin:flex:flex \ 33 | port:gettext \ 34 | port:llvm-cx \ 35 | port:mingw-w64 \ 36 | path:bin/pkg-config:pkgconfig 37 | 38 | depends_lib \ 39 | port:freetype \ 40 | port:gettext-runtime \ 41 | port:gnutls-devel \ 42 | port:libpcap \ 43 | port:libsdl2 44 | 45 | depends_run \ 46 | port:d3dmetal \ 47 | port:mingw-w64-wine-gecko-2.47.2 \ 48 | port:mingw-w64-wine-mono-7.4.1 49 | 50 | patch.pre_args-replace -p0 -p1 51 | 52 | patchfiles-append \ 53 | 1001-configure-remove-cross_compiling-check.diff \ 54 | 1002-ntdll-d3dmetal-env.diff \ 55 | 1003-build_fixes.diff 56 | 57 | configure.checks.implicit_function_declaration.whitelist-append \ 58 | __clear_cache \ 59 | fallocate \ 60 | gethostbyaddr_r \ 61 | gethostbyname_r \ 62 | sched_setaffinity 63 | 64 | # wine requires the program specified in INSTALL to create intermediate 65 | # directories; /usr/bin/install doesn't. 66 | # http://bugs.winehq.org/show_bug.cgi?id=35310 67 | configure.install \ 68 | ${worksrcpath}/tools/install-sh 69 | 70 | # Installing into libexec to not confict with wine 71 | configure.pre_args \ 72 | --prefix=${prefix}/libexec/${name} 73 | 74 | configure.pre_args.i386 \ 75 | --with-wine64=${workpath}/${worksrcdir}-x86_64 \ 76 | --enable-win32on64 \ 77 | --disable-loader 78 | 79 | configure.args.x86_64 \ 80 | --enable-win64 81 | 82 | configure.args \ 83 | --without-alsa \ 84 | --without-capi \ 85 | --with-coreaudio \ 86 | --with-cups \ 87 | --without-dbus \ 88 | --without-fontconfig \ 89 | --with-freetype \ 90 | --with-gettext \ 91 | --without-gettextpo \ 92 | --without-gphoto \ 93 | --with-gnutls \ 94 | --without-gssapi \ 95 | --without-gstreamer \ 96 | --without-inotify \ 97 | --without-krb5 \ 98 | --with-mingw \ 99 | --without-netapi \ 100 | --without-openal \ 101 | --with-opencl \ 102 | --with-opengl \ 103 | --without-oss \ 104 | --with-pcap \ 105 | --with-pthread \ 106 | --without-pulse \ 107 | --without-sane \ 108 | --with-sdl \ 109 | --without-udev \ 110 | --with-unwind \ 111 | --without-usb \ 112 | --without-v4l2 \ 113 | --without-vulkan \ 114 | --without-x 115 | 116 | configure.args-append \ 117 | --disable-tests \ 118 | --disable-winedbg \ 119 | --disable-winemenubuilder 120 | 121 | # We need to tell the linker to add MacPorts & d3dmetal to the rpath stack. 122 | configure.ldflags-append -Wl,-rpath,${compiler.library_path} -Wl,-rpath,${prefix}/libexec/d3dmetal/external 123 | 124 | # Xcode15 linker requires -ld_classic to enable legacy behaviours required to build wine 125 | configure.ldflags-prepend -Wl,-ld_classic 126 | 127 | # Xcode15.3 default SDK causes the build to fail so fallback to a working SDK 128 | configure.sdk_version 13 129 | if {${configure.sdkroot} != "${developer_dir}/SDKs/MacOSX${configure.sdk_version}.sdk"} { 130 | depends_build-append port:MacOSX${configure.sdk_version}.sdk 131 | configure.sdkroot ${prefix}/Developer/SDKs/MacOSX${configure.sdk_version}.sdk 132 | } 133 | 134 | # Use an older deployment target to avoid new dyld behaviors. 135 | # The custom compiler is too old to accept "13.0", so we use "10.14". 136 | macosx_deployment_target 10.14 137 | 138 | variant gstreamer description "Build ${subport} with GStreamer, for multimedia support" { 139 | depends_lib-append path:Library/Frameworks/GStreamer.framework:gstreamer.framework 140 | configure.args-replace --without-gstreamer --with-gstreamer 141 | 142 | pre-configure { 143 | configure.env-append "GSTREAMER_CFLAGS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --cflags gstreamer-1.0 gstreamer-video-1.0 gstreamer-audio-1.0]" 144 | configure.env-append "GSTREAMER_LIBS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --libs gstreamer-1.0 gstreamer-video-1.0 gstreamer-audio-1.0]" 145 | } 146 | 147 | post-configure { 148 | reinplace -q "s|Versions/1.0/lib/pkgconfig/../../lib|Libraries|g" ${worksrcpath}-i386/config.status 149 | reinplace -q "s|Versions/1.0/lib/pkgconfig/../../lib|Libraries|g" ${worksrcpath}-x86_64/config.status 150 | } 151 | } 152 | 153 | default_variants +gstreamer 154 | 155 | triplet.add_build cross 156 | triplet.add_host none 157 | 158 | configure.cc ${prefix}/libexec/llvm-cx/bin/clang 159 | configure.cxx ${prefix}/libexec/llvm-cx/bin/clang++ 160 | configure.cmd ${worksrcpath}/configure 161 | configure.compiler.add_deps no 162 | 163 | # macports-base injects a number of flags that now propagate to mingw-gcc this causes the build to fail since, wine-7.21 164 | # https://gitlab.winehq.org/wine/wine/-/commit/b1f59bc679a8c2dea18a6789a5b9b1a1ae825129 165 | compiler.limit_flags yes 166 | muniversal.arch_flag no 167 | muniversal.arch_compiler yes 168 | configure.ldflags-delete -L${compiler.library_path} 169 | configure.optflags -O3 170 | # gcc14 Sets -Werror=incompatible-pointer-types & -Werror=int-conversion by default 171 | # gcc15 Sets -std=gnu23 by default 172 | configure.env-append "CROSSCFLAGS=${configure.optflags} -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -std=gnu17" 173 | 174 | # Were only installing wine not the development files 175 | destroot.target install-lib 176 | 177 | configure { 178 | set configure.dir ${worksrcpath}-x86_64 179 | portconfigure::configure_main 180 | 181 | configure.args.x86_64 182 | set configure.dir ${worksrcpath}-i386 183 | configure.args-delete --enable-win64 184 | configure.args ${configure.pre_args.i386} ${configure.args} ${configure.args.i386} 185 | portconfigure::configure_main 186 | } 187 | 188 | build { 189 | set build.dir ${worksrcpath}-x86_64 190 | portbuild::build_main 191 | 192 | set build.dir ${worksrcpath}-i386 193 | portbuild::build_main 194 | } 195 | 196 | destroot { 197 | set destroot.dir ${worksrcpath}-x86_64 198 | portdestroot::destroot_main 199 | 200 | set destroot.dir ${worksrcpath}-i386 201 | portdestroot::destroot_main 202 | } 203 | 204 | post-destroot { 205 | ln -sf ${prefix}/share/wine/gecko ${destroot}${prefix}/libexec/${name}/share/wine/gecko 206 | ln -sf ${prefix}/share/wine/mono ${destroot}${prefix}/libexec/${name}/share/wine/mono 207 | 208 | xinstall -W ${filespath} \ 209 | gameportingtoolkit \ 210 | gameportingtoolkit-no-esync \ 211 | gameportingtoolkit-no-hud \ 212 | ${destroot}${prefix}/bin/ 213 | 214 | reinplace -W ${destroot}${prefix}/bin "s|@@PREFIX@@|${prefix}|g" \ 215 | gameportingtoolkit \ 216 | gameportingtoolkit-no-esync \ 217 | gameportingtoolkit-no-hud 218 | 219 | if {[variant_isset gstreamer]} { 220 | system -W ${destroot}${prefix}/libexec/${name}/lib/wine/x86_64-unix "/usr/bin/install_name_tool -delete_rpath ${compiler.library_path} winegstreamer.so" 221 | system -W ${destroot}${prefix}/libexec/${name}/lib/wine/x86_64-unix "/usr/bin/install_name_tool -delete_rpath ${prefix}/libexec/d3dmetal/external winegstreamer.so" 222 | system -W ${destroot}${prefix}/libexec/${name}/lib/wine/x86_64-unix "/usr/bin/codesign --force --sign - winegstreamer.so" 223 | system -W ${destroot}${prefix}/libexec/${name}/lib/wine/x86_32on64-unix "/usr/bin/install_name_tool -delete_rpath ${compiler.library_path} winegstreamer.so" 224 | system -W ${destroot}${prefix}/libexec/${name}/lib/wine/x86_32on64-unix "/usr/bin/install_name_tool -delete_rpath ${prefix}/libexec/d3dmetal/external winegstreamer.so" 225 | system -W ${destroot}${prefix}/libexec/${name}/lib/wine/x86_32on64-unix "/usr/bin/codesign --force --sign - winegstreamer.so" 226 | } 227 | } 228 | 229 | platform darwin i386 { 230 | pre-fetch { 231 | if {${os.major} >= 23} { 232 | set is_rosetta2 [exec sysctl -in sysctl.proc_translated] 233 | if { ${is_rosetta2} != 1 } { 234 | error "${name} does not work on Intel hardware" 235 | } 236 | } 237 | } 238 | } 239 | 240 | livecheck none 241 | -------------------------------------------------------------------------------- /emulators/wine-stable/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup github 1.0 5 | PortGroup muniversal 1.1 6 | 7 | # Keep the wine-stable, wine-devel and wine-crossover portfiles as similar as possible. 8 | 9 | github.setup wine-mirror wine 10.0 wine- 10 | github.tarball_from archive 11 | name wine-stable 12 | conflicts wine-devel wine-staging wine-crossover 13 | set my_name wine 14 | revision 0 15 | platforms {darwin > 15} 16 | set branch [lindex [split ${version} .] 0].0 17 | license LGPL-2.1+ 18 | categories emulators 19 | supported_archs i386 x86_64 20 | maintainers {@Gcenx} 21 | homepage https://www.winehq.org 22 | dist_subdir ${my_name} 23 | 24 | description \ 25 | A Windows API implementation 26 | 27 | long_description \ 28 | Wine is a compatibility layer capable of running \ 29 | Windows applications. \ 30 | Instead of simulating internal Windows logic like \ 31 | a virtual machine or emulator, Wine translates \ 32 | Windows API calls into POSIX calls on-the-fly, \ 33 | eliminating the performance and memory penalties \ 34 | of other methods and allowing you to cleanly \ 35 | integrate Windows applications into your desktop. 36 | 37 | checksums \ 38 | ${distname}${extract.suffix} \ 39 | rmd160 0807d7f380af0851151b7abd04490a9636b187f1 \ 40 | sha256 b3edf134a5698d55bd210f11c3ae833c943abcece75810f6aa8cbd7a9f293ff7 \ 41 | size 51935194 42 | 43 | depends_build \ 44 | port:bison \ 45 | bin:flex:flex \ 46 | port:gettext \ 47 | port:mingw-w64 \ 48 | path:bin/pkg-config:pkgconfig 49 | 50 | depends_lib \ 51 | port:freetype \ 52 | port:gettext-runtime \ 53 | port:gnutls-devel \ 54 | port:libinotify \ 55 | port:libpcap \ 56 | port:libsdl2 57 | 58 | depends_run \ 59 | port:mingw-w64-wine-gecko-2.47.4 \ 60 | port:mingw-w64-wine-mono-9.4.0 61 | 62 | post-extract { 63 | # https://gitlab.winehq.org/wine/wine/-/commit/c7a97b5d5d56ef00a0061b75412c6e0e489fdc99 64 | reinplace -q "/PKG_CONFIG_LIBDIR/d" ${worksrcpath}/configure 65 | reinplace -q "/PKG_CONFIG_LIBDIR/d" ${worksrcpath}/configure.ac 66 | } 67 | 68 | patch.pre_args-replace -p0 -p1 69 | 70 | patchfiles-append \ 71 | 0001-winehq_macos_hacks.diff 72 | 73 | patchfiles-append \ 74 | MR6866.diff \ 75 | MR7328.diff 76 | 77 | configure.checks.implicit_function_declaration.whitelist-append \ 78 | __clear_cache \ 79 | fallocate \ 80 | gethostbyaddr_r \ 81 | gethostbyname_r \ 82 | sched_setaffinity 83 | 84 | # wine requires the program specified in INSTALL to create intermediate 85 | # directories; /usr/bin/install doesn't. 86 | # http://bugs.winehq.org/show_bug.cgi?id=35310 87 | configure.install \ 88 | ${worksrcpath}/tools/install-sh 89 | 90 | configure.args.x86_64 \ 91 | --enable-win64 92 | 93 | configure.args \ 94 | --without-alsa \ 95 | --without-capi \ 96 | --with-coreaudio \ 97 | --with-cups \ 98 | --without-dbus \ 99 | --without-ffmpeg \ 100 | --without-fontconfig \ 101 | --with-freetype \ 102 | --with-gettext \ 103 | --without-gettextpo \ 104 | --without-gphoto \ 105 | --with-gnutls \ 106 | --without-gssapi \ 107 | --without-gstreamer \ 108 | --with-inotify \ 109 | --without-krb5 \ 110 | --with-mingw \ 111 | --without-netapi \ 112 | --with-opencl \ 113 | --with-opengl \ 114 | --without-oss \ 115 | --with-pcap \ 116 | --with-pcsclite \ 117 | --with-pthread \ 118 | --without-pulse \ 119 | --without-sane \ 120 | --with-sdl \ 121 | --without-udev \ 122 | --with-unwind \ 123 | --without-usb \ 124 | --without-v4l2 \ 125 | --without-vulkan \ 126 | --without-wayland \ 127 | --without-x 128 | 129 | configure.args-append \ 130 | --disable-tests \ 131 | --disable-winebth_sys \ 132 | --disable-winemenubuilder 133 | 134 | configure.env-append ac_cv_lib_soname_vulkan= 135 | 136 | # We need to tell the linker to add MacPorts to the rpath stack. 137 | configure.ldflags-append -Wl,-rpath,${compiler.library_path} 138 | 139 | # wine requires clang >= 3.8 140 | # FSF GCC cannot compile code using Apple's "blocks" language extensions 141 | compiler.blacklist-append {*gcc*} {clang < 800} {macports-clang-3.*} 142 | 143 | variant gphoto description "Build ${subport} with support for digital cameras" { 144 | depends_lib-append port:libgphoto2 145 | configure.args-replace --without-gphoto --with-gphoto 146 | } 147 | 148 | variant gstreamer description "Build ${subport} with GStreamer, for multimedia support" { 149 | depends_lib-append path:Library/Frameworks/GStreamer.framework:gstreamer.framework 150 | configure.args-replace --without-ffmpeg --with-ffmpeg 151 | configure.args-replace --without-gstreamer --with-gstreamer 152 | 153 | pre-configure { 154 | configure.env-append "FFMPEG_CFLAGS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --cflags libavutil libavformat libavcodec]" 155 | configure.env-append "FFMPEG_LIBS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --libs libavutil libavformat libavcodec]" 156 | configure.env-append "GSTREAMER_CFLAGS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --cflags gstreamer-1.0 gstreamer-video-1.0 gstreamer-audio-1.0 gstreamer-tag-1.0]" 157 | configure.env-append "GSTREAMER_LIBS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --libs gstreamer-1.0 gstreamer-video-1.0 gstreamer-audio-1.0 gstreamer-tag-1.0]" 158 | } 159 | 160 | post-configure { 161 | reinplace -q "s|Versions/1.0/lib/pkgconfig/../../lib|Libraries|g" ${worksrcpath}/config.status 162 | } 163 | } 164 | 165 | variant kerberos description "Build ${subport} with Kerberos, for network authentication protocol support" { 166 | depends_lib-append port:kerberos5 167 | configure.args-replace --without-krb5 --with-krb5 168 | } 169 | 170 | if {${os.major} < 19} { 171 | # CodeWeavers only tests i386 using MacOSX10.13.sdk 172 | configure.sdk_version 10.13 173 | if {${configure.sdkroot} != "${developer_dir}/SDKs/MacOSX${configure.sdk_version}.sdk"} { 174 | depends_build-append port:MacOSX${configure.sdk_version}.sdk 175 | configure.sdkroot ${prefix}/Developer/SDKs/MacOSX${configure.sdk_version}.sdk 176 | } 177 | 178 | default_variants +universal 179 | 180 | if {${universal_possible} && [variant_isset universal]} { 181 | configure.args.i386 --with-wine64=${workpath}/${worksrcdir}-x86_64 182 | 183 | notes-append " 184 | \n 185 | Wine supports both 32-bit and 64-bit now. It is compatible with your\ 186 | existing 32-bit wine prefix, but it will now default to 64-bit when you\ 187 | create a new wine prefix. The architecture can be selected using the\ 188 | WINEARCH environment variable which can be set to either \"win32\" or\ 189 | \"win64\". 190 | \n 191 | To create a new pure 32-bit prefix, you can run: 192 | \$ WINEARCH=win32 WINEPREFIX=~/.wine32 winecfg 193 | \n 194 | See the Wine FAQ for details: https://wiki.winehq.org/FAQ#Wineprefixes 195 | " 196 | } else { 197 | supported_archs i386 198 | } 199 | } 200 | 201 | # MacPorts does not support i386 on macOS Mojave by default 202 | if {${os.major} == 18} { 203 | if {[vercmp ${macosx_deployment_target} != 10.13]} { 204 | platforms {darwin > 15 != 18.*} 205 | } 206 | } 207 | 208 | if {${os.major} > 18} { 209 | depends_lib-append path:lib/libMoltenVK.dylib:MoltenVK-latest 210 | 211 | configure.args.x86_64-append --enable-archs=i386,x86_64 212 | configure.args-replace --without-vulkan --with-vulkan 213 | 214 | # Setting an older deployment target avoids build error with MacOSX15.sdk 215 | # https://gitlab.winehq.org/wine/wine/-/merge_requests/5935#note_74758 216 | macosx_deployment_target 10.15 217 | 218 | default_variants +gstreamer 219 | } 220 | 221 | triplet.add_build cross 222 | triplet.add_host none 223 | 224 | # macports-base injects a number of flags that now propagate to mingw-gcc this causes the build to fail since, wine-7.21 225 | # https://gitlab.winehq.org/wine/wine/-/commit/b1f59bc679a8c2dea18a6789a5b9b1a1ae825129 226 | compiler.limit_flags yes 227 | muniversal.arch_flag no 228 | muniversal.arch_compiler yes 229 | configure.ldflags-delete -L${compiler.library_path} 230 | configure.optflags -O2 231 | configure.env-append "CROSSCFLAGS=${configure.optflags}" 232 | 233 | # Were only installing wine not the development files 234 | destroot.target install-lib 235 | 236 | post-destroot { 237 | set docdir ${prefix}/share/doc/${my_name} 238 | xinstall -d ${destroot}${docdir} 239 | xinstall -m 0644 -W ${worksrcpath} \ 240 | ANNOUNCE.md \ 241 | AUTHORS \ 242 | COPYING.LIB \ 243 | LICENSE \ 244 | README.md \ 245 | ${destroot}${docdir} 246 | 247 | if {[variant_isset gstreamer]} { 248 | system -W ${destroot}${compiler.library_path}/wine/x86_64-unix "/usr/bin/install_name_tool -delete_rpath ${compiler.library_path} winedmo.so" 249 | system -W ${destroot}${compiler.library_path}/wine/x86_64-unix "/usr/bin/install_name_tool -delete_rpath ${compiler.library_path} winegstreamer.so" 250 | system -W ${destroot}${compiler.library_path}/wine/x86_64-unix "/usr/bin/codesign --force --sign - winedmo.so" 251 | system -W ${destroot}${compiler.library_path}/wine/x86_64-unix "/usr/bin/codesign --force --sign - winegstreamer.so" 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /emulators/wine-devel/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | PortGroup github 1.0 5 | PortGroup muniversal 1.1 6 | 7 | # Keep the wine-stable, wine-devel and wine-crossover portfiles as similar as possible. 8 | 9 | github.setup wine-mirror wine 11.0-rc3 wine- 10 | github.tarball_from archive 11 | name wine-devel 12 | conflicts wine-stable wine-staging wine-crossover 13 | revision 0 14 | platforms {darwin > 15} 15 | set branch [lindex [split ${version} .] 0].x 16 | license LGPL-2.1+ 17 | categories emulators 18 | supported_archs i386 x86_64 19 | maintainers {@Gcenx} 20 | homepage https://www.winehq.org 21 | dist_subdir wine 22 | 23 | description \ 24 | A Windows API implementation 25 | 26 | long_description \ 27 | Wine is a compatibility layer capable of running \ 28 | Windows applications. \ 29 | Instead of simulating internal Windows logic like \ 30 | a virtual machine or emulator, Wine translates \ 31 | Windows API calls into POSIX calls on-the-fly, \ 32 | eliminating the performance and memory penalties \ 33 | of other methods and allowing you to cleanly \ 34 | integrate Windows applications into your desktop. 35 | 36 | checksums \ 37 | ${distname}${extract.suffix} \ 38 | rmd160 0ebf8c05ce33e955cd1b9e3af74a5d0dcabd686b \ 39 | sha256 2898271aed7150474a12b30c52d4b76c39d4890827b03c2a22a0076f614cb9cf \ 40 | size 53777661 41 | 42 | depends_build \ 43 | port:bison \ 44 | bin:flex:flex \ 45 | port:gettext \ 46 | port:mingw-w64 \ 47 | path:bin/pkg-config:pkgconfig 48 | 49 | depends_lib \ 50 | port:freetype \ 51 | port:gettext-runtime \ 52 | port:gnutls-devel \ 53 | port:libinotify \ 54 | port:libpcap \ 55 | port:libsdl2 56 | 57 | depends_run \ 58 | port:mingw-w64-wine-gecko-2.47.4 \ 59 | port:mingw-w64-wine-mono-10.4.0 60 | 61 | post-extract { 62 | # https://gitlab.winehq.org/wine/wine/-/commit/c7a97b5d5d56ef00a0061b75412c6e0e489fdc99 63 | reinplace -q "/PKG_CONFIG_LIBDIR/d" ${worksrcpath}/configure 64 | reinplace -q "/PKG_CONFIG_LIBDIR/d" ${worksrcpath}/configure.ac 65 | } 66 | 67 | patch.pre_args-replace -p0 -p1 68 | 69 | # Upstream bug fixes here 70 | 71 | # Rosetta2 hacks here 72 | patchfiles-append \ 73 | 0001-ntdll-CW-HACK-18947.patch \ 74 | 0002-ntdll-CW-HACK-20186.patch \ 75 | 0003-wow64cpu-CW-HACK-20760.patch \ 76 | 0004-ntdll-CW-HACK-22131.patch \ 77 | 0005-ntdll-CW-HACK-23427.patch \ 78 | 0006-ntdll-CW-Hack-24256.patch \ 79 | 0007-ntdll-CW-HACK-24265.patch \ 80 | 0008-ntdll-CW-HACK-24945.patch \ 81 | 0009-ntdll-CW-HACK-25719.patch \ 82 | 0010-ntdll-HACK-Winehq-Bug-56441.patch 83 | 84 | # Steam hacks here 85 | patchfiles-append \ 86 | 0011-kernelbase-HACK-Add-hack_append_command_line.patch \ 87 | 0012-kernelbase-CW-HACK-13322-17315-21883.patch 88 | 89 | # DXMT hacks here 90 | patchfiles-append \ 91 | 0013-ntdll-CW-HACK-22435.patch \ 92 | 0014-winemac-DXMT-export.patch \ 93 | 0015-winemetal-new-stub.patch 94 | 95 | configure.checks.implicit_function_declaration.whitelist-append \ 96 | __clear_cache \ 97 | fallocate \ 98 | gethostbyaddr_r \ 99 | gethostbyname_r \ 100 | sched_setaffinity 101 | 102 | # wine requires the program specified in INSTALL to create intermediate 103 | # directories; /usr/bin/install doesn't. 104 | # http://bugs.winehq.org/show_bug.cgi?id=35310 105 | configure.install \ 106 | ${worksrcpath}/tools/install-sh 107 | 108 | configure.args.x86_64 \ 109 | --enable-win64 110 | 111 | configure.args \ 112 | --without-alsa \ 113 | --without-capi \ 114 | --with-coreaudio \ 115 | --with-cups \ 116 | --without-dbus \ 117 | --without-ffmpeg \ 118 | --without-fontconfig \ 119 | --with-freetype \ 120 | --with-gettext \ 121 | --without-gettextpo \ 122 | --without-gphoto \ 123 | --with-gnutls \ 124 | --without-gssapi \ 125 | --without-gstreamer \ 126 | --with-inotify \ 127 | --without-krb5 \ 128 | --with-mingw \ 129 | --without-netapi \ 130 | --with-opencl \ 131 | --without-opengl \ 132 | --without-oss \ 133 | --with-pcap \ 134 | --with-pcsclite \ 135 | --with-pthread \ 136 | --without-pulse \ 137 | --without-sane \ 138 | --with-sdl \ 139 | --without-udev \ 140 | --with-unwind \ 141 | --without-usb \ 142 | --without-v4l2 \ 143 | --without-vulkan \ 144 | --without-wayland \ 145 | --without-x 146 | 147 | configure.args-append \ 148 | --disable-tests \ 149 | --disable-winebth_sys \ 150 | --disable-winemenubuilder 151 | 152 | configure.env-append ac_cv_lib_soname_vulkan= 153 | 154 | # We need to tell the linker to add MacPorts to the rpath stack. 155 | configure.ldflags-append -Wl,-rpath,${compiler.library_path} 156 | 157 | # wine requires clang >= 3.8 158 | # FSF GCC cannot compile code using Apple's "blocks" language extensions 159 | compiler.blacklist-append {*gcc*} {clang < 800} {macports-clang-3.*} 160 | 161 | subport wine-staging { 162 | conflicts wine-stable wine-devel wine-crossover 163 | set staging_version 11.0-rc2 164 | set wine_staging_distfile v${staging_version}${extract.suffix} 165 | distfiles-append ${wine_staging_distfile}:stagingsource 166 | master_sites-append https://github.com/wine-staging/wine-staging/archive/:stagingsource 167 | worksrcdir wine-${distname} 168 | extract.rename no 169 | 170 | checksums-append \ 171 | ${wine_staging_distfile} \ 172 | rmd160 624ff2a5ed0d99dbecc5a42f69d3fbdb8448a634 \ 173 | sha256 4df52c8f0b4e4b33af76fc2fe9fc7d00148af14c28ef8d11ac6e9f2f5839989b \ 174 | size 9323202 175 | 176 | depends_patch-append port:autoconf 177 | 178 | # Battle.net hacks here 179 | patchfiles-append 1001-kernelbase-CW-HACK-19610.patch 180 | 181 | set py_ver 3.13 182 | set py_ver_nodot [string map {. {}} ${py_ver}] 183 | depends_patch-append port:python${py_ver_nodot} 184 | 185 | # Applying staging before other patchfiles 186 | pre-patch { 187 | system -W ${worksrcpath} \ 188 | "${frameworks_dir}/Python.framework/Versions/${py_ver}/bin/python3 ${workpath}/wine-staging-${staging_version}/staging/patchinstall.py --all" 189 | } 190 | } 191 | 192 | variant gphoto description "Build ${subport} with support for digital cameras" { 193 | depends_lib-append port:libgphoto2 194 | configure.args-replace --without-gphoto --with-gphoto 195 | } 196 | 197 | variant gstreamer description "Build ${subport} with GStreamer, for multimedia support" { 198 | depends_lib-append path:Library/Frameworks/GStreamer.framework:gstreamer.framework 199 | configure.args-replace --without-ffmpeg --with-ffmpeg 200 | configure.args-replace --without-gstreamer --with-gstreamer 201 | 202 | pre-configure { 203 | configure.env-append "FFMPEG_CFLAGS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --cflags libavutil libavformat libavcodec]" 204 | configure.env-append "FFMPEG_LIBS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --libs libavutil libavformat libavcodec]" 205 | configure.env-append "GSTREAMER_CFLAGS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --cflags gstreamer-1.0 gstreamer-video-1.0 gstreamer-audio-1.0 gstreamer-tag-1.0]" 206 | configure.env-append "GSTREAMER_LIBS=[exec ${frameworks_dir}/GStreamer.framework/Commands/pkg-config --libs gstreamer-1.0 gstreamer-video-1.0 gstreamer-audio-1.0 gstreamer-tag-1.0]" 207 | } 208 | 209 | post-configure { 210 | reinplace -q "s|Versions/1.0/lib/pkgconfig/../../lib|Libraries|g" ${worksrcpath}/config.status 211 | } 212 | } 213 | 214 | variant kerberos description "Build ${subport} with Kerberos, for network authentication protocol support" { 215 | depends_lib-append port:kerberos5 216 | configure.args-replace --without-krb5 --with-krb5 217 | } 218 | 219 | if {${os.major} >= 24} { 220 | # https://gitlab.winehq.org/wine/wine/-/merge_requests/5935#note_74758 221 | macosx_deployment_target 14.0 222 | } 223 | 224 | if {${os.major} >= 19} { 225 | depends_lib-append path:lib/libMoltenVK.dylib:MoltenVK-latest 226 | configure.args.x86_64-append --enable-archs=i386,x86_64 227 | configure.args-replace --without-vulkan --with-vulkan 228 | default_variants +gstreamer 229 | } 230 | 231 | if {${os.major} < 19} { 232 | # CodeWeavers only tests i386 using MacOSX10.13.sdk 233 | configure.sdk_version 10.13 234 | if {${configure.sdkroot} != "${developer_dir}/SDKs/MacOSX${configure.sdk_version}.sdk"} { 235 | depends_build-append port:MacOSX${configure.sdk_version}.sdk 236 | configure.sdkroot ${prefix}/Developer/SDKs/MacOSX${configure.sdk_version}.sdk 237 | } 238 | 239 | default_variants +universal 240 | 241 | if {${universal_possible} && [variant_isset universal]} { 242 | configure.args.i386 --with-wine64=${workpath}/${worksrcdir}-x86_64 243 | 244 | notes-append " 245 | \n 246 | Wine supports both 32-bit and 64-bit now. It is compatible with your\ 247 | existing 32-bit wine prefix, but it will now default to 64-bit when you\ 248 | create a new wine prefix. The architecture can be selected using the\ 249 | WINEARCH environment variable which can be set to either \"win32\" or\ 250 | \"win64\". 251 | \n 252 | To create a new pure 32-bit prefix, you can run: 253 | \$ WINEARCH=win32 WINEPREFIX=~/.wine32 winecfg 254 | \n 255 | See the Wine FAQ for details: https://wiki.winehq.org/FAQ#Wineprefixes 256 | " 257 | } else { 258 | supported_archs i386 259 | } 260 | } 261 | 262 | triplet.add_build cross 263 | triplet.add_host none 264 | 265 | # macports-base injects a number of flags that now propagate to mingw-gcc this causes the build to fail since, wine-7.21 266 | # https://gitlab.winehq.org/wine/wine/-/commit/b1f59bc679a8c2dea18a6789a5b9b1a1ae825129 267 | compiler.limit_flags yes 268 | muniversal.arch_flag no 269 | muniversal.arch_compiler yes 270 | configure.ldflags-delete -L${compiler.library_path} 271 | configure.optflags -O2 272 | configure.env-append "CROSSCFLAGS=${configure.optflags}" 273 | 274 | # Were only installing wine not the development files 275 | destroot.target install-lib 276 | 277 | post-destroot { 278 | set docdir ${prefix}/share/doc/${subport} 279 | xinstall -d ${destroot}${docdir} 280 | xinstall -m 0644 -W ${worksrcpath} \ 281 | ANNOUNCE.md \ 282 | AUTHORS \ 283 | COPYING.LIB \ 284 | LICENSE \ 285 | README.md \ 286 | ${destroot}${docdir} 287 | 288 | if {[variant_isset gstreamer]} { 289 | system -W ${destroot}${compiler.library_path}/wine/x86_64-unix "/usr/bin/install_name_tool -delete_rpath ${compiler.library_path} winedmo.so" 290 | system -W ${destroot}${compiler.library_path}/wine/x86_64-unix "/usr/bin/install_name_tool -delete_rpath ${compiler.library_path} winegstreamer.so" 291 | system -W ${destroot}${compiler.library_path}/wine/x86_64-unix "/usr/bin/codesign --force --sign - winedmo.so" 292 | system -W ${destroot}${compiler.library_path}/wine/x86_64-unix "/usr/bin/codesign --force --sign - winegstreamer.so" 293 | } 294 | } 295 | -------------------------------------------------------------------------------- /emulators/crossover/Portfile: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 2 | 3 | PortSystem 1.0 4 | 5 | name CrossOver 6 | 7 | version 25.1.1 8 | revision 0 9 | platforms {darwin any >= 19} 10 | 11 | categories emulators 12 | license Commercial 13 | maintainers {@Gcenx} 14 | 15 | supported_archs x86_64 16 | description CodeWeavers commercial version of wine 17 | 18 | long_description ${name} runs thousands of different Windows apps \ 19 | on your Mac. From productivity, utility, games, \ 20 | and design software-Windows software never looked \ 21 | better when launched right from the macOS dock with \ 22 | {name} Mac. Easily switch between Mac or Windows \ 23 | programs without rebooting, without using a virtual \ 24 | machine and without purchasing a Windows license. \ 25 | The best solution to run Windows programs on Mac \ 26 | is with native functionality like copy & paste, \ 27 | keyboard shortcuts, Mission Control, and more! 28 | 29 | homepage https://www.codeweavers.com/products/crossover-mac/ 30 | 31 | master_sites https://media.codeweavers.com/pub/crossover/cxmac/demo/ 32 | distname crossover-${version} 33 | use_zip yes 34 | 35 | checksums rmd160 be84049c5c75d3064e730ebf4eb59bfbdf0ab4c2 \ 36 | sha256 55cce02fc5c394c3b5233e4fc4bf35bfb921dbf58e85f7448161c7ef9a4a0533 \ 37 | size 378285570 38 | 39 | variant gstreamer description "Modify ${subport} to use GStreamer.framework" { 40 | depends_run-append port:gstreamer-runtime 41 | } 42 | 43 | use_configure no 44 | 45 | build { 46 | # Can't remove Sparkle.framework so remove the update url 47 | reinplace s|https://www.codeweavers.com/xml/versions/cxmac.xml||g ${workpath}/CrossOver.app/Contents/Info.plist 48 | } 49 | 50 | post-build { 51 | # Remove useless DXVK dlls 52 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib/dxvk/i386-windows/d3d9.dll 53 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib/dxvk/i386-windows/d3d10_1.dll 54 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib/dxvk/i386-windows/d3d10.dll 55 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib/dxvk/x86_64-windows/d3d9.dll 56 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib/dxvk/x86_64-windows/d3d10_1.dll 57 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib/dxvk/x86_64-windows/d3d10.dll 58 | 59 | if {[variant_isset gstreamer]} { 60 | # GStreamer 61 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgmodule-2.0.dylib 62 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgthread-2.0.dylib 63 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstplayer-1.0.0.dylib 64 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstaudio-1.0.0.dylib 65 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstsdp-1.0.dylib 66 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstmpegts-1.0.0.dylib 67 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstnet-1.0.0.dylib 68 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstmpegts-1.0.dylib 69 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstrtsp-1.0.dylib 70 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libffi.8.dylib 71 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstreamer-1.0.dylib 72 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgsttranscoder-1.0.dylib 73 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstisoff-1.0.0.dylib 74 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstphotography-1.0.0.dylib 75 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstsdp-1.0.0.dylib 76 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstplay-1.0.dylib 77 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstplay-1.0.0.dylib 78 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgobject-2.0.dylib 79 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstreamer-1.0.0.dylib 80 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstcodecs-1.0.dylib 81 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libpcre2-8.0.dylib 82 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstwebrtc-1.0.0.dylib 83 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstcontroller-1.0.0.dylib 84 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstcodecparsers-1.0.dylib 85 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstbadaudio-1.0.dylib 86 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libglib-2.0.0.dylib 87 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstrtp-1.0.dylib 88 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstwebrtc-1.0.dylib 89 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgsttag-1.0.dylib 90 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstinsertbin-1.0.0.dylib 91 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstisoff-1.0.dylib 92 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstfft-1.0.0.dylib 93 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstbadaudio-1.0.0.dylib 94 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgio-2.0.dylib 95 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libglib-2.0.dylib 96 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgobject-2.0.0.dylib 97 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgsttag-1.0.0.dylib 98 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstvideo-1.0.0.dylib 99 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgsttranscoder-1.0.0.dylib 100 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstrtp-1.0.0.dylib 101 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/gstreamer-1.0 102 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstapp-1.0.0.dylib 103 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstrtsp-1.0.0.dylib 104 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libintl.dylib 105 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstvideo-1.0.dylib 106 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstfft-1.0.dylib 107 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstadaptivedemux-1.0.dylib 108 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgmodule-2.0.0.dylib 109 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstbasecamerabinsrc-1.0.dylib 110 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstsctp-1.0.0.dylib 111 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libintl.8.dylib 112 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstphotography-1.0.dylib 113 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgsturidownloader-1.0.0.dylib 114 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstpbutils-1.0.dylib 115 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstbase-1.0.0.dylib 116 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstallocators-1.0.dylib 117 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libpcre2-posix.3.dylib 118 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libffi.dylib 119 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstcontroller-1.0.dylib 120 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstcodecparsers-1.0.0.dylib 121 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgthread-2.0.0.dylib 122 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libpcre2-8.dylib 123 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstriff-1.0.0.dylib 124 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstadaptivedemux-1.0.0.dylib 125 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstnet-1.0.dylib 126 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstriff-1.0.dylib 127 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgsturidownloader-1.0.dylib 128 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstbasecamerabinsrc-1.0.0.dylib 129 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstaudio-1.0.dylib 130 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstinsertbin-1.0.dylib 131 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstcodecs-1.0.0.dylib 132 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstbase-1.0.dylib 133 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstgl-1.0.dylib 134 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstgl-1.0.0.dylib 135 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstallocators-1.0.0.dylib 136 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstplayer-1.0.dylib 137 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstpbutils-1.0.0.dylib 138 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libpcre2-posix.dylib 139 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstsctp-1.0.dylib 140 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstapp-1.0.dylib 141 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgio-2.0.0.dylib 142 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstanalytics-1.0.dylib 143 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstmse-1.0.dylib 144 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstanalytics-1.0.0.dylib 145 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/libgstmse-1.0.0.dylib 146 | 147 | # GStreamer plugin directory 148 | delete ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib64/gstreamer-1.0 149 | 150 | # Use GStreamer.framework 151 | system -W ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib/wine/x86_64-unix \ 152 | "/usr/bin/install_name_tool -delete_rpath @loader_path/../../../lib64 winegstreamer.so" 153 | system -W ${workpath}/CrossOver.app/Contents/SharedSupport/CrossOver/lib/wine/x86_64-unix \ 154 | "/usr/bin/install_name_tool -add_rpath /Library/Frameworks/GStreamer.framework/Libraries winegstreamer.so" 155 | } 156 | } 157 | 158 | destroot { 159 | move ${workpath}/CrossOver.app ${destroot}${applications_dir}/CrossOver.app 160 | system -W ${destroot}${applications_dir} "/usr/bin/codesign --deep --force --sign - 'CrossOver.app'" 161 | } 162 | -------------------------------------------------------------------------------- /emulators/wine-stable/files/MR6866.diff: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c 2 | index 1cce2ab3466be7085dcfe0b6bdbf0f05c8397b27..67c4aa546bcf637c2bf09b8f9b0f8e7bfef149e6 100644 3 | --- a/dlls/ntdll/loader.c 4 | +++ b/dlls/ntdll/loader.c 5 | @@ -1385,9 +1385,6 @@ static BOOL alloc_tls_slot( LDR_DATA_TABLE_ENTRY *mod ) 6 | if (!new) return FALSE; 7 | if (old) memcpy( new, old, old_module_count * sizeof(*new) ); 8 | teb->ThreadLocalStoragePointer = new; 9 | -#ifdef __x86_64__ /* macOS-specific hack */ 10 | - if (teb->Instrumentation[0]) ((TEB *)teb->Instrumentation[0])->ThreadLocalStoragePointer = new; 11 | -#endif 12 | TRACE( "thread %04lx tls block %p -> %p\n", HandleToULong(teb->ClientId.UniqueThread), old, new ); 13 | /* FIXME: can't free old block here, should be freed at thread exit */ 14 | } 15 | @@ -1633,10 +1630,6 @@ static NTSTATUS alloc_thread_tls(void) 16 | TRACE( "slot %u: %u/%lu bytes at %p\n", i, size, dir->SizeOfZeroFill, pointers[i] ); 17 | } 18 | NtCurrentTeb()->ThreadLocalStoragePointer = pointers; 19 | -#ifdef __x86_64__ /* macOS-specific hack */ 20 | - if (NtCurrentTeb()->Instrumentation[0]) 21 | - ((TEB *)NtCurrentTeb()->Instrumentation[0])->ThreadLocalStoragePointer = pointers; 22 | -#endif 23 | return STATUS_SUCCESS; 24 | } 25 | 26 | @@ -3941,10 +3934,6 @@ void WINAPI LdrShutdownThread(void) 27 | if ((pointers = NtCurrentTeb()->ThreadLocalStoragePointer)) 28 | { 29 | NtCurrentTeb()->ThreadLocalStoragePointer = NULL; 30 | -#ifdef __x86_64__ /* macOS-specific hack */ 31 | - if (NtCurrentTeb()->Instrumentation[0]) 32 | - ((TEB *)NtCurrentTeb()->Instrumentation[0])->ThreadLocalStoragePointer = NULL; 33 | -#endif 34 | for (i = 0; i < tls_module_count; i++) RtlFreeHeap( GetProcessHeap(), 0, pointers[i] ); 35 | RtlFreeHeap( GetProcessHeap(), 0, pointers ); 36 | } 37 | diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c 38 | index 7320aeabd49a79d3193794f521dbc727e68c1be4..b8e6aacbfd858ec62ecded6ca968e2203d2fadc5 100644 39 | --- a/dlls/ntdll/signal_x86_64.c 40 | +++ b/dlls/ntdll/signal_x86_64.c 41 | @@ -397,8 +397,7 @@ __ASM_GLOBAL_FUNC( KiUserCallbackDispatcher, 42 | "movl 0x28(%rsp),%edx\n\t" /* len */ 43 | "movl 0x2c(%rsp),%r8d\n\t" /* id */ 44 | #ifdef __WINE_PE_BUILD 45 | - "movq %gs:0x30,%rax\n\t" /* NtCurrentTeb() */ 46 | - "movq 0x60(%rax),%rax\n\t" /* peb */ 47 | + "movq %gs:0x60,%rax\n\t" /* peb */ 48 | "movq 0x58(%rax),%rax\n\t" /* peb->KernelCallbackTable */ 49 | "call *(%rax,%r8,8)\n\t" /* KernelCallbackTable[id] */ 50 | ".seh_handler " __ASM_NAME("user_callback_handler") ", @except\n\t" 51 | @@ -818,8 +817,7 @@ __ASM_GLOBAL_FUNC( RtlRaiseException, 52 | "movq %rax,0xf8(%rdx)\n\t" /* context->Rip */ 53 | "movq %rax,0x10(%rcx)\n\t" /* rec->ExceptionAddress */ 54 | "movl $1,%r8d\n\t" 55 | - "movq %gs:(0x30),%rax\n\t" /* Teb */ 56 | - "movq 0x60(%rax),%rax\n\t" /* Peb */ 57 | + "movq %gs:0x60,%rax\n\t" /* Peb */ 58 | "cmpb $0,0x02(%rax)\n\t" /* BeingDebugged */ 59 | "jne 1f\n\t" 60 | "call " __ASM_NAME("dispatch_exception") "\n" 61 | @@ -1062,8 +1060,7 @@ __ASM_GLOBAL_FUNC( DbgUiRemoteBreakin, 62 | ".seh_stackalloc 0x28\n\t" 63 | ".seh_endprologue\n\t" 64 | ".seh_handler DbgUiRemoteBreakin_handler, @except\n\t" 65 | - "mov %gs:0x30,%rax\n\t" 66 | - "mov 0x60(%rax),%rax\n\t" 67 | + "mov %gs:0x60,%rax\n\t" 68 | "cmpb $0,2(%rax)\n\t" 69 | "je 1f\n\t" 70 | "call " __ASM_NAME("DbgBreakPoint") "\n" 71 | diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c 72 | index 26b540bd629f6f8f926cf6c113333fd9879d2f7c..cfcb1147f45db6da82f30ab6dad27860cad5cd30 100644 73 | --- a/dlls/ntdll/unix/signal_x86_64.c 74 | +++ b/dlls/ntdll/unix/signal_x86_64.c 75 | @@ -63,6 +63,14 @@ 76 | #endif 77 | #ifdef __APPLE__ 78 | # include 79 | +/* _thread_set_tsd_base is private API for setting GSBASE, added in macOS 10.12. 80 | + * It's a small thunk that sets %eax, zeroes %esi, and does the syscall (which clobbers 81 | + * %rcx and %r11). 82 | + * See https://github.com/apple-oss-distributions/xnu/blob/main/libsyscall/custom/custom.s 83 | + * or libsystem_kernel.dylib. 84 | + * Note that the dispatchers do the syscall directly to avoid using the stack. 85 | + */ 86 | +extern void _thread_set_tsd_base(uint64_t); 87 | #endif 88 | 89 | #include "ntstatus.h" 90 | @@ -423,7 +431,7 @@ struct syscall_frame 91 | void *syscall_cfa; /* 00a8 */ 92 | DWORD syscall_flags; /* 00b0 */ 93 | DWORD restore_flags; /* 00b4 */ 94 | - DWORD align[2]; /* 00b8 */ 95 | + ULONG64 teb; /* 00b8 */ 96 | XMM_SAVE_AREA32 xsave; /* 00c0 */ 97 | DECLSPEC_ALIGN(64) XSAVE_AREA_HEADER xstate; /* 02c0 */ 98 | }; 99 | @@ -462,7 +470,7 @@ static inline struct amd64_thread_data *amd64_thread_data(void) 100 | return (struct amd64_thread_data *)ntdll_get_thread_data()->cpu_data; 101 | } 102 | 103 | -#ifdef __linux__ 104 | +#if defined(__linux__) || defined(__APPLE__) 105 | static inline TEB *get_current_teb(void) 106 | { 107 | unsigned long rsp; 108 | @@ -846,6 +854,9 @@ static inline ucontext_t *init_handler( void *sigcontext ) 109 | struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)&get_current_teb()->GdiTebBatch; 110 | arch_prctl( ARCH_SET_FS, ((struct amd64_thread_data *)thread_data->cpu_data)->pthread_teb ); 111 | } 112 | +#elif defined __APPLE__ 113 | + struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)&get_current_teb()->GdiTebBatch; 114 | + _thread_set_tsd_base( (uint64_t)((struct amd64_thread_data *)thread_data->cpu_data)->pthread_teb ); 115 | #endif 116 | return sigcontext; 117 | } 118 | @@ -859,6 +870,9 @@ static inline void leave_handler( ucontext_t *sigcontext ) 119 | #ifdef __linux__ 120 | if (fs32_sel && !is_inside_signal_stack( (void *)RSP_sig(sigcontext )) && !is_inside_syscall(sigcontext)) 121 | __asm__ volatile( "movw %0,%%fs" :: "r" (fs32_sel) ); 122 | +#elif defined __APPLE__ 123 | + if (!is_inside_signal_stack( (void *)RSP_sig(sigcontext )) && !is_inside_syscall(sigcontext)) 124 | + _thread_set_tsd_base( (uint64_t)NtCurrentTeb() ); 125 | #endif 126 | #ifdef DS_sig 127 | DS_sig(sigcontext) = ds64_sel; 128 | @@ -1638,6 +1652,13 @@ __ASM_GLOBAL_FUNC( call_user_mode_callback, 129 | "jz 1f\n\t" 130 | "movw 0x338(%r8),%fs\n" /* amd64_thread_data()->fs */ 131 | "1:\n\t" 132 | +#elif defined __APPLE__ 133 | + "movq %rcx,%r10\n\t" 134 | + "movq %r8,%rdi\n\t" 135 | + "xorl %esi,%esi\n\t" 136 | + "movl $0x3000003,%eax\n\t" /* _thread_set_tsd_base */ 137 | + "syscall\n\t" 138 | + "movq %r10,%rcx\n\t" 139 | #endif 140 | "movq 0x348(%r8),%r10\n\t" /* amd64_thread_data()->instrumentation_callback */ 141 | "movq (%r10),%r10\n\t" 142 | @@ -1653,6 +1674,18 @@ __ASM_GLOBAL_FUNC( call_user_mode_callback, 143 | extern void DECLSPEC_NORETURN user_mode_callback_return( void *ret_ptr, ULONG ret_len, 144 | NTSTATUS status, TEB *teb ); 145 | __ASM_GLOBAL_FUNC( user_mode_callback_return, 146 | +#ifdef __APPLE__ 147 | + "movq %rcx,%r8\n\t" 148 | + "movq %rdi,%r9\n\t" 149 | + "movq %rsi,%r10\n\t" 150 | + "movq 0x320(%rcx),%rdi\n\t" /* amd64_thread_data()->pthread_teb */ 151 | + "xorl %esi,%esi\n\t" 152 | + "movl $0x3000003,%eax\n\t" /* _thread_set_tsd_base */ 153 | + "syscall\n\t" 154 | + "movq %r10,%rsi\n\t" 155 | + "movq %r9,%rdi\n\t" 156 | + "movq %r8,%rcx\n\t" 157 | +#endif 158 | "movq 0x328(%rcx),%r10\n\t" /* amd64_thread_data()->syscall_frame */ 159 | "movq 0xa0(%r10),%r11\n\t" /* frame->prev_frame */ 160 | "movq %r11,0x328(%rcx)\n\t" /* amd64_thread_data()->syscall_frame = prev_frame */ 161 | @@ -1974,9 +2007,9 @@ static BOOL handle_syscall_trap( ucontext_t *sigcontext, siginfo_t *siginfo ) 162 | */ 163 | static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 164 | { 165 | + ucontext_t *ucontext = init_handler( sigcontext ); 166 | EXCEPTION_RECORD rec = { 0 }; 167 | struct xcontext context; 168 | - ucontext_t *ucontext = init_handler( sigcontext ); 169 | 170 | rec.ExceptionAddress = (void *)RIP_sig(ucontext); 171 | save_context( &context, ucontext ); 172 | @@ -2059,9 +2092,9 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 173 | */ 174 | static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 175 | { 176 | + ucontext_t *ucontext = init_handler( sigcontext ); 177 | EXCEPTION_RECORD rec = { 0 }; 178 | struct xcontext context; 179 | - ucontext_t *ucontext = init_handler( sigcontext ); 180 | 181 | if (handle_syscall_trap( ucontext, siginfo )) return; 182 | 183 | @@ -2093,8 +2126,8 @@ static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 184 | */ 185 | static void fpe_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 186 | { 187 | - EXCEPTION_RECORD rec = { 0 }; 188 | ucontext_t *ucontext = init_handler( sigcontext ); 189 | + EXCEPTION_RECORD rec = { 0 }; 190 | 191 | switch (siginfo->si_code) 192 | { 193 | @@ -2440,50 +2473,12 @@ static void *mac_thread_gsbase(void) 194 | { 195 | struct thread_identifier_info tiinfo; 196 | unsigned int info_count = THREAD_IDENTIFIER_INFO_COUNT; 197 | - static int gsbase_offset = -1; 198 | 199 | mach_port_t self = mach_thread_self(); 200 | kern_return_t kr = thread_info(self, THREAD_IDENTIFIER_INFO, (thread_info_t) &tiinfo, &info_count); 201 | mach_port_deallocate(mach_task_self(), self); 202 | 203 | if (kr == KERN_SUCCESS) return (void*)tiinfo.thread_handle; 204 | - 205 | - if (gsbase_offset < 0) 206 | - { 207 | - /* Search for the array of TLS slots within the pthread data structure. 208 | - That's what the macOS pthread implementation uses for gsbase. */ 209 | - const void* const sentinel1 = (const void*)0x2bffb6b4f11228ae; 210 | - const void* const sentinel2 = (const void*)0x0845a7ff6ab76707; 211 | - int rc; 212 | - pthread_key_t key; 213 | - const void** p = (const void**)pthread_self(); 214 | - int i; 215 | - 216 | - gsbase_offset = 0; 217 | - if ((rc = pthread_key_create(&key, NULL))) return NULL; 218 | - 219 | - pthread_setspecific(key, sentinel1); 220 | - 221 | - for (i = key + 1; i < 2000; i++) /* arbitrary limit */ 222 | - { 223 | - if (p[i] == sentinel1) 224 | - { 225 | - pthread_setspecific(key, sentinel2); 226 | - 227 | - if (p[i] == sentinel2) 228 | - { 229 | - gsbase_offset = (i - key) * sizeof(*p); 230 | - break; 231 | - } 232 | - 233 | - pthread_setspecific(key, sentinel1); 234 | - } 235 | - } 236 | - 237 | - pthread_key_delete(key); 238 | - } 239 | - 240 | - if (gsbase_offset) return (char*)pthread_self() + gsbase_offset; 241 | return NULL; 242 | } 243 | #endif 244 | @@ -2609,13 +2604,7 @@ void call_init_thunk( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend, TEB 245 | #elif defined(__NetBSD__) 246 | sysarch( X86_64_SET_GSBASE, &teb ); 247 | #elif defined (__APPLE__) 248 | - __asm__ volatile ("movq %0,%%gs:%c1" :: "r" (teb->Tib.Self), "n" (FIELD_OFFSET(TEB, Tib.Self))); 249 | - __asm__ volatile ("movq %0,%%gs:%c1" :: "r" (teb->ThreadLocalStoragePointer), "n" (FIELD_OFFSET(TEB, ThreadLocalStoragePointer))); 250 | thread_data->pthread_teb = mac_thread_gsbase(); 251 | - /* alloc_tls_slot() needs to poke a value to an address relative to each 252 | - thread's gsbase. Have each thread record its gsbase pointer into its 253 | - TEB so alloc_tls_slot() can find it. */ 254 | - teb->Instrumentation[0] = thread_data->pthread_teb; 255 | #else 256 | # error Please define setting %gs for your architecture 257 | #endif 258 | @@ -2672,6 +2661,7 @@ void call_init_thunk( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend, TEB 259 | frame->restore_flags |= CONTEXT_INTEGER; 260 | frame->syscall_flags = syscall_flags; 261 | frame->syscall_cfa = syscall_cfa; 262 | + frame->teb = (ULONG64)teb; 263 | if ((callback = instrumentation_callback)) 264 | { 265 | frame->r10 = frame->rip; 266 | @@ -2722,12 +2712,7 @@ __ASM_GLOBAL_FUNC( signal_start_thread, 267 | * __wine_syscall_dispatcher 268 | */ 269 | __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, 270 | -#ifdef __APPLE__ 271 | - "movq %gs:0x30,%rcx\n\t" 272 | - "movq 0x328(%rcx),%rcx\n\t" 273 | -#else 274 | "movq %gs:0x328,%rcx\n\t" /* amd64_thread_data()->syscall_frame */ 275 | -#endif 276 | "popq 0x70(%rcx)\n\t" /* frame->rip */ 277 | __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") 278 | __ASM_CFI_REG_IS_AT2(rip, rcx, 0xf0,0x00) 279 | @@ -2759,18 +2744,15 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, 280 | "movw %ss,0x90(%rcx)\n\t" 281 | "movq %rbp,0x98(%rcx)\n\t" 282 | __ASM_CFI_REG_IS_AT2(rbp, rcx, 0x98, 0x01) 283 | + "movq %gs:0x30,%r14\n\t" 284 | + "movq %r14,0xb8(%rcx)\n\t" /* frame->teb */ 285 | /* Legends of Runeterra hooks the first system call return instruction, and 286 | * depends on us returning to it. Adjust the return address accordingly. */ 287 | "subq $0xb,0x70(%rcx)\n\t" 288 | "movl 0xb0(%rcx),%r14d\n\t" /* frame->syscall_flags */ 289 | "testl $3,%r14d\n\t" /* SYSCALL_HAVE_XSAVE | SYSCALL_HAVE_XSAVEC */ 290 | "jz 2f\n\t" 291 | -#ifdef __APPLE__ 292 | - "movq %gs:0x30,%rdx\n\t" 293 | - "movl 0x340(%rdx),%eax\n\t" 294 | -#else 295 | "movl %gs:0x340,%eax\n\t" /* amd64_thread_data()->xstate_features_mask */ 296 | -#endif 297 | "xorl %edx,%edx\n\t" 298 | "andl $7,%eax\n\t" 299 | "xorq %rbp,%rbp\n\t" 300 | @@ -2818,10 +2800,14 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, 301 | __ASM_CFI(".cfi_offset %r15,-0x38\n\t") 302 | __ASM_CFI(".cfi_undefined %rdi\n\t") 303 | __ASM_CFI(".cfi_undefined %rsi\n\t") 304 | + /* When on the kernel stack, use frame->teb instead of %gs to access the TEB. 305 | + * (on macOS, signal handlers set gsbase to pthread_teb when on the kernel stack). 306 | + */ 307 | #ifdef __linux__ 308 | "testl $12,%r14d\n\t" /* SYSCALL_HAVE_PTHREAD_TEB | SYSCALL_HAVE_WRFSGSBASE */ 309 | "jz 2f\n\t" 310 | - "movq %gs:0x320,%rsi\n\t" /* amd64_thread_data()->pthread_teb */ 311 | + "movq 0xb8(%rcx),%rsi\n\t" /* frame->teb */ 312 | + "movq 0x320(%rsi),%rsi\n\t" /* amd64_thread_data()->pthread_teb */ 313 | "testl $8,%r14d\n\t" /* SYSCALL_HAVE_WRFSGSBASE */ 314 | "jz 1f\n\t" 315 | "wrfsbase %rsi\n\t" 316 | @@ -2831,18 +2817,21 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, 317 | "syscall\n\t" 318 | "leaq -0x98(%rbp),%rcx\n" 319 | "2:\n\t" 320 | +#elif defined __APPLE__ 321 | + "movq 0xb8(%rcx),%rdi\n\t" /* frame->teb */ 322 | + "movq 0x320(%rdi),%rdi\n\t" /* amd64_thread_data()->pthread_teb */ 323 | + "xorl %esi,%esi\n\t" 324 | + "movl $0x3000003,%eax\n\t" /* _thread_set_tsd_base */ 325 | + "syscall\n\t" 326 | + "leaq -0x98(%rbp),%rcx\n" 327 | #endif 328 | "movq 0x00(%rcx),%rax\n\t" 329 | "movq 0x18(%rcx),%r11\n\t" /* 2nd argument */ 330 | "movl %eax,%ebx\n\t" 331 | "shrl $8,%ebx\n\t" 332 | "andl $0x30,%ebx\n\t" /* syscall table number */ 333 | -#ifdef __APPLE__ 334 | - "movq %gs:0x30,%rcx\n\t" 335 | - "movq 0x330(%rcx),%rcx\n\t" 336 | -#else 337 | - "movq %gs:0x330,%rcx\n\t" /* amd64_thread_data()->syscall_table */ 338 | -#endif 339 | + "movq 0xb8(%rcx),%rcx\n\t" /* frame->teb */ 340 | + "movq 0x330(%rcx),%rcx\n\t" /* amd64_thread_data()->syscall_table */ 341 | "leaq (%rcx,%rbx,2),%rbx\n\t" 342 | "andl $0xfff,%eax\n\t" /* syscall number */ 343 | "cmpq 16(%rbx),%rax\n\t" /* table->ServiceLimit */ 344 | @@ -2868,6 +2857,25 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, 345 | "callq *(%r10,%rax,8)\n\t" 346 | "leaq -0x98(%rbp),%rcx\n\t" 347 | __ASM_LOCAL_LABEL("__wine_syscall_dispatcher_return") ":\n\t" 348 | + /* push rbp-based kernel stack cfi */ 349 | + __ASM_CFI(".cfi_remember_state\n\t") 350 | + __ASM_CFI_CFA_IS_AT2(rcx, 0xa8, 0x01) /* frame->syscall_cfa */ 351 | + "leaq 0x70(%rcx),%rsp\n\t" /* %rsp > frame means no longer inside syscall */ 352 | +#ifdef __linux__ 353 | + "testl $12,%r14d\n\t" /* SYSCALL_HAVE_PTHREAD_TEB | SYSCALL_HAVE_WRFSGSBASE */ 354 | + "jz 1f\n\t" 355 | + "movw %gs:0x338,%fs\n" /* amd64_thread_data()->fs */ 356 | + "1:\n\t" 357 | +#elif defined __APPLE__ 358 | + "movq %rax,%r8\n\t" 359 | + "movq %rcx,%rdx\n\t" 360 | + "movq 0xb8(%rcx),%rdi\n\t" /* frame->teb */ 361 | + "xorl %esi,%esi\n\t" 362 | + "movl $0x3000003,%eax\n\t" /* _thread_set_tsd_base */ 363 | + "syscall\n\t" 364 | + "movq %rdx,%rcx\n\t" 365 | + "movq %r8,%rax\n\t" 366 | +#endif 367 | "movl 0xb4(%rcx),%edx\n\t" /* frame->restore_flags */ 368 | "testl $0x48,%edx\n\t" /* CONTEXT_FLOATING_POINT | CONTEXT_XSTATE */ 369 | "jnz 2f\n\t" 370 | @@ -2885,23 +2893,14 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, 371 | "2:\ttestl $3,%r14d\n\t" /* SYSCALL_HAVE_XSAVE | SYSCALL_HAVE_XSAVEC */ 372 | "jz 3f\n\t" 373 | "movq %rax,%r11\n\t" 374 | -#ifdef __APPLE__ 375 | - "movq %gs:0x30,%rdx\n\t" 376 | - "movl 0x340(%rdx),%eax\n\t" 377 | - "movl 0x344(%rdx),%edx\n\t" 378 | -#else 379 | "movl %gs:0x340,%eax\n\t" /* amd64_thread_data()->xstate_features_mask */ 380 | "movl %gs:0x344,%edx\n\t" /* amd64_thread_data()->xstate_features_mask high dword */ 381 | -#endif 382 | "xrstor64 0xc0(%rcx)\n\t" 383 | "movq %r11,%rax\n\t" 384 | "movl 0xb4(%rcx),%edx\n\t" /* frame->restore_flags */ 385 | "jmp 4f\n" 386 | "3:\tfxrstor64 0xc0(%rcx)\n" 387 | "4:\tmovq 0x98(%rcx),%rbp\n\t" 388 | - /* push rbp-based kernel stack cfi */ 389 | - __ASM_CFI(".cfi_remember_state\n\t") 390 | - __ASM_CFI_CFA_IS_AT2(rcx, 0xa8, 0x01) /* frame->syscall_cfa */ 391 | "movq 0x68(%rcx),%r15\n\t" 392 | "movq 0x58(%rcx),%r13\n\t" 393 | "movq 0x50(%rcx),%r12\n\t" 394 | @@ -2909,13 +2908,6 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, 395 | "movq 0x28(%rcx),%rdi\n\t" 396 | "movq 0x20(%rcx),%rsi\n\t" 397 | "movq 0x08(%rcx),%rbx\n\t" 398 | - "leaq 0x70(%rcx),%rsp\n\t" /* %rsp > frame means no longer inside syscall */ 399 | -#ifdef __linux__ 400 | - "testl $12,%r14d\n\t" /* SYSCALL_HAVE_PTHREAD_TEB | SYSCALL_HAVE_WRFSGSBASE */ 401 | - "jz 1f\n\t" 402 | - "movw %gs:0x338,%fs\n" /* amd64_thread_data()->fs */ 403 | - "1:\n\t" 404 | -#endif 405 | "testl $0x10000,%edx\n\t" /* RESTORE_FLAGS_INSTRUMENTATION */ 406 | "movq 0x60(%rcx),%r14\n\t" 407 | "jnz 2f\n\t" 408 | @@ -2966,12 +2958,7 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, 409 | "movq 0x10(%rcx),%rcx\n\t" 410 | "iretq\n" 411 | /* RESTORE_FLAGS_INSTRUMENTATION */ 412 | -#ifdef __APPLE__ 413 | - "2:\tmovq %gs:0x30,%r10\n\t" 414 | - "movq 0x348(%r10),%r10\n\t" 415 | -#else 416 | "2:\tmovq %gs:0x348,%r10\n\t" /* amd64_thread_data()->instrumentation_callback */ 417 | -#endif 418 | "movq (%r10),%r10\n\t" 419 | "test %r10,%r10\n\t" 420 | "jz 3b\n\t" 421 | @@ -2997,12 +2984,7 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher_return, 422 | 423 | 424 | __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher_instrumentation, 425 | -#ifdef __APPLE__ 426 | - "movq %gs:0x30,%rcx\n\t" 427 | - "movq 0x328(%rcx),%rcx\n\t" 428 | -#else 429 | "movq %gs:0x328,%rcx\n\t" /* amd64_thread_data()->syscall_frame */ 430 | -#endif 431 | "popq 0x70(%rcx)\n\t" /* frame->rip */ 432 | __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") 433 | __ASM_CFI_REG_IS_AT2(rip, rcx, 0xf0,0x00) 434 | @@ -3019,12 +3001,7 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher_instrumentation, 435 | */ 436 | __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, 437 | "movq %rcx,%r10\n\t" 438 | -#ifdef __APPLE__ 439 | - "movq %gs:0x30,%rcx\n\t" 440 | - "movq 0x328(%rcx),%rcx\n\t" 441 | -#else 442 | "movq %gs:0x328,%rcx\n\t" /* amd64_thread_data()->syscall_frame */ 443 | -#endif 444 | "popq 0x70(%rcx)\n\t" /* frame->rip */ 445 | __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") 446 | __ASM_CFI_REG_IS_AT2(rip, rcx, 0xf0,0x00) 447 | @@ -3048,6 +3025,10 @@ __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, 448 | __ASM_CFI_CFA_IS_AT2(rcx, 0x88, 0x01) 449 | "movq %rbp,0x98(%rcx)\n\t" 450 | __ASM_CFI_REG_IS_AT2(rbp, rcx, 0x98, 0x01) 451 | +#ifdef __APPLE__ 452 | + "movq %gs:0x30,%r14\n\t" 453 | + "movq %r14,0xb8(%rcx)\n\t" /* frame->teb */ 454 | +#endif 455 | "movdqa %xmm6,0x1c0(%rcx)\n\t" 456 | "movdqa %xmm7,0x1d0(%rcx)\n\t" 457 | "movdqa %xmm8,0x1e0(%rcx)\n\t" 458 | @@ -3085,6 +3066,11 @@ __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, 459 | "mov $158,%eax\n\t" /* SYS_arch_prctl */ 460 | "syscall\n\t" 461 | "2:\n\t" 462 | +#elif defined __APPLE__ 463 | + "movq %gs:0x320,%rdi\n\t" /* amd64_thread_data()->pthread_teb */ 464 | + "xorl %esi,%esi\n\t" 465 | + "movl $0x3000003,%eax\n\t" /* _thread_set_tsd_base */ 466 | + "syscall\n\t" 467 | #endif 468 | "movq %r8,%rdi\n\t" /* args */ 469 | "callq *(%r10,%rdx,8)\n\t" 470 | @@ -3109,6 +3095,15 @@ __ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, 471 | "jz 1f\n\t" 472 | "movw %gs:0x338,%fs\n" /* amd64_thread_data()->fs */ 473 | "1:\n\t" 474 | +#elif defined __APPLE__ 475 | + "movq %rax,%rdx\n\t" 476 | + "movq %rcx,%r14\n\t" 477 | + "movq 0xb8(%rcx),%rdi\n\t" /* frame->teb */ 478 | + "xorl %esi,%esi\n\t" 479 | + "movl $0x3000003,%eax\n\t" /* _thread_set_tsd_base */ 480 | + "syscall\n\t" 481 | + "movq %r14,%rcx\n\t" 482 | + "movq %rdx,%rax\n\t" 483 | #endif 484 | "movq 0x60(%rcx),%r14\n\t" 485 | "movq 0x28(%rcx),%rdi\n\t" 486 | -------------------------------------------------------------------------------- /emulators/wine-stable/files/0001-winehq_macos_hacks.diff: -------------------------------------------------------------------------------- 1 | diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c 2 | index df3447a9014..4d70b83ee14 100644 3 | --- a/dlls/kernelbase/process.c 4 | +++ b/dlls/kernelbase/process.c 5 | @@ -502,6 +502,36 @@ done: 6 | return ret; 7 | } 8 | 9 | +static const WCHAR *hack_append_command_line( const WCHAR *cmd, const WCHAR *cmd_line ) 10 | +{ 11 | + static const struct 12 | + { 13 | + const WCHAR *exe_name; 14 | + const WCHAR *append; 15 | + const WCHAR *required_args; 16 | + const WCHAR *forbidden_args; 17 | + } 18 | + options[] = 19 | + { 20 | + {L"steamwebhelper.exe", L" --no-sandbox --in-process-gpu --disable-gpu", NULL, L"--type=crashpad-handler"}, 21 | + }; 22 | + unsigned int i; 23 | + 24 | + if (!cmd) return NULL; 25 | + 26 | + for (i = 0; i < ARRAY_SIZE(options); ++i) 27 | + { 28 | + if (wcsstr( cmd, options[i].exe_name ) 29 | + && (!options[i].required_args || wcsstr(cmd_line, options[i].required_args)) 30 | + && (!options[i].forbidden_args || !wcsstr(cmd_line, options[i].forbidden_args))) 31 | + { 32 | + FIXME( "HACK: appending %s to command line.\n", debugstr_w(options[i].append) ); 33 | + return options[i].append; 34 | + } 35 | + } 36 | + return NULL; 37 | +} 38 | + 39 | /********************************************************************** 40 | * CreateProcessInternalW (kernelbase.@) 41 | */ 42 | @@ -518,6 +548,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW( HANDLE token, const WCHAR 43 | RTL_USER_PROCESS_PARAMETERS *params = NULL; 44 | RTL_USER_PROCESS_INFORMATION rtl_info; 45 | HANDLE parent = 0, debug = 0; 46 | + const WCHAR *append; 47 | ULONG nt_flags = 0; 48 | USHORT machine = 0; 49 | NTSTATUS status; 50 | @@ -543,6 +574,20 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW( HANDLE token, const WCHAR 51 | app_name = name; 52 | } 53 | 54 | + /* CROSSOVER HACK */ 55 | + if ((append = hack_append_command_line( app_name, tidy_cmdline ))) 56 | + { 57 | + WCHAR *new_cmdline = RtlAllocateHeap( GetProcessHeap(), 0, 58 | + sizeof(WCHAR) * (lstrlenW(cmd_line) + lstrlenW(append) + 1) ); 59 | + lstrcpyW(new_cmdline, tidy_cmdline); 60 | + lstrcatW(new_cmdline, append); 61 | + if (tidy_cmdline != cmd_line) RtlFreeHeap( GetProcessHeap(), 0, tidy_cmdline ); 62 | + tidy_cmdline = new_cmdline; 63 | + } 64 | + /* end CROSSOVER HACK */ 65 | + 66 | + TRACE( "app %s cmdline %s after all hacks\n", debugstr_w(app_name), debugstr_w(tidy_cmdline) ); 67 | + 68 | /* Warn if unsupported features are used */ 69 | 70 | if (flags & (IDLE_PRIORITY_CLASS | HIGH_PRIORITY_CLASS | REALTIME_PRIORITY_CLASS | 71 | diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c 72 | index 41552762841..78941747f96 100644 73 | --- a/dlls/ntdll/unix/signal_x86_64.c 74 | +++ b/dlls/ntdll/unix/signal_x86_64.c 75 | @@ -88,6 +88,15 @@ WINE_DECLARE_DEBUG_CHANNEL(seh); 76 | 77 | #include "dwarf.h" 78 | 79 | +#ifdef __APPLE__ 80 | +/* CW Hack 24256 */ 81 | +#include 82 | +static BOOL is_rosetta2; 83 | + 84 | +/* CW Hack 23427 */ 85 | +static BOOL sequoia_or_later = FALSE; 86 | +#endif 87 | + 88 | /*********************************************************************** 89 | * signal context platform-specific definitions 90 | */ 91 | @@ -455,6 +464,9 @@ struct amd64_thread_data 92 | DWORD xstate_features_size; /* 033c */ 93 | UINT64 xstate_features_mask; /* 0340 */ 94 | void **instrumentation_callback; /* 0348 */ 95 | +#ifdef __APPLE__ /* CW Hack 24265 */ 96 | + DWORD mxcsr; /* 350 */ 97 | +#endif 98 | }; 99 | 100 | C_ASSERT( sizeof(struct amd64_thread_data) <= sizeof(((struct ntdll_thread_data *)0)->cpu_data) ); 101 | @@ -464,6 +476,9 @@ C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct amd64_thread_data, sys 102 | C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct amd64_thread_data, fs ) == 0x338 ); 103 | C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct amd64_thread_data, xstate_features_size ) == 0x33c ); 104 | C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct amd64_thread_data, xstate_features_mask ) == 0x340 ); 105 | +#ifdef __APPLE__ /* CW Hack 24265 */ 106 | +C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct amd64_thread_data, mxcsr ) == 0x350 ); 107 | +#endif 108 | 109 | static inline struct amd64_thread_data *amd64_thread_data(void) 110 | { 111 | @@ -933,6 +948,13 @@ static void save_context( struct xcontext *xcontext, const ucontext_t *sigcontex 112 | 113 | context->ContextFlags |= CONTEXT_FLOATING_POINT; 114 | context->FltSave = *FPU_sig(sigcontext); 115 | +#ifdef __APPLE__ 116 | + /* CW Hack 24256: mxcsr in signal contexts is incorrect in Rosetta. 117 | + In Rosetta only, the actual value of the register from within the 118 | + handler is correct (on Intel it has some default value). */ 119 | + if (is_rosetta2) 120 | + __asm__ volatile( "stmxcsr %0" : "=m" (context->FltSave.MxCsr) ); 121 | +#endif 122 | context->MxCsr = context->FltSave.MxCsr; 123 | if (xstate_extended_features() && (xs = XState_sig(FPU_sig(sigcontext)))) 124 | { 125 | @@ -1037,7 +1059,11 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) 126 | ret = set_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_AMD64 ); 127 | #ifdef __APPLE__ 128 | if ((flags & CONTEXT_DEBUG_REGISTERS) && (ret == STATUS_UNSUCCESSFUL)) 129 | - WARN_(seh)( "Setting debug registers is not supported under Rosetta\n" ); 130 | + { 131 | + /* CW HACK 22131 */ 132 | + WARN_(seh)( "Setting debug registers is not supported under Rosetta, faking success\n" ); 133 | + ret = STATUS_SUCCESS; 134 | + } 135 | #endif 136 | if (ret || !self) return ret; 137 | if (flags & CONTEXT_DEBUG_REGISTERS) 138 | @@ -1250,6 +1276,14 @@ NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size ) 139 | if (!self) 140 | { 141 | NTSTATUS ret = set_thread_context( handle, context, &self, IMAGE_FILE_MACHINE_I386 ); 142 | +#ifdef __APPLE__ 143 | + if ((flags & CONTEXT_DEBUG_REGISTERS) && (ret == STATUS_UNSUCCESSFUL)) 144 | + { 145 | + /* CW HACK 22131 */ 146 | + WARN_(seh)( "Setting debug registers is not supported under Rosetta, faking success\n" ); 147 | + ret = STATUS_SUCCESS; 148 | + } 149 | +#endif 150 | if (ret || !self) return ret; 151 | if (flags & CONTEXT_I386_DEBUG_REGISTERS) 152 | { 153 | @@ -1775,6 +1809,166 @@ NTSTATUS WINAPI NtCallbackReturn( void *ret_ptr, ULONG ret_len, NTSTATUS status 154 | user_mode_callback_return( ret_ptr, ret_len, status, NtCurrentTeb() ); 155 | } 156 | 157 | +#ifdef __APPLE__ 158 | +/*********************************************************************** 159 | + * handle_cet_nop 160 | + * 161 | + * Check if the fault location is an Intel CET instruction that should be treated as a NOP. 162 | + * Rosetta on Big Sur throws an exception for this, but is fixed in Monterey. 163 | + * CW HACK 20186 164 | + */ 165 | +static inline BOOL handle_cet_nop( ucontext_t *sigcontext, CONTEXT *context ) 166 | +{ 167 | + BYTE instr[16]; 168 | + unsigned int i, prefix_count = 0; 169 | + unsigned int len = virtual_uninterrupted_read_memory( (BYTE *)context->Rip, instr, sizeof(instr) ); 170 | + 171 | + for (i = 0; i < len; i++) switch (instr[i]) 172 | + { 173 | + /* instruction prefixes */ 174 | + case 0x2e: /* %cs: */ 175 | + case 0x36: /* %ss: */ 176 | + case 0x3e: /* %ds: */ 177 | + case 0x26: /* %es: */ 178 | + case 0x40: /* rex */ 179 | + case 0x41: /* rex */ 180 | + case 0x42: /* rex */ 181 | + case 0x43: /* rex */ 182 | + case 0x44: /* rex */ 183 | + case 0x45: /* rex */ 184 | + case 0x46: /* rex */ 185 | + case 0x47: /* rex */ 186 | + case 0x48: /* rex */ 187 | + case 0x49: /* rex */ 188 | + case 0x4a: /* rex */ 189 | + case 0x4b: /* rex */ 190 | + case 0x4c: /* rex */ 191 | + case 0x4d: /* rex */ 192 | + case 0x4e: /* rex */ 193 | + case 0x4f: /* rex */ 194 | + case 0x64: /* %fs: */ 195 | + case 0x65: /* %gs: */ 196 | + case 0x66: /* opcode size */ 197 | + case 0x67: /* addr size */ 198 | + case 0xf0: /* lock */ 199 | + case 0xf2: /* repne */ 200 | + case 0xf3: /* repe */ 201 | + if (++prefix_count >= 15) return FALSE; 202 | + continue; 203 | + 204 | + case 0x0f: /* extended instruction */ 205 | + if (i == len - 1) return 0; 206 | + switch (instr[i + 1]) 207 | + { 208 | + case 0x1E: 209 | + /* RDSSPD/RDSSPQ: (prefixes) 0F 1E (modrm) */ 210 | + RIP_sig(sigcontext) += prefix_count + 3; 211 | + TRACE_(seh)( "skipped RDSSPD/RDSSPQ instruction\n" ); 212 | + return TRUE; 213 | + } 214 | + break; 215 | + default: 216 | + return FALSE; 217 | + } 218 | + return FALSE; 219 | +} 220 | + 221 | +/*********************************************************************** 222 | + * handle_fndisi 223 | + * 224 | + * Check if the fault location is an x87 FNDISI instruction that should be treated as a NOP. 225 | + */ 226 | +static inline BOOL handle_fndisi( ucontext_t *sigcontext, CONTEXT *context ) 227 | +{ 228 | + BYTE instr[16]; 229 | + unsigned int i, prefix_count = 0; 230 | + unsigned int len = virtual_uninterrupted_read_memory( (BYTE *)context->Rip, instr, sizeof(instr) ); 231 | + 232 | + for (i = 0; i < len; i++) switch (instr[i]) 233 | + { 234 | + /* instruction prefixes */ 235 | + case 0x2e: /* %cs: */ 236 | + case 0x36: /* %ss: */ 237 | + case 0x3e: /* %ds: */ 238 | + case 0x26: /* %es: */ 239 | + case 0x40: /* rex */ 240 | + case 0x41: /* rex */ 241 | + case 0x42: /* rex */ 242 | + case 0x43: /* rex */ 243 | + case 0x44: /* rex */ 244 | + case 0x45: /* rex */ 245 | + case 0x46: /* rex */ 246 | + case 0x47: /* rex */ 247 | + case 0x48: /* rex */ 248 | + case 0x49: /* rex */ 249 | + case 0x4a: /* rex */ 250 | + case 0x4b: /* rex */ 251 | + case 0x4c: /* rex */ 252 | + case 0x4d: /* rex */ 253 | + case 0x4e: /* rex */ 254 | + case 0x4f: /* rex */ 255 | + case 0x64: /* %fs: */ 256 | + case 0x65: /* %gs: */ 257 | + case 0x66: /* opcode size */ 258 | + case 0x67: /* addr size */ 259 | + case 0xf0: /* lock */ 260 | + case 0xf2: /* repne */ 261 | + case 0xf3: /* repe */ 262 | + if (++prefix_count >= 15) return FALSE; 263 | + continue; 264 | + 265 | + case 0xdb: 266 | + if (i == len - 1) return 0; 267 | + switch (instr[i + 1]) 268 | + { 269 | + case 0xe1: 270 | + /* RDSSPD/RDSSPQ: (prefixes) DB E1 */ 271 | + RIP_sig(sigcontext) += prefix_count + 2; 272 | + TRACE_(seh)( "skipped FNDISI instruction\n" ); 273 | + return TRUE; 274 | + } 275 | + break; 276 | + default: 277 | + return FALSE; 278 | + } 279 | + return FALSE; 280 | +} 281 | + 282 | +/*********************************************************************** 283 | + * emulate_xgetbv 284 | + * 285 | + * Check if the fault location is an Intel XGETBV instruction for xcr0 and 286 | + * emulate it if so. Actual Intel hardware supports this instruction, so this 287 | + * will only take effect under Rosetta. 288 | + * CW HACK 23427 289 | + */ 290 | +static inline BOOL emulate_xgetbv( ucontext_t *sigcontext, CONTEXT *context ) 291 | +{ 292 | + BYTE instr[3]; 293 | + unsigned int len = virtual_uninterrupted_read_memory( (BYTE *)context->Rip, instr, sizeof(instr) ); 294 | + 295 | + /* Prefixed xgetbv is illegal, so no need to check. */ 296 | + if (len < 3 || instr[0] != 0x0f || instr[1] != 0x01 || instr[2] != 0xd0 || 297 | + (RCX_sig(sigcontext) & 0xffffffff) != 0 /* only handling xcr0 (ecx==0) */) 298 | + { 299 | + return FALSE; 300 | + } 301 | + 302 | + RDX_sig(sigcontext) = 0; 303 | + if (sequoia_or_later) 304 | + { 305 | + /* Arguably we should only claim AVX support if ROSETTA_ADVERTISE_AVX is 306 | + set, but presumably apps will also check cpuid. */ 307 | + RAX_sig(sigcontext) = 0xe7; /* fpu/mmx, sse, avx, full avx-512 */ 308 | + } 309 | + else 310 | + RAX_sig(sigcontext) = 0x07; /* fpu/mmx, sse */ 311 | + 312 | + RIP_sig(sigcontext) += 3; 313 | + TRACE_(seh)( "emulated an XGETBV instruction\n" ); 314 | + return TRUE; 315 | +} 316 | +#endif 317 | 318 | /*********************************************************************** 319 | * is_privileged_instr 320 | @@ -2023,6 +2217,14 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 321 | rec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED; 322 | break; 323 | case TRAP_x86_PRIVINFLT: /* Invalid opcode exception */ 324 | +#ifdef __APPLE__ 325 | + /* CW HACK 20186 */ 326 | + if (handle_cet_nop( ucontext, &context.c )) return; 327 | + /* Winehq Bug 56441 */ 328 | + if (handle_fndisi( ucontext, &context.c )) return; 329 | + /* CW HACK 23427 */ 330 | + if (emulate_xgetbv( ucontext, &context.c )) return; 331 | +#endif 332 | rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; 333 | break; 334 | case TRAP_x86_STKFLT: /* Stack fault */ 335 | @@ -2273,6 +2475,15 @@ static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 336 | 337 | 338 | #ifdef __APPLE__ 339 | +/* CW Hack 24265 */ 340 | +extern void __restore_mxcsr_thunk(void); 341 | +__ASM_GLOBAL_FUNC( __restore_mxcsr_thunk, 342 | + "pushq %rcx\n\t" 343 | + "movq %gs:0x30,%rcx\n\t" 344 | + "ldmxcsr 0x350(%rcx)\n\t" /* amd64_thread_data()->mxcsr */ 345 | + "popq %rcx\n\t" 346 | + "jmp " __ASM_LOCAL_LABEL("__wine_syscall_dispatcher_prolog_end") ); 347 | + 348 | /********************************************************************** 349 | * sigsys_handler 350 | * 351 | @@ -2296,6 +2507,23 @@ static void sigsys_handler( int signal, siginfo_t *siginfo, void *sigcontext ) 352 | R11_sig(ucontext) = frame->eflags; 353 | EFL_sig(ucontext) &= ~0x100; /* clear single-step flag */ 354 | RIP_sig(ucontext) = (ULONG64)__wine_syscall_dispatcher_prolog_end_ptr; 355 | + 356 | + /* CW Hack 24265 */ 357 | + if (is_rosetta2) 358 | + { 359 | + unsigned int direct_mxcsr; 360 | + __asm__ volatile( "stmxcsr %0" : "=m" (direct_mxcsr) ); 361 | + if (direct_mxcsr != FPU_sig(ucontext)->MxCsr) 362 | + { 363 | + FPU_sig(ucontext)->MxCsr = direct_mxcsr; 364 | + 365 | + /* On the M3, Rosetta will restore mxcsr to the initial, incorrect 366 | + value from the sigcontext, even if we change it. So we jump to a 367 | + thunk that restores the value from amd64_thread_data. */ 368 | + amd64_thread_data()->mxcsr = direct_mxcsr; 369 | + RIP_sig(ucontext) = (ULONG64)__restore_mxcsr_thunk; 370 | + } 371 | + } 372 | } 373 | #endif 374 | 375 | @@ -2536,6 +2764,23 @@ void signal_init_process(void) 376 | } 377 | #endif 378 | 379 | +#ifdef __APPLE__ 380 | + /* CW Hack 24256: We need the value of sysctl.proc_translated in signal 381 | + handlers but sysctl[byname] is not signal-safe. */ 382 | + { 383 | + int ret = 0; 384 | + size_t size = sizeof(ret); 385 | + if (sysctlbyname( "sysctl.proc_translated", &ret, &size, NULL, 0 ) == -1) 386 | + is_rosetta2 = 0; 387 | + else 388 | + is_rosetta2 = ret; 389 | + } 390 | + 391 | + /* CW Hack 23427: __builtin_available presumably isn't signal-safe. */ 392 | + if (__builtin_available( macOS 15.0, * )) 393 | + sequoia_or_later = TRUE; 394 | +#endif 395 | + 396 | sig_act.sa_mask = server_block_set; 397 | sig_act.sa_flags = SA_SIGINFO | SA_RESTART | SA_ONSTACK; 398 | 399 | diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c 400 | index 0c0a12c394d..73bd31c9ae0 100644 401 | --- a/dlls/ntdll/unix/virtual.c 402 | +++ b/dlls/ntdll/unix/virtual.c 403 | @@ -62,6 +62,7 @@ 404 | #if defined(__APPLE__) 405 | # include 406 | # include 407 | +# include /* CrossOver Hack #22011 */ 408 | #endif 409 | 410 | #include "ntstatus.h" 411 | @@ -1744,6 +1745,40 @@ static void mprotect_range( void *base, size_t size, BYTE set, BYTE clear ) 412 | if (count) mprotect_exec( addr, count << page_shift, prot ); 413 | } 414 | 415 | +#ifdef __APPLE__ 416 | +static BOOL is_catalina_or_later(void) 417 | +{ 418 | + static int result = -1; 419 | + struct utsname name; 420 | + unsigned major, minor; 421 | + 422 | + if (result == -1) 423 | + { 424 | + result = (uname(&name) == 0 && 425 | + sscanf(name.release, "%u.%u", &major, &minor) == 2 && 426 | + major >= 19 /* macOS 10.15 Catalina */); 427 | + } 428 | + return (result == 1) ? TRUE : FALSE; 429 | +} 430 | +#endif 431 | + 432 | +static void *wine_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) 433 | +{ 434 | +#if defined(__APPLE__) && defined(__x86_64__) 435 | + // In Catalina-and-later, mapping files with execute permissions can make 436 | + // Gatekeeper prompt the user, or just fail outright. 437 | + if (!(flags & MAP_ANON) && fd >= 0 && prot & PROT_EXEC && is_catalina_or_later()) 438 | + { 439 | + void *ret = mmap(addr, len, prot & ~PROT_EXEC, flags, fd, offset); 440 | + 441 | + if (ret != MAP_FAILED && mprotect(ret, len, prot)) 442 | + WARN("failed to mprotect region: %d\n", errno); 443 | + return ret; 444 | + } 445 | +#endif 446 | + return mmap(addr, len, prot, flags, fd, offset); 447 | +} 448 | + 449 | 450 | /*********************************************************************** 451 | * set_vprot 452 | @@ -2114,7 +2149,7 @@ static NTSTATUS map_file_into_view( struct file_view *view, int fd, size_t start 453 | /* only try mmap if media is not removable (or if we require write access) */ 454 | if (!removable || (flags & MAP_SHARED)) 455 | { 456 | - if (mmap( (char *)view->base + start, size, prot, flags, fd, offset ) != MAP_FAILED) 457 | + if (wine_mmap( (char *)view->base + start, size, prot, flags, fd, offset ) != MAP_FAILED) 458 | goto done; 459 | 460 | switch (errno) 461 | @@ -2442,7 +2477,7 @@ static NTSTATUS map_pe_header( void *ptr, size_t size, int fd, BOOL *removable ) 462 | 463 | if (!*removable) 464 | { 465 | - if (mmap( ptr, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FIXED|MAP_PRIVATE, fd, 0 ) != MAP_FAILED) 466 | + if (wine_mmap( ptr, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FIXED|MAP_PRIVATE, fd, 0 ) != MAP_FAILED) 467 | return STATUS_SUCCESS; 468 | 469 | switch (errno) 470 | @@ -3943,7 +3978,7 @@ void virtual_map_user_shared_data(void) 471 | exit(1); 472 | } 473 | if ((res = server_get_unix_fd( section, 0, &fd, &needs_close, NULL, NULL )) || 474 | - (user_shared_data != mmap( user_shared_data, page_size, PROT_READ, MAP_SHARED|MAP_FIXED, fd, 0 ))) 475 | + (user_shared_data != wine_mmap( user_shared_data, page_size, PROT_READ, MAP_SHARED|MAP_FIXED, fd, 0 ))) 476 | { 477 | ERR( "failed to remap the process USD: %d\n", res ); 478 | exit(1); 479 | @@ -4039,6 +4074,17 @@ NTSTATUS virtual_handle_fault( EXCEPTION_RECORD *rec, void *stack ) 480 | WARN( "treating read fault in a readable page as a write fault, addr %p\n", addr ); 481 | err = EXCEPTION_WRITE_FAULT; 482 | } 483 | + 484 | + /* CW Hack 24945 */ 485 | + if (err == EXCEPTION_WRITE_FAULT && 486 | + ((get_unix_prot( vprot ) & (PROT_WRITE | PROT_EXEC)) == (PROT_WRITE | PROT_EXEC))) 487 | + { 488 | + FIXME( "HACK: write fault on a w|x page, addr %p\n", addr ); 489 | + mprotect_range( page, page_size, 0, VPROT_EXEC ); 490 | + mprotect_range( page, page_size, VPROT_EXEC, 0 ); 491 | + ret = STATUS_SUCCESS; 492 | + goto done; 493 | + } 494 | #endif 495 | 496 | if (!is_inside_signal_stack( stack ) && (vprot & VPROT_GUARD)) 497 | @@ -4075,6 +4121,8 @@ NTSTATUS virtual_handle_fault( EXCEPTION_RECORD *rec, void *stack ) 498 | ret = STATUS_SUCCESS; 499 | } 500 | } 501 | + 502 | +done: 503 | mutex_unlock( &virtual_mutex ); 504 | rec->ExceptionCode = ret; 505 | return ret; 506 | @@ -6124,6 +6172,56 @@ NTSTATUS WINAPI NtReadVirtualMemory( HANDLE process, const void *addr, void *buf 507 | return status; 508 | } 509 | 510 | +#ifdef __APPLE__ 511 | +static int is_apple_silicon(void) 512 | +{ 513 | + static int apple_silicon_status, did_check = 0; 514 | + if (!did_check) 515 | + { 516 | + /* returns 0 for native process or on error, 1 for translated */ 517 | + int ret = 0; 518 | + size_t size = sizeof(ret); 519 | + if (sysctlbyname( "sysctl.proc_translated", &ret, &size, NULL, 0 ) == -1) 520 | + apple_silicon_status = 0; 521 | + else 522 | + apple_silicon_status = ret; 523 | + 524 | + did_check = 1; 525 | + } 526 | + 527 | + return apple_silicon_status; 528 | +} 529 | + 530 | +/* CW HACK 18947 531 | + * If mach_vm_write() is used to modify code cross-process (which is how we implement 532 | + * NtWriteVirtualMemory), Rosetta won't notice the change and will execute the "old" code. 533 | + * 534 | + * To work around this, after the write completes, 535 | + * toggle the executable bit (from inside the target process) on/off for any executable 536 | + * pages that were modified, to force Rosetta to re-translate it. 537 | + */ 538 | +static void toggle_executable_pages_for_rosetta( HANDLE process, void *addr, SIZE_T size ) 539 | +{ 540 | + MEMORY_BASIC_INFORMATION info; 541 | + NTSTATUS status; 542 | + SIZE_T ret; 543 | + 544 | + if (!is_apple_silicon()) 545 | + return; 546 | + 547 | + status = NtQueryVirtualMemory( process, addr, MemoryBasicInformation, &info, sizeof(info), &ret ); 548 | + 549 | + if (!status && (info.AllocationProtect & 0xf0)) 550 | + { 551 | + DWORD origprot, noexec; 552 | + noexec = info.AllocationProtect & ~0xf0; 553 | + if (!noexec) noexec = PAGE_NOACCESS; 554 | + 555 | + NtProtectVirtualMemory( process, &addr, &size, noexec, &origprot ); 556 | + NtProtectVirtualMemory( process, &addr, &size, origprot, &noexec ); 557 | + } 558 | +} 559 | +#endif 560 | 561 | /*********************************************************************** 562 | * NtWriteVirtualMemory (NTDLL.@) 563 | @@ -6144,6 +6242,10 @@ NTSTATUS WINAPI NtWriteVirtualMemory( HANDLE process, void *addr, const void *bu 564 | if ((status = wine_server_call( req ))) size = 0; 565 | } 566 | SERVER_END_REQ; 567 | + 568 | +#ifdef __APPLE__ 569 | + toggle_executable_pages_for_rosetta( process, addr, size ); 570 | +#endif 571 | } 572 | else 573 | { 574 | diff --git a/dlls/wow64cpu/cpu.c b/dlls/wow64cpu/cpu.c 575 | index 6c6b2352bb6..2edac50a51c 100644 576 | --- a/dlls/wow64cpu/cpu.c 577 | +++ b/dlls/wow64cpu/cpu.c 578 | @@ -40,10 +40,35 @@ struct thunk_32to64 579 | DWORD addr; 580 | WORD cs; 581 | }; 582 | +struct thunk_32to64_rosetta2_workaround 583 | +{ 584 | + BYTE lcall; /* call far, absolute indirect */ 585 | + BYTE modrm; /* address=disp32, opcode=3 */ 586 | + DWORD op; 587 | + DWORD addr; 588 | + WORD cs; 589 | + 590 | + BYTE add; 591 | + BYTE add_modrm; 592 | + BYTE add_op; 593 | + 594 | + BYTE jmp; 595 | + BYTE jmp_modrm; 596 | + DWORD jmp_op; 597 | + ULONG64 jmp_addr; 598 | +}; 599 | struct thunk_opcodes 600 | { 601 | - struct thunk_32to64 syscall_thunk; 602 | - struct thunk_32to64 unix_thunk; 603 | + union 604 | + { 605 | + struct thunk_32to64 syscall_thunk; 606 | + struct thunk_32to64_rosetta2_workaround syscall_thunk_rosetta; 607 | + }; 608 | + union 609 | + { 610 | + struct thunk_32to64 unix_thunk; 611 | + struct thunk_32to64_rosetta2_workaround unix_thunk_rosetta; 612 | + }; 613 | }; 614 | #include "poppack.h" 615 | 616 | @@ -55,6 +80,19 @@ static USHORT fs32_sel; 617 | 618 | void **__wine_unix_call_dispatcher = NULL; 619 | 620 | +BOOL use_rosetta2_workaround; 621 | + 622 | +static BOOL is_rosetta2(void) 623 | +{ 624 | + char buffer[64]; 625 | + NTSTATUS status = NtQuerySystemInformation( SystemProcessorBrandString, buffer, sizeof(buffer), NULL ); 626 | + 627 | + if (status || !strstr( buffer, "VirtualApple" )) 628 | + return FALSE; 629 | + 630 | + return TRUE; 631 | +} 632 | + 633 | BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, void *reserved ) 634 | { 635 | if (reason == DLL_PROCESS_ATTACH) LdrDisableThreadCalloutsForDll( inst ); 636 | @@ -206,7 +244,21 @@ __ASM_GLOBAL_FUNC( syscall_32to64, 637 | "movl %edx,4(%rsp)\n\t" 638 | "movl 0xc4(%r13),%r14d\n\t" /* context->Esp */ 639 | "xchgq %r14,%rsp\n\t" 640 | - "ljmp *(%r14)\n" 641 | + 642 | + /* CW HACK 20760: 643 | + * When running under Rosetta 2, use lretq instead of ljmp to work around a SIGUSR1 race condition. 644 | + */ 645 | + "cmpl $0, " __ASM_NAME("use_rosetta2_workaround") "\n\t" 646 | + "jne syscall_32to64_rosetta2_workaround\n\t" 647 | + "ljmp *(%r14)\n\t" 648 | + "syscall_32to64_rosetta2_workaround:\n\t" 649 | + "subq $0x10,%rsp\n\t" 650 | + "movl 4(%r14),%edx\n\t" 651 | + "movq %rdx,0x8(%rsp)\n\t" 652 | + "movl 0(%r14),%edx\n\t" 653 | + "movq %rdx,(%rsp)\n\t" 654 | + "lretq\n" 655 | + 656 | ".Lsyscall_32to64_return:\n\t" 657 | "movq %rsp,%r14\n\t" 658 | "movl 0xa8(%r13),%edx\n\t" /* context->Edx */ 659 | @@ -263,7 +315,20 @@ __ASM_GLOBAL_FUNC( unix_call_32to64, 660 | "movl %edx,4(%rsp)\n\t" 661 | "movl 0xc4(%r13),%r14d\n\t" /* context->Esp */ 662 | "xchgq %r14,%rsp\n\t" 663 | - "ljmp *(%r14)" ) 664 | + 665 | + /* CW HACK 20760: 666 | + * When running under Rosetta 2, use lretq instead of ljmp to work around a SIGUSR1 race condition. 667 | + */ 668 | + "cmpl $0, " __ASM_NAME("use_rosetta2_workaround") "\n\t" 669 | + "jne unix_call_32to64_rosetta2_workaround\n\t" 670 | + "ljmp *(%r14)\n\t" 671 | + "unix_call_32to64_rosetta2_workaround:\n\t" 672 | + "subq $0x10,%rsp\n\t" 673 | + "movl 4(%r14),%edx\n\t" 674 | + "movq %rdx,0x8(%rsp)\n\t" 675 | + "movl 0(%r14),%edx\n\t" 676 | + "movq %rdx,(%rsp)\n\t" 677 | + "lretq" ) 678 | 679 | 680 | /********************************************************************** 681 | @@ -309,6 +374,8 @@ NTSTATUS WINAPI BTCpuProcessInit(void) 682 | 683 | wow64info->CpuFlags |= WOW64_CPUFLAGS_MSFT64; 684 | 685 | + use_rosetta2_workaround = is_rosetta2(); 686 | + 687 | LdrGetDllHandle( NULL, 0, &str, &module ); 688 | p__wine_unix_call_dispatcher = RtlFindExportedRoutineByName( module, "__wine_unix_call_dispatcher" ); 689 | __wine_unix_call_dispatcher = *p__wine_unix_call_dispatcher; 690 | @@ -318,17 +385,65 @@ NTSTATUS WINAPI BTCpuProcessInit(void) 691 | ds64_sel = context.SegDs; 692 | fs32_sel = context.SegFs; 693 | 694 | - thunk->syscall_thunk.ljmp = 0xff; 695 | - thunk->syscall_thunk.modrm = 0x2d; 696 | - thunk->syscall_thunk.op = PtrToUlong( &thunk->syscall_thunk.addr ); 697 | - thunk->syscall_thunk.addr = PtrToUlong( syscall_32to64 ); 698 | - thunk->syscall_thunk.cs = cs64_sel; 699 | - 700 | - thunk->unix_thunk.ljmp = 0xff; 701 | - thunk->unix_thunk.modrm = 0x2d; 702 | - thunk->unix_thunk.op = PtrToUlong( &thunk->unix_thunk.addr ); 703 | - thunk->unix_thunk.addr = PtrToUlong( unix_call_32to64 ); 704 | - thunk->unix_thunk.cs = cs64_sel; 705 | + /* CW HACK 20760 */ 706 | + if (use_rosetta2_workaround) 707 | + { 708 | + thunk->syscall_thunk_rosetta.lcall = 0xff; 709 | + thunk->syscall_thunk_rosetta.modrm = 0x1d; 710 | + thunk->syscall_thunk_rosetta.op = PtrToUlong( &thunk->syscall_thunk_rosetta.addr ); 711 | + thunk->syscall_thunk_rosetta.addr = PtrToUlong( &thunk->syscall_thunk_rosetta.add ); 712 | + thunk->syscall_thunk_rosetta.cs = cs64_sel; 713 | + 714 | + /* We are now in 64-bit. */ 715 | + /* add $0x08,%esp to remove the addr/segment pushed on the stack by the lcall */ 716 | + thunk->syscall_thunk_rosetta.add = 0x83; 717 | + thunk->syscall_thunk_rosetta.add_modrm = 0xc4; 718 | + thunk->syscall_thunk_rosetta.add_op = 0x08; 719 | + 720 | + /* jmp to syscall_32to64 */ 721 | + thunk->syscall_thunk_rosetta.jmp = 0xff; 722 | + thunk->syscall_thunk_rosetta.jmp_modrm = 0x25; 723 | + thunk->syscall_thunk_rosetta.jmp_op = 0x00; 724 | + thunk->syscall_thunk_rosetta.jmp_addr = PtrToUlong( syscall_32to64 ); 725 | + } 726 | + else 727 | + { 728 | + thunk->syscall_thunk.ljmp = 0xff; 729 | + thunk->syscall_thunk.modrm = 0x2d; 730 | + thunk->syscall_thunk.op = PtrToUlong( &thunk->syscall_thunk.addr ); 731 | + thunk->syscall_thunk.addr = PtrToUlong( syscall_32to64 ); 732 | + thunk->syscall_thunk.cs = cs64_sel; 733 | + } 734 | + 735 | + /* CW HACK 20760 */ 736 | + if (use_rosetta2_workaround) 737 | + { 738 | + thunk->unix_thunk_rosetta.lcall = 0xff; 739 | + thunk->unix_thunk_rosetta.modrm = 0x1d; 740 | + thunk->unix_thunk_rosetta.op = PtrToUlong( &thunk->unix_thunk_rosetta.addr ); 741 | + thunk->unix_thunk_rosetta.addr = PtrToUlong( &thunk->unix_thunk_rosetta.add ); 742 | + thunk->unix_thunk_rosetta.cs = cs64_sel; 743 | + 744 | + /* We are now in 64-bit. */ 745 | + /* add $0x08,%esp to remove the addr/segment pushed on the stack by the lcall */ 746 | + thunk->unix_thunk_rosetta.add = 0x83; 747 | + thunk->unix_thunk_rosetta.add_modrm = 0xc4; 748 | + thunk->unix_thunk_rosetta.add_op = 0x08; 749 | + 750 | + /* jmp to unix_call_32to64 */ 751 | + thunk->unix_thunk_rosetta.jmp = 0xff; 752 | + thunk->unix_thunk_rosetta.jmp_modrm = 0x25; 753 | + thunk->unix_thunk_rosetta.jmp_op = 0x00; 754 | + thunk->unix_thunk_rosetta.jmp_addr = PtrToUlong( unix_call_32to64 ); 755 | + } 756 | + else 757 | + { 758 | + thunk->unix_thunk.ljmp = 0xff; 759 | + thunk->unix_thunk.modrm = 0x2d; 760 | + thunk->unix_thunk.op = PtrToUlong( &thunk->unix_thunk.addr ); 761 | + thunk->unix_thunk.addr = PtrToUlong( unix_call_32to64 ); 762 | + thunk->unix_thunk.cs = cs64_sel; 763 | + } 764 | 765 | NtProtectVirtualMemory( GetCurrentProcess(), (void **)&thunk, &size, PAGE_EXECUTE_READ, &old_prot ); 766 | return STATUS_SUCCESS; 767 | diff --git a/server/mach.c b/server/mach.c 768 | index c3d4a33bdc2..9ff7580177e 100644 769 | --- a/server/mach.c 770 | +++ b/server/mach.c 771 | @@ -48,6 +48,7 @@ 772 | #include 773 | #include 774 | #include 775 | +#include 776 | 777 | static mach_port_t server_mach_port; 778 | 779 | @@ -172,6 +173,26 @@ void init_thread_context( struct thread *thread ) 780 | { 781 | } 782 | 783 | +/* CX HACK 21217 */ 784 | +static int is_apple_silicon( void ) 785 | +{ 786 | + static int apple_silicon_status, did_check = 0; 787 | + if (!did_check) 788 | + { 789 | + /* returns 0 for native process or on error, 1 for translated */ 790 | + int ret = 0; 791 | + size_t size = sizeof(ret); 792 | + if (sysctlbyname( "sysctl.proc_translated", &ret, &size, NULL, 0 ) == -1) 793 | + apple_silicon_status = 0; 794 | + else 795 | + apple_silicon_status = ret; 796 | + 797 | + did_check = 1; 798 | + } 799 | + 800 | + return apple_silicon_status; 801 | +} 802 | + 803 | /* retrieve the thread x86 registers */ 804 | void get_thread_context( struct thread *thread, struct context_data *context, unsigned int flags ) 805 | { 806 | @@ -251,6 +272,13 @@ void get_thread_context( struct thread *thread, struct context_data *context, un 807 | } 808 | context->flags |= SERVER_CTX_DEBUG_REGISTERS; 809 | } 810 | + else if (is_apple_silicon()) 811 | + { 812 | + /* CX HACK 21217: Fake debug registers on Apple Silicon */ 813 | + fprintf( stderr, "%04x: thread_get_state failed on Apple Silicon - faking zero debug registers\n", thread->id ); 814 | + memset( &context->debug, 0, sizeof(context->debug) ); 815 | + context->flags |= SERVER_CTX_DEBUG_REGISTERS; 816 | + } 817 | else 818 | mach_set_error( ret ); 819 | done: 820 | --------------------------------------------------------------------------------