macdependency/MachO/machofile.h
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

45 lines
1.3 KiB
C++

#ifndef MACHOFILE_H
#define MACHOFILE_H
#include "macho_global.h"
class InternalFile;
class MachOFile
{
public:
MachOFile(const std::string& filename, const MachOFile* parent, bool reversedByteOrder = false);
MachOFile(const MachOFile& file, bool reversedByteOrder);
~MachOFile();
uint32_t readUint32();
uint32_t readUint32LE();
uint32_t readUint32BE();
void readBytes(char* result, size_t size);
uint32_t getUint32(unsigned int data) const {return (reversedByteOrder?reverseByteOrder(data):data);}
static uint32_t getUint32LE(uint32_t data);
static uint32_t getUint32BE(uint32_t data);
std::string getPath() const;
std::string getName() const;
std::string getTitle() const;
unsigned long long getSize() const;
void seek(long long int offset) { position = offset; }
long long int getPosition() const { return position; }
const std::string& getExecutablePath() const { return executablePath; }
time_t getLastModificationTime() const;
private:
static unsigned int convertByteOrder(char* data, bool isBigEndian, unsigned int numberOfBytes);
static unsigned int reverseByteOrder(unsigned int data);
InternalFile* file;
long long int position;
const bool reversedByteOrder;
const MachOFile* parent;
std::string executablePath;
};
#endif // MACHOFILE_H