[ros-diffs] [fireball] 29323: - Rewrite IntVideoPortGetProcAddress() implementation to use a lookup table instead of doing a wrong call to ZwQuerySystemInformation() which always returned STATUS_IMAGE_ALREADY_LOADED (it's supposed to return this). MS's VideoPort seems to do it in a similar way, because it doesn't import neither ZwQSI() nor MmLoadSystemImage(). - VMWare's video driver now calls VideoPortCreateSecondaryDisplay(), without much success though (it's unimplemented).

fireball at svn.reactos.org fireball at svn.reactos.org
Mon Oct 1 10:14:24 CEST 2007


Author: fireball
Date: Mon Oct  1 12:14:24 2007
New Revision: 29323

URL: http://svn.reactos.org/svn/reactos?rev=29323&view=rev
Log:
- Rewrite IntVideoPortGetProcAddress() implementation to use a lookup table instead of doing a wrong call to ZwQuerySystemInformation() which always returned STATUS_IMAGE_ALREADY_LOADED (it's supposed to return this). MS's VideoPort seems to do it in a similar way, because it doesn't import neither ZwQSI() nor MmLoadSystemImage().
- VMWare's video driver now calls VideoPortCreateSecondaryDisplay(), without much success though (it's unimplemented).

Added:
    trunk/reactos/drivers/video/videoprt/funclist.c   (with props)
Modified:
    trunk/reactos/drivers/video/videoprt/videoprt.c
    trunk/reactos/drivers/video/videoprt/videoprt.h
    trunk/reactos/drivers/video/videoprt/videoprt.rbuild

Added: trunk/reactos/drivers/video/videoprt/funclist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/funclist.c?rev=29323&view=auto
==============================================================================
--- trunk/reactos/drivers/video/videoprt/funclist.c (added)
+++ trunk/reactos/drivers/video/videoprt/funclist.c Mon Oct  1 12:14:24 2007
@@ -1,0 +1,64 @@
+/*
+ * VideoPort driver
+ *
+ * Copyright (C) 2007 ReactOS Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; see the file COPYING.LIB.
+ * If not, write to the Free Software Foundation,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id: videoprt.c 28975 2007-09-09 12:39:11Z fireball $
+ */
+
+
+#include "videoprt.h"
+
+typedef struct _VIDEO_PORT_FUNCTION_TABLE {
+    PVOID Address;
+    PUCHAR Name;
+} *PVIDEO_PORT_FUNCTION_TABLE, VIDEO_PORT_FUNCTION_TABLE;
+
+/* GLOBAL VARIABLES ***********************************************************/
+
+#define VP_EXPORTED_FUNCS 1
+
+UCHAR FN_VideoPortCreateSecondaryDisplay[] = "VideoPortCreateSecondaryDisplay";
+
+VIDEO_PORT_FUNCTION_TABLE VideoPortExports[] = {
+    {VideoPortCreateSecondaryDisplay, FN_VideoPortCreateSecondaryDisplay}
+};
+
+PVOID NTAPI
+IntVideoPortGetProcAddress(
+   IN PVOID HwDeviceExtension,
+   IN PUCHAR FunctionName)
+{
+   ULONG i = 0;
+
+   DPRINT("VideoPortGetProcAddress(%s)\n", FunctionName);
+
+   /* Search by name */
+   for (i = 0; i < VP_EXPORTED_FUNCS; i++)
+   {
+      if (!_strnicmp((PCHAR)FunctionName, (PCHAR)VideoPortExports[i].Name,
+                     strlen((PCHAR)FunctionName)))
+      {
+         return (PVOID)VideoPortExports[i].Address;
+      }
+   }
+
+   DPRINT("VideoPortGetProcAddress: Can't resolve symbol %s\n", FunctionName);
+
+   return NULL;
+}

Propchange: trunk/reactos/drivers/video/videoprt/funclist.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/reactos/drivers/video/videoprt/videoprt.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/videoprt.c?rev=29323&r1=29322&r2=29323&view=diff
==============================================================================
--- trunk/reactos/drivers/video/videoprt/videoprt.c (original)
+++ trunk/reactos/drivers/video/videoprt/videoprt.c Mon Oct  1 12:14:24 2007
@@ -61,62 +61,6 @@
       return NULL;
 
    return (PVOID)((ULONG_PTR)BaseAddress + Va);
-}
-
-PVOID NTAPI
-IntVideoPortGetProcAddress(
-   IN PVOID HwDeviceExtension,
-   IN PUCHAR FunctionName)
-{
-   SYSTEM_GDI_DRIVER_INFORMATION GdiDriverInfo;
-   PVOID BaseAddress;
-   PIMAGE_EXPORT_DIRECTORY ExportDir;
-   PUSHORT OrdinalPtr;
-   PULONG NamePtr;
-   PULONG AddressPtr;
-   ULONG i = 0;
-   NTSTATUS Status;
-
-   DPRINT("VideoPortGetProcAddress(%s)\n", FunctionName);
-
-   RtlInitUnicodeString(&GdiDriverInfo.DriverName, L"videoprt");
-   Status = ZwSetSystemInformation(
-      SystemLoadGdiDriverInformation,
-      &GdiDriverInfo,
-      sizeof(SYSTEM_GDI_DRIVER_INFORMATION));
-   if (!NT_SUCCESS(Status))
-   {
-      DPRINT("Couldn't get our own module handle?\n");
-      return NULL;
-   }
-
-   BaseAddress = GdiDriverInfo.ImageAddress;
-
-   /* Get the pointer to the export directory */
-   ExportDir = (PIMAGE_EXPORT_DIRECTORY)IntVideoPortImageDirectoryEntryToData(
-      BaseAddress,
-      IMAGE_DIRECTORY_ENTRY_EXPORT);
-
-   /* Search by name */
-   AddressPtr = (PULONG)
-      ((ULONG_PTR)BaseAddress + (ULONG_PTR)ExportDir->AddressOfFunctions);
-   OrdinalPtr = (PUSHORT)
-      ((ULONG_PTR)BaseAddress + (ULONG_PTR)ExportDir->AddressOfNameOrdinals);
-   NamePtr = (PULONG)
-      ((ULONG_PTR)BaseAddress + (ULONG_PTR)ExportDir->AddressOfNames);
-   for (i = 0; i < ExportDir->NumberOfNames; i++, NamePtr++, OrdinalPtr++)
-   {
-      if (!_strnicmp((PCHAR)FunctionName, (PCHAR)((ULONG_PTR)BaseAddress + *NamePtr),
-                     strlen((PCHAR)FunctionName)))
-      {
-         return (PVOID)((ULONG_PTR)BaseAddress +
-                        (ULONG_PTR)AddressPtr[*OrdinalPtr]);
-      }
-   }
-
-   DPRINT("VideoPortGetProcAddress: Can't resolve symbol %s\n", FunctionName);
-
-   return NULL;
 }
 
 VOID NTAPI

Modified: trunk/reactos/drivers/video/videoprt/videoprt.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/videoprt.h?rev=29323&r1=29322&r2=29323&view=diff
==============================================================================
--- trunk/reactos/drivers/video/videoprt/videoprt.h (original)
+++ trunk/reactos/drivers/video/videoprt/videoprt.h Mon Oct  1 12:14:24 2007
@@ -34,7 +34,7 @@
 #include <ndk/ntndk.h>
 #include <reactos/helper.h>
 
-#define NDEBUG
+//#define NDEBUG
 #include <debug.h>
 
 #define TAG_VIDEO_PORT  TAG('V', 'I', 'D', 'P')
@@ -222,6 +222,11 @@
    IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
    IN PDEVICE_OBJECT DeviceObject);
 
+PVOID NTAPI
+IntVideoPortGetProcAddress(
+   IN PVOID HwDeviceExtension,
+   IN PUCHAR FunctionName);
+
 /* int10.c */
 
 VP_STATUS NTAPI

Modified: trunk/reactos/drivers/video/videoprt/videoprt.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/videoprt.rbuild?rev=29323&r1=29322&r2=29323&view=diff
==============================================================================
--- trunk/reactos/drivers/video/videoprt/videoprt.rbuild (original)
+++ trunk/reactos/drivers/video/videoprt/videoprt.rbuild Mon Oct  1 12:14:24 2007
@@ -14,6 +14,7 @@
 	<file>dispatch.c</file>
 	<file>dma.c</file>
 	<file>event.c</file>
+	<file>funclist.c</file>
 	<file>int10.c</file>
 	<file>interrupt.c</file>
 	<file>resource.c</file>




More information about the Ros-diffs mailing list