Esempio n. 1
0
/**
 * Read the encrypted text from the boot file and print it
 */
void FileManager::printBootText() {
	debugC(1, kDebugFile, "printBootText()");

	Common::File ofp;
	if (!ofp.open(getBootFilename())) {
		if (_vm->_gameVariant == kGameVariantH1Dos) {
			//TODO initialize properly _boot structure
			warning("printBootText - Skipping as H1 Dos may be a freeware");
			return;
		} else {
			error("Missing startup file '%s'", getBootFilename());
		}
	}

	// Allocate space for the text and print it
	char *buf = (char *)malloc(_vm->_boot.exit_len + 1);
	if (buf) {
		// Skip over the boot structure (already read) and read exit text
		ofp.seek((long)sizeof(_vm->_boot), SEEK_SET);
		if (ofp.read(buf, _vm->_boot.exit_len) != (size_t)_vm->_boot.exit_len)
			error("Error while reading startup file");

		// Decrypt the exit text, using CRYPT substring
		int i;
		for (i = 0; i < _vm->_boot.exit_len; i++)
			buf[i] ^= s_bootCyper[i % s_bootCyperLen];

		buf[i] = '\0';
		Utils::notifyBox(buf);
	}

	free(buf);
	ofp.close();
}
Esempio n. 2
0
/**
 * Reads boot file for program environment.  Fatal error if not there or
 * file checksum is bad.  De-crypts structure while checking checksum
 */
void FileManager::readBootFile() {
	debugC(1, kDebugFile, "readBootFile()");

	Common::File ofp;
	if (!ofp.open(getBootFilename())) {
		if (_vm->_gameVariant == kGameVariantH1Dos) {
			//TODO initialize properly _boot structure
			warning("readBootFile - Skipping as H1 Dos may be a freeware");
			memset(_vm->_boot._distrib, '\0', sizeof(_vm->_boot._distrib));
			_vm->_boot._registered = kRegFreeware;
			return;
		} else if (_vm->getPlatform() == Common::kPlatformPC) {
			warning("readBootFile - Skipping as H2 and H3 Dos may be shareware");
			memset(_vm->_boot._distrib, '\0', sizeof(_vm->_boot._distrib));
			_vm->_boot._registered = kRegShareware;
			return;
		} else {
			Utils::notifyBox(Common::String::format("Missing startup file '%s'", getBootFilename()));
			_vm->getGameStatus()._doQuitFl = true;
			return;
		}
	}

	if (ofp.size() < (int32)sizeof(_vm->_boot)) {
		Utils::notifyBox(Common::String::format("Corrupted startup file '%s'", getBootFilename()));
		_vm->getGameStatus()._doQuitFl = true;
		return;
	}

	_vm->_boot._checksum = ofp.readByte();
	_vm->_boot._registered = ofp.readByte();
	ofp.read(_vm->_boot._pbswitch, sizeof(_vm->_boot._pbswitch));
	ofp.read(_vm->_boot._distrib, sizeof(_vm->_boot._distrib));
	_vm->_boot._exitLen = ofp.readUint16LE();

	byte *p = (byte *)&_vm->_boot;

	byte checksum = 0;
	for (uint32 i = 0; i < sizeof(_vm->_boot); i++) {
		checksum ^= p[i];
		p[i] ^= s_bootCypher[i % s_bootCypherLen];
	}
	ofp.close();

	if (checksum) {
		Utils::notifyBox(Common::String::format("Corrupted startup file '%s'", getBootFilename()));
		_vm->getGameStatus()._doQuitFl = true;
	}
}
Esempio n. 3
0
/**
 * Reads boot file for program environment.  Fatal error if not there or
 * file checksum is bad.  De-crypts structure while checking checksum
 */
void FileManager::readBootFile() {
	debugC(1, kDebugFile, "readBootFile()");

	Common::File ofp;
	if (!ofp.open(getBootFilename())) {
		if (_vm->_gameVariant == kGameVariantH1Dos) {
			//TODO initialize properly _boot structure
			warning("readBootFile - Skipping as H1 Dos may be a freeware");
			memset(_vm->_boot.distrib, '\0', sizeof(_vm->_boot.distrib));
			_vm->_boot.registered = kRegFreeware;
			return;
		} else {
			error("Missing startup file '%s'", getBootFilename());
		}
	}

	if (ofp.size() < (int32)sizeof(_vm->_boot))
		error("Corrupted startup file");

	_vm->_boot.checksum = ofp.readByte();
	_vm->_boot.registered = ofp.readByte();
	ofp.read(_vm->_boot.pbswitch, sizeof(_vm->_boot.pbswitch));
	ofp.read(_vm->_boot.distrib, sizeof(_vm->_boot.distrib));
	_vm->_boot.exit_len = ofp.readUint16LE();

	byte *p = (byte *)&_vm->_boot;

	byte checksum = 0;
	for (uint32 i = 0; i < sizeof(_vm->_boot); i++) {
		checksum ^= p[i];
		p[i] ^= s_bootCyper[i % s_bootCyperLen];
	}
	ofp.close();

	if (checksum)
		error("Corrupted startup file");
}