ReactOS 0.4.15-dev-7846-g8ba6c66
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{
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}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
UINT WINAPI DeviceProblemTextW(IN HMACHINE hMachine OPTIONAL, IN DEVINST dnDevInst, IN ULONG uProblemId, OUT LPWSTR lpString, IN UINT uMaxString)
Definition: devprblm.cpp:491
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
unsigned int UINT
Definition: ndis.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ 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 {
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,
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
578 if (AdvFormat)
579 {
580 StringIDs[1] = IDS_DEVCODE2;
582 StringIDs,
583 sizeof(StringIDs) / sizeof(StringIDs[0]),
584 &szProblem,
585 szInfo,
586 uProblemId);
587 }
588 else
589 {
591 StringIDs,
592 sizeof(StringIDs) / sizeof(StringIDs[0]),
593 &szProblem,
594 uProblemId);
595 }
596
597 if (dwRet != 0)
598 {
599 if (uMaxString != 0 && uMaxString >= dwRet)
600 {
601 wcscpy(lpString,
602 szProblem);
603 }
604
605 LocalFree((HLOCAL)szProblem);
606
607 Ret = dwRet;
608 }
609 }
610
611 return Ret;
612}
INT LengthOfStrResource(IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:23
#define IDS_UNKNOWN
Definition: resource.h:7
#define CM_PROB_INVALID_DATA
Definition: cfg.h:39
#define CM_PROB_NORMAL_CONFLICT
Definition: cfg.h:42
#define CM_PROB_UNKNOWN_RESOURCE
Definition: cfg.h:47
#define CM_PROB_DISABLED
Definition: cfg.h:52
#define CM_PROB_DEVLOADER_FAILED
Definition: cfg.h:32
#define CM_PROB_DEVLOADER_NOT_FOUND
Definition: cfg.h:38
static HINSTANCE hDllInstance
Definition: clb.c:30
static const UINT ProblemStringId[NUM_CM_PROB]
Definition: devprblm.cpp:337
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD LoadAndFormatStringsCat(IN HINSTANCE hInstance, IN UINT *uID, IN UINT nIDs, OUT LPWSTR *lpTarget,...)
Definition: misc.cpp:177
#define IDS_DEVCODE2
Definition: resource.h:110
#define IDS_DEVCODE
Definition: resource.h:109
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define LoadString
Definition: winuser.h:5819

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
242Cleanup:
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
LPWSTR ConvertMultiByteToUnicode(IN LPCSTR lpMultiByteStr, IN UINT uCodePage)
Definition: misc.cpp:239
static const WCHAR Cleanup[]
Definition: register.c:80

◆ 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 {
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,
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 CM_Connect_Machine
Definition: cfgmgr32.h:1074
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_SUCCESS
Definition: cfgmgr32.h:842
CONFIGRET WINAPI CM_Disconnect_Machine(_In_opt_ HMACHINE hMachine)
Definition: cfgmgr.c:1863
BOOL ShowDeviceProblemWizard(IN HWND hWndParent OPTIONAL, IN HDEVINFO hDevInfo, IN PSP_DEVINFO_DATA DevInfoData, IN HMACHINE hMachine OPTIONAL)
Definition: devprblm.cpp:34
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE LoadAndInitComctl32(VOID)
Definition: misc.cpp:1106
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
#define SetupDiOpenDeviceInfo
Definition: setupapi.h:2614
#define SetupDiCreateDeviceInfoListEx
Definition: setupapi.h:2580
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA

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
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:
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
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_REGISTRY_TOO_LARGE
Definition: cfg.h:79
#define CM_PROB_REGISTRY
Definition: cfg.h:49
#define CM_PROB_REINSTALL
Definition: cfg.h:48
#define CM_PROB_BOOT_CONFIG_CONFLICT
Definition: cfg.h:36
#define CM_PROB_FAILED_ADD
Definition: cfg.h:61
#define CM_PROB_HELD_FOR_EJECT
Definition: cfg.h:77
#define CM_PROB_DRIVER_BLOCKED
Definition: cfg.h:78
#define CM_PROB_HARDWARE_DISABLED
Definition: cfg.h:59
#define CM_PROB_NO_SOFTCONFIG
Definition: cfg.h:64
#define CM_PROB_TRANSLATION_FAILED
Definition: cfg.h:63
#define CM_PROB_PARTIAL_LOG_CONF
Definition: cfg.h:46
#define CM_PROB_LIAR
Definition: cfg.h:41
#define CM_PROB_REENUMERATION
Definition: cfg.h:45
#define CM_PROB_NEED_RESTART
Definition: cfg.h:44
#define DN_HAS_PROBLEM
Definition: cfg.h:128
#define CM_PROB_DEVICE_NOT_THERE
Definition: cfg.h:54
#define CM_PROB_DRIVER_SERVICE_KEY_INVALID
Definition: cfg.h:70
#define CM_PROB_FAILED_FILTER
Definition: cfg.h:37
#define CM_PROB_WILL_BE_REMOVED
Definition: cfg.h:51
#define CM_PROB_FAILED_START
Definition: cfg.h:40
#define CM_PROB_PHANTOM
Definition: cfg.h:75
#define CM_PROB_DRIVER_FAILED_LOAD
Definition: cfg.h:69
#define CM_PROB_FAILED_INSTALL
Definition: cfg.h:58
#define CM_PROB_OUT_OF_MEMORY
Definition: cfg.h:33
#define CM_PROB_HALTED
Definition: cfg.h:74
#define CM_PROB_NOT_VERIFIED
Definition: cfg.h:43
#define CM_PROB_FAILED_POST_START
Definition: cfg.h:73
#define CM_PROB_SYSTEM_SHUTDOWN
Definition: cfg.h:76
#define CM_PROB_NO_VALID_LOG_CONF
Definition: cfg.h:57
#define CM_PROB_IRQ_TRANSLATION_FAILED
Definition: cfg.h:66
#define CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD
Definition: cfg.h:68
#define CM_PROB_LACKED_ARBITRATOR
Definition: cfg.h:35
#define CM_PROB_FAILED_DRIVER_ENTRY
Definition: cfg.h:67
#define CM_PROB_DEVLOADER_NOT_READY
Definition: cfg.h:53
#define CM_PROB_DISABLED_SERVICE
Definition: cfg.h:62
#define CM_PROB_TOO_EARLY
Definition: cfg.h:56
#define CM_PROB_MOVED
Definition: cfg.h:55
#define CM_PROB_DUPLICATE_DEVICE
Definition: cfg.h:72
#define CM_PROB_LEGACY_SERVICE_NO_DEVICES
Definition: cfg.h:71
#define CM_PROB_ENTRY_IS_WRONG_TYPE
Definition: cfg.h:34
#define CM_PROB_CANT_SHARE_IRQ
Definition: cfg.h:60
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:3591
BOOL WINAPI InstallDevInst(IN HWND hWndParent, IN LPCWSTR InstanceId, IN BOOL bUpdate, OUT LPDWORD lpReboot)
Definition: stubs.cpp:24
Status
Definition: gdiplustypes.h:25
#define SetupDiGetDeviceInstanceId
Definition: setupapi.h:2600
uint32_t ULONG
Definition: typedefs.h:59

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().