ReactOS  0.4.15-dev-1068-g467feb9
devprblm.cpp File Reference
#include "precomp.h"
#include "properties.h"
#include "resource.h"
Include dependency graph for devprblm.cpp:

Go to the source code of this file.

Functions

BOOL ShowDeviceProblemWizard (IN HWND hWndParent OPTIONAL, IN HDEVINFO hDevInfo, IN PSP_DEVINFO_DATA DevInfoData, IN HMACHINE hMachine OPTIONAL)
 
BOOL WINAPI DeviceProblemWizardA (IN HWND hWndParent OPTIONAL, IN LPCSTR lpMachineName OPTIONAL, IN LPCSTR lpDeviceID)
 
BOOL WINAPI DeviceProblemWizardW (IN HWND hWndParent OPTIONAL, IN LPCWSTR lpMachineName OPTIONAL, IN LPCWSTR lpDeviceID)
 
UINT WINAPI DeviceProblemTextA (IN HMACHINE hMachine OPTIONAL, IN DEVINST dnDevInst, IN ULONG uProblemId, OUT LPSTR lpString, IN UINT uMaxString)
 
UINT WINAPI DeviceProblemTextW (IN HMACHINE hMachine OPTIONAL, IN DEVINST dnDevInst, IN ULONG uProblemId, OUT LPWSTR lpString, IN UINT uMaxString)
 

Variables

static const UINT ProblemStringId [NUM_CM_PROB]
 

Function Documentation

◆ DeviceProblemTextA()

UINT WINAPI DeviceProblemTextA ( IN HMACHINE hMachine  OPTIONAL,
IN DEVINST  dnDevInst,
IN ULONG  uProblemId,
OUT LPSTR  lpString,
IN UINT  uMaxString 
)

Definition at line 417 of file devprblm.cpp.

422 {
423  LPWSTR lpBuffer = NULL;
424  UINT Ret = 0;
425 
426  if (uMaxString != 0)
427  {
429  0,
430  (uMaxString + 1) * sizeof(WCHAR));
431  if (lpBuffer == NULL)
432  {
434  return 0;
435  }
436  }
437 
438  Ret = DeviceProblemTextW(hMachine,
439  dnDevInst,
440  uProblemId,
441  lpBuffer,
442  uMaxString);
443 
444  if (lpBuffer != NULL)
445  {
446  if (Ret)
447  {
449  0,
450  lpBuffer,
451  (int)Ret,
452  lpString,
453  (int)uMaxString,
454  NULL,
455  NULL);
456  }
457 
459  0,
460  lpBuffer);
461  }
462 
463  return Ret;
464 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI DeviceProblemTextW(IN HMACHINE hMachine OPTIONAL, IN DEVINST dnDevInst, IN ULONG uProblemId, OUT LPWSTR lpString, IN UINT uMaxString)
Definition: devprblm.cpp:491
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:500
unsigned int UINT
Definition: ndis.h:50
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ DeviceProblemTextW()

UINT WINAPI DeviceProblemTextW ( IN HMACHINE hMachine  OPTIONAL,
IN DEVINST  dnDevInst,
IN ULONG  uProblemId,
OUT LPWSTR  lpString,
IN UINT  uMaxString 
)

Definition at line 491 of file devprblm.cpp.

496 {
497  UINT MessageId = IDS_UNKNOWN;
498  UINT Ret = 0;
499 
500  if (uProblemId < sizeof(ProblemStringId) / sizeof(ProblemStringId[0]))
501  MessageId = ProblemStringId[uProblemId];
502 
503  if (uProblemId == 0)
504  {
505  if (uMaxString != 0)
506  {
507  Ret = LoadString(hDllInstance,
508  MessageId,
509  lpString,
510  (int)uMaxString);
511  }
512  else
513  {
515  MessageId);
516  }
517  }
518  else
519  {
520  LPWSTR szProblem;
521  WCHAR szInfo[] = L"FIXME";
522  DWORD dwRet;
523  BOOL AdvFormat = FALSE;
524  UINT StringIDs[] =
525  {
526  MessageId,
527  IDS_DEVCODE,
528  };
529 
530  switch (uProblemId)
531  {
533  {
534  /* FIXME - if not a root bus devloader then use IDS_DEV_DEVLOADER_FAILED2 */
535  /* FIXME - get the type string (ie. ISAPNP, PCI or BIOS for root bus devloaders,
536  or FLOP, ESDI, SCSI, etc for others */
537  AdvFormat = TRUE;
538  break;
539  }
540 
542  {
543  /* FIXME - 4 cases:
544  1) if it's a missing system devloader:
545  - get the system devloader name
546  2) if it's not a system devloader but still missing:
547  - get the devloader name (file name?)
548  3) if it's not a system devloader but the file can be found:
549  - use IDS_DEV_DEVLOADER_NOT_FOUND2
550  4) if it's a missing or empty software key
551  - use IDS_DEV_DEVLOADER_NOT_FOUND3
552  - AdvFormat = FALSE!
553  */
554  AdvFormat = TRUE;
555  break;
556  }
557 
559  /* FIXME - if the device isn't enumerated by the BIOS/ACPI use IDS_DEV_INVALID_DATA2 */
560  AdvFormat = FALSE;
561  break;
562 
564  /* FIXME - get resource type (IRQ, DMA, Memory or I/O) */
565  AdvFormat = TRUE;
566  break;
567 
569  /* FIXME - get the .inf file name */
570  AdvFormat = TRUE;
571  break;
572 
573  case CM_PROB_DISABLED:
574  /* FIXME - if the device was disabled by the system use IDS_DEV_DISABLED2 */
575  break;
576 
577  case CM_PROB_FAILED_ADD:
578  /* FIXME - get the name of the sub-device with the error */
579  AdvFormat = TRUE;
580  break;
581  }
582 
583  if (AdvFormat)
584  {
585  StringIDs[1] = IDS_DEVCODE2;
587  StringIDs,
588  sizeof(StringIDs) / sizeof(StringIDs[0]),
589  &szProblem,
590  szInfo,
591  uProblemId);
592  }
593  else
594  {
596  StringIDs,
597  sizeof(StringIDs) / sizeof(StringIDs[0]),
598  &szProblem,
599  uProblemId);
600  }
601 
602  if (dwRet != 0)
603  {
604  if (uMaxString != 0 && uMaxString >= dwRet)
605  {
606  wcscpy(lpString,
607  szProblem);
608  }
609 
610  LocalFree((HLOCAL)szProblem);
611 
612  Ret = dwRet;
613  }
614  }
615 
616  return Ret;
617 }
#define TRUE
Definition: types.h:120
#define IDS_DEVCODE2
Definition: resource.h:109
DWORD LoadAndFormatStringsCat(IN HINSTANCE hInstance, IN UINT *uID, IN UINT nIDs, OUT LPWSTR *lpTarget,...)
Definition: misc.cpp:177
#define IDS_DEVCODE
Definition: resource.h:108
#define CM_PROB_DISABLED
Definition: cfg.h:52
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CM_PROB_INVALID_DATA
Definition: cfg.h:39
#define CM_PROB_NORMAL_CONFLICT
Definition: cfg.h:42
#define IDS_UNKNOWN
Definition: resource.h:7
static HINSTANCE hDllInstance
Definition: clb.c:30
#define CM_PROB_DEVLOADER_NOT_FOUND
Definition: cfg.h:38
static const UINT ProblemStringId[NUM_CM_PROB]
Definition: devprblm.cpp:337
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
_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
#define CM_PROB_UNKNOWN_RESOURCE
Definition: cfg.h:47
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int UINT
Definition: ndis.h:50
#define CM_PROB_FAILED_ADD
Definition: cfg.h:61
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define CM_PROB_DEVLOADER_FAILED
Definition: cfg.h:32
INT LengthOfStrResource(IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:23
#define LoadString
Definition: winuser.h:5794

Referenced by DeviceProblemTextA(), GetDeviceStatusString(), and InitProbeListPage().

◆ DeviceProblemWizardA()

BOOL WINAPI DeviceProblemWizardA ( IN HWND hWndParent  OPTIONAL,
IN LPCSTR lpMachineName  OPTIONAL,
IN LPCSTR  lpDeviceID 
)

Definition at line 213 of file devprblm.cpp.

216 {
217  LPWSTR lpMachineNameW = NULL;
218  LPWSTR lpDeviceIDW = NULL;
219  BOOL Ret = FALSE;
220 
221  if (lpMachineName != NULL)
222  {
223  if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName,
224  CP_ACP)))
225  {
226  goto Cleanup;
227  }
228  }
229  if (lpDeviceID != NULL)
230  {
231  if (!(lpDeviceIDW = ConvertMultiByteToUnicode(lpDeviceID,
232  CP_ACP)))
233  {
234  goto Cleanup;
235  }
236  }
237 
239  lpMachineNameW,
240  lpDeviceIDW);
241 
242 Cleanup:
243  if (lpMachineNameW != NULL)
244  {
246  0,
247  lpMachineNameW);
248  }
249  if (lpDeviceIDW != NULL)
250  {
252  0,
253  lpDeviceIDW);
254  }
255 
256  return Ret;
257 }
BOOL WINAPI DeviceProblemWizardW(IN HWND hWndParent OPTIONAL, IN LPCWSTR lpMachineName OPTIONAL, IN LPCWSTR lpDeviceID)
Definition: devprblm.cpp:280
#define CP_ACP
Definition: compat.h:109
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
LPWSTR ConvertMultiByteToUnicode(IN LPCSTR lpMultiByteStr, IN UINT uCodePage)
Definition: misc.cpp:239
static const WCHAR Cleanup[]
Definition: register.c:80
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ DeviceProblemWizardW()

BOOL WINAPI DeviceProblemWizardW ( IN HWND hWndParent  OPTIONAL,
IN LPCWSTR lpMachineName  OPTIONAL,
IN LPCWSTR  lpDeviceID 
)

Definition at line 280 of file devprblm.cpp.

283 {
284  HDEVINFO hDevInfo;
285  SP_DEVINFO_DATA DevInfoData;
286  HINSTANCE hComCtl32;
287  CONFIGRET cr;
288  HMACHINE hMachine;
289  BOOL Ret = FALSE;
290 
291  if (lpDeviceID == NULL)
292  {
294  return FALSE;
295  }
296 
297  /* dynamically load comctl32 */
298  hComCtl32 = LoadAndInitComctl32();
299  if (hComCtl32 != NULL)
300  {
302  hWndParent,
303  lpMachineName,
304  NULL);
305  if (hDevInfo != INVALID_HANDLE_VALUE)
306  {
307  cr = CM_Connect_Machine(lpMachineName,
308  &hMachine);
309  if (cr == CR_SUCCESS)
310  {
311  DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
312  if (SetupDiOpenDeviceInfo(hDevInfo,
313  lpDeviceID,
314  hWndParent,
315  0,
316  &DevInfoData))
317  {
319  hDevInfo,
320  &DevInfoData,
321  hMachine);
322  }
323 
324  CM_Disconnect_Machine(hMachine);
325  }
326 
328  }
329 
330  FreeLibrary(hComCtl32);
331  }
332 
333  return Ret;
334 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
CONFIGRET WINAPI CM_Disconnect_Machine(_In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1855
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
HINSTANCE LoadAndInitComctl32(VOID)
Definition: misc.cpp:1106
#define SetupDiCreateDeviceInfoListEx
Definition: setupapi.h:2575
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
#define FreeLibrary(x)
Definition: compat.h:496
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
#define SetLastError(x)
Definition: compat.h:500
BOOL ShowDeviceProblemWizard(IN HWND hWndParent OPTIONAL, IN HDEVINFO hDevInfo, IN PSP_DEVINFO_DATA DevInfoData, IN HMACHINE hMachine OPTIONAL)
Definition: devprblm.cpp:34
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define SetupDiOpenDeviceInfo
Definition: setupapi.h:2609
#define CM_Connect_Machine
Definition: cfgmgr32.h:1074

Referenced by DeviceProblemWizardA().

◆ ShowDeviceProblemWizard()

BOOL ShowDeviceProblemWizard ( IN HWND hWndParent  OPTIONAL,
IN HDEVINFO  hDevInfo,
IN PSP_DEVINFO_DATA  DevInfoData,
IN HMACHINE hMachine  OPTIONAL 
)

Definition at line 34 of file devprblm.cpp.

38 {
39  WCHAR szDeviceInstanceId[256];
40  CONFIGRET cr;
41  ULONG Status, ProblemNumber;
42  DWORD dwReboot;
43  BOOL Ret = FALSE;
44 
45  /* Get the device instance id */
46  if (!SetupDiGetDeviceInstanceId(hDevInfo,
47  DevInfoData,
48  szDeviceInstanceId,
49  256,
50  NULL))
51  return FALSE;
52 
54  &ProblemNumber,
55  DevInfoData->DevInst,
56  0,
57  hMachine);
58  if (cr == CR_SUCCESS && (Status & DN_HAS_PROBLEM))
59  {
60  switch (ProblemNumber)
61  {
63  {
64  /* FIXME - only if it's not a root bus devloader */
65  /* FIXME - display the update driver wizard */
66  break;
67  }
68 
73  case CM_PROB_LIAR:
75  {
76  /* FIXME - display the update driver wizard */
77  InstallDevInst(hWndParent, szDeviceInstanceId, TRUE, &dwReboot);
78  break;
79  }
80 
84  {
85  /* FIXME - display the conflict wizard */
86  break;
87  }
88 
90  case CM_PROB_REINSTALL:
92  {
93  /* FIXME - display the driver (re)installation wizard */
94  InstallDevInst(hWndParent, szDeviceInstanceId, TRUE, &dwReboot);
95  break;
96  }
97 
99  {
100  /* FIXME - 4 cases:
101  1) if it's a missing system devloader:
102  - fail
103  2) if it's not a system devloader but still missing:
104  - display the driver reinstallation wizard
105  3) if it's not a system devloader but the file can be found:
106  - display the update driver wizard
107  4) if it's a missing or empty software key
108  - display the update driver wizard
109  */
110  break;
111  }
112 
120  case CM_PROB_PHANTOM:
121  /* FIXME - do nothing */
122  break;
123 
126  /* FIXME - display search hardware wizard */
127  break;
128 
131  case CM_PROB_MOVED:
132  case CM_PROB_TOO_EARLY:
134  /* FIXME - reboot computer */
135  break;
136 
137  case CM_PROB_REGISTRY:
138  /* FIXME - check registry */
139  break;
140 
141  case CM_PROB_DISABLED:
142  {
143  /* FIXME - if device was disabled by user display the "Enable Device" wizard,
144  otherwise Troubleshoot because the device was disabled by the system */
145  break;
146  }
147 
149  {
150  /* FIXME - if it's a graphics adapter:
151  - if it's a a secondary adapter and the main adapter
152  couldn't be found
153  - do nothing or default action
154  - else
155  - display the Properties
156  - else
157  - Update driver
158  */
159  break;
160  }
161 
162  case CM_PROB_FAILED_ADD:
163  {
164  /* FIXME - display the properties of the sub-device */
165  break;
166  }
167 
177  case CM_PROB_HALTED:
181  default:
182  {
183  /* FIXME - troubleshoot the device */
184  break;
185  }
186  }
187  }
188 
189  return Ret;
190 }
#define CM_PROB_HALTED
Definition: cfg.h:74
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 CM_PROB_REENUMERATION
Definition: cfg.h:45
#define CM_PROB_HELD_FOR_EJECT
Definition: cfg.h:77
#define TRUE
Definition: types.h:120
#define CM_PROB_NOT_VERIFIED
Definition: cfg.h:43
#define CM_PROB_PHANTOM
Definition: cfg.h:75
#define CM_PROB_LACKED_ARBITRATOR
Definition: cfg.h:35
#define CM_PROB_OUT_OF_MEMORY
Definition: cfg.h:33
#define CM_PROB_FAILED_START
Definition: cfg.h:40
#define CM_PROB_FAILED_POST_START
Definition: cfg.h:73
#define CM_PROB_DUPLICATE_DEVICE
Definition: cfg.h:72
#define CM_PROB_FAILED_DRIVER_ENTRY
Definition: cfg.h:67
#define CM_PROB_REGISTRY_TOO_LARGE
Definition: cfg.h:79
#define CM_PROB_WILL_BE_REMOVED
Definition: cfg.h:51
#define CM_PROB_PARTIAL_LOG_CONF
Definition: cfg.h:46
#define CM_PROB_DISABLED
Definition: cfg.h:52
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CM_PROB_INVALID_DATA
Definition: cfg.h:39
#define CM_PROB_NO_SOFTCONFIG
Definition: cfg.h:64
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define CM_PROB_NORMAL_CONFLICT
Definition: cfg.h:42
#define CM_PROB_DEVLOADER_NOT_FOUND
Definition: cfg.h:38
#define CM_PROB_LIAR
Definition: cfg.h:41
#define CM_PROB_HARDWARE_DISABLED
Definition: cfg.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CM_PROB_DISABLED_SERVICE
Definition: cfg.h:62
#define CM_PROB_TRANSLATION_FAILED
Definition: cfg.h:63
#define DN_HAS_PROBLEM
Definition: cfg.h:128
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI InstallDevInst(IN HWND hWndParent, IN LPCWSTR InstanceId, IN BOOL bUpdate, OUT LPDWORD lpReboot)
Definition: stubs.cpp:24
#define CM_PROB_CANT_SHARE_IRQ
Definition: cfg.h:60
#define CM_PROB_REINSTALL
Definition: cfg.h:48
Status
Definition: gdiplustypes.h:24
#define SetupDiGetDeviceInstanceId
Definition: setupapi.h:2595
#define CM_PROB_DRIVER_FAILED_LOAD
Definition: cfg.h:69
#define CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD
Definition: cfg.h:68
#define CM_PROB_UNKNOWN_RESOURCE
Definition: cfg.h:47
#define CM_PROB_NEED_RESTART
Definition: cfg.h:44
#define CM_PROB_TOO_EARLY
Definition: cfg.h:56
#define CM_PROB_DEVLOADER_NOT_READY
Definition: cfg.h:53
#define CM_PROB_DEVICE_NOT_THERE
Definition: cfg.h:54
#define CM_PROB_SYSTEM_SHUTDOWN
Definition: cfg.h:76
#define CM_PROB_LEGACY_SERVICE_NO_DEVICES
Definition: cfg.h:71
#define CM_PROB_DRIVER_BLOCKED
Definition: cfg.h:78
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CM_PROB_FAILED_INSTALL
Definition: cfg.h:58
#define CM_PROB_MOVED
Definition: cfg.h:55
#define CM_PROB_DRIVER_SERVICE_KEY_INVALID
Definition: cfg.h:70
unsigned int ULONG
Definition: retypes.h:1
#define CM_PROB_FAILED_FILTER
Definition: cfg.h:37
#define CM_PROB_BOOT_CONFIG_CONFLICT
Definition: cfg.h:36
#define CM_PROB_ENTRY_IS_WRONG_TYPE
Definition: cfg.h:34
#define CM_PROB_FAILED_ADD
Definition: cfg.h:61
#define CM_PROB_DEVLOADER_FAILED
Definition: cfg.h:32
#define CM_PROB_REGISTRY
Definition: cfg.h:49
#define CM_PROB_NO_VALID_LOG_CONF
Definition: cfg.h:57
#define CM_PROB_IRQ_TRANSLATION_FAILED
Definition: cfg.h:66

Referenced by AdvPropGeneralDlgProc(), and DeviceProblemWizardW().

Variable Documentation

◆ ProblemStringId

const UINT ProblemStringId[NUM_CM_PROB]
static

Definition at line 337 of file devprblm.cpp.

Referenced by DeviceProblemTextW().