コード例 #1
0
ファイル: a5init.cpp プロジェクト: jjuran/macloader
bool A5InitLoader::isSupported(const CodeSegment &code, const uint32 offset, const uint32 size) throw() {
	// Check whether the name matches
	if (code.getName() != "%A5Init")
		return false;

	const byte *memory = _executable.getMemory();
	const uint32 memorySize = _executable.getMemorySize();

	// Check whether it only exports one function
	if (!code.is32BitSegment() && READ_UINT16_BE(memory + offset + 2) != 0x0001)
		return false;
	else if (READ_UINT32_BE(memory + offset + 8) != 0x00000001)
		return false;

	const uint32 internalOffset = (code.is32BitSegment() ? 46 : 10);
	const uint32 infoOffset = READ_UINT16_BE(memory + offset + internalOffset) + internalOffset;

	// Check whether the information area is still inside the memory dump
	if (offset + infoOffset + 16 >= memorySize)
		return false;

	const uint32 dataOffset = READ_UINT32_BE(memory + offset + infoOffset + 8);
	const uint32 relocationDataOffset = READ_UINT32_BE(memory + offset + infoOffset + 12);

	// Check whether the compressed data is still in the memory dump
	if (offset + dataOffset >= memorySize)
		return false;
	// Check whether the relocation data is still in the memory dump
	if (offset + relocationDataOffset >= memorySize)
		return false;

	// Looks like it is an %A5Init segment
	return true;
}
コード例 #2
0
ファイル: a5init.cpp プロジェクト: jjuran/macloader
void A5InitLoader::load(const CodeSegment &code, const uint32 offset, const uint32 size, std::ostream &out) throw(std::exception) {
	byte *memory = _executable.getMemory();

	const uint32 internalOffset = (code.is32BitSegment() ? 46 : 10);
	const uint32 infoOffset = READ_UINT16_BE(memory + offset + internalOffset) + internalOffset;
	const uint32 dataSize = READ_UINT32_BE(memory + offset + infoOffset + 0);
	const uint16 needLoadBit = READ_UINT16_BE(memory + offset + infoOffset + 4);
	const uint32 dataOffset = READ_UINT32_BE(memory + offset + infoOffset + 8);
	const uint32 relocationDataOffset = READ_UINT32_BE(memory + offset + infoOffset + 12);

	// Output various information about the %A5Init segment
	out << "%A5Init info data:\n"
	       "\tData size: " << dataSize << "\n"
	       "\tNeed to load: " << needLoadBit << "\n"
	       "\tData offset: " << dataOffset << "\n"
	       "\tRelocation offset: " << relocationDataOffset << std::endl;

	// Check whether we actually have to do some work
	if (needLoadBit != 1) {
		out << "A5 data does not need any initialization" << std::endl;
		return;
	}

	const Code0Segment &code0 = _executable.getCode0Segment();
	uint8 *dst = memory + code0.getApplicationGlobalsSize() - dataSize;

	// uncompress the world
	uncompressA5World(dst, memory + offset + infoOffset + dataOffset);

	// relocate the world
	relocateWorld(code0.getApplicationGlobalsSize(), dst, memory + offset + infoOffset + relocationDataOffset, out);

	// Mark segment as initialized
	WRITE_UINT16_BE(memory + offset + infoOffset + 4, 0);
}
コード例 #3
0
ファイル: data00.cpp プロジェクト: jjuran/macloader
bool Data00Loader::isSupported(const CodeSegment &code, const uint32 offset, const uint32 size) throw() {
	const byte *memory = _executable.getMemory();
	const uint32 memorySize = _executable.getMemorySize();

	// TODO: This detection heuristic is probably all wrong...

	// Chechk whether the segment is big enough
	if (memorySize < offset + 0x210)
		return false;

	// Check whether the offset into the jump table is 0
	if (READ_UINT16_BE(memory + offset + 0) != 0)
		return false;

	// Check whether just one function is exported
	if (READ_UINT16_BE(memory + offset + 2) != 1)
		return false;

	// Check whether a "CODE" tag is at 0xA
	if (READ_UINT32_BE(memory + offset + 0x0A) != 0x434F4445)
		return false;

	// Check whether a "DATA" tag is at 0x44
	if (READ_UINT32_BE(memory + offset + 0x44) != 0x44415441)
		return false;

	// Check whether we have an DATA00 resource
	_data00 = _resFork.getResource(0x44415441, 0x0000);
	if (_data00 == nullptr)
		return false;

	return true;
}
コード例 #4
0
ファイル: BlockObj.cpp プロジェクト: R0B3RDV/BitcoinArmory
uint16_t TxRef::getBlockTxIndex(void) const
{
   if(dbKey6B_.getSize() == 6)
      return READ_UINT16_BE(dbKey6B_.getPtr() + 4);
   else
      return UINT16_MAX;
}