2009-09-17 13:06:04 +00:00
|
|
|
#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) :
|
2016-11-19 16:23:39 +01:00
|
|
|
LoadCommand(header), type(type)
|
2009-09-17 13:06:04 +00:00
|
|
|
{
|
2016-11-19 16:23:39 +01:00
|
|
|
file.readBytes((char*)&command, sizeof(command));
|
2009-09-17 13:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DylibCommand::~DylibCommand() {
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int DylibCommand::getSize() const {
|
2016-11-19 16:23:39 +01:00
|
|
|
return file.getUint32(command.cmdsize);
|
2009-09-17 13:06:04 +00:00
|
|
|
}
|
|
|
|
|
2016-11-19 16:23:39 +01:00
|
|
|
std::string DylibCommand::getName() const {
|
|
|
|
return getLcDataString(command.dylib.name.offset);
|
2009-09-17 13:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int DylibCommand::getCurrentVersion() const {
|
2016-11-19 16:23:39 +01:00
|
|
|
return file.getUint32(command.dylib.current_version);
|
2009-09-17 13:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int DylibCommand::getCompatibleVersion() const {
|
2016-11-19 16:23:39 +01:00
|
|
|
return file.getUint32(command.dylib.compatibility_version);
|
2009-09-17 13:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
time_t DylibCommand::getTimeStamp() const {
|
2016-11-19 16:23:39 +01:00
|
|
|
return file.getUint32(command.dylib.timestamp);
|
2009-09-17 13:06:04 +00:00
|
|
|
}
|
|
|
|
|
2016-11-19 16:23:39 +01:00
|
|
|
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();
|
2009-09-17 13:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|