Skip to content

Commit

Permalink
Refactoring Unify version setting
Browse files Browse the repository at this point in the history
  • Loading branch information
vlabo committed Aug 25, 2022
1 parent bf9000d commit 9357ef9
Show file tree
Hide file tree
Showing 24 changed files with 412 additions and 50 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ This is how packets are handled:
The Windows Portmaster Kernel Extension is currently only developed and tested for the amd64 (64-bit) architecture.

Prerequesites:
- Visual Studio >= 2017
- Driver (`.sys`)
- [WDK 7.1](https://www.microsoft.com/en-us/download/details.aspx?id=11800)

- WDK (https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk)
- Step 1: Install Visual Studio 2022
- Install Windows 11, version 22H2 SDK
- Install Windows 11, version 22H2 WDK
- When ask to install Visual studio extension say yes

Build driver and library:

:: open a Visual Studio 2022 Developer Command Prompt (usualy located in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat)
release.bat
:: built driver lands in install\WDDK\amd64
release_build.bat
:: built driver lands in install\WDDK\x64\Release

:: shortcut to build, sign and copy the driver to portmaster install directory:
deploy.bat
Expand Down
26 changes: 26 additions & 0 deletions Version.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<PM_VERSION_MAJOR>1</PM_VERSION_MAJOR>
<PM_VERSION_MINOR>0</PM_VERSION_MINOR>
<PM_VERSION_REVISION>11</PM_VERSION_REVISION>
<PM_VERSION_BUILD>0</PM_VERSION_BUILD>
</PropertyGroup>
<PropertyGroup />
<ItemDefinitionGroup />
<ItemGroup>
<BuildMacro Include="PM_VERSION_MAJOR">
<Value>$(PM_VERSION_MAJOR)</Value>
</BuildMacro>
<BuildMacro Include="PM_VERSION_MINOR">
<Value>$(PM_VERSION_MINOR)</Value>
</BuildMacro>
<BuildMacro Include="PM_VERSION_REVISION">
<Value>$(PM_VERSION_REVISION)</Value>
</BuildMacro>
<BuildMacro Include="PM_VERSION_BUILD">
<Value>$(PM_VERSION_BUILD)</Value>
</BuildMacro>
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ del WDDK_SOURCE
set DLL_SOURCE=install\DLL\x64\pm_kernel_glue.dll
del DLL_SOURCE

@REM call wddk-build.bat
msbuild /t:Build /p:Configuration=Debug /p:Platform=x64
SignTool sign /v /s TestCertStoreName /n TestCertName /fd SHA256 %WDDK_SOURCE%

Expand Down
12 changes: 12 additions & 0 deletions include/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)

#define PM_VERSION PM_VERSION_MAJOR, PM_VERSION_MINOR, PM_VERSION_REVISION, PM_VERSION_BUILD
#define PM_VERSION_STR STRINGIZE(PM_VERSION_MAJOR) \
"." STRINGIZE(PM_VERSION_MINOR) \
"." STRINGIZE(PM_VERSION_REVISION) \
"." STRINGIZE(PM_VERSION_BUILD)


#define COMPANY_NAME "Safing ICS Technologies GmbH"
#define LEGAL_COPYWRITE "Safing ICS Technologies GmbH"
10 changes: 5 additions & 5 deletions inf/PortmasterKext32.inf → pm_kext/PortmasterKext32.inx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Class = WFPCALLOUTS
ClassGuid = {57465043-616C-6C6F-7574-5F636C617373}
Provider = %Provider%
CatalogFile = PortmasterKext32.Cat
DriverVer = 01/01/2019,1.0.11.0


[SourceDisksNames]
1 = %DiskName%
Expand All @@ -35,17 +35,17 @@ PortmasterKext32.sys = 1
DefaultDestDir = 12 ; %windir%\system32\drivers
PortmasterKext.DriverFiles = 12 ; %windir%\system32\drivers

[DefaultInstall]
[InstallSection_32]
OptionDesc = %Description%
CopyFiles = PortmasterKext.DriverFiles

[DefaultInstall.Services]
[InstallSection_32.Services]
AddService = %ServiceName%,,PortmasterKext.Service

[DefaultUninstall]
[UninstallSection_32]
DelFiles = PortmasterKext.DriverFiles

[DefaultUninstall.Services]
[UninstallSection_32.Services]
DelService = PortmasterKext,0x200 ; SPSVCINST_STOPSERVICE

[PortmasterKext.DriverFiles]
Expand Down
10 changes: 5 additions & 5 deletions inf/PortmasterKext64.inf → pm_kext/PortmasterKext64.inx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Class = WFPCALLOUTS
ClassGuid = {57465043-616C-6C6F-7574-5F636C617373}
Provider = %Provider%
CatalogFile = PortmasterKext64.Cat
DriverVer = 01/01/2019,1.0.11.0


[SourceDisksNames]
1 = %DiskName%
Expand All @@ -35,17 +35,17 @@ PortmasterKext64.sys = 1
DefaultDestDir = 12 ; %windir%\system32\drivers
PortmasterKext.DriverFiles = 12 ; %windir%\system32\drivers

[DefaultInstall]
[InstallSection_64]
OptionDesc = %Description%
CopyFiles = PortmasterKext.DriverFiles

[DefaultInstall.Services]
[InstallSection_64.Services]
AddService = %ServiceName%,,PortmasterKext.Service

[DefaultUninstall]
[UninstallSection_64]
DelFiles = PortmasterKext.DriverFiles

[DefaultUninstall.Services]
[UninstallSection_64.Services]
DelService = PortmasterKext,0x200 ; SPSVCINST_STOPSERVICE

[PortmasterKext.DriverFiles]
Expand Down
Binary file added pm_kext/pm_kext.aps
Binary file not shown.
40 changes: 37 additions & 3 deletions pm_kext/pm_kext.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<DriverType>KMDF</DriverType>
<DriverTargetPlatform>Universal</DriverTargetPlatform>
<Driver_SpectreMitigation>false</Driver_SpectreMitigation>
<ALLOW_DATE_TIME>1</ALLOW_DATE_TIME>
<ALLOW_DATE_TIME>0</ALLOW_DATE_TIME>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<TargetVersion>Windows10</TargetVersion>
Expand All @@ -72,6 +72,18 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="..\Version.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<Import Project="..\Version.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="..\Version.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<Import Project="..\Version.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand Down Expand Up @@ -100,7 +112,7 @@
<AdditionalIncludeDirectories>$(SolutionDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>false</TreatWarningAsError>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;PM_VERSION_MAJOR=$(PM_VERSION_MAJOR);PM_VERSION_MINOR=$(PM_VERSION_MINOR);PM_VERSION_REVISION=$(PM_VERSION_REVISION);PM_VERSION_BUILD=$(PM_VERSION_BUILD);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
Expand All @@ -115,12 +127,22 @@
<AdditionalIncludeDirectories>$(SolutionDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError>false</TreatWarningAsError>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;PM_VERSION_MAJOR=$(PM_VERSION_MAJOR);PM_VERSION_MINOR=$(PM_VERSION_MINOR);PM_VERSION_REVISION=$(PM_VERSION_REVISION);PM_VERSION_BUILD=$(PM_VERSION_BUILD);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>false</UseFullPaths>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>$(DDK_LIB_PATH)\wdmsec.lib;$(DDK_LIB_PATH)\ndis.lib;$(DDK_LIB_PATH)\fwpkclnt.lib;$(SDK_LIB_PATH)\uuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Inf>
<VersionHeaderPath>../include/version.h</VersionHeaderPath>
<TimeStamp>$(PM_VERSION_MAJOR).$(PM_VERSION_MINOR).$(PM_VERSION_REVISION).$(PM_VERSION_BUILD)</TimeStamp>
<DateStamp>*</DateStamp>
<SpecifyDriverVerDirectiveVersion>true</SpecifyDriverVerDirectiveVersion>
<SpecifyDriverVerDirectiveDate>true</SpecifyDriverVerDirectiveDate>
<KmdfVersionNumber>$(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR)</KmdfVersionNumber>
</Inf>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<DriverSign>
Expand Down Expand Up @@ -166,6 +188,18 @@
<ClInclude Include="..\include\pm_register.h" />
<ClInclude Include="..\include\pm_utils.h" />
<ClInclude Include="..\include\verdict_cache.h" />
<ClInclude Include="..\include\version.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="version.rc">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions);PM_VERSION_MAJOR=$(PM_VERSION_MAJOR);PM_VERSION_MINOR=$(PM_VERSION_MINOR);PM_VERSION_REVISION=$(PM_VERSION_REVISION);PM_VERSION_BUILD=$(PM_VERSION_BUILD)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">_WIN64;_AMD64_=1;AMD64;%(PreprocessorDefinitions);PM_VERSION_MAJOR=$(PM_VERSION_MAJOR);PM_VERSION_MINOR=$(PM_VERSION_MINOR);PM_VERSION_REVISION=$(PM_VERSION_REVISION);PM_VERSION_BUILD=$(PM_VERSION_BUILD)</PreprocessorDefinitions>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Inf Include="PortmasterKext32.inx" />
<Inf Include="PortmasterKext64.inx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
19 changes: 19 additions & 0 deletions pm_kext/pm_kext.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,24 @@
<ClInclude Include="..\include\verdict_cache.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\version.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="version.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Inf Include="PortmasterKext64.inx">
<Filter>Resource Files</Filter>
</Inf>
<Inf Include="PortmasterKext32.inx">
<Filter>Resource Files</Filter>
</Inf>
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions pm_kext/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by pm_kext.rc
//
#define VERSION_MINOR 0
#define VERSION_REVISION 0
#define VERSION_BUILD 0
#define VER_VER_DEBUG 0
#define VERSION_MAJOR 1
#define VER_FILETYPE 1
#define VER_FILEOS 10

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
100 changes: 100 additions & 0 deletions pm_kext/version.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
#include "../include/version.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION PM_VERSION
PRODUCTVERSION PM_VERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE VFT_DRV
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", "Portmaster Windows Kernel Extension Driver"
VALUE "FileVersion", PM_VERSION_STR
VALUE "LegalCopyright", LEGAL_COPYWRITE
VALUE "OriginalFilename", "PortmasterKext64.sys"
VALUE "ProductName", "Portmaster Windows Kernel Extension"
VALUE "ProductVersion", PM_VERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Binary file added pm_kext_glue_dll/pm_kext_glue_dll.aps
Binary file not shown.
Loading

0 comments on commit 9357ef9

Please sign in to comment.