Changeset 1773
- Timestamp:
- 08/28/08 12:34:20 (3 months ago)
- Files:
-
- capture-mod/trunk/CaptureSoapServer.cpp (modified) (9 diffs)
- capture-mod/trunk/CaptureSoapServer.h (modified) (2 diffs)
- capture-mod/trunk/install/CaptureBAT.exe (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
capture-mod/trunk/CaptureSoapServer.cpp
r1771 r1773 86 86 87 87 //now begins the arduous process of converting the values into char *s 88 //TODO: use a soap function to make r 88 89 ns__regEvent_t r; 89 //TODO: trace through and verify that all mallocs are cleaned up by the soap code 90 r.time = (char *)malloc(time.length()+1); 90 r.time = (char *)soap_malloc(&soap,time.length()+1); 91 91 sprintf(r.time, "%ls", time.c_str()); 92 printf("r.time = %s\n", r.time); 93 94 r.eventType = (char *)malloc(registryEventType.length()+1); 92 93 r.eventType = (char *)soap_malloc(&soap,registryEventType.length()+1); 95 94 sprintf(r.eventType, "%ls", registryEventType.c_str()); 96 95 97 char * tmp = (char *) malloc(extra.at(0).length()+1);96 char * tmp = (char *)soap_malloc(&soap,extra.at(0).length()+1); 98 97 sprintf(tmp, "%ls", extra.at(0).c_str()); 99 98 r.procPID = atoi(tmp); 100 printf("r.procPID = %d\n", r.procPID);101 99 free(tmp); 102 100 103 r.procName = (char *) malloc(processPath.length()+1);101 r.procName = (char *)soap_malloc(&soap,processPath.length()+1); 104 102 sprintf(r.procName, "%ls", processPath.c_str()); 105 103 106 r.keyName = (char *) malloc(registryEventPath.length()+1);104 r.keyName = (char *)soap_malloc(&soap,registryEventPath.length()+1); 107 105 sprintf(r.keyName, "%ls", registryEventPath.c_str()); 108 106 109 r.valueName = (char *) malloc(extra.at(1).length()+1);107 r.valueName = (char *)soap_malloc(&soap,extra.at(1).length()+1); 110 108 sprintf(r.valueName, "%ls", extra.at(1).c_str()); 111 109 112 r.valueType = (char *) malloc(extra.at(2).length()+1);110 r.valueType = (char *)soap_malloc(&soap,extra.at(2).length()+1); 113 111 sprintf(r.valueType, "%ls", extra.at(2).c_str()); 114 112 115 r.valueData = (char *) malloc(extra.at(3).length()+1);113 r.valueData = (char *)soap_malloc(&soap,extra.at(3).length()+1); 116 114 sprintf(r.valueData, "%ls", extra.at(3).c_str()); 117 115 … … 127 125 { 128 126 printf("CaptureSoapServer::onFileEvent got an event for time = %ls\n", time.c_str()); 127 ns__fileEvent_t f; 128 f.time = (char *)soap_malloc(&soap,time.length()+1); 129 sprintf(f.time, "%ls", time.c_str()); 130 131 f.eventType = (char *)soap_malloc(&soap,fileEventType.length()+1); 132 sprintf(f.eventType, "%ls", fileEventType.c_str()); 133 134 char * tmp = (char *)malloc(extra.at(0).length()+1); 135 sprintf(tmp, "%ls", extra.at(0).c_str()); 136 f.procPID = atoi(tmp); 137 free(tmp); 138 139 f.procName = (char *)soap_malloc(&soap,processPath.length()+1); 140 sprintf(f.procName, "%ls", processPath.c_str()); 141 142 f.fileName = (char *)soap_malloc(&soap,fileEventPath.length()+1); 143 sprintf(f.fileName, "%ls", fileEventPath.c_str()); 144 145 fileList.push_back(f); 146 printf("added one event to fileList. Now there are %d elements in the list\n", fileList.size()); 147 148 129 149 } 130 150 … … 134 154 { 135 155 printf("CaptureSoapServer::onProcessEvent got an event for time = %ls\n", time.c_str()); 156 ns__procEvent_t p; 157 p.time = (char *)soap_malloc(&soap,time.length()+1); 158 sprintf(p.time, "%ls", time.c_str()); 159 160 p.eventType = (char *)soap_malloc(&soap,11); //11 == max length == "terminated" 161 if(created){ 162 sprintf(p.eventType, "created"); 163 } 164 else{ 165 sprintf(p.eventType, "terminated"); 166 } 167 168 p.parentPID = parentProcessId; 169 170 p.parentName = (char *)soap_malloc(&soap,parentProcess.length()+1); 171 sprintf(p.parentName, "%ls", parentProcess.c_str()); 172 173 p.procPID = processId; 174 175 p.procName = (char *)soap_malloc(&soap,process.length()+1); 176 sprintf(p.procName, "%ls", process.c_str()); 177 178 procList.push_back(p); 179 printf("added one event to procList. Now there are %d elements in the list\n", procList.size()); 180 136 181 } 137 182 … … 332 377 333 378 //If maxEventsReturned == -1, then then send as many as possible. 334 //TODO: Make SOAP::Lite understand unsigned int type, so that this (and other) ints can be set as such335 379 int ns__returnEvents(struct soap *soap, int maxEventsToReturn, struct ns__allEvents &result){ 380 char debug = 0; 381 336 382 struct ns__allEvents * all = soap_new_ns__allEvents(soap, 1); 337 383 all->regEvents = NULL; … … 350 396 all->regEvents = dRegArray; 351 397 352 printf("dRegArray->__size = %d, maxEventsToReturn = %d\n", dRegArray->__size, maxEventsToReturn);353 354 398 //Figure out how many entries we will send back 355 if(maxEventsToReturn == -1 || maxEventsToReturn > dRegArray->__size){ 356 dRegArray->__size = regList.size(); 357 } 358 else{ 399 if(maxEventsToReturn < dRegArray->__size && maxEventsToReturn != -1){ 359 400 dRegArray->__size = maxEventsToReturn; 360 401 } 361 362 402 printf("Sending back %d registy events\n",dRegArray->__size); 363 403 364 //don't want to call the size function more times than we have to 404 //Allocate a flat array to hold our ns__regEvents in 405 //TODO: see if soap_new_ns__regEvent(soap, dRegArray->__size) works 365 406 struct ns__regEvent * ns__regEventArray = (struct ns__regEvent *)soap_malloc(soap, dRegArray->__size*sizeof(struct ns__regEvent)); 366 367 407 dRegArray->__ptr = ns__regEventArray; 368 408 369 int * b = (int *) ns__regEventArray;370 409 for(unsigned int i = 0; i < dRegArray->__size; i++){ 410 memcpy(&ns__regEventArray[i],®List.front(), sizeof(struct ns__regEvent)); 411 regList.pop_front(); 412 if(debug){ 371 413 printf("i = %d\n", i); 372 414 printf("regList.front().time %s, %#x\n", regList.front().time, regList.front().time); … … 374 416 printf("regList.front().procPID %d, %#x\n", regList.front().procPID, regList.front().procPID); 375 417 printf("regList.front().procName %s, %#x\n", regList.front().procName, regList.front().procName); 376 377 memcpy(&ns__regEventArray[i],®List.front(), sizeof(struct ns__regEvent)); 378 regList.pop_front(); 379 printf("%#x %#x %#x %#x\n", b[i*8+0], b[i*8+1], b[i*8+2], b[i*8+3]); 418 } 380 419 } 381 420 } … … 392 431 393 432 //Figure out how many entries we will send back 394 if(maxEventsToReturn == -1 || maxEventsToReturn > dFileArray->__size){ 395 dFileArray->__size = fileList.size(); 396 } 397 else{ 433 if(maxEventsToReturn < dFileArray->__size && maxEventsToReturn != -1){ 398 434 dFileArray->__size = maxEventsToReturn; 399 435 } 400 401 436 printf("Sending back %d file events\n",dFileArray->__size); 437 402 438 struct ns__fileEvent * ns__fileEventArray = (struct ns__fileEvent *)soap_malloc(soap, dFileArray->__size*sizeof(struct ns__fileEvent)); 403 404 439 dFileArray->__ptr = ns__fileEventArray; 405 440 406 441 for(unsigned int i = 0; i < dFileArray->__size; i++){ 407 442 memcpy(&ns__fileEventArray[i],&fileList.front(), sizeof(struct ns__fileEvent)); 408 regList.pop_front();443 fileList.pop_front(); 409 444 } 410 445 } … … 420 455 all->procEvents = dProcArray; 421 456 422 if(maxEventsToReturn == -1 || maxEventsToReturn > dProcArray->__size){ 423 dProcArray->__size = regList.size(); 424 } 425 else{ 457 if(maxEventsToReturn < dProcArray->__size && maxEventsToReturn != -1){ 426 458 dProcArray->__size = maxEventsToReturn; 427 459 } 428 429 460 printf("Sending back %d process events\n",dProcArray->__size); 430 461 … … 434 465 for(unsigned int i = 0; i < dProcArray->__size; i++){ 435 466 memcpy(&ns__procEventArray[i],&procList.front(), sizeof(struct ns__procEvent)); 436 regList.pop_front();467 procList.pop_front(); 437 468 } 438 469 } capture-mod/trunk/CaptureSoapServer.h
r1767 r1773 13 13 using namespace boost; 14 14 15 //While we could put typedefs in the definition, they don't follow through to the auto-generated 16 //soap files. Therefore you would have to include captureGSOAP.h, but that would cause double definitions 17 typedef struct ns__regEvent ns__regEvent_t; 18 typedef struct ns__fileEvent ns__fileEvent_t; 19 typedef struct ns__procEvent ns__procEvent_t; 20 15 21 class CaptureSoapServer : public Runnable 16 22 { … … 20 26 boost::signals::connection onFileEventConnection; 21 27 boost::signals::connection onProcessEventConnection; 22 typedef struct ns__regEvent ns__regEvent_t;23 typedef struct ns__fileEvent ns__fileEvent_t;24 typedef struct ns__procEvent ns__procEvent_t;25 26 28 27 29 CaptureSoapServer(Visitor *, RegistryMonitor * r, FileMonitor * f, ProcessMonitor * p);
