/** * Recognize the boot loader type (MS/HackBGRT) and architecture. */ public void Detect() { Exists = false; Type = BootLoaderType.Unknown; Arch = null; try { byte[] data = File.ReadAllBytes(Path); Exists = true; string tmp = System.Text.Encoding.ASCII.GetString(data); if (tmp.IndexOf("HackBGRT") >= 0) { Type = BootLoaderType.Own; } else if (tmp.IndexOf("Microsoft Corporation") >= 0) { Type = BootLoaderType.MS; } switch (BitConverter.ToUInt16(data, BitConverter.ToInt32(data, 0x3c) + 4)) { case 0x014c: Arch = "ia32"; break; case 0x0200: Arch = "ia64"; break; case 0x8664: Arch = "x64"; break; } } catch { } }
/** * Replace this boot loader with another. * * @param other The new boot loader. * @return true if the replacement was successful. */ public bool ReplaceWith(BootLoaderInfo other) { if (!other.Exists || !Copy(other.Path, Path)) { return(false); } Exists = other.Exists; Type = other.Type; Arch = other.Arch; return(true); }