├── .travis.yml ├── AppRun ├── LICENSE ├── README.md ├── deploydocker └── Dockerfile.wine-deploy.archlinux ├── deployscript ├── archlinux-wine-deploy.sh └── test_name.sh ├── resource ├── Wine.png └── wine.desktop └── src ├── libhookexecv.c └── preloaderhook.c /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | language: cpp 4 | services: 5 | - docker 6 | 7 | env: 8 | global: 9 | - RELEASE_BRANCH="master" 10 | 11 | before_install: 12 | # appimagetool 13 | - wget -nv -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" -O appimagetool.AppImage 14 | 15 | script: 16 | # archlinux 17 | - docker build . -f deploydocker/Dockerfile.wine-deploy.archlinux -t wine-appimage.archlinux 18 | 19 | after_success: 20 | - mkdir apps 21 | 22 | # archlinux 23 | - docker run --rm -v $(pwd)/apps:/tmp/apps -ti wine-appimage.archlinux cp result.tar /tmp/apps 24 | 25 | # extract result 26 | - tar xvf apps/result.tar -C apps 27 | - rm -rf apps/result.tar 28 | 29 | # md5sum tool 30 | - wget -c https://github.com/ferion11/libsutil/releases/download/md5sum_util_v0.1/md5sum_util.sh 31 | - bash md5sum_util.sh apps 32 | 33 | # uploadtool 34 | - wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh 35 | 36 | - |- # publish 37 | if [[ ("$TRAVIS_BRANCH" != "$RELEASE_BRANCH" && "$TRAVIS_BRANCH" != "$TRAVIS_TAG") || "$TRAVIS_EVENT_TYPE" != "push" ]]; then 38 | echo 'Publishing release to GitHub...' 39 | export UPLOADTOOL_SUFFIX="$TRAVIS_BRANCH" 40 | export UPLOADTOOL_BODY="Instructions on using the AppImage can be found [here](https://github.com/${TRAVIS_REPO_SLUG}/blob/master/README.md)\n\nThis is the ***$UPLOADTOOL_SUFFIX experimental build*** for testing new features.\n\nTravis CI build log: $TRAVIS_BUILD_WEB_URL" 41 | bash upload.sh apps/* 42 | elif [[ "$TRAVIS_BRANCH" != "$TRAVIS_TAG" ]]; then 43 | echo 'Publishing release to GitHub...' 44 | export UPLOADTOOL_BODY="Instructions on using the AppImage can be found [here](https://github.com/${TRAVIS_REPO_SLUG}/blob/master/README.md)\n\nThis is the ***latest development build***.\n\nTravis CI build log: $TRAVIS_BUILD_WEB_URL" 45 | bash upload.sh apps/* 46 | else 47 | echo 'Publishing release to GitHub...' 48 | export UPLOADTOOL_BODY="Instructions on using the AppImage can be found [here](https://github.com/${TRAVIS_REPO_SLUG}/blob/master/README.md)\n\nThis is the ***release $TRAVIS_TAG stable build***.\n\nTravis CI build log: $TRAVIS_BUILD_WEB_URL" 49 | bash upload.sh apps/* 50 | fi 51 | 52 | branches: 53 | except: 54 | - # Do not build tags that we create when we upload to GitHub Releases 55 | - /^(?i:continuous)$/ 56 | - /^release-[0-9a-z\-]*/ 57 | - /^(?i:untagged)-.*$/ 58 | 59 | notifications: 60 | email: 61 | on_success: change # default: change 62 | on_failure: always # default: always -------------------------------------------------------------------------------- /AppRun: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | HERE="$(dirname "$(readlink -f "${0}")")" 3 | F11_APPIMAGE_TMP_DIR="${HERE}_tmp" 4 | F11_APPIMAGE_CONF_DIR="${HOME}/.config/f11conf" 5 | F11_APPIMAGE_VKCONF="${F11_APPIMAGE_CONF_DIR}/vulkan.conf" 6 | #=================================================================== 7 | 8 | make_dir() { [ ! -d "${1}" ] && mkdir -p "${1}"; }; 9 | 10 | function cleanup { 11 | # clean tmp files: 12 | rm -rf "${F11_APPIMAGE_TMP_DIR}" 13 | } 14 | #------------------------------ 15 | 16 | # Configure AppImage: 17 | if [ "${1}" = "f11conf" ] ; then 18 | echo "Init Configuration:" 19 | make_dir "${F11_APPIMAGE_CONF_DIR}" 20 | #like: wine.appimage f11conf vulkan radeon:intel 21 | if [ "${2}" = "vulkan" ] ; then 22 | cat > "${F11_APPIMAGE_VKCONF}" << EOF 23 | F11_VULKAN="${3}" 24 | EOF 25 | cat "${F11_APPIMAGE_VKCONF}" 26 | fi 27 | echo "Configuration done! " 28 | exit 0 29 | fi 30 | 31 | # Create a tmp dir to some utils like vulkan (need one new, so remove the old): 32 | if [ -d "${F11_APPIMAGE_TMP_DIR}" ]; then 33 | rm -rf "${F11_APPIMAGE_TMP_DIR}" 34 | fi 35 | mkdir "${F11_APPIMAGE_TMP_DIR}" 36 | 37 | trap cleanup EXIT 38 | #=================================================================== 39 | 40 | # If not extract and overwrite, ${HERE}/lib is a link to ${HERE}/usr/lib, that link to ${HERE}/usr/lib64 41 | export LD_LIBRARY_PATH="${HERE}/usr/lib:${LD_LIBRARY_PATH}" 42 | export LD_LIBRARY_PATH="${HERE}/usr/lib32:${LD_LIBRARY_PATH}" 43 | export LD_LIBRARY_PATH="${HERE}/lib:${LD_LIBRARY_PATH}" 44 | 45 | export PATH="${HERE}/bin:${HERE}/usr/bin:${PATH}" 46 | #---------------------------------------- 47 | 48 | #Sound Library 49 | export LD_LIBRARY_PATH="${HERE}/usr/lib32/pulseaudio:${LD_LIBRARY_PATH}" 50 | export LD_LIBRARY_PATH="${HERE}/usr/lib32/alsa-lib:${LD_LIBRARY_PATH}" 51 | export LADSPA_PATH="${HERE}/usr/lib32/ladspa:${LADSPA_PATH}" 52 | export AO_PLUGIN_PATH="${HERE}/usr/lib32/ao/plugins-4:${AO_PLUGIN_PATH}" 53 | 54 | # For mpg123 55 | export LD_LIBRARY_PATH="${HERE}/usr/lib32/mpg123:${LD_LIBRARY_PATH}" 56 | 57 | # for libomxil-bellagio 58 | export BELLAGIO_SEARCH_PATH="${HERE}/usr/lib32/bellagio:${HERE}/usr/lib32/omxloaders:${HERE}/usr/lib32" 59 | 60 | # libGL drivers 61 | export LIBGL_DRIVERS_PATH="${HERE}/usr/lib32/dri:${LIBGL_DRIVERS_PATH}" 62 | 63 | # Gallium Nine 64 | export D3D_MODULE_PATH="${HERE}/usr/lib32/d3d:${D3D_MODULE_PATH}" 65 | 66 | #Font Config 67 | export FONTCONFIG_PATH="${HERE}/etc/fonts:${FONTCONFIG_PATH}" 68 | 69 | #LD 70 | export MAIN32LDLIBRARY="${HERE}/usr/lib32/ld-linux.so.2" 71 | 72 | #For webcam V4L (but only for v4l1, not for v4l2) 73 | #export V4LCLDLIBRARY="${HERE}/usr/lib32/libv4l/v4l1compat.so" 74 | #---------------------------------------- 75 | 76 | # GTK 3.0 77 | export GTK_PATH="${HERE}/usr/lib32/gtk-3.0" 78 | #------------------------------ 79 | 80 | # GStreamer environment variables 81 | export GST_REGISTRY_REUSE_PLUGIN_SCANNER="no" 82 | export GST_PLUGIN_SYSTEM_PATH_1_0="${HERE}/usr/lib32/gstreamer-1.0/" 83 | 84 | export GST_PLUGIN_SCANNER_1_0="${HERE}/usr/lib32/gstreamer-1.0/gst-plugin-scanner" 85 | export GST_PTP_HELPER_1_0="${HERE}/usr/lib32/gstreamer-1.0/gst-ptp-helper" 86 | 87 | export GST_PLUGIN_PATH="${GST_PLUGIN_SYSTEM_PATH_1_0}" 88 | export GST_PLUGIN_SYSTEM_PATH="${GST_PLUGIN_SYSTEM_PATH_1_0}" 89 | export GST_PLUGIN_SCANNER="${GST_PLUGIN_SCANNER_1_0}" 90 | #=================================================================== 91 | 92 | # Gdk Pixbuf 93 | export GDK_PIXBUF_MODULE_FILE="${F11_APPIMAGE_TMP_DIR}/gdk_pixbuf_loaders.cache" 94 | export GDK_PIXBUF_MODULEDIR="${HERE}/usr/lib32/gdk-pixbuf-2.0/2.10.0/loaders" 95 | if [ -d "${F11_APPIMAGE_TMP_DIR}" ]; then 96 | "${MAIN32LDLIBRARY}" "${HERE}/usr/bin/gdk-pixbuf-query-loaders-32" --update-cache 97 | fi 98 | #=================================================================== 99 | 100 | # For Vulkan drivers: 101 | # Setting VK_ICD_FILENAMES... But the user can use his own variable for local drivers 102 | if [ -n "${VK_ICD_FILENAMES}" ] && [ -d "${F11_APPIMAGE_TMP_DIR}" ] 103 | then 104 | echo "Using user VK_ICD_FILENAMES: ${VK_ICD_FILENAMES}" 105 | elif [ -f "${F11_APPIMAGE_VKCONF}" ]; then 106 | # shellcheck source=/dev/null 107 | . "${F11_APPIMAGE_VKCONF}" 108 | 109 | IFS_TMP="${IFS}" 110 | IFS=: 111 | for driver in ${F11_VULKAN}; do 112 | #echo "${driver}" 113 | if [ "${driver}" = "intel" ]; then 114 | export VK_ICD_FILENAMES="${VK_ICD_FILENAMES}:${F11_APPIMAGE_TMP_DIR}/intel_icd.i686.json" 115 | cat > "${F11_APPIMAGE_TMP_DIR}/intel_icd.i686.json" << EOF 116 | { 117 | "ICD": { 118 | "api_version": "1.2.131", 119 | "library_path": "${HERE}/usr/lib32/libvulkan_intel.so" 120 | }, 121 | "file_format_version": "1.0.0" 122 | } 123 | EOF 124 | elif [ "${driver}" = "radeon" ]; then 125 | export VK_ICD_FILENAMES="${VK_ICD_FILENAMES}:${F11_APPIMAGE_TMP_DIR}/radeon_icd.i686.json" 126 | cat > "${F11_APPIMAGE_TMP_DIR}/radeon_icd.i686.json" << EOF 127 | { 128 | "ICD": { 129 | "api_version": "1.2.131", 130 | "library_path": "${HERE}/usr/lib32/libvulkan_radeon.so" 131 | }, 132 | "file_format_version": "1.0.0" 133 | } 134 | EOF 135 | else 136 | echo "ERROR: Driver \"${driver}\" unsupported yet!!!" 137 | fi 138 | done 139 | 140 | IFS="${IFS_TMP}" 141 | fi 142 | #=================================================================== 143 | 144 | ##Wine ENVs (see: https://wiki.winehq.org/Wine-Staging_Environment_Variables) 145 | # arch and bottle first: 146 | export WINEARCH=win32 147 | if [ -z "${WINEPREFIX}" ] 148 | then 149 | export WINEPREFIX="${HOME}/.proton32" 150 | fi 151 | #export WINEVERPATH="${WINEVERPATH:-"${HERE}"}" 152 | export WINEVERPATH="${HERE}" 153 | export WINESERVER="${HERE}/bin/wineserver" 154 | export WINELOADER="${HERE}/bin/wine" 155 | export WINEPATH="${HERE}/bin:${HERE}/lib/wine:${WINEPATH}" 156 | export WINEDLLPATH="${HERE}/lib/wine/fakedlls:${WINEDLLPATH}" 157 | #export WINEDEBUG="${WINEDEBUG:-"-all"}" 158 | #export WINEDEBUG=fixme-all 159 | #export WINEDLLOVERRIDES="${WINEDLLOVERRIDES:-"mscoree,mshtml="}" 160 | #export WINEESYNC=0 161 | #export WINEESYNC="${WINEESYNC:-"1"}" 162 | 163 | export LD_LIBRARY_PATH="${HERE}/lib/wine:${LD_LIBRARY_PATH}" 164 | export WINELDLIBRARY="${MAIN32LDLIBRARY}" 165 | #---------------------------------------- 166 | 167 | # Load winecfg if no arguments given 168 | APPLICATION="" 169 | if [ -z "${*}" ] ; then 170 | APPLICATION="winecfg" 171 | fi 172 | 173 | # Allow the AppImage to be symlinked to e.g., /usr/bin/wineserver 174 | if [ -n "${APPIMAGE}" ] ; then 175 | BINARY_NAME="$(basename "${ARGV0}")" 176 | else 177 | BINARY_NAME="$(basename "${0}")" 178 | fi 179 | 180 | # change some scripts to exe executables 181 | if [[ "${1}" =~ ^(winecfg|wineboot|regedit|regsvr32|msiexec|msidb|notepad|winefile|winemine)$ ]]; then 182 | args=( "${@}" ) 183 | args[0]="${1}.exe" 184 | set "${args[@]}" 185 | fi 186 | 187 | if [ -n "${1}" ] && [ -x "${HERE}/bin/${1}" ] ; then 188 | MAIN="${HERE}/bin/${1}" ; shift 189 | elif [ -n "${1}" ] && [ -x "${HERE}/usr/bin/${1}" ] ; then 190 | MAIN="${HERE}/usr/bin/${1}" ; shift 191 | elif [ -x "${HERE}/bin/${BINARY_NAME}" ] ; then 192 | MAIN="${HERE}/bin/${BINARY_NAME}" 193 | elif [ -x "${HERE}/usr/bin/${BINARY_NAME}" ] ; then 194 | MAIN="${HERE}/usr/bin/${BINARY_NAME}" 195 | else 196 | MAIN="${HERE}/bin/wine" 197 | fi 198 | 199 | # Exec outside apps with inside environment (make the link name "ExternalExec") 200 | if [ "${BINARY_NAME}" = "ExternalExec" ] && [ -n "${1}" ] && [ -x "${1}" ]; then 201 | MAIN="${1}" ; shift 202 | fi 203 | #=================================================================== 204 | 205 | if [ -z "${APPLICATION}" ] ; then 206 | LD_PRELOAD="${HERE}/bin/libhookexecv.so" "${WINELDLIBRARY}" "${MAIN}" "${@}" | cat 207 | else 208 | LD_PRELOAD="${HERE}/bin/libhookexecv.so" "${WINELDLIBRARY}" "${MAIN}" "${APPLICATION}" | cat 209 | fi 210 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 DanielDevBR 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.com/ferion11/Proton_Appimage.svg?branch=master)](https://travis-ci.com/ferion11/Proton_Appimage) [![AppImage Build](https://img.shields.io/badge/AppImage-build-blue)](https://github.com/ferion11/Proton_Appimage/releases) 2 | 3 | # Appimage For Wine Proton 4 | 5 | > Appimage for last Wine Proton 32bits from PlayOnLinux. You can just download the Appimage, put in the directory you like and make symbolic links for it (for wine, wineserver...). 6 | 7 | #### 1- Download proton-VERSION.AppImage for your AppImage directory [here][PROTON_release_continuous]. And if you want the normal wine, you can get it [here_link][WINE_normal] 8 | #### 2- Make executable: 9 | ``` 10 | $ chmod +x proton-VERSION.AppImage 11 | ``` 12 | #### 3- Make the wine link in your bin directory: 13 | ``` 14 | $ ln -s proton-VERSION.AppImage wine 15 | ``` 16 | #### 4- Make the wineserver link (for winetricks) in your bin directory: 17 | ``` 18 | $ ln -s proton-VERSION.AppImage wineserver 19 | ``` 20 | 21 | ## Have set: 22 | - WINEARCH=win32 (fixed and can't be changed) 23 | - WINEPREFIX=~/.proton32 (can be changed if needed) 24 | 25 | ## Usage: 26 | #### For configuration, just run "wine" (it will run the winecfg) or: 27 | ``` 28 | $ wine winecfg 29 | ``` 30 | #### For regedit: 31 | ``` 32 | wine regedit 33 | ``` 34 | #### For your Apps: 35 | ``` 36 | wine xyz.exe 37 | ``` 38 | #### If you use PRIME, you can use something like that too: 39 | ``` 40 | DRI_PRIME=1 wine xyz.exe 41 | ``` 42 | #### Optional 1- To test the OpenGL of your video card: 43 | ``` 44 | $ wine glxinfo32 45 | $ wine glxgears32 -info 46 | $ wine shape32 47 | ``` 48 | #### Optional 2- You can use PRIME too: 49 | ``` 50 | $ DRI_PRIME=1 wine glxgears32 -info 51 | ``` 52 | #### Optional 3- Configure and run vulkan (only intel and radeon are supported now): 53 | - Configure for intel: 54 | ``` 55 | $ wine f11conf vulkan intel 56 | ``` 57 | - Configure for radeon: 58 | ``` 59 | $ wine f11conf vulkan radeon 60 | ``` 61 | - Configure for intel and radeon together: 62 | ``` 63 | $ wine f11conf vulkan radeon:intel 64 | ``` 65 | - Test vulkan: 66 | ``` 67 | $ wine vulkaninfo32 68 | $ wine vkcube32 69 | ``` 70 | 71 | [PROTON_release_continuous]: https://github.com/ferion11/Proton_Appimage/releases/tag/continuous "here" 72 | [WINE_normal]: https://github.com/ferion11/Wine_Appimage "here_link" 73 | -------------------------------------------------------------------------------- /deploydocker/Dockerfile.wine-deploy.archlinux: -------------------------------------------------------------------------------- 1 | FROM archlinux/base 2 | 3 | COPY . /srv/wineappimage 4 | 5 | WORKDIR /srv/wineappimage 6 | RUN /srv/wineappimage/deployscript/archlinux-wine-deploy.sh 7 | -------------------------------------------------------------------------------- /deployscript/archlinux-wine-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | P_URL="https://www.playonlinux.com/wine/binaries/phoenicis/proton-linux-x86/PlayOnLinux-proton_4.2-proton-linux-x86.tar.gz" 3 | P_NAME=$(echo $P_URL | cut -d/ -f7) 4 | P_FILENAME=$(echo $P_URL | cut -d/ -f8) 5 | P_CSOURCE=$(echo $P_FILENAME | cut -d- -f1) 6 | P_VERSION=$(echo $P_FILENAME | cut -d- -f2 | cut -d_ -f2) 7 | WINE_WORKDIR="wineversion" 8 | PKG_WORKDIR="pkg_work" 9 | 10 | #========================= 11 | die() { echo >&2 "$*"; exit 1; }; 12 | 13 | get_archlinux32_pkg() { 14 | #WARNING: Only work on well formatted html 15 | #usage: get_archlinux32_pkg [link] [dest] 16 | # get_archlinux32_pkg http://pool.mirror.archlinux32.org/pentium4/extra/aom-1.0.0.errata1-1.2-pentium4.pkg.tar.xz ./cache/ 17 | # get_archlinux32_pkg https://www.archlinux32.org/packages/pentium4/extra/xvidcore/ ./cache/ 18 | 19 | REAL_LINK="" 20 | PAR_PKG_LINK=$(echo $1 | grep "pkg.tar") 21 | 22 | if [ -n "$PAR_PKG_LINK" ]; then 23 | REAL_LINK="$PAR_PKG_LINK" 24 | else 25 | rm -rf tmp_file_html 26 | wget -nv -c $1 -O tmp_file_html 27 | REAL_LINK=$(grep "pkg.tar" tmp_file_html | grep --invert-match ".sig" | sed -n 's/.*href="\([^"]*\).*/\1/p') 28 | rm -rf tmp_file_html 29 | 30 | if [ -z "$REAL_LINK" ]; then 31 | die "* ERROR get_archlinux32_pkg: Fail to download: $1" 32 | fi 33 | fi 34 | 35 | wget -nv -c $REAL_LINK -P $2 36 | } 37 | 38 | get_archlinux32_pkgs() { 39 | #Usage: get_archlinux32_pkgs [dest] pack1 pack2... 40 | #https://mirror.datacenter.by/pub/archlinux32/$arch/$repo/" 41 | 42 | rm -rf tmp_pentium4_core_html 43 | rm -rf tmp_pentium4_extra_html 44 | rm -rf tmp_pentium4_community_html 45 | wget -nv -c https://mirror.datacenter.by/pub/archlinux32/pentium4/core/ -O tmp_pentium4_core_html 46 | wget -nv -c https://mirror.datacenter.by/pub/archlinux32/pentium4/extra/ -O tmp_pentium4_extra_html 47 | wget -nv -c https://mirror.datacenter.by/pub/archlinux32/pentium4/community/ -O tmp_pentium4_community_html 48 | 49 | for current_pkg in "${@:2}" 50 | do 51 | PKG_NAME_CORE=$(grep "$current_pkg-[0-9]" tmp_pentium4_core_html | grep --invert-match ".sig" | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep "^$current_pkg") 52 | 53 | if [ -n "$PKG_NAME_CORE" ]; then 54 | #echo "CORE: Downloading $current_pkg in $1 : $PKG_NAME_CORE" 55 | #echo "http://pool.mirror.archlinux32.org/pentium4/core/$PKG_NAME_CORE" 56 | get_archlinux32_pkg "http://pool.mirror.archlinux32.org/pentium4/core/$PKG_NAME_CORE" $1 57 | else 58 | PKG_NAME_EXTRA=$(grep "$current_pkg-[0-9]" tmp_pentium4_extra_html | grep --invert-match ".sig" | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep "^$current_pkg") 59 | 60 | if [ -n "$PKG_NAME_EXTRA" ]; then 61 | #echo "EXTRA: Downloading $current_pkg in $1 : $PKG_NAME_EXTRA" 62 | #echo "http://pool.mirror.archlinux32.org/pentium4/extra/$PKG_NAME_EXTRA" 63 | get_archlinux32_pkg "http://pool.mirror.archlinux32.org/pentium4/extra/$PKG_NAME_EXTRA" $1 64 | else 65 | PKG_NAME_COMMUNITY=$(grep "$current_pkg-[0-9]" tmp_pentium4_community_html | grep --invert-match ".sig" | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep "^$current_pkg") 66 | 67 | if [ -n "$PKG_NAME_COMMUNITY" ]; then 68 | #echo "COMMUNITY: Downloading $current_pkg in $1 : $PKG_NAME_COMMUNITY" 69 | #echo "http://pool.mirror.archlinux32.org/pentium4/community/$PKG_NAME_COMMUNITY" 70 | get_archlinux32_pkg "http://pool.mirror.archlinux32.org/pentium4/community/$PKG_NAME_COMMUNITY" $1 71 | else 72 | die "ERROR get_archlinux32_pkgs: Package don't found: $current_pkg" 73 | fi 74 | fi 75 | fi 76 | done 77 | 78 | rm -rf tmp_pentium4_core_html 79 | rm -rf tmp_pentium4_extra_html 80 | rm -rf tmp_pentium4_community_html 81 | } 82 | #========================= 83 | 84 | #Initializing the keyring requires entropy 85 | pacman-key --init 86 | 87 | # Enable Multilib 88 | sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf 89 | 90 | # Configure for compilation: 91 | #sed -i '/^BUILDENV/s/\!ccache/ccache/' /etc/makepkg.conf 92 | sed -i '/#MAKEFLAGS=/c MAKEFLAGS="-j2"' /etc/makepkg.conf 93 | #sed -i '/^COMPRESSXZ/s/\xz/xz -T 2/' /etc/makepkg.conf 94 | #sed -i "s/^PKGEXT='.pkg.tar.gz'/PKGEXT='.pkg.tar.xz'/" /etc/makepkg.conf 95 | #sed -i '$a CFLAGS="$CFLAGS -w"' /etc/makepkg.conf 96 | #sed -i '$a CXXFLAGS="$CXXFLAGS -w"' /etc/makepkg.conf 97 | sed -i 's/^CFLAGS\s*=.*/CFLAGS="-mtune=nehalem -O2 -pipe -ftree-vectorize -fno-stack-protector"/' /etc/makepkg.conf 98 | sed -i 's/^CXXFLAGS\s*=.*/CXXFLAGS="-mtune=nehalem -O2 -pipe -ftree-vectorize -fno-stack-protector"/' /etc/makepkg.conf 99 | #sed -i 's/^LDFLAGS\s*=.*/LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"/' /etc/makepkg.conf 100 | sed -i 's/^#PACKAGER\s*=.*/PACKAGER="DanielDevBR"/' /etc/makepkg.conf 101 | sed -i 's/^PKGEXT\s*=.*/PKGEXT=".pkg.tar"/' /etc/makepkg.conf 102 | sed -i 's/^SRCEXT\s*=.*/SRCEXT=".src.tar"/' /etc/makepkg.conf 103 | 104 | # Add more repo: 105 | echo "" >> /etc/pacman.conf 106 | 107 | # https://github.com/archlinuxcn/repo 108 | echo "[archlinuxcn]" >> /etc/pacman.conf 109 | #echo "SigLevel = Optional TrustAll" >> /etc/pacman.conf 110 | echo "SigLevel = Never" >> /etc/pacman.conf 111 | echo "Server = https://repo.archlinuxcn.org/\$arch" >> /etc/pacman.conf 112 | echo "" >> /etc/pacman.conf 113 | 114 | # https://lonewolf.pedrohlc.com/chaotic-aur/ 115 | echo "[chaotic-aur]" >> /etc/pacman.conf 116 | #echo "SigLevel = Optional TrustAll" >> /etc/pacman.conf 117 | echo "SigLevel = Never" >> /etc/pacman.conf 118 | echo "Server = http://lonewolf-builder.duckdns.org/\$repo/x86_64" >> /etc/pacman.conf 119 | echo "Server = http://chaotic.bangl.de/\$repo/x86_64" >> /etc/pacman.conf 120 | echo "Server = https://repo.kitsuna.net/x86_64" >> /etc/pacman.conf 121 | echo "" >> /etc/pacman.conf 122 | #pacman-key --keyserver keys.mozilla.org -r 3056513887B78AEB 123 | #pacman-key --lsign-key 3056513887B78AEB 124 | #sudo pacman-key --keyserver hkp://p80.pool.sks-keyservers.net:80 -r 3056513887B78AEB 125 | #sudo pacman-key --lsign-key 3056513887B78AEB 126 | 127 | # workaround one bug: https://bugzilla.redhat.com/show_bug.cgi?id=1773148 128 | echo "Set disable_coredump false" >> /etc/sudo.conf 129 | 130 | echo "DEBUG: updating pacmam keys" 131 | pacman -Syy --noconfirm && pacman --noconfirm -S archlinuxcn-keyring 132 | 133 | echo "DEBUG: pacmam sync" 134 | pacman -Syy --noconfirm 135 | 136 | echo "DEBUG: pacmam updating system" 137 | pacman -Syu --noconfirm 138 | 139 | #Add "base-devel multilib-devel" for compile in the list: 140 | pacman -S --noconfirm wget base-devel multilib-devel pacman-contrib git tar grep sed zstd xz bzip2 141 | #=========================================================================================== 142 | 143 | mkdir "$WINE_WORKDIR" 144 | mkdir "$PKG_WORKDIR" 145 | 146 | #----------- AUR ---------------- 147 | ##Delete a nobody's password (make it empty): 148 | #passwd -d nobody 149 | 150 | ## Allow the nobody passwordless sudo: 151 | #printf 'nobody ALL=(ALL) ALL\n' | tee -a /etc/sudoers 152 | 153 | ## change workind dir to nobody own: 154 | #chown nobody.nobody "$PKG_WORKDIR" 155 | 156 | #alias makepkg="sudo -u nobody makepkg" 157 | 158 | # pacthing makepkg instead of using nobody user (root error will be on the EUID=9875): 159 | #sed -i 's/EUID == 0/EUID == 9875/g' /usr/bin/makepkg 160 | #------------ 161 | 162 | #FIXME: HAVE_SECURE_MKSTEMP on fakeroot 163 | #chmod 777 /tmp 164 | 165 | # INFO: https://wiki.archlinux.org/index.php/Makepkg 166 | cd "$PKG_WORKDIR" || die "ERROR: Directory don't exist: $PKG_WORKDIR" 167 | #------------ 168 | 169 | ## lib32-gst-libav https://aur.archlinux.org/packages/lib32-gst-libav/ 170 | #git clone https://aur.archlinux.org/lib32-gst-libav.git 171 | #cd lib32-gst-libav 172 | #makepkg --syncdeps --noconfirm 173 | #pacman --noconfirm -U ./*.pkg.tar* 174 | #echo "* All files HERE: $(ls ./)" 175 | #mv *.pkg.tar* ../ || die "ERROR: Can't create the lib32-gst-libav package" 176 | #cd .. 177 | #------------ 178 | 179 | #mv *.pkg.tar* ../"$WINE_WORKDIR" || die "ERROR: None package builded from AUR" 180 | mv *.pkg.tar* ../"$WINE_WORKDIR" || echo "INFO: None package builded from AUR" 181 | 182 | cd .. 183 | rm -rf "$PKG_WORKDIR" 184 | #----------------------------------- 185 | 186 | # Get Wine 187 | wget -nv -c $P_URL 188 | tar xf $P_FILENAME -C "$WINE_WORKDIR"/ 189 | 190 | wget -nv -c https://github.com/ferion11/libsutil/releases/download/wine_hook_v0.9/libhookexecv.so 191 | wget -nv -c https://github.com/ferion11/libsutil/releases/download/wine_hook_v0.9/wine-preloader_hook 192 | mv libhookexecv.so src/ 193 | mv wine-preloader_hook src/ 194 | # compile & strip libhookexecv wine-preloader_hook 195 | #gcc -shared -fPIC -m32 -ldl src/libhookexecv.c -o src/libhookexecv.so 196 | #gcc -std=c99 -m32 -static src/preloaderhook.c -o src/wine-preloader_hook 197 | #strip src/libhookexecv.so src/wine-preloader_hook 198 | chmod +x src/wine-preloader_hook 199 | #=========================================================================================== 200 | 201 | cd "$WINE_WORKDIR" || die "ERROR: Directory don't exist: $WINE_WORKDIR" 202 | 203 | # Add a dependency library, such as freetype font library 204 | dependencys=$(pactree -s -u wine |grep lib32 | xargs) 205 | 206 | mkdir cache 207 | #mv *.pkg.tar* ./cache/ || die "ERROR: None package builded from AUR" 208 | mv *.pkg.tar* ./cache/ || echo "INFO: None package builded from AUR" 209 | 210 | pacman -Scc --noconfirm 211 | pacman -Syw --noconfirm --cachedir cache lib32-alsa-lib lib32-alsa-plugins lib32-faudio lib32-fontconfig lib32-freetype2 lib32-gcc-libs lib32-gettext lib32-giflib lib32-glu lib32-gnutls lib32-gst-plugins-base lib32-lcms2 lib32-libjpeg-turbo lib32-libjpeg6-turbo lib32-libldap lib32-libpcap lib32-libpng lib32-libpng12 lib32-libsm lib32-libxcomposite lib32-libxcursor lib32-libxdamage lib32-libxi lib32-libxml2 lib32-libxmu lib32-libxrandr lib32-libxslt lib32-libxxf86vm lib32-mesa lib32-mesa-libgl lib32-mpg123 lib32-ncurses lib32-openal lib32-sdl2 lib32-v4l-utils lib32-libdrm lib32-libva lib32-krb5 lib32-flac lib32-gst-plugins-good lib32-libcups lib32-libwebp lib32-libvpx lib32-libvpx1.3 lib32-portaudio lib32-sdl lib32-sdl2_image lib32-sdl2_mixer lib32-sdl2_ttf lib32-sdl_image lib32-sdl_mixer lib32-sdl_ttf lib32-smpeg lib32-speex lib32-speexdsp lib32-twolame lib32-ladspa lib32-libao lib32-libvdpau lib32-libpulse lib32-libcanberra-pulse lib32-libcanberra-gstreamer lib32-glew lib32-mesa-demos lib32-jansson lib32-libxinerama lib32-atk lib32-vulkan-icd-loader lib32-vulkan-intel lib32-vulkan-radeon lib32-vkd3d lib32-aom lib32-gsm lib32-lame lib32-libass lib32-libbluray lib32-dav1d lib32-libomxil-bellagio lib32-x264 lib32-x265 lib32-xvidcore lib32-opencore-amr lib32-openjpeg2 lib32-ncurses5-compat-libs lib32-ffmpeg $dependencys || die "ERROR: Some packages not found!!!" 212 | 213 | # Remove non lib32 pkgs before extracting 214 | #echo "All files in ./cache: $(ls ./cache)" 215 | find ./cache -type f ! -name "lib32*" -exec rm {} \; -exec echo "Removing: {}" \; 216 | #find ./cache -type f -name "*x86_64*" -exec rm {} \; -exec echo "Removing: {}" \; #don't work because the name of lib32 multilib packages have the x86_64 too 217 | echo "DEBUG: clean some packages" 218 | rm -rf ./cache/lib32-clang* 219 | rm -rf ./cache/lib32-nvidia-cg-toolkit* 220 | rm -rf ./cache/lib32-ocl-icd* 221 | rm -rf ./cache/lib32-opencl-mesa* 222 | echo "All files in ./cache: $(ls ./cache)" 223 | 224 | # Add the archlinux32 pentium4 libwbclient and deps: 225 | #ORIGINAL: get_archlinux32_pkgs ./cache/ gst-libav ffmpeg aom gsm lame libass libbluray dav1d libomxil-bellagio libsoxr libssh vid.stab l-smash x264 x265 xvidcore opencore-amr openjpeg2 libwbclient libtirpc tevent talloc ldb libbsd avahi libarchive smbclient 226 | # Can't get from arch64_lib32_plus_user_repo: lib32-ffmpeg lib32-gst-libav lib32-libwbclient lib32-tevent lib32-talloc lib32-ldb lib32-libbsd lib32-avahi lib32-libarchive lib32-smbclient 227 | # removed smbclient and libwbclient smbclient (the .so file isn't loading on wine) 228 | #get_archlinux32_pkgs ./cache/ ffmpeg gst-libav tevent talloc ldb libbsd avahi libarchive libsoxr libssh vid.stab l-smash libtirpc 229 | #get_archlinux32_pkgs ./cache/ tevent talloc ldb libbsd avahi libarchive libsoxr libssh vid.stab l-smash libtirpc 230 | 231 | # FIXME: "wine --check-libs" have: 232 | #libcapi20.so.3: missing (from isdn4k-utils trying now from aur) 233 | #libodbc.so.2: missing (removed because, if the lib is there, in unixodbc, then missing!?) 234 | #libsane.so.1: missing (from sane: bigger package just for scanning paper) 235 | #libnetapi.so: missing (removed because, if the lib is there, in smbclient, then missing!?) 236 | 237 | # extracting *tar.xz... 238 | find ./cache -name '*tar.xz' -exec tar --warning=no-unknown-keyword -xJf {} \; 239 | 240 | # extracting *tar.zst... 241 | find ./cache -name '*tar.zst' -exec tar --warning=no-unknown-keyword --zstd -xf {} \; 242 | 243 | # extracting *tar... 244 | find ./cache -name '*tar' -exec tar --warning=no-unknown-keyword -xf {} \; 245 | 246 | # Install vulkan tools: 247 | wget -nv -c https://github.com/ferion11/libsutil/releases/download/vulkan32_tools_v1.0/vkcube32 248 | wget -nv -c https://github.com/ferion11/libsutil/releases/download/vulkan32_tools_v1.0/vkcubepp32 249 | wget -nv -c https://github.com/ferion11/libsutil/releases/download/vulkan32_tools_v1.0/vulkaninfo32 250 | chmod +x vkcube32 vkcubepp32 vulkaninfo32 251 | mv -n vkcube32 usr/bin 252 | mv -n vkcubepp32 usr/bin 253 | mv -n vulkaninfo32 usr/bin 254 | #---------------------------------------------- 255 | 256 | # WINE_WORKDIR cleanup 257 | rm -rf cache; rm -rf include; rm usr/lib32/{*.a,*.o}; rm -rf usr/lib32/pkgconfig; rm -rf share/man; rm -rf usr/include; rm -rf usr/share/{applications,doc,emacs,gtk-doc,java,licenses,man,info,pkgconfig}; rm usr/lib32/locale 258 | rm -rf boot; rm -rf dev; rm -rf home; rm -rf mnt; rm -rf opt; rm -rf proc; rm -rf root; rm sbin; rm -rf srv; rm -rf sys; rm -rf tmp; rm -rf var 259 | rm -rf usr/src; rm -rf usr/share; rm usr/sbin; rm -rf usr/local; rm usr/lib/{*.a,*.o} 260 | #=========================================================================================== 261 | 262 | # fix broken link libglx_indirect and others 263 | rm usr/lib32/libGLX_indirect.so.0 264 | ln -s libGLX_mesa.so.0 libGLX_indirect.so.0 265 | mv -n libGLX_indirect.so.0 usr/lib32 266 | #-------- 267 | 268 | rm usr/lib32/libkeyutils.so 269 | ln -s libkeyutils.so.1 libkeyutils.so 270 | mv -n libkeyutils.so usr/lib32 271 | #-------- 272 | 273 | # workaround some of "wine --check-libs" wrong versions 274 | ln -s libpcap.so libpcap.so.0.8 275 | mv -n libpcap.so.0.8 usr/lib32 276 | 277 | ln -s libva.so libva.so.1 278 | ln -s libva-drm.so libva-drm.so.1 279 | ln -s libva-x11.so libva-x11.so.1 280 | mv -n libva.so.1 usr/lib32 281 | mv -n libva-drm.so.1 usr/lib32 282 | mv -n libva-x11.so.1 usr/lib32 283 | 284 | ## gst-libav link 285 | #ln -s ../../lib/gstreamer-1.0/libgstlibav.so libgstlibav.so 286 | #mv libgstlibav.so usr/lib32/gstreamer-1.0/ 287 | 288 | ## temp workaroud to gst-libav load x264. TODO: recompile package and avoid archlinux32 (or use all codecs tree from it) 289 | #ln -s libx264.so libx264.so.157 290 | #mv -n libx264.so.157 usr/lib32 291 | #=========================================================================================== 292 | 293 | # Disable PulseAudio 294 | rm etc/asound.conf; rm -rf etc/modprobe.d/alsa.conf; rm -rf etc/pulse 295 | 296 | # Disable winemenubuilder 297 | sed -i 's/winemenubuilder.exe -a -r/winemenubuilder.exe -r/g' share/wine/wine.inf 298 | 299 | # Disable FileOpenAssociations 300 | sed -i 's| LicenseInformation| LicenseInformation,\\\n FileOpenAssociations|g;$a \\n[FileOpenAssociations]\nHKCU,Software\\Wine\\FileOpenAssociations,"Enable",,"N"' share/wine/wine.inf 301 | #=========================================================================================== 302 | 303 | # appimage 304 | cd .. 305 | 306 | wget -nv -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" -O appimagetool.AppImage 307 | chmod +x appimagetool.AppImage 308 | 309 | chmod +x AppRun 310 | 311 | cp src/{libhookexecv.so,wine-preloader_hook} $WINE_WORKDIR/bin 312 | rm src/{libhookexecv.so,wine-preloader_hook} 313 | 314 | cp AppRun $WINE_WORKDIR 315 | cp resource/* $WINE_WORKDIR 316 | #----------------------------- 317 | 318 | ##test for others AppImage variations (have to change .travis.yml too): 319 | #cp -rp $WINE_WORKDIR test2 320 | #mkdir test2/mark_test2 321 | #----------------------------- 322 | 323 | ./appimagetool.AppImage --appimage-extract 324 | 325 | export ARCH=x86_64; squashfs-root/AppRun -v $WINE_WORKDIR -u 'gh-releases-zsync|ferion11|Proton_Appimage|continuous|${P_NAME}-v${P_VERSION}-${P_CSOURCE}-*arch*.AppImage.zsync' ${P_NAME}-v${P_VERSION}-${P_CSOURCE}-${ARCH}.AppImage 326 | 327 | echo "Packing tar result file..." 328 | rm -rf appimagetool.AppImage 329 | tar cvf result.tar *.AppImage *.zsync 330 | echo "* result.tar size: $(du -hs result.tar)" 331 | -------------------------------------------------------------------------------- /deployscript/test_name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # If it's a Release Candidate, you will have to change P_VERSION to include the "-rc2" kind of string 4 | P_URL="https://www.playonlinux.com/wine/binaries/phoenicis/proton-linux-x86/PlayOnLinux-proton_4.2-proton-linux-x86.tar.gz" 5 | 6 | # staging-linux-x86 7 | P_NAME=$(echo $P_URL | cut -d/ -f7) 8 | 9 | # PlayOnLinux-wine-4.21-staging-linux-x86.tar.gz 10 | P_FILENAME=$(echo $P_URL | cut -d/ -f8) 11 | 12 | # PlayOnLinux 13 | P_CSOURCE=$(echo $P_FILENAME | cut -d- -f1) 14 | 15 | # 4.21 16 | P_VERSION=$(echo $P_FILENAME | cut -d- -f2 | cut -d_ -f2) 17 | 18 | #======================================== 19 | echo "P_URL: $P_URL" 20 | echo "P_NAME: $P_NAME" 21 | echo "P_FILENAME: $P_FILENAME" 22 | echo "P_CSOURCE: $P_CSOURCE" 23 | echo "P_VERSION: $P_VERSION" 24 | 25 | # wine-i386_x86_64-archlinux.AppImage 26 | # wine-staging-linux-x86-v4.21-PlayOnLinux-x86_64.AppImage 27 | # ${P_NAME}-${P_MVERSION}-v${P_VERSION}-${P_CSOURCE}-x86_64.AppImage 28 | echo "RESULT: ${P_NAME}-v${P_VERSION}-${P_CSOURCE}-x86_64.AppImage" 29 | -------------------------------------------------------------------------------- /resource/Wine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ferion11/Proton_Appimage/97de0377efe9f4eadd48b26506fb6e15669e3a5a/resource/Wine.png -------------------------------------------------------------------------------- /resource/wine.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Wine 3 | GenericName=Wine Is Not an Emulator 4 | Comment=A compatibility layer capable of running Windows applications 5 | Exec=AppRun 6 | Icon=Wine 7 | Type=Application 8 | Categories=Network; 9 | Name[en_US]=Wine -------------------------------------------------------------------------------- /src/libhookexecv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /* Author: https://github.com/Hackerl/ 7 | * https://github.com/Hackerl/Wine_Appimage/issues/11#issuecomment-447834456 8 | * sudo apt-get -y install gcc-multilib 9 | * gcc -shared -fPIC -ldl libhookexecv.c -o libhookexecv.so 10 | * for i386: gcc -shared -fPIC -m32 -ldl libhookexecv.c -o libhookexecv.so 11 | * 12 | * hook wine execv syscall. use special ld.so 13 | * */ 14 | 15 | typedef int(*EXECV)(const char*, char**); 16 | 17 | static inline int strendswith( const char* str, const char* end ) 18 | { 19 | size_t len = strlen( str ); 20 | size_t tail = strlen( end ); 21 | return len >= tail && !strcmp( str + len - tail, end ); 22 | } 23 | 24 | int execv(char *path, char ** argv) 25 | { 26 | static void *handle = NULL; 27 | static EXECV old_execv = NULL; 28 | char **last_arg = argv; 29 | 30 | if( !handle ) 31 | { 32 | handle = dlopen("libc.so.6", RTLD_LAZY); 33 | old_execv = (EXECV)dlsym(handle, "execv"); 34 | } 35 | 36 | char * wineloader = getenv("WINELDLIBRARY"); 37 | 38 | if (wineloader == NULL) 39 | { 40 | return old_execv(path, argv); 41 | } 42 | 43 | while (*last_arg) last_arg++; 44 | 45 | char ** new_argv = (char **) malloc( (last_arg - argv + 2) * sizeof(*argv) ); 46 | memcpy( new_argv + 1, argv, (last_arg - argv + 1) * sizeof(*argv) ); 47 | 48 | char * pathname = NULL; 49 | 50 | char hookpath[256]; 51 | memset(hookpath, 0, 256); 52 | 53 | if (strendswith(path, "wine-preloader")) 54 | { 55 | strcat(hookpath, path); 56 | strcat(hookpath, "_hook"); 57 | 58 | wineloader = hookpath; 59 | } 60 | 61 | new_argv[0] = wineloader; 62 | int res = old_execv(wineloader, new_argv); 63 | free( new_argv ); 64 | 65 | return res; 66 | } 67 | -------------------------------------------------------------------------------- /src/preloaderhook.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /* 14 | * Author: https://github.com/Hackerl 15 | * https://github.com/Hackerl/Wine_Appimage/issues/11#issuecomment-448081998 16 | * sudo apt-get -y install gcc-multilib 17 | * only for i386: gcc -std=c99 -m32 -static preloaderhook.c -o wine-preloader_hook 18 | * Put the file in the /bin directory, in the same directory as the wine-preloader. 19 | * hook int 0x80 open syscall. use special ld.so 20 | * */ 21 | 22 | #define LONGSIZE sizeof(long) 23 | #define TARGET_PATH "/lib/ld-linux.so.2" 24 | #define HasZeroByte(v) ~((((v & 0x7F7F7F7F) + 0x7F7F7F7F) | v) | 0x7F7F7F7F) 25 | #define HOOK_OPEN_LD_SYSCALL -1 26 | 27 | int main(int argc, char ** argv) 28 | { 29 | if (argc < 2) 30 | return 0; 31 | 32 | char * wineloader = (char *) getenv("WINELDLIBRARY"); 33 | 34 | if (wineloader == NULL) 35 | { 36 | return 0; 37 | } 38 | 39 | int LD_fd = open(wineloader, O_RDONLY); 40 | 41 | if (LD_fd == -1) 42 | { 43 | return 0; 44 | } 45 | 46 | pid_t child = fork(); 47 | 48 | if(child == 0) 49 | { 50 | ptrace(PTRACE_TRACEME, 0, NULL, NULL); 51 | execv(*(argv + 1), argv + 1); 52 | } 53 | else 54 | { 55 | while(1) 56 | { 57 | int status = 0; 58 | wait(&status); 59 | 60 | if(WIFEXITED(status)) 61 | break; 62 | 63 | long orig_eax = ptrace(PTRACE_PEEKUSER, 64 | child, 4 * ORIG_EAX, 65 | NULL); 66 | 67 | static int insyscall = 0; 68 | 69 | if (orig_eax == HOOK_OPEN_LD_SYSCALL) 70 | { 71 | ptrace(PTRACE_POKEUSER, child, 4 * EAX, LD_fd); 72 | 73 | //Detch 74 | ptrace(PTRACE_DETACH, child, NULL, NULL); 75 | break; 76 | } 77 | 78 | if (orig_eax == SYS_open) 79 | { 80 | if(insyscall == 0) 81 | { 82 | /* Syscall entry */ 83 | insyscall = 1; 84 | 85 | //Get Path Ptr 86 | long ebx = ptrace(PTRACE_PEEKUSER, 87 | child, 4 * EBX, NULL); 88 | 89 | char Path[256]; 90 | memset(Path, 0, 256); 91 | 92 | //Read Path String 93 | for (int i = 0; i < sizeof(Path)/LONGSIZE; i ++) 94 | { 95 | union 96 | { 97 | long val; 98 | char chars[LONGSIZE]; 99 | } data; 100 | 101 | data.val = ptrace(PTRACE_PEEKDATA, child, ebx + i * 4, NULL); 102 | 103 | memcpy(Path + i * 4, data.chars, LONGSIZE); 104 | 105 | if (HasZeroByte(data.val)) 106 | break; 107 | } 108 | 109 | if (strcmp(Path, TARGET_PATH) == 0) 110 | { 111 | //Modify Syscall -1. So Will Not Call Open Syscall. 112 | ptrace(PTRACE_POKEUSER, child, 4 * ORIG_EAX, HOOK_OPEN_LD_SYSCALL); 113 | } 114 | } 115 | else 116 | { 117 | /* Syscall exit */ 118 | insyscall = 0; 119 | } 120 | } 121 | 122 | ptrace(PTRACE_SYSCALL, child, NULL, NULL); 123 | } 124 | } 125 | 126 | close(LD_fd); 127 | return 0; 128 | } 129 | --------------------------------------------------------------------------------