能力值:
( LV9,RANK:250 )
|
-
-
6 楼
在工程中新建一个资源脚本,把你要加的控件加进去,然后在cpp中写好他们的消息处理函数就可以拉。
比如,用一个对话框,在winmain中一个DialogBox函数就可以拉。
DialogBox(hinstExe,MAKEINTRESOURC,(IDD_DIALOG1),NULL,DialogProc);
这个参数就不解释了吧,关键是最后的对话框的消息处理函数哦。
给个例子吧:)
DWORD WINAPI StartHook(HWND hwnd)
{
WinExec("HookAll.exe", SW_SHOWNORMAL);
SendMessage(hwnd,WM_SYSCOMMAND, SC_CLOSE, 0);
return 0;
}
typedef int (__stdcall * PFN_ENABLENET)(BOOL);
int EnableNet(BOOL bEnable)
{
HMODULE hMod = LoadLibrary("enblnet.dll");
if(hMod == NULL)
{
MessageBox(NULL,"Load enblnet.dll failed!", "PFW", 0);
return -1;
}
PFN_ENABLENET pfnEnableNet = (PFN_ENABLENET)GetProcAddress(hMod, "EnableLAN");
pfnEnableNet(bEnable);
FreeLibrary(hMod);
return 0;
}
//////////////////////////////////////////////////////////////////////////
void Dlg3_OnCommandInit(HWND hwnd,UINT wNotifyCode,int wID,HWND hwndCtl)
{
switch(wID)
{
case SC_CLOSE:
EndDialog(hwnd, wID);
break;
case IDC_BUTTON1:
DWORD dwIndex=GetDlgItemInt(hwnd,IDC_EDIT1,NULL,FALSE);
SendMessage(GetDlgItem(hwnd,IDC_LIST1), LB_RESETCONTENT, 0, 0);
ModifyAcl(hwnd, dwIndex);
SendMessage(GetDlgItem(hwnd,IDC_LIST1), LB_RESETCONTENT, 0, 0);
ModifyAcl(hwnd, 0);
}
}
BOOL Dlg3_OnInitDialogInit(HWND hwnd,HWND hwndFocus,LPARAM lParam)
{
// CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartHook, (LPVOID)hwnd, 0, NULL);
SendMessage(GetDlgItem(hwnd,IDC_LIST1), LB_RESETCONTENT, 0, 0);
ModifyAcl(hwnd, 0);
return(TRUE);
}
BOOL CALLBACK Dialog3ProcInit(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_INITDIALOG:
SetWindowLong(hwndDlg,DWL_MSGRESULT,(LONG)Dlg3_OnInitDialogInit(hwndDlg,(HWND)wParam,lParam));
case WM_COMMAND:
Dlg3_OnCommandInit(hwndDlg,HIWORD(wParam),LOWORD(wParam),(HWND)lParam);
break;
case WM_SYSCOMMAND:
Dlg3_OnCommandInit(hwndDlg,HIWORD(wParam),LOWORD(wParam),(HWND)lParam);
break;
}
return(FALSE);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void Dlg_OnCommand(HWND hwnd,UINT wNotifyCode,int wID,HWND hwndCtl)
{
switch(wID)
{
case IDCANCEL://最小化
SendMessage(hwnd,WM_SYSCOMMAND, SC_MINIMIZE, 0);
break;
case IDC_BUTTON6://退出程序
RUNNING = FALSE;
EndDialog(hwnd,wID);
Sleep(100);
break;
case IDC_BUTTON5://断开网络
//SendMessage(GetDlgItem(hwnd,IDC_LIST1), LB_RESETCONTENT, 0, 0);
EnableNet(FALSE);
EnableWindow(GetDlgItem(hwnd,IDC_BUTTON7), TRUE);
EnableWindow(GetDlgItem(hwnd,IDC_BUTTON5), FALSE);
break;
case IDC_BUTTON7://连接网络
//SendMessage(GetDlgItem(hwnd,IDC_LIST1), LB_RESETCONTENT, 0, 0);
EnableNet(TRUE);
EnableWindow(GetDlgItem(hwnd,IDC_BUTTON7), FALSE);
EnableWindow(GetDlgItem(hwnd,IDC_BUTTON5), TRUE);
break;
case IDC_BUTTON8://清空数据
SendMessage(GetDlgItem(hwnd,IDC_LIST2), LB_RESETCONTENT, 0, 0);
break;
case IDC_BUTTON1://网络状态
SendMessage(GetDlgItem(hwnd,IDC_LIST1), LB_RESETCONTENT, 0, 0);
FindNetHandle(hwnd);
break;
case IDC_BUTTON2://网络进程
WinExec("ProcessInfo.exe", SW_SHOWNORMAL);
break;
case IDC_BUTTON3://访问规则
SendMessage(GetDlgItem(hwnd,IDC_LIST1), LB_RESETCONTENT, 0, 0);
QueryAcl(hwnd);
break;
case IDC_BUTTON4://修改规则
// SendMessage(GetDlgItem(hwnd,IDC_LIST1), LB_RESETCONTENT, 0, 0);
// SendMessage(GetDlgItem(hwnd,IDC_LIST1), LB_ADDSTRING,0,(LPARAM)"help\0");
DialogBox(NULL,MAKEINTRESOURCE(IDD_DIALOG3),NULL,Dialog3ProcInit);
break;
}
}
BOOL Dlg_OnInitDialog(HWND hwnd,HWND hwndFocus,LPARAM lParam)
{
SendMessage(hwnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon((HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),MAKEINTRESOURCE(IDI_ICON1)));
SendMessage(hwnd,WM_SETICON,ICON_SMALL,(LPARAM)LoadIcon((HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),MAKEINTRESOURCE(IDI_ICON1)));
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)GetTime, NULL, 0, NULL);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Sniffer, hwnd, 0, NULL);
SendDlgItemMessage(hwnd, IDC_LIST1, LB_SETHORIZONTALEXTENT, 1000, 0); // 设置长度为1000像素的水平滚动条
// SendDlgItemMessage(hwnd, IDC_LIST1, LB_DIR, DDL_READWRITE | DDL_DIRECTORY | DDL_DRIVES, (LPARAM)"*.*"); // 设置长度为1000像素的水平滚动条
return(TRUE);
}
BOOL CALLBACK DialogProc(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_INITDIALOG:
SetWindowLong(hwndDlg,DWL_MSGRESULT,(LONG)Dlg_OnInitDialog(hwndDlg,(HWND)wParam,lParam));
case WM_COMMAND:
Dlg_OnCommand(hwndDlg,HIWORD(wParam),LOWORD(wParam),(HWND)lParam);
break;
}
return(FALSE);
}
/////////////////////////////////////////////////////////////////
void Dlg_OnCommandInit(HWND hwnd,UINT wNotifyCode,int wID,HWND hwndCtl)
{
switch(wID)
{
case SC_CLOSE:
EndDialog(hwnd, wID);
break;
}
}
BOOL Dlg_OnInitDialogInit(HWND hwnd,HWND hwndFocus,LPARAM lParam)
{
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartHook, (LPVOID)hwnd, 0, NULL);
return(TRUE);
}
BOOL CALLBACK DialogProcInit(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_INITDIALOG:
SetWindowLong(hwndDlg,DWL_MSGRESULT,(LONG)Dlg_OnInitDialogInit(hwndDlg,(HWND)wParam,lParam));
case WM_COMMAND:
Dlg_OnCommandInit(hwndDlg,HIWORD(wParam),LOWORD(wParam),(HWND)lParam);
break;
case WM_SYSCOMMAND:
Dlg_OnCommandInit(hwndDlg,HIWORD(wParam),LOWORD(wParam),(HWND)lParam);
break;
}
return(FALSE);
}
int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int)
{
if(!AdjustProcessPrivileges(SE_DEBUG_NAME))
return -1;
HANDLE CallEvent = CreateEvent(NULL, TRUE, TRUE, "HOOKALL");
DialogBox(hinstExe,MAKEINTRESOURCE(IDD_DIALOG2),NULL,DialogProcInit);
DialogBox(hinstExe,MAKEINTRESOURCE(IDD_DIALOG1),NULL,DialogProc);
ResetEvent(CallEvent);
CloseHandle(CallEvent);
return 0;
}
|