Project1
标题:
ACE CORE
[打印本页]
作者:
yangff
时间:
2011-12-23 23:59
标题:
ACE CORE
// RMPlus.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "hHookMonery.h"
#include <string>
bool Okay = false;
LRESULT CALLBACK newWndProc( HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
if (uMsg==WM_COMMAND)
{
//if (MPluginHost::Effect((long)LOWORD(wParam)))
if (LOWORD(wParam)>=60000)
{
//if (wParam==1000)
//MessageBox(0,L"hi",L"hi",0);
//return 0;
return 1;
}
}
if (uMsg==WM_INITMENU)
{
EnableMenuItem ((HMENU) LOWORD(wParam),60000,MF_ENABLED);
EnableMenuItem ((HMENU) LOWORD(wParam),0,MF_ENABLED);
//return 0;
}
if (uMsg==WM_INITMENUPOPUP)
{
EnableMenuItem ((HMENU) LOWORD(wParam),60000,MF_ENABLED);
EnableMenuItem ((HMENU) LOWORD(wParam),0,MF_ENABLED);
//MessageBox(0,L"hi",L"hi",0);
//return 0;
}
return CallWindowProc((WNDPROC)oProc,hwnd,uMsg,wParam,lParam);
}
bool FirstTime=true;
LRESULT WINAPI cbthookproc(int nCode,WPARAM wparam,LPARAM lparam)
{
if (GetCurrentProcessId ()!=hPid) return CallNextHookEx(hHook1,nCode,wparam,lparam);
//if (FirstTime)
if(nCode==HCBT_CREATEWND)
{
// 请想办法鉴定是不是主窗口
LPCBT_CREATEWND pstr=(LPCBT_CREATEWND)lparam;
if (pstr->lpcs->hwndParent==0&&pstr->lpcs->hMenu!=0){
FirstTime=false;
hWnd=(HWND)wparam;
oProc = SetWindowLong(hWnd,GWL_WNDPROC,(LONG)newWndProc);
HMENU hm = pstr->lpcs->hMenu;
hPop = CreatePopupMenu();
//AppendMenu (hPop,MF_STRING,(UINT_PTR)1000,L"管理(&A)");
InsertMenu(hPop,0,MF_STRING | MF_ENABLED,(UINT_PTR)60000,L"管理(&A)");
//AppendMenu (hPop,MF_SEPARATOR,(UINT_PTR)1001,NULL);
InsertMenu(hm,8,MF_POPUP,(UINT_PTR)hPop,L"插件(&P)");
EnableMenuItem ((HMENU) hPop,0,MF_ENABLED);
EnableMenuItem ((HMENU)hPop,60000,MF_ENABLED);
EnableMenuItem ((HMENU)hm,60000,MF_ENABLED);
}
}
return CallNextHookEx(hHook1,nCode,wparam,lparam);
}
LRESULT WINAPI skinhookproc(int nCode,WPARAM wparam,LPARAM lparam)
{
if (GetCurrentProcessId ()!=hPid) return CallNextHookEx(hHook,nCode,wparam,lparam);
CWPSTRUCT *msg = (CWPSTRUCT*)lparam;
if (msg->message==WM_CREATE)
{
wchar_t className[1024]={0};
::GetClassName(msg->hwnd,className,1024);
//if (lstrcmp(className,L"Afx:00400000:b:00010003:00000006:016B31F3")){
if (lstrcmp(className,L"Afx:00400000:b:00010003:00000006:053F11ED")==0&&!Okay){
//hMenu = CreateMenu();
//HMENU child = CreateMenu();
//AppendMenu(hMenu,16,(UINT_PTR)child,L"Plugin");
//SetMenu(GetParent(msg->hwnd),hMenu);}
//SetMenu(msg->hwnd,hMenu);
//hMenu=msg->hwnd;
//hWnd=(msg->hwnd);
///
//wchar_t wt[255];
//wsprintf(wt,L"Installed %d",hMenu);
//MessageBox(0,wt,L"Installed",0);
///
//oProc = GetWindowLong(hWnd,GWL_WNDPROC);
needInitProc=true;
Okay=true;
}
}
if (needInitProc&&msg->message==WM_PAINT)
{
/*wchar_t wt[255];
wsprintf(wt,L"Installed %d",hMenu);
MessageBox(0,wt,L"Installed",0);
TBBUTTON tb;
ZeroMemory(&tb,sizeof(tb));
tb.iBitmap=I_IMAGENONE ;
tb.idCommand=133;
tb.fsState=TBSTATE_ENABLED;
tb.fsStyle|=TBSTYLE_LIST | BTNS_DROPDOWN;
tb.iString=(INT_PTR)L"插件(&P)";
SendMessage(hMenu,TB_BUTTONSTRUCTSIZE,sizeof(tb),0);
SendMessage(hMenu,TB_ADDBUTTONS,1,(LPARAM)&tb);
SendMessage(hMenu,TB_AUTOSIZE,0,0);
hPop=CreateMenu();
setg=CreateMenu();
AppendMenu(hPop,16 | MF_POPUP,(UINT_PTR)setg,L"插件(&P)");
// HMENU setg1=CreateMenu();
AppendMenu(setg,MF_STRING,200,L"管理(&M)");*/
needInitProc=false;
// MessageBox(0,L"setover",L"setover",0);
}
return CallNextHookEx(hHook,nCode,wparam,lparam);
}
void CreateMenus()
{
}
int StartRM()
{
STARTUPINFO sif;
PROCESS_INFORMATION pif;
ZeroMemory( &pif, sizeof(pif) );
ZeroMemory( &sif, sizeof(sif) );
sif.cb=sizeof(sif);
hHook = SetWindowsHookEx(WH_CALLWNDPROC,&skinhookproc,hMod,0);
hHook1 = SetWindowsHookEx(WH_CBT,&cbthookproc,hMod,0);
if (CreateProcess(L"RPGVXAce.exe",NULL,NULL,NULL,false,NORMAL_PRIORITY_CLASS,NULL,NULL,&sif,&pif))
{
hPid=pif.dwProcessId;
return (int)hHook;
}else
return -2;
return -1;
}
int KillRM()
{
//
UnhookWindowsHookEx(hHook1);
return UnhookWindowsHookEx(hHook);
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
// printf("hModule.%p lpReserved.%p \n", hModule, lpReserved);
hMod=hModule;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:{
// printf("Process attach. \n");
break;
}
case DLL_PROCESS_DETACH:{
// printf("Process detach. \n");
break;}
case DLL_THREAD_ATTACH:
// printf("Thread attach. \n");
break;
case DLL_THREAD_DETACH:
// printf("Thread detach. \n");
break;
}
return (TRUE);
}
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1