1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
private void Hex_Editor()
{
if (m_oOpenFile == null)
return;
m_aCurrentBytes = new List<byte[]>();
m_iSelectedOffset = -1;
m_bHighlighted = true;
FileStream Fs = new FileStream(m_oOpenFile.FullName, FileMode.Open, FileAccess.Read ,FileShare.ReadWrite);
BinaryReader Br = new BinaryReader(Fs);
Fs.Position = m_iOffset;
for (int i = 0; i < ScreenLines; i++)
{
m_aCurrentBytes.Add(Br.ReadBytes(ciNbBytesPerLine));
if (m_aCurrentBytes[i].Length == 0)
break;
LoOffsetGr.DrawString((m_iOffset + ciNbBytesPerLine * i).ToString("X8"), c_oFont,Brushes.White, 0, i * ciLineHeight);
for (int j = 0; j < m_aCurrentBytes[i].Length; j++)
{
if (m_aChanges.ContainsKey(m_iOffset + i * ciNbBytesPerLine + j))
{
string LsByte = m_aChanges[m_iOffset + i * ciNbBytesPerLine + j];
if (LsByte.Length == 2)
m_aCurrentBytes[i][j] = byte.Parse(LsByte, NumberStyles.HexNumber);
}
LoHexaGr.DrawString(m_aCurrentBytes[i][j].ToString("X2"), c_oFont, Brushes.Beige,
j * ciHexaWidth, i * ciLineHeight);
LoAsciiGr.DrawString(((char)m_aCurrentBytes[i][j]).ToString(), c_oFont, Brushes.Beige,
j * ciAsciiWidth, i * ciLineHeight);
}
}
Br.Close();
Fs.Close();
} |
Partager