From c1c2b4e8bbe17a3145f99fc745a61999e14bb8e7 Mon Sep 17 00:00:00 2001 From: sindoring Date: Wed, 5 Aug 2026 01:58:29 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=83=D0=BF=D1=83=D1=89=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20laa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-warcraftxl.ps1 | 119 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 8 deletions(-) diff --git a/build-warcraftxl.ps1 b/build-warcraftxl.ps1 index 4ad9486..ef9172b 100644 --- a/build-warcraftxl.ps1 +++ b/build-warcraftxl.ps1 @@ -8,6 +8,73 @@ param( [switch]$NativeRenderer ) +function Enable-LargeAddressAware { + param( + [Parameter(Mandatory)] + [string]$Path + ) + + $bytes = [System.IO.File]::ReadAllBytes($Path) + + if ($bytes.Length -lt 64) { + throw "File is too small to be a valid PE executable: $Path" + } + + # DOS header: MZ + if ($bytes[0] -ne 0x4D -or $bytes[1] -ne 0x5A) { + throw "DOS MZ signature was not found: $Path" + } + + # IMAGE_DOS_HEADER.e_lfanew + $peOffset = [BitConverter]::ToInt32($bytes, 0x3C) + + if ($peOffset -lt 0 -or ($peOffset + 24) -gt $bytes.Length) { + throw "Invalid PE header offset in: $Path" + } + + # PE\0\0 signature + $peSignature = [BitConverter]::ToUInt32($bytes, $peOffset) + + if ($peSignature -ne 0x00004550) { + throw "PE signature was not found: $Path" + } + + # IMAGE_FILE_HEADER starts after the 4-byte PE signature. + # Characteristics is at offset 18 inside IMAGE_FILE_HEADER. + $characteristicsOffset = $peOffset + 4 + 18 + $characteristics = [BitConverter]::ToUInt16( + $bytes, + $characteristicsOffset + ) + + $newCharacteristics = [uint16]( + $characteristics -bor 0x0020 + ) + + if ($newCharacteristics -ne $characteristics) { + $encoded = [BitConverter]::GetBytes($newCharacteristics) + + $bytes[$characteristicsOffset] = $encoded[0] + $bytes[$characteristicsOffset + 1] = $encoded[1] + + [System.IO.File]::WriteAllBytes($Path, $bytes) + + Write-Host ( + "LAA enabled for {0}: 0x{1:X4} -> 0x{2:X4}" -f + $Path, + $characteristics, + $newCharacteristics + ) -ForegroundColor Green + } + else { + Write-Host ( + "LAA is already enabled for {0}: 0x{1:X4}" -f + $Path, + $characteristics + ) -ForegroundColor DarkGreen + } +} + $ErrorActionPreference = 'Stop' $repoRoot = $PSScriptRoot $cmake = 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe' @@ -55,19 +122,55 @@ $selectedProxy = if ($NativeRenderer) { $nativeProxy } else { $modernProxy } $adtResources = Join-Path $repoRoot 'vendor\modules\wxl-modern-adt\_resources' function Install-WarcraftXLArtifacts { - param([Parameter(Mandatory)][string]$Destination) + param( + [Parameter(Mandatory)] + [string]$Destination + ) $utils = Join-Path $Destination 'Utils' $loosePatch = Join-Path $Destination 'Data\Patch-WXL.MPQ' - New-Item -ItemType Directory -Path $Destination, $utils, $loosePatch -Force | Out-Null - Copy-Item -LiteralPath $stockExe -Destination (Join-Path $Destination 'Wow.exe') -Force - Copy-Item -LiteralPath $warcraftXL -Destination (Join-Path $Destination 'WarcraftXL.dll') -Force - Copy-Item -LiteralPath $selectedProxy -Destination (Join-Path $Destination 'd3d9.dll') -Force - Copy-Item -LiteralPath $nativeProxy -Destination (Join-Path $utils 'd3d9-native.dll') -Force - Copy-Item -LiteralPath $hostExe -Destination (Join-Path $utils 'WarcraftXLHost.exe') -Force + New-Item ` + -ItemType Directory ` + -Path $Destination, $utils, $loosePatch ` + -Force | + Out-Null + + $destinationExe = Join-Path $Destination 'Wow.exe' + + Copy-Item ` + -LiteralPath $stockExe ` + -Destination $destinationExe ` + -Force + + Enable-LargeAddressAware -Path $destinationExe + + Copy-Item ` + -LiteralPath $warcraftXL ` + -Destination (Join-Path $Destination 'WarcraftXL.dll') ` + -Force + + Copy-Item ` + -LiteralPath $selectedProxy ` + -Destination (Join-Path $Destination 'd3d9.dll') ` + -Force + + Copy-Item ` + -LiteralPath $nativeProxy ` + -Destination (Join-Path $utils 'd3d9-native.dll') ` + -Force + + Copy-Item ` + -LiteralPath $hostExe ` + -Destination (Join-Path $utils 'WarcraftXLHost.exe') ` + -Force + Get-ChildItem -LiteralPath $adtResources | ForEach-Object { - Copy-Item -LiteralPath $_.FullName -Destination $loosePatch -Recurse -Force + Copy-Item ` + -LiteralPath $_.FullName ` + -Destination $loosePatch ` + -Recurse ` + -Force } }