11 Replies - 478 Views - Last Post: 09 August 2012 - 05:52 PM Rate Topic: -----

#1 nw22panda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 02-August 12

How do I patch my program to understand CVD files?

Posted 06 August 2012 - 03:06 PM

Hi. I am creating an anti-malware program in C#, that uses the .cvd databases of ClamWin and Clam AV for its detection rules. How can I code and/or patch my program so that it can interpret and use the CVD file?
Is This A Good Question/Topic? 0
  • +

Replies To: How do I patch my program to understand CVD files?

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1912
  • Posts: 5,707
  • Joined: 05-May 12

Re: How do I patch my program to understand CVD files?

Posted 06 August 2012 - 03:13 PM

Unless the file format is publicly available, you'll probably have to contact the makers of software to find out how the file is laid out. Then you'll have to make sure that you have at least read access to file while the file actively being used by their software. Some programs put an exclusive lock preventing others from opening the file at the same time.

After that, it's a matter of opening the file and navigating through their file structures to get to the definitions that you need. Most basic file I/O operations will work unless their file is actually managed by a database system. In that case, it maybe easier if you use the same database engine they are using to access the data in the file.
Was This Post Helpful? 1
  • +
  • -

#3 nw22panda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 02-August 12

Re: How do I patch my program to understand CVD files?

Posted 06 August 2012 - 03:23 PM

I do know that ClamWin is open source. Does this change anything?

Also, ClamWin is built off of ClamAV, which is also open-source.
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1912
  • Posts: 5,707
  • Joined: 05-May 12

Re: How do I patch my program to understand CVD files?

Posted 06 August 2012 - 03:26 PM

Then crack open the source code see how they access the files. If they applied good engineering practices, then I/O routines that deal with the .CVD files should be in only 1 or 2 files. If its a simple format, you can probably just include the header files that define the structures on disk. If it's more complicated, then you may need to copy or port to code over into your program.

If it uses a database engine that publicly available, even better then. All you need is to also use the same engine and point it at the file. Of course, you'll need to know the database schema instead of the file structures, but in theory it should be easier.
Was This Post Helpful? 0
  • +
  • -

#5 nw22panda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 02-August 12

Re: How do I patch my program to understand CVD files?

Posted 06 August 2012 - 03:36 PM

I have ClamWin on my flash drive, from PortableApps.com. So, that being said, could I just copy the engines from my flash drive over to the debug folder?
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1912
  • Posts: 5,707
  • Joined: 05-May 12

Re: How do I patch my program to understand CVD files?

Posted 06 August 2012 - 03:37 PM

Looking in the docs directory of the GIT repository, it looks like the .CVD file is a text file that you can just read using any old file I/O:
http://clamwin.git.s...res.pdf;hb=HEAD

You can probably get by just using StreamReader.ReadLine(). Chances are you've seen this MSDN micro tutorial on how to read a text file: http://msdn.microsof...y/db5x7c0d.aspx
Was This Post Helpful? 1
  • +
  • -

#7 nw22panda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 02-August 12

Re: How do I patch my program to understand CVD files?

Posted 06 August 2012 - 03:55 PM

So this code should work?
class Test
        {
            public static void Main()
            {
                try
                {
                    // Create an instance of StreamReader to read from a file.
                    // The using statement also closes the StreamReader.
                    using (StreamReader sr = new StreamReader("main.cvd"))
                    {
                        String line;
                        // Read and display lines from the file until the end of 
                        // the file is reached.
                        while ((line = sr.ReadLine()) != null)
                        {
                            Console.WriteLine(line);
                        }
                    }
                }
                catch (Exception e)
                {
                    // Let the user know what went wrong.
                    Console.WriteLine("ERROR WHILE LOADING DATABASE!:");
                    Console.WriteLine(e.Message);
                }
            }
        }

Was This Post Helpful? 0
  • +
  • -

#8 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1912
  • Posts: 5,707
  • Joined: 05-May 12

Re: How do I patch my program to understand CVD files?

Posted 06 August 2012 - 04:28 PM

That'll let you read the file. Parsing the contents will be another matter, but the PDF seemed to document things well.
Was This Post Helpful? 0
  • +
  • -

#9 nw22panda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 02-August 12

Re: How do I patch my program to understand CVD files?

Posted 07 August 2012 - 11:08 AM

So how should I go along parsing the contents?
Was This Post Helpful? 1
  • +
  • -

#10 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1912
  • Posts: 5,707
  • Joined: 05-May 12

Re: How do I patch my program to understand CVD files?

Posted 07 August 2012 - 11:33 AM

Sorry to be blunt, but if you can't even parse a text file, are you sure you want to be dealing with antivirus software?
Was This Post Helpful? 4
  • +
  • -

#11 nw22panda  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 02-August 12

Re: How do I patch my program to understand CVD files?

Posted 09 August 2012 - 04:03 PM

I understand your point, but I have created a few advanced programs in C#, but have never had to parse the contents of anything.
Was This Post Helpful? -1
  • +
  • -

#12 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1912
  • Posts: 5,707
  • Joined: 05-May 12

Re: How do I patch my program to understand CVD files?

Posted 09 August 2012 - 05:52 PM

Post #6 links to a MSDN sample for reading lines out of a file. You'll have to read the lines and try to match that up with the format documented the CVD documentation to extract the information that you need.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1