[Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.339.2.2,1.339.2.3

Eugene Sandulenko sev at users.sourceforge.net
Wed Oct 19 12:34:48 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3517

Modified Files:
      Tag: branch-0-8-0
	resource.cpp 
Log Message:
Backport ActiveMark detection.


Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.339.2.2
retrieving revision 1.339.2.3
diff -u -d -r1.339.2.2 -r1.339.2.3
--- resource.cpp	19 Oct 2005 12:11:31 -0000	1.339.2.2
+++ resource.cpp	19 Oct 2005 19:29:54 -0000	1.339.2.3
@@ -42,6 +42,8 @@
 static uint16 newTag2Old(uint32 newTag);
 static const byte *findResourceSmall(uint32 tag, const byte *searchin);
 
+static bool checkTryMedia(BaseScummFile *handle);
+
 
 /* Open a room */
 void ScummEngine::openRoom(const int room) {
@@ -353,6 +355,15 @@
 		_fileHandle->seek(0, SEEK_SET);
 	}
 
+#ifndef DISABLE_HE
+	if (checkTryMedia(_fileHandle)) {
+		displayMessage(NULL, "You're trying to run game encrypted by ActiveMark. This is not supported.");
+		_quit = true;
+
+		return;
+	}
+#endif
+
 	while (true) {
 		blocktype = fileReadDword();
 		itemsize = _fileHandle->readUint32BE();
@@ -370,6 +381,40 @@
 	closeRoom();
 }
 
+
+#ifndef DISABLE_HE
+
+#define TRYMEDIA_MARK_LEN 6
+
+bool checkTryMedia(BaseScummFile *handle) {
+	byte buf[TRYMEDIA_MARK_LEN];
+	bool matched;
+	const byte magic[2][TRYMEDIA_MARK_LEN] = 
+		{{ 0x00,  'T', 'M', 'S', 'A', 'M' },
+		 { 'i',   '=', '$', ':', '(', '$' }};  // Same but 0x69 xored
+
+	handle->read(buf, TRYMEDIA_MARK_LEN);
+
+	for (int i = 0; i < 2; i++) {
+		matched = true;
+		for (int j = 0; j < TRYMEDIA_MARK_LEN; j++)
+			if (buf[j] != magic[i][j])
+				matched = false;
+
+		if (matched)
+			break;
+	}
+
+	if (matched)
+		return true;
+
+	handle->seek(0, SEEK_SET);
+
+	return false;
+}
+#endif
+
+
 #ifndef DISABLE_SCUMM_7_8
 void ScummEngine_v7::readIndexBlock(uint32 blocktype, uint32 itemsize) {
 	int num;





More information about the Scummvm-git-logs mailing list