| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| MMM-304 Expert Cheater
 
 ![]() Reputation: 0 
 Joined: 17 Aug 2020
 Posts: 170
 Location: Milkey Way
 
 | 
			
				|  Posted: Sun Jun 23, 2024 11:55 pm    Post subject: Debugger Setup via plugin |   |  
				| 
 |  
				| I am trying to setup debugger interface using plugin with c++. I am not too familiar with debugging and encountering a few problems. 
 1. I cannot get the context of the debug thread. Here is my OnDebugEvent.
 
  	  | Code: |  	  | int __stdcall OnDebugEvent(LPDEBUG_EVENT DebugEvent) {
 brokenThreadId = NULL;
 if (!DebugEvent) return 0;
 switch (DebugEvent->dwDebugEventCode)
 {
 case EXCEPTION_DEBUG_EVENT:
 {
 volatile EXCEPTION_DEBUG_INFO& Exception = DebugEvent->u.Exception;
 logger->AddLog(string_format("ThreadID: %X - ExceptionCode: %X - ExceptionFlag: %d", DebugEvent->dwThreadId, Exception.ExceptionRecord.ExceptionCode, Exception.ExceptionRecord.ExceptionFlags));
 switch (Exception.ExceptionRecord.ExceptionCode)
 {
 case EXCEPTION_BREAKPOINT:
 break;
 case EXCEPTION_SINGLE_STEP:
 {
 brokenThreadId = DebugEvent->dwThreadId;
 isBroken = LuaAPI::debug_isBroken();
 HANDLE tHandle = OpenThread(THREAD_ALL_ACCESS, NULL, DebugEvent->dwThreadId);
 if (tHandle && tHandle != INVALID_HANDLE_VALUE)
 {
 CONTEXT context;
 ZeroMemory(&context, sizeof(CONTEXT));
 context.ContextFlags = CONTEXT_FULL;
 if (GetThreadContext(tHandle, &context))
 {
 logger->AddLog(string_format("RBX = %p, Address: %p", context.Rbx, Exception.ExceptionRecord.ExceptionAddress)); // Incorrect value
 }
 CloseHandle(tHandle);
 }
 return 0;
 }
 break;
 default:
 break;
 }
 }
 default:
 break;
 }
 return 0;
 }
 | 
 
 I tried to store the thread ID and look up the context later, but it still gave me incorrect context.
 
 2. Is there a plugin function to set the debugger with a specific callback c++ function? The current one "debug_setBreakpoint" does not include the callback function.
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Dark Byte Site Admin
 
  Reputation: 470 
 Joined: 09 May 2003
 Posts: 25807
 Location: The netherlands
 
 | 
			
				|  Posted: Mon Jun 24, 2024 2:18 am    Post subject: |   |  
				| 
 |  
				| 1 Is the debugger interface set to windows or one of the others ? 
 2 not at the moment. Although you could invoke the lua version of debug_setBreakpoint and give it a cfunction as callback (using the lua callback mechanism)
 _________________
 
 Do not ask me about online cheats. I don't know any and wont help finding them.
 Like my help? Join me on Patreon so i can keep helping
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| MMM-304 Expert Cheater
 
 ![]() Reputation: 0 
 Joined: 17 Aug 2020
 Posts: 170
 Location: Milkey Way
 
 | 
			
				|  Posted: Mon Jun 24, 2024 2:21 am    Post subject: |   |  
				| 
 |  
				| Currently im using VEH debugger 
 Edit:
 Also there is nothing within ExceptionRecord. Is there a way to get exceptioninfo? through which context?
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Dark Byte Site Admin
 
  Reputation: 470 
 Joined: 09 May 2003
 Posts: 25807
 Location: The netherlands
 
 | 
			
				|  Posted: Mon Jun 24, 2024 3:58 am    Post subject: |   |  
				| 
 |  
				| right. When using any of the non-windows debugger interfaces stuff like getthreadcontext won't work as it's interface specific 
 for vehdebug you could try mapping the TVEHDebugSharedMem shared memory and read the context from there
 
 the exceptioninfo should be correctish though.  is the target 32 or 64 bit ? You'll need to adjust the context to the correct type
 _________________
 
 Do not ask me about online cheats. I don't know any and wont help finding them.
 Like my help? Join me on Patreon so i can keep helping
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| MMM-304 Expert Cheater
 
 ![]() Reputation: 0 
 Joined: 17 Aug 2020
 Posts: 170
 Location: Milkey Way
 
 | 
			
				|  Posted: Mon Jun 24, 2024 4:23 am    Post subject: |   |  
				| 
 |  
				| The target is 64, and an example would be appreciated, especially with respect to the plugin system 
 Also is there a way to know which type of debugger is selected by the user before it is even injected? I mean `debug_getCurrentDebuggerInterface` only returns value after the injection. I need to know the type before the injection
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  |