2003-05-18 17:16:18 +00:00
|
|
|
/*
|
|
|
|
* ReactOS W32 Subsystem
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
2004-02-08 21:37:53 +00:00
|
|
|
/* $Id: driver.c,v 1.35 2004/02/08 21:37:53 weiden Exp $
|
1999-06-15 02:27:24 +00:00
|
|
|
*
|
|
|
|
* GDI Driver support routines
|
|
|
|
* (mostly swiped from Wine)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-11-20 21:51:19 +00:00
|
|
|
#undef WIN32_LEAN_AND_MEAN
|
2000-03-08 21:23:14 +00:00
|
|
|
#define WIN32_NO_PEHDR
|
|
|
|
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ddk/ntddk.h>
|
1999-11-20 21:51:19 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <win32k/driver.h>
|
2003-03-11 00:21:41 +00:00
|
|
|
#include <win32k/misc.h>
|
1999-07-12 23:26:57 +00:00
|
|
|
#include <wchar.h>
|
2002-09-08 10:23:54 +00:00
|
|
|
#include <ddk/winddi.h>
|
|
|
|
#include <ddk/ntddvid.h>
|
2003-11-17 02:12:52 +00:00
|
|
|
#include <rosrtl/string.h>
|
1999-07-12 23:26:57 +00:00
|
|
|
|
2000-07-07 01:18:04 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
1999-06-15 02:27:24 +00:00
|
|
|
|
2003-02-25 23:08:54 +00:00
|
|
|
#define DRIVER_TAG TAG('G', 'D', 'R', 'V')
|
|
|
|
|
1999-06-15 02:27:24 +00:00
|
|
|
typedef struct _GRAPHICS_DRIVER
|
|
|
|
{
|
|
|
|
PWSTR Name;
|
|
|
|
PGD_ENABLEDRIVER EnableDriver;
|
1999-12-09 02:45:06 +00:00
|
|
|
int ReferenceCount;
|
1999-06-15 02:27:24 +00:00
|
|
|
struct _GRAPHICS_DRIVER *Next;
|
|
|
|
} GRAPHICS_DRIVER, *PGRAPHICS_DRIVER;
|
|
|
|
|
|
|
|
static PGRAPHICS_DRIVER DriverList;
|
2000-07-07 01:18:04 +00:00
|
|
|
static PGRAPHICS_DRIVER GenericDriver = 0;
|
1999-06-15 02:27:24 +00:00
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
BOOL DRIVER_RegisterDriver(LPCWSTR Name, PGD_ENABLEDRIVER EnableDriver)
|
1999-06-15 02:27:24 +00:00
|
|
|
{
|
2003-02-25 23:08:54 +00:00
|
|
|
PGRAPHICS_DRIVER Driver = ExAllocatePoolWithTag(NonPagedPool, sizeof(*Driver), DRIVER_TAG);
|
2000-07-07 01:18:04 +00:00
|
|
|
DPRINT( "DRIVER_RegisterDriver( Name: %S )\n", Name );
|
2001-03-31 15:35:08 +00:00
|
|
|
if (!Driver) return FALSE;
|
1999-12-09 02:45:06 +00:00
|
|
|
Driver->ReferenceCount = 0;
|
1999-06-15 02:27:24 +00:00
|
|
|
Driver->EnableDriver = EnableDriver;
|
|
|
|
if (Name)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2003-02-25 23:08:54 +00:00
|
|
|
Driver->Name = ExAllocatePoolWithTag(PagedPool,
|
|
|
|
(wcslen(Name) + 1) * sizeof(WCHAR),
|
|
|
|
DRIVER_TAG);
|
2001-03-31 15:35:08 +00:00
|
|
|
wcscpy(Driver->Name, Name);
|
|
|
|
Driver->Next = DriverList;
|
|
|
|
DriverList = Driver;
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-06-15 02:27:24 +00:00
|
|
|
|
|
|
|
if (GenericDriver != NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
ExFreePool(Driver);
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-06-15 02:27:24 +00:00
|
|
|
|
|
|
|
GenericDriver = Driver;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-02-25 23:08:54 +00:00
|
|
|
PGD_ENABLEDRIVER DRIVER_FindDDIDriver(LPCWSTR Name)
|
1999-06-15 02:27:24 +00:00
|
|
|
{
|
2003-02-25 23:08:54 +00:00
|
|
|
static WCHAR DefaultPath[] = L"\\SystemRoot\\System32\\";
|
|
|
|
static WCHAR DefaultExtension[] = L".DLL";
|
2002-06-14 07:49:58 +00:00
|
|
|
SYSTEM_LOAD_IMAGE GdiDriverInfo;
|
1999-06-15 02:27:24 +00:00
|
|
|
GRAPHICS_DRIVER *Driver = DriverList;
|
2000-08-26 16:22:04 +00:00
|
|
|
NTSTATUS Status;
|
2003-02-25 23:08:54 +00:00
|
|
|
WCHAR *FullName;
|
2003-03-11 00:21:41 +00:00
|
|
|
LPCWSTR p;
|
2003-02-25 23:08:54 +00:00
|
|
|
BOOL PathSeparatorFound;
|
|
|
|
BOOL DotFound;
|
|
|
|
UINT Size;
|
|
|
|
|
|
|
|
DotFound = FALSE;
|
|
|
|
PathSeparatorFound = FALSE;
|
|
|
|
p = Name;
|
|
|
|
while (L'\0' != *p)
|
|
|
|
{
|
|
|
|
if (L'\\' == *p || L'/' == *p)
|
|
|
|
{
|
|
|
|
PathSeparatorFound = TRUE;
|
|
|
|
DotFound = FALSE;
|
|
|
|
}
|
|
|
|
else if (L'.' == *p)
|
|
|
|
{
|
|
|
|
DotFound = TRUE;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Size = (wcslen(Name) + 1) * sizeof(WCHAR);
|
|
|
|
if (! PathSeparatorFound)
|
|
|
|
{
|
|
|
|
Size += sizeof(DefaultPath) - sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
if (! DotFound)
|
|
|
|
{
|
|
|
|
Size += sizeof(DefaultExtension) - sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
FullName = ExAllocatePoolWithTag(PagedPool, Size, DRIVER_TAG);
|
|
|
|
if (NULL == FullName)
|
|
|
|
{
|
|
|
|
DPRINT1("Out of memory\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (PathSeparatorFound)
|
|
|
|
{
|
|
|
|
FullName[0] = L'\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wcscpy(FullName, DefaultPath);
|
|
|
|
}
|
|
|
|
wcscat(FullName, Name);
|
|
|
|
if (! DotFound)
|
|
|
|
{
|
|
|
|
wcscat(FullName, DefaultExtension);
|
|
|
|
}
|
2000-03-08 21:23:14 +00:00
|
|
|
|
|
|
|
/* First see if the driver hasn't already been loaded */
|
2003-02-25 23:08:54 +00:00
|
|
|
while (Driver && FullName)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2003-02-25 23:08:54 +00:00
|
|
|
if (!_wcsicmp( Driver->Name, FullName))
|
1999-06-15 02:27:24 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
return Driver->EnableDriver;
|
1999-06-15 02:27:24 +00:00
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
Driver = Driver->Next;
|
|
|
|
}
|
2000-03-08 21:23:14 +00:00
|
|
|
|
|
|
|
/* If not, then load it */
|
2003-02-25 23:08:54 +00:00
|
|
|
RtlInitUnicodeString (&GdiDriverInfo.ModuleName, (LPWSTR)FullName);
|
2002-06-14 07:49:58 +00:00
|
|
|
Status = ZwSetSystemInformation (SystemLoadImage, &GdiDriverInfo, sizeof(SYSTEM_LOAD_IMAGE));
|
2003-02-25 23:08:54 +00:00
|
|
|
ExFreePool(FullName);
|
2001-03-31 15:35:08 +00:00
|
|
|
if (!NT_SUCCESS(Status)) return NULL;
|
2000-03-09 21:04:10 +00:00
|
|
|
|
2000-08-26 16:22:04 +00:00
|
|
|
DRIVER_RegisterDriver( L"DISPLAY", GdiDriverInfo.EntryPoint);
|
|
|
|
return (PGD_ENABLEDRIVER)GdiDriverInfo.EntryPoint;
|
1999-06-15 02:27:24 +00:00
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
BOOL DRIVER_BuildDDIFunctions(PDRVENABLEDATA DED,
|
1999-07-12 23:26:57 +00:00
|
|
|
PDRIVER_FUNCTIONS DF)
|
|
|
|
{
|
2003-08-13 20:24:05 +00:00
|
|
|
ULONG i;
|
2000-03-09 21:04:10 +00:00
|
|
|
|
|
|
|
for (i=0; i<DED->c; i++)
|
|
|
|
{
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvEnablePDEV) DF->EnablePDev = (PGD_ENABLEPDEV)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvCompletePDEV) DF->CompletePDev = (PGD_COMPLETEPDEV)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvDisablePDEV) DF->DisablePDev = (PGD_DISABLEPDEV)DED->pdrvfn[i].pfn;
|
2000-03-10 12:39:53 +00:00
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvEnableSurface) DF->EnableSurface = (PGD_ENABLESURFACE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvDisableSurface) DF->DisableSurface = (PGD_DISABLESURFACE)DED->pdrvfn[i].pfn;
|
2000-03-09 21:04:10 +00:00
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvAssertMode) DF->AssertMode = (PGD_ASSERTMODE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvResetPDEV) DF->ResetPDev = (PGD_RESETPDEV)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvCreateDeviceBitmap)
|
|
|
|
DF->CreateDeviceBitmap = (PGD_CREATEDEVICEBITMAP)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvDeleteDeviceBitmap)
|
|
|
|
DF->DeleteDeviceBitmap = (PGD_DELETEDEVICEBITMAP)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvRealizeBrush) DF->RealizeBrush = (PGD_REALIZEBRUSH)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvDitherColor) DF->DitherColor = (PGD_DITHERCOLOR)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvStrokePath) DF->StrokePath = (PGD_STROKEPATH)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvFillPath) DF->FillPath = (PGD_FILLPATH)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvStrokeAndFillPath)
|
|
|
|
DF->StrokeAndFillPath = (PGD_STROKEANDFILLPATH)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvPaint) DF->Paint = (PGD_PAINT)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvBitBlt) DF->BitBlt = (PGD_BITBLT)DED->pdrvfn[i].pfn;
|
2001-05-02 12:33:42 +00:00
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvTransparentBlt) DF->TransparentBlt = (PGD_TRANSPARENTBLT)DED->pdrvfn[i].pfn;
|
2000-03-09 21:04:10 +00:00
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvCopyBits) DF->CopyBits = (PGD_COPYBITS)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvStretchBlt) DF->StretchBlt = (PGD_STRETCHBLT)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvSetPalette) DF->SetPalette = (PGD_SETPALETTE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvTextOut) DF->TextOut = (PGD_TEXTOUT)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvEscape) DF->Escape = (PGD_ESCAPE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvDrawEscape) DF->DrawEscape = (PGD_DRAWESCAPE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvQueryFont) DF->QueryFont = (PGD_QUERYFONT)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvQueryFontTree) DF->QueryFontTree = (PGD_QUERYFONTTREE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvQueryFontData) DF->QueryFontData = (PGD_QUERYFONTDATA)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvSetPointerShape) DF->SetPointerShape = (PGD_SETPOINTERSHAPE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvMovePointer) DF->MovePointer = (PGD_MOVEPOINTER)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvLineTo) DF->LineTo = (PGD_LINETO)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvSendPage) DF->SendPage = (PGD_SENDPAGE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvStartPage) DF->StartPage = (PGD_STARTPAGE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvEndDoc) DF->EndDoc = (PGD_ENDDOC)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvStartDoc) DF->StartDoc = (PGD_STARTDOC)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvGetGlyphMode) DF->GetGlyphMode = (PGD_GETGLYPHMODE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvSynchronize) DF->Synchronize = (PGD_SYNCHRONIZE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvSaveScreenBits) DF->SaveScreenBits = (PGD_SAVESCREENBITS)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvGetModes) DF->GetModes = (PGD_GETMODES)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvFree) DF->Free = (PGD_FREE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvDestroyFont) DF->DestroyFont = (PGD_DESTROYFONT)DED->pdrvfn[i].pfn;
|
2000-08-26 16:22:04 +00:00
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvQueryFontCaps) DF->QueryFontCaps = (PGD_QUERYFONTCAPS)DED->pdrvfn[i].pfn;
|
2000-03-09 21:04:10 +00:00
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvLoadFontFile) DF->LoadFontFile = (PGD_LOADFONTFILE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvUnloadFontFile) DF->UnloadFontFile = (PGD_UNLOADFONTFILE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvFontManagement) DF->FontManagement = (PGD_FONTMANAGEMENT)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvQueryTrueTypeTable)
|
|
|
|
DF->QueryTrueTypeTable = (PGD_QUERYTRUETYPETABLE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvQueryTrueTypeOutline)
|
|
|
|
DF->QueryTrueTypeOutline = (PGD_QUERYTRUETYPEOUTLINE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvGetTrueTypeFile) DF->GetTrueTypeFile = (PGD_GETTRUETYPEFILE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvQueryFontFile) DF->QueryFontFile = (PGD_QUERYFONTFILE)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvQueryAdvanceWidths)
|
|
|
|
DF->QueryAdvanceWidths = (PGD_QUERYADVANCEWIDTHS)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvSetPixelFormat) DF->SetPixelFormat = (PGD_SETPIXELFORMAT)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvDescribePixelFormat)
|
|
|
|
DF->DescribePixelFormat = (PGD_DESCRIBEPIXELFORMAT)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvSwapBuffers) DF->SwapBuffers = (PGD_SWAPBUFFERS)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvStartBanding) DF->StartBanding = (PGD_STARTBANDING)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvNextBand) DF->NextBand = (PGD_NEXTBAND)DED->pdrvfn[i].pfn;
|
2003-10-25 18:45:13 +00:00
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvGetDirectDrawInfo) DF->GetDirectDrawInfo = (PGD_GETDIRECTDRAWINFO)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvEnableDirectDraw) DF->EnableDirectDraw = (PGD_ENABLEDIRECTDRAW)DED->pdrvfn[i].pfn;
|
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvDisableDirectDraw) DF->DisableDirectDraw = (PGD_DISABLEDIRECTDRAW)DED->pdrvfn[i].pfn;
|
2000-03-09 21:04:10 +00:00
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvQuerySpoolType) DF->QuerySpoolType = (PGD_QUERYSPOOLTYPE)DED->pdrvfn[i].pfn;
|
2004-02-08 21:37:53 +00:00
|
|
|
if(DED->pdrvfn[i].iFunc == INDEX_DrvGradientFill) DF->GradientFill = (PGD_GRADIENTFILL)DED->pdrvfn[i].pfn;
|
2000-03-09 21:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2002-09-08 10:23:54 +00:00
|
|
|
typedef VP_STATUS (*PMP_DRIVERENTRY)(PVOID, PVOID);
|
2000-03-17 21:02:59 +00:00
|
|
|
|
2003-12-12 12:53:10 +00:00
|
|
|
PFILE_OBJECT DRIVER_FindMPDriver(LPCWSTR Name)
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
2002-06-14 07:49:58 +00:00
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
UNICODE_STRING DeviceName;
|
|
|
|
IO_STATUS_BLOCK Iosb;
|
|
|
|
HANDLE DisplayHandle;
|
|
|
|
NTSTATUS Status;
|
2003-11-07 17:40:02 +00:00
|
|
|
PFILE_OBJECT VideoFileObject;
|
2003-03-11 00:21:41 +00:00
|
|
|
|
2003-11-17 02:12:52 +00:00
|
|
|
RtlRosInitUnicodeStringFromLiteral(&DeviceName, L"\\??\\DISPLAY1");
|
2002-06-14 07:49:58 +00:00
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&DeviceName,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
Status = ZwOpenFile(&DisplayHandle,
|
|
|
|
FILE_ALL_ACCESS,
|
|
|
|
&ObjectAttributes,
|
|
|
|
&Iosb,
|
|
|
|
0,
|
|
|
|
FILE_SYNCHRONOUS_IO_ALERT);
|
2003-11-07 17:40:02 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
2003-08-18 10:18:14 +00:00
|
|
|
{
|
2003-11-07 17:40:02 +00:00
|
|
|
Status = ObReferenceObjectByHandle(DisplayHandle,
|
|
|
|
FILE_READ_DATA | FILE_WRITE_DATA,
|
|
|
|
IoFileObjectType,
|
|
|
|
KernelMode,
|
|
|
|
(PVOID *)&VideoFileObject,
|
|
|
|
NULL);
|
|
|
|
ZwClose(DisplayHandle);
|
2003-08-18 10:18:14 +00:00
|
|
|
}
|
2003-03-11 00:21:41 +00:00
|
|
|
|
2000-08-26 16:22:04 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
1999-07-12 23:26:57 +00:00
|
|
|
{
|
2003-10-24 08:22:29 +00:00
|
|
|
DPRINT1("Unable to connect to miniport (Status %lx)\n", Status);
|
|
|
|
DPRINT1("Perhaps the miniport wasn't loaded?\n");
|
2002-06-14 07:49:58 +00:00
|
|
|
return(NULL);
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2003-12-12 12:53:10 +00:00
|
|
|
return VideoFileObject;
|
1999-07-12 23:26:57 +00:00
|
|
|
}
|
|
|
|
|
2002-06-14 07:49:58 +00:00
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
BOOL DRIVER_UnregisterDriver(LPCWSTR Name)
|
1999-06-15 02:27:24 +00:00
|
|
|
{
|
|
|
|
PGRAPHICS_DRIVER Driver = NULL;
|
|
|
|
|
|
|
|
if (Name)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
if (DriverList != NULL)
|
1999-06-15 02:27:24 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
if (!_wcsicmp(DriverList->Name, Name))
|
|
|
|
{
|
|
|
|
Driver = DriverList;
|
|
|
|
DriverList = DriverList->Next;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Driver = DriverList;
|
|
|
|
while (Driver->Next && _wcsicmp(Driver->Name, Name))
|
1999-06-15 02:27:24 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
Driver = Driver->Next;
|
1999-06-15 02:27:24 +00:00
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
1999-06-15 02:27:24 +00:00
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
1999-06-15 02:27:24 +00:00
|
|
|
else
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
if (GenericDriver != NULL)
|
|
|
|
{
|
|
|
|
Driver = GenericDriver;
|
|
|
|
GenericDriver = NULL;
|
1999-06-15 02:27:24 +00:00
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
}
|
1999-06-15 02:27:24 +00:00
|
|
|
|
|
|
|
if (Driver != NULL)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
ExFreePool(Driver->Name);
|
|
|
|
ExFreePool(Driver);
|
1999-06-15 02:27:24 +00:00
|
|
|
|
2001-03-31 15:35:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
1999-06-15 02:27:24 +00:00
|
|
|
else
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-06-15 02:27:24 +00:00
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
INT DRIVER_ReferenceDriver (LPCWSTR Name)
|
1999-12-09 02:45:06 +00:00
|
|
|
{
|
|
|
|
GRAPHICS_DRIVER *Driver = DriverList;
|
|
|
|
|
|
|
|
while (Driver && Name)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2002-06-14 07:49:58 +00:00
|
|
|
DPRINT( "Comparing %S to %S\n", Driver->Name, Name );
|
2001-03-31 15:35:08 +00:00
|
|
|
if (!_wcsicmp( Driver->Name, Name))
|
1999-12-09 02:45:06 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
return ++Driver->ReferenceCount;
|
1999-12-09 02:45:06 +00:00
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
Driver = Driver->Next;
|
|
|
|
}
|
2000-07-07 01:18:04 +00:00
|
|
|
DPRINT( "Driver %S not found to reference, generic count: %d\n", Name, GenericDriver->ReferenceCount );
|
|
|
|
assert( GenericDriver != 0 );
|
|
|
|
return ++GenericDriver->ReferenceCount;
|
1999-12-09 02:45:06 +00:00
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
INT DRIVER_UnreferenceDriver (LPCWSTR Name)
|
1999-12-09 02:45:06 +00:00
|
|
|
{
|
|
|
|
GRAPHICS_DRIVER *Driver = DriverList;
|
|
|
|
|
|
|
|
while (Driver && Name)
|
2001-03-31 15:35:08 +00:00
|
|
|
{
|
2002-06-14 07:49:58 +00:00
|
|
|
DPRINT( "Comparing %S to %S\n", Driver->Name, Name );
|
2001-03-31 15:35:08 +00:00
|
|
|
if (!_wcsicmp( Driver->Name, Name))
|
1999-12-09 02:45:06 +00:00
|
|
|
{
|
2001-03-31 15:35:08 +00:00
|
|
|
return --Driver->ReferenceCount;
|
1999-12-09 02:45:06 +00:00
|
|
|
}
|
2001-03-31 15:35:08 +00:00
|
|
|
Driver = Driver->Next;
|
|
|
|
}
|
2000-07-07 01:18:04 +00:00
|
|
|
DPRINT( "Driver '%S' not found to dereference, generic count: %d\n", Name, GenericDriver->ReferenceCount );
|
|
|
|
assert( GenericDriver != 0 );
|
|
|
|
return --GenericDriver->ReferenceCount;
|
1999-12-09 02:45:06 +00:00
|
|
|
}
|
2003-05-18 17:16:18 +00:00
|
|
|
/* EOF */
|