Sniffermulti.vb is my sniffer multi class- Code is as follows: --------------------------------------------------------------------------------------------------------------------------------------------------------------- Imports System.Runtime.InteropServices Imports System.Text Public Class SnifferMulti #Region "DLL Imports" 'int startupSNF(char* Path); /* Start SNF with configuration. */ 'int shutdownSNF(); /* Shutdown SNF. */ 'int testIP(unsigned long int IPToCheck); /* Test the IP for a GBUdb range. */ 'int scanBuffer(unsigned char* Bfr, int Length, char* Name, int Setup); /* Scan msgBuffer, name, setup time. */ 'int scanFile(char* FilePath, int Setup); /* Scan msgFile, setup time. */ 'int getScanXHeaders(int ScanHandle, char** Bfr, int* Length); /* Get result & XHeaders. */ 'int getScanXMLLog(int ScanHandle, char** Bfr, int* Length); /* Get result & XML Log. */ 'int getScanClassicLog(int ScanHandle, char** Bfr, int* Length); /* Get result & Classic Log. */ 'int getScanResult(); /* Get just the scan result. */ 'int closeScan(int ScanHandle); /* Close the scan result. */ 'Startup _ Public Shared Function startupSNF(ByVal PathToConfigurationFile As String) As Int32 End Function 'Shutdown _ Public Shared Function shutdownSNF() As Int32 End Function 'ScanBuffer - returns scannerhandle _ Public Shared Function scanBuffer(ByVal MsgBfr As StringBuilder, ByVal MsgBfrLen As Int32, ByVal MsgID As String, ByVal SetupTime As Int32) As Int32 End Function 'GetScanXHeaders - use scannerhandle returned from previous - returns ScanResult Code _ Public Shared Function getScanXHeaders(ByVal ScannerHandle As Int32, ByRef HeadersPtr As IntPtr, ByRef HeadersLength As Int32) As Int32 End Function 'Close Scan _ Public Shared Function closeScan(ByVal ScannerHandle As Int32) As Int32 End Function 'Set Thread Throttling _ Public Shared Function setThrottle(ByVal Threads As Int32) As Int32 End Function 'Call MScan() this way: 'MScan(char* msgbfr, int msglen, char* mbfr, int mlen) 'MScan returns an integer = the rule group, or error code, or zero. 'msgbfr = a cstring containing the smtp message to be scanned. 'msglen = an integer, the length of the msgbfr. 'mbfr = a character buffer into which match records will be placed. 'It is assumed that the buffer is large enough for all of the data 'that might be created. It is assumed that the calling program will 'handle allocation & cleanup. It is assumed that the calling program 'will pre-fill the buffer with nulls (let me know if this is not the 'case and I can easily do that inside the DLL -- I just didn't want 'to do it twice if not needed). 'mlen = the length of the match records buffer. The DLL will not 'overwrite the buffer even if there is more data to send. 'Everything else is just like in Assert! #End Region #Region "PrivateVars" Private Enum Result_Code ALL_OK = 0 CODED_RANGE = 64 NO_RESULT_YET = 999 ERROR_RULE_FILE = 67 ' Rule file open error result. ERROR_RULE_DATA = 68 ' Token matrix creation error result. ERROR_MSG_FILE = 69 ' Scan file open error result. ERROR_ALLOCATION = 70 ' Error allocating memory. ERROR_BAD_MATRIX = 71 ' Something pushed us out of range. ERROR_MAX_EVALS = 72 ' Maximum Number Of Evaluators reached. ERROR_RULE_AUTH = 73 ' Authentication failed on the rule base. ERROR_UNKNOWN = 99 ' The What The Hell error. End Enum #End Region End Class --------------------------------------------------------------------------------------------------------------------------------------------------------------- Here is a subroutine that calls the scanner and gets the scan results. The code here has been simplified quite a bit for clarity: --------------------------------------------------------------------------------------------------------------------------------------------------------------- Sub DoSniffer3(ByVal Message As StringBuilder, ByRef AdditionalHeaders As String, ByRef GroupID As Integer) Dim Scanhandle As Int32 = -1 Dim closereturn As Int32 Try 'do a scan Dim Tm As Int32 Scanhandle = SnifferMulti.scanBuffer(Message, Message.Length, "1", TimeSoFarInms) 'get the scan headers 'if negative value here, or higher than 63, then error GroupID = SnifferMulti.getScanXHeaders(Scanhandle, IP, IPlen) If GroupID < 0 Or GroupID > 63 Then WriteToLogEvent("err.log", "DOSNIFFER3" & vbTab & "GROUPID:" & vbTab & GroupID.ToString) 'Get Additional X- headers from SNF Dim IP As IntPtr = IntPtr.Zero Dim IPlen As Int32 AdditionalHeaders = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(IP, IPlen) 'get the scan result and close the scan 'can probably ignore any nonzero issues here. closereturn = SnifferMulti.closeScan(Scanhandle) Catch ex As Exception WriteToLogEvent("err.log", "DOSNIFFER3" & vbTab & ex.Message) End Try End Sub