~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/programs/dxdiag/information.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * DxDiag information collection
  3  *
  4  * Copyright 2011 Andrew Nguyen
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #define WIN32_LEAN_AND_MEAN
 22 #include <windows.h>
 23 #include <dxdiag.h>
 24 
 25 #include "wine/debug.h"
 26 #include "wine/unicode.h"
 27 
 28 #include "dxdiag_private.h"
 29 
 30 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
 31 
 32 static const WCHAR szTimeEnglish[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0};
 33 static const WCHAR szTimeLocalized[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0};
 34 static const WCHAR szMachineNameEnglish[] = {'s','z','M','a','c','h','i','n','e','N','a','m','e','E','n','g','l','i','s','h',0};
 35 static const WCHAR szOSExLongEnglish[] = {'s','z','O','S','E','x','L','o','n','g','E','n','g','l','i','s','h',0};
 36 static const WCHAR szOSExLocalized[] = {'s','z','O','S','E','x','L','o','c','a','l','i','z','e','d',0};
 37 static const WCHAR szLanguagesEnglish[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0};
 38 static const WCHAR szLanguagesLocalized[] = {'s','z','L','a','n','g','u','a','g','e','s','L','o','c','a','l','i','z','e','d',0};
 39 static const WCHAR szSystemManufacturerEnglish[] = {'s','z','S','y','s','t','e','m','M','a','n','u','f','a','c','t','u','r','e','r','E','n','g','l','i','s','h',0};
 40 static const WCHAR szSystemModelEnglish[] = {'s','z','S','y','s','t','e','m','M','o','d','e','l','E','n','g','l','i','s','h',0};
 41 static const WCHAR szBIOSEnglish[] = {'s','z','B','I','O','S','E','n','g','l','i','s','h',0};
 42 static const WCHAR szProcessorEnglish[] = {'s','z','P','r','o','c','e','s','s','o','r','E','n','g','l','i','s','h',0};
 43 static const WCHAR szPhysicalMemoryEnglish[] = {'s','z','P','h','y','s','i','c','a','l','M','e','m','o','r','y','E','n','g','l','i','s','h',0};
 44 static const WCHAR szPageFileEnglish[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
 45 static const WCHAR szPageFileLocalized[] = {'s','z','P','a','g','e','F','i','l','e','L','o','c','a','l','i','z','e','d',0};
 46 static const WCHAR szWindowsDir[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
 47 static const WCHAR szDirectXVersionLongEnglish[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','L','o','n','g','E','n','g','l','i','s','h',0};
 48 static const WCHAR szSetupParamEnglish[] = {'s','z','S','e','t','u','p','P','a','r','a','m','E','n','g','l','i','s','h',0};
 49 static const WCHAR szDxDiagVersion[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};
 50 
 51 struct property_list
 52 {
 53     const WCHAR *property_name;
 54     WCHAR **output;
 55 };
 56 
 57 static BOOL property_to_string(IDxDiagContainer *container, const WCHAR *property, WCHAR **output)
 58 {
 59     VARIANT var;
 60     HRESULT hr;
 61     BOOL ret = FALSE;
 62 
 63     VariantInit(&var);
 64 
 65     hr = IDxDiagContainer_GetProp(container, property, &var);
 66     if (SUCCEEDED(hr))
 67     {
 68         if (V_VT(&var) == VT_BSTR)
 69         {
 70             WCHAR *bstr = V_BSTR(&var);
 71 
 72             *output = HeapAlloc(GetProcessHeap(), 0, (strlenW(bstr) + 1) * sizeof(WCHAR));
 73             if (*output)
 74             {
 75                 strcpyW(*output, bstr);
 76                 ret = TRUE;
 77             }
 78         }
 79     }
 80 
 81     VariantClear(&var);
 82     return ret;
 83 }
 84 
 85 static void free_system_information(struct dxdiag_information *dxdiag_info)
 86 {
 87     struct system_information *system_info = &dxdiag_info->system_info;
 88 
 89     HeapFree(GetProcessHeap(), 0, system_info->szTimeEnglish);
 90     HeapFree(GetProcessHeap(), 0, system_info->szTimeLocalized);
 91     HeapFree(GetProcessHeap(), 0, system_info->szMachineNameEnglish);
 92     HeapFree(GetProcessHeap(), 0, system_info->szOSExLongEnglish);
 93     HeapFree(GetProcessHeap(), 0, system_info->szOSExLocalized);
 94     HeapFree(GetProcessHeap(), 0, system_info->szLanguagesEnglish);
 95     HeapFree(GetProcessHeap(), 0, system_info->szLanguagesLocalized);
 96     HeapFree(GetProcessHeap(), 0, system_info->szSystemManufacturerEnglish);
 97     HeapFree(GetProcessHeap(), 0, system_info->szSystemModelEnglish);
 98     HeapFree(GetProcessHeap(), 0, system_info->szBIOSEnglish);
 99     HeapFree(GetProcessHeap(), 0, system_info->szProcessorEnglish);
100     HeapFree(GetProcessHeap(), 0, system_info->szPhysicalMemoryEnglish);
101     HeapFree(GetProcessHeap(), 0, system_info->szPageFileEnglish);
102     HeapFree(GetProcessHeap(), 0, system_info->szPageFileLocalized);
103     HeapFree(GetProcessHeap(), 0, system_info->szWindowsDir);
104     HeapFree(GetProcessHeap(), 0, system_info->szDirectXVersionLongEnglish);
105     HeapFree(GetProcessHeap(), 0, system_info->szSetupParamEnglish);
106     HeapFree(GetProcessHeap(), 0, system_info->szDxDiagVersion);
107 }
108 
109 static inline void fill_system_property_list(struct dxdiag_information *dxdiag_info, struct property_list *list)
110 {
111     struct system_information *system_info = &dxdiag_info->system_info;
112 
113     list[0].property_name = szTimeEnglish;
114     list[0].output = &system_info->szTimeEnglish;
115     list[1].property_name = szTimeLocalized;
116     list[1].output = &system_info->szTimeLocalized;
117     list[2].property_name = szMachineNameEnglish;
118     list[2].output = &system_info->szMachineNameEnglish;
119     list[3].property_name = szOSExLongEnglish;
120     list[3].output = &system_info->szOSExLongEnglish;
121     list[4].property_name = szOSExLocalized;
122     list[4].output = &system_info->szOSExLocalized;
123     list[5].property_name = szLanguagesEnglish;
124     list[5].output = &system_info->szLanguagesEnglish;
125     list[6].property_name = szLanguagesLocalized;
126     list[6].output = &system_info->szLanguagesLocalized;
127     list[7].property_name = szSystemManufacturerEnglish;
128     list[7].output = &system_info->szSystemManufacturerEnglish;
129     list[8].property_name = szSystemModelEnglish;
130     list[8].output = &system_info->szSystemModelEnglish;
131     list[9].property_name = szBIOSEnglish;
132     list[9].output = &system_info->szBIOSEnglish;
133     list[10].property_name = szProcessorEnglish;
134     list[10].output = &system_info->szProcessorEnglish;
135     list[11].property_name = szPhysicalMemoryEnglish;
136     list[11].output = &system_info->szPhysicalMemoryEnglish;
137     list[12].property_name = szPageFileEnglish;
138     list[12].output = &system_info->szPageFileEnglish;
139     list[13].property_name = szPageFileLocalized;
140     list[13].output = &system_info->szPageFileLocalized;
141     list[14].property_name = szWindowsDir;
142     list[14].output = &system_info->szWindowsDir;
143     list[15].property_name = szDirectXVersionLongEnglish;
144     list[15].output = &system_info->szDirectXVersionLongEnglish;
145     list[16].property_name = szSetupParamEnglish;
146     list[16].output = &system_info->szSetupParamEnglish;
147     list[17].property_name = szDxDiagVersion;
148     list[17].output = &system_info->szDxDiagVersion;
149 }
150 
151 static BOOL fill_system_information(IDxDiagContainer *container, struct dxdiag_information *dxdiag_info)
152 {
153     struct system_information *system_info = &dxdiag_info->system_info;
154     size_t i;
155     struct property_list property_list[18];
156 
157     fill_system_property_list(dxdiag_info, property_list);
158 
159     for (i = 0; i < sizeof(property_list)/sizeof(property_list[0]); i++)
160     {
161         if (!property_to_string(container, property_list[i].property_name, property_list[i].output))
162         {
163             WINE_ERR("Failed to retrieve property %s\n", wine_dbgstr_w(property_list[i].property_name));
164             return FALSE;
165         }
166     }
167 
168 #ifdef _WIN64
169     system_info->win64 = TRUE;
170 #else
171     system_info->win64 = FALSE;
172 #endif
173 
174     return TRUE;
175 }
176 
177 static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
178 
179 static const struct information_fillers
180 {
181     const WCHAR *child_container_name;
182     BOOL (*fill_function)(IDxDiagContainer *, struct dxdiag_information *);
183     void (*free_function)(struct dxdiag_information *);
184 } filler_list[] =
185 {
186     {DxDiag_SystemInfo, fill_system_information, free_system_information},
187 };
188 
189 void free_dxdiag_information(struct dxdiag_information *system_info)
190 {
191     size_t i;
192 
193     if (!system_info)
194         return;
195 
196     for (i = 0; i < sizeof(filler_list)/sizeof(filler_list[0]); i++)
197         filler_list[i].free_function(system_info);
198 
199     HeapFree(GetProcessHeap(), 0, system_info);
200 }
201 
202 struct dxdiag_information *collect_dxdiag_information(BOOL whql_check)
203 {
204     IDxDiagProvider *pddp = NULL;
205     IDxDiagContainer *root = NULL;
206     struct dxdiag_information *ret = NULL;
207     DXDIAG_INIT_PARAMS params = {sizeof(DXDIAG_INIT_PARAMS), DXDIAG_DX9_SDK_VERSION};
208     HRESULT hr;
209     size_t i;
210 
211     /* Initialize the DxDiag COM instances. */
212     hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
213                           &IID_IDxDiagProvider, (void **)&pddp);
214     if (FAILED(hr))
215     {
216         WINE_ERR("IDxDiagProvider instance creation failed with 0x%08x\n", hr);
217         goto error;
218     }
219 
220     params.bAllowWHQLChecks = whql_check;
221     hr = IDxDiagProvider_Initialize(pddp, &params);
222     if (FAILED(hr))
223         goto error;
224 
225     hr = IDxDiagProvider_GetRootContainer(pddp, &root);
226     if (FAILED(hr))
227         goto error;
228 
229     ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
230     if (!ret)
231         goto error;
232 
233     for (i = 0; i < sizeof(filler_list)/sizeof(filler_list[0]); i++)
234     {
235         IDxDiagContainer *child;
236         BOOL success;
237 
238         hr = IDxDiagContainer_GetChildContainer(root, filler_list[i].child_container_name, &child);
239         if (FAILED(hr))
240             goto error;
241 
242         success = filler_list[i].fill_function(child, ret);
243         IDxDiagContainer_Release(child);
244         if (!success)
245             goto error;
246     }
247 
248     IDxDiagContainer_Release(root);
249     IDxDiagProvider_Release(pddp);
250     return ret;
251 
252 error:
253     free_dxdiag_information(ret);
254     if (root) IDxDiagContainer_Release(root);
255     if (pddp) IDxDiagProvider_Release(pddp);
256     return NULL;
257 }
258 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.