Kod:
#include "stdafx.h"
#include <direct.h>
#include <Windows.h>
#include <TlHelp32.h>
#include <iostream>
#include <urlmon.h>
#include <shellapi.h>
#pragma comment (lib, "Urlmon.lib")
using namespace std;
void StartDefending();
void BlockInject(HANDLE, char*, char*);
bool CheckFiles();
bool LoadFile();
void Main();
HWND hwnd;
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
Main();
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
void Main(){
if(CheckFiles() == false){
MessageBoxA(hwnd, "Dosyalarını hatalı veya bulunamadı.\n"
"Yani Dosyalarınız indiriliyor.\n"
"Lütfen bekleyiniz, indirme bitince oyun otomatik olarak açılacaktır.", "Hata", MB_ICONERROR|MB_NOFOCUS);
LoadFile();
ExitProcess(0);
}
else{
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartDefending, NULL, 0, NULL);
}
}
bool CheckFiles(){
FILE *root_eix, *root_epk;
long eix, epk;
root_eix = fopen("pack/root.eix", "r");
root_epk = fopen("pack/root.epk", "r");
if(root_eix == NULL || root_epk == NULL)
return false;
else{
fseek(root_eix, 0, SEEK_END);
fseek(root_epk, 0, SEEK_END);
eix = ftell(root_eix);
epk = ftell(root_epk);
if(eix != 3040){
return false;
}
else if(eix == 3040){
return true;
}
else if(epk != 530528){
return false;
}
else if(epk == 530528){
return true;
}
}
}
bool LoadFile(){
ShellExecute(NULL, NULL, "M2Test.exe", NULL, NULL, SW_SHOWNORMAL);
return true;
}
void StartDefending(){
bool pointer=true;
bool pointer2=true;
while(1){
if(pointer){
if(GetAsyncKeyState(VK_LBUTTON) && 1){
pointer=false;
}
if(GetAsyncKeyState(VK_RBUTTON) && 1){
pointer=false;
}
}
if(!pointer){
if(pointer2){
if(GetAsyncKeyState(VK_LBUTTON) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_RBUTTON) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_TAB) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F1) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F2) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F3) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F4) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F5) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F6) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F7) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F8) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F9) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F10) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F11) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
if(GetAsyncKeyState(VK_F12) && 1){
BlockInject(GetCurrentProcess(), "NTDLL.dll", "LdrLoadDll");
pointer2=false;
}
}
}
}
}
void BlockInject(HANDLE process, char* libname, char* apiname)
{
DWORD pIP = 0;
DWORD pRet[]={0xC3};
BYTE Buff = sizeof(pRet);
VOID* pAddr = GetProcAddress(LoadLibraryA(libname), apiname);
WriteProcessMemory(GetCurrentProcess(), (LPVOID)pAddr, (LPVOID)pRet, Buff, &pIP);
}