当前位置:网站首页>Program development that runs the game is prohibited

Program development that runs the game is prohibited

2022-08-06 07:53:07Jiuyang 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

原网站

版权声明
本文为[Jiuyang Taoist]所创,转载请带上原文链接,感谢
https://chowdera.com/2022/218/202208060747561815.html

随机推荐