So you'd like to compile PeerBlock, and maybe help out with our development efforts?  Great!  This page will help you get started.  Yes it's rather long, but that's just because we're trying to cover all the bases for you.

 

Prerequisites

There are a few things you'll need to have installed on your machine in order to get PeerBlock to build.

MS Visual C++ 2008

First off, you'll need a version of Visual Studio, or at least the Visual C++ component of it.  If you already have a version of this installed, great!  If not, the free Visual Studio 2008 Express version Microsoft makes available will work fine.

If you're using Visual Studio 2008 Express though and want to compile 64-bit versions of PeerBlock, you'll need to do a few funky things.  See this page for more details: Visual C++ 2008 Express Edition and 64-bit Targets. Most usefully, scroll down to near the bottom of the page and look for Xia Wei's post linking to a .zip file. What you'll need to do is to download and install the Windows SDK (yes, even though Visual C++ installs its own copy as well you'll need to download and install it again), then run the .bat file included in Xia Wei's .zip. Note that if you installed either Visual C++ or the Windows SDK to a location other than the default, you'll need to edit the .bat file to include the correct path-names.

MS Windows SDK

It is highly recommended that you download a new version of the Microsoft Windows SDK, as PeerBlock requires some code that is not present in the version of the SDK that is installed with Visual C++ 2008 Express.  When installing the SDK, make sure the "Developer Tools" -> "Visual C++ Compilers" option is selected. 

After installing the SDK, you will need to run the Windows SDK Configuration Tool to set Visual C++ to use this new SDK.  This program can be found in Start -> Programs -> Microsoft Windows SDK v6.1 -> Visual Studio Registration -> Windows SDK Configuration Tool.  In the "Installed Windows SDK Versions" dropdown list, select "v6.1" and click "Make Current".  The next time you restart Visual Studio, it should start using the new Windows SDK version.

This is a free download from Microsoft, and includes just about everything you'd need to compile any sort of Windows program.  Because of this, it's rather large - somewhere around 1.5 GB.  You should install version 6001.18000 (aka the "Microsoft Windows SDK for Windows Server 2008", v6.1) or newer.

MS Windows WDK

Similar to the above Windows SDK, the WDK is required in order to build drivers like the pbfilter.sys PeerBlock uses to filter network connections.  This is another free download from Microsoft, and should be somewhere around 500 MB.

  • Get it Here:  A good set of instructions for navigating through MS Connect and getting to the WDK download area can be found on Microsoft's How to Get the WDK page.

Please note that you should download a slightly older version of the WDK, as we have not yet officially moved on to the newer one since it removes support for Windows 2000.  The version you need is v6001.18002 for Windows Server 2008.  This can be found near the bottom of the MS Connect WDK Downloads page, under "Archived" downloads.  Note that you will need to download this older WDK version through the MS Connect site!

Subversion Client (TortoiseSVN)

In order to access the source-control system we're using to manage our code, Subversion, you'll need to install a program that can download the code for you.  TortoiseSVN works quite well in this regard.  Simply download and install it.

Installer (InnoSetup)

If you'd like to build the Installer package, you'll also need to download the InnoSetup "QuickStart Pack" (ispack).

 

Initial Configuration

Before you can compile PeerBlock, there are a few more things you'll need to set up on your machine.

Environment Variable

In order to get Visual Studio to use the WDK you've installed, you'll need to set up an environment variable to point to the directory into which you've installed the WDK.  Right-click on "My Computer", and select Properties.  Then select to "Advanced" tab if you're on Windows XP, or select "Advanced system settings" if you're using Windows Vista/7.  Now click the "Environment Variables" button.  Under "User variables" click "New...", and enter a Name of "PB_DDK_DIR" (without the quotes, of course) and a Value of wherever you installed the WDK.  (This directory should contain subdirectories called bin, lib, inc, etc.)  Then click OK, and then OK again, to close these windows.

Download Source Code

Create a directory on your system to hold the PeerBlock source code - for example purposes, let's call it C:\peerblock_code.  Now right-click on this directory and select "SVN Checkout".  For a URL enter "http://peerblock.googlecode.com/svn/trunk", leave all the rest as their defaults, and click OK.  TortoiseSVN should now start downloading the latest version of PeerBlock's source code.

 

Build It!

You're almost there!

Double-click on the peerblock.sln file to open it in Visual Studio.  Select the appropriate Build and Platform type ("Release" for Windows 2000/XP, "Release (Vista)" for Windows Vista/7; "Win32" for 32-bit, "x64" for 64-bit), and then Build -> Build Solution and watch it compile!

Please note that some of the Debug variants don't currently work yet, so probably aren't worth bothering with.  If you'd like to get them working though, a patch would most definitely be accepted!

Once you have Visual Studio successfully building PeerBlock, you can use our build-script to more-easily build all four release "flavors".  To do this simply double-click on the compile_all.cmd file in the PeerBlock source-code directory; it should launch a command-prompt window that will build everything for you.

 

What About Signed Drivers?

If you're running a 64-bit version of Windows Vista/7, things are going to be a bit more annoying...  The problem is, those versions of Windows will not let you load a driver unless that driver's been signed.  You have two options here. 

The first is to boot your machine in "Test Signing" mode, by hitting F8 during boot and selecting "Disable Driver Signature Enforcement".  Note that you'll need to do this every time you boot, if you want to be able to run your personal driver build.  You can also use a tool called DSEO to test-sign the pbfilter.sys driver, though I have no direct experience with that.

The other thing you can do, is to compile everything except pbfilter.sys.  Simply copy a pbfilter.sys from the most recent version of PeerBlock into your C:\peerblock_code\x64\Release (Vista) directory, and it should be able to run alongside your new peerblock.exe build.  If you're going to do this, just make sure that on all builds you right-click on the "peerblock" project within the Visual Studio Solution Explorer, and select Build or Rebuild from within there.  Also note that at times the driver the code needs will NOT correspond with the most recently released one - this will be the case when, for example, we have changes to the driver interface checked in but not released.

It's a pain, sure, but there's just no good way around it.

 

What Next?

Now that you have PeerBlock building successfully for you, why not get in contact with us to let us know?  Just send us an email and we can talk more about what you'd be interested in working on, submitting patches, getting you in-sync with our Dev Team, and all the rest of that.  Please also contact us if you have any problems getting PeerBlock to compile, or if you have any feedback on this page.

Note that our source-code is open-source (hosted at Google Code) and licensed under the zlib/libpng license.  If you're planning on doing anything interesting with our code make sure you understand that license.  And make sure to let us know, too - we'd love to hear about it!