Changeset 1777

Show
Ignore:
Timestamp:
08/29/08 16:35:43 (3 months ago)
Author:
xkovah
Message:

This was when I was trying to send the events back in the visit. But I've decided to give up for now, since visit doesn't block. Thus the Manager can just poll Capture as frequently as it wants to see if any events have been seen yet.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • capture-mod/trunk/CaptureClient.sln

    r1776 r1777  
    1717    GlobalSection(ProjectConfigurationPlatforms) = postSolution 
    1818        {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Debug|Win32.ActiveCfg = Debug|Win32 
     19        {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Debug|Win32.Build.0 = Debug|Win32 
    1920        {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Release|Win32.ActiveCfg = Release|Win32 
    2021        {4A258E9F-0B4B-40EF-B6C6-E69C630E5CAC}.Release|Win32.Build.0 = Release|Win32 
     
    2324        {AE2C8E80-7D21-47AD-987B-43E0708AE549}.Release|Win32.Build.0 = Release|Win32 
    2425        {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Debug|Win32.ActiveCfg = Debug|Win32 
     26        {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Debug|Win32.Build.0 = Debug|Win32 
    2527        {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Release|Win32.ActiveCfg = Release|Win32 
    2628        {4EF34E6D-B30C-46E5-9FC5-967ECEADE2CD}.Release|Win32.Build.0 = Release|Win32 
  • capture-mod/trunk/CaptureSoapServer.cpp

    r1776 r1777  
    4848   //The below code is taken mostly from the gsoap standalone server example page 
    4949   soap_init(&soap); 
    50    //FIXME TODO: This needs to be configurable 
    51    m = soap_bind(&soap, "192.168.0.131", 1234, 100); 
     50   //TODO: change this to the desired port 
     51   m = soap_bind(&soap, "0.0.0.0", 1234, 100); 
    5252   if (m < 0) 
    5353      soap_print_fault(&soap, stderr); 
     
    8686{ 
    8787    char debug = 0; 
    88     printf("CaptureSoapServer::onRegistryEvent got an event for time = %ls, length = %d\n", time.c_str(), time.length()); 
     88    if(debug) printf("CaptureSoapServer::onRegistryEvent got an event for time = %ls, length = %d\n", time.c_str(), time.length()); 
    8989 
    9090    //now begins the arduous process of converting the values into char *s 
    91     //TODO: use a soap function to make r 
    9291    ns__regEvent_t r; 
    9392    r.time = (char *)malloc(time.length()+1); 
     
    117116    sprintf(r.valueData, "%ls", extra.at(3).c_str()); 
    118117     
    119     int * b = (int *)&r; 
    120     for(int i = 0; i < 8; i++){ 
    121         printf("r[%d] = %#x\n", i, b[i]); 
     118    if(debug){ 
     119        int * b = (int *)&r; 
     120        for(int i = 0; i < 8; i++){ 
     121            printf("r[%d] = %#x\n", i, b[i]); 
     122        } 
    122123    } 
    123124 
    124125    regList.push_back(r); 
    125     printf("added one event to regList. Now there are %d elements in the list\n", regList.size()); 
     126    if(debug) printf("added one event to regList. Now there are %d elements in the list\n", regList.size()); 
    126127} 
    127128 
     
    133134{ 
    134135    char debug = 0; 
    135     printf("CaptureSoapServer::onFileEvent got an event for time = %ls\n", time.c_str()); 
     136    if(debug) printf("CaptureSoapServer::onFileEvent got an event for time = %ls\n", time.c_str()); 
    136137    ns__fileEvent_t f; 
    137138    f.time = (char *)malloc(time.length()+1); 
     
    159160    } 
    160161    fileList.push_back(f); 
    161     printf("added one event to fileList. Now there are %d elements in the list\n", fileList.size()); 
     162    if(debug) printf("added one event to fileList. Now there are %d elements in the list\n", fileList.size()); 
    162163 
    163164} 
     
    167168                                        DWORD processId, wstring process) 
    168169{ 
    169     printf("CaptureSoapServer::onProcessEvent got an event for time = %ls\n", time.c_str()); 
     170    char debug = 0; 
     171    if(debug) printf("CaptureSoapServer::onProcessEvent got an event for time = %ls\n", time.c_str()); 
    170172    ns__procEvent_t p; 
    171173    p.time = (char *)malloc(time.length()+1); 
     
    191193 
    192194    procList.push_back(p); 
    193     printf("added one event to procList. Now there are %d elements in the list\n", procList.size()); 
     195    if(debug) printf("added one event to procList. Now there are %d elements in the list\n", procList.size()); 
    194196 
    195197} 
     
    206208//Give it a url to browse to 
    207209int ns__visitURL(struct soap *soap, char * url, struct ns__allEvents &result){ 
     210    char debug = 1; 
    208211    wchar_t xURL[1024]; 
    209212    wsprintf(xURL, L"%hs", url); 
     
    218221    e.data = NULL; 
    219222    e.dataLength = 0; 
    220     printf("visiting %s\n", url); 
     223    if(debug) printf("visitURL to %s\n", url); 
     224    EventController::getInstance()->notifyListeners(&e); 
     225 
    221226    //TODO: We currently run the browser visit event as a black box. 
    222227    //In the future we will want to be able to report back about events before 
    223228    //it times out or it's cleanly done with the browse. 
    224     EventController::getInstance()->notifyListeners(&e); 
    225  
    226     struct ns__allEvents all; 
    227     memset(&all, 0, sizeof(struct ns__allEvents)); 
    228  
     229    //NOTE: For now, telling the browser to run is not a blocking operation. 
     230    //The alternate way I had done it in the past (calling Visitor::onServerEvent directly IIRC) 
     231    //was a blocking way, and might need to be brought back, both for the blocking, and for 
     232    //being able to get richer information back 
     233 
     234    //hack, becase of the above 
     235    Sleep(5000); 
    229236    if(!regList.empty() || !fileList.empty() || !procList.empty()){ 
    230         return ns__returnEvents(soap, -1, all); 
     237        goto done; 
     238    } 
     239    Sleep(5000); 
     240    if(!regList.empty() || !fileList.empty() || !procList.empty()){ 
     241        goto done; 
     242    } 
     243    Sleep(5000); 
     244    if(!regList.empty() || !fileList.empty() || !procList.empty()){ 
     245        goto done; 
     246    } 
     247    Sleep(5000); 
     248 
     249done: 
     250    struct ns__allEvents * all = soap_new_ns__allEvents(soap, 1); 
     251    memset(all, 0, sizeof(struct ns__allEvents)); 
     252 
     253    if(!regList.empty() || !fileList.empty() || !procList.empty()){ 
     254        int ret = ns__returnEvents(soap, -1, *all); 
     255        if(debug) printf("all->regEvents = %#x, all->fileEvents = %#x, all->procEvents = %#x\n", all->regEvents, all->fileEvents, all->procEvents); 
     256        return ret; 
    231257    } 
    232258    else{ 
     
    236262 
    237263int ns__sendFileBase64(struct soap *soap, char * fileName, char * data, unsigned int encodedLength, unsigned int decodedLength, int &result){ 
    238     printf("in ns__sendFileBase64\n"); 
    239  
    240     printf("encodedLength = %d, decodedLength = %d, data[0][1][2][3] = %c%c%c%c\n", encodedLength, decodedLength, 
     264    char debug = 0; 
     265    if(debug) printf("in ns__sendFileBase64\n"); 
     266 
     267    if(debug) printf("encodedLength = %d, decodedLength = %d, data[0][1][2][3] = %c%c%c%c\n", encodedLength, decodedLength, 
    241268        data[0], data[1], data[2], data[3]); 
    242269 
     
    263290    BOOL b = WriteFile(myHandle, decodedData, decodedLength, &numWrote, NULL); 
    264291    if(b){ 
    265         printf("Wrote %d bytes of data to %s\n", numWrote, fileName); 
     292        if(debug) printf("Wrote %d bytes of data to %s\n", numWrote, fileName); 
    266293    } 
    267294    CloseHandle(myHandle); 
     
    312339    unsigned int encodedLength = (unsigned int)b64::b64_encode(buffer, fileSize, NULL, NULL); 
    313340    if(debug) printf("encodedLength = %d\n", encodedLength); 
     341    //TODO: make this a soap_malloc() 
    314342    char * encodedData = new char[encodedLength]; 
    315343    memset(encodedData, 0, encodedLength); 
     
    346374// have an 'unsigned int' type by default, and I didn't want to make one. Make sure you cast it to DWORD. 
    347375int ns__openDocument(struct soap *soap, char * fileName, int waitTimeMillisec, int &result){ 
    348     int debug = 1
     376    int debug = 0
    349377    if(debug) printf("in ns__openDocument, waitTimeMillisec = %d\n", waitTimeMillisec); 
    350378 
     
    373401    } 
    374402     
    375     //Add the process to the job object 
     403    //Add the process to the job object. 
    376404    b = AssignProcessToJobObject(myJobObj, procInfo.hProcess); 
    377405    if(!b){ 
     
    387415    //TODO: Before we terminate the jobs, see if it created any events. If so, let it run, and tell the 
    388416    //HC Manager about it. The Manager should then request the information about events separately. 
     417    //This is the sort of check we would like for browsing as well 
    389418 
    390419    b = TerminateJobObject(myJobObj, 0); 
     
    393422        return SOAP_ERR; 
    394423    } 
    395     //Just incase. I don't know if this is still needed 
    396424    CloseHandle(procInfo.hProcess); 
    397425    CloseHandle(procInfo.hThread); 
     
    403431//If maxEventsReturned == -1, then then send as many as possible. 
    404432int ns__returnEvents(struct soap *soap, int maxEventsToReturn, struct ns__allEvents &result){ 
    405     char debug = 1
     433    char debug = 0
    406434 
    407435    struct ns__allEvents * all = soap_new_ns__allEvents(soap, 1); 
     
    425453            dRegArray->__size = maxEventsToReturn; 
    426454        } 
    427         printf("Sending back %d registy events\n",dRegArray->__size); 
     455        if(debug) printf("Sending back %d registy events\n",dRegArray->__size); 
    428456 
    429457        //Allocate a flat array to hold our ns__regEvents in 
     
    464492            dFileArray->__size = maxEventsToReturn; 
    465493        } 
    466         printf("Sending back %d file events\n",dFileArray->__size); 
     494        if(debug) printf("Sending back %d file events\n",dFileArray->__size); 
    467495 
    468496        struct ns__fileEvent * ns__fileEventArray = (struct ns__fileEvent *)soap_malloc(soap, dFileArray->__size*sizeof(struct ns__fileEvent)); 
     
    489517            dProcArray->__size = maxEventsToReturn; 
    490518        } 
    491         printf("Sending back %d process events\n",dProcArray->__size); 
     519        if(debug) printf("Sending back %d process events\n",dProcArray->__size); 
    492520 
    493521        struct ns__procEvent * ns__procEventArray = (struct ns__procEvent *)soap_malloc(soap, dProcArray->__size*sizeof(struct ns__procEvent)); 
     
    502530 
    503531    result = *all; 
    504     printf("all->regEvents = %#x, all->fileEvents = %#x, all->procEvents = %#x\n", all->regEvents, all->fileEvents, all->procEvents); 
    505 //  printf("&dRegArray = %#x, dRegArray->__ptr = %#x\n",&dRegArray, dRegArray->__ptr); 
    506 //  printf("dRegArray->__ptr[0][1][2][3] = %#x %#x %#x %#x\n", dRegArray->__ptr[0], dRegArray->__ptr[1], dRegArray->__ptr[2], dRegArray->__ptr[3]); 
    507     printf("regList.size() = %d, fileList.size() = %d, procList.size() = %d\n", regList.size(), fileList.size(), procList.size()); 
     532    if(debug) printf("all->regEvents = %#x, all->fileEvents = %#x, all->procEvents = %#x\n", all->regEvents, all->fileEvents, all->procEvents); 
     533    if(debug) printf("regList.size() = %d, fileList.size() = %d, procList.size() = %d\n", regList.size(), fileList.size(), procList.size()); 
    508534 
    509535    return SOAP_OK; 
  • capture-mod/trunk/capture.wsdl

    r1776 r1777  
    257257 <documentation>gSOAP 2.7.10 generated service definition</documentation> 
    258258 <port name="capture" binding="tns:capture"> 
    259   <SOAP:address location="http://192.168.0.131:1234"/> 
     259  <SOAP:address location="http://0.0.0.0:1234"/> 
    260260 </port> 
    261261</service> 
  • capture-mod/trunk/captureGSOAP.h

    r1776 r1777  
    77//gsoap ns service style: rpc 
    88//gsoap ns service encoding: encoded 
    9 //gsoap ns service port: http://192.168.0.131:1234 
     9//gsoap ns service port: http://0.0.0.0:1234 
    1010//gsoap ns service namespace: capture 
    1111 
  • capture-mod/trunk/soapC.cpp

    r1776 r1777  
    88#include "soapH.h" 
    99 
    10 SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.7.10 2008-08-29 03:46:42 GMT") 
     10SOAP_SOURCE_STAMP("@(#) soapC.cpp ver 2.7.10 2008-08-29 08:12:30 GMT") 
    1111 
    1212 
  • capture-mod/trunk/soapClient.cpp

    r1776 r1777  
    77#include "soapH.h" 
    88 
    9 SOAP_SOURCE_STAMP("@(#) soapClient.cpp ver 2.7.10 2008-08-29 03:46:42 GMT") 
     9SOAP_SOURCE_STAMP("@(#) soapClient.cpp ver 2.7.10 2008-08-29 08:12:30 GMT") 
    1010 
    1111 
     
    1414    struct ns__pingResponse *soap_tmp_ns__pingResponse; 
    1515    if (!soap_endpoint) 
    16         soap_endpoint = "http://192.168.0.131:1234"; 
     16        soap_endpoint = "http://0.0.0.0:1234"; 
    1717    soap->encodingStyle = ""; 
    1818    soap_tmp_ns__ping.a = a; 
     
    6666{   struct ns__visitURL soap_tmp_ns__visitURL; 
    6767    if (!soap_endpoint) 
    68         soap_endpoint = "http://192.168.0.131:1234"; 
     68        soap_endpoint = "http://0.0.0.0:1234"; 
    6969    soap->encodingStyle = ""; 
    7070    soap_tmp_ns__visitURL.URL = URL; 
     
    117117    struct ns__sendFileBase64Response *soap_tmp_ns__sendFileBase64Response; 
    118118    if (!soap_endpoint) 
    119         soap_endpoint = "http://192.168.0.131:1234"; 
     119        soap_endpoint = "http://0.0.0.0:1234"; 
    120120    soap->encodingStyle = ""; 
    121121    soap_tmp_ns__sendFileBase64.fileName = fileName; 
     
    171171{   struct ns__receiveFileBase64 soap_tmp_ns__receiveFileBase64; 
    172172    if (!soap_endpoint) 
    173         soap_endpoint = "http://192.168.0.131:1234"; 
     173        soap_endpoint = "http://0.0.0.0:1234"; 
    174174    soap->encodingStyle = ""; 
    175175    soap_tmp_ns__receiveFileBase64.fileName = fileName; 
     
    222222    struct ns__openDocumentResponse *soap_tmp_ns__openDocumentResponse; 
    223223    if (!soap_endpoint) 
    224         soap_endpoint = "http://192.168.0.131:1234"; 
     224        soap_endpoint = "http://0.0.0.0:1234"; 
    225225    soap->encodingStyle = ""; 
    226226    soap_tmp_ns__openDocument.fileName = fileName; 
     
    274274{   struct ns__returnEvents soap_tmp_ns__returnEvents; 
    275275    if (!soap_endpoint) 
    276         soap_endpoint = "http://192.168.0.131:1234"; 
     276        soap_endpoint = "http://0.0.0.0:1234"; 
    277277    soap->encodingStyle = ""; 
    278278    soap_tmp_ns__returnEvents.maxEventsToReturn = maxEventsToReturn; 
     
    325325    struct ns__sendMIMEResponse *soap_tmp_ns__sendMIMEResponse; 
    326326    if (!soap_endpoint) 
    327         soap_endpoint = "http://192.168.0.131:1234"; 
     327        soap_endpoint = "http://0.0.0.0:1234"; 
    328328    soap->encodingStyle = ""; 
    329329    soap_tmp_ns__sendMIME.magicNumber = magicNumber; 
  • capture-mod/trunk/soapServer.cpp

    r1776 r1777  
    77#include "soapH.h" 
    88 
    9 SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.7.10 2008-08-29 03:46:42 GMT") 
     9SOAP_SOURCE_STAMP("@(#) soapServer.cpp ver 2.7.10 2008-08-29 08:12:30 GMT") 
    1010 
    1111