Beispiel #1
0
void _export cdecl ODBG_Pluginaction(int origin, int action, void *item)
{
	list_t* names;
	TCHAR path[TEXTLEN];
	t_status status;
	if (origin == PM_MAIN)
	{
		switch (action)
		{
			case ACTION_IMPORT:
				status = Getstatus();
				if (status && status != STAT_FINISHED && status != STAT_CLOSING)
				{
					if (mapfile_browse(path))
					{
						names = mapfile_parse(path);
						if (names)
						{
							mapfile_apply(names);
							list_freenames(names);
							Setcpu(0, 0, 0, 0, CPU_ASMFOCUS);
						}
						else
						{
							Flash("Failed to open the file");
						}
					}
				}
				else
				{
					Flash("Start the debugging session first");
				}
				break;

			case ACTION_OPTIONS:
				configwnd_create();
				break;

			case ACTION_ABOUT:
				MessageBox(g_hwndOlly, c_About, "About mapimp", MB_ICONINFORMATION);
				break;

			default:
				break;
		}
	}
}
Beispiel #2
0
extc int _export cdecl ODBG_Pluginmenu(int origin,char data[4096],void *item) {
  switch (origin) {
  case PM_MAIN: // Plugin menu in main window
    strcpy(data,
           "1 " Verstr
          );
    return 1;
  case PM_CPUDUMP:
    if(Getstatus() == STAT_NONE) {
      return 0;
    }
    strcpy(data,"#0 BASE64 encode");
    return 1;
  default:
    break; // Any other window
  }
  return 0; // Window not supported by plugin
}
// This function is called each time OllyDbg passes main Windows loop. When
// debugged application stops, b ring command line window in foreground.
extc void _export cdecl ODBG_Pluginmainloop(DEBUG_EVENT *debugevent) 
{	
	t_status status; 
	status = Getstatus();
	script_state = ollylang->script_state;
	
    // module load event. kept for future use. http://www.openrce.org/articles/full_view/25
    /*if (debugevent && debugevent->dwDebugEventCode == LOAD_DLL_DEBUG_EVENT) {
		string filename;
		if (str_filename_from_handle(debugevent->u.LoadDll.hFile, filename)) {
			MsgBox(filename,""); 
		}
	}
	*/

	if (debugevent && debugevent->dwDebugEventCode == OUTPUT_DEBUG_STRING_EVENT && debugevent->u.DebugString.nDebugStringLength>0
		&& !IsBadCodePtr((FARPROC)debugevent->u.DebugString.lpDebugStringData))
		MsgBox(debugevent->u.DebugString.lpDebugStringData,"");

	// Check for breakpoint jumps
	if(script_state == SS_RUNNING && debugevent && debugevent->dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
	{

		EXCEPTION_DEBUG_INFO edi = debugevent->u.Exception;
		if(edi.ExceptionRecord.ExceptionCode != EXCEPTION_SINGLE_STEP)
			ollylang->OnException(edi.ExceptionRecord.ExceptionCode);
		else if(edi.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT)
			ollylang->OnBreakpoint(PP_EXCEPTION,EXCEPTION_DEBUG_EVENT);
/*		else	
			if(script_state == SS_RUNNING)
			{
				t_thread* t;
				t = Findthread(Getcputhreadid());
				CONTEXT context;
				context.ContextFlags = CONTEXT_DEBUG_REGISTERS;
				GetThreadContext(t->thread, &context);

				//Hardware Breakpoints...
				if(t->reg.ip == context.Dr0 || t->reg.ip == context.Dr1 || t->reg.ip == context.Dr2 || t->reg.ip == context.Dr3) {
					ollylang->OnBreakpoint(PP_HWBREAK,t->reg.ip);
				}

			}
*/
	}

	if(status == STAT_STOPPED && (script_state == SS_RUNNING || script_state == SS_LOADED || script_state == SS_PAUSED))
	{

		if (ollylang->require_addonaction) {
			try
			{
				ollylang->ProcessAddonAction();
			}
			catch( ... )
			{
				MessageBox(hwndOllyDbg(), "An error occured in the plugin!\nPlease contact Epsylon3.", "ODbgScript", MB_OK | MB_ICONERROR | MB_TOPMOST);
			}
		}

	}


	if(status == STAT_STOPPED && (script_state == SS_RUNNING || script_state == SS_LOADED))
	{

		try
		{
			ollylang->Step(0);
			script_state = ollylang->script_state;
		}
		catch( ... )
		{
			MessageBox(hwndOllyDbg(), "An error occured in the plugin!\nPlease contact Epsylon3.", "ODbgScript", MB_OK | MB_ICONERROR | MB_TOPMOST);
			delete ollylang;
		}

	}

	//Refocus script windows (ex: when using "Step")
	if (    ollylang->wndProg.hw 
		&& (status == STAT_STOPPED || status == STAT_EVENT)
		&& (script_state != SS_RUNNING)
		) 
	{
		if (focusonstop>0) { 
//			InvalidateProgWindow();
			SetForegroundWindow(ollylang->wndProg.hw);
			SetFocus(ollylang->wndProg.hw);
			focusonstop--;
		}
	}	

}