Where you have Core.WBM.Asm.InjectAndExecute(codecave);, replace it with Core.WBM.Asm.Assemble(); and see if it throws an error. If it does not, then test if you can write to the game's memory using Core.WBM.Asm.WriteUInt(codecave, 0);. If that succeeds, then I have no idea. Maybe I should rewrite fasm_managed to be a little more descriptive.
Also, check your console output to see if anything else is written to the console directly before you get that error. If not, then it is erroring on the WriteProcessMemory call, which probably means that your handle to the Wow.exe process does not contain proper privileges, which means you're doing something wrong somewhere else (like not calling Core.WBM.Open(dwProcessId); at some point before trying to write to memory).
Here's the source to the error that you're getting:
Code:
bool ManagedFasm::Inject(IntPtr hProcess, DWORD dwAddress)
{
if (hProcess == IntPtr::Zero)
return false;
if (m_AssemblyString->ToString()->Contains("use64") || m_AssemblyString->ToString()->Contains("use16"))
m_AssemblyString->Replace("use32\n", "");
if (!m_AssemblyString->ToString()->Contains("org "))
m_AssemblyString->Insert(0, String::Format("org 0x{0:X08}\n", dwAddress));
IntPtr lpSource = IntPtr::Zero;
try
{
lpSource = Marshal::StringToHGlobalAnsi(m_AssemblyString->ToString());
_c_FasmAssemble((char *)lpSource.ToPointer(), m_MemorySize, m_PassLimit);
}
catch (Exception ^ ex)
{
Console::WriteLine(ex->Message);
return false;
}
finally
{
if (lpSource != IntPtr::Zero)
Marshal::FreeHGlobal(lpSource);
}
_C_FASM_STATE * fasm_state = reinterpret_cast<_C_FASM_STATE *>(_c_fasm_memorybuf);
if (fasm_state->condition != FASM_OK)
throw gcnew Exception(String::Format("Assembly failed! Error code: {0}; Error Line: {1}", fasm_state->error_code, fasm_state->error_data->line_number));
return WriteProcessMemory((HANDLE)hProcess, (void *)dwAddress, fasm_state->output_data, fasm_state->output_length, NULL);
}
DWORD ManagedFasm::InjectAndExecute(IntPtr hProcess, DWORD dwAddress, DWORD dwParameter)
{
if (hProcess == IntPtr::Zero)
throw gcnew ArgumentNullException("hProcess");
if (dwAddress == NULL)
throw gcnew ArgumentNullException("dwAddress");
HANDLE hThread;
DWORD dwExitCode = 0;
if (!this->Inject(hProcess, dwAddress))
throw gcnew Exception("Injection failed for some reason.");
hThread = CreateRemoteThread((HANDLE)(hProcess.ToInt32()), NULL, 0, (LPTHREAD_START_ROUTINE)dwAddress, (void *)dwParameter, 0, NULL);
if (hThread == NULL)
throw gcnew Exception("Remote thread failed.");
try
{
if (WaitForSingleObject(hThread, 10000) == WAIT_OBJECT_0)
if (!GetExitCodeThread(hThread, &dwExitCode))
throw gcnew Exception("Could not get thread exit code.");
}
finally
{
CloseHandle(hThread);
}
return dwExitCode;
}
Yes, it's poorly written; deal with it.