1 #ifndef AESALON_MONITOR_TYPES_H
2 #define AESALON_MONITOR_TYPES_H
8 /** Byte typedef; simply an 8-bit integer. */
10 #if AESALON_PLATFORM == AESALON_PLATFORM_x86_64
11 /** Unsigned word, 32-bits on 32-bit machines, 64 bits on 64-bit machines. */
12 typedef u_int64_t Word
;
13 /** Signed-word, signed version of @a Word. */
14 typedef int64_t SWord
;
15 #elif AESALON_PLATFORM == AESALON_PLATFORM_x86
16 /** Unsigned word, 32-bits on 32-bit machines, 64 bits on 64-bit machines. */
17 typedef u_int32_t Word
;
18 /** Signed-word, signed version of @a Word. */
19 typedef int32_t SWord
;
22 /** A block of data, presumably from an executable file. Custom version of std::vector<Byte>.*/
25 std::vector
<Byte
> data
;
27 /** Generic constructor, sets data and data_size to NULL and zero, respectively. */
29 /** Constructor that takes a pointer and a std::size_t, for data and data_size. */
30 Block(Byte
*data
, std::size_t data_size
);
32 /** Returns the data that this block points to, with an optional offset.
33 @param offset How many bytes to ignore when determining the address.
34 @return The block data, @a offset bytes in.
36 Byte
*get_data() { return &data
[0]; }
38 /** Retrieves the size of the current data.
39 @return The current size of the referenced data.
41 std::size_t get_size() const { return data
.size(); }
42 /** Removes a swath of Bytes, from offset @a from to offset @a to. This invalidates all
43 pointers to the current Block.
44 @param from Where to begin deleting.
45 @param to Where to end deleteing.
47 void remove(std::size_t from
, std::size_t to
);
49 /** Creates a copy of a subset of the block of represented data.
50 @param from Where to begin copying.
51 @param to Where to end copying.
52 @return The subset of the block.
54 Block
*subset(std::size_t from
, std::size_t to
) const;
56 /** Acts like the POSIX read() function -- reads a specific amount of
58 @param data The buffer to read into.
59 @param size The amount of data to read.
61 void read(void *data
, std::size_t size
);
65 void resize(std::size_t new_size
) {
66 data
.resize(new_size
);
69 void push_word(Word data
);