1 | /**********************************************
|
---|
2 |
|
---|
3 | Utility to patch the dll MMPARTS.DLL so the
|
---|
4 | IBM MM classes are not longer found.
|
---|
5 |
|
---|
6 | (c) Chris Wohlgemuth 07.06.2003
|
---|
7 |
|
---|
8 | christopher.wohlgemuth@bch.siemens.de
|
---|
9 |
|
---|
10 |
|
---|
11 | >>>> USE IT ON YOUR OWN RISK!!! <<<<
|
---|
12 |
|
---|
13 | (and remember to do a backup of the original
|
---|
14 | file)
|
---|
15 |
|
---|
16 |
|
---|
17 | This program is released under the GPL.
|
---|
18 |
|
---|
19 | Use IBM VAC++ V3 to compile: icc patch.dll
|
---|
20 | *********************************************/
|
---|
21 |
|
---|
22 |
|
---|
23 | #include <stdlib.h>
|
---|
24 | #include <stdio.h>
|
---|
25 | #include <string.h>
|
---|
26 | #include <sys\stat.h>
|
---|
27 | #include <sys\types.h>
|
---|
28 | #include <io.h>
|
---|
29 | #include <os2.h>
|
---|
30 |
|
---|
31 | #define NUMSTRINGS 90
|
---|
32 | /*
|
---|
33 | ,"MM NewClass",
|
---|
34 | "MM ClassData",
|
---|
35 | "MM CClassData"
|
---|
36 | */
|
---|
37 |
|
---|
38 | char * strings[NUMSTRINGS]= {"MMDataFileNewClass",
|
---|
39 | "MMDataFileClassData",
|
---|
40 | "MMDataFileCClassData",
|
---|
41 |
|
---|
42 | "MMAudioClassData",
|
---|
43 | "MMAudioCClassData",
|
---|
44 | "MMAudioNewClass",
|
---|
45 |
|
---|
46 | "MMWAVClassData",
|
---|
47 | "MMWAVCClassData",
|
---|
48 | "MMWAVNewClass",
|
---|
49 |
|
---|
50 | "MMAIFClassData",
|
---|
51 | "MMAIFCClassData",
|
---|
52 | "MMAIFNewClass",
|
---|
53 |
|
---|
54 | "MMAUClassData",
|
---|
55 | "MMAUCClassData",
|
---|
56 | "MMAUNewClass",
|
---|
57 |
|
---|
58 | "MM_AUClassData",
|
---|
59 | "MM_AUCClassData",
|
---|
60 | "MM_AUNewClass",
|
---|
61 |
|
---|
62 | "MMIFFClassData",
|
---|
63 | "MMIFFCClassData",
|
---|
64 | "MMIFFNewClass",
|
---|
65 |
|
---|
66 | "MMSNDFClassData",
|
---|
67 | "MMSNDFCClassData",
|
---|
68 | "MMSNDFNewClass",
|
---|
69 |
|
---|
70 | "MMVOCClassData",
|
---|
71 | "MMVOCCClassData",
|
---|
72 | "MMVOCNewClass",
|
---|
73 |
|
---|
74 | "MMMIDIClassData",
|
---|
75 | "MMMIDICClassData",
|
---|
76 | "MMMIDINewClass",
|
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|
80 | "MMVideoClassData",
|
---|
81 | "MMVideoCClassData",
|
---|
82 | "MMVideoNewClass",
|
---|
83 |
|
---|
84 | "MMAVIClassData",
|
---|
85 | "MMAVICClassData",
|
---|
86 | "MMAVINewClass",
|
---|
87 |
|
---|
88 | "MMFLIClassData",
|
---|
89 | "MMFLICClassData",
|
---|
90 | "MMFLINewClass",
|
---|
91 |
|
---|
92 | "MMMOVClassData",
|
---|
93 | "MMMOVCClassData",
|
---|
94 | "MMMOVNewClass",
|
---|
95 |
|
---|
96 | "MMMPGClassData",
|
---|
97 | "MMMPGCClassData",
|
---|
98 | "MMMPGNewClass",
|
---|
99 |
|
---|
100 | "MMImageClassData",
|
---|
101 | "MMImageCClassData",
|
---|
102 | "MMImageNewClass",
|
---|
103 |
|
---|
104 | "MMAVCClassData",
|
---|
105 | "MMAVCCClassData",
|
---|
106 | "MMAVCNewClass",
|
---|
107 |
|
---|
108 | "MMDIBClassData",
|
---|
109 | "MMDIBCClassData",
|
---|
110 | "MMDIBNewClass",
|
---|
111 |
|
---|
112 | "MMPhotoCDClassData",
|
---|
113 | "MMPhotoCDCClassData",
|
---|
114 | "MMPhotoCDNewClass",
|
---|
115 |
|
---|
116 | "MMPCXClassData",
|
---|
117 | "MMPCXCClassData",
|
---|
118 | "MMPCXNewClass",
|
---|
119 |
|
---|
120 |
|
---|
121 |
|
---|
122 | "MMTargaClassData",
|
---|
123 | "MMTargaCClassData",
|
---|
124 | "MMTargaNewClass",
|
---|
125 |
|
---|
126 | "MMTIFFClassData",
|
---|
127 | "MMTIFFCClassData",
|
---|
128 | "MMTIFFNewClass",
|
---|
129 |
|
---|
130 | "MMMMotionClassData",
|
---|
131 | "MMMMotionCClassData",
|
---|
132 | "MMMMotionNewClass",
|
---|
133 |
|
---|
134 | "MMJPGNewClass",
|
---|
135 | "MMJPGClassData",
|
---|
136 | "MMJPGCClassData",
|
---|
137 |
|
---|
138 | "MMGIFNewClass",
|
---|
139 | "MMGIFClassData",
|
---|
140 | "MMGIFCClassData",
|
---|
141 |
|
---|
142 | "MMFolderClassData",
|
---|
143 | "MMFolderCClassData",
|
---|
144 | "MMFolderNewClass",
|
---|
145 |
|
---|
146 | "MMCDDeviceClassData",
|
---|
147 | "MMCDDeviceCClassData",
|
---|
148 | "MMCDDeviceNewClass",
|
---|
149 |
|
---|
150 | "MMLVDDeviceClassData",
|
---|
151 | "MMLVDDeviceCClassData",
|
---|
152 | "MMLVDDeviceNewClass",
|
---|
153 |
|
---|
154 | "MMDeviceClassData",
|
---|
155 | "MMDeviceCClassData",
|
---|
156 | "MMDeviceNewClass",
|
---|
157 |
|
---|
158 | "MMBitmapClassData",
|
---|
159 | "MMBitmapCClassData",
|
---|
160 | "MMBitmapNewClass"
|
---|
161 |
|
---|
162 | };
|
---|
163 |
|
---|
164 | int main(int argc, char *argv[] )
|
---|
165 | {
|
---|
166 | FILE *stream;
|
---|
167 | struct stat buf;
|
---|
168 | char * memptr;
|
---|
169 | char * tempPtr;
|
---|
170 | BOOL found=FALSE;
|
---|
171 | char * testString="DOSCALLS";
|
---|
172 | char * testString2="doscalls";
|
---|
173 | int a, b, c;
|
---|
174 |
|
---|
175 | a=0;
|
---|
176 | if(argc!=2)
|
---|
177 | {
|
---|
178 | fprintf(stderr, "No DLL path given. Aborting...\n");
|
---|
179 | exit(1);
|
---|
180 | }
|
---|
181 | printf("\nPatching the file MMPARTS.DLL \n\n");
|
---|
182 |
|
---|
183 | /* Open file */
|
---|
184 | if (NULL == (stream = fopen(argv[1], "rb+"))) {
|
---|
185 | printf("Could not open dll\n");
|
---|
186 | return -1;
|
---|
187 | }
|
---|
188 | /* Get File size */
|
---|
189 | if(fstat(fileno(stream),&buf)) {
|
---|
190 | printf("Can't determine file size. Exiting...\n");
|
---|
191 | fclose(stream);
|
---|
192 | return -1;
|
---|
193 | }
|
---|
194 |
|
---|
195 | /* Get memory */
|
---|
196 | memptr=malloc( buf.st_size);
|
---|
197 |
|
---|
198 | if(!memptr) {
|
---|
199 | printf("Can't get memory. Exiting...\n");
|
---|
200 | fclose(stream);
|
---|
201 | return -1;
|
---|
202 | }
|
---|
203 | /* load file */
|
---|
204 | if(buf.st_size!=read(fileno(stream),memptr,buf.st_size))
|
---|
205 | {
|
---|
206 | printf("Can't load file into memory. Exiting...\n");
|
---|
207 | free(memptr);
|
---|
208 | fclose(stream);
|
---|
209 | return -1;
|
---|
210 | }
|
---|
211 | for(c=0;c<2;c++)
|
---|
212 | {
|
---|
213 | for(b=0;b<NUMSTRINGS;b++)
|
---|
214 | {
|
---|
215 | found=FALSE;
|
---|
216 | tempPtr=memptr;
|
---|
217 | testString=strings[b];
|
---|
218 | /* Find string in file */
|
---|
219 | while(tempPtr<memptr+buf.st_size && !found) {
|
---|
220 | if(*tempPtr==*testString ) {
|
---|
221 | /* First valid char found. Check the rest */
|
---|
222 | found=TRUE;
|
---|
223 | for(a=0;a<strlen(strings[b]);a++) {
|
---|
224 | if(*(tempPtr+a)!=*(testString+a))
|
---|
225 | found=FALSE;
|
---|
226 | }
|
---|
227 | }
|
---|
228 | tempPtr++;
|
---|
229 | }
|
---|
230 |
|
---|
231 | if(found){
|
---|
232 | tempPtr--;
|
---|
233 | printf("%s found at file position: %X\n", strings[b], tempPtr-memptr);
|
---|
234 | printf("Changing it to XX...\n");
|
---|
235 | *((char*)(tempPtr))='X';
|
---|
236 | *((char*)(tempPtr+1))='X';
|
---|
237 | }
|
---|
238 | else {
|
---|
239 | printf("Can't find strings in file. So can't rename it. Exiting...\n");
|
---|
240 | free(memptr);
|
---|
241 | fclose(stream);
|
---|
242 | return -1;
|
---|
243 | }
|
---|
244 | }/* b */
|
---|
245 | }
|
---|
246 |
|
---|
247 | /* seek to beginning of file */
|
---|
248 | if(lseek(fileno(stream),0,SEEK_SET)) {
|
---|
249 | printf("Can't seek to beginning of file. Exiting...\n");
|
---|
250 | free(memptr);
|
---|
251 | fclose(stream);
|
---|
252 | return -1;
|
---|
253 | }
|
---|
254 | /* Write modified file */
|
---|
255 | if(buf.st_size!=write(fileno(stream),memptr,buf.st_size)) {
|
---|
256 | printf("Error while writing file.\n");
|
---|
257 | printf("WARNING!! File MMPARTS.DLL may be corrupted! Exiting...\n");
|
---|
258 | free(memptr);
|
---|
259 | fclose(stream);
|
---|
260 | return -1;
|
---|
261 | }
|
---|
262 |
|
---|
263 | free(memptr);
|
---|
264 | fclose(stream);
|
---|
265 | printf("All IBM mm classes renamed...\n\n");
|
---|
266 | return 0;
|
---|
267 | }
|
---|
268 |
|
---|
269 |
|
---|
270 |
|
---|
271 |
|
---|
272 |
|
---|
273 |
|
---|