1

如何使用 C# 将图像更改为十六进制代码http://prntscr.com/1oiw50

byte[] byt = File.ReadAllBytes("D:\\\\a.exe");
string hex = new SoapHexBinary(byt).ToString().Replace("504B0304", "424C0304");
File.WriteAllBytes("D:\\\\b.exe", new SoapHexBinary(hex).Value);

Exe 不能以这种方式工作,但我正在尝试。

4

1 回答 1

0
    byte[] byt = File.ReadAllBytes("D:\\a.exe");
    for (int i = 0; i <= byt.Length - 1; i++)
    {
        if (byt[i] == 80)
        {
            if (byt[i + 1] == 75)
            {
                if (byt[i + 2] == 3)
                {
                    if (byt[i + 3] == 4)
                    {
                        byt[i] = 66;
                        byt[i + 1] = 76;
                        byt[i + 2] = 3;
                        byt[i + 3] = 4;
                    }
                }


            }
        }
    }
    File.WriteAllBytes("D:\\b.exe", byt);

Do you have a bug in this code.I turned to decimal hex codes byt changed accordingly.

于 2013-08-31T21:44:55.213 回答