当前位置:网站首页>Program development that runs the game is prohibited
Program development that runs the game is prohibited
2022-08-06 07:53:07【Jiuyang Taoist】
Development of programs to run the game is prohibited
文章目录
众所周知,Gaming is harmful to physical and mental health,There are quite a few methods and tools on the web to disable games from running,But the disadvantage is how you set the ban,Then click Unblock to start playing the game again.Based on this, a program that can only be started and cannot be canceled is developed again.
本文目的是基于Clanguage developed onePCend application layer program,When running the program, the related games are prohibited from running,This procedure is irreversible,This program will not be closed,The program will start automatically after booting,The window will be hidden after the program is running,在后台默默运行.
Unless you are a professional programmer,Otherwise, ordinary people cannot delete this program,The only way to play the game is to reinstall the system,This can achieve the effect of quitting the game to a certain extent.
开发原理:
- Use mutexes to achieve process uniqueness.
- This process will not be killed by ordinary users by using a dual-process daemon.
- Use the registry and the quick start directory to realize automatic startup at startup,At the same time, the self-starting items are continuously written in a loop,This way the user cannot delete the autostart mode,Similar to rogue programs.
- Hide the program window,后台默默运行.
Most of the most popular games now are from Penguin Factory,The following is to kill the penguinswegame和杀死LOL程序为列.Compile the following two codes as exeprogram in the same directory,After running one at random,My mother no longer has to worry about my studies.
1、Kill the game's main process code
#include <windows.h>
#include <TlHelp32.h>
#include <stdio.h>
#include <ShlObj_core.h>
// 隐藏控制台
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
// The quickstart directory starts
void StartupRun(LPCWSTR exePath)
{
// TODO: 在此处添加实现代码.
TCHAR szStartupPath[MAX_PATH] = {
};
TCHAR szExePath[MAX_PATH] = {
};
// 获取启动目录
BOOL bRet = ::SHGetSpecialFolderPath(NULL, szStartupPath, CSIDL_STARTUP, TRUE);
if (!bRet)
return;
// 原文件地址
wcscat_s(szExePath, exePath);
HRESULT hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
IShellLink *pIsl;
hr = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pIsl);
if (SUCCEEDED(hr))
{
IPersistFile* pIPF = NULL;
pIsl->SetPath(szExePath);
hr = pIsl->QueryInterface(IID_IPersistFile, (void**)&pIPF);
if (SUCCEEDED(hr))
{
int exeLength = lstrlen(exePath);
//The target address for creating the shortcut
TCHAR szDir[MAX_PATH] = {
};
memcpy_s(szDir, MAX_PATH, szStartupPath, wcslen(szStartupPath) * 2);
//printf("szStartupPath is %ls\nszDir is %ls\n", szStartupPath, szDir);
wcscat_s(szDir, L"\\svchost.lnk");
//printf("dir is %ls", szDir);
pIPF->Save(szDir, FALSE);
pIPF->Release();
}
pIsl->Release();
}
CoUninitialize();
}
}
// 注册表自启动 + Quick catalog starts automatically
void AutoRun()
{
// Get the full path of the program
wchar_t PathName[MAX_PATH] = {
};
GetModuleFileName(NULL, PathName, MAX_PATH);
// 修改注册表,添加自动启动
// 默认权限
HKEY hKey;
// 打开注册表键
if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_WRITE, &hKey))
{
return;
}
// 修改注册表值,实现开机自启
if (ERROR_SUCCESS != ::RegSetValueExW(hKey, L"SystemSetting", 0, REG_SZ, (BYTE *)PathName, (1 + ::lstrlen(PathName)) * 2))
{
::RegCloseKey(hKey);
return;
}
// 关闭注册表键
::RegCloseKey(hKey);
// Add to the quickstart directory
StartupRun(PathName);
}
// 防双开
bool IsAlreadyRun()
{
HANDLE hMutex = NULL;
hMutex = ::CreateMutex(NULL, FALSE, L"kill_lol");
if (hMutex)
{
if (ERROR_ALREADY_EXISTS == ::GetLastError())
{
return true;
}
}
return false;
}
// 守护进程
DWORD WINAPI daemon(LPVOID lParam)
{
HANDLE event1;
HANDLE event2;
STARTUPINFOA si = {
0 };
PROCESS_INFORMATION pi = {
0 };
event1 = CreateEventA(NULL, FALSE, TRUE, "Local\\p1");
while (true)
{
if (!(event2 = OpenEventA(EVENT_MODIFY_STATE, FALSE, "Local\\p2")))
{
CreateProcessA("spoolsl.exe",
NULL,
NULL,
NULL,
NULL,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi
);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
}
CloseHandle(event2);
Sleep(500);
}
return 0;
}
// Lai Mao self-starting
DWORD WINAPI ThreadAutoRun(LPVOID lParam)
{
while (true)
{
AutoRun();
Sleep(2000);
}
}
int main()
{
// 1、防双开
if (IsAlreadyRun())
{
::exit(0);
}
DWORD ThreadId;
// 2、自启动
CreateThread(NULL, 0, ThreadAutoRun, NULL, 0, &ThreadId);
// 3、Dual daemons
CreateThread(NULL, 0, daemon, NULL, 0, &ThreadId);
// 4、杀死LOLGame related process
while (true)
{
// Create a process snapshot
HANDLE hSnapProcess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 stcPe32 = {
sizeof(PROCESSENTRY32) };
// 用APITake a traversal snapshot
if (TRUE == Process32First(hSnapProcess, &stcPe32))
{
do
{
if (!wcscmp(L"WeGameMiniLoader.exe", stcPe32.szExeFile) || !wcscmp(L"wegame.exe", stcPe32.szExeFile) || !wcscmp(L"LeagueClient.exe", stcPe32.szExeFile)
|| !wcscmp(L"Client.exe", stcPe32.szExeFile))
{
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, stcPe32.th32ProcessID);
if (hProcess == NULL)
continue;
TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
}
} while (Process32Next(hSnapProcess, &stcPe32));
}
Sleep(1000);
}
return 0;
}
2、守护进程代码
#include <windows.h>
#include <stdio.h>
#include <ShlObj_core.h>
// 隐藏控制台
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
// The quickstart directory starts
void StartupRun(LPCWSTR exePath)
{
// TODO: 在此处添加实现代码.
TCHAR szStartupPath[MAX_PATH] = {
};
TCHAR szExePath[MAX_PATH] = {
};
// 获取启动目录
BOOL bRet = ::SHGetSpecialFolderPath(NULL, szStartupPath, CSIDL_STARTUP, TRUE);
if (!bRet)
return;
// 原文件地址
wcscat_s(szExePath, exePath);
HRESULT hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
IShellLink *pIsl;
hr = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pIsl);
if (SUCCEEDED(hr))
{
IPersistFile* pIPF = NULL;
pIsl->SetPath(szExePath);
hr = pIsl->QueryInterface(IID_IPersistFile, (void**)&pIPF);
if (SUCCEEDED(hr))
{
int exeLength = lstrlen(exePath);
//The target address for creating the shortcut
TCHAR szDir[MAX_PATH] = {
};
memcpy_s(szDir, MAX_PATH, szStartupPath, wcslen(szStartupPath) * 2);
//printf("szStartupPath is %ls\nszDir is %ls\n", szStartupPath, szDir);
wcscat_s(szDir, L"\\syshost.lnk");
//printf("dir is %ls", szDir);
pIPF->Save(szDir, FALSE);
pIPF->Release();
}
pIsl->Release();
}
CoUninitialize();
}
}
// 注册表自启动 + Quick catalog starts automatically
void AutoRun()
{
// Get the full path of the program
wchar_t PathName[MAX_PATH] = {
};
GetModuleFileName(NULL, PathName, MAX_PATH);
// 修改注册表,添加自动启动
// 默认权限
HKEY hKey;
// 打开注册表键
if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_WRITE, &hKey))
{
return;
}
// 修改注册表值,实现开机自启
if (ERROR_SUCCESS != ::RegSetValueExW(hKey, L"SystemLocalHost", 0, REG_SZ, (BYTE *)PathName, (1 + ::lstrlen(PathName)) * 2))
{
::RegCloseKey(hKey);
return;
}
// 关闭注册表键
::RegCloseKey(hKey);
StartupRun(PathName);
}
// 防双开
bool IsAlreadyRun()
{
// TODO: 在此处添加实现代码.
HANDLE hMutex = NULL;
hMutex = ::CreateMutex(NULL, FALSE, L"kill_lol2");
if (hMutex)
{
if (ERROR_ALREADY_EXISTS == ::GetLastError())
{
return true;
}
}
return false;
}
// Lai Mao self-starting
DWORD WINAPI ThreadAutoRun(LPVOID lParam)
{
while (true)
{
AutoRun();
Sleep(2000);
}
}
int main()
{
// 1、防双开
if (IsAlreadyRun())
{
::exit(0);
}
DWORD ThreadId;
// 2、自启动
CreateThread(NULL, 0, ThreadAutoRun, NULL, 0, &ThreadId);
// 3、双进程守护
HANDLE event1;
HANDLE event2;
STARTUPINFOA si = {
0 };
PROCESS_INFORMATION pi = {
0 };
event2 = CreateEventA(NULL, FALSE, TRUE, "Local\\p2");
while (true)
{
if (!(event1 = OpenEventA(EVENT_MODIFY_STATE, FALSE, "Local\\p1")))
{
CreateProcessA("Kill_LOL.exe",
NULL,
NULL,
NULL,
NULL,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi
);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
}
CloseHandle(event1);
Sleep(500);
}
return 0;
}
3、程序下载链接
链接:https://pan.baidu.com/s/1U6kyUpW5juDtwR-KqtOzzw?pwd=1234
提取码:1234
边栏推荐
猜你喜欢
随机推荐
- Datax3.0+DataX-Web builds distributed visual ETL system
- [Popular Science] What basic knowledge do I need to learn to engage in Web3?
- Original Questions for Level 5 of China Electronics Society Youth Grade Examination
- [Cloud Native--Kubernetes] Configuration Management
- Use Specification and Example to implement dynamic conditional query cases
- JMeter集合点
- JMeter关联执行
- JMeter代理录制手机app
- The origin of the name, concave language -, and moral
- [面试篇]Mysql 索引 BTree 与 B+Tree 的区别
- I set the global mapping table prefix in yml, but the database does not recognize it
- Simulate the realization of strcpy function (including multiple optimization ideas)
- Script for reverse generation of entity class, query and other interface xml of MySQL database
- 快速学会文件操作模块
- js simulates the function of dynamically deleting messages
- How to improve the quality of articles without being "recommended and affected" by the post assistant
- CSDN official plug-in
- C语言 结构体
- 【leetcode】8. 字符串转换整数 (atoi)
- "Digital reconstruction system, CEO is the first step"
- how to jump higher
- No, no, no, it's 2022, you don't know the principle of Jmeter, right?
- 测试用例设计方法-场景法详解
- 一文3000字解析Pytest单元测试框架【保姆级教程】
- 2022-08-05:以下go语言代码输出什么?A:65, string;B:A, string;C:65, int;D:报错。
- Jetpack WorkManager 看这一篇就够了~
- 关于np.zeros()第三个参数:c代表与c语言类似,行优先;F代表列优先的记录
- 腾讯云点播上传视频文件解决路径问题
- Parameter ‘courseId‘ not found. Available parameters are [arg1, arg0, param1, para
- LeetCode——345. 反转字符串中的元音字母
- LeetCode——1047. 删除字符串中的所有相邻重复项
- 山石发声 | 做好安全运营,没有你想象的那么难
- bpe 中文tokens
- dalle2:hierarchical text-conditional image generation with clip
- qwqの科技flag
- 2022海亮SC游记
- 20220803模拟
- 代码签名证书可以解决软件被杀毒软件报毒提醒吗?
- 使用aggird组件实现下滑请求分页从而实现无限滚动的效果
- 代码签名证书多少钱?