[solved] writing a driver: why does Windows refuse to load my simple driver?

If it doesn't fit anywhere else, drop it in here. (not to be used as a chat/nonsense section)

Moderator: Moderator Team

Post Reply
Gary
Posts: 14
Joined: Fri Jan 24, 2020 8:46 pm

[solved] writing a driver: why does Windows refuse to load my simple driver?

Post by Gary »

Hello,
I am trying to write a driver. The driver should call a function (VideoPortInitialize) and then write the return value to a file (for debugging). But Windows 2000 refuses to even start executing the machine code of the driver. When I try to start the driver I only get the error code 31 ("device does not work because the driver could not be loaded") in the device manager.

Is there a way to figure out what the PE loader is complaining?

http://ontheserver.de/temp/2020-02-12/graphic.inf
http://ontheserver.de/temp/2020-02-12/graphic.sys

Thank you.
Last edited by Gary on Sun Apr 12, 2020 5:18 pm, edited 1 time in total.
User avatar
binarymaster
Posts: 481
Joined: Sun Nov 16, 2014 7:05 pm
Location: Russia, Moscow
Contact:

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by binarymaster »

Gary wrote: Wed Feb 12, 2020 8:37 pm When I try to start the driver I only get the error code 31 ("device does not work because the driver could not be loaded") in the device manager.

http://ontheserver.de/temp/2020-02-12/graphic.inf
There are some sections in your INF file that are translated to some other language than english (Treiberinstallation, Dienstinstallation, etc), but they should be never translated.

I think it's better to ask such questions in the development chat or at least in Development Help forum section.
Gary
Posts: 14
Joined: Fri Jan 24, 2020 8:46 pm

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by Gary »

Thank you for your reply.

I thought that the development section is dedicated to ReactOS development. So I didn't want to tread on someones toes. A moderator is free to move the topic.

About those section names: You are right, english is probably the best choice. But even if I named them sfsfdhdgd Windows shouldn't care because they are no special keyword.
ThFabba
Developer
Posts: 293
Joined: Sun Jul 11, 2010 11:39 am

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by ThFabba »

Your "driver" imports from kernel32. Drivers cannot import user mode libraries. I believe for graphics drivers the rule is you can only import from win32k (and, I suppose, videoprt) or some such.
I'm not sure how you even built such a thing. Perhaps you should start with an appropriate sample driver from the WDK rather than from scratch.
Gary
Posts: 14
Joined: Fri Jan 24, 2020 8:46 pm

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by Gary »

@ThFabba: Thank you for the tip. I must have forgotten this when I just wanted to output some debug information somehow.

I have removed the imports from kernel32.dll but I still get the same error.

http://ontheserver.de/temp/2020-02-13/graphic.inf
http://ontheserver.de/temp/2020-02-13/graphic.sys

Maybe I have a second error.

BTW: The Windows driver development kit and all it's uncompiled samples might be a blessing to those who use C, but for the rest of the world it's a horror. It's a pretext for Microsoft for not documenting it's software properly. I don't use C nor the you-don't-need-to-know-let-this-black-box-do-everything-for-you-software alias Visual Studio et al.
hbelusca
Developer
Posts: 1204
Joined: Sat Dec 26, 2009 10:36 pm
Location: Zagreb, Croatia

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by hbelusca »

Gary wrote: Thu Feb 13, 2020 11:23 pm BTW: The Windows driver development kit and all it's uncompiled samples might be a blessing to those who use C, but for the rest of the world it's a horror.
That's because it is expected to write Windows drivers in C (or C++ with limitations) and not in any other language framework.
Gary
Posts: 14
Joined: Fri Jan 24, 2020 8:46 pm

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by Gary »

That's strange:
I just deleted graphic.sys from the directory "drivers" and then made a copy of vga.sys from Microsoft. Then I renamed the copy to "graphic.sys" to see if it's the sys-file or the inf-file. But surprisingly Windows said that the driver was writen for an older version of Windows and therefore is not compatible anymore. Really? Windows is rejecting it's own driver because it is too old? So I used a different driver from Windows instead of vga.sys and then everything worked.

So I took vga.sys from ReactOS and renamed it to graphic.sys. Maybe it's more.compatible :-) But now I get the same 31 error code.

So why doesn't the ReactOS vga.sys work under Windows 2000? Does it have something to do with those digital signatures?

Ok, time to start a new topic in the development section of the forum regarding the new ReactOS related issue.
shunesburg
Posts: 215
Joined: Wed Feb 21, 2018 3:46 pm
Location: Somewhere in France

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by shunesburg »

Gary wrote: Fri Feb 14, 2020 10:59 pm made a copy of vga.sys from Microsoft.
From what version ? XP, 7, 10 ?
Gary wrote: Fri Feb 14, 2020 10:59 pm So why doesn't the ReactOS vga.sys work under Windows 2000?
Because at first ReactOS was an open source alternative for Windows 95 (kernel near from the 2000's one) but know the target is Windows Server 2003.

Try with XP if you want better test.
hbelusca
Developer
Posts: 1204
Joined: Sat Dec 26, 2009 10:36 pm
Location: Zagreb, Croatia

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by hbelusca »

shunesburg wrote: Fri Feb 21, 2020 2:44 pm Because at first ReactOS was an open source alternative for Windows 95 (kernel near from the 2000's one)
Certainly not. ReactOS was originally an alternative to Windows NT 4, then Windows 2000, then XP and Server 2003.
Windows 9x/Me OS and kernels are of completely different design than those of Windows NT/2k.
justincase
Posts: 441
Joined: Sat Nov 15, 2008 4:13 pm

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by justincase »

shunesburg wrote: Fri Feb 21, 2020 2:44 pmBecause at first ReactOS was an open source alternative for Windows 95 (kernel near from the 2000's one)
hbelusca wrote: Fri Feb 21, 2020 2:56 pmCertainly not. ReactOS was originally an alternative to Windows NT 4, then Windows 2000, then XP and Server 2003.
Windows 9x/Me OS and kernels are of completely different design than those of Windows NT/2k.
In a way you're both right, though in the end this has nothing to do with the original question.

Windows 9x/ME are a very different beast from Windows NT and ReactOS has never tried to follow the Windows 9x/ME method/designs, however the project that eventually morphed into ReactOS was originally supposed to implement an open source alternative to Windows 95. It was called "FreeWin95", but it didn't get very far and it's incredibly unlikely that this little factoid from history has anything to do with why any part of ReactOS is or isn't compatible with any version of its Microsoft Windows counterpart.

Anyway, regarding the question:
Gary wrote: Fri Feb 14, 2020 10:59 pmSo why doesn't the ReactOS vga.sys work under Windows 2000? Does it have something to do with those digital signatures?
It's hard to know why it's not working without more details about how it's failing, and even with those details, I personally wouldn't know what to do with those details, however it is worth noting that ReactOS is currently targeting compatibility with the Windows NT 5.2 kernel, so the ability to swap parts of it with Windows 2000 is unlikely to be a very high priority, if it's even considered desirable at all. The ability to swap parts with Windows XP or Windows 2003 is much more desirable however, as it demonstrates bringing ReactOS closer to its current goal of being compatible with Windows NT 5.2.

Note: Windows 2000 is NT 5.0, Windows XP is NT 5.1, and Windows 2003 is NT 5.2, however the differences between NT 5.1 and NT 5.2 are less significant than the differences between NT 5.0 and NT 5.2.
I reserve the right to ignore any portion of any post if I deem it not constructive or likely to cause the discussion to degenerate.
shunesburg
Posts: 215
Joined: Wed Feb 21, 2018 3:46 pm
Location: Somewhere in France

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by shunesburg »

hbelusca wrote: Fri Feb 21, 2020 2:56 pm
shunesburg wrote: Fri Feb 21, 2020 2:44 pm Because at first ReactOS was an open source alternative for Windows 95 (kernel near from the 2000's one)
Certainly not. ReactOS was originally an alternative to Windows NT 4, then Windows 2000, then XP and Server 2003.
Windows 9x/Me OS and kernels are of completely different design than those of Windows NT/2k.
Don't forget the past:
The project was start with the name of FreeWin95 in 1995 and the target was Windows 95.
In 1997, the name change for ReactOS and the target was NT4.
Since 2009, the target is now Windows Server 2003.
In 2018, the compatibility with NT6 software was add, but the target is Windows Server 2003 yet.
User avatar
EmuandCo
Developer
Posts: 4722
Joined: Sun Nov 28, 2004 7:52 pm
Location: Germany, Bavaria, Steinfeld
Contact:

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by EmuandCo »

I say this once.... BACK TO TOPIC!
And stop spreading fake news. There never was ANY code targetting Win9x. It was an idea and nothing more.
NT4 -> NT5.0 -> NT5.2 is what we were and now are.
ReactOS is still in alpha stage, meaning it is not feature-complete and is recommended only for evaluation and testing purposes.

If my post/reply offends or insults you, be sure that you know what sarcasm is...
Gary
Posts: 14
Joined: Fri Jan 24, 2020 8:46 pm

Re: writing a driver: why does Windows refuse to load my simple driver?

Post by Gary »

Ok, I figured it out. The size of the last section needs to be divisible through the value in the field file alignment. Which is not necessary for a dll or exe file. Took me quite a while to figure it out but finally I got a working driver.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests