... | ... |
@@ -1,4 +1,4 @@ |
1 |
-<?xml version="1.0" encoding="utf-8"?> |
|
1 |
+<?xml version="1.0" encoding="utf-8"?> |
|
2 | 2 |
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
3 | 3 |
<ItemGroup Label="ProjectConfigurations"> |
4 | 4 |
<ProjectConfiguration Include="Debug|Win32"> |
... | ... |
@@ -172,11 +172,6 @@ |
172 | 172 |
<ClCompile Include="interface.c" /> |
173 | 173 |
<ClCompile Include="main.c" /> |
174 | 174 |
</ItemGroup> |
175 |
- <ItemGroup> |
|
176 |
- <ProjectReference Include="libclamav.vcxproj"> |
|
177 |
- <Project>{09d341e9-7372-46e9-b0d7-caaf77984190}</Project> |
|
178 |
- </ProjectReference> |
|
179 |
- </ItemGroup> |
|
180 | 175 |
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
181 | 176 |
<ImportGroup Label="ExtensionTargets"> |
182 | 177 |
</ImportGroup> |
... | ... |
@@ -44,6 +44,15 @@ |
44 | 44 |
#define CLAMAPI_SUCCESS 0 |
45 | 45 |
|
46 | 46 |
|
47 |
+/* CLAMAPI LIMITS */ |
|
48 |
+/* List of limits configurable via Scan_SetLimit and readable via Scan_GetLimit (see below) */ |
|
49 |
+enum CLAM_LIMIT_TYPE { |
|
50 |
+ CLAM_LIMIT_FILESIZE, |
|
51 |
+ CLAM_LIMIT_SCANSIZE, |
|
52 |
+ CLAM_LIMIT_RECURSION |
|
53 |
+}; |
|
54 |
+ |
|
55 |
+ |
|
47 | 56 |
/* CLAMAPI SCAN OPTIONS */ |
48 | 57 |
/* List of options settable via Scan_SetOption and retrievable via Scan_GetOption (see below) |
49 | 58 |
* All the options have a corresponding unsigned int value (0 = option disabled / non 0 = option enabled) |
... | ... |
@@ -252,6 +261,22 @@ int CLAMAPI Scan_DeleteScanInfo(CClamAVScanner *pScanner, PCLAM_SCAN_INFO_LIST p |
252 | 252 |
/* |
253 | 253 |
* Get integer based scanning options |
254 | 254 |
* ex: License Expiration Time, Count of DB signatures, Last updated time for DB, Major, Minor version of scan library |
255 |
+ * INPUT @param option : limit type |
|
256 |
+ * OUTPUT @param value : limit size in bytes |
|
257 |
+ */ |
|
258 |
+int CLAMAPI Scan_GetLimit(int option, unsigned int *value); |
|
259 |
+ |
|
260 |
+/* |
|
261 |
+ * Set integer based scanning options |
|
262 |
+ * ex: scan Archives, scan packed samples, scan e-mail databases, scan installers |
|
263 |
+ * INPUT @param option : limit type |
|
264 |
+ * INPUT @param value : limit size in bytes |
|
265 |
+ */ |
|
266 |
+int CLAMAPI Scan_SetLimit(int option, unsigned int value); |
|
267 |
+ |
|
268 |
+/* |
|
269 |
+ * Get integer based scanning options |
|
270 |
+ * ex: License Expiration Time, Count of DB signatures, Last updated time for DB, Major, Minor version of scan library |
|
255 | 271 |
* INPUT @param scanner : opaque object |
256 | 272 |
* INPUT @param option : option enum |
257 | 273 |
* INPUT @param value : location to store value |
... | ... |
@@ -467,6 +467,80 @@ int CLAMAPI Scan_GetOption(CClamAVScanner *pScanner, int option, void *value, un |
467 | 467 |
WIN(); |
468 | 468 |
} |
469 | 469 |
|
470 |
+ |
|
471 |
+int CLAMAPI Scan_GetLimit(int option, unsigned int *value) { |
|
472 |
+ enum cl_engine_field limit; |
|
473 |
+ long long curlimit; |
|
474 |
+ int err; |
|
475 |
+ |
|
476 |
+ INFN(); |
|
477 |
+ if(lock_engine()) |
|
478 |
+ FAIL(CL_EMEM, "Failed to lock engine"); |
|
479 |
+ if(!engine) { |
|
480 |
+ unlock_engine(); |
|
481 |
+ FAIL(CL_EARG, "Engine is NULL"); |
|
482 |
+ } |
|
483 |
+ switch((enum CLAM_LIMIT_TYPE)option) { |
|
484 |
+ case CLAM_LIMIT_FILESIZE: |
|
485 |
+ limit = CL_ENGINE_MAX_FILESIZE; |
|
486 |
+ break; |
|
487 |
+ case CLAM_LIMIT_SCANSIZE: |
|
488 |
+ limit = CL_ENGINE_MAX_SCANSIZE; |
|
489 |
+ break; |
|
490 |
+ case CLAM_LIMIT_RECURSION: |
|
491 |
+ limit = CL_ENGINE_MAX_SCANSIZE; |
|
492 |
+ break; |
|
493 |
+ default: |
|
494 |
+ unlock_engine(); |
|
495 |
+ FAIL(CL_EARG, "Unsupported limit type: %d", option); |
|
496 |
+ } |
|
497 |
+ curlimit = cl_engine_get_num(engine, limit, &err); |
|
498 |
+ if(err) { |
|
499 |
+ unlock_engine(); |
|
500 |
+ FAIL(err, "Failed to get engine value: %s", cl_strerror(err)); |
|
501 |
+ } |
|
502 |
+ if(curlimit > 0xffffffff) |
|
503 |
+ *value = 0xffffffff; |
|
504 |
+ else |
|
505 |
+ *value = (unsigned int)curlimit; |
|
506 |
+ unlock_engine(); |
|
507 |
+ WIN(); |
|
508 |
+} |
|
509 |
+ |
|
510 |
+ |
|
511 |
+int CLAMAPI Scan_SetLimit(int option, unsigned int value) { |
|
512 |
+ enum cl_engine_field limit; |
|
513 |
+ int err; |
|
514 |
+ |
|
515 |
+ INFN(); |
|
516 |
+ if(lock_engine()) |
|
517 |
+ FAIL(CL_EMEM, "Failed to lock engine"); |
|
518 |
+ if(!engine) { |
|
519 |
+ unlock_engine(); |
|
520 |
+ FAIL(CL_EARG, "Engine is NULL"); |
|
521 |
+ } |
|
522 |
+ switch((enum CLAM_LIMIT_TYPE)option) { |
|
523 |
+ case CLAM_LIMIT_FILESIZE: |
|
524 |
+ limit = CL_ENGINE_MAX_FILESIZE; |
|
525 |
+ break; |
|
526 |
+ case CLAM_LIMIT_SCANSIZE: |
|
527 |
+ limit = CL_ENGINE_MAX_SCANSIZE; |
|
528 |
+ break; |
|
529 |
+ case CLAM_LIMIT_RECURSION: |
|
530 |
+ limit = CL_ENGINE_MAX_SCANSIZE; |
|
531 |
+ break; |
|
532 |
+ default: |
|
533 |
+ unlock_engine(); |
|
534 |
+ FAIL(CL_EARG, "Unsupported limit type: %d", option); |
|
535 |
+ } |
|
536 |
+ err = cl_engine_set_num(engine, limit, (long long)value); |
|
537 |
+ unlock_engine(); |
|
538 |
+ if(err) |
|
539 |
+ FAIL(err, "Failed to set engine value: %s", cl_strerror(err)); |
|
540 |
+ WIN(); |
|
541 |
+} |
|
542 |
+ |
|
543 |
+ |
|
470 | 544 |
int CLAMAPI Scan_ScanObject(CClamAVScanner *pScanner, const wchar_t *pObjectPath, int *pScanStatus, PCLAM_SCAN_INFO_LIST *pInfoList) { |
471 | 545 |
HANDLE fhdl; |
472 | 546 |
int res; |
... | ... |
@@ -540,7 +614,6 @@ int CLAMAPI Scan_ScanObjectByHandle(CClamAVScanner *pScanner, HANDLE object, int |
540 | 540 |
do { |
541 | 541 |
CLAM_SCAN_INFO si; |
542 | 542 |
CLAM_ACTION act; |
543 |
- HANDLE fdhdl; |
|
544 | 543 |
DWORD cbperf; |
545 | 544 |
wchar_t wvirname[MAX_VIRNAME_LEN]; |
546 | 545 |
LONG lo = 0, hi = 0, hi2 = 0; |