-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimages.cpp
More file actions
50 lines (40 loc) · 1.39 KB
/
images.cpp
File metadata and controls
50 lines (40 loc) · 1.39 KB
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
#include <vector>
#include <iostream>
#include "images.h"
#include "outfile.h"
#include "bashformats.h"
// List of images.
std::vector<ImageData *> _images;
// Invalid image for not resolvable addresses.
ImageData* _invalidImage = new ImageData(0, 0, static_cast<UINT64>(-1), "invalid");
// Records the given Pin image in the internal list and returns the newly created image object.
ImageData* HandleImageLoad(IMG& img)
{
auto imageData = new ImageData(IMG_Id(img), IMG_LowAddress(img), IMG_HighAddress(img), IMG_Name(img));
_images.push_back(imageData);
// Log image load
std::cerr
<< _colorCyan << "load "
<< _colorDefault << std::dec << imageData->Id << " "
<< _colorRed << std::hex << imageData->LowAddress << " " << imageData->HighAddress << " "
<< _colorYellow << imageData->Name
<< _colorDefault
<< std::endl;
outputFile << "L"
<< " " << std::dec << imageData->Id
<< " " << std::setw(16) << std::setfill('0') << std::hex << imageData->LowAddress
<< " " << std::setw(16) << std::setfill('0') << std::hex << imageData->HighAddress
<< " " << imageData->Name
<< std::endl;
return imageData;
}
// Returns the image object containing the given address, or an invalid dummy image.
ImageData* GetImageContainingAddress(UINT64 addr)
{
for(auto imageData : _images)
{
if (imageData->LowAddress <= addr && addr < imageData->HighAddress)
return imageData;
}
return _invalidImage;
}