2
* Copyright (C) 2014 Sourcefire, Inc.
4
* Authors: Kevin Lin <klin@sourcefire.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25
#include "clamav-config.h"
31
#define MBR_SECTOR_SIZE 512
32
#define MBR_MAX_PARTITION_ENTRIES 4
33
#define CL_MAX_LOGICAL_PARTITIONS 50
35
#define MBR_SIGNATURE 0x55aa
39
#define MBR_STATUS_INACTIVE 0x00
40
/* other values are invalid status */
41
#define MBR_STATUS_ACTIVE 0x80
44
/* MBR Partition Types */
45
#define MBR_EMPTY 0x00
46
#define MBR_EXTENDED 0x05
47
#define MBR_HYBRID 0xed
48
#define MBR_PROTECTIVE 0xee
49
/* End Partition Types */
51
#ifndef HAVE_ATTRIB_PACKED
52
#define __attribute__(x)
55
#ifdef HAVE_PRAGMA_PACK
59
#ifdef HAVE_PRAGMA_PACK_HPPA
63
/* 16-byte MBR partition entry, little-endian */
64
struct mbr_partition_entry {
65
uint8_t status; /* 0x80 = active, 0x00 = inactive */
69
uint32_t firstLBA __attribute__ ((packed));
70
uint32_t numLBA __attribute__ ((packed));
73
struct mbr_boot_record {
74
/* 446 bytes of reserved, implementation-based data */
75
struct mbr_partition_entry entries[4];
76
uint16_t signature __attribute__ ((packed));
79
#ifdef HAVE_PRAGMA_PACK
83
#ifdef HAVE_PRAGMA_PACK_HPPA
87
int cli_mbr_check(const unsigned char *buff, size_t len, size_t maplen);
88
int cli_mbr_check2(cli_ctx *ctx, size_t sectorsize);
89
int cli_scanmbr(cli_ctx *ctx, size_t sectorsize);
90
void mbr_convert_to_host(struct mbr_boot_record *record);