Sublime Text 4200 注册/关闭自动更新

步骤

  1. 下载安装 Sublime Text
    访问以下链接下载并安装 Sublime Text:
    https://download.sublimetext.com/sublime_text_build_4200_x64_setup.exe

  2. 保存 PowerShell 脚本
    将以下 PowerShell 代码保存到桌面,文件名为 SublimePatcher.ps1

  3. 打开 PowerShell 窗口
    在桌面空白处按住 Shift 键并右键点击,选择“在此处打开 PowerShell 窗口”

  4. 运行补丁脚本
    在 PowerShell 窗口中输入并运行命令:

    .\SublimePatcher.ps1
    
  5. 激活许可证
    补丁完成后,打开 Sublime Text,点击主菜单“帮助” > “输入许可证”,输入许可证码 A 并点击确定。
    提示信息将显示 “许可证完成”。


额外说明

  • 在“带高级安全性的 Windows Defender 防火墙”中,可能还需要完成一些额外设置以确保安全。
  • 重要提示
    • 脚本可能需要以管理员身份运行,确保有相应权限。
    • 如果出现执行策略错误,请先运行:
      Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
      
    • 该脚本会自动备份原始 Sublime Text 可执行文件。
    • 运行补丁前,请确保 Sublime Text 已完全关闭。

PowerShell 脚本内容

$destFolder = "$env:USERPROFILE\Desktop\SUBLIME"
$sourceExe = "C:\Program Files\Sublime Text\sublime_text.exe"
$destExe = "$destFolder\sublime_text.exe"
$backupExe = "C:\Program Files\Sublime Text\sublime_text_backup.exe"

Write-Host "Starting Sublime Text patching process..."

if (-not (Test-Path -Path $sourceExe)) {
    Write-Host "Error: Source file not found at $sourceExe"
    exit
}

if (-not (Test-Path -Path $destFolder)) {
    Write-Host "Creating SUBLIME folder..."
    New-Item -Path $destFolder -ItemType Directory | Out-Null
}

Write-Host "Copying files to desktop folder..."
Copy-Item -Path $sourceExe -Destination $destExe -Force

$FilePath = $destExe

if (!(Test-Path $FilePath)) {
    Write-Host "Error: File not found at $FilePath"
    exit
}

$bytes = [System.IO.File]::ReadAllBytes($FilePath)

if ($bytes.Length -eq 0) {
    Write-Host "Error: Failed to read the file or file is empty."
    exit
}

function Apply-Patch {
    param (
        [byte[]]$Find,
        [byte[]]$Replace,
        [string]$Description
    )
    $found = $false
    for ($i = 0; $i -le $bytes.Length - $Find.Length; $i++) {
        $match = $true
        for ($j = 0; $j -lt $Find.Length; $j++) {
            if ($bytes[$i + $j] -ne $Find[$j]) {
                $match = $false
                break
            }
        }
        if ($match) {
            for ($j = 0; $j -lt $Replace.Length; $j++) {
                $bytes[$i + $j] = $Replace[$j]
            }
            Write-Host "Patch applied: $Description at offset 0x$("{0:X}" -f $i)"
            $found = $true
            break
        }
    }
    if (-not $found) {
        Write-Host "Failed to find pattern for patch: $Description"
    }
}

Write-Host "Applying patches..."

$patches = @(
    @{ Find = @(0x74, 0x06, 0x3B); Replace = @(0xEB, 0x06, 0x3B); Desc = "Patch 1: Change 74 to EB" },
    @{ Find = @(0x89, 0xF8, 0x48, 0x81, 0xC4, 0x38, 0x02); Replace = @(0x33, 0xC0, 0x48, 0x81, 0xC4, 0x38, 0x02); Desc = "Patch 2: 89 F8 to 33 C0" },
    @{ Find = @(0xE8, 0xF4, 0x7F, 0x10, 0x00); Replace = @(0x90, 0x90, 0x90, 0x90, 0x90); Desc = "Patch 3: Full 5-byte NOPs" },
    @{ Find = @(0x41, 0x57, 0x41, 0x56, 0x41, 0x54, 0x56, 0x57, 0x53, 0x48, 0x83, 0xEC, 0x38); Replace = @(0x90, 0x90, 0x41, 0x56, 0x41, 0x54, 0x56, 0x57, 0x53, 0x48, 0x83, 0xEC, 0x38); Desc = "Patch 4: 41 57 to 90 90" }
)

foreach ($patch in $patches) {
    Apply-Patch -Find $patch.Find -Replace $patch.Replace -Description $patch.Desc
}

$patchedFilePath = "$destFolder\SublimeText_patched.exe"
Write-Host "Saving patched file..."
[System.IO.File]::WriteAllBytes($patchedFilePath, $bytes)

if (-not (Test-Path $patchedFilePath)) {
    Write-Host "Error: Patched file was not created successfully"
    exit
}

$originalBackupPath = "C:\Program Files\Sublime Text\sublime_text_backup.exe"
$targetPath = "C:\Program Files\Sublime Text\sublime_text.exe"

Write-Host "Creating backup of original file..."
Copy-Item -Path $targetPath -Destination $originalBackupPath -Force

Write-Host "Replacing original file with patched version..."
try {
    Copy-Item -Path $patchedFilePath -Destination $targetPath -Force
    Write-Host "SUCCESS: Sublime Text has been patched successfully!"
    Write-Host "Original backup saved at: $originalBackupPath"
    Write-Host "Working files saved in: $destFolder"
} catch {
    Write-Host "Error: Failed to replace the original file. Error: $_"
    Write-Host "You may need to run PowerShell as Administrator"
    Write-Host "Patched file is available at: $patchedFilePath"
}

免责声明:
本文仅供学习交流使用,请遵守相关软件使用协议与法律法规。