Thanks for the help Anssi :D. I think I'm going to have to learn C++.

Cheers
Chuckie Ice


From: "Anssi Kolehmainen" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: <[EMAIL PROTECTED]>
Subject: RE: [WinPcap-users] Capturing/Sending Packets In Visual Basic
Date: Sun, 2 May 2004 13:42:30 +0300
MIME-Version: 1.0
Received: from winpcap.polito.it ([130.192.16.36]) by mc7-f13.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Sun, 2 May 2004 03:42:44 -0700
Received: from netgroup-serv ([127.0.0.1]) by winpcap.polito.it ; Sun, 02 May 2004 12:47:31 +0200
X-Message-Info: JGTYoYF78jEQILR5Gf21TTqCtoOxWc0a
X-Return-Path: <[EMAIL PROTECTED]>
X-Received: from smtp-2.hut.fi ([130.233.228.92]) by netgroup-serv.polito.it ; Sun, 02 May 2004 12:47:29 +0200
X-Received: from kannu2 (timjami.niksula.hut.fi [130.233.41.90])by smtp-2.hut.fi (8.12.10/8.12.10) with ESMTP id i42AgP1E030830for <[EMAIL PROTECTED]>; Sun, 2 May 2004 13:42:26 +0300
Message-Id: <[EMAIL PROTECTED]>
X-Mailer: Microsoft Office Outlook, Build 11.0.5510
In-Reply-To: <[EMAIL PROTECTED]>
Thread-Index: AcQwJAOQEUlrH8pSRLOWkQiZ/Y0B0AADAXqg
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
X-RAVMilter-Version: 8.4.3(snapshot 20030212) (smtp-2.hut.fi)
X-Mailing-List: [EMAIL PROTECTED]
X-listMember: [EMAIL PROTECTED] [winpcap-users-request]
Return-Path: [EMAIL PROTECTED]
X-OriginalArrivalTime: 02 May 2004 10:42:47.0764 (UTC) FILETIME=[35854140:01C43032]


> Hey, I found out about your projects and WinPCap a little
> while ago. So far,
> I can see all of you have put forth a lot of effort into
> making this. I had
> a few questions though, since I'm not really a proficient C++
> User. I do
> have C++, and all the example files work, but I wanted to
> know if it was
> possible to use WPCap.dll or Packet.dll in Visual Basic using
> API calls. I
> have tried to convert some of the C++ API to VB, but it just
> doesn't seem to
> work. Here is an example:
>
> Private Declare Function PacketGetAdapterNames Lib
> "packet.dll" (pStr As
> String, BufferSize As Long) As Boolean
>
> I thought this would be a correct API call, but it seems to
> have errors when
> I call it. If anyone could help me on this issue, I would
> greatly appriciate
> it. Thanks!

C function
BOOLEAN PacketGetAdapterNames (PTSTR pStr, PULONG BufferSize)

Would translate to
Private Declare Function PacketGetAdapterNames lib "packet.dll"
 (byval pStr as String, byref BufferSize as long) as long

One big thing with VB is that it _doesn't_ support multi-threading. Multi
threading happens if you use callback functions (like pcap_loop).

Translating functions from C to VB is easy when you remember few simple
things:
 - ByVal = direct value
 - ByRef = pointer to value (usually P or LP in front of C type)
 - With strings byval = pointer to string, byref = pointer to pointer to
string
 - PTSTR = pointer to string = byval string
 - PULONG = pointer to long = byref long
 - BOOLEAN = long
 - Nearly everything are longs
 - C int = VB long
 - C short = VB integer


Following might work.

Public Type PACKET
 hEvent as long
 Overlapped as long
 Buffer as byte*1048576
 Length as long
 BytesReceived as long
 bIoComplete as long
End Type

Private Declare Function PacketReceivePacket lib "packet.dll" (byref Adapter
as ADAPTER, byref Packet as PACKET, sync as long) as long


But it might not work because you "need" to use PakcetAllocatePacket &
PacketInitPacket... Maybe 'Dim lppacket as long' might work...

In short: It can be done but it is a real pain because VB doesn't have
pointers. (Like C/C++ has)

Anssi Kolehmainen



==================================================================
 This is the WinPcap users list. It is archived at
 http://www.mail-archive.com/[EMAIL PROTECTED]/

 To unsubscribe use
 mailto: [EMAIL PROTECTED]
==================================================================

_________________________________________________________________
Watch LIVE baseball games on your computer with MLB.TV, included with MSN Premium! http://join.msn.com/?page=features/mlb&pgmarket=en-us/go/onm00200439ave/direct/01/




==================================================================
This is the WinPcap users list. It is archived at
http://www.mail-archive.com/[EMAIL PROTECTED]/

To unsubscribe use mailto: [EMAIL PROTECTED]
==================================================================

Reply via email to