Simple patch program for the NVidia nv4_mini.sys driver

svn path=/trunk/; revision=6565
This commit is contained in:
Gé van Geldorp 2003-11-07 20:10:13 +00:00
parent 6c504bcc4c
commit e9e47f1fdb
4 changed files with 285 additions and 0 deletions

View file

@ -0,0 +1,6 @@
*.o
*.d
*.exe
*.coff
*.sym
*.map

View file

@ -0,0 +1,21 @@
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
TARGET_NAME = patchnv4
TARGET_SDKLIBS =
TARGET_OBJECTS = patchnv4.o
TARGET_CFLAGS += -Wall -Werror
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,131 @@
<!-- $Id: nv4_howto.html,v 1.1 2003/11/07 20:10:13 gvg Exp $ -->
<HTML>
<HEAD>
<TITLE>Using NVidia drivers on ReactOS How-to</TITLE>
</HEAD>
<BODY>
<CENTER><H1>Using NVidia drivers on ReactOS How-to</H1></CENTER>
<H2>1. Introduction</H2>
There is little support for changing video drivers (or any other driver for that
matter) in ReactOS at the moment. You have to know how to access the CVS repository
and how to compile (simple) programs. If this is too complicated, please wait a few
months, we should have better installation tools then.
<H2>2. Supported hardware</H2>
The NVidia drivers were tested on the following video card:
<UL>
</LI>NVidia Riva TNT2 Model 64</LI>
</UL>
However, according to the NVidia website, the same driver supports a whole series
of video cards. If you find this driver works under ReactOS with other cards, please
let us know on the <A HREF="mailto:ros-general@reactos.com">ros-general mailing list</A>
<H2>3. Download the drivers</H2>
First, go to the NVidia website, <A HREF="http://www.nvidia.com">www.nvidia.com</A>,
choose "DOWNLOAD&nbsp;DRIVERS" from the menu at the top of the page (and
"Download&nbsp;Drivers" again from the drop-down menu). Choose "Graphics&nbsp;Driver"
in the first box, "GeForce&nbsp;and&nbsp;TNT2" in the second box and "Windows&nbsp;NT4"
in the third box, then click "Go!". This How-to assumes you see a page identifying the
driver you are about to download as version 43.45, release on April&nbsp;10, 2003.
Download the English version.<BR>
(<A HREF="http://www.nvidia.com/object/winnt_43.45">This</A> is a direct link to the
download page.)
<H2>4. Unpack the drivers</H2>
Start the file you just downloaded (note: you need to do this on a MS-Windows computer,
doesn't work on ReactOS yet). It will ask you for a directory where to save the files.
You can accept the default of C:\NVIDIA\WinNT4\43.45 or change it to your liking, just
remember where you put them.... After the files are unpacked, the install wizard will
start. Just press "Cancel" on the Welcome screen and tell the thing that, yes, you
are quite sure you want to cancel the installation.<BR>
Open a Command Prompt window and cd to C:\NVIDIA\WinNT4\43.45 (or wherever you put
the files). You should have a nv4_mini.sy_ and a nv4_disp.dl_ file. Issue the following
commands:
<PRE>
expand nv4_mini.sy_ nv4_mini.sys
expand nv4_disp.dl_ nv4_disp.dll
</PRE>
After this, you should have a nv4_mini.sys file of 1511936 bytes and a nv4_disp.dll file
of 569807 bytes.
<H2>5. Patch the miniport driver</H2>
Since ReactOS is not 100% binary compatible with MS-Windows yet, the miniport driver
(nv4_mini.sys) needs to be patched. There is a small patch program in the ReactOS CVS
tree at reactos/apps/utils/patchnv4 which you need to compile. Copy the patchnv4.exe
to the directory where you have your nv4_mini.sys file and run it. Afterwards, you
should have a nv4_mini.sys.orig (the original) and a nv4_mini.sys (the patched
version).<BR>
Note that we're working towards binary compatibility, so if you're not reading this
on the <A HREF="http://www.reactos.com">ReactOS website</A>, please go there and check
if the patching is still necessary (ReactOS might have been fixed...).
<H2>6. Install the drivers</H2>
The first step is simple, copy the (patched) nv4_mini.sys file to \ReactOS\System32\drivers
and the nv4_disp.dll file to \ReactOS\System32. The second step is to update the
registry to actually load the driver. Check out the CVS tree and edit the file
reactos/bootdata/hivesys.inf. Add the following lines:
<PRE>
; NVidia driver
HKLM,"SYSTEM\CurrentControlSet\Services\nv4","ErrorControl",0x00010001,0x00000000
HKLM,"SYSTEM\CurrentControlSet\Services\nv4","Group",0x00000000,"Video"
HKLM,"SYSTEM\CurrentControlSet\Services\nv4","ImagePath",0x00020000,"system32\drivers\nv4_mini.sys"
HKLM,"SYSTEM\CurrentControlSet\Services\nv4","Start",0x00010001,0x00000004
HKLM,"SYSTEM\CurrentControlSet\Services\nv4","Type",0x00010001,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\nv4\Device0","CapabilityOverride",0x00010001,0x00000000
HKLM,"SYSTEM\CurrentControlSet\Services\nv4\Device0","EnableVia4x",0x00010001,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\nv4\Device0","InstalledDisplayDrivers",0x00010000,"nv4_disp"
HKLM,"SYSTEM\CurrentControlSet\Services\nv4\Device0","NVREGSWITCHES",0x00000001,43,52,54,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,36,34,30,2c,34,38,30,2c,38,2c,36,30,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,36,34,30,2c,34,38,30,2c,38,\
2c,36,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,36,34,30,2c,\
34,38,30,2c,38,2c,36,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,36,34,30,2c,34,38,30,2c,38,2c,36,30,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,36,34,30,2c,34,38,30,2c,38,2c,36,30,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,36,34,30,2c,34,38,30,2c,38,2c,36,30,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,36,34,30,2c,34,38,30,2c,38,\
2c,36,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,36,34,30,2c,\
34,38,30,2c,38,2c,36,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,36,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,36,30,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,36,30,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,36,30,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,44,4d,54,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01,00,00,00,01,00,\
00,00,00,04,00,00,40,00,00,00,00,04,00,00,00,06,00,00,00,00,00,00,01,00,00,\
00,00,00,00,00,00,00,00,00,05,00,00,00,00,00,04,00,00,00,50,00,00,00,01,00,\
00,00,00,01,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,99,99,99,99,99,\
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,00,00,\
00,00
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","Attach.ToDesktop",0x00010001,1
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","Attach.RelativeX",0x00010001,0
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","Attach.RelativeY",0x00010001,0
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","DefaultSettings.BitsPerPel",0x00010001,16
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","DefaultSettings.XResolution",0x00010001,1152
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","DefaultSettings.YResolution",0x00010001,864
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","DefaultSettings.VRefresh",0x00010001,85
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","DefaultSettings.Flags",0x00010001,0
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","DefaultSettings.XPanning",0x00010001,0
HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\nv4\Device0","DefaultSettings.YPanning",0x00010001,0
</PRE>
Feel free to adjust the DefaultSettings.BitsPerPel, DefaultSettings.XResolution,
DefaultSettings.YResolution and DefaultSettings.VRefresh (check the Display control
panel applet in MS-Windows for available settings for your card/monitor combo).<BR>
Search that same file for the "VGA miniport driver" section and change the "Start"
line in that section to:
<PRE>
HKLM,"SYSTEM\CurrentControlSet\Services\Vga","Start",0x00010001,0x00000004
</PRE>
(i.e. set the last value on that line to 4).<BR>
Rebuild the registry with the command "make registry" and copy the resulting SYSTEM file
to /ReactOS/System32/config. Reboot and enjoy.
</BODY>
</HTML>

View file

@ -0,0 +1,127 @@
/* $Id: patchnv4.c,v 1.1 2003/11/07 20:10:13 gvg Exp $
*
* Patch the NVidia miniport driver to work with ReactOS
*
* Should become obsolete
*/
#include <stdio.h>
#include <stdlib.h>
struct Patch
{
long Offset;
unsigned char ExpectedValue;
unsigned char NewValue;
};
static struct Patch Patches[ ] =
{
{ 0x1EBA9, 0x30, 0x3C },
{ 0x1EBAA, 0xC0, 0xF0 },
{ 0x1EC0B, 0x04, 0x01 },
{ 0x1EC67, 0x30, 0x3C },
{ 0x1EC68, 0xC0, 0xF0 }
};
int
main(int argc, char *argv[])
{
static char OriginalName[] = "nv4_mini.sys";
static char TempName[] = "nv4_mini.tmp";
static char BackupName[] = "nv4_mini.sys.orig";
FILE *File;
unsigned char *Buffer;
long Size;
unsigned n;
/* Read the whole file in memory */
File = fopen(OriginalName, "rb");
if (NULL == File)
{
perror("Unable to open original file");
exit(1);
}
if (fseek(File, 0, SEEK_END))
{
perror("Unable to determine file length");
fclose(File);
exit(1);
}
Size = ftell(File);
if (-1 == Size)
{
perror("Unable to determine file length");
fclose(File);
exit(1);
}
Buffer = malloc(Size);
if (NULL == Buffer)
{
perror("Can't allocate buffer");
fclose(File);
exit(1);
}
rewind(File);
if (Size != fread(Buffer, 1, Size, File))
{
perror("Error reading from original file");
free(Buffer);
fclose(File);
exit(1);
}
fclose(File);
/* Patch the file */
for (n = 0; n < sizeof(Patches) / sizeof(struct Patch); n++)
{
if (Buffer[Patches[n].Offset] != Patches[n].ExpectedValue)
{
fprintf(stderr, "Expected value 0x%02x at offset 0x%lx but found 0x%02x\n",
Patches[n].ExpectedValue, Patches[n].Offset,
Buffer[Patches[n].Offset]);
free(Buffer);
exit(1);
}
Buffer[Patches[n].Offset] = Patches[n].NewValue;
}
/* Write the new file */
File = fopen(TempName, "wb");
if (NULL == File)
{
perror("Unable to open output file");
free(Buffer);
exit(1);
}
if (Size != fwrite(Buffer, 1, Size, File))
{
perror("Error writing to output file");
fclose(File);
remove(TempName);
free(Buffer);
exit(1);
}
fclose(File);
free(Buffer);
/* Rename the original file, removing an existing backup */
remove(BackupName);
if (0 != rename(OriginalName, BackupName))
{
perror("Failed to rename original file");
remove(TempName);
exit(1);
}
/* Rename the new file */
if (0 != rename(TempName, OriginalName))
{
perror("Failed to rename new file");
remove(TempName);
rename(BackupName, OriginalName);
exit(1);
}
return 0;
}