Halo 2: Difference between revisions

From LANCommander
(Created page with "Category:Games {{Game.InfoBox |Cover = cover.jpg |Developers = {{Game.InfoBox.Developer|Bungie}} |Publishers = {{Game.InfoBox.Publisher|Microsoft Game Studios}} |Release Date = {{Game.InfoBox.ReleaseDate|Windows|November 9, 2004}} |Genres = {{Game.InfoBox.Genre|Shooter}} | PCGamingWiki = Halo_2 }} {{Game.ActionBox |Actions = {{Game.ActionBox.Row|Name = Play|Path = halo2.exe|Arguments = |WorkingDirectory = |Primary = True}} }} {{Game.Scripts.NameChange |Name = Name...")
 
No edit summary
 
Line 10: Line 10:
|Genres =
|Genres =
{{Game.InfoBox.Genre|Shooter}}
{{Game.InfoBox.Genre|Shooter}}
| PCGamingWiki = Halo_2
|PCGamingWiki = Halo_2}}
}}


{{Game.ActionBox
{{Game.ActionBox
|Actions =  
|Actions =  
{{Game.ActionBox.Row|Name = Play|Path = halo2.exe|Arguments = |WorkingDirectory = |Primary = True}}
{{Game.ActionBox.Row|Name = Play|Path = {InstallDir}\halo2.exe|Arguments = |WorkingDirectory = |Primary = True}}
}}
}}


{{Game.Scripts.NameChange
 
|Name = Name Change Script
{{Game.Scripts.Install
|Description = Names are stored in a `profile` and `savemeta.bin` file as an ASCII encoded string with 0x00 separating characters. Names can be a maximum of 16 characters. We force that to avoid any overflows / profile corruption.
|Name = Install Script
|Description =  
|RequiresAdmin = False
|RequiresAdmin = False
|Contents = <syntaxhighlight lang="powershell" line>
|Contents =
$NewName = $args[0]
<syntaxhighlight lang="powershell" line>
$InstallDir = $PSScriptRoot
# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay


function Get-AsciiBytes([string]$InputString, [int]$MaxLength)
New-Item -ItemType Directory -Force -Path "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games"
{
Remove-Item "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse -ErrorAction Ignore
    if ($InputString.Length -gt $MaxLength)
Copy-Item -Path "$InstallDirectory\ProfileTemplate\S0000000" -Destination "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse
    {
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2"
        $InputString = $InputString.Substring(0, $MaxLength)
    }
 
    $bytes = [System.Text.Encoding]::ASCII.GetBytes($InputString)
    $array = @()
    $count = 0
 
    $extraPadding = $MaxLength - $bytes.Length
 
    foreach ($byte in $bytes)
    {
        if ($count -lt $MaxLength)
        {
            $array += $byte
            $count++
        }
    }
 
    for ($i = $count; $i -lt $MaxLength; $i++)
    {
        $array += 0x00
    }
 
    return $array
}


function Separate-AsciiBytes([byte[]]$Data)
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings"
{
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "ReverbEnable" -Value 0 -Force
    $array = @()
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "LowPassEnable" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "MonoCount" -Value 36 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "StereoCount" -Value 36 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "Volume" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "SpeakerConfig" -Value 0 -Force


    foreach ($byte in $Data)
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings"
    {
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "ScreenResX" -Value $Display.Bounds.Width -Force
        $array += $byte
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "ScreenResY" -Value $Display.Bounds.Height -Force
        $array += 0x00
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "ScreenRefresh" -Value 60 -Force
    }
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "AspectRatio" -Value 0 -Force
 
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "DisplayMode" -Value 0 -Force
    return $array
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "Brightness" -Value 3 -Force
}
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "Gamma" -Value 2 -Force
 
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "AntiAliasing" -Value 0 -Force
function Patch-Binary([byte[]]$Data, [int]$Offset, [string]$FilePath)
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "HudSize" -Value 2 -Force
{
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "SafeArea" -Value 0 -Force
    $bytes = [System.IO.File]::ReadAllBytes($FilePath)
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "LevelOfDetail" -Value 0 -Force
 
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "@" -Value "hex(4):" -Force
    for ($i = 0; $i -lt $Data.Length; $i++)
    {
        $bytes[$Offset + $i] = $Data[$i]
    }
 
    [System.IO.File]::WriteAllBytes($FilePath, $bytes)
}
 
$rawBytes = Get-AsciiBytes -InputString $NewName -MaxLength 16
$profileNameBytes = Separate-AsciiBytes -Data $rawBytes
Remove-Item "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse -ErrorAction Ignore
Copy-Item -Path "$InstallDir\ProfileTemplate\S0000000" -Destination "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse
Patch-Binary -FilePath "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000\profile" -Offset 8 -Data $profileNameBytes
Patch-Binary -FilePath "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000\savemeta.bin" -Offset 18 -Data $profileNameBytes
</syntaxhighlight>
</syntaxhighlight>
}}
}}
 
           
{{Game.Scripts.Install
{{Game.Scripts.Uninstall
|Name = Install Script
|Name = Uninstall Script
|Description =  
|Description =  
|RequiresAdmin = False
|RequiresAdmin = False
|Contents = <syntaxhighlight lang="powershell" line>
|Contents =
$InstallDir = $PSScriptRoot
<syntaxhighlight lang="powershell" line>
Remove-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2" -Recurse -Force
Remove-Item "$($env:LOCALAPPDATA)\Microsoft\Halo 2" -Recurse -ErrorAction Ignore
</syntaxhighlight>
}}
           
{{Game.Scripts.NameChange
|Name = Name Change Script
|Description = Names are stored in a `profile` and `savemeta.bin` file as an ASCII encoded string with 0x00 separating characters. Names can be a maximum of 16 characters. We force that to avoid any overflows / profile corruption.
|RequiresAdmin = False
|Contents =
<syntaxhighlight lang="powershell" line>
# Converts a string to a UTF16-encoded byte array. This looks like ASCII characters separated by 0x00 in most cases.
$bytes = ConvertTo-StringBytes -Input $NewPlayerAlias -Utf16 1 -MaxLength 16 -MinLength 16


New-Item -ItemType Directory -Force -Path "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games"
Remove-Item "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse -ErrorAction Ignore
Remove-Item "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse -ErrorAction Ignore
Copy-Item -Path "$InstallDir\ProfileTemplate\S0000000" -Destination "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse
Copy-Item -Path "$InstallDirectory\ProfileTemplate\S0000000" -Destination "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse
Edit-PatchBinary -FilePath "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000\profile" -Offset 8 -Data $bytes
Edit-PatchBinary -FilePath "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000\savemeta.bin" -Offset 18 -Data $bytes
</syntaxhighlight>
</syntaxhighlight>
}}
}}

Latest revision as of 02:12, 6 January 2024

Developers
Bungie
Publishers
Microsoft Game Studios
Release Date
Windows: November 9, 2004
Genres
Shooter
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play {InstallDir}\halo2.exe True

Install Script

# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay

New-Item -ItemType Directory -Force -Path "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games"
Remove-Item "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse -ErrorAction Ignore
Copy-Item -Path "$InstallDirectory\ProfileTemplate\S0000000" -Destination "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2"

New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings"
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "ReverbEnable" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "LowPassEnable" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "MonoCount" -Value 36 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "StereoCount" -Value 36 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "Volume" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Audio Settings" -Name "SpeakerConfig" -Value 0 -Force

New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings"
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "ScreenResX" -Value $Display.Bounds.Width -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "ScreenResY" -Value $Display.Bounds.Height -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "ScreenRefresh" -Value 60 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "AspectRatio" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "DisplayMode" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "Brightness" -Value 3 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "Gamma" -Value 2 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "AntiAliasing" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "HudSize" -Value 2 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "SafeArea" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "LevelOfDetail" -Value 0 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2\Video Settings" -Name "@" -Value "hex(4):" -Force

Uninstall Script

Remove-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Halo 2" -Recurse -Force
Remove-Item "$($env:LOCALAPPDATA)\Microsoft\Halo 2" -Recurse -ErrorAction Ignore

Name Change Script

Names are stored in a `profile` and `savemeta.bin` file as an ASCII encoded string with 0x00 separating characters. Names can be a maximum of 16 characters. We force that to avoid any overflows / profile corruption.

# Converts a string to a UTF16-encoded byte array. This looks like ASCII characters separated by 0x00 in most cases.
$bytes = ConvertTo-StringBytes -Input $NewPlayerAlias -Utf16 1 -MaxLength 16 -MinLength 16

Remove-Item "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse -ErrorAction Ignore
Copy-Item -Path "$InstallDirectory\ProfileTemplate\S0000000" -Destination "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000" -Recurse
Edit-PatchBinary -FilePath "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000\profile" -Offset 8 -Data $bytes
Edit-PatchBinary -FilePath "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000\savemeta.bin" -Offset 18 -Data $bytes