fixed dll breakpoints

This commit is contained in:
Mr. eXoDia 2014-05-29 02:24:14 +02:00
parent 8b5a615007
commit adce077e48
3 changed files with 20 additions and 13 deletions

View File

@ -338,7 +338,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
} }
if(engineFakeDLLHandle == NULL) if(engineFakeDLLHandle == NULL)
{ {
if(lstrcmpiW(&DLLDebugFileName[i+1], L"kernel32.dll") == NULL) if(_wcsicmp(&DLLDebugFileName[i+1], L"kernel32.dll") == NULL)
{ {
engineFakeDLLHandle = (ULONG_PTR)DBGEvent.u.LoadDll.lpBaseOfDll; engineFakeDLLHandle = (ULONG_PTR)DBGEvent.u.LoadDll.lpBaseOfDll;
} }
@ -354,7 +354,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
for(int i = LibrarianData.size() - 1; i >= 0; i--) for(int i = LibrarianData.size() - 1; i >= 0; i--)
{ {
ptrLibrarianData=&LibrarianData.at(i); ptrLibrarianData=&LibrarianData.at(i);
if(!lstrcmpiA(ptrLibrarianData->szLibraryName, szAnsiLibraryName)) if(!_stricmp(ptrLibrarianData->szLibraryName, szAnsiLibraryName))
{ {
if(ptrLibrarianData->bpxType == UE_ON_LIB_LOAD || ptrLibrarianData->bpxType == UE_ON_LIB_ALL) if(ptrLibrarianData->bpxType == UE_ON_LIB_LOAD || ptrLibrarianData->bpxType == UE_ON_LIB_ALL)
{ {
@ -423,7 +423,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
for(int i= LibrarianData.size() - 1; i >= 0; i--) for(int i= LibrarianData.size() - 1; i >= 0; i--)
{ {
ptrLibrarianData = &LibrarianData.at(i); ptrLibrarianData = &LibrarianData.at(i);
if(!lstrcmpiA(ptrLibrarianData->szLibraryName, szAnsiLibraryName)) if(!_stricmp(ptrLibrarianData->szLibraryName, szAnsiLibraryName))
{ {
if(ptrLibrarianData->bpxType == UE_ON_LIB_UNLOAD || ptrLibrarianData->bpxType == UE_ON_LIB_ALL) if(ptrLibrarianData->bpxType == UE_ON_LIB_UNLOAD || ptrLibrarianData->bpxType == UE_ON_LIB_ALL)
{ {

View File

@ -44,7 +44,6 @@ __declspec(dllexport) void* TITCALL InitDebug(char* szFileName, char* szCommandL
} }
__declspec(dllexport) void* TITCALL InitDebugW(wchar_t* szFileName, wchar_t* szCommandLine, wchar_t* szCurrentFolder) __declspec(dllexport) void* TITCALL InitDebugW(wchar_t* szFileName, wchar_t* szCommandLine, wchar_t* szCurrentFolder)
{ {
wchar_t szCreateWithCmdLine[1024]; wchar_t szCreateWithCmdLine[1024];
int DebugConsoleFlag = NULL; int DebugConsoleFlag = NULL;
@ -59,7 +58,7 @@ __declspec(dllexport) void* TITCALL InitDebugW(wchar_t* szFileName, wchar_t* szC
EngineSetDebugPrivilege(GetCurrentProcess(), true); EngineSetDebugPrivilege(GetCurrentProcess(), true);
DebugRemoveDebugPrivilege = true; DebugRemoveDebugPrivilege = true;
} }
if(szCommandLine == NULL) if(szCommandLine == NULL || !lstrlenW(szCommandLine))
{ {
if(CreateProcessW(szFileName, NULL, NULL, NULL, false, DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS|DebugConsoleFlag|CREATE_NEW_CONSOLE, NULL, szCurrentFolder, &dbgStartupInfo, &dbgProcessInformation)) if(CreateProcessW(szFileName, NULL, NULL, NULL, false, DEBUG_PROCESS|DEBUG_ONLY_THIS_PROCESS|DebugConsoleFlag|CREATE_NEW_CONSOLE, NULL, szCurrentFolder, &dbgStartupInfo, &dbgProcessInformation))
{ {
@ -68,17 +67,19 @@ __declspec(dllexport) void* TITCALL InitDebugW(wchar_t* szFileName, wchar_t* szC
DebugAttachedToProcess = false; DebugAttachedToProcess = false;
DebugAttachedProcessCallBack = NULL; DebugAttachedProcessCallBack = NULL;
std::vector<BreakPointDetail>().swap(BreakPointBuffer); std::vector<BreakPointDetail>().swap(BreakPointBuffer);
return(&dbgProcessInformation); return &dbgProcessInformation;
} }
else else
{ {
DWORD lastError = GetLastError();
if(engineEnableDebugPrivilege) if(engineEnableDebugPrivilege)
{ {
EngineSetDebugPrivilege(GetCurrentProcess(), false); EngineSetDebugPrivilege(GetCurrentProcess(), false);
DebugRemoveDebugPrivilege = false; DebugRemoveDebugPrivilege = false;
} }
RtlZeroMemory(&dbgProcessInformation,sizeof PROCESS_INFORMATION); memset(&dbgProcessInformation, 0, sizeof(PROCESS_INFORMATION));
return(0); SetLastError(lastError);
return 0;
} }
} }
else else
@ -91,30 +92,35 @@ __declspec(dllexport) void* TITCALL InitDebugW(wchar_t* szFileName, wchar_t* szC
DebugAttachedToProcess = false; DebugAttachedToProcess = false;
DebugAttachedProcessCallBack = NULL; DebugAttachedProcessCallBack = NULL;
std::vector<BreakPointDetail>().swap(BreakPointBuffer); std::vector<BreakPointDetail>().swap(BreakPointBuffer);
return(&dbgProcessInformation); return &dbgProcessInformation;
} }
else else
{ {
DWORD lastError = GetLastError();
if(engineEnableDebugPrivilege) if(engineEnableDebugPrivilege)
{ {
EngineSetDebugPrivilege(GetCurrentProcess(), false); EngineSetDebugPrivilege(GetCurrentProcess(), false);
DebugRemoveDebugPrivilege = false; DebugRemoveDebugPrivilege = false;
} }
RtlZeroMemory(&dbgProcessInformation,sizeof PROCESS_INFORMATION); memset(&dbgProcessInformation, 0, sizeof(PROCESS_INFORMATION));
return(0); SetLastError(lastError);
return 0;
} }
} }
} }
__declspec(dllexport) void* TITCALL InitDebugEx(char* szFileName, char* szCommandLine, char* szCurrentFolder, LPVOID EntryCallBack) __declspec(dllexport) void* TITCALL InitDebugEx(char* szFileName, char* szCommandLine, char* szCurrentFolder, LPVOID EntryCallBack)
{ {
DebugExeFileEntryPointCallBack = EntryCallBack; DebugExeFileEntryPointCallBack = EntryCallBack;
return(InitDebug(szFileName, szCommandLine, szCurrentFolder)); return(InitDebug(szFileName, szCommandLine, szCurrentFolder));
} }
__declspec(dllexport) void* TITCALL InitDebugExW(wchar_t* szFileName, wchar_t* szCommandLine, wchar_t* szCurrentFolder, LPVOID EntryCallBack) __declspec(dllexport) void* TITCALL InitDebugExW(wchar_t* szFileName, wchar_t* szCommandLine, wchar_t* szCurrentFolder, LPVOID EntryCallBack)
{ {
DebugExeFileEntryPointCallBack = EntryCallBack; DebugExeFileEntryPointCallBack = EntryCallBack;
return(InitDebugW(szFileName, szCommandLine, szCurrentFolder)); return(InitDebugW(szFileName, szCommandLine, szCurrentFolder));
} }
__declspec(dllexport) void* TITCALL InitDLLDebug(char* szFileName, bool ReserveModuleBase, char* szCommandLine, char* szCurrentFolder, LPVOID EntryCallBack) __declspec(dllexport) void* TITCALL InitDLLDebug(char* szFileName, bool ReserveModuleBase, char* szCommandLine, char* szCurrentFolder, LPVOID EntryCallBack)
{ {
@ -149,6 +155,7 @@ __declspec(dllexport) void* TITCALL InitDLLDebug(char* szFileName, bool ReserveM
return NULL; return NULL;
} }
} }
__declspec(dllexport) void* TITCALL InitDLLDebugW(wchar_t* szFileName, bool ReserveModuleBase, wchar_t* szCommandLine, wchar_t* szCurrentFolder, LPVOID EntryCallBack) __declspec(dllexport) void* TITCALL InitDLLDebugW(wchar_t* szFileName, bool ReserveModuleBase, wchar_t* szCommandLine, wchar_t* szCurrentFolder, LPVOID EntryCallBack)
{ {
@ -202,7 +209,7 @@ __declspec(dllexport) void* TITCALL InitDLLDebugW(wchar_t* szFileName, bool Rese
DebugReserveModuleBase = DebugModuleImageBase; DebugReserveModuleBase = DebugModuleImageBase;
DebugModuleEntryPoint = (ULONG_PTR)GetPE32DataW(szFileName, NULL, UE_OEP); DebugModuleEntryPoint = (ULONG_PTR)GetPE32DataW(szFileName, NULL, UE_OEP);
DebugModuleEntryPointCallBack = EntryCallBack; DebugModuleEntryPointCallBack = EntryCallBack;
return(InitDebugW(szDebuggerName, szCommandLine, szCurrentFolder)); return InitDebugW(szDebuggerName, szCommandLine, szCurrentFolder);
} }
return 0; return 0;
} }

View File

@ -22,7 +22,7 @@ __declspec(dllexport) bool TITCALL LibrarianRemoveBreakPoint(char* szLibraryName
{ {
for(int i = LibrarianData.size() - 1; i >= 0; i--) for(int i = LibrarianData.size() - 1; i >= 0; i--)
{ {
if(!lstrcmpiA(szLibraryName, LibrarianData.at(i).szLibraryName) && (LibrarianData.at(i).bpxType == bpxType || bpxType == UE_ON_LIB_ALL)) if(!_stricmp(szLibraryName, LibrarianData.at(i).szLibraryName) && (LibrarianData.at(i).bpxType == bpxType || bpxType == UE_ON_LIB_ALL))
{ {
LibrarianData.erase(LibrarianData.begin() + i); LibrarianData.erase(LibrarianData.begin() + i);
} }