1 /* Copyright (C) 2000 CW Sandmann (sandmann@clio.rice.edu) 1206 Braelinn, Sugar Land, TX 77479 */
13 const char *client_patch_code
;
15 unsigned long search_base
= 0x4c800L
;
18 char oldpatch
[] = {0x3b, 0x05, 0xac, 0xe6 };
19 char newpatch
[] = {0x3b, 0x05, 0x58, 0x5e };
21 void patch_image(char *filename
)
26 f
= open(filename
, O_RDWR
| O_BINARY
);
28 f
= open(filename
, O_RDONLY
| O_BINARY
);
36 lseek(f
, search_base
, SEEK_SET
);
37 size
= read(f
, buffer
, sizeof(buffer
));
39 client_patch_code
= NULL
;
40 for(i
=0; i
<size
&& !client_patch_code
; i
++)
41 if(!memcmp(buffer
+i
,oldpatch
,sizeof(oldpatch
)))
42 client_patch_code
= (buffer
+i
);
44 if(!client_patch_code
) {
45 printf("Old patch string not found in %s!\n",filename
);
47 lseek(f
, search_base
+i
-1, SEEK_SET
); /* Ready to update */
49 write(f
, newpatch
, sizeof(newpatch
));
50 printf("%s patched\n",filename
);
52 printf("%s patchable (not changed, readonly)\n",filename
);
58 int main(int argc
, char **argv
)
65 if (argc
!= 1) { /* If they specify names, patch them, exit */
71 fprintf(stderr
, "This image patches Windows 2000 NTVDM to fix nesting DPMI bug.\n");
73 strcpy(filename
,getenv("SYSTEMROOT"));
74 strcpy(file2
,filename
);
75 strcat(filename
,"\\system32\\ntvdm.exe");
76 strcat(file2
,"\\system32\\dllcache\\ntvdm.exe");
78 sprintf(buf1
,"copy %s %s\\system32\\ntvdm.ori",filename
,getenv("SYSTEMROOT"));
83 patch_image(filename
);