能力值:
( LV4,RANK:50 )
3 楼
// QQSubclass.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include"resource.h"
#include "detours/detours.h"
#include <TCHAR.H>
#include <WINLDAP.H>
typedef int (__cdecl *QQFunOpenContactChatSession)(unsigned long,struct ITXData *);
typedef int (__cdecl *QQFunGetContactChatSessionMainHWnd)(unsigned long);
typedef int (__cdecl *QQFunGetIMVersion)(unsigned long);
typedef LRESULT (CALLBACK *SUBCLASSPROC)(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
typedef int (__cdecl *O_SetWindowSubclass)(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIdSubclass,
DWORD_PTR dwRefData);
QQFunOpenContactChatSession qqFunOpenContactChatSession;
QQFunOpenContactChatSession RealOpenContactChatSession;
QQFunGetContactChatSessionMainHWnd qqFunGetContactChatSessionMainHWnd;
QQFunGetIMVersion qqFunGetIMVersion;
O_SetWindowSubclass o_SetWindowSubclass;
LPVOID GetFunProc(LPCTSTR,LPCSTR);
WNDPROC fnOldWndProc;
HANDLE hModule;
int __stdcall sub_10009E1F(HWND hWnd, int a2, char *hData, int a4)
{
return 0;
}
int __cdecl sub_10008E0D(HWND hWnd, int a2)
{
int result;
HWND v5;
result = a2 - 32769;
switch(a2)
{
case 32783:
v5=CreateDialogParam((HINSTANCE)hModule, MAKEINTRESOURCE(IDD_DIALOG), hWnd, (DLGPROC)sub_10009E1F, 0);
result = SetPropW(hWnd, L"LeftHwnd", v5);
return result;
}
}
BOOL __cdecl ShowMenu(HWND hWnd)
{
OutputDebugStringA("ShowMenu");
HMENU hPopupMenu = CreatePopupMenu();
InsertMenu(hPopupMenu,0,MF_BYPOSITION,1000,"First");
InsertMenu(hPopupMenu,1,MF_BYPOSITION,1001,"Second");
POINT pt;
GetCursorPos(&pt);
int iSelection = TrackPopupMenu(hPopupMenu,
TPM_BOTTOMALIGN | TPM_RETURNCMD,
pt.x,pt.y, 0,hWnd,NULL);
sub_10008E0D(hWnd, iSelection);
return DestroyMenu(hPopupMenu);
}
static LRESULT CALLBACK SubclassWndProc(HWND hQQUIN, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
OutputDebugStringA("SubclassWndProc");
if (uMsg == WM_NCRBUTTONUP)
{
ShowMenu(hQQUIN);
return TRUE;
}
return CallWindowProc(fnOldWndProc, hQQUIN, uMsg,
wParam, lParam);
return TRUE;
}
void __cdecl MyOpenContactChatSession(unsigned long QQUIN,struct ITXData * xxx)
{
OutputDebugStringA("MyOpenContactChatSession");
o_SetWindowSubclass = (O_SetWindowSubclass)GetFunProc(_T("comctl32.dll"),"SetWindowSubclass");
if(o_SetWindowSubclass==NULL)
{
OutputDebugStringA("o_SetWindowSubclass==NULL");
return ;
}
OutputDebugStringA("o_SetWindowSubclass");
qqFunGetContactChatSessionMainHWnd = (QQFunGetContactChatSessionMainHWnd)GetFunProc(_T("AppUtil.dll"),"?GetChatSessionMainHWnd@ChatSession@Util@@YAPAUHWND__@@KH@Z");
if(qqFunOpenContactChatSession==NULL)
{
OutputDebugStringA("qqFunOpenContactChatSession");
return ;
}
if(QQUIN>10000)
{
OutputDebugStringA("qqFunGetContactChatSessionMainHWnd ==NULL");
qqFunGetContactChatSessionMainHWnd = (QQFunGetContactChatSessionMainHWnd)GetFunProc(_T("AppUtil.dll"),"?GetChatSessionMainHWnd@ChatSession@Util@@YAPAUHWND__@@KH@Z");
if(!IsWindow((HWND)qqFunGetContactChatSessionMainHWnd))
{
SetProp((HWND)qqFunGetContactChatSessionMainHWnd,"QQUIN",(HANDLE)QQUIN);
fnOldWndProc = (WNDPROC)SetWindowLong((HWND)qqFunGetContactChatSessionMainHWnd(QQUIN),GWL_WNDPROC,(DWORD)SubclassWndProc);
PostMessage((HWND)qqFunGetContactChatSessionMainHWnd(QQUIN), (WM_APP + 1), 0,0);
fnOldWndProc= (WNDPROC)SetWindowLong((HWND)qqFunGetContactChatSessionMainHWnd(QQUIN),GWL_WNDPROC, (DWORD)SubclassWndProc);
//o_SetWindowSubclass((HWND)qqFunGetContactChatSessionMainHWnd(QQUIN), (SUBCLASSPROC)SubclassWndProc, 0, 0);
}
typedef unsigned short (__cdecl * MYGETIMVERSION) (unsigned long);
unsigned short IMVersion = ((MYGETIMVERSION)GetProcAddress(LoadLibrary("KernelUtil"), "?GetIMVersion@Contact@Util@@YAGK@Z"))(QQUIN);
char tzTemp[MAX_PATH * 2];
unsigned short QQVersion = (IMVersion % 100 | ((unsigned __int8)(IMVersion / 100) << 8));
wsprintfA(tzTemp, "%d:%04X",QQUIN, QQVersion);
OutputDebugStringA(tzTemp);
}
RealOpenContactChatSession(QQUIN,xxx);
return ;
}
BOOL AttachQQFun(VOID)
{
OutputDebugStringA("AttachQQFun");
DetourRestoreAfterWith();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
RealOpenContactChatSession=(QQFunOpenContactChatSession)DetourFindFunction(_T("AppUtil.dll"),"?OpenContactChatSession@ChatSession@Util@@YAXKPAUITXData@@@Z");
if(RealOpenContactChatSession==NULL)
{
OutputDebugStringA("RealOpenContactChatSession");
return FALSE;
}
OutputDebugStringA("DetourAttach");
DetourAttach(&(PVOID&)RealOpenContactChatSession,MyOpenContactChatSession);
return DetourTransactionCommit()==NO_ERROR;
}
BOOL DetachQQFun(VOID)
{
OutputDebugStringA("DetachQQFun");
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)qqFunOpenContactChatSession,MyOpenContactChatSession);
return DetourTransactionCommit()==NO_ERROR;
}
LPVOID GetFunProc(LPCTSTR qqDllName,LPCSTR qqFunName)
{
HMODULE hMod = GetModuleHandle(qqDllName);
if(hMod == NULL)
{
TCHAR qqPath[MAX_PATH];
if(GetCurrentDirectory(MAX_PATH,qqPath)==0)
return NULL;
_tcscat(qqPath,qqDllName);
hMod = LoadLibrary(qqPath);
if(hMod==NULL)
return NULL;
}
return (LPVOID)GetProcAddress(hMod,qqFunName);
}
BOOL InitQQHook()
{
qqFunOpenContactChatSession = (QQFunOpenContactChatSession)GetFunProc(_T("AppUtil.dll"),"?OpenContactChatSession@ChatSession@Util@@YAXKPAUITXData@@@Z");
if(qqFunOpenContactChatSession==NULL)
return FALSE;
qqFunGetIMVersion = (QQFunGetIMVersion)GetFunProc(_T("KernelUtil.dll"),"?GetIMVersion@Contact@Util@@YAGK@Z");
if(qqFunGetIMVersion==NULL)
return FALSE;
return TRUE;
}
BOOL APIENTRY DllMain( HANDLE hinstDLL,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
hModule = hinstDLL;
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
OutputDebugStringA("InitQQHook");
if(InitQQHook()==FALSE)
{
OutputDebugStringA("InitQQHookerror");
MessageBox(NULL,_T("error"),_T("qqhook"),MB_OK);
return FALSE;
}
AttachQQFun();
break;
case DLL_PROCESS_DETACH:
DetachQQFun();
break;
}
return TRUE;
}
能力值:
( LV4,RANK:50 )
4 楼
int WINAPI Mysendto(SOCKET s, const char FAR * buf, int len, int flags, const struct sockaddr FAR * to, int tolen)
{
int retvalue;
char buff[512]={0};
char charQQNum[512]={0};
if(len==27 && *(byte*)buf ==3)
{
char *charIP;
char *charPosition;
CString strPosition;
charIP=inet_ntoa(((sockaddr_in *)to)->sin_addr);
strPosition = GetPosition(charIP);
charPosition = strPosition.GetBuffer(strPosition.GetLength());
int QQNum;
QQNum = (unsigned __int8)buf[26] | (((unsigned __int8)buf[25] | (((unsigned __int8)buf[24] | ((unsigned __int8)buf[23] << 8)) << 8)) << 8);
typedef unsigned short (__cdecl * MYGETIMVERSION) (unsigned long);
unsigned short IMVersion = ((MYGETIMVERSION)GetProcAddress(LoadLibrary("KernelUtil"), "?GetIMVersion@Contact@Util@@YAGK@Z"))(QQNum);
unsigned short QQVersion = (IMVersion % 100 | ((unsigned __int8)(IMVersion / 100) << 8));
char strQQVer[200];
char strQQVer1[200];
wsprintfA(strQQVer, "%04X",QQVersion);
DWORD dwRet = ReadString("版本大全", strQQVer, strQQVer1, "QQVersion.ini");
sprintf(&buff[strlen(buff)], "IP地址:%s 端口:%d\n所在地:%s \nQQ号码:%d QQ版本:%s", charIP,ntohs(((sockaddr_in *)to)->sin_port),charPosition,QQNum,strQQVer1);
sprintf(&charQQNum[strlen(charQQNum)],"%d",QQNum);
WritePrivateProfileString("WAN", charQQNum, charIP, Cacheini);
WritePrivateProfileString("IP", charIP, charPosition, Onlineini);
wchar_t wText[200];
MByteToWChar(buff,wText,sizeof(wText)/sizeof(wText[0]));
QQMsgInFrame(QQNum,wText,1);
OutputDebugStringA(buff);
}