Direct hardware access from Windows.

Boke

New member
Ok, I understand that I will need to write a driver to access hardware directly while running windows. I want to access the gamma ramp tables to fix the gamma issues ( without the overhead that many of the current tweakers have ). I already have a program finished that works for most games using the windows function "SetDeviceGammaRamp()". But it does not always work.
The program I have put together processes the "WM_DISPLAYCHANGE" windows message.. waits 2 tenths of a second and then sets the ramp values. Its nice to have one automatic global gamma setting for my games and desktop, But it does not work in some games.

My question is ( I am running WinXP ) do I need to make a .Dll, .WDM or a .VXD ? I have found very little information on which one to use.

Edit:
When I said that my program does not always work, I meant that SetDeviceGammaRamp() fails.
 
Last edited:
when you say direct hardware access, I assume you mean getting access to the register and IO level. In actual fact I think you just have a duff program. I suspect you will need to investigate alternative approaches to what your attempting. AKA re-write.

Anyway for direct access I use dlportio as my poison. get it at http://www.driverlinx.com/Software_Products/softwareproducts.htm

It is free, but you have to enter your details now. It's a sys driver and dll. I use it in visual basic.

There are others, I think giveio.sys is popular. I don't know where it is but do a search.

Also the makers of powerstrip have some excellent direct access stuff. http://www.entechtaiwan.com/tools.htm
 
Re: Direct hardware access from Windows.

Boke said:
Ok, I understand that I will need to write a driver to access hardware directly while running windows. I want to access the gamma ramp tables to fix the gamma issues ( without the overhead that many of the current tweakers have ). I already have a program finished that works for most games using the windows function "SetDeviceGammaRamp()". But it does not always work.
The program I have put together processes the "WM_DISPLAYCHANGE" windows message.. waits 2 tenths of a second and then sets the ramp values. Its nice to have one automatic global gamma setting for my games and desktop, But it does not work in some games.

My question is ( I am running WinXP ) do I need to make a .Dll, .WDM or a .VXD ? I have found very little information on which one to use.

Edit:
When I said that my program does not always work, I meant that SetDeviceGammaRamp() fails.

The return value from some MS functions isn't always in line with the docs, beware of that, if you see a change in your display then you know it worked. GetLastError() might serve you better than return values here.

The problem with what you are trying to do is that games which support gamma in their settings are constantly setting the gamma without changing display modes. Every new level, every switch from options back to the game. the only way you are going to automatically mess with that is to continuously set the gamma ramp in a loop and that will stall your game like crazy. :) If you use hardware acces you might avoid the stalls, but I'm sure the stalls are there for a very good reason and you'd likely be causing more problems than you solve. And you'll still have to do it after each and every time the game does it, talk about overhead. I've tried patching functions myself, but I suspect games use DX interfaces to control gamma and not gammaramp. If you were motivated enough you could do a stub for D3d8.dll and hack the registry to call your dll instead, passing all calls onto the orignal d3d8.dll. I'll tell you right now, that you'll have to cache interface pointers left right and center due to aggregation. That might last you until the next version of DX and might take you that long to complete. :) I tried patching just the Direct3DCreate8 call and that's just a mess of interface chasing and cloning. You're trying to herd cats with that approach.

Game Util, which I bring up because you mentioned those nasty tweakers, simply uses SetDeviceGammaRamp when you press a hotkey in the game, it remembers the last value you used so you only have to press the key once to reset it. This has a creeping effect, but it's not something I bothered to address, game util's gamma support is for games without internal gamma options. It still takes command line arguments for gamma, contrast and brightness if you wished to use that for your desktop gamma, but you should stick with ATI's gamma tab for the desktop. For games that don't have gamma support there is no issue, the game starts with the last saved gamma value because the game doesn't clobrer it with it's own gamma settings over and over again. Game util's gamma support was designed for games without gamma support not for competing with a game's built in controls. If you do benchmarks with game util installed and without it installed you'll find no difference, there is no overhead worth talking about, certainly nothing like continuously setting the gamma in hardware. One other thing wrt to game util, there is an ati driver setting called game gamma in the registry, if there were disabled, in theory, games wouldn't be overriding what game util does and you could use that for all your games.

Feel free to try all this yourself, but I've already done it.
 
Thanks for the replies guys!

I guess I'll have to keep using my program as it is. It works for ~95% of everything I've tried it with.

" the only way you are going to automatically mess with that is to continuously set the gamma ramp in a loop and that will stall your game like crazy."

Thats the reason for the 2 tenths of a second delay in setting the gamma ramp values. It seems to be just long enough to override any settings that the games make. I tested my program with many games/demos/benchmarks and all caused a WM_DISPLAYCHANGE message to be sent after they reset the gamma. The only things it does not work for is my own D3D 8.1 code and some old DirectX 5 programs.
 
Back
Top