본문 바로가기

Security/System Hacking

엑티브엑스 컨트롤을 이용한 후킹 프로그램 2. 폼뷰 만들기

우선 엑티브엑스 틀을 만들어줄 폼뷰를 만들어 준다.

 

새 프로젝트에서 MFC ActiveX 컨트롤 을 선택 후 마침 선택

 

리소스에서 Dialog 추가 후 다이얼로그에서 그림과 같이 클래스 추가해준다

후킹 시작 버튼 : IDB_START

리스트박스 : IDL_LIST

. 

MFC 클래스 마법사에서 클래스 이름을 GlobalHookingView 로선택해주고 기본클래스를 CFormView로 선택해 준다.

GlobalHookingView 클래스에서 Create함수를 오버라이딩 해준다.

GlobalHookingCtrl 클래스에서 WM_CREATE 윈도우 메시지를 생성해준다.

 

int CChatFormCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

           if (COleControl::OnCreate(lpCreateStruct) == -1)

                     return -1;

          

           // TODO: Add your specialized creation code here

           CRuntimeClass *pViewClass = RUNTIME_CLASS(CChatFormView);

           m_pFormView = (CChatFormView *)pViewClass->CreateObject();

           if(m_pFormView == NULL) {

                     TRACE("Warning : Dynamic Create of View type %Fs Failed \n",

                                pViewClass->m_lpszClassName);

                     return -1;

           }

        CCreateContext context;

           context.m_pNewViewClass = pViewClass;

           context.m_pCurrentDoc = NULL;

           if(!m_pFormView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0,0,218*2,152*2),

                     this,AFX_IDW_PANE_FIRST,&context)) {

                     TRACE("Warning : Couldn't create view for frame\n");

                     delete m_pFormView;

                     return -1;

           }

           return 0;

}

폼뷰의 CRect 크기는 리소스의 다이얼로그 사이즈에 두배의 값으로 한다.

CRect(0,0,218*2,152*2)

 

- CChatFormView의 헤더파일을 컨트롤 클래스 헤더파일에 include 하고 CChatFormView의 멤버 포인터 변수를 선언한다.

#include "ChatFormView.h"

class CChatFormView;

class CChatFormCtrl : public COleControl

{

           DECLARE_DYNCREATE(CChatFormCtrl)

// Constructor

public:

           CChatFormCtrl();

           CChatFormView* m_pFormView;

// Overrides

 

 

- CChatFormView의 헤더파일 선언부에서 protected: 로 선언된 생성자와 소멸자 모두 public:으로 바꿔준다.

class CChatFormView : public CFormView

{

public:

        CChatFormView();        

        virtual ~CChatFormView();

        DECLARE_DYNCREATE(CChatFormView)

 

 

 

 

폼뷰(FormView) 클래스 완성