锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
BHO鍏寵仈鍘熺悊 (BHO鍏寵仈鐨勬槸SHDOCVW,涔熷氨鏄涓嶅彧鍏寵仈IE,涓嬮潰鍏ㄩ儴鐢↖E鏉ヨ鏄?
1.IE鐨勭獥鍙f墦寮鏃?鍏堝鎵綡KLM涓嬬殑SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\ 閲岀殑CLSID,榪欎簺CLSID,閮藉搴旂潃鐩稿簲鐨凚HO鎻掍歡錛岀劧鍚庢牴鎹繖涓狢LSID鍒癏KCR涓嬬殑CLSIDs閲屾壘鍒版鎻掍歡鐨勪俊鎭紝鍖呮嫭鏂囦歡浣嶇疆絳夈?br>2.IE鏍規(guī)嵁鎵懼埌鐨凜LSID淇℃伅鍒涘緩 BHO 瀵硅薄,騫朵笖鏌ユ壘 IObjectWithSite 鎺ュ彛. (榪欎釜鎺ュ彛闈炲父綆鍗?鍙湁SetSite鍜孏etSite涓や釜鏂規(guī)硶)
3.IE鎶奍WebBrowser2(嫻忚鍣ㄦ彃浠?浼犲埌 BHO 鐨?SetSite 鏂規(guī)硶錛岀敤鎴峰湪姝ゆ柟娉曚腑鍙寕杞借嚜宸辯殑浜嬩歡澶勭悊鏂規(guī)硶銆?br>4.紿楀彛鍏抽棴鏃?IE鎶?null 浼犲埌 BHO 鐨?SetSite 鏂規(guī)硶錛屾鏂規(guī)硶鐢ㄦ潵鍘繪帀鎸傝澆鐨勪簨浠跺鐞嗘柟娉曘?/p>
緙栧啓BHO嫻佺▼
1.鍒涘緩IObjectWithSite鏄懼紡鎺ュ彛錛屽垱寤?COM 綾誨瀷錛屽疄鐜扮戶鎵縄ObjectWithSite鎺ュ彛
2.瀹炵幇姝ゆ帴鍙e茍鍦⊿etSite鏂規(guī)硶閲屽姞涓婃墍瑕佹寕杞界殑浜嬩歡
3.澶勭悊浜嬩歡
4.娉ㄥ唽姝HO鍒版敞鍐岃〃涓璈KLM涓嬬殑Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects;(HKCR涓嬬殑CLSIDs鏄牴鎹笂闈㈢殑璺緞鑷姩娉ㄥ唽鐨?
5銆?net 涓嬮』璁劇疆姝HO欏圭洰鐨?閰嶇疆灞炴>鐢熸垚 涓負Interop娉ㄥ唽涓篢rue錛岃繖鏍鋒墠鑳藉皢.net 綾誨簱鏂囦歡娉ㄥ唽鍒癈OM
鍒犻櫎BHO
鎵撳紑娉ㄥ唽琛ㄩ」鍒?HKLM涓嬬殑Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects 鍙互鐪嬪埌涓嬮潰鏈変竴浜汣LSID鍊?榪欎簺鍊煎搴旂浉鍏崇殑鎻掍歡,鐐瑰嚮鍙互鍦ㄩ粯璁ゅ煎悗鐪嬪埌鐩稿叧鎻掍歡鐨勫悕縐?鍙互澶嶅埗鐩稿叧CLSID鍒版敞鍐岃〃涓悳绱㈢浉鍏矯LSID,鎵懼埌鍚庢墦寮InprocServer32鍙互鐪嬪埌鐩稿叧鏂囦歡鐨勮礬寰?鑷充簬DLL鏂囦歡絳夊彲浠ョ敤UEDIT32.exe宸ュ叿鎵撳紑鏌ョ湅鍏蜂綋淇℃伅,褰撶劧涔熷彲浠ョ敤淇敼紼嬪簭綾葷殑eXeScope.exe鐮旂┒涓涓?
璇鋒牴鎹叿浣撴儏鍐靛垹闄ょ浉鍏抽敭鍊煎拰鐩稿叧鏂囦歡!
REF:
BHO 鐨勭紪鍐?nbsp;
VCKBase 鍏充簬IE 緙栫▼鏂囨。涓績
C++涓嬌鐢˙HO鏉ュ睆钄界壒瀹氱綉绔?/a>
嫻忚鍣ㄩ泦鎴愭暀瀛?鑷畾涔夋祻瑙堝櫒
褰撶敤IE 鎵撳紑榪欎釜欏甸潰鐨勬椂鍊? IE 棣栧厛鏍規(guī)嵁 classid 鍦ㄦ敞鍐岃〃涓?HKEY_CLASS_ROOT)鏌ユ壘鍏跺畨瑁呬俊鎭? 濡傛灉鏈壘鍒? 鍒橧E 鏍規(guī)嵁codebase 鍘葷湅鏄惁鏈夊搴旂殑鎺т歡瀛樺湪; 濡傛灉榪樻槸涓嶈, 鍒欎細涓浜涙帶浠舵敞鍐屾湇鍔″櫒鑱旂郴(鍒楄〃鍦?HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\CodeBaseSearchPath 鍙互鎵懼埌 ), 涓鑸槸 http://activex.microsoft.com/objects/ocget.dll , http://codecs.microsoft.com/isapi/ocget.dll , 鐒跺悗鏈嶅姟鍣ㄤ細鍛婅瘔IE 浠庡摢閲屽幓涓嬭澆.
FROM : http://oreilly.com/catalog/malmobcode/chapter/ch11.html
2. ActiveX 鎺т歡鏄浣曞惎鍔ㄧ殑
鍒涘緩涓涓帶浠舵湁寰堝縐嶆柟娉?
CoCreateInstance, CoGetInstanceFromFile, CoGetInstanceFromIStorage
CoCreateInstanceEx
CoGetClassObjectFromURL , CoGetClassObject
CoGetObject, DllGetClassObject 絳?
鍩烘湰璋冪敤欏哄簭濂藉儚鏄?
(CoGetInstanceFromFile, CoGetInstanceFromIStorage ) -> CoCreateInstance
CoCreateInstanceEx
CoGetClassObjectFromURL -> CoGetClassObject
鍏朵粬娌℃湁嫻嬭瘯榪?.. :9
IE 鍒涘緩鎺т歡鐨勬椂鍊欎細璋冪敤 CoGetClassObjectFromURL -> CoGetClassObject 鐨勯『搴忚繘琛? 鑰屼笉鏄洿鎺ヨ皟鐢?CoCreateInstance 鎴栬?CoCreateInstanceEx) , 浣嗘槸鍏嶄笉浜嗘帶浠朵細鑷繁璋冪敤 CoCreateInstanceEx, 姣斿Real 鎺т歡鍦ㄥ垱寤虹殑鏃跺欎細璋冪敤Dx 鐨勭粍浠剁瓑.
iframe 璺ㄥ煙璁塊棶(cross frame) zz from : http://codecentrix.blogspot.com/2007/10/when-ihtmlwindow2getdocument-returns.html
鐢變簬瀹夊叏鎬ч檺鍒? 涓洪槻姝㈣法鍩熻剼鏈敾鍑? 褰揻rames 璺ㄥ煙鐨勬椂鍊? IHTMLWindow2::get_document 璋冪敤灝嗚繑鍥?E_ACCESSDENIED .
涓嬮潰鍑芥暟 HtmlWindowToHtmlDocument 瀵逛簬璺ㄥ煙鐨刦rame 閫氳繃 IHTMLWindow2 -> IID_IWebBrowserApp -> IHTMLWindow2 緇曡繃浜嗛檺鍒?
== 棰勫鐞嗘搷浣滅(Preprocessor Operators) ==
Stringizing operator (#)
Causes the corresponding actual argument to be enclosed in double quotation marks
灝嗗弬鏁板彉鎴愬瓧絎︿覆 : #x -> "x"
Charizing operator (#@)
Causes the corresponding argument to be enclosed in single quotation marks and to be treated as a character (Microsoft Specific)
灝嗗弬鏁板彉鎴愬瓧絎﹀彉閲?: #x -> 'x'
Token-pasting operator (##)
Allows tokens used as actual arguments to be concatenated to form other tokens
灝嗗弬鏁板拰鍓嶉潰鐨勭鍙風粨鍚?: token##x -> tokenx
== 棰勫畾涔夊畯(Predefined Macros) ==
__FILE__
__LINE__
#define LINE1(x) #x
#define LINE(x) LINE1(x)
#define TODO(msg) message ( __FILE__ "(" LINE(__LINE__) "): [TODO] " #msg )
#define NOTE(msg) message ( __FILE__ "(" LINE(__LINE__) "): [NOTE] " #msg )
闆嗘垚嫻忚鍣ㄦ帶浠剁殑鏈綆鍗曠殑鏂規(guī)硶鏄壘涓涓敮鎸丄ctiveX鐨勯泦鎴愬紑鍙戠幆澧冿紝鍦ㄥ伐鍏風涓姞鍏icrosoft Web Browser榪欎釜鎺т歡錛屽線琛ㄥ崟涓婃嫋涓涓繖涓帶浠跺氨鍙互瀹屾垚宸ヤ綔銆備綘鐢氳嚦鍙互鐢ㄩ泦鎴愬紑鍙戠幆澧冩坊鍔燗ctiveX鐨勪簨浠跺鐞嗗嚱鏁般傚鏋滆鐩存帴瀵煎叆ActiveX鐨勮瘽錛屽緩璁嬌鐢╩ehrcpp鐨剉bMHWB鎺т歡錛?a >http://www.codeproject.com/atl/vbmhwb.asp錛夈傝繖涓帶浠跺湪嫻忚鍣ㄦ帶浠剁殑鍩虹涓婅繘琛屼簡鎵╁睍錛屾毚闇蹭簡寰堝搴曞眰鎺ュ彛銆?/p>
閫氬父瀵煎叆ActiveX灝卞彲浠ユ弧瓚沖ぇ閮ㄥ垎闇姹?nbsp; 錛屼絾鏄湁浜涚被搴撲腑涔熼泦鎴愪簡嫻忚鍣ㄦ帶浠訛紝騫朵笖鎻愪緵浜嗘洿澶氱殑鍔熻兘錛屼緥濡侻FC鐨凜HTMLView鍜孋DHtmlDialog錛孉TL鐨凥TML Control錛屼互鍙?Net 2.0涓殑Windows.Forms.WebBrowser銆傚鏋滀嬌鐢╒isual C++鏉ヨ繘琛岄潪鎵樼緙栫▼錛岄偅涔堝緩璁嬌鐢∕FC鎴栬匒TL鐨勫皝瑁呯被錛屾垨鑰呬嬌鐢╲bMHWB鎺т歡銆傛墭綆$紪紼嬩腑褰撶劧棣栭塛indows.Forms.WebBrowser銆傞櫎闈炶繖浜涚被鐨凚UG褰卞搷鍒頒簡搴旂敤紼嬪簭鐨勫紑鍙戯紝鍚﹀垯寤鴻浣跨敤榪欎簺鍔熻兘鏇村姞寮哄ぇ鐨勫皝瑁呯被銆?/p>
鍦ㄤ嬌鐢ㄦ祻瑙堝櫒鎺т歡鍙婂叾灝佽綾葷殑鏃跺欒娉ㄦ剰涓浜涘凡鐭ラ棶棰?/p>
鍦ㄩ泦鎴愭祻瑙堝櫒鎺т歡涔嬪悗錛屽彲浠ュ畬鎴愬熀鏈殑緗戦〉嫻忚錛屼絾鏄浜庝笉鍚岀殑浠誨姟錛屼篃闇瑕佽繘涓姝ョ殑澶勭悊錛屼緥濡傝緗帶浠剁殑灞炴с佷負鎺т歡娣誨姞浜嬩歡澶勭悊銆佹搷浣淗TML鏂囨。絳夌瓑銆?/p>
榪欏湪闆嗘垚寮鍙戠幆澧冧腑鍙互寰堝鏄撳湴璁劇疆錛屼篃鍙互鑷繁瀹炵幇瀹瑰櫒鏉ヨ緗紝浣嗘槸CHTMLView榪欐牱鐨勫皝瑁呯被娌℃湁榪欎釜閫夐」錛?a >http://support.microsoft.com/kb/197921錛夈?/p>
闆嗘垚寮鍙戠幆澧冧腑鍙互涔熷緢瀹規(guī)槗鍦版坊鍔犳祻瑙堝櫒鐨勪簨浠跺鐞嗗嚱鏁般傛瘮杈冨父鐢ㄧ殑浜嬩歡鍖呮嫭
閫氬父HTML鍒嗘瀽鍜屾祻瑙堝櫒鑷姩鍖栫▼搴忛兘闇瑕佸垎鏋愮綉欏電殑緇撴瀯錛屾壘鍒伴渶瑕佹搷浣滅殑鍏冪礌銆傝繖闇瑕佸緗戦〉鐨勭粨鏋勮繘琛屽垎鏋愶紝鎵懼埌鐩爣鍏冪礌鐨勬爣璇嗘柟娉曘?涓浜涘父鐢ㄧ殑鎿嶄綔鍖呮嫭錛?
鍦ㄩ〉闈㈠寘鍚鏋剁殑鏃跺欙紝鍙兘闇瑕佽法妗嗘灦璁塊棶HTML鏂囨。銆傚彲浠ラ氳繃鏌ヨ妗嗘灦鍏冪礌鎵鏀寔鐨処WebBrowser2鎺ュ彛鎴栬匢HTMLWindow2鎺ュ彛鏉ヨ闂鏋朵腑鐨勬枃。锛http://support.microsoft.com/kb/196340錛夛紝浣嗘槸涔熸湁鍙兘鍥犱負瀹夊叏璁劇疆鑰屾棤娉曡闂?http://support.microsoft.com/kb/167796)銆?/p>
鍦ㄦ祻瑙堝櫒鎺т歡涓樉紺哄叾瀹冪被鍨嬬殑鏂囨。鏃訛紝鍙互鐢↖WebBrowser2鐨刣ocument灞炴ф潵璁塊棶ActiveX鏂囨。錛屼緥濡傚湪鏄劇ずMicrosoft Word鏃訛紝IWebBrowser2鐨刣ocument灞炴у氨鏄疻ord鐨勬枃。瀵硅薄锛屽湪鏄窘C烘枃浠跺す鐨勬椂鍊欙紝IWebBrowser2鐨刣ocument灞炴у氨鏄枃浠跺す瀵硅薄絳夌瓑銆?/p>
嫻忚鍣ㄦ帶浠跺湪鍒涘緩鏃朵細鏌ヨActiveX瀹瑰櫒鐨処OleClientSite鐨勫疄鐜扮殑濡備笅鎺ュ彛錛?strong>IDocHostUIHandler, IDocHostUIHandler2 and IDocHostShowUI銆?/p>
铏界劧鍦ㄦ棤娉曡嚜瀹氫箟ActiveX瀹瑰櫒鐨勬儏鍐典笅鍙互鐢↖CustomDoc::SetUIHandler鏉ユ寕鎺DocHostUIHandler鍒版祻瑙堝櫒鎺т歡錛屼絾鏄繖鏍蜂篃浼氶犳垚鍐呭瓨娉勬紡錛?a >http://support.microsoft.com/kb/893629錛夈備竴浜涚被搴擄紝渚嬪MFC銆丄TL鍜?Net綾誨簱閮藉疄鐜頒簡IDocHostUIHandler鎺ュ彛銆?/p>
闄や簡涓撻棬鐢ㄤ簬嫻忚鍣ㄧ敤閫旂殑紼嬪簭涔嬪錛岄氬父閮介渶瑕佽嚜瀹氫箟嫻忚鍣ㄦ帶浠剁殑涓婁笅鏂囪彍鍗曘傝繖闇瑕佸疄鐜癐DocHostUIHandler::ShowContextMenu銆傞氬父鐨勫疄鐜板寘鎷畬鍏ㄧ鐢ㄤ笂涓嬫枃鑿滃崟銆佸畬鍏ㄦ浛鎹笂涓嬫枃鑿滃崟銆佷互鍙婁慨鏀歸儴鍒嗕笂涓嬫枃鑿滃崟銆傜粡甯歌浠庝笂涓嬫枃鑿滃崟涓Щ闄ょ殑鑿滃崟欏瑰寘鍚煡鐪嬫簮浠g爜銆佸埛鏂板拰灞炴с備竴縐嶆浛浠g殑鏂規(guī)鏄湪瀹瑰櫒涓繃婊ゅ彸閿秷鎭紙http://support.microsoft.com/kb/231578錛夈?/p>
涓庢祻瑙堝櫒鐩告瘮錛屼竴浜汭nternet Explorer鐨勫涓誨姛鑳藉湪嫻忚鍣ㄦ帶浠朵腑騫朵笉鏄粯璁ゅ惎鐢ㄣ傚湪鏌愪簺鍦哄悎錛岄粯璁ゅ惎鐢ㄧ殑瀹夸富鍔熻兘鍙兘騫墮潪棰勬湡銆傝繖鏃墮渶瑕佸疄鐜癐DocHostUIHandler::GetHostInfo銆傚彲浠ラ氳繃瀹炵幇IDocHostUIHandler::GetHostInfo鏉ヨ嚜瀹氫箟鐨勫姛鑳藉寘鎷細
鍦ㄤ嬌鐢ㄦ祻瑙堝櫒鎺т歡鏉ュ仛鏁版嵁褰曞叆鐣岄潰鐨勫満鍚堬紝闇瑕佹洿鏀規(guī)祻瑙堝櫒鎺т歡榛樿鐨凾ab閿鐞嗕嬌寰楃敤鎴峰彲浠ヤ嬌鐢═ab閿垏鎹㈠埌瀹瑰櫒涓殑鍏朵粬鎺т歡銆傝繖闇瑕佸疄鐜癐DocHostUIHandler::TranslateAccelerator鏉ヨ嚜瀹氫箟嫻忚鍣ㄦ帶浠剁殑蹇嵎閿鐞嗐傚浜嶮FC榪欐牱鐢ㄦ秷鎭挬瀛愭潵鍋氭秷鎭澶勭悊鐨勫彲鑷畾涔夊鍣ㄦ潵璇達紝涔熷彲浠ョ敤PreTranslateMessage鏉ヨ繃婊5閿洏娑堟伅錛岃屼笉鏄疄鐜癐DocHostUIHandler::TranslateAccelerator銆?
鍦ㄨ剼鏈腑璋冪敤搴旂敤紼嬪簭瀵規(guī)祻瑙堝櫒鎺т歡鐨勬墿灞曪紝榪欓渶瑕佸疄鐜癐DocHostUIHandler::GetExternal銆備嬌鐢?Net鐨刉ebBrowser鎺т歡鐨勮瘽璁劇疆ObjectForScripting灞炴у氨鍙互浜嗐?/p>
瀵逛簬鐢ㄦ祻瑙堝櫒鎺т歡鏉ュ仛HTML鍒嗘瀽鍣ㄧ殑鍦哄悎鏉ヨ錛屾湁鏃墮渶瑕佸睆钄借剼鏈駭鐢熺殑娑堟伅妗嗐傝繖闇瑕佸疄鐜癐DocHostShowUI::ShowMessage錛屾垨鑰呰緗祻瑙堝櫒鐨凷ilent灞炴с?/p>
鍙﹀錛屾祻瑙堝櫒涔熶細鏌ヨIOleClientSite鏉ヨ幏寰楀叾瀹冪殑鏈嶅姟淇℃伅錛屼緥濡?/p>
瀵逛簬鐢ㄦ祻瑙堝櫒鎺т歡鏉ュ仛HTML鍒嗘瀽鍣ㄧ殑鍦哄悎鏉ヨ錛屾湁鏃墮渶瑕佺鐢ㄦ祻瑙堝櫒鐨勮剼鏈丄ctiveX鎴栬呭浘鐗囦笅杞姐傝繖鍙互閫氳繃鍦ㄥ鍣ㄤ腑瀹炵幇IDispatch錛屽鐞咲ISPID_AMBIENT_DLCONTROL鏉ュ仛鍒幫紙http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/overview/Overview.asp錛夈?/p>
鐪嬫潵紱葷嚎嫻忚鐨勬帶鍒跺茍涓嶈兘鐢ㄨ繖縐嶆柟娉曟潵鎺у埗錛?a >http://support.microsoft.com/kb/247336錛夈備笉榪囦綘鍙互鑷繁緙栧啓涓涓狧TTP灞備紶閫?BINDF_OFFLINEOPERATION鏍囧織 錛?a >http://groups-beta.google.com/group/microsoft.public.inetsdk.programming.mshtml_hosting/msg/76bf4910a289d4b3錛?/p>
鍦ㄦ祻瑙堝櫒鎺т歡涓璲ava灝忕▼搴忓彲鑳戒笉鑳芥甯歌繍琛岋紝濡傛灉浣跨敤Sun JVM1.4涔嬪悗鐨勭増鏈紝鍙互鐢⊿etEnvironmentVariable 鏉ヨ緗甁AVA_PLUGIN_WEBCONTROL_ENABLE涓?鏉ュ惎鐢⊿un JVM銆?/p>
榛樿鎯呭喌涓嬪湪欏甸潰杞藉叆鏃朵細鏈夌偣鍑誨0銆傚睆钄界偣鍑誨0鐨勪竴涓柟娉曟槸鍦ㄧ▼搴忚繍琛屾椂淇敼娉ㄥ唽琛ㄩ敭錛?a >http://support.microsoft.com/kb/201901錛夛紝鍙︿竴涓柟娉曟槸灝嗘祻瑙堝櫒鎺т歡闅愯棌錛屽湪璋冪敤Navigate2涔嬪悗鍐嶆樉紺猴紝浣嗘槸榪欎篃闇瑕侀攣瀹氭帶浠剁殑鏇存柊鍖哄煙錛圠ockWindowUpdate錛変互閬垮厤闂儊銆傚湪IE7涓紝涔熷彲浠ヨ皟鐢?CoInternetSetFeatureEnabled鍑芥暟錛屼紶閫扚EATURE_DISABLE_NAVIGATION_SOUNDS鏉ョ鐢ㄦ祻瑙堟椂鐨勫0闊熾?/p>
鍦ㄩ渶瑕佷嬌鐢ㄤ唬鐞嗘湇鍔″櫒鏃訛紝鏈夊彲鑳介渶瑕佸湪搴旂敤紼嬪簭涓嬌鐢ㄩ潪榛樿鐨勪唬鐞嗘湇鍔″櫒璁劇疆銆傝繖鍙互閫氳繃璋冪敤UrlMkSetSessionOption鏉ュ疄鐜般?br>
Overriding IInternetSecurityManager in a CComControl class
CAxWindow implements IObjectWithSite interface (get it with QueryHost
method). Call SetSite passing your implementation of IServiceProvider.
At this point, AxWin will forward all QueryService calls from hosted
WebBrowser to your implementation.
1. 鏍規(guī)嵁ie 鐥囩姸
褰搃e 璁塊棶鎭舵剰欏甸潰鐨勯伃鍙楁敾鍑繪椂, 鍏墮噸瑕佽〃鐜版槸
a. 鍐呭瓨浣跨敤
b. cpu 浣跨敤鐜?br>鎵浠ュ疄鏃剁洃嫻嬭繖浜涘弬鏁板彲浠ュ熀鏈垽鏂槸鍚︽湁鏀誨嚮
2. 鏍規(guī)嵁琛屼負
shellcode 濡傛灉琚墽琛? 閭d箞鑲畾浼氳繘琛屾湪椹笅杞芥墽琛岀瓑姝ラ. 涓鑸函shellcode 閲岄潰鐨勫唴瀹逛笉浼氬緢澶? 鎵浠ヤ笉鍙兘瀹屾垚寰堝澶嶆潅鐨勬敾鍑?
win32 鍒涘緩榪涚▼鐨凙PI璋冪敤涓叉槸:
WinExec/ShellExecuteA/CreateProcessA->CreateProcessInternalA->CreateProcessInternalW->ZwCreateProcessEx
鎴?br>CreateProcessW->CreateProcessInternalW->ZwCreateProcessEx
win32 瑕佹墽琛屼笅杞界殑API 涓昏鏄痺sock32.dll 鐨?
recv , recvfrom
鎵浠ュ涓婅堪API 榪涜鎷︽埅, 涓鑸彲浠ユ嫻嬪埌鏄惁鏈塱e 鏄惁琚敾鍑? 浣嗘槸榪欎釜鍙兘鍦ㄦ敾鍑繪垚鍔熷悗, shellcode 鎵ц鍚庢墠鑳借媯嫻嬪埌
3.
鎷︽埅涓浜涙搷浣滄敞鍐岃〃, 鍒涘緩紿楀彛絳堿PI , 鍙互鍋氬埌闃叉琚慨鏀逛富欏? 寮瑰嚭紿楀彛絳?
鍒╃敤ms 鐨凞etours 鍙互寰堝鏄撶殑瀹炵幇瀵圭郴緇?API 鐨刪ook
http://blog.csdn.net/hu0406/archive/2008/03/05/2150358.aspx
http://blog.csdn.net/hu0406/archive/2008/03/05/2150351.aspx
http://www.moon-soft.com/doc/2288.htm
http://blog.csdn.net/dedodong/archive/2006/10/07/1323925.aspx
[ [JavaScript涓殑鍫嗛姘碷|[ http://www.team509.com/download/Heap%20Feng%20Shui%20in%20JavaScript_en_cn.htm ] ] ie 鍫嗗柗灝?
[ [涔熻亰inline-hook]|[ http://blog.tom.com/tigerkings941220/article/9211.html ] ] 浠嬬粛浜?榪涚▼鑷韓淇濇姢(閫氳繃鎷︽埅LoadLibraryW)鍜孖E婕忔礊闃叉姢(閫氳繃鎷︽埅CreateProcessInternalW)
[ [maxthon2(閬ㄦ父2) mxsafe.dll瀵圭綉欏墊湪椹殑闃叉姢浠ュ強緇曡繃]|[ http://hi.baidu.com/54nop/blog/item/b52cff6e713964d980cb4a9e.html ] ] 璁ㄨ浜唌axthon2 闃叉緗戦〉鏈ㄩ┈鐨勭瓥鐣? 鎷︽埅 ZwCreateProcessEx/ZwCreateProcess, ZwWriteVirtualMemory, LoadLibraryExW, CreateProcessInternalW )浠ュ強瀵規(guī)姉絳栫暐, 鍏跺疄榪欎釜鍙槸hook & unhook 鐨勬父鎴忎簡..
[ [灝忚PE鐥呮瘨鎶鏈痌|[ http://blog.vckbase.com/windowssky/archive/2007/04/17.html ] ] 浠嬬粛浜?pe 鐥呮瘨 & win32 榪涚▼鍔犺澆鍐呴儴
[ [360瀹夊叏鍗+紼嬪簭鍛樺織鎰胯匽|[ http://blog.csdn.net/dedodong/archive/2006/10/07/1323925.aspx ] ] 閫氳繃鎷︽埅 NtCreateProcessEx/NtCreateProcess 瀹炵幇浜?""緙栧啓涓涓▼搴忥紝鍦ㄦ紼嬪簭涓繍琛宎.exe錛屽茍浣垮緱a.exe璁や負鏄敱explorer.exe榪愯瀹冪殑"""
[ [闃誨嚮鎭舵剰杞歡--娓呴櫎鍜屼繚鎶や綘鐨勭綉绔欑殑灝忔妧宸|[ http://www.googlechinawebmaster.com/labels/badware.html ] ] google 涓婄殑瀵規(guī)伓鎰忚蔣浠?badware) 鐨勪粙緇?
[ [StopBadware Blog]|[ http://blogs.stopbadware.org/articles/2007/11 ] ]
鏈?縐嶆柟娉?
a)
鍒涘緩CInternetSession 瀵硅薄 -> 璋冪敤 CInternetSession::OpenURL 璇ュ嚱鏁拌В鏋怳RL錛岀劧鍚庢墦寮涓嶶RL鎸囧畾鐨勬湇鍔″櫒榪炴帴錛屽悓鏃惰繑鍥炰竴涓彧璇葷殑CInternetFile瀵硅薄 -> CInternetFile::Read 璇誨彇鏂囦歡 -> 鏋愭瀯CInternetSession
b)
鍒涘緩CInternetSession 瀵硅薄 -> 璋冪敤 CInternetSession::GetHttpConnection
榪斿洖CHttpConnection 瀵硅薄 -> 璋冪敤CHttpConnection::OpenRequest 鍒涘緩涓涓狢HttpFile瀵硅薄 -> CHttpFile::SendRequest 鍙戦佽繛鎺ヨ姹?-> CHttpFile::QueryInfo 鑾峰彇HTTP 淇℃伅(姣斿鏂囦歡澶у皬, ETAG絳? | CInternetFile::Read 璇誨彇鏂囦歡 -> 鏋愭瀯CInternetSession
鍦ㄤ笂榪拌繃紼嬩腑, 濡傛灉鍑虹幇閿欒浼氭姏鍑?CInternetException 寮傚父
鍙﹀鍦ㄦ墦寮閾炬帴鍓? 鍙互榪涜濡備笅璁劇疆
CInternetSession::SetOption 璇誨彇鎴栬緗?InternetQuery 閫夐」 (濡傝秴鏃舵垨閲嶈瘯嬈℃暟錛?br>CInternetSession::EnableStatusCallback 璁劇疆鍥炶皟鍑芥暟鐩戣session鐘舵?br>CHttpFile::AddRequestHeaders 璁劇疆HTTP 璇鋒眰澶?闇瑕佸湪CHttpFile::SendRequest 鍓嶈皟鐢?
2. 瀹炵幇鏂偣緇紶
鏂偣緇紶鍏跺疄鏄氳繃鍦℉TTP 璇鋒眰澶翠腑璁劇疆瑕佷笅杞界殑鏂囦歡鍖洪棿鏉ュ疄鐜? 涓涓吀鍨嬬殑HTTP 璇鋒眰澶存槸
GEThttp://class/download.microtool.de:80/somedata.exe
Host:download.microtool.de
Accept:*/*
Pragma:no-cache
Cache-Control:no-cache
Referer:http://class/download.microtool.de/
User-Agent:Mozilla/4.04[en](Win95;I;Nav)
Range:bytes=554554-
娉ㄦ剰鏈鍚庝竴琛岋細Range:bytes=554554-錛屾牸寮忎負:Range: bytes=璧峰浣嶇疆 - 緇堟浣嶇疆錛屼篃灝辨槸璇達紝鎴戜滑鍙互閫氳繃璁劇疆Http璇鋒眰澶寸殑璁劇疆璧峰緇撴潫浣嶇疆錛屾潵鑾峰彇HTTP鏂囦歡鐨勬煇涓閮ㄥ垎銆?
3. Win32 WinInet API 瀹炵幇
鍜孧FC 鐨勫嚱鏁板搴? 鎵ц涓嬭澆鎿嶄綔澶ц嚧闇瑕佺殑鍑芥暟鏈夛細
InternetOpen鏄渶鍏堣皟鐢ㄧ殑鍑芥暟錛屽畠榪斿洖HINTERNET鍙ユ焺錛屼範鎯畾涔変負hSession錛屽嵆浼氳瘽鍙ユ焺, 鐩稿綋浜嶤InternetSession
InternetConnect浣跨敤hSession鍙ユ焺錛岃繑鍥炵殑鏄痟ttp榪炴帴鍙ユ焺錛屽畾涔変負hConnect, 鐩稿綋浜?CInternetSession::GetHttpConnection
HttpOpenRequest浣跨敤hConnect鍙ユ焺錛岃繑鍥炵殑鍙ユ焺鏄痟ttp璇鋒眰鍙ユ焺錛屽畾涔変負hRequest, 鐩稿綋浜?CHttpConnection::OpenRequest
HttpSendRequest(鐩稿綋浜?CHttpFile::SendRequest)銆丠ttpQueryInfo銆両nternetSetFilePointer鍜孖nternetReadFile閮戒嬌鐢℉ttpOpenRequest榪斿洖鐨勫彞鏌勶紝鍗砲Request銆?/p>
CInternetSession::OpenURL 鐩稿綋浜庡疄鐜頒簡 InternetConnect & HttpOpenRequest & HttpSendRequest 3涓嚱鏁?
褰撹繖鍑犱釜鍙ユ焺涓嶅啀浣跨敤鏃訛紝搴旇鐢ㄥ嚱鏁癐nternetCloseHandle鎶婂畠鍏抽棴錛屼互閲婃斁鍏跺崰鐢ㄧ殑璧勬簮銆?
鐢╓inInet寮鍙慖nternet瀹㈡埛绔簲鐢ㄦ寚鍗楋紙涓錛?/a> http://www.vckbase.com/document/viewdoc/?id=545
鐢╓inInet寮鍙慖nternet瀹㈡埛绔簲鐢ㄦ寚鍗楋紙浜岋級 http://www.vckbase.com/document/viewdoc/?id=546
浣跨敤 CInternetSession 灝佽澶氱嚎紼?http 鏂囦歡涓嬭澆 http://www.vckbase.com/document/viewdoc/?id=1693
Http涓嬭澆鐨勬柇鐐圭畫浼?/a> http://sunyan331.spaces.live.com/blog/cns!89B9F8BF2575E281!947.entry
HTTP鏈嶅姟鍣ㄤ笂鏂偣涓嬭澆鏂囦歡(閲岄潰鏈夊緢涓嶉敊鐨勬簮鐮? http://www.cnitblog.com/wangk/archive/2007/05/22/5942.html
緙栧啓鏂偣緇紶鍜屽綰跨▼涓嬭澆(鏈夋簮鐮? http://www.bbbh.org/20060427/2620/
WinInet: implementing resuming feature http://www.clevercomponents.com/articles/article015/resuming.asp
(寰堣緇嗙殑涓涓唬鐮佽В閲?Retrieving a file via. HTTP http://www.codeproject.com/KB/IP/getwebfile.aspx
We can split up the working of MSN messenger into 2 phases
Authentication Phase
Instant Messaging Phase
The Authentication Phase involves logging into the MSN messenger server and also (friends) list retrieval in this case.
The Instant Messaging Phase involves sending/accepting requests for an Instant Messaging session and also sending/receiving messages.
The MSN messenger protocol is an ASCII based protocol. In other words the commands are in pure English !!!.The first phase involves connecting to an MSN messenger server .In this case we shall connect to the server 64.4.13.58 on port 1863(MSN messenger works through port 1863).
Once the connection is done we need to start the log in process. The first stage in this phase is the versioning stage. In this stage the client (in this case your app) lists/sends the versions that it can support to the server and waits for the server to respond.
VER 0 MSNP7 MSNP6 MSNP5 MSNP4 CVRO
In the MSN messenger protocol a "trial id" is sent along with every command. The trial id starts from 0 and is incremented every time the server responds successfully to the client's commands.
The server responds like this
VER 0 MSNP7 MSNP6 MSNP5 MSNP4
The Client and the server have agreed on a version in which they will communicate.
Next the client sends a request to the server asking it for the name of the security package it supports for authentication.
INF 1
Unlike Yahoo, Rediff and a few other Messengers MSN does not actually send the password as it is.It encrypts the password while sending it ensuring that your password will not be leaked out easily if somebody monitors your port.
The server responds with this
INF 1 MD5
Here MD5 is the name of the security package which the server currently supports.
Next the client sends the userid to the server
USR 2 MD5 I venky_dude@hotmail.com
Here the server does a check whether it contains all the relevant details about the user for authentication .If it does not then it sends the following reply
XFR 2 NS 64.4.13.55:1863 0
What the server says is that the client should connect to the Notification Server(NS) on 64.4.13.55 on port 1863. We close the current connection and repeat the steps while being connected to the new server i.e 64.4.13.55
(client) VER 3 MSNP7 MSNP6 MSNP5 MSNP4 CVRO
(server) VER 3 MSNP7 MSNP6 MSNP5 MSNP4
(client) INF 4
(server) INF 4 MD5
(client) USR 5 MD5 I venky_dude@hotmail.com
Now the server to which we are connected to has the relevant information about the user trying to log in. The server replies this way
USR 5 MD5 S 989048851.1851137130
The string which is sent by the server is the " MD5 Hash". It is a hash generated by the server and is used in the authentication process. The client then has to send the password which is encrypted using the MD5 algorithm.In effect the client has to send the unique MD5 equivalent of the MD5 hash i.e 989048851.1851137130 in this case and the password combined .i.e. MD5 equivalent of (hash+pass). In this case it turns out to be 3b7926d277068ec49576a0c40598ff21.
USR 6 MD5 S 3b7926d277068ec49576a0c40598ff21
If the password is right then the server replies with this
USR 6 OK venky_dude@hotmail.com venkat
Here the last word is the nickname/name by which the user is known.
In the new version of the protocol (MSNP7) the server sends additional data like some general information about the user and a authentication code something similar to a cookie which can be used for various other functions.
MSG Hotmai Hotmail 362
MIME-Version: 1.0
Content-Type: text/x-msmsgspro file; charset=UT
LoginTime: 1011252477
EmailEnabled: 1
MemberIdHigh: 84736
MemberIdLow: - 1434729391
lang _preference: 103
preferredEmai l: venky_dude@hotmail.com
country: IN
PostalCode:
Gender: M
Kid:0
Age: 22
sid: 517
kv: 2
MSPAuth: 2AAAAAAAADU0p4uxxxJtDJozJSlUTS0i7YpwnC9PUHRv56YKxxxCTWmg$$
Now we are logged into the server but our status is still offline. We need to change our status to online in order to send and receive messages. The client does this in the following way
CHG 7 NLN
The server replies with friends who are online and in various states.
CHG 7 NLN
ILN 7 NLN btxxxe@hotmail.com nick
ILN 7 AWY wmpyxxx@msn.com mike
ILN 7 BSY tehpxxpxx@hotmail.com yeaxxx
MSG Hotmail Hotmail 223
MIME-Version: 1.0
Content-Type: text/x-msmsgsinitialemailnotification; charset=UTF-8
Inbox-Unread: 293
Folders-Unread: 0
Inbox-URL: /cgi-bin/HoTMaiL
Folders-URL: /cgi-bin/folders
Post-URL: http://www.hotmail.com
The next command to be sent to the server pertains to the version of the client currently being used.The client send to the server it's version number and also information about the machine like the OS and the build.
CVR 8 0x0409 win 4.10 i386 MSMSGS 4.5.0127 MSMSGS
Here 0x409 win 4.10 i386 specifies that the client is running win98 on a intel microprocessor, and MSMSGS 4.5.0127 MSMSGS here specifies the version and build no of msmsgs.exe (basically the version no of MSN messenger).
The server responds with the url to download the latest version and some other info
CVR 8 4.5.0127 4.5.0127 1.0.0863 http://download.microsoft.com/download/msnmessenger/install/4.5/win98me/en-us/mmssetup.exe http://messenger.microsoft.com
It is not necesarry to send the CVR command, the messenger protocol will function properly regardless of this command being sent
To get a list of people who are in our friends list we may send this command
LST 9 RL
On sending this command the server will reply by sending the reverse list .The reverse list is basically a list of users who can see you when you are online and send you a message.You could alternatively also request for the forward list by sending LST 9 FL .The forward list contains a list of all users whom the user has added to his/her list.
The server responds this way
LST 9 RL 69 1 19 venky_dude@hotmail.com venkat
LST 9 RL 69 2 19 puxxxxx@hotmail.com PUJA
LST 9 RL 69 3 19 vancxxxxx@hotmail.com ramachandran
LST 9 RL 69 4 19 moxxxxx@hotmail.com chandramouli
LST 9 RL 69 5 19 v_n_xxxxx@hotmail.com Narayanaswamy
LST 9 RL 69 6 19 dexxxxx@hotmail.com Venkatesh
LST 9 RL 69 7 19 lousydxxxxx@hotmail.com deepika%20kalyani%20Vairam LST 9 RL 69 8 19 hexxxxxr@hotmail.com Hetchar%20Ramachandran
LST 9 RL 69 9 19 ambxxxxx@hotmail.com Aiyer
LST 9 RL 69 10 19 suxxx@hotmail.com Ganesh
LST 9 RL 69 11 19 deexxxxx@hotmail.com Deepak
LST 9 RL 69 12 19 anilxxxxx@hotmail.com anil
LST 9 RL 69 13 19 dixxxxx@hotmail.com <Diamond>
LST 9 RL 69 14 19 nvxxxx@hotmail.com giri
LST 9 RL 69 15 19 shxxx@hotmail.com Hari
LST 9 RL 69 16 19 radhikashuxxxxx@hotmail.com radhika
LST 9 RL 69 17 19 eskaxxxxx@hotmail.com kannan
LST 9 RL 69 18 19 shaxxxxx@hotmail.com Shankar
LST 9 RL 69 19 19 puneetagarxxxxx@hotmail.com puneet
*Every time a friend comes online the server(NS) sends us the following command
NLN 10NLN deaxxxx@hotmail.com Venkatesh
and when the friend goes offline the server sends us this
FLN 10 FLN deaxxxx@hotmail.com
With the MSNP7 protocol msn has introduced a new challenege authentication mechanism. The MSN server sends t a challenge key which the user has to authenticate succesfully in order for the session to continue.
CHL 0 20881396011366812350
The client has to send the md5 equivalent of this string which is formed by appending this hash with the string "Q1P7W2E4J9R8U3S5".So the final string which will be sent to the server will be the md5 equivalent of 20881396011366812350Q1P7W2E4J9R8U3S5
i.e MD5string(20881396011366812350Q1P7W2E4J9R8U3S5 )
So the client response would be something like this
QRY 18 msmsgs@msnmsgr.com 32
0212eaad0876afb8505859ca75d21a78
Here 18 is the trial id .Replace it by the appropriate trial id in your program .
The server will respond in the following way if the authentication is right
QRY 18
We have successfully logged into the MSN Messenger server. The Instant Messaging phase is next.
Instant Messaging in MSN Messenger is session based . The people in between whom the conversation is going to take place have to be in a session mode. We cannot send/receive messages unless we start a chat session with a user.
There are basically two methods in which a user can be in a chat session
User sends a chat session request
The client(user) sends a command to the server asking it for the address of the SwitchBoard(SB) server. All instant messaging conversation take place via the switchboard server.
XFR 9 SB
The server(SB) replies back with the ip address of the switchboard server(SB),the port on which to connect and a CKI hash. CKI is a security package and the client has to use the hash to connect to the switchboard server.
XFR 9 SB 64.4.13.88:1863 CKI 989487642.2070896604
Now we have to make another new connection this time to the switchboard server. Our previous connection to the MSN messenger server must be kept as it is. If we lose connection with that server we would log out.
After we have connected to the switchboard server(SB) we send the following command to the switchboard server.
USR 1 venky_dude@hotmail.com 989487642.2070896604
If the CKI hash sent by us is right the server(SB) responds back with this
USR 1 OK venky_dude@hotmail.com venkat
After this has been done the user has to "Call" the other user to the chat session. This is done by sending the following command.
CAL 2 deadxxx@hotmail.com
The server replies back with the a session id which it will pass on to the other user
CAL 2 RINGING 11717653
When the other user replies and is ready for a chat the server(SB) sends us this command
JOI deadlee@hotmail.com Venkatesh
This indicates that the other user has joined in the conversation and we are now ready to send and receive messages.
User receives a chat session request
When we are being invited to a chat session by a user the server(NS) send us the following message.
RNG 11742066 64.4.13.74:1863 CKI 989495494.750408580 deaxxxx@hotmail.com Venkatesh
Here the server(NS) sends us the session id ,the ip address of the SwitchBoard server to connect to,the port on which to connect to ,the CKI hash and the user trying to start a conversation with us.
Now we have to make another new connection this time to the switchboard server. Our previous connection to the MSN messenger server must be kept as it is. If we loose connection with that server we would log out.
We connect to the switchboard server and send the following command
ANS 1 venky_dude@hotmail.com 989495494.750408580 11742066
Here we send our login name ,the CKI hash that was sent to us and the session Id that was sent to us
The server responds back with
IRO 1 1 1 deaxxxx@hotmail.com Venkatesh
and
ANS 1 OK
We are now ready to send and receive messages.
Before sending/receiving messages let us see how the message is constructed.
When we are sending a message we build the header information in the following way
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-MMS-IM-Format: FN=Microsoft%20Sans%20Serif; EF=; CO=0; CS=0; PF=22
While sending a message we send it this way
MSG 2 N 137 MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-MMS-IM-Format: FN=Microsoft%20Sans%20Serif; EF=; CO=0; CS=0; PF=22
hello
Here 2 is the trial id which has to incremented each time we send a message. 137 is the total length of the message i.e length of the header and length of the actual message that we are sending in this case it is 'hello'.
While receiving the message it is more or less similar
Here is an example of a message received
MSG deaxxxx@hotmail.com Venkatesh 137
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-MMS-IM-Format: FN=Microsoft%20Sans%20Serif; EF=; CO=0; CS=0; PF=22
hello
When the other user is typing a message we receive the foll message
MSG deaxxxx@hotmail.com Venkatesh 100
MIME-Version: 1.0
Content-Type: text/x-msmsgscontrol
TypingUser: deaxxxx@hotmail.com
I guess now u guys are well on your way to make your own version of MSN messenger.Post your doubts/comments/message in the Forumn .Do visit my projects page for some cool vb & c++ codes
I'll keep adding to the protocol ,will try to put in addition functions like add/remove users ,rename user id,file transfer and voice chat, so keep checking back
References:
You could take a look at these sites for more information
This is the original protocol published by microsoft.
http://www.tlsecurity.net/Textware/Misc/draft-movva-msn-messenger-protocol-00.txt
This is the MD5 homepage where u can find programs/codes for doing the MD5 encryption
http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html
2. 鏍規(guī)嵁URL 鍗忚璋冪敤綾誨璞℃潵澶勭悊
鍙互鏍規(guī)嵁URL 鍗忚鎴栬匨IME type 娉ㄥ唽涓嶅悓鐨勫鐞嗗璞?br>鏈変袱縐嶆柟寮忥細
a) 閫氳繃鍦ㄦ敞鍐岃〃灝哢RL 鍗忚涓嶤OM 瀵硅薄鍏寵仈
涓昏鍦ㄦ敞鍐岃〃涓殑
HKEY_CLASSES_ROOT\PROTOCOLS\Handler # URL 鍗忚
HKEY_CLASSES_ROOT\PROTOCOLS\Filter # Mime Filter
b) 閫氳繃涓存椂娉ㄥ唽綾誨璞″皢URL 鍗忚涓庡叾鍏寵仈
// 娉ㄥ唽
CComPtr<IInternetSession> spSession;
CComPtr<IClassFactory> spCFHTTP;
HRESULT hr = CoInternetGetSession(0, &spSession, 0);
hr = FilterFactory::CreateInstance(CLSID_HttpProtocol, &spCFHTTP);
hr = spSession->RegisterNameSpace(spCFHTTP, CLSID_NULL, L"http", 0, 0, 0);
// 鍙嶆敞鍐?br>spSession->UnregisterNameSpace(spCFHTTP, L"http");
3. FilterFactory 鐨勫疄鐜板彲浠ュ弬鑰?br>Asynchronous Pluggable Protocol Implementation with ATL
http://www.codeguru.com/cpp/com-tech/atl/misc/article.php/c37/
Internet Explorer涓嬭澆鏂囦歡鐨勭粓鏋佽繃婊?/a>
http://blog.csdn.net/111222/archive/2002/02/09/7255.aspx
閫氳繃Mime filter鎶鏈緗戦〉婧愮爜榪涜榪囨護錛堢洃瑙嗕笅杞芥枃浠訛級
http://blog.csdn.net/lion_wing/archive/2006/06/27/839134.aspx
HTML浠g爜榪囨護鎶鏈?/a>
http://blog.csdn.net/lion_wing/articles/534716.aspx
About Asynchronous Pluggable Protocols 錛圡SDN錛?br>
Internet Explorer 緙栫▼綆榪幫紙涔?jié)锛夊湪鑷忿q殑嫻忚鍣ㄤ腑宓屽叆Google宸ュ叿鏉?/a>
http://blog.csdn.net/CathyEagle/archive/2005/12/12/550698.aspx
鏀?000鍒嗭紝楂樻墜榪涙潵鍔ㄦ墜璇曡瘯錛氬浣曟彁鍙朅JAX閲岀殑HTML鍐呭錛?br>http://topic.csdn.net/t/20061214/12/5230161.html
榪欓噷涓昏閫氳繃鐩戣IE 鐨勪笅杞戒粠鑰屼繚瀛楪oogle Map 鐨勫湴鍥炬暟鎹枃浠? 閫氳繃鐩戣http & text/html & application/javascript 鐨勫唴瀹規(guī)潵鑾峰彇鍥劇墖鏂囦歡URL 鍜?淇℃伅.. :)
Tree Control 涓嶆敮鎸佽妭鐐圭殑紱佺敤, 浣嗘槸鍙互閫氳繃鑷粯瀹炵幇, 涓昏濡備笅:
1. 鏍囪鑺傜偣鏄惁紱佺敤. 鍙互鐢?SetItemData & GetItemData 鏉ヨ緗?amp;鑾峰彇鑺傜偣鏁版嵁
2. 鍦ㄧ鐢ㄧ殑鑺傜偣涓? 瑕佽繃婊や竴浜涘鑺傜偣鎿嶄綔, 濡俥xpanding, selecting, drag & drop 絳?
TVN_SELCHANGING 鑺傜偣閫変腑鏀瑰彉鏃?br>TVN_ITEMEXPANDING 鑺傜偣灞曞紑鏃?br>TVN_BEGINDRAG 鑺傜偣寮濮嬭鎷栨媺
TVN_BEGINLABELEDIT 鑺傜偣琚紪杈?/p>
3. 瀵圭鐢ㄨ妭鐐硅繘琛岃嚜鐢? 鐢ㄥ浘鏍?棰滆壊灝嗙鐢ㄨ妭鐐瑰拰鍏朵粬鑺傜偣榪涜鍖哄垎
a) 鐩存帴鍦?WM_PAINT 涓繘琛岃嚜鐢?(鎴栧Tree Control鐨勭粯鍥劇粨鏋滆繘琛屼慨鏀?
鍙互鍙傝? 濡備綍鍦ㄦ爲鍨嬫帶浠朵腑浣跨敤鑳屾櫙浣嶅浘
b) 鐩稿簲 WM_OWERDRAW 浜嬩歡
鍙互鍙傝? Outlook椋庢牸鐨勫崟鍒椾嬌鐢ㄤ笉鍚岀殑棰滆壊鏄劇ず鏂伴偖浠舵暟
鍙傝?
MFC Tree Control: How to disable an item?
Setting color and font attribute for individual items
鍦?http://www.80diy.com/home/20041120/19/3572410.html 鐪嬪埌鍑犳鍏充簬COM 鐨勭被鍘傜殑璇?
"""
綾誨巶鐢ㄦ潵鎶借薄緇勪歡鐨刢reate榪囩▼錛屽鎴蜂笉闇瑕佺煡閬撶粍浠剁殑璇︾粏鎯呭喌錛屼篃涓嶉渶瑕佺煡閬撶被鍘傜殑璇︾粏鎯呭喌錛屽彧瑕佺煡閬揅oCreateInstance鍙互鍒涘緩緇勪歡鍗沖彲銆傝孋oCreateInstance鍐呴儴璋冪敤DllGetClassObject鏉ョ敓鎴愯緇勪歡鐨勭被鍘傦紝鐢變簬綾誨巶鏈夌粍浠剁殑浣滆呮挵鍐欙紝鎵浠ュ緇勪歡綾誨彲璋撶煡鏍圭煡搴曪紝鐢辯被鍘傛潵鐢熸垚緇勪歡瀹屽叏琛屽緱閫氾紝榪欐牱瀹㈡埛鍜岀粍浠跺氨榪涗竴姝ュ垝鍒嗭紝瀹㈡埛鍙兘鏌ヨ璇ョ粍浠舵槸鍚︽敮鎸佹煇鍊熷彛錛岃屽緇勪歡鐨勫叾浠栨儏鍐典竴鏃犳墍鐭ワ紝榪欐牱鐨勫垝鍒嗗彲浠ヤ嬌緇勪歡鍜屽鎴烽棿鐨勮﹀悎鏇村皬銆?br>"""
"""
緇勪歡濡傛灉灝嗘煇鎺ュ彛鐨勫叏閮ㄦ柟娉曢兘瀹炵幇浜嗭紝灝辯О璇ョ粍浠舵敮鎸佹煇鎺ュ彛錛宑om騫舵病鏈夎瀹氱粍浠跺拰鎺ュ彛涔嬮棿鏄櫄鍑芥暟緇ф壙鐨勫叧緋伙紝鍙槸鍦╟++涓互榪欑鏂規(guī)硶鏉ュ疄鐜版渶濂借屽凡銆?nbsp;
IClassFactory璇寸┛浜嗗氨鏄笓闂ㄦ瀯閫犵粍浠剁殑綾伙紝榪欐牱鍋氭槸涓轟簡鎶借薄錛屽洜涓哄鎴鋒病鏈夊繀瑕佺煡閬撶粍浠舵槸浠涔堬紝濡傛灉鐢卞鎴風洿鎺ユ瀯閫犵粍浠訛紝瀹㈡埛鍔垮繀瑕佺煡閬撶粍浠剁殑淇℃伅錛宑om灝卞け鍘諱簡瀹冪殑鎰忎箟浜嗭紝鎵浠ワ紝瑙勫畾浜嗕竴涓被鍘傦紙鏀寔IClassFactory鎺ュ彛錛夛紝姣忎釜緇勪歡鐨勭被鍘傞兘寰堟竻妤氬茍涓斾篃鍙竻妤氳緇勪歡鐨勪俊鎭紝鑰屽鎴峰彧闇瑕佽皟鐢╟om搴撳嚱鏁癈oCreateInstance灝卞彲浠ヤ簡銆?nbsp;
涓嬮潰鏄祦紼嬪浘錛?nbsp;
CoCreateInstance -> CoGetClassObject -> DllGetClassObject -> new ClassFactory -> IClassFactory::CreateInstance() -> new Component
"""
騫朵笖鍦?http://www.codeproject.com/com/comintro2.asp 涔熺湅鍒板嚑孌佃瘽
"""
姣忔瀹炵幇緇勪歡瀵硅薄綾葷殑鏃跺欙紝閮借鍐欎竴涓梺綾昏礋璐e垱寤虹涓涓粍浠跺璞$被鐨勫疄渚嬨傝繖涓梺綾誨氨鍙繖涓粍浠跺璞$被鐨勭被宸ュ巶錛坈lass factory錛夛紝鍏跺敮涓鐩殑鏄垱寤篊OM瀵硅薄銆備箣鎵浠ヨ涓涓被宸ュ巶錛屾槸鍥犱負璇█鏃犲叧鐨勭紭鏁呫侰OM鏈韓騫朵笉鍒涘緩瀵硅薄錛屽洜涓哄畠涓嶆槸鐙珛浜庤璦鐨勪篃涓嶆槸鐙珛浜庡疄鐜扮殑銆?
褰撴煇涓鎴風鎯寵鍒涘緩涓涓狢OM瀵硅薄鏃訛紝COM搴撳氨浠嶤OM鏈嶅姟鍣ㄨ姹傜被宸ュ巶銆傜劧鍚庣被宸ュ巶鍒涘緩COM瀵硅薄騫跺皢瀹冭繑鍥炲鎴風銆傚畠浠殑閫氳鏈哄埗鐢卞嚱鏁癉llGetClassObject()鏉ユ彁渚涖?br>"""
鍦?lt;COM 鎶鏈唴騫?gt; 涓? 瀵圭被鍘傜殑寮曞叆涔熸湁鎻忚堪.
涓昏鏄?
a. 鍦ㄩ潰鍚戝璞$郴緇熶腑, 瀵硅薄鍒涘緩鏄潪甯擱噸瑕佺殑, 鍥犱負瑕佷嬌鐢ㄥ畠蹇呴』鍏堝垱寤哄畠. 鎵浠ュ敖鍙兘鐏墊椿鐨勫垱寤哄璞?component)
b. 鍦–oCreateInstance 鍒涘緩瀵硅薄榪囩▼鏄? 浼犵粰涓鍏盋LSID, 鐒跺悗鍒涘緩鎴愮浉搴旂粍浠? 騫惰繑鍥炴墍璇鋒眰鐨勬寚閽? 鍏跺紛绔湪浜庢棤娉曟彁渚涚粰瀹㈡埛涓縐嶆帶鍒跺璞″垱寤鴻繃紼嬬殑鏂規(guī)硶. (闂鍏抽敭涓嶅湪鍒濆鍖? 鑰屾槸鎺у埗鍒涘緩瀵硅薄榪囩▼)
c. IClassFactory2 鎴愭壒鐨勮皟鐢ㄦ帴鍙?
2.
鍙傝僀oCreateInstance 鐨勫疄鐜拌繃紼?
CoCreateInstance -> CoGetClassObject -[緋葷粺|緇勪歡浠g爜]-> DllGetClassObject -> new ClassFactory -> IClassFactory::CreateInstance() -> new Component
鍥犱負 DllGetClassObject -> new ClassFactory -> IClassFactory::CreateInstance() -> new Component 閮芥槸緇勪歡鎵鏉ュ疄鐜扮殑, 鑰岀郴緇熻皟鐢?CoCreateInstance 鎵鎻愪緵鐨勫弬鏁? 鍜岄氳繃鑷繁浣跨敤IClassFactory 鏉ュ垱寤篊omponent 鐨勫弬鏁版槸娌℃湁鍙樺寲鐨? 鎵浠ュ鏋滅渷鐣?ClassFactory 搴旇涔熷彲浠?
CoCreateInstance -> CoGetClassObject -[緋葷粺|緇勪歡浠g爜]-> DllGetClassObject -> new Component
DllGetClassObject 瀹屽叏鍙互瀹屾垚<COM 鎶鏈唴騫曡鐨?gt; a. 鐏墊椿鍒涘緩瀵硅薄, b. 鎺у埗鍒涘緩榪囩▼, c. IClassFactory2 , 鑰屼笖榪欐牱瀛愮殑瀹炵幇涔熶笌璇█鏃犲叧.
鎵浠ユ劅瑙夋病鏈夊繀瑕佷竴瀹氳鐢ㄥ埌IClassFactory 榪欎釜鎺ュ彛
3.
鍥犳鍦ㄥ疄鐜扮殑鏃跺? 瀹屽叏鍙互榪欐牱瀛愮殑瀹炵幇緇勪歡
CCoClass : public IA, public IB, public IClassFactory
{
......
}
DllGetClassObject()
{
new CCoClass
}
鑰屼笉闇瑕侀澶栫殑鐢ㄤ竴涓被鍗曠嫭鐨勫幓瀹炵幇IClassFactory . 濂藉儚ATL 榛樿鐨勫氨鏄繖涔堝共鐨? 鎻愪緵浜嗕竴涓狢ComCoClass<CCoClass, &CLSID_CCoClass) 瀹炵幇綾?
榪欎釜鏄垜鐨勫COM 鐨処ClassFactory 鐨勭悊瑙? 鎰熻娌″繀瑕佸涓涓繖涓笢瑗?
涓嶇煡閬撳ぇ瀹舵槸濡備綍鐪嬪緟榪欎釜涓滆タ鐨?)
2 瓚呯被鍖?br>紿楀彛瓚呯被鍖栨槸鍦ㄧ獥鍙g被鈥斺擶NDCLASS鎴朩NDCLASSEX錛堥潪MFC綾繪蹇碉級綰у埆榪涜鐨勬敼鍙樼獥鍙g被鐗瑰緛鐨?/strong>銆?br>浣跨敤榪囩▼錛氶鍏堣幏寰椾竴涓凡瀛樺湪鐨勭獥鍙g被錛岀劧鍚庤緗獥鍙g被錛屾渶鍚庢敞鍐岃紿楀彛綾匯?br>渚嬶細
WNDCLASSEX wc;
wc.cbSize=sizeof(wc); //Windows鐢ㄦ潵榪涜鐗堟湰媯鏌ョ殑錛屼笌紿楀彛鐗瑰緛鏃犲叧
GetClassInfoEx(hinst,”XXXXXX”,&wc);
// hinst鈥斿畾涔夌獥鍙g被XXXXXX鐨勬ā鍧楃殑鍙ユ焺錛屽涓虹郴緇熷畾涔夌殑紿楀彛綾伙紙濡傦細EDIT銆丅UTTON錛夊垯hinst=NULL.銆?
wc.lpszClassName = “YYYYYYY”;//蹇呴』鏀瑰彉紿楀彛綾葷殑鍚嶅瓧
wc.hbrBackGround = CreateSolidBrush(RGB(0,0.0));//鏀瑰彉鑳屾櫙鍒?
wc.lpfnWndProc = NewWndProc;//鏀瑰彉紿楀彛鍑芥暟
……
RegisterClassEx(&wc);// 娉ㄥ唽鏂扮獥鍙g被
//浣跨敤紿楀彛綾?
……
::CreateWindow(_T(“YYYYYYYY”,……)錛?
鏁呰秴綾誨寲鍙兘鏀瑰彉鑷繁鍒涘緩鐨勭獥鍙g殑鐗瑰緛錛岃屼笉鑳界敤浜庣敱Windows鍒涘緩鐨勭獥鍙o紙濡傚璇濇涓婄殑鎸夐挳灝變笉鑳借繘琛岃秴綾誨寲錛?銆傝屽瓙綾誨寲鏄疄渚嬬駭鍒笂鐨勶紝鍙鑳借幏寰楃獥鍙g殑瀹炰緥錛屽氨鍙鍏跺瓙綾誨寲錛岃繖鏄敮涓鐨勫瓙綾誨寲瀵逛簬瓚呯被鍖栫殑浼樺娍銆傚彟澶栵紝鍑℃槸瀛愮被鍖栧彲瀹炵幇鐨勶紝瓚呯被鍖栭兘鍙疄鐜幫紝涓嶈繃瓚呯被鍖栫敤璧鋒潵杈冮夯鐑︺?
3. 鎬葷粨
錛?錛?瀛愮被鍖栦慨鏀圭獥鍙h繃紼嬪嚱鏁? 瓚呯被鍖栦慨鏀圭獥鍙g被(鏂扮殑紿楀彛綾誨悕)
錛?錛?瀛愮被鍖栨槸鍦ㄧ獥鍙e疄渚嬬駭鍒笂鐨勶紝瓚呯被鍖栨槸鍦ㄧ獥鍙g被錛圵NDCLASS錛夌駭鍒笂鐨勩?
錛?錛?瓚呯被鍖栧彲浠ュ畬鎴愭瘮瀛愮被鍖栨洿澶嶆潅鐨勫姛鑳斤紝鍦⊿DK鑼冪暣涓婏紝鍙互璁や負瀛愮被鍖栨槸瓚呯被鍖栫殑瀛愰泦銆?
錛?錛?瀛愮被鍖栧彧鑳芥敼鍙樼獥鍙e垱寤哄悗鐨勬ц川錛屽浜庣獥鍙e垱寤烘湡闂存棤鑳戒負鍔?鏃犳硶鎴幏ON_CREATE 浜嬩歡)錛岃岃秴綾誨寲鍙互瀹炵幇錛涜秴綾誨寲涓嶈兘鐢ㄤ簬Windows鍒涘緩鐨勭獥鍙o紝瀛愮被鍖栧彲浠ャ?nbsp;
4. 鍏朵粬
鍦?鐪艱涓哄疄(2)錛氫粙緇峎indows鐨勭獥鍙c佹秷鎭佸瓙綾誨寲鍜岃秴綾誨寲 榪欓噷鏈変竴涓緥瀛?.
鍙互寰楀嚭緇撹
a) 瀛愮被鍖栫殑classname 鏄笉浼氬彉鍖栫殑, 鑰岃秴綾誨寲浣跨敤鏂版敞鍐宑lassname
b) 瀛愮被鍖?& 瓚呯被鍖?鎻忚堪鐨勬槸涓涓姩浣?鍜屽疄鐜版柟娉曟病浠涔堝叧緋?.... 涓昏鏄瓙綾誨寲鏄疭ubclassWindow, SubclassDlgItem, 鑰岃秴綾誨寲鏄疪egisterClassEx(&newwindowclass)
c) 鎰熻鍏蜂綋娌℃湁蹇呰鍖哄垎榪欎簺, 瀹炵幇鍔熻兘灝辮浜? 鍛靛懙
Some of the DirectShow samples break if you install Visual Studio 2005 Beta 2. Most of the errors that I found fall into three categories:
Here are the specific fixes that I made. Warning: I have not thoroughly tested these, and I only tried them under the "Windows XP 32-bit Debug" environment in Platform SDK. You should use your own judgment before making any of these fixes.
4. 闂
a. DocumentComplete 浜嬩歡浼氬湪URL 瀵瑰簲欏甸潰鐨勬瘡涓厓绱犱笅杞藉畬姣曠殑鏃跺欓兘浼氬彂鐢? 鎵浠?( 榪樹笉鐭ラ亾鍝釜浜嬩歡鏄暣涓〉闈笅杞藉畬姣曠殑浜嬩歡:/
b. 鐜板湪鏄氳繃MFC 鏉ュ垱寤篧ebBrowser Control 鐨? 涓嶇煡閬撴庝箞鍦╓in32 Application 涓垱寤鴻繖涓帶浠?
c. 涓嶇煡閬撳浣曞緱鍒版暣涓〉闈㈢殑澶у皬, 鐜板湪鍙兘淇濆瓨欏甸潰鎴浘鐨勪竴閮ㄥ垎:(
榪欎釜宸茬粡鐭ラ亾鎬庝箞鍋氫簡.
IHTMLElement2 鐨?scrollWidth & scrollHeight 鍔犱笂 scrollLeft & scrollTop 鏉ュ疄鐜? 浣嗘槸涓嶇煡閬撲負浠涔? put_scrollTop & put_scrollLeft 榪欎簺鍑芥暟濂藉儚涓嶅, 鍙兘鎴幏鍒頒竴閮ㄥ垎欏甸潰鎴浘.:( 涓嶇煡閬撲負浠涔?br>
浠g爜鍙互鍦ㄨ繖閲屼笅杞? http://www.shnenglu.com/Files/bigsml/iesnapshot.zip