#include <Windows.h>
#include <iostream>
#include <string>
#include <vector>

// Define the DLL to inject
const char* dllPath = "path/to/your/dll.dll";

// Define the process to inject into
const char* processName = "League of Legends.exe";

// Define the thread creation function
HANDLE CreateRemoteThreadEx(HANDLE hProcess, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwStackSize, DWORD dwCreationFlags, LPDWORD lpThreadId) {
    HANDLE hThread = NULL;
    HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
    if (hKernel32 != NULL) {
        FARPROC pCreateRemoteThread = GetProcAddress(hKernel32, "CreateRemoteThread");
        if (pCreateRemoteThread != NULL) {
            hThread = ((HANDLE(__stdcall*)(HANDLE, SIZE_T, LPVOID, LPTHREAD_START_ROUTINE, LPVOID, DWORD, LPDWORD))pCreateRemoteThread)(hProcess, 0, lpParameter, lpStartAddress, NULL, 0, lpThreadId);
        }
    }
    return hThread;
}

// Define the DLL loading function
HMODULE LoadLibraryExEx(const char* lpFileName, HANDLE hFile, DWORD dwFlags) {
    HMODULE hModule = NULL;
    HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
    if (hKernel32 != NULL) {
        FARPROC pLoadLibraryEx = GetProcAddress(hKernel32, "LoadLibraryExW");
        if (pLoadLibraryEx != NULL) {
            hModule = ((HMODULE(__stdcall*)(LPCWSTR, HANDLE, DWORD))pLoadLibraryEx)(lpFileName, hFile, dwFlags);
        }
    }
    return hModule;
}

// Define the memory protection function
BOOL VirtualProtectEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect) {
    BOOL bResult = FALSE;
    HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
    if (hKernel32 != NULL) {
        FARPROC pVirtualProtectEx = GetProcAddress(hKernel32, "VirtualProtectEx");
        if (pVirtualProtectEx != NULL) {
            bResult = ((BOOL(__stdcall*)(HANDLE, LPVOID, SIZE_T, DWORD, PDWORD))pVirtualProtectEx)(hProcess, lpAddress, dwSize, flNewProtect, lpflOldProtect);
        }
    }
    return bResult;
}

// Define the anti-debug function
void AntiDebug() {
    // Implement your anti-debug techniques here
}

int main() {
    // Get the process ID of the target process
    DWORD pid = 0;
    HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (hProcessSnap != INVALID_HANDLE_VALUE) {
        PROCESSENTRY32 pe;
        pe.dwSize = sizeof(PROCESSENTRY32);
        if (Process32First(hProcessSnap, &pe)) {
            do {
                if (strcmp(pe.szExeFile, processName) == 0) {
                    pid = pe.th32ProcessID;
                    break;
                }
            } while (Process32Next(hProcessSnap, &pe));
        }
        CloseHandle(hProcessSnap);
    }

    if (pid == 0) {
        std::cout << "Failed to get process ID" << std::endl;
        return 1;
    }

    // Get a handle to the target process
    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
    if (hProcess == NULL) {
        std::cout << "Failed to get process handle" << std::endl;
        return 1;
    }

    // Create a new thread in the target process
    HANDLE hThread = CreateRemoteThreadEx(hProcess, (LPTHREAD_START_ROUTINE)dllPath, NULL, 0, 0, NULL);
    if (hThread == NULL) {
        std::cout << "Failed to create remote thread" << std::endl;
        return 1;
    }

    // Load the DLL into the target process
    HMODULE hModule = LoadLibraryExEx(dllPath, NULL, LOAD_LIBRARY_AS_DATAFILE);
    if (hModule == NULL) {
        std::cout << "Failed to load DLL" << std::endl;
        return 1;
    }

    // Change the memory protection of the DLL
    DWORD oldProtect;
    VirtualProtectEx(hProcess, h