Ejemplo n.º 1
0
        private int AddFile(ModuleBuilder manifestModule, string fileName, int flags)
        {
            SHA1Managed hash     = new SHA1Managed();
            string      fullPath = fileName;

            if (dir != null)
            {
                fullPath = Path.Combine(dir, fileName);
            }
            using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
            {
                using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write))
                {
                    byte[] buf = new byte[8192];
                    ModuleWriter.HashChunk(fs, cs, buf, (int)fs.Length);
                }
            }
            return(manifestModule.__AddModule(flags, Path.GetFileName(fileName), hash.Hash));
        }
Ejemplo n.º 2
0
        private int AddFile(ModuleBuilder manifestModule, string fileName, int flags)
        {
            SHA1Managed hash     = new SHA1Managed();
            string      fullPath = fileName;

            if (dir != null)
            {
                fullPath = Path.Combine(dir, fileName);
            }
            using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
            {
                using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write))
                {
                    byte[] buf = new byte[8192];
                    ModuleWriter.HashChunk(fs, cs, buf, (int)fs.Length);
                }
            }
            FileTable.Record file = new FileTable.Record();
            file.Flags     = flags;
            file.Name      = manifestModule.Strings.Add(fileName);
            file.HashValue = manifestModule.Blobs.Add(ByteBuffer.Wrap(hash.Hash));
            return(0x26000000 + manifestModule.File.AddRecord(file));
        }