简体   繁体   English

使用 Vim 替换 in.so 文件中的文本

[英]Replace text in .so file using Vim

My need is to replace all cases of a certain text in a.so file.我的需要是替换 a.so 文件中某个文本的所有情况。

I use vim to open the file and then use :%!xxd to convert it to a readable format, like in sample output below:我使用 vim 打开文件,然后使用:%!xxd将其转换为可读格式,如下面的示例 output 所示:

000001a0: f217 4dce 4321 4118 3940 1326 9a3a 62f6  ..M.C!A.9@.&.:b.                                                                                                         
000001b0: 2fde ecdd 0000 0000 0300 0000 a800 0000  /...............                                                                                                         
000001c0: 0100 0000 0600 0000 88c2 2001 0007 4109  .......... ...A.                                                                                                         
000001d0: a800 0000 ac00 0000 ae00 0000 4245 d5ec  ............BE..                                                                                                         
000001e0: bae3 927c 7092 55aa 694a b111 d871 581c  ...|p.U.iJ...qX.                                                                                                         
000001f0: b98d f10e ebd3 ef0e 0000 0000 0000 0000  ................    

My problem is that with this structure, I cannot search over line breaks, making my mission to replace text inachievable by going over search/replace results.我的问题是,使用这种结构,我无法搜索换行符,从而无法通过遍历搜索/替换结果来替换文本。

Is there a way to make vim show only the hex values, and without line breaks?有没有办法让 vim 只显示十六进制值,而没有换行符?

Any other solution that will allow text replacement over line breaks (so it could be done in one shot), is welcome as well.任何其他允许在换行符上替换文本的解决方案(因此可以一次性完成)也是受欢迎的。

Thank you!谢谢!

You can use sed multi-line search in combination with hex escape notation to search and replace any hex patter in any file.您可以使用sed 多行搜索结合十六进制转义符号来搜索和替换任何文件中的任何十六进制模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM