1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-31 09:32:03 +02:00

* Updated breakpad to latest version.

This commit is contained in:
Christian Muehlhaeuser
2012-06-24 18:25:34 +02:00
parent 0a3a9a7e97
commit d3eb5c3f88
186 changed files with 9184 additions and 5835 deletions

View File

@@ -52,6 +52,8 @@ namespace MacFileUtilities {
MachoWalker::MachoWalker(const char *path, LoadCommandCallback callback,
void *context)
: file_(0),
memory_(NULL),
memory_size_(0),
callback_(callback),
callback_context_(context),
current_header_(NULL),
@@ -60,6 +62,18 @@ MachoWalker::MachoWalker(const char *path, LoadCommandCallback callback,
file_ = open(path, O_RDONLY);
}
MachoWalker::MachoWalker(void *memory, size_t size,
LoadCommandCallback callback, void *context)
: file_(0),
memory_(memory),
memory_size_(size),
callback_(callback),
callback_context_(context),
current_header_(NULL),
current_header_size_(0),
current_header_offset_(0) {
}
MachoWalker::~MachoWalker() {
if (file_ != -1)
close(file_);
@@ -90,7 +104,21 @@ bool MachoWalker::WalkHeader(int cpu_type) {
}
bool MachoWalker::ReadBytes(void *buffer, size_t size, off_t offset) {
return pread(file_, buffer, size, offset) == (ssize_t)size;
if (memory_) {
if (offset < 0)
return false;
bool result = true;
if (offset + size > memory_size_) {
if (static_cast<size_t>(offset) >= memory_size_)
return false;
size = memory_size_ - offset;
result = false;
}
memcpy(buffer, static_cast<char *>(memory_) + offset, size);
return result;
} else {
return pread(file_, buffer, size, offset) == (ssize_t)size;
}
}
bool MachoWalker::CurrentHeader(struct mach_header_64 *header, off_t *offset) {