mirror of
https://github.com/safing/portmaster
synced 2025-09-01 10:09:11 +00:00
[windows_kext] Add metadata to sys file
This commit is contained in:
parent
bcd834c4da
commit
98fca8f1d5
4 changed files with 72 additions and 33 deletions
|
@ -21,23 +21,21 @@ fn main() {
|
|||
|
||||
// Write files to zip
|
||||
zip.add_directory("cab", FileOptions::default()).unwrap();
|
||||
|
||||
// Write driver.lib
|
||||
write_lib_file_zip(&mut zip);
|
||||
|
||||
// Write ddf file
|
||||
write_to_zip(
|
||||
&mut zip,
|
||||
"PortmasterKext.ddf",
|
||||
get_ddf_content(),
|
||||
);
|
||||
write_to_zip(&mut zip, "PortmasterKext.ddf", get_ddf_content());
|
||||
|
||||
// Write build cab script
|
||||
write_to_zip(&mut zip, "build_cab.ps1", get_build_cab_script_content());
|
||||
|
||||
// Write metadata file
|
||||
write_to_zip(&mut zip, "version.rc", get_metadata_file_content());
|
||||
|
||||
// Write inf file
|
||||
write_to_zip(
|
||||
&mut zip,
|
||||
"cab/PortmasterKext64.inf",
|
||||
get_inf_content(),
|
||||
);
|
||||
write_to_zip(&mut zip, "cab/PortmasterKext64.inf", get_inf_content());
|
||||
|
||||
zip.finish().unwrap();
|
||||
}
|
||||
|
@ -84,6 +82,20 @@ fn get_ddf_content() -> String {
|
|||
.unwrap()
|
||||
}
|
||||
|
||||
fn get_metadata_file_content() -> String {
|
||||
let reg = Handlebars::new();
|
||||
|
||||
let version = format!(
|
||||
"{}, {}, {}, {}",
|
||||
VERSION[0], VERSION[1], VERSION[2], VERSION[3]
|
||||
);
|
||||
reg.render_template(
|
||||
include_str!("../templates/version.rc"),
|
||||
&json!({"version": version, "version_str": version_str()}),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn get_build_cab_script_content() -> String {
|
||||
let reg = Handlebars::new();
|
||||
let cab_file = format!(
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
# Remove previous cab build
|
||||
Remove-Item -Path "PortmasterKext_v2-0-0.cab" -ErrorAction SilentlyContinue
|
||||
|
||||
$SDK_Version = "10.0.22621.0"
|
||||
|
||||
# Build metadata file
|
||||
rc -I "C:\Program Files (x86)\Windows Kits\10\Include\$SDK_Version\um" `
|
||||
-I "C:\Program Files (x86)\Windows Kits\10\Include\$SDK_Version\shared" `
|
||||
.\version.rc
|
||||
|
||||
# Link the driver.
|
||||
link.exe /OUT:{{sys_file}} `
|
||||
/MANIFEST:NO /PROFILE /Driver `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\wdmsec.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\ndis.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\fwpkclnt.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\um\x64\uuid.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\BufferOverflowK.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\ntoskrnl.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\hal.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\wmilib.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\wdmsec.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\ndis.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\fwpkclnt.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\um\x64\uuid.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\BufferOverflowK.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\ntoskrnl.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\hal.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\$SDK_Version\km\x64\wmilib.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x64\1.15\WdfLdr.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x64\1.15\WdfDriverEntry.lib" `
|
||||
"{{lib_file}}" `
|
||||
"{{lib_file}}" "version.res" `
|
||||
/RELEASE /VERSION:"10.0" /DEBUG /MACHINE:X64 /ENTRY:"FxDriverEntry" /OPT:REF /INCREMENTAL:NO /SUBSYSTEM:NATIVE",6.01" /OPT:ICF /ERRORREPORT:PROMPT /MERGE:"_TEXT=.text;_PAGE=PAGE" /NOLOGO /NODEFAULTLIB /SECTION:"INIT,d"
|
||||
if(!$?) {
|
||||
Exit $LASTEXITCODE
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
link.exe /OUT:{{sys_file}} `
|
||||
/MANIFEST:NO /PROFILE /Driver `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\wdmsec.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\ndis.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\fwpkclnt.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\um\x64\uuid.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\BufferOverflowK.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\ntoskrnl.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\hal.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\km\x64\wmilib.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x64\1.15\WdfLdr.lib" `
|
||||
"C:\Program Files (x86)\Windows Kits\10\lib\wdf\kmdf\x64\1.15\WdfDriverEntry.lib" `
|
||||
"{{lib_file}}" `
|
||||
/RELEASE /VERSION:"10.0" /DEBUG /MACHINE:X64 /ENTRY:"FxDriverEntry" /OPT:REF /INCREMENTAL:NO /SUBSYSTEM:NATIVE",6.01" /OPT:ICF /ERRORREPORT:PROMPT /MERGE:"_TEXT=.text;_PAGE=PAGE" /NOLOGO /NODEFAULTLIB /SECTION:"INIT,d"
|
34
windows_kext/release/templates/version.rc
Normal file
34
windows_kext/release/templates/version.rc
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include "winres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION {{version}}
|
||||
PRODUCTVERSION {{version}}
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS 0x40004L
|
||||
FILETYPE VFT_DRV
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Safing ICS Technologies GmbH"
|
||||
VALUE "FileDescription", "Portmaster Windows Kernel Extension Driver"
|
||||
VALUE "FileVersion", "{{version_str}}"
|
||||
VALUE "LegalCopyright", "Safing ICS Technologies GmbH"
|
||||
VALUE "OriginalFilename", "PortmasterKext64.sys"
|
||||
VALUE "ProductName", "Portmaster Windows Kernel Extension"
|
||||
VALUE "ProductVersion", "{{version_str}}"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
Loading…
Add table
Reference in a new issue