CloseHandle(snapshot); return pid;
It sounds like you encountered the error while using Xenos (an injection tool often used with Cheat Engine or for manual DLL injection).
// Wait for thread to finish (optional) WaitForSingleObject(hThread, INFINITE);
// Write DLL path if (!WriteProcessMemory(hProcess, remoteMem, dllPath, pathSize, NULL)) std::cerr << "WriteProcessMemory failed. Error: " << GetLastError() << std::endl; VirtualFreeEx(hProcess, remoteMem, 0, MEM_RELEASE); CloseHandle(hProcess); return false;