├── .gitattributes ├── .gitignore ├── .manifest ├── ErrorCodeFinder.sln ├── ErrorCodeFinder.vcxproj ├── ErrorCodeFinder.vcxproj.filters ├── LICENSE.txt ├── README.md ├── dlgabout.c ├── dlghelp.c ├── dlgmain.c ├── dlgread.c ├── ecf.h ├── errh.c ├── guiaux.c ├── iconapp.ico ├── img ├── 1.png └── 2.gif ├── ldmgr.c ├── main.c ├── mod ├── ec_bug.c ├── ec_ccm.c ├── ec_com.c ├── ec_d3d.c ├── ec_dme.c ├── ec_dsreg.c ├── ec_errno.c ├── ec_gdip.c ├── ec_http.c ├── ec_mdm.c ├── ec_nt.c ├── ec_setup.c ├── ec_sig.c ├── ec_win32.c └── ec_winhttp.c ├── provider.c ├── resource.h ├── resource.rc └── utils.c /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd 364 | 365 | # custom files 366 | main_vc6.c 367 | __build 368 | build_*.bat 369 | *.exe 370 | -------------------------------------------------------------------------------- /.manifest: -------------------------------------------------------------------------------- 1 | truePerMonitorV2 -------------------------------------------------------------------------------- /ErrorCodeFinder.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32630.192 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ErrorCodeFinder", "ErrorCodeFinder.vcxproj", "{2C0D5646-F28A-42EC-981C-8BE9A532C26E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {2C0D5646-F28A-42EC-981C-8BE9A532C26E}.Debug|x64.ActiveCfg = Debug|x64 17 | {2C0D5646-F28A-42EC-981C-8BE9A532C26E}.Debug|x64.Build.0 = Debug|x64 18 | {2C0D5646-F28A-42EC-981C-8BE9A532C26E}.Debug|x86.ActiveCfg = Debug|Win32 19 | {2C0D5646-F28A-42EC-981C-8BE9A532C26E}.Debug|x86.Build.0 = Debug|Win32 20 | {2C0D5646-F28A-42EC-981C-8BE9A532C26E}.Release|x64.ActiveCfg = Release|x64 21 | {2C0D5646-F28A-42EC-981C-8BE9A532C26E}.Release|x64.Build.0 = Release|x64 22 | {2C0D5646-F28A-42EC-981C-8BE9A532C26E}.Release|x86.ActiveCfg = Release|Win32 23 | {2C0D5646-F28A-42EC-981C-8BE9A532C26E}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {885429B8-CAC4-46D2-B7C8-8E793D1E988D} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ErrorCodeFinder.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 16.0 57 | Win32Proj 58 | {2c0d5646-f28a-42ec-981c-8be9a532c26e} 59 | ErrorCodeFinder 60 | 10.0 61 | 62 | 63 | 64 | Application 65 | true 66 | v143 67 | MultiByte 68 | 69 | 70 | Application 71 | false 72 | v143 73 | true 74 | MultiByte 75 | 76 | 77 | Application 78 | true 79 | v143 80 | MultiByte 81 | 82 | 83 | Application 84 | false 85 | v143 86 | true 87 | MultiByte 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | false 109 | 110 | 111 | false 112 | 113 | 114 | false 115 | 116 | 117 | false 118 | 119 | 120 | 121 | Level3 122 | false 123 | WIN32;_DEBUG;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE 124 | true 125 | 126 | 127 | Windows 128 | true 129 | comctl32.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) 130 | 131 | 132 | 133 | 134 | Level3 135 | true 136 | true 137 | false 138 | WIN32;NDEBUG;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE 139 | true 140 | 141 | 142 | Windows 143 | true 144 | true 145 | false 146 | comctl32.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) 147 | 148 | 149 | 150 | 151 | Level3 152 | false 153 | WIN32;_DEBUG;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE 154 | true 155 | 156 | 157 | Windows 158 | true 159 | comctl32.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) 160 | 161 | 162 | 163 | 164 | Level3 165 | true 166 | true 167 | false 168 | WIN32;NDEBUG;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE 169 | true 170 | 171 | 172 | Windows 173 | true 174 | true 175 | false 176 | comctl32.lib;uxtheme.lib;dbghelp.lib;%(AdditionalDependencies) 177 | 178 | 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /ErrorCodeFinder.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 源文件 32 | 33 | 34 | 源文件 35 | 36 | 37 | 源文件 38 | 39 | 40 | 源文件 41 | 42 | 43 | 源文件 44 | 45 | 46 | 源文件 47 | 48 | 49 | 源文件 50 | 51 | 52 | 源文件 53 | 54 | 55 | 源文件 56 | 57 | 58 | 源文件 59 | 60 | 61 | 源文件 62 | 63 | 64 | 源文件 65 | 66 | 67 | 源文件 68 | 69 | 70 | 源文件 71 | 72 | 73 | 源文件 74 | 75 | 76 | 源文件 77 | 78 | 79 | 源文件 80 | 81 | 82 | 源文件 83 | 84 | 85 | 源文件 86 | 87 | 88 | 源文件 89 | 90 | 91 | 源文件 92 | 93 | 94 | 95 | 96 | 头文件 97 | 98 | 99 | 头文件 100 | 101 | 102 | 103 | 104 | 资源文件 105 | 106 | 107 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ErrorCodeFinder 2 | 3 | Windows 错误代码查询工具 4 | 5 | ## 介绍 6 | 7 | 这个工具用于查询错误代码的名称和对应的解释,支持从名称、代码、类型查找。 8 | 9 | ![界面截图](https://raw.githubusercontent.com/killtimer0/ErrorCodeFinder/master/img/1.png) 10 | 11 | 错误代码包含Win32,HRESULT,NTSTATUS,HTTP状态码,WinHTTP,蓝屏代码,DirectX,Gdiplus,errno等共9000+项。工具的特点有: 12 | 13 | * 虚表加载,启动速度较快 14 | 15 | * 关键字高亮,双色显示 16 | 17 | * 支持从自定义模块加载字符串和消息表 18 | 19 | * 支持导出功能 20 | 21 | * 支持多语言(指自行修改资源段 22 | 23 | ## 用法 24 | 25 | 搜索框支持以下格式: 26 | 27 | * 错误代码,纯数字/0x开头/h结尾,如`1411`,`0xC0000005`,`0C6h` 28 | 29 | * 错误类型,前面加冒号,如`:errno`,`:Win32` 30 | 31 | * 错误名称,支持通配符,如`ACCESS`,`D2DERR_*DEVICE` 32 | 33 | * 可以用空格分隔多个条件 34 | 35 | ![使用示例](https://raw.githubusercontent.com/killtimer0/ErrorCodeFinder/master/img/2.gif) 36 | 37 | ## 下载 38 | 39 | 在右侧[Release](releases/)中下载对应平台的版本。 40 | 41 | ## 关于代码 42 | 43 | 这些代码是之前写的,当时很好奇Win32中虚表的实现,再加上errlook个人感觉并不好用,然后就写了这么一个工具。代码是用vscode写的,vc7工具链编译,当时只是写出来自己用,可能很多语法细节没注意到。这几天把它们整理了以下,创建了一个vs2022工程,导致一大堆警告,这个应该与源码注解(sal.h)缺失有关系。因为当时用vscode写的时候编译并没有sal警告,加上Win32的自绘确实十分复杂,要处理一堆情况,然后屎山就这么堆起来了。最后结果就是代码很凌乱,耦合性也比较高。不过最后终于是能用了,而且我最近收集了更全面的数据,打算重构这个工具(这个下面细说),那这个版本就先这样吧。 44 | 45 | 然后列举一下代码的结构: 46 | 47 | * `dlgmain.c`:这个是主界面的对话框,实现了主界面(除了列表框)的所有逻辑,`ErrorCodeSet *pecs;`这个变量保存了已注册的所有错误代码模块。其他`dlg*.c`是其他对话框的实现。 48 | 49 | * `errh.c`:处理程序出现的bug,当错误发生时,`BugHandler`会捕获它并汇报,同时把现场保存到同目录的dump文件中。 50 | 51 | * `guiaux.c`:一些常用的GUI操作的封装。 52 | 53 | * `utils.c`:工具类,条件搜索就是在这个文件中实现的。 54 | 55 | * `ldmgr.c`:里面子类化了一个`SysListView32`,写这个工具的大部分时间都用在这个上面了。关于这个关键字高亮,实现起来比我想象的要难得多:由于有多种字体,程序在收到DPI变化的信息时,要重新创建这些字体;由于字体改变导致列表框默认的宽度测量失效,当列表项省略号折叠时,为了迎合默认行为(鼠标悬停或者键盘定位到折叠项时会展开文字),必须自己实现原地气泡提示(In-place tooltips);双击表头分隔条的行为(拓宽列使可见的所有项都不折叠)也要自己测量文本大小…… 56 | 57 | * `provider.c`:注册所有错误代码模块,并提供这些模块会用到的一些函数。 58 | 59 | * `mod/ec_*.c`:错误代码模块,每个文件对应一种错误代码类型。 60 | 61 | 最近从Windows SDK、WDK和MSDN中收集了更多有用的信息,有时间可能会写一个更好用的版本,目前有一点想法~~大饼~~,工具写完大概是这样的: 62 | 63 | * 支持搜索常量、枚举类型和它们的对应值和解释。 64 | 65 | * 支持搜索COM接口的GUID值、继承关系、方法和它在虚函数表中的索引。 66 | 67 | * 支持搜索结构体、联合类型的成员,并提供它们在x86/x64/ARM/ARM64结构体中的偏移量。对于少量宏条件控制的复杂结构体,目前还没有什么好的办法处理,暂时选择了最长的一条分支。 68 | 69 | * 支持搜索宏和函数,包括与函数关联的静态库(.lib)和动态库(.dll)。 70 | 71 | * 上面那些类型会尽量提供MSDN在线文档的对应链接。 72 | 73 | * 考虑到用纯Win32写界面确实很蛋疼,准备用现在比较流行的前端框架写,在浏览器上运行,这样可以不用考虑GUI中那些琐碎的事情,而且可以跨平台。 74 | 75 | * 不太想弄后端,准备用wasm保证数据在前端查询的效率。工具的数据量可能比较大,目前想的是把数据包LZMA压缩,下载时保存到IndexDB,并在wasm里面解压。 76 | 77 | 至于这个可不可行还有待进一步研究。不过有一些想象中的功能放到浏览器中应该是实现不了了,比如从ProgID查CLSID、IDispatch接口查询等等。所以用MFC或者WTL也是一个选择?目前还没有想到什么双赢的办法,先走一步看一步吧。 -------------------------------------------------------------------------------- /dlgabout.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | #include "resource.h" 3 | #include 4 | 5 | INT_PTR CALLBACK DlgProcAbout(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 6 | { 7 | switch (uMsg) 8 | { 9 | case WM_COMMAND: 10 | { 11 | UINT id = LOWORD(wParam); 12 | UINT code = HIWORD(wParam); 13 | 14 | switch (id) 15 | { 16 | case IDOK: 17 | case IDCANCEL: 18 | EndDialog(hdlg, id); 19 | return 0; 20 | } 21 | } 22 | break; 23 | 24 | case WM_NOTIFY: 25 | { 26 | NMHDR *hdr = (NMHDR*)lParam; 27 | 28 | switch (hdr->idFrom) 29 | { 30 | case IDC_ABOUT_MSG: 31 | { 32 | switch (hdr->code) 33 | { 34 | case NM_CLICK: 35 | { 36 | /* Note: we don't handle href mark */ 37 | LITEM *item = &((NMLINK*)hdr)->item; 38 | 39 | if (!wcsicmp(item->szID, L"Home")) 40 | { 41 | UrlOpen(TEXT("https://killtimer0.github.io")); 42 | } 43 | else if (!wcsicmp(item->szID, L"Feedback")) 44 | { 45 | UrlOpen(TEXT("mailto:1837009039@qq.com")); 46 | } 47 | } 48 | break; 49 | } 50 | } 51 | break; 52 | } 53 | } 54 | break; 55 | 56 | case WM_INITDIALOG: 57 | SetFocus(GetDlgItem(hdlg, IDOK)); 58 | break; 59 | } 60 | 61 | return FALSE; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /dlghelp.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | #include "resource.h" 3 | 4 | INT_PTR CALLBACK DlgProcHelp(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 5 | { 6 | switch (uMsg) 7 | { 8 | case WM_COMMAND: 9 | { 10 | UINT id = LOWORD(wParam); 11 | UINT code = HIWORD(wParam); 12 | 13 | switch (id) 14 | { 15 | case IDOK: 16 | case IDCANCEL: 17 | EndDialog(hdlg, id); 18 | return 0; 19 | } 20 | } 21 | break; 22 | 23 | case WM_INITDIALOG: 24 | SetFocus(GetDlgItem(hdlg, IDOK)); 25 | break; 26 | } 27 | 28 | return FALSE; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /dlgmain.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | #include "resource.h" 3 | #include 4 | #include 5 | 6 | HINSTANCE hInst; 7 | ErrorCodeSet *pecs; 8 | DWORD necs; 9 | 10 | static HICON hIconApp = NULL; 11 | static HMENU hMainMenu = NULL; 12 | 13 | /* menu items */ 14 | BOOL bAlwaysTop = FALSE, bAltColor = TRUE; 15 | 16 | static void LayoutAdjustMain(HWND hdlg) 17 | { 18 | HWND hctl; 19 | RECT rcClient; 20 | SIZE size, unit; 21 | HDWP hdwp; 22 | LONG lBorderWidth, lBorderHeight; 23 | LONG lEditSpace; 24 | 25 | GetClientRect(hdlg, &rcClient); 26 | GetDlgUnit(hdlg, &unit); 27 | lBorderWidth = MulDiv(DLG_BORDER, unit.cx, 4); 28 | lBorderHeight = MulDiv(DLG_BORDER, unit.cy, 8); 29 | 30 | hctl = GetDlgItem(hdlg, IDC_MAIN_S_BAR); 31 | SendMessage(hctl, WM_SIZE, 0, 0); 32 | GetWndSize(hctl, &size); 33 | 34 | hdwp = BeginDeferWindowPos(2); 35 | 36 | hctl = GetDlgItem(hdlg, IDC_MAIN_E_SEARCH); 37 | DeferWindowPos( 38 | hdwp, 39 | hctl, 40 | NULL, 41 | lBorderWidth, 42 | lBorderHeight, 43 | rcClient.right - 2 * lBorderWidth, 44 | MulDiv(14, unit.cy, 8), 45 | SWP_NOACTIVATE | SWP_NOZORDER 46 | ); 47 | 48 | hctl = GetDlgItem(hdlg, IDC_MAIN_L_DATA); 49 | lEditSpace = MulDiv(14 + 2 * DLG_BORDER, unit.cy, 8); 50 | DeferWindowPos( 51 | hdwp, 52 | hctl, 53 | NULL, 54 | 0, 55 | lBorderHeight + lEditSpace, 56 | rcClient.right, 57 | rcClient.bottom - lBorderHeight - lEditSpace - size.cy, 58 | SWP_NOACTIVATE | SWP_NOZORDER 59 | ); 60 | 61 | EndDeferWindowPos(hdwp); 62 | } 63 | 64 | #define IDT_STATUS 1 65 | #define TEMPINFO_TIMEOUT 1000 66 | static TCHAR szStatus[STATUS_MAXLEN]; 67 | 68 | void SetStatusText(HWND hdlg, LPCTSTR lpText) 69 | { 70 | TCHAR buf[MAX_STRING_LENGTH]; 71 | HWND hctl = GetDlgItem(hdlg, IDC_MAIN_S_BAR); 72 | 73 | KillTimer(hdlg, IDT_STATUS); 74 | 75 | if ((SIZE_T)lpText < 0x10000) 76 | { 77 | LoadString(hInst, LOWORD(lpText), buf, MAX_STRING_LENGTH); 78 | lpText = buf; 79 | } 80 | 81 | SendMessage(hctl, WM_SETTEXT, 0, (LPARAM)lpText); 82 | } 83 | 84 | void SetStatusTextN(HWND hdlg, LPCTSTR lpText, DWORD dwNum) 85 | { 86 | TCHAR buf[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH]; 87 | HWND hctl = GetDlgItem(hdlg, IDC_MAIN_S_BAR); 88 | 89 | if ((SIZE_T)lpText < 0x10000) 90 | { 91 | LoadString(hInst, LOWORD(lpText), buf, MAX_STRING_LENGTH); 92 | lpText = buf; 93 | } 94 | 95 | _sntprintf(buf2, MAX_STRING_LENGTH, lpText, dwNum); 96 | SetStatusText(hdlg, buf2); 97 | } 98 | 99 | void SetStatusTextTemp(HWND hdlg, LPCTSTR lpText) 100 | { 101 | TCHAR buf[MAX_STRING_LENGTH]; 102 | HWND hctl = GetDlgItem(hdlg, IDC_MAIN_S_BAR); 103 | 104 | if (!KillTimer(hdlg, IDT_STATUS)) 105 | SendMessage(hctl, WM_GETTEXT, STATUS_MAXLEN, (LPARAM)szStatus); 106 | if ((SIZE_T)lpText < 0x10000) 107 | { 108 | LoadString(hInst, LOWORD(lpText), buf, MAX_STRING_LENGTH); 109 | lpText = buf; 110 | } 111 | SendMessage(hctl, WM_SETTEXT, 0, (LPARAM)lpText); 112 | 113 | SetTimer(hdlg, IDT_STATUS, TEMPINFO_TIMEOUT, NULL); 114 | } 115 | 116 | static BOOL InitListView(HWND hctl) 117 | { 118 | TCHAR buf[MAX_STRING_LENGTH]; 119 | LVCOLUMN lvc; 120 | UINT idColName[] = { 121 | IDS_MAIN_COLUMN_NAME, 122 | IDS_MAIN_COLUMN_VAL, 123 | IDS_MAIN_COLUMN_SCOPE, 124 | IDS_MAIN_COLUMN_MSG, 125 | }; 126 | int iColFmt[] = { 127 | LVCFMT_LEFT, 128 | LVCFMT_RIGHT, 129 | LVCFMT_LEFT, 130 | LVCFMT_LEFT, 131 | }; 132 | int iColWidth[] = { 133 | 120, 60, 50, MAIN_NORMAL_X - 230 134 | }; 135 | int iCol; 136 | SIZE size; 137 | DWORD dwStyle; 138 | 139 | SetWindowTheme(hctl, L"Explorer", NULL); 140 | 141 | dwStyle = ListView_GetExtendedListViewStyle(hctl); 142 | dwStyle |= LVS_EX_FULLROWSELECT 143 | | LVS_EX_HEADERDRAGDROP 144 | | LVS_EX_INFOTIP 145 | | LVS_EX_DOUBLEBUFFER; 146 | 147 | ListView_SetExtendedListViewStyle(hctl, dwStyle); 148 | 149 | GetDlgUnit(GetParent(hctl), &size); 150 | lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; 151 | for (iCol = 0; iCol < ARRAYSIZE(idColName); ++iCol) 152 | { 153 | LoadString(hInst, idColName[iCol], buf, MAX_STRING_LENGTH); 154 | 155 | lvc.fmt = iColFmt[iCol]; 156 | 157 | lvc.cx = MulDiv(iColWidth[iCol], size.cx, 4); 158 | if (iCol == ARRAYSIZE(idColName) - 1) 159 | lvc.cx -= GetSystemMetrics(SM_CXVSCROLL); 160 | 161 | lvc.pszText = buf; 162 | lvc.iSubItem = iCol; 163 | if (-1 == ListView_InsertColumn(hctl, iCol, &lvc)) 164 | return FALSE; 165 | } 166 | 167 | return TRUE; 168 | } 169 | 170 | static HMENU hMenuView; 171 | 172 | static void DlgCheckItem(UINT id, BOOL bChecked) 173 | { 174 | UINT uFlags = MF_BYCOMMAND; 175 | 176 | if (bChecked) 177 | uFlags |= MF_CHECKED; 178 | else 179 | uFlags |= MF_UNCHECKED; 180 | 181 | CheckMenuItem(hMenuView, id, uFlags); 182 | } 183 | 184 | static void SetAlwaysTop(HWND hdlg, BOOL bTop) 185 | { 186 | DWORD dwExStyle; 187 | DWORD dwFlags; 188 | HWND hwndIns, hwndTT; 189 | 190 | dwFlags = SWP_NOMOVE | SWP_NOSIZE; 191 | hwndIns = bTop ? HWND_TOPMOST : HWND_NOTOPMOST; 192 | SetWindowPos(hdlg, hwndIns, 0, 0, 0, 0, dwFlags); 193 | 194 | hwndTT = ListView_GetToolTips(GetDlgItem(hdlg, IDC_MAIN_L_DATA)); 195 | dwFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE; 196 | hwndIns = bTop ? HWND_TOPMOST : HWND_NOTOPMOST; 197 | SetWindowPos(hwndTT, hwndIns, 0, 0, 0, 0, dwFlags); 198 | 199 | dwExStyle = (DWORD)GetWindowLongPtr(hdlg, GWL_EXSTYLE); 200 | bAlwaysTop = dwExStyle & WS_EX_TOPMOST; 201 | DlgCheckItem(ID_MAIN_VIEW_TOP, bAlwaysTop); 202 | 203 | } 204 | 205 | static void SetAltColor(HWND hctl, BOOL bColor) 206 | { 207 | bAltColor = bColor; 208 | RedrawWindow(hctl, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); 209 | DlgCheckItem(ID_MAIN_VIEW_ALTCOLOR, bAltColor); 210 | } 211 | 212 | static BOOL ExportIteratorCurrent(DWORD *cur, DWORD *scope, DWORD *idx) 213 | { 214 | if (cur[0] >= ctxList.dwCount) 215 | return FALSE; 216 | 217 | *scope = ctxList.item[*cur].dwScope; 218 | *idx = ctxList.item[*cur].dwItem; 219 | ++*cur; 220 | 221 | return TRUE; 222 | } 223 | 224 | static BOOL ExportIteratorAll(DWORD *cur, DWORD *scope, DWORD *idx) 225 | { 226 | while (cur[0] < necs && cur[1] >= pecs[cur[0]].dwCodeCount) 227 | { 228 | cur[1] = 0; 229 | ++cur[0]; 230 | } 231 | 232 | if (cur[0] >= necs) 233 | return FALSE; 234 | 235 | *scope = cur[0]; 236 | *idx = cur[1]; 237 | 238 | ++cur[1]; 239 | 240 | return TRUE; 241 | } 242 | 243 | static BOOL ExportItems(HWND hdlg, UINT id) 244 | { 245 | DWORD dwPos = 0; 246 | TCHAR filter[MAX_STRING_LENGTH * 2 + ARRAYSIZE(PATTXT) + ARRAYSIZE(PATALL) + 1]; 247 | TCHAR szPath[MAX_PATH]; 248 | BOOL (*pfnExport)(DWORD *, DWORD *, DWORD *) = NULL; 249 | DWORD cur[2]; 250 | BOOL bSucceeded = FALSE; 251 | 252 | dwPos += LoadString(hInst, IDS_FILTER_TEXT, filter + dwPos, MAX_STRING_LENGTH); 253 | ++dwPos; 254 | memmove(filter + dwPos, PATTXT, sizeof (PATTXT)); 255 | dwPos += ARRAYSIZE(PATTXT); 256 | 257 | dwPos += LoadString(hInst, IDS_FILTER_ALL, filter + dwPos, MAX_STRING_LENGTH); 258 | ++dwPos; 259 | memmove(filter + dwPos, PATALL, sizeof (PATALL)); 260 | dwPos += ARRAYSIZE(PATALL); 261 | 262 | filter[dwPos++] = TEXT('\0'); 263 | 264 | switch (id) 265 | { 266 | case ID_MAIN_FILE_EXPCUR: 267 | cur[0] = 0; 268 | pfnExport = ExportIteratorCurrent; 269 | break; 270 | 271 | case ID_MAIN_FILE_EXPALL: 272 | cur[0] = cur[1] = 0; 273 | pfnExport = ExportIteratorAll; 274 | break; 275 | 276 | } 277 | 278 | if (pfnExport) 279 | { 280 | if (FileOpenOrSave(hdlg, FALSE, TEXT("txt"), filter, szPath)) 281 | { 282 | FILE *f = _tfopen(szPath, TEXT("w")); 283 | if (f) 284 | { 285 | DWORD scope, idx; 286 | while (pfnExport(cur, &scope, &idx)) 287 | { 288 | LPTSTR lpDescExp = TEXT(""); 289 | LPTSTR lpDesc = pecs[scope].pfnMessageFromCode( 290 | pecs[scope].items[idx].dwCode 291 | ); 292 | 293 | if (lpDesc) 294 | lpDescExp = lpDesc; 295 | 296 | _ftprintf( 297 | f, 298 | TEXT("%s 0x%X %s %s\n"), 299 | pecs[scope].items[idx].lpName, 300 | pecs[scope].items[idx].dwCode, 301 | pecs[scope].lpName, 302 | lpDescExp 303 | ); 304 | 305 | if (lpDesc) 306 | pecs[scope].pfnFreeMessage(lpDesc); 307 | } 308 | 309 | fclose(f); 310 | bSucceeded = TRUE; 311 | } 312 | } 313 | } 314 | 315 | return bSucceeded; 316 | } 317 | 318 | static void EditOnChange(HWND hdlg, HWND hctl) 319 | { 320 | LPTSTR lpText; 321 | SearchFilter filter; 322 | 323 | lpText = GetWndText(hctl); 324 | if (lpText) 325 | { 326 | if (FilterFromString(lpText, &filter)) 327 | { 328 | LPTSTR lpMsg = MAKEINTRESOURCE(filter.dwMask ? IDS_S_SEARCHDONE : IDS_S_DONE); 329 | 330 | LvLoadFilter(GetDlgItem(hdlg, IDC_MAIN_L_DATA), &filter); 331 | SetStatusTextN(hdlg, lpMsg, ctxList.dwCount); 332 | 333 | FilterClear(&filter); 334 | } 335 | LocalFree(lpText); 336 | } 337 | } 338 | 339 | static void DlgMainOnCmd(HWND hdlg, UINT id, UINT code, HWND hctl) 340 | { 341 | switch (id) 342 | { 343 | case IDCANCEL: 344 | EndDialog(hdlg, id); 345 | break; 346 | 347 | case IDC_MAIN_E_SEARCH: 348 | switch (code) 349 | { 350 | case EN_CHANGE: 351 | EditOnChange(hdlg, hctl); 352 | break; 353 | } 354 | break; 355 | 356 | case ID_MAIN_FILE_READ: 357 | DialogBox(hInst, MAKEINTRESOURCE(IDD_READ), hdlg, DlgProcRead); 358 | break; 359 | 360 | case ID_MAIN_FILE_EXPCUR: 361 | case ID_MAIN_FILE_EXPALL: 362 | if (ExportItems(hdlg, id)) 363 | SetStatusTextTemp(hdlg, MAKEINTRESOURCE(IDS_S_EXPORTED)); 364 | break; 365 | 366 | case ID_MAIN_VIEW_TOP: 367 | SetAlwaysTop(hdlg, !bAlwaysTop); 368 | break; 369 | 370 | case ID_MAIN_VIEW_ALTCOLOR: 371 | SetAltColor(GetDlgItem(hdlg, IDC_MAIN_L_DATA), !bAltColor); 372 | break; 373 | 374 | case ID_MAIN_HELP_HELP: 375 | DialogBox(hInst, MAKEINTRESOURCE(IDD_HELP), hdlg, DlgProcHelp); 376 | break; 377 | 378 | case ID_MAIN_HELP_ABOUT: 379 | DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), hdlg, DlgProcAbout); 380 | break; 381 | } 382 | } 383 | 384 | WNDPROC pfnLVProc = NULL; 385 | extern LRESULT CALLBACK LvxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 386 | 387 | static INT_PTR CALLBACK DlgProcMain( 388 | HWND hdlg, 389 | UINT uMsg, 390 | WPARAM wParam, 391 | LPARAM lParam 392 | ) 393 | { 394 | switch (uMsg) 395 | { 396 | case WM_NOTIFY: 397 | { 398 | NMHDR *hdr = (NMHDR*)lParam; 399 | switch(hdr->idFrom) 400 | { 401 | case IDC_MAIN_L_DATA: 402 | return LvOnNotify(hdlg, hdr); 403 | } 404 | } 405 | break; 406 | 407 | case WM_TIMER: 408 | { 409 | switch (wParam) 410 | { 411 | case IDT_STATUS: 412 | { 413 | HWND hctl = GetDlgItem(hdlg, IDC_MAIN_S_BAR); 414 | SendMessage(hctl, WM_SETTEXT, 0, (LPARAM)szStatus); 415 | KillTimer(hdlg, IDT_STATUS); 416 | } 417 | break; 418 | } 419 | } 420 | break; 421 | 422 | case WM_SIZE: 423 | LayoutAdjustMain(hdlg); 424 | break; 425 | 426 | case WM_GETMINMAXINFO: 427 | { 428 | MINMAXINFO *mmi = (MINMAXINFO*)lParam; 429 | RECT rcMinSize; 430 | 431 | rcMinSize.left = rcMinSize.top = 0; 432 | rcMinSize.right = MAIN_MIN_X; 433 | rcMinSize.bottom = MAIN_MIN_Y; 434 | MapDialogRect(hdlg, &rcMinSize); 435 | AdjustWindowRectEx( 436 | &rcMinSize, 437 | (DWORD)GetWindowLongPtr(hdlg, GWL_STYLE), 438 | GetMenu(hdlg) != NULL, 439 | (DWORD)GetWindowLongPtr(hdlg, GWL_EXSTYLE) 440 | ); 441 | 442 | mmi->ptMinTrackSize.x = rcMinSize.right - rcMinSize.left; 443 | mmi->ptMinTrackSize.y = rcMinSize.bottom - rcMinSize.top; 444 | } 445 | break; 446 | 447 | case WM_COMMAND: 448 | { 449 | UINT id = LOWORD(wParam); 450 | UINT code = HIWORD(wParam); 451 | HWND hctl = (HWND)lParam; 452 | 453 | DlgMainOnCmd(hdlg, id, code, hctl); 454 | return 0; 455 | } 456 | 457 | case WM_INITDIALOG: 458 | { 459 | WCHAR buf[MAX_STRING_LENGTH]; 460 | HWND hctl; 461 | 462 | SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)hIconApp); 463 | SetMenu(hdlg, hMainMenu); 464 | 465 | hctl = GetDlgItem(hdlg, IDC_MAIN_E_SEARCH); 466 | LoadStringW(hInst, IDS_HINT_SEARCH, buf, MAX_STRING_LENGTH); 467 | SendMessage(hctl, EM_SETCUEBANNER, TRUE, (LPARAM)buf); 468 | SetFocus(hctl); 469 | 470 | SetStatusText(hdlg, MAKEINTRESOURCE(IDS_S_PREPARING)); 471 | 472 | hctl = GetDlgItem(hdlg, IDC_MAIN_L_DATA); 473 | 474 | /* we must modify this control, as we have our own way 475 | * to calculate header width, etc. */ 476 | pfnLVProc = (WNDPROC)GetWindowLongPtr(hctl, GWLP_WNDPROC); 477 | SetWindowLongPtr(hctl, GWLP_WNDPROC, (LONG_PTR)LvxProc); 478 | LvInitFont(hctl); 479 | 480 | if (!InitListView(hctl)) 481 | { 482 | SetWindowLongPtr(hctl, GWLP_WNDPROC, (LONG_PTR)pfnLVProc); 483 | return FALSE; 484 | } 485 | 486 | ItemLoadAll(hctl); 487 | SetStatusTextN(hdlg, MAKEINTRESOURCE(IDS_S_DONE), ctxList.dwCount); 488 | 489 | hMenuView = GetSubMenu(GetMenu(hdlg), 1); 490 | SetAlwaysTop(hdlg, bAlwaysTop); 491 | DlgCheckItem(ID_MAIN_VIEW_ALTCOLOR, bAltColor); 492 | 493 | } 494 | break; 495 | 496 | default: 497 | return FALSE; 498 | 499 | } 500 | return TRUE; 501 | } 502 | 503 | static BOOL LoadClasses() 504 | { 505 | BOOL result = FALSE; 506 | /* WNDCLASSEX wc; */ 507 | 508 | InitCommonControls(); 509 | 510 | /* 511 | if (GetClassInfoEx(hInst, TEXT("SysListView32"), &wc)) 512 | { 513 | pfnLVProc = wc.lpfnWndProc; 514 | wc.cbSize = sizeof (wc); 515 | wc.lpfnWndProc = listviewx_proc; 516 | wc.lpszClassName = TEXT(CLS_LISTVIEWX); 517 | 518 | if (RegisterClassEx(&wc)) 519 | result = TRUE; 520 | } 521 | */ 522 | result = TRUE; 523 | 524 | return result; 525 | } 526 | 527 | static void UnloadClasses() 528 | { 529 | /* UnregisterClass(TEXT(CLS_LISTVIEWX), hInst); */ 530 | } 531 | 532 | int dlgmain(HINSTANCE hInstance){ 533 | hInst = hInstance; 534 | SetUnhandledExceptionFilter(BugHandler); 535 | 536 | dbgstart(); 537 | 538 | necs = EcInit(&pecs); 539 | 540 | hIconApp = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICONAPP)); 541 | 542 | if (LoadClasses(hInst)) 543 | { 544 | hMainMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MAINMENU)); 545 | DialogBox(hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProcMain); 546 | 547 | DestroyMenu(hMainMenu); 548 | UnloadClasses(hInst); 549 | } 550 | 551 | EcUninit(); 552 | 553 | dbgend(); 554 | 555 | return 0; 556 | } 557 | -------------------------------------------------------------------------------- /dlgread.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | #include "resource.h" 3 | #include 4 | 5 | static void ReadDlgOnOk(HWND hdlg) 6 | { 7 | HMODULE hMod = NULL; 8 | LPTSTR lpText, lpMsg; 9 | TCHAR buf[1024], fmt[MAX_STRING_LENGTH]; 10 | int iLen; 11 | DWORD dwCode; 12 | LPTSTR lpFailText = NULL; 13 | 14 | iLen = GetWindowText(GetDlgItem(hdlg, IDC_READ_E_ID), buf, 1024); 15 | 16 | if (FmtParseDword(buf, 0, iLen, &dwCode)) 17 | { 18 | lpText = GetWndText(GetDlgItem(hdlg, IDC_READ_COMBO)); 19 | 20 | if (lpText && _tcslen(lpText) > 0) 21 | { 22 | BOOL bFailed = TRUE; 23 | 24 | LOAD_RES(hMod, lpText); 25 | if (hMod) 26 | { 27 | FormatMessage( 28 | FORMAT_MESSAGE_ALLOCATE_BUFFER 29 | | FORMAT_MESSAGE_IGNORE_INSERTS 30 | | FORMAT_MESSAGE_FROM_HMODULE, 31 | hMod, 32 | dwCode, 33 | 0, 34 | (LPTSTR)&lpMsg, 35 | 0, 36 | NULL 37 | ); 38 | 39 | if (lpMsg) 40 | { 41 | SetDlgItemText(hdlg, IDC_READ_E_MSG, lpMsg); 42 | bFailed = FALSE; 43 | LocalFree(lpMsg); 44 | } 45 | else 46 | { 47 | SetDlgItemText(hdlg, IDC_READ_E_MSG, NULL); 48 | } 49 | 50 | iLen = LoadString(hMod, dwCode, buf, 1024); 51 | 52 | if (iLen) 53 | { 54 | SetDlgItemText(hdlg, IDC_READ_E_STR, buf); 55 | bFailed = FALSE; 56 | } 57 | else 58 | { 59 | SetDlgItemText(hdlg, IDC_READ_E_STR, NULL); 60 | } 61 | 62 | FREE_RES(hMod); 63 | 64 | if (bFailed) 65 | { 66 | LoadString(hInst, IDS_ERR_READ_RES, fmt, MAX_STRING_LENGTH); 67 | _sntprintf(buf, 1024, fmt, lpText, dwCode); 68 | lpFailText = buf; 69 | } 70 | } 71 | else 72 | { 73 | LPTSTR lpReason = TEXT(""); 74 | LoadString(hInst, IDS_ERR_READ_MOD, fmt, MAX_STRING_LENGTH); 75 | 76 | FormatMessage( 77 | FORMAT_MESSAGE_ALLOCATE_BUFFER 78 | | FORMAT_MESSAGE_IGNORE_INSERTS 79 | | FORMAT_MESSAGE_FROM_SYSTEM, 80 | NULL, 81 | GetLastError(), 82 | 0, 83 | (LPTSTR)&lpMsg, 84 | 0, 85 | NULL 86 | ); 87 | 88 | if (lpMsg) 89 | lpReason = lpMsg; 90 | 91 | _sntprintf(buf, 1024, fmt, lpText, lpReason); 92 | lpFailText = buf; 93 | } 94 | 95 | LocalFree(lpText); 96 | } 97 | else 98 | { 99 | LoadString(hInst, IDS_ERR_READ_NAME, fmt, MAX_STRING_LENGTH); 100 | lpFailText = fmt; 101 | } 102 | } 103 | else 104 | { 105 | LoadString(hInst, IDS_ERR_READ_FMT, fmt, MAX_STRING_LENGTH); 106 | lpFailText = fmt; 107 | } 108 | 109 | if (lpFailText) 110 | { 111 | MessageBox(hdlg, lpFailText, NULL, MB_OK | MB_ICONERROR); 112 | } 113 | 114 | } 115 | 116 | #define INITCOMBOEXT TEXT("\\*.dll") 117 | 118 | INT_PTR CALLBACK DlgProcRead(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 119 | { 120 | switch (uMsg) 121 | { 122 | case WM_COMMAND: 123 | { 124 | UINT id = LOWORD(wParam); 125 | UINT code = HIWORD(wParam); 126 | 127 | switch (id) 128 | { 129 | case IDOK: 130 | ReadDlgOnOk(hdlg); 131 | break; 132 | 133 | case IDCANCEL: 134 | EndDialog(hdlg, id); 135 | return 0; 136 | 137 | case IDC_READ_BROWSE: 138 | { 139 | TCHAR szPath[MAX_PATH]; 140 | TCHAR filter[ 141 | MAX_STRING_LENGTH * 2 142 | + ARRAYSIZE(PATRES) 143 | + ARRAYSIZE(PATALL) + 1]; 144 | DWORD dwPos = 0; 145 | 146 | dwPos += LoadString( 147 | hInst, 148 | IDS_FILTER_RES, 149 | filter + dwPos, 150 | MAX_STRING_LENGTH 151 | ); 152 | ++dwPos; 153 | memmove(filter + dwPos, PATRES, sizeof (PATRES)); 154 | dwPos += ARRAYSIZE(PATRES); 155 | 156 | dwPos += LoadString( 157 | hInst, 158 | IDS_FILTER_ALL, 159 | filter + dwPos, 160 | MAX_STRING_LENGTH 161 | ); 162 | ++dwPos; 163 | memmove(filter + dwPos, PATALL, sizeof (PATALL)); 164 | dwPos += ARRAYSIZE(PATALL); 165 | 166 | filter[dwPos++] = TEXT('\0'); 167 | 168 | if (FileOpenOrSave(hdlg, TRUE, TEXT("dll"), filter, szPath)) 169 | { 170 | SetDlgItemText(hdlg, IDC_READ_COMBO, szPath); 171 | } 172 | } 173 | break; 174 | } 175 | } 176 | break; 177 | 178 | case WM_INITDIALOG: 179 | { 180 | TCHAR szSystemPath[MAX_PATH + ARRAYSIZE(INITCOMBOEXT)]; 181 | WCHAR szHint[MAX_STRING_LENGTH]; 182 | DWORD dwPos = 0; 183 | HWND hctl; 184 | 185 | dwPos += GetSystemDirectory(szSystemPath, MAX_PATH); 186 | memmove(szSystemPath + dwPos, INITCOMBOEXT, sizeof (INITCOMBOEXT)); 187 | dwPos += ARRAYSIZE(INITCOMBOEXT); 188 | 189 | DlgDirListComboBox( 190 | hdlg, 191 | szSystemPath, 192 | IDC_READ_COMBO, 193 | 0, 194 | DDL_SYSTEM | DDL_READONLY 195 | ); 196 | 197 | hctl = GetDlgItem(hdlg, IDC_READ_COMBO); 198 | LoadStringW(hInst, IDS_HINT_PATH, szHint, MAX_STRING_LENGTH); 199 | SendMessage(hctl, CB_SETCUEBANNER, 0, (LPARAM)szHint); 200 | SetFocus(hctl); 201 | 202 | hctl = GetDlgItem(hdlg, IDC_READ_E_ID); 203 | LoadStringW(hInst, IDS_HINT_ID, szHint, MAX_STRING_LENGTH); 204 | SendMessage(hctl, EM_SETCUEBANNER, TRUE, (LPARAM)szHint); 205 | } 206 | break; 207 | } 208 | 209 | return FALSE; 210 | } 211 | 212 | -------------------------------------------------------------------------------- /ecf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef _DEBUG 8 | #define dbg(fmt, ...) _tprintf(fmt##_T("\n"), __VA_ARGS__) 9 | #define pause() system("pause") 10 | #define dbgstart() \ 11 | do \ 12 | { \ 13 | AllocConsole(); \ 14 | freopen("CON", "r", stdin); \ 15 | freopen("CON", "w", stdout); \ 16 | freopen("CON", "w", stderr); \ 17 | } while (0) 18 | #define dbgend() FreeConsole() 19 | #else 20 | #define dbg(fmt, ...) 21 | #define pause() 22 | #define dbgstart() 23 | #define dbgend() 24 | #endif 25 | 26 | /* res macro */ 27 | 28 | #define LOAD_RES(mod, f) \ 29 | do \ 30 | { \ 31 | if (!(mod)) \ 32 | { \ 33 | (mod) = LoadLibraryEx(f, NULL, LOAD_LIBRARY_AS_DATAFILE); \ 34 | } \ 35 | } while (0) 36 | 37 | #define FREE_RES(mod) \ 38 | do \ 39 | { \ 40 | if ((mod)) \ 41 | { \ 42 | FreeLibrary((mod)); \ 43 | (mod) = NULL; \ 44 | } \ 45 | } while (0) 46 | 47 | /* max size for error description */ 48 | #define MAX_MSG_LEN 256 49 | 50 | /* alt color alpha blend */ 51 | #define ALTALPHABK (15.0F/127) 52 | 53 | #pragma pack(4) 54 | typedef struct _ErrorCodeItem { 55 | DWORD dwCode; 56 | LPCTSTR lpName; 57 | } ErrorCodeItem; 58 | #pragma pack() 59 | 60 | #ifdef UNICODE 61 | #define REGCODE(c) c, L#c, 62 | #else 63 | #define REGCODE(c) c, #c, 64 | #endif 65 | 66 | typedef struct _ErrorCodeSet { 67 | LPCTSTR lpName; 68 | /* return NULL or a pointer that can be free by pfnFreeMessage */ 69 | LPTSTR (*pfnMessageFromCode)( 70 | DWORD dwCode 71 | ); 72 | /* the free function */ 73 | void (*pfnFreeMessage)( 74 | LPTSTR lpMessage 75 | ); 76 | DWORD dwCodeCount; 77 | ErrorCodeItem *items; 78 | } ErrorCodeSet; 79 | 80 | /* highlight related */ 81 | 82 | #define SFM_CODE 1 83 | #define SFM_NAME 2 84 | #define SFM_SCOPE 4 85 | 86 | typedef struct _HighlightRange { 87 | DWORD dwStart, dwEnd; 88 | } HighlightRange; 89 | 90 | typedef struct _HighlightHint { 91 | DWORD dwHintMask; 92 | DWORD dwRanges; 93 | HighlightRange *ranges; 94 | } HighlightHint; 95 | 96 | /* item in listview */ 97 | typedef struct _ListItem { 98 | DWORD dwScope; 99 | DWORD dwItem; 100 | HighlightHint; 101 | } ListItem; 102 | 103 | /* all items */ 104 | typedef struct _ListContext { 105 | DWORD dwCount; 106 | ListItem *item; 107 | } ListContext; 108 | 109 | typedef struct _TArray { 110 | DWORD dwCount, dwMaxCount, dwCell; 111 | LPVOID lpData; 112 | } TArray; 113 | 114 | #define SF_MAX_NAMES 16 115 | 116 | typedef struct _SearchFilter { 117 | DWORD dwMask; 118 | DWORD dwCode; 119 | DWORD dwNameCount; 120 | DWORD dwScopeCount; 121 | DWORD dwScopes[SF_MAX_NAMES]; 122 | LPTSTR lpNames[SF_MAX_NAMES]; 123 | } SearchFilter; 124 | 125 | extern HMODULE hModCertCli, hModCertUtil, hModHttp, hModNt, hModKrnl; 126 | 127 | /* main */ 128 | 129 | #define STATUS_MAXLEN 1024 130 | 131 | extern HINSTANCE hInst; 132 | extern ErrorCodeSet *pecs; 133 | extern DWORD necs; 134 | extern ListContext ctxList; 135 | extern BOOL bAlwaysTop, bAltColor; 136 | 137 | extern int dlgmain(HINSTANCE hInstance); 138 | extern void SetStatusText(HWND hdlg, LPCTSTR lpText); 139 | extern void SetStatusTextN(HWND hdlg, LPCTSTR lpText, DWORD dwNum); 140 | extern void SetStatusTextTemp(HWND hdlg, LPCTSTR lpText); 141 | 142 | /* error handler */ 143 | 144 | extern LONG WINAPI BugHandler(EXCEPTION_POINTERS *e); 145 | 146 | /* provider */ 147 | 148 | extern DWORD EcInit(ErrorCodeSet **ppecs); 149 | extern void EcUninit(); 150 | extern LPTSTR MsgFromSys(DWORD dwFlags, LPCVOID lpSource, DWORD dwCode); 151 | 152 | /* utils */ 153 | 154 | extern BOOL ArrayInit(TArray *ary, DWORD dwCell, DWORD dwSizeHint); 155 | extern void ArrayClear(TArray *ary); 156 | extern LPVOID ArrayFinish(TArray *ary, DWORD *pdwCount); 157 | extern BOOL ArrayAppend(TArray *ary, LPVOID data); 158 | extern BOOL MatchWildCard( 159 | LPCTSTR lpText, 160 | LPCTSTR lpPattern, 161 | DWORD *pdwRanges, 162 | HighlightRange **ppRange 163 | ); 164 | extern BOOL TcsStartsWith(LPCTSTR p, LPCTSTR q); 165 | extern BOOL FmtParseDword(LPCTSTR fmt, DWORD l, DWORD r, DWORD *dwResult); 166 | extern BOOL FilterFromString(LPCTSTR fmt, SearchFilter *filter); 167 | extern void FilterClear(SearchFilter *filter); 168 | extern COLORREF BlendColor(COLORREF color); 169 | 170 | /* dlgproc */ 171 | 172 | extern INT_PTR CALLBACK DlgProcRead(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 173 | extern INT_PTR CALLBACK DlgProcHelp(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 174 | extern INT_PTR CALLBACK DlgProcAbout(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 175 | 176 | /* guiaux */ 177 | 178 | #define PATALL TEXT("*.*") 179 | #define PATTXT TEXT("*.txt") 180 | #define PATRES TEXT("*.exe;*.dll;*.ocx;*.cpl;*.scr;*.mui;*.msstyles") 181 | 182 | extern HMENU LoadPopupMenu(UINT id); 183 | extern LPTSTR GetWndText(HWND hwnd); 184 | extern BOOL CopyText(HWND hwnd, LPCTSTR lpString); 185 | extern void UrlOpen(LPTSTR lpUrl); 186 | extern void SearchInMSDN(LPCTSTR what); 187 | extern void GetWndSize(HWND hwnd, SIZE *size); 188 | extern void GetDlgUnit(HWND hdlg, SIZE *size); 189 | extern void GetMsgPosClient(HWND hwnd, LPPOINT ppt); 190 | extern BOOL FileOpenOrSave( 191 | HWND hwndParent, 192 | BOOL bOpen, 193 | LPCTSTR lpDefExt, 194 | LPCTSTR lpFilter, 195 | LPTSTR lpBuffer 196 | ); 197 | 198 | /* ldmgr */ 199 | 200 | extern BOOL LvLoadFilter(HWND hctl, SearchFilter *filter); 201 | extern BOOL LvOnNotify(HWND hdlg, NMHDR *hdr); 202 | extern BOOL ItemLoadAll(HWND hctl); 203 | extern void LvInitFont(HWND hwnd); 204 | 205 | -------------------------------------------------------------------------------- /errh.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | #include 3 | 4 | static DWORD WINAPI ErrorReport(LPVOID e){ 5 | return MessageBox(NULL, (LPCTSTR)e, NULL, MB_OK | MB_ICONERROR); 6 | } 7 | 8 | LONG WINAPI BugHandler(EXCEPTION_POINTERS *e) 9 | { 10 | TCHAR s[MAX_PATH + 4]; 11 | TCHAR t[512]; 12 | DWORD dwLen; 13 | HANDLE hFile; 14 | HANDLE hThread; 15 | 16 | dwLen = GetModuleFileName(NULL, s, MAX_PATH); 17 | _tcscpy(s + dwLen, TEXT(".dmp")); 18 | 19 | hFile = CreateFile( 20 | s, 21 | GENERIC_WRITE, 22 | FILE_SHARE_READ, 23 | NULL, 24 | CREATE_ALWAYS, 25 | FILE_ATTRIBUTE_NORMAL, 26 | NULL 27 | ); 28 | 29 | if (INVALID_HANDLE_VALUE != hFile){ 30 | MINIDUMP_EXCEPTION_INFORMATION info; 31 | 32 | info.ThreadId = GetCurrentThreadId(); 33 | info.ExceptionPointers = e; 34 | info.ClientPointers = TRUE; 35 | MiniDumpWriteDump( 36 | GetCurrentProcess(), 37 | GetCurrentProcessId(), 38 | hFile, 39 | MiniDumpWithFullMemory, 40 | &info, 41 | NULL, 42 | NULL 43 | ); 44 | 45 | CloseHandle(hFile); 46 | } 47 | 48 | _sntprintf( 49 | t, 50 | 512, 51 | TEXT("An error occurred and the program must be closed.\n") 52 | TEXT("Address: 0x%p\tErrcode: 0x%08X\n") 53 | TEXT("See more information in %s."), 54 | e->ExceptionRecord->ExceptionAddress, 55 | e->ExceptionRecord->ExceptionCode, 56 | s 57 | ); 58 | 59 | hThread = CreateThread(NULL, 0, ErrorReport, t, 0, NULL); 60 | if (hThread) 61 | { 62 | WaitForSingleObject(hThread, INFINITE); 63 | CloseHandle(hThread); 64 | } 65 | 66 | return EXCEPTION_EXECUTE_HANDLER; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /guiaux.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | #include "resource.h" 3 | #include 4 | 5 | HMENU LoadPopupMenu(UINT id) 6 | { 7 | HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(id)); 8 | HMENU hPopup = NULL; 9 | 10 | if (hMenu) 11 | { 12 | hPopup = GetSubMenu(hMenu, 0); 13 | RemoveMenu(hMenu, 0, MF_BYPOSITION); 14 | DestroyMenu(hMenu); 15 | } 16 | 17 | return hPopup; 18 | } 19 | 20 | LPTSTR GetWndText(HWND hwnd) 21 | { 22 | int iLen; 23 | LPTSTR lpText; 24 | 25 | iLen = GetWindowTextLength(hwnd) + 1; 26 | lpText = LocalAlloc(LPTR, iLen * sizeof (TCHAR)); 27 | 28 | if (lpText) 29 | { 30 | GetWindowText(hwnd, lpText, iLen); 31 | } 32 | 33 | return lpText; 34 | } 35 | 36 | BOOL CopyText(HWND hwnd, LPCTSTR lpString) 37 | { 38 | BOOL result = FALSE; 39 | SIZE_T dwLen = _tcslen(lpString); 40 | HGLOBAL hMem; 41 | 42 | if (dwLen) 43 | { 44 | if (OpenClipboard(hwnd)) 45 | { 46 | EmptyClipboard(); 47 | 48 | hMem = GlobalAlloc(GMEM_MOVEABLE, (dwLen + 1) * sizeof (*lpString)); 49 | if (hMem) 50 | { 51 | LPTSTR lpText = GlobalLock(hMem); 52 | if (lpText) 53 | { 54 | memmove(lpText, lpString, (dwLen + 1) * sizeof (*lpString)); 55 | GlobalUnlock(hMem); 56 | 57 | result = NULL != SetClipboardData( 58 | #ifdef UNICODE 59 | CF_UNICODETEXT, 60 | #else 61 | CF_TEXT, 62 | #endif 63 | hMem 64 | ); 65 | } 66 | /* Note: NO NOT free hMem */ 67 | } 68 | 69 | CloseClipboard(); 70 | } 71 | } 72 | 73 | return result; 74 | } 75 | 76 | void UrlOpen(LPTSTR lpUrl) 77 | { 78 | ShellExecute( 79 | NULL, 80 | TEXT("open"), 81 | lpUrl, 82 | NULL, 83 | NULL, 84 | SW_SHOWDEFAULT 85 | ); 86 | } 87 | 88 | void SearchInMSDN(LPCTSTR what) 89 | { 90 | TCHAR fmt[256]; 91 | LPTSTR lpCommand; 92 | DWORD dwLen = 256 + _tcslen(what); 93 | 94 | LoadString(hInst, IDS_MSDN_URL_FMT, fmt, 256); 95 | lpCommand = LocalAlloc(LPTR, dwLen * sizeof (TCHAR)); 96 | 97 | if (lpCommand) 98 | { 99 | _sntprintf(lpCommand, dwLen, fmt, what); 100 | UrlOpen(lpCommand); 101 | 102 | LocalFree(lpCommand); 103 | } 104 | } 105 | 106 | void GetWndSize(HWND hwnd, SIZE *size) 107 | { 108 | RECT r; 109 | GetWindowRect(hwnd, &r); 110 | size->cx = r.right - r.left; 111 | size->cy = r.bottom - r.top; 112 | } 113 | 114 | void GetDlgUnit(HWND hdlg, SIZE *size) 115 | { 116 | RECT r; 117 | r.left = r.top = 0, r.right = 4, r.bottom = 8; 118 | MapDialogRect(hdlg, &r); 119 | size->cx = r.right; 120 | size->cy = r.bottom; 121 | } 122 | 123 | void GetMsgPosClient(HWND hwnd, LPPOINT ppt) 124 | { 125 | LPARAM lParam; 126 | lParam = GetMessagePos(); 127 | ppt->x = GET_X_LPARAM(lParam); 128 | ppt->y = GET_Y_LPARAM(lParam); 129 | ScreenToClient(hwnd, ppt); 130 | } 131 | 132 | BOOL FileOpenOrSave( 133 | HWND hwndParent, 134 | BOOL bOpen, 135 | LPCTSTR lpDefExt, 136 | LPCTSTR lpFilter, 137 | LPTSTR lpBuffer 138 | ) 139 | { 140 | OPENFILENAME ofn = {sizeof (ofn)}; 141 | 142 | ofn.hwndOwner = hwndParent; 143 | ofn.hInstance = hInst; 144 | ofn.lpstrFilter = lpFilter; 145 | ofn.lpstrCustomFilter = NULL; 146 | ofn.nMaxCustFilter = 0; 147 | ofn.nFilterIndex = 0; 148 | lpBuffer[0] = TEXT('\0'); 149 | ofn.lpstrFile = lpBuffer; 150 | ofn.nMaxFile = MAX_PATH; 151 | ofn.lpstrFileTitle = NULL; 152 | ofn.nMaxFileTitle = 0; 153 | ofn.lpstrInitialDir = NULL; 154 | ofn.lpstrTitle = NULL; 155 | ofn.Flags = OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY; 156 | ofn.Flags |= bOpen ? OFN_FILEMUSTEXIST : OFN_OVERWRITEPROMPT; 157 | ofn.lpstrDefExt = lpDefExt; 158 | 159 | return (bOpen ? GetOpenFileName : GetSaveFileName)(&ofn); 160 | } 161 | 162 | -------------------------------------------------------------------------------- /iconapp.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killtimer0/ErrorCodeFinder/438f0e9e06e1345b0e5d65ef581a1dbfc884786d/iconapp.ico -------------------------------------------------------------------------------- /img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killtimer0/ErrorCodeFinder/438f0e9e06e1345b0e5d65ef581a1dbfc884786d/img/1.png -------------------------------------------------------------------------------- /img/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killtimer0/ErrorCodeFinder/438f0e9e06e1345b0e5d65ef581a1dbfc884786d/img/2.gif -------------------------------------------------------------------------------- /ldmgr.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | #include "resource.h" 3 | #include 4 | 5 | typedef struct _CurrentSortColumn { 6 | SHORT idx; 7 | SHORT sDirection; 8 | } CurrentSortColumn; 9 | 10 | ListContext ctxList = {0, NULL}; 11 | 12 | #define LVITEM_MAXLEN 1024 13 | static HFONT hFontNormal = NULL, hFontBold = NULL; 14 | static CurrentSortColumn ctxSort = {0xFF, 0}; 15 | 16 | static void ItemFree() 17 | { 18 | if (ctxList.item) 19 | { 20 | DWORD i, dwCount = ctxList.dwCount; 21 | ListItem *item = ctxList.item; 22 | 23 | for (i = 0; i < dwCount; ++i, ++item) 24 | { 25 | if ((item->dwHintMask & SFM_NAME) && item->ranges) 26 | LocalFree(item->ranges); 27 | } 28 | 29 | LocalFree(ctxList.item); 30 | ctxList.item = NULL; 31 | ctxList.dwCount = 0; 32 | } 33 | } 34 | 35 | static void LvSetCount(HWND hctl, DWORD dwCount) 36 | { 37 | SendMessage(hctl, WM_SETREDRAW, FALSE, 0); 38 | ListView_DeleteAllItems(hctl); 39 | ListView_SetItemCountEx(hctl, dwCount, LVSICF_NOINVALIDATEALL | LVSICF_NOSCROLL); 40 | SendMessage(hctl, WM_SETREDRAW, TRUE, 0); 41 | } 42 | 43 | static void LvSetSel(HWND hctl, int idx, BOOL bVisible) 44 | { 45 | ListView_SetItemState(hctl, idx, LVIS_SELECTED, LVIS_SELECTED); 46 | ListView_SetSelectionMark(hctl, idx); 47 | if (bVisible) 48 | { 49 | ListView_EnsureVisible(hctl, idx, FALSE); 50 | } 51 | } 52 | 53 | static int __cdecl ItemSort_Name(const ListItem *p1, const ListItem *p2) 54 | { 55 | int result; 56 | 57 | result = _tcsicmp( 58 | pecs[p1->dwScope].items[p1->dwItem].lpName, 59 | pecs[p2->dwScope].items[p2->dwItem].lpName 60 | ); 61 | 62 | if (0 == result) 63 | { 64 | dbg(_T("Same string: %s in %s and %s"), 65 | pecs[p1->dwScope].items[p1->dwItem].lpName, 66 | pecs[p1->dwScope].lpName, 67 | pecs[p2->dwScope].lpName 68 | ); 69 | } 70 | 71 | return result; 72 | } 73 | 74 | static int __cdecl ItemSort_Value(const ListItem *p1, const ListItem *p2) 75 | { 76 | int result; 77 | DWORD c1, c2; 78 | 79 | c1 = pecs[p1->dwScope].items[p1->dwItem].dwCode; 80 | c2 = pecs[p2->dwScope].items[p2->dwItem].dwCode; 81 | 82 | if (c1 > c2) 83 | { 84 | result = 1; 85 | } 86 | else if (c1 < c2) 87 | { 88 | result = -1; 89 | } 90 | else 91 | { 92 | result = ItemSort_Name(p1, p2); 93 | } 94 | 95 | return result; 96 | } 97 | 98 | static int __cdecl ItemSort_Scope(const ListItem *p1, const ListItem *p2) 99 | { 100 | int result; 101 | 102 | result = _tcsicmp( 103 | pecs[p1->dwScope].lpName, 104 | pecs[p2->dwScope].lpName 105 | ); 106 | 107 | if (0 == result) 108 | result = ItemSort_Name(p1, p2); 109 | 110 | return result; 111 | } 112 | 113 | BOOL ItemLoadAll(HWND hctl) 114 | { 115 | DWORD i, c = 0; 116 | ListItem *items; 117 | 118 | for (i = 0; i < necs; ++i) 119 | { 120 | c += pecs[i].dwCodeCount; 121 | } 122 | 123 | items = (ListItem*)LocalAlloc(LPTR, c * sizeof (ListItem)); 124 | 125 | if (items) 126 | { 127 | DWORD j, idx = 0; 128 | for (i = 0; i < necs; ++i) 129 | { 130 | DWORD cc = pecs[i].dwCodeCount; 131 | for (j = 0; j < cc; ++j) 132 | { 133 | items[idx].dwScope = i; 134 | items[idx].dwItem = j; 135 | /* Other members are automatically set to zero due to LPTR */ 136 | ++idx; 137 | } 138 | } 139 | 140 | ItemFree(); 141 | ctxList.dwCount = c; 142 | ctxList.item = items; 143 | 144 | LvSetCount(hctl, c); 145 | 146 | return TRUE; 147 | } 148 | 149 | return FALSE; 150 | } 151 | 152 | static void ItemInvert() 153 | { 154 | DWORD i, j, dwCount, dwHalf; 155 | ListItem buf; 156 | 157 | dwCount = ctxList.dwCount; 158 | dwHalf = dwCount >> 1; 159 | 160 | for (i = 0, j = dwCount - 1; i < dwHalf; ++i, --j) 161 | { 162 | buf = ctxList.item[i]; 163 | ctxList.item[i] = ctxList.item[j]; 164 | ctxList.item[j] = buf; 165 | } 166 | } 167 | 168 | static void ItemSort(int (__cdecl *cmp)(const ListItem *,const ListItem *)) 169 | { 170 | qsort( 171 | ctxList.item, 172 | ctxList.dwCount, 173 | sizeof (*ctxList.item), 174 | (int (__cdecl *)(const void *, const void *))cmp 175 | ); 176 | } 177 | 178 | static BOOL LvSort(int iCol, BOOL bInvert) 179 | { 180 | switch (iCol) 181 | { 182 | /* No sort */ 183 | case -1: 184 | break; 185 | 186 | /* Sort by name */ 187 | case 0: 188 | ItemSort(ItemSort_Name); 189 | break; 190 | 191 | /* Sort by value */ 192 | case 1: 193 | ItemSort(ItemSort_Value); 194 | break; 195 | 196 | /* Sort by scope */ 197 | case 2: 198 | ItemSort(ItemSort_Scope); 199 | break; 200 | 201 | /* We cannot sort by description because it is lazy-load */ 202 | default: 203 | return FALSE; 204 | } 205 | 206 | if (bInvert) 207 | ItemInvert(); 208 | 209 | return TRUE; 210 | } 211 | 212 | BOOL LvLoadFilter(HWND hctl, SearchFilter *filter) 213 | { 214 | BOOL result = FALSE; 215 | DWORD i, j, k, iScope = 0; 216 | ListItem item; 217 | DWORD dwCount; 218 | ErrorCodeItem *p; 219 | TArray ary; 220 | DWORD dwRanges; 221 | HighlightRange *ranges; 222 | 223 | if (ArrayInit(&ary, sizeof (ListItem), 16)) 224 | { 225 | i = 0, iScope = 0; 226 | while (1) 227 | { 228 | /* breaker: global or specific scopes */ 229 | if (filter->dwMask & SFM_SCOPE) 230 | { 231 | if (i >= filter->dwScopeCount) 232 | break; 233 | iScope = filter->dwScopes[i]; 234 | } 235 | else 236 | { 237 | if (iScope >= necs) 238 | break; 239 | } 240 | 241 | /* For each scope, we collect filtered items. */ 242 | dwCount = pecs[iScope].dwCodeCount; 243 | p = pecs[iScope].items; 244 | for (j = 0; j < dwCount; ++j) 245 | { 246 | BOOL bMatch = TRUE; 247 | memset(&item, 0, sizeof (item)); 248 | 249 | /* code filter */ 250 | if ((filter->dwMask & SFM_CODE) 251 | && p[j].dwCode != filter->dwCode 252 | ) 253 | bMatch = FALSE; 254 | 255 | /* name filter */ 256 | if (bMatch && (filter->dwMask & SFM_NAME)) 257 | { 258 | BOOL bFound = FALSE; 259 | 260 | for (k = 0; k < filter->dwNameCount; ++k) 261 | { 262 | if (MatchWildCard( 263 | p[j].lpName, 264 | filter->lpNames[k], 265 | &dwRanges, 266 | &ranges 267 | )) 268 | { 269 | bFound = TRUE; 270 | break; 271 | } 272 | } 273 | 274 | if (!bFound) 275 | bMatch = FALSE; 276 | } 277 | 278 | if (bMatch) 279 | { 280 | item.dwScope = iScope; 281 | item.dwItem = j; 282 | 283 | if (filter->dwMask & SFM_CODE) 284 | item.dwHintMask |= SFM_CODE; 285 | if (filter->dwMask & SFM_SCOPE) 286 | item.dwHintMask |= SFM_SCOPE; 287 | if ((filter->dwMask & SFM_NAME) && dwRanges) 288 | { 289 | item.dwHintMask |= SFM_NAME; 290 | item.dwRanges = dwRanges; 291 | item.ranges = ranges; 292 | } 293 | 294 | ArrayAppend(&ary, &item); 295 | } 296 | } 297 | 298 | /* iterator: global or specific scopes */ 299 | if (filter->dwMask & SFM_SCOPE) 300 | ++i; 301 | else 302 | ++iScope; 303 | } 304 | 305 | ItemFree(); 306 | ctxList.item = ArrayFinish(&ary, &ctxList.dwCount); 307 | LvSort(ctxSort.idx, ctxSort.sDirection < 0); 308 | LvSetCount(hctl, ctxList.dwCount); 309 | 310 | result = TRUE; 311 | } 312 | 313 | return result; 314 | } 315 | 316 | #define ELLIPSE_SUFFIX TEXT("...") 317 | 318 | /* We don't care about RTL text, as all charactors are in [A-Za-z0-9_]. */ 319 | static void PaintPartlyHighlight( 320 | HDC hdc, 321 | RECT *prc, 322 | LPCTSTR lpText, 323 | HighlightRange *ranges, 324 | DWORD dwRangeCount 325 | ) 326 | { 327 | int iOldMode; 328 | SIZE size; 329 | int iSuffixWidth; 330 | HFONT hFontOld; 331 | UINT fmt = DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX; 332 | DWORD dwLen, now, next, idx, i; 333 | BOOL bBold; 334 | int *extent; 335 | int *part; 336 | int iEllipsePos = -1; 337 | int ox = 0, iTotalWidth; 338 | BOOL bToAddEllipse; 339 | RECT rcFinal; 340 | 341 | iTotalWidth = prc->right - prc->left; 342 | dwLen = _tcslen(lpText); 343 | if (!dwLen) 344 | return; 345 | 346 | /* worst case: extent = dwLen, part(include '...') = 2 * slice + 2 */ 347 | extent = (int*)LocalAlloc( 348 | LMEM_FIXED, 349 | (dwLen + 2 * dwRangeCount + 2) * sizeof (int) 350 | ); 351 | if (!extent) 352 | return; 353 | part = extent + dwLen; 354 | 355 | hFontOld = (HFONT)SelectObject(hdc, hFontNormal); 356 | GetTextExtentExPoint( 357 | hdc, 358 | ELLIPSE_SUFFIX, 359 | ARRAYSIZE(ELLIPSE_SUFFIX) - 1, 360 | 0, 361 | NULL, 362 | NULL, 363 | &size 364 | ); 365 | iSuffixWidth = size.cx; 366 | 367 | iOldMode = SetBkMode(hdc, TRANSPARENT); 368 | 369 | /* first loop we collect extent data */ 370 | now = 0, idx = 0; 371 | while (now < dwLen) 372 | { 373 | if (idx < dwRangeCount) 374 | { 375 | if (now == ranges[idx].dwStart) 376 | next = ranges[idx++].dwEnd, bBold = TRUE; 377 | else 378 | next = ranges[idx].dwStart, bBold = FALSE; 379 | } 380 | else 381 | next = dwLen, bBold = FALSE; 382 | 383 | SelectObject(hdc, bBold ? hFontBold : hFontNormal); 384 | 385 | GetTextExtentExPoint( 386 | hdc, 387 | lpText + now, 388 | next - now, 389 | 0, 390 | NULL, 391 | extent + now, 392 | &size 393 | ); 394 | 395 | for (i = now; i < next; ++i) 396 | extent[i] += ox; 397 | ox += size.cx; 398 | 399 | /* draw part of the text and add a suffix */ 400 | if (ox > iTotalWidth) 401 | { 402 | for (i = next - 1; i >= 0; --i) 403 | { 404 | if (extent[i] + iSuffixWidth <= iTotalWidth) 405 | { 406 | iEllipsePos = i + 1; 407 | break; 408 | } 409 | } 410 | /* We keep at least one charactor that can be seen. */ 411 | if (iEllipsePos < 1) 412 | iEllipsePos = 1; 413 | break; 414 | } 415 | 416 | now = next; 417 | } 418 | 419 | bToAddEllipse = FALSE; 420 | rcFinal.right = prc->left; 421 | rcFinal.top = prc->top; 422 | rcFinal.bottom = prc->bottom; 423 | 424 | /* then we can draw these slices */ 425 | now = 0, idx = 0; 426 | while (now < dwLen) 427 | { 428 | if (idx < dwRangeCount) 429 | { 430 | if (now == ranges[idx].dwStart) 431 | next = ranges[idx++].dwEnd, bBold = TRUE; 432 | else 433 | next = ranges[idx].dwStart, bBold = FALSE; 434 | } 435 | else 436 | next = dwLen, bBold = FALSE; 437 | 438 | SelectObject(hdc, bBold ? hFontBold : hFontNormal); 439 | 440 | if (iEllipsePos >= now && iEllipsePos < next) 441 | { 442 | next = iEllipsePos; 443 | bToAddEllipse = TRUE; 444 | } 445 | 446 | if (now < next) 447 | { 448 | rcFinal.left = prc->left + (now == 0 ? 0 : extent[now - 1]); 449 | rcFinal.right = prc->left + extent[next - 1]; 450 | DrawText(hdc, lpText + now, next - now, &rcFinal, fmt); 451 | } 452 | 453 | if (bToAddEllipse) 454 | { 455 | SelectObject(hdc, hFontNormal); 456 | rcFinal.left = rcFinal.right; 457 | rcFinal.right = rcFinal.left + iSuffixWidth; 458 | DrawText( 459 | hdc, 460 | ELLIPSE_SUFFIX, 461 | ARRAYSIZE(ELLIPSE_SUFFIX) - 1, 462 | &rcFinal, 463 | fmt 464 | ); 465 | break; 466 | } 467 | 468 | now = next; 469 | } 470 | 471 | SetBkMode(hdc, iOldMode); 472 | SelectObject(hdc, hFontOld); 473 | 474 | LocalFree(extent); 475 | } 476 | 477 | static void PaintNormal(HDC hdc, LPCTSTR lpText, int cch, LPRECT prc, UINT fmt) 478 | { 479 | DrawText(hdc, lpText, cch, prc, fmt); 480 | } 481 | 482 | static void paint_item( 483 | HWND hwnd, 484 | HDC hdc, 485 | RECT *prc, 486 | int iItem, 487 | int iSubItem 488 | ) 489 | { 490 | ListItem *item = ctxList.item + iItem; 491 | TCHAR buf[LVITEM_MAXLEN]; 492 | DWORD fmt = DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX; 493 | 494 | /* we must ensure the text is in pszText instead of one new pointer */ 495 | { 496 | LVITEM it; 497 | 498 | it.mask = LVIF_TEXT; 499 | it.iItem = iItem; 500 | it.iSubItem = iSubItem; 501 | it.pszText = buf; 502 | it.cchTextMax = ARRAYSIZE(buf); 503 | 504 | ListView_GetItem(hwnd, &it); 505 | } 506 | 507 | /* get align info */ 508 | { 509 | LVCOLUMN lvc; 510 | 511 | lvc.mask = LVCF_FMT; 512 | ListView_GetColumn(hwnd, iSubItem, &lvc); 513 | 514 | switch (lvc.fmt & LVCFMT_JUSTIFYMASK) 515 | { 516 | case LVCFMT_LEFT: 517 | fmt |= DT_LEFT; 518 | break; 519 | 520 | case LVCFMT_CENTER: 521 | fmt |= DT_CENTER; 522 | break; 523 | 524 | case LVCFMT_RIGHT: 525 | fmt |= DT_RIGHT; 526 | break; 527 | } 528 | } 529 | 530 | switch (iSubItem) 531 | { 532 | case 0: 533 | { 534 | if (item->dwHintMask & SFM_NAME) 535 | { 536 | PaintPartlyHighlight( 537 | hdc, 538 | prc, 539 | buf, 540 | item->ranges, 541 | item->dwRanges 542 | ); 543 | } 544 | else 545 | { 546 | SelectObject(hdc, hFontNormal); 547 | PaintNormal(hdc, buf, -1, prc, fmt); 548 | } 549 | } 550 | break; 551 | 552 | case 1: 553 | { 554 | SelectObject(hdc, item->dwHintMask & SFM_CODE ? hFontBold : hFontNormal); 555 | PaintNormal(hdc, buf, -1, prc, fmt); 556 | } 557 | break; 558 | 559 | case 2: 560 | { 561 | SelectObject(hdc, item->dwHintMask & SFM_SCOPE ? hFontBold : hFontNormal); 562 | PaintNormal(hdc, buf, -1, prc, fmt); 563 | } 564 | break; 565 | 566 | case 3: 567 | { 568 | SelectObject(hdc, hFontNormal); 569 | PaintNormal(hdc, buf, -1, prc, fmt); 570 | } 571 | break; 572 | } 573 | } 574 | 575 | static int MeasurePartlyHighlight( 576 | HDC hdc, 577 | LPCTSTR lpText, 578 | HighlightRange *ranges, 579 | DWORD dwRangeCount 580 | ) 581 | { 582 | DWORD dwLen, idx; 583 | int width = 0; 584 | DWORD now, next; 585 | HFONT hFontOld; 586 | int iOldMode; 587 | SIZE size; 588 | BOOL bBold; 589 | 590 | dwLen = _tcslen(lpText); 591 | if (!dwLen) 592 | return width; 593 | 594 | hFontOld = (HFONT)SelectObject(hdc, hFontNormal); 595 | iOldMode = SetBkMode(hdc, TRANSPARENT); 596 | 597 | /* we collect extent data directly */ 598 | now = 0, idx = 0; 599 | while (now < dwLen) 600 | { 601 | if (idx < dwRangeCount) 602 | { 603 | if (now == ranges[idx].dwStart) 604 | next = ranges[idx++].dwEnd, bBold = TRUE; 605 | else 606 | next = ranges[idx].dwStart, bBold = FALSE; 607 | } 608 | else 609 | next = dwLen, bBold = FALSE; 610 | 611 | SelectObject(hdc, bBold ? hFontBold : hFontNormal); 612 | 613 | GetTextExtentExPoint( 614 | hdc, 615 | lpText + now, 616 | next - now, 617 | 0, 618 | NULL, 619 | NULL, 620 | &size 621 | ); 622 | 623 | width += size.cx; 624 | 625 | now = next; 626 | } 627 | 628 | SetBkMode(hdc, iOldMode); 629 | SelectObject(hdc, hFontOld); 630 | 631 | return width; 632 | } 633 | 634 | static int MeasureItem(HWND hwnd, int iItem, int iSubItem, int *piWidthUnwrap) 635 | { 636 | ListItem *item = ctxList.item + iItem; 637 | int width = 0; 638 | int times = 6; 639 | int cxEdge = GetSystemMetrics(SM_CXEDGE); 640 | HDC hdc = GetDC(hwnd); 641 | TCHAR buf[LVITEM_MAXLEN]; 642 | BOOL bUseBoldFont; 643 | SIZE size; 644 | 645 | /* we must ensure the text is in pszText instead of one new pointer */ 646 | { 647 | LVITEM it; 648 | 649 | it.mask = LVIF_TEXT; 650 | it.iItem = iItem; 651 | it.iSubItem = iSubItem; 652 | it.pszText = buf; 653 | it.cchTextMax = ARRAYSIZE(buf); 654 | 655 | ListView_GetItem(hwnd, &it); 656 | } 657 | 658 | switch (iSubItem) 659 | { 660 | case 0: 661 | { 662 | if (item->dwHintMask & SFM_NAME) 663 | { 664 | width = MeasurePartlyHighlight(hdc, buf, item->ranges, item->dwRanges); 665 | *piWidthUnwrap = width; 666 | width += 2 * cxEdge; 667 | } 668 | else 669 | { 670 | bUseBoldFont = FALSE; 671 | times = 2; 672 | goto MEASURE; 673 | } 674 | } 675 | break; 676 | 677 | case 1: 678 | bUseBoldFont = item->dwHintMask & SFM_CODE; 679 | goto MEASURE; 680 | 681 | case 2: 682 | bUseBoldFont = item->dwHintMask & SFM_SCOPE; 683 | goto MEASURE; 684 | 685 | case 3: 686 | bUseBoldFont = FALSE; 687 | goto MEASURE; 688 | 689 | MEASURE: 690 | { 691 | HFONT hFontOld; 692 | int iOldMode; 693 | 694 | iOldMode = SetBkMode(hdc, TRANSPARENT); 695 | hFontOld = (HFONT)SelectObject( 696 | hdc, 697 | bUseBoldFont ? hFontBold : hFontNormal 698 | ); 699 | GetTextExtentExPoint( 700 | hdc, 701 | buf, 702 | _tcslen(buf), 703 | 0, 704 | NULL, 705 | NULL, 706 | &size 707 | ); 708 | SelectObject(hdc, hFontOld); 709 | SetBkMode(hdc, iOldMode); 710 | 711 | *piWidthUnwrap = size.cx; 712 | 713 | width = size.cx + times * cxEdge; 714 | } 715 | break; 716 | 717 | default: 718 | break; 719 | } 720 | 721 | ReleaseDC(hwnd, hdc); 722 | 723 | return width; 724 | } 725 | 726 | static void LvOnCmd(HWND hdlg, ListItem *p, UINT id, LPTSTR lpDesc) 727 | { 728 | TCHAR buf[32]; 729 | LPCTSTR szCopy = NULL; 730 | 731 | switch (id) 732 | { 733 | case ID_CTXMENU_COPYNAME: 734 | if (CopyText( 735 | hdlg, 736 | pecs[p->dwScope].items[p->dwItem].lpName 737 | )) 738 | { 739 | szCopy = pecs[p->dwScope].items[p->dwItem].lpName; 740 | } 741 | break; 742 | 743 | case ID_CTXMENU_COPYVAL: 744 | _stprintf( 745 | buf, 746 | TEXT("%u"), 747 | pecs[p->dwScope].items[p->dwItem].dwCode 748 | ); 749 | if (CopyText(hdlg, buf)) 750 | { 751 | szCopy = buf; 752 | } 753 | break; 754 | 755 | case ID_CTXMENU_COPYHEX: 756 | _stprintf( 757 | buf, 758 | TEXT("0x%X"), 759 | pecs[p->dwScope].items[p->dwItem].dwCode 760 | ); 761 | if (CopyText(hdlg, buf)) 762 | { 763 | szCopy = buf; 764 | } 765 | break; 766 | 767 | case ID_CTXMENU_COPYSCOPE: 768 | { 769 | if (CopyText(hdlg, pecs[p->dwScope].lpName)) 770 | { 771 | szCopy = pecs[p->dwScope].lpName; 772 | } 773 | } 774 | break; 775 | 776 | case ID_CTXMENU_COPYDESC: 777 | if (lpDesc) 778 | { 779 | if (CopyText(hdlg, lpDesc)) 780 | { 781 | szCopy = lpDesc; 782 | } 783 | } 784 | break; 785 | 786 | case ID_CTXMENU_SEARCH: 787 | SearchInMSDN(pecs[p->dwScope].items[p->dwItem].lpName); 788 | break; 789 | } 790 | 791 | if (szCopy) 792 | { 793 | TCHAR fmt[MAX_STRING_LENGTH]; 794 | TCHAR tip[STATUS_MAXLEN]; 795 | 796 | LoadString(hInst, IDS_S_COPIED, fmt, MAX_STRING_LENGTH); 797 | _sntprintf(tip, STATUS_MAXLEN, fmt, szCopy); 798 | 799 | SetStatusTextTemp(hdlg, tip); 800 | } 801 | } 802 | 803 | static void LvAdjustArrow(HWND hctl, int iCol) 804 | { 805 | HWND hHeader; 806 | HD_ITEM item; 807 | 808 | hHeader = ListView_GetHeader(hctl); 809 | item.mask = HDI_FORMAT; 810 | 811 | if (iCol == ctxSort.idx) 812 | { 813 | if (-1 != iCol) 814 | { 815 | ctxSort.sDirection *= -1; 816 | Header_GetItem(hHeader, iCol, &item); 817 | 818 | item.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN); 819 | if (0 != ctxSort.sDirection) 820 | { 821 | item.fmt |= ctxSort.sDirection > 0 ? HDF_SORTUP : HDF_SORTDOWN; 822 | } 823 | Header_SetItem(hHeader, iCol, &item); 824 | } 825 | } 826 | else 827 | { 828 | if (-1 != ctxSort.idx) 829 | { 830 | Header_GetItem(hHeader, ctxSort.idx, &item); 831 | item.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN); 832 | Header_SetItem(hHeader, ctxSort.idx, &item); 833 | } 834 | 835 | ctxSort.idx = iCol, ctxSort.sDirection = 1; 836 | if (-1 != iCol) 837 | { 838 | Header_GetItem(hHeader, iCol, &item); 839 | 840 | item.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN); 841 | if (0 != ctxSort.sDirection) 842 | { 843 | item.fmt |= ctxSort.sDirection > 0 ? HDF_SORTUP : HDF_SORTDOWN; 844 | } 845 | Header_SetItem(hHeader, iCol, &item); 846 | } 847 | } 848 | } 849 | 850 | static void LvOnGetDispInfo(HWND hdlg, HWND hctl, LVITEM *item) 851 | { 852 | TCHAR buf[MAX_STRING_LENGTH]; 853 | DWORD dwCode; 854 | 855 | if (item->mask & LVIF_TEXT) 856 | { 857 | ListItem *it = ctxList.item + item->iItem; 858 | LPCTSTR lpText; 859 | 860 | switch (item->iSubItem) 861 | { 862 | case 0: 863 | lpText = pecs[it->dwScope].items[it->dwItem].lpName; 864 | lstrcpyn(item->pszText, lpText, item->cchTextMax); 865 | break; 866 | 867 | case 1: 868 | dwCode = pecs[it->dwScope].items[it->dwItem].dwCode; 869 | _stprintf(buf, TEXT("0x%X"), dwCode); 870 | lstrcpyn(item->pszText, buf, item->cchTextMax); 871 | break; 872 | 873 | case 2: 874 | lpText = pecs[it->dwScope].lpName; 875 | lstrcpyn(item->pszText, lpText, item->cchTextMax); 876 | break; 877 | 878 | case 3: 879 | dwCode = pecs[it->dwScope].items[it->dwItem].dwCode; 880 | lpText = pecs[it->dwScope].pfnMessageFromCode(dwCode); 881 | lstrcpyn(item->pszText, lpText, item->cchTextMax); 882 | pecs[it->dwScope].pfnFreeMessage((LPTSTR)lpText); 883 | break; 884 | } 885 | } 886 | } 887 | 888 | static int LvOnFindItem(HWND hdlg, HWND hctl, LVFINDINFO *fi) 889 | { 890 | int idx = -1; 891 | 892 | if (fi->flags & (LVFI_SUBSTRING | LVFI_PARTIAL)) 893 | { 894 | DWORD i, n, dwCurrent, dwStart; 895 | int iCurrentSel; 896 | ListItem *p; 897 | 898 | iCurrentSel = ListView_GetSelectionMark(hctl); 899 | if (-1 == iCurrentSel) 900 | dwStart = 0; 901 | else 902 | dwStart = iCurrentSel; 903 | 904 | n = ctxList.dwCount; 905 | for (i = 0; i < n; ++i) 906 | { 907 | dwCurrent = dwStart + i; 908 | if (dwCurrent >= n) 909 | dwCurrent -= n; 910 | p = ctxList.item + dwCurrent; 911 | 912 | if (TcsStartsWith(pecs[p->dwScope].items[p->dwItem].lpName, fi->psz)) 913 | { 914 | idx = dwCurrent; 915 | break; 916 | } 917 | } 918 | } 919 | 920 | return idx; 921 | } 922 | 923 | static void LvOnColumnClick(HWND hdlg, HWND hctl, int iCol) 924 | { 925 | int iCurrentSel = ListView_GetSelectionMark(hctl); 926 | BOOL bSelectedItemVisible = 927 | ListView_IsItemVisible(hctl, iCurrentSel); 928 | ListItem select; 929 | 930 | if (-1 != iCurrentSel) 931 | { 932 | select = ctxList.item[iCurrentSel]; 933 | } 934 | 935 | if (iCol == ctxSort.idx) 936 | { 937 | LvSort(-1, TRUE); 938 | } 939 | else 940 | { 941 | if (!LvSort(iCol, FALSE)) 942 | return; 943 | } 944 | 945 | LvAdjustArrow(hctl, iCol); 946 | if (-1 != iCurrentSel) 947 | { 948 | int iSel = -1; 949 | DWORD i, dwCount = ctxList.dwCount; 950 | ListItem *p = ctxList.item; 951 | 952 | for (i = 0; i < dwCount; ++i, ++p) 953 | { 954 | if (p->dwItem == select.dwItem && p->dwScope == select.dwScope) 955 | iSel = i; 956 | 957 | } 958 | LvSetSel(hctl, iSel, bSelectedItemVisible); 959 | } 960 | 961 | ListView_RedrawItems(hctl, 0, ctxList.dwCount - 1); 962 | } 963 | 964 | static void LvOnItemChanged(HWND hdlg, HWND hctl, NMLISTVIEW *item) 965 | { 966 | ListItem *p = ctxList.item + item->iItem; 967 | if (item->uNewState & LVIS_SELECTED) 968 | { 969 | TCHAR fmt[MAX_STRING_LENGTH], buf[256]; 970 | LoadString(hInst, IDS_S_ITEMMSG, fmt, MAX_STRING_LENGTH); 971 | _sntprintf( 972 | buf, 973 | 256, 974 | fmt, 975 | pecs[p->dwScope].items[p->dwItem].lpName, 976 | pecs[p->dwScope].items[p->dwItem].dwCode 977 | ); 978 | SetStatusText(hdlg, buf); 979 | } 980 | } 981 | 982 | static void LvOnRClick(HWND hdlg, HWND hctl, NMITEMACTIVATE *item) 983 | { 984 | HMENU hPopup; 985 | POINT pt = item->ptAction; 986 | ListItem *p = ctxList.item + item->iItem; 987 | if (-1 != item->iItem) 988 | { 989 | hPopup = LoadPopupMenu(IDR_CONTEXTMENU); 990 | if (hPopup) 991 | { 992 | UINT id; 993 | LPTSTR lpDesc; 994 | 995 | SetMenuDefaultItem( 996 | hPopup, 997 | ID_CTXMENU_COPYNAME + item->iSubItem, 998 | MF_BYCOMMAND 999 | ); 1000 | lpDesc = pecs[p->dwScope].pfnMessageFromCode( 1001 | pecs[p->dwScope].items[p->dwItem].dwCode 1002 | ); 1003 | if (!lpDesc) 1004 | { 1005 | DeleteMenu(hPopup, ID_CTXMENU_COPYDESC, MF_BYCOMMAND); 1006 | } 1007 | 1008 | ClientToScreen(hctl, &pt); 1009 | id = (UINT)TrackPopupMenuEx( 1010 | hPopup, 1011 | TPM_RETURNCMD, 1012 | pt.x, 1013 | pt.y, 1014 | hdlg, 1015 | NULL 1016 | ); 1017 | LvOnCmd(hdlg, p, id, lpDesc); 1018 | 1019 | if (lpDesc) 1020 | pecs[p->dwScope].pfnFreeMessage(lpDesc); 1021 | 1022 | DestroyMenu(hPopup); 1023 | } 1024 | } 1025 | } 1026 | 1027 | static void LvOnDBClick(HWND hdlg, HWND hctl, NMITEMACTIVATE *item) 1028 | { 1029 | ListItem *p = ctxList.item + item->iItem; 1030 | if (-1 != item->iItem) 1031 | { 1032 | LPTSTR lpDesc; 1033 | lpDesc = pecs[p->dwScope].pfnMessageFromCode( 1034 | pecs[p->dwScope].items[p->dwItem].dwCode 1035 | ); 1036 | 1037 | LvOnCmd(hdlg, p, ID_CTXMENU_COPYNAME + item->iSubItem, lpDesc); 1038 | 1039 | if (lpDesc) 1040 | pecs[p->dwScope].pfnFreeMessage(lpDesc); 1041 | } 1042 | } 1043 | 1044 | static void LvOnDraw(HWND hdlg, HWND hctl, NMLVCUSTOMDRAW *ctx) 1045 | { 1046 | LONG_PTR lResult = CDRF_DODEFAULT; 1047 | switch (ctx->nmcd.dwDrawStage) 1048 | { 1049 | case CDDS_PREPAINT: 1050 | lResult = CDRF_NOTIFYITEMDRAW; 1051 | break; 1052 | 1053 | case CDDS_ITEMPREPAINT: 1054 | if (bAltColor && !(ctx->nmcd.dwItemSpec & 1)) 1055 | 1056 | ctx->clrTextBk = BlendColor(ListView_GetBkColor(hctl)); 1057 | 1058 | lResult = CDRF_NOTIFYSUBITEMDRAW; 1059 | break; 1060 | 1061 | case CDDS_ITEMPREPAINT | CDDS_SUBITEM: 1062 | { 1063 | ListItem *item = ctxList.item + ctx->nmcd.dwItemSpec; 1064 | /* we don't care about listview calculating the text width */ 1065 | if (!( 1066 | ctx->nmcd.rc.left == 0 1067 | && ctx->nmcd.rc.top == 0 1068 | && ctx->nmcd.rc.right == 0 1069 | && ctx->nmcd.rc.bottom == 0 1070 | )) 1071 | { 1072 | lResult = CDRF_DOERASE | CDRF_NOTIFYPOSTPAINT; 1073 | switch (ctx->iSubItem) 1074 | { 1075 | case 0: 1076 | if (item->dwHintMask & SFM_NAME) 1077 | lResult = CDRF_DOERASE | CDRF_NOTIFYPOSTPAINT; 1078 | else 1079 | SelectObject(ctx->nmcd.hdc, hFontNormal); 1080 | break; 1081 | 1082 | case 1: 1083 | SelectObject( 1084 | ctx->nmcd.hdc, 1085 | (item->dwHintMask & SFM_CODE) ? hFontBold : hFontNormal 1086 | ); 1087 | break; 1088 | 1089 | case 2: 1090 | SelectObject( 1091 | ctx->nmcd.hdc, 1092 | (item->dwHintMask & SFM_SCOPE) ? hFontBold : hFontNormal 1093 | ); 1094 | break; 1095 | 1096 | case 3: 1097 | SelectObject(ctx->nmcd.hdc, hFontNormal); 1098 | break; 1099 | 1100 | } 1101 | } 1102 | } 1103 | break; 1104 | case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM: 1105 | { 1106 | RECT rc = ctx->nmcd.rc; 1107 | int cxEdge = GetSystemMetrics(SM_CXEDGE); 1108 | 1109 | rc.left += 3 * cxEdge; 1110 | rc.right -= 3 * cxEdge; 1111 | if (ctx->iSubItem == 0) 1112 | { 1113 | rc.left -= 2 * cxEdge; 1114 | rc.right += 2 * cxEdge; 1115 | } 1116 | 1117 | paint_item(hctl, ctx->nmcd.hdc, &rc, ctx->nmcd.dwItemSpec, ctx->iSubItem); 1118 | } 1119 | break; 1120 | 1121 | } 1122 | 1123 | SetWindowLongPtr(hdlg, DWLP_MSGRESULT, lResult); 1124 | } 1125 | 1126 | static void LvGetMarkup(HWND hdlg, HWND hctl, NMLVEMPTYMARKUP *markup) 1127 | { 1128 | LONG_PTR lResult = TRUE; 1129 | 1130 | markup->dwFlags = EMF_CENTERED; 1131 | LoadStringW(hInst, IDS_HINT_EMPTY, markup->szMarkup, L_MAX_URL_LENGTH); 1132 | SetWindowLongPtr(hdlg, DWLP_MSGRESULT, lResult); 1133 | } 1134 | 1135 | BOOL LvOnNotify(HWND hdlg, NMHDR *hdr) 1136 | { 1137 | HWND hctl = hdr->hwndFrom; 1138 | 1139 | switch (hdr->code) 1140 | { 1141 | case LVN_GETDISPINFO: 1142 | LvOnGetDispInfo(hdlg, hctl, &((LV_DISPINFO*)hdr)->item); 1143 | break; 1144 | 1145 | case LVN_ODFINDITEM: 1146 | SetWindowLongPtr( 1147 | hdlg, 1148 | DWLP_MSGRESULT, 1149 | LvOnFindItem(hdlg, hctl, &((NMLVFINDITEM*)hdr)->lvfi) 1150 | ); 1151 | break; 1152 | 1153 | case LVN_COLUMNCLICK: 1154 | LvOnColumnClick(hdlg, hctl, ((NMLISTVIEW*)hdr)->iSubItem); 1155 | break; 1156 | 1157 | case LVN_ITEMCHANGED: 1158 | LvOnItemChanged(hdlg, hctl, (NMLISTVIEW*)hdr); 1159 | break; 1160 | 1161 | case NM_RCLICK: 1162 | LvOnRClick(hdlg, hctl, (NMITEMACTIVATE*)hdr); 1163 | break; 1164 | 1165 | case NM_DBLCLK: 1166 | LvOnDBClick(hdlg, hctl, (NMITEMACTIVATE*)hdr); 1167 | break; 1168 | 1169 | case NM_CUSTOMDRAW: 1170 | LvOnDraw(hdlg, hctl, (NMLVCUSTOMDRAW*)hdr); 1171 | break; 1172 | 1173 | case LVN_GETEMPTYMARKUP: 1174 | LvGetMarkup(hdlg, hctl, (NMLVEMPTYMARKUP*)hdr); 1175 | break; 1176 | 1177 | default: 1178 | return FALSE; 1179 | } 1180 | 1181 | return TRUE; 1182 | } 1183 | 1184 | extern WNDPROC pfnLVProc; 1185 | static int iTipTrack = -1; 1186 | static int extentTip; 1187 | 1188 | static BOOL LvGetCurrentTip(HWND hwnd, int *piItem, int *piSubItem) 1189 | { 1190 | if (iTipTrack == -1) 1191 | { 1192 | LVHITTESTINFO hti; 1193 | 1194 | GetMsgPosClient(hwnd, &hti.pt); 1195 | hti.flags = LVHT_ONITEM; 1196 | 1197 | if (-1 != ListView_SubItemHitTest(hwnd, &hti)) 1198 | { 1199 | *piItem = hti.iItem; 1200 | *piSubItem = hti.iSubItem; 1201 | return TRUE; 1202 | } 1203 | } 1204 | else 1205 | { 1206 | if (iTipTrack < ListView_GetItemCount(hwnd)) 1207 | { 1208 | *piItem = iTipTrack; 1209 | *piSubItem = 0; 1210 | return TRUE; 1211 | } 1212 | } 1213 | 1214 | return FALSE; 1215 | } 1216 | 1217 | void LvInitFont(HWND hwnd) 1218 | { 1219 | HFONT hFont; 1220 | LOGFONT lf; 1221 | 1222 | if (hFontNormal) 1223 | DeleteObject(hFontNormal); 1224 | if (hFontBold) 1225 | DeleteObject(hFontBold); 1226 | 1227 | hFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0); 1228 | if (!hFont) 1229 | hFont = GetStockObject(SYSTEM_FONT); 1230 | 1231 | if (GetObject(hFont, sizeof (lf), &lf)) 1232 | { 1233 | hFontNormal = CreateFontIndirect(&lf); 1234 | 1235 | lf.lfWeight = FW_BOLD; 1236 | hFontBold = CreateFontIndirect(&lf); 1237 | } 1238 | } 1239 | 1240 | /* Dirty hack, but it works. */ 1241 | #define IDT_TRACKINGTIP 48 1242 | 1243 | static LRESULT LvxhOnDbClick(HWND hwnd, NMHEADERW *header) 1244 | { 1245 | HDITEMW item; 1246 | LRESULT lResult = 0; 1247 | int i, iStart, iEnd, width = 0, extent; 1248 | 1249 | iStart = ListView_GetTopIndex(hwnd); 1250 | iEnd = iStart + ListView_GetCountPerPage(hwnd); 1251 | 1252 | if (iStart >= 0) 1253 | { 1254 | if (iEnd > ctxList.dwCount) 1255 | iEnd = ctxList.dwCount; 1256 | 1257 | for (i = iStart; i < iEnd; ++i) 1258 | { 1259 | MeasureItem(hwnd, i, header->iItem, &extent); 1260 | if (extent > width) 1261 | width = extent; 1262 | } 1263 | } 1264 | 1265 | width += GetSystemMetrics(SM_CXEDGE) * (header->iItem ? 7 : 5); 1266 | item.mask = HDI_WIDTH; 1267 | item.cxy = width; 1268 | SendMessage( 1269 | header->hdr.hwndFrom, 1270 | HDM_SETITEMW, 1271 | header->iItem, 1272 | (LPARAM)&item 1273 | ); 1274 | 1275 | SetFocus(hwnd); 1276 | return lResult; 1277 | } 1278 | 1279 | static void LvxtOnGetDispInfo(HWND hwnd, NMTTDISPINFOW *info) 1280 | { 1281 | int iItem, iSubItem; 1282 | 1283 | if (LvGetCurrentTip(hwnd, &iItem, &iSubItem)) 1284 | { 1285 | RECT rc, rcClient; 1286 | int width; 1287 | 1288 | ListView_GetSubItemRect(hwnd, iItem, iSubItem, LVIR_LABEL, &rc); 1289 | rc.right -= GetSystemMetrics(SM_CXEDGE); 1290 | GetClientRect(hwnd, &rcClient); 1291 | IntersectRect(&rc, &rc, &rcClient); 1292 | 1293 | width = MeasureItem( 1294 | hwnd, 1295 | iItem, 1296 | iSubItem, 1297 | &extentTip 1298 | ); 1299 | 1300 | /* we need to popup the tooltip */ 1301 | if (rc.left + width > rc.right) 1302 | { 1303 | /* to use tooltips, we have to set something */ 1304 | info->szText[0] = L' '; 1305 | info->szText[1] = L'\0'; 1306 | } 1307 | } 1308 | } 1309 | 1310 | static LRESULT LvxtOnDraw(HWND hwnd, NMTTCUSTOMDRAW *ctx) 1311 | { 1312 | int iItem, iSubItem; 1313 | 1314 | switch (ctx->nmcd.dwDrawStage) 1315 | { 1316 | case CDDS_PREPAINT: 1317 | /* make the placeholder invisible */ 1318 | SetTextColor( 1319 | ctx->nmcd.hdc, 1320 | (COLORREF)SendMessage(ctx->nmcd.hdr.hwndFrom, TTM_GETTIPBKCOLOR, 0, 0) 1321 | ); 1322 | return CDRF_NOTIFYPOSTPAINT; 1323 | 1324 | case CDDS_POSTPAINT: 1325 | { 1326 | if (LvGetCurrentTip(hwnd, &iItem, &iSubItem)) 1327 | { 1328 | SetTextColor(ctx->nmcd.hdc, 0); 1329 | paint_item(hwnd, ctx->nmcd.hdc, &ctx->nmcd.rc, iItem, iSubItem); 1330 | } 1331 | } 1332 | return CDRF_SKIPDEFAULT; 1333 | 1334 | default: 1335 | return CDRF_DODEFAULT; 1336 | } 1337 | } 1338 | 1339 | static LRESULT LvxtOnShow(HWND hwnd, HWND hctl) 1340 | { 1341 | int iItem, iSubItem; 1342 | 1343 | if (LvGetCurrentTip(hwnd, &iItem, &iSubItem)) 1344 | { 1345 | RECT rc; 1346 | POINT pt; 1347 | int height; 1348 | 1349 | ListView_GetSubItemRect(hwnd, iItem, iSubItem, LVIR_LABEL, &rc); 1350 | height = rc.bottom - rc.top; 1351 | 1352 | pt.x = rc.left; 1353 | pt.y = rc.top; 1354 | ClientToScreen(hwnd, &pt); 1355 | 1356 | rc.left = pt.x + GetSystemMetrics(SM_CXEDGE) 1357 | * (iSubItem == 0 ? 1 : 3); 1358 | rc.top = pt.y; 1359 | rc.right = rc.left + extentTip; 1360 | rc.bottom = rc.top + height; 1361 | 1362 | SendMessage( 1363 | hctl, 1364 | TTM_ADJUSTRECT, 1365 | TRUE, 1366 | (LPARAM)&rc 1367 | ); 1368 | 1369 | SetWindowPos( 1370 | hctl, 1371 | NULL, 1372 | rc.left, 1373 | rc.top, 1374 | rc.right - rc.left, 1375 | rc.bottom - rc.top, 1376 | SWP_NOACTIVATE 1377 | ); 1378 | 1379 | return TRUE; 1380 | } 1381 | 1382 | return 0; 1383 | } 1384 | 1385 | LRESULT CALLBACK LvxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 1386 | { 1387 | switch (uMsg) 1388 | { 1389 | case WM_NOTIFY: 1390 | { 1391 | NMHDR *hdr = (NMHDR*)lParam; 1392 | 1393 | if (hdr->hwndFrom == ListView_GetHeader(hwnd)) 1394 | { 1395 | switch (hdr->code) 1396 | { 1397 | /* The oldproc is under unicode, so this is 1398 | * always 'W' no matter what our version is. */ 1399 | case HDN_DIVIDERDBLCLICKW: 1400 | return LvxhOnDbClick(hwnd, (NMHEADERW*)hdr); 1401 | 1402 | default: 1403 | break; 1404 | } 1405 | } 1406 | 1407 | if (hdr->hwndFrom == ListView_GetToolTips(hwnd)) 1408 | { 1409 | switch (hdr->code) 1410 | { 1411 | /* use 'W' version */ 1412 | case TTN_GETDISPINFOW: 1413 | LvxtOnGetDispInfo(hwnd, (NMTTDISPINFOW*)hdr); 1414 | return 0; 1415 | 1416 | case NM_CUSTOMDRAW: 1417 | return LvxtOnDraw(hwnd, (NMTTCUSTOMDRAW*)hdr); 1418 | 1419 | case TTN_SHOW: 1420 | return LvxtOnShow(hwnd, hdr->hwndFrom); 1421 | 1422 | } 1423 | } 1424 | } 1425 | goto DODEFPROC; 1426 | 1427 | case WM_SETFONT: 1428 | { 1429 | LRESULT lResult = CallWindowProc(pfnLVProc, hwnd, uMsg, wParam, lParam); 1430 | 1431 | LvInitFont(hwnd); 1432 | return lResult; 1433 | } 1434 | 1435 | case WM_KEYDOWN: 1436 | case WM_SYSKEYDOWN: 1437 | { 1438 | int iFocus = ListView_GetSelectionMark(hwnd); 1439 | LRESULT lResult; 1440 | int iFocusNew; 1441 | 1442 | lResult = CallWindowProc(pfnLVProc, hwnd, uMsg, wParam, lParam); 1443 | iFocusNew = ListView_GetSelectionMark(hwnd); 1444 | if (iFocusNew != iFocus) 1445 | { 1446 | iTipTrack = iFocusNew; 1447 | } 1448 | 1449 | return lResult; 1450 | } 1451 | 1452 | case WM_TIMER: 1453 | { 1454 | if (wParam == IDT_TRACKINGTIP) 1455 | { 1456 | LRESULT lResult = CallWindowProc(pfnLVProc, hwnd, uMsg, wParam, lParam); 1457 | iTipTrack = -1; 1458 | 1459 | return lResult; 1460 | } 1461 | } 1462 | goto DODEFPROC; 1463 | 1464 | case WM_DESTROY: 1465 | ItemFree(); 1466 | SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)pfnLVProc); 1467 | goto DODEFPROC; 1468 | 1469 | default: 1470 | DODEFPROC: 1471 | return CallWindowProc(pfnLVProc, hwnd, uMsg, wParam, lParam); 1472 | } 1473 | } 1474 | 1475 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | 3 | int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) 4 | { 5 | UNREFERENCED_PARAMETER(hPrevInstance); 6 | UNREFERENCED_PARAMETER(lpCmdLine); 7 | UNREFERENCED_PARAMETER(nShowCmd); 8 | return dlgmain(hInstance); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /mod/ec_bug.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | #include 3 | 4 | #ifndef XBOX_ERACTRL_CS_TIMEOUT 5 | #define XBOX_ERACTRL_CS_TIMEOUT 0x356 6 | #endif 7 | 8 | static ErrorCodeItem ec_bug_items[] = { 9 | REGCODE(HARDWARE_PROFILE_UNDOCKED_STRING) 10 | REGCODE(HARDWARE_PROFILE_DOCKED_STRING) 11 | REGCODE(HARDWARE_PROFILE_UNKNOWN_STRING) 12 | REGCODE(WINDOWS_NT_BANNER) 13 | REGCODE(WINDOWS_NT_CSD_STRING) 14 | REGCODE(WINDOWS_NT_INFO_STRING) 15 | REGCODE(WINDOWS_NT_MP_STRING) 16 | REGCODE(THREAD_TERMINATE_HELD_MUTEX) 17 | REGCODE(WINDOWS_NT_INFO_STRING_PLURAL) 18 | REGCODE(WINDOWS_NT_RC_STRING) 19 | REGCODE(APC_INDEX_MISMATCH) 20 | REGCODE(DEVICE_QUEUE_NOT_BUSY) 21 | REGCODE(INVALID_AFFINITY_SET) 22 | REGCODE(INVALID_DATA_ACCESS_TRAP) 23 | REGCODE(INVALID_PROCESS_ATTACH_ATTEMPT) 24 | REGCODE(INVALID_PROCESS_DETACH_ATTEMPT) 25 | REGCODE(INVALID_SOFTWARE_INTERRUPT) 26 | REGCODE(IRQL_NOT_DISPATCH_LEVEL) 27 | REGCODE(IRQL_NOT_GREATER_OR_EQUAL) 28 | REGCODE(IRQL_NOT_LESS_OR_EQUAL) 29 | REGCODE(NO_EXCEPTION_HANDLING_SUPPORT) 30 | REGCODE(MAXIMUM_WAIT_OBJECTS_EXCEEDED) 31 | REGCODE(MUTEX_LEVEL_NUMBER_VIOLATION) 32 | REGCODE(NO_USER_MODE_CONTEXT) 33 | REGCODE(SPIN_LOCK_ALREADY_OWNED) 34 | REGCODE(SPIN_LOCK_NOT_OWNED) 35 | REGCODE(THREAD_NOT_MUTEX_OWNER) 36 | REGCODE(TRAP_CAUSE_UNKNOWN) 37 | REGCODE(EMPTY_THREAD_REAPER_LIST) 38 | REGCODE(CREATE_DELETE_LOCK_NOT_LOCKED) 39 | REGCODE(LAST_CHANCE_CALLED_FROM_KMODE) 40 | REGCODE(CID_HANDLE_CREATION) 41 | REGCODE(CID_HANDLE_DELETION) 42 | REGCODE(REFERENCE_BY_POINTER) 43 | REGCODE(BAD_POOL_HEADER) 44 | REGCODE(MEMORY_MANAGEMENT) 45 | REGCODE(PFN_SHARE_COUNT) 46 | REGCODE(PFN_REFERENCE_COUNT) 47 | REGCODE(NO_SPIN_LOCK_AVAILABLE) 48 | REGCODE(KMODE_EXCEPTION_NOT_HANDLED) 49 | REGCODE(SHARED_RESOURCE_CONV_ERROR) 50 | REGCODE(KERNEL_APC_PENDING_DURING_EXIT) 51 | REGCODE(QUOTA_UNDERFLOW) 52 | REGCODE(FILE_SYSTEM) 53 | REGCODE(FAT_FILE_SYSTEM) 54 | REGCODE(NTFS_FILE_SYSTEM) 55 | REGCODE(NPFS_FILE_SYSTEM) 56 | REGCODE(CDFS_FILE_SYSTEM) 57 | REGCODE(RDR_FILE_SYSTEM) 58 | REGCODE(CORRUPT_ACCESS_TOKEN) 59 | REGCODE(SECURITY_SYSTEM) 60 | REGCODE(INCONSISTENT_IRP) 61 | REGCODE(PANIC_STACK_SWITCH) 62 | REGCODE(PORT_DRIVER_INTERNAL) 63 | REGCODE(SCSI_DISK_DRIVER_INTERNAL) 64 | REGCODE(DATA_BUS_ERROR) 65 | REGCODE(INSTRUCTION_BUS_ERROR) 66 | REGCODE(SET_OF_INVALID_CONTEXT) 67 | REGCODE(PHASE0_INITIALIZATION_FAILED) 68 | REGCODE(PHASE1_INITIALIZATION_FAILED) 69 | REGCODE(UNEXPECTED_INITIALIZATION_CALL) 70 | REGCODE(CACHE_MANAGER) 71 | REGCODE(NO_MORE_IRP_STACK_LOCATIONS) 72 | REGCODE(DEVICE_REFERENCE_COUNT_NOT_ZERO) 73 | REGCODE(FLOPPY_INTERNAL_ERROR) 74 | REGCODE(SERIAL_DRIVER_INTERNAL) 75 | REGCODE(SYSTEM_EXIT_OWNED_MUTEX) 76 | REGCODE(SYSTEM_UNWIND_PREVIOUS_USER) 77 | REGCODE(SYSTEM_SERVICE_EXCEPTION) 78 | REGCODE(INTERRUPT_UNWIND_ATTEMPTED) 79 | REGCODE(INTERRUPT_EXCEPTION_NOT_HANDLED) 80 | REGCODE(MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED) 81 | REGCODE(NO_MORE_SYSTEM_PTES) 82 | REGCODE(TARGET_MDL_TOO_SMALL) 83 | REGCODE(MUST_SUCCEED_POOL_EMPTY) 84 | REGCODE(ATDISK_DRIVER_INTERNAL) 85 | REGCODE(NO_SUCH_PARTITION) 86 | REGCODE(MULTIPLE_IRP_COMPLETE_REQUESTS) 87 | REGCODE(INSUFFICIENT_SYSTEM_MAP_REGS) 88 | REGCODE(DEREF_UNKNOWN_LOGON_SESSION) 89 | REGCODE(REF_UNKNOWN_LOGON_SESSION) 90 | REGCODE(CANCEL_STATE_IN_COMPLETED_IRP) 91 | REGCODE(PAGE_FAULT_WITH_INTERRUPTS_OFF) 92 | REGCODE(IRQL_GT_ZERO_AT_SYSTEM_SERVICE) 93 | REGCODE(STREAMS_INTERNAL_ERROR) 94 | REGCODE(FATAL_UNHANDLED_HARD_ERROR) 95 | REGCODE(NO_PAGES_AVAILABLE) 96 | REGCODE(PFN_LIST_CORRUPT) 97 | REGCODE(NDIS_INTERNAL_ERROR) 98 | REGCODE(PAGE_FAULT_IN_NONPAGED_AREA) 99 | REGCODE(PAGE_FAULT_IN_NONPAGED_AREA_M) 100 | REGCODE(REGISTRY_ERROR) 101 | REGCODE(MAILSLOT_FILE_SYSTEM) 102 | REGCODE(NO_BOOT_DEVICE) 103 | REGCODE(LM_SERVER_INTERNAL_ERROR) 104 | REGCODE(DATA_COHERENCY_EXCEPTION) 105 | REGCODE(INSTRUCTION_COHERENCY_EXCEPTION) 106 | REGCODE(XNS_INTERNAL_ERROR) 107 | REGCODE(VOLMGRX_INTERNAL_ERROR) 108 | REGCODE(PINBALL_FILE_SYSTEM) 109 | REGCODE(CRITICAL_SERVICE_FAILED) 110 | REGCODE(SET_ENV_VAR_FAILED) 111 | REGCODE(HAL_INITIALIZATION_FAILED) 112 | REGCODE(UNSUPPORTED_PROCESSOR) 113 | REGCODE(OBJECT_INITIALIZATION_FAILED) 114 | REGCODE(SECURITY_INITIALIZATION_FAILED) 115 | REGCODE(PROCESS_INITIALIZATION_FAILED) 116 | REGCODE(HAL1_INITIALIZATION_FAILED) 117 | REGCODE(OBJECT1_INITIALIZATION_FAILED) 118 | REGCODE(SECURITY1_INITIALIZATION_FAILED) 119 | REGCODE(SYMBOLIC_INITIALIZATION_FAILED) 120 | REGCODE(MEMORY1_INITIALIZATION_FAILED) 121 | REGCODE(CACHE_INITIALIZATION_FAILED) 122 | REGCODE(CONFIG_INITIALIZATION_FAILED) 123 | REGCODE(FILE_INITIALIZATION_FAILED) 124 | REGCODE(IO1_INITIALIZATION_FAILED) 125 | REGCODE(LPC_INITIALIZATION_FAILED) 126 | REGCODE(PROCESS1_INITIALIZATION_FAILED) 127 | REGCODE(REFMON_INITIALIZATION_FAILED) 128 | REGCODE(SESSION1_INITIALIZATION_FAILED) 129 | REGCODE(BOOTPROC_INITIALIZATION_FAILED) 130 | REGCODE(VSL_INITIALIZATION_FAILED) 131 | REGCODE(SOFT_RESTART_FATAL_ERROR) 132 | REGCODE(ASSIGN_DRIVE_LETTERS_FAILED) 133 | REGCODE(CONFIG_LIST_FAILED) 134 | REGCODE(BAD_SYSTEM_CONFIG_INFO) 135 | REGCODE(CANNOT_WRITE_CONFIGURATION) 136 | REGCODE(PROCESS_HAS_LOCKED_PAGES) 137 | REGCODE(KERNEL_STACK_INPAGE_ERROR) 138 | REGCODE(PHASE0_EXCEPTION) 139 | REGCODE(MISMATCHED_HAL) 140 | REGCODE(KERNEL_DATA_INPAGE_ERROR) 141 | REGCODE(INACCESSIBLE_BOOT_DEVICE) 142 | REGCODE(BUGCODE_NDIS_DRIVER) 143 | REGCODE(INSTALL_MORE_MEMORY) 144 | REGCODE(SYSTEM_THREAD_EXCEPTION_NOT_HANDLED) 145 | REGCODE(SYSTEM_THREAD_EXCEPTION_NOT_HANDLED_M) 146 | REGCODE(UNEXPECTED_KERNEL_MODE_TRAP) 147 | REGCODE(UNEXPECTED_KERNEL_MODE_TRAP_M) 148 | REGCODE(NMI_HARDWARE_FAILURE) 149 | REGCODE(SPIN_LOCK_INIT_FAILURE) 150 | REGCODE(DFS_FILE_SYSTEM) 151 | REGCODE(OFS_FILE_SYSTEM) 152 | REGCODE(RECOM_DRIVER) 153 | REGCODE(SETUP_FAILURE) 154 | REGCODE(AUDIT_FAILURE) 155 | REGCODE(MBR_CHECKSUM_MISMATCH) 156 | REGCODE(KERNEL_MODE_EXCEPTION_NOT_HANDLED) 157 | REGCODE(KERNEL_MODE_EXCEPTION_NOT_HANDLED_M) 158 | REGCODE(PP0_INITIALIZATION_FAILED) 159 | REGCODE(PP1_INITIALIZATION_FAILED) 160 | REGCODE(WIN32K_INIT_OR_RIT_FAILURE) 161 | REGCODE(UP_DRIVER_ON_MP_SYSTEM) 162 | REGCODE(INVALID_KERNEL_HANDLE) 163 | REGCODE(KERNEL_STACK_LOCKED_AT_EXIT) 164 | REGCODE(PNP_INTERNAL_ERROR) 165 | REGCODE(INVALID_WORK_QUEUE_ITEM) 166 | REGCODE(BOUND_IMAGE_UNSUPPORTED) 167 | REGCODE(END_OF_NT_EVALUATION_PERIOD) 168 | REGCODE(INVALID_REGION_OR_SEGMENT) 169 | REGCODE(SYSTEM_LICENSE_VIOLATION) 170 | REGCODE(UDFS_FILE_SYSTEM) 171 | REGCODE(MACHINE_CHECK_EXCEPTION) 172 | REGCODE(USER_MODE_HEALTH_MONITOR) 173 | REGCODE(DRIVER_POWER_STATE_FAILURE) 174 | REGCODE(INTERNAL_POWER_ERROR) 175 | REGCODE(PCI_BUS_DRIVER_INTERNAL) 176 | REGCODE(MEMORY_IMAGE_CORRUPT) 177 | REGCODE(ACPI_DRIVER_INTERNAL) 178 | REGCODE(CNSS_FILE_SYSTEM_FILTER) 179 | REGCODE(ACPI_BIOS_ERROR) 180 | REGCODE(FP_EMULATION_ERROR) 181 | REGCODE(BAD_EXHANDLE) 182 | REGCODE(BOOTING_IN_SAFEMODE_MINIMAL) 183 | REGCODE(BOOTING_IN_SAFEMODE_NETWORK) 184 | REGCODE(BOOTING_IN_SAFEMODE_DSREPAIR) 185 | REGCODE(SESSION_HAS_VALID_POOL_ON_EXIT) 186 | REGCODE(HAL_MEMORY_ALLOCATION) 187 | REGCODE(VIDEO_DRIVER_DEBUG_REPORT_REQUEST) 188 | REGCODE(BGI_DETECTED_VIOLATION) 189 | REGCODE(VIDEO_DRIVER_INIT_FAILURE) 190 | REGCODE(BOOTLOG_LOADED) 191 | REGCODE(BOOTLOG_NOT_LOADED) 192 | REGCODE(BOOTLOG_ENABLED) 193 | REGCODE(ATTEMPTED_SWITCH_FROM_DPC) 194 | REGCODE(CHIPSET_DETECTED_ERROR) 195 | REGCODE(SESSION_HAS_VALID_VIEWS_ON_EXIT) 196 | REGCODE(NETWORK_BOOT_INITIALIZATION_FAILED) 197 | REGCODE(NETWORK_BOOT_DUPLICATE_ADDRESS) 198 | REGCODE(INVALID_HIBERNATED_STATE) 199 | REGCODE(ATTEMPTED_WRITE_TO_READONLY_MEMORY) 200 | REGCODE(MUTEX_ALREADY_OWNED) 201 | REGCODE(PCI_CONFIG_SPACE_ACCESS_FAILURE) 202 | REGCODE(SPECIAL_POOL_DETECTED_MEMORY_CORRUPTION) 203 | REGCODE(BAD_POOL_CALLER) 204 | REGCODE(SYSTEM_IMAGE_BAD_SIGNATURE) 205 | REGCODE(DRIVER_VERIFIER_DETECTED_VIOLATION) 206 | REGCODE(DRIVER_CORRUPTED_EXPOOL) 207 | REGCODE(DRIVER_CAUGHT_MODIFYING_FREED_POOL) 208 | REGCODE(TIMER_OR_DPC_INVALID) 209 | REGCODE(IRQL_UNEXPECTED_VALUE) 210 | REGCODE(DRIVER_VERIFIER_IOMANAGER_VIOLATION) 211 | REGCODE(PNP_DETECTED_FATAL_ERROR) 212 | REGCODE(DRIVER_LEFT_LOCKED_PAGES_IN_PROCESS) 213 | REGCODE(PAGE_FAULT_IN_FREED_SPECIAL_POOL) 214 | REGCODE(PAGE_FAULT_BEYOND_END_OF_ALLOCATION) 215 | REGCODE(DRIVER_UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATIONS) 216 | REGCODE(TERMINAL_SERVER_DRIVER_MADE_INCORRECT_MEMORY_REFERENCE) 217 | REGCODE(DRIVER_CORRUPTED_MMPOOL) 218 | REGCODE(DRIVER_IRQL_NOT_LESS_OR_EQUAL) 219 | REGCODE(BUGCODE_ID_DRIVER) 220 | REGCODE(DRIVER_PORTION_MUST_BE_NONPAGED) 221 | REGCODE(SYSTEM_SCAN_AT_RAISED_IRQL_CAUGHT_IMPROPER_DRIVER_UNLOAD) 222 | REGCODE(DRIVER_PAGE_FAULT_IN_FREED_SPECIAL_POOL) 223 | REGCODE(DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION) 224 | REGCODE(DRIVER_PAGE_FAULT_BEYOND_END_OF_ALLOCATION_M) 225 | REGCODE(DRIVER_UNMAPPING_INVALID_VIEW) 226 | REGCODE(DRIVER_USED_EXCESSIVE_PTES) 227 | REGCODE(LOCKED_PAGES_TRACKER_CORRUPTION) 228 | REGCODE(SYSTEM_PTE_MISUSE) 229 | REGCODE(DRIVER_CORRUPTED_SYSPTES) 230 | REGCODE(DRIVER_INVALID_STACK_ACCESS) 231 | REGCODE(POOL_CORRUPTION_IN_FILE_AREA) 232 | REGCODE(IMPERSONATING_WORKER_THREAD) 233 | REGCODE(ACPI_BIOS_FATAL_ERROR) 234 | REGCODE(WORKER_THREAD_RETURNED_AT_BAD_IRQL) 235 | REGCODE(MANUALLY_INITIATED_CRASH) 236 | REGCODE(RESOURCE_NOT_OWNED) 237 | REGCODE(WORKER_INVALID) 238 | REGCODE(POWER_FAILURE_SIMULATE) 239 | REGCODE(DRIVER_VERIFIER_DMA_VIOLATION) 240 | REGCODE(INVALID_FLOATING_POINT_STATE) 241 | REGCODE(INVALID_CANCEL_OF_FILE_OPEN) 242 | REGCODE(ACTIVE_EX_WORKER_THREAD_TERMINATION) 243 | REGCODE(SAVER_UNSPECIFIED) 244 | REGCODE(SAVER_BLANKSCREEN) 245 | REGCODE(SAVER_INPUT) 246 | REGCODE(SAVER_WATCHDOG) 247 | REGCODE(SAVER_STARTNOTVISIBLE) 248 | REGCODE(SAVER_NAVIGATIONMODEL) 249 | REGCODE(SAVER_OUTOFMEMORY) 250 | REGCODE(SAVER_GRAPHICS) 251 | REGCODE(SAVER_NAVSERVERTIMEOUT) 252 | REGCODE(SAVER_CHROMEPROCESSCRASH) 253 | REGCODE(SAVER_NOTIFICATIONDISMISSAL) 254 | REGCODE(SAVER_SPEECHDISMISSAL) 255 | REGCODE(SAVER_CALLDISMISSAL) 256 | REGCODE(SAVER_APPBARDISMISSAL) 257 | REGCODE(SAVER_RILADAPTATIONCRASH) 258 | REGCODE(SAVER_APPLISTUNREACHABLE) 259 | REGCODE(SAVER_REPORTNOTIFICATIONFAILURE) 260 | REGCODE(SAVER_UNEXPECTEDSHUTDOWN) 261 | REGCODE(SAVER_RPCFAILURE) 262 | REGCODE(SAVER_AUXILIARYFULLDUMP) 263 | REGCODE(SAVER_ACCOUNTPROVSVCINITFAILURE) 264 | REGCODE(SAVER_MTBFCOMMANDTIMEOUT) 265 | REGCODE(SAVER_MTBFCOMMANDHANG) 266 | REGCODE(SAVER_MTBFPASSBUGCHECK) 267 | REGCODE(SAVER_MTBFIOERROR) 268 | REGCODE(SAVER_RENDERTHREADHANG) 269 | REGCODE(SAVER_RENDERMOBILEUIOOM) 270 | REGCODE(SAVER_DEVICEUPDATEUNSPECIFIED) 271 | REGCODE(SAVER_AUDIODRIVERHANG) 272 | REGCODE(SAVER_BATTERYPULLOUT) 273 | REGCODE(SAVER_MEDIACORETESTHANG) 274 | REGCODE(SAVER_RESOURCEMANAGEMENT) 275 | REGCODE(SAVER_CAPTURESERVICE) 276 | REGCODE(SAVER_WAITFORSHELLREADY) 277 | REGCODE(SAVER_NONRESPONSIVEPROCESS) 278 | REGCODE(SAVER_SICKAPPLICATION) 279 | REGCODE(THREAD_STUCK_IN_DEVICE_DRIVER) 280 | REGCODE(THREAD_STUCK_IN_DEVICE_DRIVER_M) 281 | REGCODE(DIRTY_MAPPED_PAGES_CONGESTION) 282 | REGCODE(SESSION_HAS_VALID_SPECIAL_POOL_ON_EXIT) 283 | REGCODE(UNMOUNTABLE_BOOT_VOLUME) 284 | REGCODE(CRITICAL_PROCESS_DIED) 285 | REGCODE(STORAGE_MINIPORT_ERROR) 286 | REGCODE(SCSI_VERIFIER_DETECTED_VIOLATION) 287 | REGCODE(HARDWARE_INTERRUPT_STORM) 288 | REGCODE(DISORDERLY_SHUTDOWN) 289 | REGCODE(CRITICAL_OBJECT_TERMINATION) 290 | REGCODE(FLTMGR_FILE_SYSTEM) 291 | REGCODE(PCI_VERIFIER_DETECTED_VIOLATION) 292 | REGCODE(DRIVER_OVERRAN_STACK_BUFFER) 293 | REGCODE(RAMDISK_BOOT_INITIALIZATION_FAILED) 294 | REGCODE(DRIVER_RETURNED_STATUS_REPARSE_FOR_VOLUME_OPEN) 295 | REGCODE(HTTP_DRIVER_CORRUPTED) 296 | REGCODE(RECURSIVE_MACHINE_CHECK) 297 | REGCODE(ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY) 298 | REGCODE(DIRTY_NOWRITE_PAGES_CONGESTION) 299 | REGCODE(BUGCODE_USB_DRIVER) 300 | REGCODE(BC_BLUETOOTH_VERIFIER_FAULT) 301 | REGCODE(BC_BTHMINI_VERIFIER_FAULT) 302 | REGCODE(RESERVE_QUEUE_OVERFLOW) 303 | REGCODE(LOADER_BLOCK_MISMATCH) 304 | REGCODE(CLOCK_WATCHDOG_TIMEOUT) 305 | REGCODE(DPC_WATCHDOG_TIMEOUT) 306 | REGCODE(MUP_FILE_SYSTEM) 307 | REGCODE(AGP_INVALID_ACCESS) 308 | REGCODE(AGP_GART_CORRUPTION) 309 | REGCODE(AGP_ILLEGALLY_REPROGRAMMED) 310 | REGCODE(KERNEL_EXPAND_STACK_ACTIVE) 311 | REGCODE(THIRD_PARTY_FILE_SYSTEM_FAILURE) 312 | REGCODE(CRITICAL_STRUCTURE_CORRUPTION) 313 | REGCODE(APP_TAGGING_INITIALIZATION_FAILED) 314 | REGCODE(DFSC_FILE_SYSTEM) 315 | REGCODE(FSRTL_EXTRA_CREATE_PARAMETER_VIOLATION) 316 | REGCODE(WDF_VIOLATION) 317 | REGCODE(VIDEO_MEMORY_MANAGEMENT_INTERNAL) 318 | REGCODE(DRIVER_INVALID_CRUNTIME_PARAMETER) 319 | REGCODE(RECURSIVE_NMI) 320 | REGCODE(MSRPC_STATE_VIOLATION) 321 | REGCODE(VIDEO_DXGKRNL_FATAL_ERROR) 322 | REGCODE(VIDEO_SHADOW_DRIVER_FATAL_ERROR) 323 | REGCODE(AGP_INTERNAL) 324 | REGCODE(VIDEO_TDR_FAILURE) 325 | REGCODE(VIDEO_TDR_TIMEOUT_DETECTED) 326 | REGCODE(NTHV_GUEST_ERROR) 327 | REGCODE(VIDEO_SCHEDULER_INTERNAL_ERROR) 328 | REGCODE(EM_INITIALIZATION_ERROR) 329 | REGCODE(DRIVER_RETURNED_HOLDING_CANCEL_LOCK) 330 | REGCODE(ATTEMPTED_WRITE_TO_CM_PROTECTED_STORAGE) 331 | REGCODE(EVENT_TRACING_FATAL_ERROR) 332 | REGCODE(TOO_MANY_RECURSIVE_FAULTS) 333 | REGCODE(INVALID_DRIVER_HANDLE) 334 | REGCODE(BITLOCKER_FATAL_ERROR) 335 | REGCODE(DRIVER_VIOLATION) 336 | REGCODE(WHEA_INTERNAL_ERROR) 337 | REGCODE(CRYPTO_SELF_TEST_FAILURE) 338 | REGCODE(WHEA_UNCORRECTABLE_ERROR) 339 | REGCODE(NMR_INVALID_STATE) 340 | REGCODE(NETIO_INVALID_POOL_CALLER) 341 | REGCODE(PAGE_NOT_ZERO) 342 | REGCODE(WORKER_THREAD_RETURNED_WITH_BAD_IO_PRIORITY) 343 | REGCODE(WORKER_THREAD_RETURNED_WITH_BAD_PAGING_IO_PRIORITY) 344 | REGCODE(MUI_NO_VALID_SYSTEM_LANGUAGE) 345 | REGCODE(FAULTY_HARDWARE_CORRUPTED_PAGE) 346 | REGCODE(EXFAT_FILE_SYSTEM) 347 | REGCODE(VOLSNAP_OVERLAPPED_TABLE_ACCESS) 348 | REGCODE(INVALID_MDL_RANGE) 349 | REGCODE(VHD_BOOT_INITIALIZATION_FAILED) 350 | REGCODE(DYNAMIC_ADD_PROCESSOR_MISMATCH) 351 | REGCODE(INVALID_EXTENDED_PROCESSOR_STATE) 352 | REGCODE(RESOURCE_OWNER_POINTER_INVALID) 353 | REGCODE(DPC_WATCHDOG_VIOLATION) 354 | REGCODE(DRIVE_EXTENDER) 355 | REGCODE(REGISTRY_FILTER_DRIVER_EXCEPTION) 356 | REGCODE(VHD_BOOT_HOST_VOLUME_NOT_ENOUGH_SPACE) 357 | REGCODE(WIN32K_HANDLE_MANAGER) 358 | REGCODE(GPIO_CONTROLLER_DRIVER_ERROR) 359 | REGCODE(KERNEL_SECURITY_CHECK_FAILURE) 360 | REGCODE(KERNEL_MODE_HEAP_CORRUPTION) 361 | REGCODE(PASSIVE_INTERRUPT_ERROR) 362 | REGCODE(INVALID_IO_BOOST_STATE) 363 | REGCODE(CRITICAL_INITIALIZATION_FAILURE) 364 | REGCODE(ERRATA_WORKAROUND_UNSUCCESSFUL) 365 | REGCODE(STORAGE_DEVICE_ABNORMALITY_DETECTED) 366 | REGCODE(VIDEO_ENGINE_TIMEOUT_DETECTED) 367 | REGCODE(VIDEO_TDR_APPLICATION_BLOCKED) 368 | REGCODE(PROCESSOR_DRIVER_INTERNAL) 369 | REGCODE(BUGCODE_USB3_DRIVER) 370 | REGCODE(SECURE_BOOT_VIOLATION) 371 | REGCODE(NDIS_NET_BUFFER_LIST_INFO_ILLEGALLY_TRANSFERRED) 372 | REGCODE(ABNORMAL_RESET_DETECTED) 373 | REGCODE(IO_OBJECT_INVALID) 374 | REGCODE(REFS_FILE_SYSTEM) 375 | REGCODE(KERNEL_WMI_INTERNAL) 376 | REGCODE(SOC_SUBSYSTEM_FAILURE) 377 | REGCODE(FATAL_ABNORMAL_RESET_ERROR) 378 | REGCODE(EXCEPTION_SCOPE_INVALID) 379 | REGCODE(SOC_CRITICAL_DEVICE_REMOVED) 380 | REGCODE(PDC_WATCHDOG_TIMEOUT) 381 | REGCODE(TCPIP_AOAC_NIC_ACTIVE_REFERENCE_LEAK) 382 | REGCODE(UNSUPPORTED_INSTRUCTION_MODE) 383 | REGCODE(INVALID_PUSH_LOCK_FLAGS) 384 | REGCODE(KERNEL_LOCK_ENTRY_LEAKED_ON_THREAD_TERMINATION) 385 | REGCODE(UNEXPECTED_STORE_EXCEPTION) 386 | REGCODE(OS_DATA_TAMPERING) 387 | REGCODE(WINSOCK_DETECTED_HUNG_CLOSESOCKET_LIVEDUMP) 388 | REGCODE(KERNEL_THREAD_PRIORITY_FLOOR_VIOLATION) 389 | REGCODE(ILLEGAL_IOMMU_PAGE_FAULT) 390 | REGCODE(HAL_ILLEGAL_IOMMU_PAGE_FAULT) 391 | REGCODE(SDBUS_INTERNAL_ERROR) 392 | REGCODE(WORKER_THREAD_RETURNED_WITH_SYSTEM_PAGE_PRIORITY_ACTIVE) 393 | REGCODE(PDC_WATCHDOG_TIMEOUT_LIVEDUMP) 394 | REGCODE(SOC_SUBSYSTEM_FAILURE_LIVEDUMP) 395 | REGCODE(BUGCODE_NDIS_DRIVER_LIVE_DUMP) 396 | REGCODE(CONNECTED_STANDBY_WATCHDOG_TIMEOUT_LIVEDUMP) 397 | REGCODE(WIN32K_ATOMIC_CHECK_FAILURE) 398 | REGCODE(LIVE_SYSTEM_DUMP) 399 | REGCODE(KERNEL_AUTO_BOOST_INVALID_LOCK_RELEASE) 400 | REGCODE(WORKER_THREAD_TEST_CONDITION) 401 | REGCODE(WIN32K_CRITICAL_FAILURE) 402 | REGCODE(CLUSTER_CSV_STATUS_IO_TIMEOUT_LIVEDUMP) 403 | REGCODE(CLUSTER_RESOURCE_CALL_TIMEOUT_LIVEDUMP) 404 | REGCODE(CLUSTER_CSV_SNAPSHOT_DEVICE_INFO_TIMEOUT_LIVEDUMP) 405 | REGCODE(CLUSTER_CSV_STATE_TRANSITION_TIMEOUT_LIVEDUMP) 406 | REGCODE(CLUSTER_CSV_VOLUME_ARRIVAL_LIVEDUMP) 407 | REGCODE(CLUSTER_CSV_VOLUME_REMOVAL_LIVEDUMP) 408 | REGCODE(CLUSTER_CSV_CLUSTER_WATCHDOG_LIVEDUMP) 409 | REGCODE(INVALID_RUNDOWN_PROTECTION_FLAGS) 410 | REGCODE(INVALID_SLOT_ALLOCATOR_FLAGS) 411 | REGCODE(ERESOURCE_INVALID_RELEASE) 412 | REGCODE(CLUSTER_CSV_STATE_TRANSITION_INTERVAL_TIMEOUT_LIVEDUMP) 413 | REGCODE(CLUSTER_CSV_CLUSSVC_DISCONNECT_WATCHDOG) 414 | REGCODE(CRYPTO_LIBRARY_INTERNAL_ERROR) 415 | REGCODE(COREMSGCALL_INTERNAL_ERROR) 416 | REGCODE(COREMSG_INTERNAL_ERROR) 417 | REGCODE(PREVIOUS_FATAL_ABNORMAL_RESET_ERROR) 418 | REGCODE(ELAM_DRIVER_DETECTED_FATAL_ERROR) 419 | REGCODE(CLUSTER_CLUSPORT_STATUS_IO_TIMEOUT_LIVEDUMP) 420 | REGCODE(PROFILER_CONFIGURATION_ILLEGAL) 421 | REGCODE(PDC_LOCK_WATCHDOG_LIVEDUMP) 422 | REGCODE(PDC_UNEXPECTED_REVOCATION_LIVEDUMP) 423 | REGCODE(MICROCODE_REVISION_MISMATCH) 424 | REGCODE(WVR_LIVEDUMP_REPLICATION_IOCONTEXT_TIMEOUT) 425 | REGCODE(WVR_LIVEDUMP_STATE_TRANSITION_TIMEOUT) 426 | REGCODE(WVR_LIVEDUMP_RECOVERY_IOCONTEXT_TIMEOUT) 427 | REGCODE(WVR_LIVEDUMP_APP_IO_TIMEOUT) 428 | REGCODE(WVR_LIVEDUMP_MANUALLY_INITIATED) 429 | REGCODE(WVR_LIVEDUMP_STATE_FAILURE) 430 | REGCODE(WVR_LIVEDUMP_CRITICAL_ERROR) 431 | REGCODE(VIDEO_DWMINIT_TIMEOUT_FALLBACK_BDD) 432 | REGCODE(CLUSTER_CSVFS_LIVEDUMP) 433 | REGCODE(BAD_OBJECT_HEADER) 434 | REGCODE(SILO_CORRUPT) 435 | REGCODE(SECURE_KERNEL_ERROR) 436 | REGCODE(HYPERGUARD_VIOLATION) 437 | REGCODE(SECURE_FAULT_UNHANDLED) 438 | REGCODE(KERNEL_PARTITION_REFERENCE_VIOLATION) 439 | REGCODE(WIN32K_CRITICAL_FAILURE_LIVEDUMP) 440 | REGCODE(PF_DETECTED_CORRUPTION) 441 | REGCODE(KERNEL_AUTO_BOOST_LOCK_ACQUISITION_WITH_RAISED_IRQL) 442 | REGCODE(VIDEO_DXGKRNL_LIVEDUMP) 443 | REGCODE(KERNEL_STORAGE_SLOT_IN_USE) 444 | REGCODE(SMB_SERVER_LIVEDUMP) 445 | REGCODE(LOADER_ROLLBACK_DETECTED) 446 | REGCODE(WIN32K_SECURITY_FAILURE) 447 | REGCODE(UFX_LIVEDUMP) 448 | REGCODE(WORKER_THREAD_RETURNED_WHILE_ATTACHED_TO_SILO) 449 | REGCODE(TTM_FATAL_ERROR) 450 | REGCODE(WIN32K_POWER_WATCHDOG_TIMEOUT) 451 | REGCODE(CLUSTER_SVHDX_LIVEDUMP) 452 | REGCODE(BUGCODE_NETADAPTER_DRIVER) 453 | REGCODE(PDC_PRIVILEGE_CHECK_LIVEDUMP) 454 | REGCODE(TTM_WATCHDOG_TIMEOUT) 455 | REGCODE(WIN32K_CALLOUT_WATCHDOG_LIVEDUMP) 456 | REGCODE(WIN32K_CALLOUT_WATCHDOG_BUGCHECK) 457 | REGCODE(CALL_HAS_NOT_RETURNED_WATCHDOG_TIMEOUT_LIVEDUMP) 458 | REGCODE(DRIPS_SW_HW_DIVERGENCE_LIVEDUMP) 459 | REGCODE(USB_DRIPS_BLOCKER_SURPRISE_REMOVAL_LIVEDUMP) 460 | REGCODE(BLUETOOTH_ERROR_RECOVERY_LIVEDUMP) 461 | REGCODE(SMB_REDIRECTOR_LIVEDUMP) 462 | REGCODE(DRIVER_VERIFIER_DETECTED_VIOLATION_LIVEDUMP) 463 | REGCODE(IO_THREADPOOL_DEADLOCK_LIVEDUMP) 464 | REGCODE(FAST_ERESOURCE_PRECONDITION_VIOLATION) 465 | REGCODE(STORE_DATA_STRUCTURE_CORRUPTION) 466 | REGCODE(MANUALLY_INITIATED_POWER_BUTTON_HOLD) 467 | REGCODE(USER_MODE_HEALTH_MONITOR_LIVEDUMP) 468 | REGCODE(SYNTHETIC_WATCHDOG_TIMEOUT) 469 | REGCODE(INVALID_SILO_DETACH) 470 | REGCODE(EXRESOURCE_TIMEOUT_LIVEDUMP) 471 | REGCODE(INVALID_CALLBACK_STACK_ADDRESS) 472 | REGCODE(INVALID_KERNEL_STACK_ADDRESS) 473 | REGCODE(HARDWARE_WATCHDOG_TIMEOUT) 474 | REGCODE(ACPI_FIRMWARE_WATCHDOG_TIMEOUT) 475 | REGCODE(TELEMETRY_ASSERTS_LIVEDUMP) 476 | REGCODE(WORKER_THREAD_INVALID_STATE) 477 | REGCODE(WFP_INVALID_OPERATION) 478 | REGCODE(UCMUCSI_LIVEDUMP) 479 | REGCODE(DRIVER_PNP_WATCHDOG) 480 | REGCODE(WORKER_THREAD_RETURNED_WITH_NON_DEFAULT_WORKLOAD_CLASS) 481 | REGCODE(EFS_FATAL_ERROR) 482 | REGCODE(UCMUCSI_FAILURE) 483 | REGCODE(XBOX_ERACTRL_CS_TIMEOUT) 484 | REGCODE(XBOX_CORRUPTED_IMAGE) 485 | REGCODE(XBOX_INVERTED_FUNCTION_TABLE_OVERFLOW) 486 | REGCODE(XBOX_CORRUPTED_IMAGE_BASE) 487 | REGCODE(XBOX_360_SYSTEM_CRASH) 488 | REGCODE(XBOX_360_SYSTEM_CRASH_RESERVED) 489 | REGCODE(HYPERVISOR_ERROR) 490 | REGCODE(WINLOGON_FATAL_ERROR) 491 | REGCODE(MANUALLY_INITIATED_CRASH1) 492 | REGCODE(BUGCHECK_CONTEXT_MODIFIER) 493 | }; 494 | 495 | static LPTSTR bug_code2msg(DWORD dwCode) 496 | { 497 | return MsgFromSys(FORMAT_MESSAGE_FROM_HMODULE, hModKrnl, dwCode); 498 | } 499 | 500 | static void bug_freemsg(LPTSTR lpMessage) 501 | { 502 | LocalFree(lpMessage); 503 | } 504 | 505 | void EcRegBug(ErrorCodeSet *pecs) 506 | { 507 | pecs->lpName = TEXT("System"); 508 | pecs->pfnMessageFromCode = bug_code2msg; 509 | pecs->pfnFreeMessage = bug_freemsg; 510 | pecs->items = ec_bug_items; 511 | pecs->dwCodeCount = ARRAYSIZE(ec_bug_items); 512 | } 513 | 514 | void EcUnregBug() 515 | { 516 | /* Ignore */ 517 | } 518 | 519 | -------------------------------------------------------------------------------- /mod/ec_ccm.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | 3 | #define CCM_E_ITEMNOTFOUND 0x87D00215 4 | #define CCM_E_EMPTY_CERT_STORE 0x87D00280 5 | #define CCM_E_NO_CERT_MATCHING_CRITERIA 0x87D00281 6 | #define CCM_E_TOO_MANY_CERTS 0x87D00282 7 | #define CCM_E_MISSING_PRIVATEKEY 0x87D00283 8 | #define CCM_E_MISSING_SUBJECT_NAME 0x87D00284 9 | #define CCM_E_UNKNOWN_SEARCH_CRITERIA 0x87D00285 10 | #define CCM_E_INVALID_SMS_AUTHORITY 0x87D00286 11 | #define CCM_E_MISSING_SITE_SIGNING_CERT 0x87D00287 12 | #define CCM_E_CI_DECOMPRESSION_FAILURE 0x87D00288 13 | #define CCM_E_CI_DEFN_DECOMPRESSION_FAILURE 0x87D00289 14 | #define CCM_E_JOB_EMPTY 0x87D00290 15 | #define CCM_E_TASKSEQUENCE_NOT_ASSIGNED 0x87D00291 16 | #define CCM_E_COMPUTE_SIGNATURE 0x87D00292 17 | #define CCM_E_REFRESH_SSSC 0x87D00293 18 | #define CCM_E_VERIFY_POLICY 0x87D00294 19 | #define CCM_E_INVALID_OR_NO_REGISTRATION_CERT 0x87D00295 20 | #define CCM_E_CI_PROCESSING_FAILED 0x87D00296 21 | #define CCM_E_INVALID_KEY 0x87D00297 22 | #define CCM_E_INVALID_REGISTRATION 0x87D00298 23 | #define CCM_E_INVALID_SIGNATURE_TYPE 0x87D00299 24 | #define CCM_E_INVALID_AUTH_HEADER 0x87D0029A 25 | #define CCM_E_AUTHENTICATOR_EXPIRED 0x87D0029B 26 | #define CCM_E_RESET_REGISTRATION 0x87D0029C 27 | #define CCM_E_SITE_INCOMPATIBLE 0x87D0029D 28 | #define CCM_E_HASH_MISMATCH 0x87D0029E 29 | #define CCM_E_CERTENROLL_SCEP_CERTREQUEST_PENDI 0x87D00900 30 | #define CCM_E_CERTENROLL_SCEP_CERTREQUEST_UNEXP 0x87D00901 31 | #define CCM_E_CERTENROLL_SCEP_CERTREQUEST_FAILU 0x87D00902 32 | #define CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADAL 0x87D00903 33 | #define CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADME 0x87D00904 34 | #define CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADTR 0x87D00905 35 | #define CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADSI 0x87D00906 36 | #define CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADCE 0x87D00907 37 | #define CCM_E_CERTENROLL_SCEP_SERVERCERT_EMPTY 0x87D00908 38 | #define CCM_E_CERTENROLL_SCEP_SERVERCAP_EMPTY 0x87D00909 39 | #define CCM_E_CERTENROLL_SCEP_PKIOPRESPONSE_EMP 0x87D00910 40 | #define CCM_E_CERTENROLL_SCEP_TPM_UNAVAILABLE 0x87D00911 41 | 42 | static ErrorCodeItem ec_ccm_items[] = { 43 | REGCODE(CCM_E_ITEMNOTFOUND) 44 | REGCODE(CCM_E_EMPTY_CERT_STORE) 45 | REGCODE(CCM_E_NO_CERT_MATCHING_CRITERIA) 46 | REGCODE(CCM_E_TOO_MANY_CERTS) 47 | REGCODE(CCM_E_MISSING_PRIVATEKEY) 48 | REGCODE(CCM_E_MISSING_SUBJECT_NAME) 49 | REGCODE(CCM_E_UNKNOWN_SEARCH_CRITERIA) 50 | REGCODE(CCM_E_INVALID_SMS_AUTHORITY) 51 | REGCODE(CCM_E_MISSING_SITE_SIGNING_CERT) 52 | REGCODE(CCM_E_CI_DECOMPRESSION_FAILURE) 53 | REGCODE(CCM_E_CI_DEFN_DECOMPRESSION_FAILURE) 54 | REGCODE(CCM_E_JOB_EMPTY) 55 | REGCODE(CCM_E_TASKSEQUENCE_NOT_ASSIGNED) 56 | REGCODE(CCM_E_COMPUTE_SIGNATURE) 57 | REGCODE(CCM_E_REFRESH_SSSC) 58 | REGCODE(CCM_E_VERIFY_POLICY) 59 | REGCODE(CCM_E_INVALID_OR_NO_REGISTRATION_CERT) 60 | REGCODE(CCM_E_CI_PROCESSING_FAILED) 61 | REGCODE(CCM_E_INVALID_KEY) 62 | REGCODE(CCM_E_INVALID_REGISTRATION) 63 | REGCODE(CCM_E_INVALID_SIGNATURE_TYPE) 64 | REGCODE(CCM_E_INVALID_AUTH_HEADER) 65 | REGCODE(CCM_E_AUTHENTICATOR_EXPIRED) 66 | REGCODE(CCM_E_RESET_REGISTRATION) 67 | REGCODE(CCM_E_SITE_INCOMPATIBLE) 68 | REGCODE(CCM_E_HASH_MISMATCH) 69 | REGCODE(CCM_E_CERTENROLL_SCEP_CERTREQUEST_PENDI) 70 | REGCODE(CCM_E_CERTENROLL_SCEP_CERTREQUEST_UNEXP) 71 | REGCODE(CCM_E_CERTENROLL_SCEP_CERTREQUEST_FAILU) 72 | REGCODE(CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADAL) 73 | REGCODE(CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADME) 74 | REGCODE(CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADTR) 75 | REGCODE(CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADSI) 76 | REGCODE(CCM_E_CERTENROLL_SCEP_CERTREQUEST_BADCE) 77 | REGCODE(CCM_E_CERTENROLL_SCEP_SERVERCERT_EMPTY) 78 | REGCODE(CCM_E_CERTENROLL_SCEP_SERVERCAP_EMPTY) 79 | REGCODE(CCM_E_CERTENROLL_SCEP_PKIOPRESPONSE_EMP) 80 | REGCODE(CCM_E_CERTENROLL_SCEP_TPM_UNAVAILABLE) 81 | }; 82 | 83 | static LPTSTR ccm_code2msg(DWORD dwCode) 84 | { 85 | LPTSTR result = NULL; 86 | 87 | if (hModCertUtil) 88 | { 89 | UINT uID = dwCode - 0x87D00000 + 0xE000; 90 | 91 | if (0 != uID) 92 | { 93 | result = (LPTSTR)LocalAlloc(LPTR, MAX_MSG_LEN * sizeof (TCHAR)); 94 | if (result) 95 | { 96 | LoadString(hModCertUtil, uID, result, MAX_MSG_LEN); 97 | } 98 | } 99 | } 100 | 101 | return result; 102 | } 103 | 104 | static void ccm_freemsg(LPTSTR lpMessage) 105 | { 106 | LocalFree(lpMessage); 107 | } 108 | 109 | void EcRegCcm(ErrorCodeSet *pecs) 110 | { 111 | pecs->lpName = TEXT("CCM"); 112 | pecs->pfnMessageFromCode = ccm_code2msg; 113 | pecs->pfnFreeMessage = ccm_freemsg; 114 | pecs->items = ec_ccm_items; 115 | pecs->dwCodeCount = ARRAYSIZE(ec_ccm_items); 116 | } 117 | 118 | void EcUnregCcm() 119 | { 120 | /* Ignore */ 121 | } 122 | 123 | -------------------------------------------------------------------------------- /mod/ec_d3d.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | #include 3 | 4 | #include 5 | 6 | /* http://tdxlibrary.org/TDx_Library/TDx_3DI_Library/Glossary/Glossary_*.htm */ 7 | 8 | #define D3DERR_BADMAJORVERSION MAKE_DDHRESULT(700) 9 | #define D3DERR_BADMINORVERSION MAKE_DDHRESULT(701) 10 | #define D3DERR_INVALID_DEVICE MAKE_DDHRESULT(705) 11 | #define D3DERR_INITFAILED MAKE_DDHRESULT(706) 12 | #define D3DERR_DEVICEAGGREGATED MAKE_DDHRESULT(707) 13 | #define D3DERR_EXECUTE_CREATE_FAILED MAKE_DDHRESULT(710) 14 | #define D3DERR_EXECUTE_DESTROY_FAILED MAKE_DDHRESULT(711) 15 | #define D3DERR_EXECUTE_LOCK_FAILED MAKE_DDHRESULT(712) 16 | #define D3DERR_EXECUTE_UNLOCK_FAILED MAKE_DDHRESULT(713) 17 | #define D3DERR_EXECUTE_LOCKED MAKE_DDHRESULT(714) 18 | #define D3DERR_EXECUTE_NOT_LOCKED MAKE_DDHRESULT(715) 19 | #define D3DERR_EXECUTE_FAILED MAKE_DDHRESULT(716) 20 | #define D3DERR_EXECUTE_CLIPPED_FAILED MAKE_DDHRESULT(717) 21 | #define D3DERR_TEXTURE_NO_SUPPORT MAKE_DDHRESULT(720) 22 | #define D3DERR_TEXTURE_CREATE_FAILED MAKE_DDHRESULT(721) 23 | #define D3DERR_TEXTURE_DESTROY_FAILED MAKE_DDHRESULT(722) 24 | #define D3DERR_TEXTURE_LOCK_FAILED MAKE_DDHRESULT(723) 25 | #define D3DERR_TEXTURE_UNLOCK_FAILED MAKE_DDHRESULT(724) 26 | #define D3DERR_TEXTURE_LOAD_FAILED MAKE_DDHRESULT(725) 27 | #define D3DERR_TEXTURE_SWAP_FAILED MAKE_DDHRESULT(726) 28 | #define D3DERR_TEXTURE_LOCKED MAKE_DDHRESULT(727) 29 | #define D3DERR_TEXTURE_NOT_LOCKED MAKE_DDHRESULT(728) 30 | #define D3DERR_TEXTURE_GETSURF_FAILED MAKE_DDHRESULT(729) 31 | #define D3DERR_MATRIX_CREATE_FAILED MAKE_DDHRESULT(730) 32 | #define D3DERR_MATRIX_DESTROY_FAILED MAKE_DDHRESULT(731) 33 | #define D3DERR_MATRIX_SETDATA_FAILED MAKE_DDHRESULT(732) 34 | #define D3DERR_MATRIX_GETDATA_FAILED MAKE_DDHRESULT(733) 35 | #define D3DERR_SETVIEWPORTDATA_FAILED MAKE_DDHRESULT(734) 36 | #define D3DERR_INVALIDCURRENTVIEWPORT MAKE_DDHRESULT(735) 37 | #define D3DERR_INVALIDPRIMITIVETYPE MAKE_DDHRESULT(736) 38 | #define D3DERR_INVALIDVERTEXTYPE MAKE_DDHRESULT(737) 39 | #define D3DERR_TEXTURE_BADSIZE MAKE_DDHRESULT(738) 40 | #define D3DERR_INVALIDRAMPTEXTURE MAKE_DDHRESULT(739) 41 | #define D3DERR_MATERIAL_CREATE_FAILED MAKE_DDHRESULT(740) 42 | #define D3DERR_MATERIAL_DESTROY_FAILED MAKE_DDHRESULT(741) 43 | #define D3DERR_MATERIAL_SETDATA_FAILED MAKE_DDHRESULT(742) 44 | #define D3DERR_MATERIAL_GETDATA_FAILED MAKE_DDHRESULT(743) 45 | #define D3DERR_INVALIDPALETTE MAKE_DDHRESULT(744) 46 | #define D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY MAKE_DDHRESULT(745) 47 | #define D3DERR_ZBUFF_NEEDS_VIDEOMEMORY MAKE_DDHRESULT(746) 48 | #define D3DERR_SURFACENOTINVIDMEM MAKE_DDHRESULT(747) 49 | #define D3DERR_LIGHT_SET_FAILED MAKE_DDHRESULT(750) 50 | #define D3DERR_LIGHTHASVIEWPORT MAKE_DDHRESULT(751) 51 | #define D3DERR_LIGHTNOTINTHISVIEWPORT MAKE_DDHRESULT(752) 52 | #define D3DERR_SCENE_IN_SCENE MAKE_DDHRESULT(760) 53 | #define D3DERR_SCENE_NOT_IN_SCENE MAKE_DDHRESULT(761) 54 | #define D3DERR_SCENE_BEGIN_FAILED MAKE_DDHRESULT(762) 55 | #define D3DERR_SCENE_END_FAILED MAKE_DDHRESULT(763) 56 | #define D3DERR_INBEGIN MAKE_DDHRESULT(770) 57 | #define D3DERR_NOTINBEGIN MAKE_DDHRESULT(771) 58 | #define D3DERR_NOVIEWPORTS MAKE_DDHRESULT(772) 59 | #define D3DERR_VIEWPORTDATANOTSET MAKE_DDHRESULT(773) 60 | #define D3DERR_VIEWPORTHASNODEVICE MAKE_DDHRESULT(774) 61 | #define D3DERR_NOCURRENTVIEWPORT MAKE_DDHRESULT(775) 62 | #define D3DERR_INVALIDVERTEXFORMAT MAKE_DDHRESULT(2048) 63 | #define D3DERR_COLORKEYATTACHED MAKE_DDHRESULT(2050) 64 | #define D3DERR_VERTEXBUFFEROPTIMIZED MAKE_DDHRESULT(2060) 65 | #define D3DERR_VBUF_CREATE_FAILED MAKE_DDHRESULT(2061) 66 | #define D3DERR_VERTEXBUFFERLOCKED MAKE_DDHRESULT(2062) 67 | #define D3DERR_VERTEXBUFFERUNLOCKFAILED MAKE_DDHRESULT(2063) 68 | #define D3DERR_ZBUFFER_NOTPRESENT MAKE_DDHRESULT(2070) 69 | #define D3DERR_STENCILBUFFER_NOTPRESENT MAKE_DDHRESULT(2071) 70 | #define D3DERR_TOOMANYPRIMITIVES MAKE_DDHRESULT(2083) 71 | #define D3DERR_INVALIDMATRIX MAKE_DDHRESULT(2084) 72 | #define D3DERR_TOOMANYVERTICES MAKE_DDHRESULT(2085) 73 | #define D3DERR_INVALIDSTATEBLOCK MAKE_DDHRESULT(2100) 74 | #define D3DERR_INBEGINSTATEBLOCK MAKE_DDHRESULT(2101) 75 | #define D3DERR_NOTINBEGINSTATEBLOCK MAKE_DDHRESULT(2102) 76 | 77 | static ErrorCodeItem ec_d3d_items[] = { 78 | REGCODE(D3D_OK) 79 | REGCODE(D3DERR_BADMAJORVERSION) 80 | REGCODE(D3DERR_BADMINORVERSION) 81 | REGCODE(D3DERR_INVALID_DEVICE) 82 | REGCODE(D3DERR_INITFAILED) 83 | REGCODE(D3DERR_DEVICEAGGREGATED) 84 | REGCODE(D3DERR_EXECUTE_CREATE_FAILED) 85 | REGCODE(D3DERR_EXECUTE_DESTROY_FAILED) 86 | REGCODE(D3DERR_EXECUTE_LOCK_FAILED) 87 | REGCODE(D3DERR_EXECUTE_UNLOCK_FAILED) 88 | REGCODE(D3DERR_EXECUTE_LOCKED) 89 | REGCODE(D3DERR_EXECUTE_NOT_LOCKED) 90 | REGCODE(D3DERR_EXECUTE_FAILED) 91 | REGCODE(D3DERR_EXECUTE_CLIPPED_FAILED) 92 | REGCODE(D3DERR_TEXTURE_NO_SUPPORT) 93 | REGCODE(D3DERR_TEXTURE_CREATE_FAILED) 94 | REGCODE(D3DERR_TEXTURE_DESTROY_FAILED) 95 | REGCODE(D3DERR_TEXTURE_LOCK_FAILED) 96 | REGCODE(D3DERR_TEXTURE_UNLOCK_FAILED) 97 | REGCODE(D3DERR_TEXTURE_LOAD_FAILED) 98 | REGCODE(D3DERR_TEXTURE_SWAP_FAILED) 99 | REGCODE(D3DERR_TEXTURE_LOCKED) 100 | REGCODE(D3DERR_TEXTURE_NOT_LOCKED) 101 | REGCODE(D3DERR_TEXTURE_GETSURF_FAILED) 102 | REGCODE(D3DERR_MATRIX_CREATE_FAILED) 103 | REGCODE(D3DERR_MATRIX_DESTROY_FAILED) 104 | REGCODE(D3DERR_MATRIX_SETDATA_FAILED) 105 | REGCODE(D3DERR_MATRIX_GETDATA_FAILED) 106 | REGCODE(D3DERR_SETVIEWPORTDATA_FAILED) 107 | REGCODE(D3DERR_INVALIDCURRENTVIEWPORT) 108 | REGCODE(D3DERR_INVALIDPRIMITIVETYPE) 109 | REGCODE(D3DERR_INVALIDVERTEXTYPE) 110 | REGCODE(D3DERR_TEXTURE_BADSIZE) 111 | REGCODE(D3DERR_INVALIDRAMPTEXTURE) 112 | REGCODE(D3DERR_MATERIAL_CREATE_FAILED) 113 | REGCODE(D3DERR_MATERIAL_DESTROY_FAILED) 114 | REGCODE(D3DERR_MATERIAL_SETDATA_FAILED) 115 | REGCODE(D3DERR_MATERIAL_GETDATA_FAILED) 116 | REGCODE(D3DERR_INVALIDPALETTE) 117 | REGCODE(D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY) 118 | REGCODE(D3DERR_ZBUFF_NEEDS_VIDEOMEMORY) 119 | REGCODE(D3DERR_SURFACENOTINVIDMEM) 120 | REGCODE(D3DERR_LIGHT_SET_FAILED) 121 | REGCODE(D3DERR_LIGHTHASVIEWPORT) 122 | REGCODE(D3DERR_LIGHTNOTINTHISVIEWPORT) 123 | REGCODE(D3DERR_SCENE_IN_SCENE) 124 | REGCODE(D3DERR_SCENE_NOT_IN_SCENE) 125 | REGCODE(D3DERR_SCENE_BEGIN_FAILED) 126 | REGCODE(D3DERR_SCENE_END_FAILED) 127 | REGCODE(D3DERR_INBEGIN) 128 | REGCODE(D3DERR_NOTINBEGIN) 129 | REGCODE(D3DERR_NOVIEWPORTS) 130 | REGCODE(D3DERR_VIEWPORTDATANOTSET) 131 | REGCODE(D3DERR_VIEWPORTHASNODEVICE) 132 | REGCODE(D3DERR_NOCURRENTVIEWPORT) 133 | REGCODE(D3DERR_INVALIDVERTEXFORMAT) 134 | REGCODE(D3DERR_COLORKEYATTACHED) 135 | REGCODE(D3DERR_VERTEXBUFFEROPTIMIZED) 136 | REGCODE(D3DERR_VBUF_CREATE_FAILED) 137 | REGCODE(D3DERR_VERTEXBUFFERLOCKED) 138 | REGCODE(D3DERR_VERTEXBUFFERUNLOCKFAILED) 139 | REGCODE(D3DERR_ZBUFFER_NOTPRESENT) 140 | REGCODE(D3DERR_STENCILBUFFER_NOTPRESENT) 141 | REGCODE(D3DERR_WRONGTEXTUREFORMAT) 142 | REGCODE(D3DERR_UNSUPPORTEDCOLOROPERATION) 143 | REGCODE(D3DERR_UNSUPPORTEDCOLORARG) 144 | REGCODE(D3DERR_UNSUPPORTEDALPHAOPERATION) 145 | REGCODE(D3DERR_UNSUPPORTEDALPHAARG) 146 | REGCODE(D3DERR_TOOMANYOPERATIONS) 147 | REGCODE(D3DERR_CONFLICTINGTEXTUREFILTER) 148 | REGCODE(D3DERR_UNSUPPORTEDFACTORVALUE) 149 | REGCODE(D3DERR_CONFLICTINGRENDERSTATE) 150 | REGCODE(D3DERR_UNSUPPORTEDTEXTUREFILTER) 151 | REGCODE(D3DERR_TOOMANYPRIMITIVES) 152 | REGCODE(D3DERR_INVALIDMATRIX) 153 | REGCODE(D3DERR_TOOMANYVERTICES) 154 | REGCODE(D3DERR_CONFLICTINGTEXTUREPALETTE) 155 | REGCODE(D3DERR_DRIVERINTERNALERROR) 156 | REGCODE(D3DERR_INVALIDSTATEBLOCK) 157 | REGCODE(D3DERR_INBEGINSTATEBLOCK) 158 | REGCODE(D3DERR_NOTINBEGINSTATEBLOCK) 159 | REGCODE(D3DERR_NOTFOUND) 160 | REGCODE(D3DERR_MOREDATA) 161 | REGCODE(D3DERR_DEVICELOST) 162 | REGCODE(D3DERR_DEVICENOTRESET) 163 | REGCODE(D3DERR_NOTAVAILABLE) 164 | REGCODE(D3DERR_OUTOFVIDEOMEMORY) 165 | REGCODE(D3DERR_INVALIDDEVICE) 166 | REGCODE(D3DERR_INVALIDCALL) 167 | REGCODE(D3DERR_DRIVERINVALIDCALL) 168 | REGCODE(D3DERR_WASSTILLDRAWING) 169 | REGCODE(D3DOK_NOAUTOGEN) 170 | REGCODE(D3DERR_DEVICEREMOVED) 171 | REGCODE(S_NOT_RESIDENT) 172 | REGCODE(S_RESIDENT_IN_SHARED_MEMORY) 173 | REGCODE(S_PRESENT_MODE_CHANGED) 174 | REGCODE(S_PRESENT_OCCLUDED) 175 | REGCODE(D3DERR_DEVICEHUNG) 176 | REGCODE(D3DERR_UNSUPPORTEDOVERLAY) 177 | REGCODE(D3DERR_UNSUPPORTEDOVERLAYFORMAT) 178 | REGCODE(D3DERR_CANNOTPROTECTCONTENT) 179 | REGCODE(D3DERR_UNSUPPORTEDCRYPTO) 180 | REGCODE(D3DERR_PRESENT_STATISTICS_DISJOINT) 181 | }; 182 | 183 | static LPTSTR d3d_code2msg(DWORD dwCode) 184 | { 185 | switch (dwCode) 186 | { 187 | case D3D_OK: 188 | return TEXT("No error occurred."); 189 | 190 | case D3DERR_BADMAJORVERSION: 191 | return TEXT("The service that you requested is unavailable in this major version of DirectX."); 192 | 193 | case D3DERR_BADMINORVERSION: 194 | return TEXT("The service that you requested is available in this major version of DirectX, but not in this minor version."); 195 | 196 | case D3DERR_INVALID_DEVICE: 197 | return TEXT("The requested device type is not valid."); 198 | 199 | case D3DERR_INITFAILED: 200 | return TEXT("A rendering device could not be created because the new device could not be initialized."); 201 | 202 | case D3DERR_DEVICEAGGREGATED: 203 | return TEXT("The ID3DDevice::SetRenderTarget() method was called on a device that was retrieved from the render target surface."); 204 | 205 | case D3DERR_EXECUTE_CREATE_FAILED: 206 | return TEXT("The execute buffer could not be created. This typically occurs when no memory is available to allocate the execute buffer."); 207 | 208 | case D3DERR_EXECUTE_DESTROY_FAILED: 209 | return TEXT("The memory for the execute buffer could not be deallocated."); 210 | 211 | case D3DERR_EXECUTE_LOCK_FAILED: 212 | return TEXT("The execute buffer could not be locked."); 213 | 214 | case D3DERR_EXECUTE_UNLOCK_FAILED: 215 | return TEXT("The execute buffer could not be unlocked."); 216 | 217 | case D3DERR_EXECUTE_LOCKED: 218 | return TEXT("The operation requested by the application could not be completed because the execute buffer is locked."); 219 | 220 | case D3DERR_EXECUTE_NOT_LOCKED: 221 | return TEXT("The execute buffer could not be unlocked because it is not currently locked."); 222 | 223 | case D3DERR_EXECUTE_FAILED: 224 | return TEXT("The contents of the execute buffer are invalid and cannot be executed."); 225 | 226 | case D3DERR_EXECUTE_CLIPPED_FAILED: 227 | return TEXT("The execute buffer could not be clipped during execution."); 228 | 229 | case D3DERR_TEXTURE_NO_SUPPORT: 230 | return TEXT("The device does not support texture mapping."); 231 | 232 | case D3DERR_TEXTURE_CREATE_FAILED: 233 | return TEXT("The texture handle for the texture could not be retrieved from the driver."); 234 | 235 | case D3DERR_TEXTURE_DESTROY_FAILED: 236 | return TEXT("The device was unable to deallocate the texture memory."); 237 | 238 | case D3DERR_TEXTURE_LOCK_FAILED: 239 | return TEXT("The texture could not be locked."); 240 | 241 | case D3DERR_TEXTURE_UNLOCK_FAILED: 242 | return TEXT("The texture surface could not be unlocked."); 243 | 244 | case D3DERR_TEXTURE_LOAD_FAILED: 245 | return TEXT("The texture could not be loaded."); 246 | 247 | case D3DERR_TEXTURE_SWAP_FAILED: 248 | return TEXT("The texture handles could not be swapped."); 249 | 250 | case D3DERR_TEXTURE_LOCKED: 251 | return TEXT("The requested operation could not be completed because the texture surface is currently locked."); 252 | 253 | case D3DERR_TEXTURE_NOT_LOCKED: 254 | return TEXT("The requested operation could not be completed because the texture surface is not locked."); 255 | 256 | case D3DERR_TEXTURE_GETSURF_FAILED: 257 | return TEXT("The DirectDraw surface used to create the texture could not be retrieved."); 258 | 259 | case D3DERR_MATRIX_CREATE_FAILED: 260 | return TEXT("The matrix could not be created. This can occur when no memory is available to allocate for the matrix."); 261 | 262 | case D3DERR_MATRIX_DESTROY_FAILED: 263 | return TEXT("The memory for the matrix could not be deallocated."); 264 | 265 | case D3DERR_MATRIX_SETDATA_FAILED: 266 | return TEXT("The matrix data could not be set. This can occur when the matrix was not created by the current device."); 267 | 268 | case D3DERR_MATRIX_GETDATA_FAILED: 269 | return TEXT("The matrix data could not be retrieved. This can occur when the matrix was not created by the current device."); 270 | 271 | case D3DERR_SETVIEWPORTDATA_FAILED: 272 | return TEXT("The viewport parameters could not be set."); 273 | 274 | case D3DERR_INVALIDCURRENTVIEWPORT: 275 | return TEXT("The currently selected viewport is not valid."); 276 | 277 | case D3DERR_INVALIDPRIMITIVETYPE: 278 | return TEXT("The primitive type specified by the application is invalid."); 279 | 280 | case D3DERR_INVALIDVERTEXTYPE: 281 | return TEXT("The vertex type specified by the application is invalid."); 282 | 283 | case D3DERR_TEXTURE_BADSIZE: 284 | return TEXT("The dimensions of a current texture are invalid. This can occur when an application attempts to use a texture that has dimensions that are not a power of 2 with a device that requires them."); 285 | 286 | case D3DERR_INVALIDRAMPTEXTURE: 287 | return TEXT("Ramp mode is being used, and the texture handle in the current material does not match the current texture handle that is set as a render state."); 288 | 289 | case D3DERR_MATERIAL_CREATE_FAILED: 290 | return TEXT("The material could not be created. This typically occurs when no memory is available to allocate for the material."); 291 | 292 | case D3DERR_MATERIAL_DESTROY_FAILED: 293 | return TEXT("The memory for the material could not be deallocated."); 294 | 295 | case D3DERR_MATERIAL_SETDATA_FAILED: 296 | return TEXT("The material parameters could not be set."); 297 | 298 | case D3DERR_MATERIAL_GETDATA_FAILED: 299 | return TEXT("The material parameters could not be retrieved."); 300 | 301 | case D3DERR_INVALIDPALETTE: 302 | return TEXT("The palette associated with a surface is invalid."); 303 | 304 | case D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY: 305 | return TEXT("The requested operation could not be completed because the specified device requires system-memory depth-buffer surfaces."); 306 | 307 | case D3DERR_ZBUFF_NEEDS_VIDEOMEMORY: 308 | return TEXT("The requested operation could not be completed because the specified device requires video-memory depth-buffer surfaces."); 309 | 310 | case D3DERR_SURFACENOTINVIDMEM: 311 | return TEXT("The device could not be created because the render target surface is not located in video memory."); 312 | 313 | case D3DERR_LIGHT_SET_FAILED: 314 | return TEXT("The attempt to set lighting parameters for a light object failed."); 315 | 316 | case D3DERR_LIGHTHASVIEWPORT: 317 | return TEXT("The requested operation failed because the light object is associated with another viewport."); 318 | 319 | case D3DERR_LIGHTNOTINTHISVIEWPORT: 320 | return TEXT("The requested operation failed because the light object has not been associated with this viewport."); 321 | 322 | case D3DERR_SCENE_IN_SCENE: 323 | return TEXT("Scene rendering could not begin because a previous scene was not completed by a call to the ID3DDevice::EndScene() method."); 324 | 325 | case D3DERR_SCENE_NOT_IN_SCENE: 326 | return TEXT("Scene rendering could not be completed because a scene was not started by a previous call to the ID3DDevice::BeginScene() method."); 327 | 328 | case D3DERR_SCENE_BEGIN_FAILED: 329 | return TEXT("Scene rendering could not begin."); 330 | 331 | case D3DERR_SCENE_END_FAILED: 332 | return TEXT("Scene rendering could not be completed."); 333 | 334 | case D3DERR_INBEGIN: 335 | return TEXT("The requested operation cannot be completed while scene rendering is taking place."); 336 | 337 | case D3DERR_NOTINBEGIN: 338 | return TEXT("The requested rendering operation could not be completed because scene rendering has not begun."); 339 | 340 | case D3DERR_NOVIEWPORTS: 341 | return TEXT("The requested operation failed because the device currently has no viewports associated with it."); 342 | 343 | case D3DERR_VIEWPORTDATANOTSET: 344 | return TEXT("The requested operation could not be completed because viewport parameters have not yet been set."); 345 | 346 | case D3DERR_VIEWPORTHASNODEVICE: 347 | return TEXT("The requested operation could not be completed because the viewport has not yet been associated with a device."); 348 | 349 | case D3DERR_NOCURRENTVIEWPORT: 350 | return TEXT("The viewport parameters could not be retrieved because none have been set."); 351 | 352 | case D3DERR_INVALIDVERTEXFORMAT: 353 | return TEXT("The combination of flexible vertex format flags specified by the application is not valid."); 354 | 355 | case D3DERR_COLORKEYATTACHED: 356 | return TEXT("The application attempted to create a texture with a surface that uses a color key for transparency."); 357 | 358 | case D3DERR_VERTEXBUFFEROPTIMIZED: 359 | return TEXT("The requested operation could not be completed because the vertex buffer is optimized."); 360 | 361 | case D3DERR_VBUF_CREATE_FAILED: 362 | return TEXT("The vertex buffer could not be created. This can happen when there is insufficient memory to allocate a vertex buffer."); 363 | 364 | case D3DERR_VERTEXBUFFERLOCKED: 365 | return TEXT("The requested operation could not be completed because the vertex buffer is locked."); 366 | 367 | case D3DERR_VERTEXBUFFERUNLOCKFAILED: 368 | return TEXT("The vertex buffer could not be unlocked because the vertex buffer memory was overrun. Be sure that your application does not write beyond the size of the vertex buffer."); 369 | 370 | case D3DERR_ZBUFFER_NOTPRESENT: 371 | return TEXT("The requested operation could not be completed because the render target surface does not have an attached depth buffer."); 372 | 373 | case D3DERR_STENCILBUFFER_NOTPRESENT: 374 | return TEXT("The DirectDraw surface used to create the texture could not be retrieved."); 375 | 376 | case D3DERR_WRONGTEXTUREFORMAT: 377 | return TEXT("The pixel format of the texture surface is not valid."); 378 | 379 | case D3DERR_UNSUPPORTEDCOLOROPERATION: 380 | return TEXT("The device does not support a specified texture-blending operation for color values."); 381 | 382 | case D3DERR_UNSUPPORTEDCOLORARG: 383 | return TEXT("The device does not support a specified texture-blending argument for color values."); 384 | 385 | case D3DERR_UNSUPPORTEDALPHAOPERATION: 386 | return TEXT("The device does not support a specified texture-blending operation for the alpha channel."); 387 | 388 | case D3DERR_UNSUPPORTEDALPHAARG: 389 | return TEXT("The device does not support a specified texture-blending argument for the alpha channel."); 390 | 391 | case D3DERR_TOOMANYOPERATIONS: 392 | return TEXT("The application is requesting more texture-filtering operations than the device supports."); 393 | 394 | case D3DERR_CONFLICTINGTEXTUREFILTER: 395 | return TEXT("The current texture filters cannot be used together."); 396 | 397 | case D3DERR_UNSUPPORTEDFACTORVALUE: 398 | return TEXT("The device does not support the specified texture factor value. Not used; provided only to support older drivers."); 399 | 400 | case D3DERR_CONFLICTINGRENDERSTATE: 401 | return TEXT("The currently set render states cannot be used together."); 402 | 403 | case D3DERR_UNSUPPORTEDTEXTUREFILTER: 404 | return TEXT("The device does not support the specified texture filter."); 405 | 406 | case D3DERR_TOOMANYPRIMITIVES: 407 | return TEXT("The device is unable to render the provided number of primitives in a single pass."); 408 | 409 | case D3DERR_INVALIDMATRIX: 410 | return TEXT("The requested operation could not be completed because the combination of the currently set world, view, and projection matrices is invalid (the determinant of the combined matrix is 0)."); 411 | 412 | case D3DERR_TOOMANYVERTICES: 413 | return TEXT("The device is unable to process the provided number of vertices in a single pass."); 414 | 415 | case D3DERR_CONFLICTINGTEXTUREPALETTE: 416 | return TEXT("The current textures cannot be used simultaneously."); 417 | 418 | case D3DERR_DRIVERINTERNALERROR: 419 | return TEXT("Internal driver error. Applications should destroy and recreate the device when receiving this error."); 420 | 421 | case D3DERR_INVALIDSTATEBLOCK: 422 | return TEXT("The state block handle is invalid."); 423 | 424 | case D3DERR_INBEGINSTATEBLOCK: 425 | return TEXT("The operation cannot be completed while recording states for a state block. Complete recording by calling the ID3DDevice::EndStateBlock() method, and try again."); 426 | 427 | case D3DERR_NOTINBEGINSTATEBLOCK: 428 | return TEXT("The requested operation could not be completed because it is only valid while recording a state block. Call the ID3DDevice::BeginStateBlock() method, and try again."); 429 | 430 | case D3DERR_NOTFOUND: 431 | return TEXT("The requested item was not found."); 432 | 433 | case D3DERR_MOREDATA: 434 | return TEXT("There is more data available than the specified buffer size can hold."); 435 | 436 | case D3DERR_DEVICELOST: 437 | return TEXT("The device has been lost but cannot be reset at this time. Therefore, rendering is not possible. A Direct3D device object other than the one that returned this code caused the hardware adapter to be reset by the OS. Delete all video memory objects (surfaces, textures, state blocks) and call Reset() to return the device to a default state. If the application continues rendering without a reset, the rendering calls will succeed."); 438 | 439 | case D3DERR_DEVICENOTRESET: 440 | return TEXT("The device has been lost but can be reset at this time."); 441 | 442 | case D3DERR_NOTAVAILABLE: 443 | return TEXT("This device does not support the queried technique."); 444 | 445 | case D3DERR_OUTOFVIDEOMEMORY: 446 | return TEXT("Direct3D does not have enough display memory to perform the operation."); 447 | 448 | case D3DERR_INVALIDDEVICE: 449 | return TEXT("The requested device type is not valid."); 450 | 451 | case D3DERR_INVALIDCALL: 452 | return TEXT("The method call is invalid. For example, a method's parameter may not be a valid pointer."); 453 | 454 | case D3DERR_DRIVERINVALIDCALL: 455 | return TEXT("Not used."); 456 | 457 | case D3DERR_WASSTILLDRAWING: 458 | return TEXT("The previous blit operation that is transferring information to or from this surface is incomplete."); 459 | 460 | case D3DOK_NOAUTOGEN: 461 | return TEXT("This is a success code. However, the autogeneration of mipmaps is not supported for this format. This means that resource creation will succeed but the mipmap levels will not be automatically generated."); 462 | 463 | case D3DERR_DEVICEREMOVED: 464 | return TEXT("The hardware adapter has been removed. Application must destroy the device, do enumeration of adapters and create another Direct3D device. If application continues rendering without calling Reset, the rendering calls will succeed. Applies to Direct3D 9Ex only."); 465 | 466 | case S_NOT_RESIDENT: 467 | return TEXT("At least one allocation that comprises the resources is on disk. Direct3D 9Ex only."); 468 | 469 | case S_RESIDENT_IN_SHARED_MEMORY: 470 | return TEXT("No allocations that comprise the resources are on disk. However, at least one allocation is not in GPU-accessible memory. Direct3D 9Ex only."); 471 | 472 | case S_PRESENT_MODE_CHANGED: 473 | return TEXT("The desktop display mode has been changed. The application can continue rendering, but there might be color conversion/stretching. Pick a back buffer format similar to the current display mode, and call Reset to recreate the swap chains. The device will leave this state after a Reset is called. Direct3D 9Ex only."); 474 | 475 | case S_PRESENT_OCCLUDED: 476 | return TEXT("The presentation area is occluded. Direct3D 9Ex only."); 477 | 478 | case D3DERR_DEVICEHUNG: 479 | return TEXT("The device that returned this code caused the hardware adapter to be reset by the OS. Most applications should destroy the device and quit. Applications that must continue should destroy all video memory objects (surfaces, textures, state blocks etc) and call Reset() to put the device in a default state. If the application then continues rendering in the same way, the device will return to this state. Applies to Direct3D 9Ex only."); 480 | 481 | case D3DERR_UNSUPPORTEDOVERLAY: 482 | return TEXT("The device does not support overlay for the specified size or display mode. Direct3D 9Ex under Windows 7 only."); 483 | 484 | case D3DERR_UNSUPPORTEDOVERLAYFORMAT: 485 | return TEXT("The device does not support overlay for the specified surface format. Direct3D 9Ex under Windows 7 only."); 486 | 487 | case D3DERR_CANNOTPROTECTCONTENT: 488 | return TEXT("The specified content cannot be protected. Direct3D 9Ex under Windows 7 only."); 489 | 490 | case D3DERR_UNSUPPORTEDCRYPTO: 491 | return TEXT("The specified cryptographic algorithm is not supported. Direct3D 9Ex under Windows 7 only."); 492 | 493 | case D3DERR_PRESENT_STATISTICS_DISJOINT: 494 | return TEXT("The present statistics have no orderly sequence. Direct3D 9Ex under Windows 7 only."); 495 | 496 | default: 497 | return NULL; 498 | } 499 | } 500 | 501 | static void d3d_freemsg(LPTSTR lpMessage) 502 | { 503 | /* Ignore */ 504 | } 505 | 506 | void EcRegD3d(ErrorCodeSet *pecs) 507 | { 508 | pecs->lpName = TEXT("Direct3D"); 509 | pecs->pfnMessageFromCode = d3d_code2msg; 510 | pecs->pfnFreeMessage = d3d_freemsg; 511 | pecs->items = ec_d3d_items; 512 | pecs->dwCodeCount = ARRAYSIZE(ec_d3d_items); 513 | } 514 | 515 | void EcUnregD3d() 516 | { 517 | /* Ignore */ 518 | } 519 | 520 | -------------------------------------------------------------------------------- /mod/ec_dme.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | 3 | #define CMN_E_NOT_YET_INITIALIZED 0x82AA0000 4 | #define CMN_E_BAD_XML 0x82AA0001 5 | #define CMN_E_ALREADY_EXISTS 0x82AA0002 6 | #define CMN_E_INTEGER_OVERFLOW 0x82AA0003 7 | #define CMN_E_INTEGER_UNDERFLOW 0x82AA0004 8 | #define CMN_E_ROLLBACK_FAILURE 0x82AA0005 9 | #define CMN_E_CSP_OUTPROC_FAILURE 0x82AA0006 10 | #define CMN_E_MARSHAL_LIMIT_EXCEEDED 0x82AA0007 11 | #define DM_E_SESSION_ABORT 0x82AB0000 12 | #define DM_E_SERVER_AUTH_FAILURE 0x82AB0002 13 | #define DM_E_UI_ALERT_REJECT 0x82AB0004 14 | #define DM_E_UNEXPECTED_NODE_TYPE 0x82AB0005 15 | #define DM_E_UI_ALERT_CANCEL 0x82AB0006 16 | #define DM_E_CMD_BYPASSED 0x82AB0007 17 | #define DM_E_UI_ALERT_TIMEOUT 0x82AB0008 18 | #define DM_E_UI_ALERT_TEXT_TOO_LARGE 0x82AB0009 19 | #define DM_E_PUSH_MSG_PARSE_ERROR 0x82AB000B 20 | #define DM_E_PUSH_MSG_INITIATION_NOTFOUND 0x82AB000C 21 | #define DM_E_KEEPALIVE_MSG_BEING_PROCESSED 0x82AB000D 22 | #define DM_E_RESULTS_SPAN_MULTIPLE_MESSAGES 0x82AB000E 23 | #define DM_NGC_KEY_NOT_FOUND 0x82AB000F 24 | #define DM_NGC_AAD_KEY_IDENTIFIER_MISMATCH 0x82AB0010 25 | #define DM_NGC_MANAGED_BY_GP 0x82AB0011 26 | #define OMADM_E_SYNCHDR_ERROR 0x82AC0000 27 | #define OMADM_E_SESSION_ABORT_407_RECEIVED 0x82AC0001 28 | #define OMADM_E_SESSION_ABORT_BY_USER 0x82AC0002 29 | #define OMADM_E_SESSION_ABORT_ROAMING 0x82AC0004 30 | #define OMADM_E_SESSION_ABORT_INCORRECT_HMAC 0x82AC0005 31 | #define OMADM_E_SESSION_ABORT_BY_DELETE 0x82AC0006 32 | #define OMADM_E_SESSION_ABORT_NO_MORE_RETRY 0x82AC0007 33 | #define OMADM_E_SESSION_ABORT_NO_DATA_RECEIVED 0x82AC0008 34 | #define OMADM_E_SESSION_NOT_ALLOWED 0x82AC0009 35 | #define OMADM_E_SSLCERTCRITERIA_INVALID 0x82AC000A 36 | #define OMADM_E_SESSION_ABORT_401_RECEIVED 0x82AC0191 37 | #define OMADM_E_SESSION_ABORT_403_RECEIVED 0x82AC0193 38 | #define OMADM_E_SESSION_ABORT_404_RECEIVED 0x82AC0194 39 | #define OMADM_E_SESSION_ABORT_413_RECEIVED 0x82AC019D 40 | #define OMADM_E_SESSION_ABORT_UNEXPECTED_HTTP_S 0x82AC019E 41 | #define OMADM_E_SESSION_RETRIED_HTTP_STATUS 0x82AC0200 42 | #define OMADM_E_SESSION_ABORT_UNEXPECTED_CONTEN 0x82AC0201 43 | #define ZIPCONTAINER_E_INVALIDOBJECT 0x82AD0000 44 | #define ZIPCONTAINER_E_STREAMNOTAVAILABLE 0x82AD0001 45 | #define ZIPCONTAINER_E_ZIPDATAERROR 0x82AD0002 46 | #define ZIPCONTAINER_E_CORRUPTED 0x82AD0003 47 | #define ZIPCONTAINER_E_INVALIDFILENAME 0x82AD0004 48 | #define ZIPCONTAINER_E_NOTFOUND 0x82AD0005 49 | #define ZIPCONTAINER_E_NOTINITIALIZED 0x82AD0006 50 | #define ZIPCONTAINER_E_READONLY 0x82AD0007 51 | #define ZIPCONTAINER_E_INVALIDARCHIVE 0x82AD0008 52 | #define ZIPCONTAINER_E_UNSUPPORTEDCOMPRESSIONME 0x82AD0009 53 | #define ZIPCONTAINER_E_INVALIDSTREAM 0x82AD000B 54 | #define ZIPCONTAINER_E_FORMATNOTSUPPORTED 0x82AD000C 55 | #define ZIPCONTAINER_E_INVALIDITEM 0x82AD000D 56 | #define ZIPCONTAINER_E_CANNOT_LOAD_ZLIB_DLL 0x82AD000F 57 | #define ZIPCONTAINER_E_MISSING_ZLIB_DLL_EXPORT 0x82AD0010 58 | #define ENROLLMENT_E_ALREADY_ENROLLED 0x82AE0004 59 | 60 | static ErrorCodeItem ec_dme_items[] = { 61 | REGCODE(CMN_E_NOT_YET_INITIALIZED) 62 | REGCODE(CMN_E_BAD_XML) 63 | REGCODE(CMN_E_ALREADY_EXISTS) 64 | REGCODE(CMN_E_INTEGER_OVERFLOW) 65 | REGCODE(CMN_E_INTEGER_UNDERFLOW) 66 | REGCODE(CMN_E_ROLLBACK_FAILURE) 67 | REGCODE(CMN_E_CSP_OUTPROC_FAILURE) 68 | REGCODE(CMN_E_MARSHAL_LIMIT_EXCEEDED) 69 | REGCODE(DM_E_SESSION_ABORT) 70 | REGCODE(DM_E_SERVER_AUTH_FAILURE) 71 | REGCODE(DM_E_UI_ALERT_REJECT) 72 | REGCODE(DM_E_UNEXPECTED_NODE_TYPE) 73 | REGCODE(DM_E_UI_ALERT_CANCEL) 74 | REGCODE(DM_E_CMD_BYPASSED) 75 | REGCODE(DM_E_UI_ALERT_TIMEOUT) 76 | REGCODE(DM_E_UI_ALERT_TEXT_TOO_LARGE) 77 | REGCODE(DM_E_PUSH_MSG_PARSE_ERROR) 78 | REGCODE(DM_E_PUSH_MSG_INITIATION_NOTFOUND) 79 | REGCODE(DM_E_KEEPALIVE_MSG_BEING_PROCESSED) 80 | REGCODE(DM_E_RESULTS_SPAN_MULTIPLE_MESSAGES) 81 | REGCODE(DM_NGC_KEY_NOT_FOUND) 82 | REGCODE(DM_NGC_AAD_KEY_IDENTIFIER_MISMATCH) 83 | REGCODE(DM_NGC_MANAGED_BY_GP) 84 | REGCODE(OMADM_E_SYNCHDR_ERROR) 85 | REGCODE(OMADM_E_SESSION_ABORT_407_RECEIVED) 86 | REGCODE(OMADM_E_SESSION_ABORT_BY_USER) 87 | REGCODE(OMADM_E_SESSION_ABORT_ROAMING) 88 | REGCODE(OMADM_E_SESSION_ABORT_INCORRECT_HMAC) 89 | REGCODE(OMADM_E_SESSION_ABORT_BY_DELETE) 90 | REGCODE(OMADM_E_SESSION_ABORT_NO_MORE_RETRY) 91 | REGCODE(OMADM_E_SESSION_ABORT_NO_DATA_RECEIVED) 92 | REGCODE(OMADM_E_SESSION_NOT_ALLOWED) 93 | REGCODE(OMADM_E_SSLCERTCRITERIA_INVALID) 94 | REGCODE(OMADM_E_SESSION_ABORT_401_RECEIVED) 95 | REGCODE(OMADM_E_SESSION_ABORT_403_RECEIVED) 96 | REGCODE(OMADM_E_SESSION_ABORT_404_RECEIVED) 97 | REGCODE(OMADM_E_SESSION_ABORT_413_RECEIVED) 98 | REGCODE(OMADM_E_SESSION_ABORT_UNEXPECTED_HTTP_S) 99 | REGCODE(OMADM_E_SESSION_RETRIED_HTTP_STATUS) 100 | REGCODE(OMADM_E_SESSION_ABORT_UNEXPECTED_CONTEN) 101 | REGCODE(ZIPCONTAINER_E_INVALIDOBJECT) 102 | REGCODE(ZIPCONTAINER_E_STREAMNOTAVAILABLE) 103 | REGCODE(ZIPCONTAINER_E_ZIPDATAERROR) 104 | REGCODE(ZIPCONTAINER_E_CORRUPTED) 105 | REGCODE(ZIPCONTAINER_E_INVALIDFILENAME) 106 | REGCODE(ZIPCONTAINER_E_NOTFOUND) 107 | REGCODE(ZIPCONTAINER_E_NOTINITIALIZED) 108 | REGCODE(ZIPCONTAINER_E_READONLY) 109 | REGCODE(ZIPCONTAINER_E_INVALIDARCHIVE) 110 | REGCODE(ZIPCONTAINER_E_UNSUPPORTEDCOMPRESSIONME) 111 | REGCODE(ZIPCONTAINER_E_INVALIDSTREAM) 112 | REGCODE(ZIPCONTAINER_E_FORMATNOTSUPPORTED) 113 | REGCODE(ZIPCONTAINER_E_INVALIDITEM) 114 | REGCODE(ZIPCONTAINER_E_CANNOT_LOAD_ZLIB_DLL) 115 | REGCODE(ZIPCONTAINER_E_MISSING_ZLIB_DLL_EXPORT) 116 | REGCODE(ENROLLMENT_E_ALREADY_ENROLLED) 117 | }; 118 | 119 | static LPTSTR dme_code2msg(DWORD dwCode) 120 | { 121 | LPTSTR result = NULL; 122 | 123 | if (hModCertUtil) 124 | { 125 | UINT uID = dwCode; 126 | 127 | if (uID < 0x82AB0000) 128 | { 129 | uID = (uID & 0xFFFF) + 0xF000; 130 | } 131 | else if (uID < 0x82AC0000) 132 | { 133 | uID = (uID & 0xFFFF) + 0xF100; 134 | } 135 | else if (uID < 0x82AC0100) 136 | { 137 | uID = (uID & 0xFFFF) + 0xF200; 138 | } 139 | else if (uID < 0x82AD0000) 140 | { 141 | uID = (uID & 0xFFFF) + 0xF100; 142 | } 143 | else if (uID < 0x82AE0000) 144 | { 145 | uID = (uID & 0xFFFF) + 0xF300; 146 | } 147 | else 148 | { 149 | uID = (uID & 0xFFFF) + 0xF400; 150 | } 151 | 152 | if (0 != uID) 153 | { 154 | result = (LPTSTR)LocalAlloc(LPTR, MAX_MSG_LEN * sizeof (TCHAR)); 155 | if (result) 156 | { 157 | LoadString(hModCertUtil, uID, result, MAX_MSG_LEN); 158 | } 159 | } 160 | } 161 | 162 | return result; 163 | } 164 | 165 | static void dme_freemsg(LPTSTR lpMessage) 166 | { 167 | LocalFree(lpMessage); 168 | } 169 | 170 | void EcRegDme(ErrorCodeSet *pecs) 171 | { 172 | pecs->lpName = TEXT("DME"); 173 | pecs->pfnMessageFromCode = dme_code2msg; 174 | pecs->pfnFreeMessage = dme_freemsg; 175 | pecs->items = ec_dme_items; 176 | pecs->dwCodeCount = ARRAYSIZE(ec_dme_items); 177 | } 178 | 179 | void EcUnregDme() 180 | { 181 | /* Ignore */ 182 | } 183 | 184 | -------------------------------------------------------------------------------- /mod/ec_dsreg.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | 3 | #define DSREG_E_DEVICE_MESSAGE_FORMAT_ERROR 0x801C0001 4 | #define DSREG_E_DEVICE_AUTHENTICATION_ERROR 0x801C0002 5 | #define DSREG_E_DEVICE_AUTHORIZATION_ERROR 0x801C0003 6 | #define DSREG_E_DEVICE_INTERNALSERVICE_ERROR 0x801C0006 7 | #define DSREG_E_DISCOVERY_REDIRECTION_NOT_TRUST 0x801C000B 8 | #define DSREG_E_DISCOVERY_FAILED 0x801C000C 9 | #define DSREG_E_DEVICE_REGISTRATION_QUOTA_EXCCE 0x801C000E 10 | #define DSREG_E_DEVICE_REQUIRES_REBOOT 0x801C000F 11 | #define DSREG_E_DEVICE_AIK_VALIDATION_ERROR 0x801C0010 12 | #define DSREG_E_DEVICE_ATTESTATION_ERROR 0x801C0011 13 | #define DSREG_E_DISCOVERY_BAD_MESSAGE_ERROR 0x801C0012 14 | #define DSREG_E_TENANTID_NOT_FOUND 0x801C0013 15 | #define DSREG_E_USERSID_NOT_FOUND 0x801C0014 16 | #define DSREG_DEVICE_NOT_DOMAIN_JOINED 0x801C0015 17 | #define DSREG_MISSING_JOIN_INFO 0x801C0016 18 | #define DSREG_JOIN_REQUIRED 0x801C001B 19 | #define DSREG_E_SERVER_WAIT_TIMEOUT 0x801C001C 20 | #define DSREG_AUTOJOIN_ADCONFIG_READ_FAILED 0x801C001D 21 | #define DSREG_AUTOJOIN_CREATE_EVENT_FAILED 0x801C001E 22 | #define DSREG_AUTOJOIN_DISC_WAIT_TIMEOUT 0x801C001F 23 | #define DSREG_AUTOJOIN_DISC_WAIT_FAILED 0x801C0020 24 | #define DSREG_AUTOJOIN_DISC_FAILED 0x801C0021 25 | #define DSREG_MISSING_DEVICE_ID_IN_TOKEN 0x801C0022 26 | #define DSREG_MFA_REQUIRED 0x801C0023 27 | #define DSREG_USER_NOT_FOUND 0x801C0024 28 | #define DSREG_SERVER_BUSY 0x801C0025 29 | #define DSREG_NGC_KEY_ALREADY_EXISTS 0x801C0026 30 | #define DSREG_BAD_DIRECTORY_REQUEST 0x801C0027 31 | #define DSREG_DIRECTORY_REPLICA_UNAVAILABLE 0x801C0028 32 | #define DSREG_DIRECTORY_REQUEST_THROTTLED 0x801C0029 33 | #define DSREG_DIRECTORY_REQUEST_DENIED 0x801C002A 34 | #define DSREG_DEVICE_KEY_NOACCESS 0x801C002B 35 | #define DSREG_DEVICE_KEY_MISSING 0x801C002C 36 | #define DSREG_JSON_REQUEST_FAILED 0x801C002D 37 | #define DSREG_JSON_REQUEST_NODATA 0x801C002E 38 | #define DSREG_E_AADPLUGIN_PRT_NOTFOUND 0x801C0030 39 | #define DSREG_AUTH_TOKEN_NOT_FOUND 0x801C0031 40 | #define DSREG_INVALID_RESPONSE 0x801C03E9 41 | #define DSREG_E_NGC_AUTHORIZATION_ERROR 0x801C03EA 42 | #define DSREG_E_NGC_UNEXPECTED_HTTP_STATUS 0x801C03EB 43 | #define DSREG_E_NGC_INTERNAL_SERVER_ERROR 0x801C03EC 44 | #define DSREG_E_NGC_INVALID_REQUEST 0x801C03ED 45 | #define DSREG_E_NGC_ATTESTATION_ERROR 0x801C03EE 46 | #define DSREG_E_NGC_AIK_CERT_RENEW 0x801C03EF 47 | #define DSREG_E_NGC_KEY_NOT_FOUND 0x801C03F0 48 | #define DSREG_E_UPN_NOT_FOUND 0x801C03F1 49 | #define DSREG_E_DIRECTORY_FAILURE 0x801C03F2 50 | #define DSREG_E_DEVICE_NOT_FOUND 0x801C03F3 51 | #define DSREG_E_CXH_DEVICE_NOT_JOINED 0x801C03F4 52 | #define DSREG_E_CXH_NO_SCENARIO_FOUND 0x801C03F5 53 | #define DSREG_E_NGC_CERT_NO_ENTSSO 0x801C03F6 54 | #define DSREG_E_NGC_INVALID_CONTAINER_OPTIONS 0x801C03F7 55 | #define DSREG_E_NO_CORE_WINDOW 0x801C044C 56 | #define DSREG_E_USER_TOKEN_ERROR 0x801C044D 57 | #define DSREG_E_USER_INPUT_WAIT_FAILED 0x801C044E 58 | #define DSREG_E_USER_TOKEN_REQUEST_CANCELLED 0x801C044F 59 | #define DSREG_E_DEVICE_NOT_JOINED 0x801C0450 60 | 61 | static ErrorCodeItem ec_dsreg_items[] = { 62 | REGCODE(DSREG_E_DEVICE_MESSAGE_FORMAT_ERROR) 63 | REGCODE(DSREG_E_DEVICE_AUTHENTICATION_ERROR) 64 | REGCODE(DSREG_E_DEVICE_AUTHORIZATION_ERROR) 65 | REGCODE(DSREG_E_DEVICE_INTERNALSERVICE_ERROR) 66 | REGCODE(DSREG_E_DISCOVERY_REDIRECTION_NOT_TRUST) 67 | REGCODE(DSREG_E_DISCOVERY_FAILED) 68 | REGCODE(DSREG_E_DEVICE_REGISTRATION_QUOTA_EXCCE) 69 | REGCODE(DSREG_E_DEVICE_REQUIRES_REBOOT) 70 | REGCODE(DSREG_E_DEVICE_AIK_VALIDATION_ERROR) 71 | REGCODE(DSREG_E_DEVICE_ATTESTATION_ERROR) 72 | REGCODE(DSREG_E_DISCOVERY_BAD_MESSAGE_ERROR) 73 | REGCODE(DSREG_E_TENANTID_NOT_FOUND) 74 | REGCODE(DSREG_E_USERSID_NOT_FOUND) 75 | REGCODE(DSREG_DEVICE_NOT_DOMAIN_JOINED) 76 | REGCODE(DSREG_MISSING_JOIN_INFO) 77 | REGCODE(DSREG_JOIN_REQUIRED) 78 | REGCODE(DSREG_E_SERVER_WAIT_TIMEOUT) 79 | REGCODE(DSREG_AUTOJOIN_ADCONFIG_READ_FAILED) 80 | REGCODE(DSREG_AUTOJOIN_CREATE_EVENT_FAILED) 81 | REGCODE(DSREG_AUTOJOIN_DISC_WAIT_TIMEOUT) 82 | REGCODE(DSREG_AUTOJOIN_DISC_WAIT_FAILED) 83 | REGCODE(DSREG_AUTOJOIN_DISC_FAILED) 84 | REGCODE(DSREG_MISSING_DEVICE_ID_IN_TOKEN) 85 | REGCODE(DSREG_MFA_REQUIRED) 86 | REGCODE(DSREG_USER_NOT_FOUND) 87 | REGCODE(DSREG_SERVER_BUSY) 88 | REGCODE(DSREG_NGC_KEY_ALREADY_EXISTS) 89 | REGCODE(DSREG_BAD_DIRECTORY_REQUEST) 90 | REGCODE(DSREG_DIRECTORY_REPLICA_UNAVAILABLE) 91 | REGCODE(DSREG_DIRECTORY_REQUEST_THROTTLED) 92 | REGCODE(DSREG_DIRECTORY_REQUEST_DENIED) 93 | REGCODE(DSREG_DEVICE_KEY_NOACCESS) 94 | REGCODE(DSREG_DEVICE_KEY_MISSING) 95 | REGCODE(DSREG_JSON_REQUEST_FAILED) 96 | REGCODE(DSREG_JSON_REQUEST_NODATA) 97 | REGCODE(DSREG_E_AADPLUGIN_PRT_NOTFOUND) 98 | REGCODE(DSREG_AUTH_TOKEN_NOT_FOUND) 99 | REGCODE(DSREG_INVALID_RESPONSE) 100 | REGCODE(DSREG_E_NGC_AUTHORIZATION_ERROR) 101 | REGCODE(DSREG_E_NGC_UNEXPECTED_HTTP_STATUS) 102 | REGCODE(DSREG_E_NGC_INTERNAL_SERVER_ERROR) 103 | REGCODE(DSREG_E_NGC_INVALID_REQUEST) 104 | REGCODE(DSREG_E_NGC_ATTESTATION_ERROR) 105 | REGCODE(DSREG_E_NGC_AIK_CERT_RENEW) 106 | REGCODE(DSREG_E_NGC_KEY_NOT_FOUND) 107 | REGCODE(DSREG_E_UPN_NOT_FOUND) 108 | REGCODE(DSREG_E_DIRECTORY_FAILURE) 109 | REGCODE(DSREG_E_DEVICE_NOT_FOUND) 110 | REGCODE(DSREG_E_CXH_DEVICE_NOT_JOINED) 111 | REGCODE(DSREG_E_CXH_NO_SCENARIO_FOUND) 112 | REGCODE(DSREG_E_NGC_CERT_NO_ENTSSO) 113 | REGCODE(DSREG_E_NGC_INVALID_CONTAINER_OPTIONS) 114 | REGCODE(DSREG_E_NO_CORE_WINDOW) 115 | REGCODE(DSREG_E_USER_TOKEN_ERROR) 116 | REGCODE(DSREG_E_USER_INPUT_WAIT_FAILED) 117 | REGCODE(DSREG_E_USER_TOKEN_REQUEST_CANCELLED) 118 | REGCODE(DSREG_E_DEVICE_NOT_JOINED) 119 | }; 120 | 121 | static LPTSTR dsreg_code2msg(DWORD dwCode) 122 | { 123 | LPTSTR result = NULL; 124 | 125 | if (hModCertUtil) 126 | { 127 | UINT uID = dwCode & 0xFFFF; 128 | 129 | if (uID < 0x3E9) 130 | { 131 | uID += 0xCE00; 132 | } 133 | else if (uID < 0x44C) 134 | { 135 | uID += 0xCC00; 136 | } 137 | else 138 | { 139 | uID += 0xCA00; 140 | } 141 | 142 | if (0 != uID) 143 | { 144 | result = (LPTSTR)LocalAlloc(LPTR, MAX_MSG_LEN * sizeof (TCHAR)); 145 | if (result) 146 | { 147 | LoadString(hModCertUtil, uID, result, MAX_MSG_LEN); 148 | } 149 | } 150 | } 151 | 152 | return result; 153 | } 154 | 155 | static void dsreg_freemsg(LPTSTR lpMessage) 156 | { 157 | LocalFree(lpMessage); 158 | } 159 | 160 | void EcRegDsreg(ErrorCodeSet *pecs) 161 | { 162 | pecs->lpName = TEXT("DSREG"); 163 | pecs->pfnMessageFromCode = dsreg_code2msg; 164 | pecs->pfnFreeMessage = dsreg_freemsg; 165 | pecs->items = ec_dsreg_items; 166 | pecs->dwCodeCount = ARRAYSIZE(ec_dsreg_items); 167 | } 168 | 169 | void EcUnregDsreg() 170 | { 171 | /* Ignore */ 172 | } 173 | 174 | -------------------------------------------------------------------------------- /mod/ec_errno.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | #include 3 | 4 | static ErrorCodeItem ec_errno_items[] = { 5 | REGCODE(EPERM) 6 | REGCODE(ENOENT) 7 | REGCODE(ESRCH) 8 | REGCODE(EINTR) 9 | REGCODE(EIO) 10 | REGCODE(ENXIO) 11 | REGCODE(E2BIG) 12 | REGCODE(ENOEXEC) 13 | REGCODE(EBADF) 14 | REGCODE(ECHILD) 15 | REGCODE(EAGAIN) 16 | REGCODE(ENOMEM) 17 | REGCODE(EACCES) 18 | REGCODE(EFAULT) 19 | REGCODE(EBUSY) 20 | REGCODE(EEXIST) 21 | REGCODE(EXDEV) 22 | REGCODE(ENODEV) 23 | REGCODE(ENOTDIR) 24 | REGCODE(EISDIR) 25 | REGCODE(EINVAL) 26 | REGCODE(ENFILE) 27 | REGCODE(EMFILE) 28 | REGCODE(ENOTTY) 29 | REGCODE(EFBIG) 30 | REGCODE(ENOSPC) 31 | REGCODE(ESPIPE) 32 | REGCODE(EROFS) 33 | REGCODE(EMLINK) 34 | REGCODE(EPIPE) 35 | REGCODE(EDOM) 36 | REGCODE(ERANGE) 37 | REGCODE(EDEADLK) 38 | REGCODE(ENAMETOOLONG) 39 | REGCODE(ENOLCK) 40 | REGCODE(ENOSYS) 41 | REGCODE(ENOTEMPTY) 42 | REGCODE(EILSEQ) 43 | REGCODE(STRUNCATE) 44 | REGCODE(EADDRINUSE) 45 | REGCODE(EADDRNOTAVAIL) 46 | REGCODE(EAFNOSUPPORT) 47 | REGCODE(EALREADY) 48 | REGCODE(EBADMSG) 49 | REGCODE(ECANCELED) 50 | REGCODE(ECONNABORTED) 51 | REGCODE(ECONNREFUSED) 52 | REGCODE(ECONNRESET) 53 | REGCODE(EDESTADDRREQ) 54 | REGCODE(EHOSTUNREACH) 55 | REGCODE(EIDRM) 56 | REGCODE(EINPROGRESS) 57 | REGCODE(EISCONN) 58 | REGCODE(ELOOP) 59 | REGCODE(EMSGSIZE) 60 | REGCODE(ENETDOWN) 61 | REGCODE(ENETRESET) 62 | REGCODE(ENETUNREACH) 63 | REGCODE(ENOBUFS) 64 | REGCODE(ENODATA) 65 | REGCODE(ENOLINK) 66 | REGCODE(ENOMSG) 67 | REGCODE(ENOPROTOOPT) 68 | REGCODE(ENOSR) 69 | REGCODE(ENOSTR) 70 | REGCODE(ENOTCONN) 71 | REGCODE(ENOTRECOVERABLE) 72 | REGCODE(ENOTSOCK) 73 | REGCODE(ENOTSUP) 74 | REGCODE(EOPNOTSUPP) 75 | REGCODE(EOTHER) 76 | REGCODE(EOVERFLOW) 77 | REGCODE(EOWNERDEAD) 78 | REGCODE(EPROTO) 79 | REGCODE(EPROTONOSUPPORT) 80 | REGCODE(EPROTOTYPE) 81 | REGCODE(ETIME) 82 | REGCODE(ETIMEDOUT) 83 | REGCODE(ETXTBSY) 84 | REGCODE(EWOULDBLOCK) 85 | }; 86 | 87 | static LPTSTR errno_code2msg(DWORD dwCode) 88 | { 89 | return _tcserror(dwCode); 90 | } 91 | 92 | static void errno_freemsg(LPTSTR lpMessage) 93 | { 94 | /* Ignore */ 95 | } 96 | 97 | void EcRegErrno(ErrorCodeSet *pecs) 98 | { 99 | pecs->lpName = TEXT("errno"); 100 | pecs->pfnMessageFromCode = errno_code2msg; 101 | pecs->pfnFreeMessage = errno_freemsg; 102 | pecs->items = ec_errno_items; 103 | pecs->dwCodeCount = ARRAYSIZE(ec_errno_items); 104 | } 105 | 106 | void EcUnregErrno() 107 | { 108 | /* Ignore */ 109 | } 110 | 111 | -------------------------------------------------------------------------------- /mod/ec_gdip.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | 3 | #define Ok 0 4 | #define GenericError 1 5 | #define InvalidParameter 2 6 | #define OutOfMemory 3 7 | #define ObjectBusy 4 8 | #define InsufficientBuffer 5 9 | #define NotImplemented 6 10 | #define Win32Error 7 11 | #define WrongState 8 12 | #define Aborted 9 13 | #define FileNotFound 10 14 | #define ValueOverflow 11 15 | #define AccessDenied 12 16 | #define UnknownImageFormat 13 17 | #define FontFamilyNotFound 14 18 | #define FontStyleNotFound 15 19 | #define NotTrueTypeFont 16 20 | #define UnsupportedGdiplusVersion 17 21 | #define GdiplusNotInitialized 18 22 | #define PropertyNotFound 19 23 | #define PropertyNotSupported 20 24 | #define ProfileNotFound 21 25 | 26 | static ErrorCodeItem ec_gdip_items[] = { 27 | REGCODE(Ok) 28 | REGCODE(GenericError) 29 | REGCODE(InvalidParameter) 30 | REGCODE(OutOfMemory) 31 | REGCODE(ObjectBusy) 32 | REGCODE(InsufficientBuffer) 33 | REGCODE(NotImplemented) 34 | REGCODE(Win32Error) 35 | REGCODE(WrongState) 36 | REGCODE(Aborted) 37 | REGCODE(FileNotFound) 38 | REGCODE(ValueOverflow) 39 | REGCODE(AccessDenied) 40 | REGCODE(UnknownImageFormat) 41 | REGCODE(FontFamilyNotFound) 42 | REGCODE(FontStyleNotFound) 43 | REGCODE(NotTrueTypeFont) 44 | REGCODE(UnsupportedGdiplusVersion) 45 | REGCODE(GdiplusNotInitialized) 46 | REGCODE(PropertyNotFound) 47 | REGCODE(PropertyNotSupported) 48 | REGCODE(ProfileNotFound) 49 | }; 50 | 51 | static LPTSTR gdip_code2msg(DWORD dwCode) 52 | { 53 | switch (dwCode) 54 | { 55 | case Ok: 56 | return TEXT("The method call was successful."); 57 | 58 | case GenericError: 59 | return TEXT("There was an error on the method call, which is identified ") 60 | TEXT("as something other than those defined by the other elements ") 61 | TEXT("of this enumeration."); 62 | 63 | case InvalidParameter: 64 | return TEXT("One of the arguments passed to the method was not valid."); 65 | 66 | case OutOfMemory: 67 | return TEXT("The operating system is out of memory and could not ") 68 | TEXT("allocate memory to process the method call."); 69 | 70 | case ObjectBusy: 71 | return TEXT("One of the arguments specified in the API call is already ") 72 | TEXT("in use in another thread."); 73 | 74 | case InsufficientBuffer: 75 | return TEXT("A buffer specified as an argument in the API call ") 76 | TEXT("is not large enough to hold the data to be received."); 77 | 78 | case NotImplemented: 79 | return TEXT("The method is not implemented."); 80 | 81 | case Win32Error: 82 | return TEXT("The method generated a Win32 error."); 83 | 84 | case WrongState: 85 | return TEXT("The object is in an invalid state to satisfy the API call."); 86 | 87 | case Aborted: 88 | return TEXT("The method was aborted."); 89 | 90 | case FileNotFound: 91 | return TEXT("The specified image file or metafile cannot be found."); 92 | 93 | case ValueOverflow: 94 | return TEXT("The method performed an arithmetic operation ") 95 | TEXT("that produced a numeric overflow."); 96 | 97 | case AccessDenied: 98 | return TEXT("A write operation is not allowed on the specified file."); 99 | 100 | case UnknownImageFormat: 101 | return TEXT("The specified image file format is not known."); 102 | 103 | case FontFamilyNotFound: 104 | return TEXT("The specified font family cannot be found."); 105 | 106 | case FontStyleNotFound: 107 | return TEXT("The specified style is not available for the ") 108 | TEXT("specified font family."); 109 | 110 | case NotTrueTypeFont: 111 | return TEXT("The font retrieved from an HDC or LOGFONT ") 112 | TEXT("is not a TrueType font and cannot be used with GDI+."); 113 | 114 | case UnsupportedGdiplusVersion: 115 | return TEXT("The version of GDI+ that is installed on the system ") 116 | TEXT("is incompatible with the version with ") 117 | TEXT("which the application was compiled."); 118 | 119 | case GdiplusNotInitialized: 120 | return TEXT("The GDI+ API is not in an initialized state."); 121 | 122 | case PropertyNotFound: 123 | return TEXT("The specified property does not exist in the image."); 124 | 125 | case PropertyNotSupported: 126 | return TEXT("The specified property is not supported by the format ") 127 | TEXT("of the image and, therefore, cannot be set."); 128 | 129 | case ProfileNotFound: 130 | return TEXT("The color profile required to save an image ") 131 | TEXT("in CMYK format was not found."); 132 | 133 | default: 134 | return NULL; 135 | } 136 | } 137 | 138 | static void gdip_freemsg(LPTSTR lpMessage) 139 | { 140 | /* Ignore */ 141 | } 142 | 143 | void EcRegGdip(ErrorCodeSet *pecs) 144 | { 145 | pecs->lpName = TEXT("Gdiplus"); 146 | pecs->pfnMessageFromCode = gdip_code2msg; 147 | pecs->pfnFreeMessage = gdip_freemsg; 148 | pecs->items = ec_gdip_items; 149 | pecs->dwCodeCount = ARRAYSIZE(ec_gdip_items); 150 | } 151 | 152 | void EcUnregGdip() 153 | { 154 | /* Ignore */ 155 | } 156 | 157 | -------------------------------------------------------------------------------- /mod/ec_http.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | #include 3 | 4 | static ErrorCodeItem ec_http_items[] = { 5 | REGCODE(HTTP_STATUS_CONTINUE) 6 | REGCODE(HTTP_STATUS_SWITCH_PROTOCOLS) 7 | 8 | REGCODE(HTTP_STATUS_OK) 9 | REGCODE(HTTP_STATUS_CREATED) 10 | REGCODE(HTTP_STATUS_ACCEPTED) 11 | REGCODE(HTTP_STATUS_PARTIAL) 12 | REGCODE(HTTP_STATUS_NO_CONTENT) 13 | REGCODE(HTTP_STATUS_RESET_CONTENT) 14 | REGCODE(HTTP_STATUS_PARTIAL_CONTENT) 15 | 16 | REGCODE(HTTP_STATUS_AMBIGUOUS) 17 | REGCODE(HTTP_STATUS_MOVED) 18 | REGCODE(HTTP_STATUS_REDIRECT) 19 | REGCODE(HTTP_STATUS_REDIRECT_METHOD) 20 | REGCODE(HTTP_STATUS_NOT_MODIFIED) 21 | REGCODE(HTTP_STATUS_USE_PROXY) 22 | REGCODE(HTTP_STATUS_REDIRECT_KEEP_VERB) 23 | 24 | REGCODE(HTTP_STATUS_BAD_REQUEST) 25 | REGCODE(HTTP_STATUS_DENIED) 26 | REGCODE(HTTP_STATUS_PAYMENT_REQ) 27 | REGCODE(HTTP_STATUS_FORBIDDEN) 28 | REGCODE(HTTP_STATUS_NOT_FOUND) 29 | REGCODE(HTTP_STATUS_BAD_METHOD) 30 | REGCODE(HTTP_STATUS_NONE_ACCEPTABLE) 31 | REGCODE(HTTP_STATUS_PROXY_AUTH_REQ) 32 | REGCODE(HTTP_STATUS_REQUEST_TIMEOUT) 33 | REGCODE(HTTP_STATUS_CONFLICT) 34 | REGCODE(HTTP_STATUS_GONE) 35 | REGCODE(HTTP_STATUS_LENGTH_REQUIRED) 36 | REGCODE(HTTP_STATUS_PRECOND_FAILED) 37 | REGCODE(HTTP_STATUS_REQUEST_TOO_LARGE) 38 | REGCODE(HTTP_STATUS_URI_TOO_LONG) 39 | REGCODE(HTTP_STATUS_UNSUPPORTED_MEDIA) 40 | REGCODE(HTTP_STATUS_RETRY_WITH) 41 | 42 | REGCODE(HTTP_STATUS_SERVER_ERROR) 43 | REGCODE(HTTP_STATUS_NOT_SUPPORTED) 44 | REGCODE(HTTP_STATUS_BAD_GATEWAY) 45 | REGCODE(HTTP_STATUS_SERVICE_UNAVAIL) 46 | REGCODE(HTTP_STATUS_GATEWAY_TIMEOUT) 47 | REGCODE(HTTP_STATUS_VERSION_NOT_SUP) 48 | }; 49 | 50 | static LPTSTR http_code2msg(DWORD dwCode) 51 | { 52 | LPTSTR result = NULL; 53 | 54 | if (hModCertCli) 55 | { 56 | UINT uID = 0; 57 | SIZE_T i; 58 | 59 | for (i = 0; i < ARRAYSIZE(ec_http_items); ++i) 60 | { 61 | if (dwCode == ec_http_items[i].dwCode) 62 | { 63 | uID = i + 248; 64 | break; 65 | } 66 | } 67 | 68 | if (0 != uID) 69 | { 70 | result = (LPTSTR)LocalAlloc(LPTR, MAX_MSG_LEN * sizeof (TCHAR)); 71 | if (result) 72 | { 73 | LoadString(hModCertCli, uID, result, MAX_MSG_LEN); 74 | } 75 | } 76 | } 77 | 78 | return result; 79 | } 80 | 81 | static void http_freemsg(LPTSTR lpMessage) 82 | { 83 | LocalFree(lpMessage); 84 | } 85 | 86 | void EcRegHttp(ErrorCodeSet *pecs) 87 | { 88 | pecs->lpName = TEXT("HTTP"); 89 | pecs->pfnMessageFromCode = http_code2msg; 90 | pecs->pfnFreeMessage = http_freemsg; 91 | pecs->items = ec_http_items; 92 | pecs->dwCodeCount = ARRAYSIZE(ec_http_items); 93 | } 94 | 95 | void EcUnregHttp() 96 | { 97 | /* Ignore */ 98 | } 99 | 100 | -------------------------------------------------------------------------------- /mod/ec_mdm.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | 3 | #ifndef MENROLL_E_DEVICE_MESSAGE_FORMAT_ERROR 4 | #define MENROLL_E_DEVICE_MESSAGE_FORMAT_ERROR 0x80180001 5 | #endif 6 | #ifndef MENROLL_E_DEVICE_AUTHENTICATION_ERROR 7 | #define MENROLL_E_DEVICE_AUTHENTICATION_ERROR 0x80180002 8 | #endif 9 | #ifndef MENROLL_E_DEVICE_AUTHORIZATION_ERROR 10 | #define MENROLL_E_DEVICE_AUTHORIZATION_ERROR 0x80180003 11 | #endif 12 | #ifndef MENROLL_E_DEVICE_CERTIFCATEREQUEST_ERRO 13 | #define MENROLL_E_DEVICE_CERTIFCATEREQUEST_ERRO 0x80180004 14 | #endif 15 | #ifndef MENROLL_E_DEVICE_CONFIGMGRSERVER_ERROR 16 | #define MENROLL_E_DEVICE_CONFIGMGRSERVER_ERROR 0x80180005 17 | #endif 18 | #ifndef MENROLL_E_DEVICE_INTERNALSERVICE_ERROR 19 | #define MENROLL_E_DEVICE_INTERNALSERVICE_ERROR 0x80180006 20 | #endif 21 | #ifndef MENROLL_E_DEVICE_INVALIDSECURITY_ERROR 22 | #define MENROLL_E_DEVICE_INVALIDSECURITY_ERROR 0x80180007 23 | #endif 24 | #ifndef MENROLL_E_DEVICE_UNKNOWN_ERROR 25 | #define MENROLL_E_DEVICE_UNKNOWN_ERROR 0x80180008 26 | #endif 27 | #ifndef MENROLL_E_ENROLLMENT_IN_PROGRESS 28 | #define MENROLL_E_ENROLLMENT_IN_PROGRESS 0x80180009 29 | #endif 30 | #ifndef MENROLL_E_DEVICE_ALREADY_ENROLLED 31 | #define MENROLL_E_DEVICE_ALREADY_ENROLLED 0x8018000A 32 | #endif 33 | #ifndef MENROLL_E_DEVICE_NOT_ENROLLED 34 | #define MENROLL_E_DEVICE_NOT_ENROLLED 0x8018000B 35 | #endif 36 | #ifndef MENROLL_E_DISCOVERY_SEC_CERT_DATE_INVAL 37 | #define MENROLL_E_DISCOVERY_SEC_CERT_DATE_INVAL 0x8018000D 38 | #endif 39 | #ifndef MENROLL_E_PASSWORD_NEEDED 40 | #define MENROLL_E_PASSWORD_NEEDED 0x8018000E 41 | #endif 42 | #ifndef MENROLL_E_WAB_ERROR 43 | #define MENROLL_E_WAB_ERROR 0x8018000F 44 | #endif 45 | #ifndef MENROLL_E_CONNECTIVITY 46 | #define MENROLL_E_CONNECTIVITY 0x80180010 47 | #endif 48 | #ifndef MENROLL_E_INVALIDSSLCERT 49 | #define MENROLL_E_INVALIDSSLCERT 0x80180012 50 | #endif 51 | #ifndef MENROLL_E_DEVICECAPREACHED 52 | #define MENROLL_E_DEVICECAPREACHED 0x80180013 53 | #endif 54 | #ifndef MENROLL_E_DEVICENOTSUPPORTED 55 | #define MENROLL_E_DEVICENOTSUPPORTED 0x80180014 56 | #endif 57 | #ifndef MENROLL_E_NOTSUPPORTED 58 | #define MENROLL_E_NOTSUPPORTED 0x80180015 59 | #endif 60 | #ifndef MENROLL_E_NOTELIGIBLETORENEW 61 | #define MENROLL_E_NOTELIGIBLETORENEW 0x80180016 62 | #endif 63 | #ifndef MENROLL_E_INMAINTENANCE 64 | #define MENROLL_E_INMAINTENANCE 0x80180017 65 | #endif 66 | #ifndef MENROLL_E_USERLICENSE 67 | #define MENROLL_E_USERLICENSE 0x80180018 68 | #endif 69 | #ifndef MENROLL_E_ENROLLMENTDATAINVALID 70 | #define MENROLL_E_ENROLLMENTDATAINVALID 0x80180019 71 | #endif 72 | #ifndef MENROLL_E_INSECUREREDIRECT 73 | #define MENROLL_E_INSECUREREDIRECT 0x8018001A 74 | #endif 75 | #ifndef MENROLL_E_PLATFORM_WRONG_STATE 76 | #define MENROLL_E_PLATFORM_WRONG_STATE 0x8018001B 77 | #endif 78 | #ifndef MENROLL_E_PLATFORM_LICENSE_ERROR 79 | #define MENROLL_E_PLATFORM_LICENSE_ERROR 0x8018001C 80 | #endif 81 | #ifndef MENROLL_E_PLATFORM_UNKNOWN_ERROR 82 | #define MENROLL_E_PLATFORM_UNKNOWN_ERROR 0x8018001D 83 | #endif 84 | #ifndef MENROLL_E_PROV_CSP_CERTSTORE 85 | #define MENROLL_E_PROV_CSP_CERTSTORE 0x8018001E 86 | #endif 87 | #ifndef MENROLL_E_PROV_CSP_W7 88 | #define MENROLL_E_PROV_CSP_W7 0x8018001F 89 | #endif 90 | #ifndef MENROLL_E_PROV_CSP_DMCLIENT 91 | #define MENROLL_E_PROV_CSP_DMCLIENT 0x80180020 92 | #endif 93 | #ifndef MENROLL_E_PROV_CSP_PFW 94 | #define MENROLL_E_PROV_CSP_PFW 0x80180021 95 | #endif 96 | #ifndef MENROLL_E_PROV_CSP_MISC 97 | #define MENROLL_E_PROV_CSP_MISC 0x80180022 98 | #endif 99 | #ifndef MENROLL_E_PROV_UNKNOWN 100 | #define MENROLL_E_PROV_UNKNOWN 0x80180023 101 | #endif 102 | #ifndef MENROLL_E_PROV_SSLCERTNOTFOUND 103 | #define MENROLL_E_PROV_SSLCERTNOTFOUND 0x80180024 104 | #endif 105 | #ifndef MENROLL_E_PROV_CSP_APPMGMT 106 | #define MENROLL_E_PROV_CSP_APPMGMT 0x80180025 107 | #endif 108 | #ifndef MENROLL_E_DEVICE_MANAGEMENT_BLOCKED 109 | #define MENROLL_E_DEVICE_MANAGEMENT_BLOCKED 0x80180026 110 | #endif 111 | #ifndef MENROLL_E_CERTPOLICY_PRIVATEKEYCREATION 112 | #define MENROLL_E_CERTPOLICY_PRIVATEKEYCREATION 0x80180027 113 | #endif 114 | #ifndef MENROLL_E_CERTAUTH_FAILED_TO_FIND_CERT 115 | #define MENROLL_E_CERTAUTH_FAILED_TO_FIND_CERT 0x80180028 116 | #endif 117 | #ifndef MENROLL_E_EMPTY_MESSAGE 118 | #define MENROLL_E_EMPTY_MESSAGE 0x80180029 119 | #endif 120 | 121 | static ErrorCodeItem ec_mdm_items[] = { 122 | REGCODE(MENROLL_E_DEVICE_MESSAGE_FORMAT_ERROR) 123 | REGCODE(MENROLL_E_DEVICE_AUTHENTICATION_ERROR) 124 | REGCODE(MENROLL_E_DEVICE_AUTHORIZATION_ERROR) 125 | REGCODE(MENROLL_E_DEVICE_CERTIFCATEREQUEST_ERRO) 126 | REGCODE(MENROLL_E_DEVICE_CONFIGMGRSERVER_ERROR) 127 | REGCODE(MENROLL_E_DEVICE_INTERNALSERVICE_ERROR) 128 | REGCODE(MENROLL_E_DEVICE_INVALIDSECURITY_ERROR) 129 | REGCODE(MENROLL_E_DEVICE_UNKNOWN_ERROR) 130 | REGCODE(MENROLL_E_ENROLLMENT_IN_PROGRESS) 131 | REGCODE(MENROLL_E_DEVICE_ALREADY_ENROLLED) 132 | REGCODE(MENROLL_E_DEVICE_NOT_ENROLLED) 133 | REGCODE(MENROLL_E_DISCOVERY_SEC_CERT_DATE_INVAL) 134 | REGCODE(MENROLL_E_PASSWORD_NEEDED) 135 | REGCODE(MENROLL_E_WAB_ERROR) 136 | REGCODE(MENROLL_E_CONNECTIVITY) 137 | REGCODE(MENROLL_E_INVALIDSSLCERT) 138 | REGCODE(MENROLL_E_DEVICECAPREACHED) 139 | REGCODE(MENROLL_E_DEVICENOTSUPPORTED) 140 | REGCODE(MENROLL_E_NOTSUPPORTED) 141 | REGCODE(MENROLL_E_NOTELIGIBLETORENEW) 142 | REGCODE(MENROLL_E_INMAINTENANCE) 143 | REGCODE(MENROLL_E_USERLICENSE) 144 | REGCODE(MENROLL_E_ENROLLMENTDATAINVALID) 145 | REGCODE(MENROLL_E_INSECUREREDIRECT) 146 | REGCODE(MENROLL_E_PLATFORM_WRONG_STATE) 147 | REGCODE(MENROLL_E_PLATFORM_LICENSE_ERROR) 148 | REGCODE(MENROLL_E_PLATFORM_UNKNOWN_ERROR) 149 | REGCODE(MENROLL_E_PROV_CSP_CERTSTORE) 150 | REGCODE(MENROLL_E_PROV_CSP_W7) 151 | REGCODE(MENROLL_E_PROV_CSP_DMCLIENT) 152 | REGCODE(MENROLL_E_PROV_CSP_PFW) 153 | REGCODE(MENROLL_E_PROV_CSP_MISC) 154 | REGCODE(MENROLL_E_PROV_UNKNOWN) 155 | REGCODE(MENROLL_E_PROV_SSLCERTNOTFOUND) 156 | REGCODE(MENROLL_E_PROV_CSP_APPMGMT) 157 | REGCODE(MENROLL_E_DEVICE_MANAGEMENT_BLOCKED) 158 | REGCODE(MENROLL_E_CERTPOLICY_PRIVATEKEYCREATION) 159 | REGCODE(MENROLL_E_CERTAUTH_FAILED_TO_FIND_CERT) 160 | REGCODE(MENROLL_E_EMPTY_MESSAGE) 161 | }; 162 | 163 | static LPTSTR mdm_code2msg(DWORD dwCode) 164 | { 165 | return MsgFromSys(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwCode); 166 | } 167 | 168 | static void mdm_freemsg(LPTSTR lpMessage) 169 | { 170 | LocalFree(lpMessage); 171 | } 172 | 173 | void EcRegMdm(ErrorCodeSet *pecs) 174 | { 175 | pecs->lpName = TEXT("MDM"); 176 | pecs->pfnMessageFromCode = mdm_code2msg; 177 | pecs->pfnFreeMessage = mdm_freemsg; 178 | pecs->items = ec_mdm_items; 179 | pecs->dwCodeCount = ARRAYSIZE(ec_mdm_items); 180 | } 181 | 182 | void EcUnregMdm() 183 | { 184 | /* Ignore */ 185 | } 186 | 187 | -------------------------------------------------------------------------------- /mod/ec_setup.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | #include 3 | 4 | static ErrorCodeItem ec_setup_items[] = { 5 | REGCODE(ERROR_EXPECTED_SECTION_NAME) 6 | REGCODE(ERROR_BAD_SECTION_NAME_LINE) 7 | REGCODE(ERROR_SECTION_NAME_TOO_LONG) 8 | REGCODE(ERROR_GENERAL_SYNTAX) 9 | 10 | REGCODE(ERROR_WRONG_INF_STYLE) 11 | REGCODE(ERROR_SECTION_NOT_FOUND) 12 | REGCODE(ERROR_LINE_NOT_FOUND) 13 | }; 14 | 15 | static LPTSTR setup_code2msg(DWORD dwCode) 16 | { 17 | LPTSTR result = NULL; 18 | 19 | if (hModCertCli) 20 | { 21 | UINT uID = 0; 22 | SIZE_T n, i; 23 | 24 | for (i = 0; i < ARRAYSIZE(ec_setup_items); ++i) 25 | { 26 | if (dwCode == ec_setup_items[i].dwCode) 27 | { 28 | uID = i + 212; 29 | break; 30 | } 31 | } 32 | 33 | if (0 != uID) 34 | { 35 | result = (LPTSTR)LocalAlloc(LPTR, MAX_MSG_LEN * sizeof (TCHAR)); 36 | if (result) 37 | { 38 | LoadString(hModCertCli, uID, result, MAX_MSG_LEN); 39 | } 40 | } 41 | } 42 | 43 | return result; 44 | } 45 | 46 | static void setup_freemsg(LPTSTR lpMessage) 47 | { 48 | LocalFree(lpMessage); 49 | } 50 | 51 | void EcRegSetup(ErrorCodeSet *pecs) 52 | { 53 | pecs->lpName = TEXT("Setup"); 54 | pecs->pfnMessageFromCode = setup_code2msg; 55 | pecs->pfnFreeMessage = setup_freemsg; 56 | pecs->items = ec_setup_items; 57 | pecs->dwCodeCount = ARRAYSIZE(ec_setup_items); 58 | } 59 | 60 | void EcUnregSetup() 61 | { 62 | /* Ignore */ 63 | } 64 | 65 | -------------------------------------------------------------------------------- /mod/ec_sig.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | #include 3 | 4 | static ErrorCodeItem ec_sig_items[] = { 5 | REGCODE(SIGINT) 6 | REGCODE(SIGILL) 7 | REGCODE(SIGFPE) 8 | REGCODE(SIGSEGV) 9 | REGCODE(SIGTERM) 10 | REGCODE(SIGBREAK) 11 | REGCODE(SIGABRT) 12 | REGCODE(SIGABRT_COMPAT) 13 | }; 14 | 15 | static LPTSTR sig_code2msg(DWORD dwCode) 16 | { 17 | switch (dwCode) 18 | { 19 | case SIGINT: 20 | return TEXT("interrupt"); 21 | 22 | case SIGILL: 23 | return TEXT("illegal instruction - invalid function image"); 24 | 25 | case SIGFPE: 26 | return TEXT("floating point exception"); 27 | 28 | case SIGSEGV: 29 | return TEXT("segment violation"); 30 | 31 | case SIGTERM: 32 | return TEXT("Software termination signal from kill"); 33 | 34 | case SIGBREAK: 35 | return TEXT("Ctrl-Break sequence"); 36 | 37 | case SIGABRT: 38 | return TEXT("abnormal termination triggered by abort call"); 39 | 40 | case SIGABRT_COMPAT: 41 | return TEXT("SIGABRT compatible with other platforms, same as SIGABRT"); 42 | 43 | default: 44 | return TEXT("Unknown signal"); 45 | } 46 | } 47 | 48 | static void sig_freemsg(LPTSTR lpMessage) 49 | { 50 | /* Ignore */ 51 | } 52 | 53 | void EcRegSig(ErrorCodeSet *pecs) 54 | { 55 | pecs->lpName = TEXT("signal"); 56 | pecs->pfnMessageFromCode = sig_code2msg; 57 | pecs->pfnFreeMessage = sig_freemsg; 58 | pecs->items = ec_sig_items; 59 | pecs->dwCodeCount = ARRAYSIZE(ec_sig_items); 60 | } 61 | 62 | void EcUnregSig() 63 | { 64 | /* Ignore */ 65 | } 66 | 67 | -------------------------------------------------------------------------------- /mod/ec_winhttp.c: -------------------------------------------------------------------------------- 1 | #include "../ecf.h" 2 | #include 3 | 4 | #ifndef ERROR_HTTP_HSTS_REDIRECT_REQUIRED 5 | #define ERROR_HTTP_HSTS_REDIRECT_REQUIRED (INTERNET_ERROR_BASE + 60) 6 | #endif 7 | #ifndef ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE 8 | #define ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE (INTERNET_ERROR_BASE + 62) 9 | #endif 10 | #ifndef ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED_PROXY 11 | #define ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED_PROXY (INTERNET_ERROR_BASE + 187) 12 | #endif 13 | #ifndef ERROR_INTERNET_SECURE_FAILURE_PROXY 14 | #define ERROR_INTERNET_SECURE_FAILURE_PROXY (INTERNET_ERROR_BASE + 188) 15 | #endif 16 | 17 | /* In winhttp.h but conflict */ 18 | #define ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN (INTERNET_ERROR_BASE + 100) 19 | #define ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND (INTERNET_ERROR_BASE + 101) 20 | #define ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND (INTERNET_ERROR_BASE + 102) 21 | #define ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN (INTERNET_ERROR_BASE + 103) 22 | #define ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR (INTERNET_ERROR_BASE + 178) 23 | #define ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE (INTERNET_ERROR_BASE + 179) 24 | #define ERROR_WINHTTP_AUTODETECTION_FAILED (INTERNET_ERROR_BASE + 180) 25 | #define ERROR_WINHTTP_HEADER_COUNT_EXCEEDED (INTERNET_ERROR_BASE + 181) 26 | #define ERROR_WINHTTP_HEADER_SIZE_OVERFLOW (INTERNET_ERROR_BASE + 182) 27 | #define ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW (INTERNET_ERROR_BASE + 183) 28 | #define ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW (INTERNET_ERROR_BASE + 184) 29 | #define ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY (INTERNET_ERROR_BASE + 185) 30 | #define ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY (INTERNET_ERROR_BASE + 186) 31 | 32 | static ErrorCodeItem ec_winhttp_items[] = { 33 | REGCODE(ERROR_INTERNET_OUT_OF_HANDLES) 34 | REGCODE(ERROR_INTERNET_TIMEOUT) 35 | REGCODE(ERROR_INTERNET_EXTENDED_ERROR) 36 | REGCODE(ERROR_INTERNET_INTERNAL_ERROR) 37 | REGCODE(ERROR_INTERNET_INVALID_URL) 38 | REGCODE(ERROR_INTERNET_UNRECOGNIZED_SCHEME) 39 | REGCODE(ERROR_INTERNET_NAME_NOT_RESOLVED) 40 | REGCODE(ERROR_INTERNET_PROTOCOL_NOT_FOUND) 41 | REGCODE(ERROR_INTERNET_INVALID_OPTION) 42 | REGCODE(ERROR_INTERNET_BAD_OPTION_LENGTH) 43 | REGCODE(ERROR_INTERNET_OPTION_NOT_SETTABLE) 44 | REGCODE(ERROR_INTERNET_SHUTDOWN) 45 | REGCODE(ERROR_INTERNET_INCORRECT_USER_NAME) 46 | REGCODE(ERROR_INTERNET_INCORRECT_PASSWORD) 47 | REGCODE(ERROR_INTERNET_LOGIN_FAILURE) 48 | REGCODE(ERROR_INTERNET_INVALID_OPERATION) 49 | REGCODE(ERROR_INTERNET_OPERATION_CANCELLED) 50 | REGCODE(ERROR_INTERNET_INCORRECT_HANDLE_TYPE) 51 | REGCODE(ERROR_INTERNET_INCORRECT_HANDLE_STATE) 52 | REGCODE(ERROR_INTERNET_NOT_PROXY_REQUEST) 53 | REGCODE(ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND) 54 | REGCODE(ERROR_INTERNET_BAD_REGISTRY_PARAMETER) 55 | REGCODE(ERROR_INTERNET_NO_DIRECT_ACCESS) 56 | REGCODE(ERROR_INTERNET_NO_CONTEXT) 57 | REGCODE(ERROR_INTERNET_NO_CALLBACK) 58 | REGCODE(ERROR_INTERNET_REQUEST_PENDING) 59 | REGCODE(ERROR_INTERNET_INCORRECT_FORMAT) 60 | REGCODE(ERROR_INTERNET_ITEM_NOT_FOUND) 61 | REGCODE(ERROR_INTERNET_CANNOT_CONNECT) 62 | REGCODE(ERROR_INTERNET_CONNECTION_ABORTED) 63 | REGCODE(ERROR_INTERNET_CONNECTION_RESET) 64 | REGCODE(ERROR_INTERNET_FORCE_RETRY) 65 | REGCODE(ERROR_INTERNET_INVALID_PROXY_REQUEST) 66 | REGCODE(ERROR_INTERNET_NEED_UI) 67 | REGCODE(ERROR_INTERNET_HANDLE_EXISTS) 68 | REGCODE(ERROR_INTERNET_SEC_CERT_DATE_INVALID) 69 | REGCODE(ERROR_INTERNET_SEC_CERT_CN_INVALID) 70 | REGCODE(ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR) 71 | REGCODE(ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR) 72 | REGCODE(ERROR_INTERNET_MIXED_SECURITY) 73 | REGCODE(ERROR_INTERNET_CHG_POST_IS_NON_SECURE) 74 | REGCODE(ERROR_INTERNET_POST_IS_NON_SECURE) 75 | REGCODE(ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED) 76 | REGCODE(ERROR_INTERNET_INVALID_CA) 77 | REGCODE(ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP) 78 | REGCODE(ERROR_INTERNET_ASYNC_THREAD_FAILED) 79 | REGCODE(ERROR_INTERNET_REDIRECT_SCHEME_CHANGE) 80 | REGCODE(ERROR_INTERNET_DIALOG_PENDING) 81 | REGCODE(ERROR_INTERNET_RETRY_DIALOG) 82 | REGCODE(ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR) 83 | REGCODE(ERROR_INTERNET_INSERT_CDROM) 84 | REGCODE(ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED) 85 | REGCODE(ERROR_INTERNET_SEC_CERT_ERRORS) 86 | REGCODE(ERROR_INTERNET_SEC_CERT_NO_REV) 87 | REGCODE(ERROR_INTERNET_SEC_CERT_REV_FAILED) 88 | REGCODE(ERROR_HTTP_HSTS_REDIRECT_REQUIRED) 89 | REGCODE(ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE) 90 | REGCODE(ERROR_WINHTTP_CANNOT_CALL_BEFORE_OPEN) 91 | REGCODE(ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND) 92 | REGCODE(ERROR_WINHTTP_CANNOT_CALL_AFTER_SEND) 93 | REGCODE(ERROR_WINHTTP_CANNOT_CALL_AFTER_OPEN) 94 | REGCODE(ERROR_FTP_TRANSFER_IN_PROGRESS) 95 | REGCODE(ERROR_FTP_DROPPED) 96 | REGCODE(ERROR_FTP_NO_PASSIVE_MODE) 97 | REGCODE(ERROR_GOPHER_PROTOCOL_ERROR) 98 | REGCODE(ERROR_GOPHER_NOT_FILE) 99 | REGCODE(ERROR_GOPHER_DATA_ERROR) 100 | REGCODE(ERROR_GOPHER_END_OF_DATA) 101 | REGCODE(ERROR_GOPHER_INVALID_LOCATOR) 102 | REGCODE(ERROR_GOPHER_INCORRECT_LOCATOR_TYPE) 103 | REGCODE(ERROR_GOPHER_NOT_GOPHER_PLUS) 104 | REGCODE(ERROR_GOPHER_ATTRIBUTE_NOT_FOUND) 105 | REGCODE(ERROR_GOPHER_UNKNOWN_LOCATOR) 106 | REGCODE(ERROR_HTTP_HEADER_NOT_FOUND) 107 | REGCODE(ERROR_HTTP_DOWNLEVEL_SERVER) 108 | REGCODE(ERROR_HTTP_INVALID_SERVER_RESPONSE) 109 | REGCODE(ERROR_HTTP_INVALID_HEADER) 110 | REGCODE(ERROR_HTTP_INVALID_QUERY_REQUEST) 111 | REGCODE(ERROR_HTTP_HEADER_ALREADY_EXISTS) 112 | REGCODE(ERROR_HTTP_REDIRECT_FAILED) 113 | REGCODE(ERROR_HTTP_NOT_REDIRECTED) 114 | REGCODE(ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION) 115 | REGCODE(ERROR_HTTP_COOKIE_DECLINED) 116 | REGCODE(ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION) 117 | REGCODE(ERROR_INTERNET_SECURITY_CHANNEL_ERROR) 118 | REGCODE(ERROR_INTERNET_UNABLE_TO_CACHE_FILE) 119 | REGCODE(ERROR_INTERNET_TCPIP_NOT_INSTALLED) 120 | REGCODE(ERROR_INTERNET_DISCONNECTED) 121 | REGCODE(ERROR_INTERNET_SERVER_UNREACHABLE) 122 | REGCODE(ERROR_INTERNET_PROXY_SERVER_UNREACHABLE) 123 | REGCODE(ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT) 124 | REGCODE(ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT) 125 | REGCODE(ERROR_INTERNET_SEC_INVALID_CERT) 126 | REGCODE(ERROR_INTERNET_SEC_CERT_REVOKED) 127 | REGCODE(ERROR_INTERNET_FAILED_DUETOSECURITYCHECK) 128 | REGCODE(ERROR_INTERNET_NOT_INITIALIZED) 129 | REGCODE(ERROR_INTERNET_NEED_MSN_SSPI_PKG) 130 | REGCODE(ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY) 131 | REGCODE(ERROR_INTERNET_DECODING_FAILED) 132 | REGCODE(ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR) 133 | REGCODE(ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE) 134 | REGCODE(ERROR_WINHTTP_AUTODETECTION_FAILED) 135 | REGCODE(ERROR_WINHTTP_HEADER_COUNT_EXCEEDED) 136 | REGCODE(ERROR_WINHTTP_HEADER_SIZE_OVERFLOW) 137 | REGCODE(ERROR_WINHTTP_CHUNKED_ENCODING_HEADER_SIZE_OVERFLOW) 138 | REGCODE(ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW) 139 | REGCODE(ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY) 140 | REGCODE(ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY) 141 | REGCODE(ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED_PROXY) 142 | REGCODE(ERROR_INTERNET_SECURE_FAILURE_PROXY) 143 | }; 144 | 145 | static LPTSTR winhttp_code2msg(DWORD dwCode) 146 | { 147 | return MsgFromSys(FORMAT_MESSAGE_FROM_HMODULE, hModHttp, dwCode); 148 | } 149 | 150 | static void winhttp_freemsg(LPTSTR lpMessage) 151 | { 152 | LocalFree(lpMessage); 153 | } 154 | 155 | void EcRegWinhttp(ErrorCodeSet *pecs) 156 | { 157 | pecs->lpName = TEXT("WinHttp"); 158 | pecs->pfnMessageFromCode = winhttp_code2msg; 159 | pecs->pfnFreeMessage = winhttp_freemsg; 160 | pecs->items = ec_winhttp_items; 161 | pecs->dwCodeCount = ARRAYSIZE(ec_winhttp_items); 162 | } 163 | 164 | void EcUnregWinhttp() 165 | { 166 | /* Ignore */ 167 | } 168 | 169 | -------------------------------------------------------------------------------- /provider.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | 3 | extern void EcRegHttp(ErrorCodeSet *pecs); 4 | extern void EcUnregHttp(); 5 | extern void EcRegSetup(ErrorCodeSet *pecs); 6 | extern void EcUnregSetup(); 7 | extern void EcRegWinhttp(ErrorCodeSet *pecs); 8 | extern void EcUnregWinhttp(); 9 | extern void EcRegWin32(ErrorCodeSet *pecs); 10 | extern void EcUnregWin32(); 11 | extern void EcRegDsreg(ErrorCodeSet *pecs); 12 | extern void EcUnregDsreg(); 13 | extern void EcRegDme(ErrorCodeSet *pecs); 14 | extern void EcUnregDme(); 15 | extern void EcRegCcm(ErrorCodeSet *pecs); 16 | extern void EcUnregCcm(); 17 | extern void EcRegMdm(ErrorCodeSet *pecs); 18 | extern void EcUnregMdm(); 19 | extern void EcRegNt(ErrorCodeSet *pecs); 20 | extern void EcUnregNt(); 21 | extern void EcRegCom(ErrorCodeSet *pecs); 22 | extern void EcUnregCom(); 23 | extern void EcRegD3d(ErrorCodeSet *pecs); 24 | extern void EcUnregD3d(); 25 | extern void EcRegGdip(ErrorCodeSet *pecs); 26 | extern void EcUnregGdip(); 27 | extern void EcRegErrno(ErrorCodeSet *pecs); 28 | extern void EcUnregErrno(); 29 | extern void EcRegSig(ErrorCodeSet *pecs); 30 | extern void EcUnregSig(); 31 | extern void EcRegBug(ErrorCodeSet *pecs); 32 | extern void EcUnregBug(); 33 | 34 | static struct _ErrorCodeType { 35 | void (*pfnreg)(ErrorCodeSet *pecs); 36 | void (*pfnunreg)(); 37 | } types[] = { 38 | {EcRegHttp, EcUnregHttp}, 39 | {EcRegSetup, EcUnregSetup}, 40 | {EcRegWinhttp, EcUnregWinhttp}, 41 | {EcRegWin32, EcUnregWin32}, 42 | {EcRegDsreg, EcUnregDsreg}, 43 | {EcRegDme, EcUnregDme}, 44 | {EcRegCcm, EcUnregCcm}, 45 | {EcRegMdm, EcUnregMdm}, 46 | {EcRegNt, EcUnregNt}, 47 | {EcRegCom, EcUnregCom}, 48 | {EcRegD3d, EcUnregD3d}, 49 | {EcRegGdip, EcUnregGdip}, 50 | {EcRegErrno, EcUnregErrno}, 51 | {EcRegSig, EcUnregSig}, 52 | {EcRegBug, EcUnregBug}, 53 | }; 54 | 55 | static ErrorCodeSet ec_set[ARRAYSIZE(types)]; 56 | 57 | HMODULE hModCertCli = NULL, hModCertUtil = NULL, hModHttp = NULL, hModNt = NULL, hModKrnl = NULL; 58 | 59 | static void ResLoadAll() 60 | { 61 | LOAD_RES(hModCertCli, TEXT("certca")); 62 | LOAD_RES(hModCertCli, TEXT("certcli")); 63 | LOAD_RES(hModCertUtil, TEXT("certutil.exe")); 64 | LOAD_RES(hModHttp, TEXT("winhttp")); 65 | hModNt = GetModuleHandle(TEXT("ntdll")); 66 | LOAD_RES(hModKrnl, TEXT("ntoskrnl.exe")); 67 | } 68 | 69 | static void ResUnloadAll() 70 | { 71 | FREE_RES(hModCertCli); 72 | FREE_RES(hModCertUtil); 73 | FREE_RES(hModHttp); 74 | hModNt = NULL; 75 | FREE_RES(hModKrnl); 76 | } 77 | 78 | DWORD EcInit(ErrorCodeSet **ppecs) 79 | { 80 | SIZE_T i; 81 | 82 | ResLoadAll(); 83 | 84 | for (i = 0; i < ARRAYSIZE(types); ++i) 85 | { 86 | types[i].pfnreg(&ec_set[i]); 87 | } 88 | 89 | *ppecs = ec_set; 90 | return ARRAYSIZE(types); 91 | } 92 | 93 | void EcUninit() 94 | { 95 | SIZE_T i; 96 | 97 | ResUnloadAll(); 98 | 99 | for (i = 0; i < ARRAYSIZE(types); ++i) 100 | { 101 | types[i].pfnunreg(); 102 | } 103 | } 104 | 105 | LPTSTR MsgFromSys(DWORD dwFlags, LPCVOID lpSource, DWORD dwCode) 106 | { 107 | LPTSTR result = NULL; 108 | 109 | dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS; 110 | if (!FormatMessage(dwFlags, lpSource, dwCode, 0, (LPTSTR)&result, 0, NULL)) 111 | { 112 | result = (LPTSTR)LocalAlloc(LPTR, sizeof(*result)); 113 | } 114 | 115 | return result; 116 | } 117 | 118 | -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | 2 | #define DLG_BORDER 1 3 | 4 | #define IDI_ICONAPP 1 5 | 6 | //#define CLS_LISTVIEWX "ListViewX" 7 | #define VERSION "0.1" 8 | #define VERSION_NUMBER 0,1,0,0 9 | 10 | #define MAX_STRING_LENGTH 64 11 | 12 | #define IDS_HINT_SEARCH 100 13 | #define IDS_HINT_EMPTY 101 14 | #define IDS_HINT_PATH 102 15 | #define IDS_HINT_ID 103 16 | #define IDS_MSDN_URL_FMT 104 17 | #define IDS_S_PREPARING 110 18 | #define IDS_S_DONE 111 19 | #define IDS_S_SEARCHDONE 112 20 | #define IDS_S_ITEMMSG 113 21 | #define IDS_S_COPIED 114 22 | #define IDS_S_EXPORTED 115 23 | #define IDS_MAIN_COLUMN_NAME 120 24 | #define IDS_MAIN_COLUMN_VAL 121 25 | #define IDS_MAIN_COLUMN_SCOPE 122 26 | #define IDS_MAIN_COLUMN_MSG 123 27 | #define IDS_FILTER_ALL 130 28 | #define IDS_FILTER_TEXT 131 29 | #define IDS_FILTER_RES 132 30 | #define IDS_ERR_READ_FMT 140 31 | #define IDS_ERR_READ_NAME 141 32 | #define IDS_ERR_READ_MOD 142 33 | #define IDS_ERR_READ_RES 143 34 | 35 | #define MAIN_MIN_X 150 36 | #define MAIN_MIN_Y 80 37 | #define MAIN_NORMAL_X 500 38 | #define MAIN_NORMAL_Y 350 39 | 40 | #define IDD_MAIN 1000 41 | #define IDC_MAIN_E_SEARCH 1001 42 | #define IDC_MAIN_L_DATA 1002 43 | #define IDC_MAIN_S_BAR 1003 44 | 45 | #define IDD_READ 1100 46 | #define IDC_READ_COMBO 1101 47 | #define IDC_READ_BROWSE 1102 48 | #define IDC_READ_E_ID 1103 49 | #define IDC_READ_READ 1104 50 | #define IDC_READ_G_MSG 1110 51 | #define IDC_READ_E_MSG 1111 52 | #define IDC_READ_G_STR 1120 53 | #define IDC_READ_E_STR 1121 54 | 55 | #define IDD_HELP 1200 56 | #define IDC_HELP_MSG 1201 57 | 58 | #define IDD_ABOUT 1300 59 | #define IDC_ABOUT_ICON 1301 60 | #define IDC_ABOUT_MSG 1302 61 | 62 | #define IDR_MAINMENU 10000 63 | #define ID_MAIN_FILE_READ 10001 64 | #define ID_MAIN_FILE_EXPCUR 10002 65 | #define ID_MAIN_FILE_EXPALL 10003 66 | #define ID_MAIN_VIEW_TOP 10011 67 | #define ID_MAIN_VIEW_ALTCOLOR 10012 68 | #define ID_MAIN_HELP_HELP 10021 69 | #define ID_MAIN_HELP_ABOUT 10022 70 | 71 | #define IDR_CONTEXTMENU 10100 72 | #define ID_CTXMENU_COPYNAME 10101 73 | #define ID_CTXMENU_COPYVAL 10105 74 | #define ID_CTXMENU_COPYSCOPE 10103 75 | #define ID_CTXMENU_COPYDESC 10104 76 | #define ID_CTXMENU_COPYHEX 10102 77 | #define ID_CTXMENU_SEARCH 10106 78 | 79 | -------------------------------------------------------------------------------- /resource.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/killtimer0/ErrorCodeFinder/438f0e9e06e1345b0e5d65ef581a1dbfc884786d/resource.rc -------------------------------------------------------------------------------- /utils.c: -------------------------------------------------------------------------------- 1 | #include "ecf.h" 2 | 3 | #define ARRAY_EXPAND_THRESHOLD 0.5F 4 | 5 | BOOL ArrayInit(TArray *ary, DWORD dwCell, DWORD dwSizeHint) 6 | { 7 | ary->dwCount = 0; 8 | ary->dwCell = dwCell; 9 | ary->dwMaxCount = dwSizeHint ? dwSizeHint : 1; 10 | ary->lpData = (LPVOID)LocalAlloc( 11 | LMEM_FIXED, 12 | ary->dwCell * ary->dwMaxCount 13 | ); 14 | 15 | return NULL != ary->lpData; 16 | } 17 | 18 | void ArrayClear(TArray *ary) 19 | { 20 | LocalFree(ary->lpData); 21 | 22 | ary->lpData = NULL; 23 | ary->dwCell = 0; 24 | ary->dwCount = 0; 25 | ary->dwMaxCount = 0; 26 | } 27 | 28 | LPVOID ArrayFinish(TArray *ary, DWORD *pdwCount) 29 | { 30 | LPVOID lpData = ary->lpData; 31 | DWORD dwSize = ary->dwCell * ary->dwCount; 32 | DWORD dwCount = ary->dwCount; 33 | 34 | ary->lpData = NULL; 35 | ary->dwCell = 0; 36 | ary->dwCount = 0; 37 | ary->dwMaxCount = 0; 38 | 39 | *pdwCount = dwCount; 40 | if (!dwSize) 41 | { 42 | LocalFree(lpData); 43 | return NULL; 44 | } 45 | 46 | /* shrink size */ 47 | LocalReAlloc(lpData, dwSize, 0); 48 | return lpData; 49 | } 50 | 51 | BOOL ArrayAppend(TArray *ary, LPVOID data) 52 | { 53 | /* make sure we have enough space */ 54 | if (ary->dwCount == ary->dwMaxCount) 55 | { 56 | LPVOID p; 57 | DWORD dwMaxCount = ary->dwMaxCount; 58 | 59 | dwMaxCount += (DWORD)(dwMaxCount * ARRAY_EXPAND_THRESHOLD); 60 | if (dwMaxCount <= ary->dwCount) 61 | dwMaxCount = ary->dwCount + 1; 62 | 63 | p = LocalReAlloc( 64 | ary->lpData, 65 | ary->dwCell * dwMaxCount, 66 | LMEM_MOVEABLE 67 | ); 68 | 69 | if (!p) 70 | return FALSE; 71 | 72 | ary->lpData = p; 73 | ary->dwMaxCount = dwMaxCount; 74 | } 75 | 76 | memmove( 77 | (LPVOID)((SIZE_T)ary->lpData + ary->dwCell * ary->dwCount), 78 | data, 79 | ary->dwCell 80 | ); 81 | ++ary->dwCount; 82 | 83 | return TRUE; 84 | } 85 | 86 | static BOOL tciequal(TCHAR c1, TCHAR c2, BOOL bWildcard) 87 | { 88 | TCHAR c = c1; 89 | 90 | if (c1 == c2) 91 | return TRUE; 92 | 93 | if (bWildcard && c2 == TEXT('?')) 94 | return TRUE; 95 | 96 | if (c1 > c2) 97 | c1 = c2, c2 = c; 98 | 99 | return c1 >= TEXT('A') 100 | && c1 <= TEXT('Z') 101 | && c1 + TEXT('a') == c2 + TEXT('A'); 102 | } 103 | 104 | static LPTSTR TcsMatchWildcard(LPCTSTR str, LPCTSTR sub, SIZE_T len) 105 | { 106 | LPTSTR cp = (LPTSTR)str; 107 | LPTSTR s1, s2, end; 108 | 109 | if (!*sub) 110 | return (LPTSTR)str; 111 | 112 | end = (LPTSTR)sub + len; 113 | while (*cp) 114 | { 115 | s1 = cp; 116 | s2 = (LPTSTR)sub; 117 | 118 | while (*s1 && s2 < end && tciequal(*s1, *s2, TRUE)) 119 | ++s1, ++s2; 120 | 121 | if (s2 == end) 122 | return cp; 123 | 124 | ++cp; 125 | } 126 | 127 | return NULL; 128 | } 129 | 130 | BOOL MatchWildCard( 131 | LPCTSTR lpText, 132 | LPCTSTR lpPattern, 133 | DWORD *pdwRanges, 134 | HighlightRange **ppRange 135 | ) 136 | { 137 | LPTSTR str = (LPTSTR)lpText; 138 | LPTSTR pat = (LPTSTR)lpPattern; 139 | LPTSTR p, q, next, s = str; 140 | TArray ary; 141 | HighlightRange range; 142 | BOOL bNoCache = FALSE; 143 | DWORD dwPatLen; 144 | 145 | if (!*pat) 146 | return FALSE; 147 | 148 | if (!ArrayInit(&ary, sizeof (HighlightRange), 1)) 149 | bNoCache = TRUE; 150 | 151 | while (*pat) 152 | { 153 | q = _tcschr(pat, TEXT('*')); 154 | if (q) 155 | { 156 | next = q + 1; 157 | } 158 | else 159 | { 160 | q = _tcschr(pat, TEXT('\0')); 161 | next = q; 162 | } 163 | 164 | dwPatLen = q - pat; 165 | s = TcsMatchWildcard(s, pat, dwPatLen); 166 | 167 | if (!s) 168 | { 169 | if (!bNoCache) 170 | ArrayClear(&ary); 171 | 172 | return FALSE; 173 | } 174 | 175 | range.dwStart = s - lpText; 176 | range.dwEnd = range.dwStart + dwPatLen; 177 | if (!bNoCache) 178 | ArrayAppend(&ary, &range); 179 | 180 | s += dwPatLen; 181 | pat = next; 182 | } 183 | 184 | /* collect search data */ 185 | if (bNoCache) 186 | { 187 | *pdwRanges = 0; 188 | *ppRange = NULL; 189 | } 190 | else 191 | { 192 | *ppRange = (HighlightRange*)ArrayFinish(&ary, pdwRanges); 193 | } 194 | 195 | return TRUE; 196 | } 197 | 198 | static int tcsicmpn(LPCTSTR s, LPCTSTR t, SIZE_T l) 199 | { 200 | SIZE_T i; 201 | 202 | for (i = 0; i < l; ++i) 203 | { 204 | if (!tciequal(s[i], t[i], FALSE)) 205 | return s[i] - t[i]; 206 | } 207 | 208 | return s[l]; 209 | } 210 | 211 | BOOL TcsStartsWith(LPCTSTR p, LPCTSTR q) 212 | { 213 | while (*p && *q) 214 | { 215 | if (!tciequal(*p, *q, FALSE)) 216 | return FALSE; 217 | 218 | ++p, ++q; 219 | } 220 | 221 | return TRUE; 222 | } 223 | 224 | static BOOL FmtFindNextToken( 225 | LPCTSTR fmt, 226 | DWORD *pos, 227 | DWORD *l, 228 | DWORD *r 229 | ) 230 | { 231 | LPCTSTR p = fmt + *pos; 232 | 233 | while (_istspace(*p)) ++p; 234 | if (!*p) return FALSE; 235 | *l = p - fmt; 236 | 237 | while (*p && !_istspace(*p)) ++p; 238 | *r = p - fmt; 239 | 240 | *pos = *r; 241 | return TRUE; 242 | } 243 | 244 | static BOOL FmtParseHexDigit(TCHAR c, DWORD *r) 245 | { 246 | if (c >= TEXT('0') && c <= TEXT('9')) 247 | *r = c - TEXT('0'); 248 | else if (c >= TEXT('A') && c <= TEXT('F')) 249 | *r = c - TEXT('A') + 10; 250 | else if (c >= TEXT('a') && c <= TEXT('f')) 251 | *r = c - TEXT('a') + 10; 252 | else 253 | return FALSE; 254 | 255 | return TRUE; 256 | } 257 | 258 | BOOL FmtParseDword(LPCTSTR fmt, DWORD l, DWORD r, DWORD *dwResult) 259 | { 260 | DWORD i, c, d; 261 | ULONGLONG e; 262 | 263 | /* is 0xXXX? */ 264 | if (r > l + 2 && r <= l + 2 + 8) 265 | { 266 | if (fmt[l] == TEXT('0') && ( 267 | fmt[l + 1] == TEXT('X') 268 | || fmt[l + 1] == TEXT('x') 269 | )) 270 | { 271 | BOOL bHex = TRUE; 272 | 273 | c = 0; 274 | /* from MSB to LSB */ 275 | for (i = l + 2; i < r; ++i) 276 | { 277 | if (FmtParseHexDigit(fmt[i], &d)) 278 | { 279 | c = c << 4 | d; 280 | } 281 | else 282 | { 283 | bHex = FALSE; 284 | break; 285 | } 286 | } 287 | 288 | if (bHex) 289 | { 290 | *dwResult = c; 291 | return TRUE; 292 | } 293 | } 294 | } 295 | 296 | /* is dXXXh? */ 297 | if (r >= l + 2 298 | && r <= l + 1 + 8 + 1 299 | && (fmt[r - 1] == TEXT('H') || fmt[r - 1] == TEXT('h')) 300 | && fmt[l] >= TEXT('0') 301 | && fmt[l] <= TEXT('9') 302 | ) 303 | { 304 | BOOL bHex = TRUE; 305 | 306 | e = 0; 307 | for (i = l; i < r - 1; ++i) 308 | { 309 | if (FmtParseHexDigit(fmt[i], &d)) 310 | { 311 | e = e << 4 | d; 312 | } 313 | else 314 | { 315 | bHex = FALSE; 316 | break; 317 | } 318 | } 319 | 320 | if (bHex && (e >> 32) == 0) 321 | { 322 | *dwResult = e; 323 | return TRUE; 324 | } 325 | } 326 | 327 | /* is [+-]ddd? */ 328 | if (r >= l + 1 && r <= l + 1 + 10) 329 | { 330 | BOOL bSign = FALSE; 331 | BOOL bDone = FALSE; 332 | 333 | if (fmt[l] == TEXT('-')) 334 | { 335 | bSign = TRUE; 336 | ++l; 337 | } 338 | else if (fmt[l] == TEXT('+')) 339 | ++l; 340 | 341 | e = 0; 342 | for (i = l; i < r; ++i) 343 | { 344 | if (fmt[i] >= TEXT('0') && fmt[i] <= TEXT('9')) 345 | { 346 | e = e * 10 + (fmt[i] - TEXT('0')); 347 | } 348 | else 349 | { 350 | bDone = FALSE; 351 | break; 352 | } 353 | 354 | /* at least one digit */ 355 | bDone = TRUE; 356 | } 357 | 358 | if (bDone) 359 | { 360 | if (bSign && e <= 0x80000000ULL) 361 | { 362 | *dwResult = -e; 363 | return TRUE; 364 | } 365 | else if (!bSign && (e >> 32) == 0) 366 | { 367 | *dwResult = e; 368 | return TRUE; 369 | } 370 | } 371 | } 372 | return FALSE; 373 | } 374 | 375 | BOOL FilterFromString(LPCTSTR fmt, SearchFilter *filter) 376 | { 377 | BOOL result = FALSE; 378 | DWORD pos = 0, l, r, i, j; 379 | 380 | filter->dwMask = 0; 381 | filter->dwCode = 0; 382 | filter->dwNameCount = 0; 383 | filter->dwScopeCount = 0; 384 | 385 | result = TRUE; 386 | while (FmtFindNextToken(fmt, &pos, &l, &r)) 387 | { 388 | if (FmtParseDword(fmt, l, r, &filter->dwCode)) 389 | filter->dwMask |= SFM_CODE; 390 | else 391 | { 392 | BOOL bExist = FALSE; 393 | 394 | /* keywords prefixed with ':' are resolved to scopes */ 395 | if (fmt[l] == TEXT(':')) 396 | { 397 | filter->dwMask |= SFM_SCOPE; 398 | ++l; 399 | 400 | /* is the keyword in scope? */ 401 | for (i = 0; i < necs; ++i) 402 | { 403 | if (!tcsicmpn(pecs[i].lpName, fmt + l, r - l)) 404 | { 405 | if (filter->dwScopeCount < SF_MAX_NAMES) 406 | { 407 | for (j = 0; j < filter->dwScopeCount; ++j) 408 | { 409 | if (filter->dwScopes[j] == i) 410 | { 411 | bExist = TRUE; 412 | break; 413 | } 414 | } 415 | if (!bExist) 416 | { 417 | filter->dwScopes[filter->dwScopeCount++] = i; 418 | } 419 | } 420 | break; 421 | } 422 | } 423 | } 424 | else 425 | { 426 | /* it's a pattern for names */ 427 | if (filter->dwNameCount < SF_MAX_NAMES) 428 | { 429 | if (l < r) 430 | { 431 | for (i = 0; i < filter->dwNameCount; ++i) 432 | { 433 | if (!_tcsnicmp(filter->lpNames[i], fmt + l, r - l)) 434 | { 435 | bExist = TRUE; 436 | break; 437 | } 438 | } 439 | 440 | if (!bExist) 441 | { 442 | LPTSTR lpName = 443 | (LPTSTR)LocalAlloc(LPTR, (r - l + 1) * sizeof (TCHAR)); 444 | if (lpName) 445 | { 446 | memmove(lpName, fmt + l, (r - l) * sizeof (TCHAR)); 447 | lpName[r - l] = TEXT('\0'); 448 | filter->lpNames[filter->dwNameCount++] = lpName; 449 | filter->dwMask |= SFM_NAME; 450 | } 451 | } 452 | } 453 | } 454 | } 455 | } 456 | } 457 | 458 | return result; 459 | } 460 | 461 | void FilterClear(SearchFilter *filter) 462 | { 463 | DWORD dwNameCount, i; 464 | 465 | dwNameCount = filter->dwNameCount; 466 | 467 | for (i = 0; i < dwNameCount; ++i) 468 | { 469 | LocalFree(filter->lpNames[i]); 470 | filter->lpNames[i] = NULL; 471 | } 472 | 473 | filter->dwMask = 0; 474 | filter->dwCode = 0; 475 | filter->dwNameCount = 0; 476 | filter->dwScopeCount = 0; 477 | } 478 | 479 | COLORREF BlendColor(COLORREF color) 480 | { 481 | BYTE r = (color >> 0) & 0xFF; 482 | BYTE g = (color >> 8) & 0xFF; 483 | BYTE b = (color >> 16) & 0xFF; 484 | BYTE a = (color >> 24) & 0xFF; 485 | 486 | if (a) 487 | return color; 488 | else 489 | return RGB( 490 | r * (1 - ALTALPHABK) + 0x80 * ALTALPHABK, 491 | g * (1 - ALTALPHABK) + 0x80 * ALTALPHABK, 492 | b * (1 - ALTALPHABK) + 0x80 * ALTALPHABK 493 | ); 494 | } 495 | 496 | --------------------------------------------------------------------------------