How to start writing DDK code ? - windows

I want to write some simple code using DDK - but i don't know even how to compile some demo code that i download.
How to compile this thing ?
Is there some simple editor / IDE that i can use ?
Is there some way to use visual studio to write and compile DDK ?

Generally the WDK consists of a command-line tools. No IDE or etc. However with some efforts it's possible to setup the MS standard IDE (MSVC2005/2008/2010).
First download and install the latest WDK package (from the official MS website). Go into
StartMenu -> Windows Driver Kits -> WDK xxxx.xxxx.x -> Build Environments.
There you'll find a list of build environments. Each one is just a shortcut to cmd.exe, with plenty of environmental variables set accordingly. Those are build environments for different Windows version, plus for each you have a free/checked configurations, which is equivalent to user-mode's Release/Debug builds.
In order to build the driver you should launch one of those shortcuts. Then, in the command prompt, go into the source code's directory and run build batch command. The rest is determined by the makefile residing in the selected directory.
It is possible nevertheless to use the standard IDE for driver development. That is, use vcproj (or vcxproj in MSVC2010) instead of makefile. This however requires setting many build parameters.

Currently there are two main paths to choose from:
1. For drivers running on Windows 7 and above:
Since Visual Studio 2013, you can use Visual Studio's built-in integration for working with WDK projects, which is a full blown IDE for driver development.
Sample screenshot from Visual Studio 2015 + WDK 10:
There is also a short guide from Microsoft on what one needs to get started. The guide includes links to downloads of Visual Studio, WDK and samples - Get started with Windows 10, Visual Studio, and the WDK:
Used together, Visual Studio 2015 and WDK 10 provide an integrated
development environment for creating efficient, high-quality drivers
for devices running Windows 10. This release of Visual Studio includes
the Visual Studio Tools for Windows 10 and the Microsoft Windows
Software Development Kit (SDK) for Windows 10.
In short you need to install Visual Studio 2015 with Update 1 and WDK 10. Your OS need to be Windows 7 or newer (desktop only, not server).
2. For drivers running on Windows XP:
If you need to stick with older WDK 7.1 (eg. for Windows XP support), then this guide from Donald D. Burn can be a good start - Getting Started with Windows Driver Development:
WDK MVP Donald D. Burn shares his experience and insights about tools
for creating a device driver for Microsoft Windows, with information
about debugging, testing tools, and techniques that can help you find
and fix bugs early in development.
...
Updated with changes to the tools, build environment, and best
practices from the Windows Server 2003 Service Pack 1 Windows Driver
Kit (WDK) to the Windows Driver Kit (WDK) Version 7.1.
Choosing this path usually requires compiling drivers in command line via Build Environments, as described by valdo's answer. As for coding you can use an editor of your choice.

Related

Migrating driver project from VS2013 to VS2015 community

Long time reader first time poster here.
I'm a Linux developer trying to get started on Windows development in my new job. I knew it would not be trivial but the first thing I'm trying to do is complete and integrate a netvmini port driver (started by a co-op student) into one of their C++ apps. I am struggling to get the build environment going...
The project was started in Visual Studio 2013 with a Windows 7 target. When I now open it in Visual Studio 2015 and try to build the solution I get:
"Unknown or unsupported property value Win7 for TargetVersion"
for each project. This also happens if I set the configuration to Win8 (both release and debug). If I set it to Win 8.1 I get:
"An SDK corresponding to WDK version '8.1' was not found. Please install the SDK before building"
I have installed every WDK and SDK I can lay my hands on from Windows 7 to Windows 10 using both the web and the VS2015 installer. I have even installed Visual Studio 2013 again but I can't even seem to get the WDK to integrate with that.
The end goal here is to be able to build this (and hopefully debug remotely in kernel mode) from my Windows 10/VS2015 workstation for targets from Windows 7-10. Any advice or documentation that details how to integrate new build platforms into VS would be helpful (all the MS documentation just tells me what I can do if I install this or that, but not HOW to do it)
I also had the same problem after running the Project Upgrade tool.
I discovered when making new configurations that "Win7" and "Win8" TargetVersion are now "Windows7" and "Windows8".
The upgrade tool does not make that change for you but I was able to manually edit my upgraded project with those changes and got it to build for all targets.
I discovered that the installer doesn't install the windows 10 SDK by default. So all the installing of other SDK's was useless. I Also found out that by installing the Win 10 SDK through the VS 2015 installer it integrates and allows me to build for targets back to windows 7 in VS 2015.

how to run a windows application developed using Visual Studio 2010 in MAC?

A windows applicatio is developed in Visual Studio 2010 and teh database used was MS Access. Can i run it directly in MAC. i.e. using the EXE or do i have to do some setting or is it not possible at all.
You cannot run windows application directly in MAC OS at all! But there is such a enviropment like - mono, which allows to compile the C# and .NET platform solutions for other OS. Feel free to use google with query - Mono develop.
From my experience - Mono isn't stable and didn't work as fine as Visual studio.
No you can not.
EXE is a windows executable file format and thus don't work on OS X, linux or any other Unix based OS. As mentioned you can use parallels wich cost money. There is a free alternative called VirtualBox. This does not provide the same features, but you have to decide for yourself.
https://www.virtualbox.org/wiki/Downloads
http://www.parallels.com/eu/
Here is a guide to how you set up VirtualBox on your MAC -> http://www.makeuseof.com/tag/virtualbox-running-windows-on-a-mac-for-free-sort-of/

VS2005 and Windows SDK 7.1

Running the WindowsSdkVer.exe shipped with Platform SDK 7.1 does not work.
None of the .BAT files in VS 2005 get updated.
can anyone please tell me how to correct this?
Also, how do I verify that VS2005 is using Platform SDK 7.1?
There are several articles for this in MSDN but none of them for above configuration.
Also, none of them describe the concrete way / definate way of verifying this
You could try to manually set the include and lib paths of the VS environment under
Tools->Options->VC++ Directories
or something like that (it's been a while).
For verification, you can add the /showIncludes parameter to the additional compiler options of the project, and /verbose:lib to the additional linker options to double check that the correct headers/libraries are being used when compiling/linking the project.
IIRC there was some kind of incompatibility between one of the newer versions of the SDK (could have been version 7) and using VS2005, but I can't recall off hand what that was.
You can use below method for using Windows SDK 7.1 with Visual Studio 2005.
Configuring Visual Studio for Visual C++ Development with the Windows SDK
In the link , you can find the contents with
"To use the Windows SDK Configuration Tool in Visual Studio 2008".
Even though it has such title, you can use the same procedure also for VS2005.
Start the Windows SDK Configuration Tool by clicking Start, then All Programs, then Microsoft Windows SDK v7.1, and then Visual Studio Registration.
Right-click Windows SDK Configuration Tool and then click Run as
administrator.
In the Windows SDK Configuration Tool, in the list, select v7.1.
Click Make Current.

What is the best way to build open source libraries DLLs for Windows developers to use?

I have several C free software/open source libraries that I develop on Linux and OSX with the GNU toolchain (automake, conf, flex, bison, gcc, ...) but I occasionally get requests to provide Windows DLLs. I'd like to be able to provide those without having to spend a lot of time and money with Windows Visual Studio development. I do have a Windows XP virtual machine available and I also know the software is portable as occasionally I get patches to make it build in on windows.
What approaches or tools should I be using? Cross compiling on Linux? using Visual Studio Express or something else? I would prefer something that is fully automated from a SVN repository. I do not count cygwin as a solution since that does not seem to provide what Windows developers need, as far I understand the issues - linking and DLLs.
You can try Mingw with MSYS, Visual Studio (Express) with SUA (subsystem for unix application) or Cygwin to compile programs that are automake/autoconf based (./configure && make to build under linux).
Unfortunately usually the lib file they create is not compatible with other compilers, so if you want your library to work with an application that is developed using Visual Studio, then you should use the VSC++ approach. Usually a lot of GNU projects (check gnuwin32) actually have VC compatible build scripts too, than can be compiled using "nmake"
You could use MinGW or install the MSVC command line tools from Visual Studio Express.
Either of those can be driven by command line scripts.
I imagine a cross compile from Linux would also work, but I have no idea how easy (or painful) that might be to get going.
This short article shows a simple cross compile of a Windows application & running that app under Wine:
http://www.linuxjournal.com/node/1005753
The Windows Software Development Kit includes Microsoft's C/C++ compiler (command line only with no visual tools), so you don't even need Visual C++ Express Edition. The Windows SDK is a free download from Microsoft.
If you're using http://www.cmake.org/, cmake can create the Makefile (for Unix) and project file (for Visual Studio). This is what for example the KDE project is using.
Visual Studio's compiler can be started from a Windows command line with 'devenv /build debug project.csproj' on the cmake generated file. This does however require a Windows (possibly in a VM) with a (potentialy free) Visual Studio installed.

how can i build a driver using visual studio? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
does anyone have an article how to do this ?
Since you gave no exact version of Visual Studio, let me give you the options I am aware of.
Visual Studio 2012, 2013 and 2015
Respective contemporary DDK/WDK versions: WDKs 8, 8.1 and 10 (as of this writing).
With the WDK for Windows 8, the WDK team at Microsoft finally offers full integration with Visual Studio again directly from Microsoft.
However, while Visual Studio 2017 exists in minor version 15.4 already by the time of this update, the WDK still requires Visual Studio 2015.
Visual Studio 2002 through 2010
Respective contemporary DDK/WDK versions: DDKs for Windows XP/2003 Server, WDKs for Windows Vista and Windows 7 with their respective service pack levels and the respective server versions.
Those versions were not officially supported by Microsoft to build drivers. The only worse choice to compile a driver would be a complete third-party toolchain (other than Intel's C compiler which was sanctioned by MS, IIRC).
It was considered very bad form to use the Visual Studio compilers during that period, and Microsoft explicitly recommended against it. However, C++ in kernel mode was also once frowned upon and now MS provides C++ frameworks for kernel mode. The times they are changin' ... ;)
Anyway, workarounds exist in the form of ddkbuild.bat and ddkbuild.cmd which use the DDK toolchain, but effectively allow you to integrate the resulting invocation from your "make" project inside Visual Studio. DDKWizard is a project creation wizard for both of those scripts. DDKWizard does not support Visual Studio 2010! The links to the two scripts provide a good documentation and DDKWizard also comes with a decent documentation.
To my knowledge ddkbuild.cmd is originally based on ddkbuild.bat and the HollisTech version can also trace its heritage back to that version from OSR.
VisualDDK combined with VirtualKD emerged later than the aforementioned, but is to be considered a far superior, more sophisticated solution. But your mileage may vary. In either case the integration into Visual Studio is far more complete in the latter solution.
Visual Studio 6
Respective contemporary DDK/WDK versions: DDKs for Windows NT 4 and Windows 2000.
Prior to the Windows XP DDK (now DDK is called WDK) the compiler was not included in the DDK, so you had to have the compiler toolchain installed. This would be the case for NT 4.0 and Windows 2000.
Download and install VisualDDK and you'll be able to create driver projects and debug drivers directly from Visual Studio.
The ddkbuild from OSR-Online is a nice alternative ddkbuild download link.
To build my driver i used VisualDDK in visual studio 2008. In the beginning i start debugging using my computer and virtualBox machine but when i launch the debugging process in visual studio, my virtual machine did not show me the external ip address(normally should show me 192.168.1.102 and 10.0.1.15 in DDKLauncherMonitor but it show me only 10.0.1.15 ).
I stopped using virtual machine and i decide to use real computer. In the second computer i launched DDKLauncherMonitor. And i start debugging from my first computer. I received Udp package in my second machine and also the driver.sys. But when i tried to load the driver from visual studio(First computer) nothing work. Plus this, in the second machine tell me "Windows required digitally signed driver".
There is same one meet this kind of problem and he/she can help.
create a makefile project and use the following as the build command:
pushd .
call C:\WinDDK\7600.16385.1\bin\setenv.bat C:\WinDDK\7600.16385.1\ chk x86 WXP no_oacr
popd
build -cgwiz
(obviously tweak the arguments to setenv to suit)
If you want to use DDK build and WDK use ddkbuild.bat, it is pretty good (I think most of it works still) that should have you going. Alternatively check out ddkbuild.cmd from OSR.
In VS create a makefile project. Add your sources, headers, makefile and sourcefile. Open project properties->Configuration properties->NMake->Build Command Line and write:
call $(WINDDK)\bin\setenv.bat $(WINDDK) fre wnet
cd /d $(ProjectDir)
build.exe -I
Now you can build from VS. The advantage of the makefile project: it provides you with as many configurations as you need (w2k, wxp, wnet, wlh and etc) and you can build from the DDK command line.
P.S.
fre wnet - is a sample configuration, use what is required for your project. It is good to have both fre and chk configurations.
WINDDK - environment variable with a path to the DDK root.

Resources