File: apm.h

package info (click to toggle)
clamav 0.98.7+dfsg-0+deb6u2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 60,204 kB
  • ctags: 49,129
  • sloc: cpp: 267,090; ansic: 152,211; sh: 35,196; python: 2,630; makefile: 2,220; perl: 1,690; pascal: 1,218; lisp: 184; csh: 117; xml: 38; asm: 32; exp: 4
file content (117 lines) | stat: -rw-r--r-- 3,637 bytes parent folder | download | duplicates (2)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 *  Copyright (C) 2014 Sourcefire, Inc.
 *
 *  Authors: Kevin Lin <klin@sourcefire.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *  MA 02110-1301, USA.
 */

#ifndef __APM_H
#define __APM_H

#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif

#include "cltypes.h"
#include "others.h"

#define APM_FALLBACK_SECTOR_SIZE 512

#define APM_PTABLE_BLOCK 1
#define APM_STRUCT_SIZE 512

#define DDM_SIGNATURE 0x4552 /* driver description signature ('ER') */
#define APM_SIGNATURE 0x504D /* partition map signature ('PM') */

/* partition flags */
#define VALID          0x00000001
#define ALLOCATED      0x00000002
#define IN_USE         0x00000004
#define BOOTABLE       0x00000008
#define READABLE       0x00000010
#define WRITEABLE      0x00000020
#define POSINDEPENDENT 0x00000040
/* end of partition flags */

#ifndef HAVE_ATTRIB_PACKED
#define __attribute__(x)
#endif

#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)
#endif

#ifdef HAVE_PRAGMA_PACK_HPPA
#pragma pack 1
#endif

/* 8-byte driver description entry for ddmap, big endian */
struct apm_driver_desc_entry {
    uint32_t block  __attribute__ ((packed));
    uint16_t size  __attribute__ ((packed));
    uint16_t type  __attribute__ ((packed));
}; //NOTE may need to be renamed

/* 512(82)-byte driver descriptor map (Block0), big endian */
struct apm_driver_desc_map {
    uint16_t signature  __attribute__ ((packed));
    uint16_t blockSize  __attribute__ ((packed));
    uint32_t blockCount  __attribute__ ((packed));
    uint16_t deviceType  __attribute__ ((packed));
    uint16_t deviceID  __attribute__ ((packed));
    uint32_t driverData  __attribute__ ((packed));
    uint16_t driverCount  __attribute__ ((packed));
    struct apm_driver_desc_entry driverTable[8];
    /* zeroes fill remainder of sector (430 bytes in 512 sector size) */
};

/* 512(136)-byte partition info, big endian;
 * both the partition table and the individual partitions use this 
 * struct to describe their details
 */
struct apm_partition_info {
    uint16_t signature  __attribute__ ((packed));
    uint16_t reserved  __attribute__ ((packed));
    uint32_t numPartitions  __attribute__ ((packed));
    uint32_t pBlockStart  __attribute__ ((packed));
    uint32_t pBlockCount  __attribute__ ((packed));
    uint8_t name[32];
    uint8_t type[32];
    uint32_t lBlockStart  __attribute__ ((packed));
    uint32_t lBlockCount  __attribute__ ((packed));
    uint32_t flags  __attribute__ ((packed));
    uint32_t bootBlockStart  __attribute__ ((packed));
    uint32_t bootSize  __attribute__ ((packed));
    uint32_t bootAddr  __attribute__ ((packed));
    uint32_t bootAddr2  __attribute__ ((packed));
    uint32_t bootEntry  __attribute__ ((packed));
    uint32_t bootEntry2  __attribute__ ((packed));
    uint32_t bootChecksum  __attribute__ ((packed));
    uint8_t processor[16];
    /* zeroes fill remainder of sector (376 bytes in 512 sector size) */
};

#ifdef HAVE_PRAGMA_PACK
#pragma pack()
#endif

#ifdef HAVE_PRAGMA_PACK_HPPA
#pragma pack
#endif

int cli_scanapm(cli_ctx *ctx);

#endif