Mail Archives: djgpp-workers/1997/06/19/09:36:19
Here is a patch for stubedit.c to read the stub by
checking all the exe-header information:
--- src/stub/stubedit.c~ Sat Oct 26 10:09:48 1996
+++ src/stub/stubedit.c Tue Jun 17 22:57:08 1997
@@ -13,6 +13,7 @@
unsigned long size_of_stubinfo = 0;
char *client_stub_info;
+static unsigned long exe_start = 0;
void find_info(char *filename)
{
@@ -29,7 +30,16 @@
exit(1);
}
- if (fseek(f, 512L, 0) != 0 ||
+ if (fseek(f, 8L, 0) != 0 ||
+ fread(&exe_start, 1, 2, f) != 2)
+ {
+ printf("Error: %s could not read\n", filename);
+ exit(1);
+ }
+
+ exe_start *= 16;
+
+ if (fseek(f, exe_start, 0) != 0 ||
fread(test_magic, 1, 16, f) != 16 ||
memcmp(test_magic, "go32stub", 8) != 0)
{
@@ -41,7 +51,7 @@
size_of_stubinfo = (header[0]) | (header[1]<<8)
| (header[2])<<16 | (header[3]<<24);
- fseek(f, 512L, 0);
+ fseek(f, exe_start, 0);
client_stub_info = (char *)malloc(size_of_stubinfo);
fread(client_stub_info, size_of_stubinfo, 1, f);
@@ -60,7 +70,7 @@
perror(buf);
exit(1);
}
- fseek(f, 512L, 0);
+ fseek(f, exe_start, 0);
fwrite(client_stub_info, 1, size_of_stubinfo, f);
fclose(f);
}
- Raw text -