Changeset 1644
- Timestamp:
- 06/27/08 17:37:47 (2 months ago)
- Files:
-
- capture-mod/trunk/ApplicationPlugins/InternetExplorer/Application_InternetExplorer.vcproj (modified) (1 diff)
- capture-mod/trunk/ApplicationPlugins/InternetExplorer/InternetExplorerInstance.h (modified) (1 diff)
- capture-mod/trunk/CaptureClient.cpp (modified) (2 diffs)
- capture-mod/trunk/CaptureClient.sln (modified) (1 diff)
- capture-mod/trunk/CaptureClient.vcproj (modified) (2 diffs)
- capture-mod/trunk/EventController.cpp (modified) (1 diff)
- capture-mod/trunk/EventController.h (modified) (1 diff)
- capture-mod/trunk/MySoapServer.cpp (modified) (5 diffs)
- capture-mod/trunk/MySoapServer.h (modified) (1 diff)
- capture-mod/trunk/ProcessMonitor.h (modified) (1 diff)
- capture-mod/trunk/Thread.h (modified) (3 diffs)
- capture-mod/trunk/Visitor.cpp (modified) (6 diffs)
- capture-mod/trunk/Visitor.h (modified) (3 diffs)
- capture-mod/trunk/install/CaptureBAT.exe (modified) (previous)
- capture-mod/trunk/soapC.cpp (modified) (1 diff)
- capture-mod/trunk/soapClient.cpp (modified) (1 diff)
- capture-mod/trunk/soapServer.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
capture-mod/trunk/ApplicationPlugins/InternetExplorer/Application_InternetExplorer.vcproj
r823 r1644 65 65 AdditionalDependencies="comsuppw.lib Version.lib Advapi32.lib" 66 66 LinkIncremental="2" 67 AdditionalLibraryDirectories=" "D:\Microsoft Platform SDK for Windows Server 2003 R2\Lib""67 AdditionalLibraryDirectories="F:\WinDDK\6000\lib\wxp\i386;"D:\Microsoft Platform SDK for Windows Server 2003 R2\Lib"" 68 68 GenerateDebugInformation="true" 69 69 SubSystem="1" capture-mod/trunk/ApplicationPlugins/InternetExplorer/InternetExplorerInstance.h
r823 r1644 25 25 /* Below are various methods we must implement for DWebBrowserEvents. 26 26 Just ignore most of them as they are just stubs. The important ones 27 are implemented in Application_InternetExplorer.cpp */ 27 are implemented in Application_InternetExplorer.cpp 28 XENO: To be clear, the things below are actually IUnknown or IDispatch methods*/ 28 29 HRESULT STDMETHODCALLTYPE QueryInterface( 29 30 /* [in] */ REFIID riid, capture-mod/trunk/CaptureClient.cpp
r1586 r1644 50 50 51 51 hStopRunning = CreateEvent(NULL, FALSE, FALSE, NULL); 52 //XENO - Right here, set up the standalone SOAP server53 MySoapServer a = MySoapServer();54 52 55 53 wstring serverIp = OptionsManager::getInstance()->getOption(L"server"); … … 63 61 /* Start running the Capture Client */ 64 62 visitor = new Visitor(); 65 printf("entering analyzer\n"); 66 analyzer = new Analyzer(visitor, server); 63 //Set up the standalone SOAP server 64 MySoapServer a = MySoapServer(visitor); 65 analyzer = new Analyzer(visitor, server); 67 66 Thread* captureClientThread = new Thread(this); 68 67 captureClientThread->start("CaptureClient"); capture-mod/trunk/CaptureClient.sln
r823 r1644 17 17 GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 18 {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Debug|Win32.ActiveCfg = Debug|Win32 19 {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Debug|Win32.Build.0 = Debug|Win3220 19 {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Release|Win32.ActiveCfg = Release|Win32 21 20 {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Release|Win32.Build.0 = Release|Win32 22 21 {AE2C8E80-7D21-47AD-987B-43E0708AE549}.Debug|Win32.ActiveCfg = Debug|Win32 23 {AE2C8E80-7D21-47AD-987B-43E0708AE549}.Debug|Win32.Build.0 = Debug|Win3224 22 {AE2C8E80-7D21-47AD-987B-43E0708AE549}.Release|Win32.ActiveCfg = Release|Win32 25 23 {AE2C8E80-7D21-47AD-987B-43E0708AE549}.Release|Win32.Build.0 = Release|Win32 26 24 {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Debug|Win32.ActiveCfg = Debug|Win32 27 {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Debug|Win32.Build.0 = Debug|Win3228 25 {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Release|Win32.ActiveCfg = Release|Win32 29 26 {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Release|Win32.Build.0 = Release|Win32 30 27 {C57EC146-60B3-499B-BDFA-5BB5504FDB89}.Debug|Win32.ActiveCfg = Debug|Win32 31 {C57EC146-60B3-499B-BDFA-5BB5504FDB89}.Debug|Win32.Build.0 = Debug|Win3232 28 {C57EC146-60B3-499B-BDFA-5BB5504FDB89}.Release|Win32.ActiveCfg = Release|Win32 33 29 {C57EC146-60B3-499B-BDFA-5BB5504FDB89}.Release|Win32.Build.0 = Release|Win32 capture-mod/trunk/CaptureClient.vcproj
r1586 r1644 122 122 Name="VCCLCompilerTool" 123 123 Optimization="3" 124 AdditionalIncludeDirectories=" D:\WpdPack\Include;D:\expatpp\src_pp;D:\WinDDK\6000\inc;D:\boost\boost_1_34_0;D:\expatpp\expat\lib;"D:\Microsoft Platform SDK for Windows Server 2003 R2\Include""124 AdditionalIncludeDirectories="F:\Boost;"F:\Program Files\Microsoft Platform SDK\Include";F:\WinDDK\6000\inc\api;"F:\capture-mod\expatpp\src_pp";"F:\capture-mod\expatpp\expat\lib";"F:\capture-mod\WpdPack_4_0_1\WpdPack\Include"" 125 125 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 126 126 RuntimeLibrary="2" … … 144 144 AdditionalDependencies="kernel32.lib Ws2_32.lib Advapi32.lib Psapi.lib fltLib.lib shlwapi.lib expatpp.lib shell32.lib Urlmon.lib $(NOINHERIT)" 145 145 LinkIncremental="1" 146 AdditionalLibraryDirectories=" D:\WinDDK\6000\lib\wxp\i386;D:\expatpp\vc_pp\expatpp\ReleaseMTDLL;"D:\Microsoft Platform SDK for Windows Server 2003 R2\Lib";D:\boost\boost_1_34_0\lib"146 AdditionalLibraryDirectories="F:\boost_1_34_0\lib;"F:\Program Files\Microsoft Platform SDK\Lib";F:\WinDDK\6000\lib\wxp\i386;"F:\capture-mod\expatpp\expat\lib";"F:\capture-mod\expatpp\vc_pp\expatpp\ReleaseMT"" 147 147 GenerateDebugInformation="true" 148 148 SubSystem="1" capture-mod/trunk/EventController.cpp
r823 r1644 51 51 EventController::notifyListeners() 52 52 { 53 if(pCurrentElement != NULL) 54 { 55 stdext::hash_map<wstring, signal_serverEvent*>::iterator it; 56 it = onServerEventMap.find(pCurrentElement->name); 57 if(it != onServerEventMap.end()) 58 { 59 signal_serverEvent* signal_onServerEvent = it->second; 60 (*signal_onServerEvent)(pCurrentElement); 61 } 62 if(pCurrentElement->data != NULL) 63 { 64 free(pCurrentElement->data); 65 } 66 delete pCurrentElement; 67 pCurrentElement = NULL; 68 } 69 } 70 71 void 72 EventController::notifyListeners(pElement pInputElement) 73 { 74 75 pCurrentElement = (Element *)pInputElement; 53 76 if(pCurrentElement != NULL) 54 77 { capture-mod/trunk/EventController.h
r823 r1644 78 78 79 79 void receiveServerEvent(const char* xmlDocument); 80 void notifyListeners(pElement pInputElement); 80 81 private: 81 82 static bool instanceCreated; capture-mod/trunk/MySoapServer.cpp
r1586 r1644 9 9 #include "calculator.nsmap" 10 10 11 MySoapServer::MySoapServer(){ 12 11 #include "Visitor.h" 12 13 Visitor * globVisitor; 14 15 MySoapServer::MySoapServer(Visitor* v){ 16 17 globVisitor = v; 13 18 MySoapServerThread = new Thread(this); 14 19 MySoapServerThread->start("MySoapServer"); … … 25 30 struct soap soap; 26 31 SOCKET m, s; // master and slave sockets 32 33 ///loadClientPlugins(); 27 34 28 35 soap_init(&soap); … … 57 64 58 65 // Implementation of the "add" remote method: 59 //int ns__add(struct soap *soap, int a, int b, int &result)60 66 int ns__add(struct soap *soap, int a, int b, int &result) 61 67 { 62 68 //printf("add got %d and %d\n", a, b); 63 69 result = a + b; 70 64 71 return SOAP_OK; 65 72 } 73 74 void MySoapServer::test(){ 75 76 // printf("myVisitor = %#x\n", MySoapServer::myVisitor); 77 78 } 66 79 67 80 int ns__ping(struct soap *soap, char * a, char ** result) … … 69 82 printf("%s\n", a); 70 83 *result = "pong"; 84 85 //Build my own new-fangled Element to pass to Visitor:onServerEvent which I think will open 86 typedef boost::signal<void (Element*)> signal_serverEvent; 87 Attribute att; 88 att.name = L"url"; 89 att.value = L"http://slashdot.org"; 90 Element e; 91 e.name = L"iexplore"; 92 e.attributes.push_back(att); 93 e.data = NULL; 94 e.dataLength = 0; 95 // printf("trying with notifyListeners\n"); 96 // EventController::getInstance()->notifyListeners(&e); 97 printf("trying with globVisitor\n"); 98 globVisitor->onServerEvent(&e); 99 71 100 return SOAP_OK; 72 101 } … … 79 108 } 80 109 110 void 111 MySoapServer::loadClientPlugins() 112 { 113 WIN32_FIND_DATA FindFileData; 114 HANDLE hFind = INVALID_HANDLE_VALUE; 115 wchar_t pluginDirectoryPath[1024]; 116 117 GetFullPathName(L"plugins\\Application_*.dll", 1024, pluginDirectoryPath, NULL); 118 DebugPrint(L"Capture-SOAP Server: Plugin directory - %ls\n", pluginDirectoryPath); 119 hFind = FindFirstFile(pluginDirectoryPath, &FindFileData); 120 121 if (hFind != INVALID_HANDLE_VALUE) 122 { 123 typedef void (*AppPlugin)(void*); 124 do 125 { 126 wstring pluginDir = L"plugins\\"; 127 pluginDir += FindFileData.cFileName; 128 HMODULE hPlugin = LoadLibrary(pluginDir.c_str()); 129 130 if(hPlugin != NULL) 131 { 132 list<ApplicationPlugin*>* apps = new std::list<ApplicationPlugin*>(); 133 applicationPlugins.insert(PluginPair(hPlugin, apps)); 134 ApplicationPlugin* applicationPlugin = createApplicationPluginObject(hPlugin); 135 if(applicationPlugin == NULL) { 136 FreeLibrary(hPlugin); 137 } else { 138 printf("Loaded plugin: %ls\n", FindFileData.cFileName); 139 unsigned int g = applicationPlugin->getPriority(); 140 wchar_t** supportedApplications = applicationPlugin->getSupportedApplicationNames(); 141 for(int i = 0; supportedApplications[i] != NULL; i++) 142 { 143 stdext::hash_map<wstring, ApplicationPlugin*>::iterator it; 144 it = applicationMap.find(supportedApplications[i]); 145 /* Check he application isn't already being handled by a plugin */ 146 if(it != applicationMap.end()) 147 { 148 /* Check the priority of the existing application plugin */ 149 unsigned int p = it->second->getPriority(); 150 if(applicationPlugin->getPriority() > p) 151 { 152 /* Over ride the exisiting plugin if the priority of the loaded one 153 is greater */ 154 applicationMap.erase(supportedApplications[i]); 155 printf("\toverride: added application: %ls\n", supportedApplications[i]); 156 applicationMap.insert(ApplicationPair(supportedApplications[i], applicationPlugin)); 157 } else { 158 printf("\tplugin overridden: not adding application: %ls\n", supportedApplications[i]); 159 } 160 } else { 161 printf("\tinserted: added application: %ls\n", supportedApplications[i]); 162 applicationMap.insert(ApplicationPair(supportedApplications[i], applicationPlugin)); 163 } 164 } 165 } 166 } 167 } while(FindNextFile(hFind, &FindFileData) != 0); 168 FindClose(hFind); 169 } 170 171 } 172 173 ApplicationPlugin* 174 MySoapServer::createApplicationPluginObject(HMODULE hPlugin) 175 { 176 typedef void (*PluginExportInterface)(void*); 177 PluginExportInterface pluginCreateInstance = NULL; 178 ApplicationPlugin* applicationPlugin = NULL; 179 /* Get the function address to create a plugin object */ 180 pluginCreateInstance = (PluginExportInterface)GetProcAddress(hPlugin,"New"); 181 /* Create a new plugin object in the context of the plugin */ 182 pluginCreateInstance(&applicationPlugin); 183 /* If the object was created then add it to a list so we can track it */ 184 if(applicationPlugin != NULL) 185 { 186 stdext::hash_map<HMODULE, std::list<ApplicationPlugin*>*>::iterator it; 187 it = applicationPlugins.find(hPlugin); 188 if(it != applicationPlugins.end()) 189 { 190 list<ApplicationPlugin*>* apps = it->second; 191 apps->push_back(applicationPlugin); 192 } 193 } 194 return applicationPlugin; 195 } 196 197 void 198 MySoapServer::onServerEvent(Element* pElement) 199 { 200 wstring applicationName = L"iexplore"; 201 wstring url = L""; 202 int time = 30; 203 vector<Attribute>::iterator it; 204 for(it = pElement->attributes.begin(); it != pElement->attributes.end(); it++) 205 { 206 if(it->name == L"url") { 207 url = it->value; 208 } else if(it->name == L"program") { 209 applicationName = it->value; 210 } else if(it->name == L"time") { 211 time = boost::lexical_cast<int>(it->value); 212 } 213 } 214 if(url != L"") 215 { 216 url = CaptureGlobal::urlDecode(url); 217 stdext::hash_map<wstring, ApplicationPlugin*>::iterator vit; 218 vit = applicationMap.find(applicationName); 219 if(vit != applicationMap.end()) 220 { 221 ApplicationPlugin* applicationPlugin = vit->second; 222 Url* visiturl = new Url(url, applicationName, time); 223 DWORD minorErrorCode = 0; 224 DWORD majorErrorCode = 0; 225 printf("Visiting: %ls -> %ls\n", visiturl->getApplicationName().c_str(), visiturl->getUrl().c_str()); 226 227 /* Pass the actual visitation process of to the application plugin */ 228 majorErrorCode = applicationPlugin->visitUrl(visiturl, &minorErrorCode); 229 ///toVisit.push(VisitPair(applicationPlugin, visiturl)); 230 ///SetEvent(hQueueNotEmpty); 231 } else { 232 printf("MySoapServer-onServerEvent: ERROR could not find client %ls path, url not queued for visitation\n", applicationName.c_str()); 233 } 234 } else { 235 printf("MySoapServer-onServerEvent: ERROR no url specified for visit event\n"); 236 } 237 } capture-mod/trunk/MySoapServer.h
r1586 r1644 3 3 */ 4 4 5 #pragma once 5 6 #include "captureGSOAP.h" 6 7 #include "Thread.h" 8 9 #include "CaptureGlobal.h" 10 #include <string> 11 #include <queue> 12 #include <list> 13 #include <iostream> 14 #include <fstream> 15 #include <vector> 16 #include <hash_map> 17 #include <boost/signal.hpp> 18 #include <boost/bind.hpp> 19 #include <boost\regex.hpp> 20 #include <boost/algorithm/string/classification.hpp> 21 #include <boost/algorithm/string/find_iterator.hpp> 22 #include <boost/algorithm/string/finder.hpp> 23 #include <boost/lexical_cast.hpp> 24 #include <boost/tokenizer.hpp> 25 #include "Url.h" 26 #include "ApplicationPlugin.h" 27 #include "Visitor.h" 28 29 using namespace std; 30 using namespace boost; 31 32 typedef split_iterator<string::iterator> sf_it; 33 7 34 8 35 class MySoapServer : public Runnable 9 36 { 10 37 public: 11 MySoapServer(); 38 typedef boost::signal<void (DWORD, DWORD, wstring, wstring)> signal_visitEvent; 39 typedef pair <HMODULE, std::list<ApplicationPlugin*>*> PluginPair; 40 typedef pair <wstring, ApplicationPlugin*> ApplicationPair; 41 typedef pair <ApplicationPlugin*, Url*> VisitPair; 42 public: 43 MySoapServer(Visitor *); 12 44 ~MySoapServer(); 13 45 14 46 void run(); 15 47 48 //Stolen from Visitor 49 void loadClientPlugins(); 50 ApplicationPlugin* createApplicationPluginObject(HMODULE hPlugin); 51 void onServerEvent(Element* pElement); 52 16 53 Thread * MySoapServerThread; 54 signal_visitEvent signalVisitEvent; 55 stdext::hash_map<HMODULE, std::list<ApplicationPlugin*>*> applicationPlugins; 56 boost::signals::connection onServerVisitEventConnection; 57 stdext::hash_map<wstring, ApplicationPlugin*> applicationMap; 58 59 static void test(); 60 static Visitor * myVisitor; 17 61 18 62 }; capture-mod/trunk/ProcessMonitor.h
r823 r1644 58 58 are attached to the onProcessEvent slot 59 59 60 Implements: < IRunnable>, <VisitorListener>, <Monitor>60 Implements: <Runnable>, <VisitorListener>, <Monitor> 61 61 */ 62 62 class ProcessMonitor : public Runnable, public Monitor capture-mod/trunk/Thread.h
r1585 r1644 28 28 Class: Thread 29 29 30 Class that accepts a pointer to another class that implements the < IRunnable> interface. This then wraps the c-style function30 Class that accepts a pointer to another class that implements the <Runnable> interface. This then wraps the c-style function 31 31 for creating a thread (threadProc) and creates an OO way to initialise, start, and stop a thread. 32 32 */ … … 55 55 Constructor: Thread 56 56 57 Creates a thread object and stores the object which implements the IRunnable interface in <_threadObj>57 Creates a thread object and stores the object which implements the Runnable interface in <_threadObj> 58 58 */ 59 59 Thread(Runnable *ptr) { … … 111 111 Variable: _threadObj 112 112 113 Pointer to an object which implements the IRunnable interface113 Pointer to an object which implements the Runnable interface 114 114 */ 115 115 Runnable *_threadObj; capture-mod/trunk/Visitor.cpp
r823 r1644 1 1 #include "Visitor.h" 2 2 3 unsigned int threadCount = 0; 4 3 5 Visitor::Visitor(void) 4 6 { … … 6 8 7 9 hQueueNotEmpty = CreateEvent(NULL, FALSE, FALSE, NULL); 10 printf("Visitor: boost that sucka\n"); 8 11 onServerVisitEventConnection=EventController::getInstance()->connect_onServerEvent(L"visit", boost::bind(&Visitor::onServerEvent, this, _1)); 9 12 10 13 loadClientPlugins(); 11 14 15 // threadname = new char[10]; 16 // sprintf(threadname, "Visitor%d\n", threadCount); 17 // threadCount++; 12 18 visitorThread = new Thread(this); 13 19 visitorThread->start("Visitor"); … … 19 25 CloseHandle(hQueueNotEmpty); 20 26 unloadClientPlugins(); 27 delete threadname; 21 28 // TODO free items in toVisit queue 22 29 } … … 33 40 while(true) 34 41 { 42 printf("Visitor::run, waiting\n"); 35 43 WaitForSingleObject(hQueueNotEmpty, INFINITE); 44 printf("Visitor::run, runing\n"); 36 45 VisitPair visit = toVisit.front(); 37 46 toVisit.pop(); … … 82 91 { 83 92 wstring pluginDir = L"plugins\\"; 84 pluginDir += FindFileData.cFileName; 93 pluginDir += FindFileData.cFileName; 85 94 HMODULE hPlugin = LoadLibrary(pluginDir.c_str()); 86 95 … … 174 183 Visitor::onServerEvent(Element* pElement) 175 184 { 185 printf("Visitor::onServerEvent"); 176 186 wstring applicationName = L"iexplore"; 177 187 wstring url = L""; capture-mod/trunk/Visitor.h
r823 r1644 68 68 69 69 boost::signals::connection onVisitEvent(const signal_visitEvent::slot_type& s); 70 void onServerEvent(Element* pElement); 70 71 private: 71 72 void loadClientPlugins(); … … 74 75 void run(); 75 76 76 void onServerEvent(Element* pElement); 77 // void onServerEvent(Element* pElement); //XENO: Forced public for tests 77 78 78 79 ApplicationPlugin* createApplicationPluginObject(HMODULE hPlugin); … … 86 87 boost::signals::connection onServerVisitEventConnection; 87 88 stdext::hash_map<wstring, ApplicationPlugin*> applicationMap; 89 90 char * threadname; 91 ///int count; 88 92 }; capture-mod/trunk/soapC.cpp
r1586 r1644 8 8 #include "soapH.h" 9 9 10 SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.7.10 2008-0 5-20 05:48:22GMT")10 SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.7.10 2008-06-27 05:00:35 GMT") 11 11 12 12 capture-mod/trunk/soapClient.cpp
r1586 r1644 7 7 #include "soapH.h" 8 8 9 SOAP_SOURCE_STAMP("@(#) soapClient.cpp ver 2.7.10 2008-0 5-20 05:48:22GMT")9 SOAP_SOURCE_STAMP("@(#) soapClient.cpp ver 2.7.10 2008-06-27 05:00:35 GMT") 10 10 11 11 capture-mod/trunk/soapServer.cpp
r1586 r1644 7 7 #include "soapH.h" 8 8 9 SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.7.10 2008-0 5-20 05:48:22GMT")9 SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.7.10 2008-06-27 05:00:35 GMT") 10 10 11 11
