[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 WHY 于 2023-2-22 20:04 编辑

PowerShell 脚本
2023/02/22 简化脚本。我测试没有发现问题
  1. $file1 = '01.txt';
  2. $file2 = 'basetik.tik';          #修改前的文件名
  3. $file3 = 'basetik_001.tik';      #修改后的文件名
  4. $text  = [IO.File]::ReadAllText($file1, [Text.Encoding]::Default);
  5. $bytes = [IO.File]::ReadAllBytes($file2);
  6. Function Set-ByteValue($key, [int]$offSet){
  7.     $reg = '(?i)(?<=' + $key + ' *)[a-f0-9]+';
  8.     $s = ([regex]::Match($text, $reg)).Value;
  9.     for ($i = 0; $i -lt $s.Length; $i+=2) {
  10.         $x = $i / 2 + $offSet;
  11.         $bytes[$x] = [byte][int]('0x' + $s.SubString($i, 2));
  12.     }
  13. }
  14. Set-ByteValue -key 'Using title id:' -offSet 0x01DC;
  15. Set-ByteValue -key 'generated encrypted:' -offSet 0x01BF;
  16. [IO.File]::WriteAllBytes($file3, $bytes);
  17. echo 'Done';
  18. [Console]::ReadLine();
复制代码
1

评分人数

TOP

HexTool.exe下载
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set "file1=01.txt"
  4. set "file2=basetik.tik"
  5. for /f "tokens=1-2 delims=:" %%i in ('type "%file1%"') do (
  6.     if /i "%%i" == "Using title id" (
  7.         set "HexNum1=%%j"
  8.     ) else if /i "%%i" == "generated encrypted" (
  9.         set "HexNum2=%%j"
  10.     )
  11. )
  12. set "tmp1=%HexNum1: =%"
  13. set "tmp2=%HexNum2: =%"
  14. for %%i in (256, 128, 64, 32, 16, 8, 4, 2, 1) do (
  15.     if "!tmp1:~%%i!" NEQ "" (set "tmp1=!tmp1:~%%i!" & set /a Len1 += %%i)
  16.     if "!tmp2:~%%i!" NEQ "" (set "tmp2=!tmp2:~%%i!" & set /a Len2 += %%i)
  17. )
  18. set /a "offSet1=0x01DC, offSet2=0x01BF, Len1=(Len1+1)/2, Len2=(Len2+1)/2"
  19. HexTool "%file2%" %offSet1% %Len1% %HexNum1%
  20. HexTool "%file2%" %offSet2% %Len2% %HexNum2%
  21. pause
复制代码

TOP

返回列表