Testing WinPCAP with a Console Application - console-application

I want to check if I could successfully load the dll's for WinPCAP and want to do it by writing a simple C/C++ console application. However I do not have neither experience nor an idea about how to do it. What I know is according to its def file:
LIBRARY Packet32
EXPORTS
PacketOpenAdapter
PacketSendPacket
PacketAllocatePacket
PacketInitPacket
PacketFreePacket
PacketResetAdapter
PacketReceivePacket
PacketCloseAdapter
PacketSetHwFilter
PacketGetAdapterNames
PacketRequest
PacketSetBuff
PacketSetBpf
PacketGetNetType
PacketSetReadTimeout
PacketSetNumWrites
PacketGetNetInfo
PacketSetMinToCopy
PacketSetMaxLookahead
PacketCancelPacket
PacketLoadDriver
PacketUnloadDriver
I must be checking these things. But how? Could you please help me?
Best Regards

Those are functions in the packet32 library, not in the WinPcap library. Packet32 is a library of routines that provide access to the lower-level packet capture mechanism that WinPcap uses, in a fashion that hides from WinPcap the differences between "Windows OT" (95, 98, Me) and Windows NT (modern versions of Windows, up to and including Windows 8); it's not intended to be used by users. See the page about packet32 in the WinPcap documentation.
You don't need a console application that checks any of the packet32 routines. What you need is a console application that checks the WinPcap routines; if packet32 isn't working, those routines won't work, either. So you should look at some of the sample programs on the Internet for libpcap/WinPcap.

Related

How to differentiate between system calls and normal function calls

I am working on project which is trying to migrate some legacy application running on QNX neutrino operating system to other open source RTOS based on linux.
I have listed all the third party library and device drivers which must be ported and now analyzing design and source code which depends on some special QNX features like QNX IPC MsgSend, MsgReply, MsgSendPulse etc.
I want to know is there any tools which will help me to make a list of all QNX related system calls or functions which is getting used in code from normal user defined functions or functions provided by third party library and C++ library. Since code is written by other organisations we don't know much details about code except how to compiler and how to run it.
Thanks
Please refer link: https://sourceforge.net/projects/simpl/
You don't have direct API calls in linux which are equivalent to MsgSend, MsgReply etc.. but you can achieve it through using existing pipes/POSIX MQs (or) You can install above tgz package (Which is available in https://sourceforge.net/projects/simpl/).

JNI use in UMDF driver

I have a umdf driver and I would like to call some functions in .jar files to establish a connection between my driver (PCSC Reader) and an eclipse plugin (JCOP).
I called some java functions (from .jar) in a c++ main using JNI but can we write JNI code in a UMDF driver ?
If yes, I would appreciate some guidelines or point of views about how to approach the subject ...
There aren't much info about the subject when you google it so any info is much appreciated !
Thank you.
I don't have any UMDF driver experience, however, after reading the over view I don't see any reason why JNI would not be able to communicate directly with the Reflector. I don't think it will be able to communicate with the device stack or manager. So, if I understand this correctly, you should probably have some driver you load independently of JNI and then use JNI to talk to the driver via the Reflector.
On a more general note, I would recommend keeping your JNI code as simple as possible. My JNI code usually only functions as a Java <=> Native translation layer. All of the complexity and processing is done in a backing library that can be run independently of Java. By doing that, you can debug your native code with gdb or visual studio without having to jump around an already running JVM. You can choose to either ship the stand alone library as a native dependency and add it the the systems library load path or you can simply link it to the JNI library statically. I have had very good results using LTO and static linking in that exact scenario.

How to include DDK headers in visual studio 2010?

I need to use ZwLoadDriver function from ntddk.h. I installed Windows Software Development Kit (SDK) for Windows 8. Set all includes (#include <ntddk.h>). And I have lots of errors like type/sruct redefinition, ... already has a body. I think that my headers from the SDK mixes with the ones from the DDK. How to fix this ?
The DDK should only ever be used to develop a driver. It is water and fire in user mode, lots of declarations overlap with the SDK headers.
Using NtLoadDriver() from user mode is undocumented, no header is available to get a declaration and there is no import library available for ntdll.dll. It is a native operating system api function, even its argument uses a non-standard format for the registry key. The native OS is very different from the Win32 api. If you really, really want to do this then you'll have to write your own declaration and use GetProcAddress() to get the entrypoint in ntdll.dll
But loading drivers from user mode code is already well supported in Windows. Best to use the documented and supported way, OpenSCManager + CreateService. A sample project is available here.
You shouldn't do this. DDK headers are exclusively for driver development and shouldn't be included in applications source code. If you need to load driver, you should use the NtLoadDriver function which is a user mode version of ZwLoadDriver. Read more here and here.
Also from here:
"User-mode applications use the native system services routines by calling the entry points in the Ntdll.dll dynamic link library. These entry points convert calls to Nt and Zw routines into system calls that are trapped to kernel mode. To access these entry points, a user-mode application statically links to the Ntdll.lib library, which is available in the WDK. The routines that are implemented in Ntdll.lib are stubs that dynamically link to the entry points in Ntdll.dll at run time".

C++ Downloading File with Pause/Resume controls

Is there a simple library that I can use to download files Asynchronously from the internet with pause/resume controls.
You didn't mention OS you use. In case of Linux/Unix you can use libcurl. This library is pretty simple in usage and powerful at the same time. It has curl_easy_pause method that does pausing and unpausing of current connection. Please see details at http://curl.haxx.se/libcurl/c/curl_easy_pause.html. Here you can find examples of working with libcurl.
For c++ you may see my library sample : main.cpp

What API/SDK to use for this Windows Application?

I'm going to create a utility with GUI that will run on Windows operating systems.
It should require minimum (or zero!) amount of additional libraries, files or DLLs to run because it will be executed from an installer. Because of this, i don't want to use .NET for it will require user to install .NET Framework. I know today, most of Windows installed system come with .NET Framework but in my case i cannot be sure.
The utility will...
send some data to a web site and
parse the returning data,
collect some hardware info, like MAC address,
CPU type and make, hard-disk serial
number
I suppose native Win32 API could be used for all of those above, but instead of hassling with Win32, i'd prefer using a more developer friendly API, or SDK.
Thanks in advance.
Win32 API is the only way, and of course there are standard API - for sending data over the internet, you could use WinInet.lib/dll, to obtain information about the MAC, you could use the GetAdaptersInfo by using Iphlpapi.lib/dll,(here's a link on how to use it) for the Hard disk serial number you could use GetVolumeInformation by using kernel32.lib/dll. For the CPU Id, you might look into GetSystemInfomation
Edit: There's a C++ code, but you can easily derive a wrapper from this site Unfortunately, with WinAPI is not easy, no such thing as RAD with WinAPI but what you gain out of it is lightweight code instead of relying on SDK's, frameworks and dragging buggy dll's around with your application.
Hope this helps,
Best regards,
Tom.
You can statically link most C++ GUI libraries - even MFC. Personally, I recommend WTL, wihich is very light and header-only.
If what you want is minimum dependency with external files or DLLs you could statically compile all the required DLLs with the tool exe. Then you could use something like Visual C++ to develop such tool.
WTL is perfect for this sort of application and I am surprised more people aren't recommending it. You can also statically link with the CRT and hey presto - no dependencies and a very small EXE.
Delphi (now by Embarcadero) would do the job, creating a .exe file with no dependencies, and it is much easier to work with than the raw Win32 API.
If you don't like Object Pascal, you could try C++ Builder instead.
For the GUI you can either build your application with MFC (statically linked) or use a HTML based dialog that you can interact with using COM. (It is even possible to interact with javascript present in the page displayed by the dialog).
For the specific requirement that you do have, I feel Win32 API is the only way out.
Use MFC and statically link to it. No runtime dependancies need to be installed.