{"id":57,"date":"2008-10-14T17:34:50","date_gmt":"2008-10-14T17:34:50","guid":{"rendered":"http:\/\/kumouse.aafox.com\/?p=57"},"modified":"2008-10-14T17:34:50","modified_gmt":"2008-10-14T17:34:50","slug":"%e8%99%9a%e6%8b%9f%e5%86%85%e5%ad%98%e7%ae%a1%e7%90%86%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.kumouse.com\/?p=57","title":{"rendered":"\u865a\u62df\u5185\u5b58\u7ba1\u7406\u51fd\u6570"},"content":{"rendered":"<p>\u865a\u62df\u5185\u5b58\u7ba1\u7406\u51fd\u6570<br \/>VirtualAlloc,VirtualFree &#8211; \u5730\u5740\u7a7a\u95f4\u5206\u914d\u548c\u91ca\u653e<br \/>VirtualLock,VirtualUnlock &#8211; \u5bf9\u5185\u5b58\u9875\u8fdb\u884c\u9500\u5b9a\u548c\u89e3\u9501<br \/>VirtualQuery,VirtualQueryEx &#8211; \u67e5\u8be2\u5185\u5b58\u9875\u7684\u72b6\u6001<br \/>VirtualProtect,VirtualProtectEx &#8211; \u6539\u53d8\u5185\u5b58\u9875\u7684\u4fdd\u62a4\u5c5e\u6027<\/p>\n<p>1.\u4fdd\u7559\u548c\u91ca\u653e\u5730\u5740\u7a7a\u95f4<\/p>\n<blockquote><p>invoke VirtualAlloc,lpAddress,dwSize,flAllocationType,flProtect<\/p><\/blockquote>\n<p>lpAddress:\u6307\u5b9a\u8981\u4fdd\u7559\u6216\u63d0\u4ea4\u7684\u5185\u5b58\u5730\u5740,\u4e3aNULL\u65f6\u7cfb\u7edf\u81ea\u52a8\u5206\u914d\u4e00\u4e2a\u5730\u5740<br \/>dwSize:\u8868\u793a\u51fd\u6570\u5206\u914d\u7684\u5730\u5740\u8303\u56f4\u5927\u5c0f,\u5355\u4f4d\u5b57\u8282<br \/>flAlloctiontype\u53ef\u4ee5\u53d6\u7684\u6807\u5fd7\u6709\u4e09\u4e2a<br \/>MEM_COMMIT:\u4e3a\u6307\u5b9a\u5730\u5740\u7a7a\u95f4\u63d0\u4ea4\u7269\u7406\u5185\u5b58<br \/>MEM_RESERVE:\u4fdd\u7559\u6307\u5b9a\u5730\u5740\u7a7a\u95f4,\u4e0d\u5206\u914d\u7269\u7406\u5185\u5b58<br \/>MEM_TOP_DOWN:\u5c3d\u53ef\u80fd\u4f7f\u7528\u9ad8\u7aef\u7684\u5730\u5740\u7a7a\u95f4<br \/>flProtect\u53ef\u4ee5\u53d6\u7684\u6807\u5fd7\u6709\u516d\u4e2a<br \/>PAGE_READONLY:\u4e3a\u4ee5\u63d0\u4ea4\u7684\u7269\u7406\u5185\u5b58\u7684\u5740\u7a7a\u95f4\u8bbe\u5b9a\u53ea\u8bfb\u5c5e\u6027<br \/>PAGE_READWRITE:\u4e3a\u4ee5\u63d0\u4ea4\u7684\u7269\u7406\u5185\u5b58\u8bbe\u5b9a\u4e3a\u53ef\u8bfb\u5199\u5c5e\u6027<br \/>PAGE_EXECUTE:\u8bbe\u5b9a\u4e3a\u53ef\u6267\u884c\u5c5e\u6027<br \/>PAGE_EXECUTE_READ:\u4e3a\u7269\u7406\u5185\u5b58\u8bbe\u5b9a\u53ef\u8bfb\u548c\u53ef\u6267\u884c\u5c5e\u6027<br \/>PAGE_EXECUTE_READWRITE:\u4e3a\u5185\u5b58\u8bbe\u5b9a\u4e3a\u53ef\u8bfb\u5199\u548c\u53ef\u6267\u884c\u5c5e\u6027<br \/>PAGE_NOACCESS:\u4e3a\u4fdd\u7559\u7684\u5730\u5740\u7a7a\u95f4\u8bbe\u5b9a\u4e3a\u4e0d\u53ef\u5b58\u53d6\u6a21\u5f0f<br \/>\u51fd\u6570\u6267\u884c\u6210\u529f\u4f1a\u8fd4\u56de\u4e00\u4e2a\u6307\u5411\u88ab\u4fdd\u7559\u5730\u5740\u8303\u56f4\u5f00\u59cb\u4f4d\u7f6e\u7684\u6307\u9488,\u6267\u884c\u5931\u8d25\u8fd4\u56deNULL<\/p>\n<blockquote><p>invoke VirtualFree,lpAddress,dwSize,dwFreeType<\/p><\/blockquote>\n<p>lpAddress\u4e0edwSize:\u4e3a\u6307\u5b9a\u5730\u5740\u548c\u7a7a\u95f4\u7684\u5927\u5c0f,\u4e0eVirtualAlloc\u76f8\u540c<br \/>dwFreeType\u53ef\u4ee5\u7684\u6807\u5fd7\u6709\u4e24\u4e2a<br \/>MEM_DECOMMIT:\u4e3a\u4e00\u4e2a\u4ee5\u63d0\u4ea4\u7684\u7269\u7406\u5185\u5b58\u7684\u5730\u5740\u7a7a\u95f4\u89e3\u9664\u63d0\u4ea4<br \/>MEM_RELEASE:\u91ca\u653e\u4fdd\u7559\u7684\u5740\u5740\u7a7a\u95f4<\/p>\n<p>\u4f8b:<\/p>\n<blockquote><p>invoke VirtualAlloc,NULL,10485760,MEM_RESERVE,PAGE_NOACCESS<br \/>.if eax<br \/>    mov lpAddress,eax<br \/>.endif<\/p><\/blockquote>\n<p>\u7a7a\u95f4\u7684\u5206\u914d\u65b9\u5f0f\u7528MEM_RESERVE\u4fdd\u7559\u6307\u5b9a\u5730\u5740\u7a7a\u95f4,\u4e0d\u5206\u914d\u7269\u7406\u5185\u5b58,\u662f\u65e0\u6cd5\u8bbf\u95ee\u7684,\u6240\u4ee5\u4fdd\u62a4\u5c5e\u6027\u5fc5\u987b\u4f7f\u7528PAGE_NOACCESS,\u4ee5\u4e0a\u4ee3\u7801\u4fdd\u755910M\u5927\u5c0f\u7684\u7a7a\u95f4,\u4fdd\u7559\u5730\u5740\u5e76\u4e0d\u4fdd\u8bc1\u5c06\u6765\u6709\u53ef\u7528\u5185\u5b58\u6765\u63d0\u4ea4\u7ed9\u8fd9\u4e9b\u5730\u5740<\/p>\n<blockquote><p>invoke VirtualFree,lpAddress,0,MEM_RELEASE<\/p><\/blockquote>\n<p>lpAddress\u662fVirtualAlloc\u8fd4\u56de\u7684\u6307\u9488,\u91ca\u653e\u4fdd\u7559\u5185\u5b58\u65f6dwSize\u5fc5\u987b\u4e3a0,\u91ca\u653e\u4e00\u4e2a\u5730\u5740\u7a7a\u95f4\u4e2d\u7684\u6240\u6709\u9875\u9762\u5fc5\u987b\u662f\u540c\u4e00\u4e2a\u72b6\u6001,\u5426\u5219\u91ca\u653e\u64cd\u4f5c\u4f1a\u5931\u8d25.<\/p>\n<p>2.\u4f7f\u7528\u4fdd\u7559\u7684\u5730\u5740\u7a7a\u95f4<\/p>\n<blockquote><p>invoke VirtualAlloc,lpAddress,4096,MEM_COMMIT,PAGE_READWRITE<br \/>.if eax<br \/>    mov lpMemory,eax<br \/>.endif<\/p><\/blockquote>\n<p>\u4fdd\u7559\u5730\u5740\u5185\u5b58\u53ef\u4ee5\u6309\u4e00\u9875\u7684\u5927\u5c0f\u88ab\u5206\u6b21\u63d0\u4ea4,\u4e5f\u53ef\u4ee5\u4e00\u6b21\u63d0\u4ea4\u6240\u6709\u7684\u4fdd\u7559\u5730\u5740,\u5f53\u5185\u5b58\u88ab\u63d0\u4ea4\u65f6,\u53ef\u4ee5\u88ab\u5206\u914d\u4e3a\u7269\u7406\u5185\u5b58\u9875,\u4e5f\u6709\u53ef\u4ee5\u88ab\u5206\u914d\u5728\u9875\u6587\u4ef6\u4e2d,\u5728\u63d0\u4ea4\u65f6lpAddress\u4e0d\u80fd\u4e3aNULL,\u8981\u6307\u5b9a\u4e00\u4e2a\u7279\u5b9a\u7684\u5730\u5740\u6765\u51c6\u786e\u5730\u6307\u793a\u88ab\u4fdd\u7559\u7684\u54ea\u4e00\u9875\u4f1a\u88ab\u63d0\u4ea4.\u5c5e\u6027\u53ef\u4ee5\u8bbe\u5b9a\u6210\u53ef\u8bbf\u95ee\u7684,\u6210\u529f\u8fd4\u56de\u7b2c\u4e00\u9875\u8d77\u59cb\u7ebf\u7a0b\u7684\u5730\u5740,\u5931\u8d25\u8fd4\u56deNULL<\/p>\n<blockquote><p>invoke VirtualAlloc,NULL,dwSize,MEM_RESERVE or MEM_COMMIT,PAGE_READWRITE<br \/>.if eax<br \/>    mov lpMemory,eax<br \/>.endif<\/p><\/blockquote>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u4e0eGlobalAlloc\u51fd\u6570\u76f4\u63a5\u5206\u914d\u4e00\u5757\u5185\u5b58\u6ca1\u6709\u591a\u5927\u533a\u522b,\u53ea\u662f\u53ef\u4ee5\u6307\u5b9a\u5206\u914d\u7684\u5185\u5b58\u5757\u5730\u5740<\/p>\n<blockquote><p>invoke VirtualFree,lpMemory,dwSize,MEM_DECOMMIT<\/p><\/blockquote>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u4e3a\u89e3\u9664\u63d0\u4ea4,\u8ba9\u5b83\u4eec\u4ece\u63d0\u4ea4\u72b6\u6001\u8fd4\u56de\u5230\u4fdd\u7559\u72b6\u6001,\u51fd\u6570\u7684\u64cd\u4f5c\u5bf9\u8c61\u662f\u6574\u4e2a\u9875\u9762,\u5982\u679c\u6307\u5b9a\u7684\u5185\u5b58\u8303\u56f4\u4e0d\u662f\u6574\u4e2a\u9875\u9762,\u51fd\u6570\u4f1a\u81ea\u52a8\u5c06\u6574\u4e2a\u8303\u56f4\u540c\u5c5e\u4e00\u4e2a\u9875\u9762\u7684\u5730\u5740\u5168\u90e8\u89e3\u9664\u63d0\u4ea4.<\/p>\n<p>3.\u5185\u5b58\u9875\u7684\u4fdd\u62a4\u548c\u9501\u5b9a<\/p>\n<blockquote><p>invoke VirtualProtect,lpAddress,dwSize,flNewProtect,lpflOldProtect<\/p><\/blockquote>\n<p>flNewProtect:\u662f\u65b0\u7684\u4fdd\u62a4\u65b9\u5f0f,\u53d6\u503c\u53ef\u4ee5\u53c2\u8003VirtualAlloc\u7684flProtect\u7684\u6807\u5fd7<br \/>lpOldProtect:\u662f\u6307\u5411\u4e00\u4e2a\u53cc\u5b57\u7684\u6307\u9488,\u51fd\u6570\u4f1a\u5728\u8fd9\u91cc\u8fd4\u56de\u539f\u6765\u7684\u4fdd\u62a4\u65b9\u5f0f,\u5982\u679c\u4e0d\u9700\u8981\u53ef\u4ee5\u8bbe\u7f6e\u4e3aNULL<\/p>\n<blockquote><p>invoke VirtualLock,lpAddress,dwSize<br \/>invoke VirtualUnlock,lpAddress,dwSize<\/p><\/blockquote>\n<p>\u9501\u5b9a\u7684\u610f\u601d\u662f\u5c06\u6307\u5b9a\u5185\u5b58\u9875\u4fdd\u7559\u5728\u7269\u7406\u5185\u5b58\u4e2d,\u4e0d\u8bb8\u5c06\u5b83\u4ea4\u6362\u5230\u78c1\u76d8\u9875\u6587\u4ef6\u4e2d,\u540c\u65f6\u9501\u5b9a\u7684\u5185\u6570\u4e0d\u80fd\u8d85\u8fc730\u4e2a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u865a\u62df\u5185\u5b58\u7ba1\u7406\u51fd\u6570VirtualAlloc,VirtualFree &#8211; \u5730\u5740\u7a7a\u95f4\u5206\u914d\u548c\u91ca\u653eVirtu [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-12"],"_links":{"self":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=57"}],"version-history":[{"count":0,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts\/57\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}