|
19951001
高级用户
    流落街头
积分 570
发帖 272
注册 2005-10-17 来自 北京
状态 离线
|
『楼 主』:
二进制方式处理文件工具 STR (2020.11.16 更新)
使用 LLM 解释/回答一下
STR
File: A File to be Processed data. //文件
Start: Offset to Process data. //文件中处理数据的起始位置 (文件的开头位置为0)
Bytes: Bytes to Process. //要处理的字节数量 (如果输入0,则表示从Start开始到文件末尾)
/C: Copy Bytes from File to dstFile. //从源文件向目标文件复制数据
/I: Insert Bytes to dstFile from File. //从源文件向目标文件插入数据,插入数据后目标文件增加 Bytes个字节
dstFile: A File to Write Result data. //目标文件
Address: Offset to Write Result data. //目标文件中要复制或插入数据的位置 (如果目标文件不存在,该值被忽略)
STR
/D: Delete Bytes from File & Write Result to dstFile. //从源文件删除数据并结果写入目标文件
STR
/V: View File In Hex Style. //十六进制方式查看文件
/A: Show ASCII Value. //显示ASCII码
/P: Pause Echo Screen. //满屏暂停
STR :
Bytes: Must be 0. //必须为0
/F: Find String in File. //在文件中查找字符串
/Hex: Hex Style. //十六进制方式
/Asc: ASCII Style. //ASCII码方式
Value: Hex_Digital/ASCII String (40 Characters Maximum). //字符传真的值,最长40个字符 (如果是十六进制串长度应为双数)
/I: Ignore Case. //忽略大小写
/A: Process All Value in File. //在文件中查找所有满足要求的字符串(默认查找1次)
STR :
Bytes: Must be 0. //必须为0
/E: Edit File. //编辑文件
STR
Bytes: Must be 0. //必须为0
/R: Relace SrcString with DstString. //字符常替换
SrcString: :. //源串,可以使用十六进制或ASCII码串
DstString: :. //目标串,可以使用十六进制或ASCII码串
/A: Process All SrcString in File. //在文件中查找所有源字符串(默认替换1次)
说明:
1 使用 /C 和 /I 命令时,如果目的文件不存在,Adress 的值将被忽略,直接执行将源文件从 Start 开始的 Bytes 个字节写入到新创建的目的文件中
2 使用 /C 和 /I 命令时,如果目的文件存在,并且不输入 Address,则Address 默认为0,也就是文件的起始位置。
3 目前处理的单个文件大小不超过 2G
例子:
str 1.exe 0x100 0x10 /d 2.bin 执行将文件1.exe 从位置256开始的16个字节删除,并将结果写入到2.bin,文件2.bin的长度将比1.exe长度小16
str 1.exe 0x100 0x10 /c 2.bin 20 执行将文件1.exe 从位置256开始的16个字节写入到2.bin的20位置,也就是文件2.bin从位置20开始的16字节被覆盖
str 1.exe 0x100 0x10 /i 2.bin 20 执行将文件1.exe 从位置256开始的16个字节插入到2.bin的20位置,结果文件2.bin的长度将增加16字节
str 1.exe 0x100 0 /v /p /a 从文件偏移位置256开始在屏幕上显示文件内容,如果Bytes输入为0,则表示从Start开始至文件末尾。
str 1.exe 0x100 0 /e /hex:11223344 将文件偏移位置256开始的4个字节修改为,0x11,0x22,0x33,0x44。
str 1.exe 0x100 0 /e /asc:1234 将文件偏移位置256开始的4个字节修改为,1234, 也就是0x31,0x32,0x33,0x34
查找替换算法使用的是 KMP 算法,不重复计数,如文件 1.txt 的内容为10个字符0:
0000000000
如执行命令: str 1.txt 0 0 /f /asc:0000 /a
则执行结果为:
Find string At:
0 0x0
4 0x4
不会是:
Find string At:
0 0x0
1 0x1
2 0x2
3 0x3
4 0x4
5 0x5
6 0x6
压缩包中包含DOS版本和Win32版本
2008.12.14 修正替换字符串功能中存在的问题
2008.12.19 修正19楼存在问题
2009.2.15 测试版本在50楼
Last edited by 19951001 on 2020-11-16 at 17:01 ]
STR
File: A File to be Processed data. //File: A file to process data
Start: Offset to Process data. //Start: Offset to process data (the beginning of the file is 0)
Bytes: Bytes to Process. //Bytes: Bytes to process (if 0 is entered, it means from Start to the end of the file)
/C: Copy Bytes from File to dstFile. ///C: Copy bytes from the file to the destination file
/I: Insert Bytes to dstFile from File. ///I: Insert bytes from the file into the destination file, and the destination file will increase by Bytes bytes after insertion
dstFile: A File to Write Result data. //dstFile: A file to write result data
Address: Offset to Write Result data. //Address: Offset to write result data (if the destination file does not exist, this value is ignored)
STR
/D: Delete Bytes from File & Write Result to dstFile. ///D: Delete bytes from the file and write the result to the destination file
STR
/V: View File In Hex Style. ///V: View the file in hexadecimal style
/A: Show ASCII Value. ///A: Show ASCII value
/P: Pause Echo Screen. ///P: Pause the echo screen
STR :
Bytes: Must be 0. //Bytes: Must be 0
/F: Find String in File. ///F: Find string in the file
/Hex: Hex Style. ///Hex: Hexadecimal style
/Asc: ASCII Style. ///Asc: ASCII style
Value: Hex_Digital/ASCII String (40 Characters Maximum). //Value: Hexadecimal number/ASCII string (maximum 40 characters) (if it is a hexadecimal string, the length should be even)
/I: Ignore Case. ///I: Ignore case
/A: Process All Value in File. ///A: Process all values in the file (default to find once)
STR :
Bytes: Must be 0. //Bytes: Must be 0
/E: Edit File. ///E: Edit the file
STR
Bytes: Must be 0. //Bytes: Must be 0
/R: Relace SrcString with DstString. ///R: Replace SrcString with DstString
SrcString: :. //SrcString: :
DstString: :. //DstString: :
/A: Process All SrcString in File. ///A: Process all SrcString in the file (default to replace once)
Instructions:
1 When using the /C and /I commands, if the destination file does not exist, the value of Address will be ignored, and directly execute to write the Bytes bytes from Start in the source file to the newly created destination file
2 When using the /C and /I commands, if the destination file exists and Address is not entered, Address defaults to 0, which is the starting position of the file.
3 The size of a single file currently processed does not exceed 2G
Examples:
str 1.exe 0x100 0x10 /d 2.bin Execute to delete 16 bytes from position 256 in file 1.exe and write the result to 2.bin. The length of file 2.bin will be 16 bytes smaller than that of 1.exe
str 1.exe 0x100 0x10 /c 2.bin 20 Execute to write 16 bytes from position 256 in file 1.exe to position 20 of 2.bin, that is, 16 bytes starting from position 20 in file 2.bin will be overwritten
str 1.exe 0x100 0x10 /i 2.bin 20 Execute to insert 16 bytes from position 256 in file 1.exe into position 20 of 2.bin, and the length of the result file 2.bin will increase by 16 bytes
str 1.exe 0x100 0 /v /p /a Display the file content on the screen starting from file offset position 256. If Bytes is entered as 0, it means from Start to the end of the file.
str 1.exe 0x100 0 /e /hex:11223344 Modify 4 bytes starting from file offset position 256 to 0x11, 0x22, 0x33, 0x44.
str 1.exe 0x100 0 /e /asc:1234 Modify 4 bytes starting from file offset position 256 to 1234, that is, 0x31, 0x32, 0x33, 0x34
The search and replace algorithm uses the KMP algorithm, and does not count repeatedly. For example, the content of file 1.txt is 10 characters 0:
0000000000
If the command is executed: str 1.txt 0 0 /f /asc:0000 /a
Then the execution result is:
Find string At:
0 0x0
4 0x4
It will not be:
Find string At:
0 0x0
1 0x1
2 0x2
3 0x3
4 0x4
5 0x5
6 0x6
The compressed package contains DOS version and Win32 version
Corrected the problem in the replace string function on 2008.12.14
Corrected the problem on floor 19 on 2008.12.19
Test version on 2009.2.15 on floor 50
Last edited by 19951001 on 2020-11-16 at 17:01 ]
附件
1: str.rar (2008-12-19 22:27, 18.38 KiB, 下载附件所需积分 1 点
,下载次数: 168)
附件
2: strWin32.rar (2020-11-16 17:00, 20.34 KiB,下载次数: 7)
|
|
2008-4-26 21:45 |
|
|
cchessbd
高级用户
   
积分 525
发帖 222
注册 2006-8-28
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
可能这个东西我用不到,但是我需要一个DOS下查找替换文件中的某个字符串的工具……
不知道 19950101兄能否帮忙写一个?
比如: XXX /rN file "12345,d" "54321,g"
查找到才替换,或替换一次就退出。
替换所有 /r N次 /rN
此文件可能会有 3~10 M
Last edited by cchessbd on 2008-4-28 at 05:39 PM ]
Maybe I won't need this thing, but I need a tool to find and replace a certain string in a file under DOS...
I wonder if brother 19950101 can help write one?
For example: XXX /rN file "12345,d" "54321,g"
Only replace when found, or exit after replacing once. Replace all /r N times /rN
This file may be 3~10 M
Last edited by cchessbd on 2008-4-28 at 05:39 PM ]
|
|
2008-4-28 17:29 |
|
|
19951001
高级用户
    流落街头
积分 570
发帖 272
注册 2005-10-17 来自 北京
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
Originally posted by cchessbd at 2008-4-28 17:29:
可能这个东西我用不到,但是我需要一个DOS下查找替换文件中的某个字符串的工具……
不知道 19950101兄能否帮忙写一个?
比如: XXX /rN file "123 ...
只需要对文本文件处理吗?
Originally posted by cchessbd at 2008-4-28 17:29:
Maybe I don't need this thing, but I need a tool to find and replace a certain string in a file under DOS...
I wonder if brother 19950101 can help write one?
For example: XXX /rN file "123 ...
Just for text files?
|
|
2008-5-7 22:52 |
|
|
19951001
高级用户
    流落街头
积分 570
发帖 272
注册 2005-10-17 来自 北京
状态 离线
|
|
2008-11-14 21:20 |
|
|
本是
银牌会员
    
积分 2221
发帖 789
注册 2005-1-27
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
好工具,但.rar 解压时报错:文件"WIN"头被损坏!
请重新上传!!!
Good tool, but an error occurred when extracting the .rar file: The "WIN" header of the file is corrupted! Please re-upload!
|

my major is english----my love is dos----my teacher is the buddha----my friends--how about U |
|
2008-11-15 00:01 |
|
|
雨露
管理员
          DOS非常爱好者
积分 6209
发帖 2598
注册 2006-1-20
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
报错后win32文件夹是空的!
After the error, the win32 folder is empty!
|

|
|
2008-11-15 08:07 |
|
|
本是
银牌会员
    
积分 2221
发帖 789
注册 2005-1-27
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
文件WIN在根目录。
The file WIN is in the root directory.
|

my major is english----my love is dos----my teacher is the buddha----my friends--how about U |
|
2008-11-15 11:13 |
|
|
19951001
高级用户
    流落街头
积分 570
发帖 272
注册 2005-10-17 来自 北京
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
已经修复破损的压缩包
The damaged compressed package has been repaired
|
|
2008-11-15 11:42 |
|
|
chishingchan
银牌会员
    
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
因需修改二进制文件,这种小软件我以前寻找过,只找到纯DOS下的FH,现在这个应该不错。
Because I need to modify binary files, I have looked for such small software before and only found FH under pure DOS. Now this one should be good.
|
|
2008-11-24 21:25 |
|
|
goli2008
中级用户
  
积分 252
发帖 97
注册 2006-9-17
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
坚决支持,!!
找了好久,请楼主将标题改改,可好,方便其他人搜索,谢谢!
Firmly support,!!
Searched for a long time, please the landlord change the title, okay, convenient for others to search, thank you!
|
|
2008-12-13 11:07 |
|
|
chenall
银牌会员
    
积分 1276
发帖 469
注册 2002-12-23 来自 福建泉州
状态 离线
|
|
2008-12-13 18:10 |
|
|
chenall
银牌会员
    
积分 1276
发帖 469
注册 2002-12-23 来自 福建泉州
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
可不可以再加个功能"字符转义"
比如\0 就是ASCII码00
比如
strw test.bin 0x10 0 /e /asc:test\13\0
会写入test和0X0D和0X00
Can we add a "character escape" function? For example, \0 is ASCII code 00. For example, strw test.bin 0x10 0 /e /asc:test\13\0 will write test and 0X0D and 0X00.
|

QQ:366840202
http://chenall.net |
|
2008-12-13 19:10 |
|
|
19951001
高级用户
    流落街头
积分 570
发帖 272
注册 2005-10-17 来自 北京
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
Originally posted by chenall at 2008-12-13 19:10:
可不可以再加个功能"字符转义"
比如\0 就是ASCII码00
比如
strw test.bin 0x10 0 /e /asc:test\13\0
会写入test和0X0D和0X00
理论上可以实现,不过我近些日子比较忙,暂时没有时间修改
其实也可以这样实现
strw test.bin 0x10 0 /e /asc:test
strw test.bin 0x14 0 /e /hex:1300
上述两条命令可以实现你要的功能
Last edited by 19951001 on 2008-12-13 at 23:18 ]
Originally posted by chenall at 2008-12-13 19:10:
Can you add another function "character escaping"?
For example, \0 is ASCII code 00
For example
strw test.bin 0x10 0 /e /asc:test\13\0
will write test and 0X0D and 0X00
Theoretically, it can be implemented, but I've been quite busy these days and don't have time to modify it for the moment.
Actually, it can be implemented like this:
strw test.bin 0x10 0 /e /asc:test
strw test.bin 0x14 0 /e /hex:1300
The above two commands can achieve the function you want.
Last edited by 19951001 on 2008-12-13 at 23:18 ]
|
|
2008-12-13 22:28 |
|
|
chenall
银牌会员
    
积分 1276
发帖 469
注册 2002-12-23 来自 福建泉州
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
嗯,上面是可以实现,只是如果放在批处理里面要计算字符长度会比较麻烦.
另一个问题,不知程序有没有返回errorleve值?
比如查找,成功返回?失败返回?
Well, the above can be achieved, but it will be more troublesome to calculate the character length if it is placed in a batch file.
Another question, I wonder if the program returns an errorlevel value?
For example, for a search, what is returned on success? What is returned on failure?
|

QQ:366840202
http://chenall.net |
|
2008-12-14 09:43 |
|
|
chenall
银牌会员
    
积分 1276
发帖 469
注册 2002-12-23 来自 福建泉州
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
查找替换功能好像有些问题..
文件A.TXT内容
Exe =$1\TEST
Exe =$1\TEST2
strw a.txt 0 0 /r /asc:$1 /asc:j: /a
得到的结果为乱码,而且丢失字符
正确的结果
Exe =J:\TEST
Exe =J:\TEST2
There seems to be some issues with the find - replace function..
The content of file A.TXT
Exe =$1\TEST
Exe =$1\TEST2
Executing strw a.txt 0 0 /r /asc:$1 /asc:j: /a results in garbled code and loss of characters
The correct result
Exe =J:\TEST
Exe =J:\TEST2
|

QQ:366840202
http://chenall.net |
|
2008-12-14 10:14 |
|