ReactOS  0.4.15-dev-1397-g19779b3
misc.cpp File Reference
#include "precomp.h"
#include "properties.h"
#include "resource.h"
Include dependency graph for misc.cpp:

Go to the source code of this file.

Functions

INT LengthOfStrResource (IN HINSTANCE hInst, IN UINT uID)
 
static INT AllocAndLoadString (OUT LPWSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
 
static INT AllocAndLoadStringsCat (OUT LPWSTR *lpTarget, IN HINSTANCE hInst, IN UINT *uID, IN UINT nIDs)
 
DWORD LoadAndFormatString (IN HINSTANCE hInstance, IN UINT uID, OUT LPWSTR *lpTarget,...)
 
DWORD LoadAndFormatStringsCat (IN HINSTANCE hInstance, IN UINT *uID, IN UINT nIDs, OUT LPWSTR *lpTarget,...)
 
LPARAM ListViewGetSelectedItemData (IN HWND hwnd)
 
LPWSTR ConvertMultiByteToUnicode (IN LPCSTR lpMultiByteStr, IN UINT uCodePage)
 
BOOL GetDeviceManufacturerString (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, OUT LPWSTR szBuffer, IN DWORD BufferSize)
 
BOOL GetDeviceLocationString (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, IN DEVINST dnParentDevInst OPTIONAL, OUT LPWSTR szBuffer, IN DWORD BufferSize)
 
BOOL GetDeviceStatusString (IN DEVINST DevInst, IN HMACHINE hMachine, OUT LPWSTR szBuffer, IN DWORD BufferSize)
 
BOOL GetDriverProviderString (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, OUT LPWSTR szBuffer, IN DWORD BufferSize)
 
BOOL GetDriverVersionString (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, OUT LPWSTR szBuffer, IN DWORD BufferSize)
 
BOOL GetDriverDateString (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, OUT LPWSTR szBuffer, IN DWORD BufferSize)
 
BOOL IsDeviceHidden (IN DEVINST DevInst, IN HMACHINE hMachine, OUT BOOL *IsHidden)
 
BOOL CanDisableDevice (IN DEVINST DevInst, IN HMACHINE hMachine, OUT BOOL *CanDisable)
 
BOOL IsDeviceStarted (IN DEVINST DevInst, IN HMACHINE hMachine, OUT BOOL *IsStarted)
 
BOOL IsDriverInstalled (IN DEVINST DevInst, IN HMACHINE hMachine, OUT BOOL *Installed)
 
BOOL EnableDevice (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DevInfoData OPTIONAL, IN BOOL bEnable, IN DWORD HardwareProfile OPTIONAL, OUT BOOL *bNeedReboot OPTIONAL)
 
BOOL GetDeviceTypeString (IN PSP_DEVINFO_DATA DeviceInfoData, OUT LPWSTR szBuffer, IN DWORD BufferSize)
 
BOOL GetDeviceDescriptionString (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, OUT LPWSTR szBuffer, IN DWORD BufferSize)
 
BOOL FindCurrentDriver (IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, OUT PSP_DRVINFO_DATA DriverInfoData)
 
HINSTANCE LoadAndInitComctl32 (VOID)
 
BOOL GetDeviceAndComputerName (LPWSTR lpString, WCHAR szDeviceID[], WCHAR szMachineName[])
 

Function Documentation

◆ AllocAndLoadString()

static INT AllocAndLoadString ( OUT LPWSTR lpTarget,
IN HINSTANCE  hInst,
IN UINT  uID 
)
static

Definition at line 71 of file misc.cpp.

74 {
75  INT ln;
76 
78  uID);
79  if (ln++ > 0)
80  {
81  (*lpTarget) = (LPWSTR)LocalAlloc(LMEM_FIXED,
82  ln * sizeof(WCHAR));
83  if ((*lpTarget) != NULL)
84  {
85  INT Ret;
86  if (!(Ret = LoadStringW(hInst, uID, *lpTarget, ln)))
87  {
88  LocalFree((HLOCAL)(*lpTarget));
89  }
90  return Ret;
91  }
92  }
93  return 0;
94 }
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
#define LMEM_FIXED
Definition: winbase.h:349
INT LengthOfStrResource(IN HINSTANCE hInst, IN UINT uID)
Definition: misc.cpp:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
HINSTANCE hInst
Definition: dxdiag.c:13
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define NULL
Definition: types.h:112
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by LoadAndFormatString().

◆ AllocAndLoadStringsCat()

static INT AllocAndLoadStringsCat ( OUT LPWSTR lpTarget,
IN HINSTANCE  hInst,
IN UINT uID,
IN UINT  nIDs 
)
static

Definition at line 98 of file misc.cpp.

102 {
103  INT ln = 0;
104  UINT i;
105 
106  for (i = 0;
107  i != nIDs;
108  i++)
109  {
111  uID[i]);
112  }
113 
114  if (ln != 0)
115  {
116  (*lpTarget) = (LPWSTR)LocalAlloc(LMEM_FIXED,
117  (ln + 1) * sizeof(WCHAR));
118  if ((*lpTarget) != NULL)
119  {
120  LPWSTR s = *lpTarget;
121  INT Ret = 0;
122 
123  for (i = 0;
124  i != nIDs;
125  i++)
126  {
127  if (!(Ret = LoadStringW(hInst, uID[i], s, ln)))
128  {
129  LocalFree((HLOCAL)(*lpTarget));
130  return 0;
131  }
132 
133  s += Ret;
134  }
135 
136  return s - *lpTarget;
137  }
138  }
139  return 0;
140 }
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
#define LMEM_FIXED
Definition: winbase.h:349
INT LengthOfStrResource(IN HINSTANCE hInst, IN UINT uID)
Definition: misc.cpp:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLdouble s
Definition: gl.h:2039
HINSTANCE hInst
Definition: dxdiag.c:13
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by LoadAndFormatStringsCat().

◆ CanDisableDevice()

BOOL CanDisableDevice ( IN DEVINST  DevInst,
IN HMACHINE  hMachine,
OUT BOOL CanDisable 
)

Definition at line 711 of file misc.cpp.

714 {
715  CONFIGRET cr;
716  ULONG Status, ProblemNumber;
717  BOOL Ret = FALSE;
718 
720  &ProblemNumber,
721  DevInst,
722  0,
723  hMachine);
724  if (cr == CR_SUCCESS)
725  {
726  *CanDisable = ((Status & DN_DISABLEABLE) != 0);
727  Ret = TRUE;
728  }
729 
730  return Ret;
731 }
CONFIGRET WINAPI CM_Get_DevNode_Status_Ex(_Out_ PULONG pulStatus, _Out_ PULONG pulProblemNumber, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:3584
#define TRUE
Definition: types.h:120
#define DN_DISABLEABLE
Definition: cfg.h:131
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CR_SUCCESS
Definition: cfgmgr32.h:842
Status
Definition: gdiplustypes.h:24
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
unsigned int ULONG
Definition: retypes.h:1

Referenced by UpdateDevInfo().

◆ ConvertMultiByteToUnicode()

LPWSTR ConvertMultiByteToUnicode ( IN LPCSTR  lpMultiByteStr,
IN UINT  uCodePage 
)

Definition at line 239 of file misc.cpp.

241 {
242  LPWSTR lpUnicodeStr;
243  INT nLength;
244 
245  nLength = MultiByteToWideChar(uCodePage,
246  0,
247  lpMultiByteStr,
248  -1,
249  NULL,
250  0);
251  if (nLength == 0)
252  return NULL;
253 
254  lpUnicodeStr = (LPWSTR)HeapAlloc(GetProcessHeap(),
255  0,
256  nLength * sizeof(WCHAR));
257  if (lpUnicodeStr == NULL)
258  {
260  return NULL;
261  }
262 
263  if (!MultiByteToWideChar(uCodePage,
264  0,
265  lpMultiByteStr,
266  nLength,
267  lpUnicodeStr,
268  nLength))
269  {
271  0,
272  lpUnicodeStr);
273  return NULL;
274  }
275 
276  return lpUnicodeStr;
277 }
_In_ DWORD nLength
Definition: wincon.h:476
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
int32_t INT
Definition: typedefs.h:58
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:611
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by DeviceAdvancedPropertiesA(), DeviceManager_ExecuteA(), DeviceProblemWizardA(), DeviceProperties_RunDLLA(), and DevicePropertiesExA().

◆ EnableDevice()

BOOL EnableDevice ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA DevInfoData  OPTIONAL,
IN BOOL  bEnable,
IN DWORD HardwareProfile  OPTIONAL,
OUT BOOL *bNeedReboot  OPTIONAL 
)

Definition at line 784 of file misc.cpp.

789 {
792  DWORD LastErr;
793  BOOL Ret = FALSE;
794 
797  pcp.HwProfile = HardwareProfile;
798 
799  if (bEnable)
800  {
801  /* try to enable the device on the global profile */
802  pcp.StateChange = DICS_ENABLE;
803  pcp.Scope = DICS_FLAG_GLOBAL;
804 
805  /* ignore errors */
806  LastErr = GetLastError();
808  DevInfoData,
809  &pcp.ClassInstallHeader,
810  sizeof(SP_PROPCHANGE_PARAMS)))
811  {
814  DevInfoData);
815  }
816  SetLastError(LastErr);
817  }
818 
819  /* try config-specific */
822 
824  DevInfoData,
825  &pcp.ClassInstallHeader,
826  sizeof(SP_PROPCHANGE_PARAMS)) &&
829  DevInfoData))
830  {
831  dp.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
833  DevInfoData,
834  &dp))
835  {
836  if (bNeedReboot != NULL)
837  {
838  *bNeedReboot = ((dp.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT)) != 0);
839  }
840 
841  Ret = TRUE;
842  }
843  }
844  return Ret;
845 }
#define DI_NEEDREBOOT
Definition: setupapi.h:54
#define TRUE
Definition: types.h:120
#define SetupDiGetDeviceInstallParams
Definition: setupapi.h:2594
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION InstallFunction, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData)
Definition: devinst.c:4029
#define DIF_PROPERTYCHANGE
Definition: setupapi.h:137
#define DICS_ENABLE
Definition: setupapi.h:112
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DICS_DISABLE
Definition: setupapi.h:114
SP_CLASSINSTALL_HEADER ClassInstallHeader
Definition: setupapi.h:911
#define DICS_FLAG_CONFIGSPECIFIC
Definition: setupapi.h:115
unsigned long DWORD
Definition: ntddk_ex.h:95
SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS
Definition: setupapi.h:1150
#define SetLastError(x)
Definition: compat.h:611
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
_In_ BOOL bEnable
Definition: winddi.h:3426
#define NULL
Definition: types.h:112
struct _SP_CLASSINSTALL_HEADER SP_CLASSINSTALL_HEADER
#define DI_NEEDRESTART
Definition: setupapi.h:53
#define SetupDiSetClassInstallParams
Definition: setupapi.h:2612
DI_FUNCTION InstallFunction
Definition: setupapi.h:899

Referenced by ApplyGeneralSettings().

◆ FindCurrentDriver()

BOOL FindCurrentDriver ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
OUT PSP_DRVINFO_DATA  DriverInfoData 
)

Definition at line 924 of file misc.cpp.

927 {
929  SP_DEVINSTALL_PARAMS InstallParams = {0};
930  SP_DRVINFO_DETAIL_DATA DriverInfoDetailData = {0};
931  WCHAR InfPath[MAX_PATH];
932  WCHAR InfSection[LINE_LEN];
933  DWORD dwType, dwLength;
934  DWORD i = 0;
935  LONG rc;
936  BOOL Ret = FALSE;
937 
938  /* Steps to find the right driver:
939  * 1) Get the device install parameters
940  * 2) Open the driver registry key
941  * 3) Read the .inf file name
942  * 4) Update install params, by setting DI_ENUMSINGLEINF and .inf file name
943  * 5) Build class driver list
944  * 6) Read inf section and inf section extension from registry
945  * 7) Enumerate drivers
946  * 8) Find the one who is in the same section as current driver?
947  */
948 
949  /* 1) Get the install params */
950  InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
953  &InstallParams))
954  {
955  ERR("SetupDiSetDeviceInstallParams() failed with error 0x%lx\n", GetLastError());
956  goto Cleanup;
957  }
958 
959 #ifdef DI_FLAGSEX_INSTALLEDDRIVER
960  InstallParams.FlagsEx |= (DI_FLAGSEX_INSTALLEDDRIVER | DI_FLAGSEX_ALLOWEXCLUDEDDRVS);
963  &InstallParams))
964  {
971  0,
972  DriverInfoData))
973  {
974  Ret = TRUE;
975  }
976 
977  goto Cleanup;
978  }
979  InstallParams.FlagsEx &= ~(DI_FLAGSEX_INSTALLEDDRIVER | DI_FLAGSEX_ALLOWEXCLUDEDDRVS);
980 #endif
981 
982  /* 2) Open the driver registry key */
986  0,
987  DIREG_DRV,
989  if (hKey == INVALID_HANDLE_VALUE)
990  {
991  ERR("SetupDiOpenDevRegKey() failed with error 0x%lx\n", GetLastError());
992  goto Cleanup;
993  }
994 
995  /* 3) Read the .inf file name */
996  dwLength = (sizeof(InfPath) / sizeof(InfPath[0])) - 1;
997  rc = RegQueryValueEx(hKey,
999  0,
1000  &dwType,
1001  (LPBYTE)InfPath,
1002  &dwLength);
1003  if (rc != ERROR_SUCCESS)
1004  {
1005  ERR("RegQueryValueEx() failed with error 0x%lx\n", GetLastError());
1006  SetLastError(rc);
1007  goto Cleanup;
1008  }
1009  else if (dwType != REG_SZ)
1010  {
1011  ERR("Expected registry type REG_SZ (%lu), got %lu\n", REG_SZ, dwType);
1013  goto Cleanup;
1014  }
1015  InfPath[(dwLength / sizeof(WCHAR)) - 1] = L'\0';
1016 
1017  /* 4) Update install params, by setting DI_ENUMSINGLEINF and .inf file name */
1018  InstallParams.Flags |= DI_ENUMSINGLEINF;
1019  InstallParams.FlagsEx |= DI_FLAGSEX_ALLOWEXCLUDEDDRVS;
1020  wcscpy(InstallParams.DriverPath, InfPath);
1023  &InstallParams))
1024  {
1025  ERR("SetupDiSetDeviceInstallParams() failed with error 0x%lx\n", GetLastError());
1026  goto Cleanup;
1027  }
1028 
1029  /* 5) Build class driver list */
1033  {
1034  ERR("SetupDiBuildDriverInfoList() failed with error 0x%lx\n", GetLastError());
1035  goto Cleanup;
1036  }
1037 
1038  /* 6) Read inf section and from registry */
1039  dwLength = (sizeof(InfSection) / sizeof(InfSection[0])) - 1;
1040  rc = RegQueryValueEx(hKey,
1042  0,
1043  &dwType,
1044  (LPBYTE)InfSection,
1045  &dwLength);
1046  if (rc != ERROR_SUCCESS)
1047  {
1048  ERR("RegQueryValueEx() failed with error 0x%lx\n", GetLastError());
1049  SetLastError(rc);
1050  goto Cleanup;
1051  }
1052  else if (dwType != REG_SZ)
1053  {
1054  ERR("Expected registry type REG_SZ (%lu), got %lu\n", REG_SZ, dwType);
1056  goto Cleanup;
1057  }
1058  InfPath[(dwLength / sizeof(WCHAR)) - 1] = L'\0';
1059 
1060  /* 7) Enumerate drivers */
1061  DriverInfoData->cbSize = sizeof(SP_DRVINFO_DATA);
1062  DriverInfoDetailData.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);
1066  i,
1067  DriverInfoData))
1068  {
1069  /* 8) Find the one who is in the same section as current driver */
1072  DriverInfoData,
1073  &DriverInfoDetailData,
1074  DriverInfoDetailData.cbSize,
1075  NULL) &&
1077  {
1078  ERR("SetupDiGetDriverInfoDetail() failed with error 0x%lx\n", GetLastError());
1079  goto Cleanup;
1080  }
1081  if (_wcsicmp(DriverInfoDetailData.SectionName, InfSection) == 0)
1082  {
1083  /* We have found the right driver */
1084  Ret = TRUE;
1085  goto Cleanup;
1086  }
1087 
1088  i++;
1089  }
1091  {
1092  ERR("SetupDiEnumDriverInfo() failed with error 0x%lx\n", GetLastError());
1093  goto Cleanup;
1094  }
1095 
1097 
1098 Cleanup:
1099  if (hKey != INVALID_HANDLE_VALUE)
1100  RegCloseKey(hKey);
1101  return Ret;
1102 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define SetupDiEnumDriverInfo
Definition: setupapi.h:2582
#define TRUE
Definition: types.h:120
#define SetupDiGetDeviceInstallParams
Definition: setupapi.h:2594
#define REGSTR_VAL_INFPATH
Definition: regstr.h:439
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define DI_FLAGSEX_ALLOWEXCLUDEDDRVS
Definition: setupapi.h:87
CHAR SectionName[LINE_LEN]
Definition: setupapi.h:1060
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
SP_DRVINFO_DETAIL_DATA_A SP_DRVINFO_DETAIL_DATA
Definition: setupapi.h:1157
CHAR DriverPath[MAX_PATH]
Definition: setupapi.h:883
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:85
#define LINE_LEN
Definition: setupapi.h:20
#define SetupDiSetDeviceInstallParams
Definition: setupapi.h:2614
#define MAX_PATH
Definition: compat.h:34
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
unsigned long DWORD
Definition: ntddk_ex.h:95
SP_DEVINSTALL_PARAMS_A SP_DEVINSTALL_PARAMS
Definition: setupapi.h:1150
#define SetLastError(x)
Definition: compat.h:611
#define ERROR_NO_DRIVER_SELECTED
Definition: setupapi.h:294
SP_DRVINFO_DATA_V2 SP_DRVINFO_DATA
Definition: setupapi.h:1049
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5935
static const WCHAR Cleanup[]
Definition: register.c:80
#define SetupDiGetDriverInfoDetail
Definition: setupapi.h:2599
#define ERR(fmt,...)
Definition: debug.h:110
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
#define REGSTR_VAL_INFSECTION
Definition: regstr.h:440
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
#define DI_ENUMSINGLEINF
Definition: setupapi.h:62
BOOL WINAPI SetupDiBuildDriverInfoList(IN HDEVINFO DeviceInfoSet, IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN DWORD DriverType)
Definition: driver.c:718
#define DIREG_DRV
Definition: setupapi.h:182
HANDLE HKEY
Definition: registry.h:24
#define SPDIT_CLASSDRIVER
Definition: setupapi.h:500
#define ERROR_GEN_FAILURE
Definition: winerror.h:134
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22

Referenced by UpdateDriverDetailsDlg().

◆ GetDeviceAndComputerName()

BOOL GetDeviceAndComputerName ( LPWSTR  lpString,
WCHAR  szDeviceID[],
WCHAR  szMachineName[] 
)

Definition at line 1132 of file misc.cpp.

1135 {
1136  BOOL ret = FALSE;
1137 
1138  szDeviceID[0] = L'\0';
1139  szMachineName[0] = L'\0';
1140 
1141  while (*lpString != L'\0')
1142  {
1143  if (*lpString == L'/')
1144  {
1145  lpString++;
1146  if (!_wcsnicmp(lpString, L"DeviceID", 8))
1147  {
1148  lpString += 9;
1149  if (*lpString != L'\0')
1150  {
1151  int i = 0;
1152  while ((*lpString != L' ') &&
1153  (*lpString != L'\0') &&
1154  (i <= MAX_DEVICE_ID_LEN))
1155  {
1156  szDeviceID[i++] = *lpString++;
1157  }
1158  szDeviceID[i] = L'\0';
1159  ret = TRUE;
1160  }
1161  }
1162  else if (!_wcsnicmp(lpString, L"MachineName", 11))
1163  {
1164  lpString += 12;
1165  if (*lpString != L'\0')
1166  {
1167  int i = 0;
1168  while ((*lpString != L' ') &&
1169  (*lpString != L'\0') &&
1171  {
1172  szMachineName[i++] = *lpString++;
1173  }
1174  szMachineName[i] = L'\0';
1175  }
1176  }
1177  /* knock the pointer back one and let the next
1178  * pointer deal with incrementing, otherwise we
1179  * go past the end of the string */
1180  lpString--;
1181  }
1182  lpString++;
1183  }
1184 
1185  return ret;
1186 }
#define TRUE
Definition: types.h:120
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:39
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by DeviceProperties_RunDLLW().

◆ GetDeviceDescriptionString()

BOOL GetDeviceDescriptionString ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
OUT LPWSTR  szBuffer,
IN DWORD  BufferSize 
)

Definition at line 880 of file misc.cpp.

884 {
885  DWORD RegDataType;
886  BOOL Ret = FALSE;
887 
891  &RegDataType,
892  (PBYTE)szBuffer,
893  BufferSize * sizeof(WCHAR),
894  NULL) ||
898  &RegDataType,
899  (PBYTE)szBuffer,
900  BufferSize * sizeof(WCHAR),
901  NULL)) &&
902  RegDataType == REG_SZ)
903  {
904  /* FIXME - check string for NULL termination! */
905  Ret = TRUE;
906  }
907  else
908  {
909  szBuffer[0] = L'\0';
912  szBuffer,
913  BufferSize))
914  {
915  Ret = TRUE;
916  }
917  }
918 
919  return Ret;
920 }
#define TRUE
Definition: types.h:120
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2598
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static HINSTANCE hDllInstance
Definition: clb.c:30
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
#define SPDRP_FRIENDLYNAME
Definition: setupapi.h:514
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define SPDRP_DEVICEDESC
Definition: setupapi.h:502
#define IDS_UNKNOWNDEVICE
Definition: resource.h:112
#define NULL
Definition: types.h:112
BYTE * PBYTE
Definition: pedump.c:66
#define LoadString
Definition: winuser.h:5794
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define REG_SZ
Definition: layer.c:22

Referenced by FillDevicesListViewControl(), and UpdateDevInfo().

◆ GetDeviceLocationString()

BOOL GetDeviceLocationString ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
IN DEVINST dnParentDevInst  OPTIONAL,
OUT LPWSTR  szBuffer,
IN DWORD  BufferSize 
)

Definition at line 318 of file misc.cpp.

323 {
324  DWORD RegDataType;
325  ULONG DataSize;
326  CONFIGRET cRet;
327  LPWSTR szFormatted;
328  HKEY hKey;
329  DWORD dwSize, dwType;
330  BOOL Ret = FALSE;
331 
332  DataSize = BufferSize * sizeof(WCHAR);
333  szBuffer[0] = L'\0';
334 
338  0,
339  DIREG_DRV,
341  if (hKey != INVALID_HANDLE_VALUE)
342  {
343  /* query the LocationInformationOverride value */
344  dwSize = BufferSize;
345  if (RegQueryValueEx(hKey,
346  L"LocationInformationOverride",
347  NULL,
348  &dwType,
349  (LPBYTE)szBuffer,
350  &dwSize) == ERROR_SUCCESS &&
351  dwType == REG_SZ &&
352  szBuffer[0] != L'\0')
353  {
354  Ret = TRUE;
355  }
356  else
357  {
358  szBuffer[0] = L'\0';
359  }
360 
361  RegCloseKey(hKey);
362  }
363 
364 
365  if (!Ret)
366  {
367  if (dnParentDevInst != 0)
368  {
369  /* query the parent node name */
370  if (CM_Get_DevNode_Registry_Property(dnParentDevInst,
372  &RegDataType,
373  szBuffer,
374  &DataSize,
375  0) == CR_SUCCESS &&
376  RegDataType == REG_SZ &&
379  &szFormatted,
380  szBuffer) != 0)
381  {
382  wcsncpy(szBuffer,
383  szFormatted,
384  BufferSize - 1);
385  szBuffer[BufferSize - 1] = L'\0';
386  LocalFree((HLOCAL)szFormatted);
387  Ret = TRUE;
388  }
389  }
390  else if (DeviceInfoData->DevInst != 0)
391  {
394  &RegDataType,
395  szBuffer,
396  &DataSize,
397  0);
398  if (cRet == CR_SUCCESS && RegDataType == REG_SZ)
399  {
400  /* FIXME - check string for NULL termination! */
401  Ret = TRUE;
402  }
403 
404  if (Ret && szBuffer[0] >= L'0' && szBuffer[0] <= L'9')
405  {
406  /* convert the string to an integer value and create a
407  formatted string */
408  ULONG ulLocation = (ULONG)wcstoul(szBuffer,
409  NULL,
410  10);
413  &szFormatted,
414  ulLocation,
415  szBuffer) != 0)
416  {
417  wcsncpy(szBuffer,
418  szFormatted,
419  BufferSize - 1);
420  szBuffer[BufferSize - 1] = L'\0';
421  LocalFree((HLOCAL)szFormatted);
422  }
423  else
424  Ret = FALSE;
425  }
426  }
427  }
428 
429  if (!Ret &&
431  IDS_UNKNOWN,
432  szBuffer,
433  BufferSize))
434  {
435  Ret = TRUE;
436  }
437 
438  return Ret;
439 }
#define RegQueryValueEx
Definition: winreg.h:524
#define CM_Get_DevNode_Registry_Property
Definition: cfgmgr32.h:1733
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define IDS_LOCATIONSTR
Definition: resource.h:107
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define IDS_UNKNOWN
Definition: resource.h:7
static HINSTANCE hDllInstance
Definition: clb.c:30
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CM_DRP_LOCATION_INFORMATION
Definition: cfgmgr32.h:689
#define IDS_DEVONPARENT
Definition: resource.h:114
static const WCHAR L[]
Definition: oid.c:1250
#define CM_DRP_DEVICEDESC
Definition: cfgmgr32.h:676
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5935
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
FxAutoRegKey hKey
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
DWORD LoadAndFormatString(IN HINSTANCE hInstance, IN UINT uID, OUT LPWSTR *lpTarget,...)
Definition: misc.cpp:144
#define DIREG_DRV
Definition: setupapi.h:182
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define LoadString
Definition: winuser.h:5794
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define REG_SZ
Definition: layer.c:22

Referenced by UpdateControlStates(), and UpdateDevInfo().

◆ GetDeviceManufacturerString()

BOOL GetDeviceManufacturerString ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
OUT LPWSTR  szBuffer,
IN DWORD  BufferSize 
)

Definition at line 281 of file misc.cpp.

285 {
286  DWORD RegDataType;
287  BOOL Ret = FALSE;
288 
291  SPDRP_MFG,
292  &RegDataType,
293  (PBYTE)szBuffer,
294  BufferSize * sizeof(WCHAR),
295  NULL) ||
296  RegDataType != REG_SZ)
297  {
298  szBuffer[0] = L'\0';
300  IDS_UNKNOWN,
301  szBuffer,
302  BufferSize))
303  {
304  Ret = TRUE;
305  }
306  }
307  else
308  {
309  /* FIXME - check string for NULL termination! */
310  Ret = TRUE;
311  }
312 
313  return Ret;
314 }
#define SPDRP_MFG
Definition: setupapi.h:513
#define TRUE
Definition: types.h:120
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2598
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDS_UNKNOWN
Definition: resource.h:7
static HINSTANCE hDllInstance
Definition: clb.c:30
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
BYTE * PBYTE
Definition: pedump.c:66
#define LoadString
Definition: winuser.h:5794
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define REG_SZ
Definition: layer.c:22

Referenced by UpdateControlStates(), and UpdateDevInfo().

◆ GetDeviceStatusString()

BOOL GetDeviceStatusString ( IN DEVINST  DevInst,
IN HMACHINE  hMachine,
OUT LPWSTR  szBuffer,
IN DWORD  BufferSize 
)

Definition at line 443 of file misc.cpp.

447 {
448  CONFIGRET cr;
449  ULONG Status, ProblemNumber;
450  UINT MessageId = IDS_UNKNOWN;
451  BOOL Ret = FALSE;
452 
453  szBuffer[0] = L'\0';
455  &ProblemNumber,
456  DevInst,
457  0,
458  hMachine);
459  if (cr == CR_SUCCESS)
460  {
461  if (Status & DN_HAS_PROBLEM)
462  {
463  UINT uRet;
464 
465  uRet = DeviceProblemTextW(hMachine,
466  DevInst,
467  ProblemNumber,
468  szBuffer,
469  (BufferSize != 0 ? BufferSize : BufferSize - 1));
470 
471  Ret = (uRet != 0 && uRet < BufferSize);
472  }
473  else
474  {
475  if (!(Status & (DN_DRIVER_LOADED | DN_STARTED)))
476  {
477  MessageId = IDS_NODRIVERLOADED;
478  }
479  else
480  {
481  MessageId = IDS_DEV_NO_PROBLEM;
482  }
483 
484  goto GeneralMessage;
485  }
486  }
487  else
488  {
489 GeneralMessage:
491  MessageId,
492  szBuffer,
493  (int)BufferSize))
494  {
495  Ret = TRUE;
496  }
497  }
498 
499  return Ret;
500 }
CONFIGRET WINAPI CM_Get_DevNode_Status_Ex(_Out_ PULONG pulStatus, _Out_ PULONG pulProblemNumber, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:3584
#define TRUE
Definition: types.h:120
#define DN_DRIVER_LOADED
Definition: cfg.h:119
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CR_SUCCESS
Definition: cfgmgr32.h:842
UINT WINAPI DeviceProblemTextW(IN HMACHINE hMachine OPTIONAL, IN DEVINST dnDevInst, IN ULONG uProblemId, OUT LPWSTR lpString, IN UINT uMaxString)
Definition: devprblm.cpp:491
#define IDS_UNKNOWN
Definition: resource.h:7
static HINSTANCE hDllInstance
Definition: clb.c:30
Status
Definition: gdiplustypes.h:24
#define IDS_NODRIVERLOADED
Definition: resource.h:113
#define DN_HAS_PROBLEM
Definition: cfg.h:128
static const WCHAR L[]
Definition: oid.c:1250
unsigned int UINT
Definition: ndis.h:50
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DN_STARTED
Definition: cfg.h:121
unsigned int ULONG
Definition: retypes.h:1
#define IDS_DEV_NO_PROBLEM
Definition: resource.h:131
#define LoadString
Definition: winuser.h:5794
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by UpdateControlStates(), and UpdateDevInfo().

◆ GetDeviceTypeString()

BOOL GetDeviceTypeString ( IN PSP_DEVINFO_DATA  DeviceInfoData,
OUT LPWSTR  szBuffer,
IN DWORD  BufferSize 
)

Definition at line 849 of file misc.cpp.

852 {
853  BOOL Ret = FALSE;
854 
856  szBuffer,
857  BufferSize,
858  NULL))
859  {
860  szBuffer[0] = L'\0';
862  IDS_UNKNOWN,
863  szBuffer,
864  BufferSize))
865  {
866  Ret = TRUE;
867  }
868  }
869  else
870  {
871  /* FIXME - check string for NULL termination! */
872  Ret = TRUE;
873  }
874 
875  return Ret;
876 }
#define SetupDiGetClassDescription
Definition: setupapi.h:2585
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDS_UNKNOWN
Definition: resource.h:7
static HINSTANCE hDllInstance
Definition: clb.c:30
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
#define LoadString
Definition: winuser.h:5794
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by FillDevicesListViewControl(), and UpdateDevInfo().

◆ GetDriverDateString()

BOOL GetDriverDateString ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
OUT LPWSTR  szBuffer,
IN DWORD  BufferSize 
)

Definition at line 619 of file misc.cpp.

623 {
624  HKEY hKey;
625  FILETIME DriverDate;
626  SYSTEMTIME SystemTime, LocalTime;
627  DWORD dwSize, dwType;
628  BOOL Ret = FALSE;
629 
630  szBuffer[0] = L'\0';
631 
632  /* get driver provider, date and version */
636  0,
637  DIREG_DRV,
639  if (hKey != INVALID_HANDLE_VALUE)
640  {
641  /* query the driver provider */
642  dwSize = sizeof(FILETIME);
643  if (RegQueryValueEx(hKey,
644  L"DriverDateData",
645  NULL,
646  &dwType,
647  (LPBYTE)&DriverDate,
648  &dwSize) == ERROR_SUCCESS &&
649  dwType == REG_BINARY &&
650  dwSize == sizeof(FILETIME) &&
651  FileTimeToSystemTime(&DriverDate,
652  &SystemTime) &&
654  &SystemTime,
655  &LocalTime) &&
658  &LocalTime,
659  NULL,
660  szBuffer,
661  BufferSize) != 0)
662  {
663  Ret = TRUE;
664  }
665 
666  RegCloseKey(hKey);
667  }
668 
669  if (!Ret)
670  {
671  /* unable to query the information */
674  szBuffer,
675  BufferSize))
676  {
677  Ret = TRUE;
678  }
679  }
680 
681  return Ret;
682 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define REG_BINARY
Definition: nt_native.h:1496
#define TRUE
Definition: types.h:120
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:193
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
BOOL WINAPI SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime)
Definition: timezone.c:377
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static HINSTANCE hDllInstance
Definition: clb.c:30
struct _FILETIME FILETIME
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDS_NOTAVAILABLE
Definition: resource.h:121
static const WCHAR L[]
Definition: oid.c:1250
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5935
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
FxAutoRegKey hKey
#define GetDateFormat
Definition: winnls.h:1181
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
#define DIREG_DRV
Definition: setupapi.h:182
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define LoadString
Definition: winuser.h:5794
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by UpdateDriverDlg().

◆ GetDriverProviderString()

BOOL GetDriverProviderString ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
OUT LPWSTR  szBuffer,
IN DWORD  BufferSize 
)

Definition at line 504 of file misc.cpp.

508 {
509  HKEY hKey;
510  DWORD dwSize, dwType;
511  BOOL Ret = FALSE;
512 
513  szBuffer[0] = L'\0';
514 
515  /* get driver provider, date and version */
519  0,
520  DIREG_DRV,
522  if (hKey != INVALID_HANDLE_VALUE)
523  {
524  /* query the driver provider */
525  dwSize = BufferSize;
526  if (RegQueryValueEx(hKey,
528  NULL,
529  &dwType,
530  (LPBYTE)szBuffer,
531  &dwSize) == ERROR_SUCCESS &&
532  dwType == REG_SZ &&
533  szBuffer[0] != L'\0')
534  {
535  Ret = TRUE;
536  }
537  else
538  {
539  szBuffer[0] = L'\0';
540  }
541 
542  RegCloseKey(hKey);
543  }
544 
545  if (szBuffer[0] == L'\0')
546  {
547  /* unable to query the information */
549  IDS_UNKNOWN,
550  szBuffer,
551  BufferSize))
552  {
553  Ret = TRUE;
554  }
555  }
556 
557  return Ret;
558 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDS_UNKNOWN
Definition: resource.h:7
static HINSTANCE hDllInstance
Definition: clb.c:30
#define REGSTR_VAL_PROVIDER_NAME
Definition: regstr.h:540
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5935
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
#define DIREG_DRV
Definition: setupapi.h:182
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define LoadString
Definition: winuser.h:5794
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define REG_SZ
Definition: layer.c:22

Referenced by UpdateDriverDlg().

◆ GetDriverVersionString()

BOOL GetDriverVersionString ( IN HDEVINFO  DeviceInfoSet,
IN PSP_DEVINFO_DATA  DeviceInfoData,
OUT LPWSTR  szBuffer,
IN DWORD  BufferSize 
)

Definition at line 562 of file misc.cpp.

566 {
567  HKEY hKey;
568  DWORD dwSize, dwType;
569  BOOL Ret = FALSE;
570 
571  szBuffer[0] = L'\0';
572 
573  /* get driver provider, date and version */
577  0,
578  DIREG_DRV,
580  if (hKey != INVALID_HANDLE_VALUE)
581  {
582  /* query the driver provider */
583  dwSize = BufferSize;
584  if (RegQueryValueEx(hKey,
585  L"DriverVersion",
586  NULL,
587  &dwType,
588  (LPBYTE)szBuffer,
589  &dwSize) == ERROR_SUCCESS &&
590  dwType == REG_SZ &&
591  szBuffer[0] != L'\0')
592  {
593  Ret = TRUE;
594  }
595  else
596  {
597  szBuffer[0] = L'\0';
598  }
599 
600  RegCloseKey(hKey);
601  }
602 
603  if (szBuffer[0] == L'\0')
604  {
605  /* unable to query the information */
608  szBuffer,
609  BufferSize))
610  {
611  Ret = TRUE;
612  }
613  }
614 
615  return Ret;
616 }
#define RegQueryValueEx
Definition: winreg.h:524
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static HINSTANCE hDllInstance
Definition: clb.c:30
_In_opt_ PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1523
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDS_NOTAVAILABLE
Definition: resource.h:121
static const WCHAR L[]
Definition: oid.c:1250
HKEY WINAPI SetupDiOpenDevRegKey(HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired)
Definition: devinst.c:5935
#define DICS_FLAG_GLOBAL
Definition: setupapi.h:113
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
#define DIREG_DRV
Definition: setupapi.h:182
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define LoadString
Definition: winuser.h:5794
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define REG_SZ
Definition: layer.c:22

Referenced by UpdateDriverDlg().

◆ IsDeviceHidden()

BOOL IsDeviceHidden ( IN DEVINST  DevInst,
IN HMACHINE  hMachine,
OUT BOOL IsHidden 
)

Definition at line 687 of file misc.cpp.

690 {
691  CONFIGRET cr;
692  ULONG Status, ProblemNumber;
693  BOOL Ret = FALSE;
694 
696  &ProblemNumber,
697  DevInst,
698  0,
699  hMachine);
700  if (cr == CR_SUCCESS)
701  {
702  *IsHidden = ((Status & DN_NO_SHOW_IN_DM) != 0);
703  Ret = TRUE;
704  }
705 
706  return Ret;
707 }
CONFIGRET WINAPI CM_Get_DevNode_Status_Ex(_Out_ PULONG pulStatus, _Out_ PULONG pulProblemNumber, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:3584
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define DN_NO_SHOW_IN_DM
Definition: cfg.h:148
Status
Definition: gdiplustypes.h:24
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
unsigned int ULONG
Definition: retypes.h:1

Referenced by BuildDevicesList().

◆ IsDeviceStarted()

BOOL IsDeviceStarted ( IN DEVINST  DevInst,
IN HMACHINE  hMachine,
OUT BOOL IsStarted 
)

Definition at line 735 of file misc.cpp.

738 {
739  CONFIGRET cr;
740  ULONG Status, ProblemNumber;
741  BOOL Ret = FALSE;
742 
744  &ProblemNumber,
745  DevInst,
746  0,
747  hMachine);
748  if (cr == CR_SUCCESS)
749  {
750  *IsStarted = ((Status & DN_STARTED) != 0);
751  Ret = TRUE;
752  }
753 
754  return Ret;
755 }
CONFIGRET WINAPI CM_Get_DevNode_Status_Ex(_Out_ PULONG pulStatus, _Out_ PULONG pulProblemNumber, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:3584
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CR_SUCCESS
Definition: cfgmgr32.h:842
Status
Definition: gdiplustypes.h:24
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DN_STARTED
Definition: cfg.h:121
unsigned int ULONG
Definition: retypes.h:1

Referenced by UpdateDevInfo().

◆ IsDriverInstalled()

BOOL IsDriverInstalled ( IN DEVINST  DevInst,
IN HMACHINE  hMachine,
OUT BOOL Installed 
)

Definition at line 759 of file misc.cpp.

762 {
763  CONFIGRET cr;
764  ULONG Status, ProblemNumber;
765  BOOL Ret = FALSE;
766 
768  &ProblemNumber,
769  DevInst,
770  0,
771  hMachine);
772  if (cr == CR_SUCCESS)
773  {
774  *Installed = ((Status & DN_HAS_PROBLEM) != 0 ||
775  (Status & (DN_DRIVER_LOADED | DN_STARTED)) != 0);
776  Ret = TRUE;
777  }
778 
779  return Ret;
780 }
CONFIGRET WINAPI CM_Get_DevNode_Status_Ex(_Out_ PULONG pulStatus, _Out_ PULONG pulProblemNumber, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags, _In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:3584
#define TRUE
Definition: types.h:120
#define DN_DRIVER_LOADED
Definition: cfg.h:119
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CR_SUCCESS
Definition: cfgmgr32.h:842
Status
Definition: gdiplustypes.h:24
#define DN_HAS_PROBLEM
Definition: cfg.h:128
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DN_STARTED
Definition: cfg.h:121
unsigned int ULONG
Definition: retypes.h:1

Referenced by UpdateDevInfo().

◆ LengthOfStrResource()

INT LengthOfStrResource ( IN HINSTANCE  hInst,
IN UINT  uID 
)

Definition at line 34 of file misc.cpp.

36 {
37  HRSRC hrSrc;
38  HGLOBAL hRes;
39  LPWSTR lpName, lpStr;
40 
41  if (hInst == NULL)
42  {
43  return -1;
44  }
45 
46  /* There are always blocks of 16 strings */
47  lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
48 
49  /* Find the string table block */
50  if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
51  (hRes = LoadResource(hInst, hrSrc)) &&
52  (lpStr = (LPWSTR)LockResource(hRes)))
53  {
54  UINT x;
55 
56  /* Find the string we're looking for */
57  uID &= 0xF; /* position in the block, same as % 16 */
58  for (x = 0; x < uID; x++)
59  {
60  lpStr += (*lpStr) + 1;
61  }
62 
63  /* Found the string */
64  return (int)(*lpStr);
65  }
66  return -1;
67 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
_In_ LPCSTR lpName
Definition: winbase.h:2752
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
#define RT_STRING
Definition: pedump.c:368
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AllocAndLoadString(), and AllocAndLoadStringsCat().

◆ ListViewGetSelectedItemData()

LPARAM ListViewGetSelectedItemData ( IN HWND  hwnd)

Definition at line 212 of file misc.cpp.

213 {
214  int Index;
215 
217  -1,
218  LVNI_SELECTED);
219  if (Index != -1)
220  {
221  LVITEM li;
222 
223  li.mask = LVIF_PARAM;
224  li.iItem = Index;
225  li.iSubItem = 0;
226 
228  &li))
229  {
230  return li.lParam;
231  }
232  }
233 
234  return 0;
235 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2430
#define LVNI_SELECTED
Definition: commctrl.h:2420
_In_ WDFCOLLECTION _In_ ULONG Index
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2390
#define LVIF_PARAM
Definition: commctrl.h:2307
#define LVITEM
Definition: commctrl.h:2371
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235

◆ LoadAndFormatString()

DWORD LoadAndFormatString ( IN HINSTANCE  hInstance,
IN UINT  uID,
OUT LPWSTR lpTarget,
  ... 
)

Definition at line 144 of file misc.cpp.

148 {
149  DWORD Ret = 0;
151  va_list lArgs;
152 
154  hInstance,
155  uID) != 0)
156  {
157  va_start(lArgs, lpTarget);
158  /* let's use FormatMessage to format it because it has the ability to allocate
159  memory automatically */
161  lpFormat,
162  0,
163  0,
164  (LPWSTR)lpTarget,
165  0,
166  &lArgs);
167  va_end(lArgs);
168 
170  }
171 
172  return Ret;
173 }
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:402
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
HINSTANCE hInstance
Definition: charmap.c:20
#define va_end(ap)
Definition: acmsvcex.h:90
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
char * va_list
Definition: acmsvcex.h:78
unsigned long DWORD
Definition: ntddk_ex.h:95
va_start(ap, x)
LPCWSTR lpFormat
Definition: trayclock.cpp:32
static INT AllocAndLoadString(OUT LPWSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.cpp:71
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by GetDeviceLocationString().

◆ LoadAndFormatStringsCat()

DWORD LoadAndFormatStringsCat ( IN HINSTANCE  hInstance,
IN UINT uID,
IN UINT  nIDs,
OUT LPWSTR lpTarget,
  ... 
)

Definition at line 177 of file misc.cpp.

182 {
183  DWORD Ret = 0;
185  va_list lArgs;
186 
188  hInstance,
189  uID,
190  nIDs) != 0)
191  {
192  va_start(lArgs, lpTarget);
193  /* let's use FormatMessage to format it because it has the ability to allocate
194  memory automatically */
196  lpFormat,
197  0,
198  0,
199  (LPWSTR)lpTarget,
200  0,
201  &lArgs);
202  va_end(lArgs);
203 
205  }
206 
207  return Ret;
208 }
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:402
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
HINSTANCE hInstance
Definition: charmap.c:20
#define va_end(ap)
Definition: acmsvcex.h:90
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
char * va_list
Definition: acmsvcex.h:78
static INT AllocAndLoadStringsCat(OUT LPWSTR *lpTarget, IN HINSTANCE hInst, IN UINT *uID, IN UINT nIDs)
Definition: misc.cpp:98
unsigned long DWORD
Definition: ntddk_ex.h:95
va_start(ap, x)
LPCWSTR lpFormat
Definition: trayclock.cpp:32
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DeviceProblemTextW().

◆ LoadAndInitComctl32()

HINSTANCE LoadAndInitComctl32 ( VOID  )

Definition at line 1106 of file misc.cpp.

1107 {
1108  typedef VOID (WINAPI *PINITCOMMONCONTROLS)(VOID);
1109  PINITCOMMONCONTROLS pInitCommonControls;
1110  HINSTANCE hComCtl32;
1111 
1112  hComCtl32 = LoadLibrary(L"comctl32.dll");
1113  if (hComCtl32 != NULL)
1114  {
1115  /* initialize the common controls */
1116  pInitCommonControls = (PINITCOMMONCONTROLS)GetProcAddress(hComCtl32,
1117  "InitCommonControls");
1118  if (pInitCommonControls == NULL)
1119  {
1120  FreeLibrary(hComCtl32);
1121  return NULL;
1122  }
1123 
1124  pInitCommonControls();
1125  }
1126 
1127  return hComCtl32;
1128 }
#define LoadLibrary
Definition: winbase.h:3702
#define FreeLibrary(x)
Definition: compat.h:607
#define WINAPI
Definition: msvc.h:6
static const WCHAR L[]
Definition: oid.c:1250
#define VOID
Definition: acefi.h:82
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:612

Referenced by DeviceAdvancedPropertiesW(), DeviceCreateHardwarePageEx(), DeviceProblemWizardW(), and DevicePropertiesExW().