more dxdiagn fixes

Rob Crittenden <[email protected]>
Newsgroups gmane.comp.emulators.winex.devel
Message-ID <[email protected]>
Attached is a patch which:

1. Fixes a bug introduced when my last patch was applied.
   DxDiagContainer_AddRef() is called whether the property was found or not.
   This can cause a crash for non-existent properties.

2. Added some more VARTYPE support.

3. Updated make_builtins.py to support comments (lines beginning with #),
   the 2 new VARTYPEs and a new naming convention where the variable name
   contains the entire path of the container and property but the property
   name remains short. This is to provide for separate containers sharing
   the same container name. This is the first python coding I've done so
   take it easy on me. I included a patch to builtin_containers.c

I've nearly got DxDiag.exe from XP working. I'm getting an error that 
RICHED32.DLL can't be loaded, haven't figured out why yet. To get this far
I had to change DxDiagProvider_QueryInterface() to return a value when
IID_IDxDiagContainer is requested. This is not included in the patch.

rob

_______________________________________________
winex-devel mailing list
[email protected]
http://lists.transgaming.org/cgi-bin/mailman/listinfo/winex-devel
dxdiagn.diff (text/plain, 10.7 KB)
? builtin_containers_rob
? dxdiagn.diff
Index: builtin_containers.c
===================================================================
RCS file: /cvsroot/winex/dlls/dxdiagn/builtin_containers.c,v
retrieving revision 1.2
diff -u -r1.2 builtin_containers.c
--- builtin_containers.c	22 Sep 2003 16:16:03 -0000	1.2
+++ builtin_containers.c	5 Jan 2004 22:00:45 -0000
@@ -18,30 +18,30 @@
 extern ICOM_VTABLE(IDxDiagContainer) dxDiagContainerVT;
 
 
-/*********** Container: DxDiag_SystemInfo */
+/*********** Container: root_DxDiag_SystemInfo */
 
-WCHAR containerName_DxDiag_SystemInfo[] =
+WCHAR containerName_root_DxDiag_SystemInfo[] =
   { 'D' ,'x' ,'D' ,'i' ,'a' ,'g' ,'_' ,'S' ,'y' ,'s' ,'t' ,'e' ,'m' ,'I' ,'n' ,'f' ,'o' ,0 };
-Container_SubContainer subConts_DxDiag_SystemInfo[] = {
+Container_SubContainer subConts_root_DxDiag_SystemInfo[] = {
   { NULL, NULL }
 };
-WCHAR propertyName_DxDiag_SystemInfo_dwDirectXVersionMajor[] =
+WCHAR propertyName_root_DxDiag_SystemInfo_dwDirectXVersionMajor[] =
   { 'd', 'w', 'D', 'i', 'r', 'e', 'c', 't', 'X', 'V', 'e', 'r', 's', 'i', 'o', 'n', 'M', 'a', 'j', 'o', 'r', 0 };
-WCHAR propertyName_DxDiag_SystemInfo_dwDirectXVersionMinor[] =
+WCHAR propertyName_root_DxDiag_SystemInfo_dwDirectXVersionMinor[] =
   { 'd', 'w', 'D', 'i', 'r', 'e', 'c', 't', 'X', 'V', 'e', 'r', 's', 'i', 'o', 'n', 'M', 'i', 'n', 'o', 'r', 0 };
-WCHAR propertyName_DxDiag_SystemInfo_szDirectXVersionLetter[] =
+WCHAR propertyName_root_DxDiag_SystemInfo_szDirectXVersionLetter[] =
   { 's', 'z', 'D', 'i', 'r', 'e', 'c', 't', 'X', 'V', 'e', 'r', 's', 'i', 'o', 'n', 'L', 'e', 't', 't', 'e', 'r', 0 };
-  WCHAR propertyWSTRVal_DxDiag_SystemInfo_szDirectXVersionLetter[] = 
+  WCHAR propertyWSTRVal_root_DxDiag_SystemInfo_szDirectXVersionLetter[] = 
     { 0 };
-Container_Property properties_DxDiag_SystemInfo[] = {
-  { propertyName_DxDiag_SystemInfo_dwDirectXVersionMajor, DXD_DWORD, 9, 0, FALSE, NULL },
-  { propertyName_DxDiag_SystemInfo_dwDirectXVersionMinor, DXD_DWORD, 0, 0, FALSE, NULL },
-  { propertyName_DxDiag_SystemInfo_szDirectXVersionLetter, DXD_STR, 0, 0, FALSE, propertyWSTRVal_DxDiag_SystemInfo_szDirectXVersionLetter },
-  { NULL, DXD_EMPTY, 0, 0, FALSE, NULL }};
-IDxDiagContainerImpl container_DxDiag_SystemInfo =
+Container_Property properties_root_DxDiag_SystemInfo[] = {
+  { propertyName_root_DxDiag_SystemInfo_dwDirectXVersionMajor, DXD_DWORD, 9, 0, NULL, 0, FALSE, NULL },
+  { propertyName_root_DxDiag_SystemInfo_dwDirectXVersionMinor, DXD_DWORD, 0, 0, NULL, 0, FALSE, NULL },
+  { propertyName_root_DxDiag_SystemInfo_szDirectXVersionLetter, DXD_STR, 0, 0, NULL, 0, FALSE, propertyWSTRVal_root_DxDiag_SystemInfo_szDirectXVersionLetter },
+  { NULL, DXD_EMPTY, 0, 0, 0, 0, FALSE, NULL }};
+IDxDiagContainerImpl container_root_DxDiag_SystemInfo =
                        { &dxDiagContainerVT, 1,
-                         subConts_DxDiag_SystemInfo,
-                         properties_DxDiag_SystemInfo
+                         subConts_root_DxDiag_SystemInfo,
+                         properties_root_DxDiag_SystemInfo
                        };
 
 
@@ -50,11 +50,11 @@
 WCHAR containerName_root[] =
   { 'r' ,'o' ,'o' ,'t' ,0 };
 Container_SubContainer subConts_root[] = {
-  { containerName_DxDiag_SystemInfo, &container_DxDiag_SystemInfo },
+  { containerName_root_DxDiag_SystemInfo, &container_root_DxDiag_SystemInfo },
   { NULL, NULL }
 };
 Container_Property properties_root[] = {
-  { NULL, DXD_EMPTY, 0, 0, FALSE, NULL }};
+  { NULL, DXD_EMPTY, 0, 0, 0, 0, FALSE, NULL }};
 IDxDiagContainerImpl container_root =
                        { &dxDiagContainerVT, 1,
                          subConts_root,
Index: container.c
===================================================================
RCS file: /cvsroot/winex/dlls/dxdiagn/container.c,v
retrieving revision 1.5
diff -u -r1.5 container.c
--- container.c	5 Jan 2004 15:20:39 -0000	1.5
+++ container.c	5 Jan 2004 22:00:45 -0000
@@ -131,7 +131,8 @@
     // Whatever is left over is the last child node and the one we want
     hr = DXDIAGN_Container_GetOneChild(tmpContainer, tmpStr, ppInstance);
 
-    DxDiagContainer_AddRef((IDxDiagContainer *)*ppInstance);
+    if (SUCCEEDED(hr))
+        DxDiagContainer_AddRef((IDxDiagContainer *)*ppInstance);
 
 error:
     HeapFree(GetProcessHeap(), 0, tmpStr);
@@ -184,10 +185,13 @@
  *
  * VARTYPE   MEMBER    PREFIX
  * 
- *  VT_UI4    ulVal      dw
- *  VT_I4     lVal       ??
- *  VT_BOOL   boolVal    ??
- *  VT_BSTR   bstrVal    sz
+ *  VT_UI4    ulVal      dw,i
+ *  VT_I4     lVal       l
+ *  VT_BOOL   boolVal    b
+ *  VT_BSTR   bstrVal    sz,ull
+ *
+ * The DX9 sample program DxDiagReport has some helper functions that clearly
+ * show which PREFIX goes with which VARTYPE.
  */
 
 HRESULT WINAPI DxDiagContainer_GetProp(PDXDIAGCONTAINER iface,
@@ -218,9 +222,17 @@
             V_UI4(pvarProp) = property->dw;
             break;
         case DXD_INT:
-            V_VT(pvarProp) = VT_I4;
+            V_VT(pvarProp) = VT_UI4;
             V_UI4(pvarProp) = property->i;
             break;
+       case DXD_ULL:
+            V_VT(pvarProp) = VT_BSTR;
+            V_BSTR(pvarProp) = SysAllocString(property->ull);
+            break;
+       case DXD_LONG:
+            V_VT(pvarProp) = VT_I4;
+            V_I4(pvarProp) = property->l;
+            break;
         case DXD_BOOL:
             V_VT(pvarProp) = VT_BOOL;
             V_BOOL(pvarProp) = property->b;
Index: dxdiagn_private.h
===================================================================
RCS file: /cvsroot/winex/dlls/dxdiagn/dxdiagn_private.h,v
retrieving revision 1.2
diff -u -r1.2 dxdiagn_private.h
--- dxdiagn_private.h	6 Sep 2003 15:47:59 -0000	1.2
+++ dxdiagn_private.h	5 Jan 2004 22:00:45 -0000
@@ -29,9 +29,11 @@
      * so this can, then the GetProp thing will convert
      * the contents to variants. also since we static init the things,
      * they can't be in unions. :( */
-    enum { DXD_EMPTY, DXD_DWORD, DXD_INT, DXD_BOOL, DXD_STR } varType;
+    enum { DXD_EMPTY, DXD_DWORD, DXD_INT, DXD_ULL, DXD_LONG, DXD_BOOL, DXD_STR } varType;
     DWORD  dw;
     INT    i;
+    WCHAR* ull;
+    LONG   l;
     BOOL   b;
     WCHAR* psz;
 } Container_Property;
Index: make_builtins.py
===================================================================
RCS file: /cvsroot/winex/dlls/dxdiagn/make_builtins.py,v
retrieving revision 1.2
diff -u -r1.2 make_builtins.py
--- make_builtins.py	22 Sep 2003 16:16:03 -0000	1.2
+++ make_builtins.py	5 Jan 2004 22:00:46 -0000
@@ -10,10 +10,11 @@
 import sys
 
 class container:
-    def __init__(self, fileReader, name, parent):
+    def __init__(self, fileReader, name, desc, parent):
         self.children = []
         self.properties = []
         self.name = name
+        self.desc = desc
         self.parent = parent
         self.fileReader = fileReader
         self.fileReader.currentContainer = self
@@ -24,6 +25,7 @@
 
     def readLine(self, line):
         curspaces = 0
+        if line[0] == "#": return # nothing to do
         while line[curspaces] == " ":
             curspaces = curspaces + 1
         if curspaces == 0: return # nothing to do
@@ -35,7 +37,7 @@
         if len(splitline) < 2:
             raise Exception("invalid line")
         if splitline[0] == "SubContainer":
-            newContainer = container(self.fileReader, splitline[1], self)
+            newContainer = container(self.fileReader, self.name + "_" + splitline[1], splitline[1], self)
             self.children.append(newContainer)
         elif splitline[0] == "Property":
             propval = "";
@@ -54,7 +56,10 @@
         self.f = file
 
     def read(self):
-        rootline = self.f.readline()
+        done = 0
+        while (done == 0):
+            rootline = self.f.readline()
+            if rootline[0] == "R": done = 1
         if rootline != "Root\n":
             raise Exception('unexpected file format')
         for line in self.f.readlines():
@@ -88,7 +93,7 @@
         self.f.write("/*********** Container: %s */\n\n" % container.name)
         self.f.write("WCHAR containerName_%s[] =\n" % container.name)
         self.f.write("  { ")
-        for letter in container.name:
+        for letter in container.desc:
             self.f.write("'%c' ," % letter)
         self.f.write("0 };\n")
         self.f.write("Container_SubContainer subConts_%s[] = {\n" % container.name)
@@ -102,7 +107,7 @@
             for letter in property[0]:
                 self.f.write("'%c', " % letter)
             self.f.write("0 };\n")
-            if property[0][0:2] == "sz":
+            if property[0][0:2] == "sz" or property[0][0:3] == "ull":
                 self.f.write("  WCHAR propertyWSTRVal_%s_%s[] = \n" % ( container.name, property[0] ) )
                 self.f.write("    { ")
                 for letter in property[1]:
@@ -113,6 +118,8 @@
         for property in container.properties:
             prop_dw = "0"
             prop_i = "0"
+            prop_ull = "NULL"
+            prop_l = "0"
             prop_b = "FALSE"
             prop_sz = "NULL"
             if property[0][0:2] == "dw":
@@ -121,6 +128,12 @@
             elif property[0][0:1] == "i":
                 prop_i = property[1]
                 prop_type = "DXD_INT"
+            elif property[0][0:3] == "ull":
+                prop_ull = "propertyWSTRVal_%s_%s" % ( container.name, property[0] )
+                prop_type = "DXD_ULL"
+            elif property[0][0:1] == "l":
+                prop_l = property[1]
+                prop_type = "DXD_LONG"
             elif property[0][0:1] == "b":
                 prop_b = property[1]
                 prop_type = "DXD_BOOL"
@@ -129,9 +142,9 @@
                 prop_type = "DXD_STR"
             else:
                 raise Exception("invalid property tpye")
-            self.f.write("  { propertyName_%s_%s, %s, %s, %s, %s, %s },\n" %
-              ( container.name, property[0], prop_type, prop_dw, prop_i, prop_b, prop_sz ))
-        self.f.write("  { NULL, DXD_EMPTY, 0, 0, FALSE, NULL }")
+            self.f.write("  { propertyName_%s_%s, %s, %s, %s, %s, %s, %s, %s },\n" %
+              ( container.name, property[0], prop_type, prop_dw, prop_i, prop_ull, prop_l, prop_b, prop_sz ))
+        self.f.write("  { NULL, DXD_EMPTY, 0, 0, 0, 0, FALSE, NULL }")
         self.f.write("};\n")
         self.f.write("IDxDiagContainerImpl container_%s =\n" % container.name)
         self.f.write("                       { &dxDiagContainerVT, 1,\n")
@@ -155,7 +168,7 @@
 
 try:
     freader = fileReader(fin)
-    rootContainer = container(freader, "root", 0)
+    rootContainer = container(freader, "root", "root", 0)
     freader.read()
     fin.close()
     fwriter = fileWriter(fout)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.