-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileCheck.cs
41 lines (32 loc) · 1.08 KB
/
FileCheck.cs
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
using System;
using System.IO;
using System.Windows.Forms;
//Rutina para comprobar que realmente has abierto la ROM que toca.
namespace FileCheck
{
class CheckFile
{
public static bool Checker(string fileName, int checkoffset, string datacheck, string ROM)
{
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
int offset = checkoffset;
fs.Seek(offset, 0);
int hexIn;
String hex;
hex = "";
hexIn = fs.ReadByte();
for (int i = 0; i < datacheck.Length/2; i++)
{
fs.Seek(offset + i, 0);
hexIn = fs.ReadByte();
hex = hex + string.Format("{0:X2}", hexIn);
}
if (hex != datacheck)
{
MessageBox.Show("Esta ROM no es compatible con el parche.\rRecuerda que necesitas la ROM\r" + ROM + ".", "ROM no compatible", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
return true;
}
}
}