macdependency/MachO/dylibcommand.cpp
Mike Lischke 972fcb3094 Overhaul of the application to avoid it crashing on macOS Sierra.
- Applied all recommended XCode (8) settings.
- Removed boost and replaced that code by standard functions.
- Implemented name mangling via abi::__cxa_demangle instead of running an external process to use c++filt.
- Enabled C++11. Min deployment target is now OSX 10.7.
- Some code clean up (e.g. formatting, std namespace).
2016-11-19 16:23:39 +01:00

48 lines
1.3 KiB
C++

#include "dylibcommand.h"
#include "machofile.h"
#include "machoheader.h"
#define HIBYTE(x) ( (unsigned char) ((x) >> 8) )
#define LOBYTE(x) ( (unsigned char) (x) )
#define HIWORD(x) ( (unsigned short) ( (x) >> 16) )
#define LOWORD(x) ( (unsigned short) (x) )
#define MAKEVERSION(x,y,z) 0x00000000 | (x << 16) | (y << 8) | z
DylibCommand::DylibCommand(MachOHeader* header, DependencyType type) :
LoadCommand(header), type(type)
{
file.readBytes((char*)&command, sizeof(command));
}
DylibCommand::~DylibCommand() {
}
unsigned int DylibCommand::getSize() const {
return file.getUint32(command.cmdsize);
}
std::string DylibCommand::getName() const {
return getLcDataString(command.dylib.name.offset);
}
unsigned int DylibCommand::getCurrentVersion() const {
return file.getUint32(command.dylib.current_version);
}
unsigned int DylibCommand::getCompatibleVersion() const {
return file.getUint32(command.dylib.compatibility_version);
}
time_t DylibCommand::getTimeStamp() const {
return file.getUint32(command.dylib.timestamp);
}
std::string DylibCommand::getVersionString(unsigned int version) {
std::stringstream versionString;
versionString << HIWORD(version) << "." << (unsigned short)HIBYTE(LOWORD(version)) << "." << (unsigned short)LOBYTE(LOWORD(version));
return versionString.str();
}