一段C语言代码不知道错哪儿了,请高手指教

GAP1994 发布于 2012/11/03 11:54
阅读 2K+
收藏 0
// J8_QQ.cpp : Defines the entry point for the DLL application.
//


#include "stdio.h"




#include <winsock2.h>
#include <afxinet.h>
#include <shlobj.h>
#include <shellapi.h> 
 
#pragma comment(lib,"ws2_32")
#pragma comment(lib,"msimg32")


//使用CSTRING
#ifdef _DEBUG
#pragma comment(lib, "libcmtd.lib")
#else
#pragma comment(lib, "libcmt.lib")
#endif 


#ifdef _DEBUG
#define OutputDebugText OutputDebugStringEx
#else
#define OutputDebugText
#endif


#ifdef _X86_
extern "C" { int _afxForceUSRDLL; }
#else
extern "C" { int __afxForceUSRDLL; }
#endif


typedef int (__stdcall *MYMOVEFILE)(LPCWSTR,LPCWSTR);


typedef int (__cdecl *MYISCURRENTCHATVIEWINCHATWND)(ULONG,int);
typedef int (__cdecl *MYOPENCONTACTCHATSESSION)(ULONG,struct ITXData *);
typedef int (__cdecl *MYOPENCHATSESSION)(ULONG,DWORD,struct ITXData *);
typedef int (__cdecl *MYGETTXCHATSESSION)(ULONG,int,struct ITXData *,DWORD);


typedef int (__cdecl *MYGETCONTACTCHATSESSIONMAINHWND)(ULONG);
typedef int (__stdcall *MYSENDTO)(SOCKET,const char FAR *,int,int,const struct sockaddr FAR *,int);
typedef int (__stdcall *MYCREATEPROCESS)(LPCWSTR ,LPWSTR ,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,LPVOID,LPCTSTR,LPSTARTUPINFO,LPPROCESS_INFORMATION);
typedef int (__cdecl *MYGETSTATUS)(ULONG);


//号码伪造
typedef int (__cdecl *MYGETSELFUIN)(VOID);
MYGETSELFUIN OldGetSelfUin;


//版本号伪造
typedef int (__cdecl *MyGETMAJORVER)(VOID);
MyGETMAJORVER OldGetMajorVer;
typedef int (__cdecl *MYGETMINORVER)(VOID);
MYGETMINORVER OldGetMinorVer;
//成员高亮
typedef int (__cdecl *MyGETTEXTCOLOR)(ULONG);
MyGETTEXTCOLOR OldGetTextColor;
//图标全开
typedef int (__cdecl *MYISVASFLAGVALID)(ULONG,UCHAR);
MYISVASFLAGVALID OldIsVASFlagValid;
typedef int (__cdecl *MYISVASFLAGVALIDEX)(ULONG,UCHAR,UINT);
MYISVASFLAGVALIDEX OldIsVASFlagValidEx;


typedef int (__cdecl *MyGETWANIP)(ULONG *,unsigned short *);
MyGETWANIP OldGetWanIP;


#define PlusVer "J8_QQ V1.0"


typedef int (__cdecl * QQMessageBoxExByHwnd)(HWND, wchar_t *,wchar_t *,UINT,DWORD,DWORD);
QQMessageBoxExByHwnd MessageBoxExByHwnd = NULL;


typedef int (__cdecl * CreateChatFrameType)(DWORD, unsigned long, DWORD *, DWORD);        //创建提示窗口
CreateChatFrameType CreateChatFrame = NULL;


typedef void (__cdecl * WriteMsgTipInChatSession)(DWORD, DWORD, const wchar_t *, DWORD);    //写入提示
typedef void (__cdecl * WriteMsgTipInChatSession2)(DWORD, DWORD, DWORD, const wchar_t *, DWORD);    //写入提示
WriteMsgTipInChatSession WriteMsgTip = NULL;
WriteMsgTipInChatSession2 WriteMsgTip2 = NULL;


typedef struct CTXBSTR
{
int zero;//貌似要一直是0
int count;//引用计数
int len1;
int len2;
wchar_t str[4100];
} TXStr, * pTXStr;
//本地会员
typedef int (__cdecl * ISFLAGVALID) (unsigned long, unsigned long);
ISFLAGVALID OldIsFlagValid = NULL;
//虚拟摄像头
typedef int (__cdecl * CHECKCAMERASTATUS) (unsigned long);
CHECKCAMERASTATUS OldCheckCameraStatus1 = NULL;
CHECKCAMERASTATUS OldCheckCameraStatus2 = NULL;


//无限发图
typedef int (__cdecl * CHECKMSGIMAGE) (unsigned long, unsigned long);
CHECKMSGIMAGE OldCheckMsgImage = NULL;
//插件过滤
typedef int (__cdecl * INITPLUGINCORECONFIG) (wchar_t *);
INITPLUGINCORECONFIG OldInitPluginCoreConfig = NULL;


typedef int (__cdecl * ENABLEPLUGIN) (wchar_t *);
ENABLEPLUGIN OldEnablePlugin = NULL;


typedef int (__cdecl * DISABLEPLUGIN) (wchar_t *);
DISABLEPLUGIN OldDisablePlugin = NULL;


HMODULE hModule;
MYISCURRENTCHATVIEWINCHATWND OldIsCurrentChatViewInChatWnd = NULL;
MYOPENCONTACTCHATSESSION OldOpenContactChatSession = NULL;
MYOPENCHATSESSION OldOpenChatSession = NULL;
MYGETTXCHATSESSION OldGetTXChatSession = NULL;
MYMOVEFILE OldMoveFile = NULL;
MYSENDTO Oldsendto = NULL;
MYCREATEPROCESS OldCreateProcess = NULL;
MYGETSTATUS OldGetStatus;
TCHAR   szPath[MAX_PATH];
TCHAR Onlineini[MAX_PATH];
TCHAR UACini[MAX_PATH];
TCHAR Cacheini[MAX_PATH];
BOOL bFlag = TRUE;
int nSave=0;
int nLocalVip=0;
int nMemClear=0;
int nSendPic=0;
int nCamStatus=0;
HINSTANCE hInst = NULL;   
HWND hwndDLG = NULL; 
COLORREF color=RGB(0,0,255);
LPVOID GetFunProc(LPCTSTR qqDllName,LPCSTR qqFunName);
int __cdecl PutMetadata(ULONG QQUIN, const OLECHAR *psz);


#ifndef WS_EX_LAYERED
#define WS_EX_LAYERED           0x00080000
#endif


#define LWA_COLORKEY 0x00000001 
#define LWA_ALPHA 0x00000002
typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes)(HWND hWnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags); 
lpfnSetLayeredWindowAttributes SetLayeredWindowAttributes;


BOOL AdjustWindow(HWND hWnd) 
{
if(IsIconic(GetParent(hWnd))) 
ShowWindow(hWnd,SW_HIDE);
if(GetForegroundWindow()!=GetParent(hWnd)) 
return false;
RECT Rect = {0}; 
GetWindowRect(GetParent(hWnd),&Rect);


return SetWindowPos(hWnd,HWND_NOTOPMOST,Rect.left+8,Rect.bottom-34,225,26,SWP_NOSENDCHANGING | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW); 
}


BOOL MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize)  

DWORD dwMinSize;    
dwMinSize = MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, NULL, 0);    
if(dwSize < dwMinSize)   
{     return FALSE;   
}        
MultiByteToWideChar (CP_ACP, 0, lpcszStr, -1, lpwszStr, dwMinSize);    
return TRUE; 
}


BOOL WCharToMByte(LPCWSTR lpcwszStr,LPSTR lpszStr,DWORD dwSize)
{
DWORD dwMinSize;
dwMinSize = WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,NULL,0,NULL,FALSE);
if(dwSize < dwMinSize)
{
return FALSE;
}
WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,lpszStr,dwSize,NULL,FALSE);
return TRUE;
}


VOID GetTxQQLocationInfo(LPCTSTR QQNum,char chText[]) 
{
CHAR IPInFile[255];
CHAR QQPosition[255];
CHAR LeftInfo[255];
DWORD dwReturnValue = 0; 

dwReturnValue = GetPrivateProfileString("WAN", QQNum, 0, IPInFile, 255, Cacheini);

if (dwReturnValue)
{
GetPrivateProfileString("IP", IPInFile, 0, QQPosition, 255, Onlineini);
wsprintf(LeftInfo,"%s\n%s",QQPosition,IPInFile);
strcpy(chText,LeftInfo);
strcat(chText,":");
}
else
{
strcpy(chText,"提示:发送截图可获取好友归属地\n");
}


return;


}
void DrawUI(HWND hDlg)
{
static HMENU  hMenu;
HDC hdc;
char chText[MAX_PATH];
HWND hParent;


RECT rect;
hdc=GetDC(hDlg);
color=RGB(0,0,255);
SetTextColor(hdc, color);
SetBkMode(hdc, TRANSPARENT); //透明背景 
GetClientRect(hDlg, &rect);
static HFONT hFont = CreateFont(-12, 0, 0, 0, FW_NORMAL, FALSE ,FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, _T("SimSun"));

SelectObject(hdc, hFont);


int QQhaoma;
int QQVer;
hParent=GetParent(hDlg);
QQhaoma = (int)GetProp(hParent, "QQUIN");
char szTemp[MAX_PATH];
wsprintf(szTemp,"%d",QQhaoma);


GetTxQQLocationInfo(szTemp, chText);
QQVer = (int)GetProp(hParent, "QQVer");
wsprintf(szTemp," %04X",QQVer);
if (QQVer)
{
CHAR QQVersion[MAX_PATH];
CHAR UnknownQQVersion[MAX_PATH];
wsprintf(UnknownQQVersion,"未知版本0x%04X",QQVer);
GetPrivateProfileString("版本大全", szTemp,UnknownQQVersion,QQVersion,255,".\\QQVersion.ini");
strcat(chText,QQVersion);

else
{
strcat(chText,"对方离线或隐身");
}


DrawText (hdc, chText, -1, &rect, DT_LEFT);


ReleaseDC(hDlg, hdc);


}


bool IsVistaSystem(void) 

static OSVERSIONINFO info; 
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&info); 
if (info.dwMajorVersion >= 6) return true; 
else return false;
return false; 
}


BYTE bAlpha=0;


BOOL CALLBACK DlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static HMENU  hMenu;

RECT Rect;
HWND hParent;


HDC hdc;
HDC hMemDC;


switch(message)
{

case WM_SETFOCUS:
{
hParent = GetParent(hDlg);
SetFocus(hParent);
}
break;


case WM_INITDIALOG:
        {
RegisterHotKey(hDlg,1983,NULL,VK_HOME);//注册快捷键


color=RGB(0,0,255);


ShowWindow(hDlg,SW_SHOW);
SetTimer(hDlg, 0, 10, NULL);


COLORREF maskColor=RGB(0,0,0); 
HMODULE hUser32 = GetModuleHandle("user32.dll"); 
SetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32,"SetLayeredWindowAttributes"); 
SetWindowLong(hDlg, GWL_EXSTYLE, GetWindowLong(hDlg, GWL_EXSTYLE) | WS_EX_LAYERED); 
SetLayeredWindowAttributes(hDlg, maskColor, 0, LWA_COLORKEY); 
FreeLibrary(hUser32); 
        }
break;
case WM_TIMER:
{
DrawUI(hDlg);
}
break;
case WM_PAINT:
        {
HBRUSH hBrush;
PAINTSTRUCT  ps;
OutputDebugString("paint.......................");
//清空该矩形内容,解决重叠
RECT rect;
hdc=GetDC(hDlg);
SetBkMode(hdc,TRANSPARENT);
GetClientRect(hDlg, &rect);
InvalidateRect(hDlg,&rect,FALSE);//
UpdateWindow(hDlg);


hdc = BeginPaint(hDlg, &ps);
{
hdc=GetDC(hDlg);
GetClientRect(hDlg,&Rect);

hBrush = CreateSolidBrush(RGB(0,0,0));

FillRect(hdc,&ps.rcPaint,hBrush);
ReleaseDC(hDlg,hdc);
DeleteObject(hBrush);
}
EndPaint(hDlg, &ps);
}
break;
case WM_HOTKEY:
{
if (LOWORD(wParam) == 1983)
{
if (IsWindowVisible(hDlg))
ShowWindow(hDlg,SW_HIDE);
else
{
ShowWindow(hDlg,SW_NORMAL);
SetForegroundWindow(hDlg);
}
}
}
break;
}
return (FALSE);
}


BOOL CopyStringToClipboard(HWND hWnd,LPCTSTR lpszText)
{
int nlen = strlen(lpszText);
if (nlen == 0)
return FALSE;

// 将szText中的内容复制到剪贴板
HGLOBAL hglbCopy;
LPTSTR lptstrCopy;

if (!OpenClipboard(hWnd))
return FALSE;

hglbCopy = GlobalAlloc(GMEM_DDESHARE,(nlen + 1) * sizeof(char)); 
if (hglbCopy == NULL) { CloseClipboard(); 
return FALSE; } 

EmptyClipboard();

lptstrCopy = (LPTSTR)GlobalLock(hglbCopy);
memcpy(lptstrCopy, lpszText, nlen); 
lptstrCopy[nlen] = (TCHAR) 0; // null character
GlobalUnlock(lptstrCopy); 
SetClipboardData(CF_TEXT, hglbCopy);
CloseClipboard();

return TRUE;
}


BOOL CENTER_WINDOW(HWND hWnd, HWND hParent)
{
    RECT rcWnd, rcParent;
    POINT ptNew;
    int nWidth;
    int nHeight;
    int nParentWidth;
    int nParentHeight;

    if (!IsWindow(hWnd))
        return FALSE;

    if (!IsWindow(hParent) || 0 == hParent)
        hParent = GetDesktopWindow();

    GetWindowRect(hWnd, &rcWnd);
    GetWindowRect(hParent, &rcParent);

    nWidth = rcWnd.right - rcWnd.left;
    nHeight = rcWnd.bottom - rcWnd.top;
    nParentWidth = rcParent.right - rcParent.left;
    nParentHeight = rcParent.bottom - rcParent.top;
    ptNew.x = rcParent.left + (nParentWidth - nWidth) / 2;
    ptNew.y = rcParent.top + (nParentHeight - nHeight) / 2;

    return MoveWindow(hWnd, ptNew.x, ptNew.y, nWidth, nHeight, TRUE);
}


#include <commctrl.h>
#define _WIN32_WINNT 0x600 // NT 版本 Windows XP, 0x600 = Windows Vista


typedef struct LVGROUP {
    UINT cbSize;
    UINT mask;
    LPWSTR pszHeader;
    int cchHeader;
    LPWSTR pszFooter;
    int cchFooter;
    int iGroupId;
    UINT stateMask;
    UINT state;
    UINT uAlign;
} LVGROUP, *PLVGROUP;


#define LVGF_NONE               0x00000000
#define LVGF_HEADER             0x00000001
#define LVGF_FOOTER             0x00000002
#define LVGF_STATE              0x00000004
#define LVGF_ALIGN              0x00000008
#define LVGF_GROUPID            0x00000010


#define LVGS_NORMAL             0x00000000
#define LVGS_COLLAPSED          0x00000001
#define LVGS_HIDDEN             0x00000002


#define LVGA_HEADER_LEFT        0x00000001
#define LVGA_HEADER_CENTER      0x00000002
#define LVGA_HEADER_RIGHT       0x00000004
#define LVGA_FOOTER_LEFT        0x00000008
#define LVGA_FOOTER_CENTER      0x00000010
#define LVGA_FOOTER_RIGHT       0x00000020


#define LVGMF_NONE              0x00000000
#define LVGMF_BORDERSIZE        0x00000001
#define LVGMF_BORDERCOLOR       0x00000002


#define LVIF_GROUPID 0x00000100
#define LVIF_COLUMNS 0x00000200


#define LVM_INSERTGROUP 0x00001091
#define LVM_ENABLEGROUPVIEW 0x0000109D
#define LVGS_COLLAPSIBLE 0x00000008
#define LVM_SETVIEW 0x0000108E
#define LV_VIEW_TILE 0x00000004
//
#define LVM_SETTILEVIEWINFO LVM_FIRST+162
#define LVTVIM_TILESIZE 0x00000001
#define LVTVIM_COLUMNS 0x00000002
#define LVTVIF_FIXEDSIZE 0x00000003


typedef struct tagLVTILEVIEWINFO
{
    UINT cbSize;
    DWORD dwMask;     
    DWORD dwFlags;    
    SIZE sizeTile;
    int cLines;
    RECT rcLabelMargin;
} LVTILEVIEWINFO, *PLVTILEVIEWINFO;


typedef struct tagMyLVITEMA
{
    UINT mask;
    int iItem;
    int iSubItem;
    UINT state;
    UINT stateMask;
    LPSTR pszText;
    int cchTextMax;
    int iImage;
    LPARAM lParam;
#if (_WIN32_IE >= 0x0300)
    int iIndent;
#endif
#if (_WIN32_WINNT >= 0x501)
    int iGroupId;
    UINT cColumns; 
    PUINT puColumns;
#endif
} MyLVITEMA, *MyLPLVITEMA;


#define MyLVITEM    MyLVITEMA


#define ListView_EnableGroupView(hwnd, fEnable) \
    (int)SNDMSG((hwnd),LVM_ENABLEGROUPVIEW, (WPARAM)(BOOL)(fEnable), (LPARAM)0)


#define ListView_InsertGroup(hwnd, index,pgrp) \
    (int)SNDMSG((hwnd),LVM_INSERTGROUP, (WPARAM)(BOOL)(index), (LPARAM)pgrp)


#define ListView_SetCheckState(hwnd, index, pgrp) \
ListView_SetItemState(hwnd,index,INDEXTOSTATEIMAGEMASK((pgrp)?2:1),LVIS_STATEIMAGEMASK)




typedef struct
{
char *PluginsPath;
char *PluginsName;
char *PluginsDesc;
int PluginsSuggetion;
}PLUGINSSTRUCT;
//可以禁用 =  0
//建议启用 =  1
//建议禁用 = -1
PLUGINSSTRUCT g_Plugins_Data[] = 
{
{"Com.Tencent.Advertisement", "QQ广告", "QQ界面广告插件,禁用此插件可以关闭QQ界面相关广告。", -1},
{"Com.Tencent.AudioVideo", "语音视频", "与QQ好友进行语音聊天和视频聊天时,必须要加载此插件。", 1},
{"Com.Tencent.CRM", "企业好友", "如果您有使用企业QQ的好友,建议将此插件打开,否则可以将其禁用。", 0},
{"Com.Tencent.FileTransfer", "文件传输", "与好友传送文件或手法QQ表情时,必须用到此插件。", 1},
{"Com.Tencent.Friendssocial", "腾讯朋友", "腾讯朋友相关插件,如果你不使用本功能,此插件可禁用。", 0},
{"Com.Tencent.GameLife", "游戏人生", "游戏人生是为腾讯游戏玩家提供的,聊天基本不会用到此功能。", -1},
{"Com.Tencent.Graffito", "涂鸦表情", "涂鸦表情功能帮您自主玩转表情,会员涂鸦表情可以便捷的给您的QQ配上文字。", -1},
{"Com.Tencent.HDVideo", "高清视频", "QQ会员才能使用的高清视频功能,非QQ会员可以禁用此插件。", 0},
{"Com.Tencent.Mail", "QQ邮箱", "从QQ主面板点击QQ邮箱图标,可以直接打开QQ邮箱并自动登录。", 1},
{"Com.Tencent.Memo", "网络备忘录","QQ提供的一个网络记事工具,QQ会员能享受备忘录漫游。", 0},
//
{"Com.Tencent.MMOG", "QQ网游", "腾讯提供多人电脑游戏联机服务的相关插件。", 0},
{"Com.Tencent.NetBar", "QQ网吧", "如果您在QQ合作的网吧登录,可享受经验值加成、免费道具等丰富多彩的活动和奖品。", -1},
{"Com.Tencent.NetDisk", "网络硬盘", "网络硬盘提供文件的储存、访问、共享、备份和群共享功能,即免费网络储存空间服务。",1},
{"Com.Tencent.PaiPai", "拍拍购物", "腾讯旗下拍拍网购业务,如果您不需要使用拍拍购物,可以将此插件禁用。", -1},
{"Com.Tencent.PaiPaiGift", "拍拍礼物", "提醒您给快要过生日的QQ好友送礼物或接受QQ好友送来的礼物,此插件可禁用。", -1},
{"Com.Tencent.PayCenter", "QQ钱包", "从QQ主面板点击QQ钱包按钮,可以管理您的财付通和Q币。", 0},
{"Com.Tencent.QPlus", "Q+开放平台","开放式应用平台。用户可以便捷地进入互联网丰富多彩的世界,享受丰富的互联网应用。", 1},
{"Com.Tencent.QQGame", "QQ游戏", "从QQ主面板点击QQ游戏按钮,可进入QQ游戏并登陆。", 1},
{"Com.Tencent.QQLive", "QQ直播", "从QQ主面板点击QQ直播按钮,可进入QQ直播并登陆。", 0},
{"Com.Tencent.QQMusic", "QQ音乐", "从QQ主面板进入QQ音乐,禁用此插件可能导致聊天记录中的链接无法打开。", 0},
//
{"Com.Tencent.QQPet", "QQ宠物", "从QQ主面板进入QQ宠物的入口。如果你不使用宠物服务,可以禁用。", -1},
{"Com.Tencent.QQRing", "会员炫铃", "该服务为会员的上、下线及消息操作添加特殊的个性音效。", -1},
{"Com.Tencent.QQShow", "QQ秀", "QQ秀是网络个人虚拟形象装扮系统。如果你关闭了侧边栏,则可以禁用此插件。", 1},
{"Com.Tencent.QQVip", "QQ会员", "腾讯为QQ会员提供一些服务的入口,非QQ会员可以将此插件禁用。", 0},
{"Com.Tencent.QQVipMisc", "会员杂项", "QQ会员快捷功能菜单,登录提示由此插件提供。非QQ会员用户可以将此插件禁用。", 0},
{"Com.Tencent.QQWebsite", "QQ订阅", "QQ内置的一些腾讯官方网站的入口,比如QQ书签等,此插件可禁用。", 0},
{"Com.Tencent.Qzone", "QQ空间", "从QQ主面板点击QQ空间按钮,直接进入QQ空间并登陆。", 1},
{"Com.Tencent.RemoteHelp", "远程协助", "方便用户进行远程帮助好友处理电脑问题,功能与远程桌面连接类似。", 1},
{"Com.Tencent.SNSApp", "社交服务", "对好友进行关键词评价,发送抖动窗口和个性动作,展示QQ校友图标。", 1},
{"Com.Tencent.SoBar", "搜吧", "在搜吧您可以自由创建感兴趣的新版面,在该版面的主题涵盖范围内畅所欲言", -1},
//
{"Com.Tencent.Soso", "SOSO搜索", "可以搜索QQ表情,展示热门的QQ表情,并可以在聊天时搜索网页。", -1},
{"Com.Tencent.Stock", "股市行情", "在QQ主面板侧栏上点击QQ财经,可以实时关注财经信息。", -1},
{"Com.Tencent.Today", "迷你首页", "腾讯迷你首页,启动时弹出,可以显示今日相关新闻。如果你不需要可以禁用。", -1},
{"Com.Tencent.VAS", "好友状态", "向好友展示您的输入状态的插件。建议开启。", 1},
{"Com.Tencent.WBlog", "腾讯微博", "腾讯微博,用140个字记录生活中的点点滴滴,和朋友、同事一同分享无处不在的乐趣和感动。",0},
{"Com.Tencent.Weather", "天气预报", "在QQ主面板上展示天气预报信息和对方的地理位置。", 1},
{"Com.Tencent.WenWen", "问问", "在好友的资料面板中,展示该好友在问问里面提出的问题和参与的解答。", -1},
{"Com.Tencent.Winks", "魔法表情", "QQ会员的魔法表情,如果您不是会员,可以禁用此插件。", -1},
{"Com.Tencent.Wireless", "无线QQ", "无线QQ和手机短信相关业务。如果您不使用本功能,此插件可禁用。", 0},
{"com.tencent.Hrtx", "未知插件", "未找到此插件的描述,请根据插件路径自行判断。", 0},
};


int g_Plugins_Count = (sizeof(g_Plugins_Data) / 16);
BOOL CALLBACK PluginsMgrDlgProc(HWND hwnd,UINT message,WPARAM wParam, LPARAM lParam)  
{
int nEnable = 0;
HWND listView = GetDlgItem(hwnd, IDC_LIST);
switch (message)
    {
case WM_INITDIALOG:
        {
            ListView_SetExtendedListViewStyle(listView,,LVS_EX_GRIDLINES | LVS_EX_CHECKBOXES |  LVS_EX_FULLROWSELECT);


            ListView_EnableGroupView(listView, TRUE);

LVTILEVIEWINFO ltvi = { 0 };

            //Columns
            LVCOLUMN lc;
            lc.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM;
            
            lc.iSubItem = 0;
            lc.cx = 100;
            lc.pszText = _T("插件名称");
            ListView_InsertColumn(listView, 0, &lc);
            
            lc.iSubItem = 1;
            lc.cx = 180;
            lc.pszText = _T("插件路径");
            ListView_InsertColumn(listView, 1, &lc);
            
            lc.iSubItem = 2;
            lc.cx = 500;
            lc.pszText = _T("插件描述");
            ListView_InsertColumn(listView, 2, &lc);
            
            //Groups
            LVGROUP lg;
lg.cbSize = sizeof(LVGROUP);
if (IsVistaSystem())
{
//Windows Vista 以上可折叠
lg.mask = LVGF_HEADER | LVGF_STATE | LVGF_GROUPID | LVGF_ALIGN ;
lg.state = LVGS_COLLAPSIBLE;
}
else
{
lg.mask = LVGF_HEADER | LVGF_GROUPID | LVGF_ALIGN ;
}
            lg.pszHeader = L"可以禁用";
            lg.iGroupId = 101;
lg.uAlign = LVGA_HEADER_LEFT;
            ListView_InsertGroup(listView, -1, &lg);
            
            lg.pszHeader = L"建议启用";
            lg.iGroupId = 102;
lg.uAlign = LVGA_HEADER_LEFT;
            ListView_InsertGroup(listView, -1, &lg);
 
lg.pszHeader = L"建议禁用";
            lg.iGroupId = 103;
lg.uAlign = LVGA_HEADER_LEFT;
            ListView_InsertGroup(listView, -1, &lg);
            
            //items
            MyLVITEM li = {0};
            li.mask = LVIF_TEXT | LVIF_GROUPID | LVIF_COLUMNS;
            
for (int i = 0; i < g_Plugins_Count; i++)
{
switch( g_Plugins_Data[i].PluginsSuggetion )
{
case 0:
{
li.pszText = g_Plugins_Data[i].PluginsName;
li.iItem = i;
li.iSubItem = 0;
li.iGroupId = 101;
ListView_InsertItem(listView, &li);
ListView_SetItemText(listView, i, 1, g_Plugins_Data[i].PluginsPath);
ListView_SetItemText(listView, i, 2, g_Plugins_Data[i].PluginsDesc);
}
break;
case 1:
{
li.pszText = g_Plugins_Data[i].PluginsName;
li.iItem = i;
li.iSubItem = 0;
li.iGroupId = 102;
ListView_InsertItem(listView, &li);
ListView_SetItemText(listView, i, 1, g_Plugins_Data[i].PluginsPath);
ListView_SetItemText(listView, i, 2, g_Plugins_Data[i].PluginsDesc);
}
break;
case -1:
{
li.pszText = g_Plugins_Data[i].PluginsName;
li.iItem = i;
li.iSubItem = 0;
li.iGroupId = 103;
ListView_InsertItem(listView, &li);
ListView_SetItemText(listView, i, 1, g_Plugins_Data[i].PluginsPath);
ListView_SetItemText(listView, i, 2, g_Plugins_Data[i].PluginsDesc);
}
break;


}


if (GetPrivateProfileInt("插件过滤",g_Plugins_Data[i].PluginsPath, 0, ".\\JBQQ.ini"))
{
ListView_SetCheckState(listView,i,TRUE);
nEnable++;

}
else
{
ListView_SetCheckState(listView,i,FALSE);
}

}


char szCount[10];
HWND hCount= GetDlgItem(hwnd, IDC_COUNT);
wsprintf(szCount,"%d",g_Plugins_Count);
SetWindowText(hCount,szCount);


HWND hEnable= GetDlgItem(hwnd, IDC_ENABLE);
wsprintf(szCount,"%d",nEnable);
SetWindowText(hEnable,szCount);


SetFocus(listView);
        }
        break;
        
case WM_CLOSE:
EndDialog(hwnd, 0);
break;


case WM_COMMAND:  
switch(LOWORD(wParam))  

case IDC_ALL:
{
for(int i = 0; i < g_Plugins_Count; i++)
{
ListView_SetCheckState(listView,i,TRUE);
}
}
return TRUE;
case IDC_NOALL:
{
for(int i = 0; i < g_Plugins_Count; i++)
{
ListView_SetCheckState(listView,i,FALSE);
}
}
return TRUE;
case IDC_SUGGETION:
{
for(int i = 0; i < g_Plugins_Count; i++)
{
ListView_SetCheckState(listView,i,FALSE);
if (g_Plugins_Data[i].PluginsSuggetion == 0 ||
g_Plugins_Data[i].PluginsSuggetion == 1
)
{
ListView_SetCheckState(listView,i,TRUE);
}



}
}
return TRUE;
case IDOK:
{
for(int i = 0; i < g_Plugins_Count; i++)
{
BOOL bState = ListView_GetCheckState(listView,i);
CHAR szState[2];
wsprintf(szState,"%d",bState);
WritePrivateProfileString("插件过滤", g_Plugins_Data[i].PluginsPath, szState, ".\\JBQQ.ini");
char sz[MAX_PATH];
wsprintf(sz,"i=%d,插件路径:%s,状态:%d",i,g_Plugins_Data[i].PluginsPath,ListView_GetCheckState(listView,i));
OutputDebugString(sz);


}
MessageBoxExByHwnd(hwnd,L"设置成功请重新启动QQ!",L"提示",MB_ICONASTERISK,0,0);
}
case IDCANCEL:  
EndDialog(hwnd,0);  
return TRUE;
}  
                  break; 
    }
    return FALSE; 
}


BOOL CALLBACK SettingDlgProc(HWND hDlg,UINT message,WPARAM wParam, LPARAM lParam)  
{  
      switch(message)  
      {  
 case WM_INITDIALOG:
 {


 HWND hCamera =GetDlgItem(hDlg,IDC_CAMERA);
 if(GetPrivateProfileInt("常规设置","虚拟摄像头", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hCamera,BM_SETCHECK,TRUE,0);
 }


 HWND hSaveIP =GetDlgItem(hDlg,IDC_SAVEIP);
 if(GetPrivateProfileInt("常规设置","IP保存到消息", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hSaveIP,BM_SETCHECK,TRUE,0);
 }


 HWND hMemberLight =GetDlgItem(hDlg,IDC_MEMBERLIGHT);
 if(GetPrivateProfileInt("常规设置","成员高亮", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hMemberLight,BM_SETCHECK,TRUE,0);
 }


 HWND hRemoveChar =GetDlgItem(hDlg,IDC_REMOVECHAR);
 if(GetPrivateProfileInt("常规设置","去除提醒", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hRemoveChar,BM_SETCHECK,TRUE,0);
 }


 HWND hSendPIC =GetDlgItem(hDlg,IDC_SENDPIC);
 if(GetPrivateProfileInt("常规设置","群无限发图", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hSendPIC,BM_SETCHECK,TRUE,0);
 }


 HWND hShowIPInWnd =GetDlgItem(hDlg,IDC_SHOWIPINWND);
 if(GetPrivateProfileInt("常规设置","框内显示", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hShowIPInWnd,BM_SETCHECK,TRUE,0);
 }


 HWND hLocalVIP =GetDlgItem(hDlg,IDC_LOCALVIP);
 if(GetPrivateProfileInt("常规设置","本地会员", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hLocalVIP,BM_SETCHECK,TRUE,0);
 }
  HWND hMem =GetDlgItem(hDlg,IDC_MEM);
HWND hOtherQQ =GetDlgItem(hDlg,IDC_OTHERQQ);
HWND hSetQQVer =GetDlgItem(hDlg,IDC_SETQQVER);
HWND hVirtualIP =GetDlgItem(hDlg,IDC_VIRTUALIP);


HWND hSetMemNum =GetDlgItem(hDlg,IDC_SETMEMNUM);
HWND hOtherQQNum =GetDlgItem(hDlg,IDC_OTHERQQNUM);
HWND hSetQQVerNum =GetDlgItem(hDlg,IDC_SETQQVERNUM);
HWND hVirtualIPNum =GetDlgItem(hDlg,IDC_VIRTUALIPNUM);

EnableWindow(hSetMemNum,FALSE);
EnableWindow(hOtherQQNum,FALSE);
EnableWindow(hSetQQVerNum,FALSE);
EnableWindow(hVirtualIPNum,FALSE);


CHAR szSetText[60];
 if(GetPrivateProfileInt("常规设置","内存整理", 0, ".\\JBQQ.ini"))
 {
SendMessage(hMem,BM_SETCHECK,TRUE,0);
EnableWindow(hSetMemNum,TRUE);

GetPrivateProfileString("常规设置","内存整理", "0",szSetText,60, ".\\JBQQ.ini");
SetWindowText(hSetMemNum,szSetText);
 }
 if(GetPrivateProfileInt("常规设置","号码伪造", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hOtherQQ,BM_SETCHECK,TRUE,0);
 EnableWindow(hOtherQQNum,TRUE);
 
 GetPrivateProfileString("常规设置","号码伪造", "0",szSetText,60, ".\\JBQQ.ini");
 SetWindowText(hOtherQQNum,szSetText);
 }
 if(GetPrivateProfileInt("常规设置","版本号伪造", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hSetQQVer,BM_SETCHECK,TRUE,0);
 EnableWindow(hSetQQVerNum,TRUE);
 
 GetPrivateProfileString("常规设置","版本号伪造", "0",szSetText,60, ".\\JBQQ.ini");
 SetWindowText(hSetQQVerNum,szSetText);
 }
 if(GetPrivateProfileInt("常规设置","虚拟地址", 0, ".\\JBQQ.ini"))
 {
 SendMessage(hVirtualIP,BM_SETCHECK,TRUE,0);
 EnableWindow(hVirtualIPNum,TRUE);
 
 GetPrivateProfileString("常规设置","虚拟地址", "0",szSetText,60, ".\\JBQQ.ini");
 SetWindowText(hVirtualIPNum,szSetText);
 }
 }
 return TRUE;  
            case WM_COMMAND:  
                  switch(LOWORD(wParam))  
                  {  
                  case IDOK:  
                  case IDCANCEL:  
                        EndDialog(hDlg,0);  
                        return TRUE;  
                  }  
                  break;  
      }  
      return FALSE;  
}


void MyMenuMsg(HWND hWnd,int iSelection)
{
switch(iSelection)
{
case IDM_COPYIP:
{
ULONG QQUIN = (ULONG)GetProp(hWnd,"QQUIN");
USHORT QQVer = (USHORT)GetProp(hWnd , "QQVer");
CHAR IPInFile[255];
CHAR LanIPInFile[255];
CHAR QQPosition[255];
CHAR QQNum[MAX_PATH];
CHAR QQIPInfo[MAX_PATH];
CHAR QQVersion[MAX_PATH];

wsprintf(QQNum, "%d",QQUIN);
GetPrivateProfileString("WAN", QQNum, 0, IPInFile, 255, Cacheini);
if (IPInFile[0])
{
GetPrivateProfileString("LAN", QQNum, 0, LanIPInFile, 255, Cacheini);
GetPrivateProfileString("IP", IPInFile, 0, QQPosition, 255, Onlineini);


//读取对应的QQ版本
CHAR UnknownQQVersion[MAX_PATH];
CHAR QQVerTemp[MAX_PATH];
wsprintf(QQVerTemp, "%04X",QQVer);
if (QQVer)
{
wsprintf(UnknownQQVersion,"未知版本0x%04X",QQVer);
GetPrivateProfileString("版本大全", QQVerTemp,UnknownQQVersion,QQVersion,255,".\\QQVersion.ini");


}
else
{
strcpy(QQVersion,"对方离线或隐身");
}


wsprintf(QQIPInfo, "所在地:%s \n外网IP:%s \n内网IP:%s \nQQ版本:%s \n",QQPosition,IPInFile,LanIPInFile,QQVersion);

CopyStringToClipboard(hWnd,QQIPInfo);
wchar_t wText[200];
MByteToWChar(QQIPInfo,wText,sizeof(wText)/sizeof(wText[0]));
MessageBoxExByHwnd(hWnd,wText,L"已复制",MB_ICONASTERISK,0,0);
}
else
{
MessageBoxExByHwnd(hWnd,L"尚未探测到好友的归属地!\n发送截图可探测!",L"提示",MB_ICONHAND,0,0);
}


}
break;
}
switch(iSelection)
{
case IDM_PLUGINSMGR:
{
InitCommonControls();
HWND hPluginsMgrDlg = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_PLUGINSMGR),hWnd,(DLGPROC)PluginsMgrDlgProc, 0);
ShowWindow(hPluginsMgrDlg,SW_NORMAL);
CENTER_WINDOW(hPluginsMgrDlg,hWnd);
}
break;
}
switch(iSelection)
{
case IDM_NOTEPAD:
{
ShellExecute(hWnd,"open","notepad.exe","","", SW_SHOW);
}
break;
}

switch(iSelection)
{
case IDM_CALC:
{
ShellExecute(hWnd,"open","calc.exe","","", SW_SHOW );
}
break;
}

switch(iSelection)
{
case IDM_MYWEB:
{
ShellExecute(hWnd,"open","http://hi.baidu.com/175943462","","", SW_SHOW );
}
break;
}

switch(iSelection)
{
case IDM_SETTING:
{
HWND hSettingDlg = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_SETTING),hWnd,(DLGPROC)SettingDlgProc, 0);
ShowWindow(hSettingDlg,SW_NORMAL);
CENTER_WINDOW(hSettingDlg,hWnd);
}
break;
}

}


void CreateMenus(HWND hWnd)
{
int iSelection;
HMENU hMenu,hSubMenu;
POINT Point;
RECT Rect;
GetCursorPos(&Point);


hMenu = CreatePopupMenu();
hSubMenu = CreatePopupMenu();

AppendMenu(hSubMenu,MF_STRING,IDM_NOTEPAD,"记事本");
AppendMenu(hSubMenu,MF_STRING,IDM_CALC,"计算器");


AppendMenu(hMenu,MF_STRING,IDM_COPYIP,"复制---IP");
AppendMenu(hMenu,MF_STRING,IDM_PLUGINSMGR,"插件管理");
    AppendMenu(hMenu,MF_POPUP,(UINT_PTR)hSubMenu,"常用工具");
    AppendMenu(hMenu,MF_STRING,IDM_MYWEB,"我的博客");
// AppendMenu(hMenu,MF_STRING,IDM_SETTING,"选项设置");


HWND hDlg = (HWND)GetProp(hWnd,"LeftHwnd");
GetWindowRect(hDlg,&Rect);
if (PtInRect(&Rect, Point))
iSelection = TrackPopupMenu(hMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD,Point.x,Point.y,0,hWnd,NULL);


MyMenuMsg(hWnd, iSelection);
DestroyMenu(hMenu);




}
static WNDPROC OldWndProc;
LRESULT CALLBACK fnSubClass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
//OutputDebugString("进入子类化");
HWND hLeftWnd;


LRESULT (__stdcall *v8)(HWND, UINT, WPARAM, LPARAM);
v8 = (LRESULT (__stdcall *)(HWND, UINT, WPARAM, LPARAM))GetProp(hWnd, "J8QQProc");
hLeftWnd = (HWND)GetProp(hWnd, "LeftHwnd");


switch(uMsg)
{
case WM_NCRBUTTONUP:
{
CreateMenus(hWnd);
}
break;
default:
break;
}


AdjustWindow(hLeftWnd);//need  xxx  message....i only konw a little...so i pasete here
return CallWindowProc(v8, hWnd, uMsg, wParam, lParam);

}


short __cdecl CreateInfoPane(ULONG QQUIN)
{
HWND hChatMainWnd;
HWND hContactWindowHWnd;
void *Result;
MYGETCONTACTCHATSESSIONMAINHWND GetContactChatSessionMainHWndAddr;
GetContactChatSessionMainHWndAddr = (MYGETCONTACTCHATSESSIONMAINHWND)GetProcAddress(LoadLibrary("AppUtil.dll"), 
(LPCSTR)"?GetContactChatSessionMainHWnd@ChatSession@Util@@YAPAUHWND__@@K @Z");
 
hChatMainWnd=(HWND)GetContactChatSessionMainHWndAddr(QQUIN);
hContactWindowHWnd = hChatMainWnd;
Result=(void *)IsWindow(hChatMainWnd);
/*
MYISCURRENTCHATVIEWINCHATWND IsCurrentChatViewInChatWndAddr = NULL;
IsCurrentChatViewInChatWndAddr = (MYISCURRENTCHATVIEWINCHATWND)GetProcAddress(LoadLibrary("AppUtil.dll"), 
(LPCSTR)"?IsCurrentChatViewInChatWnd@ChatSession@Util@@YAHKH@Z");
*/
if (Result)
{
hwndDLG = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_DIALOG),hChatMainWnd,(DLGPROC)DlgProc, 0);
SetProp(hChatMainWnd, "LeftHwnd", hwndDLG);
OldWndProc = (WNDPROC)GetWindowLong(hChatMainWnd,  GWL_WNDPROC);
SetProp(hChatMainWnd, "J8QQProc", (HANDLE)OldWndProc);
SetWindowLong(hChatMainWnd, GWL_WNDPROC,(DWORD)fnSubClass);


}
return (short)Result;
}


//获取状态
ULONG SelfQQUIN = 0;
USHORT __cdecl MyGetStatus(ULONG QQUIN)
{
USHORT uQQStatus = 0;
if(OldGetStatus) 
uQQStatus = OldGetStatus(QQUIN);


CHAR tzTemp[MAX_PATH];
wsprintf(tzTemp, "QQ:%d的状态 %d",QQUIN,uQQStatus);
OutputDebugString(tzTemp);


MYGETSELFUIN GetSelfUinAddr;
GetSelfUinAddr = (MYGETSELFUIN)GetProcAddress(LoadLibrary("KernelUtil.dll"), 
(LPCSTR)"?GetSelfUin@Contact@Util@@YAKXZ");
/*
if ((QQUIN == GetSelfUinAddr()) || (QQUIN == SelfQQUIN))
{
return  uQQStatus;
}
*/
int nChatMainWnd;


MYGETCONTACTCHATSESSIONMAINHWND GetContactChatSessionMainHWndAddr;
GetContactChatSessionMainHWndAddr = (MYGETCONTACTCHATSESSIONMAINHWND)GetProcAddress(LoadLibrary("AppUtil.dll"), 
(LPCSTR)"?GetContactChatSessionMainHWnd@ChatSession@Util@@YAPAUHWND__@@K @Z");

nChatMainWnd=(int)GetContactChatSessionMainHWndAddr(QQUIN);


if(uQQStatus == 10)
{
if (IsWindow((HWND)nChatMainWnd))
{
wsprintf(tzTemp, "QQ:%d的状态 %d 对方在线",QQUIN,uQQStatus);
OutputDebugString(tzTemp);
}


}


if(uQQStatus == 20) //20是离线,10是在线 30是离开 40是自己的在线状态,50是忙碌(隐身?),201是超级QQ在线 微信在线
{
if (IsWindow((HWND)nChatMainWnd))
{
wsprintf(tzTemp, "QQ:%d的状态 %d 对方不在线或隐身",QQUIN,uQQStatus);
OutputDebugString(tzTemp);
}


SelfQQUIN = QQUIN;
}
return uQQStatus;
}


void QQMsgInFrame(unsigned long QQUIN,wchar_t *lpText,int save)
{
MYGETCONTACTCHATSESSIONMAINHWND GetContactChatSessionMainHWndAddr;

GetContactChatSessionMainHWndAddr = (MYGETCONTACTCHATSESSIONMAINHWND)GetProcAddress(LoadLibrary("AppUtil.dll"), 
(LPCSTR)"?GetContactChatSessionMainHWnd@ChatSession@Util@@YAPAUHWND__@@K @Z");

HWND hWnd = (HWND)GetContactChatSessionMainHWndAddr(QQUIN);
if(!IsWindow(hWnd) ) return;    //避免无效窗口


TXStr MyMsg;
MyMsg.zero = 0;
MyMsg.count = 3;
wcsncpy(MyMsg.str, lpText,4096);
MyMsg.str[4096]=0;
MyMsg.len1 = MyMsg.len2 = wcslen(MyMsg.str) * sizeof(wchar_t);


if(WriteMsgTip&&CreateChatFrame)
{
DWORD pointer = 0;//0x11111111;
CreateChatFrame(QQUIN, 0, &pointer, 0);
WriteMsgTip(pointer, 0, MyMsg.str, save);
}
else
{
if(WriteMsgTip2)
{
WriteMsgTip2(QQUIN, 0, 0, MyMsg.str,save);
}
}
}


void ShowDlg(LPVOID lpVoid)   
{   
MSG msg;


hwndDLG = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_DIALOG),(HWND)lpVoid,(DLGPROC)DlgProc, 0);  
SetProp((HWND)lpVoid, "LeftWnd", hwndDLG);
PeekMessage(&msg, hwndDLG, 0U, 0U, PM_NOREMOVE);
while(msg.message != WM_QUIT)
{

if(PeekMessage(&msg, hwndDLG, 0U, 0U, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
Sleep(10);
}
}
}


//取得对方QQ版本
LPCTSTR GetQQVersion(HWND hChatMainWnd,ULONG QQUIN)
{
LPCTSTR lpReturnString;
CHAR QQVersion[MAX_PATH];
CHAR QQVerTemp[MAX_PATH];
typedef USHORT (__cdecl * MYGETIMVERSION) (ULONG);
USHORT uIMVersion = ((MYGETIMVERSION)GetProcAddress(LoadLibrary("KernelUtil"),
"?GetIMVersion@Contact@Util@@YAGK@Z"))(QQUIN);
USHORT QQVer = (uIMVersion  % 100 | ((UCHAR)(uIMVersion / 100) << 8));
SetProp(hChatMainWnd , "QQVer", (HWND)QQVer);
if (QQVer)
{
//读取对应的QQ版本
CHAR UnknownQQVersion[MAX_PATH];
wsprintf(QQVerTemp, "%04X",QQVer);

wsprintf(UnknownQQVersion,"未知版本0x%04X",QQVer);
GetPrivateProfileString("版本大全", QQVerTemp,UnknownQQVersion,QQVersion,255,".\\QQVersion.ini");
lpReturnString = QQVersion;

else
{
lpReturnString = "对方离线或隐身";
}
return lpReturnString;


}


VOID HideQQShow(HWND hWnd)
{
RECT Rect;
GetWindowRect(hWnd,&Rect);
int lParam1;
lParam1 = (unsigned __int16)(LOWORD(Rect.right) - Rect.left - 154) | ((Rect.bottom - Rect.top) / 2 << 16);
SendMessage(hWnd,WM_LBUTTONDOWN,1,lParam1);
SendMessage(hWnd,WM_LBUTTONUP,0,lParam1);
SendMessage(hWnd,WM_PAINT,0,0);
int lParam2;
lParam2 = ((unsigned __int16)(LOWORD(Rect.bottom) - LOWORD(Rect.top) - 112) << 16) | 0x19;
SendMessage(hWnd,WM_LBUTTONDOWN,1,lParam2);
SendMessage(hWnd,WM_LBUTTONUP,0,lParam2);


}


int __cdecl MyOpenContactChatSession(ULONG QQUIN,struct ITXData * xxx)
{
OutputDebugString("Entry MyOpenContactChatSession");
HWND hChatMainWnd;
short Result;


CHAR QQVerTemp[MAX_PATH];
CHAR tzTemp[MAX_PATH];
bFlag = TRUE;
MYGETCONTACTCHATSESSIONMAINHWND GetContactChatSessionMainHWndAddr;


GetContactChatSessionMainHWndAddr = (MYGETCONTACTCHATSESSIONMAINHWND)GetProcAddress(LoadLibrary("AppUtil.dll"), (LPCSTR)"?GetContactChatSessionMainHWnd@ChatSession@Util@@YAPAUHWND__@@K @Z");

wsprintf(tzTemp, "GetContactChatSessionMainHWndAddr1:%d",GetContactChatSessionMainHWndAddr);
OutputDebugString(tzTemp);


hChatMainWnd=(HWND)GetContactChatSessionMainHWndAddr(QQUIN);

Result=(short)OldOpenContactChatSession;
if (OldOpenContactChatSession)//这句有问题
Result=(short)OldOpenContactChatSession(QQUIN,xxx);
SetProp(hChatMainWnd, "GROUP", (HWND)QQUIN);


if (!hChatMainWnd && QQUIN>10000)
{


GetContactChatSessionMainHWndAddr = (MYGETCONTACTCHATSESSIONMAINHWND)GetProcAddress(LoadLibrary("AppUtil.dll"), (LPCSTR)"?GetContactChatSessionMainHWnd@ChatSession@Util@@YAPAUHWND__@@K @Z");


hChatMainWnd=(HWND)GetContactChatSessionMainHWndAddr(QQUIN);


SetProp(hChatMainWnd , "QQUIN", (HANDLE)QQUIN);


//隐藏qqShow
HideQQShow(hChatMainWnd);




//取得对方QQ版本
typedef USHORT (__cdecl * MYGETIMVERSION) (ULONG);
USHORT uIMVersion = ((MYGETIMVERSION)GetProcAddress(LoadLibrary("KernelUtil"),"?GetIMVersion@Contact@Util@@YAGK@Z"))(QQUIN);
USHORT QQVer = (uIMVersion  % 100 | ((UCHAR)(uIMVersion / 100) << 8));
wsprintf(QQVerTemp, "QQVerTemp:%04X",QQVer);
OutputDebugString(QQVerTemp);
SetProp(hChatMainWnd , "QQVer", (HWND)QQVer);


CreateInfoPane(QQUIN);
}

/*
if (20 == MyGetStatus(QQUIN))
{
OutputDebugString("对方不在线或隐身");

*/
if (bFlag)//bFlag的作用是只写入一次
{
CHAR QQIPInfo[MAX_PATH];
wchar_t wText[200];

CHAR QQPutIPInfo[MAX_PATH];
wchar_t wText1[200];

CHAR QQNum[MAX_PATH];
DWORD dwReturnValue = 0; 
CHAR TimeInFile[MAX_PATH];
wsprintf(QQNum, "%d",QQUIN);
dwReturnValue = GetPrivateProfileString("TIME", QQNum, 0, TimeInFile, 255, Cacheini);
if (dwReturnValue)
{
CHAR IPInFile[255];
CHAR LanIPInFile[255];
CHAR QQPosition[255];
GetPrivateProfileString("WAN", QQNum, 0, IPInFile, 255, Cacheini);
GetPrivateProfileString("LAN", QQNum, 0, LanIPInFile, 255, Cacheini);
GetPrivateProfileString("IP", IPInFile, 0, QQPosition, 255, Onlineini);
wsprintf(QQIPInfo, "所在地:%s \n外网IP:%s \n内网IP:%s \nQQ版本:%s \n",QQPosition,IPInFile,LanIPInFile,GetQQVersion(hChatMainWnd,QQUIN));


wsprintf(QQPutIPInfo, "所在地:%-30s     QQ版本:%s \n外网IP:%-35s     内网IP:%s",QQPosition,GetQQVersion(hChatMainWnd,QQUIN),IPInFile,LanIPInFile);



else
{
wsprintf(QQIPInfo, "尚未探测IP地址,发送截图探测。\n对方QQ版本:%s",GetQQVersion(hChatMainWnd,QQUIN));


wsprintf(QQPutIPInfo, "尚未探测IP地址,发送截图探测。\n对方QQ版本:%s",GetQQVersion(hChatMainWnd,QQUIN));


}


int nShowInfo;
nShowInfo = GetPrivateProfileInt("常规设置", "框内显示", 0, ".\\JBQQ.ini");
if (nShowInfo)
{
MByteToWChar(QQIPInfo,wText,sizeof(wText)/sizeof(wText[0]));
QQMsgInFrame(QQUIN,wText,0);


MByteToWChar(QQPutIPInfo,wText1,sizeof(wText1)/sizeof(wText1[0]));
PutMetadata(QQUIN, wText1); 
}


// MByteToWChar(QQIPInfo,wText,sizeof(wText)/sizeof(wText[0]));
// QQMsgInFrame(QQUIN,wText,0);
}
Result = 1;
return Result;



int __cdecl MyOpenChatSession(ULONG QQUIN,DWORD xx,struct ITXData * xxx)
{
OutputDebugString("Entry MyOpenChatSession");
if (OldOpenChatSession)
OldOpenChatSession(QQUIN,xx,xxx);
return 1;
}
int __cdecl MyGetTXChatSession(ULONG QQUIN,int x,struct ITXData * xx,DWORD xxx)
{
OutputDebugString("Entry MyGetTXChatSession");
if (OldGetTXChatSession)
OldGetTXChatSession(QQUIN,x,xx,xxx);
HWND hChatMainWnd;
MYGETCONTACTCHATSESSIONMAINHWND GetContactChatSessionMainHWndAddr;

GetContactChatSessionMainHWndAddr = (MYGETCONTACTCHATSESSIONMAINHWND)GetProcAddress(LoadLibrary("AppUtil.dll"), (LPCSTR)"?GetContactChatSessionMainHWnd@ChatSession@Util@@YAPAUHWND__@@K @Z");


hChatMainWnd=(HWND)GetContactChatSessionMainHWndAddr(QQUIN);


//取得对方QQ版本
typedef USHORT (__cdecl * MYGETIMVERSION) (ULONG);
USHORT uIMVersion = ((MYGETIMVERSION)GetProcAddress(LoadLibrary("KernelUtil"),"?GetIMVersion@Contact@Util@@YAGK@Z"))(QQUIN);
USHORT QQVer = (uIMVersion  % 100 | ((UCHAR)(uIMVersion / 100) << 8));


SetProp(hChatMainWnd , "QQUIN", (HANDLE)QQUIN);
SetProp(hChatMainWnd , "QQVer", (HWND)QQVer);
//去掉群和讨论组显示IP对话框
RECT Rect;
GetClientRect(hChatMainWnd, &Rect);


if (((Rect.right - Rect.left == 556) && (Rect.bottom - Rect.top == 520)) || 
((Rect.right - Rect.left == 602) && (Rect.bottom - Rect.top == 521)) )
{
OutputDebugString("Rect.bottom - Rect.top");
return 1;
}


HideQQShow(hChatMainWnd);


CreateInfoPane(QQUIN);
return 1;
}


CString GetPosition( LPCTSTR lpIPAddr,LPCTSTR lpURL,LPCTSTR lpLeftStr,LPCTSTR lpRightStr)
{
    CInternetSession    Session(PlusVer,1,INTERNET_OPEN_TYPE_DIRECT);
    CHttpFile    *HttpFile=NULL;
    CString        strData;
    CString        strUrl; 
    CString        strReturnStr="";
    strUrl.Format( lpURL, lpIPAddr );
    HttpFile = (CHttpFile*)Session.OpenURL( strUrl );
    while( HttpFile->ReadString( strData ) )
    {
        strReturnStr += strData;
    }

    HttpFile->Close();
    Session.Close();

    strReturnStr.Delete( 0, strReturnStr.Find(lpLeftStr) + 12 ); //再加上12个沉余字符


    int nPosLen = strReturnStr.Find(lpRightStr);
    CString    strPosition = strReturnStr.Left( nPosLen - 9 );    //减去9个HTML沉余的字符


strPosition.Replace(" ",NULL);//去掉空格
    return strPosition;
}


int __cdecl PutMetadata(ULONG QQUIN, const OLECHAR *psz)

{

int result;
int *pdata=new int(4);
//typedef int (__cdecl *MYCREATETXDATA)(struct ITXData * *);
typedef int (__cdecl *MYCREATETXDATA)(int * *);
MYCREATETXDATA CreateTXData;
CreateTXData=(MYCREATETXDATA)GetFunProc("Common.dll","?CreateTXData@Data @Util@@YAHPAPAUITXData@@@Z");
if (CreateTXData)
CreateTXData(&pdata);
//long __cdecl Util::Metadata::Put(struct ITXData *,wchar_t *,int)
typedef int (__cdecl *MYPUTMETADATA1)(int *,wchar_t *,int);
MYPUTMETADATA1 PutMetadata1;
PutMetadata1 = (MYPUTMETADATA1)GetFunProc("GF.dll","?Put@Metadata@Util@@YAJPAUITXData@@PA_WH@Z");
if (PutMetadata1)
PutMetadata1(pdata, L"nIconIndex", 18);

//long __cdecl Util::Metadata::Put(struct ITXData *,wchar_t *,wchar_t *)
typedef int (__cdecl *MYPUTMETADATA2)(int *,wchar_t *,wchar_t *);
MYPUTMETADATA2 PutMetadata2;
PutMetadata2 = (MYPUTMETADATA2)GetFunProc("GF.dll","?Put@Metadata@Util@@YAJPAUITXData@@PA_W1@Z");
if (PutMetadata2)
PutMetadata2(pdata,  L"strText", SysAllocString(psz));

//long __cdecl Util::Metadata::PutBOOL(struct ITXData *,wchar_t *,int)
typedef int (__cdecl *MYPUTBOOLMETADATA1)(int *,wchar_t *,int);
MYPUTBOOLMETADATA1 PutBOOLMetadata1;
PutBOOLMetadata1 = (MYPUTBOOLMETADATA1)GetFunProc("GF.dll","?PutBOOL@Metadata@Util@@YAJPAUITXData@@PA_WH@Z");
if (PutBOOLMetadata1)
{
PutBOOLMetadata1(pdata, L"bAutoLink", 1);
PutBOOLMetadata1(pdata, L"bCloseButton", 1);
}

//long __cdecl Util::Metadata::Put(struct ITXData *,wchar_t *,int)
if (PutMetadata1)
PutMetadata1(pdata, L"nLifetime", 600000);

//int __cdecl Util::ChatSession::ChatFrameEvent(unsigned long,enum ChatFrame::CFChatType,enum ChatFrame::CFEventType,struct ITXData *)
typedef int (__cdecl *MYCHATFRAMEEVENT)(ULONG,int,int,int *);
MYCHATFRAMEEVENT ChatFrameEvent;
ChatFrameEvent = (MYCHATFRAMEEVENT)GetFunProc("AppUtil.dll","?ChatFrameEvent@ChatSession@Util@@YAHKW4CFChatType@ChatFrame@@W4CFEventType@4@PAUITXData@@@Z"); 
if (ChatFrameEvent)
result = ChatFrameEvent(QQUIN, 0, 101, pdata);
else
result = -1;

return result;
}


CHAR QQLanIP[MAX_PATH];
int WINAPI Mysendto(SOCKET s, const char FAR * buf, int len,
int flags, const struct sockaddr FAR * to, int tolen)
{
ULONG                QQUIN;
CHAR   QQNum[MAX_PATH];
CHAR IPInFile[MAX_PATH];
CHAR LanIPInFile[MAX_PATH];

//取得局域网IP地址
if(len !=27 || *buf !=3)
{
if(!*buf)
{
if(len==1 || len ==84)
{
strcpy(QQLanIP,inet_ntoa(((sockaddr_in *)to)->sin_addr));
}
}
}


if(len==27 && *buf == 3)
{
char *QQIP=inet_ntoa(((sockaddr_in *)to)->sin_addr);
//取得对方QQ号码
QQUIN = (UCHAR)buf[26] | (((UCHAR)buf[25] | (((UCHAR)buf[24] | ((UCHAR)buf[23] << 8)) << 8)) << 8);
wsprintf(QQNum,"%d",QQUIN);


//取得对方QQ版本
typedef USHORT (__cdecl * MYGETIMVERSION) (ULONG);
USHORT uIMVersion = ((MYGETIMVERSION)GetProcAddress(LoadLibrary("KernelUtil"),
"?GetIMVersion@Contact@Util@@YAGK@Z"))(QQUIN);
USHORT QQVer = (uIMVersion  % 100 | ((UCHAR)(uIMVersion / 100) << 8));


//读取对应的QQ版本
CHAR QQVersion[MAX_PATH];
CHAR QQVerTemp[MAX_PATH];
CHAR UnknownQQVersion[MAX_PATH];
wsprintf(QQVerTemp, "%04X",QQVer);
wsprintf(UnknownQQVersion,"未知版本0x%04X",QQVer);
GetPrivateProfileString("版本大全", QQVerTemp,UnknownQQVersion,QQVersion,255,".\\QQVersion.ini");
OutputDebugString(QQVersion);

//对方地理位置
CString QQPositionTemp;
CHAR *QQPosition;
QQPositionTemp = GetPosition(QQIP,"http://www.ip138.com/ips1388.asp?ip=%s&action=2","本站主数据:","参考数据");
QQPosition = QQPositionTemp.GetBuffer(QQPositionTemp.GetLength());
CHAR tzTemp[MAX_PATH];
wsprintf(tzTemp, "IP地址:%s \n所在地:%s \nQQ号码:%d \nQQ版本:%s \nQQVer:%d",QQIP,QQPosition,QQUIN,QQVersion,QQVerTemp);
OutputDebugString(tzTemp);


//取得现在的时间
SYSTEMTIME LocalTime;
CHAR LocalTimeTemp[MAX_PATH];
GetLocalTime(&LocalTime);
wsprintf(LocalTimeTemp,"%04d%02d%02d",LocalTime.wYear,LocalTime.wMonth,LocalTime.wDay);

DWORD dwReturnValue = 0; 
CHAR TimeInFile[MAX_PATH];
dwReturnValue = GetPrivateProfileString("TIME", QQNum, 0, TimeInFile, 255, Cacheini);

if (dwReturnValue)//读到时间
{
if (strcmp(LocalTimeTemp,TimeInFile))//时间不等
{
WritePrivateProfileString("TIME", QQNum, LocalTimeTemp, Cacheini);
WritePrivateProfileString("WAN", QQNum, QQIP, Cacheini);
WritePrivateProfileString("IP", QQIP, QQPosition, Onlineini);
}
else
{
GetPrivateProfileString("WAN", QQNum, 0, IPInFile, 255, Cacheini);

if (strcmp(IPInFile,QQIP))//IP地址不等
{
color=RGB(255,0,0);
WritePrivateProfileString("WAN", QQNum, QQIP, Cacheini);
WritePrivateProfileString("IP", QQIP, QQPosition, Onlineini);
}
}


else
{
WritePrivateProfileString("TIME", QQNum, LocalTimeTemp, Cacheini);
WritePrivateProfileString("WAN", QQNum, QQIP, Cacheini);
WritePrivateProfileString("IP", QQIP, QQPosition, Onlineini);
}

if (QQLanIP)
{
GetPrivateProfileString("LAN", QQNum, 0, LanIPInFile, 255, Cacheini);

if (strcmp(LanIPInFile,QQLanIP))//局域网IP地址不等
{
WritePrivateProfileString("LAN", QQNum, QQLanIP, Cacheini);
}
}
else
{
WritePrivateProfileString("LAN", QQNum, "0:0:0:0", Cacheini);
}

if (bFlag)//bFlag的作用是只写入一次
{
CHAR QQIPInfo[MAX_PATH];
wchar_t wText[200];


CHAR QQPutIPInfo[MAX_PATH];
wchar_t wText1[200];


GetPrivateProfileString("WAN", QQNum, 0, IPInFile, 255, Cacheini);
GetPrivateProfileString("LAN", QQNum, 0, LanIPInFile, 255, Cacheini);
GetPrivateProfileString("IP", QQIP, 0, QQPosition, 255, Onlineini);
wsprintf(QQIPInfo, "所在地:%s \n外网IP:%s \n内网IP:%s \nQQ版本:%s \n",QQPosition,QQIP,LanIPInFile,QQVersion);
wsprintf(QQPutIPInfo, "所在地:%-30s     QQ版本:%s \n外网IP:%-35s     内网IP:%s",QQPosition,QQVersion,QQIP,LanIPInFile);
int nShowInfo;
nShowInfo = GetPrivateProfileInt("常规设置", "框内显示", 0, ".\\JBQQ.ini");
if (nShowInfo)
{
MByteToWChar(QQIPInfo,wText,sizeof(wText)/sizeof(wText[0]));
QQMsgInFrame(QQUIN,wText,nSave);


MByteToWChar(QQPutIPInfo,wText1,sizeof(wText1)/sizeof(wText1[0]));
PutMetadata(QQUIN, wText1);

if(hwndDLG) SendMessageW(hwndDLG,WM_PAINT,NULL,NULL);
}
bFlag = FALSE;
}

}


return Oldsendto(s, buf, len, flags, to, tolen);
}


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;
strcat(qqPath,qqDllName);

hMod = LoadLibrary(qqPath);
if(hMod==NULL)
return NULL;
}
return (LPVOID)GetProcAddress(hMod,qqFunName);
}


//本地会员
int __cdecl MyIsFlagValid(unsigned long QQUIN, unsigned long Flag)
{
MYGETSELFUIN GetSelfUinAddr;
GetSelfUinAddr = (MYGETSELFUIN)GetProcAddress(LoadLibrary("KernelUtil.dll"), 
(LPCSTR)"?GetSelfUin@Contact@Util@@YAKXZ");


if ( Flag == 4 &&  QQUIN == (ULONG)GetSelfUinAddr() && nLocalVip)
{
return 1;
}
// 调用原来的函数 
if(OldIsFlagValid) return OldIsFlagValid(QQUIN, Flag);

return 0;
}


int WINAPI OutputDebugStringEx(LPCSTR lpcFormatText, ...);
//插件过滤
int __cdecl  MyEnablePlugin(wchar_t *Path)
{
int nRetVal;
char chText[MAX_PATH]="";
WCharToMByte(Path,chText,MAX_PATH);
if (OldEnablePlugin)
{
OutputDebugText("启用%s插件",chText);
nRetVal = OldEnablePlugin(Path);
}
else
nRetVal = 0;

return nRetVal;
}


int __cdecl  MyDisablePlugin(wchar_t *Path)
{

int nRetVal;
char chText[MAX_PATH]="";
WCharToMByte(Path,chText,MAX_PATH);
if (OldDisablePlugin)
{
OutputDebugText("禁用%s插件",chText);
nRetVal = OldDisablePlugin(Path);
}
else
nRetVal = 0;

return nRetVal;

}


int __cdecl MyInitPluginCoreConfig(wchar_t *Path)
{
int nRet;
char chText[MAX_PATH]="";
WCharToMByte(Path,chText,MAX_PATH);
OutputDebugString(chText);
if(GetPrivateProfileInt("插件过滤", chText,0,".\\JBQQ.ini"))
{
//MyEnablePlugin(Path);
if (strcmp(chText,"Com.Tencent.Advertisement"))
nRet = ((INITPLUGINCORECONFIG)OldInitPluginCoreConfig)(Path);
}
else
{
//MyDisablePlugin(Path);
nRet = 1;
}
return nRet;
}


//号码伪造
ULONG __cdecl MyGetSelfUin(VOID)
{
// if (OldGetSelfUin)
// return OldGetSelfUin();
return 10000;
}


//版本伪造
CHAR QQMajorVer;
CHAR QQMinorVer;
UCHAR __cdecl MyGetMajorVer(VOID)
{
return QQMajorVer;

}


UCHAR __cdecl MyGetMinorVer(VOID)
{
return QQMinorVer;
}


//虚拟地址
CHAR QQWanIP[30];
long __cdecl MyGetWanIP(ULONG *INETADDR,USHORT *X)
{
*INETADDR = inet_addr(QQWanIP);
*X = 0;
return 1;
}


//成员高亮
MYGETSELFUIN GetSelfUinAddr;
typedef int (__cdecl *MYISBUDDY)(ULONG);
MYISBUDDY IsBuddyAddr;
int __cdecl MyGetTextColor(ULONG QQUIN)
{
int result;
GetSelfUinAddr = (MYGETSELFUIN)GetFunProc("KernelUtil.dll","?GetSelfUin@Contact@Util@@YAKXZ");
if (QQUIN == (ULONG)GetSelfUinAddr())
{
result = RGB(190,40,190);
}
else
{
IsBuddyAddr = (MYISBUDDY)GetFunProc("KernelUtil.dll","?IsBuddy@Contact@Util@@YAHK@Z");
if(IsBuddyAddr(QQUIN))
result = RGB(60,160,160);
else
result = OldGetTextColor(QQUIN);
}
return result;

}


VOID CreateFiles()
{

SHGetSpecialFolderPath(NULL,szPath,CSIDL_APPDATA,0);
strcat(szPath,"\\JiaoBen");

DWORD dwAttributes = GetFileAttributes(szPath);
if(!(dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
DeleteFile(szPath);
if(-1 == dwAttributes)
CreateDirectory(szPath,NULL);

strcpy(Onlineini,szPath);
strcat(Onlineini,"\\Online.ini");

strcpy(UACini,szPath);
strcat(UACini,"\\UAC.ini");

strcpy(Cacheini,szPath);
strcat(Cacheini,"\\Cache.ini");

//C:\Documents and Settings\Administrator\Application Data\JiaoBen
CreateFile(Onlineini,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_WRITE|FILE_SHARE_READ,0,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,0);
CreateFile(UACini,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_WRITE|FILE_SHARE_READ,0,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,0);
CreateFile(Cacheini,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_WRITE|FILE_SHARE_READ,0,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,0);

OutputDebugString(szPath);
}


DWORD LoadModuleEx(LPSTR lpcModuleName)
{
HMODULE hModule;


// 获取模块基址
hModule = GetModuleHandleA(lpcModuleName);
if (hModule == NULL) hModule = LoadLibrary(lpcModuleName);
return (DWORD)hModule;
}


DWORD GetModuleImageSize(PVOID lphModule)
{
DWORD dwResult = 0;
PIMAGE_DOS_HEADER lpDosHeaders;
PIMAGE_NT_HEADERS lpNtHeaders;

// 验证模块是否是PE文件
if (lphModule == NULL) return dwResult;

lpDosHeaders = (PIMAGE_DOS_HEADER)lphModule;
if (lpDosHeaders->e_magic == IMAGE_DOS_SIGNATURE)
{
lpNtHeaders = (PIMAGE_NT_HEADERS)((DWORD)lphModule + lpDosHeaders->e_lfanew);
if (lpNtHeaders->Signature == IMAGE_NT_SIGNATURE)
{
dwResult = lpNtHeaders->OptionalHeader.SizeOfImage;
}
}
return dwResult;
}


int WINAPI OutputDebugStringEx(LPCSTR lpcFormatText, ...)
{
char szBuffer[MAX_PATH];
    int retValue;
    va_list argptr;

    va_start(argptr, lpcFormatText);
    retValue = wvsprintf(szBuffer, lpcFormatText, argptr);
    va_end(argptr);

OutputDebugString(szBuffer);
return retValue;
}


DWORD BytePos(LPBYTE lpStartAddress, DWORD dwStartLen, LPBYTE lpSubAddress, DWORD dwSubLen, int iCout)
{
if (IsBadReadPtr((PVOID)lpStartAddress, (UINT)dwStartLen)) return -1;
if (IsBadReadPtr((PVOID)lpSubAddress, (UINT)dwSubLen)) return -1;


if ((lpStartAddress == NULL) || (lpSubAddress == NULL)) return -1;
if ((dwStartLen == 0) || (dwSubLen == 0) || (dwSubLen > dwStartLen)) return -1;

for (DWORD dwLoop = 0; dwLoop < dwStartLen; dwLoop++)
{
DWORD dwLoopEx = 0;
while (lpStartAddress[dwLoopEx] == lpSubAddress[dwLoopEx]) dwLoopEx++;
if (dwLoopEx == dwSubLen)
{
if ((iCout == 0) || (iCout == 1))
{
return dwLoop += 1;
}else iCout--;
}
lpStartAddress++;
}
return -1;
}


PVOID lpDLLPatch = NULL;
//========================================================================================
// 计算Patch地址
int CalePatchAddr(LPSTR lpcModuleName,byte szDLLRealCode[],int nSize,int nOffset,BYTE szPatch[],int nPatchSize)
{
int iResult = 0;


ULONG oData;
LPVOID hProcessMemory;
DWORD dwModuleSize, dwCodeOffset;


// 搜索dll模块
hProcessMemory = (LPVOID)LoadModuleEx(lpcModuleName);
dwModuleSize = GetModuleImageSize(hProcessMemory);
OutputDebugText("当前%s模块基址: %p, 模块镜像体积: %x", lpcModuleName,hProcessMemory, dwModuleSize);
if ((dwModuleSize)&&(hProcessMemory))
{


dwCodeOffset = BytePos((LPBYTE)hProcessMemory, dwModuleSize, szDLLRealCode, nSize, 0);
OutputDebugText("[%s]文件偏移:%p", lpcModuleName, dwCodeOffset);


if (dwCodeOffset != -1)
{
// 代码断点 = 模块基址 + 特征代码偏移 + 代码断点与特征代码相对偏移
lpDLLPatch = (PVOID)((DWORD)hProcessMemory + dwCodeOffset + nOffset);
OutputDebugText("[%s]要修改的内存偏移:%p", lpcModuleName, lpDLLPatch);


// 修改内存为可读写
VirtualProtect(lpDLLPatch, nPatchSize, PAGE_EXECUTE_READWRITE, &oData);


WriteProcessMemory(GetCurrentProcess(), lpDLLPatch, szPatch, nPatchSize, NULL);
// 还原内存属性
VirtualProtect(lpDLLPatch, nPatchSize, oData, &oData);
}else
{
iResult++;
lpDLLPatch = NULL;
OutputDebugText("[%s]代码断点抓取失败!", lpcModuleName);
}
}


return iResult;
}


BOOL MyMoveFile(LPCWSTR lpExistingFileName,LPCWSTR lpNewFileName)
{
BOOL bRet;
char chText[MAX_PATH]="";


WCharToMByte(lpExistingFileName,chText,MAX_PATH);
if(strstr(chText, "msimg32.dll"))
{
bRet = false;
}
else
{
bRet = OldMoveFile(lpExistingFileName,lpNewFileName);
}


return bRet;
}


//内存整理
void MemClear()
{
OutputDebugString("启动内存整理");
SetProcessWorkingSetSize(GetCurrentProcess(),-1,-1);
}


// 无限发图
int __cdecl MyCheckMsgImage(DWORD p1, DWORD p2)
{
    return 1;
}


//虚拟摄像头
int __cdecl MyCheckCameraStatus()
{
    return nCamStatus;
}


//禁止QQ升级
int __stdcall MyCreateProcess(
LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
BOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCTSTR lpCurrentDirectory,
LPSTARTUPINFO lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
)
{
OutputDebugStringW(lpApplicationName);
OutputDebugStringW(lpCommandLine);
//QQShow
if(wcsstr(lpCommandLine,L"QQExternal.exe"))
{
if(wcsstr(lpCommandLine,L"FlashService")) return 0;
}
if(wcsstr(lpCommandLine,L"auclt.exe"))
{
if(wcsstr(lpCommandLine,L"/MU")) return 0;
}
if(wcsstr(lpCommandLine,L"txupd.exe"))
{
if(wcsstr(lpCommandLine,L"/manual")) return 0;
}

    if(OldCreateProcess) 
return OldCreateProcess(lpApplicationName,
lpCommandLine,
lpProcessAttributes,
lpThreadAttributes,
bInheritHandles,
dwCreationFlags,
lpEnvironment,
lpCurrentDirectory,
lpStartupInfo,
lpProcessInformation);
    return 0;
}


int __cdecl MyIsCurrentChatViewInChatWnd(ULONG QQUin,int X)
{
OutputDebugString("Entry MyIsCurrentChatViewInChatWnd()");
char szTemp[MAX_PATH];
wsprintf(szTemp,"QQUin:%d int X:%d",QQUin,X);
OutputDebugString(szTemp);

if(OldIsCurrentChatViewInChatWnd)
return OldIsCurrentChatViewInChatWnd(QQUin,X);


return 1;
}


//图标全开
int __cdecl MyIsVASFlagValid(ULONG QQUIN,UCHAR X)
{


  MYGETSELFUIN GetSelfUinAddr;
  int result;


  GetSelfUinAddr = (MYGETSELFUIN)GetProcAddress(LoadLibrary("KernelUtil.dll"), 
(LPCSTR)"?GetSelfUin@Contact@Util@@YAKXZ");


  if ( QQUIN != (ULONG)GetSelfUinAddr() || X == 25 || X == 57 || X == 58 || X == 102 )
    result = OldIsVASFlagValid(QQUIN, X);
  else
    result = 1;
  return result;


}


int __cdecl MyIsVASFlagValidEx(ULONG QQUIN,UCHAR X,UINT XX)
{
  MYGETSELFUIN GetSelfUinAddr;
  int result;


  GetSelfUinAddr = (MYGETSELFUIN)GetProcAddress(LoadLibrary("KernelUtil.dll"), 
(LPCSTR)"?GetSelfUin@Contact@Util@@YAKXZ");


  if ( QQUIN != (ULONG)GetSelfUinAddr() || OldIsVASFlagValidEx)
    result = OldIsVASFlagValidEx(QQUIN, X, XX);
  else
    result = 1;
  return result;


}


BOOL InitHook()
{
OutputDebugString("Entry InitHook()");
//内存整理
if (nMemClear)
{
SetTimer(NULL, 0, 1000*nMemClear, (TIMERPROC)MemClear);//60秒一次
}


int iResult;


// 计算AppMisc.dll地址
//83 c4 04 b8 01 00 00 00 8b 4d 
//f4 64 89 0d 00 00 00 00 59 5f
//5e 5b 8b e5 5d c3 cc cc cc cc
//cc cc cc 55
byte szAppMiscRealCode1[] = {0x83, 0xC4, 0x04, 0xB8, 0x01, 0x00, 0x00, 0x00, 0x8B,0x4D, 
0xF4, 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x59,0x5F,
0x5E, 0x5B, 0x8B, 0xE5, 0x5D, 0xC3, 0xCC, 0xCC, 0xCC,0xCC,
0xCC, 0xCC, 0xCC, 0x55};
BYTE szAppMiscPatch1[] = {0xC3};
iResult = CalePatchAddr("AppMisc.dll", szAppMiscRealCode1, 34, 32, szAppMiscPatch1, sizeof(szAppMiscPatch1));


// 计算AppMisc.dll地址
//75 5C 6A 65 56 68 
byte szAppMiscRealCode2[] = {0x75, 0x5C, 0x6A, 0x65, 0x56, 0x68};
BYTE szAppMiscPatch2[] = {0xEB, 0x6D};
iResult = CalePatchAddr("AppMisc.dll", szAppMiscRealCode2, 6, -1, szAppMiscPatch2, sizeof(szAppMiscPatch2));


// 计算MsgMgr.dll地址
//59 5F 5E 5B 8B E5 5D C3 CC CC 
//CC CC CC CC CC 55 8B EC 6A FF 
//68 
byte szMsgMgrRealCode[] = {0x59, 0x5F, 0x5E, 0x5B, 0x8B, 0xE5, 0x5D, 0xC3, 0xCC, 0xCC,
  0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x55, 0x8B, 0xEC, 0x6A, 0xFF, 
  0x68};
BYTE szMsgMgrPatch[] = {0xC3};
iResult = CalePatchAddr("MsgMgr.dll", szMsgMgrRealCode, 21, 14, szMsgMgrPatch, sizeof(szMsgMgrPatch));


// 计算ChatFrameApp.dll地址
//E9 F2 FE FF
byte szChatFrameAppRealCode[] = {0xE9, 0xF2, 0xFE, 0xFF};
BYTE szChatFrameAppPatch[] = {0xC3};
iResult = CalePatchAddr("ChatFrameApp.dll", szChatFrameAppRealCode, 4, -338, szChatFrameAppPatch, sizeof(szChatFrameAppPatch));


// 计算IM.dll地址
//74 1A 8B CF FF D6
byte szIMRealCode1[] = {0x74, 0x1A, 0x8B, 0xCF, 0xFF, 0xD6};
BYTE szIMPatch1[] = {0xEB};
iResult = CalePatchAddr("IM.dll", szIMRealCode1, 6, -1, szIMPatch1, sizeof(szIMPatch1));


byte szIMRealCode2[] = {0xEB, 0x1A, 0x8B, 0xCF, 0xFF, 0xD6};
BYTE szIMPatch2[] = {0x90, 0x90};
iResult = CalePatchAddr("IM.dll", szIMRealCode2, 6, -24, szIMPatch2, sizeof(szIMPatch2));
    
//去除提醒
if ( GetPrivateProfileInt("常规设置", "去除提醒", 0, ".\\JBQQ.ini") )
{
//83 C4 0C 8B 0B 8B 55 F0 52 89
//4D C8 68
//文件偏移:0x829da
//内存偏移:0x660829da
byte szAppFrameworkCode[] = {0x83, 0xC4, 0x0C, 0x8B, 0x0B, 0x8B, 0x55, 0xF0, 0x52, 0x89,
0x4D, 0xC8, 0x68};
BYTE szAppFrameworkPatch[] = {0xEB, 0x21};
iResult = CalePatchAddr("AppFramework.dll", szAppFrameworkCode, 13, 2, szAppFrameworkPatch, sizeof(szAppFrameworkPatch));

//85 C0 74 0C 6A 03 56 FF 15
//文件偏移:0x888A9
//内存偏移:0x64B888A9
byte szChatFrameAppCode[] = {0x85, 0xC0, 0x74, 0x0C, 0x6A, 0x03, 0x56, 0xFF, 0x15};
BYTE szChatFrameAppPatch[] = {0xEB, 0x0C};
iResult = CalePatchAddr("ChatFrameApp.dll", szChatFrameAppCode, 9, 1, szChatFrameAppPatch, sizeof(szChatFrameAppPatch));
}
//图片查看AppMisc.dll
//55 8b ec 53 8b 5d 0c 56 57 53 68
//文件偏移:0x1cf560
//内存偏移:0x675CF560
byte szAppMiscCode[] = {0x55, 0x8B, 0xEC, 0x53, 0x8B, 0x5D, 0x0C, 0x56, 0x57, 0x53, 0x68};

//显隐藏图标
//又要写补丁~~~~~~

//防Msimg32.dll
OldMoveFile=(MYMOVEFILE)HookFunction("kernel32.dll","MoveFileW",(void *)MyMoveFile);
//阻止QQ自动更新
OldCreateProcess=(MYCREATEPROCESS)HookFunction("Kernel32.dll","CreateProcessW",(void *)MyCreateProcess);
//拦截聊天窗口

OldIsCurrentChatViewInChatWnd=(MYISCURRENTCHATVIEWINCHATWND)HookFunction("AppUtil.dll",
"?IsCurrentChatViewInChatWnd@ChatSession@Util@@YAHKH@Z",
(void *)MyIsCurrentChatViewInChatWnd);



OldOpenContactChatSession=(MYOPENCONTACTCHATSESSION)HookFunction("AppUtil.dll",
"?OpenContactChatSession@ChatSession@Util@@YAXKPAUITXData@@@Z",
(void *)MyOpenContactChatSession);


OldOpenChatSession=(MYOPENCHATSESSION)HookFunction("AppUtil.dll",
"?OpenChatSession@ChatSession@Util@@YAXKW4CFChatType@ChatFrame@@PAUITXData@@@Z",
(void *)MyOpenChatSession);


OldGetTXChatSession=(MYGETTXCHATSESSION)HookFunction("AppUtil.dll",
"?GetTXChatSession@ChatSession@Util@@YAHKHPAUITXData@@PAPAUIAFChatSession@@@Z",
(void *)MyGetTXChatSession);


Oldsendto=(MYSENDTO)HookFunction("ws2_32.dll","sendto",(void *)Mysendto);
/*
OldGetStatus=(MYGETSTATUS)HookFunction("KernelUtil.dll",
"?GetStatus@Contact@Util@@YAGK@Z",
(void *)MyGetStatus);


*/


//图标全开
OldIsVASFlagValid=(MYISVASFLAGVALID)HookFunction("KernelUtil.dll","?IsVASFlagValid@Contact@Util@@YAHKE@Z",(void *)MyIsVASFlagValid);
OldIsVASFlagValidEx=(MYISVASFLAGVALIDEX)HookFunction("KernelUtil.dll","?IsVASFlagValidEx@Contact@Util@@YAKKEI@Z",(void *)MyIsVASFlagValidEx);


//MessageBoxExByHwnd
MessageBoxExByHwnd = (QQMessageBoxExByHwnd)GetFunProc("AFUtil.dll","?MessageBoxExByHwnd@Misc@Util@@YAHPAUHWND__@@PA_W1IPAUITXData@@PAPAU4@@Z");
// 聊天窗口写字
CreateChatFrame = (CreateChatFrameType)GetFunProc("AppUtil.dll","?CreateChatFrameType@ChatSession@Util@@YAHKHPAPAUIAFChatFrameType@@PAUITXData@@@Z");
WriteMsgTip = (WriteMsgTipInChatSession)GetFunProc("AppUtil.dll","?WriteMsgTipInChatSession@AFChatSession@Util@@YAXPAUIAFChatFrameType@@W4IconIndex@@VCTXStringW@@H @Z");
if(!CreateChatFrame || !WriteMsgTip)
{
WriteMsgTip2 = (WriteMsgTipInChatSession2)GetFunProc("AppUtil.dll","?WriteMsgTipInChatSession@ChatSession@Util@@YAXKHW4IconIndex@@VCTXStringW@@H @Z");
}


//虚拟摄像头
if (nCamStatus)
{
OldCheckCameraStatus1=(CHECKCAMERASTATUS)HookFunction("Common.dll","?CheckCameraStatus@Detect@Util@@YAHXZ",(void *)MyCheckCameraStatus);


OldCheckCameraStatus2=(CHECKCAMERASTATUS)HookFunction("Common.dll","?CheckCameraStatus@Detect@Util@@YAHAAW4enumCamera@12 @@Z",(void *)MyCheckCameraStatus);
}


//本地会员
if (nLocalVip)
{
OldIsFlagValid=(ISFLAGVALID)HookFunction("KernelUtil.dll","?IsFlagValid@Contact@Util@@YAHKK@Z",(void *)MyIsFlagValid);
}


//成员高亮
if (GetPrivateProfileInt("常规设置","成员高亮",0,".\\JBQQ.ini"))
{
OldGetTextColor=(MyGETTEXTCOLOR)HookFunction("AFUtil.dll","?GetTextColor@CUserFlags@Contact@Util@@SAKK@Z",(void *)MyGetTextColor);
}
//号码伪造
//OldGetSelfUin=(MYGETSELFUIN)HookFunction("KernelUtil.dlll","?GetSelfUin@Contact@Util@@YAKXZ",(void *)MyGetSelfUin);

//版本号伪造
if (GetPrivateProfileInt("常规设置","版本号伪造",0,".\\JBQQ.ini"))
{
CHAR QQVer[1024];
GetPrivateProfileString("常规设置", "版本号伪造", "2B2B", QQVer, 1024, ".\\JBQQ.ini");


sscanf(QQVer, "%02X%02X", &QQMajorVer, &QQMinorVer);
OldGetMajorVer=(MyGETMAJORVER)HookFunction("KernelUtil.dll","?GetMajorVer@Version@@YAEXZ",(void *)MyGetMajorVer);
OldGetMinorVer=(MYGETMINORVER)HookFunction("KernelUtil.dll","?GetMinorVer@Version@@YAEXZ",(void *)MyGetMinorVer);
}
//虚拟地址
if (GetPrivateProfileInt("常规设置","虚拟地址",0,".\\JBQQ.ini"))
{
GetPrivateProfileString("常规设置", "虚拟地址", "182.254.21.20", QQWanIP, 30, ".\\JBQQ.ini");
OldGetWanIP=(MyGETWANIP)HookFunction("Common.dll","?GetWanIP@NetworkEnv@Util@@YAJPAKPAG@Z",(void *)MyGetWanIP);
}


//无限发图
if (nSendPic)
{
OldCheckMsgImage=(CHECKMSGIMAGE)HookFunction("KernelUtil.dll","?CheckMsgImage@Group @Util@@YAHPAUITXMsgPack@@AAVCTXStringW@@@Z",(void *)MyCheckMsgImage);
}

//插件过滤
OldInitPluginCoreConfig=(INITPLUGINCORECONFIG)HookFunction("Common.dll","?InitPluginCoreConfig@Boot@Util@@YAHPA_W@Z",(void *)MyInitPluginCoreConfig);
OldEnablePlugin=(ENABLEPLUGIN)HookFunction("Common.dll","?EnablePlugin@CoreCenter@Util@@YAHPA_W@Z",(void *)MyEnablePlugin);
OldDisablePlugin=(DISABLEPLUGIN)HookFunction("Common.dll","?DisablePlugin@CoreCenter@Util@@YAHPA_W@Z",(void *)MyDisablePlugin);
return true;
}


BOOL UnHook()
{
OutputDebugString("Entry UnHook()");


UnHookFunction("AppUtil.dll",
"IsCurrentChatViewInChatWnd@ChatSession@Util@@YAHKH@Z",
(void *)OldIsCurrentChatViewInChatWnd);


UnHookFunction("AppUtil.dll",
"?OpenContactChatSession@ChatSession@Util@@YAXKPAUITXData@@@Z",
(void *)OldOpenContactChatSession);


UnHookFunction("AppUtil.dll",
"?OpenChatSession@ChatSession@Util@@YAXKW4CFChatType@ChatFrame@@PAUITXData@@@Z",
(void *)OldOpenChatSession);


UnHookFunction("AppUtil.dll",
"?GetTXChatSession@ChatSession@Util@@YAHKHPAUITXData@@PAPAUIAFChatSession@@@Z",
(void *)OldGetTXChatSession);


UnHookFunction("ws2_32.dll","sendto",(void *)Oldsendto);
UnHookFunction("Kernel32.dll","CreateProcessW",(void *)OldCreateProcess);
//UnHookFunction("KernelUtil.dll","?GetStatus@FS @@YAHPB_WAAUtagTXFileStatus@@@Z",(void *)OldGetStatus);
UnHookFunction("KernelUtil.dll",
"?IsFlagValid@Contact@Util@@YAHKK@Z",
(void *)OldIsFlagValid);


//UnHookFunction("KernelUtil.dll","?GetSelfUin@Contact@Util@@YAKXZ",(void *)OldGetSelfUin);
UnHookFunction("KernelUtil.dll","?GetMajorVer@Version@@YAEXZ",(void *)OldGetMajorVer);
UnHookFunction("KernelUtil.dll","?GetMinorVer@Version@@YAEXZ",(void *)OldGetMinorVer);


UnHookFunction("KernelUtil.dll","?IsVASFlagValid@Contact@Util@@YAHKE@Z",(void *)OldIsVASFlagValid);
UnHookFunction("KernelUtil.dll","?IsVASFlagValidEx@Contact@Util@@YAKKEI@Z",(void *)OldIsVASFlagValidEx);


UnHookFunction("Common.dll","?GetWanIP@NetworkEnv@Util@@YAJPAKPAG@Z",(void *)OldGetWanIP);


UnHookFunction("AFUtil.dll","?GetTextColor@CUserFlags@Contact@Util@@SAKK@Z",(void *)OldGetTextColor);


if (OldCheckCameraStatus1)
{
UnHookFunction("Common.dll",
"?CheckCameraStatus@Detect@Util@@YAHXZ",
(void *)OldCheckCameraStatus1);
}


if (OldCheckCameraStatus2)
{
UnHookFunction("Common.dll",
"?CheckCameraStatus@Detect@Util@@YAHAAW4enumCamera@12 @@Z",
(void *)OldCheckCameraStatus2);
}


if (OldCheckMsgImage)
{
UnHookFunction("KernelUtil.dll",
"?CheckMsgImage@Group @Util@@YAHPAUITXMsgPack@@AAVCTXStringW@@@Z",
(void *)OldCheckMsgImage);
}


UnHookFunction("Common.dll",
"?InitPluginCoreConfig@Boot@Util@@YAHPA_W@Z",
(void *)OldInitPluginCoreConfig);


UnHookFunction("Common.dll",
"?EnablePlugin@CoreCenter@Util@@YAHPA_W@Z",
(void *)OldEnablePlugin);


UnHookFunction("Common.dll",
"?DisablePlugin@CoreCenter@Util@@YAHPA_W@Z",
(void *)OldDisablePlugin);


return true;

}


BOOL APIENTRY DllMain( HINSTANCE hInstDLL, 
 DWORD  ul_reason_for_call, 
 LPVOID lpReserved
 )
{


hInst=hInstDLL;
nSave = GetPrivateProfileInt("常规设置", "IP保存到消息", 0, ".\\JBQQ.ini");
nLocalVip = GetPrivateProfileInt("常规设置", "本地会员", 0, ".\\JBQQ.ini");
nMemClear = GetPrivateProfileInt("常规设置", "内存整理", 0, ".\\JBQQ.ini");
nSendPic = GetPrivateProfileInt("常规设置", "群无限发图", 0, ".\\JBQQ.ini");
nCamStatus = GetPrivateProfileInt("常规设置", "虚拟摄像头", 0, ".\\JBQQ.ini");
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CreateFiles();
if (!InitHook())
{
MessageBox(NULL,"InitHook失败","提示",MB_OK);
return false;
}
break;
case DLL_PROCESS_DETACH:
UnHook();
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}


加载中
0
iilicshi
iilicshi
太长了,哎。
0
地瓜儿
地瓜儿
这是WIN32汇编语言、、、还不能算c、、、你调试了,错误信息上来,别人才好回答、、、
0
中山野鬼
中山野鬼

引用来自“klttl”的答案

这是WIN32汇编语言、、、还不能算c、、、你调试了,错误信息上来,别人才好回答、、、
没环境,测都没得测。哈。
中山野鬼
中山野鬼
回复 @klttl : 现在专注SERVER上的东西,人要聚焦嘛。安心不搞微软的东西。
地瓜儿
地瓜儿
你都不玩微软的玩意,老鬼你要有微软的玩意,就帮着玩下呗,环境配置也挺简单,用vc6.0或vs,建一个win32框架,在写一个makefile,就可以玩了、、、 有哪位想测试玩下,也可以玩玩、、、
0
RC_黑暗天使
RC_黑暗天使
QQ显IP插件的源代码……
0
七合一的那只小金刚
七合一的那只小金刚
这事J8 QQ的代码吧。。。
返回顶部
顶部