锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 鍏蜂綋鎿嶄綔濡備笅錛?/p>
鍦ㄧ粓绔湇鍔″櫒涓婂仛濡備笅淇敼 鍦ㄥ鎴風(fēng)鍋氬涓嬫敼鍔渼 顥ヮ棩 1. 鎵撳紑瀹㈡埛绔繛鎺ョ鐞嗗櫒錛?顥ヮ棩
銆銆3)瀹氫箟SOCK_ADDR綾誨瀷錛岃窡鎹垜浠殑緗戝崱IP緇橲ock_ADDR綾誨瀷闄勫鹼紝鐒跺悗鎴戜滑浣跨敤bind鍑芥暟鏉ョ粦瀹氭垜浠殑緗戝崱錛孊ind鍑?/p> 鏁扮敤娉曞涓嬶細(xì) 4)鐢╓SAIoctl鏉ユ敞鍐學(xué)SA鐨勮緭鍏ヨ緭鍑虹粍浠訛紝鍏剁敤娉曞涓嬶細(xì) 銆銆6)鍦ㄥ驚鐜潡閲岋紝鐢╮ecv鍑芥暟鏉ユ帴鏀舵暟鎹紝recv鍑芥暟鐢ㄦ硶濡備笅錛?/p> 鏋勶紝鐢–opyMemory()鎶奍P淇℃伅浠巄uffer閲岄潰璇誨嚭鏉ュ氨鍙互浜嗭紝涓嶈繃璇誨嚭鏉ョ殑鏄崄鍏繘鍒剁殑鏁版嵁闇瑕佽漿鎹竴涓嬨?/p> 銆銆鐪嬩簡灝佸寘鎹曡幏鐨勫叏榪囩▼搴忥紝瀵逛綘鏄笉鏄湁鐐硅搗鍙戯紝鐒惰屽湪榪欓噷瑕佸憡璇夊ぇ瀹剁殑鏄皝鍖呯殑鑾峰緱鏄緢瀹規(guī)槗鐨勶紝浣嗘槸璁稿娓告垙 鐨勫皝鍖呴兘鏄姞瀵嗙殑錛屽鏋滀綘鎯蟲悶娓呮鎵寰楀埌鐨勬槸浠涔堝唴瀹硅繕闇瑕佽嚜宸辮繘琛屽皝鍖呰В瀵嗐? [鏂囩珷瀵艱] 鍦ㄥ嚑騫村墠鎴戠湅鍒板埆浜虹帺緗戠粶娓告垙鐢ㄤ笂浜嗗鎸傦紝鍋氫負(fù)紼嬪簭鍛樼殑鎴戝績閲屽疄鍦ㄦ槸涓嶇埥錛屾兂鎼炴竻妤氳繖鍒板簳鏄庝箞鍥炰簨銆傚氨鎷夸簡涓浜?/p> 鏉?a target="_blank">鐮旂┒錛屽皬鏈夊績寰楋紝鎷垮嚭鏉ヤ笌澶у鍏變韓錛屽鎸傛棤闈炲氨鏄垎鍑犵緗簡錛堜緷鍒朵綔闅懼害錛夛細(xì) 鏃╀互鍓嶇殑鈥滅煶鍣ㄢ濆鎸傚氨鏄繖縐嶆柟寮忋傦紙榪欑澶栨寕瀹屽叏鏄瀮鍦撅紝TMD錛屽彧瑕佷細(xì)涓鐐圭偣API鐨勪漢閮界煡閬撹鎬庝箞鍋氾紝涓嶈繃榪欑澶?/p> 鎸備篃鏄?a target="_blank">鍏ラ棬綰х殑濂戒笢涓滐紝铏界劧涓嶈兘鎻愰珮浣犵殑鎴樻枟鍔涳紝浣嗘槸鍙互鎻愰珮浣犵殑澹皵錛?/p> 銆銆2銆佹湰鍦頒慨鏀瑰紡錛岃繖縐嶅鎸傝窡浼犵粺涓婄殑涓浜?a target="_blank">娓告垙淇敼鍣ㄦ病鏈変袱鏍鳳紝鍋氳繖縐嶅鎸傚湪緙栫▼鍙渶瑕佸鍐呭瓨鍦板潃鏈変竴鐐硅璇嗗茍 涓旀帉鎻PI灝卞彲浠ュ疄鐜幫紝鈥滅簿鐏碘濈殑澶栨寕榪欐槸榪欑鏂瑰紡鍐欐垚鐨勶紝瀹冪殑闅劇偣鍦ㄤ簬鎵懼埌閭d簺鍦板潃鐮侊紝鎵懼湴鍧涓鑸湴瑕佸熷姪浜庡埆 浜虹殑宸ュ叿錛屾湁鐨?a target="_blank">娓告垙榪樻湁鍙岀爜鏍¢獙錛屾姝f壘璧鋒潵浼?xì)姣旇緝鍥伴毦銆傦紙榪欑澶栨寕錛屾瘮涓婁竴縐嶆湁涓鐐圭偣闅懼害錛屼絾鏄繖縐嶅鎸傚仛璧鋒潵 鑳藉鐢紝涔熸槸鏈変竴瀹氶毦搴︾殑鍟~錛岃繖縐嶅鎸傚彲浠ュ緢蹇彁鍗囦綘瀵瑰唴瀛樺湴鍧鐨勭悊瑙e強(qiáng)搴旂敤錛屾槸浣?a target="_blank">緙栫▼鎶鏈?/font>鎻愰珮鐨勫ソ涓滀笢錛?/p> 銆銆3銆?a target="_blank">鏈ㄩ┈寮忥紝榪欑澶栨寕鐨勭洰鐨勬槸甯鎸傚埗浣滆呭伔鍒扮敤鎴風(fēng)殑瀵嗙爜錛圱MD錛屸滅儌鈥濆氨涓涓瓧錛屼笉榪囪鐭ュ凡鐭ュ郊鎵浠ヨ繕鏄璋?/p> 涓涓嬪暒~~錛夛紝鍋氳繖縐嶅鎸傛湁涓瀹氱殑闅懼害錛岄渶瑕丠OOK鎴栭敭鐩樼洃瑙?a target="_blank">鎶鏈?/font>鍋氬簳瀛愶紝鎵嶅彲浠ュ畬鎴愶紝瀹冪殑鍘熺悊鏄厛棣栨埅浜嗙敤鎴風(fēng)殑甯愬彿 鎴?a target="_blank">瀵嗙爜錛岀劧鍚庡彂鍒版寚瀹氶偖綆便傦紙鎴戜互鍓嶅啓榪囪繖鏍風(fēng)殑涓滀笢錛屼絾鏄粠鏉ユ病鏈夌敤榪囷紝鎴戠煡閬撹繖縐嶄笢涓滃緢涓嶉亾寰鳳紝鎵浠ヤ互鍚庡崈涓囧埆 鐢ㄥ憖錛侊級 銆銆4銆佸姞閫熷紡錛岃繖縐嶅鎸傚彲浠ュ姞蹇?a target="_blank">娓告垙鐨勯熷害鈥︹︼紙瀵逛笉璧峰ぇ瀹訛紝榪欑涓滀笢鎴戞病鏈夊疄闄呭仛榪囷紝鎵浠ヤ笉鑳藉鑷瘎錛屾儹鎰э級 銆銆榪欏嚑縐嶅鎸備箣涓紝鍓嶄笁縐嶅彲浠ョ敤VB錛孌elphi絳夎璦姣旇緝濂藉疄鐜幫紝鍚庝袱縐嶅垯瑕佺敤VC絳夊簳灞傛敮鎸佹瘮杈冨ソ鐨?a target="_blank">緙栫▼宸ュ叿鎵嶅ソ瀹?/p> 鐜般? 銆銆鍔ㄤ綔寮忓鎸?/p> 銆銆棣栧厛錛屽厛鏉ヨ皥涓涓嬪姩浣滃紡鐨勫鎸傦紝榪欎篃鏄垜絎竴嬈″啓澶栨寕鏃跺仛鐨勬渶綆鍗曠殑涓縐嶃?/p> 銆銆璁板緱榪樺湪鈥滅煶鍣ㄢ濇椂浠g殑鏃跺欙紝鎴戠湅鍒板埆浜烘寕鐫涓縐?a target="_blank">杞歡錛堝鎸傦級浜虹墿灝卞彲浠ュ洓澶栨父璧幫紙褰撴椂鎴戣繕涓嶇煡閬撳鎸傛庝箞鍥?/p> 浜嬶級錛屼簬鏄壘浜嗚繖縐?a target="_blank">杞歡榪囨潵鐮旂┒錛堟嬁鏉ュ悗鎵嶅惉鍒漢璇磋繖鍙鎸傦級錛屽彂鐜拌繖縐嶄笢涓滃叾瀹炲疄鐜拌搗鏉ュ茍涓嶉毦錛屼粩浣冪湅鍏跺疄浜虹墿 鐨勮璧版棤闈炲氨鏄紶鏍囧湪涓嶅悓鐨勫湴鏂圭偣鏉ョ偣鍘昏屽凡錛岀湅鍚庡氨鏈夊疄鐜拌繖鍔熻兘鐨勫啿鍔紝闅忓悗璺戝埌MSDN涓婄湅浜嗕竴浜涜祫鏂欙紝鍙戠幇榪欑 瀹炵幇榪欏嚑涓姛鑳斤紝鍙渶瑕佸嚑涓畝鍗曠殑API鍑芥暟灝卞彲浠ユ悶瀹氾細(xì) 銆銆1銆侀鍏堟垜浠鐭ラ亾鐜板湪榧犳爣鐨勪綅緗紙涓轟簡濂借繕鍘熺幇鍦ㄩ紶鏍囩殑浣嶇疆錛夋墍浠ユ垜浠氨瑕佺敤鍒癆PI鍑芥暟GetCursorPos錛屽畠鐨勪嬌 鐢ㄦ柟娉曞涓嬶細(xì) 涓嬶細(xì) MOUSEEVENTF_LEFTUP錛屽叿浣撶殑涓滀笢榪樻槸鏌ヤ竴涓婱SDN鍚~~~~ 銆銆 濂戒簡錛屾湁浜嗗墠闈㈢殑鐭ヨ瘑錛屾垜浠氨鍙互鏉ョ湅鐪?a target="_blank">浜虹墿縐昏蛋鏄庝箞瀹炵幇鐨勪簡錛?/p> 錛孴MD錛岃繖鏄瀮鍦懼鎸傜殑鍋氭硶錛岀浉淇′簡鍚~~錛夛紝鎺ヤ笅鏉ワ紝鍐嶇湅鐪?a target="_blank">娓告垙閲岄潰鑷姩鏀誨嚮鐨勫仛娉曞惂錛堝繀闇娓告垙涓?a target="_blank">鏀誨嚮鏀寔蹇嵎閿?/p> 鐨勶級錛岄亾鐞嗚繕鏄竴鏍風(fēng)殑錛屽彧鏄敤鐨凙PI涓嶅悓緗簡~~~錛岃繖鍥炴垜浠鐢ㄥ埌鐨勬槸keybd_event鍑芥暟錛屽叾鐢ㄦ硶濡備笅錛?/p> 聽 銆銆鎴戜滑榪樿鐭ラ亾鎵弿鐮佷笉鍙互鐩存帴浣跨敤錛岃鐢ㄥ嚱鏁癕apVirtualKey鎶婇敭鍊艱漿鎴愭壂鎻忕爜錛孧apVirtualKey鐨勫叿浣撲嬌鐢ㄦ柟娉曞 涓嬶細(xì) 銆銆錛堢湅鍒拌繖閲岋紝宸笉澶氬綆鏄撳鎸傛湁浜嗕竴瀹氱殑浜嗚В浜嗗惂~~~~鍋氫竴涓瘯璇曪紵濡傛灉浣犱婦涓浠夸笁榪樿兘鏈夋洿濂界殑涓滀笢鍑烘潵錛岃繖灝?/p> 瑕佺湅浣犵殑棰嗘?zhèn)熻兘鍔涗簡~~錛屼笉榪囦笉瑕侀珮鍏村お鏃╄繖鍙槸鎵嶅紑濮嬶紝浠ュ悗榪樻湁鏇村鏉傜殑涓滀笢絳夌潃浣犲憿~~錛?/p> 銆銆鐜板湪鎴戜滑鏉ョ湅鐪嬶紝姣斿姩浣滃紡澶栨寕鏇磋繘涓姝ョ殑澶栨寕鈥斺旀湰鍦頒慨鏀瑰紡澶栨寕鐨勬暣涓埗浣滆繃紼嬭繘琛屼竴涓緇嗙殑鍒嗚В銆?/p> 銆銆鍏鋒垜鎵鐭ワ紝鏈湴淇敼寮忓鎸傛渶鍏稿瀷鐨勫簲鐢ㄥ氨鏄湪鈥滅簿鐏碘?a target="_blank">娓告垙涓婇潰錛屽洜涓烘垜鍦ㄨ繎涓騫村墠錛堚滅簿鐏碘濊繕鍦ㄦ祴璇曢樁孌碉級錛?/p> 鎴戞墍鍦ㄧ殑鍏徃閲屾湁寰堝鍚屼簨鐜┾滅簿鐏碘濓紝浜庢槸鎴戠湅浜嗕竴涓?a target="_blank">娓告垙鐨勬暟鎹鐞嗘柟寮忥紝鍙戠幇瀹冩墍鍙戦佸埌鏈嶅姟鍣ㄤ笂鐨勪俊鎭槸瀛樺湪浜?/p> 鍐呭瓨褰撲腑錛堟垜鐪嬪悗絎竴涓劅鍙楁槸錛氫慨鏀硅繖縐?a target="_blank">娓告垙鍜屼慨鏀瑰崟鏈虹増鐨?a target="_blank">娓告垙娌℃湁澶氬ぇ鍒嗗埆錛屾崲鍙ヨ瘽璇村氨鏄湪浠栧悜鏈嶅姟鍣ㄦ彁浜や俊鎭?/p> 涔嬪墠淇敼浜嗗唴瀛樺湴鍧灝卞彲浠ヤ簡錛夛紝褰撴椂鎴戞壘鍒頒簡鍦板潃浜庢槸淇敼浜嗗唴瀛樺湴鍧錛屾灉鐒訛紝鎸夋垜鐨勬兂娉曚慨鏀逛簡鍦板潃錛岃緋葷粺鑷姩鎻?/p> 浜ゅ悗錛屾灉鐒舵垚鍔熶簡~~~~~錛屽悗鏉モ滅簿鐏碘濆張鏀規(guī)垚浜嗗弻鍦板潃鏍℃錛屽唴瀛樻牎媯絳夌瓑錛屽湪榪欓噷鎴戝氨涓嶅簾璇濅簡~~~~錛孫K錛屾垜浠氨鏉?/p> 鐪嬬湅榪欑被澶栨寕鏄浣曞埗浣滅殑錛?/p> 銆銆鍦ㄥ仛澶栨寕涔嬪墠鎴戜滑瑕佸Windows鐨勫唴瀛樻湁涓叿浣撶殑璁よ瘑錛岃屽湪榪欓噷鎴戜滑鎵鎸囩殑鍐呭瓨鏄寚緋葷粺鐨勫唴瀛樺亸縐婚噺錛屼篃灝辨槸鐩?/p> 瀵瑰唴瀛橈紝鑰屾垜浠墍瑕佸鍏惰繘琛屼慨鏀癸紝閭d箞鎴戜滑瑕佸鍑犱釜Windows API榪涜浜嗚В錛孫K錛岃窡鐫渚嬪瓙璁╂垜浠湅娓呮榪欑澶栨寕鐨勫埗 浣滃拰API鐨勫簲鐢紙涓轟簡淇濊瘉緗戠粶娓告垙鐨勬甯歌繍琛岋紝鎴戝氨涓嶆妸鎵懼唴瀛樺湴鍧鐨勬柟娉曡緇嗚В璇翠簡錛夛細(xì) 銆銆1銆侀鍏堟垜浠鐢‵indWindow,鐭ラ亾娓告垙紿楀彛鐨勫彞鏌勶紝鍥犱負(fù)鎴戜滑瑕侀氳繃瀹冩潵寰楃煡娓告垙鐨勮繍琛屽悗鎵鍦ㄨ繘紼嬬殑ID錛屼笅闈㈠氨鏄?/p> FindWindow鐨勭敤娉曪細(xì) DWORD GetWindowThreadProcessId( HWND hWnd, // handle of window 銆銆3銆佸緱鍒?a target="_blank">娓告垙榪涚▼ID鍚庯紝鎺ヤ笅鏉ョ殑浜嬫槸瑕佷互鏈楂樻潈闄愭墦寮榪涚▼錛屾墍鐢ㄥ埌鐨勫嚱鏁癘penProcess鐨勫叿浣撲嬌鐢ㄦ柟娉曞涓嬶細(xì) 鏉ユ墦寮榪涚▼灝卞彲浠ワ紝鍏朵粬鐨勬柟寮忔垜浠彲浠ユ煡涓涓婱SDN銆?/p> 銆銆4銆佹墦寮榪涚▼鍚庯紝鎴戜滑灝卞彲浠ョ敤鍑芥暟瀵瑰瓨鍐呰繘琛屾搷浣滐紝鍦ㄨ繖閲屾垜浠彧瑕佺敤鍒癢riteProcessMemory鏉ュ鍐呭瓨鍦板潃鍐欏叆鏁?/p> 鎹嵆鍙紙鍏朵粬鐨勬搷浣滄柟寮忔瘮濡傝錛歊eadProcessMemory絳夛紝鎴戝湪榪欓噷灝變笉涓涓浠嬬粛浜嗭級錛屾垜浠湅涓涓媁riteProcessMemory 鐨勭敤娉曪細(xì) 銆銆榪欏氨鏄繖綾?a target="_blank">娓告垙澶栨寕鐨勭▼搴忓疄鐜伴儴浠界殑鏂規(guī)硶錛屽ソ浜嗭紝鏈変簡姝ゆ柟娉曪紝鎴戜滑灝辨湁浜嗙悊鎬х殑璁よ瘑錛屾垜浠湅鐪嬪疄闄呬緥瀛愶紝鎻愬崌 涓涓嬫垜浠殑鎰熸ц璇嗗惂錛屼笅闈㈠氨鏄疿X娓告垙鐨勫鎸?a target="_blank">浠g爜錛屾垜浠収涓婇潰鐨勬柟娉曞搴斿幓鐮旂┒涓涓嬪惂錛?/p> 鍧銆?/p> 銆銆鏈ㄩ┈寮忓鎸傦紝鍙兘澶у鍍?a target="_blank">鏈ㄩ┈鍚э紝鏄府鍔╁仛澶栨寕鐨勪漢鍋峰彇鍒漢娓告垙鐨勫笎鍙峰強(qiáng)瀵嗙爜鐨勪笢涓溿傚洜涓虹綉緇滀笂鏈夋綾誨鎸傜殑瀛?/p> 鍦紝鎵浠ヤ粖澶╀笉寰椾笉璇翠竴涓嬶紙鎴戜釜浜烘槸闈炲父璁ㄥ帉榪欑被澶栨寕鐨勶紝璇風(fēng)湅榪囨湰鏂囩殑鏈嬪弸涓嶈鍒板涔辯敤姝?a target="_blank">鎶鏈?/font>錛岃阿璋㈠悎浣滐級銆傝鍋?/p> 姝ょ被澶栨寕鐨勭▼搴忓疄鐜版柟娉曞緢澶氾紙姣斿HOOK錛岄敭鐩樼洃瑙嗙瓑鎶鏈?/font>錛夛紝鍥犱負(fù)HOOK鎶鏈?/font>瀵圭▼搴忓憳鐨?a target="_blank">鎶鏈?/font>瑕佹眰姣旇緝楂樺茍涓斿湪瀹為檯搴旂敤 涓婇渶瑕佸甯︿竴涓?a target="_blank">鍔ㄦ?/font>閾炬帴搴擄紝鎵浠ュ湪鏂囦腑鎴戜細(xì)浠ラ敭鐩樼洃瑙?a target="_blank">鎶鏈?/font>鏉ュ疄鐜版綾?a target="_blank">鏈ㄩ┈鐨勫埗浣溿傞敭鐩樼洃瑙?a target="_blank">鎶鏈?/font>鍙渶瑕佷竴涓?exe鏂囦歡 灝辮兘瀹炵幇鍋氬埌鍚庡彴閿洏鐩戣錛岃繖涓▼搴忕敤榪欑鎶鏈?/font>鏉ュ疄鐜版瘮杈冮傚悎銆?/p> 銆銆鍦ㄥ仛紼嬪簭涔嬪墠鎴戜滑蹇呴渶瑕佷簡瑙d竴涓嬬▼搴忕殑鎬濊礬錛?/p> 銆銆1銆佹垜浠鍏堢煡閬撲綘鎯寵褰?a target="_blank">娓告垙鐨勭櫥褰曠獥鍙e悕縐般?/p> 銆銆2銆佸垽鏂櫥褰曠獥鍙f槸鍚﹀嚭鐜般?/p> 銆銆3銆佸鏋滅櫥褰曠獥鍙e嚭鐜幫紝灝辮褰曢敭鐩樸?/p> 銆銆4銆佸綋紿楀彛鍏抽棴鏃訛紝鎶婅褰曚俊鎭紝閫氳繃閭歡鍙戦佸埌紼嬪簭璁捐鑰呯殑閭銆?/p> 銆銆絎竴鐐規(guī)垜灝變笉鍏蜂綋鍒嗘瀽浜嗭紝鍥犱負(fù)浣犱滑姣旀垜榪樿浜嗚В浣犱滑鐜╃殑鏄粈涔?a target="_blank">娓告垙錛岀櫥褰曠獥鍙e悕縐版槸浠涔堛備粠絎簩鐐瑰紑濮嬶紝鎴戜滑 灝卞紑濮嬭繖綾誨鎸傜殑紼嬪簭瀹炵幇涔嬫梾錛?/p> 銆銆閭d箞鎴戜滑瑕佹庝箞鏍峰垽鏂櫥褰曠獥鍙h櫧鍚﹀嚭鐜板憿錛熷叾瀹炶繖涓緢綆鍗曪紝鎴戜滑鐢‵indWindow鍑芥暟灝卞彲浠ュ緢杞繪澗鐨勫疄鐜頒簡錛?/p> 鎴戜滑灝卞彲浠ュ閿洏淇℃伅榪涜璁板綍浜嗐?/p> 銆銆鍏堥鎴戜滑鐢⊿etWindowsHookEx璁劇疆鐩戣鏃ュ織錛岃岃鍑芥暟鐨勭敤娉曞涓嬶細(xì) 鐢ㄦ湰紼嬪簭鐨凥INSTANCE灝卞彲浠ヤ簡錛屽叿浣撳疄鐜版柟娉曚負(fù)錛?/p> 鏄垱寤簊etwindowshookex鍚庢墍榪斿洖鐨勫彞鏌勩?/p> 銆銆鎴戜滑宸茬粡寰楀埌浜嗛敭鐩樼殑璁板綍錛岄偅涔堢幇鍦ㄦ渶鍚庡彧瑕佹妸璁板綍鐨勮繖浜涗俊鎭彂閫佸洖鏉ワ紝鎴戜滑灝卞ぇ鍔熼犳垚浜嗐傚叾浠栧彂閫佽繖鍧楀茍涓?/p> 鏄緢闅撅紝鍙鎶婅褰曚粠鏂囨湰鏂囦歡閲岃竟璇誨嚭鏉ワ紝鐢―ELPHI鑷甫鐨勭數(shù)瀛愰偖浠剁粍浠跺彂涓涓嬪氨涓囦簨OK浜嗐?a target="_blank">浠g爜濡備笅錛?/p> 銆銆鍘熸湰鎴戜竴鐩翠互涓哄姞閫熷鎸傛槸閽堝鏌愪釜娓告垙鑰屽啓鐨勶紝鍚庢潵鍙戠幇鎴戣繖縐嶆蹇墊槸涓嶅鐨勶紝鎵璋撳姞閫熷鎸傚叾瀹炴槸淇敼鏃墮挓棰戠巼 杈懼埌鍔犻熺殑鐩殑銆?/p> 銆銆浠ュ墠DOS鏃朵唬鐜╄繃緙栫▼鐨勪漢灝變細(xì)椹笂鎯沖埌錛岃繖寰堢畝鍗曞槢涓嶅氨鏄洿鎺ヤ慨鏀逛竴涓?253瀵勫瓨鍣ㄥ槢錛岃繖鍦ㄤ互鍓岲OS鏃朵唬鍙兘鍙互 琛屽緱閫氾紝浣嗘槸windows鍒欎笉鐒躲倃indows鏄竴涓?2浣嶇殑鎿嶄綔緋葷粺錛屽茍涓嶆槸浣犳兂鏀瑰摢灝辨敼鍝殑錛堝井杞殑涓滀笢灝辨槸濡傛闇告皵錛岃 涓嶇粰浣犳敼灝變笉緇欎綘鏀癸級錛屼絾瑕佹敼涔熶笉鏄笉鍙兘錛屾垜浠彲浠ラ氳繃涓ょ鏂規(guī)硶鏉ュ疄鐜幫細(xì)絎竴鏄啓涓涓‖浠墮┍鍔ㄦ潵瀹屾垚錛岀浜屾槸鐢?/p> Ring0鏉ュ疄鐜幫紙榪欑鏂規(guī)硶鏄疌IH鐨勪綔鑰呴檲鐩堣豹棣栫敤鐨勶紝瀹冪殑鍘熺悊鏄慨鏀逛竴涓婭DE琛?>鍒涘緩涓涓腑鏂棬->榪涘叆Ring0->璋冪敤涓柇 淇敼鍚戦噺錛屼絾鏄病鏈夊姙娉曞彧鑳界敤ASM姹囩紪鏉ュ疄鐜拌繖涓鍒?_*錛屽仛涓洪珮綰ц璦浣跨敤鑰呮儴鍟︼紒錛夛紝鐢ㄧ涓縐嶆柟娉曠敤鐐歸夯鐑︼紝鎵浠?/p> 鎴戜滑鍦ㄨ繖閲屽氨鐢ㄧ浜岀鏂規(guī)硶瀹炵幇鍚~~ 銆銆鍦ㄥ疄鐜頒箣鍓嶆垜浠潵鐞嗕竴涓嬫濊礬鍚э細(xì) 銆銆1銆佹垜浠鍏堣鍐欎竴涓繃紼嬪湪榪欎釜榪囩▼閲屽祵鍏ユ眹緙栬璦鏉ュ疄鐜頒慨鏀笽DE琛ㄣ佸垱寤轟腑鏂棬錛屼慨鏀瑰悜閲忕瓑宸ヤ綔 銆銆2銆佽皟鐢ㄨ繖涓繃紼嬫潵瀹炵幇鍔犻熷姛鑳?/p> 銆銆濂戒簡錛岀幇鍦ㄦ濊礬鏈変簡錛屾垜浠氨杈圭湅浠g爜杈硅瑙e惂錛?/p> 銆銆棣栧厛鎴戜滑寤虹珛涓涓繃紼嬶紝榪欎釜榪囩▼灝辨槸鏈▼搴忕殑鏍稿績閮ㄤ喚錛?/p> 涓涓嬭繖涓繃紼嬫潵鍋氫竴涓被浼間簬鈥滃彉閫熼嬌杞濈殑涓涓笢涓滃惂錛?/p> 銆銆鍏堝姞涓涓獥鍙o紝鍦ㄧ獥鍙d笂鏀句笂涓涓猼rackbar鎺т歡鎶婂叾Max璁句負(fù)20錛孧in璁句負(fù)1錛屾妸Position璁句負(fù)10錛屽湪榪欎釜鎺т歡鐨?/p> Change浜嬩歡閲屽啓涓婏細(xì) 鍏紡錛屽ソ浜嗭紝榪欏氨鏄滃彉閫熼嬌杞濈殑涓涓狣elphi錛婣SM鐗堜簡錛堝彧閫傜敤浜巜in9X錛夛紝鍛靛懙錛岃瘯涓涓嬪惂錛岃繖瀵逛綘甯姪浼?xì)寰堝ぇ鐨勫Q?/p> 鍛靛懙銆?/p> 銆銆鍦╳in2000閲岋紝鎴戜滑涓嶅彲鑳藉疄鐜板湪鐩存帴瀵圭鍙h繘琛屾搷浣滐紝Ring0涔熷け浜嗘晥錛屾湁鐨勪漢灝變細(xì)鎯沖埌錛屾垜浠彲浠ュ啓椹卞姩紼嬪簭鏉ュ畬 鎴愬憖錛屼絾鍦ㄨ繖閲屾垜鍛婅瘔浣狅紝windows2000鐨勯┍鍔ㄤ笉鏄竴涓猇xD灝辮兘瀹炵幇鐨勶紝鍍忔垜榪欐牱鐨勪綆鎵嬫槸鍐欎笉鍑簑indows鎵鐢ㄧ殑椹卞姩WDM 鐨勶紝娌″姙娉曪紝鎴戝彧鏈夊熷姪澶栧姏瀹炵幇浜嗭紝ProtTalk灝辨槸涓涓緢濂界殑璁懼椹卞姩錛屼粬寰堟柟渚跨殑鏉ュ疄鐜板浣庡眰绔彛鐨勬搷浣滐紝浠庤屽疄 鐜板姞閫熷鎸傘?/p> 銆銆1銆佹垜浠鍏堣涓嬩竴涓狿ortTalk椹卞姩錛屼粬鐨勫畼鏂圭綉绔欐槸http://www.beyondlogic.org/ 銆銆2銆佹垜浠鎶婇噷闈㈢殑prottalk.sys鎷瘋礉鍑烘潵銆?/p> 銆銆3銆佸緩绔嬩竴涓狿rotalk.sys鐨勬帴鍙o紙鎴戞兂鐪佺暐浜嗭紝澶у鍙互涓?a >http://www.freewebs.com/liuyue/porttalk.pas涓嬩釜pas 鏂囦歡鑷繁鐪嬪惂錛?/p> 銆銆4銆佸疄鐜板姞閫熷鎸傘?/p> 銆銆涓嬮潰灝辮涓涓嬭繖紼嬪簭鐨勫疄鐜版柟娉曞惂錛屽鏋滆鐢≒rotTalk鏉ユ搷浣滅鍙e氨瀹規(guī)槗澶氫簡錛屾瘮win98涓嬬敤ring鏉冮檺鎿嶄綔鏂逛究銆?/p> 銆銆1銆佹柊寤轟竴涓伐紼嬶紝鎶婂垰鍒氫笅鐨勬帴鍙f枃浠跺拰Protalk.sys涓璧鋒嫹鍒板伐紼嬫枃浠朵繚瀛樼殑鏂囦歡澶逛笅銆?/p> 銆銆2銆佹垜浠湪鎴戜滑鏂板緩鐨勫伐紼嬪姞鍏ユ垜浠殑鎺ュ彛鏂囦歡 Change浜嬩歡閲屽啓涓婏細(xì) [鏂囩珷瀵艱] 涓嶅浜庢 銆銆鐜板湪寰堝娓告垙閮芥槸鎶婁竴浜涗俊鎭瓨鍏ュ唴瀛樺崟鍏冪殑錛岄偅涔堟垜浠彧闇瑕佷慨鏀瑰叿浣撳唴瀛樺煎氨鑳戒慨鏀?a target="_blank">娓告垙涓殑灞炴э紝寰堝緗戠粶娓?/p> 鎴忎篃涓嶅浜庢銆?/p> 鍧鏍¢獙錛屽姞澶т簡淇敼闅懼害錛屼笉榪囦粛鐒跺彲浠ラ氳繃鍐呭瓨鍒嗘瀽鍣ㄥ彲浠ョ牬瑙g殑銆傝濡傗淔PE鈥濊繖鏍風(fēng)殑杞歡渚挎彁渚涗簡涓瀹氱殑鍐呭瓨鍒嗘瀽 鍔熻兘銆?/p> 銆銆鈥淔PE鈥濇槸鍩轟簬鍐呭瓨澶栨寕鐨勪郊浣艱咃紝鏄鍠繪埛鏅撶殑娓告垙淇敼杞歡銆傚緢澶氬悓綾葷殑杞歡閮芥槸妯′豢鈥淔PE鈥濊屽緱鍒扮帺瀹剁殑璁ゅ彲 銆傝屸淔PE鈥濆疄鐜扮殑鎶鏈?/font>鍒扮幇鍦ㄩ兘娌℃湁鍏紑錛屽緢澶氫漢鍙兘澶熼氳繃鐚滄祴鈥淔PE鈥濈殑瀹炵幇鏂規(guī)硶錛屽疄鐜板悓綾誨鎸傘傜瑪鑰呬篃鏇劇粡妯′豢 榪団淔PE鈥濆疄鐜扮浉搴旂殑鍔熻兘錛屽鈥滃唴瀛樹慨鏀光濄佲滃唴瀛樻煡璇⑩濈瓑鎶鏈?/font>銆傜◢鍚庝細(xì)瀵規(guī)鎶鏈?/font>榪涜鍓栨瀽銆?/p> 銆銆鏃㈢劧瑕佸仛鍐呭瓨澶栨寕錛岄偅涔堝氨蹇呴』瀵筗indows鐨勫唴瀛樻満鍒舵湁鎵浜嗚В銆?a target="_blank">璁$畻鏈?/font>鐨勫唴瀛?RAM)鎬繪槸涓嶅鐢ㄧ殑錛屽湪鎿嶄綔緋葷粺涓唴 瀛樺氨鏈夌墿鐞嗗唴瀛樺拰铏氭嫙鍐呭瓨涔嬪垎錛屽洜涓虹▼搴忓垱寤烘斁鍏ョ墿鐞嗗唴瀛樼殑鍦板潃閮芥槸鍦ㄥ彉鍖栫殑錛屾墍浠ュ湪寰楀埌娓告垙灞炴ф椂騫朵笉鑳藉鐩存帴 璁塊棶鐗╃悊鍐呭瓨鍦板潃銆傚湪v86妯″紡涓嬶紝孌靛瘎瀛樺櫒浣跨敤鏂規(guī)硶涓庡疄妯″紡鐩稿悓錛岄偅涔堝彲浠ラ氳繃孌靛瘎瀛樺櫒鐨勫煎乏縐?浣嶅姞涓婂湴鍧鍋忕Щ閲?/p> 灝卞彲浠ュ緱鍒扮嚎鎬у湴鍧錛岃岀▼搴忓垱寤烘椂鍦ㄧ嚎鎬у湴鍧鐨勪腑淇濈暀4MB-2GB鐨勪竴孌靛湴鍧錛?a target="_blank">娓告垙涓睘鎬т究鏀句簬姝ゃ傚湪windows涓妸铏氭嫙 鍐呭瓨鍧楃О涔嬩負(fù)欏碉紝鑰屾瘡欏典負(fù)4KB錛屽湪璁塊棶鍐呭瓨鏃惰鍙?a target="_blank">娓告垙灞炴ф椂錛屼負(fù)浜嗕笉鐮村潖鏁版嵁瀹屾暣鎬х殑蹇熸祻瑙堝唴瀛樺湴鍧鍊鹼紝鏈濂戒竴 嬈¤闂竴欏點?/p> 銆銆鍦ㄦ搷浣滆繘紼嬪唴瀛樻椂錛屼笉闇瑕佸啀浣跨敤姹囩紪璇█錛學(xué)indows涓彁渚涗簡涓浜涜闂繘紼嬪唴瀛樼┖闂寸殑API錛屼究鍙互鐩存帴瀵硅繘紼嬪唴瀛?/p> 榪涜鎿嶄綔銆備絾鍒濆鑰呬竴鑸帉鎻′笉浜嗚繖涓欏?a target="_blank">鎶鏈?/font>錛屼負(fù)浜嗕嬌鍒濆鑰呬篃鑳藉瀵瑰唴瀛樿繘琛屾搷浣滐紝鍋氬嚭鍩轟簬鍐呭瓨鎺у埗鐨勫鎸傦紝絎旇呮妸 涓浜涘唴瀛樻搷浣滃強(qiáng)涓浜涘唴瀛樻搷浣滈昏緫榪涜浜嗗皝瑁咃紝浠ユ帶浠跺艦寮忔彁渚涚粰鍒濆鑰呫傛帶浠跺悕涓猴細(xì)MpMemCtl銆?/p> 銆銆鍒濆鑰呭湪浣跨敤姝ゆ帶浠舵椂錛岃鍏堝畨瑁呭鎸傚紩鎿庢帶浠跺寘錛堝湪姝ゅ悗鐨勬瘡綃囨枃绔犱腑澶栨寕寮曟搸鎺т歡鍖呬粎鎻愪緵涓庤鏂囩珷鐩稿簲鐨勬帶鍒?/p> 鎺т歡錛夛紝鍏蜂綋鎺т歡瀹夎鏂瑰紡錛岃鍙傞槄銆奃elphi鎸囧崡銆嬶紝鐢變簬綃囧箙鎵闄愶紝鎭曚笉鑳借緇嗘彁渚涖?/p> 銆銆鍦ㄥ紩鎿庡畨瑁呭畬鎴愬悗錛屼究鍙互鍦―elphi涓殑緇勪歡鏍忓唴錛屾壘鍒癧MP GameControls]鎺т歡緇勶紝鍏朵腑鍙互鎵懼埌[MpMemCtl]鎺т歡 銆傚垵瀛﹁呭彲浠ヤ嬌鐢ㄦ鎺т歡鍙互瀵瑰唴瀛樿繘琛屾帶鍒躲?/p> 銆銆涓銆?寰楀埌榪涚▼鍙ユ焺 銆銆闇瑕佹搷浣?a target="_blank">娓告垙鍐呭瓨,閭d箞棣栧厛蹇呴』紜瑕佹搷浣滅殑娓告垙,鑰?a target="_blank">娓告垙紼嬪簭鍦ㄨ繍琛屾椂鎵浜х敓鐨勬瘡涓涓繘紼嬮兘鏈変竴涓敮涓鐨勫彞鏌勩?/p> 銆銆浣跨敤鎺т歡寰楀埌鍙ユ焺鏈変笁縐嶆柟娉曪細(xì) 銆銆1銆?閫氳繃鎺т歡鎵撳紑紼嬪簭寰楀埌鍙ユ焺銆?/p> 銆銆鍦ㄦ帶浠朵腑錛屾彁渚涗簡startProgram鏂規(guī)硶錛岄氳繃璇ユ柟娉曪紝鍙互鎵撳紑紼嬪簭寰楀埌榪涚▼鍙ユ焺錛屽茍涓斿彲浠ヨ繑鍥炶繘紼嬩俊鎭?/p> 涓柟娉曞湪寰楀埌榪涚▼淇℃伅鐨勫悓鏃訛紝騫剁粰鎺т歡鐨凱rocHandle錛堣繘紼嬪彞鏌勶級灞炴ц繘琛屼簡闄勫鹼紝榪欐椂鍙互浣跨敤鎺т歡鐩存帴瀵瑰唴瀛樿繘紼?/p> 璇誨啓鎿嶄綔銆傚叾搴旂敤瀹炰緥濡備笅錛?/p> 銆銆鍦ㄦ帶浠朵腑錛屽緋葷粺榪愯榪涚▼涔熸湁浜嗙浉搴旂殑鎻忚堪錛屾帶浠舵彁渚涗簡涓や釜鏂規(guī)硶錛岀敤浜庢牴鎹▼搴忓悕縐板緱鍒扮浉搴旂殑榪涚▼鍙ユ焺銆?/p> getProcIDs()鍙互寰楀埌緋葷粺鐜板湪鎵榪愯鐨勬墍鏈夌▼搴忕殑鍚嶇О鍒楄〃銆俫etProcID()鍙互閫氳繃鎵榪愯紼嬪簭鍚嶇О錛屽緱鍒扮浉搴旇繘紼嬬殑 鍙ユ焺銆?/p> 銆銆棣栧厛鍙互閫氳繃getProcIDs()騫舵妸鍙傛暟鍒楄〃榪斿洖ComboBox1.Items閲岋細(xì) 鐢ㄦ帶浠剁洿鎺ュ鍐呭瓨榪涚▼璇誨啓鎿嶄綔銆?/p> 銆銆鍦ㄦ帶浠朵腑錛屾帶浠舵彁渚涗簡涓や釜鏂規(guī)硶錛岀敤浜庢牴鎹獥鍙e悕縐板緱鍒扮浉搴旂殑榪涚▼鍙ユ焺銆傚彲浠ラ氳繃getALLWindow()寰楀埌鎵鏈夊湪榪涚▼ 涓繍琛岀殑紿楀彛銆俫etWinProcHandle()鍙互閫氳繃鐩稿簲鐨勭獥鍙e悕縐幫紝寰楀埌鐩稿簲鐨勮繘紼嬬殑鍙ユ焺銆?/p> 銆銆棣栧厛鍙互閫氳繃getALLWindow ()騫舵妸鍙傛暟鍒楄〃榪斿洖ComboBox1.Items閲岋細(xì) 鏃跺彲浠ヤ嬌鐢ㄦ帶浠剁洿鎺ュ鍐呭瓨榪涚▼璇誨啓鎿嶄綔銆?/p> 銆銆鍦ㄧ▼搴忎腑錛屼負(fù)浜嗕究浜庢洿濂界殑寰楀埌娓告垙鐨勫綋鍓嶅睘鎬с傚湪鎺т歡涓彁渚涗簡娓告垙鏆傚仠鏂規(guī)硶銆傚彧闇瑕佽皟鐢ㄨ鏂規(guī)硶錛?a target="_blank">娓告垙渚垮彲浠ヨ嚜 鐢辯殑鏆傚仠鎴栧惎鍔ㄣ傝鏂規(guī)硶涓猴細(xì)pauseProc() 銆銆娓告垙灞炴у叾瀹炲瘎瀛樺湪鍐呭瓨鍦板潃鍊奸噷錛?a target="_blank">娓告垙涓浜嗚В鎴栦慨鏀?a target="_blank">娓告垙灞炴э紝鍙互閫氳繃瀵瑰唴瀛樺湴鍊肩殑璇誨嚭鎴栧啓鍏ュ畬鎴愩?/p> 銆銆閫氳繃鎺т歡錛岃璇誨啓鍐呭瓨鍦板潃鍊煎緢瀹規(guī)槗銆傚彲浠ラ氳繃璋冪敤鎺т歡鎻愪緵鐨刧etAddressValue錛堬級鍙?qiáng)setAddressValue錛堬級涓や釜鏂?/p> 娉曞嵆鍙紝鍦ㄤ嬌鐢ㄦ柟娉曚箣鍓嶏紝瑕佺‘璁ょ殑鏄緇橮rocHandle灞炴ц繘琛岄檮鍊鹼紝鍥犱負(fù)瀵瑰唴瀛樼殑鎿嶄綔蹇呴』鍩轟簬榪涚▼銆傜粰ProcHandle灞?/p> 鎬ч檮鍊肩殑鏂規(guī)硶錛屽湪涓婃枃涓凡緇忎粙緇嶃傛棤璁烘槸瀵瑰唴瀛樺艱繘琛岃榪樻槸榪涜鍐欙紝閮借鏄庣‘鎵瑕佹搷浣滅殑鍐呭瓨鍦板潃銆?/p> 銆銆璇誨彇鍦板潃鍊鹼紙濡傛灉鈥滀富瑙掆濈瓑綰ф墍瀛樻斁鐨勫湴鍧涓?549632錛夛細(xì) 銆銆鍐欏叆鍦板潃鍊鹼細(xì) 銆銆鍥涖佸唴瀛樺湴鍧鍊煎垎鏋?/p> 銆銆鍦?a target="_blank">娓告垙涓鎯寵鍒?a target="_blank">娓告垙灞炴у瓨鏀劇殑鍐呭瓨鍦板潃錛岄偅涔堝氨瀵圭浉搴斿唴瀛樺湴鍧榪涜鍐呭瓨鍒嗘瀽錛岀粡榪囧垎鏋愪互鍚庢墠鍙緱鍒?a target="_blank">娓告垙灞炴?/p> 瀛樻斁鐨勪漢瀛樺湴鍧銆?/p> 銆銆鎺т歡鎻愪緵涓ょ鍩轟簬鍐呭瓨鍦板潃鐨勫垎鏋愭柟娉曘備竴縐嶆槸鎸夌簿紜湴鍧鍊艱繘琛屾悳绱㈠垎鏋愶紝鍙︿竴縐嶆槸鎸夊唴瀛樺彉鍖栧鍑忛噺榪涜鎼滅儲鍒?/p> 鏋愩?/p> 銆銆1銆?濡傛灉寰堟槑紜殑鐭ラ亾褰撳墠鎯寵淇敼鐨勫湴鍧鍊鹼紝閭d箞灝辯敤綺劇‘鍦板潃鍊艱繘琛屾悳绱㈠垎鏋?/p> 銆銆鍦?a target="_blank">娓告垙涓紝闇瑕佷慨鏀?a target="_blank">浜虹墿鐨勭粡楠屽鹼紝閭d箞棣栧厛瑕佷粠娓告垙鐢婚潰涓婅幏寰楃粡楠屽間俊鎭紝濡?a target="_blank">娓告垙浜虹墿褰撳墠緇忛獙鍊間負(fù)9800錛岄渶瑕?/p> 鎶婄粡楠屽艱皟楂橈紝閭d箞榪欐椂鍊欏氨闇瑕佸浜虹墿緇忛獙鍊煎湪鍐呭瓨涓悳绱㈠緱鍒扮浉搴旂殑鍐呭瓨鍦板潃錛屽綋鐒跺緢鍙兘鍦ㄥ唴瀛樹腑鍦板潃鍊間負(fù)9800鐨?/p> 寰堝錛岀涓嬈″緢鍙兘鎼滅儲鍑鴻嫢騫蹭釜鍦板潃鍊間負(fù)9800鐨勫湴鍧銆傜瓑寰呯粡楠屽煎啀鏈夋墍鍙樺寲錛屽浠?800鍙樹負(fù)浜?0000鏃訛紝鍐嶆榪涜鎼?/p> 绱紝閭d箞浠庡垰鍒氭墍鎼滅儲鍒扮殑鍦板潃涓紝渚垮彲浠ヨ繘涓姝ヨ幏寰楄寖鍥存洿灝戠殑鍐呭瓨鍦板潃錛屼互姝ょ被鎺紝閭d箞鏈鍚庡彲寰楀埌緇忛獙鍊煎叿浣撳瓨鏀?/p> 鐨勫湴鍧銆?/p> 銆銆濡傝鐢ㄦ帶浠舵潵瀹炵幇鍐呭瓨鍊肩簿紜悳绱紝鍏跺疄鏂規(guī)硶寰堢畝鍗曪紝鍙渶瑕佽皟鐢ㄨ鎺т歡鐨凷earch錛堬級鏂規(guī)硶鍗沖彲銆備絾鏄湪鎼滅儲涔嬪墠瑕?/p> 紜鎼滅儲鐨勮寖鍥達(dá)紝姝e鍓嶆枃涓墍璇達(dá)細(xì)鈥滆岀▼搴忓垱寤烘椂鍦ㄧ嚎鎬у湴鍧鐨勪腑淇濈暀4MB-2GB鐨勪竴孌靛湴鍧鈥濓紝鎵浠ヨ鎼滅儲鐨勫湴鍧搴旇 鏄?MB-2GB涔嬮棿錛屾墍浠ヨ鎶婃帶浠剁殑MaxAddress灞炴ц涓?GB錛屾妸鎺т歡鐨凪inAddress灞炴ц涓?MB銆傝繕鏈変竴涓渶瑕佺‘璁ょ殑鏄渶 瑕佹悳绱㈢殑鍊鹼紝閭d箞搴旇鎶奡earchValue灞炴ц緗負(fù)褰撳墠鎼滅儲鐨勫箋傚鏋滈渶瑕佹樉紺烘悳绱㈣繘搴﹂偅涔堝彲浠ユ妸ShowGauge灞炴ф寕涓婁竴 涓浉搴旂殑TGauge鎺т歡錛堣鎺т歡涓鴻繘搴︽潯鎺т歡錛夈?/p> 瀹炰緥濡備笅錛?/p> 銆銆濡傛湁浜?a target="_blank">娓告垙鐨?a target="_blank">浜虹墿琛鍊間笉鏄劇ず鍑烘潵錛屼絾瑕佸浜虹墿琛鍊艱繘琛屼慨鏀癸紝閭d箞鍙湁鍊熷姪浜庡唴瀛橀噺澧炲噺鍙樺寲鑰岃繘琛屾悳绱㈠垎鏋愬嚭璇?/p> 浜虹墿琛鍊煎瓨鏀劇殑鍦板潃銆傚鏋?a target="_blank">浜虹墿琚墿鎵撲簡涓涓嬶紝閭d箞浜虹墿琛鍊煎氨浼?xì)鍑彏畱锛岄偅涔垬q欐椂鍊欏氨鐢ㄥ噺閲忚繘琛屾悳绱㈠垎鏋愶紝濡傛灉浜虹墿 鍚冧簡鈥滆鈥?a target="_blank">浜虹墿琛鍊煎氨浼?xì)澧炲姞锛岄偅涔垬q欐椂鍊欏氨鐢ㄥ閲忚繘琛屾悳绱㈠垎鏋愩傜粡榪囦笉鏂悳绱紝鏈鍚庝細(xì)鎶婅寖鍥存斁琛鍊肩殑鍐呭瓨鍦板潃緇欐悳 绱㈠嚭鏉ャ?/p> 銆銆濡傝鐢ㄦ帶浠舵潵瀹炵幇鍐呭瓨鍊肩簿紜悳绱紝鍏跺疄鏂規(guī)硶寰堢畝鍗曪紝鍙渶瑕佽皟鐢ㄨ鎺т歡鐨刢ompare()鏂規(guī)硶鍗沖彲銆侻axAddress銆?/p> MinAddress灞炴ц緗笂闈㈢珷鑺備腑鏈夎緇嗕粙緇嶏紝鍦ㄦ涓嶅啀閲嶆彁銆傚湪姝ゅ垎鏋愪腑涓嶉渶瑕佸啀鎸囧畾SearchValue灞炴с傚鏋滈渶瑕佹樉紺?/p> 鎼滅儲榪涘害閭d箞鍙互鎶奡howGauge灞炴ф寕涓婁竴涓浉搴旂殑TGauge鎺т歡銆?/p> 鏋愮被鍨嬫湁涓ょ錛氬鏋滃弬鏁板間負(fù)0錛岄偅涔堝氨浠h〃澧為噺鎼滅儲銆傚鏋滃弬鏁板間負(fù)1錛岄偅涔堝氨浠h〃鍑忛噺鎼滅儲銆傚叾搴旂敤瀹炰緥濡備笅錛?/p> 銆銆鍦ㄦ帶浠朵腑錛屾彁渚涜幏寰楀垎鏋愬悗鍐呭瓨鍦板潃鍒楄〃鐨勬柟娉曪紝鍙渶瑕佽皟鐢╣etAddressList()鏂規(guī)硶錛屼究鍙互鑾峰緱鍒嗘瀽榪囩▼涓垨鍒嗘瀽 緇撴灉鍦板潃鍒楄〃銆備絾濡傛灉浣跨敤鐨勬槸鎸夊唴瀛樺彉鍖栧鍑忛噺榪涜鎼滅儲鍒嗘瀽鐨勬柟娉曪紝閭d箞絎竴嬈″彲鑳戒細(xì)鎼滅儲鍑烘潵寰堝鐨勫湴鍧錛岃嚧浣胯繑 鍥為熷害榪囬暱錛岄偅涔堝緩璁嬌鐢╣etAddressCount錛堬級鏂規(guī)硶紜畾榪斿洖鍒楄〃涓轟竴瀹氶暱搴﹀悗鎵嶇粰浜堣繑鍥炪?/p> 鑳姐傚埄鐢ㄦ宸ュ叿錛岄氳繃涓浜涙柟娉曪紝涓嶄粎浠呭彲浠ュ垎鏋愬嚭鏉?a target="_blank">娓告垙灞炴у崟鍐呭瓨鍦板潃錛岃屼笖鍙互鍒嗘瀽鍑轟竴閮ㄤ喚澶氬唴瀛?a target="_blank">娓告垙灞炴у瓨鏀?/p> 鍦板潃銆?/p> 瀛樺湪涓ょ瀛楄妭欏哄簭錛歂BO涓嶩BO 緗戠粶瀛楄妭欏哄簭NBO錛圢etwork Byte Order錛夛細(xì) 涓繪満瀛楄妭欏哄簭錛圚BO錛孒ost Byte Order錛夛細(xì)
2銆佸皢涓繪満鐨剈nsigned long鍊艱漿鎹負(fù)緗戠粶瀛楄妭欏哄簭(32浣?錛氫負(fù)浠涔堣榪欐牱鍋氬憿錛熷洜涓轟笉鍚岀殑璁$畻鏈轟嬌鐢ㄤ笉鍚岀殑瀛楄妭欏哄簭瀛樺偍鏁版嵁銆傚洜姝や換浣曚粠Winsock鍑芥暟瀵笽P鍦板潃鍜岀鍙e彿鐨勫紩鐢ㄥ拰浼犵粰Winsock鍑芥暟鐨処P鍦板潃鍜岀鍙e彿鍧囨椂鎸夌収緗戠粶欏哄簭緇勭粐鐨勩?br />聽聽聽聽聽 u_long聽 htonl(u_long hostlong); 3銆佸皢unsigned long鏁頒粠緗戠粶瀛楄妭欏哄簭杞崲浣嶄富鏈哄瓧鑺傞『搴忥紝鏄笂闈㈠嚱鏁扮殑閫嗗嚱鏁般偮犅犅犅犅犅?u_long聽 ntohl(u_long netlong); 4銆佸皢涓繪満鐨剈nsigned short鍊艱漿鎹負(fù)緗戠粶瀛楄妭欏哄簭(16浣?錛氬師鍥犲悓2錛毬犅犅犅犅犅?u_short聽 htons(u_short hostshort); 5銆佸皢unsigned short鏁頒粠緗戠粶瀛楄妭欏哄簭杞崲浣嶄富鏈哄瓧鑺傞『搴忥紝鏄笂闈㈠嚱鏁扮殑閫嗗嚱鏁般偮犅犅犅犅犅?u_short聽 ntohs(u_short netshort); 銆銆鎺ョ潃錛屾垜浠繕闇瑕佸垱寤轟竴涓澹崇▼搴忓皢鍏ㄥ眬閽╁瓙瀹夎浜哤indows緋葷粺涓紝榪欎釜澶栧3紼嬪簭緙栧啓姝ラ濡備笅錛?/p> 銆銆(1).鍒涘緩涓涓璇濇妯″紡鐨勫簲鐢ㄧ▼搴忥紝欏圭洰鍚嶄負(fù)Simulate銆?/p> 銆銆(2).鍦ㄤ富瀵硅瘽妗嗕腑鍔犲叆涓涓寜閽紝浣跨敤ClassWizard涓哄叾鍒涘緩CLICK浜嬩歡銆?/p> 銆銆(3).灝咥ctiveKey欏圭洰Debug鐩綍涓嬬殑ActiveKey.DLL鍜孉ctiveKey.lib鎷瘋礉鍒癝imulate欏圭洰鐩綍涓嬨?/p> 銆銆(4).浠庘滃伐紼嬧濊彍鍗曚腑閫夋嫨鈥滆緗濓紝寮瑰嚭Project Setting瀵硅瘽妗嗭紝閫夋嫨Link鏍囩錛屽湪鈥滃璞?搴撴ā鍧椻濅腑杈撳叆 ActiveKey.lib銆?/p> 銆銆(5).灝咥ctiveKey欏圭洰涓殑ActiveKey.h澶存枃浠跺姞鍏ュ埌Simulate欏圭洰涓紝騫跺湪Stdafx.h涓姞鍏?include ActiveKey.h銆?/p> 銆銆(6).鍦ㄦ寜閽崟鍑諱簨浠跺嚱鏁拌緭鍏ュ涓?a target="_blank">浠g爜錛?/p> 銆銆銆void CSimulateDlg::OnButton1() 銆銆銆}聽 銆銆(7).緙栬瘧欏圭洰錛屽茍榪愯紼嬪簭錛屽崟鍑?yán)L寜閽縺媧誨鎸傘?/p> 銆銆(8).鍚?a target="_blank">鍔ㄧ敾絎旂▼搴忥紝閫夋嫨鏂囨湰宸ュ叿騫跺皢絎旂殑棰滆壊璁劇疆涓虹孩鑹詫紝灝嗛紶鏍囨斁鍦ㄤ換鎰忎綅緗悗錛屾寜F10閿紝鐢葷瑪紼嬪簭鑷姩縐誨姩 榧犳爣騫跺啓涓嬩竴涓孩鑹茬殑澶у啓R銆傚浘涓灞曠ず浜嗘寜F10閿墠鐨勭敾絎旂▼搴忕殑鐘舵侊紝鍥句簩灞曠ず浜嗘寜F10閿悗鐨勭敾絎旂▼搴忕殑鐘舵併?/p> 銆浜斻佸皝鍖?a target="_blank">鎶鏈?/font> 銆銆閫氳繃瀵瑰姩浣滄ā鎷?a target="_blank">鎶鏈?/font>鐨勪粙緇嶏紝鎴戜滑瀵?a target="_blank">娓告垙澶栨寕鏈変簡涓瀹氱▼搴︿笂鐨勮璇嗭紝涔熷浼?xì)浜嗕娇鐢ㄥ姩浣滄ā鎷?a target="_blank">鎶鏈?/font>鏉ュ疄鐜扮畝鍗曠殑鍔ㄤ綔 妯℃嫙鍨?a target="_blank">娓告垙澶栨寕鐨勫埗浣溿傝繖縐嶅姩浣滄ā鎷熷瀷娓告垙澶栨寕鏈変竴瀹氱殑灞闄愭э紝瀹冧粎浠呭彧鑳借В鍐充嬌鐢?a target="_blank">璁$畻鏈?/font>浠f浛浜哄姏瀹屾垚閭d箞鏈夎寰?/p> 銆佺箒鐞愯屾棤鑱婄殑娓告垙鍔ㄤ綔銆備絾鏄紝闅忕潃緗戠粶娓告垙鐨勭洓琛屽拰澶嶆潅搴︾殑澧炲姞錛屽緢澶?a target="_blank">娓告垙瑕佹眰灝嗗鎴風(fēng)鍔ㄤ綔淇℃伅鍙?qiáng)鏃跺弽棣堝?a target="_blank">鏈嶅姟 鍣紝閫氳繃鏈嶅姟鍣ㄥ榪欎簺鍔ㄤ綔淇℃伅榪涜鏈夋晥璁よ瘉鍚庯紝鍐嶅悜瀹㈡埛绔彂閫佷笅涓姝?a target="_blank">娓告垙鍔ㄤ綔淇℃伅錛岃繖鏍峰姩浣滄ā鎷?a target="_blank">鎶鏈?/font>灝嗗け鍘誨師鏈夌殑 鏁堝簲銆備負(fù)浜嗘洿濂藉湴鈥滃鎸傗濊繖浜?a target="_blank">娓告垙錛?a target="_blank">娓告垙澶栨寕紼嬪簭涔熻繘琛屼簡鍗囩駭鎹唬錛屽畠浠皢浠ュ墠閽堝娓告垙鐢ㄦ埛鐣岄潰灞傜殑妯℃嫙鎺ㄨ繘鍒版暟 鎹氳灞傦紝閫氳繃灝佸寘鎶鏈?/font>鍦ㄥ鎴風(fēng)鎸℃埅娓告垙鏈嶅姟鍣ㄥ彂閫佹潵鐨?a target="_blank">娓告垙鎺у埗鏁版嵁鍖咃紝鍒嗘瀽鏁版嵁鍖呭茍淇敼鏁版嵁鍖咃紱鍚屾椂榪橀渶鎸夌収娓?/p> 鎴忔暟鎹寘緇撴瀯鍒涘緩鏁版嵁鍖咃紝鍐嶆ā鎷熷鎴風(fēng)鍙戦佺粰娓告垙鏈嶅姟鍣紝榪欎釜榪囩▼鍏跺疄灝辨槸涓涓皝鍖呯殑榪囩▼銆?/p> 銆銆灝佸寘鐨?a target="_blank">鎶鏈?/font>鏄疄鐜扮浜岀被娓告垙澶栨寕鐨勬渶鏍稿績鐨?a target="_blank">鎶鏈?/font>銆傚皝鍖?a target="_blank">鎶鏈?/font>娑夊強(qiáng)鐨?a target="_blank">鐭ヨ瘑寰堝箍娉涳紝瀹炵幇鏂規(guī)硶涔熷緢澶氾紝濡傛尅鎴猈inSock 銆佹尅鎴狝PI鍑芥暟銆佹尅鎴秷鎭乂xD椹卞姩紼嬪簭絳夈傚湪姝ゆ垜浠篃涓嶅彲鑳藉湪姝ゆ枃涓皢鎵鏈夌殑灝佸寘鎶鏈?/font>閮借繘琛岃緇嗕粙緇嶏紝鏁呴夋嫨涓ょ 鍦?a target="_blank">娓告垙澶栨寕紼嬪簭涓渶甯哥敤鐨勪袱縐嶆柟娉曪細(xì)鎸℃埅WinSock鍜屾尅鎴狝PI鍑芥暟銆?/p> 銆銆1錛?鎸℃埅WinSock 銆銆浼楁墍鍛ㄧ煡錛學(xué)insock鏄疻indows緗戠粶緙栫▼鎺ュ彛錛屽畠宸ヤ綔浜嶹indows搴旂敤灞傦紝瀹冩彁渚涗笌搴曞眰浼犺緭鍗忚鏃犲叧鐨勯珮灞傛暟鎹紶杈?/p> 緙栫▼鎺ュ彛銆傚湪Windows緋葷粺涓紝浣跨敤WinSock鎺ュ彛涓哄簲鐢ㄧ▼搴忔彁渚涘熀浜?a target="_blank">TCP/IP鍗忚鐨勭綉緇滆闂?a target="_blank">鏈嶅姟錛岃繖浜?a target="_blank">鏈嶅姟鏄敱 Wsock32.DLL鍔ㄦ?/font>閾炬帴搴撴彁渚涚殑鍑芥暟搴撴潵瀹屾垚鐨勩?/p> 銆銆鐢變笂璇存槑鍙煡錛屼換浣昗indows鍩轟簬TCP/IP鐨勫簲鐢ㄧ▼搴忛兘蹇呴』閫氳繃WinSock鎺ュ彛璁塊棶緗戠粶錛屽綋鐒剁綉緇?a target="_blank">娓告垙紼嬪簭涔熶笉渚嬪銆?/p> 鐢辨鎴戜滑鍙互鎯寵薄涓涓嬶紝濡傛灉鎴戜滑鍙互鎺у埗WinSock鎺ュ彛鐨勮瘽錛岄偅涔堟帶鍒?a target="_blank">娓告垙瀹㈡埛绔▼搴忎笌鏈嶅姟鍣ㄤ箣闂寸殑鏁版嵁鍖呬篃灝嗘槗濡?/p> 鍙嶆帉銆傛寜鐫榪欎釜鎬濊礬錛屼笅闈㈢殑宸ヤ綔灝辨槸濡備綍瀹屾垚鎺у埗WinSock鎺ュ彛浜嗐傜敱涓婇潰鐨勪粙緇嶅彲鐭ワ紝W(xué)inSock鎺ュ彛鍏跺疄鏄敱涓涓?a target="_blank">鍔ㄦ?/font> 閾炬帴搴撴彁渚涚殑涓緋誨垪鍑芥暟錛岀敱榪欎簺鍑芥暟瀹炵幇瀵圭綉緇滅殑璁塊棶銆傛湁浜嗚繖灞傜殑璁よ瘑錛岄棶棰樺氨濂藉姙澶氫簡錛屾垜浠彲浠ュ埗浣滀竴涓被浼肩殑 鍔ㄦ?/font>閾炬帴搴撴潵浠f浛鍘焀inSock鎺ュ彛搴擄紝鍦ㄥ叾涓疄鐜癢inSock32.dll涓疄鐜扮殑鎵鏈夊嚱鏁幫紝騫朵繚璇佹墍鏈夊嚱鏁扮殑鍙傛暟涓暟鍜岄『搴忋?/p> 榪斿洖鍊肩被鍨嬮兘搴斾笌鍘熷簱鐩稿悓銆傚湪榪欎釜鑷埗浣滅殑鍔ㄦ?/font>搴撲腑錛屽彲浠ュ鎴戜滑鎰熷叴瓚g殑鍑芥暟錛堝鍙戦併佹帴鏀剁瓑鍑芥暟錛夎繘琛屾尅鎴紝鏀?/p> 鍏ュ鎸傛帶鍒?a target="_blank">浠g爜錛屾渶鍚庤繕緇х畫璋冪敤鍘焀inSock搴撲腑鎻愪緵鐨勭浉搴斿姛鑳藉嚱鏁幫紝榪欐牱灝卞彲浠ュ疄鐜板緗戠粶鏁版嵁鍖呯殑鎸℃埅銆佷慨鏀瑰拰鍙?/p> 閫佺瓑灝佸寘鍔熻兘銆?/p> 銆銆涓嬮潰閲嶇偣浠嬬粛鍒涘緩鎸℃埅WinSock澶栨寕紼嬪簭鐨勫熀鏈楠わ細(xì) 銆銆(1) 鍒涘緩DLL欏圭洰錛岄夋嫨Win32 Dynamic-Link Library錛屽啀閫夋嫨An empty DLL project銆?/p> 銆銆(2) 鏂板緩鏂囦歡wsock32.h錛屾寜濡備笅姝ラ杈撳叆浠g爜錛?/p> 銆銆鈶?鍔犲叆鐩稿叧鍙橀噺澹版槑錛?/p> 銆銆銆HMODULE hModule=NULL; //妯″潡鍙ユ焺 銆銆鈶?瀹氫箟鎸囧悜鍘焀inSock搴撲腑鐨勬墍鏈夊嚱鏁板湴鍧鐨勬寚閽堝彉閲忥紝鍥燱inSock搴撳叡鎻愪緵70澶氫釜鍑芥暟錛岄檺浜庣瘒騫咃紝鍦ㄦ灝卞彧閫夋嫨 鍑犱釜甯哥敤鐨勫嚱鏁板垪鍑猴紝鏈夊叧榪欎簺搴撳嚱鏁扮殑璇存槑鍙弬鑰僊SDN鐩稿叧鍐呭銆?/p> 銆銆銆//瀹氫箟鎸囧悜鍘焀inSock搴撳嚱鏁板湴鍧鐨勬寚閽堝彉閲忋?br />銆銆銆SOCKET (__stdcall *socket1)(int ,int,int);//鍒涘緩Sock鍑芥暟銆?br />銆銆銆int銆(__stdcall *WSAStartup1)(WORD,LPWSADATA);//鍒濆鍖朩inSock搴撳嚱鏁般?br />銆銆銆int銆(__stdcall *WSACleanup1)();//娓呴櫎WinSock搴撳嚱鏁般?br />銆銆銆int (__stdcall *recv1)(SOCKET ,char FAR * ,int ,int );//鎺ユ敹鏁版嵁鍑芥暟銆?br />銆銆銆int (__stdcall *send1)(SOCKET ,const char * ,int ,int);//鍙戦佹暟鎹嚱鏁般?br />銆銆銆int (__stdcall *connect1)(SOCKET,const struct sockaddr *,int);//鍒涘緩榪炴帴鍑芥暟銆?br />銆銆銆int (__stdcall *bind1)(SOCKET ,const struct sockaddr *,int );//緇戝畾鍑芥暟銆?br />銆銆銆......鍏跺畠鍑芥暟鍦板潃鎸囬拡鐨勫畾涔夌暐銆偮? 銆銆(3) 鏂板緩wsock32.cpp鏂囦歡錛屾寜濡備笅姝ラ杈撳叆浠g爜錛?/p> 銆銆鈶?鍔犲叆鐩稿叧澶存枃浠跺0鏄庯細(xì) 銆銆銆#include 銆銆鈶?娣誨姞DllMain鍑芥暟錛屽湪姝ゅ嚱鏁頒腑棣栧厛闇瑕佸姞杞藉師WinSock搴擄紝騫惰幏鍙栨搴撲腑鎵鏈夊嚱鏁扮殑鍦板潃銆?a target="_blank">浠g爜濡備笅錛?/p> 銆銆銆BOOL WINAPI DllMain (HANDLE hInst,ULONG ul_reason_for_call,LPVOID lpReserved) 銆銆鈶?瀹氫箟搴撹緭鍑哄嚱鏁幫紝鍦ㄦ鍙互瀵規(guī)垜浠劅鍏磋叮鐨勫嚱鏁頒腑娣誨姞澶栨寕鎺у埗浠g爜錛屽湪鎵鏈夌殑杈撳嚭鍑芥暟鐨勬渶鍚庝竴姝ラ兘璋冪敤鍘?/p> WinSock搴撶殑鍚屽悕鍑芥暟銆傞儴鍒嗚緭鍑哄嚱鏁板畾涔?a target="_blank">浠g爜濡備笅錛?/p> //搴撹緭鍑哄嚱鏁板畾涔夈?br />//WinSock鍒濆鍖栧嚱鏁般?br />銆銆銆銆int PASCAL FAR WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData) 銆銆銆LIBRARY "wsock32" 銆銆銆......鍏跺畠杈撳嚭鍑芥暟澹版槑浠g爜鐣ャ?/p> 銆銆(5)銆佷粠鈥滃伐紼嬧濊彍鍗曚腑閫夋嫨鈥滆緗濓紝寮瑰嚭Project Setting瀵硅瘽妗嗭紝閫夋嫨Link鏍囩錛屽湪鈥滃璞?搴撴ā鍧椻濅腑杈撳叆 Ws2_32.lib銆?/p> 銆銆(6)銆佺紪璇戦」鐩紝浜х敓wsock32.dll搴撴枃浠躲?/p> 銆銆(7)銆佸皢緋葷粺鐩綍涓嬪師wsock32.dll搴撴枃浠舵嫹璐濆埌琚鎸傜▼搴忕殑鐩綍涓嬶紝騫跺皢鍏舵敼鍚嶄負(fù)wsock.001錛涘啀灝嗕笂闈駭鐢熺殑 wsock32.dll鏂囦歡鍚屾牱鎷瘋礉鍒拌澶栨寕紼嬪簭鐨勭洰褰曚笅銆傞噸鏂板惎鍔?a target="_blank">娓告垙紼嬪簭錛屾鏃?a target="_blank">娓告垙紼嬪簭灝嗗厛鍔犺澆鎴戜滑鑷繁鍒朵綔鐨?/p> wsock32.dll鏂囦歡錛屽啀閫氳繃璇ュ簱鏂囦歡闂存帴璋冪敤鍘焀inSock鎺ュ彛鍑芥暟鏉ュ疄鐜拌闂綉緇溿備笂闈㈡垜浠粎浠呬粙緇嶄簡鎸¤澆WinSock鐨勫疄 鐜拌繃紼嬶紝鑷充簬濡備綍鍔犲叆澶栨寕鎺у埗浠g爜錛岃繕闇瑕佸鎸傚紑鍙戜漢鍛樺娓告垙鏁版嵁鍖呯粨鏋勩佸唴瀹廣佸姞瀵嗙畻娉曠瓑鏂歸潰鐨勪粩緇嗗垎鏋愶紙榪欎釜 榪囩▼灝嗘槸涓涓壈杈涚殑榪囩▼錛夛紝鍐嶇敓鎴愬鎸傛帶鍒?a target="_blank">浠g爜銆傚叧浜庢暟鎹寘鍒嗘瀽鏂規(guī)硶鍜?a target="_blank">鎶宸?/font>錛屼笉鏄湰鏂囪瑙g殑鑼冨洿錛屽鎮(zhèn)ㄦ劅鍏磋叮鍙互 鍒扮綉涓婃煡鏌ョ浉鍏寵祫鏂欍?/p> 銆銆瀹屾垚浜嗗畾浣嶅拰淇敼紼嬪簭涓皟鐢ˋPI鍑芥暟浠g爜鍚庯紝鎴戜滑灝卞彲浠ラ殢鎰忚璁¤嚜瀹氫箟鐨凙PI鍑芥暟鐨勬浛浠e嚱鏁頒簡銆傚仛瀹岃繖涓鍒囧悗錛?/p> 榪橀渶瑕佸皢榪欎簺浠g爜娉ㄥ叆鍒拌澶栨寕娓告垙紼嬪簭榪涚▼鍐呭瓨絀洪棿涓紝涓嶇劧娓告垙榪涚▼鏍規(guī)湰涓嶄細(xì)璁塊棶鍒版浛浠e嚱鏁?a target="_blank">浠g爜銆傛敞鍏ユ柟娉曟湁寰堝 錛屽鍒╃敤鍏ㄥ眬閽╁瓙娉ㄥ叆銆佸埄鐢?a target="_blank">娉ㄥ唽琛?/font>娉ㄥ叆鎸℃埅User32搴撲腑鐨凙PI鍑芥暟銆佸埄鐢–reateRemoteThread娉ㄥ叆錛堜粎闄愪簬NT/2000錛夈?/p> 鍒╃敤BHO娉ㄥ叆絳夈傚洜涓烘垜浠湪鍔ㄤ綔妯℃嫙鎶鏈?/font>涓鑺傚凡緇忔帴瑙﹁繃鍏ㄥ眬閽╁瓙錛屾垜鐩鎬俊鑱槑鐨勮鑰呭凡緇忓畬鍏ㄦ帉鎻′簡鍏ㄥ眬閽╁瓙鐨勫埗浣?/p> 榪囩▼錛屾墍浠ユ垜浠湪鍚庨潰鐨勫疄渚嬩腑錛屽皢緇х畫鍒╃敤榪欎釜鍏ㄥ眬閽╁瓙銆傝嚦浜庡叾瀹冨嚑縐嶆敞鍏ユ柟娉曪紝濡傛灉鎰熷叴瓚e彲鍙傞槄MSDN鏈夊叧鍐呭銆?/p> 銆銆鏈変簡浠ヤ笂鐞嗚鍩虹錛屾垜浠笅闈㈠氨寮濮嬪埗浣滀竴涓尅鎴狹essageBoxA鍜宺ecv鍑芥暟鐨勫疄渚嬶紝鍦ㄥ紑鍙?a target="_blank">娓告垙澶栨寕紼嬪簭 鏃訛紝鍙互姝?/p> 瀹炰緥涓烘鏋訛紝鍔犲叆鐩稿簲鐨勬浛浠e嚱鏁板拰澶勭悊浠g爜鍗沖彲銆傛瀹炰緥鐨勫紑鍙戣繃紼嬪涓嬶細(xì) 銆銆(1) 鎵撳紑鍓嶉潰鍒涘緩鐨凙ctiveKey欏圭洰銆?/p> 銆銆(2) 鍦ˋctiveKey.h鏂囦歡涓姞鍏OOKAPI緇撴瀯錛屾緇撴瀯鐢ㄦ潵瀛樺偍琚尅鎴狝PI鍑芥暟鍚嶇О銆佸師API鍑芥暟鍦板潃鍜屾浛浠e嚱鏁板湴鍧銆?/p> 銆銆銆typedef struct tag_HOOKAPI 銆銆(3) 鎵撳紑ActiveKey.cpp鏂囦歡錛岄鍏堝姞鍏ヤ竴涓嚱鏁幫紝鐢ㄤ簬瀹氫綅杈撳叆搴撳湪杈撳叆鏁版嵁孌典腑鐨処AT鍦板潃銆?a target="_blank">浠g爜濡備笅錛?/p> 銆銆銆extern "C" __declspec(dllexport)PIMAGE_IMPORT_DESCRIPTOR >e_lfanew)); return NULL; (pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress)); 銆銆鍐嶅姞鍏ヤ竴涓嚱鏁幫紝鐢ㄦ潵瀹氫綅琚尅鎴狝PI鍑芥暟鐨処AT欏瑰茍淇敼鍏跺唴瀹逛負(fù)鏇夸唬鍑芥暟鍦板潃銆?a target="_blank">浠g爜濡備笅錛?/p> 銆銆銆extern "C" __declspec(dllexport) >OriginalFirstThunk)); >FirstThunk)); >u1.AddressOfData)); &mbi_thunk.Protect); &dwOldProtect); 銆銆(4) 瀹氫箟鏇夸唬鍑芥暟錛屾瀹炰緥涓彧緇橫essageBoxA鍜宺ecv涓や釜API榪涜鎸℃埅銆?a target="_blank">浠g爜濡備笅錛?/p> 銆銆銆static int WINAPI MessageBoxA1 (HWND hWnd , LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) 銆銆(5) 鍦↘eyboardProc鍑芥暟涓姞鍏ユ縺媧繪尅鎴狝PI浠g爜錛屽湪if( wParam == 0X79 )璇彞涓悗闈㈠姞鍏ュ涓媏lse if璇彞錛?/p> 銆銆銆...... 銆銆(6) 鍦ˋctiveKey.cpp涓姞鍏ュご鏂囦歡澹版槑 "#include "wsock32.h"銆?浠庘滃伐紼嬧濊彍鍗曚腑閫夋嫨鈥滆緗濓紝寮瑰嚭Project Setting瀵硅瘽妗嗭紝閫夋嫨Link鏍囩錛屽湪鈥滃璞?搴撴ā鍧椻濅腑杈撳叆Ws2_32..lib銆?/p> 銆銆(7) 閲嶆柊緙栬瘧ActiveKey欏圭洰錛屼駭鐢烝ctiveKey.dll鏂囦歡錛屽皢鍏舵嫹璐濆埌Simulate.exe鐩綍涓嬨傝繍琛孲imulate.exe騫跺惎鍔?/p> 鍏ㄥ眬閽╁瓙銆傛縺媧諱換鎰忓簲鐢ㄧ▼搴忥紝鎸塅11閿悗錛岃繍琛屾紼嬪簭涓彲鑳借皟鐢∕essageBoxA鍑芥暟鐨勬搷浣滐紝鐪嬬湅淇℃伅妗嗘槸涓嶆槸鏈夋墍鍙樺寲 銆傚悓鏍鳳紝濡傛紼嬪簭姝e湪鎺ユ敹緗戠粶鏁版嵁鍖咃紝灝卞彲浠ュ疄鐜板皝鍖呭姛鑳戒簡銆?/p> 銆銆鍏佺粨鏉熻 銆銆闄や簡浠ヤ笂浠嬬粛鐨勫嚑縐?a target="_blank">娓告垙澶栨寕紼嬪簭甯哥敤鐨?a target="_blank">鎶鏈?/font>浠ュ錛屽湪涓浜涘鎸傜▼搴忎腑榪樹嬌鐢ㄤ簡娓告垙鏁版嵁淇敼鎶鏈?/font>銆?a target="_blank">娓告垙鍔犻?a target="_blank">鎶鏈?/font>絳?/p> 銆傚湪榪欑瘒鏂囩珷閲岋紝灝變笉閫愪竴浠嬬粛浜嗐?/p> 緗戠粶娓告垙澶栨寕鏍稿績?yōu)畞鍖呮彮瀵?/p> [鏂囩珷瀵艱] 銆?/p> 銆銆鍒湅榪欐槸灝佸寘榪欎竴闂錛屼絾鏄秹鍙?qiáng)鐨?a target="_blank">鎶鏈?/font>鑼冨洿寰堝箍鑼冿紝瀹炵幇鐨勬柟寮忎篃寰堝錛堟瘮濡傝APIHOOK,VXD,Winsock2閮藉彲浠ュ疄鐜?/p> 錛夛紝鍦ㄨ繖閲屾垜浠笉鍙兘姣忕鎶鏈?/font>鍜屾柟娉曢兘娑夊強(qiáng)錛屾墍浠ユ垜鍦ㄨ繖閲屼互Winsock2鎶鏈?/font>浣滆緇嗚瑙o紝灝辯畻浣滄姏鐮栧紩鐜夈?/p> 銆銆鐢變簬澶у鏁拌鑰呭灝佸寘綾?a target="_blank">緙栫▼涓嶆槸寰堜簡瑙o紝鎴戝湪榪欓噷灝辯畝鍗曚粙緇嶄竴涓嬬浉鍏?a target="_blank">鐭ヨ瘑錛?/p> 銆銆APIHooK錛?/p> 銆銆鐢變簬Windows鐨勬妸鍐呮牳鎻愪緵鐨勫姛鑳介兘灝佽鍒癆PI閲岄潰錛屾墍浠ュぇ瀹惰瀹炵幇鍔熻兘灝卞繀欏婚氳繃API錛屾崲鍙ヨ瘽璇村氨鏄垜浠鎯蟲崟 鑾鋒暟鎹皝鍖咃紝灝卞繀欏誨厛瑕佸緱鐭ラ亾騫朵笖鎹曡幏榪欎釜API錛屼粠API閲岄潰寰楀埌灝佸寘淇℃伅銆?/p> 銆銆VXD錛?/p> 銆銆鐩存帴閫氳繃鎺у埗VXD椹卞姩紼嬪簭鏉ュ疄鐜板皝鍖呬俊鎭殑鎹曡幏錛屼笉榪嘨XD鍙兘鐢ㄤ簬win9X銆?/p> 銆銆winsock2錛?/p> 銆銆winsock鏄疻indows緗戠粶緙栫▼鎺ュ彛錛寃insock宸ヤ綔鍦ㄥ簲鐢ㄥ眰錛屽畠鎻愪緵涓庡簳灞備紶杈?a target="_blank">鍗忚鏃犲叧鐨勯珮灞傛暟鎹紶杈?a target="_blank">緙栫▼鎺ュ彛錛?/p> winsock2鏄痺insock2.0鎻愪緵鐨?a target="_blank">鏈嶅姟鎻愪緵鑰呮帴鍙o紝浣嗗彧鑳藉湪win2000涓嬬敤銆?/p> 銆銆濂戒簡錛屾垜浠紑濮嬭繘鍏insock2灝佸寘寮?a target="_blank">緙栫▼鍚с?/p> 銆銆鍦ㄥ皝鍖?a target="_blank">緙栫▼閲岄潰鎴戝噯澶囧垎涓や釜姝ラ瀵瑰ぇ瀹惰繘琛岃瑙o細(xì)1銆佸皝鍖呯殑鎹曡幏錛?銆佸皝鍖呯殑鍙戦併?/p> 銆銆棣栧厛鎴戜滑瑕佸疄鐜扮殑鏄皝鍖呯殑鎹曡幏錛?/p> 銆銆Delphi鐨勫皝瑁呯殑winsock鏄?.0鐗堢殑錛屽緢鑷劧winsock2灝辯敤涓嶆垚銆傚鏋滆浣跨敤winsock2鎴戜滑瑕佸winsock2鍦―elphi閲岄潰 鍋氫竴涓帴鍙o紝鎵嶅彲浠ヤ嬌鐢╳insock2銆?/p> 銆銆1銆佸浣曞仛winsock2鐨勬帴鍙o紵 銆銆1錛夋垜浠鍏堝畾涔墂insock2.0鎵鐢ㄥ緱鍒扮殑綾誨瀷錛屽湪榪欓噷鎴戜滑浠SA_DATA綾誨瀷鍋氱ず鑼冿紝澶у鍙互涓句竴浠夸笁鐨勬潵瀹炵幇 winsock2鍏朵粬綾誨瀷鐨勫皝瑁呫?/p> 銆銆鎴戜滑瑕佺煡閬揥SA_DATA綾誨瀷浼?xì)琚敤浜嶹SAStartup(wVersionRequired: word; var WSData: TWSAData): Integer;錛屽ぇ瀹?/p> 浼?xì)鍙戠幇WSData鏄紩鐢ㄥ弬鏁幫紝鍦ㄤ紶鍏ュ弬鏁版椂浼犵殑鏄彉閲忕殑鍦板潃錛屾墍浠ユ垜浠WSA_DATA鍋氫互涓嬪皝瑁咃細(xì) 鍥犱負(fù)娑夊強(qiáng)鍒版鍦ㄨ繍浣滅殑緗戠粶娓告垙瀹夊叏闂錛屾墍浠ユ垜浠湪榪欓噷浠P鏁版嵁鍖呬負(fù)渚嬪仛灝佸寘鎹曡幏錛屽鏋滀笅闈㈢殑鏌愪簺鏁版嵁綾誨瀷鎮(zhèn)ㄤ笉鏄?/p> 寰堟竻妤氾紝璇鋒偍鏌ラ槄MSDN錛?/p>
铏界劧寰蔣鏀寔鍦ㄧ嚎瀹夎錛屼絾榪欑粷瀵逛笉瀹夊叏銆傚湪緋葷粺鏈叏閮ㄥ畨瑁呭畬涔嬪墠涓嶈榪炲叆緗戠粶錛岀壒鍒槸Internet錛佺敋鑷充笉瑕佹妸涓鍒囩‖浠墮兘榪炴帴濂芥潵瀹夎銆傚洜涓篧indows 2000瀹夎鏃訛紝鍦ㄨ緭鍏ョ敤鎴風(fēng)鐞嗗憳璐﹀彿鈥淎dministrator鈥濈殑瀵嗙爜鍚庯紝緋葷粺浼?xì)寰忕珛涓涓淎DMIN鈥濈殑鍏變韓璐﹀彿錛屼絾鏄茍娌℃湁鐢ㄥ垰杈撳叆鐨勫瘑鐮佹潵淇濇姢瀹冿紝榪欑鎯呭喌涓鐩翠細(xì)鎸佺畫鍒拌綆楁満鍐嶆鍚姩銆傚湪姝ゆ湡闂達(dá)紝浠諱綍浜洪兘鍙互閫氳繃鈥淎DMIN鈥濊繘鍏ョ郴緇燂紱鍚屾椂錛屽畨瑁呭畬鎴愶紝鍚勭鏈嶅姟浼?xì)椹笂鑷姩杩愯锛岃岃繖鏃剁殑鏈嶅姟鍣ㄨ繕鍒板鏄紡媧烇紝闈炲父瀹規(guī)槗浠庡閮ㄤ鏡鍏ャ?br />2銆佽閫夋嫨NTFS鏍煎紡鏉ュ垎鍖?br />銆銆鏈濂芥墍鏈夌殑鍒嗗尯閮芥槸NTFS鏍煎紡錛屽洜涓篘TFS鏍煎紡鐨勫垎鍖哄湪瀹夊叏鎬ф柟闈㈡洿鍔犳湁淇濋殰銆傚氨綆楀叾浠栧垎鍖洪噰鐢ㄥ埆鐨勬牸寮?濡侳AT32)錛屼絾鑷沖皯緋葷粺鎵鍦ㄧ殑鍒嗗尯涓簲鏄疦TFS鏍煎紡銆?br />鍙﹀錛屽簲鐢ㄧ▼搴忎笉瑕佸拰緋葷粺鏀懼湪鍚屼竴涓垎鍖轟腑錛屼互鍏嶆敾鍑昏呭埄鐢ㄥ簲鐢ㄧ▼搴忕殑婕忔礊(濡傚井杞殑IIS鐨勬紡媧?瀵艱嚧緋葷粺鏂囦歡鐨勬硠婕忥紝鐢氳嚦璁╁叆渚佃呰繙紼嬭幏鍙栫鐞嗗憳鏉冮檺銆?br />3銆佺郴緇熺増鏈殑閫夋嫨
鐗堟湰鐨勯夋嫨錛歐IN2000鏈夊悇縐嶈璦鐨勭増鏈紝瀵逛簬鎴戜滑鏉ヨ錛屽彲浠ラ夋嫨鑻辨枃鐗堟垨綆浣撲腑鏂囩増錛屾垜寮虹儓寤鴻錛氬湪璇█涓嶆垚涓洪殰紕嶇殑鎯呭喌涓嬶紝璇蜂竴瀹氫嬌鐢ㄨ嫳鏂囩増銆傝鐭ラ亾錛屽井杞殑浜у搧鏄互Bug &
Patch鑰岃憲縐扮殑錛屼腑鏂囩増鐨凚ug榪滆繙澶氫簬鑻辨枃鐗堬紝鑰岃ˉ涓佷竴鑸繕浼?xì)杩熻嚊_皯鍗婁釜鏈堬紙涔熷氨鏄涓鑸井杞叕甯冧簡婕忔礊鍚庝綘鐨勬満瀛愯繕浼?xì)鏈夊崐涓湀澶勪簬鏃犱繚鎶ょ姸鍐靛Q?
銆銆4銆佺粍浠剁殑瀹氬埗錛?br />win2000鍦ㄩ粯璁ゆ儏鍐典笅浼?xì)瀹夎涓浜涘父鐢ㄧ殑緇勪歡錛屼絾鏄鏄繖涓粯璁ゅ畨瑁呮槸寰堝嵄闄╃殑錛屼綘搴旇紜垏鐨勭煡閬撲綘闇瑕佸摢浜涙湇鍔★紝鑰屼笖浠呬粎瀹夎浣犵‘瀹為渶瑕佺殑鏈嶅姟錛屾牴鎹畨鍏ㄥ師鍒欙紝鏈灝戠殑鏈嶅姟+鏈灝忕殑鏉冮檺=鏈澶х殑瀹夊叏銆傚吀鍨嬬殑WEB鏈嶅姟鍣ㄩ渶瑕佺殑鏈灝忕粍浠墮夋嫨鏄細(xì)鍙畨瑁匢IS鐨凜om Files錛孖IS Snap-In錛學(xué)WW Server緇勪歡銆傚鏋滀綘紜疄闇瑕佸畨瑁呭叾浠栫粍浠訛紝璇鋒厧閲嶏紝鐗瑰埆鏄細(xì)Indexing Service, FrontPage 2000 Server Extensions, Internet Service Manager (HTML)榪欏嚑涓嵄闄╂湇鍔°?br />5銆佸垎鍖哄拰閫昏緫鐩樼殑鍒嗛厤
寤鴻鏈灝戝緩绔嬩袱涓垎鍖猴紝涓涓郴緇熷垎鍖猴紝涓涓簲鐢ㄧ▼搴忓垎鍖猴紝榪欐槸鍥犱負(fù)錛屽井杞殑IIS緇忓父浼?xì)鏈夋硠婕忔簮鐮?婧㈠嚭鐨勬紡媧烇紝濡傛灉鎶婄郴緇熷拰IIS鏀懼湪鍚屼竴涓┍鍔ㄥ櫒浼?xì)瀵艰嚧绯痪l熸枃浠剁殑娉勬紡鐢氳嚦鍏ヤ鏡鑰呰繙紼嬭幏鍙朅DMIN銆傛帹鑽愮殑瀹夊叏閰嶇疆鏄緩绔嬩笁涓昏緫椹卞姩鍣紝絎竴涓ぇ浜?G錛岀敤鏉ヨ緋葷粺鍜岄噸瑕佺殑鏃ュ織鏂囦歡錛岀浜屼釜鏀綢IS錛岀涓変釜鏀綟TP錛岃繖鏍鋒棤璁篒IS鎴朏TP鍑轟簡瀹夊叏婕忔礊閮戒笉浼?xì)鐩存帴濯勫搷鍒熬p葷粺鐩綍鍜岀郴緇熸枃浠躲傝鐭ラ亾錛孖IS鍜孎TP鏄澶栨湇鍔$殑錛屾瘮杈冨鏄撳嚭闂銆傝屾妸IIS鍜孎TP鍒嗗紑涓昏鏄負(fù)浜嗛槻姝㈠叆渚佃呬笂浼犵▼搴忓茍浠嶪IS涓繍琛屻傦紙榪欎釜鍙兘浼?xì)瀵艰嚧绋嬪簭寮鍙戜漢鍛樺拰緙栬緫鐨勮嫤鎭鹼紝綆′粬鍛紝鍙嶆浣犳槸綆$悊鍛楯錛?br />6銆佸畨瑁呮潃姣掕蔣浠躲?br />鏉姣掕蔣浠朵笉浠呰兘鏉鎺変竴浜涜憲鍚嶇殑鐥呮瘨錛岃繕鑳芥煡鏉澶ч噺鏈ㄩ┈鍜屽悗闂ㄧ▼搴忥紝鍥犳瑕佹敞鎰忕粡甯歌繍琛岀▼搴忓茍鍗囩駭鐥呮瘨搴撱?7銆佸畨瑁呴槻鐏銆?br />8銆佸畨瑁呯郴緇熻ˉ涓併?br />鍒板井杞綉绔欎笅杞芥渶鏂扮殑琛ヤ竵紼嬪簭錛?br />緇忓父璁塊棶寰蔣鍜屼竴浜涘畨鍏ㄧ珯鐐癸紝涓嬭澆鏈鏂扮殑Service Pack鍜屾紡媧炶ˉ涓侊紝鏄繚闅滄湇鍔″櫒闀夸箙瀹夊叏鐨勬儫涓鏂規(guī)硶銆?br />9銆佸畨瑁呴『搴忕殑閫夋嫨
棣栧厛錛屼綍鏃舵帴鍏ョ綉緇滐細(xì)Win2000鍦ㄥ畨瑁呮椂鐨凙DMIN$鐨勫叡浜殑婕忔礊錛涘悓鏃訛紝鍙瀹夎涓瀹屾垚錛屽悇縐嶆湇鍔″氨浼?xì)鑷姩杩愯锛岃岃繖鏃剁殑鏈嶅姟鍣ㄦ槸婊¤韓婕忔礊錛岄潪甯稿鏄撹繘鍏ョ殑錛屽洜姝わ紝鍦ㄥ畬鍏ㄥ畨瑁呭茍閰嶇疆濂絯in2000 SERVER涔嬪墠錛屼竴瀹氫笉瑕佹妸涓繪満鎺ュ叆緗戠粶銆?
鍏舵錛岃ˉ涓佺殑瀹夎錛氳ˉ涓佺殑瀹夎搴旇鍦ㄦ墍鏈夊簲鐢ㄧ▼搴忓畨瑁呭畬涔嬪悗錛屽洜涓鴻ˉ涓佺▼搴忓線寰瑕佹浛鎹?淇敼鏌愪簺緋葷粺鏂囦歡錛屽鏋滃厛瀹夎琛ヤ竵鍐嶅畨瑁呭簲鐢ㄧ▼搴忔湁鍙兘瀵艱嚧琛ヤ竵涓嶈兘璧峰埌搴旀湁鐨勬晥鏋滐紝渚嬪錛欼IS鐨凥otFix灝辮姹傛瘡嬈℃洿鏀笽IS鐨勯厤緗兘闇瑕佸畨瑁呫?br />緋葷粺鐨勫畨鍏ㄨ緗?br />1銆佺敤鎴峰畨鍏ㄨ緗?br />鐢ㄦ埛甯愬彿媯鏌ワ紝鍋滄涓嶉渶瑕佺殑甯愬彿錛屽緩璁洿鏀歸粯璁ょ殑甯愬彿鍚嶃?br />1)銆佺鐢℅uest璐﹀彿
銆銆鍦ㄨ綆楁満綆$悊鐨勭敤鎴烽噷闈㈡妸Guest璐﹀彿紱佺敤銆備負(fù)浜嗕繚闄╄搗瑙侊紝鏈濂界粰Guest鍔犱竴涓鏉傜殑瀵嗙爜銆?
2)銆侀檺鍒朵笉蹇呰鐨勭敤鎴?
銆銆鍘繪帀鎵鏈夌殑Duplicate User鐢ㄦ埛銆佹祴璇曠敤鎴楓佸叡浜敤鎴風(fēng)瓑絳夈傜敤鎴風(fēng)粍絳栫暐璁劇疆鐩稿簲鏉冮檺錛屽茍涓旂粡甯告鏌ョ郴緇熺殑鐢ㄦ埛錛屽垹闄ゅ凡緇忎笉鍐嶄嬌鐢ㄧ殑鐢ㄦ埛銆?br />3)銆佸垱寤轟袱涓鐞嗗憳璐﹀彿
銆銆鍒涘緩涓涓竴鑸潈闄愮敤鎴風(fēng)敤鏉ユ敹淇′互鍙?qiáng)澶勭悊涓浜涙棩甯鎬簨鐗╋紝鍙︿竴涓嫢鏈堿dministrators鏉冮檺鐨勭敤鎴峰彧鍦ㄩ渶瑕佺殑鏃跺欎嬌鐢ㄣ?
4)銆佹妸緋葷粺Administrator璐﹀彿鏀瑰悕
銆銆澶у閮界煡閬擄紝W(xué)indows 2000鐨凙dministrator鐢ㄦ埛鏄笉鑳借鍋滅敤鐨勶紝榪欐剰鍛崇潃鍒漢鍙互涓閬嶅張涓閬嶅湴灝濊瘯榪欎釜鐢ㄦ埛鐨勫瘑鐮併傚敖閲忔妸瀹冧吉瑁呮垚鏅氱敤鎴鳳紝姣斿鏀規(guī)垚Guesycludx銆?
5)銆佸垱寤轟竴涓櫡闃辯敤鎴?
銆銆浠涔堟槸闄烽槺鐢ㄦ埛?鍗沖垱寤轟竴涓悕涓衡淎dministrator鈥濈殑鏈湴鐢ㄦ埛錛屾妸瀹冪殑鏉冮檺璁劇疆鎴愭渶浣庯紝浠涔堜簨涔熷共涓嶄簡鐨勯偅縐嶏紝騫朵笖鍔犱笂涓涓秴榪?0浣嶇殑瓚呯駭澶嶆潅瀵嗙爜銆傝繖鏍峰彲浠ヨ鎯沖叆渚電殑浜烘參鎱㈠繖涓孌墊椂闂淬?
6)銆佹妸鍏變韓鏂囦歡鐨勬潈闄愪粠Everyone緇勬敼鎴愭巿鏉冪敤鎴?
銆銆涓嶈鎶婂叡浜枃浠剁殑鐢ㄦ埛璁劇疆鎴愨淓veryone鈥濈粍錛屽寘鎷墦鍗板叡浜紝榛樿鐨勫睘鎬у氨鏄淓veryone鈥濈粍鐨勩?
7)銆佸紑鍚敤鎴風(fēng)瓥鐣?錛堜笉寤鴻錛?br />銆銆浣跨敤鐢ㄦ埛絳栫暐錛屽垎鍒緗浣嶇敤鎴烽攣瀹氳鏁板櫒鏃墮棿涓?0鍒嗛挓錛岀敤鎴烽攣瀹氭椂闂翠負(fù)20鍒嗛挓錛岀敤鎴烽攣瀹氶槇鍊間負(fù)3嬈°?
8)銆佷笉璁╃郴緇熸樉紺轟笂嬈$櫥褰曠殑鐢ㄦ埛鍚?錛堝彲閫夛級
鎵撳紑娉ㄥ唽琛ㄧ紪杈戝櫒騫舵壘鍒版敞鍐岃〃欏笻KLMSoftwareMicrosoftWindowsTCurrentVersionWinlogonDont-DisplayLastUserName錛屾妸閿兼敼鎴?
9)銆佺郴緇熻處鍙?鍏變韓鍒楄〃
Win2000鐨勯粯璁ゅ畨瑁呭厑璁鎬換浣曠敤鎴烽氳繃絀虹敤鎴峰緱鍒扮郴緇熸墍鏈夎處鍙?鍏變韓鍒楄〃錛岃繖涓湰鏉ユ槸涓轟簡鏂逛究灞鍩熺綉鐢ㄦ埛鍏變韓鏂囦歡鐨勶紝浣嗘槸涓涓繙紼嬬敤鎴蜂篃鍙互寰楀埌浣犵殑鐢ㄦ埛鍒楄〃騫朵嬌鐢ㄦ毚鍔涙硶鐮磋В鐢ㄦ埛瀵嗙爜銆傚彲浠ラ氳繃鏇存敼娉ㄥ唽琛↙ocal_Machine\System\CurrentControlSet\Control\LSA-RestrictAnonymous = 1鏉ョ姝?39絀鴻繛鎺ワ紝榪樺彲浠ュ湪win2000鐨勬湰鍦板畨鍏ㄧ瓥鐣ワ紙濡傛灉鏄煙鏈嶅姟鍣ㄥ氨鏄湪鍩熸湇鍔″櫒瀹夊叏鍜屽煙瀹夊叏絳栫暐涓級灝辨湁榪欐牱鐨勯夐」RestrictAnonymous錛堝尶鍚嶈繛鎺ョ殑棰濆闄愬埗錛夛紝榪欎釜閫夐」鏈変笁涓鹼細(xì) 0錛歂one. Rely on default permissions錛堟棤錛屽彇鍐充簬榛樿鐨勬潈闄愶級 1錛欴o not allow enumeration of SAM accounts and shares錛堜笉鍏佽鏋氫婦SAM甯愬彿鍜屽叡浜級 2錛歂o access without explicit anonymous permissions錛堟病鏈夋樉寮忓尶鍚嶆潈闄愬氨涓嶅厑璁歌闂級 0榪欎釜鍊兼槸緋葷粺榛樿鐨勶紝浠涔堥檺鍒墮兘娌℃湁錛岃繙紼嬬敤鎴峰彲浠ョ煡閬撲綘鏈哄櫒涓婃墍鏈夌殑璐﹀彿銆佺粍淇℃伅銆佸叡浜洰褰曘佺綉緇滀紶杈撳垪琛?NetServerTransportEnum絳夌瓑錛屽鏈嶅姟鍣ㄦ潵璇磋繖鏍風(fēng)殑璁劇疆闈炲父鍗遍櫓銆?1榪欎釜鍊兼槸鍙厑璁?dāng)R潪NULL鐢ㄦ埛瀛樺彇SAM璐﹀彿淇℃伅鍜屽叡浜俊鎭?2榪欎釜鍊兼槸鍦╳in2000涓墠鏀寔鐨勶紝濡傛灉涓嶆兂鏈変換浣曞叡浜紝灝辮涓?銆備竴鑸帹鑽愯涓?銆?br />2銆?鍙d護(hù)瀹夊叏璁劇疆
1)銆佷嬌鐢ㄥ畨鍏ㄥ瘑鐮?
銆銆瑕佹敞鎰忓瘑鐮佺殑澶嶆潅鎬э紝榪樿璁頒綇緇忓父鏀瑰瘑鐮併?
2)銆佸紑鍚瘑鐮佺瓥鐣?
娉ㄦ剰搴旂敤瀵嗙爜絳栫暐錛屽鍚敤瀵嗙爜澶嶆潅鎬ц姹傦紝璁劇疆瀵嗙爜闀垮害鏈灝忓間負(fù)8浣嶏紝璁劇疆寮哄埗瀵嗙爜鍘嗗彶涓?嬈★紝鏃墮棿涓?2澶┿?
3銆?緋葷粺瀹夊叏璁劇疆
1)銆佸埄鐢╓indows 2000鐨勫畨鍏ㄩ厤緗伐鍏鋒潵閰嶇疆瀹夊叏絳栫暐
寰蔣鎻愪緵浜嗕竴濂楀熀浜嶮MC錛堢鐞嗘帶鍒跺彴錛夊畨鍏ㄩ厤緗拰鍒嗘瀽宸ュ叿錛屽埄鐢ㄥ畠浠綘鍙互寰堟柟渚垮湴閰嶇疆浣犵殑鏈嶅姟鍣ㄤ互婊¤凍浣犵殑瑕佹眰銆傚叿浣撳唴瀹硅鍙傝冨井杞富欏碉細(xì)http://www.microsoft.com/windows2000/techinfo/
howitworks/security/sctoolset.asp
2)銆佸畨鍏ㄦ棩蹇楋細(xì)Win2000鐨勯粯璁ゅ畨瑁呮槸涓嶅紑浠諱綍瀹夊叏瀹℃牳鐨勶紒鍙互鍒版湰鍦板畨鍏ㄧ瓥鐣?br />->瀹℃牳絳栫暐涓墦寮鐩稿簲鐨勫鏍革紝鎺ㄨ崘鐨勫鏍告槸錛?br />璐︽埛綆$悊 鎴愬姛 澶辮觸
鐧誨綍浜嬩歡 鎴愬姛 澶辮觸
瀵硅薄璁塊棶 澶辮觸
絳栫暐鏇存敼 鎴愬姛 澶辮觸
鐗規(guī)潈浣跨敤 澶辮觸
緋葷粺浜嬩歡 鎴愬姛 澶辮觸
鐩綍鏈嶅姟璁塊棶 澶辮觸
璐︽埛鐧誨綍浜嬩歡 鎴愬姛 澶辮觸
錛堝鏍擱」鐩皯鐨勭己鐐規(guī)槸涓囦竴浣犳兂鐪嬪彂鐜版病鏈夎褰曢偅灝變竴鐐歸兘娌¤緳錛涘鏍擱」鐩お澶氫笉浠呬細(xì)鍗犵敤緋葷粺璧勬簮鑰屼笖浼?xì)瀵艰嚧浣犳犚?guī)湰娌$┖鍘葷湅錛岃繖鏍峰氨澶卞幓浜嗗鏍哥殑鎰忎箟銆傦級
涓庝箣鐩稿叧鐨勬槸錛?
鍦ㄨ處鎴風(fēng)瓥鐣?>瀵嗙爜絳栫暐涓瀹氾細(xì)
瀵嗙爜澶嶆潅鎬ц姹?鍚敤
瀵嗙爜闀垮害鏈灝忓?8浣?
寮哄埗瀵嗙爜鍘嗗彶 5嬈?
鏈闀垮瓨鐣欐湡 42澶?
鍦ㄨ處鎴風(fēng)瓥鐣?>璐︽埛閿佸畾絳栫暐涓瀹氾細(xì)
璐︽埛閿佸畾 5嬈¢敊璇櫥褰?
閿佸畾鏃墮棿 20鍒嗛挓
澶嶄綅閿佸畾璁℃暟 20鍒嗛挓
鍚屾牱錛孴erminal Service鐨勫畨鍏ㄦ棩蹇楅粯璁や篃鏄笉寮鐨勶紝鎴戜滑鍙互鍦═erminal Service Configration錛堣繙紼嬫湇鍔¢厤緗級-鏉冮檺-楂樼駭涓厤緗畨鍏ㄥ鏍革紝涓鑸潵璇村彧瑕佽褰曠櫥褰曘佹敞閿浜嬩歡灝卞彲浠ヤ簡銆?br />3)銆佺洰褰曞拰鏂囦歡鏉冮檺錛?
涓轟簡鎺у埗濂芥湇鍔″櫒涓婄敤鎴風(fēng)殑鏉冮檺錛屽悓鏃朵篃涓轟簡棰勯槻浠ュ悗鍙兘鐨勫叆渚靛拰婧㈠嚭錛屾垜浠繕蹇呴』闈炲父灝忓績鍦拌緗洰褰曞拰鏂囦歡鐨勮闂潈闄愶紝NT鐨勮闂潈闄愬垎涓猴細(xì)璇誨彇銆佸啓鍏ャ佽鍙栧強(qiáng)鎵ц銆佷慨鏀廣佸垪鐩綍銆佸畬鍏ㄦ帶鍒躲傚湪榛樿鐨勬儏鍐典笅錛屽ぇ澶氭暟鐨勬枃浠跺す瀵規(guī)墍鏈夌敤鎴鳳紙Everyone榪欎釜緇勶級鏄畬鍏ㄦ暈寮鐨勶紙F(tuán)ull Control錛夛紝浣犻渶瑕佹牴鎹簲鐢ㄧ殑闇瑕佽繘琛屾潈闄愰噸璁俱?
鍦ㄨ繘琛屾潈闄愭帶鍒舵椂錛岃璁頒綇浠ヤ笅鍑犱釜鍘熷垯錛?
1>闄愭槸绱鐨勶細(xì)濡傛灉涓涓敤鎴峰悓鏃跺睘浜庝袱涓粍錛岄偅涔堜粬灝辨湁浜嗚繖涓や釜緇勬墍鍏佽鐨勬墍鏈夋潈闄愶紱
2>鎷掔粷鐨勬潈闄愯姣斿厑璁哥殑鏉冮檺楂橈紙鎷掔粷絳栫暐浼?xì)鍏堟墽琛屽Q夊鏋滀竴涓敤鎴峰睘浜庝竴涓鎷掔粷璁塊棶鏌愪釜璧勬簮鐨勭粍錛岄偅涔堜笉綆″叾浠栫殑鏉冮檺璁劇疆緇欎粬寮鏀句簡澶氬皯鏉冮檺錛屼粬涔熶竴瀹氫笉鑳借闂繖涓祫婧愩傛墍浠ヨ闈炲父灝忓績鍦頒嬌鐢ㄦ嫆緇濓紝浠諱綍涓涓笉褰撶殑鎷掔粷閮芥湁鍙兘閫犳垚緋葷粺鏃犳硶姝e父榪愯錛?
3>鏂囦歡鏉冮檺姣旀枃浠跺す鏉冮檺楂?br />4>鍒╃敤鐢ㄦ埛緇勬潵榪涜鏉冮檺鎺у埗鏄竴涓垚鐔熺殑緋葷粺綆$悊鍛樺繀欏誨叿鏈夌殑浼樿壇涔?fàn)鎯箣涓錛?
5>浠呯粰鐢ㄦ埛鐪熸闇瑕佺殑鏉冮檺錛屾潈闄愮殑鏈灝忓寲鍘熷垯鏄畨鍏ㄧ殑閲嶈淇濋殰錛?br />4)銆佺姝㈠緩绔嬬┖榪炴帴錛圛PC錛勶級
榛樿鎯呭喌涓嬶紝浠諱綍鐢ㄦ埛閮藉彲閫氳繃絀鴻繛鎺ヨ繛涓婃湇鍔″櫒錛岃繘鑰屾灇涓懼嚭璐﹀彿錛岀寽嫻嬪瘑鐮併傛垜浠彲浠ラ氳繃淇敼娉ㄥ唽琛ㄦ潵紱佹寤虹珛絀鴻繛鎺ワ細(xì)鍗蟲妸鈥?Local_Machine\System\CurrentControlSet\Control\LSA-RestrictAnonymous鈥?鐨勫兼敼鎴愨?鈥濆嵆鍙傚鏋滀嬌鐢ㄢ?鈥濆彲鑳戒細(xì)閫犳垚浣犵殑涓浜涙湇鍔℃棤娉曞惎鍔紝濡係QL Server
姝ゅ錛屽畨鍏ㄥ拰搴旂敤鍦ㄥ緢澶氭椂鍊欐槸鐭涚浘鐨勩傚洜姝わ紝浣犻渶瑕佸湪鍏朵腑鎵懼埌騫寵 鐐癸紝濡傛灉瀹夊叏鍘熷垯濡ㄧ浜嗙郴緇熷簲鐢紝閭d箞榪欎釜瀹夊叏鍘熷垯涔熶笉鏄竴涓ソ鐨勫師鍒?br />5)銆佺姝㈢鐞嗗叡浜?br />HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet
\Services\LanmanServer\Parameters欏?br />瀵逛簬鏈嶅姟鍣紝娣誨姞閿尖淎utoShareServer鈥濓紝綾誨瀷涓衡淩EG_DWORD鈥濓紝鍊間負(fù)鈥?鈥濄?br />瀵逛簬瀹㈡埛鏈猴紝娣誨姞閿尖淎utoShareWks鈥濓紝綾誨瀷涓衡淩EG_DWORD鈥濓紝鍊間負(fù)鈥?鈥濄?br />(鍏抽棴server鏈嶅姟)
6)銆佽繕鏈変竴涓氨鏄?39绔彛錛?39绔彛鏄疦etBIOS銆Session绔彛錛岀敤鏉ユ枃浠跺拰鎵撳嵃鍏變韓錛屾敞鎰忕殑鏄繍琛宻amba鐨剈nix鏈哄櫒涔熷紑鏀句簡139绔彛錛屽姛鑳戒竴鏍楓備互鍓嶆祦鍏?000鐢ㄦ潵鍒ゆ柇瀵規(guī)柟涓繪満綾誨瀷涓嶅お鍑嗙‘錛屼及璁″氨鏄?39绔彛寮鏀炬棦璁や負(fù)鏄疦T鏈猴紝鐜板湪濂戒簡銆?
鍏抽棴139鍙e惉鏂規(guī)硶鏄湪鈥滅綉緇滃拰鎷ㄥ彿榪炴帴鈥濅腑鈥滄湰鍦拌繛鎺モ濅腑閫夊彇鈥淚nternet鍗忚(TCP/IP)鈥濆睘鎬э紝榪涘叆鈥滈珮綰CP/IP璁劇疆鈥濃淲INS璁劇疆鈥濋噷闈㈡湁涓欏光滅鐢═CP/IP鐨凬ETBIOS鈥濓紝鎵撳嬀灝卞叧闂簡139绔彛銆?
瀵逛簬涓漢鐢ㄦ埛鏉ヨ錛屽彲浠ュ湪鍚勯」鏈嶅姟灞炴ц緗腑璁句負(fù)鈥滅鐢ㄢ濓紝浠ュ厤涓嬫閲嶅惎鏈嶅姟涔熼噸鏂板惎鍔紝绔彛涔熷紑鏀句簡
7)銆佷嬌鐢ㄧ粍絳栫暐錛孖P絳栫暐
------------------------
8)銆侀槻鑼僑YN鏀誨嚮
浣跨敤SYN娣規(guī)病鏀誨嚮淇濇姢
鐩稿叧鐨勫奸」鍦?br />HKLM\SYSTEM\CurrentControlSet\Service\Tcpip\Parameters涓嬨?br />1錛?DWORD錛歋ynAttackProtect錛氬畾涔変簡鏄惁鍏佽SYN娣規(guī)病鏀誨嚮淇濇姢錛屽?琛ㄧず鍏佽璧風(fēng)敤WIN2000鐨凷YN娣規(guī)病鏀誨嚮淇濇姢銆?br />2錛?DWORD錛歍cpMaxConnectResponseRetransmissions錛氬畾涔変簡瀵逛簬榪炴帴璇鋒眰鍥炲簲鍖呯殑閲嶅彂嬈℃暟銆傚間負(fù)1錛屽垯SYN娣規(guī)病鏀誨嚮涓嶄細(xì)鏈夋晥鏋滐紝浣嗘槸榪欐牱浼?xì)閫犳垚榪炴帴璇鋒眰澶辮觸鍑犵巼鐨勫楂樸係YN娣規(guī)病鏀誨嚮淇濇姢鍙湁鍦ㄨ鍊?gt;=2鏃舵墠浼?xì)琚惎鐢ㄥQ岄粯璁ゅ間負(fù)3銆?br />錛堜笂杈逛袱涓煎畾涔夋槸鍚﹀厑璁窼YN娣規(guī)病鏀誨嚮淇濇姢錛屼笅闈笁涓垯瀹氫箟浜嗘縺媧籗YN娣規(guī)病鏀誨嚮淇濇姢鐨勬潯浠訛紝婊¤凍鍏朵腑涔嬩竴錛屽垯緋葷粺鑷姩嬋媧籗YN娣規(guī)病鏀誨嚮淇濇姢銆傦級
3錛?DWORD錛歍cpMaxHalfOpen錛氬畾涔夎兘澶熷浜嶴YN_RECEIVED鐘舵佺殑TCP榪炴帴鐨勬暟鐩傞粯璁ゅ?00銆?br />4錛?TcpMaxHalfOpenRetried錛氬畾涔夊湪閲嶆柊鍙戦佽繛鎺ヨ姹傚悗錛屼粛鐒跺浜嶴YN_RECEIVED鐘舵佺殑TCP榪炴帴鐨勬暟鐩傞粯璁ゅ?0銆?br />5錛?TcpMaxPortsExhausted錛氬畾涔夌郴緇熸嫆緇濊繛鎺ヨ姹傜殑嬈℃暟銆傞粯璁ゅ?銆?br />鍑忓皬syn-ack鍖呯殑鍝嶅簲鏃墮棿銆?br />HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\TcpMaxConnectResponseRetransmissions瀹氫箟浜嗛噸鍙慡YN-ACK鍖呯殑嬈℃暟銆?br />澧炲ぇNETBT鐨勮繛鎺ュ潡澧炲姞騫呭害鍜屾渶澶ф暟鍣ㄣ侼ETBT浣跨敤139绔彛銆?br />HKLM\SYSTEM\CurrentControlSet\Services\NetBt\Parameters\BacklogIncrement榛樿鍊間負(fù)3錛屾渶澶?0錛屾渶灝?銆?br />HKLM\SYSTEM\CurrentControlSet\Services\NetBt\Parameters\MaxConnBackLog榛樿鍊間負(fù)1000錛屾渶澶у彲鍙?0000銆?br />鍔ㄦ侀厤緗瓸acklog銆?br />鐩稿叧鐨勫奸」鍦℉KLM\SYSTEM\CurrentControlSet\Service\AFD\Parameters涓?br />1) DWORD錛欵nableDynamicBacklog錛氬畾涔夋槸鍚﹀厑璁稿姩鎬丅acklog錛岄粯璁や負(fù)0錛?涓哄厑璁搞?br />2) DWORD錛歁inimumDynamicBacklog錛氬畾涔夊姩鎬丅acklog鍒嗛厤鐨勬湭浣跨敤鐨勮嚜鐢辮繛鎺ョ殑鏈灝忔暟鐩傞粯璁ゅ間負(fù)0錛屽緩璁涓?0銆?br />3) DWORD錛歁aximumDynamicBacklog錛氬畾涔夋渶澶р滃噯鈥濊繛鎺ユ暟鐩傚ぇ灝忓彇鍐充簬鍐呭瓨鐨勫ぇ灝忥紝涓鑸瘡32M鏈澶у彲浠ュ鍔?000涓?br />4) DWORD錛欴ynamicBacklogGrowthDelta錛氬畾涔夋瘡嬈″鍔犵殑鑷敱榪炴帴鏁扮洰錛屽緩璁緗負(fù)10銆?br />10)銆侀闃睤oS錛?
鍦ㄦ敞鍐岃〃HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters涓洿鏀逛互涓嬪煎彲浠ラ槻寰′竴瀹氬己搴︾殑DoS鏀誨嚮
SynAttackProtect REG_DWORD 2
EnablePMTUDiscovery REG_DWORD 0
NoNameReleaseOnDemand REG_DWORD 1
EnableDeadGWDetect REG_DWORD 0
KeepAliveTime REG_DWORD 300,000
PerformRouterDiscovery REG_DWORD 0
EnableICMPRedirects REG_DWORD 0
11)銆侀槻姝CMP閲嶅畾鍚戞姤鏂囩殑鏀誨嚮
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\ParametersEnableICMPRedirects REG_DWORD 0x0(榛樿鍊間負(fù)0x1)
璇ュ弬鏁版帶鍒禬indows 2000鏄惁浼?xì)鏀瑰彉鍏惰矾鐢辫〃浠ュ搷搴斁|戠粶璁懼(濡傝礬鐢卞櫒)鍙戦佺粰瀹冪殑ICMP閲嶅畾鍚戞秷鎭紝鏈夋椂浼?xì)琚埄鐢ㄦ潵骞插潖浜嬨俉in2000涓粯璁ゅ間負(fù)1錛岃〃紺哄搷搴擨CMP閲嶅畾鍚戞姤鏂囥?br />12)銆佺姝㈠搷搴擨CMP璺敱閫氬憡鎶ユ枃
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\interfacePerformRouterDiscovery REG_DWORD 0x0(榛樿鍊間負(fù)0x2)
鈥淚CMP璺敱鍏憡鈥濆姛鑳藉彲閫犳垚浠栦漢璁$畻鏈虹殑緗戠粶榪炴帴寮傚父,鏁版嵁琚獌鍚紝璁$畻鏈鴻鐢ㄤ簬嫻侀噺鏀誨嚮絳変弗閲嶅悗鏋溿傛闂鏇懼鑷存牎鍥綉鏌愪簺灞鍩熺綉澶ч潰縐紝闀挎椂闂寸殑緗戠粶寮傚父銆傚緩璁叧闂搷搴擨CMP璺敱閫氬憡鎶ユ枃.Win2000涓粯璁ゅ間負(fù)2錛岃〃紺哄綋DHCP鍙戦佽礬鐢卞櫒鍙戠幇閫夐」鏃跺惎鐢ㄣ?br />13)銆佽緗敓瀛樻椂闂?br />HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\ParametersDefaultTTL REG_DWORD 0-0xff(0-255 鍗佽繘鍒?榛樿鍊?28)
鎸囧畾浼犲嚭IP鏁版嵁鍖呬腑璁劇疆鐨勯粯璁ょ敓瀛樻椂闂?TTL)鍊箋俆TL鍐沖畾浜咺P鏁版嵁鍖呭湪鍒拌揪鐩爣鍓嶅湪緗戠粶涓敓瀛樼殑鏈澶ф椂闂淬傚畠瀹為檯涓婇檺瀹氫簡IP鏁版嵁鍖呭湪涓㈠純鍓嶅厑璁?dāng)R氳繃鐨勮礬鐢卞櫒鏁伴噺.鏈夋椂鍒╃敤姝ゆ暟鍊兼潵鎺㈡祴榪滅▼涓繪満*浣滅郴緇熴?br />14)銆佷笉鏀寔IGMP鍗忚
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\ParametersIGMPLevel REG_DWORD 0x0(榛樿鍊間負(fù)0x2)
璁板緱Win9x涓嬫湁涓猙ug錛屽氨鏄敤鍙互鐢↖GMP浣垮埆浜鴻摑灞忥紝淇敼娉ㄥ唽琛ㄥ彲浠ヤ慨姝h繖涓猙ug銆俉in2000铏界劧娌¤繖涓猙ug浜嗭紝浣咺GMP騫朵笉鏄繀瑕佺殑錛屽洜姝ょ収鏍峰彲浠ュ幓鎺夈傛敼鎴?鍚庣敤route print灝嗙湅涓嶅埌閭d釜璁ㄥ帉鐨?24.0.0.0欏逛簡銆?br />15)銆佽緗產(chǎn)rp緙撳瓨鑰佸寲鏃墮棿璁劇疆
HKLM\SYSTEM\CurrentControlSet\Services:\Tcpip\Parameters
ArpCacheLife REG_DWORD 0-0xFFFFFFFF(縐掓暟,榛樿鍊間負(fù)120縐?
ArpCacheMinReferencedLife REG_DWORD 0-0xFFFFFFFF(縐掓暟,榛樿鍊間負(fù)600)
濡傛灉ArpCacheLife澶т簬鎴栫瓑浜嶢rpCacheMinReferencedLife錛屽垯寮曠敤鎴栨湭寮曠敤鐨凙RP緙撳瓨欏瑰湪ArpCacheLife縐掑悗鍒版湡銆傚鏋淎rpCacheLife灝忎簬ArpCacheMinReferencedLife錛屾湭寮曠敤欏瑰湪ArpCacheLife縐掑悗鍒版湡錛岃屽紩鐢ㄩ」鍦ˋrpCacheMinReferencedLife縐掑悗鍒版湡銆傛瘡嬈″皢鍑虹珯鏁版嵁鍖呭彂閫佸埌欏圭殑IP鍦板潃鏃訛紝灝變細(xì)寮曠敤ARP緙撳瓨涓殑欏廣?br />
16)銆佺姝㈡緗戝叧鐩戞祴鎶鏈?br />HKLM\SYSTEM\CurrentControlSet\Services:\Tcpip\Parameters
EnableDeadGWDetect REG_DWORD 0x0(榛樿鍊間負(fù)ox1)
濡傛灉浣犺緗簡澶氫釜緗戝叧錛岄偅涔堜綘鐨勬満鍣ㄥ湪澶勭悊澶氫釜榪炴帴鏈夊洶闅炬椂錛屽氨浼?xì)鑷姩鏀圭敤澶囦唤缃戝吇I紝鏈夋椂鍊欒繖騫朵笉鏄竴欏瑰ソ涓繪剰錛屽緩璁姝㈡緗戝叧鐩戞祴銆?br />17)銆佷笉鏀寔璺敱鍔熻兘
HKLM\SYSTEM\CurrentControlSet\Services:\Tcpip\Parameters
IPEnableRouter REG_DWORD 0x0(榛樿鍊間負(fù)0x0)
鎶婂艱緗負(fù)0x1鍙互浣縒in2000鍏峰璺敱鍔熻兘錛岀敱姝ゅ甫鏉ヤ笉蹇呰鐨勯棶棰樸?br />18)銆佸仛NAT鏃舵斁澶ц漿鎹㈢殑瀵瑰绔彛鏈澶у?br />HKLM\SYSTEM\CurrentControlSet\Services:\Tcpip\Parameters
MaxUserPort REG_DWORD 5000-65534(鍗佽繘鍒?(榛樿鍊?x1388--鍗佽繘鍒朵負(fù)5000)
褰撳簲鐢ㄧ▼搴忎粠緋葷粺璇鋒眰鍙敤鐨勭敤鎴風(fēng)鍙f暟鏃訛紝璇ュ弬鏁版帶鍒舵墍浣跨敤鐨勬渶澶х鍙f暟銆傛甯告儏鍐典笅錛岀煭鏈熺鍙g殑鍒嗛厤鏁伴噺涓?024-5000銆傚皢璇ュ弬鏁拌緗埌鏈夋晥鑼冨洿浠ュ鏃訛紝灝變細(xì)浣跨敤鏈鎺ヨ繎鐨勬湁鏁堟暟鍊?5000鎴?5534)銆備嬌鐢∟AT鏃跺緩璁妸鍊兼斁澶х偣銆?br />19)銆佷慨鏀筂AC鍦板潃
HKLM\SYSTEM\CurrentControlSet\Control\Class鎵懼埌鍙崇獥鍙g殑璇存槑涓?緗戝崱"鐨勭洰褰曪紝姣斿璇存槸{4D36E972-E325-11CE-BFC1-08002BE10318}灞曞紑涔嬶紝鍦ㄥ叾涓?000,0001,0002...鐨勫垎鏀腑鎵懼埌"DriverDesc"鐨勯敭鍊間負(fù)浣犵綉鍗$殑璇存槑錛屾瘮濡傝"DriverDesc"鐨勫間負(fù)"Intel® 82559 Fast Ethernet LAN on Motherboard"鐒跺悗鍦ㄥ彸紿楀彛鏂板緩涓瀛楃涓插鹼紝鍚嶅瓧涓?Networkaddress"錛屽唴瀹逛負(fù)浣犳兂瑕佺殑MAC鍊鹼紝姣斿璇存槸"004040404040"鐒跺悗閲嶈搗璁$畻鏈猴紝ipconfig /all鐪嬬湅銆?br />20)銆佺姝㈠厜鐩樼殑鑷姩榪愯鍔熻兘
Windows 2000鐨勫厜鐩樼殑鑷姩榪愯鍔熻兘涔熸槸緋葷粺瀹夊叏鐨勯殣鎮(zhèn)o紝鍏夌洏涓彧瑕佸瓨鍦╝utorun錛巌nf鏂囦歡錛屽垯緋葷粺浼?xì)鑷姩璇曞浘鎵ц鏂囦欢涓檮open顧呭瓧孌靛悗鐨勬枃浠惰礬寰?甯傚満涓婂凡緇忓嚭鐜頒簡鐮磋В灞忎繚瀵嗙爜鐨勫厜鐩橈紝濡傛灉涓嶇姝㈠厜鐩樼殑鑷姩榪愯鍔熻兘錛屼互涓婃墍鍋氱殑璁劇疆閮藉皢鏄櫧璐?錛屾楠や負(fù)錛?br />鈶村睍寮HKEY錛縇OCAL錛縈ACHINE\SO
FTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer瀛愰敭鍒嗘敮錛?br />鈶靛湪Explorer涓婚敭涓柊寤篋WORD鍊糔oDriveTypeAutoRun錛屾敼鍊間負(fù)1銆?br />21)銆佺姝嬌鐢∕S錛岲OS鏂瑰紡
閲囩敤涓婅堪鏂規(guī)硶闅愯棌鏌愪釜紓佺洏鍒嗗尯鐨勪綔鐢ㄤ粎闄愪簬鍥懼艦鐣岄潰錛屼絾鍦ㄥ瓧絎︾晫闈㈠MS錛岲OS鏂瑰紡鏃犳晥錛屽洜姝ゆ垜浠繀欏婚噰鐢ㄩ傚綋鐨勬柟娉曠姝㈡櫘閫氱敤鎴蜂嬌鐢∕S錛岲OS鏂瑰紡銆傛柟娉曚負(fù)錛?br />鈶犲睍寮HKLU\SOFTWARE \Policies\Microsoft\Windows\system鍒嗘敮錛?br />鈶℃柊寤轟竴涓悕涓篋isableCMD鐨凞WORD鍊鹼紝鏀瑰間負(fù)1(榪欓」鐢ㄤ簬紱佹鐢ㄦ埛榪涘叆Windows 2000鐨凪S錛岲OS鏂瑰紡)銆傚間負(fù)2鍒欐壒澶勭悊鏂囦歡涔熶笉鑳借繍琛屻?br />22)銆佺姝㈣繍琛屾寚瀹氱殑紼嬪簭
23)銆佸彧鍏佽榪愯鎸囧畾鐨勭▼搴?br />24)銆佺姝嬌鐢ㄦ敞鍐岃〃緙栬緫鍣?br />HKCU\Software\Microsoft\Windows\Current Version\policies\System涓?br />DWORD錛欴isableRegistryTools錛氬間負(fù)1鍒欑鐢ㄦ敞鍐岃〃緙栬緫鍣ㄣ傛敞鎰忥細(xì)浣跨敤姝ゅ姛鑳芥渶濂戒綔涓敞鍐岃〃澶囦喚錛屾垨鑰呭噯澶囦竴涓叾浠栫殑娉ㄥ唽琛ㄤ慨鏀瑰伐鍏鳳紝鍥犱負(fù)紱佹浜嗘敞鍐岃〃緙栬緫鍣ㄤ互鍚庯紝灝變笉鑳藉啀鐢ㄨ娉ㄥ唽琛ㄧ紪杈戝櫒灝嗗奸」鏀瑰洖鏉ヤ簡銆?br />22)銆佺姝嬌鐢ㄤ換浣曠▼搴忥紙瀵逛簬鍓嶈竟璁劇疆鐨勯櫡闃辯敤鎴鳳級
涓嶅厑璁歌繍琛屼換浣曠▼搴忋傛柟娉曚負(fù)錛?br />鈶犲睍寮HKLU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer瀛愰敭鍒嗘敮錛?br />鈶″湪Explorer涓婚敭涓嬫柊寤篟estrctRun鐨凞WORD鍊鹼紝灝嗗兼敼涓?銆?br />涓嶈繃浣犱篃鍙互鍙戜竴涓嬪杽蹇冿紝緇欎粬鍑犱釜Windows 2000鑷甫鐨勬父鎴忕帺涓鐜╋紝鏂規(guī)硶涓猴細(xì)鍦‥xplorer涓婚敭涓嬫柊寤哄悕涓篟estrctRun鐨勪富閿紝鍦ㄥ叾涓嬪垎鍒柊寤哄悕涓?銆?銆?銆?鐨勫瓧絎︿覆鍊鹼紝灝嗗煎垎鍒敼涓篗SHEARTS錛嶦XE銆丗REECELL錛嶦XE銆乄INMINE錛嶦XE銆丼OL錛嶦XE(鍙渶紼嬪簭鍚嶏紝鏃犻渶璺緞)錛屽垯緋葷粺鍙兘榪愯緗戜笂綰㈠績澶ф垬銆佺┖褰撴帴榫欍佹壂闆楓佺焊鐗屻傛棤娉曟墽琛屽叾瀹冧換浣曠▼搴忋?br />鏈嶅姟瀹夊叏璁劇疆
1)銆佸叧闂笉蹇呰鐨勭鍙?br />鍏抽棴绔彛鎰忓懗鐫鍑忓皯鍔熻兘錛屽湪瀹夊叏鍜屽姛鑳戒笂闈㈤渶瑕佷綘鍋氫竴鐐瑰喅絳栥傚鏋滄湇鍔″櫒瀹夎鍦ㄩ槻鐏鐨勫悗闈紝鍐掗櫓灝變細(xì)灝戜簺銆備絾鏄紝姘歌繙涓嶈璁や負(fù)浣犲彲浠ラ珮鏋曟棤蹇т簡銆傜敤绔彛鎵弿鍣ㄦ壂鎻忕郴緇熷凡寮鏀劇殑绔彛錛岀‘瀹氱郴緇熷紑鏀劇殑鍝簺鏈嶅姟鍙兘寮曡搗榛戝鍏ヤ鏡銆傚湪緋葷粺鐩綍涓殑\system32\drivers\etc\services 鏂囦歡涓湁鐭ュ悕绔彛鍜屾湇鍔$殑瀵圭収琛ㄥ彲渚涘弬鑰冦傚叿浣撴柟娉曚負(fù)錛氭墦寮鈥?緗戜笂閭誨眳/灞炴?鏈湴榪炴帴/灞炴?internet 鍗忚(TCP/IP)/灞炴?楂樼駭/閫夐」/TCP/IP絳涢?灞炴р?鎵撳紑鈥淭CP/IP絳涢夆濓紝娣誨姞闇瑕佺殑TCP銆乁DP鍗忚鍗沖彲銆?br />2)銆佽緗ソ瀹夊叏璁板綍鐨勮闂潈闄?br />瀹夊叏璁板綍鍦ㄩ粯璁ゆ儏鍐典笅鏄病鏈変繚鎶ょ殑錛屾妸瀹冭緗垚鍙湁Administrators鍜岀郴緇熻處鎴鋒墠鏈夋潈璁塊棶銆?br />3)銆佹妸鏁忔劅鏂囦歡瀛樻斁鍦ㄥ彟澶栫殑鏂囦歡鏈嶅姟鍣ㄤ腑
铏界劧鐜板湪鏈嶅姟鍣ㄧ殑紜洏瀹歸噺閮藉緢澶э紝浣嗘槸浣犺繕鏄簲璇ヨ冭檻鏄惁鏈夊繀瑕佹妸涓浜涢噸瑕佺殑鐢ㄦ埛鏁版嵁錛堟枃浠躲佹暟鎹〃銆侀」鐩枃浠剁瓑錛夊瓨鏀懼湪鍙﹀涓涓畨鍏ㄧ殑鏈嶅姟鍣ㄤ腑錛屽茍涓旂粡甯稿浠藉畠浠?br />4)銆佸仠姝笉蹇呰鐨勬湇鍔?br />鏈嶅姟寮鐨勫お澶氫篃涓嶆槸涓ソ浜嬶紝灝嗘病鏈夊繀瑕佺殑鏈嶅姟閫氶氬叧鎺夊惂錛佺壒鍒槸榪炵鐞嗗憳閮戒笉鐭ラ亾鏄共浠涔堢殑鏈嶅姟錛岃繕寮鐫騫蹭粈涔堬紒鍏蟲帀錛佸厤寰楃粰緋葷粺甯︽潵鐏鵑毦銆?br />鍙﹀錛岀鐞嗗憳濡傛灉涓嶅鍑猴紝涓嶉渶瑕佽繙紼嬬鐞嗕綘鐨勮綆楁満鐨勮瘽錛屾渶濂藉皢涓鍒囩殑榪滅▼緗戠粶鐧誨綍鍔熻兘閮藉叧鎺夈傛敞鎰忥紝闄ら潪鐗瑰埆闇瑕侊紝鍚﹀垯紱佺敤鈥淭ask Scheduler鈥濄佲淩unAs Service鈥濇湇鍔★紒
鍏抽棴涓欏規(guī)湇鍔$殑鏂規(guī)硶寰堢畝鍗曪紝榪愯cmd.exe涔嬪悗錛岀洿鎺et stop servername鍗沖彲
5)銆佹洿鏀圭鐞嗘湇鍔$殑绔彛
pcanywhere绔彛鍙鳳紝緇堢鏈嶅姟绔彛鍙楓?br />5)銆佸湪Win2000涓浣曞叧闂璉CMP(Ping)
ICMP鐨勫叏鍚嶆槸Internet Control and Message Protocal鍗沖洜鐗圭綉鎺у埗娑堟伅/閿欒鎶ユ枃鍗忚錛岃繖涓崗璁富瑕佹槸鐢ㄦ潵榪涜閿欒淇℃伅鍜屾帶鍒朵俊鎭殑浼犻掞紝渚嬪钁楀悕鐨凱ing鍜孴racert宸ュ叿閮芥槸鍒╃敤ICMP鍗忚涓殑ECHO request鎶ユ枃榪涜鐨勶紙璇鋒眰鎶ユ枃ICMP ECHO綾誨瀷8浠g爜0錛屽簲絳旀姤鏂嘔CMP ECHOREPLY綾誨瀷0浠g爜0錛夈?br />ICMP鍗忚鏈変竴涓壒鐐?--瀹冩槸鏃犺繛緇撶殑錛屼篃灝辨槸璇村彧瑕佸彂閫佺瀹屾垚ICMP鎶ユ枃鐨勫皝瑁呭茍浼犻掔粰璺敱鍣紝榪欎釜鎶ユ枃灝嗕細(xì)璞¢偖鍖呬竴鏍瘋嚜宸卞幓瀵繪壘鐩殑鍦板潃錛岃繖涓壒鐐逛嬌寰桰CMP鍗忚闈炲父鐏墊椿蹇嵎錛屼絾鏄悓鏃朵篃甯︽潵涓涓嚧鍛界殑緙洪櫡---鏄撲吉閫狅紙閭寘涓婄殑瀵勪俊浜哄湴鍧鏄彲浠ラ殢渚垮啓鐨勶級錛屼換浣曚漢閮藉彲浠ヤ吉閫犱竴涓狪CMP鎶ユ枃騫跺彂閫佸嚭鍘伙紝浼犺呭彲浠ュ埄鐢⊿OCK_RAW緙栫▼鐩存帴鏀瑰啓鎶ユ枃鐨処CMP棣栭儴鍜孖P棣栭儴錛岃繖鏍風(fēng)殑鎶ユ枃鎼哄甫鐨勬簮鍦板潃鏄吉閫犵殑錛屽湪鐩殑绔牴鏈棤娉曡拷鏌ワ紝錛堟敾鍑昏呬笉鎬曡鎶撻偅榪樹笉鏈夋亙鏃犳亹錛燂級鏍規(guī)嵁榪欎釜鍘熺悊錛屽闈㈠嚭鐜頒簡涓嶅皯鍩轟簬ICMP鐨勬敾鍑昏蔣浠訛紝鏈夐氳繃緗戠粶鏋舵瀯緙洪櫡鍒墮營CMP椋庢毚鐨勶紝鏈変嬌鐢ㄩ潪甯稿ぇ鐨勬姤鏂囧牭濉炵綉緇滅殑錛屾湁鍒╃敤ICMP紕庣墖鏀誨嚮娑堣楁湇鍔″櫒CPU鐨勶紝鐢氳嚦濡傛灉灝咺CMP鍗忚鐢ㄦ潵榪涜閫氳錛屽彲浠ュ埗浣滃嚭涓嶉渶瑕佷換浣昑CP/UDP绔彛鐨勬湪椹紙鍙傝鐩稿叧鏂囩珷錛?.....鏃㈢劧ICMP鍗忚榪欎箞鍗遍櫓錛屾垜浠負(fù)浠涔堜笉鍏蟲帀瀹冨憿錛?br />鎴戜滑閮界煡閬擄紝W(xué)in2000鍦ㄧ綉緇滃睘鎬т腑鑷甫浜嗕竴涓猅CP/IP榪囨護(hù)鍣紝鎴戜滑鏉ョ湅鐪嬭兘涓嶈兘閫氳繃榪欓噷鍏蟲帀ICMP鍗忚錛屾闈笂鍙沖嚮緗戜笂閭誨眳->灞炴?>鍙沖嚮浣犺閰嶇疆鐨勭綉鍗?>灞炴?>TCP/IP->楂樼駭->閫夐」->TCP/IP榪囨護(hù)錛岃繖閲屾湁涓変釜榪囨護(hù)鍣紝鍒嗗埆涓猴細(xì)TCP绔彛銆乁DP绔彛鍜孖P鍗忚錛屾垜浠厛鍏佽TCP/IP榪囨護(hù)錛岀劧鍚庝竴涓竴涓潵閰嶇疆錛屽厛鏄疶CP绔彛錛岀偣鍑?鍙厑璁?錛岀劧鍚庡湪涓嬮潰鍔犱笂浣犻渶瑕佸紑鐨勭鍙o紝涓鑸潵璇碬EB鏈嶅姟鍣ㄥ彧闇瑕佸紑80(www)錛孎TP鏈嶅姟鍣ㄩ渶瑕佸紑20(FTP Data)錛?1(FTP Control)錛岄偖浠舵湇鍔″櫒鍙兘闇瑕佹墦寮25(SMTP),110(POP3)錛屼互姝ょ被鎺?.....鎺ョ潃鏄疷DP錛孶DP鍗忚鍜孖CMP鍗忚涓鏍鋒槸鍩轟簬鏃犺繛緇撶殑錛屼竴鏍峰鏄撲吉閫狅紝鎵浠ュ鏋滀笉鏄繀瑕侊紙渚嬪瑕佷粠UDP鎻愪緵DNS鏈嶅姟涔嬬被錛夊簲璇ラ夋嫨鍏ㄩ儴涓嶅厑璁革紝閬垮厤鍙楀埌媧按錛團(tuán)lood錛夋垨紕庣墖錛團(tuán)ragment錛夋敾鍑匯傛渶鍙寵竟鐨勪竴涓紪杈戞鏄畾涔塈P鍗忚榪囨護(hù)鐨勶紝鎴戜滑閫夋嫨鍙厑璁窽CP鍗忚閫氳繃錛屾坊鍔犱竴涓?錛?鏄疶CP鍦↖P鍗忚涓殑浠g爜錛孖PPROTO_TCP=6錛?浠庨亾鐞嗕笂鏉ヨ錛屽彧鍏佽TCP鍗忚閫氳繃鏃舵棤璁篣DP榪樻槸ICMP閮戒笉搴旇鑳介氳繃錛屽彲鎯滅殑鏄繖閲岀殑IP鍗忚榪囨護(hù)鎸囩殑鏄嫮涔夌殑IP鍗忚錛屼粠鏋舵瀯涓婃潵璇磋櫧鐒禝CMP鍗忚鍜孖GMP鍗忚閮芥槸IP鍗忚鐨勯檮灞炲崗璁紝浣嗘槸浠庣綉緇?灞傜粨鏋勪笂ICMP/IGMP鍗忚涓嶪P鍗忚鍚屽睘涓灞傦紝鎵浠ュ井杞湪榪欓噷鐨処P鍗忚榪囨護(hù)鏄笉鍖呮嫭ICMP鍗忚鐨勶紝涔熷氨鏄鍗充嬌浣犺緗簡鈥滃彧鍏佽TCP鍗忚閫氳繃鈥濓紝ICMP鎶ユ枃浠嶇劧鍙互姝e父閫氳繃錛屾墍浠ュ鏋滄垜浠榪囨護(hù)ICMP鍗忚榪橀渶瑕佸彟鎯沖姙娉曘?br />鍒氬垰鍦ㄦ垜浠繘琛孴CP/IP榪囨護(hù)鏃訛紝榪樻湁鍙﹀涓涓夐」錛欼P瀹夊叏鏈哄埗錛圛P Security錛夛紝鎴戜滑榪囨護(hù)ICMP鐨勬兂娉曞氨瑕佺潃钀藉湪瀹冭韓涓娿?br />銆銆鎵撳紑鏈湴瀹夊叏絳栫暐錛岄夋嫨IP瀹夊叏絳栫暐錛屽湪榪欓噷鎴戜滑鍙互瀹氫箟鑷繁鐨処P瀹夊叏絳栫暐銆?br />銆銆涓涓狪P瀹夊叏榪囨護(hù)鍣ㄧ敱涓や釜閮ㄥ垎緇勬垚錛氳繃婊ょ瓥鐣ュ拰榪囨護(hù)*浣滐紝榪囨護(hù)絳栫暐鍐沖畾鍝簺鎶ユ枃搴斿綋寮曡搗榪囨護(hù)鍣ㄧ殑鍏蟲敞錛岃繃婊?浣滃喅瀹氳繃婊ゅ櫒鏄滃厑璁糕濊繕鏄滄嫆緇濃濇姤鏂囩殑閫氳繃銆傝鏂板緩IP瀹夊叏榪囨護(hù)鍣紝蹇呴』鏂板緩鑷繁鐨勮繃婊ょ瓥鐣ュ拰榪囨護(hù)*浣滐細(xì)鍙沖嚮鏈満鐨処P瀹夊叏絳栫暐錛岄夋嫨綆$悊IP榪囨護(hù)鍣紝鍦↖P榪囨護(hù)鍣ㄧ鐞嗗垪琛ㄤ腑寤虹珛涓涓柊鐨勮繃婊よ鍒欙細(xì)ICMP_ANY_IN錛屾簮鍦板潃閫変換鎰廔P錛岀洰鏍囧湴鍧閫夋湰鏈猴紝鍗忚綾誨瀷鏄疘CMP錛屽垏鎹㈠埌綆$悊榪囨護(hù)鍣?浣滐紝澧炲姞涓涓悕涓篋eny鐨?浣滐紝*浣滅被鍨嬩負(fù)"闃繪"錛圔lock錛夈傝繖鏍鋒垜浠氨鏈変簡涓涓叧娉ㄦ墍鏈夎繘鍏CMP鎶ユ枃鐨勮繃婊ょ瓥鐣ュ拰涓㈠純鎵鏈夋姤鏂囩殑榪囨護(hù)*浣滀簡銆傞渶瑕佹敞鎰忕殑鏄紝鍦ㄥ湴鍧閫夐」涓湁涓涓暅鍍忛夋嫨錛屽鏋滈変腑闀滃儚錛岄偅涔堝皢浼?xì)寰忕珛涓涓縐扮殑榪囨護(hù)絳栫暐錛屼篃灝辨槸璇村綋浣犲叧娉╝ny IP->my IP鐨勬椂鍊欙紝鐢變簬闀滃儚鐨勪綔鐢紝瀹為檯涓婁綘涔熷悓鏃跺叧娉ㄤ簡my IP->any IP錛屼綘鍙互鏍規(guī)嵁鑷繁鐨勯渶瑕侀夋嫨鎴栬呮斁寮冮暅鍍忋?br />鍐嶆鍙沖嚮鏈満鐨処P瀹夊叏絳栫暐錛岄夋嫨鏂板緩IP榪囨護(hù)絳栫暐錛屽緩绔嬩竴涓悕縐頒負(fù)ICMP Filter鐨勮繃婊ゅ櫒錛岄氳繃澧炲姞榪囨護(hù)瑙勫垯鍚戝錛屾垜浠妸鍒氬垰瀹氫箟鐨処CMP_ANY_IN榪囨護(hù)絳栫暐鎸囧畾緇橧CMP Filter錛岀劧鍚庡湪*浣滈夋涓夋嫨鎴戜滑鍒氬垰瀹氫箟鐨凞eny*浣滐紝閫鍑哄悜瀵肩獥鍙o紝鍙沖嚮ICMP Filter騫跺惎鐢ㄥ畠錛岀幇鍦ㄤ換浣曞湴鍧榪涘叆鐨処CMP鎶ユ枃閮戒細(xì)琚涪寮冧簡銆?
铏界劧鐢↖P sec鑳藉瀵笽CMP鎶ユ枃榪涜榪囨護(hù)錛屼笉榪?浣滆搗鏉ュお楹葷儲錛岃屼笖濡傛灉浣犲彧闇瑕佽繃婊ょ壒瀹氱殑ICMP鎶ユ枃錛岃繕瑕佷繚鐣欎竴浜涘父鐢ㄦ姤鏂囷紙濡備富鏈轟笉鍙揪銆佺綉緇滀笉鍙揪絳夛級錛孖P sec絳栫暐灝卞姏涓嶄粠蹇冧簡錛屾垜浠彲浠ュ埄鐢╓in2000鐨勫彟涓涓己澶у伐鍏瘋礬鐢變笌榪滅▼璁塊棶鎺у埗錛圧outing & Remote Access錛夋潵瀹屾垚榪欎簺澶嶆潅鐨勮繃婊?浣溿?br />璺敱涓庤繙紼嬭闂帶鍒舵槸Win2000鐢ㄦ潵綆$悊璺敱琛ㄣ侀厤緗甐PN銆佹帶鍒惰繙紼嬭闂佽繘琛孖P鎶ユ枃榪囨護(hù)鐨勫伐鍏鳳紝榛樿鎯呭喌涓嬪茍娌℃湁瀹夎錛屾墍浠ラ鍏堜綘闇瑕佸惎鐢ㄥ畠錛屾墦寮"綆$悊宸ュ叿"->"璺敱涓庤繙紼嬭闂?錛屽彸鍑?yán)L湇鍔″櫒錛堝鏋滄病鏈夊垯闇瑕佹坊鍔犳湰鏈猴級閫夋嫨"閰嶇疆騫跺惎鐢ㄨ礬鐢卞強(qiáng)榪滅▼璁塊棶"錛岃繖鏃墮厤緗悜瀵間細(xì)璁╀綘閫夋嫨鏄粈涔堟牱鐨勬湇鍔″櫒錛屼竴鑸潵璇達(dá)紝濡傛灉浣犱笉闇瑕侀厤緗甐PN鏈嶅姟鍣紝閭d箞閫夋嫨"鎵嬪姩閰嶇疆"灝卞彲浠ヤ簡錛岄厤緗畬鎴愬悗錛屼富鏈轟笅灝嗗嚭鐜頒竴涓狪P璺敱鐨勯夐」錛屽湪"甯歌"涓夋嫨浣犳兂閰嶇疆鐨勭綉鍗★紙濡傛灉浣犳湁澶氬潡緗戝崱錛屼綘鍙互閫夋嫨鍏抽棴鏌愪竴鍧楃殑ICMP錛夛紝鍦ㄧ綉鍗″睘鎬т腑鐐瑰嚮"杈撳叆絳涢夊櫒"錛屾坊鍔犱竴鏉¤繃婊ょ瓥鐣?from:ANY銆to:ANY銆鍗忚:ICMP銆綾誨瀷:8 :緙栫爜:0銆涓㈠純"灝卞彲浠ヤ簡錛堢被鍨?緙栫爜0灝辨槸Ping浣跨敤鐨処CMP_ECHO鎶ユ枃錛屽鏋滆榪囨護(hù)鎵鏈夌殑ICMP鎶ユ枃鍙渶瑕佸皢綾誨瀷鍜岀紪鐮侀兘璁劇疆涓?55錛?br />銆
IIS錛欼IS鏄井杞殑緇勪歡涓紡媧炴渶澶氱殑涓涓紝騫沖潎涓や笁涓湀灝辮鍑轟竴涓紡媧烇紝鑰屽井杞殑IIS榛樿瀹夎鍙堝疄鍦ㄤ笉鏁㈡伃緇達(dá)紝鎵浠IS鐨勯厤緗槸鎴戜滑鐨勯噸鐐癸紝鐜板湪澶у璺熺潃鎴戜竴璧鋒潵錛?
棣栧厛錛屾妸C鐩橀偅涓粈涔圛netpub鐩綍褰誨簳鍒犳帀錛屽湪D鐩樺緩涓涓狪netpub錛堣鏄綘涓嶆斁蹇冪敤榛樿鐩綍鍚嶄篃鍙互鏀逛竴涓悕瀛楋紝浣嗘槸鑷繁瑕佽寰楋級鍦↖IS綆$悊鍣ㄤ腑灝嗕富鐩綍鎸囧悜D:\Inetpub錛?
鍏舵錛岄偅涓狪IS瀹夎鏃墮粯璁ょ殑浠涔坰cripts絳夎櫄鎷熺洰褰曚竴姒傚垹闄わ紙緗伓涔嬫簮鍛錛屽繕浜唄ttp://www.target.com/scripts/..%c1%1c../winnt/system32/cmd.exe浜嗭紵鎴戜滑铏界劧宸茬粡鎶奍netpub浠庣郴緇熺洏鎸嚭鏉ヤ簡錛屼絾鏄繕鏄皬蹇冧負(fù)涓婏級錛屽鏋滀綘闇瑕佷粈涔堟潈闄愮殑鐩綍鍙互鑷繁鎱㈡參寤猴紝闇瑕佷粈涔堟潈闄愬紑浠涔堛傦紙鐗瑰埆娉ㄦ剰鍐欐潈闄愬拰鎵ц紼嬪簭鐨勬潈闄愶紝娌℃湁緇濆鐨勫繀瑕佸崈涓囦笉瑕佺粰錛?br />絎笁錛屽簲鐢ㄧ▼搴忛厤緗細(xì)鍦↖IS綆$悊鍣ㄤ腑鍒犻櫎蹇呴』涔嬪鐨勪換浣曟棤鐢ㄦ槧灝勶紝蹇呴』鎸囩殑鏄疉SP, ASA鍜屽叾浠栦綘紜疄闇瑕佺敤鍒扮殑鏂囦歡綾誨瀷錛屼緥濡備綘鐢ㄥ埌stml絳夛紙浣跨敤server side include錛夛紝瀹為檯涓?0%鐨勪富鏈烘湁浜嗕笂闈袱涓槧灝勫氨澶熶簡錛屽叾浣欑殑鏄犲皠鍑犱箮姣忎釜閮芥湁涓涓噭鎯ㄧ殑鏁呬簨錛歨tw, htr, idq, ida鈥︹︽兂鐭ラ亾榪欎簺鏁呬簨錛熷幓鏌ヤ互鍓嶇殑婕忔礊鍒楄〃鍚с備粈涔堬紵鎵句笉鍒板湪鍝噷鍒狅紵鍦↖IS綆$悊鍣ㄤ腑鍙沖嚮涓繪満->灞炴?>WWW鏈嶅姟 緙栬緫->涓葷洰褰?閰嶇疆->搴旂敤紼嬪簭鏄犲皠錛岀劧鍚庡氨寮濮嬩竴涓釜鍒犲惂錛堥噷闈㈡病鏈夊叏閫夌殑錛屽樋鍢匡級銆傛帴鐫鍦ㄥ垰鍒氶偅涓獥鍙g殑搴旂敤紼嬪簭璋冭瘯涔︾鍐呭皢鑴氭湰閿欒娑堟伅鏀逛負(fù)鍙戦佹枃鏈紙闄ら潪浣犳兂ASP鍑洪敊鐨勬椂鍊欑敤鎴風(fēng)煡閬撲綘鐨勭▼搴?緗戠粶/鏁版嵁搴撶粨鏋勶級閿欒鏂囨湰鍐欎粈涔堬紵闅忎究浣犲枩嬈紝鑷繁鐪嬬潃鍔炪傜偣鍑葷‘瀹氶鍑烘椂鍒繕浜嗚铏氭嫙绔欑偣緇ф壙浣犺瀹氱殑灞炴с?
涓轟簡瀵逛粯鏃ョ泭澧炲鐨刢gi婕忔礊鎵弿鍣紝榪樻湁涓涓皬鎶宸у彲浠ュ弬鑰冿紝鍦↖IS涓皢HTTP404 Object Not Found鍑洪敊欏甸潰閫氳繃URL閲嶅畾鍚戝埌涓涓畾鍒禜TM鏂囦歡錛屽彲浠ヨ鐩墠緇濆ぇ澶氭暟CGI婕忔礊鎵弿鍣ㄥけ鐏點傚叾瀹炲師鍥犲緢綆鍗曪紝澶у鏁癈GI鎵弿鍣ㄥ湪緙栧啓鏃朵負(fù)浜嗘柟渚匡紝閮芥槸閫氳繃鏌ョ湅榪斿洖欏甸潰鐨凥TTP浠g爜鏉ュ垽鏂紡媧炴槸鍚﹀瓨鍦ㄧ殑錛屼緥濡傦紝钁楀悕鐨処DQ婕忔礊涓鑸兘鏄氳繃鍙?.idq鏉ユ楠岋紝濡傛灉榪斿洖HTTP200錛屽氨璁や負(fù)鏄湁榪欎釜婕忔礊錛屽弽涔嬪鏋滆繑鍥濰TTP404灝辮涓烘病鏈夛紝濡傛灉浣犻氳繃URL灝咹TTP404鍑洪敊淇℃伅閲嶅畾鍚戝埌HTTP404.htm鏂囦歡錛岄偅涔堟墍鏈夌殑鎵弿鏃犺瀛樹笉瀛樺湪婕忔礊閮戒細(xì)榪斿洖HTTP200錛?0%鐨凜GI鎵弿鍣ㄤ細(xì)璁や負(fù)浣犱粈涔堟紡媧為兘鏈夛紝緇撴灉鍙嶈屾帺鐩栦簡浣犵湡姝g殑婕忔礊錛岃鍏ヤ鏡鑰呰尗鐒舵棤澶勪笅鎵嬶紙姝︿緺灝忚涓父璇村叏韜紡媧炲弽鑰屾棤鎳堝彲鍑伙紝闅鵑亾璇寸殑灝辨槸榪欎釜澧冪晫錛燂級涓嶈繃浠庝釜浜鴻搴︽潵璇達(dá)紝鎴戣繕鏄涓烘墡鎵庡疄瀹炲仛濂藉畨鍏ㄨ緗瘮榪欐牱鐨勫皬鎶宸ч噸瑕佺殑澶氥?
鏈鍚庯紝涓轟簡淇濋櫓璧瘋錛屼綘鍙互浣跨敤IIS鐨勫浠藉姛鑳斤紝灝嗗垰鍒氱殑璁懼畾鍏ㄩ儴澶囦喚涓嬫潵錛岃繖鏍峰氨鍙互闅忔椂鎭㈠IIS鐨勫畨鍏ㄩ厤緗傝繕鏈夛紝濡傛灉浣犳旾IS璐熻嵎榪囬珮瀵艱嚧鏈嶅姟鍣ㄦ弧璐熻嵎姝繪満錛屼篃鍙互鍦ㄦц兘涓墦寮CPU闄愬埗錛屼緥濡傚皢IIS鐨勬渶澶PU浣跨敤鐜囬檺鍒跺湪70%銆?br />闇瑕佹敞鎰忎簨欏?br />瀹為檯涓婏紝瀹夊叏鍜屽簲鐢ㄥ湪寰堝鏃跺欐槸鐭涚浘鐨勶紝鍥犳錛屼綘闇瑕佸湪鍏朵腑鎵懼埌騫寵 鐐癸紝姣曠珶鏈嶅姟鍣ㄦ槸緇欑敤鎴風(fēng)敤鑰屼笉鏄仛OPEN HACK鐨勶紝濡傛灉瀹夊叏鍘熷垯濡ㄧ浜嗙郴緇熷簲鐢紝閭d箞榪欎釜瀹夊叏鍘熷垯涔熶笉鏄竴涓ソ鐨勫師鍒欍?
緗戠粶瀹夊叏鏄竴欏圭郴緇熷伐紼嬶紝瀹冧笉浠呮湁絀洪棿鐨勮法搴︼紝榪樻湁鏃墮棿鐨勮法搴︺傚緢澶氭湅鍙嬶紙鍖呮嫭閮ㄥ垎緋葷粺綆$悊鍛橈級璁や負(fù)榪涜浜嗗畨鍏ㄩ厤緗殑涓繪満灝辨槸瀹夊叏鐨勶紝鍏跺疄榪欏叾涓湁涓鍖猴細(xì)鎴戜滑鍙兘璇翠竴鍙頒富鏈哄湪涓瀹氱殑鎯呭喌涓瀹氱殑鏃墮棿涓婃槸瀹夊叏鐨勶紝闅忕潃緗戠粶緇撴瀯鐨勫彉鍖栥佹柊鐨勬紡媧炵殑鍙戠幇錛岀鐞嗗憳/鐢ㄦ埛鐨?浣滐紝涓繪満鐨勫畨鍏ㄧ姸鍐墊槸闅忔椂闅忓湴鍙樺寲鐫鐨勶紝鍙湁璁╁畨鍏ㄦ剰璇嗗拰瀹夊叏鍒跺害璐┛鏁翠釜榪囩▼鎵嶈兘鍋氬埌鐪熸鐨勫畨鍏ㄣ?
鎻愰珮I(yè)IS 5.0緗戠珯浼烘湇鍣ㄧ殑鎵ц鏁堢巼鐨勫叓縐嶆柟娉?
銆浠ヤ笅鏄彁楂業(yè)IS 5.0緗戠珯浼烘湇鍣ㄧ殑鎵ц鏁堢巼鐨勫叓縐嶆柟娉曪細(xì)
銆1. 鍚敤HTTP鐨勬寔緇綔鐢ㄥ彲浠ユ敼鍠?5~20%鐨勬墽琛屾晥鐜囥?br />銆2. 涓嶅惎鐢ㄨ褰曞彲浠ユ敼鍠?~8%鐨勬墽琛屾晥鐜囥?br />銆3. 浣跨敤 [鐙珛] 鐨勫鐞嗙▼搴忎細(xì)鎹熷け20%鐨勬墽琛屾晥鐜囥?br />銆4. 澧炲姞蹇彇璁板繂浣撶殑淇濆瓨妗f鏁伴噺錛屽彲鎻愰珮Active Server Pages涔嬫晥鑳姐?br />銆5. 鍕夸嬌鐢–GI紼嬪紡銆?br />銆6. 澧炲姞IIS 5.0鐢?shù)鑴慍PU鏁伴噺銆?br />銆7. 鍕垮惎鐢ˋSP渚﹂敊鍔熻兘銆?br />銆8. 闈欐佺綉欏甸噰鐢℉TTP 鍘嬬緝錛屽ぇ綰﹀彲浠ュ噺灝?0%鐨勪紶杈撻噺銆?br />銆綆鍗曚粙緇嶅涓嬨?銆1銆佸惎鐢℉TTP鐨勬寔緇綔鐢?br />銆鍚敤HTTP鐨勬寔緇綔鐢紙Keep-Alive錛夋椂錛孖IS涓庢祻瑙堝櫒鐨勮繛綰夸笉浼?xì)鏂U匡紝鍙互鏀瑰杽鎵ц鏁堢巼錛岀洿鍒版祻瑙堝櫒鍏抽棴鏃惰繛綰挎墠浼?xì)鏂U褲傚洜涓虹淮鎸併孠eep-Alive銆嶇姸鎬佹椂錛屾柤姣忔鐢ㄦ埛绔姹傛椂閮戒笉欏婚噸鏂板緩绔嬩竴涓柊鐨勮繛鎺ワ紝鎵浠ュ皢鏀瑰杽浼烘湇鍣ㄧ殑鏁堢巼銆?br />銆姝ゅ姛鑳戒負(fù)HTTP 1.1棰勮鐨勫姛鑳斤紝HTTP 1.0鍔犱笂Keep-Alive
header涔熷彲浠ユ彁渚汬TTP鐨勬寔緇綔鐢ㄥ姛鑳姐?br />銆2銆佸惎鐢℉TTP鐨勬寔緇綔鐢ㄥ彲浠ユ敼鍠?5~20%鐨勬墽琛屾晥鐜囥?br />銆濡備綍鍚敤HTTP鐨勬寔緇綔鐢ㄥ憿錛熸楠ゅ涓嬶細(xì)
銆鍦?[Internet鏈嶅姟綆$悊鍛榏 涓紝閫夊彇鏁翠釜IIS鐢?shù)鑴戙佹垨Web绔欏彴錛屾柤 [鍐呭] 涔?[涓葷洰褰昡
欏碉紝鍕鵑?[HTTP鐨勬寔緇綔鐢╙ 閫夐」銆?br />銆3銆佷笉鍚敤璁板綍
銆涓嶅惎鐢ㄨ褰曞彲浠ユ敼鍠?~8%鐨勬墽琛屾晥鐜囥?br />銆濡備綍璁懼畾涓嶅惎鐢ㄨ褰曞憿錛熸楠ゅ涓嬶細(xì)
銆鍦?[Internet鏈嶅姟綆$悊鍛榏 涓紝閫夊彇鏁翠釜IIS鐢?shù)鑴戙佹垨Web绔欏彴錛屾柤 [鍐呭] 涔?[涓葷洰褰昡欏碉紝涓嶅嬀閫?[鍚敤璁板綍] 閫夐」銆?br />銆璁懼畾闈炵嫭绔嬬殑澶勭悊紼嬪簭
銆浣跨敤 [鐙珛] 鐨勫鐞嗙▼搴忎細(xì)鎹熷け20%鐨勬墽琛屾晥鐜囷紝姝ゅ鎵璋撱岀嫭绔嬨嶇郴鎸囧皢 [涓葷洰褰昡銆乕铏氭嫙鐩綍] 欏典箣搴旂敤紼嬪紡淇濇姢閫夐」璁懼畾涓?[楂橈紙鐙珛鐨勶級] 鏃躲傚洜姝?[搴旂敤紼嬪紡淇濇姢] 璁懼畾涓?[浣?(IIS澶勭悊紼嬪簭)] 鏃舵墽琛屾晥鐜囪緝楂橈紝璁懼畾鐢婚潰濡備笅錛?br />銆濡備綍璁懼畾闈炪岀嫭绔嬨嶇殑澶勭悊紼嬪簭鍛紵姝ラ濡備笅錛?br />銆鍦?[Internet鏈嶅姟綆$悊鍛榏 涓紝閫夊彇鏁翠釜IIS鐢?shù)鑴戙乄eb绔欏彴銆佹垨搴旂敤紼嬪紡鐨勮搗濮嬬洰褰曘傛柤 [鍐呭] 涔?[涓葷洰褰昡銆乕铏氭嫙鐩綍] 欏碉紝璁懼畾搴旂敤紼嬪紡淇濇姢閫夐」涓?[浣?(IIS澶勭悊紼嬪簭)] 銆?br />銆4銆佽皟鏁村揩鍙栵紙Cache錛夎蹇嗕綋
銆IIS 5.0灝嗛潤鎬佺殑緗戦〉璧勬枡鏆傚瓨鏂煎揩鍙栵紙Cache錛夎蹇嗕綋褰撲腑錛汭IS
4.0鍒欏皢闈欐佺殑緗戦〉璧勬枡鏆傚瓨鏂兼。妗堝綋涓傝皟鏁村揩鍙栵紙Cache錛夎蹇嗕綋鐨勪繚瀛樻。妗堟暟閲忓彲浠ユ敼鍠勬墽琛屾晥鐜囥?br />銆ASP鎸囦護(hù)妗f鎵ц榪囧緦錛屼細(xì)鍦ㄦ殏瀛樻柤蹇彇錛圕ache錛夎蹇嗕綋涓互鎻愰珮鎵ц鏁堣兘銆傚鍔犲揩鍙栬蹇嗕綋鐨勪繚瀛樻。妗堟暟閲忥紝鍙彁楂楢ctive Server Pages涔嬫晥鑳姐?br />銆鍙互璁懼畾鎵鏈夊湪鏁翠釜IIS鐢?shù)鑴戙併岀嫭绔嬨峎eb绔欏彴銆佹垨銆岀嫭绔嬨嶅簲鐢ㄧ▼寮忎笂鎵ц涔嬪簲鐢ㄧ▼寮忕殑蹇彇璁板繂浣撴。妗堟暟閲忋?br />銆濡備綍璁懼畾蹇彇錛圕ache錛夊姛鑳藉憿錛熸楠ゅ涓嬶細(xì)
銆鍦?[Internet鏈嶅姟綆$悊鍛榏
涓紝閫夊彇鏁翠釜IIS鐢?shù)鑴戙併岀嫭绔嬨峎eb绔欏彴銆佹垨銆岀嫭绔嬨嶅簲鐢ㄧ▼寮忕殑璧峰鐩綍銆傛柤 [鍐呭]涔媅涓葷洰褰昡銆乕铏氭嫙鐩綍] 欏碉紝鎸変笅 [璁懼畾] 鎸夐挳鏃訛紝鍗沖彲鐢?[澶勭悊紼嬪簭閫夐」] 欏佃瀹?[鎸囦護(hù)妗e揩鍙栬蹇嗕綋] 銆?br />濡備綍璁懼畾蹇彇錛圕ache錛夎蹇嗕綋妗f鏁伴噺鍛紵姝ラ濡備笅錛?br />鍦?[Internet鏈嶅姟綆$悊鍛榏 涓紝閫夊彇鏁翠釜IIS鐢?shù)鑴戙佹垨Web绔欏彴鐨勮搗濮嬬洰褰曘傛柤 [鍐呭]涔媅浼烘湇鍣ㄦ墿鍏呯▼寮廬 欏碉紝鎸変笅 [璁懼畾] 鎸夐挳銆?br />銆鍗沖彲璁懼畾蹇彇錛圕ache錛夎蹇嗕綋妗f鏁伴噺銆?br />銆5銆佸嬁浣跨敤CGI紼嬪紡
銆浣跨敤CGI紼嬪紡鏃訛紝鍥犱負(fù)澶勭悊紼嬪簭錛圥rocess錛夐』涓嶆柇鍦頒駭鐢熶笌鎽ф瘉錛岄犳垚鎵ц鏁堢巼涓嶄匠銆?br />銆涓鑸岃█錛屾墽琛屾晥鐜囨瘮杈冨涓嬶細(xì)
銆 銆 闈欐佺綉欏碉紙Static錛夛細(xì)100
銆 銆 ISAPI錛?0
銆 銆 ASP錛?0
銆 銆 CGI錛?
銆鎹㈠彞璇濊錛孉SP姣擟GI鍙兘蹇?0鍊嶏紝鍥犳鍕夸嬌鐢–GI紼嬪紡鍙互鏀瑰杽IIS鐨勬墽琛屾晥鐜囥?br />銆浠ュ脊鎬э紙F(tuán)lexibility錛夎岃█錛欰SP > CGI > ISAPI > 闈欐佺綉欏碉紙Static錛夈?br />銆浠ュ畨鍏紙Security錛夎岃█錛欰SP錛堢嫭绔嬶級 = ISAPI錛堢嫭绔嬶級= CGI > ASP錛堥潪鐙珛錛?=
ISAPI錛堥潪鐙珛錛? 闈欐佺綉欏碉紙Static錛夈?br />銆6銆佸鍔營IS 5.0鐢?shù)鑴慍PU鏁伴噺
銆鏍規(guī)嵁寰蔣鐨勬祴璇曟姤鍛婏紝澧炲姞IIS 4.0鐢?shù)鑴慍PU鏁伴噺錛屾墽琛屾晥鐜囧茍涓嶄細(xì)鏀瑰杽澶氬皯錛涗絾鏄鍔營IS 5.0鐢?shù)鑴慍PU鏁伴噺錛屾墽琛屾晥鐜囦細(xì)鍑犱箮鎴愭姣斿湴鎻愪緵錛屾崲鍙ヨ瘽璇達(dá)紝涓らCPU鐨処IS 5.0鐢?shù)鑴戞墽琛屾晥鐜囧嚑涔庢槸涓棰桟PU鐢?shù)鑴戠殑涓ゅ嶏紝鍥涢CPU鐨処IS 5.0鐢?shù)鑴戞墽琛屾晥鐜囧嚑涔庢槸涓棰桟PU鐢?shù)鑴戠殑鍥涘嶃?br />銆IIS 5.0灝嗛潤鎬佺殑緗戦〉璧勬枡鏆傚瓨鏂煎揩鍙栵紙Cache錛夎蹇嗕綋褰撲腑錛汭IS
4.0鍒欏皢闈欐佺殑緗戦〉璧勬枡鏆傚瓨鏂兼。妗堝綋涓傝皟鏁村揩鍙栵紙Cache錛夎蹇嗕綋鐨勪繚瀛樻。妗堟暟閲忓彲浠ユ敼鍠勬墽琛屾晥鐜囥?br />銆7銆佸惎鐢ˋSP渚﹂敊鍔熻兘
銆鍕垮惎鐢ˋSP渚﹂敊鍔熻兘鍙互鏀瑰杽鎵ц鏁堢巼銆?br />銆濡備綍鍕垮惎鐢ˋSP渚﹂敊鍔熻兘鍛紵姝ラ濡備笅錛?br />銆鏂?[Internet鏈嶅姟綆$悊鍛榏 涓紝閫夊彇Web绔欏彴銆佹垨搴旂敤紼嬪紡鐨勮搗濮嬬洰褰曪紝鎸夊彸閿夋嫨 [鍐呭]錛屾寜 [涓葷洰褰昡銆乕铏氭嫙鐩綍] 鎴?[鐩綍] 欏碉紝鎸変笅 [璁懼畾] 鎸夐挳錛岄夋嫨 [搴旂敤紼嬪紡渚﹂敊] 欏碉紝涓嶅嬀閫?[鍚敤ASP浼烘湇鍣ㄧ鎸囦護(hù)渚﹂敊]銆乕鍚敤ASP鐢ㄦ埛绔寚浠や睛閿橾 閫夐」銆?br />銆8銆侀潤鎬佺綉欏甸噰鐢℉TTP 鍘嬬緝
銆闈欐佺綉欏甸噰鐢℉TTP 鍘嬬緝錛屽ぇ綰﹀彲浠ュ噺灝?0%鐨勪紶杈撻噺銆?br />銆HTTP鍘嬬緝鍔熻兘鍚敤鎴栧叧闂紝緋婚拡瀵規(guī)暣鍙癐IS浼烘湇鍣ㄦ潵璁懼畾銆?br />銆鐢ㄦ埛绔嬌鐢↖E 5.0嫻忚鍣ㄨ繛綰垮埌宸茬粡鍚敤HTTP鍘嬬緝IIS 5.0涔媁eb浼烘湇鍣紝鎵嶆湁HTTP鍘嬬緝鍔熻兘銆?br />銆濡備綍鍚敤HTTP鍘嬬緝鍔熻兘鍛紵姝ラ濡備笅錛?br />銆鑻ヨ鍚敤HTTP鍘嬬緝鍔熻兘錛屾柟娉曚負(fù)鍦?[Internet鏈嶅姟綆$悊鍛榏 涓紝閫夊彇鐢?shù)鑴戜?[鍐呭]錛屾柤 [涓昏鍐呭]
涔嬩笅閫夊彇 [WWW鏈嶅姟]銆傜劧寰屾寜涓涓?[緙栬緫] 鎸夐挳錛屾柤 [鏈嶅姟] 欏典笂錛岄夊彇 [鍘嬬緝闈欐佹。妗圿 鍙互鍘嬬緝闈欐佹。妗堬紝涓嶉夊彇 [鍘嬬緝搴旂敤紼嬪紡妗f] 銆?br />銆鍔ㄦ佷駭鐢熺殑鍐呭妗f錛堝帇緙╁簲鐢ㄧ▼寮忔。妗堬級涔熷彲浠ュ帇緙╋紝浣嗘槸欏昏楄垂棰濆CPU澶勭悊鏃墮棿錛岃嫢% Processor Time宸茬粡鐧懼垎涔嬪叓鍗佹垨鏇村鏃訛紝寤鴻涓嶈鍘嬬緝銆?
]]>
KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Control\Terminal Server\Wds\rdpwd\Tds\tcp
鍜?br />HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
涓嬮兘鏈変竴涓狿ortNumber鍊鹼紝閫氬父涓?389錛屽皢鍏朵慨鏀逛負(fù)鑷繁鐨勫鹼紝濡?876(鍙嚜宸辨寚瀹氱鍙o紝浣嗘渶濂戒笉瑕佽涓轟綆绔鍙o紝浠ュ厤鍐茬獊)錛?
顥ヮ棩
2.閲嶆柊鍚姩鏈嶅姟鍣ㄣ?顥ヮ棩
2. 杈撳叆涓繪満鍦板潃錛屽悗闈㈣窡绔彛鍙鳳紝渚嬪: 202.100.4.15:9876
]]>
銆銆涓銆佹壘鍑鴻嚜韜紑鏀劇殑绔彛
銆銆鎵弿绔彛錛岀劧鍚庢壘婕忔礊鏄敾鍑昏呭叆渚電殑鍩烘湰鎬濊礬銆傚彲浠ヨ錛屾満鍣ㄤ笂寮鏀劇殑绔彛瓚婂錛屾敾鍑昏呭叆渚電殑鏈轟細(xì)灝辮秺澶э紝鍥犳鎴戜滑鍙互閫氳繃鍏抽棴涓浜涙垜浠笉鐢ㄧ殑绔彛鏉ユ彁楂樼數(shù)鑴戠殑瀹夊叏鎬с?
銆銆閭e浣曠煡閬撴垜浠殑Windows XP寮鏀句簡鍝簺绔彛鍛紵鎴戜滑鍙互鐢ㄥ懡浠も淣etstat鈥濇潵鏌ョ湅緋葷粺涓紑鏀劇殑绔彛銆?
銆銆鎴戜滑闇瑕佺敤鍒拌繖涓懡浠ょ殑涓や釜鍙傛暟錛?a銆?n銆傚弬鏁?a鏄劇ず褰撳墠鎵鏈夎繛鎺ュ拰渚﹀惉绔彛錛岃屽弬鏁?n浠ユ暟瀛楁牸寮忔樉紺哄湴鍧鍜岀鍙e彿錛堣屼笉鏄皾璇曟煡鎵懼悕縐幫級錛屼袱鑰呭彲浠ョ粨鍚堣搗鏉ヤ嬌鐢細(xì)Netstatan錛堝鍥?錛夛紝灝辮兘鏌ョ湅褰撳墠绔彛鐨勫紑鏀炬儏鍐點?
銆銆鍥?
銆銆閫氳繃榪欎釜鍛戒護(hù)錛屽鏋滄垜浠彂鐜頒竴涓紓甯哥殑绔彛鍙峰湪鐩戝惉錛屽彲浠ュ厛鍘葷綉涓婃煡鎵懼父瑙佹湪椹殑绔彛鍙峰鐓т竴涓嬶紝濡傛灉鍙戠幇鏈夋湪椹嬌鐢ㄧ殑绔彛錛屽氨搴旇鐢ㄦ潃闄ゆ湪椹殑杞歡媯鏌ョ郴緇熶簡銆?/p>
銆銆鍥?
銆銆2銆佺鐢∟etBIOS銆傛墦寮鏈湴榪炴帴鐨勨滃睘鎬р啋Internet鍗忚錛圱CP/IP錛夆啋灞炴р啋楂樼駭鈫扺INS鈫掔鐢═CP/IP涓婄殑NetBIOS鈥濓紙濡傚浘3錛夈傝繖鏍蜂竴鏉ュ氨鍏抽棴浜?37銆?38浠ュ強(qiáng)139绔彛錛屼粠鑰岄闃睮PC$鍏ヤ鏡銆?
銆銆鍥?
銆銆3銆佸紑鍚疻indows XP鑷甫鐨勭綉緇滈槻鐏銆傛墦寮鏈湴榪炴帴鐨勨滃睘鎬р啋楂樼駭鈥濓紝鍚敤闃茬伀澧欎箣鍚庯紝鍗曞嚮璁劇疆鍙互璁劇疆緋葷粺寮鏀懼叧闂摢浜涙湇鍔°備竴鑸潵璇達(dá)紝榪欎簺鏈嶅姟閮藉彲浠ヤ笉瑕侊紝鍏抽棴榪欎簺鏈嶅姟鍚庯紝榪欎簺鏈嶅姟娑夊強(qiáng)鐨勭鍙e氨涓嶄細(xì)琚交鏄撴墦寮浜嗐?
銆銆4銆佺鐢?45绔彛銆傚悜娉ㄥ唽琛ㄢ淗KEY_LO-CAL_MACHINE\SYSTEM\CurrentControlSet\Servi ces\NetBT\Parameters鈥濅腑榪藉姞鍚嶄負(fù)鈥淪MBDeviceEnabled鈥濈殑DWORD鍊鹼紝騫跺皢鍏惰緗負(fù)0錛屽氨濂戒簡銆?
銆銆閫氳繃浠ヤ笂璁劇疆錛屼綘鐨刉indows XP緋葷粺鐨勫畨鍏ㄦу皢澶уぇ鎻愰珮銆傝琛ュ厖鐨勬槸錛屾枃绔犳槸閽堝閭d簺鐩存帴鎷ㄥ彿涓婄綉鐨勬満鍣紝鑰屼笉鍖呮嫭閫氳繃緗戝叧浠g悊涓婄綉鐨勬満鍣ㄣ?
]]>
銆銆 2錛変嬌鐢╯ocket鍑芥暟寰楀埌socket鍙ユ焺錛宮_hSocket:=Socket(AF_INET, SOCK_RAW, IPPROTO_IP); 鐢ㄦ硶濡備笅錛?/p>
銆銆鍦ㄧ▼搴忛噷m_hSocket涓簊ocket鍙ユ焺錛孉F_INET錛孲OCK_RAW錛孖PPROTO_IP鍧囦負(fù)甯擱噺銆?/p>
銆銆5)涓嬮潰鍋氭寰幆錛屽湪姝誨驚鐜潡閲岋紝鏉ュ疄鐜版暟鎹殑鎺ユ敹銆備絾鏄緡鐜腑闂磋鐢⊿leep()鍋氬歡鏃訛紝涓嶇劧紼嬪簭浼?xì)鍑洪敊銆?/p>
銆銆7)鍦╞uffer閲屽氨鏄垜浠帴鏀跺洖鏉ョ殑鏁版嵁浜嗭紝濡傛灉鎴戜滑鎯寵鐭ラ亾鏁版嵁鏄粈涔堝湴鏂瑰彂鏉ョ殑錛岄偅涔堬紝鎴戜滑瑕佸畾涔変竴瀹欼P鍖呯粨
鍥涚緗戠粶娓告垙澶栨寕鐨勮璁℃柟娉?/p>
聽
鍦ㄥ嚑騫村墠鎴戠湅鍒板埆浜虹帺緗戠粶娓告垙鐢ㄤ笂浜嗗鎸傦紝鍋氫負(fù)紼嬪簭鍛樼殑鎴戝績閲屽疄鍦ㄦ槸涓嶇埥
聽
銆1銆佸姩浣滃紡錛屾墍璋撳姩浣滃紡錛屽氨鏄寚鐢ˋPI鍙戝懡浠ょ粰紿楀彛鎴朅PI鎺у埗榧犳爣銆侀敭鐩樼瓑錛屼嬌娓告垙閲岀殑浜虹墿榪涜嫻佸姩鎴栬?a target="_blank">鏀誨嚮錛屾渶
銆銆 2銆佹垜浠妸榧犳爣鐨勪綅緗Щ鍒拌鍒?a target="_blank">浜虹墿璧板埌鐨勫湴鏂癸紝鎴戜滑灝辮鐢ㄥ埌SetCursorPos鍑芥暟鏉ョЩ鍔ㄩ紶鏍囦綅緗紝瀹冪殑浣跨敤鏂規(guī)硶濡?/p>
銆銆3銆佹ā鎷熼紶鏍囧彂鍑烘寜涓嬪拰鏀懼紑鐨勫姩浣滐紝鎴戜滑瑕佺敤鍒癿ouse_event鍑芥暟鏉ュ疄鐜幫紝鍏蜂紤浣跨敤鏂規(guī)硶鐢ㄤ笅錛?/p>
銆銆鍦ㄥ畠鐨刣wFlags澶勶紝鍙敤鐨勪簨浠跺緢澶氬縐誨姩MOUSEEVENTF_MOVE錛屽乏閿寜涓婱OUSEEVENTF_LEFTDOWN錛屽乏閿斁寮
銆銆鐪嬩簡浠ヤ笂鐨?a target="_blank">浠g爜錛屾槸涓嶆槸瑙夊緱浜虹墿鐨勬父璧板緢綆鍗曞暒~~錛屼婦涓浠夸笁錛岃繕鏈夊ソ澶氬ソ涓滀笢鍙互鐢ㄨ繖涓?a target="_blank">鎶宸?/font>瀹炵幇錛堟垜鏃╁氨璇磋繃
銆銆濂戒簡錛屾瘮璇存蹇帴閿槸CTRL+A錛屾帴涓嬫潵璁╂垜浠湅鐪嬪疄闄?a target="_blank">浠g爜鏄庝箞鍐欑殑錛?/p>
銆銆棣栧厛妯℃嫙鎸変笅浜咰TRL閿紝鍐嶆ā鎷熸寜涓婣閿紝鍐嶆ā鎷熸斁寮A閿紝鏈鍚庢斁寮CTRL閿紝榪欏氨鏄竴涓ā鎷熸寜蹇嵎閿殑鍛ㄦ湡銆?/p>
鏈湴淇敼寮忓鎸?/p>
銆銆2銆佹垜浠珿etWindowThreadProcessId鏉ュ緱鍒?a target="_blank">娓告垙紿楀彛鐩稿搴旇繘紼嬬殑榪涚▼ID錛屽嚱鏁扮敤娉曞涓嬶細(xì)
LPDWORD lpdwProcessId // address of variable for process identifier
);
銆銆鍦╠wDesiredAccess涔嬪灝辨槸璁懼瓨鍙栨柟寮忕殑鍦版柟錛屽畠鍙鐨勬潈闄愬緢澶氾紝鎴戜滑鍦ㄨ繖閲屼嬌鐢ㄥ彧瑕佷嬌鐢≒ROCESS_ALL_ACCESS
銆銆5銆佷笅闈㈢敤CloseHandle鍏抽棴榪涚▼鍙ユ焺灝卞畬鎴愪簡銆?/p>
銆銆榪欎釜娓告垙鏄敤浜嗗鍦板潃瀵規(guī)墍瑕佹彁浜ょ殑鏁版嵁榪涜浜嗘牎楠岋紝鎵浠ヨ榪欑被娓告垙澶栨寕鍒朵綔騫朵笉鏄緢闅撅紝鏈闅劇殑鏄鎵懼埌榪欎簺鍦?/p>
鏈ㄩ┈寮忓鎸?/p>
銆銆瀹為檯紼嬪簭瀹炵幇涓紝鎴戜滑瑕佹壘鍒?xx'紿楀彛錛屽氨鐢‵indWindow(nil,'xx')濡傛灉褰撹繑鍥炲煎ぇ浜?鏃惰〃紺虹獥鍙e凡緇忓嚭鐜幫紝閭d箞
銆銆鍦ㄨ繖閲岃璇存槑鐨勬槸鍦ㄦ垜浠▼搴忓綋涓垜浠瀵笻OOKPROC榪欓噷鎴戜滑瑕侀氳繃鍐欎竴涓嚱鏁幫紝鏉ュ疄鐜拌孒INSTANCE榪欓噷鎴戜滑鐩存帴
銆銆鑰孒OOKPROC閲岀殑鍑芥暟灝辮澶嶆潅涓鐐圭偣錛?/p>
銆銆浠ヤ笂灝辨槸璁板綍閿洏鐨勬暣涓繃紼嬶紝綆鍗曞惂錛屽鏋滆褰曞畬鍙笉瑕佸繕璁伴噴鏀懼憖錛孶nHookWindowsHookEx(hHook)錛岃宧HOOK,灝?/p>
銆銆榪欎釜紼嬪簭鍏ㄩ儴鍔熻兘宸茬粡瀹炵幇錛岀紪緙栬瘯璇曘?/p>
鍔犻熷瀷澶栨寕
銆銆鏈鏍稿績鐨勪笢瑗垮凡緇忓啓瀹屼簡錛屽ぇ閮ㄤ喚璇昏呮槸鐭ュ叾鐒朵笉鐭ュ叾鎵浠ョ劧鍚э紝鍛靛懙錛屼笉榪囦笉鐭ュ叾鎵浠ョ劧涔熺劧銆備笅闈㈡垜浠氨璇曠潃鐢?/p>
銆銆鍥犱負(fù)windows榛樿鐨勫間負(fù)$1742錛屾墍浠ユ垜浠妸1742鍋氫負(fù)鍩烘暟錛屽張鍥犱負(fù)鍊艱秺灝忚秺蹇紝鍙嶄箣瓚婃參鐨勫師鐞嗭紝鎵浠ュ啓浜嗚繖鏍蜂竴涓?/p>
銆銆3銆佹垜浠緩绔嬩竴涓繃紼?/p>
銆銆4銆佸厛鍔犱竴涓獥鍙o紝鍦ㄧ獥鍙d笂鏀句笂涓涓猼rackbar鎺т歡鎶婂叾Max璁句負(fù)20錛孧in璁句負(fù)1錛屾妸Position璁句負(fù)10錛屽湪榪欎釜鎺т歡鐨?/p>
銆銆灝辮繖涔堝鏄撱?/p>
鍦ㄥ唴瀛樹腑淇敼鏁版嵁鐨勭綉娓稿鎸?/p>
聽
鐜板湪寰堝娓告垙閮芥槸鎶婁竴浜涗俊鎭瓨鍏ュ唴瀛樺崟鍏冪殑錛岄偅涔堟垜浠彧闇瑕佷慨鏀瑰叿浣撳唴瀛樺煎氨鑳戒慨鏀?a target="_blank">娓告垙涓殑灞炴э紝寰堝緗戠粶娓告垙涔?/p>
聽
銆銆鏇懼嚑浣曟椂錛屼竴浜涚綉緇?a target="_blank">娓告垙涔熸槸鍙互鐢ㄥ唴瀛樺鎸傝繘琛屼慨鏀圭殑錛屽悗鏉ヨ鍙戠幇鍚庯紝榪欎簺娓告垙灝辨妸鍗曚竴鍐呭瓨鍦板潃鏀規(guī)垚澶氬唴瀛樺湴
銆銆璇ユ柟娉曟彁渚涗簡涓や釜鍙傛暟錛岀涓涓弬鏁頒負(fù)瑕佹墦寮鐨勭▼搴忚礬寰勶紝絎簩涓弬鏁頒負(fù)鎵撳紑紼嬪簭鍚庢墍鍒涘緩榪涚▼鐨勮繘紼嬩俊鎭備嬌鐢ㄨ繖
銆銆2銆侀氳繃鎺т歡鏍規(guī)嵁紼嬪簭鍚嶇О寰楀埌鍙ユ焺銆?/p>
銆銆鍏跺簲鐢ㄥ疄渚嬪涓嬶細(xì)
銆銆鎺ョ潃鍙互閫氳繃getProcID()寰楀埌鐩稿簲鐨勮繘紼嬪彞鏌勶紝騫剁粰鎺т歡鐨凱rocHandle錛堣繘紼嬪彞鏌勶級灞炴ц繘琛屼簡闄勫鹼紝榪欐椂鍙互浣?/p>
銆銆3銆侀氳繃鎺т歡鏍規(guī)嵁紿楀彛鍚嶇О寰楀埌鍙ユ焺銆?/p>
銆銆鍏跺簲鐢ㄥ疄渚嬪涓嬶細(xì)
銆銆鎺ョ潃鍙互閫氳繃getWinProcHandle ()寰楀埌鐩稿簲鐨勮繘紼嬪彞鏌勶紝騫剁粰鎺т歡鐨凱rocHandle錛堣繘紼嬪彞鏌勶級灞炴ц繘琛屼簡闄勫鹼紝榪?/p>
銆銆浜屻佷嬌娓告垙鏆傚仠
銆銆鎺у埗綾誨瀷鍙兘澶熶紶鍏ュ弬鏁?鎴?錛?浠h〃浣?a target="_blank">娓告垙鏆傚仠錛?浠h〃鍙栨秷鏆傚仠銆傚叾搴旂敤瀹炰緥濡備笅錛?/p>
銆銆涓夈佽鍐欏唴瀛樺?/p>
銆銆瑕佹敞鎰忕殑鏄紝浼犲叆鍐呭瓨鍦板潃鏃訛紝鍐呭瓨鍦板潃蹇呴』涓篜ointer鍨嬨傚叾搴旂敤瀹炰緥濡備笅錛?/p>
銆銆榪欐椂aValue鍙橀噺閲岀殑鍊間負(fù)鍐呭瓨鍦板潃[4549632]鐨勫箋?/p>
銆銆閫氳繃璇ユ柟娉曞彲浠ユ妸瑕佷慨鏀圭殑鍐呭瓨鍦板潃鍊兼敼涓?7錛屽嵆鎶娾滀富瑙掆濈瓑綰ф敼涓?7銆?/p>
銆銆鍦ㄦ悳绱㈠垎鏋愭椂涓轟簡鎻愰珮鎼滅儲鏁堢巼銆佸疄鐜頒笟鍔¢昏緫錛岄偅涔堥渶瑕佷紶鍏ヤ竴涓弬鏁幫紝浠庤岀‘璁ゆ槸鍚︽槸絎竴嬈¤繘琛屽唴瀛樸傚叾搴旂敤
銆銆2銆?濡傛灉涓嶆槑紜綋鍓嶆兂瑕佷慨鏀圭殑鍦板潃鍊鹼紝鍙煡閬撴兂瑕佷慨鏀圭殑鍊煎彉澶ф垨鍙樺皬錛岄偅涔堝氨鎸夊唴瀛樺彉鍖栧鍑忛噺榪涜鎼滅儲鍒嗘瀽銆?/p>
銆銆鍦ㄦ悳绱㈠垎鏋愭椂涓轟簡鎻愰珮鎼滅儲鏁堢巼銆佸疄鐜頒笟鍔¢昏緫錛岄偅涔堥渶瑕佷紶鍏ヤ竴涓弬鏁幫紝浠庤岀‘璁ゆ槸鍚︽槸絎竴嬈¤繘琛屽唴瀛樸傛悳绱㈠垎
銆銆浜斻佸緱鍒板唴瀛樺湴鍧鍊?/p>
銆銆鍏跺簲鐢ㄥ疄渚嬪涓嬶細(xì)
銆銆閫氳繃浠ヤ笂浜斾釜姝ラ錛屼究鍙互鏁村悎鎴愪竴涓姛鑳芥瘮杈冨畬澶囩殑錛屽熀浜庡唴瀛樻帶鍒舵柟娉曠殑娓告垙澶栨寕銆傛湁浜嗏淔PE鈥濈殑鍏抽敭閮ㄤ喚鍔?/p>
]]>
鎸変粠楂樺埌浣庣殑欏哄簭瀛樺偍錛屽湪緗戠粶涓婁嬌鐢ㄧ粺涓鐨勭綉緇滃瓧鑺傞『搴忥紝鍙互閬垮厤鍏煎鎬ч棶棰樸?/p>
涓嶅悓鐨勬満鍣℉BO涓嶇浉鍚岋紝涓嶤PU璁捐鏈夊叧
璁$畻鏈烘暟鎹瓨鍌ㄦ湁涓ょ瀛楄妭浼樺厛欏哄簭錛氶珮浣嶅瓧鑺備紭鍏堝拰浣庝綅瀛楄妭浼樺厛銆侷nternet涓婃暟鎹互楂樹綅瀛楄妭浼樺厛欏哄簭鍦ㄧ綉緇滀笂浼犺緭錛屾墍浠ュ浜庡湪鍐呴儴鏄互浣庝綅瀛楄妭浼樺厛鏂瑰紡瀛樺偍鏁版嵁鐨勬満鍣紝鍦↖nternet涓婁紶杈撴暟鎹椂灝遍渶瑕佽繘琛岃漿鎹€?
銆銆鎴戜滑瑕佽璁虹殑絎竴涓粨鏋勭被鍨嬫槸錛歴truct sockaddr錛岃綾誨瀷鏄敤鏉ヤ繚瀛榮ocket淇℃伅鐨勶細(xì)
銆銆struct sockaddr {
銆銆unsigned short sa_family; /* 鍦板潃鏃忥紝 AF_xxx */
銆 char sa_data[14]; /* 14 瀛楄妭鐨勫崗璁湴鍧 */ };
銆銆sa_family涓鑸負(fù)AF_INET錛泂a_data鍒欏寘鍚socket鐨処P鍦板潃鍜岀鍙e彿銆?
銆銆鍙﹀榪樻湁涓縐嶇粨鏋勭被鍨嬶細(xì)
銆銆struct sockaddr_in {
銆銆 short int sin_family; /* 鍦板潃鏃?*/
銆銆 unsigned short int sin_port; /* 绔彛鍙?*/
銆銆 struct in_addr sin_addr; /* IP鍦板潃 */
銆銆 unsigned char sin_zero[8]; /* 濉厖0 浠ヤ繚鎸佷笌struct sockaddr鍚屾牱澶у皬 */
銆銆};
銆銆榪欎釜緇撴瀯浣跨敤鏇翠負(fù)鏂逛究銆俿in_zero(瀹冪敤鏉ュ皢sockaddr_in緇撴瀯濉厖鍒頒笌struct sockaddr鍚屾牱鐨勯暱搴?搴旇鐢╞zero()鎴杕emset()鍑芥暟灝嗗叾緗負(fù)闆躲傛寚鍚憇ockaddr_in 鐨勬寚閽堝拰鎸囧悜sockaddr鐨勬寚閽堝彲浠ョ浉浜掕漿鎹紝榪欐剰鍛崇潃濡傛灉涓涓嚱鏁版墍闇鍙傛暟綾誨瀷鏄痵ockaddr鏃訛紝浣犲彲浠ュ湪鍑芥暟璋冪敤鐨勬椂鍊欏皢涓涓寚鍚憇ockaddr_in鐨勬寚閽堣漿鎹負(fù)鎸囧悜sockaddr鐨勬寚閽堬紱鎴栬呯浉鍙嶃俿in_family閫氬父琚祴AF_INET錛泂in_port鍜宻in_addr搴旇杞崲鎴愪負(fù)緗戠粶瀛楄妭浼樺厛欏哄簭錛涜宻in_addr鍒欎笉闇瑕佽漿鎹€?
銆銆鎴戜滑涓嬮潰璁ㄨ鍑犱釜瀛楄妭欏哄簭杞崲鍑芥暟錛?
銆銆htons()--"Host to Network Short" ; htonl()--"Host to Network Long"
銆銆ntohs()--"Network to Host Short" ; ntohl()--"Network to Host Long"
銆銆鍦ㄨ繖閲岋紝 h琛ㄧず"host" 錛宯琛ㄧず"network"錛宻 琛ㄧず"short"錛宭琛ㄧず "long"銆?
銆銆鎵撳紑socket 鎻忚堪絎︺佸緩绔嬬粦瀹氬茍寤虹珛榪炴帴
銆銆socket鍑芥暟鍘熷瀷涓猴細(xì)
銆銆int socket(int domain, int type, int protocol);
銆銆domain鍙傛暟鎸囧畾socket鐨勭被鍨嬶細(xì)SOCK_STREAM 鎴朣OCK_DGRAM錛沺rotocol閫氬父璧嬪尖?鈥濄係ocket()璋冪敤榪斿洖涓涓暣鍨媠ocket鎻忚堪絎︼紝浣犲彲浠ュ湪鍚庨潰鐨勮皟鐢ㄤ嬌鐢ㄥ畠銆?
銆銆涓鏃﹂氳繃socket璋冪敤榪斿洖涓涓猻ocket鎻忚堪絎︼紝浣犲簲璇ュ皢璇ocket涓庝綘鏈満涓婄殑涓涓鍙g浉鍏寵仈錛堝線寰褰撲綘鍦ㄨ璁℃湇鍔″櫒绔▼搴忔椂闇瑕佽皟鐢ㄨ鍑芥暟銆傞殢鍚庝綘灝卞彲浠ュ湪璇ョ鍙g洃鍚湇鍔¤姹?鑰屽鎴風(fēng)涓鑸棤欏昏皟鐢ㄨ鍑芥暟錛夈?Bind鍑芥暟鍘熷瀷涓猴細(xì)
銆銆int bind(int sockfd,struct sockaddr *my_addr, int addrlen);
銆銆Sockfd鏄竴涓猻ocket鎻忚堪絎︼紝my_addr鏄竴涓寚鍚戝寘鍚湁鏈満IP鍦板潃鍙?qiáng)绔彛鍙方{変俊鎭殑sockaddr綾誨瀷鐨勬寚閽?addrlen甯歌璁劇疆涓簊izeof(struct sockaddr)銆?
銆銆鏈鍚庯紝瀵逛簬bind 鍑芥暟瑕佽鏄庣殑涓鐐規(guī)槸錛屼綘鍙互鐢ㄤ笅闈㈢殑璧嬪煎疄鐜拌嚜鍔ㄨ幏寰楁湰鏈篒P鍦板潃鍜岄殢鏈鴻幏鍙栦竴涓病鏈夎鍗犵敤鐨勭鍙e彿錛?
銆銆my_addr.sin_port = 0; /* 緋葷粺闅忔満閫夋嫨涓涓湭琚嬌鐢ㄧ殑绔彛鍙?*/
銆銆my_addr.sin_addr.s_addr = INADDR_ANY; /* 濉叆鏈満IP鍦板潃 */
銆銆閫氳繃灝唌y_addr.sin_port緗負(fù)0錛屽嚱鏁頒細(xì)鑷姩涓轟綘閫夋嫨涓涓湭鍗犵敤鐨勭鍙f潵浣跨敤銆傚悓鏍鳳紝閫氳繃灝唌y_addr.sin_addr.s_addr緗負(fù)INADDR_ANY錛岀郴緇熶細(xì)鑷姩濉叆鏈満IP鍦板潃銆侭ind()鍑芥暟鍦ㄦ垚鍔熻璋冪敤鏃惰繑鍥?錛涢亣鍒伴敊璇椂榪斿洖鈥?1鈥濆茍灝唀rrno緗負(fù)鐩稿簲鐨勯敊璇彿銆傚彟澶栬娉ㄦ剰鐨勬槸錛屽綋璋冪敤鍑芥暟鏃訛紝涓鑸笉瑕佸皢绔彛鍙風(fēng)疆涓哄皬浜?024鐨勫鹼紝鍥犱負(fù)1~1024鏄繚鐣欑鍙e彿錛屼綘鍙互浣跨敤澶т簬1024涓換浣曚竴涓病鏈夎鍗犵敤鐨勭鍙e彿銆?
銆銆Connect()鍑芥暟鐢ㄦ潵涓庤繙绔湇鍔″櫒寤虹珛涓涓猅CP榪炴帴錛屽叾鍑芥暟鍘熷瀷涓猴細(xì)
銆銆int connect(int sockfd, struct sockaddr *serv_addr, int addrlen);
銆銆Sockfd鏄洰鐨勬湇鍔″櫒鐨剆ockt鎻忚堪絎︼紱serv_addr鏄寘鍚洰鐨勬満IP鍦板潃鍜岀鍙e彿鐨勬寚閽堛傞亣鍒伴敊璇椂榪斿洖-1錛屽茍涓攅rrno涓寘鍚浉搴旂殑閿欒鐮併傝繘琛屽鎴風(fēng)紼嬪簭璁捐鏃犻』璋冪敤bind()錛屽洜涓鴻繖縐嶆儏鍐典笅鍙渶鐭ラ亾鐩殑鏈哄櫒鐨処P鍦板潃錛岃屽鎴烽氳繃鍝釜绔彛涓庢湇鍔″櫒寤虹珛榪炴帴騫朵笉闇瑕佸叧蹇冿紝鍐呮牳浼?xì)鑷姩閫夋嫨涓涓湭琚崰鐢ㄧ殑绔彛渚涘鎴風(fēng)鏉ヤ嬌鐢ㄣ?
銆銆Listen()鈥斺旂洃鍚槸鍚︽湁鏈嶅姟璇鋒眰
銆銆鍦ㄦ湇鍔″櫒绔▼搴忎腑錛屽綋socket涓庢煇涓绔彛鎹嗙粦浠ュ悗錛屽氨闇瑕佺洃鍚绔彛錛屼互渚垮鍒拌揪鐨勬湇鍔¤姹傚姞浠ュ鐞嗐?
銆銆int listen(int sockfd錛?int backlog);
銆銆Sockfd鏄疭ocket緋葷粺璋冪敤榪斿洖鐨剆ocket 鎻忚堪絎︼紱backlog鎸囧畾鍦ㄨ姹傞槦鍒椾腑鍏佽鐨勬渶澶ц姹傛暟錛岃繘鍏ョ殑榪炴帴璇鋒眰灝嗗湪闃熷垪涓瓑寰卆ccept()瀹冧滑錛堝弬鑰冧笅鏂囷級銆侭acklog瀵歸槦鍒椾腑絳夊緟鏈嶅姟鐨勮姹傜殑鏁扮洰榪涜浜嗛檺鍒訛紝澶у鏁扮郴緇熺己鐪佸間負(fù)20銆傚綋listen閬囧埌閿欒鏃惰繑鍥?1錛宔rrno琚疆涓虹浉搴旂殑閿欒鐮併?
銆銆鏁呮湇鍔″櫒绔▼搴忛氬父鎸変笅鍒楅『搴忚繘琛屽嚱鏁拌皟鐢細(xì)
銆銆socket(); bind(); listen(); /* accept() goes here */
銆銆accept()鈥斺旇繛鎺ョ鍙g殑鏈嶅姟璇鋒眰銆?
銆銆褰撴煇涓鎴風(fēng)璇曞浘涓庢湇鍔″櫒鐩戝惉鐨勭鍙h繛鎺ユ椂錛岃榪炴帴璇鋒眰灝嗘帓闃熺瓑寰呮湇鍔″櫒accept()瀹冦傞氳繃璋冪敤accept()鍑芥暟涓哄叾寤虹珛涓涓繛鎺ワ紝accept()鍑芥暟灝嗚繑鍥炰竴涓柊鐨剆ocket鎻忚堪絎︼紝鏉ヤ緵榪欎釜鏂拌繛鎺ユ潵浣跨敤銆傝屾湇鍔″櫒鍙互緇х畫鍦ㄤ互鍓嶇殑閭d釜 socket涓婄洃鍚紝鍚屾椂鍙互鍦ㄦ柊鐨剆ocket鎻忚堪絎︿笂榪涜鏁版嵁send()錛堝彂閫侊級鍜宺ecv()錛堟帴鏀訛級鎿嶄綔錛?
銆銆int accept(int sockfd, void *addr, int *addrlen);
銆銆sockfd鏄鐩戝惉鐨剆ocket鎻忚堪絎︼紝addr閫氬父鏄竴涓寚鍚憇ockaddr_in鍙橀噺鐨勬寚閽堬紝璇ュ彉閲忕敤鏉ュ瓨鏀炬彁鍑鴻繛鎺ヨ姹傛湇鍔$殑涓繪満鐨勪俊鎭紙鏌愬彴涓繪満浠庢煇涓鍙e彂鍑鴻璇鋒眰錛夛紱addrten閫氬父涓轟竴涓寚鍚戝間負(fù)sizeof(struct sockaddr_in)鐨勬暣鍨嬫寚閽堝彉閲忋傞敊璇彂鐢熸椂榪斿洖涓涓?1騫朵笖璁劇疆鐩稿簲鐨別rrno鍊箋?
銆銆Send()鍜宺ecv()鈥斺旀暟鎹紶杈?
銆銆榪欎袱涓嚱鏁版槸鐢ㄤ簬闈㈠悜榪炴帴鐨剆ocket涓婅繘琛屾暟鎹紶杈撱?
銆銆Send()鍑芥暟鍘熷瀷涓猴細(xì)
銆銆int send(int sockfd, const void *msg, int len, int flags);
銆銆Sockfd鏄綘鎯崇敤鏉ヤ紶杈撴暟鎹殑socket鎻忚堪絎︼紝msg鏄竴涓寚鍚戣鍙戦佹暟鎹殑鎸囬拡銆?
銆銆Len鏄互瀛楄妭涓哄崟浣嶇殑鏁版嵁鐨勯暱搴︺俧lags涓鑸儏鍐典笅緗負(fù)0錛堝叧浜庤鍙傛暟鐨勭敤娉曞彲鍙傜収man鎵嬪唽錛夈?
銆銆char *msg = "Beej was here!"; int len錛?bytes_sent; ... ...
銆銆len = strlen(msg); bytes_sent = send(sockfd, msg,len,0); ... ...
銆銆Send()鍑芥暟榪斿洖瀹為檯涓婂彂閫佸嚭鐨勫瓧鑺傛暟錛屽彲鑳戒細(xì)灝戜簬浣犲笇鏈涘彂閫佺殑鏁版嵁銆傛墍浠ラ渶瑕佸send()鐨勮繑鍥炲艱繘琛屾祴閲忋傚綋send()榪斿洖鍊間笌len涓嶅尮閰嶆椂錛屽簲璇ュ榪欑鎯呭喌榪涜澶勭悊銆?
銆銆recv()鍑芥暟鍘熷瀷涓猴細(xì)
銆銆int recv(int sockfd,void *buf,int len,unsigned int flags);
銆銆Sockfd鏄帴鍙楁暟鎹殑socket鎻忚堪絎︼紱buf 鏄瓨鏀炬帴鏀舵暟鎹殑緙撳啿鍖猴紱len鏄紦鍐茬殑闀垮害銆侳lags涔熻緗負(fù)0銆俁ecv()榪斿洖瀹為檯涓婃帴鏀剁殑瀛楄妭鏁幫紝鎴栧綋鍑虹幇閿欒鏃訛紝榪斿洖-1騫剁疆鐩稿簲鐨別rrno鍊箋?
銆銆Sendto()鍜宺ecvfrom()鈥斺斿埄鐢ㄦ暟鎹姤鏂瑰紡榪涜鏁版嵁浼犺緭
銆銆鍦ㄦ棤榪炴帴鐨勬暟鎹姤socket鏂瑰紡涓嬶紝鐢變簬鏈湴socket騫舵病鏈変笌榪滅鏈哄櫒寤虹珛榪炴帴錛屾墍浠ュ湪鍙戦佹暟鎹椂搴旀寚鏄庣洰鐨勫湴鍧錛宻endto()鍑芥暟鍘熷瀷涓猴細(xì)
銆銆int sendto(int sockfd, const void *msg,int len,unsigned int flags,const struct sockaddr *to, int tolen);
銆銆璇ュ嚱鏁版瘮send()鍑芥暟澶氫簡涓や釜鍙傛暟錛宼o琛ㄧず鐩湴鏈虹殑IP鍦板潃鍜岀鍙e彿淇℃伅錛岃宼olen甯稿父琚祴鍊間負(fù)sizeof (struct sockaddr)銆係endto 鍑芥暟涔熻繑鍥炲疄闄呭彂閫佺殑鏁版嵁瀛楄妭闀垮害鎴栧湪鍑虹幇鍙戦侀敊璇椂榪斿洖-1銆?
銆銆Recvfrom()鍑芥暟鍘熷瀷涓猴細(xì)
銆銆int recvfrom(int sockfd,void *buf,int len,unsigned int flags,struct sockaddr *from,int *fromlen);
銆銆from鏄竴涓猻truct sockaddr綾誨瀷鐨勫彉閲忥紝璇ュ彉閲忎繚瀛樻簮鏈虹殑IP鍦板潃鍙?qiáng)绔彛鍙枫俧romlen甯哥疆涓簊izeof (struct sockaddr)銆傚綋recvfrom()榪斿洖鏃訛紝fromlen鍖呭惈瀹為檯瀛樺叆from涓殑鏁版嵁瀛楄妭鏁般俁ecvfrom()鍑芥暟榪斿洖鎺ユ敹鍒扮殑瀛楄妭鏁版垨褰撳嚭鐜伴敊璇椂榪斿洖-1錛屽茍緗浉搴旂殑errno銆?
銆銆搴旀敞鎰忕殑涓鐐規(guī)槸錛屽綋浣犲浜庢暟鎹姤socket璋冪敤浜哻onnect()鍑芥暟鏃訛紝浣犱篃鍙互鍒╃敤send()鍜宺ecv()榪涜鏁版嵁浼犺緭錛屼絾璇ocket浠嶇劧鏄暟鎹姤socket錛屽茍涓斿埄鐢ㄤ紶杈撳眰鐨刄DP鏈嶅姟銆備絾鍦ㄥ彂閫佹垨鎺ユ敹鏁版嵁鎶ユ椂錛屽唴鏍鎬細(xì)鑷姩涓轟箣鍔犱笂鐩湴鍜屾簮鍦板潃淇℃伅銆?
銆銆Close()鍜宻hutdown()鈥斺旂粨鏉熸暟鎹紶杈?
銆銆褰撴墍鏈夌殑鏁版嵁鎿嶄綔緇撴潫浠ュ悗錛屼綘鍙互璋冪敤close()鍑芥暟鏉ラ噴鏀捐socket錛屼粠鑰屽仠姝㈠湪璇ocket涓婄殑浠諱綍鏁版嵁鎿嶄綔錛歝lose(sockfd);
銆銆浣犱篃鍙互璋冪敤shutdown()鍑芥暟鏉ュ叧闂socket銆傝鍑芥暟鍏佽浣犲彧鍋滄鍦ㄦ煇涓柟鍚戜笂鐨勬暟鎹紶杈擄紝鑰屼竴涓柟鍚戜笂鐨勬暟鎹紶杈撶戶緇繘琛屻傚浣犲彲浠ュ叧闂煇socket鐨勫啓鎿嶄綔鑰屽厑璁哥戶緇湪璇ocket涓婃帴鍙楁暟鎹紝鐩磋嚦璇誨叆鎵鏈夋暟鎹?
銆銆int shutdown(int sockfd,int how);
銆銆Sockfd鐨勫惈涔夋槸鏄捐屾槗瑙佺殑錛岃屽弬鏁?how鍙互璁句負(fù)涓嬪垪鍊鹼細(xì)
銆銆路0-------涓嶅厑璁哥戶緇帴鏀舵暟鎹?
銆銆路1-------涓嶅厑璁哥戶緇彂閫佹暟鎹?
銆銆路2-------涓嶅厑璁哥戶緇彂閫佸拰鎺ユ敹鏁版嵁錛屽潎涓哄厑璁稿垯璋冪敤close ()
銆銆shutdown鍦ㄦ搷浣滄垚鍔熸椂榪斿洖0錛屽湪鍑虹幇閿欒鏃惰繑鍥?1錛堝茍緗浉搴攅rrno錛夈?
銆銆DNS鈥斺斿煙鍚嶆湇鍔$浉鍏沖嚱鏁?
銆銆鐢變簬IP鍦板潃闅句互璁板繂鍜岃鍐欙紝鎵浠ヤ負(fù)浜嗚鍐欒蹇嗘柟渚匡紝浜轟滑甯稿父鐢ㄥ煙鍚嶆潵琛ㄧず涓繪満錛岃繖灝遍渶瑕佽繘琛屽煙鍚嶅拰IP鍦板潃鐨勮漿鎹€傚嚱鏁癵ethostbyname()灝辨槸瀹屾垚榪欑杞崲鐨勶紝鍑芥暟鍘熷瀷涓猴細(xì)
銆銆struct hostent *gethostbyname(const char *name);
銆銆鍑芥暟榪斿洖涓縐嶅悕涓篽osten鐨勭粨鏋勭被鍨嬶紝瀹冪殑瀹氫箟濡備笅錛?
銆銆struct hostent {
銆銆 char *h_name; /* 涓繪満鐨勫畼鏂瑰煙鍚?*/
銆銆 char **h_aliases; /* 涓涓互NULL緇撳熬鐨勪富鏈哄埆鍚嶆暟緇?*/
銆銆 int h_addrtype; /* 榪斿洖鐨勫湴鍧綾誨瀷錛屽湪Internet鐜涓嬩負(fù)AF-INET */
銆銆 int h_length; /*鍦板潃鐨勫瓧鑺傞暱搴?*/
銆銆 char **h_addr_list; /* 涓涓互0緇撳熬鐨勬暟緇勶紝鍖呭惈璇ヤ富鏈虹殑鎵鏈夊湴鍧*/
銆銆};
銆#define h_addr h_addr_list[0] /*鍦╤-addr-list涓殑絎竴涓湴鍧*/
聽聽聽聽聽 涓句緥錛歨tonl(0)=0
聽聽聽聽聽 htonl(80)= 1342177280
聽聽聽聽聽 涓句緥錛歯tohl(0)=0
聽聽聽聽聽 ntohl(1342177280)= 80
聽聽聽聽聽 涓句緥錛歨tonl(0)=0
聽聽聽聽聽 htonl(80)= 20480
聽聽聽聽聽 涓句緥錛歯tohs(0)=0
聽聽聽聽聽 ntohsl(20480)= 80
]]>
銆銆銆{
// TODO: Add your control notification handler code here
if( !bSetup )
{
m_hook.Start();//嬋媧誨叏灞閽╁瓙銆?br />}
else
{
m_hook.Stop();//鎾ゆ秷鍏ㄥ眬閽╁瓙銆?br />}
bSetup = !bSetup;
鍥句竴錛氭寜F10鍓嶇姸鎬?001.jpg)
鍥句簩錛氭寜F10鍚庣姸鎬?002.jpg)
聽
銆銆銆char buffer[1000]; //緙撳啿鍖?br />銆銆銆FARPROC proc; //鍑芥暟鍏ュ彛鎸囬拡聽
銆銆銆#include
銆銆銆#include "wsock32.h"聽
銆銆銆{
銆銆銆銆if(hModule==NULL){
銆銆銆銆銆//鍔犺澆鍘焀inSock搴擄紝鍘焀inSock搴撳凡澶嶅埗涓簑sock32.001銆?br />銆銆銆hModule=LoadLibrary("wsock32.001");
銆銆}
銆銆銆銆else return 1;
//鑾峰彇鍘焀inSock搴撲腑鐨勬墍鏈夊嚱鏁扮殑鍦板潃騫朵繚瀛橈紝涓嬮潰浠呭垪鍑洪儴鍒?a target="_blank">浠g爜銆?br />if(hModule!=NULL){
銆銆銆銆銆//鑾峰彇鍘焀inSock搴撳垵濮嬪寲鍑芥暟鐨勫湴鍧錛屽茍淇濆瓨鍒癢SAStartup1涓?br />proc=GetProcAddress(hModule,"WSAStartup");
銆銆銆WSAStartup1=(int (_stdcall *)(WORD,LPWSADATA))proc;
銆銆銆銆銆//鑾峰彇鍘焀inSock搴撴秷闄ゅ嚱鏁扮殑鍦板潃錛屽茍淇濆瓨鍒癢SACleanup1涓?br />銆銆銆銆proc=GetProcAddress(hModule i,"WSACleanup");
銆銆銆銆WSACleanup1=(int (_stdcall *)())proc;
銆銆銆銆銆//鑾峰彇鍘熷垱寤篠ock鍑芥暟鐨勫湴鍧錛屽茍淇濆瓨鍒皊ocket1涓?br />銆銆銆銆proc=GetProcAddress(hModule,"socket");
銆銆銆銆銆socket1=(SOCKET (_stdcall *)(int ,int,int))proc;
銆銆銆銆銆//鑾峰彇鍘熷垱寤鴻繛鎺ュ嚱鏁扮殑鍦板潃錛屽茍淇濆瓨鍒癱onnect1涓?br />銆銆銆銆銆proc=GetProcAddress(hModule,"connect");
銆銆銆銆銆connect1=(int (_stdcall *)(SOCKET ,const struct sockaddr *,int ))proc;
銆銆銆銆銆//鑾峰彇鍘熷彂閫佸嚱鏁扮殑鍦板潃錛屽茍淇濆瓨鍒皊end1涓?br />銆銆銆銆銆proc=GetProcAddress(hModule,"send");
銆銆銆銆銆send1=(int (_stdcall *)(SOCKET ,const char * ,int ,int ))proc;
銆銆銆銆銆//鑾峰彇鍘熸帴鏀跺嚱鏁扮殑鍦板潃錛屽茍淇濆瓨鍒皉ecv1涓?br />銆銆銆銆銆proc=GetProcAddress(hModule,"recv");
銆銆銆銆銆recv1=(int (_stdcall *)(SOCKET ,char FAR * ,int ,int ))proc;
銆銆銆銆銆......鍏跺畠鑾峰彇鍑芥暟鍦板潃浠g爜鐣ャ?br />銆銆銆}
銆銆銆else return 0;
銆銆銆return 1;
}
銆銆銆銆{
銆銆銆銆銆//璋冪敤鍘焀inSock搴撳垵濮嬪寲鍑芥暟
銆銆銆銆銆return WSAStartup1(wVersionRequired,lpWSAData);
銆銆銆銆}
銆銆銆銆//WinSock緇撴潫娓呴櫎鍑芥暟銆?br />銆銆銆銆int PASCAL FAR WSACleanup(void)
銆銆銆銆{
銆銆銆銆銆return WSACleanup1(); //璋冪敤鍘焀inSock搴撶粨鏉熸竻闄ゅ嚱鏁般?br />銆銆銆銆}
銆銆銆銆//鍒涘緩Socket鍑芥暟銆?br />銆銆銆銆SOCKET PASCAL FAR socket (int af, int type, int protocol)
銆銆銆銆{
銆銆銆銆銆//璋冪敤鍘焀inSock搴撳垱寤篠ocket鍑芥暟銆?br />銆銆銆銆銆return socket1(af,type,protocol);
銆銆銆銆}
銆銆銆銆//鍙戦佹暟鎹寘鍑芥暟
銆銆銆銆int PASCAL FAR send(SOCKET s,const char * buf,int len,int flags)
銆銆銆銆{
銆銆銆//鍦ㄦ鍙互瀵瑰彂閫佺殑緙撳啿buf鐨勫唴瀹硅繘琛屼慨鏀癸紝浠ュ疄鐜版楠?a target="_blank">鏈嶅姟鍣ㄣ?br />銆銆銆澶栨寕浠g爜......
銆銆銆//璋冪敤鍘焀inSock搴撳彂閫佹暟鎹寘鍑芥暟銆?br />銆銆銆銆銆return send1(s,buf,len,flags);
銆銆銆銆}
//鎺ユ敹鏁版嵁鍖呭嚱鏁般?br />銆銆銆銆int PASCAL FAR recv(SOCKET s, char FAR * buf, int len, int flags)
銆銆銆銆{
銆銆銆//鍦ㄦ鍙互鎸℃埅鍒?a target="_blank">鏈嶅姟鍣ㄧ鍙戦佸埌瀹㈡埛绔殑鏁版嵁鍖咃紝鍏堝皢鍏朵繚瀛樺埌buffer涓?br />銆銆銆strcpy(buffer,buf);
銆銆銆//瀵筨uffer鏁版嵁鍖呮暟鎹繘琛屽垎鏋愬悗錛屽鍏舵寜鐓х帺瀹剁殑鎸囦護(hù)榪涜鐩稿叧淇敼銆?br />銆銆銆澶栨寕浠g爜......
銆銆銆//鏈鍚庤皟鐢ㄥ師WinSock涓殑鎺ユ敹鏁版嵁鍖呭嚱鏁般?br />銆銆銆銆銆return recv1(s, buffer, len, flags);
銆銆銆銆銆}
銆銆銆銆.......鍏跺畠鍑芥暟瀹氫箟浠g爜鐣ャ?/p>
]]>
銆銆銆EXPORTS
銆銆銆銆WSAStartup @1
銆銆銆WSACleanup @2
銆銆銆銆recv @3
銆銆銆銆send @4
銆銆銆銆socket @5
銆銆銆bind @6
銆銆銆closesocket @7
銆銆銆connect @8
(3)銆佹敞鍏ュ鎸?a target="_blank">浠g爜榪涘叆琚寕娓告垙榪涚▼涓?/p>
銆銆銆{
銆銆銆LPCSTR szFunc;//琚獺OOK鐨凙PI鍑芥暟鍚嶇О銆?br />銆銆銆PROC pNewProc;//鏇夸唬鍑芥暟鍦板潃銆?br />銆銆銆PROC pOldProc;//鍘烝PI鍑芥暟鍦板潃銆?br />銆銆銆}HOOKAPI, *LPHOOKAPI;聽
銆銆銆LocationIAT(HMODULE hModule, LPCSTR szImportMod)
銆銆銆//鍏朵腑錛宧Module涓鴻繘紼嬫ā鍧楀彞鏌勶紱szImportMod涓鴻緭鍏ュ簱鍚嶇О銆?br />銆銆銆{
銆銆銆//媯鏌ユ槸鍚︿負(fù)DOS紼嬪簭錛屽鏄繑鍥濶ULL錛屽洜DOS紼嬪簭娌℃湁IAT銆?br />銆銆銆PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER) hModule;
銆銆銆if(pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE) return NULL;
銆銆銆銆//媯鏌ユ槸鍚︿負(fù)NT鏍囧織錛屽惁鍒欒繑鍥濶ULL銆?br />銆銆銆銆PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((DWORD)pDOSHeader+ (DWORD)(pDOSHeader-
銆銆銆銆if(pNTHeader->Signature != IMAGE_NT_SIGNATURE) return NULL;
銆銆銆銆//娌℃湁IAT琛ㄥ垯榪斿洖NULL銆?br />銆銆銆銆if(pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress == 0)
銆銆銆銆//瀹氫綅絎竴涓狪AT浣嶇疆銆?
銆銆銆銆PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)pDOSHeader + (DWORD)
銆銆銆銆//鏍規(guī)嵁杈撳叆搴撳悕縐板驚鐜鏌ユ墍鏈夌殑IAT錛屽鍖歸厤鍒欒繑鍥炶IAT鍦板潃錛屽惁鍒欐嫻嬩笅涓涓狪AT銆?br />銆銆銆銆while (pImportDesc->Name)
銆銆銆銆{
銆銆銆銆銆//鑾峰彇璇AT鎻忚堪鐨勮緭鍏ュ簱鍚嶇О銆?br />銆銆銆PSTR szCurrMod = (PSTR)((DWORD)pDOSHeader + (DWORD)(pImportDesc->Name));
銆銆銆if (stricmp(szCurrMod, szImportMod) == 0) break;
銆銆銆pImportDesc++;
銆銆銆銆}
銆銆銆銆if(pImportDesc->Name == NULL) return NULL;
銆銆銆return pImportDesc;
銆銆銆}
銆銆銆HookAPIByName( HMODULE hModule, LPCSTR szImportMod, LPHOOKAPI pHookApi)
銆銆銆//鍏朵腑錛宧Module涓鴻繘紼嬫ā鍧楀彞鏌勶紱szImportMod涓鴻緭鍏ュ簱鍚嶇О錛沺HookAPI涓篐OOKAPI緇撴瀯鎸囬拡銆?br />銆銆銆{
銆銆銆銆//瀹氫綅szImportMod杈撳叆搴撳湪杈撳叆鏁版嵁孌典腑鐨処AT鍦板潃銆?br />銆銆銆銆PIMAGE_IMPORT_DESCRIPTOR pImportDesc = LocationIAT(hModule, szImportMod);
銆銆if (pImportDesc == NULL) return FALSE;
銆銆銆銆//絎竴涓猅hunk鍦板潃銆?br />銆銆銆銆PIMAGE_THUNK_DATA pOrigThunk = (PIMAGE_THUNK_DATA)((DWORD)hModule + (DWORD)(pImportDesc-
銆銆 //絎竴涓狪AT欏圭殑Thunk鍦板潃銆?br />銆銆銆銆PIMAGE_THUNK_DATA pRealThunk = (PIMAGE_THUNK_DATA)((DWORD)hModule + (DWORD)(pImportDesc-
銆銆銆銆//寰幆鏌ユ壘琚埅API鍑芥暟鐨処AT欏癸紝騫朵嬌鐢ㄦ浛浠e嚱鏁板湴鍧淇敼鍏跺箋?br />銆銆銆while(pOrigThunk->u1.Function)
{
銆//媯嫻嬫Thunk鏄惁涓篒AT欏廣?br />if((pOrigThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) != IMAGE_ORDINAL_FLAG)
{
銆 //鑾峰彇姝AT欏規(guī)墍鎻忚堪鐨勫嚱鏁板悕縐般?br />銆PIMAGE_IMPORT_BY_NAME pByName =(PIMAGE_IMPORT_BY_NAME)((DWORD)hModule+(DWORD)(pOrigThunk-
銆if(pByName->Name[0] == '\0') return FALSE;
銆銆//媯嫻嬫槸鍚︿負(fù)鎸℃埅鍑芥暟銆?br />if(strcmpi(pHookApi->szFunc, (char*)pByName->Name) == 0)
銆 {
銆銆銆銆銆銆銆MEMORY_BASIC_INFORMATION mbi_thunk;
銆銆銆銆銆銆銆//鏌ヨ淇敼欏電殑淇℃伅銆?br />銆銆銆銆銆銆銆VirtualQuery(pRealThunk, &mbi_thunk, sizeof(MEMORY_BASIC_INFORMATION));
//鏀瑰彉淇敼欏典繚鎶ゅ睘鎬т負(fù)PAGE_READWRITE銆?br />銆銆銆銆銆銆銆VirtualProtect(mbi_thunk.BaseAddress,mbi_thunk.RegionSize, PAGE_READWRITE,
//淇濆瓨鍘熸潵鐨凙PI鍑芥暟鍦板潃銆?br />銆銆銆 銆銆if(pHookApi->pOldProc == NULL)
pHookApi->pOldProc = (PROC)pRealThunk->u1.Function;
銆 //淇敼API鍑芥暟IAT欏瑰唴瀹逛負(fù)鏇夸唬鍑芥暟鍦板潃銆?br />pRealThunk->u1.Function = (PDWORD)pHookApi->pNewProc;
//鎭㈠淇敼欏典繚鎶ゅ睘鎬с?br />DWORD dwOldProtect;
銆銆銆銆銆銆銆VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize, mbi_thunk.Protect,
銆銆銆銆銆 }
}
銆 pOrigThunk++;
銆 pRealThunk++;
}
銆銆SetLastError(ERROR_SUCCESS); //璁劇疆閿欒涓篍RROR_SUCCESS錛岃〃紺烘垚鍔熴?br />銆銆return TRUE;
銆銆銆}聽
銆銆銆{
銆銆銆銆//榪囨護(hù)鎺夊師MessageBoxA鐨勬鏂囧拰鏍囬鍐呭錛屽彧鏄劇ず濡備笅鍐呭, 銆?br />return MessageBox(hWnd, "Hook API OK!", "Hook API", uType);
銆銆銆}
銆銆銆static int WINAPI recv1(SOCKET s, char FAR *buf, int len, int flags )
銆銆銆{
銆銆銆//姝ゅ鍙互鎸℃埅娓告垙鏈嶅姟鍣ㄥ彂閫佹潵鐨勭綉緇滄暟鎹寘錛屽彲浠ュ姞鍏ュ垎鏋愬拰澶勭悊鏁版嵁浠g爜銆?br />銆銆銆return recv(s,buf,len,flags);
銆銆銆}聽
銆銆銆//褰撴縺媧籉11閿椂錛屽惎鍔ㄦ尅鎴狝PI鍑芥暟鍔熻兘銆?br />銆銆銆else if( wParam == 0x7A )
銆銆銆{
銆銆銆銆HOOKAPI api[2];
api[0].szFunc ="MessageBoxA";//璁劇疆琚尅鎴嚱鏁扮殑鍚嶇О銆?br />api[0].pNewProc = (PROC)MessageBoxA1;//璁劇疆鏇夸唬鍑芥暟鐨勫湴鍧銆?br />api[1].szFunc ="recv";//璁劇疆琚尅鎴嚱鏁扮殑鍚嶇О銆?br />api[1].pNewProc = (PROC)recv1; //璁劇疆鏇夸唬鍑芥暟鐨勫湴鍧銆?br />//璁劇疆鎸℃埅User32.dll搴撲腑鐨凪essageBoxA鍑芥暟銆?br />HookAPIByName(GetModuleHandle(NULL),"User32.dll",&api[0]);
//璁劇疆鎸℃埅Wsock32.dll搴撲腑鐨剅ecv鍑芥暟銆?br />HookAPIByName(GetModuleHandle(NULL),"Wsock32.dll",&api[1]);
銆銆銆}
銆銆銆......聽
聽
緗戠粶娓告垙鐨勫皝鍖?a target="_blank">鎶鏈?/font>鏄ぇ澶氭暟緙栫▼鐖卞ソ鑰呴兘姣旇緝鍏蟲敞鐨勫叧娉ㄧ殑闂涔嬩竴錛屽湪榪欓噷灝辮鎴戜滑涓璧?a target="_blank">鐮旂┒涓涓嬭繖涓涓棶棰樺惂
銆銆緗戠粶娓告垙鐨勫皝鍖?a target="_blank">鎶鏈?/font>鏄ぇ澶氭暟緙栫▼鐖卞ソ鑰呴兘姣旇緝鍏蟲敞鐨勫叧娉ㄧ殑闂涔嬩竴錛屽湪榪欓噷灝辮鎴戜滑涓璧?a target="_blank">鐮旂┒涓涓嬭繖涓涓棶棰樺惂
銆銆2錛夋垜浠浠嶹S2_32.DLL寮曞叆winsock2鐨勫嚱鏁幫紝鍦ㄦ鎴戜滑涔熸槸浠SAStartup涓轟緥鍋氬嚱鏁板紩鍏ワ細(xì)
銆銆閫氳繃浠ヤ笂鏂規(guī)硶錛屾垜浠究鍙互瀵箇insock2鍋氭帴鍙o紝涓嬮潰鎴戜滑灝卞彲浠ョ敤winsock2鍋氬皝鍖呮崟鑾蜂簡錛屼笉榪囬鍏堣鏈変竴鍧楃綉鍗°?/p>
]]>
聽
涓銆?鍓嶈█
銆銆鎵璋?a target="_blank">娓告垙澶栨寕錛屽叾瀹炴槸涓縐?a target="_blank">娓告垙澶栬緟紼嬪簭錛屽畠鍙互鍗忓姪鐜╁鑷姩浜х敓娓告垙鍔ㄤ綔銆佷慨鏀?a target="_blank">娓告垙緗戠粶鏁版嵁鍖呬互鍙?qiáng)淇?a target="_blank">娓告垙鍐?/p>
瀛樻暟鎹瓑錛屼互瀹炵幇鐜╁鐢ㄦ渶灝戠殑鏃墮棿鍜岄噾閽卞幓瀹屾垚鍔熷姏鍗囩駭鍜岃繃鍏蟲柀灝嗐傝櫧鐒訛紝鐜板湪瀵?a target="_blank">娓告垙澶栨寕紼嬪簭鐨勨滃悎娉曗濊韓浠戒紬璇?/p>
綰風(fēng)涵錛屽湪榪欓噷鎴戜笉鎯沖姝ゅ彂琛ㄤ換浣曚釜浜烘剰瑙侊紝璁╂椂闂村幓璇存槑涓鍒囧惂銆?/p>
銆銆闅忕潃緗戠粶娓告垙鐨勬椂浠g殑鏉ヤ復(fù)錛?a target="_blank">娓告垙澶栨寕鍦ㄥ師鏈夌殑鍔熻兘涔嬩笂榪涜浜嗘柊鐨勫彂灞曪紝瀹冨彉寰楁洿鍔犲縐嶅鏍鳳紝鍔熻兘鏇村姞寮哄ぇ錛屾搷
浣滄洿鍔犵畝鍗曪紝浠ヨ嚦鏈変簺娓告垙鐨勫鎸傚凡緇忔垚涓轟竴涓綋緋伙紝姣斿銆婄煶鍣ㄦ椂浠c嬶紝澶栨寕鍝佺杈懼埌浜嗗嚑鍗佺錛岃嚜鍔ㄦ垬鏂椼佽嚜鍔ㄨ璧?/p>
銆佽嚜鍔ㄧ粌綰с佽嚜鍔ㄨˉ琛銆佸姞閫熴佷笉閬囨晫銆佸師鍦伴亣鏁屻佸揩閫熷鍔犵粡楠屽箋佹寜閿簿鐏碘︹﹀嚑涔庢棤鎵涓嶅寘銆?/p>
銆銆娓告垙澶栨寕鐨勮璁′富瑕佹槸閽堝浜庢煇涓?a target="_blank">娓告垙寮鍙戠殑錛屾垜浠彲浠ユ牴鎹畠閽堝鐨?a target="_blank">娓告垙鐨勭被鍨嬪彲澶ц嚧鍙皢澶栨寕鍒嗕負(fù)涓ょ澶х被銆?/p>
銆銆涓綾繪槸灝?a target="_blank">娓告垙涓ぇ閲忕箒鐞愬拰鏃犺亰鐨?a target="_blank">鏀誨嚮鍔ㄤ綔浣跨敤澶栨寕鑷姩瀹屾垚錛屼互甯姪鐜╁杞繪澗鎼炲畾鏀誨嚮瀵硅薄騫跺彲浠ュ揩閫熺殑澧炲姞鐜╁
鐨勭粡楠屽箋傛瘮濡傚湪銆婇緳鏃忋嬩腑鏈変竴縐嶅伐浣滅殑璁懼畾錛岀帺瀹剁殑宸ヤ綔絳夌駭瓚婇珮錛屽氨鍙互椹鵑┉瓚婂ソ鐨勮澶囥備絾鏄鍔犲伐浣滅瓑綰у嵈涓?/p>
鏄竴浠舵湁瓚g殑浜嬫儏錛屾瘚瀹佽鏄噸澶嶆灟鐕ョ殑鏈烘鍔沖姩銆傚鏋滀綘鎯沖仛娉曞笀鐢ㄧ殑鏉栵紝棣栧厛闇瑕佸仛鍩烘湰宸ヤ綔--?鐮嶆爲(wèi)銆傜爫鏍?wèi)鐨勬栆?guī)硶
寰堢畝鍗曪紝鍦ㄤ竴媯靛ぇ鏍?wèi)鍓嶄笉鍋滅殑鐐归紶鏍嚍鍙互浜嗗Q屾瘡10000鐨勭粡楠屽崌涓綰с傝繖灝辨剰鍛崇潃鐜╁瑕佸湪澶ф爲(wèi)鍓嶄笉鍋滅殑鐐瑰嚮榧犳爣錛岃繖
縐嶆棤鑱婄殑浜嬫儏閫氳繃"鎸夐敭綺劇伒"灝卞彲浠ヨВ鍐熾傚鎸傜殑"鎸夐敭綺劇伒"鍔熻兘鍙互璁╃帺瀹舵憜鑴辨棤瓚g殑鐐瑰嚮榧犳爣鐨勫伐浣溿?/p>
銆銆鍙︿竴綾繪槸鐢卞鎸傜▼搴忎駭鐢熸楠楁х殑緗戠粶娓告垙灝佸寘錛屽茍灝嗚繖浜涘皝鍖呭彂閫佸埌緗戠粶娓告垙鏈嶅姟鍣紝鍒╃敤榪欎簺铏氬亣淇℃伅嬈洪獥鏈嶅姟
鍣ㄨ繘琛?a target="_blank">娓告垙鏁板肩殑淇敼錛岃揪鍒頒慨鏀硅鑹茶兘鍔涙暟鍊肩殑鐩殑銆傝繖綾誨鎸傜▼搴忛拡瀵規(guī)у緢寮猴紝涓鑸湪璁捐鏃墮兘鏄拡瀵規(guī)煇涓?a target="_blank">娓告垙鏌愪釜
鐗堟湰鏉ュ仛鐨勶紝鍥犱負(fù)姣忎釜緗戠粶娓告垙鏈嶅姟鍣ㄤ笌瀹㈡埛绔氦嫻佺殑鏁版嵁鍖呭悇涓嶇浉鍚岋紝澶栨寕紼嬪簭蹇呴』瑕佸嬈洪獥鐨勭綉緇?a target="_blank">娓告垙鏈嶅姟鍣ㄧ殑鏁版嵁
鍖呰繘琛屽垎鏋愶紝鎵嶈兘浜х敓鏈嶅姟鍣ㄨ瘑鍒殑鏁版嵁鍖呫傝繖綾誨鎸傜▼搴忎篃鏄綋鍓嶆渶嫻佸埄鐨勪竴綾?a target="_blank">娓告垙澶栨寕紼嬪簭銆?/p>
銆銆鍙﹀錛岀幇鍦ㄥ緢澶氬鎸傜▼搴忓姛鑳藉己澶э紝涓嶄粎瀹炵幇浜嗚嚜鍔ㄥ姩浣滀唬鐞嗗拰灝佸寘鍔熻兘錛岃屼笖榪樻彁渚涗簡瀵圭綉緇?a target="_blank">娓告垙鐨勫鎴風(fēng)紼嬪簭鐨?/p>
鏁版嵁榪涜淇敼錛屼互杈懼埌嬈洪獥緗戠粶娓告垙鏈嶅姟鍣ㄧ殑鐩殑銆傛垜鐩鎬俊錛岄殢鐫緗戠粶娓告垙鍟嗗鐨勫弽澶栨寕鎶鏈?/font>鐨勮繘灞曪紝娓告垙澶栨寕灝嗕細(xì)浜х敓
鏇村鏇翠紭縐鐨?a target="_blank">鎶鏈?/font>錛岃鎴戜滑鏈熷緟鐫鐪嬪満鎶鏈?/font>澶ф垬鍚?.....
銆銆涓夈佸鎸?a target="_blank">鎶鏈?/font>緇艱堪
銆銆鍙互灝嗗紑鍙?a target="_blank">娓告垙澶栨寕紼嬪簭鐨勮繃紼嬪ぇ浣撲笂鍒掑垎涓轟袱涓儴鍒嗭細(xì)
銆銆鍓嶆湡閮ㄥ垎宸ヤ綔鏄澶栨寕鐨勪富浣?a target="_blank">娓告垙榪涜鍒嗘瀽錛屼笉鍚岀被鍨嬬殑澶栨寕鍒嗘瀽涓諱綋娓告垙鐨勫唴瀹逛篃涓嶇浉鍚屻傚澶栨寕涓轟笂榪拌皥鍒扮殑澶?/p>
鎸傜被鍨嬩腑鐨勭涓綾繪椂錛屽叾鍒嗘瀽榪囩▼甯告槸閽堝娓告垙鐨勫満鏅腑鐨?a target="_blank">鏀誨嚮瀵硅薄鐨勪綅緗拰鍒嗗竷鎯呭喌榪涜鍒嗘瀽錛屼互瀹炵幇澶栨寕鑷姩榪涜鏀?/p>
鍑諱互鍙?qiáng)浣嵕|Щ鍔ㄣ傚澶栨寕涓哄鎸傜被鍨嬩腑鐨勭浜岀被鏃訛紝鍏跺垎鏋愯繃紼嬪父鏄拡瀵?a target="_blank">娓告垙鏈嶅姟鍣ㄤ笌瀹㈡埛绔箣闂撮氳鍖呮暟鎹殑緇撴瀯銆佸唴
瀹逛互鍙?qiáng)鍔犲瘑绠楁硶鐨勫垎鏋愩傚洜緗戠粶娓告垙鍏徃涓鑸兘涓嶄細(xì)鍏竷鍏?a target="_blank">娓告垙浜у搧鐨勯氳鍖呮暟鎹殑緇撴瀯銆佸唴瀹瑰拰鍔犲瘑綆楁硶鐨勪俊鎭紝鎵浠?/p>
瀵逛簬寮鍙戠浜岀被澶栨寕鎴愬姛鐨勫叧閿湪浜庢槸鍚﹁兘姝g‘鍒嗘瀽娓告垙鍖呮暟鎹殑緇撴瀯銆佸唴瀹逛互鍙?qiáng)鍔犲瘑绠楁硶锛岃櫧鐒跺彲浠ヤ娇鐢ㄤ竴浜?a target="_blank">宸ュ叿杈呭姪
鍒嗘瀽錛屼絾鏄繖榪樻槸涓縐嶅潥鑻﹁屽鏉傜殑宸ヤ綔銆?/p>
銆銆鍚庢湡閮ㄥ垎宸ヤ綔涓昏鏄牴鎹墠鏈熷娓告垙鐨勫垎鏋愮粨鏋滐紝浣跨敤澶ч噺鐨勭▼搴忓紑鍙?a target="_blank">鎶鏈?/font>緙栧啓澶栨寕紼嬪簭浠ュ疄鐜板娓告垙鐨勬帶鍒舵垨淇敼
銆傚澶栨寕紼嬪簭涓虹涓綾誨鎸傛椂錛岄氬父浼?xì)鋴社敤鍒伴紶鏍囨ā鎷?a target="_blank">鎶鏈?/font>鏉ュ疄鐜?a target="_blank">娓告垙瑙掕壊鐨勮嚜鍔ㄤ綅緗Щ鍔紝浣跨敤閿洏妯℃嫙鎶鏈?/font>鏉ュ疄鐜版父
鎴忚鑹茬殑鑷姩鏀誨嚮銆傚澶栨寕紼嬪簭涓虹浜岀被澶栨寕鏃訛紝閫氬父浼?xì)鋴社敤鍒版尅鎴猄ock鍜屾尅鎴狝PI鍑芥暟鎶鏈?/font>錛屼互鎸℃埅娓告垙鏈嶅姟鍣ㄤ紶鏉ョ殑
緗戠粶鏁版嵁鍖呭茍灝嗘暟鎹寘淇敼鍚庡皝鍖呭悗浼犵粰娓告垙鏈嶅姟鍣ㄣ傚彟澶栵紝榪樻湁璁稿澶栨寕浣跨敤瀵?a target="_blank">娓告垙瀹㈡埛绔▼搴忓唴瀛樻暟鎹慨鏀?a target="_blank">鎶鏈?/font>浠ュ強(qiáng)
娓告垙
鍔犻?a target="_blank">鎶鏈?/font>銆?/p>
銆銆鏈枃涓昏鏄拡瀵瑰紑鍙?a target="_blank">娓告垙澶栨寕紼嬪簭鍚庢湡浣跨敤鐨勭▼搴忓紑鍙?a target="_blank">鎶鏈?/font>榪涜鎺㈣錛岄噸鐐逛粙緇嶇殑濡備笅鍑犵鍦?a target="_blank">娓告垙澶栨寕涓父浣跨敤鐨勭▼ 搴忓紑鍙?a target="_blank">鎶鏈?/font>錛?/p>
銆銆鈼?鍔ㄤ綔妯℃嫙鎶鏈?/font>錛氫富瑕佸寘鎷敭鐩樻ā鎷?a target="_blank">鎶鏈?/font>鍜岄紶鏍囨ā鎷?a target="_blank">鎶鏈?/font>銆?/p>
銆銆鈼?灝佸寘鎶鏈?/font>錛氫富瑕佸寘鎷尅鎴猄ock鎶鏈?/font>鍜屾尅鎴狝PI鎶鏈?/font>銆?/p>
鍥涖佸姩浣滄ā鎷?a target="_blank">鎶鏈?/font> 銆銆鎴戜滑鍦ㄥ墠闈粙緇嶈繃錛屽嚑涔庢墍鏈夌殑娓告垙閮芥湁澶ч噺綣佺悙鍜屾棤鑱婄殑鏀誨嚮鍔ㄤ綔浠ュ鍔犵帺瀹剁殑鍔熷姏錛岃繕鏈夐偅浜涙暟涓嶅畬鐨勮糠瀹紝榪?/p>
浜涘ソ鍍忓凡緇忔垚涓轟簡瑙掕壊娓告垙鐨勪唬鍚嶈瘝銆傜幇鍦紝澶栨寕鍙互甯姪鐜╁浠庤繖浜涚箒鐞愯屾棤鑱婄殑宸ヤ綔涓憜鑴卞嚭鏉ワ紝涓撴敞浜?a target="_blank">娓告垙鎯呰妭鐨?/p>
榪涘睍銆傚鎸傜▼搴忎負(fù)浜嗗疄鐜拌嚜鍔ㄨ鑹蹭綅緗Щ鍔ㄥ拰鑷姩鏀誨嚮絳夊姛鑳斤紝闇瑕佷嬌鐢ㄥ埌閿洏妯℃嫙鎶鏈?/font>鍜岄紶鏍囨ā鎷?a target="_blank">鎶鏈?/font>銆備笅闈㈡垜浠皢閲?/p>
鐐逛粙緇嶈繖浜?a target="_blank">鎶鏈?/font>騫剁紪鍐欎竴涓畝鍗曠殑瀹炰緥甯姪璇昏呯悊瑙e姩浣滄ā鎷?a target="_blank">鎶鏈?/font>鐨勫疄鐜拌繃紼嬨?/p>
銆銆錛戯紟 榧犳爣妯℃嫙鎶鏈?/font> 錛屾垜浠浣曞疄鐜板湪娌℃湁鐜╁鐨勫弬涓庝笅瑙掕壊涔熷彲浠ヨ嚜鍔ㄨ璧板憿銆傚叾瀹炲疄鐜拌繖涓茍涓嶉毦錛屼粎浠呭嚑涓猈indows API鍑芥暟灝卞彲浠ユ悶 瀹氾紝璁╂垜浠厛鏉ヨ璇嗚璇嗚繖浜汚PI鍑芥暟銆?/p>
銆銆(1) 妯℃嫙榧犳爣鍔ㄤ綔API鍑芥暟mouse_event錛屽畠鍙互瀹炵幇妯℃嫙榧犳爣鎸変笅鍜屾斁寮絳夊姩浣溿?/p>
銆銆銆銆VOID mouse_event( 銆銆鍏朵腑錛宒wFlags琛ㄧず浜嗗悇縐嶅悇鏍風(fēng)殑榧犳爣鍔ㄤ綔鍜岀偣鍑?yán)L椿鍔紝瀹冪殑甯哥敤鍙栧煎涓嬶細(xì) 銆銆銆MOUSEEVENTF_MOVE銆琛ㄧず妯℃嫙榧犳爣縐誨姩浜嬩歡銆?/p>
銆銆銆MOUSEEVENTF_LEFTDOWN 琛ㄧず妯℃嫙鎸変笅榧犳爣宸﹂敭銆?/p>
銆銆銆MOUSEEVENTF_LEFTUP 琛ㄧず妯℃嫙鏀懼紑榧犳爣宸﹂敭銆?/p>
銆銆銆MOUSEEVENTF_RIGHTDOWN 琛ㄧず妯℃嫙鎸変笅榧犳爣鍙抽敭銆?/p>
銆銆銆MOUSEEVENTF_RIGHTUP 琛ㄧず妯℃嫙鏀懼紑榧犳爣鍙抽敭銆?/p>
銆銆銆MOUSEEVENTF_MIDDLEDOWN 琛ㄧず妯℃嫙鎸変笅榧犳爣涓敭銆?/p>
銆銆銆MOUSEEVENTF_MIDDLEUP 琛ㄧず妯℃嫙鏀懼紑榧犳爣涓敭銆?/p>
銆銆(2)銆佽緗拰鑾峰彇褰撳墠榧犳爣浣嶇疆鐨凙PI鍑芥暟銆傝幏鍙栧綋鍓嶉紶鏍囦綅緗嬌鐢℅etCursorPos()鍑芥暟錛岃緗綋鍓嶉紶鏍囦綅緗嬌鐢?/p>
SetCursorPos()鍑芥暟銆?/p>
銆銆銆銆BOOL GetCursorPos( 銆銆閫氬父娓告垙瑙掕壊鐨勮璧伴兘鏄氳繃榧犳爣縐誨姩鑷崇洰鐨勫湴錛岀劧鍚庢寜涓涓嬮紶鏍囩殑鎸夐挳灝辨悶瀹氫簡銆備笅闈㈡垜浠嬌鐢ㄤ笂闈粙緇嶇殑API鍑?/p>
鏁版潵妯℃嫙瑙掕壊琛岃蛋榪囩▼銆?/p>
銆銆銆CPoint oldPoint,newPoint; 銆銆2錛?閿洏妯℃嫙鎶鏈?/font> 銆銆鍦ㄥ緢澶?a target="_blank">娓告垙涓紝涓嶄粎鎻愪緵浜嗛紶鏍囩殑鎿嶄綔錛岃屼笖榪樻彁渚涗簡閿洏鐨勬搷浣滐紝鍦ㄥ鏀誨嚮瀵硅薄榪涜鏀誨嚮鏃惰繕鍙互浣跨敤蹇嵎閿備負(fù) 浜嗕嬌榪欎簺鏀誨嚮榪囩▼鑳藉鑷姩榪涜錛屽鎸傜▼搴忛渶瑕佷嬌鐢ㄩ敭鐩樻ā鎷?a target="_blank">鎶鏈?/font>銆傚儚榧犳爣妯℃嫙鎶鏈?/font>涓鏍鳳紝W(xué)indows API涔熸彁渚涗簡涓緋誨垪 API鍑芥暟鏉ュ畬鎴愬閿洏鍔ㄤ綔鐨勬ā鎷熴?/p>
銆銆妯℃嫙閿洏鍔ㄤ綔API鍑芥暟keydb_event錛屽畠鍙互妯℃嫙瀵歸敭鐩樹笂鐨勬煇涓垨鏌愪簺閿繘琛屾寜涓嬫垨鏀懼紑鐨勫姩浣溿?/p>
銆銆銆VOID keybd_event( 銆銆鍏朵腑錛宐Vk琛ㄧず铏氭嫙閿鹼紝鍏跺疄瀹冩槸涓涓狟YTE綾誨瀷鍊肩殑瀹忥紝鍏跺彇鍊艱寖鍥翠負(fù)1-254銆傛湁鍏寵櫄鎷熼敭鍊艱〃璇峰湪MSDN涓婁嬌鐢ㄥ叧閿?/p>
瀛椻淰irtual-Key Codes鈥濇煡鎵劇浉鍏寵祫鏂欍俠Scan琛ㄧず褰撻敭鐩樹笂鏌愰敭琚寜涓嬪拰鏀懼紑鏃訛紝閿洏緋葷粺紜歡浜х敓鐨勬壂鎻忕爜錛屾垜浠彲 浠apVirtualKey()鍑芥暟鍦ㄨ櫄鎷熼敭鍊間笌鎵弿鐮佷箣闂磋繘琛岃漿鎹€俤wFlags琛ㄧず鍚勭鍚勬牱鐨勯敭鐩樺姩浣滐紝瀹冩湁涓ょ鍙栧鹼細(xì) KEYEVENTF_EXTENDEDKEY鍜孠EYEVENTF_KEYUP銆?/p>
銆銆涓嬮潰鎴戜滑浣跨敤涓孌?a target="_blank">浠g爜瀹炵幇鍦?a target="_blank">娓告垙涓寜涓婼hift+R蹇嵎閿鏀誨嚮瀵硅薄榪涜鏀誨嚮銆?/p>
銆銆銆keybd_event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),0,0); //鎸変笅CTRL閿?br />銆銆銆keybd_event(0x52,MapVirtualKey(0x52,0),0,0);//閿笅R閿?br />銆銆銆keybd_event(0x52,MapVirtualKey(0x52,0), KEYEVENTF_KEYUP,0);//鏀懼紑R閿?br />銆銆銆keybd_event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0), 銆銆3錛?嬋媧誨鎸?/p>
銆銆涓婇潰浠嬬粛鐨勯紶鏍囧拰閿洏妯℃嫙鎶鏈?/font>瀹炵幇浜嗗娓告垙瑙掕壊鐨勫姩浣滈儴鍒嗙殑妯℃嫙錛屼絾瑕佹兂澶栨寕鑳藉伐浣滀簬娓告垙涔嬩笂錛岃繕闇瑕佸皢鍏朵笌
娓告垙
鐨勫満鏅獥鍙h仈緋昏搗鏉ユ垨鑰呬嬌鐢ㄤ竴涓縺媧婚敭錛屽氨璞℃寜閿簿鐏電殑閭d釜嬋媧婚敭涓鏍楓傛垜浠彲浠ョ敤GetWindow鍑芥暟鏉ユ灇涓劇獥鍙?/p>
錛屼篃鍙互鐢‵indwindow鍑芥暟鏉ユ煡鎵劇壒瀹氱殑紿楀彛銆傚彟澶栬繕鏈変竴涓狥indWindowEx鍑芥暟鍙互鎵懼埌紿楀彛鐨勫瓙紿楀彛錛屽綋娓告垙鍒囨崲鍦烘櫙 鐨勬椂鍊欐垜浠彲浠ョ敤FindWindowEx鏉ョ‘瀹氫竴浜涘綋鍓嶇獥鍙g殑鐗瑰緛錛屼粠鑰屽垽鏂槸鍚﹁繕鍦ㄨ繖涓満鏅紝鏂規(guī)硶寰堝浜嗭紝姣斿鍙互 GetWindowInfo鏉ョ‘瀹氫竴浜涗笢瑗匡紝姣斿褰撴煡鎵句笉鍒版煇涓寜閽殑鏃跺欏氨璇存槑娓告垙鍦烘櫙宸茬粡鍒囨崲浜嗙瓑絳夊姙娉曘傚綋浣跨敤嬋媧婚敭榪?/p>
琛屽叧鑱旓紝闇瑕佷嬌鐢℉ook鎶鏈?/font>寮鍙戜竴涓叏灞閿洏閽╁瓙錛屽湪榪欓噷灝變笉鍏蜂綋浠嬬粛鍏ㄥ眬閽╁瓙鐨勫紑鍙戣繃紼嬩簡錛屽湪鍚庨潰鐨勫疄渚嬩腑鎴戜滑灝?/p>
浼?xì)鋴社敤鍒板叏灞閽╁瓙錛屽埌鏃跺皢瀛︿範(fàn)鍒板叏灞閽╁瓙鐨勭浉鍏?a target="_blank">鐭ヨ瘑銆?/p>
銆銆閫氳繃涓婇潰鐨勫涔?fàn)锛屾垜浠凡缁忓熀鏈叿澶囦簡缂栧啓鍔ㄤ綔寮?a target="_blank">娓告垙澶栨寕鐨勮兘鍔涗簡銆備笅闈㈡垜浠皢鍒涘緩涓涓敾絎旂▼搴忓鎸傦紝瀹冨疄鐜拌嚜 鍔ㄧЩ鍔ㄧ敾絎斿瓧鍏夋爣鐨勪綅緗茍鍐欎笅涓涓孩鑹茬殑鈥淩鈥濆瓧銆備互榪欎釜瀹炰緥涓哄熀紜錛屽姞鍏ョ浉搴旂殑娓告垙鍔ㄤ綔瑙勫垯錛屽氨鍙互瀹炵幇涓涓畬 鏁寸殑娓告垙澶栨寕銆傝繖閲屼綔鑰呬笉鎯充嬌鐢ㄦ煇涓?a target="_blank">娓告垙浣滀負(fù)渚嬪瓙鏉ュ紑鍙戝鎸傦紙鍥犳病鏈?a target="_blank">娓告垙鍟嗗鐨勬巿鏉冨晩錛侊級錛屽璇昏呮劅鍏磋叮鐨勮瘽鍙互 鎵句竴涓?a target="_blank">娓告垙璇曡瘯錛屾渶濂戒粎鍋氭祴璇?a target="_blank">鎶鏈?/font>鐢ㄣ?/p>
銆銆棣栧厛錛屾垜浠渶瑕佺紪鍐欎竴涓叏灞閽╁瓙錛屼嬌鐢ㄥ畠鏉ユ縺媧誨鎸傦紝嬋媧婚敭涓篎10銆傚垱寤哄叏灞閽╁瓙姝ラ濡備笅錛?/p>
銆銆(1)錛庨夋嫨MFC AppWizard(DLL)鍒涘緩欏圭洰ActiveKey錛屽茍閫夋嫨MFC Extension DLL錛堝叡浜玀FC鎷瘋礉錛夌被鍨嬨?/p>
銆銆(2).鎻掑叆鏂版枃浠禔ctiveKey.h錛屽湪鍏朵腑杈撳叆濡備笅浠g爜錛?/p>
銆銆銆#ifndef _KEYDLL_H 銆銆銆class AFX_EXT_CLASS CKeyHook:public CObject 銆銆(3).鍦ˋctiveKey.cpp鏂囦歡涓姞鍏ュ0鏄庯紓#include ActiveKey.h錛傘?/p>
銆銆(4).鍦ˋctiveKey.cpp鏂囦歡涓姞鍏ュ叡浜暟鎹錛?a target="_blank">浠g爜濡備笅錛?/p>
銆銆銆//Shared data section 銆銆(5).鍦ˋctiveKey.def鏂囦歡涓緗叡浜暟鎹灞炴э紝浠g爜濡備笅錛?/p>
銆銆銆SETCTIONS 銆銆(6).鍦ˋctiveKey.cpp鏂囦歡涓姞鍏keyHook綾葷殑瀹炵幇浠g爜鍜岄挬瀛愬嚱鏁?a target="_blank">浠g爜錛?/p>
銆銆銆//閿洏閽╁瓙澶勭悊鍑芥暟銆?br />銆銆銆extern "C" LRESULT WINAPI KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam) 銆銆銆CKeyHook::CKeyHook(){} 銆銆(7).淇敼DllMain鍑芥暟錛?a target="_blank">浠g爜濡備笅錛?/p>
銆銆銆extern "C" int APIENTRY if (dwReason == DLL_PROCESS_ATTACH) 銆銆鐜板湪澶ч儴鍒嗙殑涓繪祦澶栨寕錛屽寘鎷寜閿簿鐏碉紝鑷姩鍋氫竴浜涘姩浣滀箣綾葷殑澶栨寕銆?閮芥槸閫氳繃HOOK榪涙父鎴忕獥鍙o紝騫朵笖鐢ㄤ笉鍚岀殑HOOK綾誨瀷鏉ュ畬鎴愮殑錛屾瘮濡傚浜?緗戠粶錛岄氬父鏄氳繃HOOK娑堟伅錛屾妸DLL寮勫埌鎴戜滑鐨勬父鎴忕▼搴忎腑錛岀劧鍚庨氳繃 銆銆閭d箞鍦ㄦ垜浠殑娓告垙鎵ц鐨勬椂鍊欙紝鏀跺埌娑堟伅灝變細(xì)鍏堣Е鍙戜粬浠殑閽╁瓙錛岀瓑浠栦滑甯冪疆濂介偑鎭剁殑闄烽槺錛岀劧鍚庡啀鎵ц鎴戜滑鐨勭▼搴忋傞偅涔堬紝瀵逛簬榪欑被鍨嬬殑澶栨寕錛岃鎬庝箞闃插憿錛熶織璇濊寰楀ソ錛屼互褰間箣閬擄紝榪樺埗褰艱韓銆傛墍璋撻瓟楂樹竴灝猴紝閬撻珮涓涓堛傛墍璋撻偑涓嶈儨姝c傛墍璋撳ぉ緗戞仮鎭€傛墍璋撳仛璐煎績铏氥? 銆銆鎭╋紝W(xué)INDOWS鐨勯挬瀛愭湁涓壒鐐癸紝灝辨槸閽╁瓙閾撅紝鍥犱負(fù)瀵逛簬鍚屼竴涓繘紼嬶紝鍗充嬌鏄悓涓綾誨瀷鐨勯挬瀛愶紝鑳藉悓鏃舵湁澶氫釜錛屼篃灝辨槸璇達(dá)紝瀵逛簬鍚屼竴涓父鎴忥紝寮涓や釜鍔熻兘鐩稿悓鐨勫鎸備篃鍙互銆傞偅涔堬紝鎬庝箞鏍鋒潵鍐沖畾閽╁瓙鐨勯『搴忓憿錛熸墍璋? 銆銆榪欎釜鍑芥暟鏄疌allNextHookEx錛屼篃灝辨槸璇達(dá)紝濡傛灉鍦ㄦ煇涓挬瀛愰噷闈笉鎵ц榪欎釜鍑芥暟鐨勮瘽錛岄挬瀛愰摼灝變細(xì)鍦ㄨ繖涓柇錛岄偅涔堟垜浠殑鎬濊礬灝卞緢綆鍗曚簡錛屽湪娓告垙榪愯涓紝寮涓涓繘紼嬶紝姣忛殧涓孌墊椂闂村氨hook鎴戜滑鐨勪富紼嬪簭錛岀劧鍚庡湪閽? 銆銆鎵璋擄紝浠呬粎鍙戠幇鏁屼漢榪樹笉澶燂紝榪樿娑堢伃鏁屼漢銆備笉鎬ワ紝鎴戜滑鏉ョ湅鐪嬪浣曞交搴曟妸鏁屼漢鎵撴垚綺夌鎬ч鎶樸傛仼錛岃娑堢伃鏁屼漢灝辮澶嶆潅涓鐐逛簡錛岃閽堝涓嶅悓綾誨瀷鐨勯挬瀛愭潵閲囧彇涓嶅悓綾誨瀷鐨勬柟娉曚簡錛屽洜涓烘晫浜虹殑閽╁瓙涓嶇鎬庝箞鍋氾紝 銆銆褰撶劧錛屾晫浜轟篃涓嶆槸榪欎箞鑴嗗急鐨勶紝鎹鏈変漢鐢╮aw socket鏉ユ埅鑾鋒墍鏈夌殑緗戠粶娑堟伅錛岃繖涓窡閽╁瓙鏃犲叧錛岃繖涓洿搴曞眰涓浜涖備笉榪囦笉鐢ㄦ曪紝淇楄瘽璇村緱濂斤紝浠ュ郊涔嬮亾錛岃繕鍒跺郊韜傛墍璋撻瓟楂樹竴灝猴紝閬撻珮涓涓堛傛墍璋撻偑涓嶈儨姝c傛墍璋? 銆銆姣旀渶絳夌駭楂樹竴鐐圭偣鐨勬晫浜猴紝浼?xì)鍠湅脾鐢ㄩ挬瀛愭潵鐩存帴閽╁Q屼竴鑸殑鍋氭硶鏄紝鍏堥氳繃GetProcAddress鏉ヨ幏鍙朣OCKET API鐨勫湴鍧錛岀劧鍚庨氳繃WriteProcessMemory鐨勬柟娉曟潵淇敼鍏ュ彛鍦板潃錛屽皢鍏舵敼鎴恓mp 鑷繁鐨勫嚱鏁板湴鍧銆傝繖縐嶆柟娉曞叾瀹炲緢鍗戝姡鐨勶紝鎵璋撴棤姣掍笉涓堝か錛屾垜浠彲浠ラ氳繃淇敼閫氱敤鐨凣etProcAddress鐨勪唬鐮佹潵闃叉鍒漢鎷︽埅SOCKET錛岃繖鏍鳳紝鐩存帴榪為槻鐏閮藉彲浠ョ獊鐮翠簡銆? 銆銆榪欓噷鐨勬妧鏈毦鐐瑰湪浜庯紝鎴戜滑涓嶈兘鐢ㄧ被浼糤riteProcessMemory鐨勬柟娉曟潵鍐欏唴瀛樺洜涓烘垜浠笉鐭ラ亾絀剁珶澶栨寕鏄摢涓繘紼嬶紝鎵浠ユ垜浠渶瑕佷慨鏀筗INDOWS鐨勪唬鐮佹錛岃繖鏍瘋鐞嗚涓婃槸涓嶅彲鑳界殑錛屽彲鎯淲INDOWS鑷繁緇欒嚜宸辯暀浜嗕釜鍚庨棬錛屽湪kernel.dll銆閲岄潰錛孶INT AllocCsToDsAlias(UINT)錛岄氳繃鎶夾PI鐨勪唬鐮佹鐨勯夋嫨絎︿紶緇欏畠錛屽彲浠ヨ繑鍥炰竴涓彲浠ュ啓鐨勬暟鎹鐨勯夋嫨絎︼紝鐒跺悗鎶婃柊鐨勯夋嫨絎﹀拰API鐨勫叆鍙e湴鍧鍔犲湪涓璧鳳紝灝卞彲浠ュ緱鍒頒竴涓彲浠ュ啓鐨勪唬鐮佹鐨勬寚閽堛? 銆銆鍥藉唴濂藉鍙栬瘝杞歡鍜屽叏灞忕炕璇戣蔣浠墮兘鏄敤鐨勮繖涓師鐞嗭紝鍏蜂綋鐨勪緥瀛愬涓嬶細(xì) 銆銆鐒跺悗灝卞彲浠ュ線addr榪欎釜鍦板潃鍐?涓狟YTE鐨勪笢瑗匡紝絎竴涓狟YTE鏄痡mp錛屼笉鍚岀殑CPU銆鍙兘浼?xì)涓嶅悓锛屼箣鍚庣殑涓涓狣WORD鏄綘鐨勫嚱鏁扮殑鍦板潃銆傘? 銆銆榪欐牱錛屽彲浠ラ氳繃淇濆瓨涓や喚addr鐨勬暟鎹潵鍋氬埌閽╁瓙鐨勫紑鍏籌紝褰撻挬瀛愭墦寮鐨勬椂鍊欙紝鎵鏈夌殑GetProcAddress鐨勮皟鐢ㄩ兘浼?xì)璋冨埌鎴戜滑鐨勫嚱鏁板Q岃繖涓椂鍊欏彲浠ラ氳繃媯鏌ュ鏋滄湁浜烘兂GetProcAddress wsock32.dll閲岀殑涓滆タ錛屾垜浠氨騫叉帀瀹冦傘? 銆銆鍚屾牱錛屽鏋滄湁浜洪氳繃寮鍚痵ocket榪欎釜API鐨凷OCK_RAW鍙傛暟鏉ヨ皟鐢≧AW SOCKET鐩戣緗戠粶錛屾垜浠篃鍙互閫氳繃涓婇潰鐨勬柟娉曟潵鍋氬埌鍏堝叆涓轟富錛岀湅璋佸湪鐩戣鎴戜滑鐨勭綉緇滀紶杈撱?/p>
銆銆鍏跺疄鏌ュ鎸傜殑鍘熺悊鍜屾崏鐥呮瘨鐨勫師鐞嗕竴鏍鳳紝鍙槸鐜板湪鍋氬鎸傜殑鎶鏈繕涓嶆垚鐔熴傚綋鍋氬鎸傜殑鎶鏈拰闃插鎸傜殑鎶鏈湪鍚屼竴鏉$嚎涓婄殑鏃跺欙紝鎯充粠鎶鏈笂闃蹭綇澶栨寕鏄笉鍙兘鐨勩? 銆銆鍏跺疄鏄棤濂堬紝鏉姣掕蔣浠剁殑鍋氭硶鏄嚭鏉ヤ竴縐嶆柊鐨勭梾姣掞紝鍦ㄧ涓鏃墮棿鍐呭叕甯冨叾鐗瑰緛鐮侊紝鐒跺悗鏇存柊鎵鏈夌殑瀹㈡埛绔紝鐪嬪埌榪欑鐗瑰緛鐨勶紝灝辨潃銆傚叾瀹炴煡鏉澶栨寕涔熻濡傛錛屽叾瀹濩S鐨凜heating-Death灝辨槸榪欎釜鍘熺悊錛屼笉綆″嚭浜嗕粈涔堟柊鐨勫鎸傦紝CD 鎬繪槸鍦ㄧ涓鏃墮棿鍐呮洿鏂幫紝鐒跺悗瀹㈡埛绔篃灝卞偦鍌?cè)潥勫彧瑕佷竴鐪嬪埌鏈夎繖涓壒寰佺殑涓滆タ灝辨妸瀹冨共鎺夈傚叾瀹炰粩緇嗘兂鎯籌紝榪欐槸涓緢濂界殑涓繪剰錛屼粠澶栨寕寮鍙戝晢鐨勫姩鏈烘潵鍒嗘瀽銆備粬浠箣鎵浠ヨ寮鍙戝鎸傦紝浼拌鐐鎶鏈槸涓鏂歸潰錛屾洿閲嶈鐨勮繕鏄兂璧氶挶錛屾垨鑰呯敤鏉ユ寕鏈轟箣綾葷殑錛屾棦鐒惰璧氶挶錛屾垨鑰呮寕鏈猴紝灝卞繀鐒朵細(xì)琚叾浠栫帺瀹跺彂鐜版垨鑰呬婦鎶ワ紝榪欎釜鏃跺欏簲璇ュ仛鐨勫氨鏄敖蹇殑涓嬭澆涓浠藉鎸傦紝鎴栬呮牴鎹叾琛屼負(fù)鐮旂┒鍏剁壒寰侊紝騫跺湪闃插鎸傜殑鐗瑰緛鐮佷笂璁頒笅涓絎旓紝鍏跺疄涓嶇敤澶鏉傦紝鏈綆鍗曠殑鍋氭硶灝辨槸璁頒綇鍏跺鎸傜獥鍙g殑鍚嶇О錛岀劧鍚庡彧瑕佺湅鍒拌繖涓鎸傜獥鍙o紝鍋氫簺澶勭悊灝卞ソ浜嗐? 銆銆閭d箞榪欐牱涓鏉ワ紝鍏抽敭鐨勬妧鏈氨钀藉湪濡備綍璁捐鏌ュ鎸傝繖涓粨鏋勪笂浜嗭紝棣栧厛瀹㈡埛绔渶瑕佺殑鏄竴涓煡澶栨寕寮曟搸錛屽拰涓涓鎸傜壒寰佸簱錛屾牴鎹紩鎿庡拰鐗瑰緛搴撶敓鎴愪竴涓浐瀹氱殑鐗堟湰鍙鳳紝鐒跺悗姣忔鐧婚檰鐨勬椂鍊欏氨鐢ㄨ繖涓増鏈彿錛岃窡鏈嶅姟鍣ㄤ笂鐨勭増鏈彿瀵規(guī)瘮錛屽鏋滀笉涓鏍風(fēng)殑璇濓紝鍒欎粠鏈嶅姟鍣ㄨ嚜鍔ㄤ笅杞芥渶鏂扮殑鏌ュ鎸傚紩鎿庡拰澶栨寕鐗瑰緛搴撱? 銆銆榪欐牱铏界劧涓嶈兘灝嗗鎸傝刀灝芥潃緇濓紝鍗磋兘姣旇緝澶х殑闄愬害涓婂洿鍓夸嬌鐢ㄥ鎸傜殑椋庢皵錛岀浉淇′嬌鐢ㄥ鎸傜殑鐜╁涔熷彧鏄兂鏇村ソ鐨勭帺娓告垙錛屽彧涓嶈繃鍔ㄧ殑蹇靛ご鏈変簺姝簡錛屼絾鍏跺嚭鍙戠偣浠嶆槸濂界殑錛屽彧瑕佸湪浠栦嬌鐢ㄥ鎸傜殑鏃跺欏浜涢樆鎷︽垨鑰呰瀵間粬涓嶄嬌鐢ㄥ鎸傦紝榪欐牱鏁堟灉灝變細(xì)濂藉緢澶氥傝鎯充竴涓嬶紝璋佹効鎰忔瘡澶╃瓑涓涓鎸傜殑鏇存柊錛岃屼笉鍘葷帺浠栧緢鎯崇帺鐨勬父鎴忓憿銆傝繖鏍蜂竴鏉ワ紝鍒朵綔澶栨寕鐨勪漢涔熶細(xì)閫愭笎鍑忓皯錛屼粠鑰岃繘鍏ヤ竴涓壇鎬у驚鐜? 銆銆灝卞ソ璞″浠婂啓鐥呮瘨錛屽茍涓嶅褰撳勾閭d箞嫻佽浜嗐傘?銆?
銆銆
銆銆鍑犱箮鎵鏈夌殑娓告垙涓兘浣跨敤浜嗛紶鏍囨潵鏀瑰彉瑙掕壊鐨勪綅緗拰鏂瑰悜錛岀帺瀹朵粎鐢ㄤ竴涓皬灝忕殑榧犳爣錛屽氨鍙互浣胯鑹茬晠娓稿ぉ涓嬨傞偅涔?/p>
銆銆銆銆銆銆DWORD dwFlags, // 榧犳爣鍔ㄤ綔鏍囪瘑銆?br />銆銆銆銆銆銆DWORD dx, // 榧犳爣姘村鉤鏂瑰悜浣嶇疆銆?br />銆銆銆銆銆銆DWORD dy, // 榧犳爣鍨傜洿鏂瑰悜浣嶇疆銆?br />銆銆銆銆銆銆DWORD dwData, // 榧犳爣杞瓙杞姩鐨勬暟閲忋?br />銆銆銆銆銆銆DWORD dwExtraInfo // 涓涓叧鑱旈紶鏍囧姩浣滆緟鍔犱俊鎭?br />銆銆銆銆);
銆銆銆銆銆LPPOINT銆lpPoint // 榪斿洖榧犳爣鐨勫綋鍓嶄綅緗?br />銆銆銆銆);
銆銆銆銆BOOL SetCursorPos(
銆銆銆銆int X, // 榧犳爣鐨勬按騫蟲柟鍚戜綅緗?br />銆銆銆銆銆銆int Y //榧犳爣鐨勫瀭鐩存柟鍚戜綅緗?br />銆銆銆銆);聽
銆銆銆GetCursorPos(&oldPoint); //淇濆瓨褰撳墠榧犳爣浣嶇疆銆?br />銆銆銆newPoint.x = oldPoint.x+40;
銆銆銆newPoint.y = oldPoint.y+10;
銆銆銆SetCursorPos(newPoint.x,newPoint.y); //璁劇疆鐩殑鍦頒綅緗?br />銆銆銆mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);//妯℃嫙鎸変笅榧犳爣鍙抽敭銆?br />銆銆銆mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);//妯℃嫙鏀懼紑榧犳爣鍙抽敭銆偮?
銆銆銆銆銆BYTE bVk, // 铏氭嫙閿箋?br />銆銆銆銆銆BYTE bScan, // 紜歡鎵弿鐮併?br />銆銆銆銆銆DWORD dwFlags, // 鍔ㄤ綔鏍囪瘑銆?br />銆銆銆銆銆DWORD dwExtraInfo // 涓庨敭鐩樺姩浣滃叧鑱旂殑杈呭姞淇℃伅銆?br />銆銆銆);
銆銆銆KEYEVENTF_KEYUP,0);//鏀懼紑CTRL閿?
銆銆4錛?瀹炰緥瀹炵幇
銆銆銆#define _KEYDLL_H
銆銆銆{
銆銆銆銆public:
銆CKeyHook();
銆~CKeyHook();
銆HHOOK Start();銆//瀹夎閽╁瓙
銆BOOL Stop(); //鍗歌澆閽╁瓙
銆銆銆};
銆銆銆#endif聽
銆銆銆#pragma data_seg("sharedata")
銆銆銆HHOOK glhHook=NULL; //閽╁瓙鍙ユ焺銆?br />銆銆銆HINSTANCE glhInstance=NULL; //DLL瀹炰緥鍙ユ焺銆?br />銆銆銆#pragma data_seg()聽
銆銆銆shareddata READ WRITE SHARED
銆銆銆{
銆銆銆if( nCode >= 0 )
銆銆銆{
銆銆銆if( wParam == 0X79 )//褰撴寜涓婩10閿椂錛屾縺媧誨鎸傘?br />銆{
銆銆//澶栨寕瀹炵幇浠g爜銆?br />CPoint newPoint,oldPoint;
銆銆 GetCursorPos(&oldPoint);
銆銆 newPoint.x = oldPoint.x+40;
銆銆 newPoint.y = oldPoint.y+10;
銆銆 SetCursorPos(newPoint.x,newPoint.y);
銆銆 mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);//妯℃嫙鎸変笅榧犳爣宸﹂敭銆?br />銆銆mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);//妯℃嫙鏀懼紑榧犳爣宸﹂敭銆?br />銆銆keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),0,0); //鎸変笅SHIFT閿?br />銆銆keybd_event(0x52,MapVirtualKey(0x52,0),0,0);//鎸変笅R閿?br />銆銆keybd_event(0x52,MapVirtualKey(0x52,0),KEYEVENTF_KEYUP,0);//鏀懼紑R閿?br />銆銆keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),KEYEVENTF_KEYUP,0);//鏀懼紑SHIFT閿?br />銆銆銆銆銆銆SetCursorPos(oldPoint.x,oldPoint.y);
銆}
銆銆銆}
銆銆銆return CallNextHookEx(glhHook,nCode,wParam,lParam);
銆銆銆}
銆銆銆CKeyHook::~CKeyHook()
銆銆銆{銆
銆銆銆if( glhHook )
Stop();
銆銆銆}
銆銆銆//瀹夎鍏ㄥ眬閽╁瓙銆?br />銆銆銆HHOOK CKeyHook::Start()
銆銆銆{
glhHook = SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,glhInstance,0);//璁劇疆閿洏閽╁瓙銆?br />return glhHook;
}
銆銆銆//鍗歌澆鍏ㄥ眬閽╁瓙銆?br />銆銆銆BOOL CKeyHook::Stop()
銆銆銆{
銆銆銆BOOL bResult = TRUE;
銆if( glhHook )
銆銆銆bResult = UnhookWindowsHookEx(glhHook);//鍗歌澆閿洏閽╁瓙銆?br />銆銆銆return bResult;
銆銆銆}聽
銆銆銆DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
銆銆銆{
//濡傛灉浣跨敤lpReserved鍙傛暟鍒欏垹闄や笅闈㈣繖琛?
UNREFERENCED_PARAMETER(lpReserved);
{
銆銆TRACE0("NOtePadHOOK.DLL Initializing!\n");
銆銆 //鎵╁睍DLL浠呭垵濮嬪寲涓嬈?
銆銆if (!AfxInitExtensionModule(ActiveKeyDLL, hInstance))
return 0;
銆銆new CDynLinkLibrary(ActiveKeyDLL);
銆銆銆銆銆銆//鎶奃LL鍔犲叆鍔ㄦ?/font>MFC綾誨簱涓?
銆銆glhInstance = hInstance;
銆銆//鎻掑叆淇濆瓨DLL瀹炰緥鍙ユ焺
}
else if (dwReason == DLL_PROCESS_DETACH)
{
銆銆TRACE0("NotePadHOOK.DLL Terminating!\n");
銆銆//緇堟榪欎釜閾炬帴搴撳墠璋冪敤瀹?
銆銆AfxTermExtensionModule(ActiveKeyDLL);
}
return 1;
銆銆銆}
]]>
GetProcAddress寰楀埌DLL涓畠浠崙鍔g殑鍑芥暟鐨勫湴鍧鍜岀湡瀹炵殑鍑芥暟鍦板潃錛?鐒跺悗閫氳繃WriteProcessMemory鏉ユ妸鎴戜滑鐨勫嚱鏁板湴鍧鏀規(guī)垚浠栦滑浠栦滑鐨凙PI 鍦板潃銆?
鍚庢潵鑰呭厛寰楋紝W(xué)INDOWS鐨勫仛娉曟槸錛屾渶鍚庝竴涓狧OOK鏌愪釜榪涚▼鐨勯挬瀛愭渶鍏堟墽琛屻傚茍涓旀尟濂嬩漢蹇冪殑娑堟伅鏄紝鍦ㄩ挬瀛愰噷闈㈠彲浠ユ帶鍒朵笅涓涓挬瀛愭槸鍚︽墽琛屻?
瀛愰噷闈紝涓嶆墽琛孋allNextHookEx錛岃繖鏍峰氨鍙互閬垮厤鍒漢鐨勯挬瀛愭墽琛屻?
鏃犻潪鏄嚭浜庝袱縐嶇洰鐨勶紝涓縐嶆槸淇敼鏁版嵁錛屽彟澶栧氨鏄繃婊ゆ暟鎹傚叾鏍稿績鎬濇兂灝辨槸鎴戜滑鑷繁鐨勬父鎴忔敞鍐屼袱涓挬瀛愶紝涓涓繪槸鍦ㄩ挬瀛愰摼鐨勬渶搴曞眰錛屽彟澶栦竴涓繪槸鍦ㄩ挬瀛愰摼鐨勬渶涓婂眰錛屼竴姣旇緝涓や釜閽╁瓙鏀跺埌鐨勬秷鎭紝灝辯煡閬撲腑
闂存湁娌℃湁鍒殑閽╁瓙浜嗐備竴浣嗗彂鐜版湁鍒殑閽╁瓙錛屼笉鐢ㄦ兂浜嗭紝鑲畾鏄鎸傦紝鏈灝戜篃鐢ㄤ簡鎸夐敭綺劇伒錛屽皝鍙鳳紝鏉妗o紝鎯蟲庝箞騫插氨鎬庝箞騫層?
澶╃綉鎭㈡仮銆傛墍璋撳仛璐煎績铏氥傚浠樻嫤鎴猺aw socket鐨勫鎸傦紝榪欓噷棣栧厛瑕佹妸鏁屼漢鍒嗙被錛屽浜庢按騫蟲渶嬈$殑鏁屼漢錛屾柟娉曚篃鐩稿簲瑕佺畝鍗曞緱澶氥?鏈嬈$殑鏁屼漢涓鑸敤鐨勬柟娉曟槸鑷繁鍐欎竴涓獁sock32.dll鏀懼湪鍜屾父鎴忕浉鍚岀殑鐩綍涓嬶紝鏉ユ浛鎹㈡帀緋葷粺鐨剋sock32.dll銆傚浜庤繖縐嶆剼锠㈢殑鏂規(guī)硶錛岃В鍐崇殑鍔炴硶鏈夊緢澶氾紝鎶妉oad time鐨勮澆鍏sock32.dll鏀規(guī)垚run time鐨勮澆鍏ワ紝鐒跺悗鎸囧畾涓涓嬭礬寰勶紝灝變粈涔堥棶棰橀兘娌℃湁浜嗐傛洿綆鍗曠偣錛岃繍琛屾父鎴忕殑鏃跺欐鏌ヤ竴涓嬪綋鍓嶇洰褰曚笅鏈夋病鏈墂sock32.dll錛屾湁鐨勮瘽錛岄偅灝辮偗瀹氭槸澶栨寕閽╁瓙浜嗐?
銆銆姣斿GetProcAddress榪欎釜API錛屽湪kernel.dll閲岄潰錛屾垜浠鍋氶拡瀵瑰畠鐨勯氱敤閽╁瓙灝卞簲璇ユ寜鐓т互涓嬬殑姝ョ皣錛?
typedef UINT (WINAPI* FOO)(UINT);
FOO AllocCsToDsAlias;
HMODULE hKernel = GetModuleHandle("kernel");
AllocCsToDsAlias = (FOO)GetProcAddress(hKernel, "AllocCsToDsAlias");
FARPROC entry = GetProcAddress(hKernel, "GetProcAddress");
WORD offset = (WORD)(FP_OFF(entry));
UINT selector = AllocCsToDsAlias(FP_SEG(entry));
BYTE *addr = (BYTE *)MK_FP(selector, offset);
]]>
1 鍙栧緱榧犳爣褰撳墠浣嶇疆
2 浠ラ紶鏍囦綅緗負(fù)涓績鐢熸垚涓涓煩褰?
3 鎸備笂API閽╁瓙
4 璁╄繖涓煩褰駭鐢熼噸鐢繪秷鎭?
5 鍦ㄩ挬瀛愰噷絳夎緭鍑哄瓧絎?
6 璁$畻榧犳爣鍦ㄥ摢涓崟璇嶄笂闈紝鎶婅繖涓崟璇嶄繚瀛樹笅鏉?
7 濡傛灉寰楀埌鍗曡瘝鍒欐憳鎺堿PI閽╁瓙錛屽湪涓孌墊椂闂村悗錛屾棤璁烘槸鍚﹀緱鍒板崟璇嶉兘鎽樻帀API閽╁瓙
8 鐢ㄥ崟璇嶆煡璇嶅簱錛屾樉紺鴻В閲婃
濡備綍鎸傞挬瀛愶細(xì)
鎵璋撻挬瀛愬叾瀹炲氨鏄湪WindowsAPI鍏ュ彛鍐欎竴涓狫MP XXXX:XXXX璇彞錛岃煩杞埌鑷繁鐨勪唬鐮侀噷銆?
姝ラ濡備笅錛?
1.鍙栧緱Windows API鍏ュ彛錛岀敤GetProcAddress瀹炵幇
2.淇濆瓨API鍏ュ彛鐨勫墠浜斾釜瀛楄妭錛屽洜涓篔MP鏄?xEA錛屽湴鍧鏄?涓瓧鑺?
3.鍐欏叆璺寵漿璇彞
榪欐鏈澶嶆潅
Windows鐨勪唬鐮佹鏈潵鏄笉鍙互鍐欑殑錛屼絾鏄疢icrosoft緇欒嚜宸辯暀浜嗕釜鍚庨棬銆?
鏈変竴涓湭鍏紑鍑芥暟鏄疉llocCsToDsAlias錛?
UINT WINAPI ALLOCCSTODSALIAS(UINT);
浣犲彲浠ュ彇鍒拌繖涓嚱鏁扮殑鍏ュ彛錛屾妸API鐨勪唬鐮佹鐨勯夋嫨絎︿紶緇欎粬錛屼粬浼?xì)杩斿洖涓涓彲鍐欑殑鏁版嵁孌甸夋嫨絎︺傝繖涓夋嫨絎︾敤瀹岃閲婃斁鐨勩傜敤鏂伴夋嫨絎﹀拰API鍏ュ彛鐨勫亸縐婚噺鍚堟垚涓涓寚閽堝氨鍙互鍐檞indows鐨勪唬鐮佹浜嗐?
]]>
鍏抽敭璇嶏細(xì)姹夊寲Windows閲嶅畾浣嶆妧鏈?
涓銆佸彂鐜頒簡浠涔堬紵
浣滆呭騫存潵涓鐩翠粠浜媁indows涓嬬殑杞歡寮鍙戝伐浣滐紝緇忓巻
浜哤indows2.0銆?.0銆?.1,鐩磋嚦WindowsNT,95鐨勬垚闀胯繃紼嬶紝涔熼亶鍘?br />浜嗛暱闈掔獥鍙c侀暱鍩庣獥鍙c丏BWin銆丆Star銆丷ichWin絳夊涓猈indows姹夊寲
浜у搧銆備粠鐜板湪鐪嬫潵錛屽獎鍝嶆渶澶т篃鏈涓烘垚鍔熺殑錛屽綋鎺ㄥ洓閫氬埄鏂?br />鐨凴ichWin錛屾澶栵紝涓枃涔嬫槦CStar涓嶳ichWin甯堝嚭涓闂紝鍏舵牳蹇冩妧鏈?br />鑷劧涔熷樊涓嶈澶氥傚叾瀵瑰瀹d紶閲囩敤鐙壒鐨勨滈櫡闃扁濇妧鏈姩鎬?br />淇敼Windows浠g爜錛屼竴鐩存槸浣滆呮劅鍏磋叮鐨勫湴鏂廣?br />
EXEHDR鏄疢icrosoftVisualC++寮鍙戝伐鍏蜂腑寰堟湁鐢ㄧ殑涓涓▼
搴忥紝瀹冨彲浠ユ鏌E錛圢ew_Executable錛夋牸寮忔枃浠訛紝鐢ㄥ畠鏉ュ垎鏋怰ichWin
鐨刉SENGINE.DLL鎴朇Star鐨凜HINESE.DLL灝變細(xì)鍙戠幇涓庝紬涓嶅悓鐨勪袱鐐癸細(xì)
錛?浠Star 1.20 涓?渚嬶級
C:\CSTAR>exehdr chinese.dll /v
..................................
6 type offset target
BASE060aseg 2 offset 0000
PTR 047eimp GDI.GETCHARABCWIDTHS
PTR 059bimp GDI.ENUMFONTFAMILIES
PTR 0451imp DISPLAY.14( EXTTEXTOUT )
PTR 0415imp KEYBOARD.4( TOASCII )
PTR 04baimp KEYBOARD.5( ANSITOOEM )
PTR 04c9imp KEYBOARD.6( OEMTOANSI )
PTR 04d8imp KEYBOARD.134( ANSITOOEMBUFF)
PTR 05f5imp USER.430( LSTRCMP )
PTR 04e7imp KEYBOARD.135( OEMTOANSIBUFF)
PTR 0514imp USER.431( ANSIUPPER)
PTR 0523imp USER.432( ANSILOWER )
PTR 05aaimp GDI.56( CREATEFONT)
PTR 056eimp USER.433( ISCHARALPHA )
PTR 05b9imp GDI.57( CREATEFONTINDIRECT )
PTR 057dimp USER.434( ISCHARALPHANUMERIC )
PTR 049cimp USER.179( GETSYSTEMMETRICS )
PTR 0550imp USER.435( ISCHARUPPER)
PTR 055fimp USER.436( ISCHARLOWER)
PTR 0532imp USER.437( ANSIUPPERBUFF)
PTR 0541imp USER.438( ANSILOWERBUFF)
PTR 05c8imp GDI.69( DELETEOBJECT )
PTR 058cimp GDI.70( ENUMFONTS )
PTR 04abimp KERNEL.ISDBCSLEADBYTE
PTR 05d7imp GDI.82( GETOBJECT)
PTR 048dimp KERNEL.74 ( OPENFILE )
PTR 0460imp GDI.91( GETTEXTEXTENT)
PTR 05e6imp GDI.92( GETTEXTFACE)
PTR 046fimp GDI.350 ( GETCHARWIDTH )
PTR 0442imp GDI.351 ( EXTTEXTOUT )
PTR 0604imp USER.471( LSTRCMPI )
PTR 04f6imp USER.472( ANSINEXT )
PTR 0505imp USER.473( ANSIPREV )
PTR 0424imp USER.108( GETMESSAGE )
PTR 0433imp USER.109( PEEKMESSAGE)
35 relocations
*******鎵╁彿鍐呬負(fù)浣滆呭姞涓婄殑瀵瑰簲WindowsAPI鍑芥暟
絎竴錛屽湪鏁版嵁孌典腑錛屽彂鐜頒簡閲嶅畾浣嶄俊鎭?br />絎簩錛岃繖浜涢噸瀹氫綅淇℃伅鎻愮ず鐨勫嚱鏁幫紝鍏ㄩ兘涓庢枃瀛楁樉紺?br />杈撳嚭鍜岄敭鐩橈紝瀛楃涓叉湁鍏熾備篃灝辨槸璇存眽鍖朩indows錛屽繀欏諱慨鏀硅繖浜涘嚱鏁般?br />鍦ㄨ繖闈炲父鐗規(guī)畩鐨勫湴鏂癸紝闅愯棌鐫浠涔堝憿錛熸棤搴歌嚧鐤戯紝榪欎笌浼椾笉鍚岀殑涓ょ偣錛屽鎵撳紑鈥滈櫡闃扁濇妧鏈箣闂ㄨ岃█錛屼笉鏄噾閽ュ寵錛屼篃鏄暡闂ㄧ爾銆?br />
浜屻乄indows鐨勬ā鍧楄皟鐢ㄦ満鍒朵笌閲嶅畾浣嶆蹇?br />涓轟簡娣卞叆鎺㈢┒鈥滈櫡闃扁濇妧鏈紝鎴戜滑鍏堟潵浠嬬粛Windows鐨勬ā鍧楄皟鐢ㄦ満鍒躲俉indows鐨勮繍琛屽垎瀹炴ā寮忥紙RealMode錛夛紝鏍囧噯妯″紡錛圫tandMode錛夊拰澧炲己妯″紡錛?86EnhancedMode錛変笁縐嶏紝铏界劧榪欏嚑縐嶆ā寮忓悇涓嶇浉鍚岋紝浣嗗叾鏍稿績妯″潡鐨勮皟鐢ㄥ叧緋誨嵈鏄畬鍏ㄤ竴鑷寸殑銆?br />涓昏鐨勪笁涓ā鍧楋紝鏈夊涓嬬殑鍏崇郴錛?br />
KERNEL鏄疻indows緋葷粺鍐呮牳錛屽畠涓嶄緷璧栧叾瀹冩ā鍧椼?br />
GDI鏄疻indows鍥懼艦璁懼鎺ュ彛妯″潡錛屽畠渚濊禆浜嶬ERNEL妯″潡銆?br />
USER鏄疻indows鐢ㄦ埛鎺ュ彛鏈嶅姟妯″潡錛屽畠渚濊禆浜嶬ERNEL錛孏DI妯″潡鍙?qiáng)璁惧椹卞姩绋嬪簭绛夋墍鏈夋ā鍧椼?br />榪欎笁涓ā鍧楋紝瀹為檯涓婂氨鏄疻indows鐨勪笁涓姩鎬佽繛鎺ュ簱錛屽湪緋葷粺鐨勫瓨鍦ㄥ艦寮忓涓嬶紝KERNEL鏈変笁縐嶄笉鍚屽艦寮忥紝Kernel.exe(瀹炴ā寮?,Krnl286.exe(鏍囧噯妯″紡),Krnl386.
exe(386澧炲己妯″紡)錛汫DI妯″潡鏄疓di.exe錛沀SER妯″潡鏄疷ser.exe錛岃櫧鐒舵枃浠跺悕閮戒互EXE涓烘墿灞曞悕錛屼絾瀹冧滑瀹為檯閮芥槸鍔ㄦ佽繛鎺ュ簱銆?br />
鍚屾椂錛屽嚑涔庢墍鏈夌殑API鍑芥暟閮介殣钘忓湪榪欎笁涓ā鍧椾腑銆傜敤EXEHDR瀵硅繖涓変釜妯″潡鍒嗘瀽錛屽氨鍙垪鍑轟竴澶у爢浣犳墍鐔熸?zhèn)夌殑WindowsAPI鍑芥暟銆?br />
浠DI妯″潡涓轟緥錛?br />
C:\WINDOWS\SYSTEM>exehdr gdi.exe
Exports:
ord seg offset name
............
351 1923eEXTTEXTOUT exported, shared data
56 319e1CREATEFONT exported, shared data
............
鑷蟲錛屼綘宸茶兘浠嶹indows綰風(fēng)箒澶嶆潅鐨勭郴緇熶腑錛岀悊鍑轟竴浜涘ご緇潵銆備笅闈紝鍐嶅紩鍏ヤ竴涓噸瑕佹蹇碘斺旈噸瀹氫綅銆?br />涓涓猈indows鎵ц紼嬪簭瀵硅皟鐢ˋPI鍑芥暟錛屾垨瀵瑰叾瀹冨姩鎬佸簱鐨勮皟鐢紝鍦ㄧ▼搴忚鍏ュ唴瀛樺墠錛岄兘鏄竴浜涗笉鑳藉畾浣嶇殑鍔ㄦ佽繛鎺ワ紝褰撶▼搴忚皟鍏ュ唴瀛樻椂錛岃繖浜涜繙璋冪敤閮介渶瑕侀噸鏂板畾浣嶏紝閲嶆柊瀹氫綅鐨勪緷鎹氨鏄噸瀹氫綅琛ㄣ傚湪Windows鎵ц紼嬪簭錛堝寘鎷姩鎬佸簱錛夌殑姣忎釜孌靛悗闈紝閫氬父閮借窡鏈夎繖鏍蜂竴涓噸瀹氫綅琛ㄣ傞噸瀹氫綅鍖呭惈璋冪敤鍑芥暟鎵鍦ㄦā鍧楋紝鍑芥暟搴忓垪鍙鳳紝浠ュ強(qiáng)瀹氫綅鍦ㄦā鍧椾腑鐨勪綅緗?br />
渚嬪錛岀敤EXEHDR/v鍒嗘瀽CHINESE.DLL寰楀埌
6 type offset target
..........
PTR 0442imp GDI.351
..........
灝辮〃鏄庯紝鍦ㄦ湰孌電殑0442H鍋忕Щ澶勶紝璋冪敤浜咷DI鐨勭351鍙峰嚱鏁般傚鏋滃湪0442H澶勬槸0000:FFFF錛屽垯琛ㄧず錛屾湰孌靛唴浠呮涓澶勮皟鐢ㄤ簡GDI.351鍑芥暟錛屽惁鍒欙紝琛ㄦ槑浜嗘湰孌靛唴榪樻湁涓澶勮皟鐢ㄦ鍑芥暟錛岃皟鐢ㄧ殑浣嶇疆灝辨槸0442H澶勬墍鎸囧悜鐨勫唴瀹癸紝瀹為檯涓婇噸瀹氫綅琛ㄥ彧鍚湁寮曠敤浣嶇疆鐨勯摼琛ㄧ殑閾懼ご銆傞偅涔堬紝GDI.351鏄竴涓粈涔堝嚱鏁板憿錛熻繕鏄敤EXEHDR瀵笹DI.EXE浣滀竴鍒嗘瀽錛屽氨鍙緱鍑猴紝鍦℅DI鐨勫嚭鍙o紙Export錛夊嚱鏁頒腑錛岀351鍙鋒槸ExtTextOut銆?br />榪欐牱錛屾垜浠湪EXEHDR榪欎竴綆鍗曡岄潪甯告湁鐢ㄧ殑宸ュ叿甯姪涓嬶紝宸茬粡鍦╓indows鐨勬旦鐎氭搗媧嬩腑鐣呮父浜嗕竴浼?xì)锛屼笅闈鏉ユ巰寮鈥滈櫡闃扁濇妧鏈殑紲炵闈㈢罕銆?br />
涓夈佸姩鎬佹眽鍖朩indows鍘熺悊
鎴戜滑鐭ラ亾錛屼紶緇熺殑姹夊寲Windows鐨勬柟娉曪紝鏄鐩存帴淇敼Windows鐨勬樉紺恒佽緭鍏ャ佹墦鍗扮瓑妯″潡浠g爜錛屾垨鐢―DK鐩存帴寮鍙戔滀腑鏂囪澶団濋┍鍔ㄦā鍧楋紝榪欐牱涓嶄粎宸ヤ綔閲忔旦澶э紝鑰屼笖錛岀郴緇熺殑瀹屽鎬у緢闅句繚璇侊紝鎬ц兘涓婁篃鏈夊緢澶氶檺鍒訛紙鏃╂湡鐨勯暱闈掔獥鍙e氨鏄繖鏍鳳級錛岃繖鏍鳳紝鍙湁浠庡唴鏍鎬笂淇敼Windows鏍稿績浠g爜鎵嶆槸鏈褰誨簳鐨勫姙娉曘?br />浠嶹indows鐨勬ā鍧楄皟鐢ㄦ満鍒訛紝鎴戜滑鍙互鐪嬪埌錛學(xué)indows瀹為檯涓婃槸鐢卞寘鎷湪KERNEL錛孏DI錛孶SER絳夊嚑涓ā鍧椾腑鐨勪紬澶氬嚱鏁版敮鎾戠殑銆傞偅涔堬紝淇敼鍏朵腑娑夊強(qiáng)璇█鏂囧瓧澶勭悊鐨勫嚱鏁幫紝浣夸箣鑳介傚簲涓枃闇瑕侊紝涓嶅氨鑳借揪鍒版眽鍖栫洰鐨勪簡鍚楋紵鍥犺岋紝鎴戜滑鍙互寰楀嚭榪欐牱鐨勭粨璁猴細(xì)鍦ㄨ嚜宸辯殑妯″潡涓噸鏂扮紪鍐欐秹鍙?qiáng)鏂囧瓧鏄窘C猴紝杈撳叆鐨勫涓嚱鏁幫紝鐒跺悗錛屽皢Windows涓榪欎簺鍑芥暟鐨勫紩鐢紝鏀瑰悜鍒拌嚜宸辯殑榪欎簺妯″潡涓潵銆?br />
淇敼鍝簺鍑芥暟鎵嶈兘瀹屾垚姹夊寲錛岃繖闇瑕佹繁鍏ュ垎鏋怶indows鐨勫唴閮ㄧ粨鏋勶紝浣咰HINESE.DLL宸叉槑紜棤璇湴鍛婅瘔浜嗘垜浠紝鍦ㄥ叾鏁版嵁孌電殑閲嶅畾浣嶈〃涓垪鍑虹殑寮曠敤鍑芥暟錛屾鏄疌Star淇敼浜嗙殑Windows鍑芥暟錛?br />
涓轟簡楠岃瘉榪欎竴鎬濊礬錛屾垜浠埄鐢≧ichWin浣滀竴鏍稿疄銆?br />
鐢‥XEHDR鍒嗘瀽GDI.EXE錛屽緱鍑篍xtTextOut鍑芥暟鍦℅DI鐨勭涓浠g爜孌?139H鍋忕Щ澶勶紙涓嶅悓鐗堟湰鐨刉indows鍏舵墍鍦ㄤ唬鐮佹鍜屽亸縐誨彲鑳戒笉涓鏍鳳級銆傜劧鍚庯紝鐢℉elpWalk錛堜篃鏄疢icrosoftVisualC++寮鍙戝伐鍏蜂腑鐨勪竴涓級媯鏌DI鐨凜ode1孌碉紝6139H澶勫墠5涓瓧鑺傛槸B8FF054555錛岀粡榪囪繍琛孯ichWin4.3forInternet鍚庯紝鍐嶆煡鐪嬪悓鏍風(fēng)殑鍦版柟錛屽凡鏀逛負(fù)EA08088F3D,鍏跺疄鍙嶆眹緙栧氨鐭ラ亾錛岃繖5涓瓧鑺傚氨鏄唬琛↗mp3D8F:0808錛岃屽彞鏌勪負(fù)0x3D8F鐨勬ā鍧楋紝鐢℉elpWalk鑳借瀵熷埌姝f槸RichWin鐨刉SENGINE.DLL鐨勭涓浠g爜孌碉紙妯″潡鍚嶄負(fù)TEXTMAN錛夈傝屽亸縐?808H澶凚8B73D45558BEC1E錛屾鏄竴涓嚱鏁拌搗濮嬬殑鍦版柟錛岃繖瀹為檯涓婂氨鏄疪ichWin鎵閲嶆敼鍐欑殑ExtTextOut鍑芥暟銆傞鍑篟ichWin鍚庯紝鍐嶇敤HelpWalk瑙傚療GDI鐨凜ode1浠g爜孌碉紝涓鍒囧張鎭㈠姝e父錛佽繖涓庡墠闈㈢殑鍒嗘瀽緇撹瀹屽叏鍚誨悎錛侀偅涔堬紝涓嬩竴涓叧閿偣灝辨槸濡備綍鍔ㄦ佷慨鏀筗indows鐨勫嚱鏁頒唬鐮侊紝涔熷氨鏄眽鍖朩indows鐨勬牳蹇冣斺斺滈櫡闃扁濇妧鏈?br />
鍥涖佲滈櫡闃扁濇妧鏈?br />璁ㄨ鈥滈櫡闃扁濇妧鏈紝榪樿鍥炲埌鍓嶉潰鐨勪袱涓彂鐜般傚彂鐜頒箣浜岋紝宸茶兘瑙i噴涓轟慨鏀圭殑Windows鍑芥暟錛岃屽彂鐜頒箣涓錛屽嵈浠嶆槸涓涓糠銆?br />鏁版嵁孌靛瓨鏀劇殑鏄彉閲忓強(qiáng)甯擱噺絳夊唴瀹癸紝濡傛灉榪欓噷闈㈠寘鍚湁閲嶅畾浣嶄俊鎭紝閭d箞錛屽繀瀹氳鍦ㄥ彉閲忚鏄庝腑灝嗗嚱鏁版寚閽堣祴緇欎竴涓狥ARPROC綾誨瀷鐨勫彉閲忥紝浜庢槸錛屽湪鍙橀噺璇存槑涓啓涓嬶細(xì)
FARPROC FarProcFunc=ExtTextOut;
鏋滅劧錛屾垜鑷繁紼嬪簭鐨勬暟鎹涓篃鏈変簡閲嶅畾浣嶄俊鎭傝繖鏍鳳紝褰撶▼搴忚皟鍏ュ唴瀛樹腑鏃訛紝鍙橀噺FarProcFunc宸叉槸鍑芥暟ExtTextOut鐨勫湴鍧浜嗐?br />
瑕佺洿鎺ヤ慨鏀逛唬鐮佹鐨勫唴瀹癸紝榪橀亣鍒頒竴涓毦棰橈紝灝辨槸浠g爜孌墊槸涓嶅彲鏀瑰啓鐨勩傝繖鏃訛紝闇瑕佺敤鍒頒竴涓湭鍏紑鐨刉indows鍑芥暟AllocCStoDSAlias鍙栧緱涓庝唬鐮佹鏈夌浉鍚屽熀鍧鐨勫彲鍐欐暟鎹鍒悕錛屽叾鍑芥暟澹版槑涓?br />WORD FAR PASCAL AllocCStoDSAlias(WORD code_sel);
鍙傛暟鏄唬鐮佹鐨勫彞鏌勶紝榪斿洖鍊兼槸鍙啓鏁版嵁孌靛埆鍚嶅彞鏌勩?br />
Windows涓嚱鏁板湴鍧鏄?2浣嶏紝楂樺瓧鏄叾妯″潡鐨勫唴瀛樺彞鏌勶紝浣庡瓧鏄嚱鏁板湪妯″潡鍐呯殑鍋忕Щ銆傚皢寰楀埌鐨勫彲鍐欐暟鎹鍒悕鍙ユ焺閿佸畾錛屽啀灝嗗嚱鏁板亸縐誨鐨?涓瓧鑺備繚鐣欎笅鏉ワ紝鐒跺悗灝嗗叾鏀逛負(fù)杞悜鏇夸唬鍑芥暟錛堢敤EA Jmp錛?br />
*(lpStr+wOffset)=0xEA;
*(lpStr+wOffset+1)=lpFarProcReplace;
鍙嶆眹緙栧嵆鏄疛mp lpFarProcReplace錛屾渶鍚庯紝鍐呭瓨瑙i攣銆?br />榪欏氨鏄垜浠負(fù)Windows璁劇殑鈥滈櫡闃扁濓紝褰撴墍鏈夊姝ゅ嚱鏁扮殑璋冪敤閮芥棤鏉′歡鍦拌漿鍒版垜浠瀹氱殑鏇夸唬鍑芥暟澶勩傚綋紼嬪簭緇撴潫涔嬪墠錛屽皢淇濈暀鐨?瀛楄妭鍐呭鍐嶇疆鍥炴潵錛屽惁鍒欙紝緋葷粺浼?xì)宕╂簝銆?br />
涓嬮潰緇欏嚭浣滆呯紪鍐欑殑浣縒indows鐨凟xtTextOut鍑芥暟钀藉叆鑷繁鍑芥暟鈥滈櫡闃扁濈殑婧愮▼搴忋?br />
//婧愮▼搴?relocate.c
#include
#include
BOOL WINAPI MyExtTextOut(HDC hDC, int x, int y, UINT nInt1, const RECT FAR* lpRect,LPCSTR lpStr, UINT nInt2, int FAR* lpInt);
WORD FAR PASCAL AllocCStoDSAlias(WORD code_sel);
typedef struct tagFUNC
{
FARPROC lpFarProcReplace;//鏇夸唬鍑芥暟鍦板潃
FARPROC lpFarProcWindows;//Windows鍑芥暟鍦板潃
BYTE bOld;//淇濆瓨鍘熷嚱鏁扮涓瀛楄妭
LONG lOld;//淇濆瓨鍘熷嚱鏁版帴鍚庣殑鍥涘瓧鑺傞暱鍊?br />}FUNC;
FUNC Func={MyExtTextOut,ExtTextOut};
//Windows涓誨嚱鏁?br />int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
HANDLE hMemCode;//浠g爜孌靛彞鏌?br />WORD hMemData;//鐩稿悓鍩哄潃鐨勫彲鍐欐暟鎹鍒悕
WORD wOffset; //鍑芥暟鍋忕Щ
LPSTR lpStr;
LPLONG lpLong;
char lpNotice[96];
hMemCode=HIWORD((LONG) Func.lpFarProcWindows );
wOffset=LOWORD((LONG) Func.lpFarProcWindows );
wsprintf(lpNotice,"鍑芥暟鎵鍦ㄦā鍧楀彞鏌?0x%4xH,鍋忕Щ 0x%4xH",hMemCode,wOffset);
MessageBox(NULL,lpNotice,"鎻愮ず",MB_OK);
//鍙栦笌浠g爜孌墊湁鐩稿悓鍩哄潃鐨勫彲鍐欐暟鎹鍒悕
hMemData=AllocCStoDSAlias(hMemCode);
lpStr=GlobalLock(hMemData);
lpLong=(lpStr+wOffset+1 );
//淇濆瓨鍘熷嚱鏁拌鏇挎崲鐨勫ご鍑犱釜瀛楄妭
Func.bOld=*(lpStr+wOffset);
Func.lOld=*lpLong;
*(lpStr+wOffset)=0xEA;
*lpLong=Func.lpFarProcReplace;
GlobalUnlock(hMemData);
MessageBox(NULL,"鏀逛負(fù)鑷繁鐨勫嚱鏁?,"鎻愮ず",MB_OK);
//灝嗕繚鐣欑殑鍐呭鏀瑰洖鏉?br />hMemData=AllocCStoDSAlias(hMemCode);
lpStr=GlobalLock(hMemData);
lpLong=(lpStr+wOffset+1 );
*(lpStr+wOffset)=Func.bOld;
*lpLong=Func.lOld;
GlobalUnlock(hMemData);
MessageBox(NULL,"鏀瑰洖鍘焀indows鍑芥暟","鎻愮ず",MB_OK);
return 1;
}
//鑷繁鐨勬浛浠e嚱鏁?br />BOOL WINAPI MyExtTextOut(HDC hDC, int x, int y, UINT nInt1, const RECT FAR* lpRect, LPCSTR lpStr, UINT nInt2, int FAR* lpInt)
{
BYTE NameDot[96]={
0x09, 0x00, 0xfd, 0x08, 0x09, 0x08, 0x09, 0x10, 0x09, 0x20,
0x79, 0x40, 0x41, 0x04, 0x47, 0xfe, 0x41, 0x40, 0x79, 0x40,
0x09, 0x20, 0x09, 0x20, 0x09, 0x10, 0x09, 0x4e, 0x51, 0x84,
0x21, 0x00, 0x02, 0x00, 0x01, 0x04, 0xff, 0xfe, 0x00, 0x00,
0x1f, 0xf0, 0x10, 0x10, 0x10, 0x10, 0x1f, 0xf0, 0x00, 0x00,
0x7f, 0xfc, 0x40, 0x04, 0x4f, 0xe4, 0x48, 0x24, 0x48, 0x24,
0x4f, 0xe4, 0x40, 0x0c, 0x10, 0x80, 0x10, 0xfc, 0x10, 0x88,
0x11, 0x50, 0x56, 0x20, 0x54, 0xd8, 0x57, 0x06, 0x54, 0x20,
0x55, 0xfc, 0x54, 0x20, 0x55, 0xfc, 0x5c, 0x20, 0x67, 0xfe,
0x00, 0x20, 0x00, 0x20, 0x00, 0x20
};
HBITMAP hBitmap,hOldBitmap;
HDC hMemDC;
BYTE far *lpDot;
int i;
for ( i=0;i<3;i++ )
{
lpDot=(LPSTR)NameDot+i*32;
hMemDC=CreateCompatibleDC(hDC);
hBitmap=CreateBitmap(16,16,1,1,lpDot);
SetBitmapBits(hBitmap,32L,lpDot);
hOldBitmap=SelectObject(hMemDC,hBitmap);
BitBlt(hDC,x+i*16,y,16,16,hMemDC,0,0,SRCCOPY);
DeleteDC(hMemDC);
DeleteObject(hBitmap);
}
return TRUE;
}
//妯″潡瀹氫箟鏂囦歡relocate.def
NAMERELOCATE
EXETYPE WINDOWS
CODEPRELOAD MOVEABLE DISCARDABLE
DATAPRELOAD MOVEABLE MULTIPLE
HEAPSIZE1024
EXPORTS
浜斻佺粨鏉熻
鏈枃浠庡師鐞嗕笂鍒嗘瀽浜嗙О涓衡滈櫡闃扁濇妧鏈殑姹夊寲Windows鏂規(guī)硶銆傝褰誨簳姹夊寲Windows榪樿娑夊強(qiáng)鏄劇ず錛岄敭鐩樿緭鍏ョ瓑璇稿鍐呭錛屽喅闈炰竴鏃ヤ箣鍔熴備絾浣滀負(fù)瀵光滈櫡闃扁濇妧鏈殑鍒嗘瀽錛屾湰鏂囦粙緇嶄簡灝嗕換涓Windows鍑芥暟璋冪敤鏀瑰悜鍒拌嚜宸辨寚瀹氬嚱鏁板鐨勯氱敤鏂規(guī)硶錛岃繖縐嶆柟娉曞彲浠ユ嫇灞曞埌鍏跺畠搴旂敤涓紝濡傚璇鏄劇ず錛屼笉鍚屽唴鐮佸埗寮忕殑鍒囨崲鏄劇ず絳夈?br />鍙傝冩枃鐚細(xì)
AndrewSchulmanDavidMaxeyMattPietrek,銆婃湭鍏紑鐨刉indows鏍稿績鎶鏈嬶紝娓呭崕澶у鍑虹増紺撅紝1993騫淬?br />
鐜嬪織涓滐紝鈥淲indows涓枃鐜鈥濓紝銆奧indows杞歡鐨勫簲鐢ㄤ笌寮鍙戙嬶紝1993.5銆?br />錛堜綔鑰呭湴鍧錛氬北涓滄綅鍧婂崕鍏夌鎶鑲′喚鍏徃鐮旂┒寮鍙戜腑蹇?寮犻珮宄?閭紪261041 錛?img src ="http://www.shnenglu.com/eday/aggbug/15372.html" width = "1" height = "1" />
]]>
銆銆閫氳繃瀵瑰姩浣滄ā鎷?b>鎶鏈?/b>鐨勪粙緇嶏紝鎴戜滑瀵?b>娓告垙澶栨寕鏈変簡涓瀹氱▼搴︿笂鐨勮璇嗭紝涔熷浼?xì)浜嗕娇鐢ㄥ姩浣滄ā鎷?b>鎶鏈?/b>鏉ュ疄鐜扮畝鍗曠殑鍔ㄤ綔妯℃嫙鍨?b>娓告垙澶栨寕鐨勫埗浣溿傝繖縐嶅姩浣滄ā鎷熷瀷娓告垙澶栨寕鏈変竴瀹氱殑灞闄愭э紝瀹冧粎浠呭彧鑳借В鍐充嬌鐢ㄨ綆楁満浠f浛浜哄姏瀹屾垚閭d箞鏈夎寰嬨佺箒鐞愯屾棤鑱婄殑娓告垙鍔ㄤ綔銆備絾鏄紝闅忕潃緗戠粶娓告垙鐨勭洓琛屽拰澶嶆潅搴︾殑澧炲姞錛屽緢澶?b>娓告垙瑕佹眰灝嗗鎴風(fēng)鍔ㄤ綔淇℃伅鍙?qiáng)鏃跺弽棣堝洖鏈嶅姟鍣ㄥQ岄氳繃鏈嶅姟鍣ㄥ榪欎簺鍔ㄤ綔淇℃伅榪涜鏈夋晥璁よ瘉鍚庯紝鍐嶅悜瀹㈡埛绔彂閫佷笅涓姝?b>娓告垙鍔ㄤ綔淇℃伅錛岃繖鏍峰姩浣滄ā鎷?b>鎶鏈?/b>灝嗗け鍘誨師鏈夌殑鏁堝簲銆備負(fù)浜嗘洿濂藉湴鈥滃鎸傗濊繖浜?b>娓告垙錛?b>娓告垙澶栨寕紼嬪簭涔熻繘琛屼簡鍗囩駭鎹唬錛屽畠浠皢浠ュ墠閽堝娓告垙鐢ㄦ埛鐣岄潰灞傜殑妯℃嫙鎺ㄨ繘鍒版暟鎹氳灞傦紝閫氳繃灝佸寘鎶鏈?/b>鍦ㄥ鎴風(fēng)鎸℃埅娓告垙鏈嶅姟鍣ㄥ彂閫佹潵鐨?b>娓告垙鎺у埗鏁版嵁鍖咃紝鍒嗘瀽鏁版嵁鍖呭茍淇敼鏁版嵁鍖咃紱鍚屾椂榪橀渶鎸夌収娓告垙鏁版嵁鍖呯粨鏋勫垱寤烘暟鎹寘錛屽啀妯℃嫙瀹㈡埛绔彂閫佺粰娓告垙鏈嶅姟鍣紝榪欎釜榪囩▼鍏跺疄灝辨槸涓涓皝鍖呯殑榪囩▼銆?br />
銆銆灝佸寘鐨?b>鎶鏈?/b>鏄疄鐜扮浜岀被娓告垙澶栨寕鐨勬渶鏍稿績鐨?b>鎶鏈?/b>銆傚皝鍖?b>鎶鏈?/b>娑夊強(qiáng)鐨勭煡璇嗗緢騫挎硾錛屽疄鐜版柟娉曚篃寰堝錛屽鎸℃埅WinSock銆佹尅鎴狝PI鍑芥暟銆佹尅鎴秷鎭乂xD椹卞姩紼嬪簭絳夈傚湪姝ゆ垜浠篃涓嶅彲鑳藉湪姝ゆ枃涓皢鎵鏈夌殑灝佸寘鎶鏈?/b>閮借繘琛岃緇嗕粙緇嶏紝鏁呴夋嫨涓ょ鍦?b>娓告垙澶栨寕紼嬪簭涓渶甯哥敤鐨勪袱縐嶆柟娉曪細(xì)鎸℃埅WinSock鍜屾尅鎴狝PI鍑芥暟銆?br />
銆銆1錛?鎸℃埅WinSock
銆銆浼楁墍鍛ㄧ煡錛學(xué)insock鏄?b>Windows緗戠粶緙栫▼鎺ュ彛錛屽畠宸ヤ綔浜?b>Windows搴旂敤灞傦紝瀹冩彁渚涗笌搴曞眰浼犺緭鍗忚鏃犲叧鐨勯珮灞傛暟鎹紶杈撶紪紼嬫帴鍙c傚湪Windows緋葷粺涓紝浣跨敤WinSock鎺ュ彛涓哄簲鐢ㄧ▼搴忔彁渚涘熀浜嶵CP/IP鍗忚鐨勭綉緇滆闂湇鍔★紝榪欎簺鏈嶅姟鏄敱Wsock32.DLL鍔ㄦ侀摼鎺ュ簱鎻愪緵鐨勫嚱鏁板簱鏉ュ畬鎴愮殑銆?br />
銆銆鐢變笂璇存槑鍙煡錛屼換浣?b>Windows鍩轟簬TCP/IP鐨勫簲鐢ㄧ▼搴忛兘蹇呴』閫氳繃WinSock鎺ュ彛璁塊棶緗戠粶錛屽綋鐒剁綉緇?b>娓告垙紼嬪簭涔熶笉渚嬪銆傜敱姝ゆ垜浠彲浠ユ兂璞′竴涓嬶紝濡傛灉鎴戜滑鍙互鎺у埗WinSock鎺ュ彛鐨勮瘽錛岄偅涔堟帶鍒?b>娓告垙瀹㈡埛绔▼搴忎笌鏈嶅姟鍣ㄤ箣闂寸殑鏁版嵁鍖呬篃灝嗘槗濡傚弽鎺屻傛寜鐫榪欎釜鎬濊礬錛屼笅闈㈢殑宸ヤ綔灝辨槸濡備綍瀹屾垚鎺у埗WinSock鎺ュ彛浜嗐傜敱涓婇潰鐨勪粙緇嶅彲鐭ワ紝W(xué)inSock鎺ュ彛鍏跺疄鏄敱涓涓姩鎬侀摼鎺ュ簱鎻愪緵鐨勪竴緋誨垪鍑芥暟錛岀敱榪欎簺鍑芥暟瀹炵幇瀵圭綉緇滅殑璁塊棶銆傛湁浜嗚繖灞傜殑璁よ瘑錛岄棶棰樺氨濂藉姙澶氫簡錛屾垜浠彲浠ュ埗浣滀竴涓被浼肩殑鍔ㄦ侀摼鎺ュ簱鏉ヤ唬鏇垮師WinSock鎺ュ彛搴擄紝鍦ㄥ叾涓疄鐜癢inSock32.dll涓疄鐜扮殑鎵鏈夊嚱鏁幫紝騫朵繚璇佹墍鏈夊嚱鏁扮殑鍙傛暟涓暟鍜岄『搴忋佽繑鍥炲肩被鍨嬮兘搴斾笌鍘熷簱鐩稿悓銆傚湪榪欎釜鑷埗浣滅殑鍔ㄦ佸簱涓紝鍙互瀵規(guī)垜浠劅鍏磋叮鐨勫嚱鏁幫紙濡傚彂閫併佹帴鏀剁瓑鍑芥暟錛夎繘琛屾尅鎴紝鏀懼叆澶栨寕鎺у埗浠g爜錛屾渶鍚庤繕緇х畫璋冪敤鍘焀inSock搴撲腑鎻愪緵鐨勭浉搴斿姛鑳藉嚱鏁幫紝榪欐牱灝卞彲浠ュ疄鐜板緗戠粶鏁版嵁鍖呯殑鎸℃埅銆佷慨鏀瑰拰鍙戦佺瓑灝佸寘鍔熻兘銆?br />
銆銆涓嬮潰閲嶇偣浠嬬粛鍒涘緩鎸℃埅WinSock澶栨寕紼嬪簭鐨勫熀鏈楠わ細(xì)
銆銆(1) 鍒涘緩DLL欏圭洰錛岄夋嫨Win32 Dynamic-Link Library錛屽啀閫夋嫨An empty DLL project銆?br />
銆銆(2) 鏂板緩鏂囦歡wsock32.h錛屾寜濡備笅姝ラ杈撳叆浠g爜錛?br />
銆銆鈶?鍔犲叆鐩稿叧鍙橀噺澹版槑錛?br />
銆銆銆HMODULE hModule=NULL; //妯″潡鍙ユ焺
銆銆銆char buffer[1000]; //緙撳啿鍖?br />銆銆銆FARPROC proc; //鍑芥暟鍏ュ彛鎸囬拡
銆銆鈶?瀹氫箟鎸囧悜鍘焀inSock搴撲腑鐨勬墍鏈夊嚱鏁板湴鍧鐨勬寚閽堝彉閲忥紝鍥燱inSock搴撳叡鎻愪緵70澶氫釜鍑芥暟錛岄檺浜庣瘒騫咃紝鍦ㄦ灝卞彧閫夋嫨鍑犱釜甯哥敤鐨勫嚱鏁板垪鍑猴紝鏈夊叧榪欎簺搴撳嚱鏁扮殑璇存槑鍙弬鑰僊SDN鐩稿叧鍐呭銆?br />
銆銆銆//瀹氫箟鎸囧悜鍘焀inSock搴撳嚱鏁板湴鍧鐨勬寚閽堝彉閲忋?br />銆銆銆SOCKET (__stdcall *socket1)(int ,int,int);//鍒涘緩Sock鍑芥暟銆?br />銆銆銆int銆(__stdcall *WSAStartup1)(WORD,LPWSADATA);//鍒濆鍖朩inSock搴撳嚱鏁般?br />銆銆銆int銆(__stdcall *WSACleanup1)();//娓呴櫎WinSock搴撳嚱鏁般?br />銆銆銆int (__stdcall *recv1)(SOCKET ,char FAR * ,int ,int );//鎺ユ敹鏁版嵁鍑芥暟銆?br />銆銆銆int (__stdcall *send1)(SOCKET ,const char * ,int ,int);//鍙戦佹暟鎹嚱鏁般?br />銆銆銆int (__stdcall *connect1)(SOCKET,const struct sockaddr *,int);//鍒涘緩榪炴帴鍑芥暟銆?br />銆銆銆int (__stdcall *bind1)(SOCKET ,const struct sockaddr *,int );//緇戝畾鍑芥暟銆?br />銆銆銆......鍏跺畠鍑芥暟鍦板潃鎸囬拡鐨勫畾涔夌暐銆?
銆銆(3) 鏂板緩wsock32.cpp鏂囦歡錛屾寜濡備笅姝ラ杈撳叆浠g爜錛?br />
銆銆鈶?鍔犲叆鐩稿叧澶存枃浠跺0鏄庯細(xì)
銆銆銆#include "windows.h"
銆銆銆#include "stdio.h"
銆銆銆#include "wsock32.h"
銆銆鈶?娣誨姞DllMain鍑芥暟錛屽湪姝ゅ嚱鏁頒腑棣栧厛闇瑕佸姞杞藉師WinSock搴擄紝騫惰幏鍙栨搴撲腑鎵鏈夊嚱鏁扮殑鍦板潃銆備唬鐮佸涓嬶細(xì)
銆銆銆BOOL WINAPI DllMain (HANDLE hInst,ULONG ul_reason_for_call,LPVOID lpReserved)
銆銆銆{
銆銆銆銆if(hModule==NULL){
銆銆銆銆銆//鍔犺澆鍘焀inSock搴擄紝鍘焀inSock搴撳凡澶嶅埗涓簑sock32.001銆?br />銆銆銆hModule=LoadLibrary("wsock32.001");
銆銆}
銆銆銆銆else return 1;
//鑾峰彇鍘焀inSock搴撲腑鐨勬墍鏈夊嚱鏁扮殑鍦板潃騫朵繚瀛橈紝涓嬮潰浠呭垪鍑洪儴鍒嗕唬鐮併?br />if(hModule!=NULL){
銆銆銆銆銆//鑾峰彇鍘焀inSock搴撳垵濮嬪寲鍑芥暟鐨勫湴鍧錛屽茍淇濆瓨鍒癢SAStartup1涓?br />proc=GetProcAddress(hModule,"WSAStartup");
銆銆銆WSAStartup1=(int (_stdcall *)(WORD,LPWSADATA))proc;
銆銆銆銆銆//鑾峰彇鍘焀inSock搴撴秷闄ゅ嚱鏁扮殑鍦板潃錛屽茍淇濆瓨鍒癢SACleanup1涓?br />銆銆銆銆proc=GetProcAddress(hModule i,"WSACleanup");
銆銆銆銆WSACleanup1=(int (_stdcall *)())proc;
銆銆銆銆銆//鑾峰彇鍘熷垱寤篠ock鍑芥暟鐨勫湴鍧錛屽茍淇濆瓨鍒皊ocket1涓?br />銆銆銆銆proc=GetProcAddress(hModule,"socket");
銆銆銆銆銆socket1=(SOCKET (_stdcall *)(int ,int,int))proc;
銆銆銆銆銆//鑾峰彇鍘熷垱寤鴻繛鎺ュ嚱鏁扮殑鍦板潃錛屽茍淇濆瓨鍒癱onnect1涓?br />銆銆銆銆銆proc=GetProcAddress(hModule,"connect");
銆銆銆銆銆connect1=(int (_stdcall *)(SOCKET ,const struct sockaddr *,int ))proc;
銆銆銆銆銆//鑾峰彇鍘熷彂閫佸嚱鏁扮殑鍦板潃錛屽茍淇濆瓨鍒皊end1涓?br />銆銆銆銆銆proc=GetProcAddress(hModule,"send");
銆銆銆銆銆send1=(int (_stdcall *)(SOCKET ,const char * ,int ,int ))proc;
銆銆銆銆銆//鑾峰彇鍘熸帴鏀跺嚱鏁扮殑鍦板潃錛屽茍淇濆瓨鍒皉ecv1涓?br />銆銆銆銆銆proc=GetProcAddress(hModule,"recv");
銆銆銆銆銆recv1=(int (_stdcall *)(SOCKET ,char FAR * ,int ,int ))proc;
銆銆銆銆銆......鍏跺畠鑾峰彇鍑芥暟鍦板潃浠g爜鐣ャ?br />銆銆銆}
銆銆銆else return 0;
銆銆銆return 1;
}
銆銆鈶?瀹氫箟搴撹緭鍑哄嚱鏁幫紝鍦ㄦ鍙互瀵規(guī)垜浠劅鍏磋叮鐨勫嚱鏁頒腑娣誨姞澶栨寕鎺у埗浠g爜錛屽湪鎵鏈夌殑杈撳嚭鍑芥暟鐨勬渶鍚庝竴姝ラ兘璋冪敤鍘焀inSock搴撶殑鍚屽悕鍑芥暟銆傞儴鍒嗚緭鍑哄嚱鏁板畾涔変唬鐮佸涓嬶細(xì)
//搴撹緭鍑哄嚱鏁板畾涔夈?br />//WinSock鍒濆鍖栧嚱鏁般?br />銆銆銆銆int PASCAL FAR WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData)
銆銆銆銆{
銆銆銆銆銆//璋冪敤鍘焀inSock搴撳垵濮嬪寲鍑芥暟
銆銆銆銆銆return WSAStartup1(wVersionRequired,lpWSAData);
銆銆銆銆}
銆銆銆銆//WinSock緇撴潫娓呴櫎鍑芥暟銆?br />銆銆銆銆int PASCAL FAR WSACleanup(void)
銆銆銆銆{
銆銆銆銆銆return WSACleanup1(); //璋冪敤鍘焀inSock搴撶粨鏉熸竻闄ゅ嚱鏁般?br />銆銆銆銆}
銆銆銆銆//鍒涘緩Socket鍑芥暟銆?br />銆銆銆銆SOCKET PASCAL FAR socket (int af, int type, int protocol)
銆銆銆銆{
銆銆銆銆銆//璋冪敤鍘焀inSock搴撳垱寤篠ocket鍑芥暟銆?br />銆銆銆銆銆return socket1(af,type,protocol);
銆銆銆銆}
銆銆銆銆//鍙戦佹暟鎹寘鍑芥暟
銆銆銆銆int PASCAL FAR send(SOCKET s,const char * buf,int len,int flags)
銆銆銆銆{
銆銆銆//鍦ㄦ鍙互瀵瑰彂閫佺殑緙撳啿buf鐨勫唴瀹硅繘琛屼慨鏀癸紝浠ュ疄鐜版楠楁湇鍔″櫒銆?br />銆銆銆澶栨寕浠g爜......
銆銆銆//璋冪敤鍘焀inSock搴撳彂閫佹暟鎹寘鍑芥暟銆?br />銆銆銆銆銆return send1(s,buf,len,flags);
銆銆銆銆}
//鎺ユ敹鏁版嵁鍖呭嚱鏁般?br />銆銆銆銆int PASCAL FAR recv(SOCKET s, char FAR * buf, int len, int flags)
銆銆銆銆{
銆銆銆//鍦ㄦ鍙互鎸℃埅鍒版湇鍔″櫒绔彂閫佸埌瀹㈡埛绔殑鏁版嵁鍖咃紝鍏堝皢鍏朵繚瀛樺埌buffer涓?br />銆銆銆strcpy(buffer,buf);
銆銆銆//瀵筨uffer鏁版嵁鍖呮暟鎹繘琛屽垎鏋愬悗錛屽鍏舵寜鐓х帺瀹剁殑鎸囦護(hù)榪涜鐩稿叧淇敼銆?br />銆銆銆澶栨寕浠g爜......
銆銆銆//鏈鍚庤皟鐢ㄥ師WinSock涓殑鎺ユ敹鏁版嵁鍖呭嚱鏁般?br />銆銆銆銆銆return recv1(s, buffer, len, flags);
銆銆銆銆銆}
銆銆銆銆.......鍏跺畠鍑芥暟瀹氫箟浠g爜鐣ャ?
銆銆(4)銆佹柊寤簑sock32.def閰嶇疆鏂囦歡錛屽湪鍏朵腑鍔犲叆鎵鏈夊簱杈撳嚭鍑芥暟鐨勫0鏄庯紝閮ㄥ垎澹版槑浠g爜濡備笅錛?br />
銆銆銆LIBRARY "wsock32"
銆銆銆EXPORTS
銆銆銆銆WSAStartup @1
銆銆銆WSACleanup @2
銆銆銆銆recv @3
銆銆銆銆send @4
銆銆銆銆socket @5
銆銆銆bind @6
銆銆銆closesocket @7
銆銆銆connect @8
銆銆銆......鍏跺畠杈撳嚭鍑芥暟澹版槑浠g爜鐣ャ?br />
銆銆(5)銆佷粠鈥滃伐紼嬧濊彍鍗曚腑閫夋嫨鈥滆緗濓紝寮瑰嚭Project Setting瀵硅瘽妗嗭紝閫夋嫨Link鏍囩錛屽湪鈥滃璞?搴撴ā鍧椻濅腑杈撳叆Ws2_32.lib銆?br />
銆銆(6)銆佺紪璇戦」鐩紝浜х敓wsock32.dll搴撴枃浠躲?br />
銆銆(7)銆佸皢緋葷粺鐩綍涓嬪師wsock32.dll搴撴枃浠舵嫹璐濆埌琚鎸傜▼搴忕殑鐩綍涓嬶紝騫跺皢鍏舵敼鍚嶄負(fù)wsock.001錛涘啀灝嗕笂闈駭鐢熺殑wsock32.dll鏂囦歡鍚屾牱鎷瘋礉鍒拌澶栨寕紼嬪簭鐨勭洰褰曚笅銆傞噸鏂板惎鍔?b>娓告垙紼嬪簭錛屾鏃?b>娓告垙紼嬪簭灝嗗厛鍔犺澆鎴戜滑鑷繁鍒朵綔鐨剋sock32.dll鏂囦歡錛屽啀閫氳繃璇ュ簱鏂囦歡闂存帴璋冪敤鍘焀inSock鎺ュ彛鍑芥暟鏉ュ疄鐜拌闂綉緇溿備笂闈㈡垜浠粎浠呬粙緇嶄簡鎸¤澆WinSock鐨勫疄鐜拌繃紼嬶紝鑷充簬濡備綍鍔犲叆澶栨寕鎺у埗浠g爜錛岃繕闇瑕佸鎸傚紑鍙戜漢鍛樺娓告垙鏁版嵁鍖呯粨鏋勩佸唴瀹廣佸姞瀵嗙畻娉曠瓑鏂歸潰鐨勪粩緇嗗垎鏋愶紙榪欎釜榪囩▼灝嗘槸涓涓壈杈涚殑榪囩▼錛夛紝鍐嶇敓鎴愬鎸傛帶鍒朵唬鐮併傚叧浜庢暟鎹寘鍒嗘瀽鏂規(guī)硶鍜屾妧宸э紝涓嶆槸鏈枃璁茶В鐨勮寖鍥達(dá)紝濡傛?zhèn)ㄦ劅鍏喘懀鍙互鍒熬|戜笂鏌ユ煡鐩稿叧璧勬枡銆?br />
銆銆2.鎸℃埅API
銆銆鎸℃埅API鎶鏈?/b>涓庢尅鎴猈inSock鎶鏈?/b>鍦ㄥ師鐞嗕笂寰堢浉浼鹼紝浣嗘槸鍓嶈呮瘮鍚庤呮彁渚涗簡鏇村己澶х殑鍔熻兘銆傛尅鎴猈inSock浠呭彧鑳芥尅鎴猈inSock鎺ュ彛鍑芥暟錛岃屾尅鎴狝PI鍙互瀹炵幇瀵瑰簲鐢ㄧ▼搴忚皟鐢ㄧ殑鍖呮嫭WinSock API鍑芥暟鍦ㄥ唴鐨勬墍鏈堿PI鍑芥暟鐨勬尅鎴傚鏋滄?zhèn)ㄧ殑澶栨寕绋嬪簭浠呮墦绠楀WinSock鐨勫嚱鏁拌繘琛屾尅鎴殑璇濓紝鎮(zhèn)ㄥ彲浠ュ彧閫夋嫨浣跨敤涓婂皬鑺備粙緇嶇殑鎸℃埅WinSock鎶鏈?/b>銆傞殢鐫澶ч噺澶栨寕紼嬪簭鍦ㄥ姛鑳戒笂鐨勬墿灞曪紝瀹冧滑涓嶄粎浠呭彧鎻愪緵瀵規(guī)暟鎹寘鐨勬尅鎴紝鑰屼笖榪樺娓告垙紼嬪簭涓嬌鐢ㄧ殑Windows API鎴栧叾瀹僁LL搴撳嚱鏁扮殑鎸℃埅錛屼互浣垮鎸傜殑鍔熻兘鏇村姞寮哄ぇ銆備緥濡傦紝鍙互閫氳繃鎸℃埅鐩稿叧API鍑芥暟浠ュ疄鐜板闈炰腑鏂?b>娓告垙鐨勬眽鍖栧姛鑳斤紝鏈変簡榪欎釜鍒╁櫒錛屽彲浠ヤ嬌鎮(zhèn)ㄧ殑澶栨寕紼嬪簭鏃犳墍涓嶈兘浜嗐?br />
銆銆鎸℃埅API鎶鏈?/b>鐨勫師鐞嗘牳蹇冧篃鏄嬌鐢ㄦ垜浠嚜宸辯殑鍑芥暟鏉ユ浛鎹㈡帀Windows鎴栧叾瀹僁LL搴撴彁渚涚殑鍑芥暟錛屾湁鐐瑰悓鎸℃埅WinSock鍘熺悊鐩鎬技鍚с備絾鏄紝鍏跺疄鐜拌繃紼嬪嵈姣旀尅鎴猈inSock瑕佸鏉傜殑澶氾紝濡傚儚瀹炵幇鎸℃埅Winsock榪囩▼涓鏍鳳紝灝嗗簲鐢ㄧ▼搴忚皟鐢ㄧ殑鎵鏈夌殑搴撴枃浠墮兘鍐欎竴涓ā鎷熷簱鏈夌偣涓嶅ぇ鍙兘錛屽氨鍙Windows API灝辨湁涓?b>鍗?/b>涓紝榪樻湁寰堝搴撴彁渚涚殑鍑芥暟緇撴瀯騫舵湭鍏紑錛屾墍浠ュ啓涓涓ā鎷熷簱浠f浛鐨勬柟寮忎笉澶х幇瀹烇紝鏁呮垜浠繀欏誨彟璋嬭壇鏂廣?br />
銆銆鎸℃埅API鐨勬渶緇堢洰鏍囨槸浣跨敤鑷畾涔夌殑鍑芥暟浠f浛鍘熷嚱鏁般傞偅涔堬紝鎴戜滑棣栧厛搴旇鐭ラ亾搴旂敤紼嬪簭浣曟椂銆佷綍鍦般佺敤浣曠鏂瑰紡璋冪敤鍘熷嚱鏁般傛帴涓嬫潵錛岄渶瑕佸皢搴旂敤紼嬪簭涓皟鐢ㄨ鍘熷嚱鏁扮殑鎸囦護(hù)浠g爜榪涜淇敼錛屼嬌瀹冨皢璋冪敤鍑芥暟鐨勬寚閽堟寚鍚戞垜浠嚜宸卞畾涔夌殑鍑芥暟鍦板潃銆傝繖鏍鳳紝澶栨寕紼嬪簭鎵嶈兘瀹屽叏鎺у埗搴旂敤紼嬪簭璋冪敤鐨凙PI鍑芥暟錛岃嚦浜庡湪鍏朵腑濡備綍鍔犲叆澶栨寕浠g爜錛屽氨搴旈渶姹傝屽紓浜嗐傛渶鍚庤繕鏈変竴涓噸瑕佺殑闂瑕佽В鍐籌紝濡備綍灝嗘垜浠嚜瀹氫箟鐨勭敤鏉ヤ唬鏇垮師API鍑芥暟鐨勫嚱鏁頒唬鐮佹敞鍏ヨ澶栨寕娓告垙紼嬪簭榪涜鍦板潃絀洪棿涓紝鍥犲湪Windows緋葷粺涓簲鐢ㄧ▼搴忎粎鍙兘璁塊棶鍒版湰榪涚▼鍦板潃絀洪棿鍐呯殑浠g爜鍜屾暟鎹?br />
銆銆緇間笂鎵榪幫紝瑕佸疄鐜版尅鎴狝PI鍑芥暟錛岃嚦灝戦渶瑕佽В鍐沖涓嬩笁涓棶棰橈細(xì)
銆銆鈼?濡備綍瀹氫綅娓告垙紼嬪簭涓皟鐢ˋPI鍑芥暟鎸囦護(hù)浠g爜錛?br />
銆銆鈼?濡備綍淇敼娓告垙紼嬪簭涓皟鐢ˋPI鍑芥暟鎸囦護(hù)浠g爜錛?br />
銆銆鈼?濡備綍灝嗗鎸備唬鐮侊紙鑷畾涔夌殑鏇挎崲鍑芥暟浠g爜錛夋敞鍏ュ埌娓告垙紼嬪簭榪涚▼鍦板潃絀洪棿錛?br />
銆銆涓嬮潰鎴戜滑閫愪竴浠嬬粛榪欏嚑涓棶棰樼殑瑙e喅鏂規(guī)硶錛?br />
銆銆(1) 銆佸畾浣嶈皟鐢ˋPI鍑芥暟鎸囦護(hù)浠g爜
銆銆鎴戜滑鐭ラ亾錛屽湪姹囩紪璇█涓嬌鐢–ALL鎸囦護(hù)鏉ヨ皟鐢ㄥ嚱鏁版垨榪囩▼鐨勶紝瀹冩槸閫氳繃鎸囦護(hù)鍙傛暟涓殑鍑芥暟鍦板潃鑰屽畾浣嶅埌鐩稿簲鐨勫嚱鏁頒唬鐮佺殑銆傞偅涔堬紝鎴戜滑濡傛灉鑳藉鎵懼埌紼嬪簭浠g爜涓墍鏈夎皟鐢ㄨ鎸℃埅鐨凙PI鍑芥暟鐨凜ALL鎸囦護(hù)鐨勮瘽錛屽氨鍙互灝嗚鎸囦護(hù)涓殑鍑芥暟鍦板潃鍙傛暟淇敼涓烘浛浠e嚱鏁扮殑鍦板潃銆傝櫧鐒惰繖鏄竴涓彲琛岀殑鏂規(guī)錛屼絾鏄疄鐜拌搗鏉ヤ細(xì)寰堢箒鐞愶紝涔熶笉紼沖仴銆傚簡騫哥殑鏄紝Windows緋葷粺涓墍浣跨敤鐨勫彲鎵ц鏂囦歡錛圥E鏍煎紡錛夐噰鐢ㄤ簡杈撳叆鍦板潃琛ㄦ満鍒訛紝灝嗘墍鏈夊湪紼嬪簭璋冪敤鐨凙PI鍑芥暟鐨勫湴鍧淇℃伅瀛樻斁鍦ㄨ緭鍏ュ湴鍧琛ㄤ腑錛岃屽湪紼嬪簭浠g爜CALL鎸囦護(hù)涓嬌鐢ㄧ殑鍦板潃涓嶆槸API鍑芥暟鐨勫湴鍧錛岃屾槸杈撳叆鍦板潃琛ㄤ腑璇PI鍑芥暟鐨勫湴鍧欏癸紝濡傛兂浣跨▼搴忎唬鐮佷腑璋冪敤鐨凙PI鍑芥暟琚唬鏇挎帀錛屽彧鐢ㄥ皢杈撳叆鍦板潃琛ㄤ腑璇PI鍑芥暟鐨勫湴鍧欏瑰唴瀹逛慨鏀瑰嵆鍙傚叿浣撶悊瑙h緭鍏ュ湴鍧琛ㄨ繍琛屾満鍒訛紝榪橀渶瑕佷簡瑙d竴涓婸E鏍煎紡鏂囦歡緇撴瀯錛屽叾涓浘涓夊垪鍑轟簡PE鏍煎紡鏂囦歡鐨勫ぇ鑷寸粨鏋勩?br />
鍥句笁錛歅E鏍煎紡澶ц嚧緇撴瀯鍥?br />
銆銆PE鏍煎紡鏂囦歡涓寮濮嬫槸涓孌礑OS紼嬪簭錛屽綋浣犵殑紼嬪簭鍦ㄤ笉鏀寔Windows鐨勭幆澧冧腑榪愯鏃訛紝瀹冨氨浼?xì)鏄窘C衡淭his Program cannot be run in DOS mode鈥濊繖鏍風(fēng)殑璀﹀憡璇彞錛屾帴鐫榪欎釜DOS鏂囦歡澶達(dá)紝灝卞紑濮嬬湡姝g殑PE鏂囦歡鍐呭浜嗐傞鍏堟槸涓孌電О涓衡淚MAGE_NT_HEADER鈥濈殑鏁版嵁錛屽叾涓槸璁稿鍏充簬鏁翠釜PE鏂囦歡鐨勬秷鎭紝鍦ㄨ繖孌墊暟鎹殑灝劇鏄竴涓О涓篋ata Directory鐨勬暟鎹〃錛岄氳繃瀹冭兘蹇熷畾浣嶄竴浜汸E鏂囦歡涓錛坰ection錛夌殑鍦板潃銆傚湪榪欐鏁版嵁涔嬪悗錛屽垯鏄竴涓淚MAGE_SECTION_HEADER鈥濈殑鍒楄〃錛屽叾涓殑姣忎竴欏歸兘璇︾粏鎻忚堪浜嗗悗闈竴涓鐨勭浉鍏充俊鎭傛帴鐫瀹冨氨鏄疨E鏂囦歡涓渶涓昏鐨勬鏁版嵁浜嗭紝鎵ц浠g爜銆佹暟鎹拰璧勬簮絳夌瓑淇℃伅灝卞垎鍒瓨鏀懼湪榪欎簺孌典腑銆?br />
銆銆鍦ㄦ墍鏈夌殑榪欎簺孌甸噷錛屾湁涓涓縐頒負(fù)鈥?idata鈥濈殑孌碉紙杈撳叆鏁版嵁孌碉級鍊煎緱鎴戜滑鍘繪敞鎰忥紝璇ユ涓寘鍚潃涓浜涜縐頒負(fù)杈撳叆鍦板潃琛紙IAT錛孖mport Address Table錛夌殑鏁版嵁鍒楄〃銆傛瘡涓敤闅愬紡鏂瑰紡鍔犺澆鐨凙PI鎵鍦ㄧ殑DLL閮芥湁涓涓狪AT涓庝箣瀵瑰簲錛屽悓鏃朵竴涓狝PI鐨勫湴鍧涔熶笌IAT涓竴欏圭浉瀵瑰簲銆傚綋涓涓簲鐢ㄧ▼搴忓姞杞藉埌鍐呭瓨涓悗錛岄拡瀵規(guī)瘡涓涓狝PI鍑芥暟璋冪敤錛岀浉搴旂殑浜х敓濡備笅鐨勬眹緙栨寚浠わ細(xì)
銆銆JMP DWORD PTR [XXXXXXXX]
銆銆鎴?br />
銆銆CALL DWORD PTR [XXXXXXXX]
銆銆鍏朵腑錛孾XXXXXXXX]琛ㄧず鎸囧悜浜嗚緭鍏ュ湴鍧琛ㄤ腑涓涓」錛屽叾鍐呭鏄竴涓狣WORD錛岃屾鏄繖涓狣WORD鎵嶆槸API鍑芥暟鍦ㄥ唴瀛樹腑鐨勭湡姝e湴鍧銆傚洜姝ゆ垜浠鎯蟲嫤鎴竴涓狝PI鐨勮皟鐢紝鍙綆鍗曠殑鎶婇偅涓狣WORD鏀逛負(fù)鎴戜滑鑷繁鐨勫嚱鏁扮殑鍦板潃銆?br />
銆銆(2) 銆佷慨鏀硅皟鐢ˋPI鍑芥暟浠g爜
銆銆浠庝笂闈㈠PE鏂囦歡鏍煎紡鐨勫垎鏋愬彲鐭ワ紝淇敼璋冪敤API鍑芥暟浠g爜鍏跺疄鏄慨鏀硅璋冪敤API鍑芥暟鍦ㄨ緭鍏ュ湴鍧琛ㄤ腑IAT欏瑰唴瀹廣傜敱浜?b>Windows緋葷粺瀵瑰簲鐢ㄧ▼搴忔寚浠や唬鐮佸湴鍧絀洪棿鐨勪弗瀵嗕繚鎶ゆ満鍒訛紝浣垮緱淇敼紼嬪簭鎸囦護(hù)浠g爜闈炲父鍥伴毦錛屼互鑷充簬璁稿楂樻墜涓轟箣緙栧啓VxD榪涘叆Ring0銆傚湪榪欓噷錛屾垜涓哄ぇ瀹朵粙緇嶄竴縐嶈緝涓烘柟渚跨殑鏂規(guī)硶淇敼榪涚▼鍐呭瓨錛屽畠浠呴渶瑕佽皟鐢ㄥ嚑涓?b>Windows鏍稿績API鍑芥暟錛屼笅闈㈡垜棣栧厛鏉ュ浼?xì)涓涓嬭繖鍑犱釜API鍑芥暟錛?br />
銆銆銆DWORD VirtualQuery(
銆銆銆LPCVOID lpAddress, // address of region
銆銆銆PMEMORY_BASIC_INFORMATION lpBuffer, // information buffer
銆銆銆DWORD dwLength // size of buffer
銆銆銆);
銆銆璇ュ嚱鏁扮敤浜庢煡璇㈠叧浜庢湰榪涚▼鍐呰櫄鎷熷湴鍧欏電殑淇℃伅銆傚叾涓紝lpAddress琛ㄧず琚煡璇㈤〉鐨勫尯鍩熷湴鍧錛沴pBuffer琛ㄧず鐢ㄤ簬淇濆瓨鏌ヨ欏典俊鎭殑緙撳啿錛沝wLength琛ㄧず緙撳啿鍖哄ぇ灝忋傝繑鍥炲間負(fù)瀹為檯緙撳啿澶у皬銆?br />
銆銆銆BOOL VirtualProtect(
銆銆銆LPVOID lpAddress, // region of committed pages
銆銆銆SIZE_T dwSize, // size of the region
銆銆銆DWORD flNewProtect, // desired access protection
銆銆銆PDWORD lpflOldProtect // old protection
銆銆銆);
銆銆璇ュ嚱鏁扮敤浜庢敼鍙樻湰榪涚▼鍐呰櫄鎷熷湴鍧欏電殑淇濇姢灞炴с傚叾涓紝lpAddress琛ㄧず琚敼鍙樹繚鎶ゅ睘鎬ч〉鍖哄煙鍦板潃錛沝wSize琛ㄧず欏靛尯鍩熷ぇ灝忥紱flNewProtect琛ㄧず鏂扮殑淇濇姢灞炴э紝鍙彇鍊間負(fù)PAGE_READONLY銆丳AGE_READWRITE銆丳AGE_EXECUTE絳夛紱lpflOldProtect琛ㄧず鐢ㄤ簬淇濆瓨鏀瑰彉鍓嶇殑淇濇姢灞炴с傚鏋滃嚱鏁拌皟鐢ㄦ垚鍔熻繑鍥炩淭鈥濓紝鍚﹀垯榪斿洖鈥淔鈥濄?br />
銆銆鏈変簡榪欎袱涓狝PI鍑芥暟錛屾垜浠氨鍙互闅忓績鎵嬈茬殑淇敼榪涚▼鍐呭瓨浜嗐傞鍏堬紝璋冪敤VirtualQuery()鍑芥暟鏌ヨ琚慨鏀瑰唴瀛樼殑欏典俊鎭紝鍐嶆牴鎹淇℃伅璋冪敤VirtualProtect()鍑芥暟鏀瑰彉榪欎簺欏電殑淇濇姢灞炴т負(fù)PAGE_READWRITE錛屾湁浜嗚繖涓潈闄愭?zhèn)鍙互鋼Q鎰忎慨鏀硅繘紼嬪唴瀛樻暟鎹簡銆備笅闈竴孌典唬鐮佹紨紺轟簡濡備綍灝嗚繘紼嬭櫄鎷熷湴鍧涓?x0040106c澶勭殑瀛楄妭娓呴浂銆?br />
銆銆銆BYTE* pData = 0x0040106c;
銆銆銆MEMORY_BASIC_INFORMATION mbi_thunk;
銆銆銆//鏌ヨ欏典俊鎭?br />銆銆銆VirtualQuery(pData, &mbi_thunk, sizeof(MEMORY_BASIC_INFORMATION));
銆銆銆//鏀瑰彉欏典繚鎶ゅ睘鎬т負(fù)璇誨啓銆?br />銆銆銆VirtualProtect(mbi_thunk.BaseAddress,mbi_thunk.RegionSize,
銆銆銆PAGE_READWRITE, &mbi_thunk.Protect);
銆銆銆//娓呴浂銆?br />銆銆銆*pData = 0x00;
銆銆銆//鎭㈠欏電殑鍘熶繚鎶ゅ睘鎬с?br />銆銆銆DWORD dwOldProtect;
銆銆銆VirtualProtect(mbi_thunk.BaseAddress,mbi_thunk.RegionSize,
銆銆銆mbi_thunk.Protect, &dwOldProtect);
銆銆(3)銆佹敞鍏ュ鎸備唬鐮佽繘鍏ヨ鎸?b>娓告垙榪涚▼涓?br />
銆銆瀹屾垚浜嗗畾浣嶅拰淇敼紼嬪簭涓皟鐢ˋPI鍑芥暟浠g爜鍚庯紝鎴戜滑灝卞彲浠ラ殢鎰忚璁¤嚜瀹氫箟鐨凙PI鍑芥暟鐨勬浛浠e嚱鏁頒簡銆傚仛瀹岃繖涓鍒囧悗錛岃繕闇瑕佸皢榪欎簺浠g爜娉ㄥ叆鍒拌澶栨寕娓告垙紼嬪簭榪涚▼鍐呭瓨絀洪棿涓紝涓嶇劧娓告垙榪涚▼鏍規(guī)湰涓嶄細(xì)璁塊棶鍒版浛浠e嚱鏁頒唬鐮併傛敞鍏ユ柟娉曟湁寰堝錛屽鍒╃敤鍏ㄥ眬閽╁瓙娉ㄥ叆銆佸埄鐢ㄦ敞鍐岃〃娉ㄥ叆鎸℃埅User32搴撲腑鐨凙PI鍑芥暟銆佸埄鐢–reateRemoteThread娉ㄥ叆錛堜粎闄愪簬NT/2000錛夈佸埄鐢˙HO娉ㄥ叆絳夈傚洜涓烘垜浠湪鍔ㄤ綔妯℃嫙鎶鏈?/b>涓鑺傚凡緇忔帴瑙﹁繃鍏ㄥ眬閽╁瓙錛屾垜鐩鎬俊鑱槑鐨勮鑰呭凡緇忓畬鍏ㄦ帉鎻′簡鍏ㄥ眬閽╁瓙鐨勫埗浣滆繃紼嬶紝鎵浠ユ垜浠湪鍚庨潰鐨勫疄渚嬩腑錛屽皢緇х畫鍒╃敤榪欎釜鍏ㄥ眬閽╁瓙銆傝嚦浜庡叾瀹冨嚑縐嶆敞鍏ユ柟娉曪紝濡傛灉鎰熷叴瓚e彲鍙傞槄MSDN鏈夊叧鍐呭銆?br />
銆銆鏈変簡浠ヤ笂鐞嗚鍩虹錛屾垜浠笅闈㈠氨寮濮嬪埗浣滀竴涓尅鎴狹essageBoxA鍜宺ecv鍑芥暟鐨勫疄渚嬶紝鍦ㄥ紑鍙?b>娓告垙澶栨寕紼嬪簭 鏃訛紝鍙互姝ゅ疄渚嬩負(fù)妗嗘灦錛屽姞鍏ョ浉搴旂殑鏇夸唬鍑芥暟鍜屽鐞嗕唬鐮佸嵆鍙傛瀹炰緥鐨勫紑鍙戣繃紼嬪涓嬶細(xì)
銆銆(1) 鎵撳紑鍓嶉潰鍒涘緩鐨凙ctiveKey欏圭洰銆?br />
銆銆(2) 鍦ˋctiveKey.h鏂囦歡涓姞鍏OOKAPI緇撴瀯錛屾緇撴瀯鐢ㄦ潵瀛樺偍琚尅鎴狝PI鍑芥暟鍚嶇О銆佸師API鍑芥暟鍦板潃鍜屾浛浠e嚱鏁板湴鍧銆?br />
銆銆銆typedef struct tag_HOOKAPI
銆銆銆{
銆銆銆LPCSTR szFunc;//琚獺OOK鐨凙PI鍑芥暟鍚嶇О銆?br />銆銆銆PROC pNewProc;//鏇夸唬鍑芥暟鍦板潃銆?br />銆銆銆PROC pOldProc;//鍘烝PI鍑芥暟鍦板潃銆?br />銆銆銆}HOOKAPI, *LPHOOKAPI;
銆銆(3) 鎵撳紑ActiveKey.cpp鏂囦歡錛岄鍏堝姞鍏ヤ竴涓嚱鏁幫紝鐢ㄤ簬瀹氫綅杈撳叆搴撳湪杈撳叆鏁版嵁孌典腑鐨処AT鍦板潃銆備唬鐮佸涓嬶細(xì)
銆銆銆extern "C" __declspec(dllexport)PIMAGE_IMPORT_DESCRIPTOR
銆銆銆LocationIAT(HMODULE hModule, LPCSTR szImportMod)
銆銆銆//鍏朵腑錛宧Module涓鴻繘紼嬫ā鍧楀彞鏌勶紱szImportMod涓鴻緭鍏ュ簱鍚嶇О銆?br />銆銆銆{
銆銆銆//媯鏌ユ槸鍚︿負(fù)DOS紼嬪簭錛屽鏄繑鍥濶ULL錛屽洜DOS紼嬪簭娌℃湁IAT銆?br />銆銆銆PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER) hModule;
銆銆銆if(pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE) return NULL;
銆銆銆銆//媯鏌ユ槸鍚︿負(fù)NT鏍囧織錛屽惁鍒欒繑鍥濶ULL銆?br />銆銆銆銆PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((DWORD)pDOSHeader+ (DWORD)(pDOSHeader->e_lfanew));
銆銆銆銆if(pNTHeader->Signature != IMAGE_NT_SIGNATURE) return NULL;
銆銆銆銆//娌℃湁IAT琛ㄥ垯榪斿洖NULL銆?br />銆銆銆銆if(pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress == 0) return NULL;
銆銆銆銆//瀹氫綅絎竴涓狪AT浣嶇疆銆?
銆銆銆銆PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD)pDOSHeader + (DWORD)(pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress));
銆銆銆銆//鏍規(guī)嵁杈撳叆搴撳悕縐板驚鐜鏌ユ墍鏈夌殑IAT錛屽鍖歸厤鍒欒繑鍥炶IAT鍦板潃錛屽惁鍒欐嫻嬩笅涓涓狪AT銆?br />銆銆銆銆while (pImportDesc->Name)
銆銆銆銆{
銆銆銆銆銆//鑾峰彇璇AT鎻忚堪鐨勮緭鍏ュ簱鍚嶇О銆?br />銆銆銆PSTR szCurrMod = (PSTR)((DWORD)pDOSHeader + (DWORD)(pImportDesc->Name));
銆銆銆if (stricmp(szCurrMod, szImportMod) == 0) break;
銆銆銆pImportDesc++;
銆銆銆銆}
銆銆銆銆if(pImportDesc->Name == NULL) return NULL;
銆銆銆return pImportDesc;
銆銆銆}
銆銆鍐嶅姞鍏ヤ竴涓嚱鏁幫紝鐢ㄦ潵瀹氫綅琚尅鎴狝PI鍑芥暟鐨処AT欏瑰茍淇敼鍏跺唴瀹逛負(fù)鏇夸唬鍑芥暟鍦板潃銆備唬鐮佸涓嬶細(xì)
銆銆銆extern "C" __declspec(dllexport)
銆銆銆HookAPIByName( HMODULE hModule, LPCSTR szImportMod, LPHOOKAPI pHookApi)
銆銆銆//鍏朵腑錛宧Module涓鴻繘紼嬫ā鍧楀彞鏌勶紱szImportMod涓鴻緭鍏ュ簱鍚嶇О錛沺HookAPI涓篐OOKAPI緇撴瀯鎸囬拡銆?br />銆銆銆{
銆銆銆銆//瀹氫綅szImportMod杈撳叆搴撳湪杈撳叆鏁版嵁孌典腑鐨処AT鍦板潃銆?br />銆銆銆銆PIMAGE_IMPORT_DESCRIPTOR pImportDesc = LocationIAT(hModule, szImportMod);
銆銆if (pImportDesc == NULL) return FALSE;
銆銆銆銆//絎竴涓猅hunk鍦板潃銆?br />銆銆銆銆PIMAGE_THUNK_DATA pOrigThunk = (PIMAGE_THUNK_DATA)((DWORD)hModule + (DWORD)(pImportDesc->OriginalFirstThunk));
銆銆 //絎竴涓狪AT欏圭殑Thunk鍦板潃銆?br />銆銆銆銆PIMAGE_THUNK_DATA pRealThunk = (PIMAGE_THUNK_DATA)((DWORD)hModule + (DWORD)(pImportDesc->FirstThunk));
銆銆銆銆//寰幆鏌ユ壘琚埅API鍑芥暟鐨処AT欏癸紝騫朵嬌鐢ㄦ浛浠e嚱鏁板湴鍧淇敼鍏跺箋?br />銆銆銆while(pOrigThunk->u1.Function)
{
銆//媯嫻嬫Thunk鏄惁涓篒AT欏廣?br />if((pOrigThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) != IMAGE_ORDINAL_FLAG)
{
銆 //鑾峰彇姝AT欏規(guī)墍鎻忚堪鐨勫嚱鏁板悕縐般?br />銆PIMAGE_IMPORT_BY_NAME pByName =(PIMAGE_IMPORT_BY_NAME)((DWORD)hModule+(DWORD)(pOrigThunk->u1.AddressOfData));
銆if(pByName->Name[0] == '\0') return FALSE;
銆銆//媯嫻嬫槸鍚︿負(fù)鎸℃埅鍑芥暟銆?br />if(strcmpi(pHookApi->szFunc, (char*)pByName->Name) == 0)
銆 {
銆銆銆銆銆銆銆MEMORY_BASIC_INFORMATION mbi_thunk;
銆銆銆銆銆銆銆//鏌ヨ淇敼欏電殑淇℃伅銆?br />銆銆銆銆銆銆銆VirtualQuery(pRealThunk, &mbi_thunk, sizeof(MEMORY_BASIC_INFORMATION));
//鏀瑰彉淇敼欏典繚鎶ゅ睘鎬т負(fù)PAGE_READWRITE銆?br />銆銆銆銆銆銆銆VirtualProtect(mbi_thunk.BaseAddress,mbi_thunk.RegionSize, PAGE_READWRITE, &mbi_thunk.Protect);
//淇濆瓨鍘熸潵鐨凙PI鍑芥暟鍦板潃銆?br />銆銆銆 銆銆if(pHookApi->pOldProc == NULL)
pHookApi->pOldProc = (PROC)pRealThunk->u1.Function;
銆 //淇敼API鍑芥暟IAT欏瑰唴瀹逛負(fù)鏇夸唬鍑芥暟鍦板潃銆?br />pRealThunk->u1.Function = (PDWORD)pHookApi->pNewProc;
//鎭㈠淇敼欏典繚鎶ゅ睘鎬с?br />DWORD dwOldProtect;
銆銆銆銆銆銆銆VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize, mbi_thunk.Protect, &dwOldProtect);
銆銆銆銆銆 }
}
銆 pOrigThunk++;
銆 pRealThunk++;
}
銆銆SetLastError(ERROR_SUCCESS); //璁劇疆閿欒涓篍RROR_SUCCESS錛岃〃紺烘垚鍔熴?br />銆銆return TRUE;
銆銆銆}
銆銆(4) 瀹氫箟鏇夸唬鍑芥暟錛屾瀹炰緥涓彧緇橫essageBoxA鍜宺ecv涓や釜API榪涜鎸℃埅銆備唬鐮佸涓嬶細(xì)
銆銆銆static int WINAPI MessageBoxA1 (HWND hWnd , LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
銆銆銆{
銆銆銆銆//榪囨護(hù)鎺夊師MessageBoxA鐨勬鏂囧拰鏍囬鍐呭錛屽彧鏄劇ず濡備笅鍐呭銆?br />return MessageBox(hWnd, "Hook API OK!", "Hook API", uType);
銆銆銆}
銆銆銆static int WINAPI recv1(SOCKET s, char FAR *buf, int len, int flags )
銆銆銆{
銆銆銆//姝ゅ鍙互鎸℃埅娓告垙鏈嶅姟鍣ㄥ彂閫佹潵鐨勭綉緇滄暟鎹寘錛屽彲浠ュ姞鍏ュ垎鏋愬拰澶勭悊鏁版嵁浠g爜銆?br />銆銆銆return recv(s,buf,len,flags);
銆銆銆}
銆銆(5) 鍦↘eyboardProc鍑芥暟涓姞鍏ユ縺媧繪尅鎴狝PI浠g爜錛屽湪if( wParam == 0X79 )璇彞涓悗闈㈠姞鍏ュ涓媏lse if璇彞錛?br />
銆銆銆......
銆銆銆//褰撴縺媧籉11閿椂錛屽惎鍔ㄦ尅鎴狝PI鍑芥暟鍔熻兘銆?br />銆銆銆else if( wParam == 0x7A )
銆銆銆{
銆銆銆銆HOOKAPI api[2];
api[0].szFunc ="MessageBoxA";//璁劇疆琚尅鎴嚱鏁扮殑鍚嶇О銆?br />api[0].pNewProc = (PROC)MessageBoxA1;//璁劇疆鏇夸唬鍑芥暟鐨勫湴鍧銆?br />api[1].szFunc ="recv";//璁劇疆琚尅鎴嚱鏁扮殑鍚嶇О銆?br />api[1].pNewProc = (PROC)recv1; //璁劇疆鏇夸唬鍑芥暟鐨勫湴鍧銆?br />//璁劇疆鎸℃埅User32.dll搴撲腑鐨凪essageBoxA鍑芥暟銆?br />HookAPIByName(GetModuleHandle(NULL),"User32.dll",&api[0]);
//璁劇疆鎸℃埅Wsock32.dll搴撲腑鐨剅ecv鍑芥暟銆?br />HookAPIByName(GetModuleHandle(NULL),"Wsock32.dll",&api[1]);
銆銆銆}
銆銆銆......
銆銆(6) 鍦ˋctiveKey.cpp涓姞鍏ュご鏂囦歡澹版槑 "#include "wsock32.h"銆?浠庘滃伐紼嬧濊彍鍗曚腑閫夋嫨鈥滆緗濓紝寮瑰嚭Project Setting瀵硅瘽妗嗭紝閫夋嫨Link鏍囩錛屽湪鈥滃璞?搴撴ā鍧椻濅腑杈撳叆Ws2_32..lib銆?br />
銆銆(7) 閲嶆柊緙栬瘧ActiveKey欏圭洰錛屼駭鐢烝ctiveKey.dll鏂囦歡錛屽皢鍏舵嫹璐濆埌Simulate.exe鐩綍涓嬨傝繍琛孲imulate.exe騫跺惎鍔ㄥ叏灞閽╁瓙銆傛縺媧諱換鎰忓簲鐢ㄧ▼搴忥紝鎸塅11閿悗錛岃繍琛屾紼嬪簭涓彲鑳借皟鐢∕essageBoxA鍑芥暟鐨勬搷浣滐紝鐪嬬湅淇℃伅妗嗘槸涓嶆槸鏈夋墍鍙樺寲銆傚悓鏍鳳紝濡傛紼嬪簭姝e湪鎺ユ敹緗戠粶鏁版嵁鍖咃紝灝卞彲浠ュ疄鐜板皝鍖呭姛鑳戒簡銆?br />
銆銆鍏佺粨鏉熻
銆銆闄や簡浠ヤ笂浠嬬粛鐨勫嚑縐?b>娓告垙澶栨寕紼嬪簭甯哥敤鐨?b>鎶鏈?/b>浠ュ錛屽湪涓浜涘鎸傜▼搴忎腑榪樹嬌鐢ㄤ簡娓告垙鏁版嵁淇敼鎶鏈?/b>銆?b>娓告垙鍔犻?b>鎶鏈?/b>絳夈傚湪榪欑瘒鏂囩珷閲岋紝灝變笉閫愪竴浠嬬粛浜嗐?img src ="http://www.shnenglu.com/eday/aggbug/15363.html" width = "1" height = "1" />
]]>
銆銆鎵璋?b>娓告垙澶栨寕錛屽叾瀹炴槸涓縐?b>娓告垙澶栬緟紼嬪簭錛屽畠鍙互鍗忓姪鐜╁鑷姩浜х敓娓告垙鍔ㄤ綔銆佷慨鏀?b>娓告垙緗戠粶鏁版嵁鍖呬互鍙?qiáng)淇?b>娓告垙鍐呭瓨鏁版嵁絳夛紝浠ュ疄鐜扮帺瀹剁敤鏈灝戠殑鏃墮棿鍜岄噾閽卞幓瀹屾垚鍔熷姏鍗囩駭鍜岃繃鍏蟲柀灝嗐傝櫧鐒訛紝鐜板湪瀵?b>娓告垙澶栨寕紼嬪簭鐨勨滃悎娉曗濊韓浠戒紬璇寸悍綰紝鍦ㄨ繖閲屾垜涓嶆兂瀵規(guī)鍙戣〃浠諱綍涓漢鎰忚錛岃鏃墮棿鍘昏鏄庝竴鍒囧惂銆?br />
銆銆涓嶇娓告垙澶栨寕紼嬪簭鏄笉鏄滃悎娉曗濊韓浠斤紝浣嗘槸瀹冨嵈鏄叿鏈変竴瀹氱殑鎶鏈?/b>鍚噺鐨勶紝鍦ㄨ繖浜涘皬灝忕▼搴忎腑浣跨敤浜嗚澶氶珮绔?b>鎶鏈?/b>錛屽鎷︽埅Sock鎶鏈?/b>銆佹嫤鎴狝PI鎶鏈?/b>銆佹ā鎷熼敭鐩樹笌榧犳爣鎶鏈?/b>銆佺洿鎺ヤ慨鏀圭▼搴忓唴瀛?b>鎶鏈?/b>絳夌瓑銆傛湰鏂囧皢瀵瑰父瑙佺殑娓告垙澶栨寕涓嬌鐢ㄧ殑鎶鏈?/b>榪涜鍏ㄩ潰鍓栨瀽銆?br />
銆銆浜屻佽璇嗗鎸?br />
銆銆娓告垙澶栨寕鐨勫巻鍙插彲浠ヨ拷婧埌鍗曟満鐗?b>娓告垙鏃朵唬錛屽彧涓嶈繃褰撴椂瀹冧嬌鐢ㄤ簡鍙︿竴涓洿閫氫織鏄撴噦鐨勫悕瀛??娓告垙淇敼鍣ㄣ傚畠鍙互鍦?b>娓告垙涓拷韙攣瀹?b>娓告垙涓諱漢鍏殑鍚勯」鑳藉姏鏁板箋傝繖鏍風(fēng)帺瀹跺湪娓告垙涓彲浠ヨ揪鍒頒富瑙掍笉鎺夎銆佷笉鑰楄垂欖旀硶銆佷笉娑堣楅噾閽辯瓑鐩殑銆傝繖鏍烽檷浣庝簡娓告垙鐨勯毦搴︼紝浣垮緱鐜╁鏇村鏄撻氬叧銆?br />
銆銆闅忕潃緗戠粶娓告垙鐨勬椂浠g殑鏉ヤ復(fù)錛?b>娓告垙澶栨寕鍦ㄥ師鏈夌殑鍔熻兘涔嬩笂榪涜浜嗘柊鐨勫彂灞曪紝瀹冨彉寰楁洿鍔犲縐嶅鏍鳳紝鍔熻兘鏇村姞寮哄ぇ錛屾搷浣滄洿鍔犵畝鍗曪紝浠ヨ嚦鏈変簺娓告垙鐨勫鎸傚凡緇忔垚涓轟竴涓綋緋伙紝姣斿銆婄煶鍣ㄦ椂浠c嬶紝澶栨寕鍝佺杈懼埌浜嗗嚑鍗佺錛岃嚜鍔ㄦ垬鏂椼佽嚜鍔ㄨ璧般佽嚜鍔ㄧ粌綰с佽嚜鍔ㄨˉ琛銆佸姞閫熴佷笉閬囨晫銆佸師鍦伴亣鏁屻佸揩閫熷鍔犵粡楠屽箋佹寜閿簿鐏碘︹﹀嚑涔庢棤鎵涓嶅寘銆?br />
銆銆娓告垙澶栨寕鐨勮璁′富瑕佹槸閽堝浜庢煇涓?b>娓告垙寮鍙戠殑錛屾垜浠彲浠ユ牴鎹畠閽堝鐨?b>娓告垙鐨勭被鍨嬪彲澶ц嚧鍙皢澶栨寕鍒嗕負(fù)涓ょ澶х被銆?br />
銆銆涓綾繪槸灝?b>娓告垙涓ぇ閲忕箒鐞愬拰鏃犺亰鐨勬敾鍑誨姩浣滀嬌鐢ㄥ鎸傝嚜鍔ㄥ畬鎴愶紝浠ュ府鍔╃帺瀹惰交鏉炬悶瀹氭敾鍑誨璞″茍鍙互蹇熺殑澧炲姞鐜╁鐨勭粡楠屽箋傛瘮濡傚湪銆婇緳鏃忋嬩腑鏈変竴縐嶅伐浣滅殑璁懼畾錛岀帺瀹剁殑宸ヤ綔絳夌駭瓚婇珮錛屽氨鍙互椹鵑┉瓚婂ソ鐨勮澶囥備絾鏄鍔犲伐浣滅瓑綰у嵈涓嶆槸涓浠舵湁瓚g殑浜嬫儏錛屾瘚瀹佽鏄噸澶嶆灟鐕ョ殑鏈烘鍔沖姩銆傚鏋滀綘鎯沖仛娉曞笀鐢ㄧ殑鏉栵紝棣栧厛闇瑕佸仛鍩烘湰宸ヤ綔--?鐮嶆爲(wèi)銆傜爫鏍?wèi)鐨勬栆?guī)硶寰堢畝鍗曪紝鍦ㄤ竴媯靛ぇ鏍?wèi)鍓嶄笉鍋滅殑鐐归紶鏍嚍鍙互浜嗗Q屾瘡10000鐨勭粡楠屽崌涓綰с傝繖灝辨剰鍛崇潃鐜╁瑕佸湪澶ф爲(wèi)鍓嶄笉鍋滅殑鐐瑰嚮榧犳爣錛岃繖縐嶆棤鑱婄殑浜嬫儏閫氳繃"鎸夐敭綺劇伒"灝卞彲浠ヨВ鍐熾傚鎸傜殑"鎸夐敭綺劇伒"鍔熻兘鍙互璁╃帺瀹舵憜鑴辨棤瓚g殑鐐瑰嚮榧犳爣鐨勫伐浣溿?br />
銆銆鍙︿竴綾繪槸鐢卞鎸傜▼搴忎駭鐢熸楠楁х殑緗戠粶娓告垙灝佸寘錛屽茍灝嗚繖浜涘皝鍖呭彂閫佸埌緗戠粶娓告垙鏈嶅姟鍣紝鍒╃敤榪欎簺铏氬亣淇℃伅嬈洪獥鏈嶅姟鍣ㄨ繘琛?b>娓告垙鏁板肩殑淇敼錛岃揪鍒頒慨鏀硅鑹茶兘鍔涙暟鍊肩殑鐩殑銆傝繖綾誨鎸傜▼搴忛拡瀵規(guī)у緢寮猴紝涓鑸湪璁捐鏃墮兘鏄拡瀵規(guī)煇涓?b>娓告垙鏌愪釜鐗堟湰鏉ュ仛鐨勶紝鍥犱負(fù)姣忎釜緗戠粶娓告垙鏈嶅姟鍣ㄤ笌瀹㈡埛绔氦嫻佺殑鏁版嵁鍖呭悇涓嶇浉鍚岋紝澶栨寕紼嬪簭蹇呴』瑕佸嬈洪獥鐨勭綉緇?b>娓告垙鏈嶅姟鍣ㄧ殑鏁版嵁鍖呰繘琛屽垎鏋愶紝鎵嶈兘浜х敓鏈嶅姟鍣ㄨ瘑鍒殑鏁版嵁鍖呫傝繖綾誨鎸傜▼搴忎篃鏄綋鍓嶆渶嫻佸埄鐨勪竴綾?b>娓告垙澶栨寕紼嬪簭銆?br />
銆銆鍙﹀錛岀幇鍦ㄥ緢澶氬鎸傜▼搴忓姛鑳藉己澶э紝涓嶄粎瀹炵幇浜嗚嚜鍔ㄥ姩浣滀唬鐞嗗拰灝佸寘鍔熻兘錛岃屼笖榪樻彁渚涗簡瀵圭綉緇?b>娓告垙鐨勫鎴風(fēng)紼嬪簭鐨勬暟鎹繘琛屼慨鏀癸紝浠ヨ揪鍒版楠楃綉緇?b>娓告垙鏈嶅姟鍣ㄧ殑鐩殑銆傛垜鐩鎬俊錛岄殢鐫緗戠粶娓告垙鍟嗗鐨勫弽澶栨寕鎶鏈?/b>鐨勮繘灞曪紝娓告垙澶栨寕灝嗕細(xì)浜х敓鏇村鏇翠紭縐鐨?b>鎶鏈?/b>錛岃鎴戜滑鏈熷緟鐫鐪嬪満鎶鏈?/b>澶ф垬鍚?.....
銆銆涓夈佸鎸?b>鎶鏈?/b>緇艱堪
銆銆鍙互灝嗗紑鍙?b>娓告垙澶栨寕紼嬪簭鐨勮繃紼嬪ぇ浣撲笂鍒掑垎涓轟袱涓儴鍒嗭細(xì)
銆銆鍓嶆湡閮ㄥ垎宸ヤ綔鏄澶栨寕鐨勪富浣?b>娓告垙榪涜鍒嗘瀽錛屼笉鍚岀被鍨嬬殑澶栨寕鍒嗘瀽涓諱綋娓告垙鐨勫唴瀹逛篃涓嶇浉鍚屻傚澶栨寕涓轟笂榪拌皥鍒扮殑澶栨寕綾誨瀷涓殑絎竴綾繪椂錛屽叾鍒嗘瀽榪囩▼甯告槸閽堝娓告垙鐨勫満鏅腑鐨勬敾鍑誨璞$殑浣嶇疆鍜屽垎甯冩儏鍐佃繘琛屽垎鏋愶紝浠ュ疄鐜板鎸傝嚜鍔ㄨ繘琛屾敾鍑諱互鍙?qiáng)浣嵕|Щ鍔ㄣ傚澶栨寕涓哄鎸傜被鍨嬩腑鐨勭浜岀被鏃訛紝鍏跺垎鏋愯繃紼嬪父鏄拡瀵?b>娓告垙鏈嶅姟鍣ㄤ笌瀹㈡埛绔箣闂撮氳鍖呮暟鎹殑緇撴瀯銆佸唴瀹逛互鍙?qiáng)鍔犲瘑绠楁硶鐨勫垎鏋愩傚洜緗戠粶娓告垙鍏徃涓鑸兘涓嶄細(xì)鍏竷鍏?b>娓告垙浜у搧鐨勯氳鍖呮暟鎹殑緇撴瀯銆佸唴瀹瑰拰鍔犲瘑綆楁硶鐨勪俊鎭紝鎵浠ュ浜庡紑鍙戠浜岀被澶栨寕鎴愬姛鐨勫叧閿湪浜庢槸鍚﹁兘姝g‘鍒嗘瀽娓告垙鍖呮暟鎹殑緇撴瀯銆佸唴瀹逛互鍙?qiáng)鍔犲瘑绠楁硶锛岃櫧鐒跺彲浠ヤ娇鐢ㄤ竴浜涘伐鍏瘋緟鍔╁垎鏋愶紝浣嗘槸榪欒繕鏄竴縐嶅潥鑻﹁屽鏉傜殑宸ヤ綔銆?br />
銆銆鍚庢湡閮ㄥ垎宸ヤ綔涓昏鏄牴鎹墠鏈熷娓告垙鐨勫垎鏋愮粨鏋滐紝浣跨敤澶ч噺鐨勭▼搴忓紑鍙?b>鎶鏈?/b>緙栧啓澶栨寕紼嬪簭浠ュ疄鐜板娓告垙鐨勬帶鍒舵垨淇敼銆傚澶栨寕紼嬪簭涓虹涓綾誨鎸傛椂錛岄氬父浼?xì)鋴社敤鍒伴紶鏍囨ā鎷?b>鎶鏈?/b>鏉ュ疄鐜?b>娓告垙瑙掕壊鐨勮嚜鍔ㄤ綅緗Щ鍔紝浣跨敤閿洏妯℃嫙鎶鏈?/b>鏉ュ疄鐜?b>娓告垙瑙掕壊鐨勮嚜鍔ㄦ敾鍑匯傚澶栨寕紼嬪簭涓虹浜岀被澶栨寕鏃訛紝閫氬父浼?xì)鋴社敤鍒版尅鎴猄ock鍜屾尅鎴狝PI鍑芥暟鎶鏈?/b>錛屼互鎸℃埅娓告垙鏈嶅姟鍣ㄤ紶鏉ョ殑緗戠粶鏁版嵁鍖呭茍灝嗘暟鎹寘淇敼鍚庡皝鍖呭悗浼犵粰娓告垙鏈嶅姟鍣ㄣ傚彟澶栵紝榪樻湁璁稿澶栨寕浣跨敤瀵?b>娓告垙瀹㈡埛绔▼搴忓唴瀛樻暟鎹慨鏀?b>鎶鏈?/b>浠ュ強(qiáng)娓告垙鍔犻?b>鎶鏈?/b>銆?br />
銆銆鏈枃涓昏鏄拡瀵瑰紑鍙?b>娓告垙澶栨寕紼嬪簭鍚庢湡浣跨敤鐨勭▼搴忓紑鍙?b>鎶鏈?/b>榪涜鎺㈣錛岄噸鐐逛粙緇嶇殑濡備笅鍑犵鍦?b>娓告垙澶栨寕涓父浣跨敤鐨勭▼搴忓紑鍙?b>鎶鏈?/b>錛?br />
銆銆鈼?鍔ㄤ綔妯℃嫙鎶鏈?/b>錛氫富瑕佸寘鎷敭鐩樻ā鎷?b>鎶鏈?/b>鍜岄紶鏍囨ā鎷?b>鎶鏈?/b>銆?br />
銆銆鈼?灝佸寘鎶鏈?/b>錛氫富瑕佸寘鎷尅鎴猄ock鎶鏈?/b>鍜屾尅鎴狝PI鎶鏈?/b>銆?br />
鍥涖佸姩浣滄ā鎷?b>鎶鏈?/b>
銆銆鎴戜滑鍦ㄥ墠闈粙緇嶈繃錛屽嚑涔庢墍鏈夌殑娓告垙閮芥湁澶ч噺綣佺悙鍜屾棤鑱婄殑鏀誨嚮鍔ㄤ綔浠ュ鍔犵帺瀹剁殑鍔熷姏錛岃繕鏈夐偅浜涙暟涓嶅畬鐨勮糠瀹紝榪欎簺濂藉儚宸茬粡鎴愪負(fù)浜嗚鑹?b>娓告垙鐨勪唬鍚嶈瘝銆傜幇鍦紝澶栨寕鍙互甯姪鐜╁浠庤繖浜涚箒鐞愯屾棤鑱婄殑宸ヤ綔涓憜鑴卞嚭鏉ワ紝涓撴敞浜?b>娓告垙鎯呰妭鐨勮繘灞曘傚鎸傜▼搴忎負(fù)浜嗗疄鐜拌嚜鍔ㄨ鑹蹭綅緗Щ鍔ㄥ拰鑷姩鏀誨嚮絳夊姛鑳斤紝闇瑕佷嬌鐢ㄥ埌閿洏妯℃嫙鎶鏈?/b>鍜岄紶鏍囨ā鎷?b>鎶鏈?/b>銆備笅闈㈡垜浠皢閲嶇偣浠嬬粛榪欎簺鎶鏈?/b>騫剁紪鍐欎竴涓畝鍗曠殑瀹炰緥甯姪璇昏呯悊瑙e姩浣滄ā鎷?b>鎶鏈?/b>鐨勫疄鐜拌繃紼嬨?br />
銆銆錛戯紟 榧犳爣妯℃嫙鎶鏈?/b>
銆銆
銆銆鍑犱箮鎵鏈夌殑娓告垙涓兘浣跨敤浜嗛紶鏍囨潵鏀瑰彉瑙掕壊鐨勪綅緗拰鏂瑰悜錛岀帺瀹朵粎鐢ㄤ竴涓皬灝忕殑榧犳爣錛屽氨鍙互浣胯鑹茬晠娓稿ぉ涓嬨傞偅涔堬紝鎴戜滑濡備綍瀹炵幇鍦ㄦ病鏈夌帺瀹剁殑鍙備笌涓嬭鑹蹭篃鍙互鑷姩琛岃蛋鍛€傚叾瀹炲疄鐜拌繖涓茍涓嶉毦錛屼粎浠呭嚑涓?b>Windows API鍑芥暟灝卞彲浠ユ悶瀹氾紝璁╂垜浠厛鏉ヨ璇嗚璇嗚繖浜汚PI鍑芥暟銆?br />
銆銆(1) 妯℃嫙榧犳爣鍔ㄤ綔API鍑芥暟mouse_event錛屽畠鍙互瀹炵幇妯℃嫙榧犳爣鎸変笅鍜屾斁寮絳夊姩浣溿?br />
銆銆銆銆VOID mouse_event(
銆銆銆銆銆銆DWORD dwFlags, // 榧犳爣鍔ㄤ綔鏍囪瘑銆?br />銆銆銆銆銆銆DWORD dx, // 榧犳爣姘村鉤鏂瑰悜浣嶇疆銆?br />銆銆銆銆銆銆DWORD dy, // 榧犳爣鍨傜洿鏂瑰悜浣嶇疆銆?br />銆銆銆銆銆銆DWORD dwData, // 榧犳爣杞瓙杞姩鐨勬暟閲忋?br />銆銆銆銆銆銆DWORD dwExtraInfo // 涓涓叧鑱旈紶鏍囧姩浣滆緟鍔犱俊鎭?br />銆銆銆銆);
銆銆鍏朵腑錛宒wFlags琛ㄧず浜嗗悇縐嶅悇鏍風(fēng)殑榧犳爣鍔ㄤ綔鍜岀偣鍑?yán)L椿鍔紝瀹冪殑甯哥敤鍙栧煎涓嬶細(xì)
銆銆銆MOUSEEVENTF_MOVE銆琛ㄧず妯℃嫙榧犳爣縐誨姩浜嬩歡銆?br />
銆銆銆MOUSEEVENTF_LEFTDOWN 琛ㄧず妯℃嫙鎸変笅榧犳爣宸﹂敭銆?br />
銆銆銆MOUSEEVENTF_LEFTUP 琛ㄧず妯℃嫙鏀懼紑榧犳爣宸﹂敭銆?br />
銆銆銆MOUSEEVENTF_RIGHTDOWN 琛ㄧず妯℃嫙鎸変笅榧犳爣鍙抽敭銆?br />
銆銆銆MOUSEEVENTF_RIGHTUP 琛ㄧず妯℃嫙鏀懼紑榧犳爣鍙抽敭銆?br />
銆銆銆MOUSEEVENTF_MIDDLEDOWN 琛ㄧず妯℃嫙鎸変笅榧犳爣涓敭銆?br />
銆銆銆MOUSEEVENTF_MIDDLEUP 琛ㄧず妯℃嫙鏀懼紑榧犳爣涓敭銆?br />
銆銆(2)銆佽緗拰鑾峰彇褰撳墠榧犳爣浣嶇疆鐨凙PI鍑芥暟銆傝幏鍙栧綋鍓嶉紶鏍囦綅緗嬌鐢℅etCursorPos()鍑芥暟錛岃緗綋鍓嶉紶鏍囦綅緗嬌鐢⊿etCursorPos()鍑芥暟銆?br />
銆銆銆銆BOOL GetCursorPos(
銆銆銆銆銆LPPOINT銆lpPoint // 榪斿洖榧犳爣鐨勫綋鍓嶄綅緗?br />銆銆銆銆);
銆銆銆銆BOOL SetCursorPos(
銆銆銆銆int X, // 榧犳爣鐨勬按騫蟲柟鍚戜綅緗?br />銆銆銆銆銆銆int Y //榧犳爣鐨勫瀭鐩存柟鍚戜綅緗?br />銆銆銆銆);
銆銆閫氬父娓告垙瑙掕壊鐨勮璧伴兘鏄氳繃榧犳爣縐誨姩鑷崇洰鐨勫湴錛岀劧鍚庢寜涓涓嬮紶鏍囩殑鎸夐挳灝辨悶瀹氫簡銆備笅闈㈡垜浠嬌鐢ㄤ笂闈粙緇嶇殑API鍑芥暟鏉ユā鎷熻鑹茶璧拌繃紼嬨?br />
銆銆銆CPoint oldPoint,newPoint;
銆銆銆GetCursorPos(&oldPoint); //淇濆瓨褰撳墠榧犳爣浣嶇疆銆?br />銆銆銆newPoint.x = oldPoint.x+40;
銆銆銆newPoint.y = oldPoint.y+10;
銆銆銆SetCursorPos(newPoint.x,newPoint.y); //璁劇疆鐩殑鍦頒綅緗?br />銆銆銆mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);//妯℃嫙鎸変笅榧犳爣鍙抽敭銆?br />銆銆銆mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);//妯℃嫙鏀懼紑榧犳爣鍙抽敭銆?
銆銆2錛?閿洏妯℃嫙鎶鏈?/b>
銆銆鍦ㄥ緢澶?b>娓告垙涓紝涓嶄粎鎻愪緵浜嗛紶鏍囩殑鎿嶄綔錛岃屼笖榪樻彁渚涗簡閿洏鐨勬搷浣滐紝鍦ㄥ鏀誨嚮瀵硅薄榪涜鏀誨嚮鏃惰繕鍙互浣跨敤蹇嵎閿備負(fù)浜嗕嬌榪欎簺鏀誨嚮榪囩▼鑳藉鑷姩榪涜錛屽鎸傜▼搴忛渶瑕佷嬌鐢ㄩ敭鐩樻ā鎷?b>鎶鏈?/b>銆傚儚榧犳爣妯℃嫙鎶鏈?/b>涓鏍鳳紝Windows API涔熸彁渚涗簡涓緋誨垪API鍑芥暟鏉ュ畬鎴愬閿洏鍔ㄤ綔鐨勬ā鎷熴?br />
銆銆妯℃嫙閿洏鍔ㄤ綔API鍑芥暟keydb_event錛屽畠鍙互妯℃嫙瀵歸敭鐩樹笂鐨勬煇涓垨鏌愪簺閿繘琛屾寜涓嬫垨鏀懼紑鐨勫姩浣溿?br />
銆銆銆VOID keybd_event(
銆銆銆銆銆BYTE bVk, // 铏氭嫙閿箋?br />銆銆銆銆銆BYTE bScan, // 紜歡鎵弿鐮併?br />銆銆銆銆銆DWORD dwFlags, // 鍔ㄤ綔鏍囪瘑銆?br />銆銆銆銆銆DWORD dwExtraInfo // 涓庨敭鐩樺姩浣滃叧鑱旂殑杈呭姞淇℃伅銆?br />銆銆銆);
銆銆鍏朵腑錛宐Vk琛ㄧず铏氭嫙閿鹼紝鍏跺疄瀹冩槸涓涓狟YTE綾誨瀷鍊肩殑瀹忥紝鍏跺彇鍊艱寖鍥翠負(fù)1-254銆傛湁鍏寵櫄鎷熼敭鍊艱〃璇峰湪MSDN涓婁嬌鐢ㄥ叧閿瓧鈥淰irtual-Key Codes鈥濇煡鎵劇浉鍏寵祫鏂欍俠Scan琛ㄧず褰撻敭鐩樹笂鏌愰敭琚寜涓嬪拰鏀懼紑鏃訛紝閿洏緋葷粺紜歡浜х敓鐨勬壂鎻忕爜錛屾垜浠彲浠apVirtualKey()鍑芥暟鍦ㄨ櫄鎷熼敭鍊間笌鎵弿鐮佷箣闂磋繘琛岃漿鎹€俤wFlags琛ㄧず鍚勭鍚勬牱鐨勯敭鐩樺姩浣滐紝瀹冩湁涓ょ鍙栧鹼細(xì)KEYEVENTF_EXTENDEDKEY鍜孠EYEVENTF_KEYUP銆?br />
銆銆涓嬮潰鎴戜滑浣跨敤涓孌典唬鐮佸疄鐜板湪娓告垙涓寜涓婼hift+R蹇嵎閿鏀誨嚮瀵硅薄榪涜鏀誨嚮銆?br />
銆銆銆keybd_event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),0,0); //鎸変笅CTRL閿?br />銆銆銆keybd_event(0x52,MapVirtualKey(0x52,0),0,0);//閿笅R閿?br />銆銆銆keybd_event(0x52,MapVirtualKey(0x52,0), KEYEVENTF_KEYUP,0);//鏀懼紑R閿?br />銆銆銆keybd_event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),
銆銆銆KEYEVENTF_KEYUP,0);//鏀懼紑CTRL閿?
銆銆3錛?嬋媧誨鎸?br />
銆銆涓婇潰浠嬬粛鐨勯紶鏍囧拰閿洏妯℃嫙鎶鏈?/b>瀹炵幇浜嗗娓告垙瑙掕壊鐨勫姩浣滈儴鍒嗙殑妯℃嫙錛屼絾瑕佹兂澶栨寕鑳藉伐浣滀簬娓告垙涔嬩笂錛岃繕闇瑕佸皢鍏朵笌娓告垙鐨勫満鏅獥鍙h仈緋昏搗鏉ユ垨鑰呬嬌鐢ㄤ竴涓縺媧婚敭錛屽氨璞℃寜閿簿鐏電殑閭d釜嬋媧婚敭涓鏍楓傛垜浠彲浠ョ敤GetWindow鍑芥暟鏉ユ灇涓劇獥鍙o紝涔熷彲浠ョ敤Findwindow鍑芥暟鏉ユ煡鎵劇壒瀹氱殑紿楀彛銆傚彟澶栬繕鏈変竴涓狥indWindowEx鍑芥暟鍙互鎵懼埌紿楀彛鐨勫瓙紿楀彛錛屽綋娓告垙鍒囨崲鍦烘櫙鐨勬椂鍊欐垜浠彲浠ョ敤FindWindowEx鏉ョ‘瀹氫竴浜涘綋鍓嶇獥鍙g殑鐗瑰緛錛屼粠鑰屽垽鏂槸鍚﹁繕鍦ㄨ繖涓満鏅紝鏂規(guī)硶寰堝浜嗭紝姣斿鍙互GetWindowInfo鏉ョ‘瀹氫竴浜涗笢瑗匡紝姣斿褰撴煡鎵句笉鍒版煇涓寜閽殑鏃跺欏氨璇存槑娓告垙鍦烘櫙宸茬粡鍒囨崲浜嗙瓑絳夊姙娉曘傚綋浣跨敤嬋媧婚敭榪涜鍏寵仈錛岄渶瑕佷嬌鐢℉ook鎶鏈?/b>寮鍙戜竴涓叏灞閿洏閽╁瓙錛屽湪榪欓噷灝變笉鍏蜂綋浠嬬粛鍏ㄥ眬閽╁瓙鐨勫紑鍙戣繃紼嬩簡錛屽湪鍚庨潰鐨勫疄渚嬩腑鎴戜滑灝嗕細(xì)浣跨敤鍒板叏灞閽╁瓙錛屽埌鏃跺皢瀛︿範(fàn)鍒板叏灞閽╁瓙鐨勭浉鍏崇煡璇嗐?br />
銆銆4錛?瀹炰緥瀹炵幇
銆銆閫氳繃涓婇潰鐨勫涔?fàn)锛屾垜浠凡缁忓熀鏈叿澶囦簡缂栧啓鍔ㄤ綔寮?b>娓告垙澶栨寕鐨勮兘鍔涗簡銆備笅闈㈡垜浠皢鍒涘緩涓涓敾絎旂▼搴忓鎸傦紝瀹冨疄鐜拌嚜鍔ㄧЩ鍔ㄧ敾絎斿瓧鍏夋爣鐨勪綅緗茍鍐欎笅涓涓孩鑹茬殑鈥淩鈥濆瓧銆備互榪欎釜瀹炰緥涓哄熀紜錛屽姞鍏ョ浉搴旂殑娓告垙鍔ㄤ綔瑙勫垯錛屽氨鍙互瀹炵幇涓涓畬鏁寸殑娓告垙澶栨寕銆傝繖閲屼綔鑰呬笉鎯充嬌鐢ㄦ煇涓?b>娓告垙浣滀負(fù)渚嬪瓙鏉ュ紑鍙戝鎸傦紙鍥犳病鏈?b>娓告垙鍟嗗鐨勬巿鏉冨晩錛侊級錛屽璇昏呮劅鍏磋叮鐨勮瘽鍙互鎵句竴涓?b>娓告垙璇曡瘯錛屾渶濂戒粎鍋氭祴璇?b>鎶鏈?/b>鐢ㄣ?br />
銆銆棣栧厛錛屾垜浠渶瑕佺紪鍐欎竴涓叏灞閽╁瓙錛屼嬌鐢ㄥ畠鏉ユ縺媧誨鎸傦紝嬋媧婚敭涓篎10銆傚垱寤哄叏灞閽╁瓙姝ラ濡備笅錛?br />
銆銆(1)錛庨夋嫨MFC AppWizard(DLL)鍒涘緩欏圭洰ActiveKey錛屽茍閫夋嫨MFC Extension DLL錛堝叡浜玀FC鎷瘋礉錛夌被鍨嬨?br />
銆銆(2).鎻掑叆鏂版枃浠禔ctiveKey.h錛屽湪鍏朵腑杈撳叆濡備笅浠g爜錛?br />
銆銆銆#ifndef _KEYDLL_H
銆銆銆#define _KEYDLL_H
銆銆銆class AFX_EXT_CLASS CKeyHook:public CObject
銆銆銆{
銆銆銆銆public:
銆CKeyHook();
銆~CKeyHook();
銆HHOOK Start();銆//瀹夎閽╁瓙
銆BOOL Stop(); //鍗歌澆閽╁瓙
銆銆銆};
銆銆銆#endif
銆銆(3).鍦ˋctiveKey.cpp鏂囦歡涓姞鍏ュ0鏄庯紓#include ActiveKey.h錛傘?br />
銆銆(4).鍦ˋctiveKey.cpp鏂囦歡涓姞鍏ュ叡浜暟鎹錛屼唬鐮佸涓嬶細(xì)
銆銆銆//Shared data section
銆銆銆#pragma data_seg("sharedata")
銆銆銆HHOOK glhHook=NULL; //閽╁瓙鍙ユ焺銆?br />銆銆銆HINSTANCE glhInstance=NULL; //DLL瀹炰緥鍙ユ焺銆?br />銆銆銆#pragma data_seg()
銆銆(5).鍦ˋctiveKey.def鏂囦歡涓緗叡浜暟鎹灞炴э紝浠g爜濡備笅錛?br />
銆銆銆SETCTIONS
銆銆銆shareddata READ WRITE SHARED
銆銆(6).鍦ˋctiveKey.cpp鏂囦歡涓姞鍏keyHook綾葷殑瀹炵幇浠g爜鍜岄挬瀛愬嚱鏁頒唬鐮侊細(xì)
銆銆銆//閿洏閽╁瓙澶勭悊鍑芥暟銆?br />銆銆銆extern "C" LRESULT WINAPI KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
銆銆銆{
銆銆銆if( nCode >= 0 )
銆銆銆{
銆銆銆if( wParam == 0X79 )//褰撴寜涓婩10閿椂錛屾縺媧誨鎸傘?br />銆{
銆銆//澶栨寕瀹炵幇浠g爜銆?br />CPoint newPoint,oldPoint;
銆銆 GetCursorPos(&oldPoint);
銆銆 newPoint.x = oldPoint.x+40;
銆銆 newPoint.y = oldPoint.y+10;
銆銆 SetCursorPos(newPoint.x,newPoint.y);
銆銆 mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);//妯℃嫙鎸変笅榧犳爣宸﹂敭銆?br />銆銆mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);//妯℃嫙鏀懼紑榧犳爣宸﹂敭銆?br />銆銆keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),0,0); //鎸変笅SHIFT閿?br />銆銆keybd_event(0x52,MapVirtualKey(0x52,0),0,0);//鎸変笅R閿?br />銆銆keybd_event(0x52,MapVirtualKey(0x52,0),KEYEVENTF_KEYUP,0);//鏀懼紑R閿?br />銆銆keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),KEYEVENTF_KEYUP,0);//鏀懼紑SHIFT閿?br />銆銆銆銆銆銆SetCursorPos(oldPoint.x,oldPoint.y);
銆}
銆銆銆}
銆銆銆return CallNextHookEx(glhHook,nCode,wParam,lParam);
銆銆銆}
銆銆銆CKeyHook::CKeyHook(){}
銆銆銆CKeyHook::~CKeyHook()
銆銆銆{銆
銆銆銆if( glhHook )
Stop();
銆銆銆}
銆銆銆//瀹夎鍏ㄥ眬閽╁瓙銆?br />銆銆銆HHOOK CKeyHook::Start()
銆銆銆{
glhHook = SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,glhInstance,0);//璁劇疆閿洏閽╁瓙銆?br />return glhHook;
}
銆銆銆//鍗歌澆鍏ㄥ眬閽╁瓙銆?br />銆銆銆BOOL CKeyHook::Stop()
銆銆銆{
銆銆銆BOOL bResult = TRUE;
銆if( glhHook )
銆銆銆bResult = UnhookWindowsHookEx(glhHook);//鍗歌澆閿洏閽╁瓙銆?br />銆銆銆return bResult;
銆銆銆}
銆銆(7).淇敼DllMain鍑芥暟錛屼唬鐮佸涓嬶細(xì)
銆銆銆extern "C" int APIENTRY
銆銆銆DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
銆銆銆{
//濡傛灉浣跨敤lpReserved鍙傛暟鍒欏垹闄や笅闈㈣繖琛?
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
銆銆TRACE0("NOtePadHOOK.DLL Initializing!\n");
銆銆 //鎵╁睍DLL浠呭垵濮嬪寲涓嬈?
銆銆if (!AfxInitExtensionModule(ActiveKeyDLL, hInstance))
return 0;
銆銆new CDynLinkLibrary(ActiveKeyDLL);
銆銆銆銆銆銆//鎶奃LL鍔犲叆鍔ㄦ丮FC綾誨簱涓?
銆銆glhInstance = hInstance;
銆銆//鎻掑叆淇濆瓨DLL瀹炰緥鍙ユ焺
}
else if (dwReason == DLL_PROCESS_DETACH)
{
銆銆TRACE0("NotePadHOOK.DLL Terminating!\n");
銆銆//緇堟榪欎釜閾炬帴搴撳墠璋冪敤瀹?
銆銆AfxTermExtensionModule(ActiveKeyDLL);
}
return 1;
銆銆銆}
銆銆(8).緙栬瘧欏圭洰ActiveKey錛岀敓鎴怉ctiveKey.DLL鍜孉ctiveKey.lib銆?br />
銆銆鎺ョ潃錛屾垜浠繕闇瑕佸垱寤轟竴涓澹崇▼搴忓皢鍏ㄥ眬閽╁瓙瀹夎浜?b>Windows緋葷粺涓紝榪欎釜澶栧3紼嬪簭緙栧啓姝ラ濡備笅錛?br />
銆銆(1).鍒涘緩涓涓璇濇妯″紡鐨勫簲鐢ㄧ▼搴忥紝欏圭洰鍚嶄負(fù)Simulate銆?br />
銆銆(2).鍦ㄤ富瀵硅瘽妗嗕腑鍔犲叆涓涓寜閽紝浣跨敤ClassWizard涓哄叾鍒涘緩CLICK浜嬩歡銆?br />
銆銆(3).灝咥ctiveKey欏圭洰Debug鐩綍涓嬬殑ActiveKey.DLL鍜孉ctiveKey.lib鎷瘋礉鍒癝imulate欏圭洰鐩綍涓嬨?br />
銆銆(4).浠庘滃伐紼嬧濊彍鍗曚腑閫夋嫨鈥滆緗濓紝寮瑰嚭Project Setting瀵硅瘽妗嗭紝閫夋嫨Link鏍囩錛屽湪鈥滃璞?搴撴ā鍧椻濅腑杈撳叆ActiveKey.lib銆?br />
銆銆(5).灝咥ctiveKey欏圭洰涓殑ActiveKey.h澶存枃浠跺姞鍏ュ埌Simulate欏圭洰涓紝騫跺湪Stdafx.h涓姞鍏?include ActiveKey.h銆?br />
銆銆(6).鍦ㄦ寜閽崟鍑諱簨浠跺嚱鏁拌緭鍏ュ涓嬩唬鐮侊細(xì)
銆銆銆void CSimulateDlg::OnButton1()
銆銆銆{
// TODO: Add your control notification handler code here
if( !bSetup )
{
m_hook.Start();//嬋媧誨叏灞閽╁瓙銆?br />}
else
{
m_hook.Stop();//鎾ゆ秷鍏ㄥ眬閽╁瓙銆?br />}
bSetup = !bSetup;
銆銆銆}
銆銆(7).緙栬瘧欏圭洰錛屽茍榪愯紼嬪簭錛屽崟鍑?yán)L寜閽縺媧誨鎸傘?br />
銆銆(8).鍚姩鐢葷瑪紼嬪簭錛岄夋嫨鏂囨湰宸ュ叿騫跺皢絎旂殑棰滆壊璁劇疆涓虹孩鑹詫紝灝嗛紶鏍囨斁鍦ㄤ換鎰忎綅緗悗錛屾寜F10閿紝鐢葷瑪紼嬪簭鑷姩縐誨姩榧犳爣騫跺啓涓嬩竴涓孩鑹茬殑澶у啓R銆傚浘涓灞曠ず浜嗘寜F10閿墠鐨勭敾絎旂▼搴忕殑鐘舵侊紝鍥句簩灞曠ず浜嗘寜F10閿悗鐨勭敾絎旂▼搴忕殑鐘舵併?br />
鍥句竴錛氭寜F10鍓嶇姸鎬?001.jpg)
鍥句簩錛氭寜F10鍚庣姸鎬?002.jpg)
]]>