選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <html>
  2. <head>
  3. <title>C:\M\Projects\MessageSniffer\PKG-SNF-SDK-WIN_Work\PKG-SNF-SDK-WIN\VBSample\main.vb</title>
  4. <style>
  5. body { background-color: #ffffff; font-family: "Courier New"; font-size:10.0pt; font-style: normal; font-weight: normal; text-decoration: none; }
  6. .se2 { color: #000000; background-color: #ffffff; } /* Window Text */
  7. .se17 { color: #800080; background-color: #ffffff; } /* Keyword */
  8. .se19 { color: #000080; background-color: #ffffff; } /* Number */
  9. .se20 { color: #008080; background-color: #ffffff; } /* String */
  10. .se22 { color: #808000; background-color: #ffffff; } /* Preprocessor */
  11. .se23 { color: #800000; background-color: #ffffff; } /* Punctuation */
  12. .se24 { color: #c04000; background-color: #ffffff; } /* Library Symbol */
  13. .se25 { color: #000000; background-color: #ffffff; } /* Operator */
  14. .se49 { color: #008000; background-color: #ffffff; font-style: italic; } /* Comment */
  15. .se55 { color: #000000; background-color: #ffffff; } /* Window Text */
  16. .se57 { color: #000080; background-color: #ffffff; } /* Number */
  17. </style>
  18. </head>
  19. <body>
  20. <pre>
  21. <span class="se49">' main.vb SNF-SDK-WIN CPP OEM Demonstration Code</span>
  22. <span class="se49">' Copyright (C) 2009 ARM Research Labs, LLC</span>
  23. <span class="se49">'</span>
  24. <span class="se49">' This app simply exercises the API provided by snfmultidll.</span>
  25. <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>
  26. <span class="se17">Imports</span><span class="se2"> </span><span class="se24">System</span><span class="se2">.</span><span class="se24">Text</span>
  27. <span class="se17">Module</span><span class="se2"> </span><span class="se55">SNFMultiDLLExample</span>
  28. <span class="se22">#Region</span><span class="se2"> </span><span class="se20">&quot;DLL Imports&quot;</span>
  29. <span class="se2"> </span><span class="se49">' Location of SNFMulti.dll.</span>
  30. <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">&quot;..\..\..\..\64bitDll\SNFMulti.dll&quot;</span><span class="se2"> </span><span class="se49">' Set CPU type to &quot;Any CPU&quot;</span>
  31. <span class="se2"> </span><span class="se49">'Const SNFMULTI_DLL As String = &quot;..\..\..\..\..\64bitDll\SNFMulti.dll&quot; ' Set CPU type to &quot;x64&quot;</span>
  32. <span class="se2"> </span><span class="se49">'Const SNFMULTI_DLL As String = &quot;..\..\..\..\..\32bitDll\SNFMulti.dll&quot; ' Set CPU type to &quot;x86&quot;</span>
  33. <span class="se2"> </span><span class="se49">'int setThrottle(int Threads); /* Set scan thread limit. */</span>
  34. <span class="se2"> </span><span class="se49">'int startupSNF(char* Path); /* Start SNF with configuration. */</span>
  35. <span class="se2"> </span><span class="se49">'int startupSNFAuthenticated(char* Path, char* Lic, char* Auth); /* Start SNF with conf &amp; auth. */</span>
  36. <span class="se2"> </span><span class="se49">'int shutdownSNF(); /* Shutdown SNF. */</span>
  37. <span class="se2"> </span><span class="se49">'int testIP(unsigned long int IPToCheck); /* Test the IP for a GBUdb range. */</span>
  38. <span class="se2"> </span><span class="se49">'double getIPReputation(unsigned long int IPToCheck); /* Get reputation figure for IP. */</span>
  39. <span class="se2"> </span><span class="se49">'int scanBuffer(unsigned char* Bfr, int Length, char* Name, int Setup); /* Scan msgBuffer, name, setup time. */</span>
  40. <span class="se2"> </span><span class="se49">'int scanFile(char* FilePath, int Setup); /* Scan msgFile, setup time. */</span>
  41. <span class="se2"> </span><span class="se49">'int getScanXHeaders(int ScanHandle, char** Bfr, int* Length); /* Get result &amp; XHeaders. */</span>
  42. <span class="se2"> </span><span class="se49">'int getScanXMLLog(int ScanHandle, char** Bfr, int* Length); /* Get result &amp; XML Log. */</span>
  43. <span class="se2"> </span><span class="se49">'int getScanClassicLog(int ScanHandle, char** Bfr, int* Length); /* Get result &amp; Classic Log. */</span>
  44. <span class="se2"> </span><span class="se49">'int getScanResult(int ScanHandle); /* Get just the scan result. */</span>
  45. <span class="se2"> </span><span class="se49">'int closeScan(int ScanHandle); /* Close the scan result. */</span>
  46. <span class="se2"> </span><span class="se49">'Set scan thread limit</span>
  47. <span class="se2"> </span><span class="se25">&lt;</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">&quot;setThrottle&quot;</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">&gt;</span><span class="se2"> _</span>
  48. <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>
  49. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  50. <span class="se2"> </span><span class="se49">'Startup</span>
  51. <span class="se2"> </span><span class="se25">&lt;</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">&quot;startupSNF&quot;</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">&gt;</span><span class="se2"> _</span>
  52. <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>
  53. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  54. <span class="se2"> </span><span class="se49">'Start SNF with conf &amp; auth.</span>
  55. <span class="se2"> </span><span class="se25">&lt;</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">&quot;startupSNFAuthenticated&quot;</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>
  56. <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">&gt;</span><span class="se2"> _</span>
  57. <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>
  58. <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>
  59. <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>
  60. <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>
  61. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  62. <span class="se2"> </span><span class="se49">'Shutdown</span>
  63. <span class="se2"> </span><span class="se25">&lt;</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">&quot;shutdownSNF&quot;</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">&gt;</span><span class="se2"> _</span>
  64. <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>
  65. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  66. <span class="se2"> </span><span class="se49">'Test IP</span>
  67. <span class="se2"> </span><span class="se25">&lt;</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">&quot;testIP&quot;</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">&gt;</span><span class="se2"> _</span>
  68. <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>
  69. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  70. <span class="se2"> </span><span class="se49">'getIPReputation</span>
  71. <span class="se2"> </span><span class="se25">&lt;</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">&quot;getIPReputation&quot;</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">&gt;</span><span class="se2"> _</span>
  72. <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>
  73. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  74. <span class="se2"> </span><span class="se49">'ScanBuffer - returns scannerhandle</span>
  75. <span class="se2"> </span><span class="se25">&lt;</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">&quot;scanBuffer&quot;</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">&gt;</span><span class="se2"> _</span>
  76. <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>
  77. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  78. <span class="se2"> </span><span class="se49">'ScanFile</span>
  79. <span class="se2"> </span><span class="se25">&lt;</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">&quot;scanFile&quot;</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">&gt;</span><span class="se2"> _</span>
  80. <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>
  81. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  82. <span class="se2"> </span><span class="se49">'GetScanXHeaders - use scannerhandle returned from previous - returns ScanResult Code</span>
  83. <span class="se2"> </span><span class="se25">&lt;</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">&quot;getScanXHeaders&quot;</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">&gt;</span><span class="se2"> _</span>
  84. <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>
  85. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  86. <span class="se2"> </span><span class="se49">'GetScanXMLLog - Get result &amp; XML Log</span>
  87. <span class="se2"> </span><span class="se25">&lt;</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">&quot;getScanXMLLog&quot;</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">&gt;</span><span class="se2"> _</span>
  88. <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>
  89. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  90. <span class="se2"> </span><span class="se49">'GetScanClassicLog - Get result &amp; Classic Log</span>
  91. <span class="se2"> </span><span class="se25">&lt;</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">&quot;getScanClassicLog&quot;</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">&gt;</span><span class="se2"> _</span>
  92. <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>
  93. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  94. <span class="se2"> </span><span class="se49">'GetScanResult - Get just the scan result</span>
  95. <span class="se2"> </span><span class="se25">&lt;</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">&quot;getScanResult&quot;</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">&gt;</span><span class="se2"> _</span>
  96. <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>
  97. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  98. <span class="se2"> </span><span class="se49">'Close Scan</span>
  99. <span class="se2"> </span><span class="se25">&lt;</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">&quot;closeScan&quot;</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">&gt;</span><span class="se2"> _</span>
  100. <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>
  101. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Function</span>
  102. <span class="se22">#End</span><span class="se2"> </span><span class="se22">Region</span>
  103. <span class="se2"> </span><span class="se17">Sub</span><span class="se2"> </span><span class="se55">Main</span><span class="se23">()</span>
  104. <span class="se2"> </span><span class="se49">' Setup the basics we need to run this test.</span>
  105. <span class="se2"> </span><span class="se49">'Const LicenseID As String = &quot;licensid&quot; ' SNF License ID can be passed</span>
  106. <span class="se2"> </span><span class="se49">'Const Authentication As String = &quot;authentication&quot; ' directly or read from the</span>
  107. <span class="se2"> </span><span class="se49">' configuration. OEMs go direct!</span>
  108. <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">&quot;..\..\..\snf_engine.xml&quot;</span><span class="se2"> </span><span class="se49">' For &quot;Any CPU&quot; platform.</span>
  109. <span class="se2"> </span><span class="se49">'Const ConfigurationPath As String = &quot;..\..\..\..\snf_engine.xml&quot; ' For &quot;x86&quot; or &quot;x64&quot; platforms.</span>
  110. <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">&amp;HC22384E</span><span class="se2"> </span><span class="se49">' Same as IP 12.34.56.78</span>
  111. <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>
  112. <span class="se2"> </span><span class="se20">&quot;Received: from mx-out.example.com [12.34.56.78] (HELO Somebody)\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  113. <span class="se2"> </span><span class="se20">&quot; by mx-in.example.com (nosuchserver v1.0) for nobody@example.com\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  114. <span class="se2"> </span><span class="se20">&quot;From: &lt;somebody@example.com&gt;\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  115. <span class="se2"> </span><span class="se20">&quot;To: &lt;nobody@example.com&gt;\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  116. <span class="se2"> </span><span class="se20">&quot;Subject: Nothing to see here\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  117. <span class="se2"> </span><span class="se20">&quot;\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  118. <span class="se2"> </span><span class="se20">&quot;So this is the big thing that's not here to see.\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  119. <span class="se2"> </span><span class="se20">&quot;I thought it would be more interesting than this.\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  120. <span class="se2"> </span><span class="se20">&quot;\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  121. <span class="se2"> </span><span class="se20">&quot;_M\r\n&quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> _</span>
  122. <span class="se2"> </span><span class="se20">&quot;.\r\n&quot;</span>
  123. <span class="se2"> </span><span class="se49">'' Here is a simple example. Startup, exercise the API, shut down.</span>
  124. <span class="se2"> </span><span class="se49">'' Note that we're doing this in a very &quot;C&quot; style becuase the DLL API is C</span>
  125. <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>
  126. <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>
  127. <span class="se2"> </span><span class="se49">'Result = startupSNFAuthenticated( _</span>
  128. <span class="se2"> </span><span class="se49">' ConfigurationPath, _</span>
  129. <span class="se2"> </span><span class="se49">' LicenseID, _</span>
  130. <span class="se2"> </span><span class="se49">' Authentication)</span>
  131. <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">&quot;Started with config &quot;</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">&quot; Result: &quot;</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">&quot;D&quot;</span><span class="se23">))</span>
  132. <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>
  133. <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>
  134. <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">&quot;IP test result: &quot;</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">&quot;D&quot;</span><span class="se23">))</span>
  135. <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>
  136. <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">&quot;IP Reputation: &quot;</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>
  137. <span class="se2"> </span><span class="se49">' Messgae scans happen in a scan, read, close cycle as shown inside this loop.</span>
  138. <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>
  139. <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>
  140. <span class="se2"> </span><span class="se49">' Show how the IP reputation changes over time.</span>
  141. <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>
  142. <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">&quot;IP Reputation: &quot;</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>
  143. <span class="se2"> </span><span class="se49">' Scan a message from a buffer.</span>
  144. <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>
  145. <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>
  146. <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>
  147. <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>
  148. <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">&quot;TestMessage&quot;</span><span class="se2">, </span><span class="se55">SetupTime</span><span class="se23">)</span>
  149. <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">&quot;Scan Handle: &quot;</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">&quot;D&quot;</span><span class="se23">))</span>
  150. <span class="se2"> </span><span class="se49">' Retrieve the X-Headers for the scan.</span>
  151. <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>
  152. <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>
  153. <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>
  154. <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>
  155. <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>
  156. <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>
  157. <span class="se2"> </span><span class="se49">' Close the scan.</span>
  158. <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>
  159. <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">&quot;Scan Close Result: &quot;</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">&quot;D&quot;</span><span class="se23">))</span>
  160. <span class="se2"> </span><span class="se49">' X- headers were captured in a string BEFORE closing the scan so we can</span>
  161. <span class="se2"> </span><span class="se49">' use them here.</span>
  162. <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">&quot;Scan result code: &quot;</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">&quot;D&quot;</span><span class="se23">))</span>
  163. <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">&quot;Scan X- headers: &quot;</span><span class="se2"> </span><span class="se25">+</span><span class="se2"> </span><span class="se55">XHeaders</span><span class="se23">)</span>
  164. <span class="se2"> </span><span class="se17">Next</span><span class="se2"> </span><span class="se55">i</span>
  165. <span class="se2"> </span><span class="se49">' Now that all scanning is done we shut down.</span>
  166. <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>
  167. <span class="se2"> </span><span class="se17">End</span><span class="se2"> </span><span class="se17">Sub</span>
  168. <span class="se17">End</span><span class="se2"> </span><span class="se17">Module</span>
  169. </pre>
  170. </body>
  171. </html>