В код ниже добавь ожидание процесса до 1 минуты времени:
#include <Windows.h>
#include <tlhelp32.h>
#include <fstream>
#include <vector>
#include <string>
#include "pch.h"

std::ofstream logFile("patcher_log.txt", std::ios::out | std::ios::app);

DWORD FindProcessId(const std::wstring& processName) {
    PROCESSENTRY32W processInfo;
    processInfo.dwSize = sizeof(PROCESSENTRY32W);

    HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    if (processesSnapshot == INVALID_HANDLE_VALUE) {
        logFile << "Failed to create process snapshot." << std::endl;
        return 0;
    }

    Process32FirstW(processesSnapshot, &processInfo);
    do {
        if (processName.compare(processInfo.szExeFile) == 0) {
            CloseHandle(processesSnapshot);
            return processInfo.th32ProcessID;
        }
    } while (Process32NextW(processesSnapshot, &processInfo));

    CloseHandle(processesSnapshot);
    return 0;
}

bool PatchProcess(DWORD processID) {
    HANDLE hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, processID);
    if (!hProcess) {
        logFile << "Failed to open the target process." << std::endl;
        return false;
    }

    BYTE signatureBytes[] = { 0x85, 0xC0, 0x74, 0x57, 0x5F, 0xB8, 0x01 };
    BYTE patchByte = 0x00;
    MEMORY_BASIC_INFORMATION mbi;
    bool success = false;

    for (BYTE* addr = nullptr; VirtualQueryEx(hProcess, addr, &mbi, sizeof(mbi)) && addr < (BYTE*)0x7FFFFFFF; addr += mbi.RegionSize) {
        if (mbi.State == MEM_COMMIT && (mbi.Protect == PAGE_EXECUTE_READWRITE || mbi.Protect == PAGE_EXECUTE_READ)) {
            std::vector<BYTE> buffer(mbi.RegionSize);
            SIZE_T bytesRead;
            if (ReadProcessMemory(hProcess, mbi.BaseAddress, buffer.data(), mbi.RegionSize, &bytesRead)) {
                for (size_t j = 0; j < bytesRead - sizeof(signatureBytes); ++j) {
                    if (memcmp(buffer.data() + j, signatureBytes, sizeof(signatureBytes)) == 0) {
                        DWORD oldProtect;
                        if (VirtualProtectEx(hProcess, static_cast<BYTE*>(mbi.BaseAddress) + j + sizeof(signatureBytes) - 1, 1, PAGE_EXECUTE_READWRITE, &oldProtect)) {
                            if (WriteProcessMemory(hProcess, static_cast<BYTE*>(mbi.BaseAddress) + j + sizeof(signatureBytes) - 1, &patchByte, 1, nullptr)) {
                                VirtualProtectEx(hProcess, static_cast<BYTE*>(mbi.BaseAddress) + j + sizeof(signatureBytes) - 1, 1, oldProtect, &oldProtect);
                                logFile << "Signature patched." << std::endl;
                                success = true;
                                goto cleanup;
                            }
                        }
                    }
                }
            }
        }
    }

cleanup:
    CloseHandle(hProcess);
    return success;
}

extern "C" BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
    switch (ul_reason_for_call) {
    case DLL_PROCESS_ATTACH:
        logFile << "DLL injected." << std::endl;
        DisableThreadLibraryCalls(hModule); // Опционально отключаем вызовы DLL_THREAD_ATTACH и DLL_THREAD_DETACH
        if (DWORD pid = FindProcessId(L"L2.bin")) {
            if (PatchProcess(pid)) {
                logFile << "Process patched." << std::endl;
            }
            else {
                logFile << "Failed to patch the process." << std::endl;
            }
        }
        else {
            logFile << "Process not found." << std::endl;
        }
        break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}