From 52097a19f9eac39db1023014e6ca325a9f51c176 Mon Sep 17 00:00:00 2001 From: Magnus Lindhe Date: Sat, 12 Oct 2024 15:44:09 +0200 Subject: [PATCH 1/2] Added FACILITY_WINDOWSUPDATE codes --- .../FacilityWindowsUpdateResolver.cs | 318 ++++++++++++++++++ src/Elmah.Io.HResults/IntExtensions.cs | 3 +- test/Elmah.Io.HResults.Test/HResultTest.cs | 18 + 3 files changed, 337 insertions(+), 2 deletions(-) create mode 100644 src/Elmah.Io.HResults/Facilities/FacilityWindowsUpdateResolver.cs diff --git a/src/Elmah.Io.HResults/Facilities/FacilityWindowsUpdateResolver.cs b/src/Elmah.Io.HResults/Facilities/FacilityWindowsUpdateResolver.cs new file mode 100644 index 0000000..b525e9a --- /dev/null +++ b/src/Elmah.Io.HResults/Facilities/FacilityWindowsUpdateResolver.cs @@ -0,0 +1,318 @@ +using System; +using System.Collections.Generic; +using System.Text; +using static System.Net.WebRequestMethods; + +namespace Elmah.Io.HResults.Facilities +{ + internal class FacilityWindowsUpdateResolver : FacilityResolverBase + { + public FacilityWindowsUpdateResolver() : base(36, "FACILITY_WINDOWSUPDATE") + { + } + + internal override Code Resolve(bool failure, int code) + { + if (!failure) + { + return code switch + { + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#windows-update-success-codes + 0x0001 => new Code(code, "WU_S_SERVICE_STOP", "Windows Update Agent was stopped successfully."), + 0x0002 => new Code(code, "WU_S_SELFUPDATE", "Windows Update Agent updated itself."), + 0x0003 => new Code(code, "WU_S_UPDATE_ERROR", "Operation completed successfully but there were errors applying the updates."), + 0x0004 => new Code(code, "WU_S_MARKED_FOR_DISCONNECT", "A callback was marked to be disconnected later because the request to disconnect the operation came while a callback was executing."), + 0x0005 => new Code(code, "WU_S_REBOOT_REQUIRED", "The system must be restarted to complete installation of the update."), + 0x0006 => new Code(code, "WU_S_ALREADY_INSTALLED", "The update to be installed is already installed on the system."), + 0x0007 => new Code(code, "WU_S_ALREADY_UNINSTALLED", "The update to be removed isn't installed on the system."), + 0x0008 => new Code(code, "WU_S_ALREADY_DOWNLOADED", "The update to be downloaded has already been downloaded."), + _ => base.Resolve(failure, code) + }; + } + + return code switch + { + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#automatic-update-errors + 0xA000 => new Code(code, "WU_E_AU_NOSERVICE", "Automatic Updates was unable to service incoming requests."), + 0xA002 => new Code(code, "WU_E_AU_NONLEGACYSERVER", "The old version of the Automatic Updates client has stopped because the WSUS server has been upgraded."), + 0xA003 => new Code(code, "WU_E_AU_LEGACYCLIENTDISABLED", "The old version of the Automatic Updates client was disabled."), + 0xA004 => new Code(code, "WU_E_AU_PAUSED", "Automatic Updates was unable to process incoming requests because it was paused."), + 0xA005 => new Code(code, "WU_E_AU_NO_REGISTERED_SERVICE", "No unmanaged service is registered with AU."), + 0xAFFF => new Code(code, "WU_E_AU_UNEXPECTED", "An Automatic Updates error not covered by another WU_E_AU* code."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#windows-update-ui-errors + 0x3001 => new Code(code, "WU_E_INSTALLATION_RESULTS_UNKNOWN_VERSION", "The results of download and installation couldn't be read from the registry due to an unrecognized data format version."), + 0x3002 => new Code(code, "WU_E_INSTALLATION_RESULTS_INVALID_DATA", "The results of download and installation couldn't be read from the registry due to an invalid data format."), + 0x3003 => new Code(code, "WU_E_INSTALLATION_RESULTS_NOT_FOUND", "The results of download and installation aren't available; the operation may have failed to start."), + 0x3004 => new Code(code, "WU_E_TRAYICON_FAILURE", "A failure occurred when trying to create an icon in the taskbar notification area."), + 0x3FFD => new Code(code, "WU_E_NON_UI_MODE", "Unable to show UI when in non-UI mode; Windows Update client UI modules may not be installed."), + 0x3FFE => new Code(code, "WU_E_WUCLTUI_UNSUPPORTED_VERSION", "Unsupported version of Windows Update client UI exported functions."), + 0x3FFF => new Code(code, "WU_E_AUCLIENT_UNEXPECTED", "There was a user interface error not covered by another WU_E_AUCLIENT_* error code."), + 0x043D => new Code(code, "WU_E_SERVICEPROP_NOTAVAIL", "The requested service property isn't available."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#inventory-errors + 0x9001 => new Code(code, "WU_E_INVENTORY_PARSEFAILED", "Parsing of the rule file failed."), + 0x9002 => new Code(code, "WU_E_INVENTORY_GET_INVENTORY_TYPE_FAILED", "Failed to get the requested inventory type from the server."), + 0x9003 => new Code(code, "WU_E_INVENTORY_RESULT_UPLOAD_FAILED", "Failed to upload inventory result to the server."), + 0x9004 => new Code(code, "WU_E_INVENTORY_UNEXPECTED", "There was an inventory error not covered by another error code."), + 0x9005 => new Code(code, "WU_E_INVENTORY_WMI_ERROR", "A WMI error occurred when enumerating the instances for a particular class."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#expression-evaluator-errors + 0xE001 => new Code(code, "WU_E_EE_UNKNOWN_EXPRESSION", "An expression evaluator operation couldn't be completed because an expression was unrecognized."), + 0xE002 => new Code(code, "WU_E_EE_INVALID_EXPRESSION", "An expression evaluator operation couldn't be completed because an expression was invalid."), + 0xE003 => new Code(code, "WU_E_EE_MISSING_METADATA", "An expression evaluator operation couldn't be completed because an expression contains an incorrect number of metadata nodes."), + 0xE004 => new Code(code, "WU_E_EE_INVALID_VERSION", "An expression evaluator operation couldn't be completed because the version of the serialized expression data is invalid."), + 0xE005 => new Code(code, "WU_E_EE_NOT_INITIALIZED", "The expression evaluator couldn't be initialized."), + 0xE006 => new Code(code, "WU_E_EE_INVALID_ATTRIBUTEDATA", "An expression evaluator operation couldn't be completed because there was an invalid attribute."), + 0xE007 => new Code(code, "WU_E_EE_CLUSTER_ERROR", "An expression evaluator operation couldn't be completed because the cluster state of the computer couldn't be determined."), + 0xEFFF => new Code(code, "WU_E_EE_UNEXPECTED", "There was an expression evaluator error not covered by another WU_E_EE_* error code."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#reporter-errors + 0x7001 => new Code(code, "WU_E_OL_INVALID_SCANFILE", "An operation couldn't be completed because the scan package was invalid."), + 0x7002 => new Code(code, "WU_E_OL_NEWCLIENT_REQUIRED", "An operation couldn't be completed because the scan package requires a greater version of the Windows Update Agent."), + 0x7FFF => new Code(code, "WU_E_OL_UNEXPECTED", "Search using the scan package failed."), + 0xF001 => new Code(code, "WU_E_REPORTER_EVENTCACHECORRUPT", "The event cache file was defective."), + 0xF002 => new Code(code, "WU_E_REPORTER_EVENTNAMESPACEPARSEFAILED", "The XML in the event namespace descriptor couldn't be parsed."), + 0xF003 => new Code(code, "WU_E_INVALID_EVENT", "The XML in the event namespace descriptor couldn't be parsed."), + 0xF004 => new Code(code, "WU_E_SERVER_BUSY", "The server rejected an event because the server was too busy."), + 0xFFFF => new Code(code, "WU_E_REPORTER_UNEXPECTED", "There was a reporter error not covered by another error code."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#redirector-errors + 0x5001 => new Code(code, "WU_E_REDIRECTOR_LOAD_XML", "The redirector XML document couldn't be loaded into the DOM class."), + 0x5002 => new Code(code, "WU_E_REDIRECTOR_S_FALSE", "The redirector XML document is missing some required information."), + 0x5003 => new Code(code, "WU_E_REDIRECTOR_ID_SMALLER", "The redirectorId in the downloaded redirector cab is less than in the cached cab."), + 0x5FFF => new Code(code, "WU_E_REDIRECTOR_UNEXPECTED", "The redirector failed for reasons not covered by another WU_E_REDIRECTOR_* error code."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#protocol-talker-errors + 0x4000 => new Code(code, "WU_E_PT_SOAPCLIENT_BASE", "WU_E_PT_SOAPCLIENT_* error codes map to the SOAPCLIENT_ERROR enum of the ATL Server Library."), + 0x4001 => new Code(code, "WU_E_PT_SOAPCLIENT_INITIALIZE", "Same as SOAPCLIENT_INITIALIZE_ERROR - initialization of the SOAP client failed possibly because of an MSXML installation failure."), + 0x4002 => new Code(code, "WU_E_PT_SOAPCLIENT_OUTOFMEMORY", "Same as SOAPCLIENT_OUTOFMEMORY - SOAP client failed because it ran out of memory."), + 0x4003 => new Code(code, "WU_E_PT_SOAPCLIENT_GENERATE", "Same as SOAPCLIENT_GENERATE_ERROR - SOAP client failed to generate the request."), + 0x4004 => new Code(code, "WU_E_PT_SOAPCLIENT_CONNECT", "Same as SOAPCLIENT_CONNECT_ERROR - SOAP client failed to connect to the server."), + 0x4005 => new Code(code, "WU_E_PT_SOAPCLIENT_SEND", "Same as SOAPCLIENT_SEND_ERROR - SOAP client failed to send a message for reasons of WU_E_WINHTTP_* error codes."), + 0x4006 => new Code(code, "WU_E_PT_SOAPCLIENT_SERVER", "Same as SOAPCLIENT_SERVER_ERROR - SOAP client failed because there was a server error."), + 0x4007 => new Code(code, "WU_E_PT_SOAPCLIENT_SOAPFAULT", "Same as SOAPCLIENT_SOAPFAULT - SOAP client failed because there was a SOAP fault for reasons of WU_E_PT_SOAP_* error codes."), + 0x4008 => new Code(code, "WU_E_PT_SOAPCLIENT_PARSEFAULT", "Same as SOAPCLIENT_PARSEFAULT_ERROR - SOAP client failed to parse a SOAP fault."), + 0x4009 => new Code(code, "WU_E_PT_SOAPCLIENT_READ", "Same as SOAPCLIENT_READ_ERROR - SOAP client failed while reading the response from the server."), + 0x400A => new Code(code, "WU_E_PT_SOAPCLIENT_PARSE", "Same as SOAPCLIENT_PARSE_ERROR - SOAP client failed to parse the response from the server."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#other-protocol-talker-errors + 0x400B => new Code(code, "WU_E_PT_SOAP_VERSION", "Same as SOAP_E_VERSION_MISMATCH - SOAP client found an unrecognizable namespace for the SOAP envelope."), + 0x400C => new Code(code, "WU_E_PT_SOAP_MUST_UNDERSTAND", "Same as SOAP_E_MUST_UNDERSTAND - SOAP client was unable to understand a header."), + 0x400D => new Code(code, "WU_E_PT_SOAP_CLIENT", "Same as SOAP_E_CLIENT - SOAP client found the message was malformed; fix before resending."), + 0x400E => new Code(code, "WU_E_PT_SOAP_SERVER", "Same as SOAP_E_SERVER - The SOAP message couldn't be processed due to a server error; resend later."), + 0x400F => new Code(code, "WU_E_PT_WMI_ERROR", "There was an unspecified Windows Management Instrumentation (WMI) error."), + 0x4010 => new Code(code, "WU_E_PT_EXCEEDED_MAX_SERVER_TRIPS", "The number of round trips to the server exceeded the maximum limit."), + 0x4011 => new Code(code, "WU_E_PT_SUS_SERVER_NOT_SET", "WUServer policy value is missing in the registry."), + 0x4012 => new Code(code, "WU_E_PT_DOUBLE_INITIALIZATION", "Initialization failed because the object was already initialized."), + 0x4013 => new Code(code, "WU_E_PT_INVALID_COMPUTER_NAME", "The computer name couldn't be determined."), + 0x4015 => new Code(code, "WU_E_PT_REFRESH_CACHE_REQUIRED", "The reply from the server indicates that the server was changed or the cookie was invalid; refresh the state of the internal cache and retry."), + 0x4016 => new Code(code, "WU_E_PT_HTTP_STATUS_BAD_REQUEST", "Same as HTTP status 400 - the server couldn't process the request due to invalid syntax."), + 0x4017 => new Code(code, "WU_E_PT_HTTP_STATUS_DENIED", "Same as HTTP status 401 - the requested resource requires user authentication."), + 0x4018 => new Code(code, "WU_E_PT_HTTP_STATUS_FORBIDDEN", "Same as HTTP status 403 - server understood the request but declined to fulfill it."), + 0x4019 => new Code(code, "WU_E_PT_HTTP_STATUS_NOT_FOUND", "Same as HTTP status 404 - the server can't find the requested URI (Uniform Resource Identifier)."), + 0x401A => new Code(code, "WU_E_PT_HTTP_STATUS_BAD_METHOD", "Same as HTTP status 405 - the HTTP method isn't allowed."), + 0x401B => new Code(code, "WU_E_PT_HTTP_STATUS_PROXY_AUTH_REQ", "Same as HTTP status 407 - proxy authentication is required."), + 0x401C => new Code(code, "WU_E_PT_HTTP_STATUS_REQUEST_TIMEOUT", "Same as HTTP status 408 - the server timed out waiting for the request."), + 0x401D => new Code(code, "WU_E_PT_HTTP_STATUS_CONFLICT", "Same as HTTP status 409 - the request wasn't completed due to a conflict with the current state of the resource."), + 0x401E => new Code(code, "WU_E_PT_HTTP_STATUS_GONE", "Same as HTTP status 410 - requested resource is no longer available at the server."), + 0x401F => new Code(code, "WU_E_PT_HTTP_STATUS_SERVER_ERROR", "Same as HTTP status 500 - an error internal to the server prevented fulfilling the request."), + 0x4020 => new Code(code, "WU_E_PT_HTTP_STATUS_NOT_SUPPORTED", "Same as HTTP status 500 - server doesn't support the functionality required to fulfill the request."), + 0x4021 => new Code(code, "WU_E_PT_HTTP_STATUS_BAD_GATEWAY", "Same as HTTP status 502 - the server while acting as a gateway or a proxy received an invalid response from the upstream server it accessed in attempting to fulfill the request."), + 0x4022 => new Code(code, "WU_E_PT_HTTP_STATUS_SERVICE_UNAVAIL", "Same as HTTP status 503 - the service is temporarily overloaded."), + 0x4023 => new Code(code, "WU_E_PT_HTTP_STATUS_GATEWAY_TIMEOUT", "Same as HTTP status 503 - the request was timed out waiting for a gateway."), + 0x4024 => new Code(code, "WU_E_PT_HTTP_STATUS_VERSION_NOT_SUP", "Same as HTTP status 505 - the server doesn't support the HTTP protocol version used for the request."), + 0x4025 => new Code(code, "WU_E_PT_FILE_LOCATIONS_CHANGED", "Operation failed due to a changed file location; refresh internal state and resend."), + 0x4026 => new Code(code, "WU_E_PT_REGISTRATION_NOT_SUPPORTED", "Operation failed because Windows Update Agent doesn't support registration with a non-WSUS server."), + 0x4027 => new Code(code, "WU_E_PT_NO_AUTH_PLUGINS_REQUESTED", "The server returned an empty authentication information list."), + 0x4028 => new Code(code, "WU_E_PT_NO_AUTH_COOKIES_CREATED", "Windows Update Agent was unable to create any valid authentication cookies."), + 0x4029 => new Code(code, "WU_E_PT_INVALID_CONFIG_PROP", "A configuration property value was wrong."), + 0x402A => new Code(code, "WU_E_PT_CONFIG_PROP_MISSING", "A configuration property value was missing."), + 0x402B => new Code(code, "WU_E_PT_HTTP_STATUS_NOT_MAPPED", "The HTTP request couldn't be completed and the reason didn't correspond to any of the WU_E_PT_HTTP_* error codes."), + 0x402C => new Code(code, "WU_E_PT_WINHTTP_NAME_NOT_RESOLVED", "Same as ERROR_WINHTTP_NAME_NOT_RESOLVED - the proxy server or target server name can't be resolved."), + 0x402F => new Code(code, "WU_E_PT_ECP_SUCCEEDED_WITH_ERRORS", "External cab file processing completed with some errors."), + 0x4030 => new Code(code, "WU_E_PT_ECP_INIT_FAILED", "The external cab processor initialization didn't complete."), + 0x4031 => new Code(code, "WU_E_PT_ECP_INVALID_FILE_FORMAT", "The format of a metadata file was invalid."), + 0x4032 => new Code(code, "WU_E_PT_ECP_INVALID_METADATA", "External cab processor found invalid metadata."), + 0x4033 => new Code(code, "WU_E_PT_ECP_FAILURE_TO_EXTRACT_DIGEST", "The file digest couldn't be extracted from an external cab file."), + 0x4034 => new Code(code, "WU_E_PT_ECP_FAILURE_TO_DECOMPRESS_CAB_FILE", "An external cab file couldn't be decompressed."), + 0x4035 => new Code(code, "WU_E_PT_ECP_FILE_LOCATION_ERROR", "External cab processor was unable to get file locations."), + 0x4FFF => new Code(code, "WU_E_PT_UNEXPECTED", "A communication error not covered by another WU_E_PT_* error code."), + 0x502D => new Code(code, "WU_E_PT_SAME_REDIR_ID", "Windows Update Agent failed to download a redirector cabinet file with a new redirectorId value from the server during the recovery."), + 0x502E => new Code(code, "WU_E_PT_NO_MANAGED_RECOVER", "A redirector recovery action didn't complete because the server is managed."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#download-manager-errors + 0x6001 => new Code(code, "WU_E_DM_URLNOTAVAILABLE", "A download manager operation couldn't be completed because the requested file doesn't have a URL."), + 0x6002 => new Code(code, "WU_E_DM_INCORRECTFILEHASH", "A download manager operation couldn't be completed because the file digest wasn't recognized."), + 0x6003 => new Code(code, "WU_E_DM_UNKNOWNALGORITHM", "A download manager operation couldn't be completed because the file metadata requested an unrecognized hash algorithm."), + 0x6004 => new Code(code, "WU_E_DM_NEEDDOWNLOADREQUEST", "An operation couldn't be completed because a download request is required from the download handler."), + 0x6005 => new Code(code, "WU_E_DM_NONETWORK", "A download manager operation couldn't be completed because the network connection was unavailable."), + 0x6006 => new Code(code, "WU_E_DM_WRONGBITSVERSION", "A download manager operation couldn't be completed because the version of Background Intelligent Transfer Service (BITS) is incompatible."), + 0x6007 => new Code(code, "WU_E_DM_NOTDOWNLOADED", "The update hasn't been downloaded."), + 0x6008 => new Code(code, "WU_E_DM_FAILTOCONNECTTOBITS", "A download manager operation failed because the download manager was unable to connect to the Background Intelligent Transfer Service (BITS)."), + 0x6009 => new Code(code, "WU_E_DM_BITSTRANSFERERROR", "A download manager operation failed because there was an unspecified Background Intelligent Transfer Service (BITS) transfer error."), + 0x600A => new Code(code, "WU_E_DM_DOWNLOADLOCATIONCHANGED", "A download must be restarted because the location of the source of the download has changed."), + 0x600B => new Code(code, "WU_E_DM_CONTENTCHANGED", "A download must be restarted because the update content changed in a new revision."), + 0x6FFF => new Code(code, "WU_E_DM_UNEXPECTED", "There was a download manager error not covered by another WU_E_DM_* error code."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#update-handler-errors + 0x2000 => new Code(code, "WU_E_UH_REMOTEUNAVAILABLE", "A request for a remote update handler couldn't be completed because no remote process is available."), + 0x2001 => new Code(code, "WU_E_UH_LOCALONLY", "A request for a remote update handler couldn't be completed because the handler is local only."), + 0x2002 => new Code(code, "WU_E_UH_UNKNOWNHANDLER", "A request for an update handler couldn't be completed because the handler couldn't be recognized."), + 0x2003 => new Code(code, "WU_E_UH_REMOTEALREADYACTIVE", "A remote update handler couldn't be created because one already exists."), + 0x2004 => new Code(code, "WU_E_UH_DOESNOTSUPPORTACTION", "A request for the handler to install (uninstall) an update couldn't be completed because the update doesn't support install (uninstall)."), + 0x2005 => new Code(code, "WU_E_UH_WRONGHANDLER", "An operation didn't complete because the wrong handler was specified."), + 0x2006 => new Code(code, "WU_E_UH_INVALIDMETADATA", "A handler operation couldn't be completed because the update contains invalid metadata."), + 0x2007 => new Code(code, "WU_E_UH_INSTALLERHUNG", "An operation couldn't be completed because the installer exceeded the time limit."), + 0x2008 => new Code(code, "WU_E_UH_OPERATIONCANCELLED", "An operation being done by the update handler was canceled."), + 0x2009 => new Code(code, "WU_E_UH_BADHANDLERXML", "An operation couldn't be completed because the handler-specific metadata is invalid."), + 0x200A => new Code(code, "WU_E_UH_CANREQUIREINPUT", "A request to the handler to install an update couldn't be completed because the update requires user input."), + 0x200B => new Code(code, "WU_E_UH_INSTALLERFAILURE", "The installer failed to install (uninstall) one or more updates."), + 0x200C => new Code(code, "WU_E_UH_FALLBACKTOSELFCONTAINED", "The update handler should download self-contained content rather than delta-compressed content for the update."), + 0x200D => new Code(code, "WU_E_UH_NEEDANOTHERDOWNLOAD", "The update handler didn't install the update because it needs to be downloaded again."), + 0x200E => new Code(code, "WU_E_UH_NOTIFYFAILURE", "The update handler failed to send notification of the status of the install (uninstall) operation."), + 0x200F => new Code(code, "WU_E_UH_INCONSISTENT_FILE_NAMES", "The file names contained in the update metadata and in the update package are inconsistent."), + 0x2010 => new Code(code, "WU_E_UH_FALLBACKERROR", "The update handler failed to fall back to the self-contained content."), + 0x2011 => new Code(code, "WU_E_UH_TOOMANYDOWNLOADREQUESTS", "The update handler has exceeded the maximum number of download requests."), + 0x2012 => new Code(code, "WU_E_UH_UNEXPECTEDCBSRESPONSE", "The update handler has received an unexpected response from CBS."), + 0x2013 => new Code(code, "WU_E_UH_BADCBSPACKAGEID", "The update metadata contains an invalid CBS package identifier."), + 0x2014 => new Code(code, "WU_E_UH_POSTREBOOTSTILLPENDING", "The post-reboot operation for the update is still in progress."), + 0x2015 => new Code(code, "WU_E_UH_POSTREBOOTRESULTUNKNOWN", "The result of the post-reboot operation for the update couldn't be determined."), + 0x2016 => new Code(code, "WU_E_UH_POSTREBOOTUNEXPECTEDSTATE", "The state of the update after its post-reboot operation has completed is unexpected."), + 0x2017 => new Code(code, "WU_E_UH_NEW_SERVICING_STACK_REQUIRED", "The OS servicing stack must be updated before this update is downloaded or installed."), + 0x2FFF => new Code(code, "WU_E_UH_UNEXPECTED", "An update handler error not covered by another WU_E_UH_* code."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#data-store-errors + 0x8000 => new Code(code, "WU_E_DS_SHUTDOWN", "An operation failed because Windows Update Agent is shutting down."), + 0x8001 => new Code(code, "WU_E_DS_INUSE", "An operation failed because the data store was in use."), + 0x8002 => new Code(code, "WU_E_DS_INVALID", "The current and expected states of the data store don't match."), + 0x8003 => new Code(code, "WU_E_DS_TABLEMISSING", "The data store is missing a table."), + 0x8004 => new Code(code, "WU_E_DS_TABLEINCORRECT", "The data store contains a table with unexpected columns."), + 0x8005 => new Code(code, "WU_E_DS_INVALIDTABLENAME", "A table couldn't be opened because the table isn't in the data store."), + 0x8006 => new Code(code, "WU_E_DS_BADVERSION", "The current and expected versions of the data store don't match."), + 0x8007 => new Code(code, "WU_E_DS_NODATA", "The information requested isn't in the data store."), + 0x8008 => new Code(code, "WU_E_DS_MISSINGDATA", "The data store is missing required information or has a NULL in a table column that requires a non-null value."), + 0x8009 => new Code(code, "WU_E_DS_MISSINGREF", "The data store is missing required information or has a reference to missing license terms file localized property or linked row."), + 0x800A => new Code(code, "WU_E_DS_UNKNOWNHANDLER", "The update wasn't processed because its update handler couldn't be recognized."), + 0x800B => new Code(code, "WU_E_DS_CANTDELETE", "The update wasn't deleted because it's still referenced by one or more services."), + 0x800C => new Code(code, "WU_E_DS_LOCKTIMEOUTEXPIRED", "The data store section couldn't be locked within the allotted time."), + 0x800D => new Code(code, "WU_E_DS_NOCATEGORIES", "The category wasn't added because it contains no parent categories and isn't a top-level category itself."), + 0x800E => new Code(code, "WU_E_DS_ROWEXISTS", "The row wasn't added because an existing row has the same primary key."), + 0x800F => new Code(code, "WU_E_DS_STOREFILELOCKED", "The data store couldn't be initialized because it was locked by another process."), + 0x8010 => new Code(code, "WU_E_DS_CANNOTREGISTER", "The data store isn't allowed to be registered with COM in the current process."), + 0x8011 => new Code(code, "WU_E_DS_UNABLETOSTART", "Couldn't create a data store object in another process."), + 0x8013 => new Code(code, "WU_E_DS_DUPLICATEUPDATEID", "The server sent the same update to the client with two different revision IDs."), + 0x8014 => new Code(code, "WU_E_DS_UNKNOWNSERVICE", "An operation didn't complete because the service isn't in the data store."), + 0x8015 => new Code(code, "WU_E_DS_SERVICEEXPIRED", "An operation didn't complete because the registration of the service has expired."), + 0x8016 => new Code(code, "WU_E_DS_DECLINENOTALLOWED", "A request to hide an update was declined because it's a mandatory update or because it was deployed with a deadline."), + 0x8017 => new Code(code, "WU_E_DS_TABLESESSIONMISMATCH", "A table wasn't closed because it isn't associated with the session."), + 0x8018 => new Code(code, "WU_E_DS_SESSIONLOCKMISMATCH", "A table wasn't closed because it isn't associated with the session."), + 0x8019 => new Code(code, "WU_E_DS_NEEDWINDOWSSERVICE", "A request to remove the Windows Update service or to unregister it with Automatic Updates was declined because it's a built-in service and/or Automatic Updates can't fall back to another service."), + 0x801A => new Code(code, "WU_E_DS_INVALIDOPERATION", "A request was declined because the operation isn't allowed."), + 0x801B => new Code(code, "WU_E_DS_SCHEMAMISMATCH", "The schema of the current data store and the schema of a table in a backup XML document don't match."), + 0x801C => new Code(code, "WU_E_DS_RESETREQUIRED", "The data store requires a session reset; release the session and retry with a new session."), + 0x801D => new Code(code, "WU_E_DS_IMPERSONATED", "A data store operation didn't complete because it was requested with an impersonated identity."), + 0x8FFF => new Code(code, "WU_E_DS_UNEXPECTED", "A data store error not covered by another WU_E_DS_* code."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#driver-util-errors + 0xC001 => new Code(code, "WU_E_DRV_PRUNED", "A driver was skipped."), + 0xC002 => new Code(code, "WU_E_DRV_NOPROP_OR_LEGACY", "A property for the driver couldn't be found. It may not conform with required specifications."), + 0xC003 => new Code(code, "WU_E_DRV_REG_MISMATCH", "The registry type read for the driver doesn't match the expected type."), + 0xC004 => new Code(code, "WU_E_DRV_NO_METADATA", "The driver update is missing metadata."), + 0xC005 => new Code(code, "WU_E_DRV_MISSING_ATTRIBUTE", "The driver update is missing a required attribute."), + 0xC006 => new Code(code, "WU_E_DRV_SYNC_FAILED", "Driver synchronization failed."), + 0xC007 => new Code(code, "WU_E_DRV_NO_PRINTER_CONTENT", "Information required for the synchronization of applicable printers is missing."), + 0xCFFF => new Code(code, "WU_E_DRV_UNEXPECTED", "A driver error not covered by another WU_E_DRV_* code."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#windows-update-error-codes + 0x0001 => new Code(code, "WU_E_NO_SERVICE", "Windows Update Agent was unable to provide the service."), + 0x0002 => new Code(code, "WU_E_MAX_CAPACITY_REACHED", "The maximum capacity of the service was exceeded."), + 0x0003 => new Code(code, "WU_E_UNKNOWN_ID", "An ID can't be found."), + 0x0004 => new Code(code, "WU_E_NOT_INITIALIZED", "The object couldn't be initialized."), + 0x0005 => new Code(code, "WU_E_RANGEOVERLAP", "The update handler requested a byte range overlapping a previously requested range."), + 0x0006 => new Code(code, "WU_E_TOOMANYRANGES", "The requested number of byte ranges exceeds the maximum number (2^31 - 1)."), + 0x0007 => new Code(code, "WU_E_INVALIDINDEX", "The index to a collection was invalid."), + 0x0008 => new Code(code, "WU_E_ITEMNOTFOUND", "The key for the item queried couldn't be found."), + 0x0009 => new Code(code, "WU_E_OPERATIONINPROGRESS", "Another conflicting operation was in progress. Some operations such as installation can't be performed twice simultaneously."), + 0x000A => new Code(code, "WU_E_COULDNOTCANCEL", "Cancellation of the operation wasn't allowed."), + 0x000B => new Code(code, "WU_E_CALL_CANCELLED", "Operation was canceled."), + 0x000C => new Code(code, "WU_E_NOOP", "No operation was required."), + 0x000D => new Code(code, "WU_E_XML_MISSINGDATA", "Windows Update Agent couldn't find required information in the update's XML data."), + 0x000E => new Code(code, "WU_E_XML_INVALID", "Windows Update Agent found invalid information in the update's XML data."), + 0x000F => new Code(code, "WU_E_CYCLE_DETECTED", "Circular update relationships were detected in the metadata."), + 0x0010 => new Code(code, "WU_E_TOO_DEEP_RELATION", "Update relationships too deep to evaluate were evaluated."), + 0x0011 => new Code(code, "WU_E_INVALID_RELATIONSHIP", "An invalid update relationship was detected."), + 0x0012 => new Code(code, "WU_E_REG_VALUE_INVALID", "An invalid registry value was read."), + 0x0013 => new Code(code, "WU_E_DUPLICATE_ITEM", "Operation tried to add a duplicate item to a list."), + 0x0016 => new Code(code, "WU_E_INSTALL_NOT_ALLOWED", "Operation tried to install while another installation was in progress or the system was pending a mandatory restart."), + 0x0017 => new Code(code, "WU_E_NOT_APPLICABLE", "Operation wasn't performed because there are no applicable updates."), + 0x0018 => new Code(code, "WU_E_NO_USERTOKEN", "Operation failed because a required user token is missing."), + 0x0019 => new Code(code, "WU_E_EXCLUSIVE_INSTALL_CONFLICT", "An exclusive update can't be installed with other updates at the same time."), + 0x001A => new Code(code, "WU_E_POLICY_NOT_SET", "A policy value wasn't set."), + 0x001B => new Code(code, "WU_E_SELFUPDATE_IN_PROGRESS", "The operation couldn't be performed because the Windows Update Agent is self-updating."), + 0x001D => new Code(code, "WU_E_INVALID_UPDATE", "An update contains invalid metadata."), + 0x001E => new Code(code, "WU_E_SERVICE_STOP", "Operation didn't complete because the service or system was being shut down."), + 0x001F => new Code(code, "WU_E_NO_CONNECTION", "Operation didn't complete because the network connection was unavailable."), + 0x0020 => new Code(code, "WU_E_NO_INTERACTIVE_USER", "Operation didn't complete because there's no logged-on interactive user."), + 0x0021 => new Code(code, "WU_E_TIME_OUT", "Operation didn't complete because it timed out."), + 0x0022 => new Code(code, "WU_E_ALL_UPDATES_FAILED", "Operation failed for all the updates."), + 0x0023 => new Code(code, "WU_E_EULAS_DECLINED", "The license terms for all updates were declined."), + 0x0024 => new Code(code, "WU_E_NO_UPDATE", "There are no updates."), + 0x0025 => new Code(code, "WU_E_USER_ACCESS_DISABLED", "Group Policy settings prevented access to Windows Update."), + 0x0026 => new Code(code, "WU_E_INVALID_UPDATE_TYPE", "The type of update is invalid."), + 0x0027 => new Code(code, "WU_E_URL_TOO_LONG", "The URL exceeded the maximum length."), + 0x0028 => new Code(code, "WU_E_UNINSTALL_NOT_ALLOWED", "The update couldn't be uninstalled because the request didn't originate from a WSUS server."), + 0x0029 => new Code(code, "WU_E_INVALID_PRODUCT_LICENSE", "Search may have missed some updates before there's an unlicensed application on the system."), + 0x002A => new Code(code, "WU_E_MISSING_HANDLER", "A component required to detect applicable updates was missing."), + 0x002B => new Code(code, "WU_E_LEGACYSERVER", "An operation didn't complete because it requires a newer version of server."), + 0x002C => new Code(code, "WU_E_BIN_SOURCE_ABSENT", "A delta-compressed update couldn't be installed because it required the source."), + 0x002D => new Code(code, "WU_E_SOURCE_ABSENT", "A full-file update couldn't be installed because it required the source."), + 0x002E => new Code(code, "WU_E_WU_DISABLED", "Access to an unmanaged server isn't allowed."), + 0x002F => new Code(code, "WU_E_CALL_CANCELLED_BY_POLICY", "Operation didn't complete because the DisableWindowsUpdateAccess policy was set."), + 0x0030 => new Code(code, "WU_E_INVALID_PROXY_SERVER", "The format of the proxy list was invalid."), + 0x0031 => new Code(code, "WU_E_INVALID_FILE", "The file is in the wrong format."), + 0x0032 => new Code(code, "WU_E_INVALID_CRITERIA", "The search criteria string was invalid."), + 0x0033 => new Code(code, "WU_E_EULA_UNAVAILABLE", "License terms couldn't be downloaded."), + 0x0034 => new Code(code, "WU_E_DOWNLOAD_FAILED", "Update failed to download."), + 0x0035 => new Code(code, "WU_E_UPDATE_NOT_PROCESSED", "The update wasn't processed."), + 0x0036 => new Code(code, "WU_E_INVALID_OPERATION", "The object's current state didn't allow the operation."), + 0x0037 => new Code(code, "WU_E_NOT_SUPPORTED", "The functionality for the operation isn't supported."), + 0x0038 => new Code(code, "WU_E_WINHTTP_INVALID_FILE", "The downloaded file has an unexpected content type."), + 0x0039 => new Code(code, "WU_E_TOO_MANY_RESYNC", "Agent is asked by server to resync too many times."), + 0x0040 => new Code(code, "WU_E_NO_SERVER_CORE_SUPPORT", "WUA API method doesn't run on Server Core installation."), + 0x0041 => new Code(code, "WU_E_SYSPREP_IN_PROGRESS", "Service isn't available while sysprep is running."), + 0x0042 => new Code(code, "WU_E_UNKNOWN_SERVICE", "The update service is no longer registered with AU."), + 0x0043 => new Code(code, "WU_E_NO_UI_SUPPORT", "There's no support for WUA UI."), + 0x0FFF => new Code(code, "WU_E_UNEXPECTED", "An operation failed due to reasons not covered by another error code."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#windows-installer-minor-errors + 0x1001 => new Code(code, "WU_E_MSI_WRONG_VERSION", "Search may have missed some updates because the Windows Installer is less than version 3.1."), + 0x1002 => new Code(code, "WU_E_MSI_NOT_CONFIGURED", "Search may have missed some updates because the Windows Installer isn't configured."), + 0x1003 => new Code(code, "WU_E_MSP_DISABLED", "Search may have missed some updates because policy has disabled Windows Installer patching."), + 0x1004 => new Code(code, "WU_E_MSI_WRONG_APP_CONTEXT", "An update couldn't be applied because the application is installed per-user."), + 0x1FFF => new Code(code, "WU_E_MSP_UNEXPECTED", "Search may have missed some updates because there was a failure of the Windows Installer."), + + // https://learn.microsoft.com/en-us/windows/deployment/update/windows-update-error-reference#windows-update-agent-update-and-setup-errors + 0xD001 => new Code(code, "WU_E_SETUP_INVALID_INFDATA", "Windows Update Agent couldn't be updated because an INF file contains invalid information."), + 0xD002 => new Code(code, "WU_E_SETUP_INVALID_IDENTDATA", "Windows Update Agent couldn't be updated because the wuident.cab file contains invalid information."), + 0xD003 => new Code(code, "WU_E_SETUP_ALREADY_INITIALIZED", "Windows Update Agent couldn't be updated because of an internal error that caused setup initialization to be performed twice."), + 0xD004 => new Code(code, "WU_E_SETUP_NOT_INITIALIZED", "Windows Update Agent couldn't be updated because setup initialization never completed successfully."), + 0xD005 => new Code(code, "WU_E_SETUP_SOURCE_VERSION_MISMATCH", "Windows Update Agent couldn't be updated because the versions specified in the INF don't match the actual source file versions."), + 0xD006 => new Code(code, "WU_E_SETUP_TARGET_VERSION_GREATER", "Windows Update Agent couldn't be updated because a WUA file on the target system is newer than the corresponding source file."), + 0xD007 => new Code(code, "WU_E_SETUP_REGISTRATION_FAILED", "Windows Update Agent couldn't be updated because regsvr32.exe returned an error."), + 0xD009 => new Code(code, "WU_E_SETUP_SKIP_UPDATE", "An update to the Windows Update Agent was skipped due to a directive in the wuident.cab file."), + 0xD00A => new Code(code, "WU_E_SETUP_UNSUPPORTED_CONFIGURATION", "Windows Update Agent couldn't be updated because the current system configuration isn't supported."), + 0xD00B => new Code(code, "WU_E_SETUP_BLOCKED_CONFIGURATION", "Windows Update Agent couldn't be updated because the system is configured to block the update."), + 0xD00C => new Code(code, "WU_E_SETUP_REBOOT_TO_FIX", "Windows Update Agent couldn't be updated because a restart of the system is required."), + 0xD00D => new Code(code, "WU_E_SETUP_ALREADYRUNNING", "Windows Update Agent setup is already running."), + 0xD00E => new Code(code, "WU_E_SETUP_REBOOTREQUIRED", "Windows Update Agent setup package requires a reboot to complete installation."), + 0xD00F => new Code(code, "WU_E_SETUP_HANDLER_EXEC_FAILURE", "Windows Update Agent couldn't be updated because the setup handler failed during execution."), + 0xD010 => new Code(code, "WU_E_SETUP_INVALID_REGISTRY_DATA", "Windows Update Agent couldn't be updated because the registry contains invalid information."), + 0xD013 => new Code(code, "WU_E_SETUP_WRONG_SERVER_VERSION", "Windows Update Agent couldn't be updated because the server doesn't contain update information for this version."), + 0xDFFF => new Code(code, "WU_E_SETUP_UNEXPECTED", "Windows Update Agent couldn't be updated because of an error not covered by another WU_E_SETUP_* error code."), + + _ => base.Resolve(failure, code) + }; + } + } +} diff --git a/src/Elmah.Io.HResults/IntExtensions.cs b/src/Elmah.Io.HResults/IntExtensions.cs index 2637a32..83c7377 100644 --- a/src/Elmah.Io.HResults/IntExtensions.cs +++ b/src/Elmah.Io.HResults/IntExtensions.cs @@ -15,7 +15,7 @@ internal static class IntExtensions new FacilityStorageResolver(), new FacilityTpmServicesResolver(), new FacilityTpmSoftwareResolver(), new FacilityUrtResolver(), new FacilityUsermodeFilterManagerResolver(), new FacilityWin32Resolver(), new FacilityWindowsResolver(), new FacilityControlResolver(), new FacilityWincodecDwriteDwmResolver(), - new FacilityInternetResolver() + new FacilityInternetResolver(), new FacilityWindowsUpdateResolver() }; internal static Code ToCode(this int code, bool failure, int facility) @@ -47,7 +47,6 @@ internal static Facility ToFacility(this int facility) 33 => new Facility(facility, "FACILITY_CONFIGURATION"), 34 => new Facility(facility, "FACILITY_STATE_MANAGEMENT"), 35 => new Facility(facility, "FACILITY_METADIRECTORY"), - 36 => new Facility(facility, "FACILITY_WINDOWSUPDATE"), 37 => new Facility(facility, "FACILITY_DIRECTORYSERVICE"), 39 => new Facility(facility, "FACILITY_SHELL"), 51 => new Facility(facility, "FACILITY_WINRM"), diff --git a/test/Elmah.Io.HResults.Test/HResultTest.cs b/test/Elmah.Io.HResults.Test/HResultTest.cs index 4b2ca80..b43f271 100644 --- a/test/Elmah.Io.HResults.Test/HResultTest.cs +++ b/test/Elmah.Io.HResults.Test/HResultTest.cs @@ -10,6 +10,7 @@ public class HResultTest [TestCase(-2146232832, "0x80131600", 19, "FACILITY_URT", 5632, "COR_E_APPLICATION")] [TestCase(-2146828283, "0x800A0005", 10, "FACILITY_CONTROL", 5, "CTL_E_ILLEGALFUNCTIONCALL")] [TestCase(-1072896680, "0xC00CE558", 12, "FACILITY_INTERNET", 58712, "XML_E_MISSINGROOT")] + [TestCase(-2145067009, "0x8024DFFF", 36, "FACILITY_WINDOWSUPDATE", 57343, "WU_E_SETUP_UNEXPECTED")] public void CanParseKnownFailure(int hresult, string expectedHex, int expectedFacilityCode, string expectedFacilityName, int expectedCode, string expectedName) { var res = HResult.Parse(hresult); @@ -26,6 +27,23 @@ public void CanParseKnownFailure(int hresult, string expectedHex, int expectedFa Assert.That(res.Code.IsMatch, Is.True); } + [TestCase(2359297, "0x00240001", 36, "FACILITY_WINDOWSUPDATE", 1, "WU_S_SERVICE_STOP")] + public void CanParseKnownSuccess(int hresult, string expectedHex, int expectedFacilityCode, string expectedFacilityName, int expectedCode, string expectedName) + { + var res = HResult.Parse(hresult); + Assert.IsNotNull(res); + Assert.That(res.Hex, Is.EqualTo(expectedHex)); + Assert.That(res.IsFailure, Is.False); + Assert.That(res.Facility, Is.Not.Null); + Assert.That(res.Facility.Identifier, Is.EqualTo(expectedFacilityCode)); + Assert.That(res.Facility.Name, Is.EqualTo(expectedFacilityName)); + Assert.That(res.Facility.IsMatch, Is.True); + Assert.That(res.Code, Is.Not.Null); + Assert.That(res.Code.Identifier, Is.EqualTo(expectedCode)); + Assert.That(res.Code.Name, Is.EqualTo(expectedName)); + Assert.That(res.Code.IsMatch, Is.True); + } + [Test] public void CanParseUnknown() { From f097386f9b5002c3513123231c63b2d8c3249207 Mon Sep 17 00:00:00 2001 From: Magnus Lindhe Date: Sat, 12 Oct 2024 15:56:38 +0200 Subject: [PATCH 2/2] Removed unused using directives --- .../Facilities/FacilityWindowsUpdateResolver.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Elmah.Io.HResults/Facilities/FacilityWindowsUpdateResolver.cs b/src/Elmah.Io.HResults/Facilities/FacilityWindowsUpdateResolver.cs index b525e9a..ca4b672 100644 --- a/src/Elmah.Io.HResults/Facilities/FacilityWindowsUpdateResolver.cs +++ b/src/Elmah.Io.HResults/Facilities/FacilityWindowsUpdateResolver.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static System.Net.WebRequestMethods; - -namespace Elmah.Io.HResults.Facilities +namespace Elmah.Io.HResults.Facilities { internal class FacilityWindowsUpdateResolver : FacilityResolverBase {