{"id":827,"date":"2014-10-09T15:10:31","date_gmt":"2014-10-09T07:10:31","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=827"},"modified":"2014-10-09T15:16:12","modified_gmt":"2014-10-09T07:16:12","slug":"%e8%8e%b7%e5%8f%96%e5%8a%a8%e6%80%81%e9%93%be%e6%8e%a5%e5%ba%93%e5%9c%a8%e8%bf%9b%e7%a8%8b%e4%b8%ad%e7%9a%84%e5%8a%a0%e8%bd%bd%e5%9c%b0%e5%9d%80","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=827","title":{"rendered":"\u83b7\u53d6\u52a8\u6001\u94fe\u63a5\u5e93\u5728\u8fdb\u7a0b\u4e2d\u7684\u52a0\u8f7d\u5730\u5740"},"content":{"rendered":"<p>\u6211\u4eec\u77e5\u9053\uff0cWindows\u4e0bDLL\u88ab\u52a0\u8f7d\u5230\u8fdb\u7a0b\u4e2d\u65f6\uff0c\u53ef\u80fd\u53d1\u751f\u5730\u5740\u51b2\u7a81\u800c\u88ab\u91cd\u5b9a\u4f4d\uff0c\u90a3\u4e48\u6211\u4eec\u5982\u4f55\u83b7\u53d6\u8fd9\u4e9b\u8fdb\u7a0b\u7684\u91cd\u5b9a\u4f4d\u5730\u5740\u5462\uff1f\u5b9e\u9645\u4e0a\u5f88\u7b80\u5355\uff0c\u901a\u8fc7GetModuleHandle\u51fd\u6570\u53ef\u4ee5\u83b7\u53d6\u5230\u5df2\u7ecf\u88ab\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u7684DLL\u6620\u50cf\u7684\u53e5\u67c4\uff0c\u8fd9\u4e2a\u53e5\u67c4\u7684\u503c\u5c31\u662fDLL\u88ab\u52a0\u8f7d\u7684\u6620\u50cf\u57fa\u51c6\u5730\u5740\u3002\u8981\u5217\u4e3e\u51fa\u6240\u6709\u7684\u6a21\u5757\u6620\u50cf\u52a0\u8f7d\u5730\u5740\uff0c\u7528EnumProcessModules\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u4e0b\u9762\u5f15\u7528QMapSymbols\u4e2d\u7684\u4e00\u6bb5\u4ee3\u7801\u7ed9\u5927\u5bb6\u53c2\u8003\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">  var\r\n    AHandles: array of THandle;\r\n    ACount: Cardinal;\r\n    I, J: Integer;\r\n    AMapFile: TQSymbolMapFile;\r\n    AFile: TFileStream;\r\n    AImports: TStringList;\r\n  begin\r\n  \/\/ \u679a\u4e3e\u5df2\u52a0\u8f7d\u52a8\u6001\u94fe\u63a5\u5e93\u5bfc\u5165\u51fd\u6570\r\n  ACount := 0;\r\n  EnumProcessModules(GetCurrentProcess, nil, 0, ACount);\r\n  SetLength(AHandles, ACount);\r\n  if EnumProcessModules(GetCurrentProcess, @AHandles[0], ACount, ACount) then\r\n    begin\r\n    for I := 0 to ACount - 1 do\r\n      begin\r\n      if (AHandles[I] &lt;&gt; 0) and (AHandles[I] &lt;&gt; MainInstance) then\r\n        begin\r\n        \/\/\u6b64\u65f6\uff0cAHandles\u5217\u8868\u5c31\u662f\u6bcf\u4e2aDLL\u7684\u5b9e\u9645\u52a0\u8f7d\u5730\u5740\uff0c\u7528GetModuleFileName\u51fd\u6570\u5c31\u53ef\u4ee5\u83b7\u53d6\u5230\u53e5\u67c4\u5bf9\u5e94\u7684\u6587\u4ef6\u540d\r\n        end;\r\n      end;\r\n...<\/pre>\n<p>QMapSymbols\u4e3a\u4e86\u5b9e\u73b0DLL\u4e2d\u5bfc\u51fa\u51fd\u6570\u540d\u7684\u6620\u5c04\uff0c\u8fd8\u52a0\u5165\u4e86\u4e00\u4e9b\u4ee3\u7801\u6765\u89e3\u6790PE\u683c\u5f0f\uff0c\u4ece\u4e2d\u83b7\u53d6\u6620\u50cf\u7684\u4ee3\u7801\u6bb5\u504f\u79fb\u548c\u4ee3\u7801\u6bb5\u5927\u5c0f\uff0c\u5b9e\u9645\u7684\u4ee3\u7801\u6bb5\u8d77\u59cb\u5730\u5740\uff0c\u662f\u6a21\u5757\u53e5\u67c4\u5730\u5740+\u4ee3\u7801\u6bb5\u504f\u79fb\uff0c\u8fd9\u6837\u5b50\u5c31\u53ef\u4ee5\u5f97\u5230\u7279\u5b9a\u7684DLL\u4ee3\u7801\u5728\u5185\u5b58\u4e2d\u7684\u5206\u5e03\u5730\u5740\u8303\u56f4\u4e3a\uff1a<\/p>\n<p>\u6a21\u5757\u53e5\u67c4\u503c+\u4ee3\u7801\u6bb5\u504f\u79fb ~ \u6a21\u5757\u53e5\u67c4\u503c+\u4ee3\u7801\u6bb5\u504f\u79fb+\u4ee3\u7801\u6bb5\u5927\u5c0f<\/p>\n<p>\u7136\u540e\u6211\u4eec\u518d\u4ecePE\u6587\u4ef6\u5934\u90e8\u4e2d\u8bfb\u53d6\u5bfc\u5165\u51fd\u6570\u5217\u8868\uff0c\u7136\u540e\u5c06\u5bfc\u5165\u51fd\u6570\u5730\u5740\u4fdd\u5b58\u8d77\u6765\uff0c\u4ee5\u4fbf\u4e0e\u8bf7\u6c42\u7684\u5730\u5740\u8fdb\u884c\u6bd4\u8f83\u5c31\u53ef\u4ee5\u77e5\u9053\u4ee3\u7801\u6765\u81ea\u90a3\u4e2a\u51fd\u6570\u3002\u5177\u4f53\u4ee3\u7801\u53c2\u8003LoadPEImports\u548cReadImports\u51fd\u6570\uff0c\u4e3b\u8981\u5176\u4e2d\u7275\u6d89\u5230\u865a\u62df\u5730\u5740\u5230\u6587\u4ef6\u504f\u79fb\u5730\u5740\u7684\u8ba1\u7b97\uff0c\u6709\u70b9\u5c0f\u95f9\u5fc3\uff0c\u597d\u5728\u89e3\u51b3\u6389\u4e86\uff0c\u4f7f\u7528\u7684\u7b97\u6cd5\u662f\u76f4\u63a5\u7528IMAGE_SECTION_HEADER\u7684PointerToRawData &#8211; VirtualAddress\u503c\u505a\u4e3a\u504f\u79fb\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u77e5\u9053\uff0cWindows\u4e0bDLL\u88ab\u52a0\u8f7d\u5230 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[69,8],"tags":[30,77],"class_list":["post-827","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","tag-dll","tag-map"],"views":5146,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=827"}],"version-history":[{"count":4,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/827\/revisions"}],"predecessor-version":[{"id":831,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/827\/revisions\/831"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}