| 제 목 Internet Explorer의 주소창 Hooking하기 작 성 자 송은희(song82) 첨 부 파 일 작성시간 2002-06-18 오전 11:06:53 조 회 수 151 데브피아의 Q&A에서 찾은 방법으로 작성한 것을 정리해서 올립니다. 여기 예제는 주소창의 Keyboard와 윈도우 Message를 hooking하는 예제입니다. 아래의 변수들을 Global로 선언합니다. static HHOOK g_hKeyHook = NULL; static HHOOK g_hMsgHook = NULL; static HWND g_hAddrComboBox = NULL; static HWND g_hAddrEdit = NULL; 헤더파일에 다음의 함수를 선언합니다. // Address Bar hooking void IEAddressBarHook(); static LRESULT CALLBACK AddrBarKeyHookProc(int nCode, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK AddrBarMsgHookProc(int nCode, WPARAM wParam, LPARAM lParam); 위 세개의 함수 구현은 다음과 같습니다. void CMyclass::IEAddressBarHook() { HWND hwndIEFrame = NULL; HWND hWorker = NULL; HWND hComboBoxEx = NULL; HWND hRebar = NULL; g_pThis = this; hwndIEFrame = ::FindWindow("IEFrame", NULL); if(hwndIEFrame != NULL) hWorker = ::FindWindowEx(hwndIEFrame, NULL, "WorkerW", NULL); if(hWorker == NULL) hWorker = ::FindWindowEx(hwndIEFrame, NULL, "WorkerA", NULL); if(hWorker != NULL) hRebar = ::FindWindowEx(hWorker,NULL, "ReBarWindow32", NULL); hComboBoxEx = ::FindWindowEx(hRebar, NULL, "ComboBoxEx32", NULL); g_hAddrComboBox = ::FindWindowEx(hComboBoxEx, NULL, "ComboBox", NULL); g_hAddrEdit = ::FindWindowEx(g_hAddrComboBox, NULL, "Edit", NULL); g_hKeyHook = SetWindowsHookEx(WH_KEYBOARD, reinterpret_cast<HOOKPROC>(AddrBarKeyHookProc), NULL, ::GetCurrentThreadId()); g_hMsgHook = SetWindowsHookEx(WH_GETMESSAGE, reinterpret_cast<HOOKPROC>(AddrBarMsgHookProc), NULL, ::GetCurrentThreadId()); } LRESULT CALLBACK CMyClass::AddrBarKeyHookProc(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode < 0) return CallNextHookEx(g_hKeyHook, nCode, wParam, lParam); if ((lParam & 0x80000000) || (lParam & 0x40000000)) return CallNextHookEx(g_hKeyHook, nCode, wParam, lParam); if (wParam == VK_RETURN) { // 여기서 주소창에서 엔터키를 사용했을 경우의 처리를 할 수 있습니다. } return CallNextHookEx(g_hKeyHook, nCode, wParam, lParam); } LRESULT CALLBACK CMyClass::AddrBarMsgHookProc(int nCode, WPARAM wParam, LPARAM lParam) { if(((PMSG)lParam)->hwnd == g_hAddrEdit || ((PMSG)lParam)->hwnd == g_hAddrComboBox) { if (((PMSG)lParam)->message == WM_PAINT) { // 주소창의 내용이 변할때를 인식해 낼 수 있습니다. } } return CallNextHookEx(g_hMsgHook, nCode, wParam, lParam); } IEAddressBarHook()함수를 원하는 위치에서 호출해 주면, 상황에 따랄 Callback함수들이 호출되게 됩니다. 주소창 윈도우을 찾아낼 때 FindWindow()함수를 사용했는데요.. 확인은 안해 봤지만, classname이 IE의 버전에 따라 차이가 있을수도 있을거 같습니다. 혹, 더 좋은 방법을 알고 계신 분들은 리플 달아주세요. ^^; [데브피아 펌] "Steal Article" 카테고리의 다른 글
|
TRACKBACK :: http://fiadot.com/TatterTools/trackback/649
-
Subject: Tramadol side effects.
Tracked from Cheap tramadol fedex overnight. 삭제Canine tramadol. Tramadol no prescription. Taking tramadol while pregnant. Hydrocodone vs tramadol. Tramadol. Tramadol cheap no rx.
2010/05/13 23:38 -
Subject: Generic ambien.
Tracked from Ambien. 삭제Ambien and pregnancy. Ambien. Ambien next day delivery where us. Ambien side effects. Will ambien show up in a urine test. Buy ambien without prescription.
2010/05/14 17:06 -
Subject: Dog s tramadol.
Tracked from Cheap tramadol. 삭제Tramadol.
2010/05/19 08:25 -
Subject: Dog s tramadol.
Tracked from Tramadol. 삭제Tramadol withdraw. Will tramadol hcl test positive in drug testing. Tramadol.
2010/06/04 12:06 -
Subject: Buy cialis.
Tracked from Cialis. 삭제Cialis lawyers. Cialis uk. Cialis. Cialis drug interaction. Cialis canada. Cialis prescription.
2010/07/18 05:46 -
Subject: Xanax.
Tracked from Buy xanax precrition needed. 삭제Side effects of drug xanax. Xanax. Generic xanax 2 mg no prescription.
2010/08/11 08:21

댓글을 달아 주세요