summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2003-09-25 19:53:41 +0000
committerpixel <pixel>2003-09-25 19:53:41 +0000
commit96507ec5c6715bfcbd38adefbeaaa511844f094f (patch)
tree07386a657b3e0a13ff079f1d111aa2f9994f3700
parent82cd864169e0f3915927d8dcf46045a95d0a0365 (diff)
Bugfix
-rw-r--r--PE/groupe-12.txt2
-rw-r--r--PE/reinsert.cpp47
2 files changed, 20 insertions, 29 deletions
diff --git a/PE/groupe-12.txt b/PE/groupe-12.txt
index 79b487b..12d8f3e 100644
--- a/PE/groupe-12.txt
+++ b/PE/groupe-12.txt
@@ -1,3 +1,5 @@
191
+221
+233
239
256
diff --git a/PE/reinsert.cpp b/PE/reinsert.cpp
index 61372aa..581c16f 100644
--- a/PE/reinsert.cpp
+++ b/PE/reinsert.cpp
@@ -43,7 +43,7 @@ virtual int startup() throw (GeneralException) {
int patch_img(cdutils * cd) {
struct cdutils::DirEntry d_slus, d_pe1;
unsigned char * slus;
- int i, j, c, fontei;
+ int i, c, fontei;
String s;
int groupes[100][20];
int counts[20];
@@ -95,7 +95,7 @@ int patch_img(cdutils * cd) {
f->read(script, f->GetSize());
printm(M_INFO, "Groupe %i...\n", i);
for (c = 0; c < counts[i]; c++) {
- int sector, s1, s2, s3, r, size, size2, ptr, tptr, sig, jptr, sizes[2];
+ int sector, s1, s2, s3, r, size, size2, sizes[2], tptr, uptr, aptr, asiz, maxsize;
r = groupes[c][i] - 1;
unsigned char * room;
@@ -111,37 +111,26 @@ int patch_img(cdutils * cd) {
room = (unsigned char *) malloc(size);
cd->read_datas(room, GUESS, d_pe1.Sector + sector + s1 + s2, size);
-
-#if 0
- ptr = size - 4;
- while (1) {
- tptr = *((int *) (room + ptr));
- if ((tptr >> 24) == 1) {
- tptr &= 0xffffff;
- sig = *((int *) (room + tptr));
- if ((sig & 0xffff) == 0xfe) {
- break;
- }
- }
- ptr -= 4;
- }
-
- jptr = *((int *) (room + ptr - 8));
-#else
- jptr = *((int *) (room + ((*((int *) (room + size2 + 32))) & 0xfffff) + 4));
-#endif
-
printm(M_INFO, " Room %i\n", r + 1);
- if (size2 < (jptr + f->GetSize())) {
- printm(M_ERROR, "size2 = %i, jptr = %i, f = %i, + = %i - script trop gros.\n", size2, jptr, f->GetSize(), jptr + f->GetSize());
- exit(-1);
+ tptr = *((int *) (room + size2 + 32)) & 0xfffff;
+ uptr = *((int *) (room + tptr + 4));
+ aptr = *((int *) (room + tptr + 12)) & 0xfffff;
+ asiz = *((int *) (room + tptr + 8));
+ maxsize = aptr - uptr + (asiz | 3);
+// printm(M_INFO, "size2 = 0x%08x\ntptr = 0x%08x\nuptr = 0x%08x\naptr = 0x%08x\nasiz = 0x%08x\nmaxsize = 0x%08x\nsize = 0x%08x\n", size2, tptr, uptr, aptr, asiz, maxsize, f->GetSize());
+ if (f->GetSize() > maxsize) {
+ printm(M_WARNING, "Script trop grand (%i octets et %i libres)\n", f->GetSize(), maxsize);
+ free(room);
+ continue;
}
- memcpy(room + jptr, script, f->GetSize());
-
- *((int *) (room + ptr)) = jptr | 0x01000000;
- *((int *) (room + ptr - 4)) = f->GetSize();
+ uptr = (uptr + maxsize - f->GetSize()) & (~3);
+
+ memcpy(room + uptr, script, f->GetSize());
+
+ *((int *) (room + tptr + 12)) = uptr | 0x01000000;
+ *((int *) (room + tptr + 8)) = f->GetSize();
cd->write_datas(room, GUESS, d_pe1.Sector + sector + s1 + s2, size);