VC 获取MBR引导分区数据
来源:互联网 发布:imo软件下载 编辑:程序博客网 时间:2024/06/06 07:36
// ParseMbr.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <Windows.h>#include <stdio.h>#define BOOTRECORDSIZE 440typedef struct _BOOTRECORD{ unsigned char BootRecord[BOOTRECORDSIZE];}BOOTRECORD, *PBOOTRECORD;#define DPTSIZE 64typedef struct _DPT{ unsigned char Dpt[DPTSIZE];}DPT, *PDPT;#define DPTNUMBER 4typedef struct _DP{ unsigned char BootSign; // 引导标志 unsigned char StartHsc[3]; unsigned char PartitionType; // 分区类型 unsigned char EndHsc[3]; ULONG SectorsPreceding; // 本分区之前使用的扇区数 ULONG SectorsInPartition; // 分区的总扇区数}DP, *PDP;typedef struct _MBR{ BOOTRECORD BootRecord; // 引导程序 unsigned char ulSigned[4]; // Windows磁盘签名 unsigned char sReserve[2]; // 保留位 DPT Dpt; // 分区表 unsigned char EndSign[2]; // 结束标志}MBR, *PMBR;// 显示MBR数据VOID ShowMbr(HANDLE hDevice, PMBR pMbr){ DWORD dwRead = 0; ReadFile(hDevice, (LPVOID)pMbr, sizeof(MBR), &dwRead, NULL); for ( int i = 0; i < 512; i ++ ) { printf("%02X ", ((BYTE *)pMbr)[i]); if ( ( i + 1 ) % 16 == 0 ) { printf("\r\n"); } }}// 解析MBRVOID ParseMbr(MBR Mbr){ printf("引导记录: \r\n");int i=0; for ( int i = 0; i < BOOTRECORDSIZE; i ++ ) { printf("%02X ", Mbr.BootRecord.BootRecord[i]); if ( ( i + 1 ) % 16 == 0 ) { printf("\r\n"); } } printf("\r\n"); printf("磁盘签名: \r\n"); for ( i = 0; i < 4; i ++ ) { printf("%02X ", Mbr.ulSigned[i]); } printf("\r\n"); printf("解析分区表: \r\n"); for ( i = 0; i < DPTSIZE; i ++ ) { printf("%02X ", Mbr.Dpt.Dpt[i]); if ( ( i + 1 ) % 16 == 0 ) { printf("\r\n"); } } printf("\r\n"); PDP pDp = (PDP)&(Mbr.Dpt.Dpt); for ( i = 0; i < DPTNUMBER; i ++ ) { printf("引导标志: %02X ", pDp[i].BootSign); printf("分区类型: %02X", pDp[i].PartitionType); printf("\r\n"); printf("本分区之前扇区数: %d ", pDp[i].SectorsInPartition); printf("本分区的总扇区数: %d", pDp[i].SectorsInPartition); printf("\r\n"); printf("该分区的大小: %f \r\n", (double)pDp[i].SectorsInPartition / 1024 * 512 / 1024 / 1024 ); printf("\r\n \r\n"); } printf("结束标志: \r\n"); for ( i = 0; i < 2; i ++ ) { printf("%02X ", Mbr.EndSign[i]); } printf("\r\n");}int main(int argc, char* argv[]){ // 打开物理硬盘设备,通过读取PhysicalDrive0设备文件获取MBR引导分区数据 HANDLE hDevice = CreateFile("\\\\.\\PhysicalDrive0", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if ( hDevice == INVALID_HANDLE_VALUE ) { printf("CreateFile Error %d \r\n", GetLastError()); return -1; } MBR Mbr = { 0 }; ShowMbr(hDevice, &Mbr); ParseMbr(Mbr); CloseHandle(hDevice);getchar();return 0;}
0 0
- VC 获取MBR引导分区数据
- 主引导分区MBR 详解
- VC Win32 读取 磁盘MBR 和 EBR扩展分区 数据
- 单硬盘MBR分区双系统引导解决方法
- 操作系统开机流程与引导分区(mbR)
- 开机流程与主引导分区MBR
- 硬盘主引导记录,分区引导记录(MBR,PBR)
- 开机流程与主引导分区(MBR)
- MBR分区结构、DPT分区表、EBR扩展引导
- 开机流程与主引导分区(MBR)
- MBR分区结构、DPT分区表、EBR扩展引导
- MBR分区结构、DPT分区表、EBR扩展引导
- MBR分区结构、DPT分区表、EBR扩展引导
- 硬盘的那些事(主分区、扩展分区、逻辑分区、活动分区、系统分区、启动分区、引导扇区、MBR等
- 硬盘结构,主引导记录MBR,硬盘分区表DPT,主分区、扩展分区和逻辑分区
- 硬盘结构,主引导记录MBR,硬盘分区表DPT,主分区、扩展分区和逻辑分区
- MBR分区
- MBR、主引导扇区,主分区、扩展分区、逻辑分区,活动分区、引导分区、系统分区、启动分区的区别详解
- FB打印与驱动分析
- malloc(0)参数为0的情况,malloc分配最小空间,free真的释放内存了?
- ajax使用
- 如此爱你
- document.createDocumentFragment()的用法
- VC 获取MBR引导分区数据
- 再谈“我是怎么招聘程序员的”(下)
- 方便了解国家大事
- JTree,将树的每个节点设置成不同的图标
- mean shift的各种资料
- 现金流量的结构分析
- 程序猿《程序员》杂志怎么样?
- 数据结构6:使用栈计算逆波兰表达式
- 天涯赤子心