{"id":7443,"date":"2023-10-16T15:45:26","date_gmt":"2023-10-16T07:45:26","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=7443"},"modified":"2023-10-16T15:45:26","modified_gmt":"2023-10-16T07:45:26","slug":"masm%e7%94%9f%e6%88%90exe%e6%96%87%e4%bb%b6%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/10\/16\/masm%e7%94%9f%e6%88%90exe%e6%96%87%e4%bb%b6%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9%ef%bc%9f\/","title":{"rendered":"masm\u751f\u6210exe\u6587\u4ef6\u6ce8\u610f\u4e8b\u9879\uff1f"},"content":{"rendered":"

MASM\u662f\u4e00\u79cd\u6c47\u7f16\u8bed\u8a00\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u751f\u6210\u53ef\u6267\u884c\u7684exe\u6587\u4ef6\u3002MASM\u7684\u751f\u6210e\u60f3\u505a\u4e00\u6b3epc\u8f6f\u4ef6<\/a>xe\u6587\u4ef6\u7684\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n

1. \u7f16\u5199\u6c47\u7f16\u4ee3\u7801<\/p>\n

\u9996\u5148\uff0c\u9700\u8981\u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u3002\u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u7684\u76ee\u7684\u662f\u5b9e\u73b0\u7a0b\u5e8f\u7684\u529f\u80fd\u3002MASM\u652f\u6301x86\u67b6\u6784\u7684\u6c47\u7f16\u8bed\u8a00\uff0c\u53ef\u4ee5\u4f7f\u7528\u5927\u91cf\u7684\u6307\u4ee4\u548c\u64cd\u4f5c\u7b26\uff0c\u5b9e\u73b0\u590d\u6742\u7684\u64cd\u4f5c\u3002\u7f16\u5199\u597d\u7684\u6c47\u7f16\u4ee3\u7801\u9700\u8981\u4fdd\u5b58\u4e3a.asm\u6587\u4ef6\u3002<\/p>\n

\u7535\u8111\u6027\u80fd\u6d4b\u8bd5\u8f6f\u4ef6\u6253\u5305<\/a>2. \u6c47\u7f16\u4ee3\u7801\u8f6c\u6362\u4e3a\u76ee\u6807\u6587\u4ef6<\/p>\n

\u5c06\u7f16\u5199\u597d\u7684\u6c47\u7f16\u4ee3\u7801\u8f6c\u6362\u4e3a\u76ee\u6807\u6587\u4ef6\u3002\u5728<\/p>\n

<\/figure>\n<\/p>\n

Windows\u5e73\u53f0\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528MASM\u81ea\u5e26\u7684ml.exe\u5de5\u5177\u6765\u5b8c\u6210\u8fd9\u4e00\u6b65\u9aa4\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06.asm\u6587\u4ef6\u8f6c\u6362\u4e3a.obj\u6587\u4ef6\uff1a<\/p>\n

“`<\/p>\n

ml \/c \/coff source.asm<\/p>\n

“`<\/p>\n

\u5176\u4e2d\uff0c\/c\u9009\u9879\u8868\u793a\u53ea\u7f16\u8bd1\u4e0d\u94fe\u63a5\uff0c\/coff\u9009\u9879\u8868\u793a\u751f\u6210COFF\u683c\u5f0f\u7684\u76ee\u6807\u6587\u4ef6\u3002\u751f\u6210\u7684.obj\u6587\u4ef6\u5305\u542b\u4e86\u6c47\u7f16\u4ee3\u7801\u7684\u673a\u5668\u8bed\u8a00\u6307\u4ee4\u548c\u6570\u636e\u3002<\/p>\n

3. \u76ee\u6807\u6587\u4ef6\u94fe\u63a5<\/p>\n

\u76ee\u6807\u6587\u4ef6\u5305\u542b\u4e86\u6c47\u7f16\u4ee3\u7801\u7684\u673a\u5668\u8bed\u8a00\u6307\u4ee4\u548c\u6570\u636e\uff0c\u4f46\u662f\u8fd8\u9700\u8981\u94fe\u63a5\u5176\u4ed6\u7684\u5e93\u6587\u4ef6\u624d\u80fd\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5728Windows\u5e73\u53f0\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528MASM\u81ea\u5e26\u7684link.exe\u5de5\u5177\u6765\u5b8c\u6210\u8fd9\u4e00\u6b65\u9aa4\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06.obj\u6587\u4ef6\u94fe\u63a5\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\uff1a<\/p>\n

“`<\/p>\n

link \/subsystem:windows \/entry:start source.obj kernel32.lib user32.lib<\/p>\n

“`<\/p>\n

\u5176\u4e2d\uff0c\/subsystem:windows\u9009\u9879\u8868\u793a\u751f\u6210Windows\u5b50\u7cfb\u7edf\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff0c\/entry:start\u9009\u9879\u8868\u793a\u7a0b\u5e8f\u7684\u5165\u53e3\u5730\u5740\u4e3astart\u6807\u7b7e\u6240\u5728\u7684\u5730\u5740\uff0ckernel32.lib\u548cuser32.lib\u662fWindows API\u7684\u5e93\u6587\u4ef6\u3002\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u5305\u542b\u4e86\u6c47\u7f16\u4ee3\u7801\u548cWindows API\u7684\u51fd\u6570\u8c03\u7528\u3002<\/p>\n

4. \u8fd0\u884c\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n

\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\u540e\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u8be5\u6587\u4ef6\uff0c\u6267\u884c\u7a0b\u5e8f\u7684\u529f\u80fd\u3002\u5728Windows\u5e73\u53f0\u4e0a\uff0c\u53ef\u4ee5\u53cc\u51fb\u53ef\u6267\u884c\u6587\u4ef6\u6216\u8005\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884c\u3002<\/p>\n

\u4ee5\u4e0a\u5c31\u662fMASM\u751f\u6210exe\u6587\u4ef6\u7684\u8fc7\u7a0b\u3002\u901a\u8fc7\u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u3001\u8f6c\u6362\u4e3a\u76ee\u6807\u6587\u4ef6\u3001\u94fe\u63a5\u5176\u4ed6\u5e93\u6587\u4ef6\u548c\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u53ef\u4ee5\u5b9e\u73b0\u6c47\u7f16\u4ee3\u7801\u7684\u529f\u80fd\uff0c\u5e76\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002MASM\u7684\u751f\u6210exe\u6587\u4ef6\u7684\u8fc7\u7a0b\u76f8\u5bf9\u4e8e\u5176\u4ed6\u8bed\u8a00\u6765\u8bf4\uff0c\u66f4\u52a0\u5e95\u5c42\uff0c\u9700\u8981\u624b\u52a8\u7ba1\u7406\u5185\u5b58\u548c\u5bc4\u5b58\u5668\u7b49\u786c\u4ef6\u8d44\u6e90\uff0c\u4f46\u662f\u53ef\u4ee5\u66f4\u52a0\u7cbe\u7ec6\u5730\u63a7\u5236\u7a0b\u5e8f\u7684\u6267\u884c\u8fc7\u7a0b\uff0c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

MASM\u662f\u4e00\u79cd\u6c47\u7f16\u8bed\u8a00\uff0c\u5b83\u53ef\u4ee5\u7528\u6765\u751f\u6210\u53ef\u6267\u884c\u7684exe\u6587\u4ef6\u3002MASM\u7684\u751f\u6210exe\u6587\u4ef6\u7684\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a1. \u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u9996\u5148\uff0c\u9700\u8981\u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u3002\u7f16\u5199\u6c47\u7f16\u4ee3\u7801\u7684\u76ee\u7684\u662f\u5b9e\u73b0\u7a0b\u5e8f\u7684\u529f\u80fd\u3002MASM<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[13073,38,2654,24,12],"topic":[],"class_list":["post-7443","post","type-post","status-publish","format-standard","hentry","category-zhuomianruanjian","tag-windows","tag-38","tag-exe","tag-24","tag-12"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/7443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=7443"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/7443\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=7443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=7443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=7443"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=7443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}