//---------------------------------------------------------------------------
// createInstallFileMap
//---------------------------------------------------------------------------
int CPluginDeploymentEngine::createInstallFileMap(IPropertyTree& node, 
                                                     const char* destPath, 
                                                     mmapStr2PairStrStr& fileMap) const
{
   CDeploymentEngine::createInstallFileMap(node, destPath, fileMap);

   //get files for plugin references...
   //
   StringBuffer sPluginDest;
   getPluginDirectory(destPath, sPluginDest);//get absolute path where plugins are to be deployed

   //process plugin references for this eclserver process and add files for each service used by 
   //each binding before adding files for this esp process
   Owned<IPropertyTreeIterator> iter = m_process.getElements("PluginRef");
   ForEach(*iter)
   {
      // Lookup plugin process
      const char* pluginName = iter->query().queryProp("@process");
      IPropertyTree* pluginProcess = lookupProcess("PluginProcess", pluginName);
      if (!pluginProcess)
         throw MakeStringException(0, "Process %s references unknown plugin %s", m_name, pluginName);

      // Get plugin file list from the plugin process
      CDeploymentEngine::createInstallFileMap(*pluginProcess, sPluginDest.str(), fileMap);
   }
   return fileMap.size();
}
Ejemplo n.º 2
0
int Mhelp(t_table* pt, wchar_t* name, ulong index, int mode)
{
	switch (mode)
	{
		case MENU_VERIFY:
			return MENU_NORMAL;

		case MENU_EXECUTE:
		{
			wstring directory, helpfile;
			getPluginDirectory(directory);
			helpfile = directory + L"\\ODbgScript.txt";
			ShellExecute(hwollymain, L"open", helpfile.c_str(), NULL, directory.c_str(), SW_SHOWDEFAULT);
			return MENU_NOREDRAW;
		}

		default:
			return MENU_ABSENT;
	}
}
Ejemplo n.º 3
0
// Receives commands from windows menus.
extc void _export cdecl ODBG_Pluginaction(int origin, int action, void *item) 
{

  switch (origin)
  {
	case PM_MAIN:
	case PM_DISASM:
		break;
	default:
		//Other windows ignored
		return;
  }

  char s[256];
  HINSTANCE hinst  = hinstModule();
  HWND      hwmain = hwndOllyDbg();
  OPENFILENAME ofn={0};
  switch (action) 
  {
	case 0: // Run script
		       // common dialog box structure
		char szFile[260];       // buffer for file name
		
		// Initialize OPENFILENAME
		//ZeroMemory(&ofn, sizeof(ofn));
		ofn.lStructSize = sizeof(ofn);
		ofn.hwndOwner = hwmain;
		ofn.lpstrFile = szFile; 
		//
		// Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
		// use the contents of szFile to initialize itself.
		//
		ofn.lpstrFile[0] = '\0';
		ofn.nMaxFile = sizeof(szFile);
		ofn.lpstrFilter = "Olly Scripts\0*.osc;*.txt\0All\0*.*\0";
		ofn.nFilterIndex = 1;
		ofn.lpstrFileTitle = NULL;
		ofn.nMaxFileTitle = 0;
		Pluginreadstringfromini(hinst, "ScriptDir", buff, 0);
		ofn.lpstrInitialDir = buff;
		ofn.lpstrTitle = "Select Script";
		ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
		

		// Display the Open dialog box. 
		if (GetOpenFileName(&ofn)==TRUE) //Comdlg32.lib
		{
			// Load script
			ollylang->LoadScript(ofn.lpstrFile);
			if (ollylang->wndProg.hw) {
				SetForegroundWindow(ollylang->wndProg.hw);
				SetFocus(ollylang->wndProg.hw);
			}
			// Start script
			ollylang->Resume();
		}
		break;

	case 1: // Abort
		MessageBox(hwmain,"Script aborted!","ODbgScript",MB_OK|MB_ICONEXCLAMATION);
		ollylang->Reset(); 
		ollylang->Pause();
		break;

	case 2: // Pause
		ollylang->Pause();
		break;

	case 3: // Resume
		ollylang->Resume();
		break;

	case 4: // Step
		ollylang->Step(1);
		script_state = ollylang->script_state;
		break;

	case 5: // Force Pause (like Pause Key)
		focusonstop=4;
		ollylang->Pause();
		script_state = ollylang->script_state;
    	break;

	case 10:
		sprintf(s,"ODbgScript plugin v%i.%i.%i\n"
			      "by [email protected]\n\n"
				  "From OllyScript written by SHaG\n"
				  "PE dumper by R@dier\n"
				  "Byte replacement algo by Hex\n\n"
				  "http://odbgscript.sf.net/ \n\n"
				  "Compiled %s %s",
			VERSIONHI,VERSIONLO,VERSIONST, __DATE__, __TIME__);
		MessageBox(hwmain,s,"ODbgScript",MB_OK|MB_ICONINFORMATION);
		break;
	case 20: 
		{
			string directory, helpfile;
			getPluginDirectory(directory);
			helpfile = directory + "\\ODbgScript.txt";			
			ShellExecute(hwndOllyDbg(),"open",helpfile.c_str(),NULL,directory.c_str(),SW_SHOWDEFAULT);
		}
		break;
	case 21: // MRU List in CPU Window
	case 22:
	case 23:
	case 24:
	case 25:
	case 26:
	case 27:
	case 28:
	case 29:
		{
			action-=20; 
			char key[5]="NRU ";
			key[3]=action+0x30;
						
			ZeroMemory(&buff, sizeof(buff));
			Pluginreadstringfromini(hinst,key,buff,0);

			// Load script
			ollylang->LoadScript(buff);

			mruAddFile(buff);
 
			// Save script directory
			char* buf2;
			GetFullPathName(buff,sizeof(buff),buff,&buf2); *buf2=0;			
			Pluginwritestringtoini(hinst, "ScriptDir", buff);

			ollylang->Resume();
			if (ollylang->wndProg.hw) {
				SetForegroundWindow(ollylang->wndProg.hw);
				SetFocus(ollylang->wndProg.hw);
			}

			break;
		}
	case 30:
		{
			initProgTable();
			break;
		}
	case 31:
		{
			initLogWindow();
			break;
		}
	case 32: // Edit Script
		{
			ShellExecute(hwndOllyDbg(),"open",ollylang->scriptpath.c_str(),NULL,ollylang->currentdir.c_str(),SW_SHOWDEFAULT);
			break;
		}
	case 11:
		{
//			string x = "Hej";
//			string y = ToLower(x);
//			__asm nop;
		}
	case 12:
		{
//			Broadcast(WM_USER_CHALL, 0, 0);
		}
//			t_thread* thr = Findthread(Getcputhreadid());
//			byte buffer[4];
//			ulong fs = thr->reg.limit[2]; // BUG IN ODBG!!!
//			fs += 0x30;
//			Readmemory(buffer, fs, 4, MM_RESTORE);
//			fs = *((ulong*)buffer);
//			fs += 2;
//			buffer[0] = 0;
//			Writememory(buffer, fs, 1, MM_RESTORE);
//			cout << endl;
		
//			ulong addr = t->reg.s[SEG_FS];
//			Readmemory(buffer, addr, 4, MM_RESTORE);
//			cout << hex << &buffer;

			/*
			HMODULE hMod = GetModuleHandle("OllyScript.dll");
			if(hMod) // Check that the other plugin is present and loaded
			{
				// Get address of exported function
				int (*pFunc)(char*) = (int (*)(char*)) GetProcAddress(hMod, "ExecuteScript");
				if(pFunc) // Check that the other plugin exports the correct function
					pFunc("xxx"); // Execute exported function
			}

			cout << hex << hMod << endl;*/
			//403008 401035
			/*DWORD pid = Plugingetvalue(VAL_PROCESSID);
			DebugSetProcessKillOnExit(FALSE);
			DebugActiveProcessStop(pid);
			break;*/
			//t_module* mod = Findmodule(0x401000);
			//cout << hex << mod->codebase;
			
			//cout << hex << mod->codebase;
		
		break;

    default: 
		break;
  }
}
Ejemplo n.º 4
0
void PluginCallbackManager::init()
{
	DIR *dp;
	struct dirent *ep;

	dp = opendir(getPluginDirectory());
	if (dp != NULL)
	{
		while (ep = readdir(dp))
		{
			int location = strstr(ep->d_name,".") - ep->d_name;
			// We're one of ".", "..", or hidden, so let's skip
			if ( location == 0 )
				continue;

			LogDebug(VB_PLUGIN, "Found Plugin: (%s)\n", ep->d_name);

			std::string filename = std::string(getPluginDirectory()) + "/" + ep->d_name + "/callbacks";
			bool found = false;

			if ( FileExists(filename.c_str()) )
			{
				printf("Found callback with no extension");
				found = true;
			}
			else
			{
				std::vector<std::string> extensions;
				extensions.push_back(std::string(".sh"));
				extensions.push_back(std::string(".pl"));
				extensions.push_back(std::string(".php"));
				extensions.push_back(std::string(".py"));

				for ( std::vector<std::string>::iterator i = extensions.begin(); i != extensions.end(); ++i)
				{
					std::string tmpFilename = filename + *i;
					if ( FileExists( tmpFilename.c_str() ) )
					{
						filename += *i;
						found = true;
					}
				}
			}
			std::string eventScript = std::string(getFPPDirectory()) + "/scripts/eventScript";

			if ( !found )
			{
				LogExcess(VB_PLUGIN, "No callbacks supported by plugin: '%s'\n", ep->d_name);
				continue;
			}

			LogDebug(VB_PLUGIN, "Processing Callbacks (%s) for plugin: '%s'\n", filename.c_str(), ep->d_name);

			int output_pipe[2], pid, bytes_read;
			char readbuffer[128];
			std::string callback_list = "";

			if (pipe(output_pipe) == -1)
			{
				LogErr(VB_PLUGIN, "Failed to make pipe\n");
				exit(EXIT_FAILURE);
			}

			if ((pid = fork()) == -1 )
			{
				LogErr(VB_PLUGIN, "Failed to fork\n");
				exit(EXIT_FAILURE);
			}

			if ( pid == 0 )
			{
				dup2(output_pipe[1], STDOUT_FILENO);
				close(output_pipe[1]);
				execl(eventScript.c_str(), "eventScript", filename.c_str(), "--list", NULL);

				LogErr(VB_PLUGIN, "We failed to exec our callbacks query!\n");
				exit(EXIT_FAILURE);
			}
			else
			{
				close(output_pipe[1]);

				while (true)
				{
					bytes_read = read(output_pipe[0], readbuffer, sizeof(readbuffer)-1);

					if (bytes_read <= 0)
						break;

					readbuffer[bytes_read] = '\0';
					callback_list += readbuffer;
				}

				boost::trim(callback_list);

				LogExcess(VB_PLUGIN, "Callback output: (%s)\n", callback_list.c_str());

				wait(NULL);
			}

			boost::char_separator<char> sep(",");
			boost::tokenizer< boost::char_separator<char> > tokens(callback_list, sep);
		    BOOST_FOREACH (const std::string& type, tokens)
			{
				if (type == "media")
				{
					LogDebug(VB_PLUGIN, "Plugin %s supports media callback.\n", ep->d_name);
					MediaCallback *media = new MediaCallback(std::string(ep->d_name), filename);
					mCallbacks.push_back(media);
				}
				else if (type == "playlist")
				{
					LogDebug(VB_PLUGIN, "Plugin %s supports playlist callback.\n", ep->d_name);
					PlaylistCallback *playlist = new PlaylistCallback(std::string(ep->d_name), filename);
					mCallbacks.push_back(playlist);
				}
				else if (type == "nextplaylist")
				{
					LogDebug(VB_PLUGIN, "Plugin %s supports nextplaylist callback.\n", ep->d_name);
					NextPlaylistEntryCallback *nextplaylistentry = new NextPlaylistEntryCallback(std::string(ep->d_name), filename);
					mCallbacks.push_back(nextplaylistentry);
				}
				else if (type == "event")
				{
					LogDebug(VB_PLUGIN, "Plugin %s supports event callback.\n", ep->d_name);
					EventCallback *eventcallback = new EventCallback(std::string(ep->d_name), filename);
					mCallbacks.push_back(eventcallback);
				}
			}

			plugin_count += 1;
		}
		closedir(dp);
	}
	else
	{
Ejemplo n.º 5
0
				}
				else if (type == "event")
				{
					LogDebug(VB_PLUGIN, "Plugin %s supports event callback.\n", ep->d_name);
					EventCallback *eventcallback = new EventCallback(std::string(ep->d_name), filename);
					mCallbacks.push_back(eventcallback);
				}
			}

			plugin_count += 1;
		}
		closedir(dp);
	}
	else
	{
		LogWarn(VB_PLUGIN, "Couldn't open the directory %s: (%d): %s\n", getPluginDirectory(), errno, strerror(errno));
	}

	return;
}

PluginCallbackManager::~PluginCallbackManager()
{
	while (!mCallbacks.empty())
	{
		delete mCallbacks.back();
		mCallbacks.pop_back();
	}
}

int PluginCallbackManager::nextPlaylistEntryCallback(const char *plugin_data, int currentPlaylistEntry, int mode, bool repeat, OldPlaylistEntry *pe)