How do I make a WinDivert program with the precompiled driver modules? - c

I need to use WinDivert to make a program. I'm confused how to make and compile a C program that uses the precompiled WinDivert.dll, WinDivert.sys, WinDivert.inf, and WdfCoInstaller*.dll files.
For example, if I wanted to compile the passthru example with some modifications, how do I do it?
The precompiled driver modules seem to work fine, as do the precompiled samples, but I need to make a program of my own.
Notes: I'm using windows 8.1. I have Visual Studio 2013 Ultimate and WDK 8.1 installed. I don't think it works with Visual Studio, or if it does, I don't know how.

You could try using LoadLibrary()/GetProcAddress() to dynamically load WinDivert.dll. This is a reasonably foolproof method that should work for any compiler/library combination.

Related

Compiling a Visual Studio dll and using it with cygwin

my question is very simple.
I'm dealing with portaudio with the support of ASIO drivers for a university assignment. With Visual Studio I managed to compile everything an also to create a dll and now I must do the same but with cygwin. Is it possible to use the dll created with Visual Studio 2019 with cygwin? If it isn't, there is a way to do it?
Thanks in advance
Yes, you must have myfile.h myfile.dll and myfile.lib .
your goal is to produce myfile.a and put it in lib directory.
For that there is a tool Lib2a that take myfile.dll and myfile.lib in input and give myfile.a file.
https://code.google.com/archive/p/lib2a/downloads

How to use modbus library in a Visual Studio 2017 project?

Full disclosure: I'm not a C/C++ programmer, I can write basic programs like a calculator or some other very basic stuff where you don't need to use external libraries.
My goal is to use this modbus C library in a proof of concept piece of code that runs just the example line (with the IP and port changed) however I cannot wrap around my head on how to use the library.
In Python I know I could just run
import library_x
and I'd use Python, however the code needs to be in C and am completely lost when it comes to add this library. My understanding is that I should compile it in a static or dynamic library (dll) but I don't know if it's the right way to go.
Basically:
I want to run the example code in the documentation in the main of a C program, how can I do it?C
I am using Windows 10 and Visual Studio 2017.
I tried to add all the header files in the library (.h) in the Visual Studio project and compile it but it did not work.
This question has been already answered here:
libmodbus in MFC
I don't use Visual Studio but even if you don't want to use the project templates it should be quite straight forward to compile the sample code whatever your tools and environment: you have to point your compiler to include the headers and link using libmodbus. On Linux, after installing the library of compiling from sources you just have to:
$ gcc -o your_modbus_example -I/usr/include/modbus your_modbus_example.c -lmodbus
The unit_test_client.c and unit_test_server.c files provided with libmodbus should compile and work out of the box.

Visual Studio Code does not include C header files

I recently downloaded Visual Studio Code to begin learning the C programming language. I installed the program as well as the C extension. However, when I tried to create the "Hello, World!" program, it would not run, and in the Problems menu it did not recognize the stdio.h header file, saying that I need to update my includePath. I have not been able to find any stdio.h file on my computer to link to. Do I need to download the C library files (even though I have read they should be included with the compiler), and if so, where can I find them? Or is there another solution? Thanks, and sorry if this is a stupid question, I am new to this.
I think you might be confusing VS Code with the VS IDE.
VS Code is a source editor only; that is to say that it's basically just a glorified text editor. It has the ability to load extensions and open a shell to compile the code, and there are a few extensions that let you debug the code itself, but they can be tricky to get setup and installed to work well with C/C++ code. VS Code does not have a compiler/assembler/linker nor the requisite headers or SDK's as that is up to you (the user) to install and then point to those in your settings file.
The Visual Studio IDE, on the other hand, is a complete integrated development environment that also includes the system headers and SDK's for Windows, as well as the binaries to properly compile, link and assemble your code into a binary for a Windows system (cross platform is possible as well). The Visual Studio IDE comes in many different flavors with the latest being VS 2017.
If you wish to stick with VS Code, you'll need to grab a compiler and the appropriate header files for the system you're targeting. If you wish to just stick with Windows for now, you can grab the Windows 7 SDK here or the Windows 10 SDK here .. you could even grab both and just reference the one you wish when you want. Note that the Windows 7 SDK includes the Microsoft C/C++ compiler, alternatively you can download the MSVC compiler from their Build Tools site.
There's also Cygwin in which you can use the GNU compiler, and of course Clang, which can be referenced in both VS Code and the VS IDE.
I hope that can help.

Compiling and Distributing C Programs

I just finished a semester up of C programming for a class I'm in, and it has left me with some questions that I was hoping to get answered.
During my class we have been using GCC to compile C programs. This is all good and well, but I have a question about compiling.
What if I wanted to build a C program on Windows? There is no GCC. Is that what Microsoft Visual Studio is for?
Also, what if I wanted to compile a program and distribute it? What would I compile to distribute to other Window's users?
In summary, I know how to write C programs, but I just don't get how you would make a program to give to someone who doesn't have a C compiler and is basically computer dumb.
Thanks in advance,
Ryan
Generally you will need to do two things:
Compile your program into a stand-alone executable or binary.
a. On Windows this would be a win32 executable.
b. On Linux this would be an elf binary.
Create an installer package for your program.
a. On Windows you might use NSIS, Microsoft MSI, or InstallShield.
b. On Linux you would do well to use a packager for the distribution you want to target.
Anecodtally, it is very easy to utilize Eclipse CDT and NSIS to develop C and C++ software on Windows without needing to pay any license fees.
Eclipse CDT: http://eclipse.org/cdt/
Starter Guide: http://www.codeproject.com/KB/tips/CPP_Dev_eclipse_CDT.aspx
NSIS: http://nsis.sourceforge.net/Main_Page
Note that if you use Visual Studio then you will also need to compile in release mode and distribute the Visual Studio CRT or .NET runtime(s). It depends upon how you link to the standard library provided by your compiler.
you can get GCC for windows....
but, Visual Studio is probably a better choice.
Once you have built it, you can use something like Wix or InnoSetup to make an install program for it.

Compile lighttpd in Visual Studio 2005

I have a platform independent source code that can run on Windows and UNIX platforms. To compile the source on Windows, there is support for cygwin. But I want to compile it with Visual Studio 2005. How will I do it? What are the project settings required to be done on Visual studio and what about linking options? Will I be able to get any idea from successfully compiled source on cygwin? BTW, source code is in C language. Please someone help me on this.
Thanks in advance!
IMHO you're out of luck. If this project depends on cygwin, you most probably can't compile it with reasonable effort in vs.
Basically (for simple libraries) you should be fine by dumping all the .c and .h files into a visual studio project.
Most of the time you can just drop it to your own sources. If you want to create a library choose create new project -> new library, put all the sourcefiles in there and the library will automatically be linked with your main program.

Resources