ReactOS  0.4.14-dev-50-g13bb5e2
processor.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Shell Extensions
3  * LICENSE: LGPL - See COPYING in the top level directory
4  * FILE: dll/shellext/devcpux/processor.c
5  * PURPOSE:
6  * COPYRIGHT: Copyright 2007 Christoph von Wittich <Christoph_vW@ReactOS.org>
7  *
8  */
9 
10 #define WIN32_NO_STATUS
11 #define _INC_WINDOWS
12 #define COM_NO_WINDOWS_H
13 #include <stdarg.h>
14 #include <windef.h>
15 #include <winbase.h>
16 #include <winreg.h>
17 #include <winuser.h>
18 #include <setupapi.h>
19 #include <powrprof.h>
20 #include <strsafe.h>
21 
22 #include "resource.h"
23 
26 
27 BOOL
30 {
31  switch (dwReason)
32  {
33  case DLL_THREAD_ATTACH:
34  case DLL_THREAD_DETACH:
35  case DLL_PROCESS_ATTACH:
36  case DLL_PROCESS_DETACH:
37  break;
38  }
39 
41  return TRUE;
42 }
43 
44 
45 BOOL
48 {
50  HPROPSHEETPAGE hPropSheetPage;
51 
52  if(PropPageRequest->PageRequested != SPPSR_ENUM_ADV_DEVICE_PROPERTIES)
53  return FALSE;
54 
55  if ((!PropPageRequest->DeviceInfoSet) || (!PropPageRequest->DeviceInfoData))
56  return FALSE;
57 
59  PropSheetPage.dwSize = sizeof(PROPSHEETPAGE);
60  PropSheetPage.hInstance = g_hInstance;
62  PropSheetPage.pfnDlgProc = ProcessorDlgProc;
63 
64  hPropSheetPage = CreatePropertySheetPage(&PropSheetPage);
65  if(!hPropSheetPage)
66  return FALSE;
67 
68  if(!(fAddFunc)(hPropSheetPage, lParam)) {
69  DestroyPropertySheetPage (hPropSheetPage);
70  return FALSE;
71  }
72 
73  return TRUE;
74 }
75 
76 void
77 AddFeature(WCHAR* szFeatures, size_t cbDest, WCHAR* Feature, BOOL* bFirst)
78 {
79  if (!*bFirst)
80  StringCbCatW(szFeatures, cbDest, L", ");
81  *bFirst = FALSE;
82  StringCbCatW(szFeatures, cbDest, Feature);
83 }
84 
85 INT_PTR
88 {
89  switch (uMessage) {
90  case WM_INITDIALOG:
91  {
92  WCHAR szFeatures[MAX_PATH] = L"";
93  WCHAR szModel[3];
94  WCHAR szStepping[3];
95  WCHAR szMhz[16];
96  WCHAR szCurrentMhz[10];
97  BOOL bFirst = TRUE;
98  SYSTEM_INFO SystemInfo;
100 
101  if (!LoadStringW(g_hInstance, IDS_MEGAHERTZ, szMhz, ARRAYSIZE(szMhz)))
102  {
103  StringCbCopyW(szMhz, sizeof(szMhz), L"%ld MHz");
104  }
105 
107  AddFeature(szFeatures, sizeof(szFeatures), L"MMX", &bFirst);
109  AddFeature(szFeatures, sizeof(szFeatures), L"SSE", &bFirst);
111  AddFeature(szFeatures, sizeof(szFeatures), L"SSE2", &bFirst);
112  /*if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
113  AddFeature(szFeatures, sizeof(szFeatures), L"SSE3", &bFirst); */
115  AddFeature(szFeatures, sizeof(szFeatures), L"3DNOW", &bFirst);
116 
117  SetDlgItemTextW(hDlg, IDC_FEATURES, szFeatures);
118 
119  GetSystemInfo(&SystemInfo);
120 
121  StringCbPrintfW(szModel, sizeof(szModel), L"%x", HIBYTE(SystemInfo.wProcessorRevision));
122  StringCbPrintfW(szStepping, sizeof(szStepping), L"%d", LOBYTE(SystemInfo.wProcessorRevision));
123 
124  SetDlgItemTextW(hDlg, IDC_MODEL, szModel);
125  SetDlgItemTextW(hDlg, IDC_STEPPING, szStepping);
126 
127  CallNtPowerInformation(11, NULL, 0, &PowerInfo, sizeof(PowerInfo));
128  StringCbPrintfW(szCurrentMhz, sizeof(szCurrentMhz), szMhz, PowerInfo.CurrentMhz);
129  SetDlgItemTextW(hDlg, IDC_CORESPEED, szCurrentMhz);
130 
131  return TRUE;
132  }
133  }
134  return FALSE;
135 }
HINSTANCE g_hInstance
Definition: processor.c:24
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDC_STEPPING
Definition: resource.h:7
#define IDC_CORESPEED
Definition: resource.h:8
#define TRUE
Definition: types.h:120
#define LOBYTE(W)
Definition: jmemdos.c:487
#define IDC_FEATURES
Definition: resource.h:5
#define DLL_THREAD_ATTACH
Definition: compat.h:121
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3141
#define IDS_MEGAHERTZ
Definition: resource.h:60
#define CALLBACK
Definition: compat.h:27
#define HIBYTE(W)
Definition: jmemdos.c:486
#define DLG_PROCESSORINFO
Definition: resource.h:3
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ZeroMemory
Definition: winbase.h:1635
BOOL(CALLBACK * LPFNADDPROPSHEETPAGE)(HPROPSHEETPAGE, LPARAM)
Definition: prsht.h:309
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:62
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
WPARAM wParam
Definition: combotst.c:138
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
#define DLL_THREAD_DETACH
Definition: compat.h:122
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
DWORD dwReason
Definition: misc.cpp:154
HINSTANCE hInstance
Definition: charmap.c:20
WORD wProcessorRevision
Definition: winbase.h:1134
PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1099
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSTATUS WINAPI CallNtPowerInformation(POWER_INFORMATION_LEVEL InformationLevel, PVOID lpInputBuffer, ULONG nInputBufferSize, PVOID lpOutputBuffer, ULONG nOutputBufferSize)
Definition: powrprof.c:59
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define PF_XMMI_INSTRUCTIONS_AVAILABLE
smooth NULL
Definition: ftsmooth.c:416
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LONG_PTR LPARAM
Definition: windef.h:208
INT_PTR CALLBACK ProcessorDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
Definition: processor.c:87
#define CreatePropertySheetPage
Definition: prsht.h:381
#define DLL_PROCESS_DETACH
Definition: compat.h:119
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
BOOL APIENTRY DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: processor.c:29
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL APIENTRY PropSheetExtProc(PSP_PROPSHEETPAGE_REQUEST PropPageRequest, LPFNADDPROPSHEETPAGE fAddFunc, LPARAM lParam)
Definition: processor.c:47
HANDLE HINSTANCE
Definition: typedefs.h:75
static const WCHAR L[]
Definition: oid.c:1250
#define SPPSR_ENUM_ADV_DEVICE_PROPERTIES
Definition: setupapi.h:610
BOOL WINAPI IsProcessorFeaturePresent(IN DWORD ProcessorFeature)
Definition: sysinfo.c:168
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:142
unsigned int UINT
Definition: ndis.h:50
void AddFeature(WCHAR *szFeatures, size_t cbDest, WCHAR *Feature, BOOL *bFirst)
Definition: processor.c:77
#define PF_XMMI64_INSTRUCTIONS_AVAILABLE
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
#define PF_3DNOW_INSTRUCTIONS_AVAILABLE
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define PROPSHEETPAGE
Definition: prsht.h:371
#define APIENTRY
Definition: api.h:79
#define IDC_MODEL
Definition: resource.h:6
#define PF_MMX_INSTRUCTIONS_AVAILABLE