Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendevprblm.c
Go to the documentation of this file.
00001 /* 00002 * ReactOS Device Manager Applet 00003 * Copyright (C) 2004 - 2005 ReactOS Team 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 /* $Id: hwpage.c 19599 2005-11-26 02:12:58Z weiden $ 00020 * 00021 * PROJECT: ReactOS devmgr.dll 00022 * FILE: lib/devmgr/devprblm.c 00023 * PURPOSE: ReactOS Device Manager 00024 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com> 00025 * UPDATE HISTORY: 00026 * 04-04-2004 Created 00027 */ 00028 #include <precomp.h> 00029 00030 #define NDEBUG 00031 #include <debug.h> 00032 00033 00034 BOOL 00035 ShowDeviceProblemWizard(IN HWND hWndParent OPTIONAL, 00036 IN HDEVINFO hDevInfo, 00037 IN PSP_DEVINFO_DATA DevInfoData, 00038 IN HMACHINE hMachine OPTIONAL) 00039 { 00040 CONFIGRET cr; 00041 ULONG Status, ProblemNumber; 00042 BOOL Ret = FALSE; 00043 00044 cr = CM_Get_DevNode_Status_Ex(&Status, 00045 &ProblemNumber, 00046 DevInfoData->DevInst, 00047 0, 00048 hMachine); 00049 if (cr == CR_SUCCESS && (Status & DN_HAS_PROBLEM)) 00050 { 00051 switch (ProblemNumber) 00052 { 00053 case CM_PROB_DEVLOADER_FAILED: 00054 { 00055 /* FIXME - only if it's not a root bus devloader */ 00056 /* FIXME - display the update driver wizard */ 00057 break; 00058 } 00059 00060 case CM_PROB_OUT_OF_MEMORY: 00061 case CM_PROB_ENTRY_IS_WRONG_TYPE: 00062 case CM_PROB_LACKED_ARBITRATOR: 00063 case CM_PROB_FAILED_START: 00064 case CM_PROB_LIAR: 00065 case CM_PROB_UNKNOWN_RESOURCE: 00066 { 00067 /* FIXME - display the update driver wizard */ 00068 break; 00069 } 00070 00071 case CM_PROB_BOOT_CONFIG_CONFLICT: 00072 case CM_PROB_NORMAL_CONFLICT: 00073 case CM_PROB_REENUMERATION: 00074 { 00075 /* FIXME - display the conflict wizard */ 00076 break; 00077 } 00078 00079 case CM_PROB_FAILED_FILTER: 00080 case CM_PROB_REINSTALL: 00081 case CM_PROB_FAILED_INSTALL: 00082 { 00083 /* FIXME - display the driver (re)installation wizard */ 00084 break; 00085 } 00086 00087 case CM_PROB_DEVLOADER_NOT_FOUND: 00088 { 00089 /* FIXME - 4 cases: 00090 1) if it's a missing system devloader: 00091 - fail 00092 2) if it's not a system devloader but still missing: 00093 - display the driver reinstallation wizard 00094 3) if it's not a system devloader but the file can be found: 00095 - display the update driver wizard 00096 4) if it's a missing or empty software key 00097 - display the update driver wizard 00098 */ 00099 break; 00100 } 00101 00102 case CM_PROB_INVALID_DATA: 00103 case CM_PROB_PARTIAL_LOG_CONF: 00104 case CM_PROB_NO_VALID_LOG_CONF: 00105 case CM_PROB_HARDWARE_DISABLED: 00106 case CM_PROB_CANT_SHARE_IRQ: 00107 case CM_PROB_TRANSLATION_FAILED: 00108 case CM_PROB_SYSTEM_SHUTDOWN: 00109 case CM_PROB_PHANTOM: 00110 /* FIXME - do nothing */ 00111 break; 00112 00113 case CM_PROB_NOT_VERIFIED: 00114 case CM_PROB_DEVICE_NOT_THERE: 00115 /* FIXME - display search hardware wizard */ 00116 break; 00117 00118 case CM_PROB_NEED_RESTART: 00119 case CM_PROB_WILL_BE_REMOVED: 00120 case CM_PROB_MOVED: 00121 case CM_PROB_TOO_EARLY: 00122 case CM_PROB_DISABLED_SERVICE: 00123 /* FIXME - reboot computer */ 00124 break; 00125 00126 case CM_PROB_REGISTRY: 00127 /* FIXME - check registry */ 00128 break; 00129 00130 case CM_PROB_DISABLED: 00131 { 00132 /* FIXME - if device was disabled by user display the "Enable Device" wizard, 00133 otherwise Troubleshoot because the device was disabled by the system */ 00134 break; 00135 } 00136 00137 case CM_PROB_DEVLOADER_NOT_READY: 00138 { 00139 /* FIXME - if it's a graphics adapter: 00140 - if it's a a secondary adapter and the main adapter 00141 couldn't be found 00142 - do nothing or default action 00143 - else 00144 - display the Properties 00145 - else 00146 - Update driver 00147 */ 00148 break; 00149 } 00150 00151 case CM_PROB_FAILED_ADD: 00152 { 00153 /* FIXME - display the properties of the sub-device */ 00154 break; 00155 } 00156 00157 case CM_PROB_NO_SOFTCONFIG: 00158 case CM_PROB_IRQ_TRANSLATION_FAILED: 00159 case CM_PROB_FAILED_DRIVER_ENTRY: 00160 case CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD: 00161 case CM_PROB_DRIVER_FAILED_LOAD: 00162 case CM_PROB_DRIVER_SERVICE_KEY_INVALID: 00163 case CM_PROB_LEGACY_SERVICE_NO_DEVICES: 00164 case CM_PROB_DUPLICATE_DEVICE: 00165 case CM_PROB_FAILED_POST_START: 00166 case CM_PROB_HALTED: 00167 case CM_PROB_HELD_FOR_EJECT: 00168 case CM_PROB_DRIVER_BLOCKED: 00169 case CM_PROB_REGISTRY_TOO_LARGE: 00170 default: 00171 { 00172 /* FIXME - troubleshoot the device */ 00173 break; 00174 } 00175 } 00176 } 00177 00178 return Ret; 00179 } 00180 00181 00182 /*************************************************************************** 00183 * NAME EXPORTED 00184 * DeviceProblemWizardA 00185 * 00186 * DESCRIPTION 00187 * Calls the device problem wizard 00188 * 00189 * ARGUMENTS 00190 * hWndParent: Handle to the parent window 00191 * lpMachineName: Machine Name, NULL is the local machine 00192 * lpDeviceID: Specifies the device, also see NOTEs 00193 * 00194 * RETURN VALUE 00195 * TRUE: if no errors occured 00196 * FALSE: if errors occured 00197 * 00198 * @implemented 00199 */ 00200 BOOL 00201 WINAPI 00202 DeviceProblemWizardA(IN HWND hWndParent OPTIONAL, 00203 IN LPCSTR lpMachineName OPTIONAL, 00204 IN LPCSTR lpDeviceID) 00205 { 00206 LPWSTR lpMachineNameW = NULL; 00207 LPWSTR lpDeviceIDW = NULL; 00208 BOOL Ret = FALSE; 00209 00210 if (lpMachineName != NULL) 00211 { 00212 if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName, 00213 CP_ACP))) 00214 { 00215 goto Cleanup; 00216 } 00217 } 00218 if (lpDeviceID != NULL) 00219 { 00220 if (!(lpDeviceIDW = ConvertMultiByteToUnicode(lpDeviceID, 00221 CP_ACP))) 00222 { 00223 goto Cleanup; 00224 } 00225 } 00226 00227 Ret = DeviceProblemWizardW(hWndParent, 00228 lpMachineNameW, 00229 lpDeviceIDW); 00230 00231 Cleanup: 00232 if (lpMachineNameW != NULL) 00233 { 00234 HeapFree(GetProcessHeap(), 00235 0, 00236 lpMachineNameW); 00237 } 00238 if (lpDeviceIDW != NULL) 00239 { 00240 HeapFree(GetProcessHeap(), 00241 0, 00242 lpDeviceIDW); 00243 } 00244 00245 return Ret; 00246 } 00247 00248 00249 /*************************************************************************** 00250 * NAME EXPORTED 00251 * DeviceProblemWizardW 00252 * 00253 * DESCRIPTION 00254 * Calls the device problem wizard 00255 * 00256 * ARGUMENTS 00257 * hWndParent: Handle to the parent window 00258 * lpMachineName: Machine Name, NULL is the local machine 00259 * lpDeviceID: Specifies the device, also see NOTEs 00260 * 00261 * RETURN VALUE 00262 * TRUE: if no errors occured 00263 * FALSE: if errors occured 00264 * 00265 * @unimplemented 00266 */ 00267 BOOL 00268 WINAPI 00269 DeviceProblemWizardW(IN HWND hWndParent OPTIONAL, 00270 IN LPCWSTR lpMachineName OPTIONAL, 00271 IN LPCWSTR lpDeviceID) 00272 { 00273 HDEVINFO hDevInfo; 00274 SP_DEVINFO_DATA DevInfoData; 00275 HINSTANCE hComCtl32; 00276 CONFIGRET cr; 00277 HMACHINE hMachine; 00278 BOOL Ret = FALSE; 00279 00280 if (lpDeviceID == NULL) 00281 { 00282 SetLastError(ERROR_INVALID_PARAMETER); 00283 return FALSE; 00284 } 00285 00286 /* dynamically load comctl32 */ 00287 hComCtl32 = LoadAndInitComctl32(); 00288 if (hComCtl32 != NULL) 00289 { 00290 hDevInfo = SetupDiCreateDeviceInfoListEx(NULL, 00291 hWndParent, 00292 lpMachineName, 00293 NULL); 00294 if (hDevInfo != INVALID_HANDLE_VALUE) 00295 { 00296 cr = CM_Connect_Machine(lpMachineName, 00297 &hMachine); 00298 if (cr == CR_SUCCESS) 00299 { 00300 DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); 00301 if (SetupDiOpenDeviceInfo(hDevInfo, 00302 lpDeviceID, 00303 hWndParent, 00304 0, 00305 &DevInfoData)) 00306 { 00307 Ret = ShowDeviceProblemWizard(hWndParent, 00308 hDevInfo, 00309 &DevInfoData, 00310 hMachine); 00311 } 00312 00313 CM_Disconnect_Machine(hMachine); 00314 } 00315 00316 SetupDiDestroyDeviceInfoList(hDevInfo); 00317 } 00318 00319 FreeLibrary(hComCtl32); 00320 } 00321 00322 return Ret; 00323 } 00324 00325 00326 static const UINT ProblemStringId[NUM_CM_PROB] = 00327 { 00328 IDS_DEV_NO_PROBLEM, 00329 IDS_DEV_DEVLOADER_FAILED, 00330 IDS_DEV_NOT_CONFIGURED, 00331 IDS_DEV_OUT_OF_MEMORY, 00332 IDS_DEV_ENTRY_IS_WRONG_TYPE, 00333 IDS_DEV_LACKED_ARBITRATOR, 00334 IDS_DEV_BOOT_CONFIG_CONFLICT, 00335 IDS_DEV_FAILED_FILTER, 00336 IDS_DEV_DEVLOADER_NOT_FOUND, 00337 IDS_DEV_INVALID_DATA, 00338 IDS_DEV_FAILED_START, 00339 IDS_DEV_LIAR, 00340 IDS_DEV_NORMAL_CONFLICT, 00341 IDS_DEV_NOT_VERIFIED, 00342 IDS_DEV_NEED_RESTART, 00343 IDS_DEV_REENUMERATION, 00344 IDS_DEV_PARTIAL_LOG_CONF, 00345 IDS_DEV_UNKNOWN_RESOURCE, 00346 IDS_DEV_REINSTALL, 00347 IDS_DEV_REGISTRY, 00348 IDS_UNKNOWN, /* CM_PROB_VXDLDR, not used on NT */ 00349 IDS_DEV_WILL_BE_REMOVED, 00350 IDS_DEV_DISABLED, 00351 IDS_DEV_DEVLOADER_NOT_READY, 00352 IDS_DEV_DEVICE_NOT_THERE, 00353 IDS_DEV_MOVED, 00354 IDS_DEV_TOO_EARLY, 00355 IDS_DEV_NO_VALID_LOG_CONF, 00356 IDS_DEV_FAILED_INSTALL, 00357 IDS_DEV_HARDWARE_DISABLED, 00358 IDS_DEV_CANT_SHARE_IRQ, 00359 IDS_DEV_FAILED_ADD, 00360 IDS_DEV_DISABLED_SERVICE, 00361 IDS_DEV_TRANSLATION_FAILED, 00362 IDS_DEV_NO_SOFTCONFIG, 00363 IDS_DEV_BIOS_TABLE, 00364 IDS_DEV_IRQ_TRANSLATION_FAILED, 00365 IDS_DEV_FAILED_DRIVER_ENTRY, 00366 IDS_DEV_DRIVER_FAILED_PRIOR_UNLOAD, 00367 IDS_DEV_DRIVER_FAILED_LOAD, 00368 IDS_DEV_DRIVER_SERVICE_KEY_INVALID, 00369 IDS_DEV_LEGACY_SERVICE_NO_DEVICES, 00370 IDS_DEV_DUPLICATE_DEVICE, 00371 IDS_DEV_FAILED_POST_START, 00372 IDS_DEV_HALTED, 00373 IDS_DEV_PHANTOM, 00374 IDS_DEV_SYSTEM_SHUTDOWN, 00375 IDS_DEV_HELD_FOR_EJECT, 00376 IDS_DEV_DRIVER_BLOCKED, 00377 IDS_DEV_REGISTRY_TOO_LARGE, 00378 IDS_DEV_SETPROPERTIES_FAILED 00379 }; 00380 00381 00382 /*************************************************************************** 00383 * NAME EXPORTED 00384 * DeviceProblemTextA 00385 * 00386 * DESCRIPTION 00387 * Gets the problem text from a problem number displayed in the properties dialog 00388 * 00389 * ARGUMENTS 00390 * hMachine: Machine handle or NULL for the local machine 00391 * DevInst: Device instance handle 00392 * uProblemId: Specifies the problem ID 00393 * lpString: Pointer to a buffer where the string is to be copied to. If the buffer 00394 * is too small, the return value is the required string length in characters, 00395 * excluding the NULL-termination. 00396 * uMaxString: Size of the buffer in characters 00397 * 00398 * RETURN VALUE 00399 * The return value is the length of the string in characters. 00400 * It returns 0 if an error occured. 00401 * 00402 * @implemented 00403 */ 00404 UINT 00405 WINAPI 00406 DeviceProblemTextA(IN HMACHINE hMachine OPTIONAL, 00407 IN DEVINST dnDevInst, 00408 IN ULONG uProblemId, 00409 OUT LPSTR lpString, 00410 IN UINT uMaxString) 00411 { 00412 LPWSTR lpBuffer = NULL; 00413 UINT Ret = 0; 00414 00415 if (uMaxString != 0) 00416 { 00417 lpBuffer = HeapAlloc(GetProcessHeap(), 00418 0, 00419 (uMaxString + 1) * sizeof(WCHAR)); 00420 if (lpBuffer == NULL) 00421 { 00422 SetLastError(ERROR_NOT_ENOUGH_MEMORY); 00423 return 0; 00424 } 00425 } 00426 00427 Ret = DeviceProblemTextW(hMachine, 00428 dnDevInst, 00429 uProblemId, 00430 lpBuffer, 00431 uMaxString); 00432 00433 if (lpBuffer != NULL) 00434 { 00435 if (Ret) 00436 { 00437 WideCharToMultiByte(CP_ACP, 00438 0, 00439 lpBuffer, 00440 (int)Ret, 00441 lpString, 00442 (int)uMaxString, 00443 NULL, 00444 NULL); 00445 } 00446 00447 HeapFree(GetProcessHeap(), 00448 0, 00449 lpBuffer); 00450 } 00451 00452 return Ret; 00453 } 00454 00455 00456 /*************************************************************************** 00457 * NAME EXPORTED 00458 * DeviceProblemTextW 00459 * 00460 * DESCRIPTION 00461 * Gets the problem text from a problem number displayed in the properties dialog 00462 * 00463 * ARGUMENTS 00464 * hMachine: Machine handle or NULL for the local machine 00465 * DevInst: Device instance handle 00466 * uProblemId: Specifies the problem ID 00467 * lpString: Pointer to a buffer where the string is to be copied to. If the buffer 00468 * is too small, the return value is the required string length in characters, 00469 * excluding the NULL-termination. 00470 * uMaxString: Size of the buffer in characters 00471 * 00472 * RETURN VALUE 00473 * The return value is the length of the string in characters. 00474 * It returns 0 if an error occured. 00475 * 00476 * @implemented 00477 */ 00478 UINT 00479 WINAPI 00480 DeviceProblemTextW(IN HMACHINE hMachine OPTIONAL, 00481 IN DEVINST dnDevInst, 00482 IN ULONG uProblemId, 00483 OUT LPWSTR lpString, 00484 IN UINT uMaxString) 00485 { 00486 UINT MessageId = IDS_UNKNOWN; 00487 UINT Ret = 0; 00488 00489 if (uProblemId < sizeof(ProblemStringId) / sizeof(ProblemStringId[0])) 00490 MessageId = ProblemStringId[uProblemId]; 00491 00492 if (uProblemId == 0) 00493 { 00494 if (uMaxString != 0) 00495 { 00496 Ret = LoadString(hDllInstance, 00497 MessageId, 00498 lpString, 00499 (int)uMaxString); 00500 } 00501 else 00502 { 00503 Ret = (UINT)LengthOfStrResource(hDllInstance, 00504 MessageId); 00505 } 00506 } 00507 else 00508 { 00509 LPWSTR szProblem, szInfo = NULL; 00510 DWORD dwRet; 00511 BOOL AdvFormat = FALSE; 00512 UINT StringIDs[] = 00513 { 00514 MessageId, 00515 IDS_DEVCODE, 00516 }; 00517 00518 switch (uProblemId) 00519 { 00520 case CM_PROB_DEVLOADER_FAILED: 00521 { 00522 /* FIXME - if not a root bus devloader then use IDS_DEV_DEVLOADER_FAILED2 */ 00523 /* FIXME - get the type string (ie. ISAPNP, PCI or BIOS for root bus devloaders, 00524 or FLOP, ESDI, SCSI, etc for others */ 00525 AdvFormat = (szInfo != NULL); 00526 break; 00527 } 00528 00529 case CM_PROB_DEVLOADER_NOT_FOUND: 00530 { 00531 /* FIXME - 4 cases: 00532 1) if it's a missing system devloader: 00533 - get the system devloader name 00534 2) if it's not a system devloader but still missing: 00535 - get the devloader name (file name?) 00536 3) if it's not a system devloader but the file can be found: 00537 - use IDS_DEV_DEVLOADER_NOT_FOUND2 00538 4) if it's a missing or empty software key 00539 - use IDS_DEV_DEVLOADER_NOT_FOUND3 00540 - AdvFormat = FALSE! 00541 */ 00542 AdvFormat = (szInfo != NULL); 00543 break; 00544 } 00545 00546 case CM_PROB_INVALID_DATA: 00547 /* FIXME - if the device isn't enumerated by the BIOS/ACPI use IDS_DEV_INVALID_DATA2 */ 00548 AdvFormat = FALSE; 00549 break; 00550 00551 case CM_PROB_NORMAL_CONFLICT: 00552 /* FIXME - get resource type (IRQ, DMA, Memory or I/O) */ 00553 AdvFormat = (szInfo != NULL); 00554 break; 00555 00556 case CM_PROB_UNKNOWN_RESOURCE: 00557 /* FIXME - get the .inf file name */ 00558 AdvFormat = (szInfo != NULL); 00559 break; 00560 00561 case CM_PROB_DISABLED: 00562 /* FIXME - if the device was disabled by the system use IDS_DEV_DISABLED2 */ 00563 break; 00564 00565 case CM_PROB_FAILED_ADD: 00566 /* FIXME - get the name of the sub-device with the error */ 00567 AdvFormat = (szInfo != NULL); 00568 break; 00569 } 00570 00571 if (AdvFormat) 00572 { 00573 StringIDs[1] = IDS_DEVCODE2; 00574 dwRet = LoadAndFormatStringsCat(hDllInstance, 00575 StringIDs, 00576 sizeof(StringIDs) / sizeof(StringIDs[0]), 00577 &szProblem, 00578 szInfo, 00579 uProblemId); 00580 LocalFree((HLOCAL)szInfo); 00581 } 00582 else 00583 { 00584 dwRet = LoadAndFormatStringsCat(hDllInstance, 00585 StringIDs, 00586 sizeof(StringIDs) / sizeof(StringIDs[0]), 00587 &szProblem, 00588 uProblemId); 00589 } 00590 00591 if (dwRet != 0) 00592 { 00593 if (uMaxString != 0 && uMaxString >= dwRet) 00594 { 00595 wcscpy(lpString, 00596 szProblem); 00597 } 00598 00599 LocalFree((HLOCAL)szProblem); 00600 00601 Ret = dwRet; 00602 } 00603 } 00604 00605 return Ret; 00606 } Generated on Sun May 27 2012 04:23:26 for ReactOS by
1.7.6.1
|