52f7ab63ba8ca84e0971ad46f8457630f0684eac
3 * Patch the NVidia miniport driver to work with ReactOS
5 * Should become obsolete
14 unsigned char ExpectedValue
;
15 unsigned char NewValue
;
18 static struct Patch Patches
[ ] =
20 { 0x1EBA9, 0x30, 0x3C },
21 { 0x1EBAA, 0xC0, 0xF0 },
22 { 0x1EC0B, 0x04, 0x01 },
23 { 0x1EC67, 0x30, 0x3C },
24 { 0x1EC68, 0xC0, 0xF0 }
28 main(int argc
, char *argv
[])
30 static char OriginalName
[] = "nv4_mini.sys";
31 static char TempName
[] = "nv4_mini.tmp";
32 static char BackupName
[] = "nv4_mini.sys.orig";
34 unsigned char *Buffer
;
38 /* Read the whole file in memory */
39 File
= fopen(OriginalName
, "rb");
42 perror("Unable to open original file");
45 if (fseek(File
, 0, SEEK_END
))
47 perror("Unable to determine file length");
54 perror("Unable to determine file length");
58 Buffer
= malloc(Size
);
61 perror("Can't allocate buffer");
66 if (Size
!= fread(Buffer
, 1, Size
, File
))
68 perror("Error reading from original file");
76 for (n
= 0; n
< sizeof(Patches
) / sizeof(struct Patch
); n
++)
78 if (Buffer
[Patches
[n
].Offset
] != Patches
[n
].ExpectedValue
)
80 fprintf(stderr
, "Expected value 0x%02x at offset 0x%lx but found 0x%02x\n",
81 Patches
[n
].ExpectedValue
, Patches
[n
].Offset
,
82 Buffer
[Patches
[n
].Offset
]);
86 Buffer
[Patches
[n
].Offset
] = Patches
[n
].NewValue
;
89 /* Write the new file */
90 File
= fopen(TempName
, "wb");
93 perror("Unable to open output file");
97 if (Size
!= fwrite(Buffer
, 1, Size
, File
))
99 perror("Error writing to output file");
108 /* Rename the original file, removing an existing backup */
110 if (0 != rename(OriginalName
, BackupName
))
112 perror("Failed to rename original file");
117 /* Rename the new file */
118 if (0 != rename(TempName
, OriginalName
))
120 perror("Failed to rename new file");
122 rename(BackupName
, OriginalName
);