DBG: (hopefully) resolved issue #289
This commit is contained in:
parent
7b3aa207f3
commit
2bdae29fa5
|
@ -1012,6 +1012,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
|
|||
dputs("paused!");
|
||||
SetNextDbgContinueStatus(DBG_CONTINUE);
|
||||
GuiSetDebugState(paused);
|
||||
MemUpdateMap(fdProcessInfo->hProcess);
|
||||
DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true);
|
||||
//lock
|
||||
lock(WAITID_RUN);
|
||||
|
|
|
@ -844,8 +844,31 @@ CMDRESULT cbDebugPause(int argc, char* argv[])
|
|||
dputs("Program is not running");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
void* remoteCode = MemAllocRemote(0, PAGE_SIZE, PAGE_EXECUTE_READWRITE);
|
||||
if(!remoteCode)
|
||||
{
|
||||
dputs("Failed to allocate memory in debuggee");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
unsigned char code[] = { 0xCC, 0xC3 };
|
||||
if(!MemWrite(remoteCode, code, sizeof(code), 0))
|
||||
{
|
||||
MemFreeRemote((uint)remoteCode);
|
||||
dputs("Failed to write memory in debuggee");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
DWORD dwThreadId = 0;
|
||||
HANDLE hThread = CreateRemoteThread(fdProcessInfo->hProcess, 0, 0, (LPTHREAD_START_ROUTINE)remoteCode, 0, CREATE_SUSPENDED, &dwThreadId);
|
||||
if(!hThread)
|
||||
{
|
||||
MemFreeRemote((uint)remoteCode);
|
||||
dputs("Failed to create thread in debuggee");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
dprintf("Created thread with ThreadId %X\n", dwThreadId);
|
||||
dbgsetispausedbyuser(true);
|
||||
DebugBreakProcess(fdProcessInfo->hProcess);
|
||||
ResumeThread(hThread);
|
||||
CloseHandle(hThread);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -943,10 +966,34 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbDebugDetach(int argc, char* argv[])
|
||||
{
|
||||
unlock(WAITID_RUN); //run
|
||||
void* remoteCode = MemAllocRemote(0, PAGE_SIZE, PAGE_EXECUTE_READWRITE);
|
||||
if(!remoteCode)
|
||||
{
|
||||
dputs("Failed to allocate memory in debuggee");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
MemUpdateMap(fdProcessInfo->hProcess);
|
||||
unsigned char code[] = { 0xCC, 0xC3 };
|
||||
if(!MemWrite(remoteCode, code, sizeof(code), 0))
|
||||
{
|
||||
MemFreeRemote((uint)remoteCode);
|
||||
dputs("Failed to write memory in debuggee");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
DWORD dwThreadId = 0;
|
||||
HANDLE hThread = CreateRemoteThread(fdProcessInfo->hProcess, 0, 0, (LPTHREAD_START_ROUTINE)remoteCode, 0, CREATE_SUSPENDED, &dwThreadId);
|
||||
if(!hThread)
|
||||
{
|
||||
MemFreeRemote((uint)remoteCode);
|
||||
dputs("Failed to create thread in debuggee");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
dprintf("Created thread with ThreadId %X\n", dwThreadId);
|
||||
dbgsetisdetachedbyuser(true); //detach when paused
|
||||
ResumeThread(hThread);
|
||||
CloseHandle(hThread);
|
||||
unlock(WAITID_RUN); //run
|
||||
StepInto((void*)cbDetach);
|
||||
DebugBreakProcess(fdProcessInfo->hProcess);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -253,14 +253,14 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
|
|||
len--;
|
||||
dir[len] = 0;
|
||||
strcpy_s(alloctrace, dir);
|
||||
PathAppendA(alloctrace, "\\alloctrace.txt");
|
||||
strcat_s(alloctrace, "\\alloctrace.txt");
|
||||
DeleteFileW(StringUtils::Utf8ToUtf16(alloctrace).c_str());
|
||||
setalloctrace(alloctrace);
|
||||
strcpy_s(dbbasepath, dir); //debug directory
|
||||
PathAppendA(dbbasepath, "db");
|
||||
strcat_s(dbbasepath, "\\db");
|
||||
CreateDirectoryW(StringUtils::Utf8ToUtf16(dbbasepath).c_str(), 0); //create database directory
|
||||
strcpy_s(szSymbolCachePath, dir);
|
||||
PathAppendA(szSymbolCachePath, "symbols");
|
||||
strcat_s(szSymbolCachePath, "\\symbols");
|
||||
SetCurrentDirectoryW(StringUtils::Utf8ToUtf16(dir).c_str());;
|
||||
gMsgStack = MsgAllocStack();
|
||||
if(!gMsgStack)
|
||||
|
@ -270,7 +270,7 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
|
|||
hCommandLoopThread = CreateThread(0, 0, DbgCommandLoopThread, 0, 0, 0);
|
||||
char plugindir[deflen] = "";
|
||||
strcpy_s(plugindir, dir);
|
||||
PathAppendA(plugindir, "plugins");
|
||||
strcat_s(plugindir, "\\plugins");
|
||||
CreateDirectoryW(StringUtils::Utf8ToUtf16(plugindir).c_str(), 0);
|
||||
pluginload(plugindir);
|
||||
//handle command line
|
||||
|
|
Loading…
Reference in New Issue