diff --git a/include/retdec/fileformat/file_format/pe/pe_format.h b/include/retdec/fileformat/file_format/pe/pe_format.h index 9390dcbfc..c3d6f0d87 100644 --- a/include/retdec/fileformat/file_format/pe/pe_format.h +++ b/include/retdec/fileformat/file_format/pe/pe_format.h @@ -44,7 +44,6 @@ class PeFormat : public FileFormat std::string typeRefHashSha256; ///< .NET typeref table hash as SHA256 VisualBasicInfo visualBasicInfo; ///< visual basic header information - static const std::unordered_set defDllList; ///< Default set of DLLs for checking dependency missing std::unordered_set dllList; ///< Override set of DLLs for checking dependency missing bool errorLoadingDllList; ///< If true, then an error happened while loading DLL list @@ -75,6 +74,7 @@ class PeFormat : public FileFormat void loadResources(); void loadCertificates(); void loadTlsInformation(); + static bool checkDefaultList(std::string_view); /// @} /// @name .NET methods diff --git a/src/fileformat/file_format/pe/pe_dll_list.cpp b/src/fileformat/file_format/pe/pe_dll_list.cpp index ab1118d04..f62cc91fc 100644 --- a/src/fileformat/file_format/pe/pe_dll_list.cpp +++ b/src/fileformat/file_format/pe/pe_dll_list.cpp @@ -4,20 +4,11 @@ #include "retdec/utils/conversion.h" #include "retdec/utils/scope_exit.h" #include "retdec/utils/string.h" +#include +#include -/** - * @file src/fileformat/file_format/pe/pe_dll_list.cpp - * @brief List of DLL modules for evaluating missing dependencies - * @copyright (c) 2017 Avast Software, licensed under the MIT license - */ - -namespace retdec { -namespace fileformat { - -// This list was obtained from Windows 10 build 17763 (Redstone 5) -// Keep it converted to lowerspace for speedup -const std::unordered_set PeFormat::defDllList -{ +// make sure this list is sorted by ASCII values +constexpr static std::string_view defDllList[] = { "7z.dll", "aadauthhelper.dll", "aadcloudap.dll", @@ -327,6 +318,24 @@ const std::unordered_set PeFormat::defDllList "cflapi.dll", "cfmifs.dll", "cfmifsproxy.dll", + "chakra.dll", + "chakradiag.dll", + "chakrathunk.dll", + "chartv.dll", + "chatapis.dll", + "chkwudrv.dll", + "chsstrokeds.dll", + "chtadvancedds.dll", + "chtbopomofods.dll", + "chtcangjieds.dll", + "chthkstrokeds.dll", + "chtquickds.dll", + "chxapds.dll", + "chxdecoder.dll", + "chxhapds.dll", + "chxinputrouter.dll", + "chxranker.dll", + "chxreadingstringime.dll", "ci.dll", "cic.dll", "cimwin32.dll", @@ -468,8 +477,6 @@ const std::unordered_set PeFormat::defDllList "d2d1.dll", "d2d1debug2.dll", "d2d1debug3.dll", - "d3d9.dll", - "d3dx9_26.dll", "d3d10.dll", "d3d10_1.dll", "d3d10_1core.dll", @@ -492,7 +499,6 @@ const std::unordered_set PeFormat::defDllList "d3d9.dll", "d3d9on12.dll", "d3dcompiler_47.dll", - "d3dcompiler_47.dll", "d3dim.dll", "d3dim700.dll", "d3dramp.dll", @@ -551,8 +557,8 @@ const std::unordered_set PeFormat::defDllList "ddores.dll", "ddp_ps.dll", "ddpa64.dll", - "ddpd64a.dll", "ddpchunk.dll", + "ddpd64a.dll", "ddpo64a.dll", "ddpp64a.dll", "ddptrace.dll", @@ -971,7 +977,6 @@ const std::unordered_set PeFormat::defDllList "framedynos.dll", "frameserver.dll", "frameworkperf.dll", - "frameworkperf.dll", "frprov.dll", "fsclient.dll", "fsutilext.dll", @@ -1127,24 +1132,6 @@ const std::unordered_set PeFormat::defDllList "hvsigpext.dll", "hvsocket.dll", "hydrogen.dll", - "chakra.dll", - "chakradiag.dll", - "chakrathunk.dll", - "chartv.dll", - "chatapis.dll", - "chkwudrv.dll", - "chsstrokeds.dll", - "chtadvancedds.dll", - "chtbopomofods.dll", - "chtcangjieds.dll", - "chthkstrokeds.dll", - "chtquickds.dll", - "chxapds.dll", - "chxdecoder.dll", - "chxhapds.dll", - "chxinputrouter.dll", - "chxranker.dll", - "chxreadingstringime.dll", "ias.dll", "iasacct.dll", "iasads.dll", @@ -1290,20 +1277,10 @@ const std::unordered_set PeFormat::defDllList "jsproxy.dll", "kaaport64.dll", "kbd101.dll", - "kbd101.dll", - "kbd101.dll", - "kbd101a.dll", "kbd101a.dll", - "kbd101a.dll", - "kbd101a.dll", - "kbd101b.dll", "kbd101b.dll", - "kbd101b.dll", - "kbd101c.dll", "kbd101c.dll", "kbd103.dll", - "kbd103.dll", - "kbd103.dll", "kbd106.dll", "kbd106n.dll", "kbda1.dll", @@ -1331,6 +1308,8 @@ const std::unordered_set PeFormat::defDllList "kbdbulg.dll", "kbdca.dll", "kbdcan.dll", + "kbdcher.dll", + "kbdcherp.dll", "kbdcr.dll", "kbdcz.dll", "kbdcz1.dll", @@ -1374,9 +1353,6 @@ const std::unordered_set PeFormat::defDllList "kbdhept.dll", "kbdhu.dll", "kbdhu1.dll", - "kbdcher.dll", - "kbdcherp.dll", - "kbdibm02.dll", "kbdibm02.dll", "kbdibo.dll", "kbdic.dll", @@ -1430,14 +1406,8 @@ const std::unordered_set PeFormat::defDllList "kbdmyan.dll", "kbdne.dll", "kbdnec.dll", - "kbdnec.dll", - "kbdnec.dll", - "kbdnec.dll", - "kbdnec95.dll", "kbdnec95.dll", "kbdnecat.dll", - "kbdnecat.dll", - "kbdnecnt.dll", "kbdnecnt.dll", "kbdnepr.dll", "kbdnko.dll", @@ -1446,8 +1416,8 @@ const std::unordered_set PeFormat::defDllList "kbdnso.dll", "kbdntl.dll", "kbdogham.dll", - "kbdoldit.dll", "kbdolch.dll", + "kbdoldit.dll", "kbdosm.dll", "kbdpash.dll", "kbdphags.dll", @@ -1694,27 +1664,26 @@ const std::unordered_set PeFormat::defDllList "mfasfsrcsnk.dll", "mfaudiocnv.dll", "mfc100.dll", + "mfc100chs.dll", + "mfc100cht.dll", "mfc100d.dll", - "mfc100u.dll", - "mfc100ud.dll", "mfc100deu.dll", "mfc100enu.dll", "mfc100esn.dll", "mfc100fra.dll", - "mfc100chs.dll", - "mfc100cht.dll", "mfc100ita.dll", "mfc100jpn.dll", "mfc100kor.dll", "mfc100rus.dll", "mfc100u.dll", + "mfc100ud.dll", "mfc110.dll", + "mfc110chs.dll", + "mfc110cht.dll", "mfc110deu.dll", "mfc110enu.dll", "mfc110esn.dll", "mfc110fra.dll", - "mfc110chs.dll", - "mfc110cht.dll", "mfc110ita.dll", "mfc110jpn.dll", "mfc110kor.dll", @@ -1722,13 +1691,13 @@ const std::unordered_set PeFormat::defDllList "mfc110u.dll", "mfc110ud.dll", "mfc120.dll", + "mfc120chs.dll", + "mfc120cht.dll", "mfc120d.dll", "mfc120deu.dll", "mfc120enu.dll", "mfc120esn.dll", "mfc120fra.dll", - "mfc120chs.dll", - "mfc120cht.dll", "mfc120ita.dll", "mfc120jpn.dll", "mfc120kor.dll", @@ -1736,13 +1705,13 @@ const std::unordered_set PeFormat::defDllList "mfc120u.dll", "mfc120ud.dll", "mfc140.dll", + "mfc140chs.dll", + "mfc140cht.dll", "mfc140d.dll", "mfc140deu.dll", "mfc140enu.dll", "mfc140esn.dll", "mfc140fra.dll", - "mfc140chs.dll", - "mfc140cht.dll", "mfc140ita.dll", "mfc140jpn.dll", "mfc140kor.dll", @@ -1923,8 +1892,8 @@ const std::unordered_set PeFormat::defDllList "mrmcorer.dll", "mrmdeploy.dll", "mrmindexer.dll", - "mrt_map.dll", "mrt100.dll", + "mrt_map.dll", "ms3dthumbnailprovider.dll", "msaatext.dll", "msac3enc.dll", @@ -1969,8 +1938,8 @@ const std::unordered_set PeFormat::defDllList "msdtcuiu.dll", "msdtcvsp1res.dll", "msdtcwmi.dll", - "msexcl40.dll", "msexch40.dll", + "msexcl40.dll", "msfeeds.dll", "msfeedsbs.dll", "msflacdecoder.dll", @@ -2051,23 +2020,22 @@ const std::unordered_set PeFormat::defDllList "msv1_0.dll", "msvbvm60.dll", "msvcirt.dll", - "msvcp_win.dll", "msvcm80.dll", "msvcm90.dll", "msvcp100.dll", "msvcp100d.dll", "msvcp110.dll", - "msvcp110d.dll", "msvcp110_win.dll", + "msvcp110d.dll", "msvcp120.dll", - "msvcp120d.dll", "msvcp120_clr0400.dll", + "msvcp120d.dll", "msvcp140.dll", - "msvcp140d.dll", "msvcp140_1.dll", "msvcp140_1d.dll", "msvcp140_2.dll", "msvcp140_2d.dll", + "msvcp140d.dll", "msvcp50.dll", "msvcp50d.dll", "msvcp60.dll", @@ -2080,14 +2048,15 @@ const std::unordered_set PeFormat::defDllList "msvcp80d.dll", "msvcp90.dll", "msvcp90d.dll", + "msvcp_win.dll", "msvcr100.dll", - "msvcr100d.dll", "msvcr100_clr0400.dll", + "msvcr100d.dll", "msvcr110.dll", "msvcr110d.dll", "msvcr120.dll", - "msvcr120d.dll", "msvcr120_clr0400.dll", + "msvcr120d.dll", "msvcr70.dll", "msvcr70d.dll", "msvcr71.dll", @@ -2097,9 +2066,9 @@ const std::unordered_set PeFormat::defDllList "msvcr90.dll", "msvcr90d.dll", "msvcrt.dll", - "msvcrtd.dll", "msvcrt20.dll", "msvcrt40.dll", + "msvcrtd.dll", "msvfw32.dll", "msvidc32.dll", "msvidctl.dll", @@ -2131,6 +2100,7 @@ const std::unordered_set PeFormat::defDllList "msys-brotlidec-1.dll", "msys-brotlienc-1.dll", "msys-bz2-1.dll", + "msys-charset-1.dll", "msys-cilkrts-5.dll", "msys-com_err-1.dll", "msys-crypt-0.dll", @@ -2171,7 +2141,6 @@ const std::unordered_set PeFormat::defDllList "msys-history7.dll", "msys-hogweed-4.dll", "msys-hx509-5.dll", - "msys-charset-1.dll", "msys-iconv-2.dll", "msys-icudata62.dll", "msys-icui18n62.dll", @@ -2476,8 +2445,8 @@ const std::unordered_set PeFormat::defDllList "ole2nls.dll", "ole32.dll", "oleacc.dll", - "oleaccrc.dll", "oleacchooks.dll", + "oleaccrc.dll", "oleaut32.dll", "olecli32.dll", "oledlg.dll", @@ -2686,9 +2655,9 @@ const std::unordered_set PeFormat::defDllList "pyshellext.amd64.dll", "python27.dll", "python3.dll", - "python3_d.dll", "python37.dll", "python37_d.dll", + "python3_d.dll", "qasf.dll", "qcap.dll", "qdv.dll", @@ -2718,13 +2687,13 @@ const std::unordered_set PeFormat::defDllList "rasadhlp.dll", "rasapi32.dll", "rasauto.dll", + "raschap.dll", + "raschapext.dll", "rasctrs.dll", "rascustom.dll", "rasdiag.dll", "rasdlg.dll", "rasgcw.dll", - "raschap.dll", - "raschapext.dll", "rasman.dll", "rasmans.dll", "rasmbmgr.dll", @@ -2788,9 +2757,9 @@ const std::unordered_set PeFormat::defDllList "retdec-libelf.dll", "rfxvmt.dll", "rgb9rast.dll", - "ricu0ilm.dll", "riched20.dll", "riched32.dll", + "ricu0ilm.dll", "rilproxy.dll", "rjvmdmconfig.dll", "rmapi.dll", @@ -2803,12 +2772,12 @@ const std::unordered_set PeFormat::defDllList "rp3daa64.dll", "rp3dht64.dll", "rpcepmap.dll", + "rpchttp.dll", "rpcns4.dll", "rpcnsh.dll", "rpcrt4.dll", "rpcrtremote.dll", "rpcss.dll", - "rpchttp.dll", "rsaenh.dll", "rshx32.dll", "rstrtmgr.dll", @@ -2855,12 +2824,17 @@ const std::unordered_set PeFormat::defDllList "scdeviceenum.dll", "scecli.dll", "scesrv.dll", + "schannel.dll", + "schedcli.dll", + "schedprov.dll", + "schedsvc.dll", "scilexer.dll", "scksp.dll", "scripto.dll", "scrobj.dll", "scrptadm.dll", "scrrun.dll", + "scsiport.sys", "sdcpl.dll", "sdds.dll", "sdengin2.dll", @@ -2875,6 +2849,7 @@ const std::unordered_set PeFormat::defDllList "search.protocolhandler.mapi2.dll", "searchfolder.dll", "sebbackgroundmanagerpolicy.dll", + "sechost.dll", "seclogon.dll", "secproc.dll", "secproc_isv.dll", @@ -2890,7 +2865,6 @@ const std::unordered_set PeFormat::defDllList "securityhealthagent.dll", "securityhealthproxystub.dll", "securityhealthsso.dll", - "sechost.dll", "semgrps.dll", "semgrsvc.dll", "semgrsvcpal.dll", @@ -3002,11 +2976,6 @@ const std::unordered_set PeFormat::defDllList "shutdownext.dll", "shutdownux.dll", "shwebsvc.dll", - "schannel.dll", - "schedcli.dll", - "schedprov.dll", - "schedsvc.dll", - "scsiport.sys", "signdrv.dll", "simauth.dll", "simcfg.dll", @@ -3084,12 +3053,12 @@ const std::unordered_set PeFormat::defDllList "sqlwid.dll", "sqlwoa.dll", "sqmapi.dll", + "srchadmin.dll", "srclient.dll", "srcore.dll", "srevents.dll", "srh.dll", "srhelper.dll", - "srchadmin.dll", "srm.dll", "srm_ps.dll", "srmclient.dll", @@ -3444,10 +3413,6 @@ const std::unordered_set PeFormat::defDllList "vm3dum-debug.dll", "vm3dum-stats.dll", "vm3dum.dll", - "vm3dum_10-debug.dll", - "vm3dum_10-stats.dll", - "vm3dum_10.dll", - "vm3dum_loader.dll", "vm3dum64-debug.dll", "vm3dum64-stats.dll", "vm3dum64.dll", @@ -3455,9 +3420,13 @@ const std::unordered_set PeFormat::defDllList "vm3dum64_10-stats.dll", "vm3dum64_10.dll", "vm3dum64_loader.dll", + "vm3dum_10-debug.dll", + "vm3dum_10-stats.dll", + "vm3dum_10.dll", + "vm3dum_loader.dll", "vmapplicationhealthmonitorproxy.dll", - "vmbuspipe.dll", "vmbkmcl.sys", + "vmbuspipe.dll", "vmdevicehost.dll", "vmguestlib.dll", "vmguestlibjava.dll", @@ -3481,7 +3450,6 @@ const std::unordered_set PeFormat::defDllList "vscmgrps.dll", "vscover140.dll", "vscover150.dll", - "vscover150.dll", "vsd3drefdebug.dll", "vsd3dwarpdebug.dll", "vsgraphicscapture.dll", @@ -3542,8 +3510,8 @@ const std::unordered_set PeFormat::defDllList "wdscore.dll", "webauthn.dll", "webcamui.dll", - "webclnt.dll", "webcheck.dll", + "webclnt.dll", "webio.dll", "webplatstorageserver.dll", "webruntimemanager.dll", @@ -4003,10 +3971,10 @@ const std::unordered_set PeFormat::defDllList "wpnsruprov.dll", "wpnuserservice.dll", "wpportinglibrary.dll", + "wpprecorder.sys", "wpprecorderum.dll", "wptaskscheduler.dll", "wpx.dll", - "wpprecorder.sys", "ws2_32.dll", "ws2help.dll", "wscapi.dll", @@ -4118,5 +4086,13 @@ const std::unordered_set PeFormat::defDllList "ztrace_maps.dll", }; +namespace retdec { +namespace fileformat { + +bool PeFormat::checkDefaultList(std::string_view name) { + return std::binary_search(std::begin(defDllList), std::end(defDllList), name); +} + } // namespace retdec } // namespace fileformat + diff --git a/src/fileformat/file_format/pe/pe_format.cpp b/src/fileformat/file_format/pe/pe_format.cpp index 305c877ad..9baedd4fb 100644 --- a/src/fileformat/file_format/pe/pe_format.cpp +++ b/src/fileformat/file_format/pe/pe_format.cpp @@ -3548,8 +3548,11 @@ bool PeFormat::isMissingDependency(std::string dllName) const // If we have overriden set, use that one. // Otherwise, use the default DLL set - const std::unordered_set & depsDllList = (dllList.size() != 0) ? dllList : defDllList; - return (depsDllList.count(dllName) == 0); + if (std::empty(dllList)) { + return checkDefaultList(dllName); + } else { + return dllList.find(dllName) != dllList.end(); + } } /**