BattleNet.AdvancedCheckRevision.ComputeHash C# (CSharp) Method

ComputeHash() public static method

public static ComputeHash ( string formula, string mpqFile, FileStream gameExe, FileStream bnclientDll, FileStream d2clientDll ) : uint
formula string
mpqFile string
gameExe System.IO.FileStream
bnclientDll System.IO.FileStream
d2clientDll System.IO.FileStream
return uint
        public static uint ComputeHash(string formula, string mpqFile, FileStream gameExe, FileStream bnclientDll, FileStream d2clientDll)
        {
            byte[] game = File.ReadAllBytes(gameExe.Name);
            byte[] bnclient = File.ReadAllBytes(bnclientDll.Name);
            byte[] d2client = File.ReadAllBytes(d2clientDll.Name);

            uint[] values = new uint[4];
            IEnumerable<FormulaOp> ops = BuildFormula(formula, ref values);

            // TODO: figure out the real mpq hashing code
            //computeFileHash(ops, mpqBytes, ref values);
            // UGLY HACK: use the hardcoded mpq hash
            int mpq = Convert.ToInt32("" + mpqFile[mpqFile.LastIndexOf('.') - 1], 10);
            values[0] ^= hashes[mpq];

            ComputeFileHash(ops, game, ref values);
            ComputeFileHash(ops, bnclient, ref values);
            ComputeFileHash(ops, d2client, ref values);

            return values[2];
        }