[Winpcap-users] Using Packet.dll in an 'not-admin' session

Eduardo Escudero Sánchez edu.kungfu at gmail.com
Mon Aug 7 07:22:55 GMT 2006


Sorry, it wasn't packetgetpacket the function i was referring to. it was
packetrequest which lets me retrieve adapter information using
deviceiocontrol, sorry about that.
PacketGetAdapterNames returns nothing, a security exception is thrown before
my code can call it but its a managed exception. This is because of the code
access security of the CLR (I've been reading about it). I haven't used
security attributes for my classes when they access to protected resources
(i thought that the coding paradigm was the same than, for example, C++,
where you only worry about coding your application) so when running the
application in a restricted session the CLR detects that they are accesing
protected resources without permission and throws a security exception which
was not capturred or managed by my application. If i had used the
aforementioned attributes the CLR would have detected that the application
uses protected resources and it would inform the user before running the
application that he doesn't have enough permissions to run it.
To solve this i would have to include in the installer a call to the '
Caspol.exe' utility to give my application the permissions it needs.
So this is not (at least i thonk so) a WinPcap issue. Sorry for the mess.
And thanks.

2006/8/7, Gianluca Varenni <gianluca.varenni at cacetech.com>:
>
>  Eduardo,
>
> PacketGetAdapterNames uses a mixture of approaches to retrieve the adapter
> names, mainly IPHelperAPI and registry. But it also tries to open the
> adapters exported by the driver npf.sys to check that they are really
> available. So the driver should be started.
>
> From the mails it seems that your wrapper is generating an exception
> (managed? unmanaged?) because PacketGetAdapterNames is failing (i.e. it's
> returning FALSE), and you are retrieving the error code using
> GetLastError(). Right? If so, what is the exact error code?
>
> Finally, you were saying that you use the Packet API because you need to
> retrieve some information not available with the pcap API, and you talk
> about PacketGetPacket. Although it's true that some functionalities are not
> available with the pcap API, PacketGetPacket is completely exposed through
> pcap_next_ex (or similar calls).
>
> Have a nice day
>  GV
>
>
>
>
>  ----- Original Message -----
> *From:* Eduardo Escudero Sánchez <edu.kungfu at gmail.com>
> *To:* Tom at redtile.com ; winpcap-users at winpcap.org
> *Sent:* Saturday, August 05, 2006 11:41 PM
> *Subject:* Re: [Winpcap-users] Using Packet.dll in an 'not-admin' session
>
>
> As Far as i know the PacketGetAdapterNames function looks inside the
> registry all the entries concerning to network adapters in the system and
> this action looks like one which needs privileges i think, and which has
> nothing in common with the starting of the NPF driver.
> OK the C code can't throw any exception to my C# code but the C++ code i'm
> using does. I will explain myself: i don't use the Packet.dll library
> directly pinvoking it from my C sharp code. What i have done is making an
> auxiliar C++ dll to manage directly the Packet.dll API and export some
> easy pinvokable functions to my Csharp code. So i use the packet.dll API
> through an auxiliar C++ dll, which was more  easy for me than trying
> pinvoking directly the API.
> Im using Packet.dll because this API has some functions i need to retrieve
> network adapter information, for example, the packetgetpacket function to
> retrieve information about the number of frames received or the number of
> frames received with collision, etc...
> I think that this exception is being launched when the API tries to read
> the registry in a not-privileged account.
>
>
> 2006/8/6, Thomas O'Hare <Tom at redtile.com>:
> >
> > FWIW...
> >
> > Permissions include "all" dirs and files that are used in the operation.
> > IOW, System32, your home dir, your working did, your files, etc, must
> > all have the correct permissions.
> >
> > BTW, since I believe C# is Win32, why are you not using WinPCap.Dll
> > instead with the list of exported functions?
> >
> > Also, when you get it working, can you mention your experiences using
> > C#?  I am using C and C++ and I wonder which would really be better.  My
> > guess is C would be much more portable.  But I look forward to any
> > comments on this.
> >
> > Thanks,
> > ~ Thomas O'Hare ~
> > President, RedTile, Inc. - DBA: RedTile Software
> > Web, Wireless, Network, Database & Systems Software
> > +1.407.295.9148 ; +49.8651.717950 ; http://www.RedTile.Com/<http://www.redtile.com/>
> > Operations Manager; Virtual FoxPro User Group
> > Tom at VFUG.Org ; http://www.VFUG.Org/ <http://www.vfug.org/>
> >
> >
> > Eduardo Escudero Sánchez wrote:
> > > Hi i have developed an application in C# which uses Packet.dll to
> > capture
> > > and send packets using an adapter.
> > > The problem is that i want to use that application in a session
> > without
> > > admin privileges.
> > > I have posted before a message on this topic and someone told me that
> > the
> > > only thing i had to do was run a command sc config npf start= auto and
> >
> > > that's all.
> > > But the thruth is that this is not enough. When i start running my
> > project
> > > and PacketGetAdapterNames is called my program throws an exception
> > telling
> > > me that i haven't enough permissions.
> > > Can someone tell me please how can i use Packet.dll API without admin
> > > privileges? thanks.
> > >
> > >
> > >
> > ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > Winpcap-users mailing list
> > > Winpcap-users at winpcap.org
> > > https://www.winpcap.org/mailman/listinfo/winpcap-users
> > _______________________________________________
> > Winpcap-users mailing list
> > Winpcap-users at winpcap.org
> > https://www.winpcap.org/mailman/listinfo/winpcap-users
> >
>
>  ------------------------------
>
> _______________________________________________
>
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
>
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20060807/8602f8a3/attachment-0001.htm


More information about the Winpcap-users mailing list