123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <html>
- <head>
- <title>C:\M\Projects\MessageSniffer\PKG-SNF-SDK-WIN_Work\PKG-SNF-SDK-WIN\VBSample\main.vb</title>
- <style>
- body { background-color: #ffffff; font-family: "Courier New"; font-size:10.0pt; font-style: normal; font-weight: normal; text-decoration: none; }
- .se2 { color: #000000; background-color: #ffffff; } /* Window Text */
- .se17 { color: #800080; background-color: #ffffff; } /* Keyword */
- .se19 { color: #000080; background-color: #ffffff; } /* Number */
- .se20 { color: #008080; background-color: #ffffff; } /* String */
- .se22 { color: #808000; background-color: #ffffff; } /* Preprocessor */
- .se23 { color: #800000; background-color: #ffffff; } /* Punctuation */
- .se24 { color: #c04000; background-color: #ffffff; } /* Library Symbol */
- .se25 { color: #000000; background-color: #ffffff; } /* Operator */
- .se49 { color: #008000; background-color: #ffffff; font-style: italic; } /* Comment */
- .se55 { color: #000000; background-color: #ffffff; } /* Window Text */
- .se57 { color: #000080; background-color: #ffffff; } /* Number */
- </style>
- </head>
- <body>
- <pre>
- <span class="se49">' main.vb SNF-SDK-WIN CPP OEM Demonstration Code</span>
- <span class="se49">' Copyright (C) 2009 ARM Research Labs, LLC</span>
- <span class="se49">'</span>
- <span class="se49">' This app simply exercises the API provided by snfmultidll.</span>
-
- <span class="se17">Imports</span><span class="se2"> </span><span class="se24">System</span><span class="se2">.</span><span class="se55">Runtime</span><span class="se2">.</span><span class="se55">InteropServices</span>
- <span class="se17">Imports</span><span class="se2"> </span><span class="se24">System</span><span class="se2">.</span><span class="se24">Text</span>
-
- <span class="se17">Module</span><span class="se2"> </span><span class="se55">SNFMultiDLLExample</span>
-
- <span class="se22">#Region</span><span class="se2"> </span><span class="se20">"DLL Imports"</span>
-
- <span class="se2"> </span><span class="se49">' Location of SNFMulti.dll.</span>
- <span class="se2"> </span><span class="se17">Const</span><span class="se2"> </span><span class="se55">SNFMULTI_DLL</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se20">"..\..\..\..\64bitDll\SNFMulti.dll"</span><span class="se2"> </span><span class="se49">' Set CPU type to "Any CPU"</span>
- <span class="se2"> </span><span class="se49">'Const SNFMULTI_DLL As String = "..\..\..\..\..\64bitDll\SNFMulti.dll" ' Set CPU type to "x64"</span>
- <span class="se2"> </span><span class="se49">'Const SNFMULTI_DLL As String = "..\..\..\..\..\32bitDll\SNFMulti.dll" ' Set CPU type to "x86"</span>
-
- <span class="se2"> </span><span class="se49">'int setThrottle(int Threads); /* Set scan thread limit. */</span>
- <span class="se2"> </span><span class="se49">'int startupSNF(char* Path); /* Start SNF with configuration. */</span>
- <span class="se2"> </span><span class="se49">'int startupSNFAuthenticated(char* Path, char* Lic, char* Auth); /* Start SNF with conf & auth. */</span>
- <span class="se2"> </span><span class="se49">'int shutdownSNF(); /* Shutdown SNF. */</span>
- <span class="se2"> </span><span class="se49">'int testIP(unsigned long int IPToCheck); /* Test the IP for a GBUdb range. */</span>
- <span class="se2"> </span><span class="se49">'double getIPReputation(unsigned long int IPToCheck); /* Get reputation figure for IP. */</span>
- <span class="se2"> </span><span class="se49">'int scanBuffer(unsigned char* Bfr, int Length, char* Name, int Setup); /* Scan msgBuffer, name, setup time. */</span>
- <span class="se2"> </span><span class="se49">'int scanFile(char* FilePath, int Setup); /* Scan msgFile, setup time. */</span>
- <span class="se2"> </span><span class="se49">'int getScanXHeaders(int ScanHandle, char** Bfr, int* Length); /* Get result & XHeaders. */</span>
- <span class="se2"> </span><span class="se49">'int getScanXMLLog(int ScanHandle, char** Bfr, int* Length); /* Get result & XML Log. */</span>
- <span class="se2"> </span><span class="se49">'int getScanClassicLog(int ScanHandle, char** Bfr, int* Length); /* Get result & Classic Log. */</span>
- <span class="se2"> </span><span class="se49">'int getScanResult(int ScanHandle); /* Get just the scan result. */</span>
- <span class="se2"> </span><span class="se49">'int closeScan(int ScanHandle); /* Close the scan result. */</span>
-
-
- <span class="se2"> </span><span class="se49">'Set scan thread limit</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"setThrottle"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">setThrottle</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">Threads</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'Startup</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"startupSNF"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">startupSNF</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">PathToConfigurationFile</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'Start SNF with conf & auth.</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"startupSNFAuthenticated"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, _</span>
- <span class="se2"> </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">startupSNFAuthenticated</span><span class="se23">(</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">ByVal</span><span class="se2"> </span><span class="se24">Path</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span><span class="se2">, _</span>
- <span class="se2"> </span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">Lic</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span><span class="se2">, _</span>
- <span class="se2"> </span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">Auth</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'Shutdown</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"shutdownSNF"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">shutdownSNF</span><span class="se23">()</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'Test IP</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"testIP"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">testIP</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">IPToCheck</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">UInt32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'getIPReputation</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"getIPReputation"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">getIPReputation</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">IPToCheck</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">UInt32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">Double</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'ScanBuffer - returns scannerhandle</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"scanBuffer"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">scanBuffer</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">MsgBfr</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">StringBuilder</span><span class="se2">, </span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">MsgBfrLen</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se2">, </span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">MsgID</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span><span class="se2">, </span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">SetupTime</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'ScanFile</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"scanFile"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">scanFile</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">FilePath</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span><span class="se2">, </span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">Setup</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'GetScanXHeaders - use scannerhandle returned from previous - returns ScanResult Code</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"getScanXHeaders"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">getScanXHeaders</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">ScannerHandle</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se2">, </span><span class="se17">ByRef</span><span class="se2"> </span><span class="se55">HeadersPtr</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">IntPtr</span><span class="se2">, </span><span class="se17">ByRef</span><span class="se2"> </span><span class="se55">HeadersLength</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'GetScanXMLLog - Get result & XML Log</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"getScanXMLLog"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">getScanXMLLog</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">ScannerHandle</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se2">, </span><span class="se17">ByRef</span><span class="se2"> </span><span class="se55">LogPtr</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">IntPtr</span><span class="se2">, </span><span class="se17">ByRef</span><span class="se2"> </span><span class="se55">LogLength</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'GetScanClassicLog - Get result & Classic Log</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"getScanClassicLog"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">getScanClassicLog</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">ScannerHandle</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se2">, </span><span class="se17">ByRef</span><span class="se2"> </span><span class="se55">LogPtr</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">IntPtr</span><span class="se2">, </span><span class="se17">ByRef</span><span class="se2"> </span><span class="se55">LogLength</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'GetScanResult - Get just the scan result</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"getScanResult"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">getScanResult</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">ScannerHandle</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se2"> </span><span class="se49">'Close Scan</span>
- <span class="se2"> </span><span class="se25"><</span><span class="se55">DllImport</span><span class="se23">(</span><span class="se55">SNFMULTI_DLL</span><span class="se2">, </span><span class="se55">EntryPoint</span><span class="se2">:</span><span class="se25">=</span><span class="se20">"closeScan"</span><span class="se2">, </span><span class="se55">CharSet</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CharSet</span><span class="se2">.</span><span class="se17">Ansi</span><span class="se2">, </span><span class="se55">CallingConvention</span><span class="se2">:</span><span class="se25">=</span><span class="se55">CallingConvention</span><span class="se2">.</span><span class="se55">Winapi</span><span class="se23">)</span><span class="se25">></span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se17">Public</span><span class="se2"> </span><span class="se17">Function</span><span class="se2"> </span><span class="se55">closeScan</span><span class="se23">(</span><span class="se17">ByVal</span><span class="se2"> </span><span class="se55">ScannerHandle</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span><span class="se23">)</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
-
- <span class="se22">#End</span><span class="se2"> </span><span class="se22">Region</span>
-
- <span class="se2"> </span><span class="se17">Sub</span><span class="se2"> </span><span class="se55">Main</span><span class="se23">()</span>
-
- <span class="se2"> </span><span class="se49">' Setup the basics we need to run this test.</span>
-
- <span class="se2"> </span><span class="se49">'Const LicenseID As String = "licensid" ' SNF License ID can be passed</span>
- <span class="se2"> </span><span class="se49">'Const Authentication As String = "authentication" ' directly or read from the</span>
- <span class="se2"> </span><span class="se49">' configuration. OEMs go direct!</span>
- <span class="se2"> </span><span class="se17">Const</span><span class="se2"> </span><span class="se55">ConfigurationPath</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se20">"..\..\..\snf_engine.xml"</span><span class="se2"> </span><span class="se49">' For "Any CPU" platform.</span>
- <span class="se2"> </span><span class="se49">'Const ConfigurationPath As String = "..\..\..\..\snf_engine.xml" ' For "x86" or "x64" platforms.</span>
-
-
- <span class="se2"> </span><span class="se17">Const</span><span class="se2"> </span><span class="se55">IPToTest</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">UInt32</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se57">&HC22384E</span><span class="se2"> </span><span class="se49">' Same as IP 12.34.56.78</span>
-
- <span class="se2"> </span><span class="se17">Const</span><span class="se2"> </span><span class="se55">SampleMessage</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">"Received: from mx-out.example.com [12.34.56.78] (HELO Somebody)\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">" by mx-in.example.com (nosuchserver v1.0) for nobody@example.com\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">"From: <somebody@example.com>\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">"To: <nobody@example.com>\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">"Subject: Nothing to see here\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">"\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">"So this is the big thing that's not here to see.\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">"I thought it would be more interesting than this.\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">"\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">"_M\r\n"</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
- <span class="se2"> </span><span class="se20">".\r\n"</span>
-
- <span class="se2"> </span><span class="se49">'' Here is a simple example. Startup, exercise the API, shut down.</span>
- <span class="se2"> </span><span class="se49">'' Note that we're doing this in a very "C" style becuase the DLL API is C</span>
-
- <span class="se2"> </span><span class="se17">Dim</span><span class="se2"> </span><span class="se55">Result</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">Integer</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se19">0</span>
-
- <span class="se2"> </span><span class="se55">Result</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se55">startupSNF</span><span class="se23">(</span><span class="se55">ConfigurationPath</span><span class="se23">)</span>
-
- <span class="se2"> </span><span class="se49">'Result = startupSNFAuthenticated( _</span>
- <span class="se2"> </span><span class="se49">' ConfigurationPath, _</span>
- <span class="se2"> </span><span class="se49">' LicenseID, _</span>
- <span class="se2"> </span><span class="se49">' Authentication)</span>
-
- <span class="se2"> </span><span class="se55">Console</span><span class="se2">.</span><span class="se24">WriteLine</span><span class="se23">(</span><span class="se20">"Started with config "</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">ConfigurationPath</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se20">" Result: "</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">Result</span><span class="se2">.</span><span class="se55">ToString</span><span class="se23">(</span><span class="se20">"D"</span><span class="se23">))</span>
-
- <span class="se2"> </span><span class="se49">' IP tests can be done asynchrounously - they do not have to be part of any particular scan.</span>
-
- <span class="se2"> </span><span class="se55">Result</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se55">testIP</span><span class="se23">(</span><span class="se55">IPToTest</span><span class="se23">)</span>
- <span class="se2"> </span><span class="se55">Console</span><span class="se2">.</span><span class="se24">WriteLine</span><span class="se23">(</span><span class="se20">"IP test result: "</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">Result</span><span class="se2">.</span><span class="se55">ToString</span><span class="se23">(</span><span class="se20">"D"</span><span class="se23">))</span>
-
- <span class="se2"> </span><span class="se17">Dim</span><span class="se2"> </span><span class="se55">IPReputation</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">Double</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se55">getIPReputation</span><span class="se23">(</span><span class="se55">IPToTest</span><span class="se23">)</span>
- <span class="se2"> </span><span class="se55">Console</span><span class="se2">.</span><span class="se24">WriteLine</span><span class="se23">(</span><span class="se20">"IP Reputation: "</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">IPReputation</span><span class="se2">.</span><span class="se55">ToString</span><span class="se23">())</span>
-
- <span class="se2"> </span><span class="se49">' Messgae scans happen in a scan, read, close cycle as shown inside this loop.</span>
-
- <span class="se2"> </span><span class="se17">Const</span><span class="se2"> </span><span class="se55">NumberOfScans</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">Integer</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se19">10</span>
- <span class="se2"> </span><span class="se17">For</span><span class="se2"> </span><span class="se55">i</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">Integer</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se19">0</span><span class="se2"> </span><span class="se17">To</span><span class="se2"> </span><span class="se55">NumberOfScans</span>
-
- <span class="se2"> </span><span class="se49">' Show how the IP reputation changes over time.</span>
-
- <span class="se2"> </span><span class="se55">IPReputation</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se55">getIPReputation</span><span class="se23">(</span><span class="se55">IPToTest</span><span class="se23">)</span>
- <span class="se2"> </span><span class="se55">Console</span><span class="se2">.</span><span class="se24">WriteLine</span><span class="se23">(</span><span class="se20">"IP Reputation: "</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">IPReputation</span><span class="se2">.</span><span class="se55">ToString</span><span class="se23">())</span>
-
- <span class="se2"> </span><span class="se49">' Scan a message from a buffer.</span>
-
- <span class="se2"> </span><span class="se17">Dim</span><span class="se2"> </span><span class="se55">SetupTime</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">Integer</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se19">12</span>
- <span class="se2"> </span><span class="se17">Dim</span><span class="se2"> </span><span class="se55">ScanHandle</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">Integer</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se19">0</span>
- <span class="se2"> </span><span class="se17">Dim</span><span class="se2"> </span><span class="se55">MsgBuffer</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">New</span><span class="se2"> </span><span class="se55">StringBuilder</span>
- <span class="se2"> </span><span class="se55">MsgBuffer</span><span class="se2">.</span><span class="se24">Append</span><span class="se23">(</span><span class="se55">SampleMessage</span><span class="se23">)</span>
- <span class="se2"> </span><span class="se55">ScanHandle</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se55">scanBuffer</span><span class="se23">(</span><span class="se55">MsgBuffer</span><span class="se2">, </span><span class="se55">MsgBuffer</span><span class="se2">.</span><span class="se55">Length</span><span class="se23">()</span><span class="se2">, </span><span class="se20">"TestMessage"</span><span class="se2">, </span><span class="se55">SetupTime</span><span class="se23">)</span>
-
-
- <span class="se2"> </span><span class="se55">Console</span><span class="se2">.</span><span class="se24">WriteLine</span><span class="se23">(</span><span class="se20">"Scan Handle: "</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">ScanHandle</span><span class="se2">.</span><span class="se55">ToString</span><span class="se23">(</span><span class="se20">"D"</span><span class="se23">))</span>
-
- <span class="se2"> </span><span class="se49">' Retrieve the X-Headers for the scan.</span>
-
- <span class="se2"> </span><span class="se17">Dim</span><span class="se2"> </span><span class="se55">XHeadersBuffer</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">IntPtr</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se55">IntPtr</span><span class="se2">.</span><span class="se55">Zero</span>
- <span class="se2"> </span><span class="se17">Dim</span><span class="se2"> </span><span class="se55">XHeadersLength</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se55">Int32</span>
- <span class="se2"> </span><span class="se17">Dim</span><span class="se2"> </span><span class="se55">XHeaders</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">String</span>
-
- <span class="se2"> </span><span class="se17">Dim</span><span class="se2"> </span><span class="se55">ScanResult</span><span class="se2"> </span><span class="se17">As</span><span class="se2"> </span><span class="se17">Integer</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se19">0</span>
- <span class="se2"> </span><span class="se55">ScanResult</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se55">getScanXHeaders</span><span class="se23">(</span><span class="se55">ScanHandle</span><span class="se2">, </span><span class="se55">XHeadersBuffer</span><span class="se2">, </span><span class="se55">XHeadersLength</span><span class="se23">)</span>
- <span class="se2"> </span><span class="se55">XHeaders</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se24">System</span><span class="se2">.</span><span class="se55">Runtime</span><span class="se2">.</span><span class="se55">InteropServices</span><span class="se2">.</span><span class="se55">Marshal</span><span class="se2">.</span><span class="se55">PtrToStringAnsi</span><span class="se23">(</span><span class="se55">XHeadersBuffer</span><span class="se2">, </span><span class="se55">XHeadersLength</span><span class="se23">)</span>
-
- <span class="se2"> </span><span class="se49">' Close the scan.</span>
-
- <span class="se2"> </span><span class="se55">Result</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se55">closeScan</span><span class="se23">(</span><span class="se55">ScanHandle</span><span class="se23">)</span>
-
- <span class="se2"> </span><span class="se55">Console</span><span class="se2">.</span><span class="se24">WriteLine</span><span class="se23">(</span><span class="se20">"Scan Close Result: "</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">Result</span><span class="se2">.</span><span class="se55">ToString</span><span class="se23">(</span><span class="se20">"D"</span><span class="se23">))</span>
-
- <span class="se2"> </span><span class="se49">' X- headers were captured in a string BEFORE closing the scan so we can</span>
- <span class="se2"> </span><span class="se49">' use them here.</span>
-
- <span class="se2"> </span><span class="se55">Console</span><span class="se2">.</span><span class="se24">WriteLine</span><span class="se23">(</span><span class="se20">"Scan result code: "</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">ScanResult</span><span class="se2">.</span><span class="se55">ToString</span><span class="se23">(</span><span class="se20">"D"</span><span class="se23">))</span>
- <span class="se2"> </span><span class="se55">Console</span><span class="se2">.</span><span class="se24">WriteLine</span><span class="se23">(</span><span class="se20">"Scan X- headers: "</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">XHeaders</span><span class="se23">)</span>
-
- <span class="se2"> </span><span class="se17">Next</span><span class="se2"> </span><span class="se55">i</span>
-
- <span class="se2"> </span><span class="se49">' Now that all scanning is done we shut down.</span>
-
- <span class="se2"> </span><span class="se55">Result</span><span class="se2"> </span><span class="se25">=</span><span class="se2"> </span><span class="se55">shutdownSNF</span><span class="se23">()</span>
-
- <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Sub</span>
-
- <span class="se17">End</span><span class="se2"> </span><span class="se17">Module</span>
- </pre>
- </body>
- </html>
|