diff --git a/.gitattributes b/.gitattributes index b8bc1f360..45cf1e579 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,45 @@ -*.cs diff=csharp +# Set default behavior, in case users don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files we want to always be normalized and converted +# to native line endings on checkout. +*.config text +*.cs text diff=csharp +*.manifest text +*.md text +*.resx text +*.txt text +*.xml text +*.xaml text +*.yml text +*.yaml text +*.json text +*.props text +*.targets text + +# Declare files that will always have CRLF line endings on checkout. +*.csproj text eol=crlf +*.dbproj text eol=crlf +*.fsproj text eol=crlf +*.inf text eol=crlf +*.lsproj text eol=crlf +*.modelproj text eol=crlf +*.sln text eol=crlf +*.sqlproj text eol=crlf +*.vbproj text eol=crlf +*.vcproj text eol=crlf +*.vcxproj text eol=crlf +*.wixproj text eol=crlf +*.wmaproj text eol=crlf + +# Denote all files that are truly binary and should not be modified. +*.apk binary +*.dll binary +*.exe binary +*.ico binary +*.jpeg binary +*.jpg binary +*.otf binary +*.pdf binary +*.png binary +*.snk binary diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50713d395..70c05580e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,10 @@ on: jobs: build: - runs-on: windows-2022 - timeout-minutes: 15 + runs-on: windows-2025 + timeout-minutes: 10 + env: + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages steps: - uses: actions/checkout@v5 with: @@ -18,14 +20,13 @@ jobs: - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 - - name: Install .NET 4.6.1 targeting pack - shell: pwsh - run: | - $url = 'https://download.microsoft.com/download/F/1/D/F1DEB8DB-D277-4EF9-9F48-3A65D4D8F965/NDP461-DevPack-KB3105179-ENU.exe' - $installer = "$env:TEMP\ndp461-devpack.exe" - Invoke-WebRequest -Uri $url -OutFile $installer -UseBasicParsing - Start-Process -FilePath $installer -ArgumentList '/quiet','/norestart' -Wait - Write-Host "Installed .NET 4.6.1 Developer Pack" + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.vcxproj') }} + restore-keys: | + ${{ runner.os }}-nuget- - name: Install nbgv run: dotnet tool install -g nbgv @@ -47,7 +48,7 @@ jobs: - name: Package CLI shell: pwsh run: | - $src = 'Confuser.CLI/bin/Release/net461' + $src = 'Confuser.CLI/bin/Release/net10.0' $zip = 'ConfuserEx-CLI.zip' Get-ChildItem $src -Exclude '*.pdb','*.xml' | Compress-Archive -DestinationPath $zip Write-Host "Created $zip ($([math]::Round((Get-Item $zip).Length / 1MB, 1)) MB)" @@ -55,7 +56,7 @@ jobs: - name: Package GUI shell: pwsh run: | - $src = 'ConfuserEx/bin/Release/net461' + $src = 'ConfuserEx/bin/Release/net10.0-windows' $zip = 'ConfuserEx-GUI.zip' Get-ChildItem $src -Exclude '*.pdb','*.xml' | Compress-Archive -DestinationPath $zip Write-Host "Created $zip ($([math]::Round((Get-Item $zip).Length / 1MB, 1)) MB)" @@ -66,8 +67,8 @@ jobs: $zip = 'ConfuserEx.zip' $tmp = 'combined' New-Item -ItemType Directory -Path $tmp -Force | Out-Null - Copy-Item 'Confuser.CLI/bin/Release/net461/*' $tmp -Exclude '*.pdb','*.xml' -Recurse - Copy-Item 'ConfuserEx/bin/Release/net461/*' $tmp -Exclude '*.pdb','*.xml' -Recurse -Force + Copy-Item 'Confuser.CLI/bin/Release/net10.0/*' $tmp -Exclude '*.pdb','*.xml' -Recurse + Copy-Item 'ConfuserEx/bin/Release/net10.0-windows/*' $tmp -Exclude '*.pdb','*.xml' -Recurse -Force Get-ChildItem $tmp | Compress-Archive -DestinationPath $zip Remove-Item $tmp -Recurse -Force Write-Host "Created $zip ($([math]::Round((Get-Item $zip).Length / 1MB, 1)) MB)" @@ -86,7 +87,7 @@ jobs: pre-release: needs: build if: github.event_name == 'push' && github.ref == 'refs/heads/pre-release' - runs-on: windows-2022 + runs-on: windows-2025 timeout-minutes: 5 permissions: contents: write @@ -136,7 +137,7 @@ jobs: release: needs: build if: github.event_name == 'push' && github.ref == 'refs/heads/master' - runs-on: windows-2022 + runs-on: windows-2025 timeout-minutes: 5 permissions: contents: write diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..a09a13123 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,34 @@ +name: format + +on: + pull_request: + branches: [master, pre-release] + +jobs: + check-format: + runs-on: windows-2025 + timeout-minutes: 5 + permissions: + contents: read + steps: + - uses: actions/checkout@v5 + + - name: Check formatting + run: dotnet format Confuser2.sln --verify-no-changes --verbosity diagnostic + continue-on-error: true + id: format-check + + - name: Format diff + if: steps.format-check.outcome == 'failure' + shell: pwsh + run: | + dotnet format Confuser2.sln + git diff --stat + $diff = git diff --name-only + if ($diff) { + Write-Host "::warning::The following files need formatting:" -ForegroundColor Yellow + $diff | ForEach-Object { Write-Host " $_" } + Write-Host "" + Write-Host "Run 'dotnet format Confuser2.sln' locally and commit the changes." + exit 1 + } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..f0a28a0be --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,240 @@ +name: test + +on: + push: + branches: [master, pre-release, feature/**, fix/**] + pull_request: + branches: [master, pre-release] + +jobs: + test: + runs-on: windows-2025 + timeout-minutes: 20 + permissions: + contents: read + pull-requests: write + env: + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Setup .NET runtimes for cross-framework tests + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 8.0.x + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + + - name: Cache NuGet packages + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.vcxproj') }} + restore-keys: | + ${{ runner.os }}-nuget- + + - name: Restore + run: msbuild Confuser2.sln -t:Restore -verbosity:minimal + + - name: Build + run: msbuild Confuser2.sln -p:Configuration=Release -verbosity:minimal + + - name: Run tests with coverage + id: tests + shell: pwsh + run: | + $resultsDir = 'test-results' + New-Item -ItemType Directory -Path $resultsDir -Force | Out-Null + + $testProjects = Get-ChildItem -Path Tests -Filter '*.Test.csproj' -Recurse | Select-Object -Unique + $anyFailed = $false + + foreach ($proj in $testProjects) { + $name = $proj.BaseName + Write-Host "`n========================================" -ForegroundColor Cyan + Write-Host "Testing $name" -ForegroundColor Cyan + Write-Host "========================================" -ForegroundColor Cyan + + dotnet test $proj.FullName -c Release --no-build --verbosity minimal ` + --collect:"XPlat Code Coverage" ` + --logger "trx;LogFileName=$name.trx" ` + --results-directory "$resultsDir/$name" + + if ($LASTEXITCODE -ne 0) { $anyFailed = $true } + } + + # Parse all TRX files into a combined report + $allTests = @() + $trxFiles = Get-ChildItem -Path $resultsDir -Filter '*.trx' -Recurse + + foreach ($trx in $trxFiles) { + [xml]$xml = Get-Content $trx.FullName + $ns = @{ t = 'http://microsoft.com/schemas/VisualStudio/TeamTest/2010' } + + $results = Select-Xml -Xml $xml -XPath '//t:UnitTestResult' -Namespace $ns + foreach ($r in $results) { + $node = $r.Node + $testName = $node.testName + $outcome = $node.outcome # Passed, Failed, NotExecuted + $duration = $node.duration + $errorMsg = '' + if ($node.Output -and $node.Output.ErrorInfo) { + $errorMsg = $node.Output.ErrorInfo.Message + } + $allTests += [PSCustomObject]@{ + Name = $testName + Outcome = $outcome + Duration = $duration + Error = $errorMsg + TrxFile = $trx.BaseName + } + } + } + + # Group by category for nice display + $passed = $allTests | Where-Object { $_.Outcome -eq 'Passed' } + $failed = $allTests | Where-Object { $_.Outcome -eq 'Failed' } + $skipped = $allTests | Where-Object { $_.Outcome -eq 'NotExecuted' } + + # Build markdown report + $md = @() + $md += '## Test Results' + $md += '' + if ($failed.Count -gt 0) { + $md += "> :x: **$($failed.Count) test(s) failed** out of $($allTests.Count) total" + } else { + $md += "> :white_check_mark: **All $($passed.Count) tests passed**" + } + $md += '' + + # Summary table grouped by project (TRX file) + $grouped = $allTests | Group-Object TrxFile + $md += '| Project | :white_check_mark: Passed | :x: Failed | :fast_forward: Skipped | Total |' + $md += '|---------|--------|--------|---------|-------|' + foreach ($g in $grouped | Sort-Object Name) { + $p = ($g.Group | Where-Object { $_.Outcome -eq 'Passed' }).Count + $f = ($g.Group | Where-Object { $_.Outcome -eq 'Failed' }).Count + $s = ($g.Group | Where-Object { $_.Outcome -eq 'NotExecuted' }).Count + $icon = if ($f -gt 0) { ':x:' } else { ':white_check_mark:' } + $md += "| $icon $($g.Name) | $p | $f | $s | $($g.Group.Count) |" + } + + # Expand CrossFramework tests individually + $crossTests = $allTests | Where-Object { $_.Name -match 'CrossFramework|Console_Net|WinForms_Net|WPF_Net|Library_Net' } + if ($crossTests.Count -gt 0) { + $md += '' + $md += '
Cross-Framework Test Details (click to expand)' + $md += '' + $md += '| Test | Framework | App Type | Result |' + $md += '|------|-----------|----------|--------|' + foreach ($t in $crossTests | Sort-Object Name) { + $icon = switch ($t.Outcome) { 'Passed' { ':white_check_mark:' } 'Failed' { ':x:' } default { ':fast_forward:' } } + # Parse TFM and app type from test name + $tfm = ''; $appType = '' + if ($t.Name -match '_Net(\w+)_') { $tfm = $Matches[1] } + if ($t.Name -match '(Console|WinForms|WPF|Library)_') { $appType = $Matches[1] } + $md += "| ``$($t.Name)`` | $tfm | $appType | $icon |" + } + $md += '' + $md += '
' + } + + # List failed tests with error messages + if ($failed.Count -gt 0) { + $md += '' + $md += '### :x: Failed Tests' + $md += '' + foreach ($f in $failed) { + $md += "**``$($f.Name)``**" + if ($f.Error) { + $shortError = ($f.Error -split "`n")[0] + if ($shortError.Length -gt 200) { $shortError = $shortError.Substring(0, 200) + '...' } + $md += "> $shortError" + } + $md += '' + } + } + + $md += '' + + # Write results + $md -join "`n" | Set-Content -Path 'test-results.md' -Encoding utf8 + $md -join "`n" >> $env:GITHUB_STEP_SUMMARY + + echo "any_failed=$anyFailed" >> $env:GITHUB_OUTPUT + echo "total_passed=$($passed.Count)" >> $env:GITHUB_OUTPUT + echo "total_failed=$($failed.Count)" >> $env:GITHUB_OUTPUT + + - name: Generate coverage report + if: always() + shell: pwsh + run: | + dotnet tool install -g dotnet-reportgenerator-globaltool + $reports = (Get-ChildItem -Path test-results -Filter 'coverage.cobertura.xml' -Recurse).FullName -join ';' + if ($reports) { + reportgenerator "-reports:$reports" "-targetdir:coverage/report" "-reporttypes:HtmlInline_AzurePipelines;Cobertura;TextSummary;MarkdownSummaryGithub" + Write-Host "--- Coverage Summary ---" + Get-Content coverage/report/Summary.txt + } else { + Write-Host "No coverage files found." + } + + - name: Build PR comment + if: always() && github.event_name == 'pull_request' + shell: pwsh + run: | + $comment = @() + if (Test-Path 'test-results.md') { + $comment += Get-Content 'test-results.md' -Raw + } + $coverageMd = 'coverage/report/SummaryGithub.md' + if (Test-Path $coverageMd) { + $comment += "`n---`n" + $comment += Get-Content $coverageMd -Raw + } + $comment -join "`n" | Set-Content -Path 'pr-comment.md' -Encoding utf8 + + - name: Coverage to job summary + if: always() + shell: pwsh + run: | + $mdFile = 'coverage/report/SummaryGithub.md' + if (Test-Path $mdFile) { + "`n---`n" >> $env:GITHUB_STEP_SUMMARY + Get-Content $mdFile >> $env:GITHUB_STEP_SUMMARY + } + + - name: Post PR comment + if: always() && github.event_name == 'pull_request' + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: test-coverage-report + path: pr-comment.md + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v5 + with: + name: test-results + path: test-results/ + if-no-files-found: ignore + + - name: Upload coverage report + if: always() + uses: actions/upload-artifact@v5 + with: + name: coverage-report + path: coverage/report/ + if-no-files-found: ignore + + - name: Fail if tests failed + if: always() && steps.tests.outputs.any_failed == 'True' + run: | + Write-Host "::error::Tests failed. See the test results above for details." + exit 1 + shell: pwsh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a26c85519..42a023fc3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,23 +1,136 @@ -# Contributing +# Contributing to ConfuserExx -Contributions of any kind are in general always welcome. +Contributions of any kind are welcome. For bugfixes and unit tests, you can submit a PR directly. For larger changes, please open an issue first to discuss the approach. -When contributing to this repository, please first discuss the changes you wish -to make via issue, email, discussions, or any other method with the owners of -this repository before making a change. +## Getting Started -For contributions that contain only bugfixes or added unit tests, this -discussion is not required before hand. +1. Fork the repository +2. Create a feature branch from `pre-release`: `git checkout -b feat/my-feature pre-release` +3. Make your changes and ensure CI passes +4. Open a PR targeting `pre-release` -Please note we have a code of conduct, please follow it in all your -interactions with the project. +See [README.md](README.md#building-from-source) for build prerequisites. + +## Testing Policy + +Every PR must maintain or improve test coverage. We use a **ratchet strategy** — coverage only goes up, never down. + +### Coverage Targets + +| Assembly | Current Goal | Long-term Goal | +|----------|-------------|----------------| +| Confuser.Core | 40% | 70% | +| Confuser.CLI | 50% | 70% | +| Confuser.Protections | 30% | 60% | +| Confuser.Renamer | 30% | 60% | +| Confuser.DynCipher | 20% | 50% | + +These targets will be raised as coverage improves. CI reports coverage on every PR — check the comment. + +### What Must Be Tested + +**Always test:** +- New protection implementations (integration test: obfuscate + run + verify) +- Bug fixes (regression test proving the fix works) +- Assembly resolution and path handling logic +- CLI argument parsing and error handling +- Project file (`.crproj`) parsing edge cases + +**Don't need tests:** +- Simple property getters/setters +- WPF UI layout or styling changes +- Third-party library behavior (dnlib, CommunityToolkit) + +### Test Types + +| Type | Location | Framework | Purpose | +|------|----------|-----------|---------| +| Unit tests | `Tests/Confuser.Core.Test/` | xunit + Moq | Test individual classes in isolation | +| Unit tests | `Tests/Confuser.Renamer.Test/` | xunit + Moq | Test renaming logic | +| CLI e2e | `Tests/Confuser.CLI.Test/` | xunit | End-to-end CLI obfuscation | +| GUI smoke | `Tests/Confuser.GUI.Test/` | xunit + FlaUI | WPF UI automation | +| Integration | `Tests/*_*.Test/` | xunit | Obfuscate sample app, run it, verify output | + +### Writing a New Integration Test + +Each integration test has two projects: +- **Subject** (`Tests/MyFeature/`): Small .NET Framework console app that prints `START`, some output, `END`, and returns exit code `42` +- **Test** (`Tests/MyFeature.Test/`): References `Confuser.UnitTest` and the subject, calls `Run()` with the desired protections + +```csharp +public class MyFeatureTest : TestBase { + public MyFeatureTest(ITestOutputHelper outputHelper) : base(outputHelper) { } + + [Fact] + public Task MyProtection_SampleApp_RunsCorrectly() => + Run("MyFeature.exe", + new[] { "expected output line" }, + new SettingItem("my-protection-id")); +} +``` + +### Writing a Unit Test + +```csharp +[Fact] +public void MethodName_Condition_ExpectedResult() { + // Arrange + var sut = new MyService(); + + // Act + var result = sut.DoSomething(input); + + // Assert + Assert.Equal(expected, result); +} +``` + +Test names follow `MethodName_Condition_ExpectedResult` convention. + +### Running Tests Locally + +```bash +# All tests +dotnet test Confuser2.sln -c Release + +# Specific test project +dotnet test Tests/Confuser.CLI.Test/Confuser.CLI.Test.csproj -c Release + +# With coverage +dotnet test Tests/Confuser.CLI.Test/Confuser.CLI.Test.csproj -c Release --collect:"XPlat Code Coverage" +``` + +### Coverage Reporting + +Every PR receives an automatic coverage comment showing per-assembly line and branch coverage. The full HTML drill-down report is downloadable as the `coverage-report` artifact from the test workflow. + +## Commit Conventions + +We use [Conventional Commits](https://www.conventionalcommits.org/): + +``` +feat(scope): add new feature +fix(scope): fix a bug +test(scope): add or update tests +refactor(scope): code change that doesn't fix a bug or add a feature +chore(scope): build, CI, dependency updates +docs(scope): documentation changes +``` + +Always reference the issue number: `fix(renamer): handle FnPtr types (#6)` ## Pull Request Process -1. Ensure that only the files that are part of your change are actually part of - the pull request. Changes in unrelated files, unrelated additional files or - binaries have to be removed. -2. In case the pull request is created in response to a specific issue, please - reference the issue in the description of the pull request. -3. Pull-Requests are merged once they are signed-off by one other developer - with the permission to merge changes into the repository. +1. PRs target `pre-release`, not `master` +2. CI must pass (build + tests + coverage) +3. Coverage must not decrease +4. Only include files that are part of your change — no unrelated modifications +5. Reference the issue in the PR description +6. If fixing a community-reported issue, tag the reporter to test +7. Push fixes to the **same branch** — never close and create a replacement PR + +## Code Quality + +- Roslyn analyzers (NetAnalyzers + Roslynator) run during build — resolve all warnings +- No `ResolveThrow` calls in new code — use null-safe `Resolve` + handle null +- Follow existing code style (tabs, braces on same line, etc.) diff --git a/Confuser.CLI/Confuser.CLI.csproj b/Confuser.CLI/Confuser.CLI.csproj index 82743f158..d087b4871 100644 --- a/Confuser.CLI/Confuser.CLI.csproj +++ b/Confuser.CLI/Confuser.CLI.csproj @@ -4,7 +4,7 @@ Exe - net461 + net10.0 true ..\ConfuserEx.snk @@ -24,6 +24,14 @@ + + + + + \ No newline at end of file diff --git a/Confuser.CLI/Program.cs b/Confuser.CLI/Program.cs index de11d40a2..d0fc00ce6 100644 --- a/Confuser.CLI/Program.cs +++ b/Confuser.CLI/Program.cs @@ -13,8 +13,11 @@ internal class Program { static int Main(string[] args) { ConsoleColor original = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.White; - string originalTitle = Console.Title; - Console.Title = "ConfuserEx"; + string originalTitle = null; + if (OperatingSystem.IsWindows()) { + originalTitle = Console.Title; + Console.Title = "ConfuserEx"; + } try { bool noPause = false; bool debug = false; @@ -138,7 +141,8 @@ static int Main(string[] args) { } finally { Console.ForegroundColor = original; - Console.Title = originalTitle; + if (OperatingSystem.IsWindows() && originalTitle != null) + Console.Title = originalTitle; } } diff --git a/Confuser.Core/API/APIStore.cs b/Confuser.Core/API/APIStore.cs index b024aebf2..9cd06ef26 100644 --- a/Confuser.Core/API/APIStore.cs +++ b/Confuser.Core/API/APIStore.cs @@ -50,8 +50,8 @@ public IOpaquePredicateDescriptor GetPredicate(MethodDef method, OpaquePredicate random.Shuffle(randomPredicates); foreach (var predicate in randomPredicates) { if (predicate.IsUsable(method) && - (type == null || predicate.Type == type.Value) && - (argCount == null || Array.IndexOf(argCount, predicate.ArgumentCount) != -1)) + (type == null || predicate.Type == type.Value) && + (argCount == null || Array.IndexOf(argCount, predicate.ArgumentCount) != -1)) return predicate; } return null; @@ -95,4 +95,4 @@ public interface IAPIStore { /// The suitable opaque predicate if found, or null if not found. IOpaquePredicateDescriptor GetPredicate(MethodDef method, OpaquePredicateType? type, params int[] argCount); } -} \ No newline at end of file +} diff --git a/Confuser.Core/API/IDataStore.cs b/Confuser.Core/API/IDataStore.cs index e8aa12f3a..c96e70889 100644 --- a/Confuser.Core/API/IDataStore.cs +++ b/Confuser.Core/API/IDataStore.cs @@ -50,4 +50,4 @@ public interface IDataStoreAccessor { /// An instruction sequence that returns the stored data. Instruction[] Emit(); } -} \ No newline at end of file +} diff --git a/Confuser.Core/API/IOpaquePredicate.cs b/Confuser.Core/API/IOpaquePredicate.cs index a1eef14b5..9f3b44129 100644 --- a/Confuser.Core/API/IOpaquePredicate.cs +++ b/Confuser.Core/API/IOpaquePredicate.cs @@ -76,4 +76,4 @@ public enum OpaquePredicateType { /// Invariant } -} \ No newline at end of file +} diff --git a/Confuser.Core/Annotations.cs b/Confuser.Core/Annotations.cs index 5e2056d30..9b778b98f 100644 --- a/Confuser.Core/Annotations.cs +++ b/Confuser.Core/Annotations.cs @@ -189,4 +189,4 @@ public WeakReferenceKey(object target) public int HashCode { get; private set; } } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Confuser.Core.csproj b/Confuser.Core/Confuser.Core.csproj index 0d7acf713..de95bce88 100644 --- a/Confuser.Core/Confuser.Core.csproj +++ b/Confuser.Core/Confuser.Core.csproj @@ -4,7 +4,7 @@ - net461;netstandard2.0 + net48;netstandard2.0 true ..\ConfuserEx.snk @@ -18,7 +18,6 @@ - diff --git a/Confuser.Core/ConfuserAssemblyResolver.cs b/Confuser.Core/ConfuserAssemblyResolver.cs index 0b6a39da3..500d3f92e 100644 --- a/Confuser.Core/ConfuserAssemblyResolver.cs +++ b/Confuser.Core/ConfuserAssemblyResolver.cs @@ -84,7 +84,7 @@ public void Clear() { InternalFuzzyResolver.Clear(); } - public IEnumerable GetCachedAssemblies() => + public IEnumerable GetCachedAssemblies() => InternalExactResolver.GetCachedAssemblies().Concat(InternalFuzzyResolver.GetCachedAssemblies()); public void AddToCache(ModuleDefMD modDef) { @@ -105,13 +105,13 @@ private sealed class TeeList : IList { /// public void Add(string item) { - foreach (var list in _lists) + foreach (var list in _lists) list.Add(item); } /// public void Clear() { - foreach (var list in _lists) + foreach (var list in _lists) list.Clear(); } @@ -136,13 +136,13 @@ public bool Remove(string item) => /// public void Insert(int index, string item) { - foreach (var list in _lists) + foreach (var list in _lists) list.Insert(index, item); } /// public void RemoveAt(int index) { - foreach (var list in _lists) + foreach (var list in _lists) list.RemoveAt(index); } diff --git a/Confuser.Core/ConfuserComponent.cs b/Confuser.Core/ConfuserComponent.cs index 105211392..7d554c6f5 100644 --- a/Confuser.Core/ConfuserComponent.cs +++ b/Confuser.Core/ConfuserComponent.cs @@ -41,4 +41,4 @@ public abstract class ConfuserComponent { /// The processing pipeline. protected internal abstract void PopulatePipeline(ProtectionPipeline pipeline); } -} \ No newline at end of file +} diff --git a/Confuser.Core/ConfuserContext.cs b/Confuser.Core/ConfuserContext.cs index 94092bec1..a8c7a1c76 100644 --- a/Confuser.Core/ConfuserContext.cs +++ b/Confuser.Core/ConfuserContext.cs @@ -166,7 +166,7 @@ public NativeModuleWriterOptions RequestNative(bool optimizeImageSize) { return null; if (CurrentModuleWriterOptions == null) CurrentModuleWriterOptions = new NativeModuleWriterOptions(CurrentModule, optimizeImageSize); - + // Clone the current options to the new options var newOptions = new NativeModuleWriterOptions(CurrentModule, optimizeImageSize) { AddCheckSum = CurrentModuleWriterOptions.AddCheckSum, diff --git a/Confuser.Core/ConfuserEngine.cs b/Confuser.Core/ConfuserEngine.cs index 2b90fb315..a4e737cce 100644 --- a/Confuser.Core/ConfuserEngine.cs +++ b/Confuser.Core/ConfuserEngine.cs @@ -11,11 +11,11 @@ using dnlib.DotNet.Emit; using dnlib.DotNet.Writer; using Microsoft.Win32; -using InformationalAttribute = System.Reflection.AssemblyInformationalVersionAttribute; -using ProductAttribute = System.Reflection.AssemblyProductAttribute; using CopyrightAttribute = System.Reflection.AssemblyCopyrightAttribute; +using InformationalAttribute = System.Reflection.AssemblyInformationalVersionAttribute; using MethodAttributes = dnlib.DotNet.MethodAttributes; using MethodImplAttributes = dnlib.DotNet.MethodImplAttributes; +using ProductAttribute = System.Reflection.AssemblyProductAttribute; using TypeAttributes = dnlib.DotNet.TypeAttributes; namespace Confuser.Core { @@ -93,7 +93,7 @@ static void RunInternal(ConfuserParameters parameters, CancellationToken token) new SettingItem(WatermarkingProtection._Id) }); - var asmResolver = new ConfuserAssemblyResolver {EnableTypeDefCache = true}; + var asmResolver = new ConfuserAssemblyResolver { EnableTypeDefCache = true }; asmResolver.DefaultModuleContext = new ModuleContext(asmResolver); context.InternalResolver = asmResolver; context.BaseDirectory = Path.GetFullPath(context.Project.BaseDirectory).TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar; @@ -320,7 +320,7 @@ static void CheckStrongName(ConfuserContext context, ModuleDef module) { else if (isKeyProvided && !moduleIsSignedOrDelayedSigned) context.Logger.WarnFormat("[{0}] SN Key or SN public Key is provided for an unsigned module, the output may not be working.", module.Name); else if (snPubKeyBytes != null && moduleIsSignedOrDelayedSigned && - !module.Assembly.PublicKey.Data.SequenceEqual(snPubKeyBytes)) + !module.Assembly.PublicKey.Data.SequenceEqual(snPubKeyBytes)) context.Logger.WarnFormat("[{0}] Provided SN public Key and signed module's public key do not match, the output may not be working.", module.Name); } @@ -375,7 +375,7 @@ static void BeginModule(ConfuserContext context) { } } - static void ProcessModule(ConfuserContext context) => + static void ProcessModule(ConfuserContext context) => context.CurrentModuleWriterOptions.WriterEvent += (sender, e) => context.CheckCancellation(); static void OptimizeMethods(ConfuserContext context) { @@ -396,7 +396,8 @@ static void EndModule(ConfuserContext context) { context.Logger.WarnFormat("Input file is not inside the base directory. Relative path can't be created. Placing file into output root." + Environment.NewLine + "Responsible file is: {0}", output); output = Path.GetFileName(output); - } else { + } + else { output = relativeOutput; } } diff --git a/Confuser.Core/ConfuserParameters.cs b/Confuser.Core/ConfuserParameters.cs index ad30f8bab..f3e05a2c1 100644 --- a/Confuser.Core/ConfuserParameters.cs +++ b/Confuser.Core/ConfuserParameters.cs @@ -56,4 +56,4 @@ internal Marker GetMarker() { return Marker ?? new ObfAttrMarker(); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/CoreComponent.cs b/Confuser.Core/CoreComponent.cs index 7ae6d7a82..31ca4b15e 100644 --- a/Confuser.Core/CoreComponent.cs +++ b/Confuser.Core/CoreComponent.cs @@ -42,11 +42,9 @@ public class CoreComponent : ConfuserComponent { readonly Marker marker; readonly ConfuserContext _context; - /// /// Initializes a new instance of the class. /// - /// The parameters. /// The marker. internal CoreComponent(ConfuserContext context, Marker marker) { _context = context; diff --git a/Confuser.Core/DependencyResolver.cs b/Confuser.Core/DependencyResolver.cs index c7c694525..8c0bca6a3 100644 --- a/Confuser.Core/DependencyResolver.cs +++ b/Confuser.Core/DependencyResolver.cs @@ -146,4 +146,4 @@ internal CircularDependencyException(Protection a, Protection b) /// public Protection ProtectionB { get; private set; } } -} \ No newline at end of file +} diff --git a/Confuser.Core/DnlibUtils.cs b/Confuser.Core/DnlibUtils.cs index 7570da946..440b1af97 100644 --- a/Confuser.Core/DnlibUtils.cs +++ b/Confuser.Core/DnlibUtils.cs @@ -544,7 +544,7 @@ public static bool IsEntryPoint(this TypeDef typeDef) { return typeDef == typeDef.Module.EntryPoint?.DeclaringType; } - + /// /// Merges a specified call instruction into the body. /// diff --git a/Confuser.Core/Helpers/ControlFlowGraph.cs b/Confuser.Core/Helpers/ControlFlowGraph.cs index 54127be3b..aeea27dfa 100644 --- a/Confuser.Core/Helpers/ControlFlowGraph.cs +++ b/Confuser.Core/Helpers/ControlFlowGraph.cs @@ -91,7 +91,7 @@ void PopulateBlockHeaders(HashSet blockHeaders, HashSet {1} {2}", Id, Type, string.Join(", ", Targets.Select(block => block.Id.ToString()).ToArray())); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Helpers/InjectHelper.cs b/Confuser.Core/Helpers/InjectHelper.cs index 6cb066c23..6c5f931fe 100644 --- a/Confuser.Core/Helpers/InjectHelper.cs +++ b/Confuser.Core/Helpers/InjectHelper.cs @@ -99,7 +99,7 @@ static void CopyMethodDef(MethodDef methodDef, InjectContext ctx) { newMethodDef.Signature = ctx.Importer.Import(methodDef.Signature); newMethodDef.Parameters.UpdateParameterTypes(); - + foreach (var paramDef in methodDef.ParamDefs) newMethodDef.ParamDefs.Add(new ParamDefUser(paramDef.Name, paramDef.Sequence, paramDef.Attributes)); @@ -112,16 +112,14 @@ static void CopyMethodDef(MethodDef methodDef, InjectContext ctx) { if (methodDef.HasBody) CopyMethodBody(methodDef, ctx, newMethodDef); } - - static void CopyMethodBody(MethodDef methodDef, InjectContext ctx, MethodDef newMethodDef) - { + + static void CopyMethodBody(MethodDef methodDef, InjectContext ctx, MethodDef newMethodDef) { newMethodDef.Body = new CilBody(methodDef.Body.InitLocals, new List(), - new List(), new List()) {MaxStack = methodDef.Body.MaxStack}; + new List(), new List()) { MaxStack = methodDef.Body.MaxStack }; var bodyMap = new Dictionary(); - foreach (Local local in methodDef.Body.Variables) - { + foreach (Local local in methodDef.Body.Variables) { var newLocal = new Local(ctx.Importer.Import(local.Type)); newMethodDef.Body.Variables.Add(newLocal); newLocal.Name = local.Name; @@ -129,15 +127,12 @@ static void CopyMethodBody(MethodDef methodDef, InjectContext ctx, MethodDef new bodyMap[local] = newLocal; } - foreach (Instruction instr in methodDef.Body.Instructions) - { - var newInstr = new Instruction(instr.OpCode, instr.Operand) - { + foreach (Instruction instr in methodDef.Body.Instructions) { + var newInstr = new Instruction(instr.OpCode, instr.Operand) { SequencePoint = instr.SequencePoint }; - switch (newInstr.Operand) - { + switch (newInstr.Operand) { case IType type: newInstr.Operand = ctx.Importer.Import(type); break; @@ -153,23 +148,21 @@ static void CopyMethodBody(MethodDef methodDef, InjectContext ctx, MethodDef new bodyMap[instr] = newInstr; } - foreach (Instruction instr in newMethodDef.Body.Instructions) - { + foreach (Instruction instr in newMethodDef.Body.Instructions) { if (instr.Operand != null && bodyMap.ContainsKey(instr.Operand)) instr.Operand = bodyMap[instr.Operand]; else if (instr.Operand is Instruction[] instructions) - instr.Operand = instructions.Select(target => (Instruction) bodyMap[target]).ToArray(); + instr.Operand = instructions.Select(target => (Instruction)bodyMap[target]).ToArray(); } foreach (ExceptionHandler eh in methodDef.Body.ExceptionHandlers) - newMethodDef.Body.ExceptionHandlers.Add(new ExceptionHandler(eh.HandlerType) - { + newMethodDef.Body.ExceptionHandlers.Add(new ExceptionHandler(eh.HandlerType) { CatchType = eh.CatchType == null ? null : ctx.Importer.Import(eh.CatchType), - TryStart = (Instruction) bodyMap[eh.TryStart], - TryEnd = (Instruction) bodyMap[eh.TryEnd], - HandlerStart = (Instruction) bodyMap[eh.HandlerStart], - HandlerEnd = (Instruction) bodyMap[eh.HandlerEnd], - FilterStart = eh.FilterStart == null ? null : (Instruction) bodyMap[eh.FilterStart] + TryStart = (Instruction)bodyMap[eh.TryStart], + TryEnd = (Instruction)bodyMap[eh.TryEnd], + HandlerStart = (Instruction)bodyMap[eh.HandlerStart], + HandlerEnd = (Instruction)bodyMap[eh.HandlerEnd], + FilterStart = eh.FilterStart == null ? null : (Instruction)bodyMap[eh.FilterStart] }); newMethodDef.Body.SimplifyMacros(newMethodDef.Parameters); @@ -288,7 +281,7 @@ public InjectContext(ModuleDef module, ModuleDef target) { public override ITypeDefOrRef Map(ITypeDefOrRef source) { if (DefMap.TryGetValue(source, out var mappedRef)) return mappedRef as ITypeDefOrRef; - + // check if the assembly reference needs to be fixed. if (source is TypeRef sourceRef) { var targetAssemblyRef = TargetModule.GetAssemblyRef(sourceRef.DefinitionAssembly.Name); diff --git a/Confuser.Core/Helpers/KeySequence.cs b/Confuser.Core/Helpers/KeySequence.cs index 170d3afba..7df2bfa87 100644 --- a/Confuser.Core/Helpers/KeySequence.cs +++ b/Confuser.Core/Helpers/KeySequence.cs @@ -120,13 +120,13 @@ static void ProcessBlocks(BlockKey[] keys, ControlFlowGraph graph, RandomGenerat foreach (var eh in graph.Body.ExceptionHandlers) { if (eh.FilterStart != null && block.Footer.OpCode.Code == Code.Endfilter) { if (footerIndex >= graph.IndexOf(eh.FilterStart) && - footerIndex < graph.IndexOf(eh.HandlerStart)) + footerIndex < graph.IndexOf(eh.HandlerStart)) ehs.Add(eh); } else if (eh.HandlerType == ExceptionHandlerType.Finally || - eh.HandlerType == ExceptionHandlerType.Fault) { + eh.HandlerType == ExceptionHandlerType.Fault) { if (footerIndex >= graph.IndexOf(eh.HandlerStart) && - (eh.HandlerEnd == null || footerIndex < graph.IndexOf(eh.HandlerEnd))) + (eh.HandlerEnd == null || footerIndex < graph.IndexOf(eh.HandlerEnd))) ehs.Add(eh); } } @@ -158,7 +158,7 @@ static void ProcessBlocks(BlockKey[] keys, ControlFlowGraph graph, RandomGenerat int footerIndex = graph.IndexOf(block.Footer); foreach (var eh in graph.Body.ExceptionHandlers) { if (footerIndex >= graph.IndexOf(eh.TryStart) && - (eh.TryEnd == null || footerIndex < graph.IndexOf(eh.TryEnd))) + (eh.TryEnd == null || footerIndex < graph.IndexOf(eh.TryEnd))) ehs.Add(eh); } ehMap[block] = ehs; @@ -209,4 +209,4 @@ static void ProcessBlocks(BlockKey[] keys, ControlFlowGraph graph, RandomGenerat } } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Helpers/MutationHelper.cs b/Confuser.Core/Helpers/MutationHelper.cs index b671634b3..a33ba5061 100644 --- a/Confuser.Core/Helpers/MutationHelper.cs +++ b/Confuser.Core/Helpers/MutationHelper.cs @@ -43,8 +43,8 @@ public static void InjectKey(MethodDef method, int keyId, int key) { var field = (IField)instr.Operand; int _keyId; if (field.DeclaringType.FullName == mutationType && - field2index.TryGetValue(field.Name, out _keyId) && - _keyId == keyId) { + field2index.TryGetValue(field.Name, out _keyId) && + _keyId == keyId) { instr.OpCode = OpCodes.Ldc_I4; instr.Operand = key; } @@ -64,8 +64,8 @@ public static void InjectKeys(MethodDef method, int[] keyIds, int[] keys) { var field = (IField)instr.Operand; int _keyIndex; if (field.DeclaringType.FullName == mutationType && - field2index.TryGetValue(field.Name, out _keyIndex) && - (_keyIndex = Array.IndexOf(keyIds, _keyIndex)) != -1) { + field2index.TryGetValue(field.Name, out _keyIndex) && + (_keyIndex = Array.IndexOf(keyIds, _keyIndex)) != -1) { instr.OpCode = OpCodes.Ldc_I4; instr.Operand = keys[_keyIndex]; } @@ -85,7 +85,7 @@ public static void ReplacePlaceholder(MethodDef method, Func(); var pendingInstructions = new Queue(); pendingInstructions.Enqueue(instr); diff --git a/Confuser.Core/ILogger.cs b/Confuser.Core/ILogger.cs index 171691226..ec55db448 100644 --- a/Confuser.Core/ILogger.cs +++ b/Confuser.Core/ILogger.cs @@ -101,4 +101,4 @@ public interface ILogger { /// Indicated whether the protection process is successful. void Finish(bool successful); } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Common/CRC.cs b/Confuser.Core/LZMA/Common/CRC.cs index 3dcc96e26..46e01a038 100644 --- a/Confuser.Core/LZMA/Common/CRC.cs +++ b/Confuser.Core/LZMA/Common/CRC.cs @@ -52,4 +52,4 @@ private static bool VerifyDigest(uint digest, byte[] data, uint offset, uint siz } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Common/InBuffer.cs b/Confuser.Core/LZMA/Common/InBuffer.cs index 89e5ba9bd..4a68cef70 100644 --- a/Confuser.Core/LZMA/Common/InBuffer.cs +++ b/Confuser.Core/LZMA/Common/InBuffer.cs @@ -66,4 +66,4 @@ public ulong GetProcessedSize() { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Common/OutBuffer.cs b/Confuser.Core/LZMA/Common/OutBuffer.cs index 519279392..39e9c7b7f 100644 --- a/Confuser.Core/LZMA/Common/OutBuffer.cs +++ b/Confuser.Core/LZMA/Common/OutBuffer.cs @@ -56,4 +56,4 @@ public ulong GetProcessedSize() { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/LZ/IMatchFinder.cs b/Confuser.Core/LZMA/Compress/LZ/IMatchFinder.cs index ddbdd0be7..b8dbe1965 100644 --- a/Confuser.Core/LZMA/Compress/LZ/IMatchFinder.cs +++ b/Confuser.Core/LZMA/Compress/LZ/IMatchFinder.cs @@ -18,10 +18,10 @@ internal interface IInWindowStream { internal interface IMatchFinder : IInWindowStream { void Create(UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter); + UInt32 matchMaxLen, UInt32 keepAddBufferAfter); UInt32 GetMatches(UInt32[] distances); void Skip(UInt32 num); } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/LZ/LzBinTree.cs b/Confuser.Core/LZMA/Compress/LZ/LzBinTree.cs index a5b155b83..79d61b8db 100644 --- a/Confuser.Core/LZMA/Compress/LZ/LzBinTree.cs +++ b/Confuser.Core/LZMA/Compress/LZ/LzBinTree.cs @@ -57,13 +57,13 @@ internal class BinTree : InWindow, IMatchFinder { } public void Create(UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter) { + UInt32 matchMaxLen, UInt32 keepAddBufferAfter) { if (historySize > kMaxValForNormalize - 256) throw new Exception(); _cutValue = 16 + (matchMaxLen >> 1); UInt32 windowReservSize = (historySize + keepAddBufferBefore + - matchMaxLen + keepAddBufferAfter) / 2 + 256; + matchMaxLen + keepAddBufferAfter) / 2 + 256; base.Create(historySize + keepAddBufferBefore, matchMaxLen + keepAddBufferAfter, windowReservSize); @@ -157,7 +157,7 @@ public UInt32 GetMatches(UInt32[] distances) { if (kNumHashDirectBytes != 0) { if (curMatch > matchMinPos) { if (_bufferBase[_bufferOffset + curMatch + kNumHashDirectBytes] != - _bufferBase[cur + kNumHashDirectBytes]) { + _bufferBase[cur + kNumHashDirectBytes]) { distances[offset++] = maxLen = kNumHashDirectBytes; distances[offset++] = _pos - curMatch - 1; } @@ -173,8 +173,8 @@ public UInt32 GetMatches(UInt32[] distances) { } UInt32 delta = _pos - curMatch; UInt32 cyclicPos = ((delta <= _cyclicBufferPos) ? - (_cyclicBufferPos - delta) : - (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1; + (_cyclicBufferPos - delta) : + (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1; UInt32 pby1 = _bufferOffset + curMatch; UInt32 len = Math.Min(len0, len1); @@ -257,8 +257,8 @@ public void Skip(UInt32 num) { UInt32 delta = _pos - curMatch; UInt32 cyclicPos = ((delta <= _cyclicBufferPos) ? - (_cyclicBufferPos - delta) : - (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1; + (_cyclicBufferPos - delta) : + (_cyclicBufferPos - delta + _cyclicBufferSize)) << 1; UInt32 pby1 = _bufferOffset + curMatch; UInt32 len = Math.Min(len0, len1); @@ -334,4 +334,4 @@ public void SetCutValue(UInt32 cutValue) { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/LZ/LzInWindow.cs b/Confuser.Core/LZMA/Compress/LZ/LzInWindow.cs index ede3933ba..744c0d520 100644 --- a/Confuser.Core/LZMA/Compress/LZ/LzInWindow.cs +++ b/Confuser.Core/LZMA/Compress/LZ/LzInWindow.cs @@ -129,4 +129,4 @@ public void ReduceOffsets(Int32 subValue) { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/LZ/LzOutWindow.cs b/Confuser.Core/LZMA/Compress/LZ/LzOutWindow.cs index 9c187bd21..a29017799 100644 --- a/Confuser.Core/LZMA/Compress/LZ/LzOutWindow.cs +++ b/Confuser.Core/LZMA/Compress/LZ/LzOutWindow.cs @@ -97,4 +97,4 @@ public byte GetByte(uint distance) { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/LZMA/LzmaBase.cs b/Confuser.Core/LZMA/Compress/LZMA/LzmaBase.cs index 8cfc875bb..e1b1f329a 100644 --- a/Confuser.Core/LZMA/Compress/LZMA/LzmaBase.cs +++ b/Confuser.Core/LZMA/Compress/LZMA/LzmaBase.cs @@ -48,7 +48,7 @@ internal abstract class Base { public const uint kNumMidLenSymbols = 1 << kNumMidLenBits; public const uint kNumLenSymbols = kNumLowLenSymbols + kNumMidLenSymbols + - (1 << kNumHighLenBits); + (1 << kNumHighLenBits); public const uint kMatchMaxLen = kMatchMinLen + kNumLenSymbols - 1; @@ -92,4 +92,4 @@ public bool IsCharState() { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/LZMA/LzmaDecoder.cs b/Confuser.Core/LZMA/Compress/LZMA/LzmaDecoder.cs index ff5006454..852e267ef 100644 --- a/Confuser.Core/LZMA/Compress/LZMA/LzmaDecoder.cs +++ b/Confuser.Core/LZMA/Compress/LZMA/LzmaDecoder.cs @@ -39,7 +39,7 @@ public Decoder() { } public void Code(Stream inStream, Stream outStream, - Int64 inSize, Int64 outSize, ICodeProgress progress) { + Int64 inSize, Int64 outSize, ICodeProgress progress) { Init(inStream, outStream); var state = new Base.State(); @@ -66,7 +66,7 @@ public void Code(Stream inStream, Stream outStream, byte prevByte = m_OutWindow.GetByte(0); if (!state.IsCharState()) b = m_LiteralDecoder.DecodeWithMatchByte(m_RangeDecoder, - (uint)nowPos64, prevByte, m_OutWindow.GetByte(rep0)); + (uint)nowPos64, prevByte, m_OutWindow.GetByte(rep0)); else b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, (uint)nowPos64, prevByte); m_OutWindow.PutByte(b); @@ -116,7 +116,7 @@ public void Code(Stream inStream, Stream outStream, rep0 = ((2 | (posSlot & 1)) << numDirectBits); if (posSlot < Base.kEndPosModelIndex) rep0 += BitTreeDecoder.ReverseDecode(m_PosDecoders, - rep0 - posSlot - 1, m_RangeDecoder, numDirectBits); + rep0 - posSlot - 1, m_RangeDecoder, numDirectBits); else { rep0 += (m_RangeDecoder.DecodeDirectBits( numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits); @@ -269,7 +269,7 @@ private class LiteralDecoder { public void Create(int numPosBits, int numPrevBits) { if (m_Coders != null && m_NumPrevBits == numPrevBits && - m_NumPosBits == numPosBits) + m_NumPosBits == numPosBits) return; m_NumPosBits = numPosBits; m_PosMask = ((uint)1 << numPosBits) - 1; @@ -363,4 +363,4 @@ public override void SetLength(long value) {} */ } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/LZMA/LzmaEncoder.cs b/Confuser.Core/LZMA/Compress/LZMA/LzmaEncoder.cs index ff70a41cf..9b82864a2 100644 --- a/Confuser.Core/LZMA/Compress/LZMA/LzmaEncoder.cs +++ b/Confuser.Core/LZMA/Compress/LZMA/LzmaEncoder.cs @@ -103,7 +103,7 @@ public Encoder() { } public void Code(Stream inStream, Stream outStream, - Int64 inSize, Int64 outSize, ICodeProgress progress) { + Int64 inSize, Int64 outSize, ICodeProgress progress) { _needReleaseMFStream = false; try { SetStreams(inStream, outStream, inSize, outSize); @@ -168,7 +168,7 @@ public void SetCoderProperties(CoderPropID[] propIDs, object[] properties) { ; var dictionarySize = (Int32)prop; if (dictionarySize < (UInt32)(1 << Base.kDicLogSizeMin) || - dictionarySize > (UInt32)(1 << kDicLogSizeMaxCompress)) + dictionarySize > (UInt32)(1 << kDicLogSizeMaxCompress)) throw new InvalidParamException(); _dictionarySize = (UInt32)dictionarySize; int dicLogSize; @@ -311,7 +311,7 @@ private void ReadMatchDistances(out UInt32 lenRes, out UInt32 numDistancePairs) lenRes = _matchDistances[numDistancePairs - 2]; if (lenRes == _numFastBytes) lenRes += _matchFinder.GetMatchLen((int)lenRes - 1, _matchDistances[numDistancePairs - 1], - Base.kMatchMaxLen - lenRes); + Base.kMatchMaxLen - lenRes); } _additionalOffset++; } @@ -326,7 +326,7 @@ private void MovePos(UInt32 num) { private UInt32 GetRepLen1Price(Base.State state, UInt32 posState) { return _isRepG0[state.Index].GetPrice0() + - _isRep0Long[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0(); + _isRep0Long[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0(); } private UInt32 GetPureRepPrice(UInt32 repIndex, Base.State state, UInt32 posState) { @@ -359,7 +359,7 @@ private UInt32 GetPosLenPrice(UInt32 pos, UInt32 len, UInt32 posState) { price = _distancesPrices[(lenToPosState * Base.kNumFullDistances) + pos]; else price = _posSlotPrices[(lenToPosState << Base.kNumPosSlotBits) + GetPosSlot2(pos)] + - _alignPrices[pos & Base.kAlignMask]; + _alignPrices[pos & Base.kAlignMask]; return price + _lenEncoder.GetPrice(len - Base.kMatchMinLen, posState); } @@ -454,7 +454,7 @@ private UInt32 GetOptimum(UInt32 position, out UInt32 backRes) { UInt32 posState = (position & _posStateMask); _optimum[1].Price = _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0() + - _literalEncoder.GetSubCoder(position, _previousByte).GetPrice(!_state.IsCharState(), matchByte, currentByte); + _literalEncoder.GetSubCoder(position, _previousByte).GetPrice(!_state.IsCharState(), matchByte, currentByte); _optimum[1].MakeAsChar(); UInt32 matchPrice = _isMatch[(_state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice1(); @@ -510,7 +510,7 @@ private UInt32 GetOptimum(UInt32 position, out UInt32 backRes) { UInt32 offs = 0; while (len > _matchDistances[offs]) offs += 2; - for (;; len++) { + for (; ; len++) { UInt32 distance = _matchDistances[offs + 1]; UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState); Optimal optimum = _optimum[len]; @@ -627,9 +627,9 @@ private UInt32 GetOptimum(UInt32 position, out UInt32 backRes) { posState = (position & _posStateMask); UInt32 curAnd1Price = curPrice + - _isMatch[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0() + - _literalEncoder.GetSubCoder(position, _matchFinder.GetIndexByte(0 - 2)). - GetPrice(!state.IsCharState(), matchByte, currentByte); + _isMatch[(state.Index << Base.kNumPosStatesBitsMax) + posState].GetPrice0() + + _literalEncoder.GetSubCoder(position, _matchFinder.GetIndexByte(0 - 2)). + GetPrice(!state.IsCharState(), matchByte, currentByte); Optimal nextOptimum = _optimum[cur + 1]; @@ -645,7 +645,7 @@ private UInt32 GetOptimum(UInt32 position, out UInt32 backRes) { repMatchPrice = matchPrice + _isRep[state.Index].GetPrice1(); if (matchByte == currentByte && - !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0)) { + !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0)) { UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(state, posState); if (shortRepPrice <= nextOptimum.Price) { nextOptimum.Price = shortRepPrice; @@ -672,8 +672,8 @@ private UInt32 GetOptimum(UInt32 position, out UInt32 backRes) { state2.UpdateChar(); UInt32 posStateNext = (position + 1) & _posStateMask; UInt32 nextRepMatchPrice = curAnd1Price + - _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1() + - _isRep[state2.Index].GetPrice1(); + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1() + + _isRep[state2.Index].GetPrice1(); { UInt32 offset = cur + 1 + lenTest2; while (lenEnd < offset) @@ -728,9 +728,9 @@ private UInt32 GetOptimum(UInt32 position, out UInt32 backRes) { repMatchPrice + GetRepPrice(repIndex, lenTest, state, posState) + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice0() + _literalEncoder.GetSubCoder(position + lenTest, - _matchFinder.GetIndexByte((Int32)lenTest - 1 - 1)).GetPrice(true, - _matchFinder.GetIndexByte((Int32)lenTest - 1 - (Int32)(reps[repIndex] + 1)), - _matchFinder.GetIndexByte((Int32)lenTest - 1)); + _matchFinder.GetIndexByte((Int32)lenTest - 1 - 1)).GetPrice(true, + _matchFinder.GetIndexByte((Int32)lenTest - 1 - (Int32)(reps[repIndex] + 1)), + _matchFinder.GetIndexByte((Int32)lenTest - 1)); state2.UpdateChar(); posStateNext = (position + lenTest + 1) & _posStateMask; UInt32 nextMatchPrice = curAndLenCharPrice + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1(); @@ -772,7 +772,7 @@ private UInt32 GetOptimum(UInt32 position, out UInt32 backRes) { while (startLen > _matchDistances[offs]) offs += 2; - for (UInt32 lenTest = startLen;; lenTest++) { + for (UInt32 lenTest = startLen; ; lenTest++) { UInt32 curBack = _matchDistances[offs + 1]; UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(curBack, lenTest, posState); Optimal optimum = _optimum[cur + lenTest]; @@ -792,12 +792,12 @@ private UInt32 GetOptimum(UInt32 position, out UInt32 backRes) { state2.UpdateMatch(); UInt32 posStateNext = (position + lenTest) & _posStateMask; UInt32 curAndLenCharPrice = curAndLenPrice + - _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice0() + - _literalEncoder.GetSubCoder(position + lenTest, - _matchFinder.GetIndexByte((Int32)lenTest - 1 - 1)). - GetPrice(true, - _matchFinder.GetIndexByte((Int32)lenTest - (Int32)(curBack + 1) - 1), - _matchFinder.GetIndexByte((Int32)lenTest - 1)); + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice0() + + _literalEncoder.GetSubCoder(position + lenTest, + _matchFinder.GetIndexByte((Int32)lenTest - 1 - 1)). + GetPrice(true, + _matchFinder.GetIndexByte((Int32)lenTest - (Int32)(curBack + 1) - 1), + _matchFinder.GetIndexByte((Int32)lenTest - 1)); state2.UpdateChar(); posStateNext = (position + lenTest + 1) & _posStateMask; UInt32 nextMatchPrice = curAndLenCharPrice + _isMatch[(state2.Index << Base.kNumPosStatesBitsMax) + posStateNext].GetPrice1(); @@ -966,7 +966,7 @@ public void CodeOneBlock(out Int64 inSize, out Int64 outSize, out bool finished) if (posSlot < Base.kEndPosModelIndex) BitTreeEncoder.ReverseEncode(_posEncoders, - baseVal - posSlot - 1, _rangeEncoder, footerBits, posReduced); + baseVal - posSlot - 1, _rangeEncoder, footerBits, posReduced); else { _rangeEncoder.EncodeDirectBits(posReduced >> Base.kNumAlignBits, footerBits - Base.kNumAlignBits); _posAlignEncoder.ReverseEncode(_rangeEncoder, posReduced & Base.kAlignMask); @@ -1026,7 +1026,7 @@ private void ReleaseStreams() { } private void SetStreams(Stream inStream, Stream outStream, - Int64 inSize, Int64 outSize) { + Int64 inSize, Int64 outSize) { _inStream = inStream; _finished = false; Create(); @@ -1034,10 +1034,10 @@ private void SetStreams(Stream inStream, Stream outStream, Init(); // if (!_fastMode) - { - FillDistancesPrices(); - FillAlignPrices(); - } + { + FillDistancesPrices(); + FillAlignPrices(); + } _lenEncoder.SetTableSize(_numFastBytes + 1 - Base.kMatchMinLen); _lenEncoder.UpdateTables((UInt32)1 << _posStateBits); @@ -1054,7 +1054,7 @@ private void FillDistancesPrices() { var footerBits = (int)((posSlot >> 1) - 1); UInt32 baseVal = ((2 | (posSlot & 1)) << footerBits); tempPrices[i] = BitTreeEncoder.ReverseGetPrice(_posEncoders, - baseVal - posSlot - 1, footerBits, i - baseVal); + baseVal - posSlot - 1, footerBits, i - baseVal); } for (UInt32 lenToPosState = 0; lenToPosState < Base.kNumLenToPosStates; lenToPosState++) { @@ -1328,4 +1328,4 @@ public bool IsShortRep() { }; } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoder.cs b/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoder.cs index e1e9d9145..e2a5375f2 100644 --- a/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoder.cs +++ b/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoder.cs @@ -94,7 +94,7 @@ public void EncodeBit(uint size0, int numTotalBits, uint symbol) { public long GetProcessedSizeAdd() { return _cacheSize + - Stream.Position - StartPosition + 4; + Stream.Position - StartPosition + 4; // (long)Stream.GetProcessedSize(); } @@ -197,4 +197,4 @@ public uint DecodeBit(uint size0, int numTotalBits) { // ulong GetProcessedSize() {return Stream.GetProcessedSize(); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoderBit.cs b/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoderBit.cs index d2b958423..891ec1dfe 100644 --- a/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoderBit.cs +++ b/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoderBit.cs @@ -19,7 +19,7 @@ static BitEncoder() { UInt32 end = (UInt32)1 << (kNumBits - i); for (UInt32 j = start; j < end; j++) ProbPrices[j] = ((UInt32)i << kNumBitPriceShiftBits) + - (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1)); + (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1)); } } @@ -108,4 +108,4 @@ public uint Decode(Decoder rangeDecoder) { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs b/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs index 34ca1604d..7e2b568e5 100644 --- a/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs +++ b/Confuser.Core/LZMA/Compress/RangeCoder/RangeCoderBitTree.cs @@ -61,7 +61,7 @@ public UInt32 ReverseGetPrice(UInt32 symbol) { } public static UInt32 ReverseGetPrice(BitEncoder[] Models, UInt32 startIndex, - int NumBitLevels, UInt32 symbol) { + int NumBitLevels, UInt32 symbol) { UInt32 price = 0; UInt32 m = 1; for (int i = NumBitLevels; i > 0; i--) { @@ -74,7 +74,7 @@ public static UInt32 ReverseGetPrice(BitEncoder[] Models, UInt32 startIndex, } public static void ReverseEncode(BitEncoder[] Models, UInt32 startIndex, - Encoder rangeEncoder, int NumBitLevels, UInt32 symbol) { + Encoder rangeEncoder, int NumBitLevels, UInt32 symbol) { UInt32 m = 1; for (int i = 0; i < NumBitLevels; i++) { UInt32 bit = symbol & 1; @@ -121,7 +121,7 @@ public uint ReverseDecode(Decoder rangeDecoder) { } public static uint ReverseDecode(BitDecoder[] Models, UInt32 startIndex, - Decoder rangeDecoder, int NumBitLevels) { + Decoder rangeDecoder, int NumBitLevels) { uint m = 1; uint symbol = 0; for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++) { @@ -134,4 +134,4 @@ public static uint ReverseDecode(BitDecoder[] Models, UInt32 startIndex, } } -} \ No newline at end of file +} diff --git a/Confuser.Core/LZMA/ICoder.cs b/Confuser.Core/LZMA/ICoder.cs index 439ab2780..60b2c3ea9 100644 --- a/Confuser.Core/LZMA/ICoder.cs +++ b/Confuser.Core/LZMA/ICoder.cs @@ -61,7 +61,7 @@ internal interface ICoder { /// if input stream is not valid /// void Code(Stream inStream, Stream outStream, - Int64 inSize, Int64 outSize, ICodeProgress progress); + Int64 inSize, Int64 outSize, ICodeProgress progress); }; @@ -176,4 +176,4 @@ internal interface ISetDecoderProperties { void SetDecoderProperties(byte[] properties); } -} \ No newline at end of file +} diff --git a/Confuser.Core/Marker.cs b/Confuser.Core/Marker.cs index f77c218c3..889ae036d 100644 --- a/Confuser.Core/Marker.cs +++ b/Confuser.Core/Marker.cs @@ -9,52 +9,52 @@ using dnlib.DotNet; namespace Confuser.Core { - using Rules = Dictionary; - + using Rules = Dictionary; + /// /// Resolves and marks the modules with protection settings according to the rules. /// - public class Marker { + public class Marker { /// /// Annotation key of Strong Name Key. /// - public static readonly object SNKey = new object(); - + public static readonly object SNKey = new object(); + /// /// Annotation key of Strong Name Public Key. - /// - public static readonly object SNPubKey = new object(); - + /// + public static readonly object SNPubKey = new object(); + /// /// Annotation key of Strong Name delay signing. - /// - public static readonly object SNDelaySig = new object(); - + /// + public static readonly object SNDelaySig = new object(); + /// /// Annotation key of Strong Name Signature Key. - /// - public static readonly object SNSigKey = new object(); - + /// + public static readonly object SNSigKey = new object(); + /// /// Annotation key of Strong Name Public Signature Key. - /// - public static readonly object SNSigPubKey = new object(); - + /// + public static readonly object SNSigPubKey = new object(); + /// /// Annotation key of rules. /// - public static readonly object RulesKey = new object(); - + public static readonly object RulesKey = new object(); + /// /// The packers available to use. /// - protected Dictionary packers; - + protected Dictionary packers; + /// /// The protections available to use. /// - protected Dictionary protections; - + protected Dictionary protections; + /// /// Initializes the Marker with specified protections and packers. /// @@ -63,8 +63,8 @@ public class Marker { public virtual void Initialize(IList protections, IList packers) { this.protections = protections.ToDictionary(prot => prot.Id, prot => prot, StringComparer.OrdinalIgnoreCase); this.packers = packers.ToDictionary(packer => packer.Id, packer => packer, StringComparer.OrdinalIgnoreCase); - } - + } + /// /// Fills the protection settings with the specified preset. /// @@ -74,20 +74,20 @@ void FillPreset(ProtectionPreset preset, ProtectionSettings settings) { foreach (Protection prot in protections.Values) if (prot.Preset != ProtectionPreset.None && prot.Preset <= preset && !settings.ContainsKey(prot)) settings.Add(prot, new Dictionary()); - } - + } + public static StrongNamePublicKey LoadSNPubKey(ConfuserContext context, string path) { - if (path == null) return null; - - try { - return new StrongNamePublicKey(path); + if (path == null) return null; + + try { + return new StrongNamePublicKey(path); } catch (Exception ex) { context.Logger.ErrorException("Cannot load the Strong Name Public Key located at: " + path, ex); throw new ConfuserException(ex); - } - } - + } + } + /// /// Loads the Strong Name Key at the specified path with a optional password. /// @@ -102,9 +102,9 @@ public static StrongNameKey LoadSNKey(ConfuserContext context, string path, stri if (path == null) return null; try { - if (pass != null) //pfx - { - // http://stackoverflow.com/a/12196742/462805 + if (pass != null) //pfx + { + // http://stackoverflow.com/a/12196742/462805 var cert = new X509Certificate2(); cert.Import(path, pass, X509KeyStorageFlags.Exportable); @@ -120,8 +120,8 @@ public static StrongNameKey LoadSNKey(ConfuserContext context, string path, stri context.Logger.ErrorException("Cannot load the Strong Name Key located at: " + path, ex); throw new ConfuserException(ex); } - } - + } + /// /// Loads the assembly and marks the project. /// @@ -173,23 +173,23 @@ protected internal virtual MarkerResult MarkProject(ConfuserProject proj, Confus context.Annotations.Set(module.Item2, SNKey, LoadSNKey(context, module.Item1.SNKeyPath == null ? null : Path.Combine(proj.BaseDirectory, module.Item1.SNKeyPath), module.Item1.SNKeyPassword)); context.Annotations.Set(module.Item2, SNSigKey, LoadSNKey(context, module.Item1.SNSigKeyPath == null ? null : Path.Combine(proj.BaseDirectory, module.Item1.SNSigKeyPath), module.Item1.SNSigKeyPassword)); context.Annotations.Set(module.Item2, SNPubKey, LoadSNPubKey(context, module.Item1.SNPubKeyPath == null ? null : Path.Combine(proj.BaseDirectory, module.Item1.SNPubKeyPath))); - context.Annotations.Set(module.Item2, SNSigPubKey, LoadSNPubKey(context, module.Item1.SNPubSigKeyPath == null ? null : Path.Combine(proj.BaseDirectory, module.Item1.SNPubSigKeyPath))); - context.Annotations.Set(module.Item2, SNDelaySig, module.Item1.SNDelaySig); - + context.Annotations.Set(module.Item2, SNSigPubKey, LoadSNPubKey(context, module.Item1.SNPubSigKeyPath == null ? null : Path.Combine(proj.BaseDirectory, module.Item1.SNPubSigKeyPath))); + context.Annotations.Set(module.Item2, SNDelaySig, module.Item1.SNDelaySig); + context.Annotations.Set(module.Item2, RulesKey, rules); foreach (IDnlibDef def in module.Item2.FindDefinitions()) { ApplyRules(context, def, rules); context.CheckCancellation(); - } - - // Packer parameters are stored in modules + } + + // Packer parameters are stored in modules if (packerParams != null) ProtectionParameters.GetParameters(context, module.Item2)[packer] = packerParams; } return new MarkerResult(modules.Select(module => module.Item2).ToList(), packer, extModules); - } - + } + /// /// Marks the member definition. /// @@ -199,8 +199,8 @@ protected internal virtual void MarkMember(IDnlibDef member, ConfuserContext con ModuleDef module = ((IMemberRef)member).Module; var rules = context.Annotations.Get(module, RulesKey); ApplyRules(context, member, rules); - } - + } + /// /// Parses the rules' patterns. /// @@ -230,8 +230,8 @@ protected Rules ParseRules(ConfuserProject proj, ProjectModule module, ConfuserC } } return ret; - } - + } + /// /// Applies the rules to the target definition. /// diff --git a/Confuser.Core/MarkerResult.cs b/Confuser.Core/MarkerResult.cs index ef7e14d82..4a342bcd7 100644 --- a/Confuser.Core/MarkerResult.cs +++ b/Confuser.Core/MarkerResult.cs @@ -37,4 +37,4 @@ public MarkerResult(IList modules, Packer packer, IList ext /// The packer, or null if no packer exists. public Packer Packer { get; private set; } } -} \ No newline at end of file +} diff --git a/Confuser.Core/ModuleSorter.cs b/Confuser.Core/ModuleSorter.cs index e3a94e9fd..d45292174 100644 --- a/Confuser.Core/ModuleSorter.cs +++ b/Confuser.Core/ModuleSorter.cs @@ -19,7 +19,7 @@ public IList Sort() { var edges = new List(); var roots = new HashSet(modules); var asmMap = modules.GroupBy(module => module.Assembly.ToAssemblyRef(), AssemblyNameComparer.CompareAll) - .ToDictionary(gp => gp.Key, gp => gp.ToList(), AssemblyNameComparer.CompareAll); + .ToDictionary(gp => gp.Key, gp => gp.ToList(), AssemblyNameComparer.CompareAll); foreach (ModuleDefMD m in modules) foreach (AssemblyRef nameRef in m.GetAssemblyRefs()) { @@ -74,4 +74,4 @@ public DependencyGraphEdge(ModuleDefMD from, ModuleDefMD to) { public ModuleDefMD To { get; private set; } } } -} \ No newline at end of file +} diff --git a/Confuser.Core/NativeEraser.cs b/Confuser.Core/NativeEraser.cs index 05a7a8887..64d8bf669 100644 --- a/Confuser.Core/NativeEraser.cs +++ b/Confuser.Core/NativeEraser.cs @@ -35,19 +35,19 @@ static void Erase(List> sections, uint methodOffset) { uint f = sect.Item3[methodOffset - sect.Item1]; uint size; switch ((f & 7)) { - case 2: - case 6: - size = (f >> 2) + 1; - break; + case 2: + case 6: + size = (f >> 2) + 1; + break; - case 3: - f |= (uint)((sect.Item3[methodOffset - sect.Item1 + 1]) << 8); - size = (f >> 12) * 4; - uint codeSize = BitConverter.ToUInt32(sect.Item3, (int)(methodOffset - sect.Item1 + 4)); - size += codeSize; - break; - default: - return; + case 3: + f |= (uint)((sect.Item3[methodOffset - sect.Item1 + 1]) << 8); + size = (f >> 12) * 4; + uint codeSize = BitConverter.ToUInt32(sect.Item3, (int)(methodOffset - sect.Item1 + 4)); + size += codeSize; + break; + default: + return; } Erase(sect, methodOffset, size); } diff --git a/Confuser.Core/NullLogger.cs b/Confuser.Core/NullLogger.cs index 9d629a0ce..c40382274 100644 --- a/Confuser.Core/NullLogger.cs +++ b/Confuser.Core/NullLogger.cs @@ -61,4 +61,4 @@ public void BeginModule(ModuleDef module) { } /// public void EndModule(ModuleDef module) { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/ObfAttrMarker.cs b/Confuser.Core/ObfAttrMarker.cs index 0738d5ca4..1c8cb068c 100644 --- a/Confuser.Core/ObfAttrMarker.cs +++ b/Confuser.Core/ObfAttrMarker.cs @@ -146,49 +146,49 @@ static IEnumerable ReadObfuscationAttributes(IHasCusto bool strip = true; foreach (var prop in ca.Properties) { switch (prop.Name) { - case "ApplyToMembers": - Debug.Assert(prop.Type.ElementType == ElementType.Boolean); - info.ApplyToMembers = (bool)prop.Value; - break; - - case "Exclude": - Debug.Assert(prop.Type.ElementType == ElementType.Boolean); - info.Exclude = (bool)prop.Value; - break; - - case "StripAfterObfuscation": - Debug.Assert(prop.Type.ElementType == ElementType.Boolean); - strip = (bool)prop.Value; - break; - - case "Feature": - Debug.Assert(prop.Type.ElementType == ElementType.String); - string feature = (UTF8String)prop.Value; - - var match = OrderPattern.Match(feature); - if (match.Success) { - var orderStr = match.Groups[1].Value; - var f = match.Groups[2].Value; - int o; - if (!int.TryParse(orderStr, out o)) - throw new NotSupportedException(string.Format("Failed to parse feature '{0}' in {1} ", feature, item)); - order = o; - feature = f; - } - - int sepIndex = feature.IndexOf(':'); - if (sepIndex == -1) { - info.FeatureName = ""; - info.FeatureValue = feature; - } - else { - info.FeatureName = feature.Substring(0, sepIndex); - info.FeatureValue = feature.Substring(sepIndex + 1); - } - break; - - default: - throw new NotSupportedException("Unsupported property: " + prop.Name); + case "ApplyToMembers": + Debug.Assert(prop.Type.ElementType == ElementType.Boolean); + info.ApplyToMembers = (bool)prop.Value; + break; + + case "Exclude": + Debug.Assert(prop.Type.ElementType == ElementType.Boolean); + info.Exclude = (bool)prop.Value; + break; + + case "StripAfterObfuscation": + Debug.Assert(prop.Type.ElementType == ElementType.Boolean); + strip = (bool)prop.Value; + break; + + case "Feature": + Debug.Assert(prop.Type.ElementType == ElementType.String); + string feature = (UTF8String)prop.Value; + + var match = OrderPattern.Match(feature); + if (match.Success) { + var orderStr = match.Groups[1].Value; + var f = match.Groups[2].Value; + int o; + if (!int.TryParse(orderStr, out o)) + throw new NotSupportedException(string.Format("Failed to parse feature '{0}' in {1} ", feature, item)); + order = o; + feature = f; + } + + int sepIndex = feature.IndexOf(':'); + if (sepIndex == -1) { + info.FeatureName = ""; + info.FeatureValue = feature; + } + else { + info.FeatureName = feature.Substring(0, sepIndex); + info.FeatureValue = feature.Substring(sepIndex + 1); + } + break; + + default: + throw new NotSupportedException("Unsupported property: " + prop.Name); } } if (strip) diff --git a/Confuser.Core/ObfAttrParser.cs b/Confuser.Core/ObfAttrParser.cs index 32fd91182..11c9bc779 100644 --- a/Confuser.Core/ObfAttrParser.cs +++ b/Confuser.Core/ObfAttrParser.cs @@ -311,4 +311,4 @@ public void ParsePackerString(string str, out Packer packer, out Dictionary protections, IList packers, IList components, Assembly asm) { - foreach(var module in asm.GetLoadedModules()) + foreach (var module in asm.GetLoadedModules()) foreach (var i in module.GetTypes()) { if (i.IsAbstract || !HasAccessibleDefConstructor(i)) continue; diff --git a/Confuser.Core/Project/ConfuserProject.cs b/Confuser.Core/Project/ConfuserProject.cs index 6f0073637..3c0886a8e 100644 --- a/Confuser.Core/Project/ConfuserProject.cs +++ b/Confuser.Core/Project/ConfuserProject.cs @@ -40,13 +40,13 @@ public ProjectModule() { /// /// The password of the strong name private key, or null if not necessary. /// This is the password for the key in - public string SNKeyPassword { get; set; } - + public string SNKeyPassword { get; set; } + /// /// Gets or sets if the generated assembly should be delayed signed. /// - public bool SNDelaySig { get; set; } - + public bool SNDelaySig { get; set; } + /// /// Gets or sets the path to the strong name public key for signing. /// @@ -55,8 +55,8 @@ public ProjectModule() { /// This is only used in enhanced strong name signing and is the public part of the identity key. /// The private part of the key /// - public string SNPubKeyPath { get; set; } - + public string SNPubKeyPath { get; set; } + /// /// Gets or sets the path to the strong name private key used for enhanced signing. /// @@ -67,14 +67,14 @@ public ProjectModule() { /// Gets or sets the password of the strong name private key. /// /// The password of the strong name private key, or null if not necessary. - public string SNSigKeyPassword { get; set; } - + public string SNSigKeyPassword { get; set; } + /// /// Gets or sets the path to the strong name public key used for enhanced signing. /// /// The path to the strong name public key used for enhanced signing, or null if not necessary. - public string SNPubSigKeyPath { get; set; } - + public string SNPubSigKeyPath { get; set; } + /// /// Gets a list of protection rules applies to the module. /// @@ -136,17 +136,17 @@ internal XmlElement Save(XmlDocument xmlDoc) { XmlAttribute snKeyPassAttr = xmlDoc.CreateAttribute("snKeyPass"); snKeyPassAttr.Value = SNKeyPassword; elem.Attributes.Append(snKeyPassAttr); - } + } if (SNDelaySig) { XmlAttribute snKeyAttr = xmlDoc.CreateAttribute("snDelaySig"); snKeyAttr.Value = SNDelaySig ? "true" : "false"; elem.Attributes.Append(snKeyAttr); - } + } if (SNPubKeyPath != null) { XmlAttribute snKeyAttr = xmlDoc.CreateAttribute("snPubKey"); snKeyAttr.Value = SNPubKeyPath; elem.Attributes.Append(snKeyAttr); - } + } if (SNSigKeyPath != null) { XmlAttribute snKeyAttr = xmlDoc.CreateAttribute("snSigKey"); snKeyAttr.Value = SNSigKeyPath; @@ -156,7 +156,7 @@ internal XmlElement Save(XmlDocument xmlDoc) { XmlAttribute snKeyPassAttr = xmlDoc.CreateAttribute("snSigKeyPass"); snKeyPassAttr.Value = SNSigKeyPassword; elem.Attributes.Append(snKeyPassAttr); - } + } if (SNPubSigKeyPath != null) { XmlAttribute snKeyAttr = xmlDoc.CreateAttribute("snPubSigKey"); snKeyAttr.Value = SNPubSigKeyPath; @@ -189,20 +189,20 @@ internal void Load(XmlElement elem) { if (elem.Attributes["snKeyPass"] != null) SNKeyPassword = elem.Attributes["snKeyPass"].Value.NullIfEmpty(); else - SNKeyPassword = null; - - bool delaySig = false; - + SNKeyPassword = null; + + bool delaySig = false; + if (elem.Attributes["snDelaySig"] != null) bool.TryParse(elem.Attributes["snDelaySig"].Value, out delaySig); - SNDelaySig = delaySig; - + SNDelaySig = delaySig; + if (elem.Attributes["snPubKey"] != null) SNPubKeyPath = elem.Attributes["snPubKey"].Value.NullIfEmpty(); else - SNPubKeyPath = null; - + SNPubKeyPath = null; + if (elem.Attributes["snSigKey"] != null) SNSigKeyPath = elem.Attributes["snSigKey"].Value.NullIfEmpty(); else @@ -211,13 +211,13 @@ internal void Load(XmlElement elem) { if (elem.Attributes["snSigKeyPass"] != null) SNSigKeyPassword = elem.Attributes["snSigKeyPass"].Value.NullIfEmpty(); else - SNSigKeyPassword = null; - + SNSigKeyPassword = null; + if (elem.Attributes["snPubSigKey"] != null) SNPubSigKeyPath = elem.Attributes["snPubSigKey"].Value.NullIfEmpty(); else SNPubSigKeyPath = null; - + Rules.Clear(); foreach (XmlElement i in elem.ChildNodes.OfType()) { var rule = new Rule(); @@ -242,10 +242,10 @@ public ProjectModule Clone() { var ret = new ProjectModule(); ret.Path = Path; ret.IsExternal = IsExternal; - ret.SNKeyPath = SNKeyPath; - ret.SNPubKeyPath = SNPubKeyPath; - ret.SNDelaySig = SNDelaySig; - ret.SNPubSigKeyPath = SNPubSigKeyPath; + ret.SNKeyPath = SNKeyPath; + ret.SNPubKeyPath = SNPubKeyPath; + ret.SNDelaySig = SNDelaySig; + ret.SNPubSigKeyPath = SNPubSigKeyPath; ret.SNSigKeyPath = SNSigKeyPath; ret.SNKeyPassword = SNKeyPassword; ret.SNSigKeyPassword = SNSigKeyPassword; @@ -641,8 +641,7 @@ public void Load(XmlDocument doc, string baseDirRoot = null) { OutputDirectory = docElem.Attributes["outputDir"].Value; BaseDirectory = docElem.Attributes["baseDir"].Value; - if (!string.IsNullOrEmpty(baseDirRoot)) - { + if (!string.IsNullOrEmpty(baseDirRoot)) { BaseDirectory = Path.Combine(baseDirRoot, BaseDirectory); } @@ -701,8 +700,7 @@ internal bool IsWildcard(string path) { internal bool BatchLoadModules(XmlElement elem) { string wildCardPath = elem.Attributes["path"].Value; string[] files = Directory.GetFiles(BaseDirectory, wildCardPath, SearchOption.TopDirectoryOnly); - if (files.Length <= 0) - { + if (files.Length <= 0) { return false; } diff --git a/Confuser.Core/Project/InvalidPatternException.cs b/Confuser.Core/Project/InvalidPatternException.cs index e3236454b..208f335eb 100644 --- a/Confuser.Core/Project/InvalidPatternException.cs +++ b/Confuser.Core/Project/InvalidPatternException.cs @@ -23,4 +23,4 @@ public InvalidPatternException(string message) public InvalidPatternException(string message, Exception innerException) : base(message, innerException) { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/PatternParser.cs b/Confuser.Core/Project/PatternParser.cs index 5f894fab2..364ee5b33 100644 --- a/Confuser.Core/Project/PatternParser.cs +++ b/Confuser.Core/Project/PatternParser.cs @@ -122,7 +122,7 @@ PatternExpression ParseExpression(bool readBinOp = false) { if (parens.Type != TokenType.RParens) throw MismatchParens(token.Position.Value); } - break; + break; case TokenType.Identifier: if (IsOperator(token)) { // unary operator @@ -200,4 +200,4 @@ PatternExpression ParseExpression(bool readBinOp = false) { return ret; } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/PatternToken.cs b/Confuser.Core/Project/PatternToken.cs index 39d98e91b..6075e399a 100644 --- a/Confuser.Core/Project/PatternToken.cs +++ b/Confuser.Core/Project/PatternToken.cs @@ -107,4 +107,4 @@ public override string ToString() { return string.Format("[{0}]", Type); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/PatternTokenizer.cs b/Confuser.Core/Project/PatternTokenizer.cs index b2c64b7d5..00e506e19 100644 --- a/Confuser.Core/Project/PatternTokenizer.cs +++ b/Confuser.Core/Project/PatternTokenizer.cs @@ -91,4 +91,4 @@ string ReadIdentifier() { } } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/AndOperator.cs b/Confuser.Core/Project/Patterns/AndOperator.cs index e55f27a90..ac43504cf 100644 --- a/Confuser.Core/Project/Patterns/AndOperator.cs +++ b/Confuser.Core/Project/Patterns/AndOperator.cs @@ -25,4 +25,4 @@ public override object Evaluate(IDnlibDef definition) { return (bool)OperandB.Evaluate(definition); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/DeclTypeFunction.cs b/Confuser.Core/Project/Patterns/DeclTypeFunction.cs index 40af325f0..9d4f15956 100644 --- a/Confuser.Core/Project/Patterns/DeclTypeFunction.cs +++ b/Confuser.Core/Project/Patterns/DeclTypeFunction.cs @@ -26,4 +26,4 @@ public override object Evaluate(IDnlibDef definition) { return ((IMemberDef)definition).DeclaringType.FullName == fullName.ToString(); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/FullNameFunction.cs b/Confuser.Core/Project/Patterns/FullNameFunction.cs index 4fbd7b9d6..fd329336e 100644 --- a/Confuser.Core/Project/Patterns/FullNameFunction.cs +++ b/Confuser.Core/Project/Patterns/FullNameFunction.cs @@ -24,4 +24,4 @@ public override object Evaluate(IDnlibDef definition) { return definition.FullName == name.ToString(); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/HasAttrFunction.cs b/Confuser.Core/Project/Patterns/HasAttrFunction.cs index 8b9c10d7b..d550e69fd 100644 --- a/Confuser.Core/Project/Patterns/HasAttrFunction.cs +++ b/Confuser.Core/Project/Patterns/HasAttrFunction.cs @@ -24,4 +24,4 @@ public override object Evaluate(IDnlibDef definition) { return definition.CustomAttributes.IsDefined(attrName); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/InheritsFunction.cs b/Confuser.Core/Project/Patterns/InheritsFunction.cs index 03734815d..9cbeb3812 100644 --- a/Confuser.Core/Project/Patterns/InheritsFunction.cs +++ b/Confuser.Core/Project/Patterns/InheritsFunction.cs @@ -34,4 +34,4 @@ public override object Evaluate(IDnlibDef definition) { return false; } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/IsTypeFunction.cs b/Confuser.Core/Project/Patterns/IsTypeFunction.cs index 72863629e..3573c6ff9 100644 --- a/Confuser.Core/Project/Patterns/IsTypeFunction.cs +++ b/Confuser.Core/Project/Patterns/IsTypeFunction.cs @@ -56,4 +56,4 @@ public override object Evaluate(IDnlibDef definition) { return Regex.IsMatch(typeType.ToString(), typeRegex); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/LiteralExpression.cs b/Confuser.Core/Project/Patterns/LiteralExpression.cs index e796aaaee..c07ccde24 100644 --- a/Confuser.Core/Project/Patterns/LiteralExpression.cs +++ b/Confuser.Core/Project/Patterns/LiteralExpression.cs @@ -36,4 +36,4 @@ public override void Serialize(IList tokens) { tokens.Add(new PatternToken(TokenType.Literal, Literal.ToString())); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/MatchFunction.cs b/Confuser.Core/Project/Patterns/MatchFunction.cs index 94ff40e38..bbc6122ab 100644 --- a/Confuser.Core/Project/Patterns/MatchFunction.cs +++ b/Confuser.Core/Project/Patterns/MatchFunction.cs @@ -78,4 +78,4 @@ public override object Evaluate(IDnlibDef definition) { return false; } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/MemberTypeFunction.cs b/Confuser.Core/Project/Patterns/MemberTypeFunction.cs index 1dc26f295..3fa20da9a 100644 --- a/Confuser.Core/Project/Patterns/MemberTypeFunction.cs +++ b/Confuser.Core/Project/Patterns/MemberTypeFunction.cs @@ -62,4 +62,4 @@ public override object Evaluate(IDnlibDef definition) { return Regex.IsMatch(memberType.ToString(), typeRegex); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/ModuleFunction.cs b/Confuser.Core/Project/Patterns/ModuleFunction.cs index 4f0b1ba78..1b0d5c375 100644 --- a/Confuser.Core/Project/Patterns/ModuleFunction.cs +++ b/Confuser.Core/Project/Patterns/ModuleFunction.cs @@ -28,4 +28,4 @@ public override object Evaluate(IDnlibDef definition) { return ((IOwnerModule)definition).Module.Name == name.ToString(); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/NameFunction.cs b/Confuser.Core/Project/Patterns/NameFunction.cs index c6d8d49a5..0f18ef2ee 100644 --- a/Confuser.Core/Project/Patterns/NameFunction.cs +++ b/Confuser.Core/Project/Patterns/NameFunction.cs @@ -24,4 +24,4 @@ public override object Evaluate(IDnlibDef definition) { return definition.Name == name.ToString(); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/NamespaceFunction.cs b/Confuser.Core/Project/Patterns/NamespaceFunction.cs index b08708af2..08bfe7fd4 100644 --- a/Confuser.Core/Project/Patterns/NamespaceFunction.cs +++ b/Confuser.Core/Project/Patterns/NamespaceFunction.cs @@ -38,4 +38,4 @@ public override object Evaluate(IDnlibDef definition) { return type != null && Regex.IsMatch(type.Namespace ?? "", ns); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/NotOperator.cs b/Confuser.Core/Project/Patterns/NotOperator.cs index 65dd31f78..f5b289a8c 100644 --- a/Confuser.Core/Project/Patterns/NotOperator.cs +++ b/Confuser.Core/Project/Patterns/NotOperator.cs @@ -23,4 +23,4 @@ public override object Evaluate(IDnlibDef definition) { return !(bool)OperandA.Evaluate(definition); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/OrOperator.cs b/Confuser.Core/Project/Patterns/OrOperator.cs index 112150e91..7bf667bf7 100644 --- a/Confuser.Core/Project/Patterns/OrOperator.cs +++ b/Confuser.Core/Project/Patterns/OrOperator.cs @@ -25,4 +25,4 @@ public override object Evaluate(IDnlibDef definition) { return (bool)OperandB.Evaluate(definition); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/PatternExpression.cs b/Confuser.Core/Project/Patterns/PatternExpression.cs index e0700ef7d..67b90fcbe 100644 --- a/Confuser.Core/Project/Patterns/PatternExpression.cs +++ b/Confuser.Core/Project/Patterns/PatternExpression.cs @@ -20,4 +20,4 @@ public abstract class PatternExpression { /// The output list of tokens. public abstract void Serialize(IList tokens); } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/PatternFunction.cs b/Confuser.Core/Project/Patterns/PatternFunction.cs index 29aeae9d3..b3e266ccc 100644 --- a/Confuser.Core/Project/Patterns/PatternFunction.cs +++ b/Confuser.Core/Project/Patterns/PatternFunction.cs @@ -36,4 +36,4 @@ public override void Serialize(IList tokens) { tokens.Add(new PatternToken(TokenType.RParens)); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Project/Patterns/PatternOperator.cs b/Confuser.Core/Project/Patterns/PatternOperator.cs index 96c9bd652..babc9abb0 100644 --- a/Confuser.Core/Project/Patterns/PatternOperator.cs +++ b/Confuser.Core/Project/Patterns/PatternOperator.cs @@ -43,4 +43,4 @@ public override void Serialize(IList tokens) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Protection.cs b/Confuser.Core/Protection.cs index f7bb08075..c08b78872 100644 --- a/Confuser.Core/Protection.cs +++ b/Confuser.Core/Protection.cs @@ -14,4 +14,4 @@ public abstract class Protection : ConfuserComponent { /// The protection's preset. public abstract ProtectionPreset Preset { get; } } -} \ No newline at end of file +} diff --git a/Confuser.Core/ProtectionDependencyAttributes.cs b/Confuser.Core/ProtectionDependencyAttributes.cs index dabdcaaa9..39524cfda 100644 --- a/Confuser.Core/ProtectionDependencyAttributes.cs +++ b/Confuser.Core/ProtectionDependencyAttributes.cs @@ -40,4 +40,4 @@ public AfterProtectionAttribute(params string[] ids) { /// The IDs of protections. public string[] Ids { get; private set; } } -} \ No newline at end of file +} diff --git a/Confuser.Core/ProtectionParameters.cs b/Confuser.Core/ProtectionParameters.cs index 00a6dfb00..e3fbeb078 100644 --- a/Confuser.Core/ProtectionParameters.cs +++ b/Confuser.Core/ProtectionParameters.cs @@ -98,4 +98,4 @@ public static ProtectionSettings GetParameters( return context.Annotations.Get(target, ParametersKey); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/ProtectionPhase.cs b/Confuser.Core/ProtectionPhase.cs index 69c762410..bef472f46 100644 --- a/Confuser.Core/ProtectionPhase.cs +++ b/Confuser.Core/ProtectionPhase.cs @@ -46,4 +46,4 @@ public virtual bool ProcessAll { /// The parameters of protection. protected internal abstract void Execute(ConfuserContext context, ProtectionParameters parameters); } -} \ No newline at end of file +} diff --git a/Confuser.Core/ProtectionPipeline.cs b/Confuser.Core/ProtectionPipeline.cs index 4146c0a10..79da655dc 100644 --- a/Confuser.Core/ProtectionPipeline.cs +++ b/Confuser.Core/ProtectionPipeline.cs @@ -177,4 +177,4 @@ static IList Filter(ConfuserContext context, IList targets }).ToList(); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/ProtectionPreset.cs b/Confuser.Core/ProtectionPreset.cs index 9a686ba2c..32e8148f4 100644 --- a/Confuser.Core/ProtectionPreset.cs +++ b/Confuser.Core/ProtectionPreset.cs @@ -20,4 +20,4 @@ public enum ProtectionPreset { /// The protection provides strongest security with possible incompatibility. Maximum = 4 } -} \ No newline at end of file +} diff --git a/Confuser.Core/ProtectionSettings.cs b/Confuser.Core/ProtectionSettings.cs index 18b677b25..715ca456a 100644 --- a/Confuser.Core/ProtectionSettings.cs +++ b/Confuser.Core/ProtectionSettings.cs @@ -32,4 +32,4 @@ public bool IsEmpty() { return Count == 0; } } -} \ No newline at end of file +} diff --git a/Confuser.Core/ProtectionTargets.cs b/Confuser.Core/ProtectionTargets.cs index 7b7f3c762..66175db38 100644 --- a/Confuser.Core/ProtectionTargets.cs +++ b/Confuser.Core/ProtectionTargets.cs @@ -30,4 +30,4 @@ public enum ProtectionTargets { /// All definitions (i.e. All member definitions and modules). AllDefinitions = AllMembers | Modules } -} \ No newline at end of file +} diff --git a/Confuser.Core/ServiceRegistry.cs b/Confuser.Core/ServiceRegistry.cs index f3be8a06d..4f3b3d05d 100644 --- a/Confuser.Core/ServiceRegistry.cs +++ b/Confuser.Core/ServiceRegistry.cs @@ -47,4 +47,4 @@ public bool Contains(string serviceId) { return serviceIds.Contains(serviceId); } } -} \ No newline at end of file +} diff --git a/Confuser.Core/Services/CompressionService.cs b/Confuser.Core/Services/CompressionService.cs index 9ab783663..d16543ef9 100644 --- a/Confuser.Core/Services/CompressionService.cs +++ b/Confuser.Core/Services/CompressionService.cs @@ -100,7 +100,7 @@ public byte[] Compress(byte[] data, Action progressFunc = null) { var length = BitConverter.GetBytes(data.Length); if (!BitConverter.IsLittleEndian) Array.Reverse(length); - + // Store 4 byte length value (little-endian) x.Write(length, 0, sizeof(int)); diff --git a/Confuser.Core/Services/MarkerService.cs b/Confuser.Core/Services/MarkerService.cs index f982904b7..d4f849c67 100644 --- a/Confuser.Core/Services/MarkerService.cs +++ b/Confuser.Core/Services/MarkerService.cs @@ -74,4 +74,4 @@ public interface IMarkerService { /// The parent component of the helper, or null if the specified definition is not a helper. ConfuserComponent GetHelperParent(IDnlibDef def); } -} \ No newline at end of file +} diff --git a/Confuser.Core/Services/TraceService.cs b/Confuser.Core/Services/TraceService.cs index 44efd0d0c..c7f57d76f 100644 --- a/Confuser.Core/Services/TraceService.cs +++ b/Confuser.Core/Services/TraceService.cs @@ -8,11 +8,9 @@ namespace Confuser.Core.Services { public sealed class TraceService : ITraceService { readonly Dictionary cache = new Dictionary(); - /// /// Initializes a new instance of the class. /// - /// The working context. public TraceService() { } @@ -224,10 +222,12 @@ public int[] TraceArguments(Instruction instr) { if (push == 0 && pop == 0) { // This instruction isn't doing anything to the stack. Could be a nop or some prefix. // Ignore it and move on to the next. - } else if (Instructions[index].OpCode.Code != Code.Dup) { + } + else if (Instructions[index].OpCode.Code != Code.Dup) { // It's not a duplicate instruction, this is an acceptable start point. break; - } else { + } + else { var prevInstr = Instructions[index - 1]; prevInstr.CalculateStackUsage(Method.HasReturnType, out push, out _); if (push > 0) { @@ -319,7 +319,7 @@ public int[] TraceArguments(Instruction instr) { // To handle things properly we're only using the required amount on the top of the stack. var tmp = evalStack.ToArray(); evalStack.Clear(); - foreach(var idx in tmp.Take(argCount).Reverse()) + foreach (var idx in tmp.Take(argCount).Reverse()) evalStack.Push(idx); } @@ -337,8 +337,7 @@ public int[] TraceArguments(Instruction instr) { return ret; } - public static Stack CopyStack(Stack original) - { + public static Stack CopyStack(Stack original) { var arr = new T[original.Count]; original.CopyTo(arr, 0); Array.Reverse(arr); diff --git a/Confuser.Core/UnreachableException.cs b/Confuser.Core/UnreachableException.cs index a42d0585f..86aed5b7a 100644 --- a/Confuser.Core/UnreachableException.cs +++ b/Confuser.Core/UnreachableException.cs @@ -11,4 +11,4 @@ public class UnreachableException : SystemException { public UnreachableException() : base("Unreachable code reached.") { } } -} \ No newline at end of file +} diff --git a/Confuser.Core/WatermarkingProtection.cs b/Confuser.Core/WatermarkingProtection.cs index 5330bdcb9..1b1cdb967 100644 --- a/Confuser.Core/WatermarkingProtection.cs +++ b/Confuser.Core/WatermarkingProtection.cs @@ -63,7 +63,7 @@ protected internal override void Execute(ConfuserContext context, ProtectionPara MethodSig.CreateInstance(module.CorLibTypes.Void, module.CorLibTypes.String), MethodImplAttributes.Managed, MethodAttributes.HideBySig | MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName) { - Body = new CilBody {MaxStack = 1} + Body = new CilBody { MaxStack = 1 } }; ctor.Body.Instructions.Add(OpCodes.Ldarg_0.ToInstruction()); ctor.Body.Instructions.Add(OpCodes.Call.ToInstruction(new MemberRefUser(module, ".ctor", diff --git a/Confuser.DynCipher/AST/ArrayIndexExpression.cs b/Confuser.DynCipher/AST/ArrayIndexExpression.cs index f08453645..bfecd05cc 100644 --- a/Confuser.DynCipher/AST/ArrayIndexExpression.cs +++ b/Confuser.DynCipher/AST/ArrayIndexExpression.cs @@ -9,4 +9,4 @@ public override string ToString() { return string.Format("{0}[{1}]", Array, Index); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/AssignmentStatement.cs b/Confuser.DynCipher/AST/AssignmentStatement.cs index b02d5c3c2..a281a4cb5 100644 --- a/Confuser.DynCipher/AST/AssignmentStatement.cs +++ b/Confuser.DynCipher/AST/AssignmentStatement.cs @@ -9,4 +9,4 @@ public override string ToString() { return string.Format("{0} = {1};", Target, Value); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/BinOpExpression.cs b/Confuser.DynCipher/AST/BinOpExpression.cs index 10191d5a3..dd1fe3b88 100644 --- a/Confuser.DynCipher/AST/BinOpExpression.cs +++ b/Confuser.DynCipher/AST/BinOpExpression.cs @@ -54,4 +54,4 @@ public override string ToString() { return string.Format("({0} {1} {2})", Left, op, Right); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/Expression.cs b/Confuser.DynCipher/AST/Expression.cs index 144e36799..dadccd125 100644 --- a/Confuser.DynCipher/AST/Expression.cs +++ b/Confuser.DynCipher/AST/Expression.cs @@ -83,4 +83,4 @@ public abstract class Expression { }; } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/LiteralExpression.cs b/Confuser.DynCipher/AST/LiteralExpression.cs index fa6257cde..c0798d2cd 100644 --- a/Confuser.DynCipher/AST/LiteralExpression.cs +++ b/Confuser.DynCipher/AST/LiteralExpression.cs @@ -12,4 +12,4 @@ public override string ToString() { return Value.ToString("x8") + "h"; } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/LoopStatement.cs b/Confuser.DynCipher/AST/LoopStatement.cs index b3fee191c..14ef84051 100644 --- a/Confuser.DynCipher/AST/LoopStatement.cs +++ b/Confuser.DynCipher/AST/LoopStatement.cs @@ -15,4 +15,4 @@ public override string ToString() { return ret.ToString(); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/Statement.cs b/Confuser.DynCipher/AST/Statement.cs index 24f5c5366..ced49d696 100644 --- a/Confuser.DynCipher/AST/Statement.cs +++ b/Confuser.DynCipher/AST/Statement.cs @@ -5,4 +5,4 @@ public abstract class Statement { public object Tag { get; set; } public abstract override string ToString(); } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/StatementBlock.cs b/Confuser.DynCipher/AST/StatementBlock.cs index b209fc317..9d9b715fa 100644 --- a/Confuser.DynCipher/AST/StatementBlock.cs +++ b/Confuser.DynCipher/AST/StatementBlock.cs @@ -19,4 +19,4 @@ public override string ToString() { return sb.ToString(); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/UnaryOpExpression.cs b/Confuser.DynCipher/AST/UnaryOpExpression.cs index 627625a2e..c3c7b2c60 100644 --- a/Confuser.DynCipher/AST/UnaryOpExpression.cs +++ b/Confuser.DynCipher/AST/UnaryOpExpression.cs @@ -25,4 +25,4 @@ public override string ToString() { return op + Value; } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/Variable.cs b/Confuser.DynCipher/AST/Variable.cs index 856f9b081..21237df93 100644 --- a/Confuser.DynCipher/AST/Variable.cs +++ b/Confuser.DynCipher/AST/Variable.cs @@ -13,4 +13,4 @@ public override string ToString() { return Name; } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/AST/VariableExpression.cs b/Confuser.DynCipher/AST/VariableExpression.cs index 1e6836de9..6e561075f 100644 --- a/Confuser.DynCipher/AST/VariableExpression.cs +++ b/Confuser.DynCipher/AST/VariableExpression.cs @@ -8,4 +8,4 @@ public override string ToString() { return Variable.Name; } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Confuser.DynCipher.csproj b/Confuser.DynCipher/Confuser.DynCipher.csproj index 669658e52..17c15479d 100644 --- a/Confuser.DynCipher/Confuser.DynCipher.csproj +++ b/Confuser.DynCipher/Confuser.DynCipher.csproj @@ -4,7 +4,7 @@ - net461;netstandard2.0 + net48;netstandard2.0 true ..\ConfuserEx.snk diff --git a/Confuser.DynCipher/DynCipherComponent.cs b/Confuser.DynCipher/DynCipherComponent.cs index 497f4d316..6a9b819dd 100644 --- a/Confuser.DynCipher/DynCipherComponent.cs +++ b/Confuser.DynCipher/DynCipherComponent.cs @@ -29,4 +29,4 @@ protected override void PopulatePipeline(ProtectionPipeline pipeline) { // } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/DynCipherService.cs b/Confuser.DynCipher/DynCipherService.cs index bba7c4cc7..2362fc5e2 100644 --- a/Confuser.DynCipher/DynCipherService.cs +++ b/Confuser.DynCipher/DynCipherService.cs @@ -18,4 +18,4 @@ public void GenerateExpressionPair(RandomGenerator random, Expression var, Expre ExpressionGenerator.GeneratePair(random, var, result, depth, out expression, out inverse); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Elements/AddKey.cs b/Confuser.DynCipher/Elements/AddKey.cs index 782d3a2cb..d24e7b170 100644 --- a/Confuser.DynCipher/Elements/AddKey.cs +++ b/Confuser.DynCipher/Elements/AddKey.cs @@ -31,4 +31,4 @@ public override void EmitInverse(CipherGenContext context) { EmitCore(context); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Elements/BinOp.cs b/Confuser.DynCipher/Elements/BinOp.cs index 24fe75dd3..0e1bb746e 100644 --- a/Confuser.DynCipher/Elements/BinOp.cs +++ b/Confuser.DynCipher/Elements/BinOp.cs @@ -70,4 +70,4 @@ public override void EmitInverse(CipherGenContext context) { } } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Elements/CryptoElement.cs b/Confuser.DynCipher/Elements/CryptoElement.cs index 6f68c89da..7bfac2f79 100644 --- a/Confuser.DynCipher/Elements/CryptoElement.cs +++ b/Confuser.DynCipher/Elements/CryptoElement.cs @@ -16,4 +16,4 @@ public CryptoElement(int count) { public abstract void Emit(CipherGenContext context); public abstract void EmitInverse(CipherGenContext context); } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Elements/Matrix.cs b/Confuser.DynCipher/Elements/Matrix.cs index ac2268a83..2866958c5 100644 --- a/Confuser.DynCipher/Elements/Matrix.cs +++ b/Confuser.DynCipher/Elements/Matrix.cs @@ -67,11 +67,11 @@ static uint cofactor4(uint[,] mat, int i, int j) { static uint det3(uint[,] mat) { return mat[0, 0] * mat[1, 1] * mat[2, 2] + - mat[0, 1] * mat[1, 2] * mat[2, 0] + - mat[0, 2] * mat[1, 0] * mat[2, 1] - - mat[0, 2] * mat[1, 1] * mat[2, 0] - - mat[0, 1] * mat[1, 0] * mat[2, 2] - - mat[0, 0] * mat[1, 2] * mat[2, 1]; + mat[0, 1] * mat[1, 2] * mat[2, 0] + + mat[0, 2] * mat[1, 0] * mat[2, 1] - + mat[0, 2] * mat[1, 1] * mat[2, 0] - + mat[0, 1] * mat[1, 0] * mat[2, 2] - + mat[0, 0] * mat[1, 2] * mat[2, 1]; } static uint[,] transpose4(uint[,] mat) { @@ -118,10 +118,10 @@ void EmitCore(CipherGenContext context, uint[,] k) { Value = a * l(k[3, 0]) + b * l(k[3, 1]) + c * l(k[3, 2]) + d * l(k[3, 3]), Target = td }) - .Emit(new AssignmentStatement { Value = ta, Target = a }) - .Emit(new AssignmentStatement { Value = tb, Target = b }) - .Emit(new AssignmentStatement { Value = tc, Target = c }) - .Emit(new AssignmentStatement { Value = td, Target = d }); + .Emit(new AssignmentStatement { Value = ta, Target = a }) + .Emit(new AssignmentStatement { Value = tb, Target = b }) + .Emit(new AssignmentStatement { Value = tc, Target = c }) + .Emit(new AssignmentStatement { Value = td, Target = d }); } } @@ -133,4 +133,4 @@ public override void EmitInverse(CipherGenContext context) { EmitCore(context, InverseKey); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Elements/NumOp.cs b/Confuser.DynCipher/Elements/NumOp.cs index edf3d26d6..59b173879 100644 --- a/Confuser.DynCipher/Elements/NumOp.cs +++ b/Confuser.DynCipher/Elements/NumOp.cs @@ -97,4 +97,4 @@ public override void EmitInverse(CipherGenContext context) { } } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Elements/RotateBit.cs b/Confuser.DynCipher/Elements/RotateBit.cs index c71dbb34f..99bebea1c 100644 --- a/Confuser.DynCipher/Elements/RotateBit.cs +++ b/Confuser.DynCipher/Elements/RotateBit.cs @@ -62,4 +62,4 @@ public override void EmitInverse(CipherGenContext context) { } } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Elements/Swap.cs b/Confuser.DynCipher/Elements/Swap.cs index d65000c18..44de37d6c 100644 --- a/Confuser.DynCipher/Elements/Swap.cs +++ b/Confuser.DynCipher/Elements/Swap.cs @@ -72,4 +72,4 @@ public override void EmitInverse(CipherGenContext context) { EmitCore(context); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Generation/CILCodeGen.cs b/Confuser.DynCipher/Generation/CILCodeGen.cs index fbd9a6ad3..0bf103dfb 100644 --- a/Confuser.DynCipher/Generation/CILCodeGen.cs +++ b/Confuser.DynCipher/Generation/CILCodeGen.cs @@ -190,4 +190,4 @@ void EmitStatement(Statement statement) { throw new NotSupportedException(); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Generation/CipherGenContext.cs b/Confuser.DynCipher/Generation/CipherGenContext.cs index 59221655c..1602a8bd3 100644 --- a/Confuser.DynCipher/Generation/CipherGenContext.cs +++ b/Confuser.DynCipher/Generation/CipherGenContext.cs @@ -63,4 +63,4 @@ public void Dispose() { } } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Generation/CipherGenerator.cs b/Confuser.DynCipher/Generation/CipherGenerator.cs index 29fb741f3..34b5e997d 100644 --- a/Confuser.DynCipher/Generation/CipherGenerator.cs +++ b/Confuser.DynCipher/Generation/CipherGenerator.cs @@ -87,4 +87,4 @@ public static void GeneratePair(RandomGenerator random, out StatementBlock encry PostProcessStatements(decrypt, random); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Generation/DMCodeGen.cs b/Confuser.DynCipher/Generation/DMCodeGen.cs index 8d1918cff..d066b6166 100644 --- a/Confuser.DynCipher/Generation/DMCodeGen.cs +++ b/Confuser.DynCipher/Generation/DMCodeGen.cs @@ -196,4 +196,4 @@ void EmitStatement(Statement statement) { throw new NotSupportedException(); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Generation/ExpressionGenerator.cs b/Confuser.DynCipher/Generation/ExpressionGenerator.cs index 4a01dac81..240580ca4 100644 --- a/Confuser.DynCipher/Generation/ExpressionGenerator.cs +++ b/Confuser.DynCipher/Generation/ExpressionGenerator.cs @@ -14,18 +14,18 @@ static Expression GenerateExpression(RandomGenerator random, Expression current, switch ((ExpressionOps)random.NextInt32(6)) { case ExpressionOps.Add: return GenerateExpression(random, current, currentDepth + 1, targetDepth) + - GenerateExpression(random, (LiteralExpression)random.NextUInt32(), currentDepth + 1, targetDepth); + GenerateExpression(random, (LiteralExpression)random.NextUInt32(), currentDepth + 1, targetDepth); case ExpressionOps.Sub: return GenerateExpression(random, current, currentDepth + 1, targetDepth) - - GenerateExpression(random, (LiteralExpression)random.NextUInt32(), currentDepth + 1, targetDepth); + GenerateExpression(random, (LiteralExpression)random.NextUInt32(), currentDepth + 1, targetDepth); case ExpressionOps.Mul: return GenerateExpression(random, current, currentDepth + 1, targetDepth) * (LiteralExpression)(random.NextUInt32() | 1); case ExpressionOps.Xor: return GenerateExpression(random, current, currentDepth + 1, targetDepth) ^ - GenerateExpression(random, (LiteralExpression)random.NextUInt32(), currentDepth + 1, targetDepth); + GenerateExpression(random, (LiteralExpression)random.NextUInt32(), currentDepth + 1, targetDepth); case ExpressionOps.Not: return ~GenerateExpression(random, current, currentDepth + 1, targetDepth); @@ -161,4 +161,4 @@ enum ExpressionOps { Neg } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Generation/x86CodeGen.cs b/Confuser.DynCipher/Generation/x86CodeGen.cs index 363853acd..22611a176 100644 --- a/Confuser.DynCipher/Generation/x86CodeGen.cs +++ b/Confuser.DynCipher/Generation/x86CodeGen.cs @@ -55,8 +55,8 @@ void ReleaseRegister(x86Register reg) { x86Register Normalize(x86Instruction instr) { if (instr.Operands.Length == 2 && - instr.Operands[0] is x86ImmediateOperand && - instr.Operands[1] is x86ImmediateOperand) { + instr.Operands[0] is x86ImmediateOperand && + instr.Operands[1] is x86ImmediateOperand) { /* * op imm1, imm2 * ==> @@ -72,7 +72,7 @@ instr.Operands[0] is x86ImmediateOperand && } if (instr.Operands.Length == 1 && - instr.Operands[0] is x86ImmediateOperand) { + instr.Operands[0] is x86ImmediateOperand) { /* * op imm * ==> @@ -88,8 +88,8 @@ instr.Operands[0] is x86ImmediateOperand && } if (instr.OpCode == x86OpCode.SUB && - instr.Operands[0] is x86ImmediateOperand && - instr.Operands[1] is x86RegisterOperand) { + instr.Operands[0] is x86ImmediateOperand && + instr.Operands[1] is x86RegisterOperand) { /* * sub imm, reg * ==> @@ -108,8 +108,8 @@ instr.Operands[0] is x86ImmediateOperand && } if (instr.Operands.Length == 2 && - instr.Operands[0] is x86ImmediateOperand && - instr.Operands[1] is x86RegisterOperand) { + instr.Operands[0] is x86ImmediateOperand && + instr.Operands[1] is x86RegisterOperand) { /* * op imm, reg * ==> @@ -264,7 +264,7 @@ public byte[] Assemble() { case x86OpCode.MOV: { if (Operands.Length != 2) throw new InvalidOperationException(); if (Operands[0] is x86RegisterOperand && - Operands[1] is x86RegisterOperand) { + Operands[1] is x86RegisterOperand) { var ret = new byte[2]; ret[0] = 0x89; ret[1] = 0xc0; @@ -273,7 +273,7 @@ public byte[] Assemble() { return ret; } if (Operands[0] is x86RegisterOperand && - Operands[1] is x86ImmediateOperand) { + Operands[1] is x86ImmediateOperand) { var ret = new byte[5]; ret[0] = 0xb8; ret[0] |= (byte)((int)(Operands[0] as x86RegisterOperand).Register << 0); @@ -286,7 +286,7 @@ public byte[] Assemble() { case x86OpCode.ADD: { if (Operands.Length != 2) throw new InvalidOperationException(); if (Operands[0] is x86RegisterOperand && - Operands[1] is x86RegisterOperand) { + Operands[1] is x86RegisterOperand) { var ret = new byte[2]; ret[0] = 0x01; ret[1] = 0xc0; @@ -295,7 +295,7 @@ public byte[] Assemble() { return ret; } if (Operands[0] is x86RegisterOperand && - Operands[1] is x86ImmediateOperand) { + Operands[1] is x86ImmediateOperand) { var ret = new byte[6]; ret[0] = 0x81; ret[1] = 0xc0; @@ -309,7 +309,7 @@ public byte[] Assemble() { case x86OpCode.SUB: { if (Operands.Length != 2) throw new InvalidOperationException(); if (Operands[0] is x86RegisterOperand && - Operands[1] is x86RegisterOperand) { + Operands[1] is x86RegisterOperand) { var ret = new byte[2]; ret[0] = 0x29; ret[1] = 0xc0; @@ -318,7 +318,7 @@ public byte[] Assemble() { return ret; } if (Operands[0] is x86RegisterOperand && - Operands[1] is x86ImmediateOperand) { + Operands[1] is x86ImmediateOperand) { var ret = new byte[6]; ret[0] = 0x81; ret[1] = 0xe8; @@ -356,7 +356,7 @@ public byte[] Assemble() { case x86OpCode.XOR: { if (Operands.Length != 2) throw new InvalidOperationException(); if (Operands[0] is x86RegisterOperand && - Operands[1] is x86RegisterOperand) { + Operands[1] is x86RegisterOperand) { var ret = new byte[2]; ret[0] = 0x31; ret[1] = 0xc0; @@ -365,7 +365,7 @@ public byte[] Assemble() { return ret; } if (Operands[0] is x86RegisterOperand && - Operands[1] is x86ImmediateOperand) { + Operands[1] is x86ImmediateOperand) { var ret = new byte[6]; ret[0] = 0x81; ret[1] = 0xf0; @@ -390,7 +390,7 @@ public byte[] Assemble() { case x86OpCode.IMUL: { if (Operands.Length != 2) throw new InvalidOperationException(); if (Operands[0] is x86RegisterOperand && - Operands[1] is x86RegisterOperand) { + Operands[1] is x86RegisterOperand) { var ret = new byte[3]; ret[0] = 0x0f; ret[1] = 0xaf; @@ -400,7 +400,7 @@ public byte[] Assemble() { return ret; } if (Operands[0] is x86RegisterOperand && - Operands[1] is x86ImmediateOperand) { + Operands[1] is x86ImmediateOperand) { var ret = new byte[6]; ret[0] = 0x69; ret[1] = 0xc0; @@ -426,4 +426,4 @@ public override string ToString() { return ret.ToString(); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Transforms/ConvertVariables.cs b/Confuser.DynCipher/Transforms/ConvertVariables.cs index 3e7252611..e7689c6f8 100644 --- a/Confuser.DynCipher/Transforms/ConvertVariables.cs +++ b/Confuser.DynCipher/Transforms/ConvertVariables.cs @@ -38,4 +38,4 @@ public static void Run(StatementBlock block) { block.Statements[i] = ReplaceVar(block.Statements[i], mainBuff); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Transforms/ExpansionTransform.cs b/Confuser.DynCipher/Transforms/ExpansionTransform.cs index f295c2b4b..c3b9d8b36 100644 --- a/Confuser.DynCipher/Transforms/ExpansionTransform.cs +++ b/Confuser.DynCipher/Transforms/ExpansionTransform.cs @@ -10,7 +10,7 @@ static bool ProcessStatement(Statement st, StatementBlock block) { if (assign.Value is BinOpExpression) { var exp = (BinOpExpression)assign.Value; if ((exp.Left is BinOpExpression || exp.Right is BinOpExpression) && - exp.Left != assign.Target) { + exp.Left != assign.Target) { block.Statements.Add(new AssignmentStatement { Target = assign.Target, Value = exp.Left @@ -42,4 +42,4 @@ public static void Run(StatementBlock block) { } while (workDone); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Transforms/MulToShiftTransform.cs b/Confuser.DynCipher/Transforms/MulToShiftTransform.cs index 577000a4d..e7c70f106 100644 --- a/Confuser.DynCipher/Transforms/MulToShiftTransform.cs +++ b/Confuser.DynCipher/Transforms/MulToShiftTransform.cs @@ -67,4 +67,4 @@ public static void Run(StatementBlock block) { ProcessStatement(st); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Transforms/NormalizeBinOpTransform.cs b/Confuser.DynCipher/Transforms/NormalizeBinOpTransform.cs index d565a2e0d..b51ecc414 100644 --- a/Confuser.DynCipher/Transforms/NormalizeBinOpTransform.cs +++ b/Confuser.DynCipher/Transforms/NormalizeBinOpTransform.cs @@ -9,9 +9,9 @@ static Expression ProcessExpression(Expression exp) { var binOpRight = binOp.Right as BinOpExpression; // a + (b + c) => (a + b) + c if (binOpRight != null && binOpRight.Operation == binOp.Operation && - (binOp.Operation == BinOps.Add || binOp.Operation == BinOps.Mul || - binOp.Operation == BinOps.Or || binOp.Operation == BinOps.And || - binOp.Operation == BinOps.Xor)) { + (binOp.Operation == BinOps.Add || binOp.Operation == BinOps.Mul || + binOp.Operation == BinOps.Or || binOp.Operation == BinOps.And || + binOp.Operation == BinOps.Xor)) { binOp.Left = new BinOpExpression { Left = binOp.Left, Operation = binOp.Operation, @@ -24,7 +24,7 @@ static Expression ProcessExpression(Expression exp) { binOp.Right = ProcessExpression(binOp.Right); if (binOp.Right is LiteralExpression && ((LiteralExpression)binOp.Right).Value == 0 && - binOp.Operation == BinOps.Add) // x + 0 => x + binOp.Operation == BinOps.Add) // x + 0 => x return binOp.Left; } else if (exp is ArrayIndexExpression) { @@ -49,4 +49,4 @@ public static void Run(StatementBlock block) { ProcessStatement(st); } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Transforms/ShuffleTransform.cs b/Confuser.DynCipher/Transforms/ShuffleTransform.cs index bd64eef12..dfd578651 100644 --- a/Confuser.DynCipher/Transforms/ShuffleTransform.cs +++ b/Confuser.DynCipher/Transforms/ShuffleTransform.cs @@ -53,7 +53,7 @@ static int SearchUpwardKill(TransformContext context, Statement st, StatementBlo Variable[] definition = context.Definitions[st]; for (int i = startIndex - 1; i >= 0; i--) { if (context.Usages[block.Statements[i]].Intersect(definition).Count() > 0 || - context.Definitions[block.Statements[i]].Intersect(usage).Count() > 0) + context.Definitions[block.Statements[i]].Intersect(usage).Count() > 0) return i; } return 0; @@ -64,7 +64,7 @@ static int SearchDownwardKill(TransformContext context, Statement st, StatementB Variable[] definition = context.Definitions[st]; for (int i = startIndex + 1; i < block.Statements.Count; i++) { if (context.Usages[block.Statements[i]].Intersect(definition).Count() > 0 || - context.Definitions[block.Statements[i]].Intersect(usage).Count() > 0) + context.Definitions[block.Statements[i]].Intersect(usage).Count() > 0) return i; } return block.Statements.Count - 1; @@ -101,4 +101,4 @@ class TransformContext { public Dictionary Usages; } } -} \ No newline at end of file +} diff --git a/Confuser.DynCipher/Utils.cs b/Confuser.DynCipher/Utils.cs index ad22524d5..5bb06d0e8 100644 --- a/Confuser.DynCipher/Utils.cs +++ b/Confuser.DynCipher/Utils.cs @@ -81,4 +81,4 @@ public static byte[] AssembleCode(x86CodeGen codeGen, x86Register reg) { return stream.ToArray(); } } -} \ No newline at end of file +} diff --git a/Confuser.MSBuild.Tasks/Confuser.MSBuild.Tasks.csproj b/Confuser.MSBuild.Tasks/Confuser.MSBuild.Tasks.csproj index 06999b4d3..f6d6c588a 100644 --- a/Confuser.MSBuild.Tasks/Confuser.MSBuild.Tasks.csproj +++ b/Confuser.MSBuild.Tasks/Confuser.MSBuild.Tasks.csproj @@ -4,7 +4,7 @@ - net461;netstandard2.0 + net48;netstandard2.0 true ..\ConfuserEx.snk @@ -25,14 +25,14 @@ - + - + @@ -48,10 +48,10 @@ - + - - + + diff --git a/Confuser.MSBuild.Tasks/CreateProjectTask.cs b/Confuser.MSBuild.Tasks/CreateProjectTask.cs index f962f22e9..fe0e82e0a 100644 --- a/Confuser.MSBuild.Tasks/CreateProjectTask.cs +++ b/Confuser.MSBuild.Tasks/CreateProjectTask.cs @@ -18,14 +18,14 @@ public sealed class CreateProjectTask : Task { public ITaskItem[] SatelliteAssemblyPaths { get; set; } - public ITaskItem KeyFilePath { get; set; } - - public ITaskItem DelaySig { get; set; } - - public ITaskItem PubKeyFilePath { get; set; } - - public ITaskItem SigKeyFilePath { get; set; } - + public ITaskItem KeyFilePath { get; set; } + + public ITaskItem DelaySig { get; set; } + + public ITaskItem PubKeyFilePath { get; set; } + + public ITaskItem SigKeyFilePath { get; set; } + public ITaskItem PubSigKeyFilePath { get; set; } [Required, Output] @@ -43,8 +43,8 @@ public override bool Execute() { } project.BaseDirectory = Path.GetDirectoryName(AssemblyPath.ItemSpec); - var mainModule = GetOrCreateProjectModule(project, AssemblyPath.ItemSpec); - + var mainModule = GetOrCreateProjectModule(project, AssemblyPath.ItemSpec); + if (!string.IsNullOrWhiteSpace(KeyFilePath?.ItemSpec)) { mainModule.SNKeyPath = KeyFilePath.ItemSpec; } @@ -56,7 +56,7 @@ public override bool Execute() { } if (!string.IsNullOrWhiteSpace(PubSigKeyFilePath?.ItemSpec)) { mainModule.SNPubSigKeyPath = PubSigKeyFilePath.ItemSpec; - } + } if (!string.IsNullOrWhiteSpace(DelaySig?.ItemSpec)) { bool.TryParse(DelaySig.ItemSpec, out bool delaySig); mainModule.SNDelaySig = delaySig; diff --git a/Confuser.MSBuild.Tasks/MSBuildLogger.cs b/Confuser.MSBuild.Tasks/MSBuildLogger.cs index c0f81eddb..fdcb2319b 100644 --- a/Confuser.MSBuild.Tasks/MSBuildLogger.cs +++ b/Confuser.MSBuild.Tasks/MSBuildLogger.cs @@ -6,7 +6,7 @@ namespace Confuser.MSBuild.Tasks { internal sealed class MSBuildLogger : ILogger { private readonly TaskLoggingHelper loggingHelper; - + internal bool HasError { get; private set; } internal MSBuildLogger(TaskLoggingHelper loggingHelper) => @@ -18,7 +18,7 @@ void ILogger.DebugFormat(string format, params object[] args) { loggingHelper.LogMessage(MessageImportance.Low, "[DEBUG] " + format, args); } - void ILogger.EndProgress() {} + void ILogger.EndProgress() { } void ILogger.Error(string msg) { loggingHelper.LogError(msg); diff --git a/Confuser.Protections/AntiDumpProtection.cs b/Confuser.Protections/AntiDumpProtection.cs index 77b02700d..78211bce0 100644 --- a/Confuser.Protections/AntiDumpProtection.cs +++ b/Confuser.Protections/AntiDumpProtection.cs @@ -73,4 +73,4 @@ protected override void Execute(ConfuserContext context, ProtectionParameters pa } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/AntiILDasmProtection.cs b/Confuser.Protections/AntiILDasmProtection.cs index 43241c96e..54f34ce0c 100644 --- a/Confuser.Protections/AntiILDasmProtection.cs +++ b/Confuser.Protections/AntiILDasmProtection.cs @@ -59,4 +59,4 @@ protected override void Execute(ConfuserContext context, ProtectionParameters pa } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/AntiTamper/AntiTamperExtensions.cs b/Confuser.Protections/AntiTamper/AntiTamperExtensions.cs index 96740388f..d9683a0a8 100644 --- a/Confuser.Protections/AntiTamper/AntiTamperExtensions.cs +++ b/Confuser.Protections/AntiTamper/AntiTamperExtensions.cs @@ -21,7 +21,7 @@ internal static void InsertBeforeReloc(this List sections, int prefer sections.Insert(relocIndex, newSection); } - private static bool IsRelocSection(PESection section) => + private static bool IsRelocSection(PESection section) => section.Name.Equals(".reloc", StringComparison.Ordinal); } } diff --git a/Confuser.Protections/AntiTamper/DynamicDeriver.cs b/Confuser.Protections/AntiTamper/DynamicDeriver.cs index 0409f9f55..68fcc96b3 100644 --- a/Confuser.Protections/AntiTamper/DynamicDeriver.cs +++ b/Confuser.Protections/AntiTamper/DynamicDeriver.cs @@ -59,4 +59,4 @@ protected override Local Var(Variable var) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/AntiTamper/IKeyDeriver.cs b/Confuser.Protections/AntiTamper/IKeyDeriver.cs index a89fb9592..9dedde9f1 100644 --- a/Confuser.Protections/AntiTamper/IKeyDeriver.cs +++ b/Confuser.Protections/AntiTamper/IKeyDeriver.cs @@ -16,4 +16,4 @@ internal interface IKeyDeriver { uint[] DeriveKey(uint[] a, uint[] b); IEnumerable EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src); } -} \ No newline at end of file +} diff --git a/Confuser.Protections/AntiTamper/IModeHandler.cs b/Confuser.Protections/AntiTamper/IModeHandler.cs index c7ccc660d..502444688 100644 --- a/Confuser.Protections/AntiTamper/IModeHandler.cs +++ b/Confuser.Protections/AntiTamper/IModeHandler.cs @@ -6,4 +6,4 @@ internal interface IModeHandler { void HandleInject(AntiTamperProtection parent, ConfuserContext context, ProtectionParameters parameters); void HandleMD(AntiTamperProtection parent, ConfuserContext context, ProtectionParameters parameters); } -} \ No newline at end of file +} diff --git a/Confuser.Protections/AntiTamper/JITBody.cs b/Confuser.Protections/AntiTamper/JITBody.cs index fcc719f40..f6c799eee 100644 --- a/Confuser.Protections/AntiTamper/JITBody.cs +++ b/Confuser.Protections/AntiTamper/JITBody.cs @@ -104,7 +104,7 @@ public void Serialize(uint token, uint key, byte[] fieldLayout) { counter ^= (state >> 5) | (state << 27); } } - } + } internal class JITMethodBodyWriter : MethodBodyWriterBase { readonly CilBody body; @@ -136,13 +136,13 @@ public void Write() { else jitBody.LocalVars = Array.Empty(); - { - var newCode = new byte[codeSize]; - var writer = new ArrayWriter(newCode); - uint _codeSize = WriteInstructions(ref writer); - Debug.Assert(codeSize == _codeSize); - jitBody.ILCode = newCode; - } + { + var newCode = new byte[codeSize]; + var writer = new ArrayWriter(newCode); + uint _codeSize = WriteInstructions(ref writer); + Debug.Assert(codeSize == _codeSize); + jitBody.ILCode = newCode; + } jitBody.EHs = new JITEHClause[exceptionHandlers.Count]; if (exceptionHandlers.Count > 0) { @@ -176,7 +176,7 @@ public void Write() { } protected override void WriteInlineField(ref ArrayWriter writer, Instruction instr) { - writer.WriteUInt32(metadata.GetToken(instr.Operand).Raw); + writer.WriteUInt32(metadata.GetToken(instr.Operand).Raw); } protected override void WriteInlineMethod(ref ArrayWriter writer, Instruction instr) { @@ -252,4 +252,4 @@ public void PopulateSection(PESection section) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/AntiTamper/NormalDeriver.cs b/Confuser.Protections/AntiTamper/NormalDeriver.cs index 52ac6629f..a4dfb1e34 100644 --- a/Confuser.Protections/AntiTamper/NormalDeriver.cs +++ b/Confuser.Protections/AntiTamper/NormalDeriver.cs @@ -54,4 +54,4 @@ public IEnumerable EmitDerivation(MethodDef method, ConfuserContext } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/AntiTamper/NormalMode.cs b/Confuser.Protections/AntiTamper/NormalMode.cs index ec6313072..7818271aa 100644 --- a/Confuser.Protections/AntiTamper/NormalMode.cs +++ b/Confuser.Protections/AntiTamper/NormalMode.cs @@ -100,8 +100,7 @@ public void HandleMD(AntiTamperProtection parent, ConfuserContext context, Prote } void WriterEvent(object sender, ModuleWriterEventArgs e) { - switch (e.Event) - { + switch (e.Event) { case ModuleWriterEvent.MDEndCreateTables: CreateSections(e.Writer); break; diff --git a/Confuser.Protections/Compress/Compressor.cs b/Confuser.Protections/Compress/Compressor.cs index abbbd13c6..28e8ec5cd 100644 --- a/Confuser.Protections/Compress/Compressor.cs +++ b/Confuser.Protections/Compress/Compressor.cs @@ -82,10 +82,10 @@ protected override void Pack(ConfuserContext context, ProtectionParameters param InjectStub(context, ctx, parameters, stubModule); - var snKey = context.Annotations.Get(originModule, Marker.SNKey); + var snKey = context.Annotations.Get(originModule, Marker.SNKey); var snPubKey = context.Annotations.Get(originModule, Marker.SNPubKey); var snDelaySig = context.Annotations.Get(originModule, Marker.SNDelaySig, false); - var snSigKey = context.Annotations.Get(originModule, Marker.SNSigKey); + var snSigKey = context.Annotations.Get(originModule, Marker.SNSigKey); var snPubSigKey = context.Annotations.Get(originModule, Marker.SNSigPubKey); using (var ms = new MemoryStream()) { @@ -197,7 +197,7 @@ void InjectData(ConfuserContext context, ModuleDef stubModule, MethodDef method, repl.Add(Instruction.Create(OpCodes.Dup)); repl.Add(Instruction.Create(OpCodes.Ldtoken, dataField)); repl.Add(Instruction.Create(OpCodes.Call, stubModule.Import( - context, typeof(RuntimeHelpers), "InitializeArray"))); + context, typeof(RuntimeHelpers), "InitializeArray"))); return repl.ToArray(); }); } @@ -211,14 +211,14 @@ void InjectStub(ConfuserContext context, CompressorContext compCtx, ProtectionPa IEnumerable defs = InjectHelper.Inject(rtType, stubModule.GlobalType, stubModule); switch (parameters.GetParameter(context, context.CurrentModule, "key", Mode.Normal)) { - case Mode.Normal: - compCtx.Deriver = new NormalDeriver(); - break; - case Mode.Dynamic: - compCtx.Deriver = new DynamicDeriver(); - break; - default: - throw new UnreachableException(); + case Mode.Normal: + compCtx.Deriver = new NormalDeriver(); + break; + case Mode.Dynamic: + compCtx.Deriver = new DynamicDeriver(); + break; + default: + throw new UnreachableException(); } compCtx.Deriver.Init(context, random); diff --git a/Confuser.Protections/Compress/DynamicDeriver.cs b/Confuser.Protections/Compress/DynamicDeriver.cs index fb983ecae..753a686da 100644 --- a/Confuser.Protections/Compress/DynamicDeriver.cs +++ b/Confuser.Protections/Compress/DynamicDeriver.cs @@ -59,4 +59,4 @@ protected override Local Var(Variable var) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Compress/IKeyDeriver.cs b/Confuser.Protections/Compress/IKeyDeriver.cs index 5284205ce..8a0161385 100644 --- a/Confuser.Protections/Compress/IKeyDeriver.cs +++ b/Confuser.Protections/Compress/IKeyDeriver.cs @@ -16,4 +16,4 @@ internal interface IKeyDeriver { uint[] DeriveKey(uint[] a, uint[] b); IEnumerable EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src); } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Compress/NormalDeriver.cs b/Confuser.Protections/Compress/NormalDeriver.cs index 27465d7eb..9ac371a2d 100644 --- a/Confuser.Protections/Compress/NormalDeriver.cs +++ b/Confuser.Protections/Compress/NormalDeriver.cs @@ -93,4 +93,4 @@ public IEnumerable EmitDerivation(MethodDef method, ConfuserContext } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Compress/StubProtection.cs b/Confuser.Protections/Compress/StubProtection.cs index 784e9482a..fb14144ae 100644 --- a/Confuser.Protections/Compress/StubProtection.cs +++ b/Confuser.Protections/Compress/StubProtection.cs @@ -106,12 +106,12 @@ protected override void Execute(ConfuserContext context, ProtectionParameters pa MDTable fileTbl = writer.Metadata.TablesHeap.FileTable; uint fileRid = fileTbl.Add(new RawFileRow( - (uint)FileAttributes.ContainsMetadata, - writer.Metadata.StringsHeap.Add("koi"), - hashBlob)); + (uint)FileAttributes.ContainsMetadata, + writer.Metadata.StringsHeap.Add("koi"), + hashBlob)); } }; } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Confuser.Protections.csproj b/Confuser.Protections/Confuser.Protections.csproj index 8584200be..f969fbfb8 100644 --- a/Confuser.Protections/Confuser.Protections.csproj +++ b/Confuser.Protections/Confuser.Protections.csproj @@ -4,7 +4,7 @@ - net461;netstandard2.0 + net48;netstandard2.0 true ..\ConfuserEx.snk @@ -14,14 +14,10 @@ Protections and packers of ConfuserEx - - - - - + diff --git a/Confuser.Protections/Constants/CEContext.cs b/Confuser.Protections/Constants/CEContext.cs index 2928a5770..c6feeb21d 100644 --- a/Confuser.Protections/Constants/CEContext.cs +++ b/Confuser.Protections/Constants/CEContext.cs @@ -44,4 +44,4 @@ internal class DecoderDesc { public byte NumberID; public byte StringID; } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Constants/ConstantProtection.cs b/Confuser.Protections/Constants/ConstantProtection.cs index bfa304746..fe2337a1b 100644 --- a/Confuser.Protections/Constants/ConstantProtection.cs +++ b/Confuser.Protections/Constants/ConstantProtection.cs @@ -48,4 +48,4 @@ protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPostStage(PipelineStage.ProcessModule, new EncodePhase(this)); } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Constants/DynamicMode.cs b/Confuser.Protections/Constants/DynamicMode.cs index 5567904c2..ab9cb341d 100644 --- a/Confuser.Protections/Constants/DynamicMode.cs +++ b/Confuser.Protections/Constants/DynamicMode.cs @@ -79,4 +79,4 @@ protected override Local Var(Variable var) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Constants/EncodeElements.cs b/Confuser.Protections/Constants/EncodeElements.cs index 4adc622ef..d26875533 100644 --- a/Confuser.Protections/Constants/EncodeElements.cs +++ b/Confuser.Protections/Constants/EncodeElements.cs @@ -8,4 +8,4 @@ internal enum EncodeElements { Primitive = 4, Initializers = 8 } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Constants/EncodePhase.cs b/Confuser.Protections/Constants/EncodePhase.cs index ade681d17..c108d14d4 100644 --- a/Confuser.Protections/Constants/EncodePhase.cs +++ b/Confuser.Protections/Constants/EncodePhase.cs @@ -114,8 +114,8 @@ protected override void Execute(ConfuserContext context, ProtectionParameters pa moduleCtx.DataField.HasFieldRVA = true; moduleCtx.DataType.ClassLayout = new ClassLayoutUser(0, (uint)encryptedBuffer.Length); MutationHelper.InjectKeys(moduleCtx.InitMethod, - new[] { 0, 1 }, - new[] { encryptedBuffer.Length / 4, (int)keySeed }); + new[] { 0, 1 }, + new[] { encryptedBuffer.Length / 4, (int)keySeed }); MutationHelper.ReplacePlaceholder(moduleCtx.InitMethod, arg => { var repl = new List(); repl.AddRange(arg); @@ -150,7 +150,7 @@ void EncodeConstant64(CEContext moduleCtx, uint hi, uint lo, TypeSig valueType, if (buffIndex + 1 < moduleCtx.EncodedBuffer.Count && moduleCtx.EncodedBuffer[buffIndex + 1] == hi) break; } while (buffIndex >= 0); - + if (buffIndex == -1) { buffIndex = moduleCtx.EncodedBuffer.Count; moduleCtx.EncodedBuffer.Add(lo); @@ -274,9 +274,9 @@ void ExtractConstants( else if (instr.OpCode == OpCodes.Call && (moduleCtx.Elements & EncodeElements.Initializers) != 0) { var operand = (IMethod)instr.Operand; if (operand.DeclaringType.DefinitionAssembly.IsCorLib() && - operand.DeclaringType.Namespace == "System.Runtime.CompilerServices" && - operand.DeclaringType.Name == "RuntimeHelpers" && - operand.Name == "InitializeArray") { + operand.DeclaringType.Namespace == "System.Runtime.CompilerServices" && + operand.DeclaringType.Name == "RuntimeHelpers" && + operand.Name == "InitializeArray") { IList instrs = method.Body.Instructions; int i = instrs.IndexOf(instr); if (instrs[i - 1].OpCode != OpCodes.Ldtoken) continue; diff --git a/Confuser.Protections/Constants/IEncodeMode.cs b/Confuser.Protections/Constants/IEncodeMode.cs index 9df0aa6e7..a42b2c6a6 100644 --- a/Confuser.Protections/Constants/IEncodeMode.cs +++ b/Confuser.Protections/Constants/IEncodeMode.cs @@ -11,4 +11,4 @@ internal interface IEncodeMode { object CreateDecoder(MethodDef decoder, CEContext ctx); uint Encode(object data, CEContext ctx, uint id); } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Constants/InjectPhase.cs b/Confuser.Protections/Constants/InjectPhase.cs index c8d0c3318..dc23a8091 100644 --- a/Confuser.Protections/Constants/InjectPhase.cs +++ b/Confuser.Protections/Constants/InjectPhase.cs @@ -117,12 +117,12 @@ void InjectHelpers(ConfuserContext context, ICompressionService compression, IRu var method = instr.Operand as IMethod; var field = instr.Operand as IField; if (instr.OpCode == OpCodes.Call && - method.DeclaringType.Name == "Mutation" && - method.Name == "Value") { + method.DeclaringType.Name == "Mutation" && + method.Name == "Value") { decoderInst.Body.Instructions[j] = Instruction.Create(OpCodes.Sizeof, new GenericMVar(0).ToTypeDefOrRef()); } else if (instr.OpCode == OpCodes.Ldsfld && - method.DeclaringType.Name == "Constant") { + method.DeclaringType.Name == "Constant") { if (field.Name == "b") instr.Operand = moduleCtx.BufferField; else throw new UnreachableException(); } @@ -140,8 +140,8 @@ void InjectHelpers(ConfuserContext context, ICompressionService compression, IRu do decoderDesc.InitializerID = (byte)(moduleCtx.Random.NextByte() & 3); while (decoderDesc.InitializerID == decoderDesc.StringID || decoderDesc.InitializerID == decoderDesc.NumberID); MutationHelper.InjectKeys(decoderInst, - new[] { 0, 1, 2 }, - new int[] { decoderDesc.StringID, decoderDesc.NumberID, decoderDesc.InitializerID }); + new[] { 0, 1, 2 }, + new int[] { decoderDesc.StringID, decoderDesc.NumberID, decoderDesc.InitializerID }); decoderDesc.Data = moduleCtx.ModeHandler.CreateDecoder(decoderInst, moduleCtx); moduleCtx.Decoders.Add(Tuple.Create(decoderInst, decoderDesc)); } @@ -155,7 +155,7 @@ void MutateInitializer(CEContext moduleCtx, MethodDef decomp) { var method = instr.Operand as IMethod; if (instr.OpCode == OpCodes.Call) { if (method.DeclaringType.Name == "Mutation" && - method.Name == "Crypt") { + method.Name == "Crypt") { Instruction ldBlock = instrs[i - 2]; Instruction ldKey = instrs[i - 1]; Debug.Assert(ldBlock.OpCode == OpCodes.Ldloc && ldKey.OpCode == OpCodes.Ldloc); @@ -165,7 +165,7 @@ void MutateInitializer(CEContext moduleCtx, MethodDef decomp) { instrs.InsertRange(i - 2, moduleCtx.ModeHandler.EmitDecrypt(moduleCtx.InitMethod, moduleCtx, (Local)ldBlock.Operand, (Local)ldKey.Operand)); } else if (method.DeclaringType.Name == "Lzma" && - method.Name == "Decompress") { + method.Name == "Decompress") { instr.Operand = decomp; } } @@ -175,4 +175,4 @@ void MutateInitializer(CEContext moduleCtx, MethodDef decomp) { moduleCtx.InitMethod.Body.Instructions.Add(instr); } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Constants/Mode.cs b/Confuser.Protections/Constants/Mode.cs index 29cacb71f..e16eb7784 100644 --- a/Confuser.Protections/Constants/Mode.cs +++ b/Confuser.Protections/Constants/Mode.cs @@ -6,4 +6,4 @@ internal enum Mode { Dynamic, x86 } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Constants/NormalMode.cs b/Confuser.Protections/Constants/NormalMode.cs index 473673568..85cda2c0a 100644 --- a/Confuser.Protections/Constants/NormalMode.cs +++ b/Confuser.Protections/Constants/NormalMode.cs @@ -52,4 +52,4 @@ public uint Encode(object data, CEContext ctx, uint id) { return ret; } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Constants/x86Mode.cs b/Confuser.Protections/Constants/x86Mode.cs index 83cadd390..01a5ab28d 100644 --- a/Confuser.Protections/Constants/x86Mode.cs +++ b/Confuser.Protections/Constants/x86Mode.cs @@ -125,20 +125,20 @@ public void Compile(CEContext ctx) { void InjectNativeCode(object sender, ModuleWriterEventArgs e) { var writer = e.Writer; switch (e.Event) { - case ModuleWriterEvent.MDEndWriteMethodBodies: - codeChunk = writer.MethodBodies.Add(new MethodBody(code)); - break; - case ModuleWriterEvent.EndCalculateRvasAndFileOffsets: - uint rid = writer.Metadata.GetRid(native); - var methodRow = writer.Metadata.TablesHeap.MethodTable[rid]; - writer.Metadata.TablesHeap.MethodTable[rid] = new RawMethodRow( - (uint)codeChunk.RVA, - methodRow.ImplFlags, - methodRow.Flags, - methodRow.Name, - methodRow.Signature, - methodRow.ParamList); - break; + case ModuleWriterEvent.MDEndWriteMethodBodies: + codeChunk = writer.MethodBodies.Add(new MethodBody(code)); + break; + case ModuleWriterEvent.EndCalculateRvasAndFileOffsets: + uint rid = writer.Metadata.GetRid(native); + var methodRow = writer.Metadata.TablesHeap.MethodTable[rid]; + writer.Metadata.TablesHeap.MethodTable[rid] = new RawMethodRow( + (uint)codeChunk.RVA, + methodRow.ImplFlags, + methodRow.Flags, + methodRow.Name, + methodRow.Signature, + methodRow.ParamList); + break; } } } diff --git a/Confuser.Protections/ControlFlow/BlockParser.cs b/Confuser.Protections/ControlFlow/BlockParser.cs index 6a4dafd63..529500465 100644 --- a/Confuser.Protections/ControlFlow/BlockParser.cs +++ b/Confuser.Protections/ControlFlow/BlockParser.cs @@ -87,4 +87,4 @@ public static ScopeBlock ParseBody(CilBody body) { return root; } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ControlFlow/Blocks.cs b/Confuser.Protections/ControlFlow/Blocks.cs index 38a35dea9..260914610 100644 --- a/Confuser.Protections/ControlFlow/Blocks.cs +++ b/Confuser.Protections/ControlFlow/Blocks.cs @@ -107,4 +107,4 @@ public override void ToBody(CilBody body) { body.Instructions.Add(instr); } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ControlFlow/CFContext.cs b/Confuser.Protections/ControlFlow/CFContext.cs index 21affaa5a..fba0ea318 100644 --- a/Confuser.Protections/ControlFlow/CFContext.cs +++ b/Confuser.Protections/ControlFlow/CFContext.cs @@ -33,8 +33,8 @@ internal class CFContext { public void AddJump(IList instrs, Instruction target) { if (!Method.Module.IsClr40 && JunkCode && - !Method.DeclaringType.HasGenericParameters && !Method.HasGenericParameters && - (instrs[0].OpCode.FlowControl == FlowControl.Call || instrs[0].OpCode.FlowControl == FlowControl.Next)) { + !Method.DeclaringType.HasGenericParameters && !Method.HasGenericParameters && + (instrs[0].OpCode.FlowControl == FlowControl.Call || instrs[0].OpCode.FlowControl == FlowControl.Next)) { switch (Random.NextInt32(3)) { case 0: instrs.Add(Instruction.Create(OpCodes.Ldc_I4_0)); diff --git a/Confuser.Protections/ControlFlow/ControlFlowProtection.cs b/Confuser.Protections/ControlFlow/ControlFlowProtection.cs index 8a58222a1..24b3d6a6a 100644 --- a/Confuser.Protections/ControlFlow/ControlFlowProtection.cs +++ b/Confuser.Protections/ControlFlow/ControlFlowProtection.cs @@ -45,4 +45,4 @@ protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new ControlFlowPhase(this)); } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ControlFlow/ExpressionPredicate.cs b/Confuser.Protections/ControlFlow/ExpressionPredicate.cs index d9c7d68c5..bca04839e 100644 --- a/Confuser.Protections/ControlFlow/ExpressionPredicate.cs +++ b/Confuser.Protections/ControlFlow/ExpressionPredicate.cs @@ -72,4 +72,4 @@ protected override Local Var(Variable var) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ControlFlow/IPredicate.cs b/Confuser.Protections/ControlFlow/IPredicate.cs index 4dc1152fe..10a328d64 100644 --- a/Confuser.Protections/ControlFlow/IPredicate.cs +++ b/Confuser.Protections/ControlFlow/IPredicate.cs @@ -8,4 +8,4 @@ internal interface IPredicate { void EmitSwitchLoad(IList instrs); int GetSwitchKey(int key); } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ControlFlow/JumpMangler.cs b/Confuser.Protections/ControlFlow/JumpMangler.cs index 5901679f7..3a63435f7 100644 --- a/Confuser.Protections/ControlFlow/JumpMangler.cs +++ b/Confuser.Protections/ControlFlow/JumpMangler.cs @@ -26,13 +26,13 @@ LinkedList SpiltFragments(InstrBlock block, CFContext ctx) { if (block.Instructions[i].OpCode.OpCodeType == OpCodeType.Prefix) { skipCount = 1; } - else if (HasInstructionSeq(block.Instructions, i,Code.Dup, Code.Ldvirtftn, Code.Newobj)) { + else if (HasInstructionSeq(block.Instructions, i, Code.Dup, Code.Ldvirtftn, Code.Newobj)) { skipCount = 2; } - else if (HasInstructionSeq(block.Instructions, i,Code.Ldc_I4, Code.Newarr, Code.Dup, Code.Ldtoken, Code.Call)) { // Array initializer + else if (HasInstructionSeq(block.Instructions, i, Code.Ldc_I4, Code.Newarr, Code.Dup, Code.Ldtoken, Code.Call)) { // Array initializer skipCount = 4; } - else if (HasInstructionSeq(block.Instructions, i,Code.Ldftn, Code.Newobj)) { // Create delegate to function + else if (HasInstructionSeq(block.Instructions, i, Code.Ldftn, Code.Newobj)) { // Create delegate to function skipCount = 1; } currentFragment.Add(block.Instructions[i]); diff --git a/Confuser.Protections/ControlFlow/ManglerBase.cs b/Confuser.Protections/ControlFlow/ManglerBase.cs index 8e42e29f3..95ccebe21 100644 --- a/Confuser.Protections/ControlFlow/ManglerBase.cs +++ b/Confuser.Protections/ControlFlow/ManglerBase.cs @@ -17,4 +17,4 @@ protected static IEnumerable GetAllBlocks(ScopeBlock scope) { public abstract void Mangle(CilBody body, ScopeBlock root, CFContext ctx); } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ControlFlow/NormalPredicate.cs b/Confuser.Protections/ControlFlow/NormalPredicate.cs index 84b808e62..89bb70a51 100644 --- a/Confuser.Protections/ControlFlow/NormalPredicate.cs +++ b/Confuser.Protections/ControlFlow/NormalPredicate.cs @@ -29,4 +29,4 @@ public int GetSwitchKey(int key) { return key ^ xorKey; } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ControlFlow/SwitchMangler.cs b/Confuser.Protections/ControlFlow/SwitchMangler.cs index 7dca5f55c..8357ba2d8 100644 --- a/Confuser.Protections/ControlFlow/SwitchMangler.cs +++ b/Confuser.Protections/ControlFlow/SwitchMangler.cs @@ -145,8 +145,8 @@ LinkedList SpiltStatements(InstrBlock block, Trace trace, CFConte } requiredInstr.Remove(instr); if ((instr.OpCode.OpCodeType != OpCodeType.Prefix && trace.AfterStack[instr.Offset] == 0 && - requiredInstr.Count == 0) && - (shouldSpilt || ctx.Intensity > ctx.Random.NextDouble())) { + requiredInstr.Count == 0) && + (shouldSpilt || ctx.Intensity > ctx.Random.NextDouble())) { statements.AddLast(currentStatement.ToArray()); currentStatement.Clear(); } @@ -257,7 +257,7 @@ public override void Mangle(CilBody body, ScopeBlock root, CFContext ctx) { // Not within current instruction block / targeted in first statement if (srcs.Any(src => src.Offset <= statements.First.Value.Last().Offset || - src.Offset >= block.Instructions.Last().Offset)) + src.Offset >= block.Instructions.Last().Offset)) return true; // Not targeted by the last of statements @@ -304,7 +304,7 @@ public override void Mangle(CilBody body, ScopeBlock root, CFContext ctx) { var target = (Instruction)newStatement.Last().Operand; int brKey; if (!trace.IsBranchTarget(newStatement.Last().Offset) && - statementKeys.TryGetValue(target, out brKey)) { + statementKeys.TryGetValue(target, out brKey)) { var targetKey = predicate != null ? predicate.GetSwitchKey(brKey) : brKey; var unkSrc = hasUnknownSource(newStatement); @@ -335,7 +335,7 @@ public override void Mangle(CilBody body, ScopeBlock root, CFContext ctx) { var target = (Instruction)newStatement.Last().Operand; int brKey; if (!trace.IsBranchTarget(newStatement.Last().Offset) && - statementKeys.TryGetValue(target, out brKey)) { + statementKeys.TryGetValue(target, out brKey)) { bool unkSrc = hasUnknownSource(newStatement); int nextKey = key[i + 1]; OpCode condBr = newStatement.Last().OpCode; diff --git a/Confuser.Protections/ControlFlow/x86Predicate.cs b/Confuser.Protections/ControlFlow/x86Predicate.cs index 1220fbc93..c3ae5b284 100644 --- a/Confuser.Protections/ControlFlow/x86Predicate.cs +++ b/Confuser.Protections/ControlFlow/x86Predicate.cs @@ -95,21 +95,21 @@ public void Compile(CFContext ctx) { void InjectNativeCode(object sender, ModuleWriterEventArgs e) { var writer = e.Writer; switch (e.Event) { - case ModuleWriterEvent.MDEndWriteMethodBodies: - codeChunk = writer.MethodBodies.Add(new MethodBody(code)); - break; - case ModuleWriterEvent.EndCalculateRvasAndFileOffsets: - uint rid = writer.Metadata.GetRid(native); - - var methodRow = writer.Metadata.TablesHeap.MethodTable[rid]; - writer.Metadata.TablesHeap.MethodTable[rid] = new RawMethodRow( - (uint)codeChunk.RVA, - methodRow.ImplFlags, - methodRow.Flags, - methodRow.Name, - methodRow.Signature, - methodRow.ParamList); - break; + case ModuleWriterEvent.MDEndWriteMethodBodies: + codeChunk = writer.MethodBodies.Add(new MethodBody(code)); + break; + case ModuleWriterEvent.EndCalculateRvasAndFileOffsets: + uint rid = writer.Metadata.GetRid(native); + + var methodRow = writer.Metadata.TablesHeap.MethodTable[rid]; + writer.Metadata.TablesHeap.MethodTable[rid] = new RawMethodRow( + (uint)codeChunk.RVA, + methodRow.ImplFlags, + methodRow.Flags, + methodRow.Name, + methodRow.Signature, + methodRow.ParamList); + break; } } } diff --git a/Confuser.Protections/HardeningProtection.cs b/Confuser.Protections/HardeningProtection.cs index 8e4cbfe18..96009c4f1 100644 --- a/Confuser.Protections/HardeningProtection.cs +++ b/Confuser.Protections/HardeningProtection.cs @@ -20,7 +20,7 @@ internal sealed class HardeningProtection : Protection { protected override void Initialize(ConfuserContext context) { } /// - protected override void PopulatePipeline(ProtectionPipeline pipeline) => + protected override void PopulatePipeline(ProtectionPipeline pipeline) => pipeline.InsertPreStage(PipelineStage.OptimizeMethods, new HardeningPhase(this)); /// diff --git a/Confuser.Protections/ReferenceProxy/ExpressionEncoding.cs b/Confuser.Protections/ReferenceProxy/ExpressionEncoding.cs index 07a0719a7..f33a749be 100644 --- a/Confuser.Protections/ReferenceProxy/ExpressionEncoding.cs +++ b/Confuser.Protections/ReferenceProxy/ExpressionEncoding.cs @@ -67,4 +67,4 @@ protected override void LoadVar(Variable var) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ReferenceProxy/IRPEncoding.cs b/Confuser.Protections/ReferenceProxy/IRPEncoding.cs index 0c16e6270..113b3fb20 100644 --- a/Confuser.Protections/ReferenceProxy/IRPEncoding.cs +++ b/Confuser.Protections/ReferenceProxy/IRPEncoding.cs @@ -7,4 +7,4 @@ internal interface IRPEncoding { Instruction[] EmitDecode(MethodDef init, RPContext ctx, Instruction[] arg); int Encode(MethodDef init, RPContext ctx, int value); } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ReferenceProxy/MildMode.cs b/Confuser.Protections/ReferenceProxy/MildMode.cs index fc5c2f169..3a1edd1e3 100644 --- a/Confuser.Protections/ReferenceProxy/MildMode.cs +++ b/Confuser.Protections/ReferenceProxy/MildMode.cs @@ -73,4 +73,4 @@ public override void ProcessCall(RPContext ctx, int instrIndex) { public override void Finalize(RPContext ctx) { } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ReferenceProxy/NormalEncoding.cs b/Confuser.Protections/ReferenceProxy/NormalEncoding.cs index addf48a80..4e7e37663 100644 --- a/Confuser.Protections/ReferenceProxy/NormalEncoding.cs +++ b/Confuser.Protections/ReferenceProxy/NormalEncoding.cs @@ -38,4 +38,4 @@ Tuple GetKey(RandomGenerator random, MethodDef init) { return ret; } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ReferenceProxy/RPContext.cs b/Confuser.Protections/ReferenceProxy/RPContext.cs index 40a5b6560..ec6ceb4eb 100644 --- a/Confuser.Protections/ReferenceProxy/RPContext.cs +++ b/Confuser.Protections/ReferenceProxy/RPContext.cs @@ -42,4 +42,4 @@ internal class RPContext { public RandomGenerator Random; public bool TypeErasure; } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ReferenceProxy/RPMode.cs b/Confuser.Protections/ReferenceProxy/RPMode.cs index 66c040d32..4eee183f4 100644 --- a/Confuser.Protections/ReferenceProxy/RPMode.cs +++ b/Confuser.Protections/ReferenceProxy/RPMode.cs @@ -89,4 +89,4 @@ protected static TypeDef GetDelegateType(RPContext ctx, MethodSig sig) { return ret; } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ReferenceProxy/ReferenceProxyPhase.cs b/Confuser.Protections/ReferenceProxy/ReferenceProxyPhase.cs index 98e0c8bb5..3e299f2fa 100644 --- a/Confuser.Protections/ReferenceProxy/ReferenceProxyPhase.cs +++ b/Confuser.Protections/ReferenceProxy/ReferenceProxyPhase.cs @@ -35,11 +35,11 @@ RPContext ParseParameters(MethodDef method, ConfuserContext context, ProtectionP ret.Body = method.Body; ret.BranchTargets = new HashSet( method.Body.Instructions - .Select(instr => instr.Operand as Instruction) - .Concat(method.Body.Instructions - .Where(instr => instr.Operand is Instruction[]) - .SelectMany(instr => (Instruction[])instr.Operand)) - .Where(target => target != null)); + .Select(instr => instr.Operand as Instruction) + .Concat(method.Body.Instructions + .Where(instr => instr.Operand is Instruction[]) + .SelectMany(instr => (Instruction[])instr.Operand)) + .Where(target => target != null)); ret.Protection = (ReferenceProxyProtection)Parent; ret.Random = store.random; diff --git a/Confuser.Protections/ReferenceProxy/ReferenceProxyProtection.cs b/Confuser.Protections/ReferenceProxy/ReferenceProxyProtection.cs index 7a5ecc57b..37f175a11 100644 --- a/Confuser.Protections/ReferenceProxy/ReferenceProxyProtection.cs +++ b/Confuser.Protections/ReferenceProxy/ReferenceProxyProtection.cs @@ -60,4 +60,4 @@ protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.ProcessModule, new ReferenceProxyPhase(this)); } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/ReferenceProxy/StrongMode.cs b/Confuser.Protections/ReferenceProxy/StrongMode.cs index 766c777cc..ced9a081c 100644 --- a/Confuser.Protections/ReferenceProxy/StrongMode.cs +++ b/Confuser.Protections/ReferenceProxy/StrongMode.cs @@ -151,14 +151,14 @@ void ProcessInvoke(RPContext ctx, int instrIndex, int argBeginIndex) { // Insert field load & replace instruction if (argBeginIndex == instrIndex) { ctx.Body.Instructions.Insert(instrIndex + 1, - new Instruction(OpCodes.Call, delegateType.FindMethod("Invoke"))); + new Instruction(OpCodes.Call, delegateType.FindMethod("Invoke"))); instr.OpCode = OpCodes.Ldsfld; instr.Operand = proxy.Item1; } else { Instruction argBegin = ctx.Body.Instructions[argBeginIndex]; ctx.Body.Instructions.Insert(argBeginIndex + 1, - new Instruction(argBegin.OpCode, argBegin.Operand)); + new Instruction(argBegin.OpCode, argBegin.Operand)); argBegin.OpCode = OpCodes.Ldsfld; argBegin.Operand = proxy.Item1; diff --git a/Confuser.Protections/ReferenceProxy/x86Encoding.cs b/Confuser.Protections/ReferenceProxy/x86Encoding.cs index 726b3b458..370878f46 100644 --- a/Confuser.Protections/ReferenceProxy/x86Encoding.cs +++ b/Confuser.Protections/ReferenceProxy/x86Encoding.cs @@ -81,14 +81,14 @@ void InjectNativeCode(object sender, ModuleWriterEventArgs e) { else if (e.Event == ModuleWriterEvent.EndCalculateRvasAndFileOffsets) { foreach (var native in nativeCodes) { uint rid = writer.Metadata.GetRid(native.Item1); - RawMethodRow methodRow = writer.Metadata.TablesHeap.MethodTable[rid]; - writer.Metadata.TablesHeap.MethodTable[rid] = new RawMethodRow( - (uint)native.Item3.RVA, - methodRow.ImplFlags, - methodRow.Flags, - methodRow.Name, - methodRow.Signature, - methodRow.ParamList); + RawMethodRow methodRow = writer.Metadata.TablesHeap.MethodTable[rid]; + writer.Metadata.TablesHeap.MethodTable[rid] = new RawMethodRow( + (uint)native.Item3.RVA, + methodRow.ImplFlags, + methodRow.Flags, + methodRow.Name, + methodRow.Signature, + methodRow.ParamList); } } } @@ -122,4 +122,4 @@ protected override void LoadVar(Variable var) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Resources/DynamicMode.cs b/Confuser.Protections/Resources/DynamicMode.cs index 69522b6cd..2ab0a63ca 100644 --- a/Confuser.Protections/Resources/DynamicMode.cs +++ b/Confuser.Protections/Resources/DynamicMode.cs @@ -54,4 +54,4 @@ protected override Local Var(Variable var) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Resources/IEncodeMode.cs b/Confuser.Protections/Resources/IEncodeMode.cs index 5fd04c23f..a73c50cc9 100644 --- a/Confuser.Protections/Resources/IEncodeMode.cs +++ b/Confuser.Protections/Resources/IEncodeMode.cs @@ -8,4 +8,4 @@ internal interface IEncodeMode { IEnumerable EmitDecrypt(MethodDef init, REContext ctx, Local block, Local key); uint[] Encrypt(uint[] data, int offset, uint[] key); } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Resources/InjectPhase.cs b/Confuser.Protections/Resources/InjectPhase.cs index aa07f7d05..3d086568b 100644 --- a/Confuser.Protections/Resources/InjectPhase.cs +++ b/Confuser.Protections/Resources/InjectPhase.cs @@ -28,7 +28,7 @@ protected override void Execute(ConfuserContext context, ProtectionParameters pa if (parameters.Targets.Any()) { if (!UTF8String.IsNullOrEmpty(context.CurrentModule.Assembly.Culture)) { context.Logger.DebugFormat("Skipping resource encryption for satellite assembly '{0}'.", - context.CurrentModule.Assembly.FullName); + context.CurrentModule.Assembly.FullName); return; } var compression = context.Registry.GetService(); @@ -112,7 +112,7 @@ void MutateInitializer(REContext moduleCtx, MethodDef decomp) { var method = instr.Operand as IMethod; if (instr.OpCode == OpCodes.Call) { if (method.DeclaringType.Name == "Mutation" && - method.Name == "Crypt") { + method.Name == "Crypt") { Instruction ldBlock = instrs[i - 2]; Instruction ldKey = instrs[i - 1]; Debug.Assert(ldBlock.OpCode == OpCodes.Ldloc && ldKey.OpCode == OpCodes.Ldloc); @@ -122,7 +122,7 @@ void MutateInitializer(REContext moduleCtx, MethodDef decomp) { instrs.InsertRange(i - 2, moduleCtx.ModeHandler.EmitDecrypt(moduleCtx.InitMethod, moduleCtx, (Local)ldBlock.Operand, (Local)ldKey.Operand)); } else if (method.DeclaringType.Name == "Lzma" && - method.Name == "Decompress") { + method.Name == "Decompress") { instr.Operand = decomp; } } diff --git a/Confuser.Protections/Resources/MDPhase.cs b/Confuser.Protections/Resources/MDPhase.cs index 13f6b8b73..0f676cd26 100644 --- a/Confuser.Protections/Resources/MDPhase.cs +++ b/Confuser.Protections/Resources/MDPhase.cs @@ -38,10 +38,10 @@ void OnWriterEvent(object sender, ModuleWriterEventArgs e) { // move resources string asmName = ctx.Name.RandomName(RenameMode.Letters); PublicKey pubKey = null; - if (writer.TheOptions.StrongNamePublicKey != null) + if (writer.TheOptions.StrongNamePublicKey != null) pubKey = PublicKeyBase.CreatePublicKey(writer.TheOptions.StrongNamePublicKey.CreatePublicKey()); else if (writer.TheOptions.StrongNameKey != null) - pubKey = PublicKeyBase.CreatePublicKey(writer.TheOptions.StrongNameKey.PublicKey); + pubKey = PublicKeyBase.CreatePublicKey(writer.TheOptions.StrongNameKey.PublicKey); var assembly = new AssemblyDefUser(asmName, new Version(0, 0), pubKey); assembly.Modules.Add(new ModuleDefUser(asmName + ".dll")); ModuleDef module = assembly.ManifestModule; diff --git a/Confuser.Protections/Resources/Mode.cs b/Confuser.Protections/Resources/Mode.cs index f32d31386..858f36647 100644 --- a/Confuser.Protections/Resources/Mode.cs +++ b/Confuser.Protections/Resources/Mode.cs @@ -5,4 +5,4 @@ internal enum Mode { Normal, Dynamic } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Resources/NormalMode.cs b/Confuser.Protections/Resources/NormalMode.cs index bd37689d3..67512e9e9 100644 --- a/Confuser.Protections/Resources/NormalMode.cs +++ b/Confuser.Protections/Resources/NormalMode.cs @@ -27,4 +27,4 @@ public uint[] Encrypt(uint[] data, int offset, uint[] key) { return ret; } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Resources/REContext.cs b/Confuser.Protections/Resources/REContext.cs index 0166c8b38..bbb4bc762 100644 --- a/Confuser.Protections/Resources/REContext.cs +++ b/Confuser.Protections/Resources/REContext.cs @@ -22,4 +22,4 @@ internal class REContext { public INameService Name; public RandomGenerator Random; } -} \ No newline at end of file +} diff --git a/Confuser.Protections/Resources/ResourceProtection.cs b/Confuser.Protections/Resources/ResourceProtection.cs index a572bf079..d6c5f8e29 100644 --- a/Confuser.Protections/Resources/ResourceProtection.cs +++ b/Confuser.Protections/Resources/ResourceProtection.cs @@ -35,4 +35,4 @@ protected override void PopulatePipeline(ProtectionPipeline pipeline) { pipeline.InsertPreStage(PipelineStage.ProcessModule, new InjectPhase(this)); } } -} \ No newline at end of file +} diff --git a/Confuser.Protections/TypeScrambler/AnalyzePhase.cs b/Confuser.Protections/TypeScrambler/AnalyzePhase.cs index a24328485..fbec05899 100644 --- a/Confuser.Protections/TypeScrambler/AnalyzePhase.cs +++ b/Confuser.Protections/TypeScrambler/AnalyzePhase.cs @@ -6,7 +6,7 @@ namespace Confuser.Protections.TypeScrambler { internal sealed class AnalyzePhase : ProtectionPhase { - public AnalyzePhase(TypeScrambleProtection parent) : base(parent) {} + public AnalyzePhase(TypeScrambleProtection parent) : base(parent) { } public override ProtectionTargets Targets => ProtectionTargets.Types | ProtectionTargets.Methods; diff --git a/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/ContextAnalyzer`1.cs b/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/ContextAnalyzer`1.cs index 8aaec6fe9..4114b246d 100644 --- a/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/ContextAnalyzer`1.cs +++ b/Confuser.Protections/TypeScrambler/Scrambler/Analyzers/ContextAnalyzer`1.cs @@ -5,7 +5,7 @@ namespace Confuser.Protections.TypeScrambler.Scrambler.Analyzers { internal abstract class ContextAnalyzer : ContextAnalyzer { internal override Type TargetType() => typeof(T); internal abstract void Process(ScannedMethod method, Instruction instruction, T operand); - internal override void ProcessOperand(ScannedMethod method, Instruction instruction, object operand) => + internal override void ProcessOperand(ScannedMethod method, Instruction instruction, object operand) => Process(method, instruction, (T)operand); } } diff --git a/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/InstructionRewriterFactory.cs b/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/InstructionRewriterFactory.cs index 0960ab670..a3e3dbe45 100644 --- a/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/InstructionRewriterFactory.cs +++ b/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/InstructionRewriterFactory.cs @@ -7,7 +7,7 @@ namespace Confuser.Protections.TypeScrambler.Scrambler.Rewriter.Instructions { internal sealed class InstructionRewriterFactory : IEnumerable { - private IDictionary RewriterDefinitions { get; } + private IDictionary RewriterDefinitions { get; } = new Dictionary(); internal void Add(InstructionRewriter i) { diff --git a/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/MethodSpecInstructionRewriter.cs b/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/MethodSpecInstructionRewriter.cs index c6f1a3547..6bdb10880 100644 --- a/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/MethodSpecInstructionRewriter.cs +++ b/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/MethodSpecInstructionRewriter.cs @@ -20,7 +20,8 @@ internal override void ProcessOperand(TypeService service, MethodDef method, ILi if (operandScanned?.IsScambled == true) { operand.GenericInstMethodSig = operandScanned.CreateGenericMethodSig(current, service, operand.GenericInstMethodSig); } - } else if (current?.IsScambled == true) { + } + else if (current?.IsScambled == true) { var generics = operand.GenericInstMethodSig.GenericArguments.Select(x => current.ConvertToGenericIfAvalible(x)); operand.GenericInstMethodSig = new GenericInstMethodSig(generics.ToArray()); } diff --git a/Confuser.Protections/TypeScrambler/Scrambler/ScannedMethod.cs b/Confuser.Protections/TypeScrambler/Scrambler/ScannedMethod.cs index 800658159..06d2e3c26 100644 --- a/Confuser.Protections/TypeScrambler/Scrambler/ScannedMethod.cs +++ b/Confuser.Protections/TypeScrambler/Scrambler/ScannedMethod.cs @@ -42,7 +42,7 @@ internal override void Scan() { if (TargetMethod.HasReturnType) { RegisterGeneric(TargetMethod.ReturnType); } - + foreach (var param in TargetMethod.Parameters.Where(ProcessParameter)) RegisterGeneric(param.Type); @@ -155,13 +155,16 @@ internal GenericInstMethodSig CreateGenericMethodSig(ScannedMethod from, TypeSer $"{nameof(number)} < {nameof(original)}.GenericArguments.Count"); var originalArgument = original.GenericArguments[(int)number]; types.Add(originalArgument); - } else if (from?.IsScambled == true) { + } + else if (from?.IsScambled == true) { types.Add(from.ConvertToGenericIfAvalible(trueType)); - } else if (trueType.ToTypeDefOrRef() is TypeDef def) { + } + else if (trueType.ToTypeDefOrRef() is TypeDef def) { // I am sure there are cleaner and better ways to do this. var item = srv.GetItem(def); types.Add(item?.IsScambled == true ? item.CreateGenericTypeSig(null) : trueType); - } else { + } + else { types.Add(trueType); } } diff --git a/Confuser.Renamer/AnalyzePhase.cs b/Confuser.Renamer/AnalyzePhase.cs index efd1ae693..4d95e27d1 100644 --- a/Confuser.Renamer/AnalyzePhase.cs +++ b/Confuser.Renamer/AnalyzePhase.cs @@ -262,7 +262,7 @@ void Analyze(NameService service, ConfuserContext context, ProtectionParameters void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, PropertyDef property) { if (IsVisibleOutside(context, parameters, property.DeclaringType) && - (property.IsFamily() || property.IsFamilyOrAssembly() || property.IsPublic()) && + (property.IsFamily() || property.IsFamilyOrAssembly() || property.IsPublic()) && IsVisibleOutside(context, parameters, property)) service.SetCanRename(property, false); @@ -284,7 +284,7 @@ void Analyze(NameService service, ConfuserContext context, ProtectionParameters void Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, EventDef evt) { if (IsVisibleOutside(context, parameters, evt.DeclaringType) && - (evt.IsFamily() || evt.IsFamilyOrAssembly() || evt.IsPublic()) && + (evt.IsFamily() || evt.IsFamilyOrAssembly() || evt.IsPublic()) && IsVisibleOutside(context, parameters, evt)) service.SetCanRename(evt, false); diff --git a/Confuser.Renamer/Analyzers/CaliburnAnalyzer.cs b/Confuser.Renamer/Analyzers/CaliburnAnalyzer.cs index 6e6d33262..3e01d5fc8 100644 --- a/Confuser.Renamer/Analyzers/CaliburnAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/CaliburnAnalyzer.cs @@ -113,4 +113,4 @@ public void PostRename(ConfuserContext context, INameService service, Protection // } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/Analyzers/InterReferenceAnalyzer.cs b/Confuser.Renamer/Analyzers/InterReferenceAnalyzer.cs index 9ea0ea8b6..47cbeccfb 100644 --- a/Confuser.Renamer/Analyzers/InterReferenceAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/InterReferenceAnalyzer.cs @@ -15,7 +15,7 @@ public void Analyze(ConfuserContext context, INameService service, ProtectionPar // MemberRef/MethodSpec var methods = module.GetTypes().SelectMany(type => type.Methods); - foreach(var methodDef in methods) { + foreach (var methodDef in methods) { foreach (var ov in methodDef.Overrides) { ProcessMemberRef(context, service, module, ov.MethodBody); ProcessMemberRef(context, service, module, ov.MethodDeclaration); diff --git a/Confuser.Renamer/Analyzers/JsonAnalyzer.cs b/Confuser.Renamer/Analyzers/JsonAnalyzer.cs index 6903400ad..6b0b2ee44 100644 --- a/Confuser.Renamer/Analyzers/JsonAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/JsonAnalyzer.cs @@ -120,4 +120,4 @@ public void PostRename(ConfuserContext context, INameService service, Protection // } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/Analyzers/LdtokenEnumAnalyzer.cs b/Confuser.Renamer/Analyzers/LdtokenEnumAnalyzer.cs index e652d5a3f..abdee514f 100644 --- a/Confuser.Renamer/Analyzers/LdtokenEnumAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/LdtokenEnumAnalyzer.cs @@ -40,7 +40,7 @@ public void Analyze(ConfuserContext context, INameService service, ProtectionPar if (!(instr.Operand is TypeSpec)) { TypeDef type = ((ITypeDefOrRef)instr.Operand).ResolveTypeDefThrow(); if (context.Modules.Contains((ModuleDefMD)type.Module) && - HandleTypeOf(context, service, method, i)) { + HandleTypeOf(context, service, method, i)) { var t = type; do { DisableRename(service, t, false); @@ -53,7 +53,7 @@ public void Analyze(ConfuserContext context, INameService service, ProtectionPar throw new UnreachableException(); } else if ((instr.OpCode.Code == Code.Call || instr.OpCode.Code == Code.Callvirt) && - ((IMethod)instr.Operand).Name == "ToString") { + ((IMethod)instr.Operand).Name == "ToString") { HandleEnum(context, service, method, i); } else if (instr.OpCode.Code == Code.Ldstr) { @@ -75,7 +75,7 @@ public void PostRename(ConfuserContext context, INameService service, Protection void HandleEnum(ConfuserContext context, INameService service, MethodDef method, int index) { var target = (IMethod)method.Body.Instructions[index].Operand; if (target.FullName == "System.String System.Object::ToString()" || - target.FullName == "System.String System.Enum::ToString(System.String)") { + target.FullName == "System.String System.Enum::ToString(System.String)") { int prevIndex = index - 1; while (prevIndex >= 0 && method.Body.Instructions[prevIndex].OpCode.Code == Code.Nop) prevIndex--; @@ -139,8 +139,8 @@ bool HandleTypeOf(ConfuserContext context, INameService service, MethodDef metho if (operand.Name.StartsWith("Get") || operand.Name == "InvokeMember") return true; if (operand.Name == "get_AssemblyQualifiedName" || - operand.Name == "get_FullName" || - operand.Name == "get_Namespace") + operand.Name == "get_FullName" || + operand.Name == "get_Namespace") return true; return false; case "System.Reflection.MemberInfo": @@ -183,4 +183,4 @@ void DisableRename(INameService service, TypeDef typeDef, bool memberOnly = true DisableRename(service, nested, false); } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/Analyzers/ManifestResourceAnalyzer.cs b/Confuser.Renamer/Analyzers/ManifestResourceAnalyzer.cs index 636386cfa..6a911d0b4 100644 --- a/Confuser.Renamer/Analyzers/ManifestResourceAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/ManifestResourceAnalyzer.cs @@ -24,9 +24,9 @@ public static void PreRename(ModuleDef currentModule, ITraceService trace, Metho for (var i = 0; i < instructions.Count; i++) { var instruction = instructions[i]; if (instruction.OpCode != OpCodes.Callvirt || - !(instruction.Operand is IMethodDefOrRef targetMethodDefOrRef) || - !UTF8String.Equals(targetMethodDefOrRef.Name, "GetManifestResourceStream") || - !UTF8String.Equals(targetMethodDefOrRef.DeclaringType.FullName, "System.Reflection.Assembly")) continue; + !(instruction.Operand is IMethodDefOrRef targetMethodDefOrRef) || + !UTF8String.Equals(targetMethodDefOrRef.Name, "GetManifestResourceStream") || + !UTF8String.Equals(targetMethodDefOrRef.DeclaringType.FullName, "System.Reflection.Assembly")) continue; var targetMethodDef = targetMethodDefOrRef.ResolveMethodDefThrow(); if (targetMethodDef.Parameters.Count != 3) continue; @@ -38,18 +38,18 @@ public static void PreRename(ModuleDef currentModule, ITraceService trace, Metho var resNameInstruction = instructions[argumentIdx[2]]; if (typeLoadInstruction.OpCode != OpCodes.Call || - !(typeLoadInstruction.Operand is IMethodDefOrRef loadTypeMethodRef) || - !UTF8String.Equals(loadTypeMethodRef.Name, "GetTypeFromHandle") || - !UTF8String.Equals(loadTypeMethodRef.DeclaringType.FullName, "System.Type")) continue; + !(typeLoadInstruction.Operand is IMethodDefOrRef loadTypeMethodRef) || + !UTF8String.Equals(loadTypeMethodRef.Name, "GetTypeFromHandle") || + !UTF8String.Equals(loadTypeMethodRef.DeclaringType.FullName, "System.Type")) continue; if (resNameInstruction.OpCode != OpCodes.Ldstr || - !(resNameInstruction.Operand is string resName)) continue; + !(resNameInstruction.Operand is string resName)) continue; var typeLoadArguments = methodTrace.Value.TraceArguments(typeLoadInstruction); if (typeLoadArguments.Length != 1) continue; var typeTokenLoadInstruction = instructions[typeLoadArguments[0]]; if (typeTokenLoadInstruction.OpCode != OpCodes.Ldtoken || - !(typeTokenLoadInstruction.Operand is ITypeDefOrRef refTypeDefOrRef)) continue; + !(typeTokenLoadInstruction.Operand is ITypeDefOrRef refTypeDefOrRef)) continue; var resourceName = refTypeDefOrRef.Namespace + '.' + resName; @@ -58,7 +58,7 @@ public static void PreRename(ModuleDef currentModule, ITraceService trace, Metho var expectedSig = MethodSig.CreateInstance(getManifestMethodDef.MethodSig.RetType, getManifestMethodDef.MethodSig.Params.Last()); var newMethodDef = assemblyTypeDef.FindMethod("GetManifestResourceStream", expectedSig); var newMethodRef = currentModule.Import(newMethodDef); - + resNameInstruction.Operand = resourceName; instruction.Operand = newMethodRef; diff --git a/Confuser.Renamer/Analyzers/ReflectionAnalyzer.cs b/Confuser.Renamer/Analyzers/ReflectionAnalyzer.cs index 0ed42f279..5deeeaa4a 100644 --- a/Confuser.Renamer/Analyzers/ReflectionAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/ReflectionAnalyzer.cs @@ -50,7 +50,7 @@ MethodTrace GetMethodTrace() { var arguments = trace.TraceArguments(instr); if (arguments == null) { logger.WarnFormat(Resources.ReflectionAnalyzer_Analyze_TracingArgumentsFailed, calledMethod.FullName, method.FullName); - } + } else if (arguments.Length >= 2) { var types = GetReferencedTypes(method.Body.Instructions[arguments[0]], method, trace); var names = GetReferencedNames(method.Body.Instructions[arguments[1]]); @@ -61,7 +61,7 @@ MethodTrace GetMethodTrace() { foreach (var possibleMember in types.SelectMany(GetTypeAndBaseTypes).SelectMany(getMember).Where(m => names.Contains(m.Name))) { nameService.SetCanRename(possibleMember, false); if (!(possibleMember is IMethod) && !(possibleMember is PropertyDef) && !(possibleMember is EventDef)) continue; - + foreach (var reference in nameService.GetReferences(possibleMember).OfType()) { nameService.SetCanRename(reference.BaseMemberDef, false); } diff --git a/Confuser.Renamer/Analyzers/VTableAnalyzer.cs b/Confuser.Renamer/Analyzers/VTableAnalyzer.cs index d1510fd3f..288f4195c 100644 --- a/Confuser.Renamer/Analyzers/VTableAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/VTableAnalyzer.cs @@ -1,390 +1,390 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using Confuser.Core; -using Confuser.Renamer.References; -using dnlib.DotNet; - -namespace Confuser.Renamer.Analyzers { - public class VTableAnalyzer : IRenamer { - void IRenamer.Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { - switch (def) { - case TypeDef typeDef: - Analyze(service, context.Modules, typeDef); - break; - case MethodDef methodDef: - Analyze(service, context.Modules, methodDef); - break; - } - } - - public static void Analyze(INameService service, ICollection modules, TypeDef type) { - if (type.IsInterface) - return; - - var vTbl = service.GetVTables()[type]; - foreach (var ifaceVTbl in vTbl.InterfaceSlots.Values) { - foreach (var slot in ifaceVTbl) { - if (slot.Overrides == null) - continue; - Debug.Assert(slot.Overrides.MethodDef.DeclaringType.IsInterface); - // A method in base type can implements an interface method for a - // derived type. If the base type/interface is not in our control, we should - // not rename the methods. - bool baseUnderCtrl = modules.Contains(slot.MethodDef.DeclaringType.Module as ModuleDefMD); - bool interfaceUnderCtrl = modules.Contains(slot.Overrides.MethodDef.DeclaringType.Module as ModuleDefMD); - if (!baseUnderCtrl && interfaceUnderCtrl || !service.CanRename(slot.MethodDef)) { - service.SetCanRename(slot.Overrides.MethodDef, false); - } - else if ((baseUnderCtrl && !interfaceUnderCtrl) || (!service.CanRename(slot.Overrides.MethodDef))) { - service.SetCanRename(slot.MethodDef, false); - } - - // Now it is possible that the method implementing the interface, belongs to the base class. - // If that happens the methods analyzing the methods will not pick up on this. We'll mark that - // case here. - if (!TypeEqualityComparer.Instance.Equals(slot.MethodDef.DeclaringType, type)) { - SetupOverwriteReferences(service, modules, slot, type); - - // If required, create the sibling references, so the names of the interfaces line up correctly. - var existingReferences = service.GetReferences(slot.MethodDef); - var overrideDef = existingReferences - .OfType() - .FirstOrDefault(r => !MethodEqualityComparer.CompareDeclaringTypes.Equals(r.BaseMemberDef as MethodDef, slot.Overrides.MethodDef)); - - if (!(overrideDef is null)) { - var baseMemberDef = overrideDef.BaseMemberDef; - CreateSiblingReference(slot.Overrides.MethodDef, ref baseMemberDef, service); - } - } - - // For the case when method in base type implements an interface method for a derived type - // do not consider method parameters to make method name the same in base type, derived type and interface - var methodDef = slot.MethodDef; - var typeDef = type.BaseType?.ResolveTypeDef(); - var baseMethod = typeDef?.FindMethod(methodDef.Name, methodDef.Signature as MethodSig); - if (baseMethod != null) { - string unifiedName = service.GetNormalizedName(slot.Overrides.MethodDef); - service.SetNormalizedName(slot.MethodDef, unifiedName); - service.SetNormalizedName(baseMethod, unifiedName); - } - } - } - } - - public static void Analyze(INameService service, ICollection modules, MethodDef method) { - if (!method.IsVirtual) - return; - - IMemberDef discoveredBaseMemberDef = null; - MethodDef discoveredBaseMethodDef = null; - - bool doesOverridePropertyOrEvent = false; - var methodProp = method.DeclaringType.Properties.Where(p => BelongsToProperty(p, method)); - foreach (var prop in methodProp) { - foreach (var baseMethodDef in FindBaseDeclarations(service, method)) { - var basePropDef = baseMethodDef.DeclaringType.Properties. - FirstOrDefault(p => BelongsToProperty(p, baseMethodDef) && String.Equals(p.Name, prop.Name, StringComparison.Ordinal)); - - if (basePropDef is null) continue; - - // Name of property has to line up. - CreateOverrideReference(service, prop, basePropDef); - CreateSiblingReference(basePropDef, ref discoveredBaseMemberDef, service); - - // Method names have to line up as well (otherwise inheriting attributes does not work). - CreateOverrideReference(service, method, baseMethodDef); - CreateSiblingReference(baseMethodDef, ref discoveredBaseMethodDef, service); - - doesOverridePropertyOrEvent = true; - } - } - - discoveredBaseMemberDef = null; - discoveredBaseMethodDef = null; - - var methodEvent = method.DeclaringType.Events.Where(e => BelongsToEvent(e, method)); - foreach (var evt in methodEvent) { - foreach (var baseMethodDef in FindBaseDeclarations(service, method)) { - var baseEventDef = baseMethodDef.DeclaringType.Events. - FirstOrDefault(e => BelongsToEvent(e, baseMethodDef) && String.Equals(e.Name, evt.Name, StringComparison.Ordinal)); - - if (baseEventDef is null) continue; - - // Name of event has to line up. - CreateOverrideReference(service, evt, baseEventDef); - CreateSiblingReference(baseEventDef, ref discoveredBaseMemberDef, service); - - // Method names have to line up as well (otherwise inheriting attributes does not work). - CreateOverrideReference(service, method, baseMethodDef); - CreateSiblingReference(baseMethodDef, ref discoveredBaseMethodDef, service); - - doesOverridePropertyOrEvent = true; - } - } - - if (!method.IsAbstract) { - var vTbl = service.GetVTables()[method.DeclaringType]; - var slots = vTbl.FindSlots(method).ToArray(); - - foreach (var slot in slots) { - if (slot.Overrides == null) - continue; - - SetupOverwriteReferences(service, modules, slot, method.DeclaringType); - } - } - else if (!doesOverridePropertyOrEvent) { - foreach (var baseMethodDef in FindBaseDeclarations(service, method)) { - CreateOverrideReference(service, method, baseMethodDef); - } - } - } - - static void CreateSiblingReference(T baseMemberDef, ref T discoveredBaseMemberDef, INameService service) where T : class, IMemberDef { - if (discoveredBaseMemberDef is null) - discoveredBaseMemberDef = baseMemberDef; - else { - var references = service.GetReferences(discoveredBaseMemberDef) - .OfType() - .ToArray(); - if (references.Length > 0) { - discoveredBaseMemberDef = (T)references[0].OldestSiblingDef; - foreach (var siblingRef in references.Skip(1)) { - // Redirect all the siblings to the new oldest reference - RedirectSiblingReferences(siblingRef.OldestSiblingDef, discoveredBaseMemberDef, service); - } - } - - // Check if the discovered base type is the current type. If so, nothing needs to be done. - if (ReferenceEquals(baseMemberDef, discoveredBaseMemberDef)) return; - - var reference = new MemberSiblingReference(baseMemberDef, discoveredBaseMemberDef); - service.AddReference(baseMemberDef, reference); - service.AddReference(discoveredBaseMemberDef, reference); - UpdateOldestSiblingReference(discoveredBaseMemberDef, baseMemberDef, service); - } - } - - static void UpdateOldestSiblingReference(IMemberDef oldestSiblingMemberDef, IMemberDef basePropDef, INameService service) { - var reverseReference = service.GetReferences(oldestSiblingMemberDef).OfType() - .SingleOrDefault(); - if (reverseReference is null) { - service.AddReference(oldestSiblingMemberDef, new MemberOldestSiblingReference(oldestSiblingMemberDef, basePropDef)); - PropagateRenamingRestrictions(service, oldestSiblingMemberDef, basePropDef); - } - else if (!reverseReference.OtherSiblings.Contains(basePropDef)) { - reverseReference.OtherSiblings.Add(basePropDef); - PropagateRenamingRestrictions(service, reverseReference.OtherSiblings); - } - } - - static void RedirectSiblingReferences(IMemberDef oldMemberDef, IMemberDef newMemberDef, INameService service) { - if (ReferenceEquals(oldMemberDef, newMemberDef)) return; - - var referencesToUpdate = service.GetReferences(oldMemberDef) - .OfType() - .SelectMany(r => r.OtherSiblings) - .SelectMany(service.GetReferences) - .OfType() - .Where(r => ReferenceEquals(r.OldestSiblingDef, oldMemberDef)); - - foreach (var reference in referencesToUpdate) { - reference.OldestSiblingDef = newMemberDef; - UpdateOldestSiblingReference(newMemberDef, reference.ThisMemberDef, service); - } - UpdateOldestSiblingReference(newMemberDef, oldMemberDef, service); - } - - static void CreateOverrideReference(INameService service, IMemberDef thisMemberDef, IMemberDef baseMemberDef) { - var overrideRef = new MemberOverrideReference(thisMemberDef, baseMemberDef); - service.AddReference(thisMemberDef, overrideRef); - service.AddReference(baseMemberDef, overrideRef); - - PropagateRenamingRestrictions(service, thisMemberDef, baseMemberDef); - } - - static void PropagateRenamingRestrictions(INameService service, params object[] objects) => - PropagateRenamingRestrictions(service, (IList)objects); - - static void PropagateRenamingRestrictions(INameService service, IList objects) { - if (!objects.All(service.CanRename)) { - foreach (var o in objects) { - service.SetCanRename(o, false); - } - } - else { - var minimalRenamingLevel = objects.Max(service.GetRenameMode); - foreach (var o in objects) { - service.ReduceRenameMode(o, minimalRenamingLevel); - } - } - } - - private static IEnumerable FindBaseDeclarations(INameService service, MethodDef method) { - var unprocessed = new Queue(); - unprocessed.Enqueue(method); - - var vTables = service.GetVTables(); - - while (unprocessed.Any()) { - var currentMethod = unprocessed.Dequeue(); - - var vTbl = vTables[currentMethod.DeclaringType]; - var slots = vTbl.FindSlots(currentMethod).Where(s => s.Overrides != null); - - bool slotsExists = false; - foreach (var slot in slots) { - unprocessed.Enqueue(slot.Overrides.MethodDef); - slotsExists = true; - } - - if (!slotsExists && method != currentMethod) - yield return currentMethod; - } - } - - private static bool BelongsToProperty(PropertyDef propertyDef, MethodDef methodDef) => - propertyDef.GetMethods.Contains(methodDef) || propertyDef.SetMethods.Contains(methodDef) || - (propertyDef.HasOtherMethods && propertyDef.OtherMethods.Contains(methodDef)); - - private static bool BelongsToEvent(EventDef eventDef, MethodDef methodDef) => - Equals(eventDef.AddMethod, methodDef) || Equals(eventDef.RemoveMethod, methodDef) || Equals(eventDef.InvokeMethod, methodDef) || - (eventDef.HasOtherMethods && eventDef.OtherMethods.Contains(methodDef)); - - private static void AddImportReference(INameService service, ICollection modules, ModuleDef module, MethodDef method, MemberRef methodRef) { - if (method.Module != module && modules.Contains((ModuleDefMD)module)) { - var declType = (TypeRef)methodRef.DeclaringType.ScopeType; - service.AddReference(method.DeclaringType, new TypeRefReference(declType, method.DeclaringType)); - service.AddReference(method, new MemberRefReference(methodRef, method)); - - var typeRefs = methodRef.MethodSig.Params.SelectMany(param => param.FindTypeRefs()).ToList(); - typeRefs.AddRange(methodRef.MethodSig.RetType.FindTypeRefs()); - typeRefs.AddRange(methodRef.DeclaringType.ToTypeSig().FindTypeRefs()); - foreach (var typeRef in typeRefs) { - SetupTypeReference(service, modules, module, typeRef); - } - } - } - - private static void SetupTypeReference(INameService service, ICollection modules, ModuleDef module, ITypeDefOrRef typeDefOrRef) { - if (!(typeDefOrRef is TypeRef typeRef)) return; - - var def = typeRef.ResolveTypeDef(); - if (!(def is null) && def.Module != module && modules.Contains((ModuleDefMD)def.Module)) - service.AddReference(def, new TypeRefReference(typeRef, def)); - } - - private static void SetupSignatureReferences(INameService service, ICollection modules, - ModuleDef module, GenericInstSig typeSig) { - SetupSignatureReferences(service, modules, module, typeSig.GenericType); - foreach (var genericArgument in typeSig.GenericArguments) - SetupSignatureReferences(service, modules, module, genericArgument); - } - - private static void SetupSignatureReferences(INameService service, ICollection modules, ModuleDef module, TypeSig typeSig) { - var asTypeRef = typeSig.TryGetTypeRef(); - if (asTypeRef != null) { - SetupTypeReference(service, modules, module, asTypeRef); - } - } - - private static void SetupOverwriteReferences(INameService service, ICollection modules, VTableSlot slot, TypeDef thisType) { - var module = thisType.Module; - var methodDef = slot.MethodDef; - var baseSlot = slot.Overrides; - var baseMethodDef = baseSlot.MethodDef; - - var overrideRef = new OverrideDirectiveReference(slot, baseSlot); - service.AddReference(methodDef, overrideRef); - service.AddReference(slot.Overrides.MethodDef, overrideRef); - - var importer = new Importer(module, ImporterOptions.TryToUseTypeDefs); - - IMethodDefOrRef target; - if (baseSlot.MethodDefDeclType is GenericInstSig declType) { - MemberRef targetRef = new MemberRefUser(module, baseMethodDef.Name, baseMethodDef.MethodSig, declType.ToTypeDefOrRef()); - targetRef = importer.Import(targetRef); - service.AddReference(baseMethodDef, new MemberRefReference(targetRef, baseMethodDef)); - SetupSignatureReferences(service, modules, module, targetRef.DeclaringType.ToTypeSig() as GenericInstSig); - - target = targetRef; - } - else { - target = baseMethodDef; - if (target.Module != module) { - target = (IMethodDefOrRef)importer.Import(baseMethodDef); - if (target is MemberRef memberRef) - service.AddReference(baseMethodDef, new MemberRefReference(memberRef, baseMethodDef)); - } - } - - if (target is MemberRef methodRef) - AddImportReference(service, modules, module, baseMethodDef, methodRef); - - if (TypeEqualityComparer.Instance.Equals(methodDef.DeclaringType, thisType)) { - if (methodDef.Overrides.Any(impl => IsMatchingOverride(impl, target))) - return; - - methodDef.Overrides.Add(new MethodOverride(methodDef, target)); - } - else if (target is IMemberDef targetDef) { - // Reaching this place means that a slot of the base type is overwritten by a specific interface. - // In case the this type is implementing the interface responsible for this, we need to declare - // this as an override reference. If the base type is implementing the interface (as well), this - // declaration is redundant. - var overrideRefRequired = true; - if (targetDef.DeclaringType.IsInterface) { - var baseTypeDef = thisType.BaseType?.ResolveTypeDef(); - if (!(baseTypeDef is null)) { - var baseTypeVTable = service.GetVTables()[baseTypeDef]; - if (baseTypeVTable.InterfaceSlots.TryGetValue(targetDef.DeclaringType.ToTypeSig(), out var ifcSlots)) { - overrideRefRequired = !ifcSlots.Contains(slot); - } - } - } - if (overrideRefRequired) - CreateOverrideReference(service, methodDef, targetDef); - } - } - - private static bool IsMatchingOverride(MethodOverride methodOverride, IMethodDefOrRef targetMethod) { - SigComparer comparer = default; - - var targetDeclTypeDef = targetMethod.DeclaringType.ResolveTypeDef(); - var overrideDeclTypeDef = methodOverride.MethodDeclaration.DeclaringType.ResolveTypeDef(); - if (!comparer.Equals(targetDeclTypeDef, overrideDeclTypeDef)) - return false; - - var targetMethodSig = targetMethod.MethodSig; - var overrideMethodSig = methodOverride.MethodDeclaration.MethodSig; - - targetMethodSig = ResolveGenericSignature(targetMethod, targetMethodSig); - overrideMethodSig = ResolveGenericSignature(methodOverride.MethodDeclaration, overrideMethodSig); - - return comparer.Equals(targetMethodSig, overrideMethodSig); - } - - static MethodSig ResolveGenericSignature(IMemberRef method, MethodSig overrideMethodSig) { - if (method.DeclaringType is TypeSpec spec && spec.TypeSig is GenericInstSig genericInstSig) { - overrideMethodSig = GenericArgumentResolver.Resolve(overrideMethodSig, genericInstSig.GenericArguments); - } - - return overrideMethodSig; - } - - public void PreRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { - // - } - - public void PostRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { - var method = def as MethodDef; - if (method == null || !method.IsVirtual || method.Overrides.Count == 0) - return; - - method.Overrides - .RemoveWhere(impl => MethodEqualityComparer.CompareDeclaringTypes.Equals(impl.MethodDeclaration, method)); - } - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Confuser.Core; +using Confuser.Renamer.References; +using dnlib.DotNet; + +namespace Confuser.Renamer.Analyzers { + public class VTableAnalyzer : IRenamer { + void IRenamer.Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { + switch (def) { + case TypeDef typeDef: + Analyze(service, context.Modules, typeDef); + break; + case MethodDef methodDef: + Analyze(service, context.Modules, methodDef); + break; + } + } + + public static void Analyze(INameService service, ICollection modules, TypeDef type) { + if (type.IsInterface) + return; + + var vTbl = service.GetVTables()[type]; + foreach (var ifaceVTbl in vTbl.InterfaceSlots.Values) { + foreach (var slot in ifaceVTbl) { + if (slot.Overrides == null) + continue; + Debug.Assert(slot.Overrides.MethodDef.DeclaringType.IsInterface); + // A method in base type can implements an interface method for a + // derived type. If the base type/interface is not in our control, we should + // not rename the methods. + bool baseUnderCtrl = modules.Contains(slot.MethodDef.DeclaringType.Module as ModuleDefMD); + bool interfaceUnderCtrl = modules.Contains(slot.Overrides.MethodDef.DeclaringType.Module as ModuleDefMD); + if (!baseUnderCtrl && interfaceUnderCtrl || !service.CanRename(slot.MethodDef)) { + service.SetCanRename(slot.Overrides.MethodDef, false); + } + else if ((baseUnderCtrl && !interfaceUnderCtrl) || (!service.CanRename(slot.Overrides.MethodDef))) { + service.SetCanRename(slot.MethodDef, false); + } + + // Now it is possible that the method implementing the interface, belongs to the base class. + // If that happens the methods analyzing the methods will not pick up on this. We'll mark that + // case here. + if (!TypeEqualityComparer.Instance.Equals(slot.MethodDef.DeclaringType, type)) { + SetupOverwriteReferences(service, modules, slot, type); + + // If required, create the sibling references, so the names of the interfaces line up correctly. + var existingReferences = service.GetReferences(slot.MethodDef); + var overrideDef = existingReferences + .OfType() + .FirstOrDefault(r => !MethodEqualityComparer.CompareDeclaringTypes.Equals(r.BaseMemberDef as MethodDef, slot.Overrides.MethodDef)); + + if (!(overrideDef is null)) { + var baseMemberDef = overrideDef.BaseMemberDef; + CreateSiblingReference(slot.Overrides.MethodDef, ref baseMemberDef, service); + } + } + + // For the case when method in base type implements an interface method for a derived type + // do not consider method parameters to make method name the same in base type, derived type and interface + var methodDef = slot.MethodDef; + var typeDef = type.BaseType?.ResolveTypeDef(); + var baseMethod = typeDef?.FindMethod(methodDef.Name, methodDef.Signature as MethodSig); + if (baseMethod != null) { + string unifiedName = service.GetNormalizedName(slot.Overrides.MethodDef); + service.SetNormalizedName(slot.MethodDef, unifiedName); + service.SetNormalizedName(baseMethod, unifiedName); + } + } + } + } + + public static void Analyze(INameService service, ICollection modules, MethodDef method) { + if (!method.IsVirtual) + return; + + IMemberDef discoveredBaseMemberDef = null; + MethodDef discoveredBaseMethodDef = null; + + bool doesOverridePropertyOrEvent = false; + var methodProp = method.DeclaringType.Properties.Where(p => BelongsToProperty(p, method)); + foreach (var prop in methodProp) { + foreach (var baseMethodDef in FindBaseDeclarations(service, method)) { + var basePropDef = baseMethodDef.DeclaringType.Properties. + FirstOrDefault(p => BelongsToProperty(p, baseMethodDef) && String.Equals(p.Name, prop.Name, StringComparison.Ordinal)); + + if (basePropDef is null) continue; + + // Name of property has to line up. + CreateOverrideReference(service, prop, basePropDef); + CreateSiblingReference(basePropDef, ref discoveredBaseMemberDef, service); + + // Method names have to line up as well (otherwise inheriting attributes does not work). + CreateOverrideReference(service, method, baseMethodDef); + CreateSiblingReference(baseMethodDef, ref discoveredBaseMethodDef, service); + + doesOverridePropertyOrEvent = true; + } + } + + discoveredBaseMemberDef = null; + discoveredBaseMethodDef = null; + + var methodEvent = method.DeclaringType.Events.Where(e => BelongsToEvent(e, method)); + foreach (var evt in methodEvent) { + foreach (var baseMethodDef in FindBaseDeclarations(service, method)) { + var baseEventDef = baseMethodDef.DeclaringType.Events. + FirstOrDefault(e => BelongsToEvent(e, baseMethodDef) && String.Equals(e.Name, evt.Name, StringComparison.Ordinal)); + + if (baseEventDef is null) continue; + + // Name of event has to line up. + CreateOverrideReference(service, evt, baseEventDef); + CreateSiblingReference(baseEventDef, ref discoveredBaseMemberDef, service); + + // Method names have to line up as well (otherwise inheriting attributes does not work). + CreateOverrideReference(service, method, baseMethodDef); + CreateSiblingReference(baseMethodDef, ref discoveredBaseMethodDef, service); + + doesOverridePropertyOrEvent = true; + } + } + + if (!method.IsAbstract) { + var vTbl = service.GetVTables()[method.DeclaringType]; + var slots = vTbl.FindSlots(method).ToArray(); + + foreach (var slot in slots) { + if (slot.Overrides == null) + continue; + + SetupOverwriteReferences(service, modules, slot, method.DeclaringType); + } + } + else if (!doesOverridePropertyOrEvent) { + foreach (var baseMethodDef in FindBaseDeclarations(service, method)) { + CreateOverrideReference(service, method, baseMethodDef); + } + } + } + + static void CreateSiblingReference(T baseMemberDef, ref T discoveredBaseMemberDef, INameService service) where T : class, IMemberDef { + if (discoveredBaseMemberDef is null) + discoveredBaseMemberDef = baseMemberDef; + else { + var references = service.GetReferences(discoveredBaseMemberDef) + .OfType() + .ToArray(); + if (references.Length > 0) { + discoveredBaseMemberDef = (T)references[0].OldestSiblingDef; + foreach (var siblingRef in references.Skip(1)) { + // Redirect all the siblings to the new oldest reference + RedirectSiblingReferences(siblingRef.OldestSiblingDef, discoveredBaseMemberDef, service); + } + } + + // Check if the discovered base type is the current type. If so, nothing needs to be done. + if (ReferenceEquals(baseMemberDef, discoveredBaseMemberDef)) return; + + var reference = new MemberSiblingReference(baseMemberDef, discoveredBaseMemberDef); + service.AddReference(baseMemberDef, reference); + service.AddReference(discoveredBaseMemberDef, reference); + UpdateOldestSiblingReference(discoveredBaseMemberDef, baseMemberDef, service); + } + } + + static void UpdateOldestSiblingReference(IMemberDef oldestSiblingMemberDef, IMemberDef basePropDef, INameService service) { + var reverseReference = service.GetReferences(oldestSiblingMemberDef).OfType() + .SingleOrDefault(); + if (reverseReference is null) { + service.AddReference(oldestSiblingMemberDef, new MemberOldestSiblingReference(oldestSiblingMemberDef, basePropDef)); + PropagateRenamingRestrictions(service, oldestSiblingMemberDef, basePropDef); + } + else if (!reverseReference.OtherSiblings.Contains(basePropDef)) { + reverseReference.OtherSiblings.Add(basePropDef); + PropagateRenamingRestrictions(service, reverseReference.OtherSiblings); + } + } + + static void RedirectSiblingReferences(IMemberDef oldMemberDef, IMemberDef newMemberDef, INameService service) { + if (ReferenceEquals(oldMemberDef, newMemberDef)) return; + + var referencesToUpdate = service.GetReferences(oldMemberDef) + .OfType() + .SelectMany(r => r.OtherSiblings) + .SelectMany(service.GetReferences) + .OfType() + .Where(r => ReferenceEquals(r.OldestSiblingDef, oldMemberDef)); + + foreach (var reference in referencesToUpdate) { + reference.OldestSiblingDef = newMemberDef; + UpdateOldestSiblingReference(newMemberDef, reference.ThisMemberDef, service); + } + UpdateOldestSiblingReference(newMemberDef, oldMemberDef, service); + } + + static void CreateOverrideReference(INameService service, IMemberDef thisMemberDef, IMemberDef baseMemberDef) { + var overrideRef = new MemberOverrideReference(thisMemberDef, baseMemberDef); + service.AddReference(thisMemberDef, overrideRef); + service.AddReference(baseMemberDef, overrideRef); + + PropagateRenamingRestrictions(service, thisMemberDef, baseMemberDef); + } + + static void PropagateRenamingRestrictions(INameService service, params object[] objects) => + PropagateRenamingRestrictions(service, (IList)objects); + + static void PropagateRenamingRestrictions(INameService service, IList objects) { + if (!objects.All(service.CanRename)) { + foreach (var o in objects) { + service.SetCanRename(o, false); + } + } + else { + var minimalRenamingLevel = objects.Max(service.GetRenameMode); + foreach (var o in objects) { + service.ReduceRenameMode(o, minimalRenamingLevel); + } + } + } + + private static IEnumerable FindBaseDeclarations(INameService service, MethodDef method) { + var unprocessed = new Queue(); + unprocessed.Enqueue(method); + + var vTables = service.GetVTables(); + + while (unprocessed.Any()) { + var currentMethod = unprocessed.Dequeue(); + + var vTbl = vTables[currentMethod.DeclaringType]; + var slots = vTbl.FindSlots(currentMethod).Where(s => s.Overrides != null); + + bool slotsExists = false; + foreach (var slot in slots) { + unprocessed.Enqueue(slot.Overrides.MethodDef); + slotsExists = true; + } + + if (!slotsExists && method != currentMethod) + yield return currentMethod; + } + } + + private static bool BelongsToProperty(PropertyDef propertyDef, MethodDef methodDef) => + propertyDef.GetMethods.Contains(methodDef) || propertyDef.SetMethods.Contains(methodDef) || + (propertyDef.HasOtherMethods && propertyDef.OtherMethods.Contains(methodDef)); + + private static bool BelongsToEvent(EventDef eventDef, MethodDef methodDef) => + Equals(eventDef.AddMethod, methodDef) || Equals(eventDef.RemoveMethod, methodDef) || Equals(eventDef.InvokeMethod, methodDef) || + (eventDef.HasOtherMethods && eventDef.OtherMethods.Contains(methodDef)); + + private static void AddImportReference(INameService service, ICollection modules, ModuleDef module, MethodDef method, MemberRef methodRef) { + if (method.Module != module && modules.Contains((ModuleDefMD)module)) { + var declType = (TypeRef)methodRef.DeclaringType.ScopeType; + service.AddReference(method.DeclaringType, new TypeRefReference(declType, method.DeclaringType)); + service.AddReference(method, new MemberRefReference(methodRef, method)); + + var typeRefs = methodRef.MethodSig.Params.SelectMany(param => param.FindTypeRefs()).ToList(); + typeRefs.AddRange(methodRef.MethodSig.RetType.FindTypeRefs()); + typeRefs.AddRange(methodRef.DeclaringType.ToTypeSig().FindTypeRefs()); + foreach (var typeRef in typeRefs) { + SetupTypeReference(service, modules, module, typeRef); + } + } + } + + private static void SetupTypeReference(INameService service, ICollection modules, ModuleDef module, ITypeDefOrRef typeDefOrRef) { + if (!(typeDefOrRef is TypeRef typeRef)) return; + + var def = typeRef.ResolveTypeDef(); + if (!(def is null) && def.Module != module && modules.Contains((ModuleDefMD)def.Module)) + service.AddReference(def, new TypeRefReference(typeRef, def)); + } + + private static void SetupSignatureReferences(INameService service, ICollection modules, + ModuleDef module, GenericInstSig typeSig) { + SetupSignatureReferences(service, modules, module, typeSig.GenericType); + foreach (var genericArgument in typeSig.GenericArguments) + SetupSignatureReferences(service, modules, module, genericArgument); + } + + private static void SetupSignatureReferences(INameService service, ICollection modules, ModuleDef module, TypeSig typeSig) { + var asTypeRef = typeSig.TryGetTypeRef(); + if (asTypeRef != null) { + SetupTypeReference(service, modules, module, asTypeRef); + } + } + + private static void SetupOverwriteReferences(INameService service, ICollection modules, VTableSlot slot, TypeDef thisType) { + var module = thisType.Module; + var methodDef = slot.MethodDef; + var baseSlot = slot.Overrides; + var baseMethodDef = baseSlot.MethodDef; + + var overrideRef = new OverrideDirectiveReference(slot, baseSlot); + service.AddReference(methodDef, overrideRef); + service.AddReference(slot.Overrides.MethodDef, overrideRef); + + var importer = new Importer(module, ImporterOptions.TryToUseTypeDefs); + + IMethodDefOrRef target; + if (baseSlot.MethodDefDeclType is GenericInstSig declType) { + MemberRef targetRef = new MemberRefUser(module, baseMethodDef.Name, baseMethodDef.MethodSig, declType.ToTypeDefOrRef()); + targetRef = importer.Import(targetRef); + service.AddReference(baseMethodDef, new MemberRefReference(targetRef, baseMethodDef)); + SetupSignatureReferences(service, modules, module, targetRef.DeclaringType.ToTypeSig() as GenericInstSig); + + target = targetRef; + } + else { + target = baseMethodDef; + if (target.Module != module) { + target = (IMethodDefOrRef)importer.Import(baseMethodDef); + if (target is MemberRef memberRef) + service.AddReference(baseMethodDef, new MemberRefReference(memberRef, baseMethodDef)); + } + } + + if (target is MemberRef methodRef) + AddImportReference(service, modules, module, baseMethodDef, methodRef); + + if (TypeEqualityComparer.Instance.Equals(methodDef.DeclaringType, thisType)) { + if (methodDef.Overrides.Any(impl => IsMatchingOverride(impl, target))) + return; + + methodDef.Overrides.Add(new MethodOverride(methodDef, target)); + } + else if (target is IMemberDef targetDef) { + // Reaching this place means that a slot of the base type is overwritten by a specific interface. + // In case the this type is implementing the interface responsible for this, we need to declare + // this as an override reference. If the base type is implementing the interface (as well), this + // declaration is redundant. + var overrideRefRequired = true; + if (targetDef.DeclaringType.IsInterface) { + var baseTypeDef = thisType.BaseType?.ResolveTypeDef(); + if (!(baseTypeDef is null)) { + var baseTypeVTable = service.GetVTables()[baseTypeDef]; + if (baseTypeVTable.InterfaceSlots.TryGetValue(targetDef.DeclaringType.ToTypeSig(), out var ifcSlots)) { + overrideRefRequired = !ifcSlots.Contains(slot); + } + } + } + if (overrideRefRequired) + CreateOverrideReference(service, methodDef, targetDef); + } + } + + private static bool IsMatchingOverride(MethodOverride methodOverride, IMethodDefOrRef targetMethod) { + SigComparer comparer = default; + + var targetDeclTypeDef = targetMethod.DeclaringType.ResolveTypeDef(); + var overrideDeclTypeDef = methodOverride.MethodDeclaration.DeclaringType.ResolveTypeDef(); + if (!comparer.Equals(targetDeclTypeDef, overrideDeclTypeDef)) + return false; + + var targetMethodSig = targetMethod.MethodSig; + var overrideMethodSig = methodOverride.MethodDeclaration.MethodSig; + + targetMethodSig = ResolveGenericSignature(targetMethod, targetMethodSig); + overrideMethodSig = ResolveGenericSignature(methodOverride.MethodDeclaration, overrideMethodSig); + + return comparer.Equals(targetMethodSig, overrideMethodSig); + } + + static MethodSig ResolveGenericSignature(IMemberRef method, MethodSig overrideMethodSig) { + if (method.DeclaringType is TypeSpec spec && spec.TypeSig is GenericInstSig genericInstSig) { + overrideMethodSig = GenericArgumentResolver.Resolve(overrideMethodSig, genericInstSig.GenericArguments); + } + + return overrideMethodSig; + } + + public void PreRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { + // + } + + public void PostRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { + var method = def as MethodDef; + if (method == null || !method.IsVirtual || method.Overrides.Count == 0) + return; + + method.Overrides + .RemoveWhere(impl => MethodEqualityComparer.CompareDeclaringTypes.Equals(impl.MethodDeclaration, method)); + } + } +} diff --git a/Confuser.Renamer/Analyzers/VisualBasicRuntimeAnalyzer.cs b/Confuser.Renamer/Analyzers/VisualBasicRuntimeAnalyzer.cs index 8de4b55d8..bc674e2bd 100644 --- a/Confuser.Renamer/Analyzers/VisualBasicRuntimeAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/VisualBasicRuntimeAnalyzer.cs @@ -17,7 +17,8 @@ private static void AnalyzeType(ConfuserContext context, INameService service, P def.BaseType != null && def.BaseType.FullName.Equals("System.Attribute", StringComparison.Ordinal)) { service.SetCanRename(def, false); - } else if (def.HasCustomAttributes && def.CustomAttributes.Any(a => IsEmbeddedAttribute(a.AttributeType))) { + } + else if (def.HasCustomAttributes && def.CustomAttributes.Any(a => IsEmbeddedAttribute(a.AttributeType))) { service.SetCanRename(def, false); } } @@ -26,8 +27,8 @@ private static bool IsEmbeddedAttribute(ITypeDefOrRef defOrRef) { if (defOrRef.FullName.Equals("Microsoft.VisualBasic.Embedded", StringComparison.Ordinal)) { var typeDef = (defOrRef as TypeDef); if (typeDef != null) { - return typeDef.IsNotPublic && - typeDef.BaseType != null && + return typeDef.IsNotPublic && + typeDef.BaseType != null && typeDef.BaseType.FullName.Equals("System.Attribute", StringComparison.Ordinal); } } diff --git a/Confuser.Renamer/Analyzers/WPFAnalyzer.cs b/Confuser.Renamer/Analyzers/WPFAnalyzer.cs index 47097bbb3..ebf49dceb 100644 --- a/Confuser.Renamer/Analyzers/WPFAnalyzer.cs +++ b/Confuser.Renamer/Analyzers/WPFAnalyzer.cs @@ -359,4 +359,4 @@ void AnalyzeResources(ConfuserContext context, INameService service, ModuleDefMD context.Annotations.Set(module, BAMLKey, wpfResInfo); } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/BAML/BAMLAnalyzer.cs b/Confuser.Renamer/BAML/BAMLAnalyzer.cs index 141a5ac0d..dec64a2e7 100644 --- a/Confuser.Renamer/BAML/BAMLAnalyzer.cs +++ b/Confuser.Renamer/BAML/BAMLAnalyzer.cs @@ -637,7 +637,7 @@ void AnalyzePropertyPathIndexer(PropertyPathPartUpdater part) { foreach (var indexerArg in part.ParamList) { if (!string.IsNullOrWhiteSpace(indexerArg.ParenString)) { var sig = ResolveType(indexerArg.ParenString, out var prefix); - if (sig != null && context.Modules.Contains((ModuleDefMD) sig.ToBasicTypeDefOrRef().ResolveTypeDefThrow().Module)) { + if (sig != null && context.Modules.Contains((ModuleDefMD)sig.ToBasicTypeDefOrRef().ResolveTypeDefThrow().Module)) { var reference = new BAMLPathTypeReference(xmlnsCtx, sig, indexerArg); AddTypeSigReference(sig, reference); break; @@ -680,7 +680,7 @@ public XmlNsContext(BamlDocument doc, Dictionary assemblyRe Debug.Assert(rootIndex != -1); } - public void AddNsMap(string clrNs, AssemblyDef assembly, string prefix) => + public void AddNsMap(string clrNs, AssemblyDef assembly, string prefix) => AddNsMap(Tuple.Create(assembly, clrNs), prefix); public void AddNsMap(Tuple scope, string prefix) { diff --git a/Confuser.Renamer/BAML/BamlDocument.cs b/Confuser.Renamer/BAML/BamlDocument.cs index b2df1d581..de4f1afb8 100644 --- a/Confuser.Renamer/BAML/BamlDocument.cs +++ b/Confuser.Renamer/BAML/BamlDocument.cs @@ -15,4 +15,4 @@ public struct BamlVersion { public ushort Minor; } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/BAML/BamlElement.cs b/Confuser.Renamer/BAML/BamlElement.cs index dccc65ee5..4129151c2 100644 --- a/Confuser.Renamer/BAML/BamlElement.cs +++ b/Confuser.Renamer/BAML/BamlElement.cs @@ -123,4 +123,4 @@ public static BamlElement Read(BamlDocument document) { return current; } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/BAML/BamlRW.cs b/Confuser.Renamer/BAML/BamlRW.cs index 24243d5d8..0f95863fb 100644 --- a/Confuser.Renamer/BAML/BamlRW.cs +++ b/Confuser.Renamer/BAML/BamlRW.cs @@ -37,8 +37,8 @@ public static BamlDocument ReadDocument(Stream str) { ret.UpdaterVersion = new BamlDocument.BamlVersion { Major = reader.ReadUInt16(), Minor = reader.ReadUInt16() }; ret.WriterVersion = new BamlDocument.BamlVersion { Major = reader.ReadUInt16(), Minor = reader.ReadUInt16() }; if (ret.ReaderVersion.Major != 0 || ret.ReaderVersion.Minor != 0x60 || - ret.UpdaterVersion.Major != 0 || ret.UpdaterVersion.Minor != 0x60 || - ret.WriterVersion.Major != 0 || ret.WriterVersion.Minor != 0x60) + ret.UpdaterVersion.Major != 0 || ret.UpdaterVersion.Minor != 0x60 || + ret.WriterVersion.Major != 0 || ret.WriterVersion.Minor != 0x60) throw new NotSupportedException(); var recs = new Dictionary(); @@ -252,4 +252,4 @@ public static void WriteDocument(BamlDocument doc, Stream str) { (doc[i] as IBamlDeferRecord).WriteDefer(doc, i, writer); } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/BAML/IKnownThings.cs b/Confuser.Renamer/BAML/IKnownThings.cs index e27bb0078..e3f3bef1c 100644 --- a/Confuser.Renamer/BAML/IKnownThings.cs +++ b/Confuser.Renamer/BAML/IKnownThings.cs @@ -1042,4 +1042,4 @@ internal interface IKnownThings { Func> Properties { get; } AssemblyDef FrameworkAssembly { get; } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/BAML/KnownThingsv3.cs b/Confuser.Renamer/BAML/KnownThingsv3.cs index d5a65e351..5717b3e8a 100644 --- a/Confuser.Renamer/BAML/KnownThingsv3.cs +++ b/Confuser.Renamer/BAML/KnownThingsv3.cs @@ -1083,4 +1083,4 @@ void InitProperties() { properties[KnownProperties.XmlDataProvider_XmlSerializer] = InitProperty(KnownTypes.XmlDataProvider, "XmlSerializer", assemblies[5].Find("System.Xml.Serialization.IXmlSerializable", true)); } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/BAML/KnownThingsv4.cs b/Confuser.Renamer/BAML/KnownThingsv4.cs index d1fbb530b..b93287a7c 100644 --- a/Confuser.Renamer/BAML/KnownThingsv4.cs +++ b/Confuser.Renamer/BAML/KnownThingsv4.cs @@ -1084,4 +1084,4 @@ void InitProperties() { properties[KnownProperties.XmlDataProvider_XmlSerializer] = InitProperty(KnownTypes.XmlDataProvider, "XmlSerializer", assemblies[6].Find("System.Xml.Serialization.IXmlSerializable", true)); } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/Confuser.Renamer.csproj b/Confuser.Renamer/Confuser.Renamer.csproj index f053a7a77..61292609e 100644 --- a/Confuser.Renamer/Confuser.Renamer.csproj +++ b/Confuser.Renamer/Confuser.Renamer.csproj @@ -4,7 +4,7 @@ - net461;netstandard2.0 + net48;netstandard2.0 true ..\ConfuserEx.snk @@ -15,13 +15,11 @@ - + - - diff --git a/Confuser.Renamer/GenericArgumentResolver.cs b/Confuser.Renamer/GenericArgumentResolver.cs index d7b5ec730..72766ebed 100644 --- a/Confuser.Renamer/GenericArgumentResolver.cs +++ b/Confuser.Renamer/GenericArgumentResolver.cs @@ -98,10 +98,10 @@ private TypeSig ResolveGenericArgs(TypeSig typeSig) { result = new ByRefSig(ResolveGenericArgs(typeSig.Next)); break; case ElementType.Var: - result = new GenericVar(((GenericVar) typeSig).Number); + result = new GenericVar(((GenericVar)typeSig).Number); break; case ElementType.ValueArray: - result = new ValueArraySig(ResolveGenericArgs(typeSig.Next), ((ValueArraySig) typeSig).Size); + result = new ValueArraySig(ResolveGenericArgs(typeSig.Next), ((ValueArraySig)typeSig).Size); break; case ElementType.SZArray: result = new SZArraySig(ResolveGenericArgs(typeSig.Next)); @@ -136,7 +136,7 @@ private TypeSig ResolveGenericArgs(TypeSig typeSig) { var genArgs = new List(gis.GenericArguments.Count); foreach (var ga in gis.GenericArguments) genArgs.Add(ResolveGenericArgs(ga)); - + result = new GenericInstSig(ResolveGenericArgs(gis.GenericType) as ClassOrValueTypeSig, genArgs); break; @@ -150,4 +150,4 @@ private TypeSig ResolveGenericArgs(TypeSig typeSig) { return result; } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/GenericArguments.cs b/Confuser.Renamer/GenericArguments.cs index 7bb0e731a..d9e1e0d68 100644 --- a/Confuser.Renamer/GenericArguments.cs +++ b/Confuser.Renamer/GenericArguments.cs @@ -70,7 +70,7 @@ public TypeSig Resolve(TypeSig typeSig) { return sig; } - + private ref struct GenericArgumentsStack { private List> _argsStack; diff --git a/Confuser.Renamer/INameReference.cs b/Confuser.Renamer/INameReference.cs index 3e1b953af..fb5164090 100644 --- a/Confuser.Renamer/INameReference.cs +++ b/Confuser.Renamer/INameReference.cs @@ -33,7 +33,7 @@ public interface INameReference { /// is /// bool UpdateNameReference(ConfuserContext context, INameService service); - + /// /// Get a description of this reference, containing the original /// names of the referenced objects. diff --git a/Confuser.Renamer/IRenamer.cs b/Confuser.Renamer/IRenamer.cs index 956c0d660..b45a7196e 100644 --- a/Confuser.Renamer/IRenamer.cs +++ b/Confuser.Renamer/IRenamer.cs @@ -8,4 +8,4 @@ public interface IRenamer { void PreRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def); void PostRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def); } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/NameService.cs b/Confuser.Renamer/NameService.cs index ac60618b7..ae5a481ec 100644 --- a/Confuser.Renamer/NameService.cs +++ b/Confuser.Renamer/NameService.cs @@ -250,7 +250,7 @@ public string ObfuscateName(string format, string name, RenameMode mode, bool pr } if (!identifiers.Contains(MakeGenericName(newName, genericParamsCount)) - && !_obfuscatedToOriginalNameMap.ContainsKey(newName)) + && !_obfuscatedToOriginalNameMap.ContainsKey(newName)) break; hash = Utils.SHA1(hash); } @@ -329,27 +329,27 @@ public void MarkHelper(IDnlibDef def, IMarkerService marker, ConfuserComponent p static readonly char[] asciiCharset = Enumerable.Range(32, 95) .Select(ord => (char)ord) - .Except(new[] {'.'}) + .Except(new[] { '.' }) .ToArray(); - static readonly char[] reflectionCharset = asciiCharset.Except(new[] {' ', '[', ']'}).ToArray(); + static readonly char[] reflectionCharset = asciiCharset.Except(new[] { ' ', '[', ']' }).ToArray(); static readonly char[] letterCharset = Enumerable.Range(0, 26) - .SelectMany(ord => new[] {(char)('a' + ord), (char)('A' + ord)}) + .SelectMany(ord => new[] { (char)('a' + ord), (char)('A' + ord) }) .ToArray(); static readonly char[] alphaNumCharset = Enumerable.Range(0, 26) - .SelectMany(ord => new[] {(char)('a' + ord), (char)('A' + ord)}) + .SelectMany(ord => new[] { (char)('a' + ord), (char)('A' + ord) }) .Concat(Enumerable.Range(0, 10).Select(ord => (char)('0' + ord))) .ToArray(); // Especially chosen, just to mess with people. // Inspired by: http://xkcd.com/1137/ :D - static readonly char[] unicodeCharset = new char[] { } + static readonly char[] unicodeCharset = Array.Empty() .Concat(Enumerable.Range(0x200b, 5).Select(ord => (char)ord)) .Concat(Enumerable.Range(0x2029, 6).Select(ord => (char)ord)) .Concat(Enumerable.Range(0x206a, 6).Select(ord => (char)ord)) - .Except(new[] {'\u2029'}) + .Except(new[] { '\u2029' }) .ToArray(); #endregion @@ -376,8 +376,8 @@ public string GetNormalizedName(IDnlibDef obj) => DisplayNormalizedName ExtractDisplayNormalizedName(IDnlibDef dnlibDef, bool forceShortNames = false) { var shortNames = forceShortNames || - GetParam(dnlibDef, "shortNames")?.Equals("true", StringComparison.OrdinalIgnoreCase) == - true; + GetParam(dnlibDef, "shortNames")?.Equals("true", StringComparison.OrdinalIgnoreCase) == + true; var renameMode = GetRenameMode(dnlibDef); if (dnlibDef is TypeDef typeDef) { @@ -429,12 +429,9 @@ DisplayNormalizedName ExtractDisplayNormalizedName(IDnlibDef dnlibDef, bool forc shortNames ? dnlibDef.Name.ToString() : normalizedNameBuilder.ToString()); } - DisplayNormalizedName CompressTypeName(string typeName, RenameMode renameMode) - { - if (renameMode == RenameMode.Reversible) - { - if (!_prefixesMap.TryGetValue(typeName, out string prefix)) - { + DisplayNormalizedName CompressTypeName(string typeName, RenameMode renameMode) { + if (renameMode == RenameMode.Reversible) { + if (!_prefixesMap.TryGetValue(typeName, out string prefix)) { _prefixesMap.Add(typeName, GetNextSequentialName()); } diff --git a/Confuser.Renamer/PostRenamePhase.cs b/Confuser.Renamer/PostRenamePhase.cs index 77ed723f7..123367a41 100644 --- a/Confuser.Renamer/PostRenamePhase.cs +++ b/Confuser.Renamer/PostRenamePhase.cs @@ -29,4 +29,4 @@ protected override void Execute(ConfuserContext context, ProtectionParameters pa } } } -} \ No newline at end of file +} diff --git a/Confuser.Renamer/References/BAMLPathTypeReference.cs b/Confuser.Renamer/References/BAMLPathTypeReference.cs index 042dc60a0..08f5c1da3 100644 --- a/Confuser.Renamer/References/BAMLPathTypeReference.cs +++ b/Confuser.Renamer/References/BAMLPathTypeReference.cs @@ -24,7 +24,7 @@ private BAMLPathTypeReference(BAMLAnalyzer.XmlNsContext xmlnsCtx, TypeSig sig) { /// public bool DelayRenaming(INameService service, IDnlibDef currentDef) => false; - public BAMLPathTypeReference(BAMLAnalyzer.XmlNsContext xmlnsCtx, TypeSig sig, PropertyPathIndexUpdater indexerInfo) : this(xmlnsCtx, sig) => + public BAMLPathTypeReference(BAMLAnalyzer.XmlNsContext xmlnsCtx, TypeSig sig, PropertyPathIndexUpdater indexerInfo) : this(xmlnsCtx, sig) => IndexerInfo = indexerInfo; public BAMLPathTypeReference(BAMLAnalyzer.XmlNsContext xmlnsCtx, TypeSig sig, PropertyDef property, PropertyPathPartUpdater propertyInfo) : this(xmlnsCtx, sig) { diff --git a/Confuser.Renamer/References/MemberOldestSiblingReference.cs b/Confuser.Renamer/References/MemberOldestSiblingReference.cs index 3bc543c65..bb2fd6def 100644 --- a/Confuser.Renamer/References/MemberOldestSiblingReference.cs +++ b/Confuser.Renamer/References/MemberOldestSiblingReference.cs @@ -18,7 +18,7 @@ public sealed class MemberOldestSiblingReference : INameReference { public MemberOldestSiblingReference(IMemberDef oldestSiblingDef, IMemberDef otherSiblingDef) { OldestSiblingDef = oldestSiblingDef ?? throw new ArgumentNullException(nameof(oldestSiblingDef)); if (otherSiblingDef is null) throw new ArgumentNullException(nameof(otherSiblingDef)); - OtherSiblings = new List {otherSiblingDef}; + OtherSiblings = new List { otherSiblingDef }; } /// @@ -31,14 +31,14 @@ public MemberOldestSiblingReference(IMemberDef oldestSiblingDef, IMemberDef othe public bool UpdateNameReference(ConfuserContext context, INameService service) => false; public override string ToString() => ToString(null); - + /// public string ToString(INameService nameService) { var builder = new StringBuilder(); builder.Append("Oldest Sibling Reference").Append("("); builder.Append("Oldest Sibling ").AppendReferencedDef(OldestSiblingDef, nameService); builder.Append("; Other Siblings: "); - foreach (var otherSibling in OtherSiblings) + foreach (var otherSibling in OtherSiblings) builder.AppendReferencedDef(otherSibling, nameService).Append(", "); builder.Length -= 2; diff --git a/Confuser.Renamer/References/MemberOverrideReference.cs b/Confuser.Renamer/References/MemberOverrideReference.cs index a3090f127..420056447 100644 --- a/Confuser.Renamer/References/MemberOverrideReference.cs +++ b/Confuser.Renamer/References/MemberOverrideReference.cs @@ -18,9 +18,9 @@ public MemberOverrideReference(IMemberDef thisMemberDef, IMemberDef baseMemberDe } /// - public bool DelayRenaming(INameService service, IDnlibDef currentDef) => - currentDef != BaseMemberDef - && !ShouldCancelRename + public bool DelayRenaming(INameService service, IDnlibDef currentDef) => + currentDef != BaseMemberDef + && !ShouldCancelRename && !service.IsRenamed(BaseMemberDef); public bool UpdateNameReference(ConfuserContext context, INameService service) { diff --git a/Confuser.Renamer/References/MemberRefReference.cs b/Confuser.Renamer/References/MemberRefReference.cs index 978129bcf..edca18178 100644 --- a/Confuser.Renamer/References/MemberRefReference.cs +++ b/Confuser.Renamer/References/MemberRefReference.cs @@ -23,7 +23,7 @@ public bool UpdateNameReference(ConfuserContext context, INameService service) { return true; } - public override string ToString() => ToString(null); + public override string ToString() => ToString(null); public string ToString(INameService nameService) { var builder = new StringBuilder(); diff --git a/Confuser.Renamer/References/MemberSiblingReference.cs b/Confuser.Renamer/References/MemberSiblingReference.cs index 61bedb7e9..72be0e514 100644 --- a/Confuser.Renamer/References/MemberSiblingReference.cs +++ b/Confuser.Renamer/References/MemberSiblingReference.cs @@ -27,9 +27,9 @@ public MemberSiblingReference(IMemberDef thisMemberDef, IMemberDef oldestSibling public bool ShouldCancelRename => ThisMemberDef.Module != OldestSiblingDef.Module; /// - public bool DelayRenaming(INameService service, IDnlibDef currentDef) => - currentDef != OldestSiblingDef - && !ShouldCancelRename + public bool DelayRenaming(INameService service, IDnlibDef currentDef) => + currentDef != OldestSiblingDef + && !ShouldCancelRename && !service.IsRenamed(OldestSiblingDef); /// @@ -40,7 +40,7 @@ public bool UpdateNameReference(ConfuserContext context, INameService service) { } public override string ToString() => ToString(null); - + /// public string ToString(INameService nameService) { var builder = new StringBuilder(); diff --git a/Confuser.Renamer/References/OverrideDirectiveReference.cs b/Confuser.Renamer/References/OverrideDirectiveReference.cs index 3873a27de..e4eacdc99 100644 --- a/Confuser.Renamer/References/OverrideDirectiveReference.cs +++ b/Confuser.Renamer/References/OverrideDirectiveReference.cs @@ -8,7 +8,7 @@ internal sealed class OverrideDirectiveReference : INameReference { readonly VTableSlot thisSlot; public bool ShouldCancelRename => baseSlot.MethodDefDeclType is GenericInstSig && thisSlot.MethodDef.Module.IsClr20; - + public OverrideDirectiveReference(VTableSlot thisSlot, VTableSlot baseSlot) { this.thisSlot = thisSlot; this.baseSlot = baseSlot; diff --git a/Confuser.Renamer/References/RequiredPrefixReference.cs b/Confuser.Renamer/References/RequiredPrefixReference.cs index 028bbc81e..190b3830c 100644 --- a/Confuser.Renamer/References/RequiredPrefixReference.cs +++ b/Confuser.Renamer/References/RequiredPrefixReference.cs @@ -6,7 +6,7 @@ namespace Confuser.Renamer.References { public sealed class RequiredPrefixReference : INameReference where T : class, IDnlibDef { T Def { get; } - string Prefix { get; } + string Prefix { get; } /// public bool ShouldCancelRename => false; @@ -14,7 +14,7 @@ public sealed class RequiredPrefixReference : INameReference where T : cla internal RequiredPrefixReference(T def, string prefix) { Def = def ?? throw new ArgumentNullException(nameof(def)); Prefix = prefix ?? throw new ArgumentNullException(nameof(prefix)); - if (prefix.Length < 0) throw new ArgumentException("Prefix must not be empty.", nameof(prefix)); + if (false) throw new ArgumentException("Prefix must not be empty.", nameof(prefix)); } /// diff --git a/Confuser.Renamer/References/TypeRefReference.cs b/Confuser.Renamer/References/TypeRefReference.cs index ff1c4f873..ff285e8b9 100644 --- a/Confuser.Renamer/References/TypeRefReference.cs +++ b/Confuser.Renamer/References/TypeRefReference.cs @@ -18,7 +18,7 @@ public TypeRefReference(TypeRef typeRef, TypeDef typeDef) { public bool DelayRenaming(INameService service, IDnlibDef currentDef) => false; public bool UpdateNameReference(ConfuserContext context, INameService service) { - if (UTF8String.Equals(typeRef.Namespace, typeDef.Namespace) && + if (UTF8String.Equals(typeRef.Namespace, typeDef.Namespace) && UTF8String.Equals(typeRef.Name, typeDef.Name)) return false; typeRef.Namespace = typeDef.Namespace; diff --git a/Confuser.Renamer/RenamePhase.cs b/Confuser.Renamer/RenamePhase.cs index 91021abcd..a73630deb 100644 --- a/Confuser.Renamer/RenamePhase.cs +++ b/Confuser.Renamer/RenamePhase.cs @@ -123,10 +123,9 @@ protected override void Execute(ConfuserContext context, ProtectionParameters pa } } - static void RenameGenericParameters(IList genericParams) - { + static void RenameGenericParameters(IList genericParams) { foreach (var param in genericParams) - param.Name = ((char) (param.Number + 1)).ToString(); + param.Name = ((char)(param.Number + 1)).ToString(); } /// diff --git a/Confuser.Renamer/VTable.cs b/Confuser.Renamer/VTable.cs index a1fe8f215..cca4effa4 100644 --- a/Confuser.Renamer/VTable.cs +++ b/Confuser.Renamer/VTable.cs @@ -156,7 +156,7 @@ public static VTable ConstructVTable(TypeDef typeDef, VTableStorage storage) { if (slots.Select(g => g.Key) .Any(sig => virtualMethods.ContainsKey(sig) || vTbl.SlotsMap.ContainsKey(sig))) { // Something has a new signature. We need to rewrite the whole thing. - + // This is the step 1 of 12.2 algorithm -- find implementation for still empty slots. // Note that it seems we should include newslot methods as well, despite what the standard said. slots = slots @@ -214,7 +214,7 @@ public static VTable ConstructVTable(TypeDef typeDef, VTableStorage storage) { vTbl.InterfaceSlots[iface] = ifaceVTbl .SelectMany(g => g.Select(slot => (g.Key, Slot: slot))) .ToLookup(t => t.Key, t => { - if (!t.Key.Equals(signature)) + if (!t.Key.Equals(signature)) return t.Slot; var targetSlot = t.Slot; diff --git a/Confuser.Runtime/AntiDebug.Antinet.cs b/Confuser.Runtime/AntiDebug.Antinet.cs index ce323bb0b..fada428c0 100644 --- a/Confuser.Runtime/AntiDebug.Antinet.cs +++ b/Confuser.Runtime/AntiDebug.Antinet.cs @@ -12,4 +12,4 @@ static void Initialize() { } } } -} \ No newline at end of file +} diff --git a/Confuser.Runtime/AntiDebug.Safe.cs b/Confuser.Runtime/AntiDebug.Safe.cs index 8b69342c7..fca4253e8 100644 --- a/Confuser.Runtime/AntiDebug.Safe.cs +++ b/Confuser.Runtime/AntiDebug.Safe.cs @@ -12,7 +12,7 @@ static void Initialize() { // Comparison is done using is-operator to avoid the op_inequality overload of .NET 4.0 // This is required to ensure that the result is .NET 2.0 compatible. if (!(method is null) && - "1".Equals(method.Invoke(null, new object[] { x + "_ENABLE_PROFILING" }))) + "1".Equals(method.Invoke(null, new object[] { x + "_ENABLE_PROFILING" }))) Environment.FailFast(null); var thread = new Thread(Worker); diff --git a/Confuser.Runtime/AntiDebug.Win32.cs b/Confuser.Runtime/AntiDebug.Win32.cs index 6dbf355ec..10801467e 100644 --- a/Confuser.Runtime/AntiDebug.Win32.cs +++ b/Confuser.Runtime/AntiDebug.Win32.cs @@ -8,11 +8,11 @@ internal static class AntiDebugWin32 { static void Initialize() { string x = "COR"; if (Environment.GetEnvironmentVariable(x + "_PROFILER") != null || - Environment.GetEnvironmentVariable(x + "_ENABLE_PROFILING") != null) + Environment.GetEnvironmentVariable(x + "_ENABLE_PROFILING") != null) Environment.FailFast(null); //Anti dnspy Process here = GetParentProcess(); - if (here != null && here.ProcessName.ToLower().Contains("dnspy")) + if (here != null && here.ProcessName.IndexOf("dnspy", StringComparison.OrdinalIgnoreCase) >= 0) Environment.FailFast(""); var thread = new Thread(Worker); @@ -42,7 +42,7 @@ internal struct ParentProcessUtilities { [DllImport("ntdll.dll")] private static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcessUtilities processInformation, uint processInformationLength, out int returnLength); - + /// /// Gets the parent process of the current process. /// diff --git a/Confuser.Runtime/AntiDump.cs b/Confuser.Runtime/AntiDump.cs index 798707c3d..0c6a896ad 100644 --- a/Confuser.Runtime/AntiDump.cs +++ b/Confuser.Runtime/AntiDump.cs @@ -235,4 +235,4 @@ static unsafe void Initialize() { } } } -} \ No newline at end of file +} diff --git a/Confuser.Runtime/AntiTamper.JIT.cs b/Confuser.Runtime/AntiTamper.JIT.cs index ca0535fbb..876f41f78 100644 --- a/Confuser.Runtime/AntiTamper.JIT.cs +++ b/Confuser.Runtime/AntiTamper.JIT.cs @@ -77,9 +77,11 @@ public static void Initialize() { var obj = GetFieldValue(hnd, "m_ptr"); if (obj is IntPtr) { moduleHnd = (IntPtr)obj; - } else if (obj.GetType().ToString() == "System.Reflection.RuntimeModule") { + } + else if (obj.GetType().ToString() == "System.Reflection.RuntimeModule") { moduleHnd = (IntPtr)GetFieldValue(obj, "m_pData"); - } else { + } + else { throw new ApplicationException($"Failed to get pointer for module handle: {hnd.ToString()}"); } diff --git a/Confuser.Runtime/Constant.cs b/Confuser.Runtime/Constant.cs index 88f92b402..cc64d3e81 100644 --- a/Confuser.Runtime/Constant.cs +++ b/Confuser.Runtime/Constant.cs @@ -51,8 +51,8 @@ static T Get(int id) { id = (id & 0x3fffffff) << 2; if (t == Mutation.KeyI0) { - int l = b[id] | (b[id+1] << 8) | (b[id+2] << 16) | (b[id+3] << 24); - ret = (T)(object)string.Intern(Encoding.UTF8.GetString(b, id+4, l)); + int l = b[id] | (b[id + 1] << 8) | (b[id + 2] << 16) | (b[id + 3] << 24); + ret = (T)(object)string.Intern(Encoding.UTF8.GetString(b, id + 4, l)); } // NOTE: Assume little-endian else if (t == Mutation.KeyI1) { @@ -61,10 +61,10 @@ static T Get(int id) { ret = v[0]; } else if (t == Mutation.KeyI2) { - int s = b[id] | (b[id+1] << 8) | (b[id+2] << 16) | (b[id+3] << 24); - int l = b[id+4] | (b[id+5] << 8) | (b[id+6] << 16) | (b[id+7] << 24); + int s = b[id] | (b[id + 1] << 8) | (b[id + 2] << 16) | (b[id + 3] << 24); + int l = b[id + 4] | (b[id + 5] << 8) | (b[id + 6] << 16) | (b[id + 7] << 24); Array v = Array.CreateInstance(typeof(T).GetElementType(), l); - Buffer.BlockCopy(b, id+8, v, 0, s - 4); + Buffer.BlockCopy(b, id + 8, v, 0, s - 4); ret = (T)(object)v; } else diff --git a/Confuser.Runtime/ExcludeFromCodeCoverageAttribute.cs b/Confuser.Runtime/ExcludeFromCodeCoverageAttribute.cs index b60fb8029..5ba199430 100644 --- a/Confuser.Runtime/ExcludeFromCodeCoverageAttribute.cs +++ b/Confuser.Runtime/ExcludeFromCodeCoverageAttribute.cs @@ -1,6 +1,7 @@ #if NETFRAMEWORK && (NET20 || NET35) // ReSharper disable once CheckNamespace namespace System.Diagnostics.CodeAnalysis { + [AttributeUsage(AttributeTargets.All, AllowMultiple = false)] internal sealed class ExcludeFromCodeCoverageAttribute : Attribute { } } diff --git a/Confuser.Runtime/Lzma.cs b/Confuser.Runtime/Lzma.cs index 0111dcce0..24ddfa58b 100644 --- a/Confuser.Runtime/Lzma.cs +++ b/Confuser.Runtime/Lzma.cs @@ -119,7 +119,7 @@ public uint ReverseDecode(Decoder rangeDecoder) { } public static uint ReverseDecode(BitDecoder[] Models, UInt32 startIndex, - Decoder rangeDecoder, int NumBitLevels) { + Decoder rangeDecoder, int NumBitLevels) { uint m = 1; uint symbol = 0; for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++) { @@ -268,7 +268,7 @@ void Init(Stream inStream, Stream outStream) { } public void Code(Stream inStream, Stream outStream, - Int64 inSize, Int64 outSize) { + Int64 inSize, Int64 outSize) { Init(inStream, outStream); var state = new State(); @@ -294,7 +294,7 @@ public void Code(Stream inStream, Stream outStream, byte prevByte = m_OutWindow.GetByte(0); if (!state.IsCharState()) b = m_LiteralDecoder.DecodeWithMatchByte(m_RangeDecoder, - (uint)nowPos64, prevByte, m_OutWindow.GetByte(rep0)); + (uint)nowPos64, prevByte, m_OutWindow.GetByte(rep0)); else b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, (uint)nowPos64, prevByte); m_OutWindow.PutByte(b); @@ -344,7 +344,7 @@ public void Code(Stream inStream, Stream outStream, rep0 = ((2 | (posSlot & 1)) << numDirectBits); if (posSlot < kEndPosModelIndex) rep0 += BitTreeDecoder.ReverseDecode(m_PosDecoders, - rep0 - posSlot - 1, m_RangeDecoder, numDirectBits); + rep0 - posSlot - 1, m_RangeDecoder, numDirectBits); else { rep0 += (m_RangeDecoder.DecodeDirectBits( numDirectBits - kNumAlignBits) << kNumAlignBits); @@ -436,7 +436,7 @@ class LiteralDecoder { public void Create(int numPosBits, int numPrevBits) { if (m_Coders != null && m_NumPrevBits == numPrevBits && - m_NumPosBits == numPosBits) + m_NumPosBits == numPosBits) return; m_NumPosBits = numPosBits; m_PosMask = ((uint)1 << numPosBits) - 1; diff --git a/Confuser.Runtime/Mutation.cs b/Confuser.Runtime/Mutation.cs index c95881747..25545385e 100644 --- a/Confuser.Runtime/Mutation.cs +++ b/Confuser.Runtime/Mutation.cs @@ -31,4 +31,4 @@ public static T Value(Arg0 arg0) { } public static void Crypt(uint[] data, uint[] key) { } -} \ No newline at end of file +} diff --git a/Confuser.Runtime/RefProxy.Strong.cs b/Confuser.Runtime/RefProxy.Strong.cs index c63e8e9c9..9924712d9 100644 --- a/Confuser.Runtime/RefProxy.Strong.cs +++ b/Confuser.Runtime/RefProxy.Strong.cs @@ -88,4 +88,4 @@ internal static void Initialize(RuntimeFieldHandle field, byte opKey) { } } } -} \ No newline at end of file +} diff --git a/Confuser.Runtime/Resource.cs b/Confuser.Runtime/Resource.cs index 194af7ce1..c856e5f28 100644 --- a/Confuser.Runtime/Resource.cs +++ b/Confuser.Runtime/Resource.cs @@ -94,4 +94,4 @@ static Assembly Handler(object sender, ResolveEventArgs args) { return null; } } -} \ No newline at end of file +} diff --git a/Confuser.Runtime/antinet/AntiManagedDebugger.cs b/Confuser.Runtime/antinet/AntiManagedDebugger.cs index a3b496885..af0592eb9 100644 --- a/Confuser.Runtime/antinet/AntiManagedDebugger.cs +++ b/Confuser.Runtime/antinet/AntiManagedDebugger.cs @@ -238,4 +238,4 @@ private static class Infos { } } -} \ No newline at end of file +} diff --git a/Confuser.Runtime/antinet/AntiManagedProfiler.cs b/Confuser.Runtime/antinet/AntiManagedProfiler.cs index 1de13206a..ce2b5c1a3 100644 --- a/Confuser.Runtime/antinet/AntiManagedProfiler.cs +++ b/Confuser.Runtime/antinet/AntiManagedProfiler.cs @@ -276,13 +276,13 @@ private class ProfilerDetectorCLR40 : ProfilerDetector { [DllImport("kernel32", SetLastError = true)] private static extern SafeFileHandle CreateNamedPipe(string lpName, uint dwOpenMode, - uint dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize, - uint nDefaultTimeOut, IntPtr lpSecurityAttributes); + uint dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize, + uint nDefaultTimeOut, IntPtr lpSecurityAttributes); [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Auto)] private static extern SafeFileHandle CreateFile(string lpFileName, uint dwDesiredAccess, - uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, - uint dwFlagsAndAttributes, IntPtr hTemplateFile); + uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, + uint dwFlagsAndAttributes, IntPtr hTemplateFile); [DllImport("kernel32")] private static extern bool VirtualProtect(IntPtr lpAddress, int dwSize, uint flNewProtect, out uint lpflOldProtect); @@ -425,8 +425,8 @@ private static SafeFileHandle CreatePipeFileHandle() { private static string GetPipeName() { return string.Format(@"\\.\pipe\CPFATP_{0}_v{1}.{2}.{3}", - GetCurrentProcessId(), Environment.Version.Major, - Environment.Version.Minor, Environment.Version.Build); + GetCurrentProcessId(), Environment.Version.Major, + Environment.Version.Minor, Environment.Version.Build); } private bool CreateNamedPipe() { @@ -434,13 +434,13 @@ private bool CreateNamedPipe() { return true; profilerPipe = CreateNamedPipe(GetPipeName(), - FILE_FLAG_OVERLAPPED | PIPE_ACCESS_DUPLEX, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, - 1, // nMaxInstances - 0x24, // nOutBufferSize - 0x338, // nInBufferSize - 1000, // nDefaultTimeOut - IntPtr.Zero); // lpSecurityAttributes + FILE_FLAG_OVERLAPPED | PIPE_ACCESS_DUPLEX, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, + 1, // nMaxInstances + 0x24, // nOutBufferSize + 0x338, // nInBufferSize + 1000, // nDefaultTimeOut + IntPtr.Zero); // lpSecurityAttributes return !profilerPipe.IsInvalid; } @@ -555,7 +555,7 @@ private static unsafe IntPtr FindTimeOutOptionAddress() { IntPtr sectionAddr; uint sectionSize; if (!peInfo.FindSection(".rdata", out sectionAddr, out sectionSize) && - !peInfo.FindSection(".text", out sectionAddr, out sectionSize)) + !peInfo.FindSection(".text", out sectionAddr, out sectionSize)) return IntPtr.Zero; var p = (byte*)sectionAddr; @@ -793,15 +793,15 @@ private unsafe bool FindProfilerControlBlock() { else addr = new IntPtr(p + 5 + *(int*)(p + 1)); } - // 8B 05 xx xx xx xx mov eax,[mem] - // 83 F8 04 cmp eax,4 + // 8B 05 xx xx xx xx mov eax,[mem] + // 83 F8 04 cmp eax,4 else if (*p == 0x8B && p[1] == 0x05 && p[6] == 0x83 && p[7] == 0xF8 && p[8] == 0x04) { if (IntPtr.Size == 4) addr = new IntPtr((void*)*(uint*)(p + 2)); else addr = new IntPtr(p + 6 + *(int*)(p + 2)); } - // 83 3D XX XX XX XX 04 cmp dword ptr [mem],4 + // 83 3D XX XX XX XX 04 cmp dword ptr [mem],4 else if (*p == 0x83 && p[1] == 0x3D && p[6] == 0x04) { if (IntPtr.Size == 4) addr = new IntPtr((void*)*(uint*)(p + 2)); @@ -852,4 +852,4 @@ public override unsafe void PreventActiveProfilerFromReceivingProfilingMessages( } } -} \ No newline at end of file +} diff --git a/Confuser.Runtime/antinet/HandleProcessCorruptedStateExceptionsAttribute.cs b/Confuser.Runtime/antinet/HandleProcessCorruptedStateExceptionsAttribute.cs index ee61a6982..2dd78687e 100644 --- a/Confuser.Runtime/antinet/HandleProcessCorruptedStateExceptionsAttribute.cs +++ b/Confuser.Runtime/antinet/HandleProcessCorruptedStateExceptionsAttribute.cs @@ -5,4 +5,4 @@ namespace System.Runtime.ExceptionServices { internal class HandleProcessCorruptedStateExceptionsAttribute : Attribute { } -} \ No newline at end of file +} diff --git a/Confuser.Runtime/antinet/PEInfo.cs b/Confuser.Runtime/antinet/PEInfo.cs index ceb1a9074..7567e7f6e 100644 --- a/Confuser.Runtime/antinet/PEInfo.cs +++ b/Confuser.Runtime/antinet/PEInfo.cs @@ -160,4 +160,4 @@ public static bool IsAligned(IntPtr addr, uint alignment) { } } -} \ No newline at end of file +} diff --git a/Confuser2.sln b/Confuser2.sln index cbacdd964..b200f0781 100644 --- a/Confuser2.sln +++ b/Confuser2.sln @@ -151,6 +151,60 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "470_ImplementationInBaseCla EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "470_ImplementationInBaseClass.Test", "Tests\470_ImplementationInBaseClass.Test\470_ImplementationInBaseClass.Test.csproj", "{F7581FB4-FAF5-4CD0-888A-B588F5BC69CD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Confuser.CLI.Test", "Tests\Confuser.CLI.Test\Confuser.CLI.Test.csproj", "{2E824EE5-2955-4C21-A16F-9867DFE7238D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Confuser.GUI.Test", "Tests\Confuser.GUI.Test\Confuser.GUI.Test.csproj", "{C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Console.Net10", "Tests\CrossFramework.Console.Net10\CrossFramework.Console.Net10.csproj", "{DA4385C6-BEEA-475F-947D-D06CC15AE36F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Console.Net20", "Tests\CrossFramework.Console.Net20\CrossFramework.Console.Net20.csproj", "{6D4C6502-8155-49DD-BBB1-7E99F5782738}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Console.Net35", "Tests\CrossFramework.Console.Net35\CrossFramework.Console.Net35.csproj", "{56A9138E-23D0-45AE-AA0C-EB27AC14064C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Console.Net40", "Tests\CrossFramework.Console.Net40\CrossFramework.Console.Net40.csproj", "{2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Console.Net48", "Tests\CrossFramework.Console.Net48\CrossFramework.Console.Net48.csproj", "{7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Console.Net6", "Tests\CrossFramework.Console.Net6\CrossFramework.Console.Net6.csproj", "{FA75BDE0-9364-4A18-BF26-2110DA417797}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Console.Net8", "Tests\CrossFramework.Console.Net8\CrossFramework.Console.Net8.csproj", "{9273835F-C47F-4705-87AE-0EF7BDBFC85A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Library.Net8", "Tests\CrossFramework.Library.Net8\CrossFramework.Library.Net8.csproj", "{3C326F28-33CE-44FC-89BE-2DAA0D087644}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Library.NetStd20", "Tests\CrossFramework.Library.NetStd20\CrossFramework.Library.NetStd20.csproj", "{61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Test", "Tests\CrossFramework.Test\CrossFramework.Test.csproj", "{88CA9001-6138-4D0F-98D9-EC59A75FE1E8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WinForms.Net35", "Tests\CrossFramework.WinForms.Net35\CrossFramework.WinForms.Net35.csproj", "{EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WinForms.Net40", "Tests\CrossFramework.WinForms.Net40\CrossFramework.WinForms.Net40.csproj", "{1227C9C3-068C-4643-8E7C-8D90552243EE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WinForms.Net48", "Tests\CrossFramework.WinForms.Net48\CrossFramework.WinForms.Net48.csproj", "{8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WinForms.Net10", "Tests\CrossFramework.WinForms.Net10\CrossFramework.WinForms.Net10.csproj", "{0323A3B1-8607-4914-894F-08BBBD1D8618}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WPF.Net35", "Tests\CrossFramework.WPF.Net35\CrossFramework.WPF.Net35.csproj", "{CB4835D2-06BC-472F-9B5A-D3844C5D8D81}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WPF.Net40", "Tests\CrossFramework.WPF.Net40\CrossFramework.WPF.Net40.csproj", "{79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WPF.Net48", "Tests\CrossFramework.WPF.Net48\CrossFramework.WPF.Net48.csproj", "{EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WPF.Net10", "Tests\CrossFramework.WPF.Net10\CrossFramework.WPF.Net10.csproj", "{DE876679-5C28-45B3-BDFB-952C9C586CA1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WinForms.Net6", "Tests\CrossFramework.WinForms.Net6\CrossFramework.WinForms.Net6.csproj", "{3FB8F727-BD28-455C-A14A-09DCE7C42E90}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WinForms.Net8", "Tests\CrossFramework.WinForms.Net8\CrossFramework.WinForms.Net8.csproj", "{424E07DB-C32E-4AAE-BE50-D839AF541041}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Library.Net48", "Tests\CrossFramework.Library.Net48\CrossFramework.Library.Net48.csproj", "{EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Library.Net6", "Tests\CrossFramework.Library.Net6\CrossFramework.Library.Net6.csproj", "{0E65E38D-3A0D-42DB-ACD1-38096CE56092}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WPF.Net6", "Tests\CrossFramework.WPF.Net6\CrossFramework.WPF.Net6.csproj", "{3942E3FD-06BC-470C-A1ED-BB18F2332B94}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.WPF.Net8", "Tests\CrossFramework.WPF.Net8\CrossFramework.WPF.Net8.csproj", "{30DC9F52-E08A-4EF0-B041-04AED6135C3D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossFramework.Library.Net10", "Tests\CrossFramework.Library.Net10\CrossFramework.Library.Net10.csproj", "{4458415A-0F5E-4136-B723-7A67955D6047}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -965,6 +1019,330 @@ Global {F7581FB4-FAF5-4CD0-888A-B588F5BC69CD}.Release|x64.Build.0 = Release|Any CPU {F7581FB4-FAF5-4CD0-888A-B588F5BC69CD}.Release|x86.ActiveCfg = Release|Any CPU {F7581FB4-FAF5-4CD0-888A-B588F5BC69CD}.Release|x86.Build.0 = Release|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Debug|x64.ActiveCfg = Debug|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Debug|x64.Build.0 = Debug|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Debug|x86.ActiveCfg = Debug|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Debug|x86.Build.0 = Debug|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Release|Any CPU.Build.0 = Release|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Release|x64.ActiveCfg = Release|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Release|x64.Build.0 = Release|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Release|x86.ActiveCfg = Release|Any CPU + {2E824EE5-2955-4C21-A16F-9867DFE7238D}.Release|x86.Build.0 = Release|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Debug|x64.ActiveCfg = Debug|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Debug|x64.Build.0 = Debug|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Debug|x86.ActiveCfg = Debug|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Debug|x86.Build.0 = Debug|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Release|Any CPU.Build.0 = Release|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Release|x64.ActiveCfg = Release|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Release|x64.Build.0 = Release|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Release|x86.ActiveCfg = Release|Any CPU + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5}.Release|x86.Build.0 = Release|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Debug|x64.ActiveCfg = Debug|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Debug|x64.Build.0 = Debug|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Debug|x86.ActiveCfg = Debug|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Debug|x86.Build.0 = Debug|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Release|Any CPU.Build.0 = Release|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Release|x64.ActiveCfg = Release|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Release|x64.Build.0 = Release|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Release|x86.ActiveCfg = Release|Any CPU + {DA4385C6-BEEA-475F-947D-D06CC15AE36F}.Release|x86.Build.0 = Release|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Debug|x64.ActiveCfg = Debug|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Debug|x64.Build.0 = Debug|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Debug|x86.ActiveCfg = Debug|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Debug|x86.Build.0 = Debug|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Release|Any CPU.Build.0 = Release|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Release|x64.ActiveCfg = Release|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Release|x64.Build.0 = Release|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Release|x86.ActiveCfg = Release|Any CPU + {6D4C6502-8155-49DD-BBB1-7E99F5782738}.Release|x86.Build.0 = Release|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Debug|x64.ActiveCfg = Debug|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Debug|x64.Build.0 = Debug|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Debug|x86.ActiveCfg = Debug|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Debug|x86.Build.0 = Debug|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Release|Any CPU.Build.0 = Release|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Release|x64.ActiveCfg = Release|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Release|x64.Build.0 = Release|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Release|x86.ActiveCfg = Release|Any CPU + {56A9138E-23D0-45AE-AA0C-EB27AC14064C}.Release|x86.Build.0 = Release|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Debug|x64.ActiveCfg = Debug|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Debug|x64.Build.0 = Debug|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Debug|x86.ActiveCfg = Debug|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Debug|x86.Build.0 = Debug|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Release|Any CPU.Build.0 = Release|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Release|x64.ActiveCfg = Release|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Release|x64.Build.0 = Release|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Release|x86.ActiveCfg = Release|Any CPU + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7}.Release|x86.Build.0 = Release|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Debug|x64.ActiveCfg = Debug|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Debug|x64.Build.0 = Debug|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Debug|x86.ActiveCfg = Debug|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Debug|x86.Build.0 = Debug|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Release|Any CPU.Build.0 = Release|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Release|x64.ActiveCfg = Release|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Release|x64.Build.0 = Release|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Release|x86.ActiveCfg = Release|Any CPU + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF}.Release|x86.Build.0 = Release|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Debug|x64.ActiveCfg = Debug|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Debug|x64.Build.0 = Debug|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Debug|x86.ActiveCfg = Debug|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Debug|x86.Build.0 = Debug|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Release|Any CPU.Build.0 = Release|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Release|x64.ActiveCfg = Release|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Release|x64.Build.0 = Release|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Release|x86.ActiveCfg = Release|Any CPU + {FA75BDE0-9364-4A18-BF26-2110DA417797}.Release|x86.Build.0 = Release|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Debug|x64.ActiveCfg = Debug|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Debug|x64.Build.0 = Debug|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Debug|x86.ActiveCfg = Debug|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Debug|x86.Build.0 = Debug|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Release|Any CPU.Build.0 = Release|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Release|x64.ActiveCfg = Release|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Release|x64.Build.0 = Release|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Release|x86.ActiveCfg = Release|Any CPU + {9273835F-C47F-4705-87AE-0EF7BDBFC85A}.Release|x86.Build.0 = Release|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Debug|x64.ActiveCfg = Debug|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Debug|x64.Build.0 = Debug|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Debug|x86.ActiveCfg = Debug|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Debug|x86.Build.0 = Debug|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Release|Any CPU.Build.0 = Release|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Release|x64.ActiveCfg = Release|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Release|x64.Build.0 = Release|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Release|x86.ActiveCfg = Release|Any CPU + {3C326F28-33CE-44FC-89BE-2DAA0D087644}.Release|x86.Build.0 = Release|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Debug|x64.ActiveCfg = Debug|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Debug|x64.Build.0 = Debug|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Debug|x86.ActiveCfg = Debug|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Debug|x86.Build.0 = Debug|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Release|Any CPU.Build.0 = Release|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Release|x64.ActiveCfg = Release|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Release|x64.Build.0 = Release|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Release|x86.ActiveCfg = Release|Any CPU + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA}.Release|x86.Build.0 = Release|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Debug|x64.ActiveCfg = Debug|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Debug|x64.Build.0 = Debug|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Debug|x86.ActiveCfg = Debug|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Debug|x86.Build.0 = Debug|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Release|Any CPU.Build.0 = Release|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Release|x64.ActiveCfg = Release|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Release|x64.Build.0 = Release|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Release|x86.ActiveCfg = Release|Any CPU + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8}.Release|x86.Build.0 = Release|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Debug|x64.ActiveCfg = Debug|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Debug|x64.Build.0 = Debug|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Debug|x86.ActiveCfg = Debug|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Debug|x86.Build.0 = Debug|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Release|Any CPU.Build.0 = Release|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Release|x64.ActiveCfg = Release|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Release|x64.Build.0 = Release|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Release|x86.ActiveCfg = Release|Any CPU + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0}.Release|x86.Build.0 = Release|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Debug|x64.ActiveCfg = Debug|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Debug|x64.Build.0 = Debug|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Debug|x86.ActiveCfg = Debug|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Debug|x86.Build.0 = Debug|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Release|Any CPU.Build.0 = Release|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Release|x64.ActiveCfg = Release|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Release|x64.Build.0 = Release|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Release|x86.ActiveCfg = Release|Any CPU + {1227C9C3-068C-4643-8E7C-8D90552243EE}.Release|x86.Build.0 = Release|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Debug|x64.ActiveCfg = Debug|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Debug|x64.Build.0 = Debug|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Debug|x86.ActiveCfg = Debug|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Debug|x86.Build.0 = Debug|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Release|Any CPU.Build.0 = Release|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Release|x64.ActiveCfg = Release|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Release|x64.Build.0 = Release|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Release|x86.ActiveCfg = Release|Any CPU + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B}.Release|x86.Build.0 = Release|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Debug|x64.ActiveCfg = Debug|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Debug|x64.Build.0 = Debug|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Debug|x86.ActiveCfg = Debug|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Debug|x86.Build.0 = Debug|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Release|Any CPU.Build.0 = Release|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Release|x64.ActiveCfg = Release|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Release|x64.Build.0 = Release|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Release|x86.ActiveCfg = Release|Any CPU + {0323A3B1-8607-4914-894F-08BBBD1D8618}.Release|x86.Build.0 = Release|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Debug|x64.ActiveCfg = Debug|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Debug|x64.Build.0 = Debug|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Debug|x86.ActiveCfg = Debug|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Debug|x86.Build.0 = Debug|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Release|Any CPU.Build.0 = Release|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Release|x64.ActiveCfg = Release|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Release|x64.Build.0 = Release|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Release|x86.ActiveCfg = Release|Any CPU + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81}.Release|x86.Build.0 = Release|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Debug|x64.ActiveCfg = Debug|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Debug|x64.Build.0 = Debug|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Debug|x86.ActiveCfg = Debug|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Debug|x86.Build.0 = Debug|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Release|Any CPU.Build.0 = Release|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Release|x64.ActiveCfg = Release|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Release|x64.Build.0 = Release|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Release|x86.ActiveCfg = Release|Any CPU + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC}.Release|x86.Build.0 = Release|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Debug|x64.ActiveCfg = Debug|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Debug|x64.Build.0 = Debug|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Debug|x86.ActiveCfg = Debug|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Debug|x86.Build.0 = Debug|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Release|Any CPU.Build.0 = Release|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Release|x64.ActiveCfg = Release|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Release|x64.Build.0 = Release|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Release|x86.ActiveCfg = Release|Any CPU + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0}.Release|x86.Build.0 = Release|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Debug|x64.ActiveCfg = Debug|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Debug|x64.Build.0 = Debug|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Debug|x86.ActiveCfg = Debug|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Debug|x86.Build.0 = Debug|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Release|Any CPU.Build.0 = Release|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Release|x64.ActiveCfg = Release|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Release|x64.Build.0 = Release|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Release|x86.ActiveCfg = Release|Any CPU + {DE876679-5C28-45B3-BDFB-952C9C586CA1}.Release|x86.Build.0 = Release|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Debug|x64.ActiveCfg = Debug|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Debug|x64.Build.0 = Debug|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Debug|x86.ActiveCfg = Debug|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Debug|x86.Build.0 = Debug|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Release|Any CPU.Build.0 = Release|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Release|x64.ActiveCfg = Release|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Release|x64.Build.0 = Release|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Release|x86.ActiveCfg = Release|Any CPU + {3FB8F727-BD28-455C-A14A-09DCE7C42E90}.Release|x86.Build.0 = Release|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Debug|Any CPU.Build.0 = Debug|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Debug|x64.ActiveCfg = Debug|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Debug|x64.Build.0 = Debug|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Debug|x86.ActiveCfg = Debug|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Debug|x86.Build.0 = Debug|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Release|Any CPU.ActiveCfg = Release|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Release|Any CPU.Build.0 = Release|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Release|x64.ActiveCfg = Release|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Release|x64.Build.0 = Release|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Release|x86.ActiveCfg = Release|Any CPU + {424E07DB-C32E-4AAE-BE50-D839AF541041}.Release|x86.Build.0 = Release|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Debug|x64.ActiveCfg = Debug|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Debug|x64.Build.0 = Debug|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Debug|x86.ActiveCfg = Debug|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Debug|x86.Build.0 = Debug|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Release|Any CPU.Build.0 = Release|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Release|x64.ActiveCfg = Release|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Release|x64.Build.0 = Release|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Release|x86.ActiveCfg = Release|Any CPU + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F}.Release|x86.Build.0 = Release|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Debug|x64.ActiveCfg = Debug|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Debug|x64.Build.0 = Debug|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Debug|x86.ActiveCfg = Debug|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Debug|x86.Build.0 = Debug|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Release|Any CPU.Build.0 = Release|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Release|x64.ActiveCfg = Release|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Release|x64.Build.0 = Release|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Release|x86.ActiveCfg = Release|Any CPU + {0E65E38D-3A0D-42DB-ACD1-38096CE56092}.Release|x86.Build.0 = Release|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Debug|x64.ActiveCfg = Debug|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Debug|x64.Build.0 = Debug|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Debug|x86.ActiveCfg = Debug|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Debug|x86.Build.0 = Debug|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Release|Any CPU.Build.0 = Release|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Release|x64.ActiveCfg = Release|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Release|x64.Build.0 = Release|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Release|x86.ActiveCfg = Release|Any CPU + {3942E3FD-06BC-470C-A1ED-BB18F2332B94}.Release|x86.Build.0 = Release|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Debug|x64.ActiveCfg = Debug|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Debug|x64.Build.0 = Debug|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Debug|x86.ActiveCfg = Debug|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Debug|x86.Build.0 = Debug|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Release|Any CPU.Build.0 = Release|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Release|x64.ActiveCfg = Release|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Release|x64.Build.0 = Release|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Release|x86.ActiveCfg = Release|Any CPU + {30DC9F52-E08A-4EF0-B041-04AED6135C3D}.Release|x86.Build.0 = Release|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Debug|x64.ActiveCfg = Debug|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Debug|x64.Build.0 = Debug|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Debug|x86.ActiveCfg = Debug|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Debug|x86.Build.0 = Debug|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Release|Any CPU.Build.0 = Release|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Release|x64.ActiveCfg = Release|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Release|x64.Build.0 = Release|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Release|x86.ActiveCfg = Release|Any CPU + {4458415A-0F5E-4136-B723-7A67955D6047}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1029,6 +1407,33 @@ Global {B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} {5D10ED0A-6C52-49FE-90F5-CFAAECA8FABE} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} {F7581FB4-FAF5-4CD0-888A-B588F5BC69CD} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {2E824EE5-2955-4C21-A16F-9867DFE7238D} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {C3EA99B7-7B9F-4589-BCCC-5D3D61C082B5} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {DA4385C6-BEEA-475F-947D-D06CC15AE36F} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {6D4C6502-8155-49DD-BBB1-7E99F5782738} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {56A9138E-23D0-45AE-AA0C-EB27AC14064C} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {2B085FD5-3AC9-4E5E-A9B1-E8A7B0628FD7} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {7DDCA8D5-BE85-4BD4-9B47-85B29D2FA3AF} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {FA75BDE0-9364-4A18-BF26-2110DA417797} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {9273835F-C47F-4705-87AE-0EF7BDBFC85A} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {3C326F28-33CE-44FC-89BE-2DAA0D087644} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {61AC60A9-C462-44BB-B792-3D6EA1C1FFAA} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {88CA9001-6138-4D0F-98D9-EC59A75FE1E8} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {EA611DF7-7FA6-4FA4-BE18-E6C569618FB0} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {1227C9C3-068C-4643-8E7C-8D90552243EE} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {8A95BAB0-ACFF-43B5-BA77-A78A3C24611B} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {0323A3B1-8607-4914-894F-08BBBD1D8618} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {CB4835D2-06BC-472F-9B5A-D3844C5D8D81} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {79A8C4D6-2199-4B0D-BCBE-E0FCA93A8BDC} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {EB8D610B-E413-4C6E-97A2-AA92EA2C1DA0} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {DE876679-5C28-45B3-BDFB-952C9C586CA1} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {3FB8F727-BD28-455C-A14A-09DCE7C42E90} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {424E07DB-C32E-4AAE-BE50-D839AF541041} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {EF581C5C-5AAB-4A35-A2E4-1583CB4FDB9F} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {0E65E38D-3A0D-42DB-ACD1-38096CE56092} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {3942E3FD-06BC-470C-A1ED-BB18F2332B94} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {30DC9F52-E08A-4EF0-B041-04AED6135C3D} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} + {4458415A-0F5E-4136-B723-7A67955D6047} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0D937D9E-E04B-4A68-B639-D4260473A388} diff --git a/ConfuserEx.Common.props b/ConfuserEx.Common.props index e597a9e26..612e6611a 100644 --- a/ConfuserEx.Common.props +++ b/ConfuserEx.Common.props @@ -1,15 +1,15 @@ - true - 7.3 + true + latest <_CurrentYear>$([System.DateTime]::Now.ToString(yyyy)) Ki;Martin Karing Copyright © 2014 Ki, 2018 - $(_CurrentYear) Martin Karing - https://github.com/mkaring/ConfuserEx.git + https://github.com/mcpolo99/ConfuserExx.git git diff --git a/ConfuserEx/App.xaml.cs b/ConfuserEx/App.xaml.cs index df9c8accd..0ffef6bf7 100644 --- a/ConfuserEx/App.xaml.cs +++ b/ConfuserEx/App.xaml.cs @@ -3,4 +3,4 @@ namespace ConfuserEx { public partial class App : Application { } -} \ No newline at end of file +} diff --git a/ConfuserEx/BoolToVisibilityConverter.cs b/ConfuserEx/BoolToVisibilityConverter.cs index 2d5afb72d..3ff0b8a2f 100644 --- a/ConfuserEx/BoolToVisibilityConverter.cs +++ b/ConfuserEx/BoolToVisibilityConverter.cs @@ -19,4 +19,4 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu throw new NotSupportedException(); } } -} \ No newline at end of file +} diff --git a/ConfuserEx/BrushToColorConverter.cs b/ConfuserEx/BrushToColorConverter.cs index 23a9212a5..5cdf1d8b7 100644 --- a/ConfuserEx/BrushToColorConverter.cs +++ b/ConfuserEx/BrushToColorConverter.cs @@ -19,4 +19,4 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/ConfuserEx/CompComboBox.xaml.cs b/ConfuserEx/CompComboBox.xaml.cs index c3cff594e..d7e826014 100644 --- a/ConfuserEx/CompComboBox.xaml.cs +++ b/ConfuserEx/CompComboBox.xaml.cs @@ -29,4 +29,4 @@ public Dictionary Arguments { set { SetValue(ArgumentsProperty, value); } } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ComponentConverter.cs b/ConfuserEx/ComponentConverter.cs index d11bd5f8c..259e64103 100644 --- a/ConfuserEx/ComponentConverter.cs +++ b/ConfuserEx/ComponentConverter.cs @@ -37,4 +37,4 @@ protected override Freezable CreateInstanceCore() { return new ComponentConverter(); } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ComponentDiscovery.cs b/ConfuserEx/ComponentDiscovery.cs index 3a8988579..dc1276da0 100644 --- a/ConfuserEx/ComponentDiscovery.cs +++ b/ConfuserEx/ComponentDiscovery.cs @@ -1,38 +1,34 @@ -using System; +using System; using System.Collections.Generic; +using System.IO; using System.Reflection; +using System.Runtime.Loader; using Confuser.Core; namespace ConfuserEx { internal class ComponentDiscovery { - static void CrossDomainLoadComponents() { - var ctx = (CrossDomainContext)AppDomain.CurrentDomain.GetData("ctx"); - // Initialize the version resolver callback - ConfuserEngine.Version.ToString(); - - Assembly assembly = Assembly.LoadFile(ctx.PluginPath); - foreach (var module in assembly.GetLoadedModules()) - foreach (var i in module.GetTypes()) { - if (i.IsAbstract || !PluginDiscovery.HasAccessibleDefConstructor(i)) - continue; - - if (typeof(Protection).IsAssignableFrom(i)) { - var prot = (Protection)Activator.CreateInstance(i); - ctx.AddProtection(Info.FromComponent(prot, ctx.PluginPath)); - } - else if (typeof(Packer).IsAssignableFrom(i)) { - var packer = (Packer)Activator.CreateInstance(i); - ctx.AddPacker(Info.FromComponent(packer, ctx.PluginPath)); - } - } - } - public static void LoadComponents(IList protections, IList packers, string pluginPath) { - var ctx = new CrossDomainContext(protections, packers, pluginPath); - AppDomain appDomain = AppDomain.CreateDomain(""); - appDomain.SetData("ctx", ctx); - appDomain.DoCallBack(CrossDomainLoadComponents); - AppDomain.Unload(appDomain); + var alc = new PluginLoadContext(pluginPath); + try { + Assembly assembly = alc.LoadFromAssemblyPath(pluginPath); + foreach (var module in assembly.GetLoadedModules()) + foreach (var i in module.GetTypes()) { + if (i.IsAbstract || !PluginDiscovery.HasAccessibleDefConstructor(i)) + continue; + + if (typeof(Protection).IsAssignableFrom(i)) { + var prot = (Protection)Activator.CreateInstance(i); + AddProtection(protections, Info.FromComponent(prot, pluginPath)); + } + else if (typeof(Packer).IsAssignableFrom(i)) { + var packer = (Packer)Activator.CreateInstance(i); + AddPacker(packers, Info.FromComponent(packer, pluginPath)); + } + } + } + finally { + alc.Unload(); + } } public static void RemoveComponents(IList protections, IList packers, string pluginPath) { @@ -40,39 +36,55 @@ public static void RemoveComponents(IList protections, IList< packers.RemoveWhere(comp => comp is InfoComponent && ((InfoComponent)comp).info.path == pluginPath); } - class CrossDomainContext : MarshalByRefObject { - readonly IList packers; - readonly string pluginPath; - readonly IList protections; + static void AddProtection(IList protections, Info info) { + foreach (var comp in protections) { + if (comp.Id == info.id) + return; + } + protections.Add(new InfoComponent(info)); + } - public CrossDomainContext(IList protections, IList packers, string pluginPath) { - this.protections = protections; - this.packers = packers; - this.pluginPath = pluginPath; + static void AddPacker(IList packers, Info info) { + foreach (var comp in packers) { + if (comp.Id == info.id) + return; } + packers.Add(new InfoComponent(info)); + } + + sealed class PluginLoadContext : AssemblyLoadContext { + readonly AssemblyDependencyResolver resolver; - public string PluginPath { - get { return pluginPath; } + public PluginLoadContext(string pluginPath) + : base(isCollectible: true) { + resolver = new AssemblyDependencyResolver(pluginPath); } - public void AddProtection(Info info) { - foreach (var comp in protections) { - if (comp.Id == info.id) - return; - } - protections.Add(new InfoComponent(info)); + protected override Assembly Load(AssemblyName assemblyName) { + // Defer to the default context for Confuser.Core types to maintain type identity + if (assemblyName.Name == "Confuser.Core" || + assemblyName.Name == "Confuser.Protections" || + assemblyName.Name == "Confuser.Renamer" || + assemblyName.Name == "Confuser.DynCipher" || + assemblyName.Name == "dnlib") + return null; + + string assemblyPath = resolver.ResolveAssemblyToPath(assemblyName); + if (assemblyPath != null) + return LoadFromAssemblyPath(assemblyPath); + + return null; } - public void AddPacker(Info info) { - foreach (var comp in packers) { - if (comp.Id == info.id) - return; - } - packers.Add(new InfoComponent(info)); + protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) { + string libraryPath = resolver.ResolveUnmanagedDllToPath(unmanagedDllName); + if (libraryPath != null) + return LoadUnmanagedDllFromPath(libraryPath); + + return IntPtr.Zero; } } - [Serializable] class Info { public string desc; public string fullId; @@ -123,4 +135,4 @@ protected override void PopulatePipeline(ProtectionPipeline pipeline) { } } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ConfuserEx.csproj b/ConfuserEx/ConfuserEx.csproj index f9f103e7a..5f11173c4 100644 --- a/ConfuserEx/ConfuserEx.csproj +++ b/ConfuserEx/ConfuserEx.csproj @@ -1,10 +1,10 @@ - + WinExe - net461 + net10.0-windows true true ..\ConfuserEx.snk @@ -17,8 +17,8 @@ - - + + @@ -33,6 +33,14 @@ + + + + + diff --git a/ConfuserEx/EmptyToBoolConverter.cs b/ConfuserEx/EmptyToBoolConverter.cs index 9fed4cace..af5ad01cb 100644 --- a/ConfuserEx/EmptyToBoolConverter.cs +++ b/ConfuserEx/EmptyToBoolConverter.cs @@ -23,7 +23,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn return string.IsNullOrEmpty(strValue) ? stateIfEmpty : !stateIfEmpty; } - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException(); } } diff --git a/ConfuserEx/EnumValuesExtension.cs b/ConfuserEx/EnumValuesExtension.cs index b52f014aa..dcffdfb64 100644 --- a/ConfuserEx/EnumValuesExtension.cs +++ b/ConfuserEx/EnumValuesExtension.cs @@ -13,4 +13,4 @@ public override object ProvideValue(IServiceProvider serviceProvider) { return Enum.GetValues(enumType); } } -} \ No newline at end of file +} diff --git a/ConfuserEx/FileDragDrop.cs b/ConfuserEx/FileDragDrop.cs index c58a5a10a..eb0432a8a 100644 --- a/ConfuserEx/FileDragDrop.cs +++ b/ConfuserEx/FileDragDrop.cs @@ -6,15 +6,15 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using CommunityToolkit.Mvvm.Input; using ConfuserEx.ViewModel; -using GalaSoft.MvvmLight.CommandWpf; namespace ConfuserEx { public class FileDragDrop { public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached("Command", typeof(ICommand), typeof(FileDragDrop), new UIPropertyMetadata(null, OnCommandChanged)); - public static ICommand FileCmd = new DragDropCommand( + public static ICommand FileCmd = new RelayCommand>( data => { Debug.Assert(data.Item2.GetDataPresent(DataFormats.FileDrop)); if (data.Item1 is TextBox) { @@ -38,7 +38,7 @@ public class FileDragDrop { }); - public static ICommand DirectoryCmd = new DragDropCommand( + public static ICommand DirectoryCmd = new RelayCommand>( data => { Debug.Assert(data.Item2.GetDataPresent(DataFormats.FileDrop)); if (data.Item1 is TextBox) { @@ -86,7 +86,7 @@ static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventA static void OnDragOver(object sender, DragEventArgs e) { ICommand cmd = GetCommand((DependencyObject)sender); e.Effects = DragDropEffects.None; - if (cmd is DragDropCommand) { + if (cmd is RelayCommand>) { if (cmd.CanExecute(Tuple.Create((UIElement)sender, e.Data))) e.Effects = DragDropEffects.Link; } @@ -99,7 +99,7 @@ static void OnDragOver(object sender, DragEventArgs e) { static void OnDrop(object sender, DragEventArgs e) { ICommand cmd = GetCommand((DependencyObject)sender); - if (cmd is DragDropCommand) { + if (cmd is RelayCommand>) { if (cmd.CanExecute(Tuple.Create((UIElement)sender, e.Data))) cmd.Execute(Tuple.Create((UIElement)sender, e.Data)); } @@ -111,9 +111,5 @@ static void OnDrop(object sender, DragEventArgs e) { } - class DragDropCommand : RelayCommand> { - public DragDropCommand(Action> execute, Func, bool> canExecute) - : base(execute, canExecute) { } - } } -} \ No newline at end of file +} diff --git a/ConfuserEx/InvertBoolConverter.cs b/ConfuserEx/InvertBoolConverter.cs index 8d5269253..81db9e478 100644 --- a/ConfuserEx/InvertBoolConverter.cs +++ b/ConfuserEx/InvertBoolConverter.cs @@ -18,4 +18,4 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu throw new NotSupportedException(); } } -} \ No newline at end of file +} diff --git a/ConfuserEx/MainWindow.xaml.cs b/ConfuserEx/MainWindow.xaml.cs index 52abfb6e9..07ee5b2ac 100644 --- a/ConfuserEx/MainWindow.xaml.cs +++ b/ConfuserEx/MainWindow.xaml.cs @@ -59,4 +59,4 @@ protected override void OnClosing(CancelEventArgs e) { e.Cancel = !((AppVM)DataContext).OnWindowClosing(); } } -} \ No newline at end of file +} diff --git a/ConfuserEx/Skin.cs b/ConfuserEx/Skin.cs index b182e18e3..de8570607 100644 --- a/ConfuserEx/Skin.cs +++ b/ConfuserEx/Skin.cs @@ -59,4 +59,4 @@ public static void SetRTBDocument(DependencyObject obj, FlowDocument value) { obj.SetValue(RTBDocumentProperty, value); } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ViewModel/IViewModel.cs b/ConfuserEx/ViewModel/IViewModel.cs index dcfa0d430..f7b86175b 100644 --- a/ConfuserEx/ViewModel/IViewModel.cs +++ b/ConfuserEx/ViewModel/IViewModel.cs @@ -4,4 +4,4 @@ namespace ConfuserEx.ViewModel { public interface IViewModel { TModel Model { get; } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ViewModel/Project/ProjectRuleVM.cs b/ConfuserEx/ViewModel/Project/ProjectRuleVM.cs index f15940d26..46c242a81 100644 --- a/ConfuserEx/ViewModel/Project/ProjectRuleVM.cs +++ b/ConfuserEx/ViewModel/Project/ProjectRuleVM.cs @@ -88,4 +88,4 @@ void ParseExpression() { Expression = expression; } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ViewModel/Project/ProjectSettingVM.cs b/ConfuserEx/ViewModel/Project/ProjectSettingVM.cs index 72b5fac38..98d3c5528 100644 --- a/ConfuserEx/ViewModel/Project/ProjectSettingVM.cs +++ b/ConfuserEx/ViewModel/Project/ProjectSettingVM.cs @@ -31,4 +31,4 @@ SettingItem IViewModel>.Model { get { return setting; } } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ViewModel/StringItem.cs b/ConfuserEx/ViewModel/StringItem.cs index b81f292ee..f63ab1fb1 100644 --- a/ConfuserEx/ViewModel/StringItem.cs +++ b/ConfuserEx/ViewModel/StringItem.cs @@ -16,4 +16,4 @@ public override string ToString() { return Item; } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ViewModel/UI/AboutTabVM.cs b/ConfuserEx/ViewModel/UI/AboutTabVM.cs index 113b452af..ec4a2bc3a 100644 --- a/ConfuserEx/ViewModel/UI/AboutTabVM.cs +++ b/ConfuserEx/ViewModel/UI/AboutTabVM.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Windows.Input; using System.Windows.Media.Imaging; -using GalaSoft.MvvmLight.CommandWpf; +using CommunityToolkit.Mvvm.Input; namespace ConfuserEx.ViewModel { internal class AboutTabVM : TabViewModel { @@ -15,9 +15,9 @@ public AboutTabVM(AppVM app) } public ICommand LaunchBrowser { - get { return new RelayCommand(site => Process.Start(site)); } + get { return new RelayCommand(site => Process.Start(new ProcessStartInfo(site) { UseShellExecute = true })); } } public BitmapSource Icon { get; private set; } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ViewModel/UI/AppVM.cs b/ConfuserEx/ViewModel/UI/AppVM.cs index b058b239c..c4c283221 100644 --- a/ConfuserEx/ViewModel/UI/AppVM.cs +++ b/ConfuserEx/ViewModel/UI/AppVM.cs @@ -6,9 +6,9 @@ using System.Windows; using System.Windows.Input; using System.Xml; +using CommunityToolkit.Mvvm.Input; using Confuser.Core; using Confuser.Core.Project; -using GalaSoft.MvvmLight.CommandWpf; using Ookii.Dialogs.Wpf; namespace ConfuserEx.ViewModel { @@ -49,9 +49,9 @@ public string FileName { public string Title { get { return string.Format("{0}{1} - {2}", - Path.GetFileName(fileName), - (proj.IsModified ? "*" : ""), - ConfuserEngine.Version); + Path.GetFileName(fileName), + (proj.IsModified ? "*" : ""), + ConfuserEngine.Version); } } diff --git a/ConfuserEx/ViewModel/UI/ProjectTabVM.cs b/ConfuserEx/ViewModel/UI/ProjectTabVM.cs index 899dd5f9f..a989f7bf8 100644 --- a/ConfuserEx/ViewModel/UI/ProjectTabVM.cs +++ b/ConfuserEx/ViewModel/UI/ProjectTabVM.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Windows; using System.Windows.Input; +using CommunityToolkit.Mvvm.Input; using Confuser.Core.Project; using ConfuserEx.Views; -using GalaSoft.MvvmLight.CommandWpf; using Ookii.Dialogs.Wpf; namespace ConfuserEx.ViewModel { diff --git a/ConfuserEx/ViewModel/UI/ProtectTabVM.cs b/ConfuserEx/ViewModel/UI/ProtectTabVM.cs index 7e2f1686e..a9f7088cc 100644 --- a/ConfuserEx/ViewModel/UI/ProtectTabVM.cs +++ b/ConfuserEx/ViewModel/UI/ProtectTabVM.cs @@ -5,9 +5,9 @@ using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; +using CommunityToolkit.Mvvm.Input; using Confuser.Core; using Confuser.Core.Project; -using GalaSoft.MvvmLight.CommandWpf; namespace ConfuserEx.ViewModel { internal class ProtectTabVM : TabViewModel, ILogger { @@ -58,12 +58,12 @@ void DoProtect() { App.NavigationDisabled = true; ConfuserEngine.Run(parameters, cancelSrc.Token) - .ContinueWith(_ => - Application.Current.Dispatcher.BeginInvoke(new Action(() => { - Progress = 0; - App.NavigationDisabled = false; - CommandManager.InvalidateRequerySuggested(); - }))); + .ContinueWith(_ => + Application.Current.Dispatcher.BeginInvoke(new Action(() => { + Progress = 0; + App.NavigationDisabled = false; + CommandManager.InvalidateRequerySuggested(); + }))); } void DoCancel() { diff --git a/ConfuserEx/ViewModel/UI/SettingsTabVM.cs b/ConfuserEx/ViewModel/UI/SettingsTabVM.cs index 5641d0886..3eb68739e 100644 --- a/ConfuserEx/ViewModel/UI/SettingsTabVM.cs +++ b/ConfuserEx/ViewModel/UI/SettingsTabVM.cs @@ -5,10 +5,10 @@ using System.Windows; using System.Windows.Data; using System.Windows.Input; +using CommunityToolkit.Mvvm.Input; using Confuser.Core; using Confuser.Core.Project; using ConfuserEx.Views; -using GalaSoft.MvvmLight.CommandWpf; namespace ConfuserEx.ViewModel { internal class SettingsTabVM : TabViewModel { @@ -47,7 +47,7 @@ public int SelectedRuleIndex { public ICommand Add { get { - var cmd = new RelayCommand(() => { + var cmd = new RelayCommand(() => { Debug.Assert(SelectedList != null); var rule = new ProjectRuleVM(App.Project, new Rule()); diff --git a/ConfuserEx/ViewModel/UI/TabViewModel.cs b/ConfuserEx/ViewModel/UI/TabViewModel.cs index 41c5ff40c..412c22f3e 100644 --- a/ConfuserEx/ViewModel/UI/TabViewModel.cs +++ b/ConfuserEx/ViewModel/UI/TabViewModel.cs @@ -10,4 +10,4 @@ protected TabViewModel(AppVM app, string header) { public AppVM App { get; private set; } public string Header { get; private set; } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ViewModel/Utils.cs b/ConfuserEx/ViewModel/Utils.cs index 02e546b21..c8ecb7ea5 100644 --- a/ConfuserEx/ViewModel/Utils.cs +++ b/ConfuserEx/ViewModel/Utils.cs @@ -76,4 +76,4 @@ public static ObservableCollection Wrap(IList(bool changed, Action setter, T value, string pr return false; } } -} \ No newline at end of file +} diff --git a/ConfuserEx/Views/ProjectModuleView.xaml.cs b/ConfuserEx/Views/ProjectModuleView.xaml.cs index 03b5dbfae..16bc31be3 100644 --- a/ConfuserEx/Views/ProjectModuleView.xaml.cs +++ b/ConfuserEx/Views/ProjectModuleView.xaml.cs @@ -18,10 +18,10 @@ void Done(object sender, RoutedEventArgs e) { DialogResult = true; } - void ChooseSNKey(object sender, RoutedEventArgs e) => + void ChooseSNKey(object sender, RoutedEventArgs e) => module.SNKeyPath = ChooseKey(); - void ChooseSNSigKey(object sender, RoutedEventArgs e) => + void ChooseSNSigKey(object sender, RoutedEventArgs e) => module.SNSigKeyPath = ChooseKey(); void ChooseSNPublicKey(object sender, RoutedEventArgs e) => diff --git a/ConfuserEx/Views/ProjectRuleView.xaml.cs b/ConfuserEx/Views/ProjectRuleView.xaml.cs index 6d8a15348..8da8f2df9 100644 --- a/ConfuserEx/Views/ProjectRuleView.xaml.cs +++ b/ConfuserEx/Views/ProjectRuleView.xaml.cs @@ -3,10 +3,10 @@ using System.Diagnostics; using System.Windows; using System.Windows.Media; +using CommunityToolkit.Mvvm.Input; using Confuser.Core; using Confuser.Core.Project; using ConfuserEx.ViewModel; -using GalaSoft.MvvmLight.CommandWpf; namespace ConfuserEx.Views { public partial class ProjectRuleView : Window { @@ -43,7 +43,7 @@ public override void OnApplyTemplate() { prots.SelectedIndex = selIndex >= rule.Protections.Count ? rule.Protections.Count - 1 : selIndex; }, () => prots.SelectedIndex != -1); - prots.SelectionChanged += (sender, args) => (RemoveBtn.Command as RelayCommand)?.RaiseCanExecuteChanged(); + prots.SelectionChanged += (sender, args) => (RemoveBtn.Command as RelayCommand)?.NotifyCanExecuteChanged(); } public void Cleanup() { diff --git a/ConfuserEx/Views/ProjectTabAdvancedView.xaml.cs b/ConfuserEx/Views/ProjectTabAdvancedView.xaml.cs index fe6bbd244..09b632064 100644 --- a/ConfuserEx/Views/ProjectTabAdvancedView.xaml.cs +++ b/ConfuserEx/Views/ProjectTabAdvancedView.xaml.cs @@ -1,8 +1,8 @@ using System; using System.Diagnostics; using System.Windows; +using CommunityToolkit.Mvvm.Input; using ConfuserEx.ViewModel; -using GalaSoft.MvvmLight.CommandWpf; using Ookii.Dialogs.Wpf; namespace ConfuserEx.Views { @@ -61,4 +61,4 @@ public override void OnApplyTemplate() { }, () => ProbePaths.SelectedIndex != -1); } } -} \ No newline at end of file +} diff --git a/README.md b/README.md index bec88334a..0c2c0814a 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,37 @@ The format of project file can be found in [docs/ProjectFormat.md][project_forma -snkeypass : specifies strong name key password ``` +## Building from Source + +### Prerequisites + +* [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) (or later) +* [.NET Framework 4.8 Developer Pack](https://dotnet.microsoft.com/download/dotnet-framework/net48) (for library targets and test subjects) +* [Visual Studio 2025+](https://visualstudio.microsoft.com/) with **Desktop development with C++** workload (for the C++/CLI test project) +* Windows 10/11 (WPF GUI is Windows-only) + +### Build + +```bash +# Full solution (requires VS 2025+ MSBuild 18) +msbuild Confuser2.sln -p:Configuration=Release + +# .NET projects only (without C++/CLI test project) +dotnet build Confuser2.sln -c Release + +# Run tests +dotnet test Confuser2.sln -c Release +``` + +### Target Frameworks + +| Project | TFM | +|---------|-----| +| Core, Protections, Renamer, DynCipher | net48 + netstandard2.0 | +| GUI (ConfuserEx) | net10.0-windows | +| CLI (Confuser.CLI) | net10.0 | +| Runtime | net20 (injected into targets) | + ## Bug Report See the [Issues][issues] section. Please check existing issues before filing a new one. diff --git a/Tests/118_EnhancedStrongName.Test/118_EnhancedStrongName.Test.csproj b/Tests/118_EnhancedStrongName.Test/118_EnhancedStrongName.Test.csproj index 2c0eb9046..7c166760c 100644 --- a/Tests/118_EnhancedStrongName.Test/118_EnhancedStrongName.Test.csproj +++ b/Tests/118_EnhancedStrongName.Test/118_EnhancedStrongName.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 EnhancedStrongName.Test false diff --git a/Tests/118_EnhancedStrongName.Test/EnhancedStrongNameTest.cs b/Tests/118_EnhancedStrongName.Test/EnhancedStrongNameTest.cs index 16e3c47dc..5d2ad7700 100644 --- a/Tests/118_EnhancedStrongName.Test/EnhancedStrongNameTest.cs +++ b/Tests/118_EnhancedStrongName.Test/EnhancedStrongNameTest.cs @@ -14,7 +14,7 @@ public EnhancedStrongNameTest(ITestOutputHelper outputHelper) : base(outputHelpe [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/118")] public async Task EnhancedStrongName() => await Run("118_EnhancedStrongName.exe", - new[] {"My strong key token: 79A18AF4CEA8A9BD", "My signature is valid!"}, + new[] { "My strong key token: 79A18AF4CEA8A9BD", "My signature is valid!" }, NoProtections, projectModuleAction: projectModule => { projectModule.SNSigKeyPath = Path.Combine(Environment.CurrentDirectory, "SignatureKey.snk"); diff --git a/Tests/118_EnhancedStrongName/118_EnhancedStrongName.csproj b/Tests/118_EnhancedStrongName/118_EnhancedStrongName.csproj index f14639c1f..59b0c6c6b 100644 --- a/Tests/118_EnhancedStrongName/118_EnhancedStrongName.csproj +++ b/Tests/118_EnhancedStrongName/118_EnhancedStrongName.csproj @@ -10,7 +10,15 @@ - + + + <_SnExeDir Condition="'$(SDK40ToolsPath)' != ''">$(SDK40ToolsPath) + <_SnExeDir Condition="'$(_SnExeDir)' == ''">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.8\WinSDK-NetFx40Tools', 'InstallationFolder', '', RegistryView.Registry32)) + <_SnExeDir Condition="'$(_SnExeDir)' == ''">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools', 'InstallationFolder', '', RegistryView.Registry32)) + + + diff --git a/Tests/118_EnhancedStrongName/IClrStrongName.cs b/Tests/118_EnhancedStrongName/IClrStrongName.cs index 7c8e77001..349b251fb 100644 --- a/Tests/118_EnhancedStrongName/IClrStrongName.cs +++ b/Tests/118_EnhancedStrongName/IClrStrongName.cs @@ -8,83 +8,83 @@ namespace EnhancedStrongName { [ComImport] internal interface IClrStrongName { [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int GetHashFromAssemblyFile([MarshalAs(UnmanagedType.LPStr)] [In] string pszFilePath, [MarshalAs(UnmanagedType.U4)] [In] [Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] [Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)] [In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); + int GetHashFromAssemblyFile([MarshalAs(UnmanagedType.LPStr)][In] string pszFilePath, [MarshalAs(UnmanagedType.U4)][In][Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)][Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)][In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int GetHashFromAssemblyFileW([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzFilePath, [MarshalAs(UnmanagedType.U4)] [In] [Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] [Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)] [In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); + int GetHashFromAssemblyFileW([MarshalAs(UnmanagedType.LPWStr)][In] string pwzFilePath, [MarshalAs(UnmanagedType.U4)][In][Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)][Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)][In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int GetHashFromBlob([In] IntPtr pbBlob, [MarshalAs(UnmanagedType.U4)] [In] int cchBlob, [MarshalAs(UnmanagedType.U4)] [In] [Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] [Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)] [In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); + int GetHashFromBlob([In] IntPtr pbBlob, [MarshalAs(UnmanagedType.U4)][In] int cchBlob, [MarshalAs(UnmanagedType.U4)][In][Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)][Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)][In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int GetHashFromFile([MarshalAs(UnmanagedType.LPStr)] [In] string pszFilePath, [MarshalAs(UnmanagedType.U4)] [In] [Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] [Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)] [In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); + int GetHashFromFile([MarshalAs(UnmanagedType.LPStr)][In] string pszFilePath, [MarshalAs(UnmanagedType.U4)][In][Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)][Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)][In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int GetHashFromFileW([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzFilePath, [MarshalAs(UnmanagedType.U4)] [In] [Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] [Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)] [In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); + int GetHashFromFileW([MarshalAs(UnmanagedType.LPWStr)][In] string pwzFilePath, [MarshalAs(UnmanagedType.U4)][In][Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)][Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)][In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int GetHashFromHandle([In] IntPtr hFile, [MarshalAs(UnmanagedType.U4)] [In] [Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] [Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)] [In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); + int GetHashFromHandle([In] IntPtr hFile, [MarshalAs(UnmanagedType.U4)][In][Out] ref int piHashAlg, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)][Out] byte[] pbHash, [MarshalAs(UnmanagedType.U4)][In] int cchHash, [MarshalAs(UnmanagedType.U4)] out int pchHash); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] [return: MarshalAs(UnmanagedType.U4)] - int StrongNameCompareAssemblies([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzAssembly1, [MarshalAs(UnmanagedType.LPWStr)] [In] string pwzAssembly2, [MarshalAs(UnmanagedType.U4)] out int dwResult); + int StrongNameCompareAssemblies([MarshalAs(UnmanagedType.LPWStr)][In] string pwzAssembly1, [MarshalAs(UnmanagedType.LPWStr)][In] string pwzAssembly2, [MarshalAs(UnmanagedType.U4)] out int dwResult); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] int StrongNameFreeBuffer([In] IntPtr pbMemory); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameGetBlob([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzFilePath, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] [Out] byte[] pbBlob, [MarshalAs(UnmanagedType.U4)] [In] [Out] ref int pcbBlob); + int StrongNameGetBlob([MarshalAs(UnmanagedType.LPWStr)][In] string pwzFilePath, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)][Out] byte[] pbBlob, [MarshalAs(UnmanagedType.U4)][In][Out] ref int pcbBlob); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameGetBlobFromImage([In] IntPtr pbBase, [MarshalAs(UnmanagedType.U4)] [In] int dwLength, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] [Out] byte[] pbBlob, [MarshalAs(UnmanagedType.U4)] [In] [Out] ref int pcbBlob); + int StrongNameGetBlobFromImage([In] IntPtr pbBase, [MarshalAs(UnmanagedType.U4)][In] int dwLength, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)][Out] byte[] pbBlob, [MarshalAs(UnmanagedType.U4)][In][Out] ref int pcbBlob); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameGetPublicKey([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzKeyContainer, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] [In] byte[] pbKeyBlob, [MarshalAs(UnmanagedType.U4)] [In] int cbKeyBlob, out IntPtr ppbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbPublicKeyBlob); + int StrongNameGetPublicKey([MarshalAs(UnmanagedType.LPWStr)][In] string pwzKeyContainer, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)][In] byte[] pbKeyBlob, [MarshalAs(UnmanagedType.U4)][In] int cbKeyBlob, out IntPtr ppbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbPublicKeyBlob); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] [return: MarshalAs(UnmanagedType.U4)] - int StrongNameHashSize([MarshalAs(UnmanagedType.U4)] [In] int ulHashAlg, [MarshalAs(UnmanagedType.U4)] out int cbSize); + int StrongNameHashSize([MarshalAs(UnmanagedType.U4)][In] int ulHashAlg, [MarshalAs(UnmanagedType.U4)] out int cbSize); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameKeyDelete([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzKeyContainer); + int StrongNameKeyDelete([MarshalAs(UnmanagedType.LPWStr)][In] string pwzKeyContainer); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameKeyGen([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzKeyContainer, [MarshalAs(UnmanagedType.U4)] [In] int dwFlags, out IntPtr ppbKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbKeyBlob); + int StrongNameKeyGen([MarshalAs(UnmanagedType.LPWStr)][In] string pwzKeyContainer, [MarshalAs(UnmanagedType.U4)][In] int dwFlags, out IntPtr ppbKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbKeyBlob); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameKeyGenEx([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzKeyContainer, [MarshalAs(UnmanagedType.U4)] [In] int dwFlags, [MarshalAs(UnmanagedType.U4)] [In] int dwKeySize, out IntPtr ppbKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbKeyBlob); + int StrongNameKeyGenEx([MarshalAs(UnmanagedType.LPWStr)][In] string pwzKeyContainer, [MarshalAs(UnmanagedType.U4)][In] int dwFlags, [MarshalAs(UnmanagedType.U4)][In] int dwKeySize, out IntPtr ppbKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbKeyBlob); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameKeyInstall([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzKeyContainer, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] [In] byte[] pbKeyBlob, [MarshalAs(UnmanagedType.U4)] [In] int cbKeyBlob); + int StrongNameKeyInstall([MarshalAs(UnmanagedType.LPWStr)][In] string pwzKeyContainer, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)][In] byte[] pbKeyBlob, [MarshalAs(UnmanagedType.U4)][In] int cbKeyBlob); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameSignatureGeneration([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzFilePath, [MarshalAs(UnmanagedType.LPWStr)] [In] string pwzKeyContainer, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] [In] byte[] pbKeyBlob, [MarshalAs(UnmanagedType.U4)] [In] int cbKeyBlob, [In] [Out] IntPtr ppbSignatureBlob, [MarshalAs(UnmanagedType.U4)] out int pcbSignatureBlob); + int StrongNameSignatureGeneration([MarshalAs(UnmanagedType.LPWStr)][In] string pwzFilePath, [MarshalAs(UnmanagedType.LPWStr)][In] string pwzKeyContainer, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)][In] byte[] pbKeyBlob, [MarshalAs(UnmanagedType.U4)][In] int cbKeyBlob, [In][Out] IntPtr ppbSignatureBlob, [MarshalAs(UnmanagedType.U4)] out int pcbSignatureBlob); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameSignatureGenerationEx([MarshalAs(UnmanagedType.LPWStr)] [In] string wszFilePath, [MarshalAs(UnmanagedType.LPWStr)] [In] string wszKeyContainer, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] [In] byte[] pbKeyBlob, [MarshalAs(UnmanagedType.U4)] [In] int cbKeyBlob, [In] [Out] IntPtr ppbSignatureBlob, [MarshalAs(UnmanagedType.U4)] out int pcbSignatureBlob, [MarshalAs(UnmanagedType.U4)] [In] int dwFlags); + int StrongNameSignatureGenerationEx([MarshalAs(UnmanagedType.LPWStr)][In] string wszFilePath, [MarshalAs(UnmanagedType.LPWStr)][In] string wszKeyContainer, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)][In] byte[] pbKeyBlob, [MarshalAs(UnmanagedType.U4)][In] int cbKeyBlob, [In][Out] IntPtr ppbSignatureBlob, [MarshalAs(UnmanagedType.U4)] out int pcbSignatureBlob, [MarshalAs(UnmanagedType.U4)][In] int dwFlags); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameSignatureSize([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] [In] byte[] pbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)] [In] int cbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbSize); + int StrongNameSignatureSize([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)][In] byte[] pbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)][In] int cbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbSize); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] [return: MarshalAs(UnmanagedType.U4)] - int StrongNameSignatureVerification([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzFilePath, [MarshalAs(UnmanagedType.U4)] [In] int dwInFlags, [MarshalAs(UnmanagedType.U4)] out int dwOutFlags); + int StrongNameSignatureVerification([MarshalAs(UnmanagedType.LPWStr)][In] string pwzFilePath, [MarshalAs(UnmanagedType.U4)][In] int dwInFlags, [MarshalAs(UnmanagedType.U4)] out int dwOutFlags); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] [return: MarshalAs(UnmanagedType.U4)] - int StrongNameSignatureVerificationEx([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzFilePath, [MarshalAs(UnmanagedType.I1)] [In] bool fForceVerification, [MarshalAs(UnmanagedType.I1)] out bool fWasVerified); + int StrongNameSignatureVerificationEx([MarshalAs(UnmanagedType.LPWStr)][In] string pwzFilePath, [MarshalAs(UnmanagedType.I1)][In] bool fForceVerification, [MarshalAs(UnmanagedType.I1)] out bool fWasVerified); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] [return: MarshalAs(UnmanagedType.U4)] - int StrongNameSignatureVerificationFromImage([In] IntPtr pbBase, [MarshalAs(UnmanagedType.U4)] [In] int dwLength, [MarshalAs(UnmanagedType.U4)] [In] int dwInFlags, [MarshalAs(UnmanagedType.U4)] out int dwOutFlags); + int StrongNameSignatureVerificationFromImage([In] IntPtr pbBase, [MarshalAs(UnmanagedType.U4)][In] int dwLength, [MarshalAs(UnmanagedType.U4)][In] int dwInFlags, [MarshalAs(UnmanagedType.U4)] out int dwOutFlags); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameTokenFromAssembly([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzFilePath, out IntPtr ppbStrongNameToken, [MarshalAs(UnmanagedType.U4)] out int pcbStrongNameToken); + int StrongNameTokenFromAssembly([MarshalAs(UnmanagedType.LPWStr)][In] string pwzFilePath, out IntPtr ppbStrongNameToken, [MarshalAs(UnmanagedType.U4)] out int pcbStrongNameToken); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameTokenFromAssemblyEx([MarshalAs(UnmanagedType.LPWStr)] [In] string pwzFilePath, out IntPtr ppbStrongNameToken, [MarshalAs(UnmanagedType.U4)] out int pcbStrongNameToken, out IntPtr ppbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbPublicKeyBlob); + int StrongNameTokenFromAssemblyEx([MarshalAs(UnmanagedType.LPWStr)][In] string pwzFilePath, out IntPtr ppbStrongNameToken, [MarshalAs(UnmanagedType.U4)] out int pcbStrongNameToken, out IntPtr ppbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)] out int pcbPublicKeyBlob); [MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.InternalCall)] - int StrongNameTokenFromPublicKey([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] [In] byte[] pbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)] [In] int cbPublicKeyBlob, out IntPtr ppbStrongNameToken, [MarshalAs(UnmanagedType.U4)] out int pcbStrongNameToken); + int StrongNameTokenFromPublicKey([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)][In] byte[] pbPublicKeyBlob, [MarshalAs(UnmanagedType.U4)][In] int cbPublicKeyBlob, out IntPtr ppbStrongNameToken, [MarshalAs(UnmanagedType.U4)] out int pcbStrongNameToken); } } diff --git a/Tests/123_InheritCustomAttr.Test/123_InheritCustomAttr.Test.csproj b/Tests/123_InheritCustomAttr.Test/123_InheritCustomAttr.Test.csproj index 3f5046d72..85068c37e 100644 --- a/Tests/123_InheritCustomAttr.Test/123_InheritCustomAttr.Test.csproj +++ b/Tests/123_InheritCustomAttr.Test/123_InheritCustomAttr.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 InheritCustomAttr.Test false diff --git a/Tests/123_InheritCustomAttr.Test/InheritCustomAttributeTest.cs b/Tests/123_InheritCustomAttr.Test/InheritCustomAttributeTest.cs index 1b6654976..0d53ea6f1 100644 --- a/Tests/123_InheritCustomAttr.Test/InheritCustomAttributeTest.cs +++ b/Tests/123_InheritCustomAttr.Test/InheritCustomAttributeTest.cs @@ -21,14 +21,14 @@ public InheritCustomAttributeTest(ITestOutputHelper outputHelper) : base(outputH public async Task InheritCustomAttribute(string renameMode, bool flatten) => await Run( "123_InheritCustomAttr.exe", - new[] {"Monday", "43", "1"}, - new SettingItem("rename") {{"mode", renameMode}, {"flatten", flatten ? "True" : "False"}}, + new[] { "Monday", "43", "1" }, + new SettingItem("rename") { { "mode", renameMode }, { "flatten", flatten ? "True" : "False" } }, $"_{renameMode}_{flatten}", l => Assert.False(l.StartsWith("[WARN]"), "Logged line may not start with [WARN]\r\n" + l)); public static IEnumerable InheritCustomAttributeData() { - foreach (var renameMode in new [] { nameof(RenameMode.Unicode), nameof(RenameMode.ASCII), nameof(RenameMode.Letters), nameof(RenameMode.Debug), nameof(RenameMode.Retain) }) - foreach (var flatten in new [] { true, false }) + foreach (var renameMode in new[] { nameof(RenameMode.Unicode), nameof(RenameMode.ASCII), nameof(RenameMode.Letters), nameof(RenameMode.Debug), nameof(RenameMode.Retain) }) + foreach (var flatten in new[] { true, false }) yield return new object[] { renameMode, flatten }; } } diff --git a/Tests/123_InheritCustomAttr/D.cs b/Tests/123_InheritCustomAttr/D.cs index b494dbd69..c8295c282 100644 --- a/Tests/123_InheritCustomAttr/D.cs +++ b/Tests/123_InheritCustomAttr/D.cs @@ -2,10 +2,10 @@ namespace InheritCustomAttr { class D : C { - #pragma warning disable CS0067 +#pragma warning disable CS0067 // Just here to make sure it works. public event EventHandler TestEvent; - #pragma warning restore CS0067 +#pragma warning restore CS0067 // this property should inherit the MyAttribute from its base class public override DayOfWeek T { get => DayOfWeek.Monday; } diff --git a/Tests/161_DynamicTypeRename.Test/161_DynamicTypeRename.Test.csproj b/Tests/161_DynamicTypeRename.Test/161_DynamicTypeRename.Test.csproj index 5e9bad8c7..9224ca9b3 100644 --- a/Tests/161_DynamicTypeRename.Test/161_DynamicTypeRename.Test.csproj +++ b/Tests/161_DynamicTypeRename.Test/161_DynamicTypeRename.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 DynamicTypeRename.Test false diff --git a/Tests/161_DynamicTypeRename.Test/RenameDynamicMethodTest.cs b/Tests/161_DynamicTypeRename.Test/RenameDynamicMethodTest.cs index 5ebdb81d4..6af04a6fb 100644 --- a/Tests/161_DynamicTypeRename.Test/RenameDynamicMethodTest.cs +++ b/Tests/161_DynamicTypeRename.Test/RenameDynamicMethodTest.cs @@ -20,7 +20,7 @@ public RenameDynamicTypeTest(ITestOutputHelper outputHelper) : base(outputHelper public async Task RenameDynamicType(string renameMode, bool flatten) => await Run( "161_DynamicTypeRename.exe", - new [] { + new[] { "Type declaration done", "Dynamic type created", "Fields in type: 1", @@ -34,8 +34,8 @@ await Run( ); public static IEnumerable RenameDynamicTypeData() { - foreach (var renameMode in new [] { nameof(RenameMode.Unicode), nameof(RenameMode.ASCII), nameof(RenameMode.Letters), nameof(RenameMode.Debug), nameof(RenameMode.Retain) }) - foreach (var flatten in new [] { true, false }) + foreach (var renameMode in new[] { nameof(RenameMode.Unicode), nameof(RenameMode.ASCII), nameof(RenameMode.Letters), nameof(RenameMode.Debug), nameof(RenameMode.Retain) }) + foreach (var flatten in new[] { true, false }) yield return new object[] { renameMode, flatten }; } } diff --git a/Tests/193_ConstantsInlining.Test/193_ConstantsInlining.Test.csproj b/Tests/193_ConstantsInlining.Test/193_ConstantsInlining.Test.csproj index 71b0f2ad0..4ae43ab9f 100644 --- a/Tests/193_ConstantsInlining.Test/193_ConstantsInlining.Test.csproj +++ b/Tests/193_ConstantsInlining.Test/193_ConstantsInlining.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 ConstantsInlining.Test false diff --git a/Tests/193_ConstantsInlining.Test/ConstantInliningTest.cs b/Tests/193_ConstantsInlining.Test/ConstantInliningTest.cs index d0d8b6227..b7ecfe334 100644 --- a/Tests/193_ConstantsInlining.Test/ConstantInliningTest.cs +++ b/Tests/193_ConstantsInlining.Test/ConstantInliningTest.cs @@ -14,8 +14,8 @@ public ConstantInliningTest(ITestOutputHelper outputHelper) : base(outputHelper) [Trait("Protection", "constants")] [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/193")] public async Task ConstantInlining() => - await Run(new[] {"193_ConstantsInlining.exe", "193_ConstantsInlining.Lib.dll"}, - new[] {"From External"}, - new SettingItem("constants") {{"elements", "S"}}); + await Run(new[] { "193_ConstantsInlining.exe", "193_ConstantsInlining.Lib.dll" }, + new[] { "From External" }, + new SettingItem("constants") { { "elements", "S" } }); } } diff --git a/Tests/244_ClrProtection.Test/244_ClrProtection.Test.csproj b/Tests/244_ClrProtection.Test/244_ClrProtection.Test.csproj index 6c8485fa6..1c37d01b8 100644 --- a/Tests/244_ClrProtection.Test/244_ClrProtection.Test.csproj +++ b/Tests/244_ClrProtection.Test/244_ClrProtection.Test.csproj @@ -1,7 +1,7 @@  - net461 + net48 ClrProtection.Test false x86 diff --git a/Tests/244_ClrProtection.Test/ProtectClrAssemblyTest.cs b/Tests/244_ClrProtection.Test/ProtectClrAssemblyTest.cs index a75d91b82..1f25a5fb1 100644 --- a/Tests/244_ClrProtection.Test/ProtectClrAssemblyTest.cs +++ b/Tests/244_ClrProtection.Test/ProtectClrAssemblyTest.cs @@ -48,7 +48,7 @@ public Task TypeScrambleProtection() => Run( public Task AntiTamperResourceProtection() => Run( "244_ClrProtection.exe", Array.Empty(), - new[] {new SettingItem("anti tamper"), new SettingItem("resources") }, + new[] { new SettingItem("anti tamper"), new SettingItem("resources") }, $"_{nameof(AntiTamperResourceProtection)}"); } } diff --git a/Tests/244_ClrProtection/244_ClrProtection.vcxproj b/Tests/244_ClrProtection/244_ClrProtection.vcxproj index 82d5573aa..0cbad50aa 100644 --- a/Tests/244_ClrProtection/244_ClrProtection.vcxproj +++ b/Tests/244_ClrProtection/244_ClrProtection.vcxproj @@ -24,7 +24,7 @@ {73f11ee8-f565-479e-8366-bd74ee467ce8} My244ClrProtection 10.0 - v4.6.1 + v4.8 v143 v142 diff --git a/Tests/252_ComplexInterfaceRenaming.Test/252_ComplexInterfaceRenaming.Test.csproj b/Tests/252_ComplexInterfaceRenaming.Test/252_ComplexInterfaceRenaming.Test.csproj index cdff07597..33bf6364a 100644 --- a/Tests/252_ComplexInterfaceRenaming.Test/252_ComplexInterfaceRenaming.Test.csproj +++ b/Tests/252_ComplexInterfaceRenaming.Test/252_ComplexInterfaceRenaming.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 ComplexInterfaceRenaming.Test false diff --git a/Tests/252_ComplexInterfaceRenaming/IWorker.cs b/Tests/252_ComplexInterfaceRenaming/IWorker.cs index da60f3245..8fc632d9e 100644 --- a/Tests/252_ComplexInterfaceRenaming/IWorker.cs +++ b/Tests/252_ComplexInterfaceRenaming/IWorker.cs @@ -1,4 +1,3 @@ -namespace ComplexInterfaceRenaming -{ - public interface IWorker : IName, IC {} +namespace ComplexInterfaceRenaming { + public interface IWorker : IName, IC { } } diff --git a/Tests/252_ComplexInterfaceRenaming/Manager.cs b/Tests/252_ComplexInterfaceRenaming/Manager.cs index 29f33d50f..572f80ae1 100644 --- a/Tests/252_ComplexInterfaceRenaming/Manager.cs +++ b/Tests/252_ComplexInterfaceRenaming/Manager.cs @@ -1,8 +1,7 @@ using System; namespace ComplexInterfaceRenaming { - internal sealed class Manager : Worker, IWorker, IOperator - { + internal sealed class Manager : Worker, IWorker, IOperator { public string Name => "I'm a manager!"; public void Operate() => throw new NotImplementedException(); diff --git a/Tests/270_EnumArrayConstantProtection.Test/270_EnumArrayConstantProtection.Test.csproj b/Tests/270_EnumArrayConstantProtection.Test/270_EnumArrayConstantProtection.Test.csproj index d69c16f58..e0b095341 100644 --- a/Tests/270_EnumArrayConstantProtection.Test/270_EnumArrayConstantProtection.Test.csproj +++ b/Tests/270_EnumArrayConstantProtection.Test/270_EnumArrayConstantProtection.Test.csproj @@ -1,7 +1,7 @@  - net461 + net462 EnumArrayConstantProtection.Test false diff --git a/Tests/306_ComplexClassStructureRename.Lib/InternalClass1.cs b/Tests/306_ComplexClassStructureRename.Lib/InternalClass1.cs index cc1ff68a9..f142a3945 100644 --- a/Tests/306_ComplexClassStructureRename.Lib/InternalClass1.cs +++ b/Tests/306_ComplexClassStructureRename.Lib/InternalClass1.cs @@ -2,7 +2,7 @@ namespace ComplexClassStructureRename.Lib { internal class InternalClass1 : InternalBaseClass { - public new void FireLog(string message) => + public new void FireLog(string message) => Console.WriteLine("InternalClass1: " + message); } } diff --git a/Tests/306_ComplexClassStructureRename.Test/306_ComplexClassStructureRename.Test.csproj b/Tests/306_ComplexClassStructureRename.Test/306_ComplexClassStructureRename.Test.csproj index 382d0e6a3..2da180f80 100644 --- a/Tests/306_ComplexClassStructureRename.Test/306_ComplexClassStructureRename.Test.csproj +++ b/Tests/306_ComplexClassStructureRename.Test/306_ComplexClassStructureRename.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 ComplexClassStructureRename.Test false diff --git a/Tests/306_ComplexClassStructureRename.Test/ComplexRenameTest.cs b/Tests/306_ComplexClassStructureRename.Test/ComplexRenameTest.cs index 666fa4c1f..1d8429fa6 100644 --- a/Tests/306_ComplexClassStructureRename.Test/ComplexRenameTest.cs +++ b/Tests/306_ComplexClassStructureRename.Test/ComplexRenameTest.cs @@ -23,7 +23,7 @@ await Run( new[] { "InternalClass1: test1 Hello" }, - new SettingItem("rename") { + new SettingItem("rename") { { "mode", "sequential" }, { "renPublic", "true" }, { "flatten", "false" } diff --git a/Tests/342_InterfaceRenamingLoop.Test/342_InterfaceRenamingLoop.Test.csproj b/Tests/342_InterfaceRenamingLoop.Test/342_InterfaceRenamingLoop.Test.csproj index e945936c9..eb303e06a 100644 --- a/Tests/342_InterfaceRenamingLoop.Test/342_InterfaceRenamingLoop.Test.csproj +++ b/Tests/342_InterfaceRenamingLoop.Test/342_InterfaceRenamingLoop.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 InterfaceRenamingLoop.Test false diff --git a/Tests/342_InterfaceRenamingLoop/Program.cs b/Tests/342_InterfaceRenamingLoop/Program.cs index bb96b141d..0ff37c5cd 100644 --- a/Tests/342_InterfaceRenamingLoop/Program.cs +++ b/Tests/342_InterfaceRenamingLoop/Program.cs @@ -4,7 +4,7 @@ namespace InterfaceRenamingLoop { public class Program { internal static int Main(string[] args) { Console.WriteLine("START"); - + var test = new ClassB(); test.TestEvent(0, "TEST"); diff --git a/Tests/345_RenameDynamicParameter.Test/345_RenameDynamicParameter.Test.csproj b/Tests/345_RenameDynamicParameter.Test/345_RenameDynamicParameter.Test.csproj index 74840158d..e98f005bd 100644 --- a/Tests/345_RenameDynamicParameter.Test/345_RenameDynamicParameter.Test.csproj +++ b/Tests/345_RenameDynamicParameter.Test/345_RenameDynamicParameter.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 RenameDynamicParameter.Test false diff --git a/Tests/345_RenameDynamicParameter/Program.cs b/Tests/345_RenameDynamicParameter/Program.cs index 906c2881e..c0f3748b2 100644 --- a/Tests/345_RenameDynamicParameter/Program.cs +++ b/Tests/345_RenameDynamicParameter/Program.cs @@ -4,7 +4,7 @@ namespace RenameDynamicParameter { public class Program { internal static int Main(string[] args) { Console.WriteLine("START"); - + SimpleTestClass.TestStatic(); SimpleTestClass.TestDynamic(); diff --git a/Tests/389_MixedCultureCasing.Test/389_MixedCultureCasing.Test.csproj b/Tests/389_MixedCultureCasing.Test/389_MixedCultureCasing.Test.csproj index 58723b18b..42b703450 100644 --- a/Tests/389_MixedCultureCasing.Test/389_MixedCultureCasing.Test.csproj +++ b/Tests/389_MixedCultureCasing.Test/389_MixedCultureCasing.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 MixedCultureCasing.Test false diff --git a/Tests/389_MixedCultureCasing.Test/MixedCultureCasingTest.cs b/Tests/389_MixedCultureCasing.Test/MixedCultureCasingTest.cs index fd01b68e3..2ef2f76bd 100644 --- a/Tests/389_MixedCultureCasing.Test/MixedCultureCasingTest.cs +++ b/Tests/389_MixedCultureCasing.Test/MixedCultureCasingTest.cs @@ -6,9 +6,8 @@ using Xunit; using Xunit.Abstractions; -namespace MixedCultureCasing.Test -{ - public class MixedCultureCasingTest : TestBase { +namespace MixedCultureCasing.Test { + public class MixedCultureCasingTest : TestBase { public MixedCultureCasingTest(ITestOutputHelper outputHelper) : base(outputHelper) { } [Fact] @@ -17,11 +16,11 @@ public MixedCultureCasingTest(ITestOutputHelper outputHelper) : base(outputHelpe [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/389")] public async Task MixedCultureCasing() => await Run( - new [] { + new[] { "389_MixedCultureCasing.exe", @"de-DE\389_MixedCultureCasing.resources.dll" }, - new [] { + new[] { "Test 1 (neutral)", "Test 1 (deutsch)", "Test 2 (neutral)", diff --git a/Tests/389_MixedCultureCasing/Program.cs b/Tests/389_MixedCultureCasing/Program.cs index e3b8ca498..13fc10b06 100644 --- a/Tests/389_MixedCultureCasing/Program.cs +++ b/Tests/389_MixedCultureCasing/Program.cs @@ -5,13 +5,13 @@ namespace MixedCultureCasing { public class Program { internal static int Main(string[] args) { Console.WriteLine("START"); - + Resource1.Culture = CultureInfo.GetCultureInfo("en-US"); Console.WriteLine(Resource1.Test1); Resource1.Culture = CultureInfo.GetCultureInfo("de-DE"); Console.WriteLine(Resource1.Test1); - + Resource2.Culture = CultureInfo.GetCultureInfo("en-US"); Console.WriteLine(Resource2.Test2); diff --git a/Tests/421_NewtonsoftJsonSerialization.Test/421_NewtonsoftJsonSerialization.Test.csproj b/Tests/421_NewtonsoftJsonSerialization.Test/421_NewtonsoftJsonSerialization.Test.csproj index 26fceb15a..78c7491b6 100644 --- a/Tests/421_NewtonsoftJsonSerialization.Test/421_NewtonsoftJsonSerialization.Test.csproj +++ b/Tests/421_NewtonsoftJsonSerialization.Test/421_NewtonsoftJsonSerialization.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 NewtonsoftJsonSerialization.Test false diff --git a/Tests/421_NewtonsoftJsonSerialization.Test/NewtonsoftJsonTest.cs b/Tests/421_NewtonsoftJsonSerialization.Test/NewtonsoftJsonTest.cs index bd5f388bf..1545c3e08 100644 --- a/Tests/421_NewtonsoftJsonSerialization.Test/NewtonsoftJsonTest.cs +++ b/Tests/421_NewtonsoftJsonSerialization.Test/NewtonsoftJsonTest.cs @@ -19,7 +19,7 @@ await Run( "421_NewtonsoftJsonSerialization.exe", "external:Newtonsoft.Json.dll" }, - new [] { + new[] { "{\"a\":\"a\",\"b\":\"b\",\"c\":\"c\"}", "{\"a\":\"a\",\"b\":\"b\",\"c\":\"c\"}" }, diff --git a/Tests/470_ImplementationInBaseClass.Test/470_ImplementationInBaseClass.Test.csproj b/Tests/470_ImplementationInBaseClass.Test/470_ImplementationInBaseClass.Test.csproj index edd3f7892..c833b8d44 100644 --- a/Tests/470_ImplementationInBaseClass.Test/470_ImplementationInBaseClass.Test.csproj +++ b/Tests/470_ImplementationInBaseClass.Test/470_ImplementationInBaseClass.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 ImplementationInBaseClass.Test false diff --git a/Tests/470_ImplementationInBaseClass.Test/RenameTest.cs b/Tests/470_ImplementationInBaseClass.Test/RenameTest.cs index a08f181b1..bc7c0ee77 100644 --- a/Tests/470_ImplementationInBaseClass.Test/RenameTest.cs +++ b/Tests/470_ImplementationInBaseClass.Test/RenameTest.cs @@ -7,10 +7,8 @@ using Xunit; using Xunit.Abstractions; -namespace ImplementationInBaseClass.Test -{ - public class RenameTest : TestBase - { +namespace ImplementationInBaseClass.Test { + public class RenameTest : TestBase { public RenameTest(ITestOutputHelper outputHelper) : base(outputHelper) { } [Theory] diff --git a/Tests/78_SignatureMismatch.Test/78_SignatureMismatch.Test.csproj b/Tests/78_SignatureMismatch.Test/78_SignatureMismatch.Test.csproj index b39a0b47a..4eac766ed 100644 --- a/Tests/78_SignatureMismatch.Test/78_SignatureMismatch.Test.csproj +++ b/Tests/78_SignatureMismatch.Test/78_SignatureMismatch.Test.csproj @@ -1,7 +1,7 @@  - net461 + net462 SignatureMismatch.Test false diff --git a/Tests/78_SignatureMismatch.Test/SignatureMismatchTest.cs b/Tests/78_SignatureMismatch.Test/SignatureMismatchTest.cs index 3f3d1f72a..dddf8a8c4 100644 --- a/Tests/78_SignatureMismatch.Test/SignatureMismatchTest.cs +++ b/Tests/78_SignatureMismatch.Test/SignatureMismatchTest.cs @@ -16,7 +16,7 @@ public SignatureMismatchTest(ITestOutputHelper outputHelper) : base(outputHelper public async Task SignatureMismatch() => await Run( "78_SignatureMismatch.exe", - new [] { + new[] { "Dictionary created", "Dictionary count: 1", "[Test1] = Test2" diff --git a/Tests/78_SignatureMismatch/Program.cs b/Tests/78_SignatureMismatch/Program.cs index 6f2cab947..3cffbb4af 100644 --- a/Tests/78_SignatureMismatch/Program.cs +++ b/Tests/78_SignatureMismatch/Program.cs @@ -12,12 +12,12 @@ static int Main(string[] args) { var file = new TextFile("filename", "text"); - foreach (var kvp in dict) + foreach (var kvp in dict) Console.WriteLine($"[{kvp.Key}] = {kvp.Value}"); - + Console.WriteLine("END"); - return 42; + return 42; } } } diff --git a/Tests/AntiTamper.Test/AntiTamper.Test.csproj b/Tests/AntiTamper.Test/AntiTamper.Test.csproj index 8c5b421a4..48ef32c65 100644 --- a/Tests/AntiTamper.Test/AntiTamper.Test.csproj +++ b/Tests/AntiTamper.Test/AntiTamper.Test.csproj @@ -1,7 +1,7 @@  - net461 + net462 false diff --git a/Tests/BlockingReferences.Test/BlockingReferences.Test.csproj b/Tests/BlockingReferences.Test/BlockingReferences.Test.csproj index f38282b59..056680a47 100644 --- a/Tests/BlockingReferences.Test/BlockingReferences.Test.csproj +++ b/Tests/BlockingReferences.Test/BlockingReferences.Test.csproj @@ -1,7 +1,7 @@ - net461 + net462 diff --git a/Tests/CompressorWithResx.Test/CompressTest.cs b/Tests/CompressorWithResx.Test/CompressTest.cs index d3eb96f71..1bbf3b276 100644 --- a/Tests/CompressorWithResx.Test/CompressTest.cs +++ b/Tests/CompressorWithResx.Test/CompressTest.cs @@ -17,18 +17,18 @@ public CompressTest(ITestOutputHelper outputHelper) : base(outputHelper) { } [Trait("Packer", "compressor")] public async Task CompressAndExecuteTest(string compatKey, string deriverKey, string resourceProtectionMode) => await Run( - new[] {"CompressorWithResx.exe", Path.Combine("de", "CompressorWithResx.resources.dll")}, - new[] {"Test (fallback)", "Test (deutsch)"}, + new[] { "CompressorWithResx.exe", Path.Combine("de", "CompressorWithResx.resources.dll") }, + new[] { "Test (fallback)", "Test (deutsch)" }, resourceProtectionMode != "none" - ? new SettingItem("resources") {{"mode", resourceProtectionMode}} + ? new SettingItem("resources") { { "mode", resourceProtectionMode } } : null, $"_{compatKey}_{deriverKey}_{resourceProtectionMode}", - packer: new SettingItem("compressor") {{"compat", compatKey}, {"key", deriverKey}}); + packer: new SettingItem("compressor") { { "compat", compatKey }, { "key", deriverKey } }); public static IEnumerable CompressAndExecuteTestData() { - foreach (var compressorCompatKey in new [] { "true", "false" }) - foreach (var compressorDeriveKey in new [] { "normal", "dynamic" }) - foreach (var resourceProtectionMode in new [] { "none", "normal", "dynamic" }) + foreach (var compressorCompatKey in new[] { "true", "false" }) + foreach (var compressorDeriveKey in new[] { "normal", "dynamic" }) + foreach (var resourceProtectionMode in new[] { "none", "normal", "dynamic" }) yield return new object[] { compressorCompatKey, compressorDeriveKey, resourceProtectionMode }; } } diff --git a/Tests/CompressorWithResx.Test/CompressorWithResx.Test.csproj b/Tests/CompressorWithResx.Test/CompressorWithResx.Test.csproj index f62c72446..462b7f911 100644 --- a/Tests/CompressorWithResx.Test/CompressorWithResx.Test.csproj +++ b/Tests/CompressorWithResx.Test/CompressorWithResx.Test.csproj @@ -1,7 +1,7 @@  - net461 + net462 false diff --git a/Tests/Confuser.CLI.Test/CliEndToEndTest.cs b/Tests/Confuser.CLI.Test/CliEndToEndTest.cs new file mode 100644 index 000000000..5853bf88c --- /dev/null +++ b/Tests/Confuser.CLI.Test/CliEndToEndTest.cs @@ -0,0 +1,99 @@ +using System; +using System.Diagnostics; +using System.IO; +using Xunit; +using Xunit.Abstractions; + +namespace Confuser.CLI.Test { + public class CliEndToEndTest { + readonly ITestOutputHelper output; + + public CliEndToEndTest(ITestOutputHelper output) { + this.output = output; + } + + [Fact] + public void Obfuscate_SampleApp_ProducesRunnableOutput() { + // Arrange — locate pre-built SampleApp.exe and Confuser.CLI + var sampleAppExe = Path.Combine(AppContext.BaseDirectory, "Fixtures", "SampleApp", "bin", "SampleApp.exe"); + Assert.True(File.Exists(sampleAppExe), $"Pre-built SampleApp.exe not found at {sampleAppExe}"); + + var cliDll = Path.Combine(AppContext.BaseDirectory, "Confuser.CLI.dll"); + Assert.True(File.Exists(cliDll), $"Confuser.CLI.dll not found at {cliDll}"); + + var testDir = Path.Combine(Path.GetTempPath(), "confuserex-cli-e2e-" + Guid.NewGuid().ToString("N")[..8]); + Directory.CreateDirectory(testDir); + + try { + // Copy the pre-built exe to a working directory + File.Copy(sampleAppExe, Path.Combine(testDir, "SampleApp.exe")); + + // Write the .crproj + var outputDir = Path.Combine(testDir, "obfuscated"); + var crproj = Path.Combine(testDir, "SampleApp.crproj"); + File.WriteAllText(crproj, +@" + + + + +"); + + // Act — run Confuser.CLI + var cliResult = RunProcess("dotnet", $"\"{cliDll}\" -n \"{crproj}\""); + output.WriteLine("=== Confuser.CLI Output ==="); + output.WriteLine(cliResult.stdout); + if (!string.IsNullOrEmpty(cliResult.stderr)) + output.WriteLine(cliResult.stderr); + Assert.Equal(0, cliResult.exitCode); + + // Assert — obfuscated output exists + var obfuscatedExe = Path.Combine(outputDir, "SampleApp.exe"); + Assert.True(File.Exists(obfuscatedExe), "Obfuscated SampleApp.exe should exist"); + + // Assert — obfuscated file differs from original + var originalBytes = File.ReadAllBytes(Path.Combine(testDir, "SampleApp.exe")); + var obfuscatedBytes = File.ReadAllBytes(obfuscatedExe); + Assert.NotEqual(originalBytes, obfuscatedBytes); + + // Assert — obfuscated exe runs and produces correct output + var runResult = RunProcess(obfuscatedExe, ""); + output.WriteLine("=== Obfuscated App Output ==="); + output.WriteLine(runResult.stdout); + Assert.Equal(42, runResult.exitCode); + Assert.Contains("START", runResult.stdout); + Assert.Contains("Hello from SampleApp", runResult.stdout); + Assert.Contains("END", runResult.stdout); + } + finally { + try { Directory.Delete(testDir, true); } catch { } + } + } + + [Fact] + public void Cli_NoArgs_ReturnsNonZeroAndShowsUsage() { + var cliDll = Path.Combine(AppContext.BaseDirectory, "Confuser.CLI.dll"); + var result = RunProcess("dotnet", $"\"{cliDll}\" -n"); + output.WriteLine(result.stdout); + Assert.NotEqual(0, result.exitCode); + Assert.Contains("Usage", result.stdout); + } + + static (string stdout, string stderr, int exitCode) RunProcess(string fileName, string arguments) { + var psi = new ProcessStartInfo { + FileName = fileName, + Arguments = arguments, + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true + }; + + using var process = Process.Start(psi); + var stdout = process.StandardOutput.ReadToEnd(); + var stderr = process.StandardError.ReadToEnd(); + process.WaitForExit(120_000); + return (stdout, stderr, process.ExitCode); + } + } +} diff --git a/Tests/Confuser.CLI.Test/Confuser.CLI.Test.csproj b/Tests/Confuser.CLI.Test/Confuser.CLI.Test.csproj new file mode 100644 index 000000000..1c3448807 --- /dev/null +++ b/Tests/Confuser.CLI.Test/Confuser.CLI.Test.csproj @@ -0,0 +1,38 @@ + + + + net10.0 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Confuser.CLI.Test/Fixtures/SampleApp.crproj b/Tests/Confuser.CLI.Test/Fixtures/SampleApp.crproj new file mode 100644 index 000000000..73fd08623 --- /dev/null +++ b/Tests/Confuser.CLI.Test/Fixtures/SampleApp.crproj @@ -0,0 +1,6 @@ + + + + + + diff --git a/Tests/Confuser.CLI.Test/Fixtures/SampleApp/Program.cs b/Tests/Confuser.CLI.Test/Fixtures/SampleApp/Program.cs new file mode 100644 index 000000000..674d65380 --- /dev/null +++ b/Tests/Confuser.CLI.Test/Fixtures/SampleApp/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace SampleApp { + class Program { + static int Main() { + Console.WriteLine("START"); + Console.WriteLine("Hello from SampleApp"); + Console.WriteLine("END"); + return 42; + } + } +} diff --git a/Tests/Confuser.CLI.Test/Fixtures/SampleApp/SampleApp.csproj b/Tests/Confuser.CLI.Test/Fixtures/SampleApp/SampleApp.csproj new file mode 100644 index 000000000..7a8b42a81 --- /dev/null +++ b/Tests/Confuser.CLI.Test/Fixtures/SampleApp/SampleApp.csproj @@ -0,0 +1,8 @@ + + + Exe + net48 + 7.3 + disable + + diff --git a/Tests/Confuser.Core.Test/Confuser.Core.Test.csproj b/Tests/Confuser.Core.Test/Confuser.Core.Test.csproj index 35ce0567d..bf805c034 100644 --- a/Tests/Confuser.Core.Test/Confuser.Core.Test.csproj +++ b/Tests/Confuser.Core.Test/Confuser.Core.Test.csproj @@ -1,12 +1,12 @@  - net461 + net10.0 false - + diff --git a/Tests/Confuser.Core.Test/Helpers.cs b/Tests/Confuser.Core.Test/Helpers.cs index 11b134ff0..7a373fb10 100644 --- a/Tests/Confuser.Core.Test/Helpers.cs +++ b/Tests/Confuser.Core.Test/Helpers.cs @@ -11,11 +11,11 @@ internal static ModuleDefMD LoadTestModuleDef() { TryToLoadPdbFromDisk = false }; - asmResolver.AddToCache(ModuleDefMD.Load(typeof(Mock).Module, options)); - asmResolver.AddToCache(ModuleDefMD.Load(typeof(FactAttribute).Module, options)); + asmResolver.AddToCache(ModuleDefMD.Load(typeof(Mock).Module, options)); + asmResolver.AddToCache(ModuleDefMD.Load(typeof(FactAttribute).Module, options)); - var thisModule = ModuleDefMD.Load(typeof(Helpers).Module, options); - asmResolver.AddToCache(thisModule); + var thisModule = ModuleDefMD.Load(typeof(Helpers).Module, options); + asmResolver.AddToCache(thisModule); return thisModule; } diff --git a/Tests/Confuser.Core.Test/UtilsTest.cs b/Tests/Confuser.Core.Test/UtilsTest.cs index 5a1217b96..2b77653c5 100644 --- a/Tests/Confuser.Core.Test/UtilsTest.cs +++ b/Tests/Confuser.Core.Test/UtilsTest.cs @@ -6,7 +6,7 @@ public class UtilsTest { [Theory] [MemberData(nameof(BuildRelativePathTestData))] [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/413")] - public void BuildRelativePath(string baseDirectory, string fileReference, string expectedRelativePath) => + public void BuildRelativePath(string baseDirectory, string fileReference, string expectedRelativePath) => Assert.Equal(expectedRelativePath, Utils.GetRelativePath(fileReference, baseDirectory), ignoreCase: true); public static IEnumerable BuildRelativePathTestData() { diff --git a/Tests/Confuser.GUI.Test/Confuser.GUI.Test.csproj b/Tests/Confuser.GUI.Test/Confuser.GUI.Test.csproj new file mode 100644 index 000000000..2bbe390a7 --- /dev/null +++ b/Tests/Confuser.GUI.Test/Confuser.GUI.Test.csproj @@ -0,0 +1,27 @@ + + + + net10.0-windows + true + false + + + + + + + + + + + + + + + + + + + diff --git a/Tests/Confuser.GUI.Test/GuiSmokeTest.cs b/Tests/Confuser.GUI.Test/GuiSmokeTest.cs new file mode 100644 index 000000000..ac6f04a64 --- /dev/null +++ b/Tests/Confuser.GUI.Test/GuiSmokeTest.cs @@ -0,0 +1,229 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Xml; +using FlaUI.Core; +using FlaUI.Core.AutomationElements; +using FlaUI.Core.Conditions; +using FlaUI.Core.Tools; +using FlaUI.UIA3; +using Xunit; +using Xunit.Abstractions; + +namespace Confuser.GUI.Test { + public class GuiSmokeTest : IDisposable { + readonly ITestOutputHelper output; + Application app; + UIA3Automation automation; + + public GuiSmokeTest(ITestOutputHelper output) { + this.output = output; + automation = new UIA3Automation(); + } + + public void Dispose() { + try { app?.Close(); } catch { } + try { app?.Dispose(); } catch { } + automation?.Dispose(); + } + + static string FindGuiExe() { + // Walk up from test bin to solution root, then into ConfuserEx output + var dir = AppContext.BaseDirectory; + for (int i = 0; i < 6; i++) { + var candidate = Path.Combine(dir, "ConfuserEx", "bin", "Release", "net10.0-windows", "ConfuserEx.exe"); + if (File.Exists(candidate)) return candidate; + dir = Path.GetDirectoryName(dir); + if (dir == null) break; + } + + // Fallback: search relative to solution + var solutionDir = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "..")); + var fallback = Path.Combine(solutionDir, "ConfuserEx", "bin", "Release", "net10.0-windows", "ConfuserEx.exe"); + return fallback; + } + + Application LaunchGui(string arguments = null) { + var exePath = FindGuiExe(); + output.WriteLine($"GUI exe: {exePath}"); + Assert.True(File.Exists(exePath), $"ConfuserEx.exe not found at {exePath}. Build the solution first."); + + var psi = new ProcessStartInfo(exePath) { UseShellExecute = false }; + if (arguments != null) psi.Arguments = arguments; + + app = Application.Launch(psi); + return app; + } + + Window WaitForMainWindow(Application application, int timeoutSeconds = 15) { + var mainWindow = Retry.WhileNull( + () => application.GetMainWindow(automation), + TimeSpan.FromSeconds(timeoutSeconds), + TimeSpan.FromMilliseconds(500)).Result; + + Assert.NotNull(mainWindow); + output.WriteLine($"Main window: '{mainWindow.Title}'"); + return mainWindow; + } + + [Fact] + public void Gui_Launches_ShowsMainWindow() { + // Act — launch the GUI + LaunchGui(); + var mainWindow = WaitForMainWindow(app); + + // Assert — window title contains project name and version + Assert.Contains("Unnamed.crproj", mainWindow.Title); + Assert.Contains("Confuser", mainWindow.Title); + + // Verify the tab control exists with expected tabs + var tabs = mainWindow.FindAllDescendants(cf => cf.ByControlType(FlaUI.Core.Definitions.ControlType.TabItem)); + output.WriteLine($"Found {tabs.Length} tabs"); + Assert.True(tabs.Length >= 4, "Expected at least 4 tabs (Project, Settings, Protect!, About)"); + } + + [Fact] + public void Gui_LoadProject_ShowsModules() { + // Arrange — create a .crproj that references the SampleApp + var testDir = Path.Combine(Path.GetTempPath(), "confuserex-gui-test-" + Guid.NewGuid().ToString("N")[..8]); + Directory.CreateDirectory(testDir); + + try { + var sampleAppExe = Path.Combine(AppContext.BaseDirectory, "Fixtures", "SampleApp", "SampleApp.exe"); + Assert.True(File.Exists(sampleAppExe), $"SampleApp.exe not found at {sampleAppExe}"); + + // Copy sample app to test dir + File.Copy(sampleAppExe, Path.Combine(testDir, "SampleApp.exe")); + + // Create .crproj + var crprojPath = Path.Combine(testDir, "Test.crproj"); + File.WriteAllText(crprojPath, +@" + +"); + + // Act — launch GUI with the project file + LaunchGui($"\"{crprojPath}\""); + var mainWindow = WaitForMainWindow(app); + + // Assert — title shows the project file name + Assert.Contains("Test.crproj", mainWindow.Title); + + // Find the modules list and verify SampleApp.exe appears + var found = Retry.WhileEmpty( + () => mainWindow.FindAllDescendants(cf => cf.ByText("SampleApp.exe")), + TimeSpan.FromSeconds(5), + TimeSpan.FromMilliseconds(500)).Result; + + output.WriteLine($"Found {found.Length} elements with 'SampleApp.exe'"); + Assert.True(found.Length > 0, "SampleApp.exe should appear in the modules list"); + } + finally { + try { Directory.Delete(testDir, true); } catch { } + } + } + + [Fact] + public void Gui_ProtectSampleApp_ShowsSuccess() { + // Arrange — create a project with rename protection + var testDir = Path.Combine(Path.GetTempPath(), "confuserex-gui-protect-" + Guid.NewGuid().ToString("N")[..8]); + Directory.CreateDirectory(testDir); + var outputDir = Path.Combine(testDir, "obfuscated"); + + try { + // Copy SampleApp + Confuser.Runtime to test dir + var sampleAppExe = Path.Combine(AppContext.BaseDirectory, "Fixtures", "SampleApp", "SampleApp.exe"); + Assert.True(File.Exists(sampleAppExe), $"SampleApp.exe not found at {sampleAppExe}"); + File.Copy(sampleAppExe, Path.Combine(testDir, "SampleApp.exe")); + + // Create .crproj with rename protection + var crprojPath = Path.Combine(testDir, "Test.crproj"); + File.WriteAllText(crprojPath, +@" + + + + +"); + + // Act — launch GUI with the project + LaunchGui($"\"{crprojPath}\""); + var mainWindow = WaitForMainWindow(app); + + // Navigate to the Protect! tab + var protectTab = Retry.WhileNull( + () => mainWindow.FindFirstDescendant(cf => cf.ByText("Protect!")), + TimeSpan.FromSeconds(5), + TimeSpan.FromMilliseconds(500)).Result; + Assert.NotNull(protectTab); + protectTab.Click(); + + // Find and click the Protect! button + var protectButton = Retry.WhileNull( + () => { + var buttons = mainWindow.FindAllDescendants(cf => cf.ByControlType(FlaUI.Core.Definitions.ControlType.Button)); + foreach (var btn in buttons) { + if (btn.Name == "Protect!") return btn; + } + return null; + }, + TimeSpan.FromSeconds(5), + TimeSpan.FromMilliseconds(500)).Result; + + Assert.NotNull(protectButton); + output.WriteLine("Clicking Protect! button..."); + protectButton.Click(); + + // Wait for "Finished" to appear in the log (indicates success) + var finishedText = Retry.WhileNull( + () => { + var richTextBoxes = mainWindow.FindAllDescendants(cf => cf.ByControlType(FlaUI.Core.Definitions.ControlType.Document)); + foreach (var rtb in richTextBoxes) { + var text = rtb.Name ?? ""; + if (text.Contains("Finished")) return rtb; + } + return null; + }, + TimeSpan.FromSeconds(30), + TimeSpan.FromMilliseconds(1000)).Result; + + // If direct text check didn't work, wait for the output file to appear + if (finishedText == null) { + Retry.WhileNull( + () => File.Exists(Path.Combine(outputDir, "SampleApp.exe")) ? (object)true : null, + TimeSpan.FromSeconds(30), + TimeSpan.FromMilliseconds(1000)); + } + + output.WriteLine($"Protection completed. Output exists: {File.Exists(Path.Combine(outputDir, "SampleApp.exe"))}"); + Assert.True(File.Exists(Path.Combine(outputDir, "SampleApp.exe")), + "Obfuscated SampleApp.exe should exist after protection"); + + // Verify the obfuscated exe runs correctly + var runResult = RunProcess(Path.Combine(outputDir, "SampleApp.exe"), ""); + output.WriteLine($"Obfuscated output: {runResult.stdout}"); + Assert.Equal(42, runResult.exitCode); + Assert.Contains("Hello from SampleApp", runResult.stdout); + } + finally { + try { Directory.Delete(testDir, true); } catch { } + } + } + + static (string stdout, string stderr, int exitCode) RunProcess(string fileName, string arguments) { + var psi = new ProcessStartInfo { + FileName = fileName, + Arguments = arguments, + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true + }; + using var process = Process.Start(psi); + var stdout = process.StandardOutput.ReadToEnd(); + var stderr = process.StandardError.ReadToEnd(); + process.WaitForExit(60_000); + return (stdout, stderr, process.ExitCode); + } + } +} diff --git a/Tests/Confuser.Renamer.Test/Analyzers/ManifestResourceAnalyzerTest.cs b/Tests/Confuser.Renamer.Test/Analyzers/ManifestResourceAnalyzerTest.cs index 058153f99..fc13f7397 100644 --- a/Tests/Confuser.Renamer.Test/Analyzers/ManifestResourceAnalyzerTest.cs +++ b/Tests/Confuser.Renamer.Test/Analyzers/ManifestResourceAnalyzerTest.cs @@ -43,7 +43,8 @@ private static void CompareMethodBody(CilBody body1, CilBody body2) { if (instruction1.Operand is IMethodDefOrRef methodRef1) { var methodRef2 = Assert.IsAssignableFrom(instruction2.Operand); Assert.Equal(methodRef1.FullName, methodRef2.FullName); - } else { + } + else { Assert.Equal(instruction1.Operand, instruction2.Operand); } } diff --git a/Tests/Confuser.Renamer.Test/Analyzers/ReflectionAnalyzerTest.cs b/Tests/Confuser.Renamer.Test/Analyzers/ReflectionAnalyzerTest.cs index 8358e0acc..fe2ff1be0 100644 --- a/Tests/Confuser.Renamer.Test/Analyzers/ReflectionAnalyzerTest.cs +++ b/Tests/Confuser.Renamer.Test/Analyzers/ReflectionAnalyzerTest.cs @@ -41,7 +41,7 @@ public void TestReferenceField1() { var field2 = typeof(ReflectionAnalyzerTest).GetField(nameof(_referenceField), BindingFlags.NonPublic | BindingFlags.Instance); Assert.NotNull(field2); } - + [SuppressMessage("Usage", "xUnit1013:Public method should be marked as test", Justification = "It's not a test!")] public void TestReferenceProperty1() { var prop1 = typeof(ReflectionAnalyzerTest).GetProperty(nameof(ReferenceProperty)); diff --git a/Tests/Confuser.Renamer.Test/Analyzers/TypeBlobAnalyzerTest.cs b/Tests/Confuser.Renamer.Test/Analyzers/TypeBlobAnalyzerTest.cs index 7a8c090bc..8534cc375 100644 --- a/Tests/Confuser.Renamer.Test/Analyzers/TypeBlobAnalyzerTest.cs +++ b/Tests/Confuser.Renamer.Test/Analyzers/TypeBlobAnalyzerTest.cs @@ -18,21 +18,21 @@ public class TypeBlobAnalyzerTest { public TypeBlobAnalyzerTest(ITestOutputHelper outputHelper) => this.outputHelper = outputHelper ?? throw new ArgumentNullException(nameof(outputHelper)); - [Fact] + [Fact] [Trait("Category", "Protection")] [Trait("Protection", "rename")] [Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/84")] public void AnalyseAttributeTest() { var moduleDef = Helpers.LoadTestModuleDef(); - + var nameService = Mock.Of(); - void VerifyLog(string message) { - Assert.DoesNotContain("Failed to resolve CA field", message); - Assert.DoesNotContain("Failed to resolve CA property", message); + void VerifyLog(string message) { + Assert.DoesNotContain("Failed to resolve CA field", message); + Assert.DoesNotContain("Failed to resolve CA property", message); } - TypeBlobAnalyzer.Analyze(nameService, new List() { moduleDef }, new XunitLogger(outputHelper, VerifyLog), moduleDef); + TypeBlobAnalyzer.Analyze(nameService, new List() { moduleDef }, new XunitLogger(outputHelper, VerifyLog), moduleDef); Mock.Get(nameService).VerifyAll(); } diff --git a/Tests/Confuser.Renamer.Test/Confuser.Renamer.Test.csproj b/Tests/Confuser.Renamer.Test/Confuser.Renamer.Test.csproj index 050aa41f6..8e3084de6 100644 --- a/Tests/Confuser.Renamer.Test/Confuser.Renamer.Test.csproj +++ b/Tests/Confuser.Renamer.Test/Confuser.Renamer.Test.csproj @@ -1,12 +1,12 @@  - net461 + net10.0 false - + diff --git a/Tests/Confuser.Renamer.Test/Helpers.cs b/Tests/Confuser.Renamer.Test/Helpers.cs index caa4cfe74..1588a3fe4 100644 --- a/Tests/Confuser.Renamer.Test/Helpers.cs +++ b/Tests/Confuser.Renamer.Test/Helpers.cs @@ -11,11 +11,11 @@ internal static ModuleDefMD LoadTestModuleDef() { TryToLoadPdbFromDisk = false }; - asmResolver.AddToCache(ModuleDefMD.Load(typeof(Mock).Module, options)); - asmResolver.AddToCache(ModuleDefMD.Load(typeof(FactAttribute).Module, options)); + asmResolver.AddToCache(ModuleDefMD.Load(typeof(Mock).Module, options)); + asmResolver.AddToCache(ModuleDefMD.Load(typeof(FactAttribute).Module, options)); - var thisModule = ModuleDefMD.Load(typeof(VTableTest).Module, options); - asmResolver.AddToCache(thisModule); + var thisModule = ModuleDefMD.Load(typeof(VTableTest).Module, options); + asmResolver.AddToCache(thisModule); return thisModule; } diff --git a/Tests/Confuser.Renamer.Test/VTableTest.cs b/Tests/Confuser.Renamer.Test/VTableTest.cs index 1e5d3df11..12bd50a0c 100644 --- a/Tests/Confuser.Renamer.Test/VTableTest.cs +++ b/Tests/Confuser.Renamer.Test/VTableTest.cs @@ -28,7 +28,7 @@ public void DuplicatedMethodSignatureTest() { var moduleDef = Helpers.LoadTestModuleDef(); var refClassTypeDef = moduleDef.Find("Confuser.Renamer.Test.VTableTestRefClass", false); - + Assert.NotNull(refClassTypeDef); var vTableStorage = new VTableStorage(new XunitLogger(outputHelper)); var refClassVTable = vTableStorage.GetVTable(refClassTypeDef); diff --git a/Tests/Confuser.UnitTest/Confuser.UnitTest.csproj b/Tests/Confuser.UnitTest/Confuser.UnitTest.csproj index de58ba3f9..557a11859 100644 --- a/Tests/Confuser.UnitTest/Confuser.UnitTest.csproj +++ b/Tests/Confuser.UnitTest/Confuser.UnitTest.csproj @@ -3,13 +3,13 @@ - net461 + net462;net10.0 - - - + + + diff --git a/Tests/Confuser.UnitTest/TestBase.cs b/Tests/Confuser.UnitTest/TestBase.cs index b4bf8feea..c23372ebc 100644 --- a/Tests/Confuser.UnitTest/TestBase.cs +++ b/Tests/Confuser.UnitTest/TestBase.cs @@ -24,30 +24,31 @@ protected TestBase(ITestOutputHelper outputHelper) => protected Task Run(string inputFileName, string[] expectedOutput, SettingItem protection, string outputDirSuffix = "", Action outputAction = null, SettingItem packer = null, Action projectModuleAction = null, Func postProcessAction = null, - string seed = null, bool checkOutput = true) => + string seed = null, bool checkOutput = true, string processArguments = null) => Run(new[] { inputFileName }, expectedOutput, protection, outputDirSuffix, outputAction, packer, - projectModuleAction, postProcessAction, seed, checkOutput); + projectModuleAction, postProcessAction, seed, checkOutput, processArguments); protected Task Run(string inputFileName, string[] expectedOutput, IEnumerable> protections, string outputDirSuffix = "", Action outputAction = null, SettingItem packer = null, - Action projectModuleAction = null, Func postProcessAction = null) => + Action projectModuleAction = null, Func postProcessAction = null, + string processArguments = null) => Run(new[] { inputFileName }, expectedOutput, protections, outputDirSuffix, outputAction, packer, - projectModuleAction, postProcessAction); + projectModuleAction, postProcessAction, processArguments: processArguments); protected Task Run(string[] inputFileNames, string[] expectedOutput, SettingItem protection, string outputDirSuffix = "", Action outputAction = null, SettingItem packer = null, Action projectModuleAction = null, Func postProcessAction = null, - string seed = null, bool checkOutput = true) { + string seed = null, bool checkOutput = true, string processArguments = null) { var protections = (protection is null) ? Enumerable.Empty>() : new[] { protection }; - return Run(inputFileNames, expectedOutput, protections, outputDirSuffix, outputAction, packer, projectModuleAction, postProcessAction, seed, checkOutput); + return Run(inputFileNames, expectedOutput, protections, outputDirSuffix, outputAction, packer, projectModuleAction, postProcessAction, seed, checkOutput, processArguments); } protected async Task Run(string[] inputFileNames, string[] expectedOutput, IEnumerable> protections, string outputDirSuffix = "", Action outputAction = null, SettingItem packer = null, Action projectModuleAction = null, Func postProcessAction = null, - string seed = null, bool checkOutput = true) { + string seed = null, bool checkOutput = true, string processArguments = null) { var baseDir = Environment.CurrentDirectory; var outputDir = Path.Combine(baseDir, "obfuscated" + outputDirSuffix); @@ -115,7 +116,8 @@ protected async Task Run(string[] inputFileNames, string[] expectedOutput, IEnum var info = new ProcessStartInfo(entryOutputFileName) { RedirectStandardOutput = true, RedirectStandardError = true, - UseShellExecute = false + UseShellExecute = false, + Arguments = processArguments ?? "" }; using (var process = Process.Start(info)) { using (var stdout = process.StandardOutput) { diff --git a/Tests/Confuser.UnitTest/XUnitLogger.cs b/Tests/Confuser.UnitTest/XUnitLogger.cs index 151e07f13..aa627b036 100644 --- a/Tests/Confuser.UnitTest/XUnitLogger.cs +++ b/Tests/Confuser.UnitTest/XUnitLogger.cs @@ -51,7 +51,7 @@ void ILogger.WarnException(string msg, Exception ex) => void ILogger.WarnFormat(string format, params object[] args) => ProcessOutput("[WARN] " + format, args); - private void ProcessOutput(string format, params object[] args) => + private void ProcessOutput(string format, params object[] args) => ProcessOutput(string.Format(format, args)); private void ProcessOutput(string message) { diff --git a/Tests/CrossFramework.Console.Net10/CrossFramework.Console.Net10.csproj b/Tests/CrossFramework.Console.Net10/CrossFramework.Console.Net10.csproj new file mode 100644 index 000000000..efcb38afd --- /dev/null +++ b/Tests/CrossFramework.Console.Net10/CrossFramework.Console.Net10.csproj @@ -0,0 +1,7 @@ + + + Exe + net10.0 + disable + + diff --git a/Tests/CrossFramework.Console.Net10/Program.cs b/Tests/CrossFramework.Console.Net10/Program.cs new file mode 100644 index 000000000..9b583fac2 --- /dev/null +++ b/Tests/CrossFramework.Console.Net10/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace CrossFramework.Console { + class Program { + static int Main() { + System.Console.WriteLine("START"); + System.Console.WriteLine("Hello from net10.0"); + System.Console.WriteLine("END"); + return 42; + } + } +} diff --git a/Tests/CrossFramework.Console.Net20/CrossFramework.Console.Net20.csproj b/Tests/CrossFramework.Console.Net20/CrossFramework.Console.Net20.csproj new file mode 100644 index 000000000..38a27fb7b --- /dev/null +++ b/Tests/CrossFramework.Console.Net20/CrossFramework.Console.Net20.csproj @@ -0,0 +1,10 @@ + + + Exe + net20 + 7.3 + + + + + diff --git a/Tests/CrossFramework.Console.Net20/Program.cs b/Tests/CrossFramework.Console.Net20/Program.cs new file mode 100644 index 000000000..beae9a9b4 --- /dev/null +++ b/Tests/CrossFramework.Console.Net20/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace CrossFramework.Console { + class Program { + static int Main() { + System.Console.WriteLine("START"); + System.Console.WriteLine("Hello from net20"); + System.Console.WriteLine("END"); + return 42; + } + } +} diff --git a/Tests/CrossFramework.Console.Net35/CrossFramework.Console.Net35.csproj b/Tests/CrossFramework.Console.Net35/CrossFramework.Console.Net35.csproj new file mode 100644 index 000000000..430f17839 --- /dev/null +++ b/Tests/CrossFramework.Console.Net35/CrossFramework.Console.Net35.csproj @@ -0,0 +1,10 @@ + + + Exe + net35 + 7.3 + + + + + diff --git a/Tests/CrossFramework.Console.Net35/Program.cs b/Tests/CrossFramework.Console.Net35/Program.cs new file mode 100644 index 000000000..b675bcf22 --- /dev/null +++ b/Tests/CrossFramework.Console.Net35/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace CrossFramework.Console { + class Program { + static int Main() { + System.Console.WriteLine("START"); + System.Console.WriteLine("Hello from net35"); + System.Console.WriteLine("END"); + return 42; + } + } +} diff --git a/Tests/CrossFramework.Console.Net40/CrossFramework.Console.Net40.csproj b/Tests/CrossFramework.Console.Net40/CrossFramework.Console.Net40.csproj new file mode 100644 index 000000000..1d1e01555 --- /dev/null +++ b/Tests/CrossFramework.Console.Net40/CrossFramework.Console.Net40.csproj @@ -0,0 +1,10 @@ + + + Exe + net40 + 7.3 + + + + + diff --git a/Tests/CrossFramework.Console.Net40/Program.cs b/Tests/CrossFramework.Console.Net40/Program.cs new file mode 100644 index 000000000..5eef86bc4 --- /dev/null +++ b/Tests/CrossFramework.Console.Net40/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace CrossFramework.Console { + class Program { + static int Main() { + System.Console.WriteLine("START"); + System.Console.WriteLine("Hello from net40"); + System.Console.WriteLine("END"); + return 42; + } + } +} diff --git a/Tests/CrossFramework.Console.Net48/CrossFramework.Console.Net48.csproj b/Tests/CrossFramework.Console.Net48/CrossFramework.Console.Net48.csproj new file mode 100644 index 000000000..f26e46227 --- /dev/null +++ b/Tests/CrossFramework.Console.Net48/CrossFramework.Console.Net48.csproj @@ -0,0 +1,7 @@ + + + Exe + net48 + 7.3 + + diff --git a/Tests/CrossFramework.Console.Net48/Program.cs b/Tests/CrossFramework.Console.Net48/Program.cs new file mode 100644 index 000000000..72f9ac69f --- /dev/null +++ b/Tests/CrossFramework.Console.Net48/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace CrossFramework.Console { + class Program { + static int Main() { + System.Console.WriteLine("START"); + System.Console.WriteLine("Hello from net48"); + System.Console.WriteLine("END"); + return 42; + } + } +} diff --git a/Tests/CrossFramework.Console.Net6/CrossFramework.Console.Net6.csproj b/Tests/CrossFramework.Console.Net6/CrossFramework.Console.Net6.csproj new file mode 100644 index 000000000..b87b9174f --- /dev/null +++ b/Tests/CrossFramework.Console.Net6/CrossFramework.Console.Net6.csproj @@ -0,0 +1,7 @@ + + + Exe + net6.0 + disable + + diff --git a/Tests/CrossFramework.Console.Net6/Program.cs b/Tests/CrossFramework.Console.Net6/Program.cs new file mode 100644 index 000000000..adf77bd1d --- /dev/null +++ b/Tests/CrossFramework.Console.Net6/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace CrossFramework.Console { + class Program { + static int Main() { + System.Console.WriteLine("START"); + System.Console.WriteLine("Hello from net6.0"); + System.Console.WriteLine("END"); + return 42; + } + } +} diff --git a/Tests/CrossFramework.Console.Net8/CrossFramework.Console.Net8.csproj b/Tests/CrossFramework.Console.Net8/CrossFramework.Console.Net8.csproj new file mode 100644 index 000000000..d0ab6f9a4 --- /dev/null +++ b/Tests/CrossFramework.Console.Net8/CrossFramework.Console.Net8.csproj @@ -0,0 +1,7 @@ + + + Exe + net8.0 + disable + + diff --git a/Tests/CrossFramework.Console.Net8/Program.cs b/Tests/CrossFramework.Console.Net8/Program.cs new file mode 100644 index 000000000..779a97411 --- /dev/null +++ b/Tests/CrossFramework.Console.Net8/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace CrossFramework.Console { + class Program { + static int Main() { + System.Console.WriteLine("START"); + System.Console.WriteLine("Hello from net8.0"); + System.Console.WriteLine("END"); + return 42; + } + } +} diff --git a/Tests/CrossFramework.Library.Net10/CrossFramework.Library.Net10.csproj b/Tests/CrossFramework.Library.Net10/CrossFramework.Library.Net10.csproj new file mode 100644 index 000000000..012b60f13 --- /dev/null +++ b/Tests/CrossFramework.Library.Net10/CrossFramework.Library.Net10.csproj @@ -0,0 +1,6 @@ + + + net10.0 + disable + + diff --git a/Tests/CrossFramework.Library.Net10/SampleService.cs b/Tests/CrossFramework.Library.Net10/SampleService.cs new file mode 100644 index 000000000..110d9fa41 --- /dev/null +++ b/Tests/CrossFramework.Library.Net10/SampleService.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace CrossFramework.Library { + public class SampleService { + private readonly string prefix; + + public SampleService(string prefix) { + this.prefix = prefix ?? throw new ArgumentNullException(nameof(prefix)); + } + + public string Prefix => prefix; + + public string Format(string input) { + return prefix + ": " + input; + } + + public IReadOnlyList FormatMany(IEnumerable inputs) { + var results = new List(); + foreach (var input in inputs) + results.Add(Format(input)); + return results; + } + } + + public interface IProcessor { + string Process(string data); + } + + public class UpperCaseProcessor : IProcessor { + public string Process(string data) { + return data.ToUpperInvariant(); + } + } + + public class ReverseProcessor : IProcessor { + public string Process(string data) { + var chars = data.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + } +} diff --git a/Tests/CrossFramework.Library.Net48/CrossFramework.Library.Net48.csproj b/Tests/CrossFramework.Library.Net48/CrossFramework.Library.Net48.csproj new file mode 100644 index 000000000..6a0fdfd0f --- /dev/null +++ b/Tests/CrossFramework.Library.Net48/CrossFramework.Library.Net48.csproj @@ -0,0 +1,6 @@ + + + net48 + 7.3 + + diff --git a/Tests/CrossFramework.Library.Net48/SampleService.cs b/Tests/CrossFramework.Library.Net48/SampleService.cs new file mode 100644 index 000000000..110d9fa41 --- /dev/null +++ b/Tests/CrossFramework.Library.Net48/SampleService.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace CrossFramework.Library { + public class SampleService { + private readonly string prefix; + + public SampleService(string prefix) { + this.prefix = prefix ?? throw new ArgumentNullException(nameof(prefix)); + } + + public string Prefix => prefix; + + public string Format(string input) { + return prefix + ": " + input; + } + + public IReadOnlyList FormatMany(IEnumerable inputs) { + var results = new List(); + foreach (var input in inputs) + results.Add(Format(input)); + return results; + } + } + + public interface IProcessor { + string Process(string data); + } + + public class UpperCaseProcessor : IProcessor { + public string Process(string data) { + return data.ToUpperInvariant(); + } + } + + public class ReverseProcessor : IProcessor { + public string Process(string data) { + var chars = data.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + } +} diff --git a/Tests/CrossFramework.Library.Net6/CrossFramework.Library.Net6.csproj b/Tests/CrossFramework.Library.Net6/CrossFramework.Library.Net6.csproj new file mode 100644 index 000000000..f84197458 --- /dev/null +++ b/Tests/CrossFramework.Library.Net6/CrossFramework.Library.Net6.csproj @@ -0,0 +1,6 @@ + + + net6.0 + disable + + diff --git a/Tests/CrossFramework.Library.Net6/SampleService.cs b/Tests/CrossFramework.Library.Net6/SampleService.cs new file mode 100644 index 000000000..110d9fa41 --- /dev/null +++ b/Tests/CrossFramework.Library.Net6/SampleService.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace CrossFramework.Library { + public class SampleService { + private readonly string prefix; + + public SampleService(string prefix) { + this.prefix = prefix ?? throw new ArgumentNullException(nameof(prefix)); + } + + public string Prefix => prefix; + + public string Format(string input) { + return prefix + ": " + input; + } + + public IReadOnlyList FormatMany(IEnumerable inputs) { + var results = new List(); + foreach (var input in inputs) + results.Add(Format(input)); + return results; + } + } + + public interface IProcessor { + string Process(string data); + } + + public class UpperCaseProcessor : IProcessor { + public string Process(string data) { + return data.ToUpperInvariant(); + } + } + + public class ReverseProcessor : IProcessor { + public string Process(string data) { + var chars = data.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + } +} diff --git a/Tests/CrossFramework.Library.Net8/CrossFramework.Library.Net8.csproj b/Tests/CrossFramework.Library.Net8/CrossFramework.Library.Net8.csproj new file mode 100644 index 000000000..b0437b597 --- /dev/null +++ b/Tests/CrossFramework.Library.Net8/CrossFramework.Library.Net8.csproj @@ -0,0 +1,6 @@ + + + net8.0 + disable + + diff --git a/Tests/CrossFramework.Library.Net8/SampleService.cs b/Tests/CrossFramework.Library.Net8/SampleService.cs new file mode 100644 index 000000000..110d9fa41 --- /dev/null +++ b/Tests/CrossFramework.Library.Net8/SampleService.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace CrossFramework.Library { + public class SampleService { + private readonly string prefix; + + public SampleService(string prefix) { + this.prefix = prefix ?? throw new ArgumentNullException(nameof(prefix)); + } + + public string Prefix => prefix; + + public string Format(string input) { + return prefix + ": " + input; + } + + public IReadOnlyList FormatMany(IEnumerable inputs) { + var results = new List(); + foreach (var input in inputs) + results.Add(Format(input)); + return results; + } + } + + public interface IProcessor { + string Process(string data); + } + + public class UpperCaseProcessor : IProcessor { + public string Process(string data) { + return data.ToUpperInvariant(); + } + } + + public class ReverseProcessor : IProcessor { + public string Process(string data) { + var chars = data.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + } +} diff --git a/Tests/CrossFramework.Library.NetStd20/CrossFramework.Library.NetStd20.csproj b/Tests/CrossFramework.Library.NetStd20/CrossFramework.Library.NetStd20.csproj new file mode 100644 index 000000000..b3d23924d --- /dev/null +++ b/Tests/CrossFramework.Library.NetStd20/CrossFramework.Library.NetStd20.csproj @@ -0,0 +1,6 @@ + + + netstandard2.0 + 7.3 + + diff --git a/Tests/CrossFramework.Library.NetStd20/SampleService.cs b/Tests/CrossFramework.Library.NetStd20/SampleService.cs new file mode 100644 index 000000000..110d9fa41 --- /dev/null +++ b/Tests/CrossFramework.Library.NetStd20/SampleService.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace CrossFramework.Library { + public class SampleService { + private readonly string prefix; + + public SampleService(string prefix) { + this.prefix = prefix ?? throw new ArgumentNullException(nameof(prefix)); + } + + public string Prefix => prefix; + + public string Format(string input) { + return prefix + ": " + input; + } + + public IReadOnlyList FormatMany(IEnumerable inputs) { + var results = new List(); + foreach (var input in inputs) + results.Add(Format(input)); + return results; + } + } + + public interface IProcessor { + string Process(string data); + } + + public class UpperCaseProcessor : IProcessor { + public string Process(string data) { + return data.ToUpperInvariant(); + } + } + + public class ReverseProcessor : IProcessor { + public string Process(string data) { + var chars = data.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + } +} diff --git a/Tests/CrossFramework.Test/ConsoleFrameworkTest.cs b/Tests/CrossFramework.Test/ConsoleFrameworkTest.cs new file mode 100644 index 000000000..8f0ea9990 --- /dev/null +++ b/Tests/CrossFramework.Test/ConsoleFrameworkTest.cs @@ -0,0 +1,89 @@ +using System.Threading.Tasks; +using Confuser.Core; +using Confuser.Core.Project; +using Confuser.UnitTest; +using Xunit; +using Xunit.Abstractions; + +namespace CrossFramework.Test { + public class ConsoleFrameworkTest : TestBase { + public ConsoleFrameworkTest(ITestOutputHelper outputHelper) : base(outputHelper) { } + + // --- .NET Framework (produces real .exe — obfuscate + run) --- + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Console")] + [Trait("TFM", "net20")] + public Task Console_Net20_RenameProtection() => + Run("CrossFramework.Console.Net20.exe", + new[] { "Hello from net20" }, + new SettingItem("rename"), + outputDirSuffix: "-console-net20"); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Console")] + [Trait("TFM", "net35")] + public Task Console_Net35_RenameProtection() => + Run("CrossFramework.Console.Net35.exe", + new[] { "Hello from net35" }, + new SettingItem("rename"), + outputDirSuffix: "-console-net35"); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Console")] + [Trait("TFM", "net40")] + public Task Console_Net40_RenameProtection() => + Run("CrossFramework.Console.Net40.exe", + new[] { "Hello from net40" }, + new SettingItem("rename"), + outputDirSuffix: "-console-net40"); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Console")] + [Trait("TFM", "net48")] + public Task Console_Net48_RenameProtection() => + Run("CrossFramework.Console.Net48.exe", + new[] { "Hello from net48" }, + new SettingItem("rename"), + outputDirSuffix: "-console-net48"); + + // --- Modern .NET (apphost .exe is not a managed assembly — obfuscate the .dll) --- + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Console")] + [Trait("TFM", "net6.0")] + public Task Console_Net6_RenameProtection() => + Run("CrossFramework.Console.Net6.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-console-net6", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Console")] + [Trait("TFM", "net8.0")] + public Task Console_Net8_RenameProtection() => + Run("CrossFramework.Console.Net8.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-console-net8", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Console")] + [Trait("TFM", "net10.0")] + public Task Console_Net10_RenameProtection() => + Run("CrossFramework.Console.Net10.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-console-net10", + checkOutput: false); + } +} diff --git a/Tests/CrossFramework.Test/CrossFramework.Test.csproj b/Tests/CrossFramework.Test/CrossFramework.Test.csproj new file mode 100644 index 000000000..84e67f836 --- /dev/null +++ b/Tests/CrossFramework.Test/CrossFramework.Test.csproj @@ -0,0 +1,54 @@ + + + + net10.0-windows + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/CrossFramework.Test/LibraryFrameworkTest.cs b/Tests/CrossFramework.Test/LibraryFrameworkTest.cs new file mode 100644 index 000000000..17a977088 --- /dev/null +++ b/Tests/CrossFramework.Test/LibraryFrameworkTest.cs @@ -0,0 +1,68 @@ +using System.IO; +using System.Threading.Tasks; +using Confuser.Core; +using Confuser.Core.Project; +using Confuser.UnitTest; +using Xunit; +using Xunit.Abstractions; + +namespace CrossFramework.Test { + public class LibraryFrameworkTest : TestBase { + public LibraryFrameworkTest(ITestOutputHelper outputHelper) : base(outputHelper) { } + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Library")] + [Trait("TFM", "netstandard2.0")] + public Task Library_NetStd20_RenameProtection() => + Run("CrossFramework.Library.NetStd20.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-lib-netstd20", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Library")] + [Trait("TFM", "net48")] + public Task Library_Net48_RenameProtection() => + Run("CrossFramework.Library.Net48.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-lib-net48", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Library")] + [Trait("TFM", "net6.0")] + public Task Library_Net6_RenameProtection() => + Run("CrossFramework.Library.Net6.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-lib-net6", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Library")] + [Trait("TFM", "net8.0")] + public Task Library_Net8_RenameProtection() => + Run("CrossFramework.Library.Net8.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-lib-net8", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "Library")] + [Trait("TFM", "net10.0")] + public Task Library_Net10_RenameProtection() => + Run("CrossFramework.Library.Net10.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-lib-net10", + checkOutput: false); + } +} diff --git a/Tests/CrossFramework.Test/WinFormsFrameworkTest.cs b/Tests/CrossFramework.Test/WinFormsFrameworkTest.cs new file mode 100644 index 000000000..b6fecf658 --- /dev/null +++ b/Tests/CrossFramework.Test/WinFormsFrameworkTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using Confuser.Core; +using Confuser.Core.Project; +using Confuser.UnitTest; +using Xunit; +using Xunit.Abstractions; + +namespace CrossFramework.Test { + public class WinFormsFrameworkTest : TestBase { + public WinFormsFrameworkTest(ITestOutputHelper outputHelper) : base(outputHelper) { } + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WinForms")] + [Trait("TFM", "net35")] + public Task WinForms_Net35_RenameProtection() => + Run("CrossFramework.WinForms.Net35.exe", + new[] { "Label: Not clicked", "Title: ConfuserEx WinForms Test (net35)" }, + new SettingItem("rename"), + processArguments: "--verify", + outputDirSuffix: "-winforms-net35"); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WinForms")] + [Trait("TFM", "net40")] + public Task WinForms_Net40_RenameProtection() => + Run("CrossFramework.WinForms.Net40.exe", + new[] { "Label: Not clicked", "Title: ConfuserEx WinForms Test (net40)" }, + new SettingItem("rename"), + processArguments: "--verify", + outputDirSuffix: "-winforms-net40"); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WinForms")] + [Trait("TFM", "net48")] + public Task WinForms_Net48_RenameProtection() => + Run("CrossFramework.WinForms.Net48.exe", + new[] { "Label: Not clicked", "Title: ConfuserEx WinForms Test (net48)" }, + new SettingItem("rename"), + processArguments: "--verify", + outputDirSuffix: "-winforms-net48"); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WinForms")] + [Trait("TFM", "net6.0-windows")] + public Task WinForms_Net6_RenameProtection() => + Run("CrossFramework.WinForms.Net6.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-winforms-net6", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WinForms")] + [Trait("TFM", "net8.0-windows")] + public Task WinForms_Net8_RenameProtection() => + Run("CrossFramework.WinForms.Net8.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-winforms-net8", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WinForms")] + [Trait("TFM", "net10.0-windows")] + public Task WinForms_Net10_RenameProtection() => + Run("CrossFramework.WinForms.Net10.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-winforms-net10", + checkOutput: false); + } +} diff --git a/Tests/CrossFramework.Test/WpfFrameworkTest.cs b/Tests/CrossFramework.Test/WpfFrameworkTest.cs new file mode 100644 index 000000000..b60030a41 --- /dev/null +++ b/Tests/CrossFramework.Test/WpfFrameworkTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using Confuser.Core; +using Confuser.Core.Project; +using Confuser.UnitTest; +using Xunit; +using Xunit.Abstractions; + +namespace CrossFramework.Test { + public class WpfFrameworkTest : TestBase { + public WpfFrameworkTest(ITestOutputHelper outputHelper) : base(outputHelper) { } + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WPF")] + [Trait("TFM", "net35")] + public Task WPF_Net35_RenameProtection() => + Run("CrossFramework.WPF.Net35.exe", + new[] { "Title: ConfuserEx WPF Test (net35)", "Content: WPF is working" }, + new SettingItem("rename"), + processArguments: "--verify", + outputDirSuffix: "-wpf-net35"); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WPF")] + [Trait("TFM", "net40")] + public Task WPF_Net40_RenameProtection() => + Run("CrossFramework.WPF.Net40.exe", + new[] { "Title: ConfuserEx WPF Test (net40)", "Content: WPF is working" }, + new SettingItem("rename"), + processArguments: "--verify", + outputDirSuffix: "-wpf-net40"); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WPF")] + [Trait("TFM", "net48")] + public Task WPF_Net48_RenameProtection() => + Run("CrossFramework.WPF.Net48.exe", + new[] { "Title: ConfuserEx WPF Test (Net48)", "Content: WPF is working" }, + new SettingItem("rename"), + processArguments: "--verify", + outputDirSuffix: "-wpf-net48"); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WPF")] + [Trait("TFM", "net6.0-windows")] + public Task WPF_Net6_RenameProtection() => + Run("CrossFramework.WPF.Net6.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-wpf-net6", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WPF")] + [Trait("TFM", "net8.0-windows")] + public Task WPF_Net8_RenameProtection() => + Run("CrossFramework.WPF.Net8.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-wpf-net8", + checkOutput: false); + + [Fact] + [Trait("Category", "CrossFramework")] + [Trait("AppType", "WPF")] + [Trait("TFM", "net10.0-windows")] + public Task WPF_Net10_RenameProtection() => + Run("CrossFramework.WPF.Net10.dll", + null, + new SettingItem("rename"), + outputDirSuffix: "-wpf-net10", + checkOutput: false); + } +} diff --git a/Tests/CrossFramework.WPF.Net10/App.xaml b/Tests/CrossFramework.WPF.Net10/App.xaml new file mode 100644 index 000000000..a13360fb3 --- /dev/null +++ b/Tests/CrossFramework.WPF.Net10/App.xaml @@ -0,0 +1,5 @@ + + diff --git a/Tests/CrossFramework.WPF.Net10/App.xaml.cs b/Tests/CrossFramework.WPF.Net10/App.xaml.cs new file mode 100644 index 000000000..8ca54a6ce --- /dev/null +++ b/Tests/CrossFramework.WPF.Net10/App.xaml.cs @@ -0,0 +1,18 @@ +using System; +using System.Windows; + +namespace CrossFramework.WPF { + public partial class App : Application { + protected override void OnStartup(StartupEventArgs e) { + base.OnStartup(e); + if (e.Args.Length > 0 && e.Args[0] == "--verify") { + Console.WriteLine("START"); + var window = new MainWindow(); + Console.WriteLine("Title: " + window.Title); + Console.WriteLine("Content: " + window.GetStatusText()); + Console.WriteLine("END"); + Shutdown(42); + } + } + } +} diff --git a/Tests/CrossFramework.WPF.Net10/CrossFramework.WPF.Net10.csproj b/Tests/CrossFramework.WPF.Net10/CrossFramework.WPF.Net10.csproj new file mode 100644 index 000000000..37a5b6c03 --- /dev/null +++ b/Tests/CrossFramework.WPF.Net10/CrossFramework.WPF.Net10.csproj @@ -0,0 +1,8 @@ + + + WinExe + net10.0-windows + true + disable + + diff --git a/Tests/CrossFramework.WPF.Net10/MainWindow.xaml b/Tests/CrossFramework.WPF.Net10/MainWindow.xaml new file mode 100644 index 000000000..f65346f27 --- /dev/null +++ b/Tests/CrossFramework.WPF.Net10/MainWindow.xaml @@ -0,0 +1,9 @@ + + + +