123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
-
-
-
-
-
- Imports System.Runtime.InteropServices
- Imports System.Text
-
- Module SNFMultiDLLExample
-
- #Region "DLL Imports"
-
-
- Const SNFMULTI_DLL As String = "..\..\..\..\64bitDll\SNFMulti.dll"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="setThrottle", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function setThrottle(ByVal Threads As Int32) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="startupSNF", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function startupSNF(ByVal PathToConfigurationFile As String) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="startupSNFAuthenticated", CharSet:=CharSet.Ansi, _
- CallingConvention:=CallingConvention.Winapi)> _
- Public Function startupSNFAuthenticated( _
- ByVal Path As String, _
- ByVal Lic As String, _
- ByVal Auth As String) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="shutdownSNF", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function shutdownSNF() As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="testIP", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function testIP(ByVal IPToCheck As UInt32) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="getIPReputation", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function getIPReputation(ByVal IPToCheck As UInt32) As Double
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="scanBuffer", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function scanBuffer(ByVal MsgBfr As StringBuilder, ByVal MsgBfrLen As Int32, ByVal MsgID As String, ByVal SetupTime As Int32) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="scanFile", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function scanFile(ByVal FilePath As String, ByVal Setup As Int32) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="getScanXHeaders", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function getScanXHeaders(ByVal ScannerHandle As Int32, ByRef HeadersPtr As IntPtr, ByRef HeadersLength As Int32) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="getScanXMLLog", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function getScanXMLLog(ByVal ScannerHandle As Int32, ByRef LogPtr As IntPtr, ByRef LogLength As Int32) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="getScanClassicLog", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function getScanClassicLog(ByVal ScannerHandle As Int32, ByRef LogPtr As IntPtr, ByRef LogLength As Int32) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="getScanResult", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function getScanResult(ByVal ScannerHandle As Int32) As Int32
- End Function
-
-
- <DllImport(SNFMULTI_DLL, EntryPoint:="closeScan", CharSet:=CharSet.Ansi, CallingConvention:=CallingConvention.Winapi)> _
- Public Function closeScan(ByVal ScannerHandle As Int32) As Int32
- End Function
-
- #End Region
-
- Sub Main()
-
-
-
-
-
-
- Const ConfigurationPath As String = "..\..\..\snf_engine.xml"
-
-
-
- Const IPToTest As UInt32 = &HC22384E
-
- Const SampleMessage As String = _
- "Received: from mx-out.example.com [12.34.56.78] (HELO Somebody)\r\n" + _
- " by mx-in.example.com (nosuchserver v1.0) for nobody@example.com\r\n" + _
- "From: <somebody@example.com>\r\n" + _
- "To: <nobody@example.com>\r\n" + _
- "Subject: Nothing to see here\r\n" + _
- "\r\n" + _
- "So this is the big thing that's not here to see.\r\n" + _
- "I thought it would be more interesting than this.\r\n" + _
- "\r\n" + _
- "_M\r\n" + _
- ".\r\n"
-
-
-
-
- Dim Result As Integer = 0
-
- Result = startupSNF(ConfigurationPath)
-
-
-
-
-
-
- Console.WriteLine("Started with config " + ConfigurationPath + " Result: " + Result.ToString("D"))
-
-
-
- Result = testIP(IPToTest)
- Console.WriteLine("IP test result: " + Result.ToString("D"))
-
- Dim IPReputation As Double = getIPReputation(IPToTest)
- Console.WriteLine("IP Reputation: " + IPReputation.ToString())
-
-
-
- Const NumberOfScans As Integer = 10
- For i As Integer = 0 To NumberOfScans
-
-
-
- IPReputation = getIPReputation(IPToTest)
- Console.WriteLine("IP Reputation: " + IPReputation.ToString())
-
-
-
- Dim SetupTime As Integer = 12
- Dim ScanHandle As Integer = 0
- Dim MsgBuffer As New StringBuilder
- MsgBuffer.Append(SampleMessage)
- ScanHandle = scanBuffer(MsgBuffer, MsgBuffer.Length(), "TestMessage", SetupTime)
-
-
- Console.WriteLine("Scan Handle: " + ScanHandle.ToString("D"))
-
-
-
- Dim XHeadersBuffer As IntPtr = IntPtr.Zero
- Dim XHeadersLength As Int32
- Dim XHeaders As String
-
- Dim ScanResult As Integer = 0
- ScanResult = getScanXHeaders(ScanHandle, XHeadersBuffer, XHeadersLength)
- XHeaders = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(XHeadersBuffer, XHeadersLength)
-
-
-
- Result = closeScan(ScanHandle)
-
- Console.WriteLine("Scan Close Result: " + Result.ToString("D"))
-
-
-
-
- Console.WriteLine("Scan result code: " + ScanResult.ToString("D"))
- Console.WriteLine("Scan X- headers: " + XHeaders)
-
- Next i
-
-
-
- Result = shutdownSNF()
-
- End Sub
-
- End Module
|