Prev: Bugcheck 101
Next: ksdebug.h and _DbgPrintF
From: Eric on 24 Jan 2009 10:00 Hello, with CreateFileMapping() it is possible to map a file that is not represented in the filesystem (like c:\file.dat) by specifying INVALID_HANDLE_VALUE for the file handle and then an arbitrary filename can be chosen (like "Global\myfile"). Now I am not sure if this is possible in a display driver when calling EngMapFile? What parameter would I have to pass to this function to mimic the behaviour of CreateFileMapping or is there any other function that I would have to use? Thank you very much!
From: Eric on 25 Jan 2009 18:07 On a different note: If I am stuck at using EngMapFile() I'd like to put the file in the temporary directory. Probably in the system wide and not the user temp path since the display driver is loaded before logon. What is the best way to retrieve the location of special folders like Temp from kernel mode (from a display driver)?
From: Uraeu on 26 Jan 2009 20:21 Eric, Try using GetTempPath located in kernel32.dll to retrieve the temporary folder path. And GetTempFileName in kernel32.dll to generate a unique temporary filename Try this article to get yourself started: http://msdn.microsoft.com/en-us/library/aa363875(VS.85).aspx "Eric" wrote: > On a different note: If I am stuck at using EngMapFile() I'd like to put the > file in the temporary directory. Probably in the system wide and not the user > temp path since the display driver is loaded before logon. > > What is the best way to retrieve the location of special folders like Temp > from kernel mode (from a display driver)?
From: Eric on 27 Jan 2009 05:09 Thank you for the reply! The problem is that GetTempPath is a user mode function, so that I cannot call it from the display driver (Win2k driver model). I can include windows.h and link against kernel32.lib, but the driver will fail to load (obviously). An idea I had was to read the value from the registry (from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment ), but I am not sure if this section is even available when the display driver loads and I think paths there can include environment variables like %TEMP% (which I don't know how so resolve), so that would also not be helpful. I could let the installer determine the path and write to the drivers registry entry, but I just checked the inf docs and temp directory paths are not accessible (through numbers, like %10%=%WINDIR%). Well, I am at a loss here. Writing directly to c:\ is ugly but it seems to be the only reliable way of using EngMapFile.
From: Uraeu on 27 Jan 2009 19:54
Why not C:\Windows\Temp ... I know that the printer driver write a whole bunch of temp files into the C:\system32\spooler dir so why not use win\temp ? "Eric" wrote: > Thank you for the reply! > > The problem is that GetTempPath is a user mode function, so that I cannot > call it from the display driver (Win2k driver model). I can include windows.h > and link against kernel32.lib, but the driver will fail to load (obviously). > > An idea I had was to read the value from the registry (from > HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session > Manager\Environment ), but I am not sure if this section is even available > when the display driver loads and I think paths there can include environment > variables like %TEMP% (which I don't know how so resolve), so that would also > not be helpful. > > I could let the installer determine the path and write to the drivers > registry entry, but I just checked the inf docs and temp directory paths are > not accessible (through numbers, like %10%=%WINDIR%). > > Well, I am at a loss here. Writing directly to c:\ is ugly but it seems to > be the only reliable way of using EngMapFile. |