Skip to content

Commit

Permalink
Publishing stripcert for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
assarbad committed Sep 29, 2023
0 parents commit 0fb652b
Show file tree
Hide file tree
Showing 28 changed files with 3,584 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
IndentWidth: 4
TabWidth: 4
UseTab: Never
Language: Cpp
BasedOnStyle: Microsoft
Standard: c++17
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignEscapedNewlinesLeft: true
AllowShortFunctionsOnASingleLine: false
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 160
IndentCaseLabels: false
IndentCaseBlocks: true
PointerAlignment: Left
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
FixNamespaceComments: true
NamespaceIndentation: All
BreakBeforeBraces: Allman
IndentPPDirectives: AfterHash
# AlignArrayOfStructures: Right // clang-format-13
BreakConstructorInitializers: BeforeComma
ConstructorInitializerAllOnOneLineOrOnePerLine: false
IncludeBlocks: Preserve
IndentExternBlock: Indent
47 changes: 47 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[*.{c,cpp,h,hpp,rc}]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.cmd]
end_of_line = crlf
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.lua]
end_of_line = lf
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.{rst,md}]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
trim_trailing_whitespace = false

[*.xml]
end_of_line = lf
indent_style = space

[*.{props,vcxproj,vcxproj.filters}]
charset = utf-8
end_of_line = crlf
indent_style = space
indent_size = 4

[.{clang-format,editorconfig,hgignore,gitignore}]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
buildnumber.h
build*.log
BuildLog.htm
*.wrn
*.err
.vs/
bin/
obj/
objfre_*/
objchk_*/
*.aps
*.suo
*.ncb
*.user
17 changes: 17 additions & 0 deletions .vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "1.0",
"components": [
"Microsoft.Component.MSBuild",
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Component.Graphics.Tools",
"Microsoft.VisualStudio.Component.TextTemplating",
"Microsoft.VisualStudio.Component.VC.CoreIde",
"Microsoft.VisualStudio.Component.VC.DiagnosticTools",
"Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.Windows10SDK.*",
"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.VisualStudio.Workload.NativeDesktop"
]
}
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8
47 changes: 47 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="LogBuild;GetGitRevision">
<PropertyGroup>
<ThisProjectBuildLogFileName Condition="'$(MSBuildProjectName)' == ''">$(MSBuildThisFileDirectory)BuildCommandLines.log</ThisProjectBuildLogFileName>
<ThisProjectBuildLogFileName Condition="'$(MSBuildProjectName)' != ''">$(MSBuildThisFileDirectory)BuildCommandLines-$(MSBuildProjectName).log</ThisProjectBuildLogFileName>
<PreferredToolArchitecture Condition="'$(PreferredToolArchitecture)' == '' and ('$(PROCESSOR_ARCHITECTURE)' == 'AMD64')">x64</PreferredToolArchitecture>
<GitWorkTreeRootDir>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), '.git\refs\heads\main'))</GitWorkTreeRootDir>
<GitWorkTreeRootDir Condition="'$(GitWorkTreeRootDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), '.git\refs\heads\master'))</GitWorkTreeRootDir>
<GitWorkTreeRootDir Condition="'$(GitWorkTreeRootDir)' != '' and !HasTrailingSlash('$(GitWorkTreeRootDir)')">$(GitWorkTreeRootDir)\</GitWorkTreeRootDir>
<GitDirSentinelFile Condition="Exists('$(GitWorkTreeRootDir).git\HEAD')">$(GitWorkTreeRootDir).git\HEAD</GitDirSentinelFile>
</PropertyGroup>
<Target Name="LogBuild" BeforeTargets="SetUserMacroEnvironmentVariables;SetBuildDefaultEnvironmentVariables">
<Message Text="Setting LOG_BUILD_COMMANDLINES='$(ThisProjectBuildLogFileName)'" />
<SetEnv Name="LOG_BUILD_COMMANDLINES" Value="$(ThisProjectBuildLogFileName)" Prefix="false" />
<SetEnv Name="PreferredToolArchitecture" Value="$(PreferredToolArchitecture)" Prefix="false" />
<Message Importance="high" Text="Retrieved %24(GitWorkTreeRootDir) = '$(GitWorkTreeRootDir)'" Condition="'$(GitWorkTreeRootDir)' != ''" />
</Target>
<Target Name="FindGitExecutablePath" Condition="'$(GitDirSentinelFile)' != ''">
<PropertyGroup>
<_GitExecutableToFind>git.exe</_GitExecutableToFind>
</PropertyGroup>
<ItemGroup>
<_GitExecPaths Include="$([System.Environment]::GetEnvironmentVariable('PATH').Split(';'))" />
<_GitFilteredExecPaths Include="@(_GitExecPaths)" Condition="Exists('%(FullPath)\$(_GitExecutableToFind)')" />
<_GitFilteredExecPaths Include="@(_GitFilteredExecPaths->Reverse())" Condition="Exists('%(FullPath)\$(_GitExecutableToFind)')" />
</ItemGroup>
<PropertyGroup>
<GitExecutableFullPath Condition="'%(_GitFilteredExecPaths.Identity)' != ''">%(_GitFilteredExecPaths.Identity)\$(_GitExecutableToFind)</GitExecutableFullPath>
<GitExecutableFullPath Condition="'%(_GitFilteredExecPaths.Identity)' == ''"></GitExecutableFullPath>
</PropertyGroup>
</Target>
<Target Name="GetGitRevision" DependsOnTargets="FindGitExecutablePath" Condition="'$(GitDirSentinelFile)' != ''">
<Message Importance="high" Text="Detecting Git revision, since '$(GitDirSentinelFile)' was found. Using %24(GitExecutableFullPath) = '$(GitExecutableFullPath)'." Condition="'$(GitExecutableFullPath)' != '' and '$(GitWorkTreeRootDir)' != ''" />
<Exec Command="&quot;$(GitExecutableFullPath)&quot; -C &quot;$(GitWorkTreeRootDir)\&quot; rev-parse HEAD" EchoOff="true" Condition="'$(GitExecutableFullPath)' != '' and '$(GitWorkTreeRootDir)' != ''" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GitRevision" />
</Exec>
<Message Importance="high" Text="Retrieved for HEAD %24(GitRevision) = '$(GitRevision)'." Condition="'$(GitRevision)' != ''" />
<ItemGroup Condition="'$(GitRevision)' != ''">
<ClCompile>
<PreprocessorDefinitions>GIT_COMMIT="$(GitRevision)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>GIT_COMMIT="$(GitRevision)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemGroup>
</Target>
</Project>
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# stripcert

**Purpose:** This utility strips the AuthentiCode (code-signing) signature from a PE binary.
**NB:** Beware that it will strip anything beyond the so-called security directory. That means if an overlay has been added past the signature, it too will get stripped.

This is a small utility which I wrote back in 2007 during my first month in Iceland. I created it with DDKWizard at the time, albeit obviously an older version of DDKWizard.

I never published it, but the topic came up in 2021 and now again in 2023. So I took the time to run `clang-format` on it, fix the few code analysis warnings and wrap it up in a DDKWizard-generated VS2005 project from the latest DDKWizard version as well as a premake4-generated VS2022 project.

The VS2005 solution/project targets the Windows 7 SP1 WDK (7600.16385.1), but should be possible to target even further back; this WDK supports only Windows back until XP.

PS: these days [osslsigncode](https://github.com/mtrojnar/osslsigncode) has a command to achieve the same.
16 changes: 16 additions & 0 deletions buildinc.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off
setlocal
set WORKPATH=%1
if {%WORKPATH%}=={} set WORKPATH=.
set BUILD=%WORKPATH%\BUILD
set outfile=%WORKPATH%\buildnumber.h
for /f "" %%i in ('type "%BUILD%"') do (
set BUILDNR=%%i
)
set /a BUILDNR=%BUILDNR%+1
echo New build number is %BUILDNR% ...
echo // Automatically created file! > %outfile%
echo #define _FILE_VERSION_BUILD %BUILDNR% >> %outfile%
echo. >> %outfile%
echo %BUILDNR% > %BUILD%
endlocal
46 changes: 46 additions & 0 deletions clang-reformat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Unlicense
[[ -t 1 ]] && { cG="\e[1;32m"; cR="\e[1;31m"; cB="\e[1;34m"; cW="\e[1;37m"; cY="\e[1;33m"; cG_="\e[0;32m"; cR_="\e[0;31m"; cB_="\e[0;34m"; cW_="\e[0;37m"; cY_="\e[0;33m"; cZ="\e[0m"; export cR cG cB cY cW cR_ cG_ cB_ cY_ cW_ cZ; }
for tool in dirname env find readlink; do type $tool > /dev/null 2>&1 || { echo -e "${cR}ERROR:${cZ} couldn't find '$tool' which is required by this script."; exit 1; }; done
pushd $(dirname $0) > /dev/null; CURRABSPATH=$(readlink -nf "$(pwd)"); popd > /dev/null; # Get the directory in which the script resides
# Allow our callers to override the name (think clang-format-13 or similar stuff)
CLANGFMT=${CLANGFMT:-"clang-format"}

if [[ "$CLANGFMT" == "clang-format" ]] && [[ -n "$COMSPEC" ]]; then # assume Windows
for tool in cygpath; do type $tool > /dev/null 2>&1 || { echo -e "${cR}ERROR:${cZ} couldn't find '$tool' which is required by this script."; exit 1; }; done
PF86="$(cygpath -amF 42)"
VSWHERE="$PF86/Microsoft Visual Studio/Installer/vswhere.exe"
echo -e "${cG}VSWHERE${cZ}=$VSWHERE"
if [[ -f "$VSWHERE" && -x "$VSWHERE" ]]; then
WIN_VSINSTPATH="$(set -x; "$VSWHERE" -products \* -format value -property installationPath -latest)"
VSINSTPATH="$(cygpath -u "$WIN_VSINSTPATH")"
if [[ -n "$VSINSTPATH" ]]; then
echo -e "${cG}VSINSTPATH${cZ}=$VSINSTPATH"
LLVMPATH="$VSINSTPATH/VC/Tools/Llvm/bin"
if [[ ! -d "$LLVMPATH" ]]; then
echo -e "${cR}ERROR:${cZ} couldn't find '$LLVMPATH' inside of which we hoped to find '$CLANGFMT'."; exit 1
fi
if (export PATH="$LLVMPATH:$PATH"; "$CLANGFMT" --version 2> /dev/null); then
export PATH="$LLVMPATH:$PATH"
else
echo -e "${cR}ERROR:${cZ} couldn't find '$CLANGFMT' inside '$LLVMPATH'."; exit 1
fi
fi
else
echo -e "${cR}ERROR:${cZ} couldn't find '$VSWHERE' which is required by this script, unless you have set ${cW}CLANGFMT${cZ} to point to ${cW}clang-format${cZ}."; exit 1
fi
else
echo "$CLANGFMT"
fi

command find -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) |while read fname; do
case "${fname#./}" in
# Ignore a bunch of folders
bin/* | obj/* | .vs/* ) ;;
# Only process what remains
*)
echo -e "Formatting: ${cW}${fname#./}${cZ}"
( set -x; "$CLANGFMT" -i "${fname#./}" )
;;
esac
done
2 changes: 2 additions & 0 deletions ddkbldenv.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
:: $Id$
Loading

0 comments on commit 0fb652b

Please sign in to comment.