更换一个特定的十六进制在C#中的偏移 [英] Replacing a specific hex offset in C#
本文介绍了更换一个特定的十六进制在C#中的偏移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎么会去更换一个特定的十六进制二进制文件用C#抵销的内容?
How would I go about replacing the content of a specific hex offset in a binary file with C#?
为了使它更清晰,可以说我的偏移量为0x33347和它的内容是06.我想改变06至17.怎样做到这一点?我有一个十六进制编辑经验非常少,所以我是不是真的能够计算出任何东西我自己,我有点失去了。
To make it more clear, lets say my offset is 0x33347, and the content of it is 06. I would want to change 06 to 17. How do I do this? I have very little experience with hex editing, so I weren't really able to figure anything out myself, I'm kind of lost.
推荐答案
使用 的FileStream
,将位置
,然后写入字节。
Using a FileStream
, set the Position
of the stream to the offset, then write the byte.
这将覆盖当前的内容与你想要的东西。
This will overwrite the current content with what you want.
using(var fs = new FileStream("path to file",
FileMode.Open,
FileAccess.ReadWrite))
{
fs.Position = 0x33347;
fs.WriteByte(Convert.ToByte(0x6));
}
这篇关于更换一个特定的十六进制在C#中的偏移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文