- SignalDesk1小时前
Original Summary
@echo off rem ========================================================================== rem PCL download-limit unlocker (patches Plain Craft Launcher 2.exe in place) rem rem What it does: rem The launcher hides Minecraft downloads behind the compile-time constant rem "RestrictMcDownload". This script rewrites the tiny IL method rem PCL.PageDownloadInstall::LoaderInit so the download page uses the real rem version-list loader (PCL.ModDownload::DlClientListLoader) instead of the rem "download disabled" loader that always throws. rem rem How to use: rem Put this .bat next to "Plain Craft Launcher 2.exe" and double-click it, rem or drag the exe onto this .bat. A backup (.bak_yyyyMMdd_HHmmss) is made rem before the exe is modified. rem rem Option: --no-pause do not wait for a key press when finished. rem ========================================================================== setlocal EnableExtensions set "BATFILE=%~f0" set "PSFILE=%TEMP%\pcl_unlock_mcdl_%RANDOM%%RANDOM%.ps1" powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$bytes=[IO.File]::ReadAllBytes($env:BATFILE);$u=New-Object Text.UTF8Encoding($false,$true);try{$b=$u.GetString($bytes)}catch{$b=[Text.Encoding]::GetEncoding(936).GetString($bytes)};$m='#@@PCL_UNLOCK_PS_BEGIN@@#';$i=$b.LastIndexOf($m);if($i -lt 0){exit 9};$c=$b.Substring($i+$m.Length).TrimStart([char[]](13,10));[IO.File]::WriteAllText($env:PSFILE,$c,(New-Object Text.UTF8Encoding($true)))" if errorlevel 1 ( echo. echo [ERROR] Failed to prepare the patch script. Windows PowerShell is required. pause exit /b 1 ) powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%PSFILE%" -BatDir "%~dp0." -CurrentDir "%CD%" -Target "%~1" set "RC=%ERRORLEVEL%" del /f /q "%PSFILE%" >nul 2>&1 echo. if /i "%~1"=="--no-pause" exit /b %RC% pause exit /b %RC% #@@PCL_UNLOCK_PS_BEGIN@@# # ========================================================================== # PCL 下载限制解除补丁:直接修改 Plain Craft Launcher 2.exe # # 原理:开源版编译时 RestrictMcDownload=True 被编译器折叠,下载页的 # LoaderInit 被替换成“关闭下载”的 LoaderTask(一运行就抛异常)。 # 本脚本把该方法体改回使用真正的版本列表加载器 # PCL.ModDownload::DlClientListLoader,其它代码一律不动。 # # 用法:把 .bat 放到 exe 同目录双击,或把 exe 拖到 .bat 上。 # 修改前自动备份;重复运行是安全的。 # ========================================================================== param( [string]$BatDir = '', [string]$CurrentDir = '', [string]$Target = '' ) $ErrorActionPreference = 'Stop' # 输出被重定向(管道/文件)时改用 UTF-8,避免中文乱码 if ([Console]::IsOutputRedirected) { try { [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding($false) } catch { } } $script:ExeName = 'Plain Craft Launcher 2.exe' $script:Steps = 5 $script:MethodFlags = [Reflection.BindingFlags]'Public,NonPublic,Instance,Static,DeclaredOnly' function Write-Step { param([int]$Number, [string]$Text) Write-Host (' [{0}/{1}] {2}' -f $Number, $script:Steps, $Text) -ForegroundColor Yellow } function Write-Detail { param([string]$Text) Write-Host (' ' + $Text) -ForegroundColor Gray } function Write-Fail { param([string]$Text) Write-Host '' Write-Host (' [失败] ' + $Text) -ForegroundColor Red } function Resolve-ExePath { param([string]$Target, [string[]]$Dirs) $found = New-Object System.Collections.ArrayList if (-not [string]::IsNullOrWhiteSpace($Target)) { if (Test-Path -LiteralPath $Target -PathType Leaf) { $full = [IO.Path]::GetFullPath($Target) if ([IO.Path]::GetExtension($full) -ieq '.exe') { [void]$found.Add($full) } } } foreach ($dir in $Dirs) { if ([string]::IsNullOrWhiteSpace($dir)) { continue } if (-not (Test-Path -LiteralPath $dir -PathType Container)) { continue } $exact = Join-Path $dir $script:ExeName if (Test-Path -LiteralPath $exact -PathType Leaf) { [void]$found.Add((Resolve-Path -LiteralPath $exact).Path) continue } $alt = Get-ChildItem -LiteralPath $dir -Filter 'Craft Launcher*.exe' -File -ErrorAction SilentlyContinue | Select-Object -First 1 if ($alt) { [void]$found.Add($alt.FullName) } } if ($found.Count -eq 0) { return $null } return $found[0] } function Get-PclInfo { param([byte[]]$Bytes) $asm = [Reflection.Assembly]::Load($Bytes) $type = $asm.GetType('PCL.PageDownloadInstall', $false) if ($null -eq $type) { throw '找不到 PCL.PageDownloadInstall 类型,这可能不是 PCL 主程序。' } $method = $type.GetMethod('LoaderInit', $script:MethodFlags) if ($null -eq $method) { throw '找不到 LoaderInit 方法,exe 版本不受支持。' } $modDownload = $asm.GetType('PCL.ModDownload', $false) if ($null -eq $modDownload) { throw '找不到 PCL.ModDownload 类型,exe 版本不受支持。' } $field = $modDownload.GetField('DlClientListLoader', [Reflection.BindingFlags]'Public,Static') if ($null -eq $field) { throw '找不到 DlClientListLoader 字段,exe 版本不受支持。' } return [pscustomobject]@{ Assembly = $asm Type = $type Method = $method IL = $method.GetMethodBody().GetILAsByteArray() Token = $field.MetadataToken } } function Test-RestrictedIL { param([byte[]]$IL) return ( $IL.Length -eq 94 -and $IL[0x19] -eq 0x14 -and # ldnull $IL[0x1A] -eq 0x72 -and # ldstr "关闭下载" $IL[0x1F] -eq 0x7E -and # ldsfld <closure> $IL[0x4A] -eq 0x02 -and # ldarg.0 $IL[93] -eq 0x2A # ret ) } function Test-UnlockedIL { param([byte[]]$IL, [int]$Token) if ($IL.Length -lt 0x20) { return $false } if ($IL[0x1A] -ne 0x7E) { return $false } return ([BitConverter]::ToInt32($IL, 0x1B) -eq $Token) } function New-Backup { param([string]$Path) $stamp = Get-Date -Format 'yyyyMMdd_HHmmss' $bak = ('{0}.bak_{1}' -f $Path, $stamp) $n = 1 while (Test-Path -LiteralPath $bak) { $bak = ('{0}.bak_{1}_{2}' -f $Path, $stamp, $n) $n++ } Copy-Item -LiteralPath $Path -Destination $bak -Force return $bak } function Restore-Backup { param([string]$Path, [string]$Backup) try { Copy-Item -LiteralPath $Backup -Destination $Path -Force return $true } catch { return $false } } try { Write-Host '' Write-Host ' ==============================================================' -ForegroundColor Cyan Write-Host ' PCL 下载限制解除(直接修改 Plain Craft Launcher 2.exe)' -ForegroundColor Cyan Write-Host ' ==============================================================' -ForegroundColor Cyan Write-Host '' # ---------- 1. 定位 exe
- 情报分类:商业与市场研究
- 分类依据:内容涉及商业、投资或市场动态
- 信息来源:服务器 / LINUX DO - 最新话题
- 发布时间:2026/10/20 20:07:25
- 暂无回复