Skip to content

Commit bb2811a

Browse files
mamoreau-devolutionsawakecoding
authored andcommitted
add build workflow
1 parent d59c1a7 commit bb2811a

File tree

9 files changed

+212
-25
lines changed

9 files changed

+212
-25
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: build package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'release version'
8+
default: "latest"
9+
required: true
10+
skip-publish:
11+
description: 'Skip publishing'
12+
required: true
13+
type: boolean
14+
default: false
15+
dry-run:
16+
description: 'Dry run (simulate)'
17+
required: true
18+
type: boolean
19+
default: true
20+
schedule:
21+
- cron: '32 5 * * 1' # 05:32 AM UTC every Monday
22+
23+
jobs:
24+
preflight:
25+
name: Preflight
26+
runs-on: ubuntu-22.04
27+
outputs:
28+
package-env: ${{ steps.info.outputs.package-env }}
29+
package-version: ${{ steps.info.outputs.package-version }}
30+
skip-publish: ${{ steps.info.outputs.skip-publish }}
31+
dry-run: ${{ steps.info.outputs.dry-run }}
32+
33+
steps:
34+
- name: Package information
35+
id: info
36+
shell: pwsh
37+
run: |
38+
$IsMasterBranch = ('${{ github.ref_name }}' -eq 'master')
39+
$IsScheduledJob = ('${{ github.event_name }}' -eq 'schedule')
40+
41+
try { $SkipPublish = [System.Boolean]::Parse('${{ inputs.skip-publish }}') } catch { $SkipPublish = $false }
42+
try { $DryRun = [System.Boolean]::Parse('${{ inputs.dry-run }}') } catch { $DryRun = $true }
43+
44+
$PackageEnv = if ($IsMasterBranch -And -Not $IsScheduledJob) {
45+
"publish-prod"
46+
} else {
47+
"publish-test"
48+
}
49+
50+
if (-Not $IsMasterBranch) {
51+
$DryRun = $true # force dry run when not on master branch
52+
}
53+
if ($IsScheduledJob) {
54+
$DryRun = $true # force dry run for scheduled runs
55+
}
56+
57+
$PackageVersion = '${{ inputs.version }}'
58+
if ([string]::IsNullOrEmpty($PackageVersion) -or $PackageVersion -eq 'latest') {
59+
$PackageVersion = (Get-Date -Format "yyyy.MM.dd") + ".0"
60+
}
61+
62+
if ($PackageVersion -NotMatch '^\d+\.\d+\.\d+\.\d+$') {
63+
throw "invalid version format: $PackageVersion, expected: 1.2.3.4"
64+
}
65+
66+
echo "package-env=$PackageEnv" >> $Env:GITHUB_OUTPUT
67+
echo "package-version=$PackageVersion" >> $Env:GITHUB_OUTPUT
68+
echo "skip-publish=$($SkipPublish.ToString().ToLower())" >> $Env:GITHUB_OUTPUT
69+
echo "dry-run=$($DryRun.ToString().ToLower())" >> $Env:GITHUB_OUTPUT
70+
71+
echo "::notice::Version: $PackageVersion"
72+
echo "::notice::DryRun: $DryRun"
73+
74+
build:
75+
name: Build library
76+
runs-on: windows-2022
77+
needs: [preflight]
78+
strategy:
79+
fail-fast: false
80+
81+
steps:
82+
- name: Check out ${{ github.repository }}
83+
uses: actions/checkout@v4
84+
85+
- name: Configure runner
86+
shell: pwsh
87+
run: |
88+
Install-Module -Name VsDevShell -Force
89+
New-Item .\package -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
90+
91+
- name: Set package version
92+
shell: pwsh
93+
run: |
94+
$PackageVersion = '${{ needs.preflight.outputs.package-version }}'
95+
Set-Content -Path ".\VERSION" -Value $PackageVersion -Encoding UTF8
96+
97+
- name: Build RdpCredProv
98+
shell: pwsh
99+
run: |
100+
foreach ($Arch in @('x64', 'arm64')) {
101+
$BuildDir = "build-$Arch"
102+
$PackageVersion = '${{ needs.preflight.outputs.package-version }}'
103+
$MsvcArch = @{"x86"="Win32";"x64"="x64";"arm64"="ARM64"}[$Arch]
104+
cmake -G "Visual Studio 17 2022" -A $MsvcArch -B $BuildDir
105+
cmake --build $BuildDir --config Release
106+
Compress-Archive "$BuildDir\bin\Release\*" ".\package\RdpCredProv-$PackageVersion-$Arch.zip" -CompressionLevel Optimal
107+
}
108+
109+
- name: Upload RdpCredProv
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: RdpCredProv-zip
113+
path: package/*.zip
114+
115+
publish:
116+
name: Publish packages
117+
runs-on: ubuntu-22.04
118+
needs: [preflight, build]
119+
environment: ${{ needs.preflight.outputs.package-env }}
120+
if: ${{ fromJSON(needs.preflight.outputs.skip-publish) == false }}
121+
122+
steps:
123+
- name: Download zip package
124+
uses: actions/download-artifact@v4
125+
with:
126+
name: RdpCredProv-zip
127+
path: package
128+
129+
- name: Create GitHub release
130+
shell: pwsh
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
working-directory: package
134+
run: |
135+
$PackageVersion = '${{ needs.preflight.outputs.package-version }}'
136+
$DryRun = [System.Boolean]::Parse('${{ needs.preflight.outputs.dry-run }}')
137+
138+
$HashPath = 'checksums'
139+
$Files = Get-Item * | % { Get-FileHash -Algorithm SHA256 $_.FullName }
140+
$Files | % { "$($_.Hash) $(Split-Path $_.Path -Leaf)" } | Out-File -FilePath $HashPath -Append -Encoding ASCII
141+
142+
echo "::group::checksums"
143+
Get-Content $HashPath
144+
echo "::endgroup::"
145+
146+
$ReleaseTag = "v$PackageVersion"
147+
$ReleaseTitle = "RdpCredProv v${PackageVersion}"
148+
$Repository = $Env:GITHUB_REPOSITORY
149+
150+
if ($DryRun) {
151+
Write-Host "Dry Run: skipping GitHub release!"
152+
} else {
153+
& gh release create $ReleaseTag --repo $Repository --title $ReleaseTitle ./*
154+
}

CMakeLists.txt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@ include(CMakePackageConfigHelpers)
99
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION_STRINGS)
1010
list(GET VERSION_STRINGS 0 VERSION_STRING)
1111

12-
string(TIMESTAMP COPYRIGHT_YEAR "%Y")
13-
set(RDPCREDPROV_VENDOR "Devolutions")
14-
set(RDPCREDPROV_COPYRIGHT "Copyright ${COPYRIGHT_YEAR} ${RDPCREDPROV_VENDOR} All Rights Reserved.")
15-
16-
string(REGEX REPLACE "([0-9]+).[0-9]+.[0-9]+" "\\1" RDPCREDPROV_VERSION_MAJOR ${VERSION_STRING})
17-
string(REGEX REPLACE "[0-9]+.([0-9]+).[0-9]+" "\\1" RDPCREDPROV_VERSION_MINOR ${VERSION_STRING})
18-
string(REGEX REPLACE "[0-9]+.[0-9]+.([0-9]+)" "\\1" RDPCREDPROV_VERSION_PATCH ${VERSION_STRING})
19-
set(RDPCREDPROV_VERSION "${RDPCREDPROV_VERSION_MAJOR}.${RDPCREDPROV_VERSION_MINOR}.${RDPCREDPROV_VERSION_PATCH}")
12+
string(TIMESTAMP CURRENT_YEAR "%Y")
13+
set(RDPCREDPROV_VENDOR "Devolutions Inc.")
14+
set(RDPCREDPROV_COPYRIGHT "Copyright 2013-${CURRENT_YEAR} ${RDPCREDPROV_VENDOR}")
15+
16+
# Enforce strict 4-part version string: MAJOR.MINOR.PATCH.BUILD
17+
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$" _ ${VERSION_STRING})
18+
if(NOT CMAKE_MATCH_COUNT EQUAL 4)
19+
message(FATAL_ERROR "VERSION_STRING must be in the format MAJOR.MINOR.PATCH.BUILD (e.g., 1.0.0.0)")
20+
endif()
21+
22+
set(RDPCREDPROV_VERSION_MAJOR "${CMAKE_MATCH_1}")
23+
set(RDPCREDPROV_VERSION_MINOR "${CMAKE_MATCH_2}")
24+
set(RDPCREDPROV_VERSION_PATCH "${CMAKE_MATCH_3}")
25+
set(RDPCREDPROV_VERSION_BUILD "${CMAKE_MATCH_4}")
26+
27+
set(RDPCREDPROV_VERSION "${RDPCREDPROV_VERSION_MAJOR}.${RDPCREDPROV_VERSION_MINOR}.${RDPCREDPROV_VERSION_PATCH}.${RDPCREDPROV_VERSION_BUILD}")
2028

2129
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
2230
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Permission is hereby granted, free of charge, to any
2+
person obtaining a copy of this software and associated
3+
documentation files (the "Software"), to deal in the
4+
Software without restriction, including without
5+
limitation the rights to use, copy, modify, merge,
6+
publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software
8+
is furnished to do so, subject to the following
9+
conditions:
10+
11+
The above copyright notice and this permission notice
12+
shall be included in all copies or substantial portions
13+
of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# RdpCredProv
22

3-
This is an experimental credential provider with fun features for RDP. Use at your own risk.
3+
This is an experimental credential provider with fun features for RDP. Use at your own risk. I have built this to get autologon to work with Hyper-V in a lab environment where security is not a concern.
44

55
## Building
66

@@ -21,12 +21,12 @@ Copy-Item RdpCredProv.dll "C:\Windows\System32\RdpCredProv.dll" -Force
2121
Register it:
2222

2323
```powershell
24-
$clsid = "{DD2ACC5E-EF4B-4C89-B296-15489C9FAC47}"
25-
$basePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\$clsid"
24+
$RdpCredProvClsid = "{DD2ACC5E-EF4B-4C89-B296-15489C9FAC47}"
25+
$basePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\$RdpCredProvClsid"
2626
New-Item -Path $basePath -Force | Out-Null
2727
Set-ItemProperty -Path $basePath -Name "(default)" -Value "RdpCredProv"
28-
$clsidRegPath = "CLSID\$clsid"
29-
$inprocPath = "CLSID\$clsid\InprocServer32"
28+
$clsidRegPath = "CLSID\$RdpCredProvClsid"
29+
$inprocPath = "CLSID\$$RdpCredProvClsid\InprocServer32"
3030
$regHKCR = [Microsoft.Win32.Registry]::ClassesRoot
3131
$cpKey = $regHKCR.CreateSubKey($clsidRegPath)
3232
$cpKey.SetValue("", "RdpCredProv")
@@ -51,7 +51,14 @@ Set-ItemProperty -Path $RdpCredProvRegPath -Name "AutoLogonWithDefault" -Value 1
5151
Set-ItemProperty -Path $RdpCredProvRegPath -Name "UseDefaultCredentials" -Value 1 -Type DWORD
5252
```
5353

54-
Those credentials will be used automatically in the Hyper-V enhanced session mode. Local accounts work, domain accounts still fail, I have to look into it.
54+
Those credentials will be used automatically in the Hyper-V enhanced session mode. If you want to enable autologon in the Hyper-V basic session mode, set the following registry keys:
55+
56+
```powershell
57+
$RdpCredProvRegPath = "HKLM:\SOFTWARE\Devolutions\RdpCredProv"
58+
Set-ItemProperty -Path $RdpCredProvRegPath -Name "RemoteOnly" -Value 0 -Type DWORD
59+
$WinlogonRegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
60+
Set-ItemProperty -Path $WinlogonRegPath -Name "DisableCAD" -Value 1 -Type DWORD
61+
```
5562

5663
## Logging
5764

@@ -67,19 +74,16 @@ Set-ItemProperty -Path $RdpCredProvRegPath -Name "LogEnabled" -Value 1 -Type DWO
6774
Unregister the credential provider:
6875

6976
```powershell
70-
$clsid = "{DD2ACC5E-EF4B-4C89-B296-15489C9FAC47}"
71-
$basePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\$clsid"
77+
$RdpCredProvClsid = "{DD2ACC5E-EF4B-4C89-B296-15489C9FAC47}"
78+
$basePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\$RdpCredProvClsid"
79+
$clsidRegPath = "CLSID\$RdpCredProvClsid"
7280
if (Test-Path $basePath) {
7381
Remove-Item -Path $basePath -Recurse -Force
74-
Write-Host "✅ Removed: $basePath"
7582
}
76-
$clsidRegPath = "CLSID\$clsid"
7783
try {
7884
$regHKCR = [Microsoft.Win32.Registry]::ClassesRoot
7985
$regHKCR.DeleteSubKeyTree($clsidRegPath)
80-
} catch {
81-
82-
}
86+
} catch { }
8387
```
8488

8589
Reboot the machine or kill Winlogon.exe, then delete RdpCredProv.dll:

RdpCredProv/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ add_library(${MODULE_NAME} SHARED
1919

2020
windows_rc_generate_version_info(
2121
NAME "${MODULE_NAME}" TYPE "DLL"
22-
VERSION "${RDPCREDPROV_VERSION}.0"
22+
VERSION "${RDPCREDPROV_VERSION}"
2323
FILENAME "${MODULE_NAME}.dll"
2424
VENDOR "${RDPCREDPROV_VENDOR}"
2525
COPYRIGHT "${RDPCREDPROV_COPYRIGHT}"

RdpCredProv/Register.reg

-836 Bytes
Binary file not shown.

RdpCredProv/Unregister.reg

-362 Bytes
Binary file not shown.

RdpCredProv/common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include <intsafe.h>
99
#include <shlguid.h>
1010

11-
#define RDPCREDPROV_RESTRICTED 1 /* enable restricting usage to the remote desktop environment only */
12-
1311
#define RDPCREDPROV_REGPATH L"SOFTWARE\\Devolutions\\RdpCredProv"
1412

1513
enum SAMPLE_FIELD_ID

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0
1+
1.0.0.0

0 commit comments

Comments
 (0)