示例#1
0
bool DecryptSelf(const std::string& elf, const std::string& self)
{
	LOG_NOTICE(LOADER, "Decrypting %s", self);

	// Check for a debug SELF first.
	if (!CheckDebugSelf(self, elf))
	{
		// Set a virtual pointer to the SELF file.
		fs::file self_vf(self);

		if (!self_vf)
			return false;

		// Check the ELF file class (32 or 64 bit).
		bool isElf32 = IsSelfElf32(self);

		// Start the decrypter on this SELF file.
		SELFDecrypter self_dec(self_vf);

		// Load the SELF file headers.
		if (!self_dec.LoadHeaders(isElf32))
		{
			LOG_ERROR(LOADER, "SELF: Failed to load SELF file headers!");
			return false;
		}
		
		// Load and decrypt the SELF file metadata.
		if (!self_dec.LoadMetadata())
		{
			LOG_ERROR(LOADER, "SELF: Failed to load SELF file metadata!");
			return false;
		}
		
		// Decrypt the SELF file data.
		if (!self_dec.DecryptData())
		{
			LOG_ERROR(LOADER, "SELF: Failed to decrypt SELF file data!");
			return false;
		}
		
		// Make a new ELF file from this SELF.
		if (!self_dec.MakeElf(elf, isElf32))
		{
			LOG_ERROR(LOADER, "SELF: Failed to make ELF file from SELF!");
			return false;
		}
	}

	return true;
}
示例#2
0
bool DecryptSelf(const std::string& elf, const std::string& self)
{
	// Check for a debug SELF first.
	if (!CheckDebugSelf(self, elf))
	{
		// Set a virtual pointer to the SELF file.
		vfsLocalFile self_vf(nullptr);

		if (!self_vf.Open(self))
			return false;

		// Check the ELF file class (32 or 64 bit).
		bool isElf32 = IsSelfElf32(self);

		// Start the decrypter on this SELF file.
		SELFDecrypter self_dec(self_vf);

		// Load the SELF file headers.
		if (!self_dec.LoadHeaders(isElf32))
		{
			ConLog.Error("SELF: Failed to load SELF file headers!");
			return false;
		}
		
		// Load and decrypt the SELF file metadata.
		if (!self_dec.LoadMetadata())
		{
			ConLog.Error("SELF: Failed to load SELF file metadata!");
			return false;
		}
		
		// Decrypt the SELF file data.
		if (!self_dec.DecryptData())
		{
			ConLog.Error("SELF: Failed to decrypt SELF file data!");
			return false;
		}
		
		// Make a new ELF file from this SELF.
		if (!self_dec.MakeElf(elf, isElf32))
		{
			ConLog.Error("SELF: Failed to make ELF file from SELF!");
			return false;
		}
	}

	return true;
}