~ubuntu-branches/ubuntu/saucy/clamav/saucy-backports

« back to all changes in this revision

Viewing changes to libclamav/mbr.h

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-07-15 01:08:10 UTC
  • mfrom: (0.35.47 sid)
  • Revision ID: package-import@ubuntu.com-20140715010810-ru66ek4fun2iseba
Tags: 0.98.4+dfsg-2~ubuntu13.10.1
No-change backport to saucy (LP: #1341962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2014 Sourcefire, Inc.
 
3
 *
 
4
 *  Authors: Kevin Lin <klin@sourcefire.com>
 
5
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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,
 
18
 *  MA 02110-1301, USA.
 
19
 */
 
20
 
 
21
#ifndef __MBR_H
 
22
#define __MBR_H
 
23
 
 
24
#if HAVE_CONFIG_H
 
25
#include "clamav-config.h"
 
26
#endif
 
27
 
 
28
#include "cltypes.h"
 
29
#include "others.h"
 
30
 
 
31
#define MBR_SECTOR_SIZE 512
 
32
#define MBR_MAX_PARTITION_ENTRIES 4
 
33
#define CL_MAX_LOGICAL_PARTITIONS 50
 
34
 
 
35
#define MBR_SIGNATURE 0x55aa
 
36
#define MBR_SECTOR 0
 
37
 
 
38
/* MBR Status */
 
39
#define MBR_STATUS_INACTIVE 0x00
 
40
/* other values are invalid status */
 
41
#define MBR_STATUS_ACTIVE   0x80
 
42
/* End MBR Status */
 
43
 
 
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 */
 
50
 
 
51
#ifndef HAVE_ATTRIB_PACKED
 
52
#define __attribute__(x)
 
53
#endif
 
54
 
 
55
#ifdef HAVE_PRAGMA_PACK
 
56
#pragma pack(1)
 
57
#endif
 
58
 
 
59
#ifdef HAVE_PRAGMA_PACK_HPPA
 
60
#pragma pack 1
 
61
#endif
 
62
 
 
63
/* 16-byte MBR partition entry, little-endian */
 
64
struct mbr_partition_entry {
 
65
    uint8_t status; /* 0x80 = active, 0x00 = inactive */
 
66
    uint8_t firstCHS[3];
 
67
    uint8_t type;
 
68
    uint8_t lastCHS[3];
 
69
    uint32_t firstLBA  __attribute__ ((packed));
 
70
    uint32_t numLBA  __attribute__ ((packed));
 
71
};
 
72
 
 
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));
 
77
};
 
78
 
 
79
#ifdef HAVE_PRAGMA_PACK
 
80
#pragma pack()
 
81
#endif
 
82
 
 
83
#ifdef HAVE_PRAGMA_PACK_HPPA
 
84
#pragma pack
 
85
#endif
 
86
 
 
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);
 
91
 
 
92
#endif