Hi All,
I am trying to test evaluation version of the Symantec engine for Cloud dll for .NET.
I have written the code as shown below:
private void button2_Click(object sender, EventArgs e)
{
String s = @"X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*";
string filePath1 = @"C:\Projects\Security\SampleFiles\File1.txt";
string filePath2 = @"C:\Projects\Security\SampleFiles\File2.txt";
MemoryStream memStream1 = new MemoryStream();
Byte[] info1 = Encoding.ASCII.GetBytes(s);
MemoryStream sst = new MemoryStream(info1);
List<ScanEngineInfo> scanEnginesForScanning = new List<ScanEngineInfo>();
if (scanEnginesForScanning.Count == 0)
{
scanEnginesForScanning.Add(new ScanEngineInfo("127.0.0.1", 1344));
}
ScanRequestManager requestManagerObj = new ScanRequestManager();
requestManagerObj.PrepareForScan(scanEnginesForScanning, 20000, 20);
Policy enumPolicy = Policy.DEFAULT;//.DEFAULT;
//Create StreamScanRequest object
StreamScanRequest testObj = requestManagerObj.CreateStreamScanRequest(Policy.DEFAULT);
using (BinaryReader br = new BinaryReader(sst))
{
int dataRead = 0;
// Read file in bytes
byte[] data = new byte[512];
scanEnginesForScanning.Clear();
if (!testObj.Start(string.Empty,string.Empty))
{
throw new System.Exception("Unable to start streaming, possible server connection issue");
}
bool test = testObj.Start(System.IO.Path.GetFileName(filePath1), System.IO.Path.GetFileName(filePath1));
FileInfo fInfo = new FileInfo(filePath1);
long numBytes = fInfo.Length;
long bytesToRead = numBytes + 1;
int buffCapRead = data.Length;
// Read file in bytes
do
{
if (bytesToRead >= buffCapRead)
{
buffCapRead = data.Length;
}
else
{
buffCapRead = Convert.ToInt32(bytesToRead);
}
// Refresh data buffer.
data = new byte[buffCapRead];
dataRead = br.Read(data, 0, buffCapRead);
// Send the bytes to symantec protection engine
testObj.Send(data);
bytesToRead = bytesToRead - dataRead;
} while (bytesToRead > 0);
MemoryStream wr = new MemoryStream();
ScanResult scanResult = testObj.Finish(wr);
}
}
In this testObj.Start is always retruning false and scean is not happening even though I pass virus stream to scan.
Your help will be appricated.
Thank you,
Jithendra.