├── .gitignore
├── Core20Reader
├── Core20Reader.sln
└── Core20Reader
│ ├── Core20Reader.vbproj
│ ├── DataDirectory.vb
│ ├── IReader.vb
│ ├── My Project
│ ├── Application.Designer.vb
│ ├── Application.myapp
│ ├── AssemblyInfo.vb
│ ├── Resources.Designer.vb
│ ├── Resources.resx
│ ├── Settings.Designer.vb
│ └── Settings.settings
│ └── Reader.vb
├── DotNetPatcher.sln
├── DotNetPatcher
├── DNP.ico
├── DotNetPatcher.sln
├── DotNetPatcher.vbproj
├── Frm_Exclusion.designer.vb
├── Frm_Exclusion.resx
├── Frm_Exclusion.vb
├── Frm_Main.Designer.vb
├── Frm_Main.resx
├── Frm_Main.vb
├── Frm_Result.Designer.vb
├── Frm_Result.resx
├── Frm_Result.vb
├── My Project
│ ├── Application.Designer.vb
│ ├── Application.myapp
│ ├── AssemblyInfo.vb
│ ├── Resources.Designer.vb
│ ├── Resources.resx
│ ├── Settings.Designer.vb
│ ├── Settings.settings
│ └── app.manifest
├── Program.vb
├── Resources
│ ├── Loading.png
│ ├── TDD.png
│ ├── Valid.png
│ ├── Warning.png
│ └── error.png
└── app.config
├── Helper
├── Assembly
│ ├── Data.vb
│ ├── DataFull.vb
│ ├── IAssemblyInfos.vb
│ ├── Infos.vb
│ └── Loader.vb
├── Cecil
│ ├── DelegateEmitter.vb
│ ├── Finder.vb
│ ├── Injecter.vb
│ ├── Msil.vb
│ ├── NameChecker.vb
│ ├── ProcessedIL.vb
│ └── Utils.vb
├── CodeDom
│ └── Compiler.vb
├── Crypto
│ ├── Crypt.vb
│ └── Generator.vb
├── Helper.vbproj
├── My Project
│ ├── Application.Designer.vb
│ ├── Application.myapp
│ ├── AssemblyInfo.vb
│ ├── Resources.Designer.vb
│ ├── Resources.resx
│ ├── Settings.Designer.vb
│ └── Settings.settings
├── Randomize
│ ├── Randomizer.vb
│ └── RandomizerType.vb
├── Resource
│ ├── NativeMethods.vb
│ └── ResourceEx.vb
└── Utils
│ └── Functions.vb
├── Implementer
├── Core
│ ├── Dependencing
│ │ ├── AnalysisResult.vb
│ │ ├── Checker.vb
│ │ ├── Dependencies.vb
│ │ ├── DependenciesInfos.vb
│ │ └── Embedding.vb
│ ├── IconChanger
│ │ ├── Changer.vb
│ │ ├── IconInfos.vb
│ │ └── Replacer.vb
│ ├── ManifestRequest
│ │ ├── ManifestInfos.vb
│ │ ├── ManifestReader.vb
│ │ └── ManifestWriter.vb
│ ├── Obfuscation
│ │ ├── Anti
│ │ │ ├── AntiDebug.vb
│ │ │ ├── AntiDumper.vb
│ │ │ ├── AntiIlDasm.vb
│ │ │ └── AntiTamper.vb
│ │ ├── Builder
│ │ │ ├── Source.vb
│ │ │ └── Stub.vb
│ │ ├── Exclusion
│ │ │ ├── ExcludeList.vb
│ │ │ ├── ExcludeReflection.vb
│ │ │ ├── ExclusionReflection.vb
│ │ │ ├── ExclusionState.vb
│ │ │ ├── ExclusionTreeview.vb
│ │ │ └── ReflectionAnalyzer.vb
│ │ └── Protection
│ │ │ ├── Attribut.vb
│ │ │ ├── Bool.vb
│ │ │ ├── Constants.vb
│ │ │ ├── InvalidMetadata.vb
│ │ │ ├── Mild.vb
│ │ │ ├── Numeric.vb
│ │ │ ├── ObfuscationInfos.vb
│ │ │ ├── Pinvoke.vb
│ │ │ ├── PinvokeModifier.vb
│ │ │ ├── Str.vb
│ │ │ └── invalidOpcodes.vb
│ ├── Packer
│ │ ├── Pack.vb
│ │ ├── PackInfos.vb
│ │ └── ZipInfos.vb
│ ├── Resource
│ │ ├── Compression.vb
│ │ └── Content.vb
│ └── Versions
│ │ ├── Extractor.vb
│ │ ├── Infos.vb
│ │ └── Injector.vb
├── Engine
│ ├── Analyze
│ │ ├── Analyzer.vb
│ │ └── ValidatedFile.vb
│ ├── Checking
│ │ └── CheckerEventArgs.vb
│ ├── Context
│ │ ├── Parameters.vb
│ │ ├── RenamedItem
│ │ │ ├── RenamedItem.vb
│ │ │ ├── RenamedItemEventArgs.vb
│ │ │ └── RenamedItemType.vb
│ │ ├── RenamerState.vb
│ │ ├── TaskState.vb
│ │ └── Tasks.vb
│ ├── Identification
│ │ ├── Identifier.vb
│ │ ├── IdentifierEnum.vb
│ │ └── IdentifierResult.vb
│ └── Processing
│ │ ├── Mapping.vb
│ │ ├── ProcessTask.vb
│ │ └── Renamer.vb
├── Implementer.vbproj
├── My Project
│ ├── Application.Designer.vb
│ ├── Application.myapp
│ ├── AssemblyInfo.vb
│ ├── Resources.Designer.vb
│ ├── Resources.resx
│ ├── Settings.Designer.vb
│ └── Settings.settings
└── Resources
│ ├── AgileDotNet.png
│ ├── Babel.png
│ ├── CodeFort.png
│ ├── CodeVeil.png
│ ├── Confuser.png
│ ├── CryptoObfuscator.png
│ ├── DNP.png
│ ├── DotBundle.png
│ ├── DotFuscator.png
│ ├── DotWall.png
│ ├── EazFuscator.png
│ ├── Goliath.png
│ ├── ILProtector.png
│ ├── ILRepack.exe
│ ├── MPress.png
│ ├── Macrobject.png
│ ├── Manco.png
│ ├── NetPack.png
│ ├── NetReactor.png
│ ├── NetShrink.png
│ ├── Netz.png
│ ├── RPX.png
│ ├── SevenzipLib.dll
│ ├── Skater.png
│ ├── SmartAssembly.png
│ ├── Spices.png
│ ├── Valid.png
│ └── Warning.png
├── Injections
├── Injections.sln
└── Injections
│ ├── AntiDumping.cs
│ ├── Injections.csproj
│ └── Properties
│ └── AssemblyInfo.cs
├── LICENSE
├── LoginTheme
├── LoginTheme.vb
├── LoginTheme.vbproj
└── My Project
│ ├── Application.Designer.vb
│ ├── Application.myapp
│ ├── AssemblyInfo.vb
│ ├── Resources.Designer.vb
│ ├── Resources.resx
│ ├── Settings.Designer.vb
│ └── Settings.settings
├── README.md
├── ResourceLib
├── .gitignore
├── Accelerator.cs
├── AcceleratorResource.cs
├── BitmapFile.cs
├── BitmapResource.cs
├── CursorDirectoryResource.cs
├── CursorResource.cs
├── DeviceIndependentBitmap.cs
├── DialogExTemplate.cs
├── DialogExTemplateControl.cs
├── DialogResource.cs
├── DialogTemplate.cs
├── DialogTemplateBase.cs
├── DialogTemplateControl.cs
├── DialogTemplateControlBase.cs
├── DialogTemplateUtil.cs
├── DirectoryResource.cs
├── FixedFileInfo.cs
├── FontDirectoryEntry.cs
├── FontDirectoryResource.cs
├── FontResource.cs
├── Gdi32.cs
├── GenericResource.cs
├── IconDirectoryResource.cs
├── IconFile.cs
├── IconFileIcon.cs
├── IconImageResource.cs
├── IconResource.cs
├── Kernel32.cs
├── Key.snk
├── License.txt
├── LoadException.cs
├── ManifestResource.cs
├── MenuExTemplate.cs
├── MenuExTemplateItem.cs
├── MenuExTemplateItemCollection.cs
├── MenuExTemplateItemCommand.cs
├── MenuExTemplateItemPopup.cs
├── MenuResource.cs
├── MenuTemplate.cs
├── MenuTemplateBase.cs
├── MenuTemplateItem.cs
├── MenuTemplateItemCollection.cs
├── MenuTemplateItemCommand.cs
├── MenuTemplateItemPopup.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resource.cs
├── ResourceId.cs
├── ResourceInfo.cs
├── ResourceLib.csproj
├── ResourceTableHeader.cs
├── ResourceUtil.cs
├── StringFileInfo.cs
├── StringResource.cs
├── StringTable.cs
├── StringTableEntry.cs
├── User32.cs
├── VarFileInfo.cs
├── VarTable.cs
├── VersionResource.cs
├── Winver.cs
└── packages.config
└── Sevenzip
├── Sevenzip.sln
└── Sevenzip
├── CRC.cs
├── ICoder.cs
├── IMatchFinder.cs
├── LzBinTree.cs
├── LzInWindow.cs
├── LzOutWindow.cs
├── LzmaBase.cs
├── LzmaDecoder.cs
├── LzmaEncoder.cs
├── Properties
└── AssemblyInfo.cs
├── RangeCoder.cs
├── RangeCoderBit.cs
├── RangeCoderBitTree.cs
├── SevenZipHelper.cs
└── Sevenzip.csproj
/Core20Reader/Core20Reader.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DotNetRenamer.Core20Reader", "DotNetRenamer.Core20Reader\DotNetRenamer.Core20Reader.vbproj", "{EEF33D18-4542-4E3D-80F0-6BDA8DEEC0CD}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {EEF33D18-4542-4E3D-80F0-6BDA8DEEC0CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {EEF33D18-4542-4E3D-80F0-6BDA8DEEC0CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {EEF33D18-4542-4E3D-80F0-6BDA8DEEC0CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {EEF33D18-4542-4E3D-80F0-6BDA8DEEC0CD}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/Core20Reader/Core20Reader/DataDirectory.vb:
--------------------------------------------------------------------------------
1 | Imports Core20Reader.Reader
2 |
3 | Friend Class DataDirectory
4 |
5 | #Region " PRIVATE MEMBERS "
6 | Private m_Section As IMAGE_SECTION_HEADER
7 | Private m_SectionStartOffset As ULong
8 | Private m_Address As ULong
9 | Private m_Size As ULong
10 | #End Region
11 |
12 | #Region " PROPERTIES "
13 | Friend Property Address() As ULong
14 | Get
15 | Return m_Address
16 | End Get
17 | Set(value As ULong)
18 | m_Address = value
19 | End Set
20 | End Property
21 |
22 | Friend Property Size() As ULong
23 | Get
24 | Return m_Size
25 | End Get
26 | Set(value As ULong)
27 | m_Size = value
28 | End Set
29 | End Property
30 |
31 | Friend Property Section As IMAGE_SECTION_HEADER
32 | Get
33 | Return Me.m_Section
34 | End Get
35 | Set(value As IMAGE_SECTION_HEADER)
36 | m_Section = value
37 | End Set
38 | End Property
39 |
40 | Friend Property SectionStartOffset As ULong
41 | Get
42 | Return Me.m_SectionStartOffset
43 | End Get
44 | Set(value As ULong)
45 | m_SectionStartOffset = value
46 | End Set
47 | End Property
48 | #End Region
49 |
50 | End Class
51 |
--------------------------------------------------------------------------------
/Core20Reader/Core20Reader/IReader.vb:
--------------------------------------------------------------------------------
1 | Imports System.Drawing
2 |
3 | Public Interface IReader
4 |
5 | #Region " Methods "
6 | Sub ReadFile(filePath$)
7 | Function isExecutable() As Boolean
8 | #End Region
9 |
10 | #Region " Properties "
11 | ReadOnly Property isManagedFile() As Boolean
12 | ReadOnly Property GetSystemType As String
13 | ReadOnly Property GetTargetRuntime As String
14 | ReadOnly Property GetTargetPlatform As String
15 | ReadOnly Property GetMainIcon As Icon
16 | ReadOnly Property GetVersionInfos As FileVersionInfo
17 | ReadOnly Property HasInvalidSectionHeader As Boolean
18 | #End Region
19 |
20 | End Interface
21 |
--------------------------------------------------------------------------------
/Core20Reader/Core20Reader/My Project/Application.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.34014
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
--------------------------------------------------------------------------------
/Core20Reader/Core20Reader/My Project/Application.myapp:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | false
5 | 0
6 | true
7 | 0
8 | 1
9 | true
10 |
11 |
--------------------------------------------------------------------------------
/Core20Reader/Core20Reader/My Project/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | Imports System
2 | Imports System.Reflection
3 | Imports System.Runtime.InteropServices
4 |
5 | ' Les informations générales relatives à un assembly dépendent de
6 | ' l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7 | ' associées à un assembly.
8 |
9 | ' Passez en revue les valeurs des attributs de l'assembly
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 'Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
21 |
22 |
23 | ' Les informations de version pour un assembly se composent des quatre valeurs suivantes :
24 | '
25 | ' Version principale
26 | ' Version secondaire
27 | ' Numéro de build
28 | ' Révision
29 | '
30 | ' Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
31 | ' en utilisant '*', comme indiqué ci-dessous :
32 | '
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Core20Reader/Core20Reader/My Project/Resources.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.34014
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 | Imports System
15 |
16 | Namespace My.Resources
17 |
18 | 'Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
19 | 'à l'aide d'un outil, tel que ResGen ou Visual Studio.
20 | 'Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
21 | 'avec l'option /str ou régénérez votre projet VS.
22 | '''
23 | ''' Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
24 | '''
25 | _
29 | Friend Module Resources
30 |
31 | Private resourceMan As Global.System.Resources.ResourceManager
32 |
33 | Private resourceCulture As Global.System.Globalization.CultureInfo
34 |
35 | '''
36 | ''' Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
37 | '''
38 | _
39 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
40 | Get
41 | If Object.ReferenceEquals(resourceMan, Nothing) Then
42 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Core20Reader.Resources", GetType(Resources).Assembly)
43 | resourceMan = temp
44 | End If
45 | Return resourceMan
46 | End Get
47 | End Property
48 |
49 | '''
50 | ''' Remplace la propriété CurrentUICulture du thread actuel pour toutes
51 | ''' les recherches de ressources à l'aide de cette classe de ressource fortement typée.
52 | '''
53 | _
54 | Friend Property Culture() As Global.System.Globalization.CultureInfo
55 | Get
56 | Return resourceCulture
57 | End Get
58 | Set
59 | resourceCulture = value
60 | End Set
61 | End Property
62 | End Module
63 | End Namespace
64 |
--------------------------------------------------------------------------------
/Core20Reader/Core20Reader/My Project/Settings.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.34014
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | _
20 | Partial Friend NotInheritable Class MySettings
21 | Inherits Global.System.Configuration.ApplicationSettingsBase
22 |
23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()), MySettings)
24 |
25 | #Region "Fonctionnalité Enregistrement automatique My.Settings"
26 | #If _MyType = "WindowsForms" Then
27 | Private Shared addedHandler As Boolean
28 |
29 | Private Shared addedHandlerLockObject As New Object
30 |
31 | _
32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
33 | If My.Application.SaveMySettingsOnExit Then
34 | My.Settings.Save()
35 | End If
36 | End Sub
37 | #End If
38 | #End Region
39 |
40 | Public Shared ReadOnly Property [Default]() As MySettings
41 | Get
42 |
43 | #If _MyType = "WindowsForms" Then
44 | If Not addedHandler Then
45 | SyncLock addedHandlerLockObject
46 | If Not addedHandler Then
47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48 | addedHandler = True
49 | End If
50 | End SyncLock
51 | End If
52 | #End If
53 | Return defaultInstance
54 | End Get
55 | End Property
56 | End Class
57 | End Namespace
58 |
59 | Namespace My
60 |
61 | _
64 | Friend Module MySettingsProperty
65 |
66 | _
67 | Friend ReadOnly Property Settings() As Global.Core20Reader.My.MySettings
68 | Get
69 | Return Global.Core20Reader.My.MySettings.Default
70 | End Get
71 | End Property
72 | End Module
73 | End Namespace
74 |
--------------------------------------------------------------------------------
/Core20Reader/Core20Reader/My Project/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/DotNetPatcher/DNP.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/DotNetPatcher/DNP.ico
--------------------------------------------------------------------------------
/DotNetPatcher/Frm_Result.vb:
--------------------------------------------------------------------------------
1 | Imports System.IO
2 | Imports Implementer.Core.Obfuscation.Exclusion
3 |
4 | Public Class Frm_Result
5 |
6 | #Region " Fields "
7 | Private m_FilePath$
8 | Private m_hideAssemblyViewer As Boolean
9 | #End Region
10 |
11 | #Region " Constructor "
12 | Sub New(Title$, Message$, FilePath$, Optional ByVal hideAssemblyViewer As Boolean = False)
13 | InitializeComponent()
14 | Frm_ResultThemeContainer.Text = Title
15 | LblResultMessage.Text = Message
16 | m_FilePath = FilePath
17 | m_hideAssemblyViewer = hideAssemblyViewer
18 | End Sub
19 | #End Region
20 |
21 | #Region " Methods "
22 |
23 | Private Sub Frm_Result_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
24 | If Frm_ResultThemeContainer.Text.Contains("Error") Then
25 | PcbResultIcon.Image = My.Resources._error
26 | BtnResultOpenFileDir.Visible = False
27 | BtnResultOpenAssemblyViewer.Visible = False
28 | ElseIf Frm_ResultThemeContainer.Text.Contains("Success") Then
29 | PcbResultIcon.Image = My.Resources.Valid
30 | BtnResultOpenFileDir.Visible = True
31 | BtnResultOpenAssemblyViewer.Visible = True
32 | BtnResultOpenAssemblyViewer.Enabled = If(m_hideAssemblyViewer, False, True)
33 | ElseIf Frm_ResultThemeContainer.Text.Contains("Warning") Then
34 | PcbResultIcon.Image = My.Resources.Warning
35 | BtnResultOpenFileDir.Visible = False
36 | BtnResultOpenAssemblyViewer.Visible = False
37 | ElseIf Frm_ResultThemeContainer.Text.Contains("Loading") Then
38 | PcbResultIcon.Image = My.Resources.Loading
39 | BtnResultOpenFileDir.Visible = False
40 | BtnResultOpenAssemblyViewer.Visible = False
41 | End If
42 | PcbResultIcon.Visible = True
43 | End Sub
44 |
45 | Private Sub BtnStart_Click(sender As Object, e As EventArgs) Handles BtnResultClose.Click
46 | Me.Close()
47 | End Sub
48 |
49 | Private Sub BtnResultOpenFileDir_Click(sender As Object, e As EventArgs) Handles BtnResultOpenFileDir.Click
50 | Dim fi As New FileInfo(m_FilePath)
51 | Process.Start(fi.DirectoryName)
52 | Me.Close()
53 | End Sub
54 |
55 | Private Sub BtnResultOpenAssemblyViewer_Click(sender As Object, e As EventArgs) Handles BtnResultOpenAssemblyViewer.Click
56 | Dim m_exclude = New Frm_Exclusion
57 | m_exclude.InitializeExcludeList()
58 | m_exclude.SettingsState = New ExclusionState(False, False, False, False, False, False)
59 | With m_exclude
60 | .Dependencies = New List(Of String)
61 | .Title = "Protected file"
62 | .ViewAssemblyOnly = True
63 | .FilePath = m_FilePath
64 | .ShowDialog()
65 | End With
66 |
67 | 'Dim frm As New Frm_Exclusion(New ExclusionTreeview(_FilePath), "Protected file", True)
68 | 'frm.ShowDialog()
69 | End Sub
70 | #End Region
71 |
72 | End Class
--------------------------------------------------------------------------------
/DotNetPatcher/My Project/Application.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.18449
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
--------------------------------------------------------------------------------
/DotNetPatcher/My Project/Application.myapp:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | Frm_Main
5 | false
6 | 0
7 | true
8 | 0
9 | false
10 |
--------------------------------------------------------------------------------
/DotNetPatcher/My Project/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | Imports System
2 | Imports System.Reflection
3 | Imports System.Runtime.InteropServices
4 |
5 | ' Les informations générales relatives à un assembly dépendent de
6 | ' l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7 | ' associées à un assembly.
8 |
9 | ' Passez en revue les valeurs des attributs de l'assembly
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 'Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
21 |
22 |
23 | ' Les informations de version pour un assembly se composent des quatre valeurs suivantes :
24 | '
25 | ' Version principale
26 | ' Version secondaire
27 | ' Numéro de build
28 | ' Révision
29 | '
30 | ' Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
31 | ' en utilisant '*', comme indiqué ci-dessous :
32 | '
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/DotNetPatcher/My Project/Settings.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.18449
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | _
20 | Partial Friend NotInheritable Class MySettings
21 | Inherits Global.System.Configuration.ApplicationSettingsBase
22 |
23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
24 |
25 | #Region "Fonctionnalité Enregistrement automatique My.Settings"
26 | #If _MyType = "WindowsForms" Then
27 | Private Shared addedHandler As Boolean
28 |
29 | Private Shared addedHandlerLockObject As New Object
30 |
31 | _
32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
33 | If My.Application.SaveMySettingsOnExit Then
34 | My.Settings.Save()
35 | End If
36 | End Sub
37 | #End If
38 | #End Region
39 |
40 | Public Shared ReadOnly Property [Default]() As MySettings
41 | Get
42 |
43 | #If _MyType = "WindowsForms" Then
44 | If Not addedHandler Then
45 | SyncLock addedHandlerLockObject
46 | If Not addedHandler Then
47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48 | addedHandler = True
49 | End If
50 | End SyncLock
51 | End If
52 | #End If
53 | Return defaultInstance
54 | End Get
55 | End Property
56 | End Class
57 | End Namespace
58 |
59 | Namespace My
60 |
61 | _
64 | Friend Module MySettingsProperty
65 |
66 | _
67 | Friend ReadOnly Property Settings() As Global.DotNetPatcher.My.MySettings
68 | Get
69 | Return Global.DotNetPatcher.My.MySettings.Default
70 | End Get
71 | End Property
72 | End Module
73 | End Namespace
74 |
--------------------------------------------------------------------------------
/DotNetPatcher/My Project/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/DotNetPatcher/My Project/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/DotNetPatcher/Program.vb:
--------------------------------------------------------------------------------
1 | Imports System.Threading
2 |
3 | Friend Class Program
4 |
5 | Public Shared Sub Main(ByVal Args As String())
6 | Application.EnableVisualStyles()
7 | Application.SetCompatibleTextRenderingDefault(False)
8 | Dim instanceCountOne As Boolean = False
9 | Using mtex As Mutex = New Mutex(True, Application.ProductName, instanceCountOne)
10 | If instanceCountOne Then
11 | Application.Run(New Frm_Main)
12 | mtex.ReleaseMutex()
13 | End If
14 | End Using
15 | End Sub
16 | End Class
17 |
18 |
--------------------------------------------------------------------------------
/DotNetPatcher/Resources/Loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/DotNetPatcher/Resources/Loading.png
--------------------------------------------------------------------------------
/DotNetPatcher/Resources/TDD.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/DotNetPatcher/Resources/TDD.png
--------------------------------------------------------------------------------
/DotNetPatcher/Resources/Valid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/DotNetPatcher/Resources/Valid.png
--------------------------------------------------------------------------------
/DotNetPatcher/Resources/Warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/DotNetPatcher/Resources/Warning.png
--------------------------------------------------------------------------------
/DotNetPatcher/Resources/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/DotNetPatcher/Resources/error.png
--------------------------------------------------------------------------------
/DotNetPatcher/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Helper/Assembly/Data.vb:
--------------------------------------------------------------------------------
1 | Imports System.Reflection
2 |
3 | Namespace AssemblyHelper
4 | Public Class Data
5 |
6 | #Region " Properties "
7 | Public Property AssName As String
8 | Public Property AssVersion As String
9 | Public Property IsWpf As Boolean
10 | Public Property Location As String
11 | Public Property EntryPoint As MethodInfo
12 | Public Property AssemblyReferences As AssemblyName()
13 | Public Property Result As Message
14 | #End Region
15 |
16 | #Region " Enumerations"
17 | Public Enum Message
18 | Failed = 0
19 | Success = 1
20 | End Enum
21 | #End Region
22 |
23 | End Class
24 | End Namespace
25 |
26 |
--------------------------------------------------------------------------------
/Helper/Assembly/DataFull.vb:
--------------------------------------------------------------------------------
1 | Imports System.Reflection
2 | Imports System.IO
3 |
4 | Namespace AssemblyHelper
5 | Public Class DataFull
6 | Inherits Data
7 |
8 | #Region " Properties "
9 | Public Property ManifestResourceNames As IEnumerable(Of String)
10 | Public Property ManifestResourceStreams As List(Of Stream)
11 | Public Property TypesClass As IEnumerable(Of Type)
12 | Public Property Modules As IEnumerable(Of Reflection.Module)
13 | #End Region
14 |
15 | End Class
16 | End Namespace
17 |
18 |
--------------------------------------------------------------------------------
/Helper/Assembly/IAssemblyInfos.vb:
--------------------------------------------------------------------------------
1 | Imports System.Reflection
2 | Imports System.IO
3 |
4 | Namespace AssemblyHelper
5 | Public Interface IAssemblyInfos
6 | Sub GetAssemblyInfo(assembly() As Byte, ByRef AssName$, ByRef AssVersion$, ByRef IsWpfApp As Boolean, ByRef EntryPoint As MethodInfo, ByRef AssemblyReferences As AssemblyName(), ByRef ManifestResourceNames As IEnumerable(Of String), ByRef ManifestResourceStreams As List(Of Stream), ByRef TypesClass As IEnumerable(Of Type), ByRef Modules As IEnumerable(Of [Module]), ByRef Result As Data.Message, Optional ByVal LoadMaxInfos As Boolean = False)
7 | End Interface
8 |
9 | End Namespace
10 |
11 |
--------------------------------------------------------------------------------
/Helper/Cecil/DelegateEmitter.vb:
--------------------------------------------------------------------------------
1 | Imports Mono.Cecil
2 | Imports Helper.RandomizeHelper
3 |
4 | Namespace CecilHelper
5 | Public Class DelegateEmitter
6 |
7 | #Region " Constants "
8 | Private Const DelegateTypeAttributes As TypeAttributes = TypeAttributes.Class Or TypeAttributes.Public Or TypeAttributes.Sealed
9 | Private Const ConstructorAttributes As MethodAttributes = MethodAttributes.Public Or MethodAttributes.SpecialName Or MethodAttributes.RTSpecialName
10 | Private Const DelegateMethodAttributes As MethodAttributes = MethodAttributes.Public Or MethodAttributes.Virtual Or MethodAttributes.VtableLayoutMask
11 | #End Region
12 |
13 | #Region " Fields "
14 | Private Shared voidType As TypeReference
15 | Private Shared objectType As TypeReference
16 | Private Shared nativeIntType As TypeReference
17 | Private Shared multidelegate As TypeReference
18 | #End Region
19 |
20 | #Region " Methods "
21 |
22 | Public Shared Function Create(asm As AssemblyDefinition, delegateName As String, returnType As TypeReference, arguments As List(Of TypeReference)) As TypeDefinition
23 | InitializeTypes(asm)
24 |
25 | Dim TypeDef = New TypeDefinition(String.Empty, delegateName, DelegateTypeAttributes, multidelegate)
26 | With TypeDef.Methods
27 | .Add(BuildConstructor)
28 | .Add(BuildInvoke(returnType, arguments))
29 | End With
30 |
31 | Return TypeDef
32 | End Function
33 |
34 | Private Shared Sub InitializeTypes(assDef As AssemblyDefinition)
35 | voidType = assDef.MainModule.Import(GetType(Void))
36 | objectType = assDef.MainModule.Import(GetType(Object))
37 | nativeIntType = assDef.MainModule.Import(GetType(IntPtr))
38 | multidelegate = assDef.MainModule.Import(GetType(System.MulticastDelegate))
39 | End Sub
40 |
41 | Private Shared Function BuildConstructor() As MethodDefinition
42 | Dim constructor = New MethodDefinition(".ctor", ConstructorAttributes, voidType)
43 | With constructor
44 | .Parameters.Add(New ParameterDefinition("objectInstance", ParameterAttributes.None, objectType))
45 | .Parameters.Add(New ParameterDefinition("functionPtr", ParameterAttributes.None, nativeIntType))
46 | .ImplAttributes = MethodImplAttributes.Runtime
47 | End With
48 | Return constructor
49 | End Function
50 |
51 | Private Shared Function BuildInvoke(returnType As TypeReference, arguments As List(Of TypeReference)) As MethodDefinition
52 | Dim invoke = New MethodDefinition("Invoke", DelegateMethodAttributes, returnType)
53 | With invoke
54 | For Each argument In arguments
55 | .Parameters.Add(New ParameterDefinition(Randomizer.GenerateNew, ParameterAttributes.None, argument))
56 | Next
57 | .ImplAttributes = MethodImplAttributes.Runtime
58 | End With
59 | Return invoke
60 | End Function
61 |
62 | #End Region
63 |
64 | End Class
65 | End Namespace
--------------------------------------------------------------------------------
/Helper/Cecil/NameChecker.vb:
--------------------------------------------------------------------------------
1 | Imports Mono.Cecil
2 |
3 | Namespace CecilHelper
4 | Public NotInheritable Class NameChecker
5 |
6 | #Region " Methods "
7 | '''
8 | ''' INFO : Verifying if typeDefinition is renamable
9 | '''
10 | '''
11 | Public Shared Function IsRenamable(type As TypeDefinition) As Boolean
12 | If Not type.BaseType Is Nothing Then
13 | If type.BaseType.IsArray Then
14 | Return False
15 | End If
16 | End If
17 | Return Not type.FullName = "" AndAlso Not type.IsImport
18 | End Function
19 |
20 | '''
21 | ''' INFO : Verifying if methodDefinition is renamable
22 | '''
23 | '''
24 | Public Shared Function IsRenamable(method As MethodDefinition, Optional ByVal Force As Boolean = False) As Boolean
25 | If Force Then
26 | If method.HasBody Then
27 | If Finder.AccessorMethods(method.DeclaringType).Contains(method) Then
28 | Return Not Finder.FindGenericParameter(method) AndAlso Not Finder.FindCustomAttributeByName(method, "DebuggerHiddenAttribute")
29 | End If
30 | End If
31 | End If
32 | Return method IsNot Nothing AndAlso Not (method.IsRuntimeSpecialName OrElse method.IsRuntime OrElse method.IsSpecialName OrElse method.IsConstructor OrElse method.HasOverrides OrElse method.IsVirtual OrElse method.IsAbstract OrElse method.Name.EndsWith("GetEnumerator"))
33 | End Function
34 |
35 | '''
36 | ''' INFO : Verifying if eventDefinition is renamable
37 | '''
38 | '''
39 | Public Shared Function IsRenamable(ByVal Events As EventDefinition) As Boolean
40 | Return If(Not Events.IsSpecialName OrElse Not Events.IsRuntimeSpecialName OrElse Not Events.IsDefinition, True, False)
41 | End Function
42 |
43 | '''
44 | ''' INFO : Verifying if propertyDefinition is renamable
45 | '''
46 | '''
47 | Public Shared Function IsRenamable(prop As PropertyDefinition) As Boolean
48 | Return Not prop.IsRuntimeSpecialName OrElse Not prop.IsSpecialName
49 | End Function
50 |
51 | '''
52 | ''' INFO : Verifying if fieldDefinition is renamable
53 | '''
54 | '''
55 | Public Shared Function IsRenamable(field As FieldDefinition) As Boolean
56 | If (Not field.IsRuntimeSpecialName AndAlso Not field.DeclaringType.HasGenericParameters) And Not field.IsPInvokeImpl AndAlso Not field.IsSpecialName Then
57 | Return True
58 | End If
59 | Return False
60 | End Function
61 | #End Region
62 |
63 | End Class
64 | End Namespace
65 |
66 |
--------------------------------------------------------------------------------
/Helper/Cecil/ProcessedIL.vb:
--------------------------------------------------------------------------------
1 | Imports Mono.Cecil.Cil
2 |
3 | Namespace CecilHelper
4 | Public NotInheritable Class ProcessedIL
5 |
6 | #Region " Fields "
7 | Public Instruction As Instruction
8 | Public OriginalOffset As Integer
9 | #End Region
10 |
11 | #Region " Constructors "
12 | Public Sub New(ByVal instruct As Instruction)
13 | Me.New(instruct, instruct.Offset)
14 | End Sub
15 |
16 | Public Sub New(instruct As Instruction, isNewInstruction As Boolean)
17 | Me.New(instruct, If(isNewInstruction, -1, instruct.Offset))
18 | End Sub
19 |
20 | Public Sub New(instruct As Instruction, originalOffset%)
21 | Instruction = instruct
22 | originalOffset = originalOffset
23 | End Sub
24 | #End Region
25 |
26 | End Class
27 |
28 | End Namespace
29 |
--------------------------------------------------------------------------------
/Helper/Cecil/Utils.vb:
--------------------------------------------------------------------------------
1 | Imports Mono.Cecil
2 | Imports Mono.Cecil.Rocks
3 | Imports Mono.Cecil.Cil
4 | Imports Helper.RandomizeHelper
5 | Imports Helper.AssemblyHelper
6 |
7 | Namespace CecilHelper
8 | Public NotInheritable Class Utils
9 |
10 | #Region " Methods "
11 |
12 | Public Shared Function HasUnsafeInstructions(member As MethodDefinition) As Boolean
13 | If member.HasBody Then
14 | If member.Body.HasVariables Then
15 | Return member.Body.Variables.Any(Function(x) x.VariableType.IsPointer)
16 | End If
17 | End If
18 | Return False
19 | End Function
20 |
21 | Public Shared Function RemoveCustomAttributeByName(member As AssemblyDefinition, CaName$) As Boolean
22 | If member.HasCustomAttributes Then
23 | Dim caList = Enumerable.Where(Of CustomAttribute)(member.CustomAttributes, Function(ca) ca.AttributeType.Name = CaName)
24 | Dim caCount = caList.Count
25 | If caCount <> 0 Then
26 | Dim Finded = caList.First
27 | If Not Finded Is Nothing Then
28 | Return member.CustomAttributes.Remove(Finded)
29 | End If
30 | End If
31 | End If
32 | Return False
33 | End Function
34 |
35 | Public Shared Function isStronglyTypedResourceBuilder(td As TypeDefinition) As Boolean
36 | If td.HasCustomAttributes Then
37 | For Each ca In (From c In td.CustomAttributes
38 | Where c IsNot Nothing AndAlso c.AttributeType.Name = "GeneratedCodeAttribute" AndAlso c.HasConstructorArguments AndAlso c.ConstructorArguments(0).Value = "System.Resources.Tools.StronglyTypedResourceBuilder"
39 | Select c)
40 | Return True
41 | Next
42 | End If
43 | Return False
44 | End Function
45 |
46 | Public Shared Function IsDebuggerNonUserCode(assDef As AssemblyDefinition) As Boolean
47 | Return assDef.MainModule.EntryPoint.DeclaringType.Namespace.EndsWith(".My")
48 | End Function
49 |
50 | Public Shared Function MakeGeneric(method As MethodReference, genericarg As TypeReference) As MethodReference
51 | Dim genericTypeRef = New GenericInstanceMethod(method)
52 | genericTypeRef.GenericArguments.Add(genericarg)
53 | Return genericTypeRef
54 | End Function
55 |
56 | #End Region
57 |
58 | End Class
59 | End Namespace
--------------------------------------------------------------------------------
/Helper/Crypto/Crypt.vb:
--------------------------------------------------------------------------------
1 | Imports System.Security.Cryptography
2 | Imports System.Text
3 | Imports Helper.RandomizeHelper
4 |
5 | Namespace CryptoHelper
6 | Public Class Crypt
7 |
8 | #Region "Fields "
9 | Private _SaltSize%
10 | Private _key As Byte()
11 | #End Region
12 |
13 | #Region "Properties "
14 | Public ReadOnly Property SaltSize() As Integer
15 | Get
16 | Return _SaltSize
17 | End Get
18 | End Property
19 |
20 | Public ReadOnly Property key() As Byte()
21 | Get
22 | Return _key
23 | End Get
24 | End Property
25 | #End Region
26 |
27 | #Region " Constructor "
28 | Public Sub New()
29 | _SaltSize = New Random().Next(1, 8)
30 | _key = Encoding.ASCII.GetBytes(Randomizer.GenerateNew)
31 | End Sub
32 | #End Region
33 |
34 | #Region " Methods "
35 | Public Function Encrypt(ByVal input As Byte()) As Byte()
36 | Dim RND As New RNGCryptoServiceProvider()
37 | Dim Output As Byte() = New Byte(input.Length - 1) {}
38 | Dim Salt As Byte() = New Byte(SaltSize - 1) {}
39 | RND.GetBytes(Salt)
40 | For i As Integer = 0 To input.Length - 1
41 | Output(i) = CByte(input(i) Xor key(i Mod key.Length) Xor Salt(i Mod Salt.Length))
42 | Next
43 | Array.Resize(Of Byte)(Output, Output.Length + SaltSize)
44 | Buffer.BlockCopy(Salt, 0, Output, Output.Length - SaltSize, SaltSize)
45 | Return Output
46 | End Function
47 | #End Region
48 |
49 | 'Public Function AESEncrypt(ByVal input As Byte()) As Byte()
50 | ' Dim AES As New RijndaelManaged()
51 | ' Dim hash As Byte() = New Byte(&H20 - 1) {}
52 | ' Dim temp As Byte() = New MD5CryptoServiceProvider().ComputeHash(key)
53 | ' Array.Copy(temp, 0, hash, 0, 16)
54 | ' Array.Copy(temp, 0, hash, 15, 16)
55 | ' AES.Key = hash
56 | ' AES.Mode = CipherMode.ECB
57 | ' Dim DESEncrypter As ICryptoTransform = AES.CreateEncryptor()
58 | ' Return DESEncrypter.TransformFinalBlock(input, 0, input.Length)
59 | 'End Function
60 |
61 | 'Public Function AESDecrypt(ByVal input As Byte()) As Byte()
62 | ' Dim managed As New RijndaelManaged
63 | ' Dim destinationArray As Byte() = New Byte(&H20 - 1) {}
64 | ' Dim sourceArray As Byte() = New MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(Pass))
65 | ' Array.Copy(sourceArray, 0, destinationArray, 0, &H10)
66 | ' Array.Copy(sourceArray, 0, destinationArray, 15, &H10)
67 | ' managed.Key = destinationArray
68 | ' managed.Mode = CipherMode.ECB
69 | ' Return managed.CreateDecryptor.TransformFinalBlock(input, 0, input.Length)
70 | 'End Function
71 |
72 | 'Public Function Decrypt(ByVal input As Byte()) As Byte()
73 | ' Dim Output As Byte() = New Byte(input.Length - SaltSize - 1) {}
74 | ' Dim Salt As Byte() = New Byte(SaltSize - 1) {}
75 | ' Buffer.BlockCopy(input, input.Length - SaltSize, Salt, 0, SaltSize)
76 | ' Array.Resize(Of Byte)(input, input.Length - SaltSize)
77 | ' For i As Integer = 0 To input.Length - 1
78 | ' Output(i) = CByte(input(i) Xor key(i Mod key.Length) Xor Salt(i Mod Salt.Length))
79 | ' Next
80 | ' Return Output
81 | 'End Function
82 |
83 | End Class
84 | End Namespace
85 |
--------------------------------------------------------------------------------
/Helper/My Project/Application.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.34014
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
--------------------------------------------------------------------------------
/Helper/My Project/Application.myapp:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | false
5 | 0
6 | true
7 | 0
8 | 1
9 | true
10 |
11 |
--------------------------------------------------------------------------------
/Helper/My Project/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | Imports System
2 | Imports System.Reflection
3 | Imports System.Runtime.InteropServices
4 |
5 | ' Les informations générales relatives à un assembly dépendent de
6 | ' l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7 | ' associées à un assembly.
8 |
9 | ' Passez en revue les valeurs des attributs de l'assembly
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 'Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
21 |
22 |
23 | ' Les informations de version pour un assembly se composent des quatre valeurs suivantes :
24 | '
25 | ' Version principale
26 | ' Version secondaire
27 | ' Numéro de build
28 | ' Révision
29 | '
30 | ' Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
31 | ' en utilisant '*', comme indiqué ci-dessous :
32 | '
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Helper/My Project/Resources.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.34014
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 | Imports System
15 |
16 | Namespace My.Resources
17 |
18 | 'Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
19 | 'à l'aide d'un outil, tel que ResGen ou Visual Studio.
20 | 'Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
21 | 'avec l'option /str ou régénérez votre projet VS.
22 | '''
23 | ''' Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
24 | '''
25 | _
29 | Friend Module Resources
30 |
31 | Private resourceMan As Global.System.Resources.ResourceManager
32 |
33 | Private resourceCulture As Global.System.Globalization.CultureInfo
34 |
35 | '''
36 | ''' Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
37 | '''
38 | _
39 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
40 | Get
41 | If Object.ReferenceEquals(resourceMan, Nothing) Then
42 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Helper.Resources", GetType(Resources).Assembly)
43 | resourceMan = temp
44 | End If
45 | Return resourceMan
46 | End Get
47 | End Property
48 |
49 | '''
50 | ''' Remplace la propriété CurrentUICulture du thread actuel pour toutes
51 | ''' les recherches de ressources à l'aide de cette classe de ressource fortement typée.
52 | '''
53 | _
54 | Friend Property Culture() As Global.System.Globalization.CultureInfo
55 | Get
56 | Return resourceCulture
57 | End Get
58 | Set
59 | resourceCulture = value
60 | End Set
61 | End Property
62 | End Module
63 | End Namespace
64 |
--------------------------------------------------------------------------------
/Helper/My Project/Settings.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.34014
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | _
20 | Partial Friend NotInheritable Class MySettings
21 | Inherits Global.System.Configuration.ApplicationSettingsBase
22 |
23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()), MySettings)
24 |
25 | #Region "Fonctionnalité Enregistrement automatique My.Settings"
26 | #If _MyType = "WindowsForms" Then
27 | Private Shared addedHandler As Boolean
28 |
29 | Private Shared addedHandlerLockObject As New Object
30 |
31 | _
32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
33 | If My.Application.SaveMySettingsOnExit Then
34 | My.Settings.Save()
35 | End If
36 | End Sub
37 | #End If
38 | #End Region
39 |
40 | Public Shared ReadOnly Property [Default]() As MySettings
41 | Get
42 |
43 | #If _MyType = "WindowsForms" Then
44 | If Not addedHandler Then
45 | SyncLock addedHandlerLockObject
46 | If Not addedHandler Then
47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48 | addedHandler = True
49 | End If
50 | End SyncLock
51 | End If
52 | #End If
53 | Return defaultInstance
54 | End Get
55 | End Property
56 | End Class
57 | End Namespace
58 |
59 | Namespace My
60 |
61 | _
64 | Friend Module MySettingsProperty
65 |
66 | _
67 | Friend ReadOnly Property Settings() As Global.Helper.My.MySettings
68 | Get
69 | Return Global.Helper.My.MySettings.Default
70 | End Get
71 | End Property
72 | End Module
73 | End Namespace
74 |
--------------------------------------------------------------------------------
/Helper/My Project/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Helper/Randomize/RandomizerType.vb:
--------------------------------------------------------------------------------
1 | Namespace RandomizeHelper
2 | Public NotInheritable Class RandomizerType
3 |
4 | #Region " Fields "
5 | Public Shared RenameSetting As RenameEnum
6 | #End Region
7 |
8 | #Region " Enumerations "
9 | Public Enum RenameEnum
10 | Alphabetic = 0
11 | Dot = 1
12 | Invisible = 2
13 | Chinese = 3
14 | Japanese = 4
15 | Greek = 5
16 | Symbols = 6
17 | Flowing = 7
18 | End Enum
19 | #End Region
20 |
21 | End Class
22 | End Namespace
--------------------------------------------------------------------------------
/Helper/Resource/NativeMethods.vb:
--------------------------------------------------------------------------------
1 | Imports System.Runtime.InteropServices
2 |
3 | Namespace ResourcesHelper
4 |
5 | Public NotInheritable Class NativeMethods
6 |
7 | #Region " Methods "
8 | _
9 | Public Shared Function LoadLibrary(lpFileName As String) As IntPtr
10 | End Function
11 |
12 | _
13 | Public Shared Function LoadLibraryEx(ByVal lpFileName As String, ByVal hReservedNull As IntPtr, ByVal dwFlags As Integer) As IntPtr
14 | End Function
15 |
16 | _
17 | Public Shared Function FindResource(ByVal hModule As IntPtr, ByVal lpszName As IntPtr, ByVal lpszType As IntPtr) As IntPtr
18 | End Function
19 |
20 | _
21 | Public Shared Function LoadResource(ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As IntPtr
22 | End Function
23 |
24 | _
25 | Public Shared Function LockResource(ByVal hResData As IntPtr) As IntPtr
26 | End Function
27 |
28 | _
29 | Public Shared Function SizeofResource(ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As UInteger
30 | End Function
31 |
32 | _
33 | Public Shared Function FreeLibrary(ByVal hModule As IntPtr) As Boolean
34 | End Function
35 |
36 | _
37 | Public Shared Function BeginUpdateResource(ByVal pFileName As String, ByVal bDeleteExistingResources As Boolean) As IntPtr
38 | End Function
39 |
40 | _
41 | Public Shared Function UpdateResource(ByVal hUpdate As IntPtr, ByVal lpType As IntPtr, ByVal lpName As IntPtr, ByVal wLanguage As UInt16, ByVal lpData As Byte(), ByVal cbData As UInt32) As Boolean
42 | End Function
43 |
44 | _
45 | Public Shared Function UpdateResource(ByVal hUpdate As IntPtr, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As UInt16, ByVal lpData As IntPtr, ByVal cbData As UInt32) As Boolean
46 | End Function
47 |
48 | _
49 | Public Shared Function EndUpdateResource(ByVal hUpdate As IntPtr, ByVal fDiscard As Boolean) As Boolean
50 | End Function
51 |
52 | _
53 | Public Shared Sub CopyMemory(Destination As IntPtr, Source As IntPtr, Length As Integer)
54 | End Sub
55 |
56 | _
57 | Public Shared Function FreeResource(hglbResource As IntPtr) As Integer
58 | End Function
59 | #End Region
60 |
61 | End Class
62 |
63 | End Namespace
64 |
65 |
66 |
--------------------------------------------------------------------------------
/Implementer/Core/Dependencing/AnalysisResult.vb:
--------------------------------------------------------------------------------
1 | Namespace Core.Dependencing
2 |
3 | Public NotInheritable Class AnalysisResult
4 |
5 | #Region " Fields "
6 | Private m_result As String
7 | #End Region
8 |
9 | #Region " Properties "
10 | Public ReadOnly Property result As String
11 | Get
12 | Return m_result
13 | End Get
14 | End Property
15 | #End Region
16 |
17 | #Region " Constructor "
18 | Friend Sub New(result As String)
19 | m_result = result
20 | End Sub
21 | #End Region
22 |
23 | End Class
24 |
25 | End Namespace
26 |
--------------------------------------------------------------------------------
/Implementer/Core/Dependencing/DependenciesInfos.vb:
--------------------------------------------------------------------------------
1 | Namespace Core.Dependencing
2 | Public Class DependenciesInfos
3 | Implements IDisposable
4 |
5 | #Region " Fields "
6 | Private m_Enabled As Boolean
7 | Private m_Dependencies As IEnumerable(Of String)
8 | Private m_DependenciesMode As DependenciesAddMode
9 | Private m_DependenciesCompressEncryptMode As CompressEncryptMode
10 | #End Region
11 |
12 | #Region " Enumerations "
13 | Enum DependenciesAddMode
14 | Merged = 0
15 | Embedded = 1
16 | End Enum
17 |
18 | Enum CompressEncryptMode
19 | None = 0
20 | Encrypt = 1
21 | Compress = 2
22 | Both = 3
23 | End Enum
24 | #End Region
25 |
26 | #Region " Properties "
27 | Public ReadOnly Property Enabled As Boolean
28 | Get
29 | Return m_Enabled
30 | End Get
31 | End Property
32 |
33 | Public ReadOnly Property Dependencies As IEnumerable(Of String)
34 | Get
35 | Return m_Dependencies
36 | End Get
37 | End Property
38 |
39 | Public ReadOnly Property DependenciesMode As DependenciesAddMode
40 | Get
41 | Return m_DependenciesMode
42 | End Get
43 | End Property
44 |
45 | Public ReadOnly Property DependenciesCompressEncryptMode As CompressEncryptMode
46 | Get
47 | Return m_DependenciesCompressEncryptMode
48 | End Get
49 | End Property
50 | #End Region
51 |
52 | #Region " Constructor "
53 | Public Sub New(Enable As Boolean, Dependenc As IEnumerable(Of String), DependenciesMod As Boolean, DependenciesCompressEncryptMod%)
54 | m_Enabled = Enable
55 | m_Dependencies = Dependenc
56 | m_DependenciesMode = DependenciesModeValue(DependenciesMod)
57 | m_DependenciesCompressEncryptMode = DependenciesCompressEncryptModeValue(DependenciesCompressEncryptMod)
58 | End Sub
59 | #End Region
60 |
61 | #Region " Methods "
62 | Private Function DependenciesModeValue(boolValue As Boolean) As DependenciesAddMode
63 | Return If(boolValue, DependenciesInfos.DependenciesAddMode.Embedded, DependenciesInfos.DependenciesAddMode.Merged)
64 | End Function
65 |
66 | Private Function DependenciesCompressEncryptModeValue(intValue%) As CompressEncryptMode
67 | Select Case intValue
68 | Case 0
69 | Return CompressEncryptMode.None
70 | Case 1
71 | Return CompressEncryptMode.Encrypt
72 | Case 2
73 | Return CompressEncryptMode.Compress
74 | Case 3
75 | Return CompressEncryptMode.Both
76 | End Select
77 | Return CompressEncryptMode.None
78 | End Function
79 | #End Region
80 |
81 | #Region "IDisposable Support"
82 | Private disposedValue As Boolean
83 |
84 | Protected Overridable Sub Dispose(disposing As Boolean)
85 | If Not Me.disposedValue Then
86 | If disposing Then
87 | End If
88 | m_Enabled = False
89 | End If
90 | Me.disposedValue = True
91 | End Sub
92 |
93 | Public Sub Dispose() Implements IDisposable.Dispose
94 | Dispose(True)
95 | GC.SuppressFinalize(Me)
96 | End Sub
97 | #End Region
98 |
99 | End Class
100 | End Namespace
101 |
--------------------------------------------------------------------------------
/Implementer/Core/Dependencing/Embedding.vb:
--------------------------------------------------------------------------------
1 | Imports System.IO
2 | Imports System.IO.Compression
3 | Imports System.CodeDom.Compiler
4 | Imports System.Text
5 | Imports System.Reflection
6 | Imports Mono.Cecil
7 | Imports Mono.Cecil.Cil
8 | Imports Helper.RandomizeHelper
9 | Imports Helper.CryptoHelper
10 | Imports Helper.CecilHelper
11 | Imports Helper.AssemblyHelper
12 | Imports Helper.CodeDomHelper
13 | Imports Implementer.Core.Dependencing.DependenciesInfos
14 | Imports Helper.UtilsHelper
15 | Imports System.Runtime.InteropServices
16 | Imports Implementer.Core.Packer
17 | Imports Implementer.Core.Obfuscation
18 | Imports Implementer.Core.Obfuscation.Builder
19 |
20 | Namespace Core.Dependencing
21 | Public NotInheritable Class Embedding
22 | Inherits Source
23 |
24 | #Region " Fields "
25 | Private m_encrypt As Boolean
26 | Private m_compress As Boolean
27 | Private m_files As IEnumerable(Of String)
28 | #End Region
29 |
30 | #Region " Constructor "
31 | Friend Sub New(assDef As AssemblyDefinition, files As IEnumerable(Of String), framewk As String, CompressEncrypt As CompressEncryptMode, Optional ByVal EnabledPack As Boolean = False)
32 | AssemblyDef = assDef
33 | m_files = files
34 | Frmwk = framewk
35 | Pack = EnabledPack
36 |
37 | Select Case CompressEncrypt
38 | Case CompressEncryptMode.Both
39 | m_encrypt = True
40 | m_compress = True
41 | Case CompressEncryptMode.Compress
42 | m_compress = True
43 | Case CompressEncryptMode.Encrypt
44 | m_encrypt = True
45 | End Select
46 | End Sub
47 |
48 | #End Region
49 |
50 | #Region " Methods "
51 |
52 | Friend Sub InjectFiles()
53 | For Each f In m_files
54 | Dim assname = AssemblyDefinition.ReadAssembly(f)
55 | Dim resNameGUID = CStr(assname.FullName.GetHashCode)
56 | If Pack Then resNameGUID = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(resNameGUID))
57 |
58 | Dim encryptedBytes = File.ReadAllBytes(f)
59 | Dim resourceName = String.Format("{0}.{1}", resNameGUID, "resources")
60 |
61 | If m_encrypt Then Array.Reverse(encryptedBytes)
62 | If m_compress Then encryptedBytes = Functions.GZipedByte(encryptedBytes)
63 |
64 | Injecter.InjectResource(AssemblyDef.MainModule, resourceName, ResourceType.Embedded, encryptedBytes)
65 | Next
66 | End Sub
67 |
68 | Friend Sub CreateResolverClass()
69 | Try
70 | Dim reposit As New Stub(Randomizer.GenerateNewAlphabetic, Randomizer.GenerateNewAlphabetic)
71 | With reposit
72 | .ResolveTypeFromFile(ResourcesEmbeddingStub(.className, .funcName1, m_encrypt, m_compress))
73 | .InjectToCctor(AssemblyDef)
74 | .DeleteDll()
75 | End With
76 | Catch ex As Exception
77 | MsgBox(ex.ToString)
78 | End Try
79 | End Sub
80 | #End Region
81 |
82 | End Class
83 | End Namespace
84 |
--------------------------------------------------------------------------------
/Implementer/Core/IconChanger/Changer.vb:
--------------------------------------------------------------------------------
1 |
2 | Imports System.IO
3 | Imports System.Windows.Forms
4 | Imports System.Drawing
5 | Imports Implementer.Engine.Checking
6 | Imports Helper.UtilsHelper
7 |
8 | Namespace Core.IconChanger
9 | Public NotInheritable Class Changer
10 |
11 | #Region " Events "
12 | Public Event CheckerResult As Check
13 | #End Region
14 |
15 | #Region " Methods "
16 | Private Sub RaiseCheckerResultEvent(message As String, title As String, addedFiles As String)
17 | Dim itemEvent As New CheckEventArgs(message, title, addedFiles)
18 | RaiseEvent CheckerResult(Nothing, itemEvent)
19 | itemEvent = Nothing
20 | End Sub
21 |
22 | Public Sub SelectingIcon(ByVal FileName As String)
23 | If New FileInfo(FileName).Length = 0 Then
24 | RaiseCheckerResultEvent("The file : " & New FileInfo(FileName).Name & " is empty !", "Bad size", "")
25 | Else
26 | Try
27 | If Functions.isValid(FileName, Imaging.ImageFormat.Icon) Then
28 | RaiseCheckerResultEvent("File Added", "Operation Completed", FileName)
29 | Else
30 | RaiseCheckerResultEvent("Unsupported selected file", "Error", "")
31 | End If
32 | Catch ex As Exception
33 | RaiseCheckerResultEvent(ex.Message, "Error", "")
34 | Exit Sub
35 | End Try
36 | End If
37 | End Sub
38 | #End Region
39 |
40 | End Class
41 | End Namespace
42 |
--------------------------------------------------------------------------------
/Implementer/Core/IconChanger/IconInfos.vb:
--------------------------------------------------------------------------------
1 | Imports Helper.RandomizeHelper
2 | Imports Helper.UtilsHelper
3 | Imports System.IO
4 | Imports Core20Reader
5 | Imports Helper.CecilHelper
6 | Imports System.Drawing
7 |
8 | Namespace Core.IconChanger
9 | Public Class IconInfos
10 | Implements IDisposable
11 |
12 | #Region " Fields "
13 | Private m_tmpExePath As String
14 | #End Region
15 |
16 | #Region " Properties "
17 | Private m_Enabled As Boolean
18 | Public ReadOnly Property Enabled As Boolean
19 | Get
20 | Return m_Enabled
21 | End Get
22 | End Property
23 |
24 | Private m_NewIcon As Icon
25 | Public ReadOnly Property NewIcon As Icon
26 | Get
27 | Return m_NewIcon
28 | End Get
29 | End Property
30 | #End Region
31 |
32 | #Region " Constructor "
33 | Public Sub New(Enable As Boolean, NewIconPath$)
34 | m_Enabled = Enable
35 | m_NewIcon = If(File.Exists(NewIconPath), New Icon(NewIconPath), Nothing)
36 | m_Enabled = checkNewIconExists()
37 | End Sub
38 |
39 | Public Sub New(FilePath$)
40 | m_NewIcon = FromExeFile(FilePath)
41 | End Sub
42 | #End Region
43 |
44 | #Region " Methods "
45 | Private Function FromExeFile(FilePath$) As Icon
46 | If File.Exists(FilePath) Then
47 | m_tmpExePath = Functions.GetTempFolder & "\" & Randomizer.GenerateNewAlphabetic & ".exe"
48 | File.Copy(FilePath, m_tmpExePath, True)
49 | Dim ic As New Reader()
50 | With ic
51 | .ReadFile(m_tmpExePath)
52 | m_Enabled = True
53 | Return .GetMainIcon
54 | End With
55 | End If
56 | m_Enabled = False
57 | Return Nothing
58 | End Function
59 |
60 | Private Function checkNewIconExists() As Boolean
61 | If m_Enabled Then
62 | If m_NewIcon IsNot Nothing Then
63 | Return True
64 | End If
65 | End If
66 | Return False
67 | End Function
68 | #End Region
69 |
70 | #Region "IDisposable Support"
71 | Private disposedValue As Boolean
72 |
73 | Protected Overridable Sub Dispose(disposing As Boolean)
74 | If Not Me.disposedValue Then
75 | If disposing Then
76 | End If
77 | m_Enabled = False
78 | m_NewIcon = Nothing
79 | Try
80 | File.Delete(m_tmpExePath)
81 | Catch ex As Exception
82 | End Try
83 | End If
84 | Me.disposedValue = True
85 | End Sub
86 |
87 | Public Sub Dispose() Implements IDisposable.Dispose
88 | Dispose(True)
89 | GC.SuppressFinalize(Me)
90 | End Sub
91 | #End Region
92 |
93 | End Class
94 | End Namespace
95 |
--------------------------------------------------------------------------------
/Implementer/Core/ManifestRequest/ManifestInfos.vb:
--------------------------------------------------------------------------------
1 | Imports System.IO
2 | Imports Vestris.ResourceLib
3 | Imports System.Xml
4 |
5 | Namespace Core.ManifestRequest
6 | Public Class ManifestInfos
7 | Implements IDisposable
8 |
9 | #Region " Properties "
10 | Private m_LastRequested As String
11 | Public ReadOnly Property LastRequested As String
12 | Get
13 | Return m_LastRequested
14 | End Get
15 | End Property
16 |
17 | Private m_NewRequested As String
18 | Public ReadOnly Property NewRequested As String
19 | Get
20 | Return m_NewRequested
21 | End Get
22 | End Property
23 |
24 | Public ReadOnly Property Modified() As Boolean
25 | Get
26 | Return If(m_LastRequested <> "" AndAlso m_NewRequested <> "", m_LastRequested <> m_NewRequested, False)
27 | End Get
28 | End Property
29 | #End Region
30 |
31 | #Region " Constructor "
32 | Public Sub New(LastRequest$, NewRequest$)
33 | m_LastRequested = LastRequest
34 | m_NewRequested = NewRequest
35 | End Sub
36 | #End Region
37 |
38 | #Region " Methods "
39 | Private Sub CleanUp()
40 | m_LastRequested = String.Empty
41 | m_NewRequested = String.Empty
42 | End Sub
43 | #End Region
44 |
45 | #Region "IDisposable Support"
46 | Private disposedValue As Boolean
47 |
48 | Protected Overridable Sub Dispose(disposing As Boolean)
49 | If Not Me.disposedValue Then
50 | If disposing Then
51 | End If
52 | CleanUp()
53 | End If
54 | Me.disposedValue = True
55 | End Sub
56 |
57 | Public Sub Dispose() Implements IDisposable.Dispose
58 | Dispose(True)
59 | GC.SuppressFinalize(Me)
60 | End Sub
61 | #End Region
62 |
63 | End Class
64 |
65 | End Namespace
66 |
67 |
--------------------------------------------------------------------------------
/Implementer/Core/ManifestRequest/ManifestReader.vb:
--------------------------------------------------------------------------------
1 | Imports System.IO
2 | Imports Vestris.ResourceLib
3 | Imports System.Xml
4 |
5 | Namespace Core.ManifestRequest
6 | Friend NotInheritable Class ManifestReader
7 |
8 | #Region " Methods "
9 | Friend Shared Function ExtractManifest(ByVal FilePath As String) As String
10 | Try
11 | Dim rc As New ManifestResource
12 | rc.LoadFrom(FilePath)
13 | Dim ManifestXmlDocument As XmlDocument = New XmlDocument()
14 | ManifestXmlDocument.LoadXml(rc.Manifest.OuterXml)
15 | Dim elemList As XmlNodeList = ManifestXmlDocument.GetElementsByTagName("requestedExecutionLevel")
16 | For i As Integer = 0 To elemList.Count - 1
17 | If elemList(i).Attributes("level") IsNot Nothing Then
18 | Return elemList(i).Attributes("level").Value
19 | End If
20 | Next
21 | Catch ex As Exception
22 | Return "asInvoker"
23 | End Try
24 | Return "asInvoker"
25 | End Function
26 | #End Region
27 |
28 | End Class
29 |
30 | End Namespace
31 |
32 |
--------------------------------------------------------------------------------
/Implementer/Core/ManifestRequest/ManifestWriter.vb:
--------------------------------------------------------------------------------
1 | Imports System.IO
2 | Imports Vestris.ResourceLib
3 | Imports Helper.UtilsHelper
4 |
5 | Namespace Core.ManifestRequest
6 | Friend NotInheritable Class ManifestWriter
7 |
8 | #Region " Fields "
9 | Private Shared _xmlstart As String = _
10 | "" & vbNewLine & _
11 | "" & vbNewLine & _
12 | " " & vbNewLine & _
13 | " " & vbNewLine & _
14 | " " & vbNewLine & _
15 | " "
16 | Private Shared _xmlmiddle As String = " "
17 | Private Shared _xmlEnd As String = _
18 | " " & vbNewLine & _
19 | " " & vbNewLine & _
20 | " " & vbNewLine & _
21 | "" & vbNewLine & _
22 | ""
23 | #End Region
24 |
25 | #Region " Methods "
26 | Friend Shared Sub ApplyManifest(ByVal FilePath As String, ByVal PrivilegeName As String)
27 | WriteXmlFile(PrivilegeName)
28 | If File.Exists(Functions.GetTempFolder & "\DNMP.txt") Then
29 | Dim Res As New GenericResource(New ResourceId(Kernel32.ResourceTypes.RT_MANIFEST), New ResourceId(CUInt(1)), CUShort(0))
30 | Res.Data = IO.File.ReadAllBytes(Functions.GetTempFolder & "\DNMP.txt")
31 | Res.Name = New ResourceId(CUInt(1))
32 | Res.SaveTo(FilePath)
33 | File.Delete(Functions.GetTempFolder & "\DNMP.txt")
34 | End If
35 | End Sub
36 |
37 | Private Shared Sub WriteXmlFile(ByVal PrivilegeName As String)
38 | Dim s As Stream = New FileStream(Functions.GetTempFolder & "\DNMP.txt", FileMode.Create, FileAccess.Write)
39 | Dim writer As New StreamWriter(s, System.Text.Encoding.UTF8)
40 |
41 | Select Case PrivilegeName
42 | Case "asInvoker"
43 | _xmlmiddle = " "
44 | Case "requireAdministrator"
45 | _xmlmiddle = " "
46 | Case "highestAvailable"
47 | _xmlmiddle = " "
48 | End Select
49 |
50 | writer.WriteLine(_xmlstart)
51 | writer.WriteLine(_xmlmiddle)
52 | writer.WriteLine(_xmlEnd)
53 | writer.Flush()
54 | s.Close()
55 | s.Dispose()
56 | End Sub
57 | #End Region
58 |
59 | End Class
60 |
61 | End Namespace
62 |
63 |
--------------------------------------------------------------------------------
/Implementer/Core/Obfuscation/Anti/AntiDebug.vb:
--------------------------------------------------------------------------------
1 | Imports Mono.Cecil
2 | Imports Helper.RandomizeHelper
3 | Imports System.IO
4 | Imports Helper.CecilHelper
5 | Imports Mono.Cecil.Cil
6 | Imports Mono.Cecil.Rocks
7 | Imports System.Threading
8 | Imports Helper.AssemblyHelper
9 | Imports Helper.CodeDomHelper
10 | Imports Implementer.Core.Obfuscation.Builder
11 |
12 | Namespace Core.Obfuscation.Anti
13 |
14 | Public NotInheritable Class AntiDebug
15 | Inherits Source
16 |
17 | #Region " Methods "
18 | Friend Shared Sub InjectAntiDebug(assDef As AssemblyDefinition, Framwk$, EnabledPack As Boolean)
19 | Try
20 | AssemblyDef = assDef
21 | Frmwk = Framwk
22 | Pack = EnabledPack
23 |
24 | Dim reposit = New Stub(Randomizer.GenerateNewAlphabetic, Randomizer.GenerateNewAlphabetic)
25 | With reposit
26 | .ResolveTypeFromFile(AntiDebugStub(.className, .funcName1), Finder.FindDefaultNamespace(assDef, Pack), Randomizer.GenerateNew, Randomizer.GenerateNew)
27 | .InjectToCctor(assDef)
28 | .DeleteDll()
29 | End With
30 |
31 | CleanUp()
32 |
33 | Catch ex As Exception
34 | MsgBox(ex.ToString)
35 | End Try
36 | End Sub
37 |
38 | #End Region
39 |
40 | End Class
41 | End Namespace
42 |
--------------------------------------------------------------------------------
/Implementer/Core/Obfuscation/Anti/AntiDumper.vb:
--------------------------------------------------------------------------------
1 | Imports Mono.Cecil
2 | Imports Helper.RandomizeHelper
3 | Imports System.IO
4 | Imports Helper.CecilHelper
5 | Imports Mono.Cecil.Cil
6 | Imports Mono.Cecil.Rocks
7 | Imports System.Runtime.InteropServices
8 | Imports Helper
9 | Imports Implementer.Core.Obfuscation.Builder
10 |
11 | Namespace Core.Obfuscation.Anti
12 |
13 | Public NotInheritable Class AntiDumper
14 |
15 | #Region " Methods "
16 | Friend Shared Sub CreateAntiDumperClass(AssDef As AssemblyDefinition, Optional Pack As Boolean = False)
17 |
18 | Dim reposit = New Stub("AntiDumping", "Initialize")
19 | With reposit
20 | .ResolveTypeFromFile(GetType(Injections.AntiDumping).Assembly.Location, Finder.FindDefaultNamespace(AssDef, Pack), Randomizer.GenerateNew, Randomizer.GenerateNew)
21 | .InjectToCctor(AssDef)
22 | .DeleteDll()
23 | End With
24 |
25 | End Sub
26 |
27 | #End Region
28 |
29 | End Class
30 |
31 | End Namespace
32 |
33 |
34 |
--------------------------------------------------------------------------------
/Implementer/Core/Obfuscation/Anti/AntiIlDasm.vb:
--------------------------------------------------------------------------------
1 | Imports Mono.Cecil
2 | Imports System.IO
3 | Imports Mono.Cecil.Cil
4 | Imports System.Threading
5 | Imports System.Runtime.CompilerServices
6 | Imports Helper.CecilHelper
7 |
8 | Namespace Core.Obfuscation.Anti
9 |
10 | Public NotInheritable Class AntiIlDasm
11 |
12 | #Region " Methods "
13 |
14 | Friend Shared Sub Inject(Ass As AssemblyDefinition)
15 | Dim si As Type = GetType(SuppressIldasmAttribute)
16 | If Finder.FindCustomAttributeByName(Ass, si.Name) = False Then
17 | Ass.CustomAttributes.Add(New CustomAttribute(Ass.MainModule.Import(si.GetConstructor(Type.EmptyTypes))))
18 | End If
19 | End Sub
20 |
21 | #End Region
22 |
23 | End Class
24 |
25 | End Namespace
26 |
27 |
--------------------------------------------------------------------------------
/Implementer/Core/Obfuscation/Anti/AntiTamper.vb:
--------------------------------------------------------------------------------
1 | Imports Helper.RandomizeHelper
2 | Imports System.IO
3 | Imports Helper.CecilHelper
4 | Imports Mono.Cecil.Cil
5 | Imports Mono.Cecil.Rocks
6 | Imports System.Threading
7 | Imports Mono.Cecil
8 | Imports System.Security.Cryptography
9 | Imports Helper.CodeDomHelper
10 | Imports Implementer.Core.Obfuscation.Builder
11 |
12 | Namespace Core.Obfuscation.Anti
13 |
14 | Public NotInheritable Class AntiTamper
15 | Inherits Source
16 |
17 | #Region " Methods "
18 | Friend Shared Sub CreateAntiTamperClass(AssDef As AssemblyDefinition, ByVal framwk$, EnabledPack As Boolean)
19 | Try
20 | AssemblyDef = AssDef
21 | Frmwk = framwk
22 | Pack = EnabledPack
23 |
24 | Dim reposit = New Stub(Randomizer.GenerateNewAlphabetic, Randomizer.GenerateNewAlphabetic)
25 | With reposit
26 | .ResolveTypeFromFile(AntiTamperStub(.className, .funcName1), Finder.FindDefaultNamespace(AssDef, Pack), Randomizer.GenerateNew, Randomizer.GenerateNew)
27 | .InjectToCctor(AssDef)
28 | .InjectToMyProject()
29 | .DeleteDll()
30 | End With
31 |
32 | CleanUp()
33 | Catch ex As Exception
34 | MsgBox(ex.ToString)
35 | End Try
36 | End Sub
37 |
38 | Public Shared Sub InjectMD5(ByVal SelectedFile As String)
39 | Dim md5bytes As Byte() = Nothing
40 | md5bytes = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(File.ReadAllBytes(SelectedFile))
41 | Using stream = New FileStream(SelectedFile, FileMode.Append)
42 | stream.Write(md5bytes, 0, md5bytes.Length)
43 | End Using
44 | End Sub
45 |
46 | #End Region
47 |
48 | End Class
49 |
50 | End Namespace
--------------------------------------------------------------------------------
/Implementer/Core/Obfuscation/Exclusion/ExcludeReflection.vb:
--------------------------------------------------------------------------------
1 | Imports System.IO
2 | Imports Mono.Cecil.Cil
3 | Imports Mono.Cecil.Rocks
4 | Imports Mono.Cecil
5 |
6 | Namespace Core.Obfuscation.Exclusion
7 |
8 | Public NotInheritable Class ExcludeReflection
9 |
10 | #Region " Properties "
11 | Public Shared HasItems As Boolean
12 | #End Region
13 |
14 | #Region " Methods "
15 | Public Shared Sub AnalyzeCodes(assDef As AssemblyDefinition, m_exclude As ExcludeList)
16 | For Each modul In assDef.Modules
17 | If modul.HasTypes Then
18 | For Each type In modul.GetAllTypes
19 | If type.HasMethods Then
20 | For Each method In type.Methods
21 | If method.HasBody AndAlso method.Body.Instructions.Count <> 0 Then
22 | For i = 0 To method.Body.Instructions.Count - 1
23 | Dim Inst = method.Body.Instructions(i)
24 | If TypeOf Inst.Operand Is MethodReference Then
25 | Dim refer As MethodReference = TryCast(Inst.Operand, MethodReference)
26 | Dim id = refer.DeclaringType.FullName & "::" & refer.Name
27 |
28 | If ExclusionReflection.Reflections.ContainsKey(id) Then
29 | Dim Rmtd = ExclusionReflection.Reflections(id)
30 | Dim memInst As Instruction = Nothing
31 | Dim mem = ReflectionAnalyzer.StackTrace(i, method.Body, Rmtd, method.Module, memInst)
32 | If Not mem Is Nothing Then
33 | m_exclude.AddTo(New ExclusionState(True, TryCast(mem, TypeDefinition), ExclusionState.mType.Types, False, False, False, False, True, False, False))
34 | m_exclude.AddTo(New ExclusionState(True, TryCast(refer, MethodDefinition), ExclusionState.mType.Methods, False, False, False, False, False, True, False))
35 | HasItems = True
36 | End If
37 | End If
38 | End If
39 | Next
40 | End If
41 | Next
42 | End If
43 | Next
44 | End If
45 | Next
46 | 'm_methodReferences = m_assdef.MainModule.Types.Cast(Of TypeDefinition).SelectMany(Function(type) Type.Methods.Cast(Of MethodDefinition)()).Where(Function(method) method.Body IsNot Nothing).SelectMany(Function(method) method.Body.Instructions.Cast(Of Instruction)()).Select(Function(instr) InStr.Operand).OfType(Of MethodReference)()
47 | End Sub
48 |
49 | Public Shared Sub CleanUp()
50 | HasItems = False
51 | End Sub
52 |
53 | #End Region
54 |
55 | End Class
56 |
57 | End Namespace
58 |
--------------------------------------------------------------------------------
/Implementer/Core/Obfuscation/Exclusion/ExclusionState.vb:
--------------------------------------------------------------------------------
1 |
2 | Namespace Core.Obfuscation.Exclusion
3 | Public NotInheritable Class ExclusionState
4 |
5 | #Region " Enumerations "
6 | Enum mType
7 | Namespaces = 0
8 | Types = 1
9 | Methods = 2
10 | Properties = 3
11 | Events = 4
12 | Fields = 5
13 | End Enum
14 | #End Region
15 |
16 | #Region " Properties "
17 | Public Property exclude As Boolean
18 | Public Property member As Object
19 | Public Property memberType As mType
20 | Public Property allEntities As Boolean
21 |
22 | Public Property stringEncrypt As Boolean
23 | Public Property integerEncoding As Boolean
24 | Public Property booleanEncrypt As Boolean
25 | Public Property Renaming As Boolean
26 | Public Property InvalidOpcodes As Boolean
27 | Public Property hideCalls As Boolean
28 | #End Region
29 |
30 | #Region " Constructor "
31 | Public Sub New(exclud As Boolean, memb As Object, memberT As mType, Optional ByVal allEntit As Boolean = False, _
32 | Optional ByVal stringEncr As Boolean = False, Optional ByVal integerEncod As Boolean = False, _
33 | Optional ByVal booleanEncr As Boolean = False, Optional ByVal Renamin As Boolean = False, _
34 | Optional ByVal InvalidOp As Boolean = False, Optional ByVal HideCall As Boolean = False)
35 | _exclude = exclud
36 | _member = memb
37 | _memberType = memberT
38 | _allEntities = allEntit
39 | _stringEncrypt = stringEncr
40 | _integerEncoding = integerEncod
41 | _booleanEncrypt = booleanEncr
42 | _Renaming = Renamin
43 | _InvalidOpcodes = InvalidOp
44 | _hideCalls = HideCall
45 | End Sub
46 |
47 | Public Sub New(stringEncr As Boolean, integerEncod As Boolean, booleanEncr As Boolean, Renamin As Boolean, InvalidOp As Boolean, HideCall As Boolean)
48 | _stringEncrypt = stringEncr
49 | _integerEncoding = integerEncod
50 | _booleanEncrypt = booleanEncr
51 | _Renaming = Renamin
52 | _InvalidOpcodes = InvalidOp
53 | _hideCalls = HideCall
54 | End Sub
55 | #End Region
56 |
57 | End Class
58 | End Namespace
59 |
--------------------------------------------------------------------------------
/Implementer/Core/Obfuscation/Protection/Attribut.vb:
--------------------------------------------------------------------------------
1 | Imports Mono.Cecil
2 | Imports System.IO
3 | Imports Mono.Cecil.Cil
4 | Imports System.Reflection
5 |
6 | Namespace Core.Obfuscation.Protection
7 | Public NotInheritable Class Attribut
8 |
9 | #Region " Fields "
10 | Private Shared attribs As String()
11 | #End Region
12 |
13 | #Region " Constructor "
14 | Shared Sub New()
15 | attribs = New String() {"DotNetPatcherObfuscatorAttribute", "DotNetPatcherPackerAttribute", "DotfuscatorAttribute", "ConfusedByAttribute", _
16 | "ObfuscatedByGoliath", "dotNetProtector", "PoweredByAttribute", "AssemblyInfoAttribute"}
17 | End Sub
18 | #End Region
19 |
20 | #Region " Methods "
21 | Public Shared Sub DoInjection(assdef As AssemblyDefinition, pack As Boolean)
22 | assdef.MainModule.Resources.Add(New EmbeddedResource(If(pack, My.Resources.DnpPattribute, My.Resources.DnpOattribute), ManifestResourceAttributes.Private, File.ReadAllBytes(IO.Path.GetTempFileName)))
23 |
24 | For Each it In attribs
25 | Dim item As New TypeDefinition("", it, Mono.Cecil.TypeAttributes.AnsiClass, assdef.MainModule.Import(GetType(Attribute)))
26 | If it = "DotNetPatcherObfuscatorAttribute" AndAlso pack = False Then
27 | creatAttribut(assdef, item, it)
28 | ElseIf it = "DotNetPatcherPackerAttribute" AndAlso pack = True Then
29 | creatAttribut(assdef, item, it)
30 | ElseIf it = "AssemblyInfoAttribute" Then
31 | creatAttribut(assdef, item, it)
32 | Else
33 | If it = "DotNetPatcherObfuscatorAttribute" Then
34 | ElseIf it = "DotNetPatcherPackerAttribute" Then
35 | ElseIf it = "AssemblyInfoAttribute" Then
36 | Else
37 | assdef.MainModule.Types.Add(item)
38 | End If
39 | End If
40 | Next
41 | End Sub
42 |
43 | Private Shared Sub creatAttribut(assdef As AssemblyDefinition, item As TypeDefinition, it$)
44 | Dim method As New MethodDefinition(".ctor", (Mono.Cecil.MethodAttributes.CompilerControlled Or (Mono.Cecil.MethodAttributes.FamANDAssem Or (Mono.Cecil.MethodAttributes.Family Or (Mono.Cecil.MethodAttributes.RTSpecialName Or Mono.Cecil.MethodAttributes.SpecialName)))), assdef.MainModule.TypeSystem.Void)
45 | method.Parameters.Add(New ParameterDefinition(assdef.MainModule.TypeSystem.String))
46 |
47 | Dim iLProc As ILProcessor = method.Body.GetILProcessor
48 | With iLProc
49 | .Emit(OpCodes.Ldarg_0)
50 | .Emit(OpCodes.Call, assdef.MainModule.Import(GetType(Attribute).GetConstructor((BindingFlags.NonPublic Or BindingFlags.Instance), Nothing, Type.EmptyTypes, Nothing)))
51 | .Emit(OpCodes.Ret)
52 | End With
53 |
54 | item.Methods.Add(method)
55 | assdef.MainModule.Types.Add(item)
56 | Dim att As New CustomAttribute(method)
57 | att.ConstructorArguments.Add(New CustomAttributeArgument(assdef.MainModule.TypeSystem.String, If(it = "AssemblyInfoAttribute", "", String.Format(("DotNetPatcher v" & GetType(Attribut).Assembly.GetName.Version.ToString), New Object(0 - 1) {}))))
58 | assdef.MainModule.CustomAttributes.Add(att)
59 | assdef.CustomAttributes.Add(att)
60 | End Sub
61 | #End Region
62 |
63 | End Class
64 | End Namespace
65 |
66 |
--------------------------------------------------------------------------------
/Implementer/Core/Obfuscation/Protection/invalidOpcodes.vb:
--------------------------------------------------------------------------------
1 | Imports System.Text
2 | Imports System.IO
3 | Imports System.CodeDom.Compiler
4 | Imports Mono.Cecil
5 | Imports Mono.Cecil.Cil
6 | Imports System.ComponentModel
7 | Imports System.Resources
8 | Imports Helper.RandomizeHelper
9 | Imports Helper.CecilHelper
10 | Imports Mono.Cecil.Rocks
11 | Imports Implementer.Core.Obfuscation.Exclusion
12 |
13 | Namespace Core.Obfuscation.Protection
14 | Public NotInheritable Class invalidOpcodes
15 |
16 | #Region " Fields "
17 | Private Shared r As Random
18 | #End Region
19 |
20 | #Region " Constructor "
21 | Shared Sub New()
22 | r = New Random
23 | End Sub
24 | #End Region
25 |
26 | #Region " Methods "
27 | Friend Shared Sub Inject(library As AssemblyDefinition, Exclude As ExcludeList)
28 | For Each mode In (From m In library.Modules
29 | Where m.HasTypes
30 | Select m)
31 |
32 | For Each type In (From t In mode.Types
33 | Where t.HasMethods
34 | Select t)
35 |
36 | For Each method In (From mtd In type.Methods
37 | Where mtd.HasBody AndAlso Not Finder.FindCustomAttributeByName(mtd.DeclaringType, "EditorBrowsableAttribute")
38 | Select mtd)
39 | Using optim As New Msil(method.Body)
40 | For i% = 0 To method.Body.Instructions.Count - 1
41 | Dim Instruction As Instruction = method.Body.Instructions(i)
42 | If Randomizer.GenerateBoolean() Then
43 | If Exclude.isInvalidOpcodesExclude(type) = False Then
44 | optim.StackUnflow(r)
45 | End If
46 | Else
47 | If Exclude.isInvalidOpcodesExclude(type) = False Then
48 | optim.StackOverFlow(r)
49 | End If
50 | End If
51 | Next
52 | optim.FixBranchOffsets()
53 | optim.MethodBody.SimplifyMacros()
54 | End Using
55 | Next
56 | Next
57 | Next
58 | End Sub
59 | #End Region
60 |
61 | End Class
62 | End Namespace
63 |
64 |
--------------------------------------------------------------------------------
/Implementer/Core/Packer/PackInfos.vb:
--------------------------------------------------------------------------------
1 | Imports Implementer.Core.IconChanger
2 | Imports System.IO
3 | Imports System.Drawing
4 |
5 | Namespace Core.Packer
6 | Public Class PackInfos
7 | Implements IDisposable
8 |
9 | #Region " Fields "
10 | Private m_Enabled As Boolean
11 | Private m_NewIcon As Icon
12 | Private m_RequestedLevel As String
13 | #End Region
14 |
15 | #Region " Properties "
16 | Public ReadOnly Property Enabled As Boolean
17 | Get
18 | Return m_Enabled
19 | End Get
20 | End Property
21 |
22 | Public ReadOnly Property NewIcon As Icon
23 | Get
24 | Return m_NewIcon
25 | End Get
26 | End Property
27 |
28 | Public ReadOnly Property RequestedLevel As String
29 | Get
30 | Return m_RequestedLevel
31 | End Get
32 | End Property
33 | #End Region
34 |
35 | #Region " Constructor "
36 | Public Sub New(Enable As Boolean, NewIconP$, RequestedL$)
37 | m_Enabled = Enable
38 | m_NewIcon = NewIconValue(NewIconP)
39 | m_RequestedLevel = RequestedL
40 | End Sub
41 | #End Region
42 |
43 | #Region " Methods "
44 | Private Function NewIconValue(fPath$) As Icon
45 | If fPath.ToLower.EndsWith(".ico") Then Return New Icon(fPath)
46 | Return New IconInfos(fPath).NewIcon
47 | End Function
48 | #End Region
49 |
50 | #Region "IDisposable Support"
51 | Private disposedValue As Boolean ' Pour détecter les appels redondants
52 |
53 | ' IDisposable
54 | Protected Overridable Sub Dispose(disposing As Boolean)
55 | If Not Me.disposedValue Then
56 | If disposing Then
57 | ' TODO: supprimez l'état managé (objets managés).
58 | End If
59 |
60 | ' TODO: libérez les ressources non managées (objets non managés) et substituez la méthode Finalize() ci-dessous.
61 | ' TODO: définissez les champs volumineux à null.
62 | End If
63 | Me.disposedValue = True
64 | End Sub
65 |
66 | ' Ce code a été ajouté par Visual Basic pour permettre l'implémentation correcte du modèle pouvant être supprimé.
67 | Public Sub Dispose() Implements IDisposable.Dispose
68 | ' Ne modifiez pas ce code. Ajoutez du code de nettoyage dans Dispose(disposing As Boolean) ci-dessus.
69 | Dispose(True)
70 | GC.SuppressFinalize(Me)
71 | End Sub
72 | #End Region
73 |
74 | End Class
75 | End Namespace
76 |
--------------------------------------------------------------------------------
/Implementer/Core/Packer/ZipInfos.vb:
--------------------------------------------------------------------------------
1 | Imports System.IO
2 | Imports Mono.Cecil
3 |
4 | Namespace Core.Packer
5 | Public NotInheritable Class ZipInfos
6 |
7 | #Region " Fields "
8 | Private m_fPath As String
9 | Private m_refByte As Byte()
10 | Private m_refNewNamespaceName As String
11 | Private m_refNewTypeName As String
12 | Private m_refNewMethodName As String
13 | #End Region
14 |
15 | #Region " Properties "
16 | Friend ReadOnly Property fPath As String
17 | Get
18 | Return m_fPath
19 | End Get
20 | End Property
21 |
22 | Friend ReadOnly Property refByte As Byte()
23 | Get
24 | Return m_refByte
25 | End Get
26 | End Property
27 |
28 | Friend ReadOnly Property refNewNamespaceName As String
29 | Get
30 | Return m_refNewNamespaceName
31 | End Get
32 | End Property
33 |
34 | Friend ReadOnly Property refNewTypeName As String
35 | Get
36 | Return m_refNewTypeName
37 | End Get
38 | End Property
39 |
40 | Friend ReadOnly Property refNewMethodName As String
41 | Get
42 | Return m_refNewMethodName
43 | End Get
44 | End Property
45 | #End Region
46 |
47 | #Region " Constructor "
48 |
49 | Friend Sub New(filePath$, rByte As Byte(), refNewNamespaceName$, refNewTypeName$, refNewMethodName$)
50 | m_fPath = filePath
51 | m_refByte = rByte
52 | m_refNewNamespaceName = refNewNamespaceName
53 | m_refNewTypeName = refNewTypeName
54 | m_refNewMethodName = refNewMethodName
55 | End Sub
56 |
57 | #End Region
58 |
59 | End Class
60 | End Namespace
61 |
--------------------------------------------------------------------------------
/Implementer/Core/Versions/Extractor.vb:
--------------------------------------------------------------------------------
1 | Imports Helper.ResourcesHelper
2 |
3 | Namespace Core.Versions
4 | Friend NotInheritable Class Extractor
5 |
6 | #Region " Methods "
7 | Friend Shared Sub SaveFileInfoTo(ByVal FileName As String, ByVal ResPath As Byte())
8 | ResourceEx.UpdateResourceEx(FileName, 1, 16, ResPath)
9 | End Sub
10 |
11 | Friend Shared Function LoadFileInfoFrom(ByVal FileName As String) As Byte()
12 | Return ResourceEx.ExtractResourceEx(FileName, "1", New IntPtr(16))
13 | End Function
14 |
15 | Friend Shared Function ReturnAssemblyInfosFormat(ByVal filename As String) As String
16 | Dim fvi As FileVersionInfo = FileVersionInfo.GetVersionInfo(filename)
17 | Return "<" & "Assembly: AssemblyTitle(""" & fvi.FileDescription & """)>" & vbNewLine _
18 | & "" & vbNewLine _
19 | & "<" & "Assembly: AssemblyCompany(""" & fvi.CompanyName & """)>" & vbNewLine _
20 | & "" & vbNewLine _
21 | & "" & vbNewLine _
22 | & "<" & "Assembly: AssemblyTrademark(""" & fvi.LegalTrademarks & """)>" & vbNewLine _
23 | & "" & vbNewLine _
24 | & "" & vbNewLine & vbNewLine
25 | End Function
26 | #End Region
27 |
28 | End Class
29 | End Namespace
--------------------------------------------------------------------------------
/Implementer/Engine/Analyze/ValidatedFile.vb:
--------------------------------------------------------------------------------
1 | Imports System.Reflection
2 | Imports Helper.AssemblyHelper
3 | Imports Core20Reader
4 |
5 | Namespace Engine.Analyze
6 | Public NotInheritable Class ValidatedFile
7 | Inherits EventArgs
8 |
9 | #Region " Fields "
10 | Private m_peInfos As IReader
11 | Private m_isValid As Boolean
12 | Private m_assembly As Data
13 | #End Region
14 |
15 | #Region " Properties "
16 | Public ReadOnly Property peInfos As IReader
17 | Get
18 | Return m_peInfos
19 | End Get
20 | End Property
21 |
22 | Public ReadOnly Property isValid As Boolean
23 | Get
24 | Return m_isValid
25 | End Get
26 | End Property
27 |
28 | Public ReadOnly Property assembly As Data
29 | Get
30 | Return m_assembly
31 | End Get
32 | End Property
33 | #End Region
34 |
35 | #Region " Constructor "
36 | Public Sub New(isvalid As Boolean, peInfos As Reader, ass As Data)
37 | m_isValid = isvalid
38 | m_assembly = ass
39 | m_peInfos = peInfos
40 | End Sub
41 | #End Region
42 |
43 | End Class
44 | End Namespace
--------------------------------------------------------------------------------
/Implementer/Engine/Checking/CheckerEventArgs.vb:
--------------------------------------------------------------------------------
1 | Imports System.Windows.Forms
2 |
3 | Namespace Engine.Checking
4 |
5 | #Region " Delegates "
6 | Public Delegate Sub Check(sender As Object, e As CheckEventArgs)
7 | #End Region
8 |
9 | Public NotInheritable Class CheckEventArgs
10 | Inherits EventArgs
11 |
12 | #Region " Fields "
13 | Private m_message As String
14 | Private m_title As String
15 | Private m_checkedFile As String
16 | #End Region
17 |
18 | #Region " Properties "
19 | Public ReadOnly Property message As String
20 | Get
21 | Return m_message
22 | End Get
23 | End Property
24 |
25 | Public ReadOnly Property title As String
26 | Get
27 | Return m_title
28 | End Get
29 | End Property
30 |
31 | Public ReadOnly Property checkedFile As String
32 | Get
33 | Return m_checkedFile
34 | End Get
35 | End Property
36 | #End Region
37 |
38 | #Region " Constructor "
39 | Public Sub New(message As String, title As String, checkedFile As String)
40 | m_message = message
41 | m_title = title
42 | m_checkedFile = checkedFile
43 | End Sub
44 | #End Region
45 |
46 | End Class
47 | End Namespace
48 |
--------------------------------------------------------------------------------
/Implementer/Engine/Context/Parameters.vb:
--------------------------------------------------------------------------------
1 | Imports Implementer.Engine.Context
2 | Imports Implementer.Engine.Analyze
3 | Imports Implementer.Core.Obfuscation.Exclusion
4 |
5 | Namespace Engine.Context
6 |
7 | '''
8 | ''' INFO : This is the first step of the renamer library.
9 | ''' You must pass two arguments (inputFile and outputFile properties) when instantiating this class and calling the ReadAssembly sub.
10 | ''' This Class inherits Cls_Analyzer.
11 | '''
12 | Public NotInheritable Class Parameters
13 | Inherits Analyzer
14 |
15 | #Region " Fields "
16 | Property ExcludeList As ExcludeList
17 | Property RenamingAccept As RenamerState
18 | Property TaskAccept As TaskState
19 | #End Region
20 |
21 | #Region " Constructor "
22 | '''
23 | ''' INFO : Initializes a new instance of the class Context.Cls_Parameters (inherits Context.Cls_Analyzer class) which used to check if the selected inputfile is a valid PE and executable file.
24 | '''
25 | Public Sub New(inputFile$, outputFile$)
26 | MyBase.New(inputFile, outputFile)
27 | End Sub
28 | #End Region
29 |
30 | End Class
31 | End Namespace
32 |
33 |
--------------------------------------------------------------------------------
/Implementer/Engine/Context/RenamedItem/RenamedItem.vb:
--------------------------------------------------------------------------------
1 | Namespace Engine.Context
2 |
3 | Public NotInheritable Class RenamedItem
4 |
5 | #Region " Fields "
6 | Private ReadOnly m_itemType As RenamedItemType.ItemType
7 | Private ReadOnly m_itemName$
8 | Private ReadOnly m_obfuscatedItemName$
9 | #End Region
10 |
11 | #Region " Constructor "
12 | Friend Sub New(ItemType As RenamedItemType.ItemType, ItemName$, obfuscatedItemName$)
13 | m_itemType = ItemType
14 | m_itemName = ItemName
15 | m_obfuscatedItemName = obfuscatedItemName
16 | End Sub
17 | #End Region
18 |
19 | #Region " Properties "
20 | Public ReadOnly Property ItemType As String
21 | Get
22 | Return TypeToString(Me.m_itemType)
23 | End Get
24 | End Property
25 |
26 | Public ReadOnly Property ItemName As String
27 | Get
28 | Return m_itemName
29 | End Get
30 | End Property
31 |
32 | Public ReadOnly Property obfuscatedItemName As String
33 | Get
34 | Return m_obfuscatedItemName
35 | End Get
36 | End Property
37 | #End Region
38 |
39 | #Region " Methods "
40 | Private Function TypeToString(ItemType%) As String
41 | Select Case ItemType
42 | Case 0
43 | Return "Namespace"
44 | Exit Select
45 | Case 1
46 | Return "Type"
47 | Exit Select
48 | Case 2
49 | Return "Method"
50 | Exit Select
51 | Case 3
52 | Return "Parameter"
53 | Exit Select
54 | Case 4
55 | Return "Generic Parameter"
56 | Exit Select
57 | Case 5
58 | Return "Variable"
59 | Exit Select
60 | Case 6
61 | Return "Property"
62 | Exit Select
63 | Case 7
64 | Return "Event"
65 | Exit Select
66 | Case 8
67 | Return "Field"
68 | Exit Select
69 | End Select
70 | Return Nothing
71 | End Function
72 | #End Region
73 |
74 | End Class
75 | End Namespace
76 |
--------------------------------------------------------------------------------
/Implementer/Engine/Context/RenamedItem/RenamedItemEventArgs.vb:
--------------------------------------------------------------------------------
1 | Namespace Engine.Context
2 |
3 | #Region " Delegates "
4 | Public Delegate Sub RenamedItemDelegate(sender As Object, e As RenamedItemEventArgs)
5 | #End Region
6 |
7 | Public NotInheritable Class RenamedItemEventArgs
8 | Inherits EventArgs
9 |
10 | #Region " Fields "
11 | Private m_item As RenamedItem
12 | #End Region
13 |
14 | #Region " Constructor "
15 | Public Sub New(item As RenamedItem)
16 | m_item = item
17 | End Sub
18 | #End Region
19 |
20 | #Region " Properties "
21 | Public ReadOnly Property item As RenamedItem
22 | Get
23 | Return m_item
24 | End Get
25 | End Property
26 | #End Region
27 |
28 | End Class
29 | End Namespace
30 |
--------------------------------------------------------------------------------
/Implementer/Engine/Context/RenamedItem/RenamedItemType.vb:
--------------------------------------------------------------------------------
1 | Namespace Engine.Context
2 | Friend NotInheritable Class RenamedItemType
3 |
4 | #Region " Enumerations"
5 | Enum ItemType
6 | Namespaces = 0
7 | Types = 1
8 | Methods = 2
9 | Parameters = 3
10 | GenericParameters = 4
11 | Variables = 5
12 | Properties = 6
13 | Events = 7
14 | Fields = 8
15 | End Enum
16 | #End Region
17 |
18 | End Class
19 | End Namespace
20 |
--------------------------------------------------------------------------------
/Implementer/Engine/Context/TaskState.vb:
--------------------------------------------------------------------------------
1 | Imports Implementer.Core.Obfuscation
2 | Imports Implementer.Core.Versions
3 | Imports Implementer.Core.ManifestRequest
4 | Imports Implementer.Core.IconChanger
5 | Imports Implementer.Core.Packer
6 | Imports Implementer.Core.Dependencing
7 | Imports Implementer.Core.Obfuscation.Protection
8 |
9 | Namespace Engine.Context
10 | Public NotInheritable Class TaskState
11 |
12 | #Region " Fields "
13 | Public MergeReferences As DependenciesInfos
14 | Public Obfuscation As ObfuscationInfos
15 | Public Packer As PackInfos
16 | Public VersionInfos As Infos
17 | Public Manifest As ManifestInfos
18 | Public IconChanger As IconInfos
19 | #End Region
20 |
21 | #Region " Methods "
22 | Public Sub CleanUp()
23 | If Not MergeReferences Is Nothing Then MergeReferences.Dispose()
24 | If Not Obfuscation Is Nothing Then Obfuscation.Dispose()
25 | If Not Packer Is Nothing Then Packer.Dispose()
26 | If Not VersionInfos Is Nothing Then VersionInfos.Dispose()
27 | If Not Manifest Is Nothing Then Manifest.Dispose()
28 | If Not IconChanger Is Nothing Then IconChanger.Dispose()
29 | End Sub
30 | #End Region
31 |
32 | End Class
33 |
34 | End Namespace
35 |
36 |
--------------------------------------------------------------------------------
/Implementer/Engine/Identification/IdentifierEnum.vb:
--------------------------------------------------------------------------------
1 |
2 | Namespace Engine.Identification
3 | Public NotInheritable Class IdentifierEnum
4 |
5 | #Region " Enumerations "
6 | Enum ResultName
7 | Unknown = 0
8 | Confuser = 1
9 | Rpx = 2
10 | DotNetPatcher = 3
11 | MPress = 4
12 | Netz = 5
13 | ILProtector = 6
14 | NetPack = 7
15 | NetShrink = 8
16 | DotBundle = 9
17 | SmartAssembly = 10
18 | BabelObfuscator = 11
19 | AgileDotNet = 12
20 | CodeVeil = 13
21 | CryptoObfuscator = 14
22 | DotFuscator = 15
23 | GoliathDotNet = 16
24 | SpicesDotNet = 17
25 | XenocodeObfuscator = 18
26 | SkaterDotNetObfuscator = 19
27 | MancoDotNetObfuscator = 20
28 | CodeFortObfuscator = 21
29 | PhoenixProtector = 22
30 | MacrobjectObfuscator = 23
31 | EazfuscatorDotNet = 24
32 | DotWall = 25
33 | Unidentified = 26
34 | End Enum
35 |
36 | Enum ResultType
37 | Other = 0
38 | Packer = 1
39 | Obfuscator = 2
40 | Empty = 3
41 | End Enum
42 | #End Region
43 |
44 | End Class
45 | End Namespace
46 |
--------------------------------------------------------------------------------
/Implementer/My Project/Application.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.34014
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
--------------------------------------------------------------------------------
/Implementer/My Project/Application.myapp:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | false
5 | 0
6 | true
7 | 0
8 | 1
9 | true
10 |
11 |
--------------------------------------------------------------------------------
/Implementer/My Project/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | Imports System
2 | Imports System.Reflection
3 | Imports System.Runtime.InteropServices
4 |
5 | ' Les informations générales relatives à un assembly dépendent de
6 | ' l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7 | ' associées à un assembly.
8 |
9 | ' Passez en revue les valeurs des attributs de l'assembly
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 'Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
21 |
22 |
23 | ' Les informations de version pour un assembly se composent des quatre valeurs suivantes :
24 | '
25 | ' Version principale
26 | ' Version secondaire
27 | ' Numéro de build
28 | ' Révision
29 | '
30 | ' Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
31 | ' en utilisant '*', comme indiqué ci-dessous :
32 | '
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Implementer/My Project/Settings.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' Ce code a été généré par un outil.
4 | ' Version du runtime :4.0.30319.34014
5 | '
6 | ' Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | ' le code est régénéré.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | _
20 | Partial Friend NotInheritable Class MySettings
21 | Inherits Global.System.Configuration.ApplicationSettingsBase
22 |
23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
24 |
25 | #Region "Fonctionnalité Enregistrement automatique My.Settings"
26 | #If _MyType = "WindowsForms" Then
27 | Private Shared addedHandler As Boolean
28 |
29 | Private Shared addedHandlerLockObject As New Object
30 |
31 | _
32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
33 | If My.Application.SaveMySettingsOnExit Then
34 | My.Settings.Save()
35 | End If
36 | End Sub
37 | #End If
38 | #End Region
39 |
40 | Public Shared ReadOnly Property [Default]() As MySettings
41 | Get
42 |
43 | #If _MyType = "WindowsForms" Then
44 | If Not addedHandler Then
45 | SyncLock addedHandlerLockObject
46 | If Not addedHandler Then
47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48 | addedHandler = True
49 | End If
50 | End SyncLock
51 | End If
52 | #End If
53 | Return defaultInstance
54 | End Get
55 | End Property
56 | End Class
57 | End Namespace
58 |
59 | Namespace My
60 |
61 | _
64 | Friend Module MySettingsProperty
65 |
66 | _
67 | Friend ReadOnly Property Settings() As Global.Implementer.My.MySettings
68 | Get
69 | Return Global.Implementer.My.MySettings.Default
70 | End Get
71 | End Property
72 | End Module
73 | End Namespace
74 |
--------------------------------------------------------------------------------
/Implementer/My Project/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Implementer/Resources/AgileDotNet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/AgileDotNet.png
--------------------------------------------------------------------------------
/Implementer/Resources/Babel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Babel.png
--------------------------------------------------------------------------------
/Implementer/Resources/CodeFort.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/CodeFort.png
--------------------------------------------------------------------------------
/Implementer/Resources/CodeVeil.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/CodeVeil.png
--------------------------------------------------------------------------------
/Implementer/Resources/Confuser.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Confuser.png
--------------------------------------------------------------------------------
/Implementer/Resources/CryptoObfuscator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/CryptoObfuscator.png
--------------------------------------------------------------------------------
/Implementer/Resources/DNP.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/DNP.png
--------------------------------------------------------------------------------
/Implementer/Resources/DotBundle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/DotBundle.png
--------------------------------------------------------------------------------
/Implementer/Resources/DotFuscator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/DotFuscator.png
--------------------------------------------------------------------------------
/Implementer/Resources/DotWall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/DotWall.png
--------------------------------------------------------------------------------
/Implementer/Resources/EazFuscator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/EazFuscator.png
--------------------------------------------------------------------------------
/Implementer/Resources/Goliath.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Goliath.png
--------------------------------------------------------------------------------
/Implementer/Resources/ILProtector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/ILProtector.png
--------------------------------------------------------------------------------
/Implementer/Resources/ILRepack.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/ILRepack.exe
--------------------------------------------------------------------------------
/Implementer/Resources/MPress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/MPress.png
--------------------------------------------------------------------------------
/Implementer/Resources/Macrobject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Macrobject.png
--------------------------------------------------------------------------------
/Implementer/Resources/Manco.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Manco.png
--------------------------------------------------------------------------------
/Implementer/Resources/NetPack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/NetPack.png
--------------------------------------------------------------------------------
/Implementer/Resources/NetReactor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/NetReactor.png
--------------------------------------------------------------------------------
/Implementer/Resources/NetShrink.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/NetShrink.png
--------------------------------------------------------------------------------
/Implementer/Resources/Netz.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Netz.png
--------------------------------------------------------------------------------
/Implementer/Resources/RPX.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/RPX.png
--------------------------------------------------------------------------------
/Implementer/Resources/SevenzipLib.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/SevenzipLib.dll
--------------------------------------------------------------------------------
/Implementer/Resources/Skater.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Skater.png
--------------------------------------------------------------------------------
/Implementer/Resources/SmartAssembly.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/SmartAssembly.png
--------------------------------------------------------------------------------
/Implementer/Resources/Spices.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Spices.png
--------------------------------------------------------------------------------
/Implementer/Resources/Valid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Valid.png
--------------------------------------------------------------------------------
/Implementer/Resources/Warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/Implementer/Resources/Warning.png
--------------------------------------------------------------------------------
/Injections/Injections.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Injections", "Injections\Injections.csproj", "{2E99870D-2ADF-448B-92CE-CCE190C9134D}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {2E99870D-2ADF-448B-92CE-CCE190C9134D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {2E99870D-2ADF-448B-92CE-CCE190C9134D}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {2E99870D-2ADF-448B-92CE-CCE190C9134D}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {2E99870D-2ADF-448B-92CE-CCE190C9134D}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/Injections/Injections/Injections.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {2E99870D-2ADF-448B-92CE-CCE190C9134D}
8 | Library
9 | Properties
10 | Injections
11 | Injections
12 | v4.0
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 | true
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 | true
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
55 |
--------------------------------------------------------------------------------
/Injections/Injections/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Les informations générales relatives à un assembly dépendent de
6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7 | // associées à un assembly.
8 | [assembly: AssemblyTitle("Injections")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Injections")]
13 | [assembly: AssemblyCopyright("Copyright © 3DotDev 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type.
20 | [assembly: ComVisible(false)]
21 |
22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
23 | [assembly: Guid("dc231337-2824-40af-a9b6-12b404aa5b0e")]
24 |
25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes :
26 | //
27 | // Version principale
28 | // Version secondaire
29 | // Numéro de build
30 | // Révision
31 | //
32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
33 | // en utilisant '*', comme indiqué ci-dessous :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 PhilipMo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LoginTheme/My Project/Application.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.34014
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
--------------------------------------------------------------------------------
/LoginTheme/My Project/Application.myapp:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | false
5 | 0
6 | true
7 | 0
8 | 1
9 | true
10 |
11 |
--------------------------------------------------------------------------------
/LoginTheme/My Project/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | Imports System
2 | Imports System.Reflection
3 | Imports System.Runtime.InteropServices
4 |
5 | ' Les informations générales relatives à un assembly dépendent de
6 | ' l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7 | ' associées à un assembly.
8 |
9 | ' Passez en revue les valeurs des attributs de l'assembly
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | 'Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
21 |
22 |
23 | ' Les informations de version pour un assembly se composent des quatre valeurs suivantes :
24 | '
25 | ' Version principale
26 | ' Version secondaire
27 | ' Numéro de build
28 | ' Révision
29 | '
30 | ' Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
31 | ' en utilisant '*', comme indiqué ci-dessous :
32 | '
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/LoginTheme/My Project/Resources.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.34014
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My.Resources
16 |
17 | 'This class was auto-generated by the StronglyTypedResourceBuilder
18 | 'class via a tool like ResGen or Visual Studio.
19 | 'To add or remove a member, edit your .ResX file then rerun ResGen
20 | 'with the /str option, or rebuild your VS project.
21 | '''
22 | ''' A strongly-typed resource class, for looking up localized strings, etc.
23 | '''
24 | _
28 | Friend Module Resources
29 |
30 | Private resourceMan As Global.System.Resources.ResourceManager
31 |
32 | Private resourceCulture As Global.System.Globalization.CultureInfo
33 |
34 | '''
35 | ''' Returns the cached ResourceManager instance used by this class.
36 | '''
37 | _
38 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
39 | Get
40 | If Object.ReferenceEquals(resourceMan, Nothing) Then
41 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("LoginTheme.Resources", GetType(Resources).Assembly)
42 | resourceMan = temp
43 | End If
44 | Return resourceMan
45 | End Get
46 | End Property
47 |
48 | '''
49 | ''' Overrides the current thread's CurrentUICulture property for all
50 | ''' resource lookups using this strongly typed resource class.
51 | '''
52 | _
53 | Friend Property Culture() As Global.System.Globalization.CultureInfo
54 | Get
55 | Return resourceCulture
56 | End Get
57 | Set(ByVal value As Global.System.Globalization.CultureInfo)
58 | resourceCulture = value
59 | End Set
60 | End Property
61 | End Module
62 | End Namespace
63 |
--------------------------------------------------------------------------------
/LoginTheme/My Project/Settings.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.34014
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | _
20 | Partial Friend NotInheritable Class MySettings
21 | Inherits Global.System.Configuration.ApplicationSettingsBase
22 |
23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
24 |
25 | #Region "My.Settings Auto-Save Functionality"
26 | #If _MyType = "WindowsForms" Then
27 | Private Shared addedHandler As Boolean
28 |
29 | Private Shared addedHandlerLockObject As New Object
30 |
31 | _
32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
33 | If My.Application.SaveMySettingsOnExit Then
34 | My.Settings.Save()
35 | End If
36 | End Sub
37 | #End If
38 | #End Region
39 |
40 | Public Shared ReadOnly Property [Default]() As MySettings
41 | Get
42 |
43 | #If _MyType = "WindowsForms" Then
44 | If Not addedHandler Then
45 | SyncLock addedHandlerLockObject
46 | If Not addedHandler Then
47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48 | addedHandler = True
49 | End If
50 | End SyncLock
51 | End If
52 | #End If
53 | Return defaultInstance
54 | End Get
55 | End Property
56 | End Class
57 | End Namespace
58 |
59 | Namespace My
60 |
61 | _
64 | Friend Module MySettingsProperty
65 |
66 | _
67 | Friend ReadOnly Property Settings() As Global.LoginTheme.My.MySettings
68 | Get
69 | Return Global.LoginTheme.My.MySettings.Default
70 | End Get
71 | End Property
72 | End Module
73 | End Namespace
74 |
--------------------------------------------------------------------------------
/LoginTheme/My Project/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # **original**
2 | * BitBucket Link :: https://bitbucket.org/3dotdev/dotnet-patcher
3 | # **DotNet Patcher v4** #
4 |
5 | # Description
6 |
7 | DNP is a Obfuscator/Packer which use MonoCecil library for .NET applications !
8 | It doesn't support WPF .exe !
9 |
10 | # Screenshot
11 |
12 | 
13 |
14 |
15 | # Features
16 |
17 | * English UI language only
18 | * Displays selected .exe informations (assembly name, Version, TargetRuntime, TargetCPU, SubSystemType)
19 | * Selecting encoding chars type : Alphabetic, Dots, Invisible, Chinese, Japanese, Greek, Flowing)
20 | * Renaming : Namespaces, Types, Methods, Properties, Fields, Custom Attributes, Events, Parameters, .....
21 | * Dependencies merging/embedding (encrypt and/or compress)
22 | * Displays number of renamed members
23 | * Exclusionary rules Manager
24 | * Anti-IlDasm, Anti-Tamper, Anti-Debug, Anti-Dumping
25 | * "System-Reflection" methods calls detection
26 | * Public calls hidding
27 | * Pinvoke calls hidding
28 | * Strings encryption
29 | * Numerics encryption
30 | * Constants encoding
31 | * Booleans encoding
32 | * Invalid Metadatas
33 | * Mild calls
34 | * Stackflow
35 | * Fake attributes injection
36 | * Invalid opcodes injection
37 | * Packer with LZX compression and encryption
38 |
39 |
40 | # Prerequisites
41 |
42 | * All Windows OS
43 | * DotNet Framework 4.0
44 | * The binary doesn't require installation
45 |
46 |
47 | # WebSite
48 |
49 | * [http://3dotdevcoder.blogspot.fr/](http://3dotdevcoder.blogspot.fr/)
50 |
51 |
52 | # Credits
53 |
54 | * jbevains : for [MonoCecil](https://github.com/jbevain/cecil) library
55 | * Yck1509 : for [Confuser](https://confuser.codeplex.com/) project
56 | * Daniel Doubrovkine : for his ResourceLib library [Vestris](https://github.com/dblock/resourcelib)
57 | * Markhor : For his Sevenzip library [Sevenzip](https://sevenzipsharp.codeplex.com/)
58 | * Xertz : for his [Login GDI+ theme](http://xertzproductions.weebly.com/login-gdi-theme.html) which I modified a little bit
59 | * Paupino : for some useful functions from his open source project : [NCloak](https://github.com/paupino/ncloak/)
60 | * Mirhabi : for his IconInjector class
61 |
62 |
63 | # Copyright
64 |
65 | Copyright © 3DotDev 2008-2015
66 |
67 |
68 | # Licence
69 |
70 | [MIT/X11](http://en.wikipedia.org/wiki/MIT_License)
71 |
--------------------------------------------------------------------------------
/ResourceLib/.gitignore:
--------------------------------------------------------------------------------
1 | /*.user
2 |
--------------------------------------------------------------------------------
/ResourceLib/Accelerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// Standard accelerator.
11 | ///
12 | public class Accelerator
13 | {
14 | private User32.ACCEL _accel = new User32.ACCEL();
15 |
16 | ///
17 | /// Read the accelerator.
18 | ///
19 | /// Address in memory.
20 | internal IntPtr Read(IntPtr lpRes)
21 | {
22 | _accel = (User32.ACCEL) Marshal.PtrToStructure(
23 | lpRes, typeof(User32.ACCEL));
24 |
25 | return new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_accel));
26 | }
27 |
28 | ///
29 | /// Write accelerator to a binary stream.
30 | ///
31 | /// Binary stream.
32 | internal void Write(BinaryWriter w)
33 | {
34 | w.Write(_accel.fVirt);
35 | w.Write(_accel.key);
36 | w.Write(_accel.cmd);
37 | ResourceUtil.PadToWORD(w);
38 | }
39 |
40 | ///
41 | /// String representation of the accelerator key.
42 | ///
43 | public string Key
44 | {
45 | get
46 | {
47 | string key = Enum.GetName(typeof(User32.VirtualKeys), _accel.key);
48 | return string.IsNullOrEmpty(key) ? ((char) _accel.key).ToString() : key;
49 | }
50 | }
51 |
52 | ///
53 | /// An unsigned integer value that identifies the accelerator.
54 | ///
55 | public UInt32 Command
56 | {
57 | get
58 | {
59 | return _accel.cmd;
60 | }
61 | set
62 | {
63 | _accel.cmd = value;
64 | }
65 | }
66 |
67 | ///
68 | /// String representation of the accelerator.
69 | ///
70 | /// String representation of the accelerator.
71 | public override string ToString()
72 | {
73 | return string.Format("{0}, {1}, {2}",
74 | Key, Command, ResourceUtil.FlagsToString(
75 | _accel.fVirt).Replace(" |", ","));
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/ResourceLib/BitmapFile.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using System.IO;
4 |
5 | namespace Vestris.ResourceLib
6 | {
7 | ///
8 | /// A bitmap file in a .bmp format.
9 | ///
10 | public class BitmapFile
11 | {
12 | private Gdi32.BITMAPFILEHEADER _header = new Gdi32.BITMAPFILEHEADER();
13 | private DeviceIndependentBitmap _bitmap = null;
14 |
15 | ///
16 | /// Device independent bitmap.
17 | ///
18 | public DeviceIndependentBitmap Bitmap
19 | {
20 | get
21 | {
22 | return _bitmap;
23 | }
24 | }
25 |
26 | ///
27 | /// An existing bitmap file.
28 | ///
29 | /// A file in a .bmp format.
30 | public BitmapFile(string filename)
31 | {
32 | byte[] data = File.ReadAllBytes(filename);
33 |
34 | IntPtr pFileHeaderData = Marshal.AllocHGlobal(Marshal.SizeOf(_header));
35 | try
36 | {
37 | Marshal.Copy(data, 0, pFileHeaderData, Marshal.SizeOf(_header));
38 | _header = (Gdi32.BITMAPFILEHEADER)Marshal.PtrToStructure(
39 | pFileHeaderData, typeof(Gdi32.BITMAPFILEHEADER));
40 | }
41 | finally
42 | {
43 | Marshal.FreeHGlobal(pFileHeaderData);
44 | }
45 |
46 | Int32 size = data.Length - Marshal.SizeOf(_header);
47 | byte[] bitmapData = new byte[size];
48 | Buffer.BlockCopy(data, Marshal.SizeOf(_header), bitmapData, 0, size);
49 | _bitmap = new DeviceIndependentBitmap(bitmapData);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/ResourceLib/BitmapResource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.IO;
5 | using System.Runtime.InteropServices;
6 | using System.Xml;
7 |
8 | namespace Vestris.ResourceLib
9 | {
10 | ///
11 | /// An embedded bitmap resource.
12 | ///
13 | public class BitmapResource : Resource
14 | {
15 | private DeviceIndependentBitmap _bitmap = null;
16 |
17 | ///
18 | /// An existing bitmap resource.
19 | ///
20 | /// Module handle.
21 | /// Resource ID.
22 | /// Resource type.
23 | /// Resource name.
24 | /// Language ID.
25 | /// Resource size.
26 | public BitmapResource(IntPtr hModule, IntPtr hResource, ResourceId type, ResourceId name, UInt16 language, int size)
27 | : base(hModule, hResource, type, name, language, size)
28 | {
29 |
30 | }
31 |
32 | ///
33 | /// A new bitmap resource.
34 | ///
35 | public BitmapResource()
36 | : base(IntPtr.Zero,
37 | IntPtr.Zero,
38 | new ResourceId(Kernel32.ResourceTypes.RT_BITMAP),
39 | new ResourceId(1),
40 | Kernel32.LANG_NEUTRAL,
41 | 0)
42 | {
43 |
44 | }
45 |
46 | ///
47 | /// Read the resource.
48 | ///
49 | /// Module handle.
50 | /// Pointer to the beginning of a resource.
51 | /// Pointer to the end of the resource.
52 | internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
53 | {
54 | byte[] data = new byte[_size];
55 | Marshal.Copy(lpRes, data, 0, data.Length);
56 | _bitmap = new DeviceIndependentBitmap(data);
57 | return new IntPtr(lpRes.ToInt64() + _size);
58 | }
59 |
60 | ///
61 | /// Write the bitmap resource to a binary stream.
62 | ///
63 | /// Binary stream.
64 | internal override void Write(BinaryWriter w)
65 | {
66 | w.Write(_bitmap.Data);
67 | }
68 |
69 | ///
70 | /// A device independent bitmap.
71 | ///
72 | public DeviceIndependentBitmap Bitmap
73 | {
74 | get
75 | {
76 | return _bitmap;
77 | }
78 | set
79 | {
80 | _bitmap = value;
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/ResourceLib/CursorDirectoryResource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.ComponentModel;
5 | using System.Runtime.InteropServices;
6 | using System.IO;
7 |
8 | namespace Vestris.ResourceLib
9 | {
10 | ///
11 | /// This structure depicts the organization of data in a hardware-independent cursor resource.
12 | ///
13 | public class CursorDirectoryResource : DirectoryResource
14 | {
15 | ///
16 | /// A hardware-independent cursor resource.
17 | ///
18 | /// Module handle.
19 | /// Resource ID.
20 | /// Resource type.
21 | /// Resource name.
22 | /// Language ID.
23 | /// Resource size.
24 | internal CursorDirectoryResource(IntPtr hModule, IntPtr hResource, ResourceId type, ResourceId name, UInt16 language, int size)
25 | : base(hModule, hResource, type, name, language, size)
26 | {
27 |
28 | }
29 |
30 | ///
31 | /// A new hardware-independent cursor resource.
32 | ///
33 | public CursorDirectoryResource()
34 | : base(Kernel32.ResourceTypes.RT_GROUP_CURSOR)
35 | {
36 |
37 | }
38 |
39 | ///
40 | /// A new collection of cursors that can be embedded into an executable file.
41 | ///
42 | public CursorDirectoryResource(IconFile iconFile)
43 | : base(Kernel32.ResourceTypes.RT_GROUP_CURSOR)
44 | {
45 | for (UInt16 id = 0; id < iconFile.Icons.Count; id++)
46 | {
47 | CursorResource cursorResource = new CursorResource(
48 | iconFile.Icons[id], new ResourceId(id), _language);
49 | // cursor structure abuses planes and bits per pixel for cursor data
50 | cursorResource.HotspotX = iconFile.Icons[id].Header.wPlanes;
51 | cursorResource.HotspotY = iconFile.Icons[id].Header.wBitsPerPixel;
52 | Icons.Add(cursorResource);
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/ResourceLib/DialogResource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.IO;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Vestris.ResourceLib
7 | {
8 | ///
9 | /// A dialog template resource.
10 | ///
11 | public class DialogResource : Resource
12 | {
13 | private DialogTemplateBase _dlgtemplate = null;
14 |
15 | ///
16 | /// A dialog template structure that describes the dialog.
17 | ///
18 | public DialogTemplateBase Template
19 | {
20 | get
21 | {
22 | return _dlgtemplate;
23 | }
24 | set
25 | {
26 | _dlgtemplate = value;
27 | }
28 | }
29 |
30 | ///
31 | /// A structured dialog resource embedded in an executable module.
32 | ///
33 | /// Module handle.
34 | /// Resource handle.
35 | /// Type of resource.
36 | /// Resource name.
37 | /// Language id.
38 | /// Resource size.
39 | public DialogResource(IntPtr hModule, IntPtr hResource, ResourceId type, ResourceId name, UInt16 language, int size)
40 | : base(hModule, hResource, type, name, language, size)
41 | {
42 |
43 | }
44 |
45 | ///
46 | /// A structured dialog resource embedded in an executable module.
47 | ///
48 | public DialogResource()
49 | : base(IntPtr.Zero,
50 | IntPtr.Zero,
51 | new ResourceId(Kernel32.ResourceTypes.RT_DIALOG),
52 | new ResourceId(1),
53 | ResourceUtil.NEUTRALLANGID,
54 | 0)
55 | {
56 |
57 | }
58 |
59 | internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
60 | {
61 | switch ((uint)Marshal.ReadInt32(lpRes) >> 16)
62 | {
63 | case 0xFFFF:
64 | _dlgtemplate = new DialogExTemplate();
65 | break;
66 | default:
67 | _dlgtemplate = new DialogTemplate();
68 | break;
69 | }
70 |
71 | // dialog structure itself
72 | return _dlgtemplate.Read(lpRes);
73 | }
74 |
75 | internal override void Write(BinaryWriter w)
76 | {
77 | _dlgtemplate.Write(w);
78 | }
79 |
80 | ///
81 | /// Dialog resource in standard resource editor text format.
82 | ///
83 | /// Multi-line string.
84 | public override string ToString()
85 | {
86 | StringBuilder sb = new StringBuilder();
87 | sb.AppendFormat("{0} {1}",
88 | Name.IsIntResource() ? Name.ToString() : "\"" + Name.ToString() + "\"",
89 | _dlgtemplate);
90 | return sb.ToString();
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/ResourceLib/FontResource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Runtime.InteropServices;
5 | using System.IO;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// A font, RT_FONT resource.
11 | ///
12 | public class FontResource : GenericResource
13 | {
14 | ///
15 | /// A new font resource.
16 | ///
17 | public FontResource()
18 | : base(IntPtr.Zero,
19 | IntPtr.Zero,
20 | new ResourceId(Kernel32.ResourceTypes.RT_FONT),
21 | null,
22 | ResourceUtil.NEUTRALLANGID,
23 | 0)
24 | {
25 |
26 | }
27 |
28 | ///
29 | /// An existing font resource.
30 | ///
31 | /// Module handle.
32 | /// Resource ID.
33 | /// Resource type.
34 | /// Resource name.
35 | /// Language ID.
36 | /// Resource size.
37 | public FontResource(IntPtr hModule, IntPtr hResource, ResourceId type, ResourceId name, UInt16 language, int size)
38 | : base(hModule, hResource, type, name, language, size)
39 | {
40 |
41 | }
42 |
43 | ///
44 | /// Read the font resource.
45 | ///
46 | /// Handle to a module.
47 | /// Pointer to the beginning of the font structure.
48 | /// Address of the end of the font structure.
49 | internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
50 | {
51 | return base.Read(hModule, lpRes);
52 | }
53 |
54 | ///
55 | /// Write the font resource to a binary writer.
56 | ///
57 | /// Binary writer.
58 | internal override void Write(BinaryWriter w)
59 | {
60 | base.Write(w);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ResourceLib/GenericResource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.IO;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// A generic resource.
11 | ///
12 | public class GenericResource : Resource
13 | {
14 | ///
15 | /// Raw resource data.
16 | ///
17 | protected byte[] _data = null;
18 |
19 | ///
20 | /// Raw resource data.
21 | ///
22 | public byte[] Data
23 | {
24 | get
25 | {
26 | return _data;
27 | }
28 | set
29 | {
30 | _data = value;
31 | }
32 | }
33 |
34 | ///
35 | /// An unstructured generic resource embedded in an executable module.
36 | ///
37 | /// Module handle.
38 | /// Resource handle.
39 | /// Type of resource.
40 | /// Resource name.
41 | /// Language id.
42 | /// Resource size.
43 | public GenericResource(IntPtr hModule, IntPtr hResource, ResourceId type, ResourceId name, UInt16 language, int size)
44 | : base(hModule, hResource, type, name, language, size)
45 | {
46 |
47 | }
48 |
49 | ///
50 | /// A generic resource.
51 | ///
52 | /// Resource name.
53 | /// Resource type.
54 | /// Resource language.
55 | public GenericResource(ResourceId type, ResourceId name, UInt16 language)
56 | {
57 | _type = type;
58 | _name = name;
59 | _language = language;
60 | }
61 |
62 | ///
63 | /// Read a generic resource.
64 | ///
65 | /// Module handle.
66 | /// Pointer to the beginning of a resource.
67 | /// Pointer to the end of the resource.
68 | internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
69 | {
70 | if (_size > 0)
71 | {
72 | _data = new byte[_size];
73 | Marshal.Copy(lpRes, _data, 0, _data.Length);
74 | }
75 |
76 | return new IntPtr(lpRes.ToInt64() + _size);
77 | }
78 |
79 | ///
80 | /// Write the resource to a binary stream.
81 | ///
82 | /// Binary stream.
83 | internal override void Write(BinaryWriter w)
84 | {
85 | w.Write(_data);
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/ResourceLib/IconDirectoryResource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.ComponentModel;
5 | using System.Runtime.InteropServices;
6 | using System.IO;
7 |
8 | namespace Vestris.ResourceLib
9 | {
10 | ///
11 | /// This structure depicts the organization of data in a hardware-independent icon resource.
12 | ///
13 | public class IconDirectoryResource : DirectoryResource
14 | {
15 | ///
16 | /// A hardware-independent icon resource.
17 | ///
18 | /// Module handle.
19 | /// Resource ID.
20 | /// Resource type.
21 | /// Resource name.
22 | /// Language ID.
23 | /// Resource size.
24 | internal IconDirectoryResource(IntPtr hModule, IntPtr hResource, ResourceId type, ResourceId name, UInt16 language, int size)
25 | : base(hModule, hResource, type, name, language, size)
26 | {
27 |
28 | }
29 |
30 | ///
31 | /// A new hardware-independent icon resource.
32 | ///
33 | public IconDirectoryResource()
34 | : base(Kernel32.ResourceTypes.RT_GROUP_ICON)
35 | {
36 |
37 | }
38 |
39 | ///
40 | /// A new collection of icons that can be embedded into an executable file.
41 | ///
42 | public IconDirectoryResource(IconFile iconFile)
43 | : base(Kernel32.ResourceTypes.RT_GROUP_ICON)
44 | {
45 | for (UInt16 id = 0; id < iconFile.Icons.Count; id++)
46 | {
47 | IconResource iconResource = new IconResource(
48 | iconFile.Icons[id], new ResourceId(id), _language);
49 | Icons.Add(iconResource);
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ResourceLib/IconFileIcon.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.ComponentModel;
5 | using System.Runtime.InteropServices;
6 | using System.IO;
7 | using System.Drawing.Imaging;
8 |
9 | namespace Vestris.ResourceLib
10 | {
11 | ///
12 | /// This structure depicts the organization of icon data in a .ico file.
13 | ///
14 | public class IconFileIcon
15 | {
16 | private Kernel32.FILEGRPICONDIRENTRY _header;
17 | private DeviceIndependentBitmap _image = new DeviceIndependentBitmap();
18 |
19 | ///
20 | /// Icon header.
21 | ///
22 | public Kernel32.FILEGRPICONDIRENTRY Header
23 | {
24 | get
25 | {
26 | return _header;
27 | }
28 | }
29 |
30 | ///
31 | /// Icon bitmap.
32 | ///
33 | public DeviceIndependentBitmap Image
34 | {
35 | get
36 | {
37 | return _image;
38 | }
39 | set
40 | {
41 | _image = value;
42 | }
43 | }
44 |
45 | ///
46 | /// New icon data.
47 | ///
48 | public IconFileIcon()
49 | {
50 |
51 | }
52 |
53 | ///
54 | /// Icon width.
55 | ///
56 | public Byte Width
57 | {
58 | get
59 | {
60 | return _header.bWidth;
61 | }
62 | }
63 |
64 | ///
65 | /// Icon height.
66 | ///
67 | public Byte Height
68 | {
69 | get
70 | {
71 | return _header.bHeight;
72 | }
73 | }
74 |
75 | ///
76 | /// Image size in bytes.
77 | ///
78 | public UInt32 ImageSize
79 | {
80 | get
81 | {
82 | return _header.dwImageSize;
83 | }
84 | }
85 |
86 | ///
87 | /// Read a single icon (.ico).
88 | ///
89 | /// Pointer to the beginning of this icon's data.
90 | /// Pointer to the beginning of all icon data.
91 | /// Pointer to the end of this icon's data.
92 | internal IntPtr Read(IntPtr lpData, IntPtr lpAllData)
93 | {
94 | _header = (Kernel32.FILEGRPICONDIRENTRY)Marshal.PtrToStructure(
95 | lpData, typeof(Kernel32.FILEGRPICONDIRENTRY));
96 |
97 | IntPtr lpImage = new IntPtr(lpAllData.ToInt64() + _header.dwFileOffset);
98 | _image.Read(lpImage, _header.dwImageSize);
99 |
100 | return new IntPtr(lpData.ToInt64() + Marshal.SizeOf(_header));
101 | }
102 |
103 | ///
104 | /// Icon size as a string.
105 | ///
106 | /// Icon size in the width x height format.
107 | public override string ToString()
108 | {
109 | return string.Format("{0}x{1}", Width, Height);
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/ResourceLib/IconResource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Vestris.ResourceLib
6 | {
7 | ///
8 | /// This structure depicts the organization of data in an icon resource.
9 | ///
10 | public class IconResource : IconImageResource
11 | {
12 | ///
13 | /// An existing icon resource.
14 | ///
15 | /// Module handle.
16 | /// Resource ID.
17 | /// Resource type.
18 | /// Resource name.
19 | /// Language ID.
20 | /// Resource size.
21 | internal IconResource(IntPtr hModule, IntPtr hResource, ResourceId type, ResourceId name, UInt16 language, int size)
22 | : base(hModule, hResource, type, name, language, size)
23 | {
24 |
25 | }
26 |
27 | ///
28 | /// A new icon resource.
29 | ///
30 | public IconResource()
31 | : base(new ResourceId(Kernel32.ResourceTypes.RT_ICON))
32 | {
33 |
34 | }
35 |
36 | ///
37 | /// Convert into an icon resource that can be written into an executable.
38 | ///
39 | /// Icon image.
40 | /// Icon Id.
41 | /// Resource language.
42 | /// An icon resource.
43 | public IconResource(IconFileIcon icon, ResourceId id, UInt16 language)
44 | : base(icon, new ResourceId(Kernel32.ResourceTypes.RT_ICON), id, language)
45 | {
46 |
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ResourceLib/Kernel32.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/ResourceLib/Kernel32.cs
--------------------------------------------------------------------------------
/ResourceLib/Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mwsrc/DotNetObfuscator/d692b407774f91b1b65ae5131f196102d8e885c0/ResourceLib/Key.snk
--------------------------------------------------------------------------------
/ResourceLib/License.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Daniel Doubrovkine, 2008-2012, Vestris Inc.
4 |
5 | https://github.com/dblock/resourcelib/
6 |
7 | You may freely use and distribute this software under the terms of the following license agreement.
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
10 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation
11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
12 | to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of
15 | the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
18 | THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/ResourceLib/LoadException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Vestris.ResourceLib
6 | {
7 | ///
8 | /// A resource load exception.
9 | ///
10 | public class LoadException : Exception
11 | {
12 | private Exception _outerException = null;
13 |
14 | ///
15 | /// The Win32 exception from a resource enumeration function.
16 | ///
17 | public Exception OuterException
18 | {
19 | get
20 | {
21 | return _outerException;
22 | }
23 | }
24 |
25 | ///
26 | /// A new resource load exception.
27 | ///
28 | /// Error message.
29 | /// The inner exception thrown within a single resource.
30 | /// The outer exception from the Win32 API.
31 | public LoadException(string message, Exception innerException, Exception outerException)
32 | : base(message, innerException)
33 | {
34 | _outerException = outerException;
35 | }
36 |
37 | ///
38 | /// A combined message of the inner and outer exception.
39 | ///
40 | public override string Message
41 | {
42 | get
43 | {
44 | return _outerException != null ? string.Format("{0} {1}.",
45 | base.Message, _outerException.Message) : base.Message;
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ResourceLib/MenuExTemplate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Vestris.ResourceLib
7 | {
8 | ///
9 | /// Extended menu template.
10 | ///
11 | public class MenuExTemplate : MenuTemplateBase
12 | {
13 | private User32.MENUEXTEMPLATE _header = new User32.MENUEXTEMPLATE();
14 | private MenuExTemplateItemCollection _menuItems = new MenuExTemplateItemCollection();
15 |
16 | ///
17 | /// Menu items.
18 | ///
19 | public MenuExTemplateItemCollection MenuItems
20 | {
21 | get
22 | {
23 | return _menuItems;
24 | }
25 | set
26 | {
27 | _menuItems = value;
28 | }
29 | }
30 |
31 | ///
32 | /// Read the menu template.
33 | ///
34 | /// Address in memory.
35 | internal override IntPtr Read(IntPtr lpRes)
36 | {
37 | _header = (User32.MENUEXTEMPLATE) Marshal.PtrToStructure(
38 | lpRes, typeof(User32.MENUEXTEMPLATE));
39 |
40 | IntPtr lpMenuItem = ResourceUtil.Align(lpRes.ToInt64()
41 | + Marshal.SizeOf(_header)
42 | + _header.wOffset);
43 |
44 | return _menuItems.Read(lpMenuItem);
45 | }
46 |
47 | ///
48 | /// Write the menu template.
49 | ///
50 | /// Binary stream.
51 | internal override void Write(System.IO.BinaryWriter w)
52 | {
53 | long head = w.BaseStream.Position;
54 | // write header
55 | w.Write(_header.wVersion);
56 | w.Write(_header.wOffset);
57 | // w.Write(_header.dwHelpId);
58 | // pad to match the offset value
59 | ResourceUtil.Pad(w, (UInt16) (_header.wOffset - 4));
60 | // seek to the beginning of the menu item per offset value
61 | // this may be behind, ie. the help id structure is part of the first popup menu
62 | w.BaseStream.Seek(head + _header.wOffset + 4, System.IO.SeekOrigin.Begin);
63 | // write menu items
64 | _menuItems.Write(w);
65 | }
66 |
67 | ///
68 | /// String representation of the menu in the MENUEX format.
69 | ///
70 | /// String representation of the menu.
71 | public override string ToString()
72 | {
73 | StringBuilder sb = new StringBuilder();
74 | sb.AppendLine("MENUEX");
75 | sb.Append(_menuItems.ToString());
76 | return sb.ToString();
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/ResourceLib/MenuExTemplateItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// A base menu template item.
11 | ///
12 | public abstract class MenuExTemplateItem
13 | {
14 | ///
15 | /// Menu item header.
16 | ///
17 | protected User32.MENUEXITEMTEMPLATE _header = new User32.MENUEXITEMTEMPLATE();
18 | ///
19 | /// Menu string.
20 | ///
21 | protected string _menuString = null;
22 |
23 | ///
24 | /// Menu text.
25 | ///
26 | public string MenuString
27 | {
28 | get
29 | {
30 | return _menuString;
31 | }
32 | set
33 | {
34 | _menuString = value;
35 | }
36 | }
37 |
38 | ///
39 | /// Read the menu item.
40 | ///
41 | /// Address in memory.
42 | /// End of the menu item structure.
43 | internal virtual IntPtr Read(IntPtr lpRes)
44 | {
45 | _header = (User32.MENUEXITEMTEMPLATE) Marshal.PtrToStructure(
46 | lpRes, typeof(User32.MENUEXITEMTEMPLATE));
47 |
48 | lpRes = new IntPtr(lpRes.ToInt64()
49 | + Marshal.SizeOf(_header));
50 |
51 | switch ((UInt32) Marshal.ReadInt32(lpRes))
52 | {
53 | case 0:
54 | break;
55 | default:
56 | _menuString = Marshal.PtrToStringUni(lpRes);
57 | lpRes = new IntPtr(lpRes.ToInt64() +
58 | (_menuString.Length + 1) * Marshal.SystemDefaultCharSize);
59 | break;
60 | }
61 |
62 | return lpRes;
63 | }
64 |
65 | ///
66 | /// Write the menu item to a binary stream.
67 | ///
68 | /// Binary stream.
69 | internal virtual void Write(BinaryWriter w)
70 | {
71 | // header
72 | w.Write(_header.dwType);
73 | w.Write(_header.dwState);
74 | w.Write(_header.dwMenuId);
75 | w.Write(_header.bResInfo);
76 | // menu string
77 | if (_menuString != null)
78 | {
79 | w.Write(Encoding.Unicode.GetBytes(_menuString));
80 | w.Write((UInt16) 0);
81 | ResourceUtil.PadToDWORD(w);
82 | }
83 | }
84 |
85 | ///
86 | /// String representation in the MENU format.
87 | ///
88 | /// Indent.
89 | /// String representation.
90 | public abstract string ToString(int indent);
91 |
92 | ///
93 | /// String representation in the MENU format.
94 | ///
95 | /// String representation.
96 | public override string ToString()
97 | {
98 | return ToString(0);
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/ResourceLib/MenuExTemplateItemCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.InteropServices;
4 | using System.Text;
5 | using System.IO;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// A collection of menu items.
11 | ///
12 | public class MenuExTemplateItemCollection : List
13 | {
14 | ///
15 | /// A collection of extended menu items.
16 | ///
17 | public MenuExTemplateItemCollection()
18 | {
19 |
20 | }
21 |
22 | ///
23 | /// Read the menu item collection.
24 | ///
25 | /// Address in memory.
26 | /// End of the menu item structure.
27 | internal IntPtr Read(IntPtr lpRes)
28 | {
29 | while(true)
30 | {
31 | lpRes = ResourceUtil.Align(lpRes.ToInt64());
32 |
33 | User32.MENUEXITEMTEMPLATE childItem = (User32.MENUEXITEMTEMPLATE)Marshal.PtrToStructure(
34 | lpRes, typeof(User32.MENUEXITEMTEMPLATE));
35 |
36 | MenuExTemplateItem childMenu = null;
37 | if ((childItem.bResInfo & (uint) User32.MenuResourceType.Sub) > 0)
38 | childMenu = new MenuExTemplateItemPopup();
39 | else
40 | childMenu = new MenuExTemplateItemCommand();
41 |
42 | lpRes = childMenu.Read(lpRes);
43 | Add(childMenu);
44 |
45 | if ((childItem.bResInfo & (uint) User32.MenuResourceType.Last) > 0)
46 | break;
47 | }
48 |
49 | return lpRes;
50 | }
51 |
52 | ///
53 | /// Write the menu collection to a binary stream.
54 | ///
55 | /// Binary stream.
56 | internal void Write(BinaryWriter w)
57 | {
58 | foreach (MenuExTemplateItem menuItem in this)
59 | {
60 | ResourceUtil.PadToDWORD(w);
61 | menuItem.Write(w);
62 | }
63 | }
64 |
65 | ///
66 | /// String representation in the MENU format.
67 | ///
68 | /// String representation.
69 | public override string ToString()
70 | {
71 | return ToString(0);
72 | }
73 |
74 | ///
75 | /// String representation in the MENU format.
76 | ///
77 | /// Indent.
78 | /// String representation.
79 | public string ToString(int indent)
80 | {
81 | StringBuilder sb = new StringBuilder();
82 | if (Count > 0)
83 | {
84 | sb.AppendLine(string.Format("{0}BEGIN", new String(' ', indent)));
85 | foreach (MenuExTemplateItem child in this)
86 | {
87 | sb.Append(child.ToString(indent + 1));
88 | }
89 | sb.AppendLine(string.Format("{0}END", new String(' ', indent)));
90 | }
91 | return sb.ToString();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/ResourceLib/MenuExTemplateItemCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// A command menu item.
11 | ///
12 | public class MenuExTemplateItemCommand : MenuExTemplateItem
13 | {
14 | ///
15 | /// A command menu item.
16 | ///
17 | public MenuExTemplateItemCommand()
18 | {
19 |
20 | }
21 |
22 | ///
23 | /// Returns true if the item is a separator.
24 | ///
25 | public bool IsSeparator
26 | {
27 | get
28 | {
29 | return _header.dwType == (uint)User32.MenuFlags.MFT_SEPARATOR
30 | || ((_header.bResInfo == 0xFFFF || _header.bResInfo == 0)
31 | && _header.dwMenuId == 0 && _menuString == null);
32 | }
33 | }
34 |
35 | ///
36 | /// String representation in the MENU format.
37 | ///
38 | /// Indent.
39 | /// String representation.
40 | public override string ToString(int indent)
41 | {
42 | StringBuilder sb = new StringBuilder();
43 | if (IsSeparator)
44 | {
45 | sb.AppendLine(string.Format("{0}MENUITEM SEPARATOR",
46 | new String(' ', indent)));
47 | }
48 | else
49 | {
50 | sb.AppendLine(string.Format("{0}MENUITEM \"{1}\", {2}",
51 | new String(' ', indent), _menuString == null
52 | ? string.Empty : _menuString.Replace("\t", @"\t"), _header.dwMenuId));
53 | }
54 | return sb.ToString();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ResourceLib/MenuExTemplateItemPopup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 | using System.Collections.Generic;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// An extended popup menu item.
11 | ///
12 | public class MenuExTemplateItemPopup : MenuExTemplateItem
13 | {
14 | private UInt32 _dwHelpId = 0;
15 | MenuExTemplateItemCollection _subMenuItems = new MenuExTemplateItemCollection();
16 |
17 | ///
18 | /// Sub menu items.
19 | ///
20 | public MenuExTemplateItemCollection SubMenuItems
21 | {
22 | get
23 | {
24 | return _subMenuItems;
25 | }
26 | set
27 | {
28 | _subMenuItems = value;
29 | }
30 | }
31 |
32 | ///
33 | /// An extended popup menu item.
34 | ///
35 | public MenuExTemplateItemPopup()
36 | {
37 |
38 | }
39 |
40 | ///
41 | /// Read an extended popup menu item.
42 | ///
43 | /// Address in memory.
44 | /// End of the menu item structure.
45 | internal override IntPtr Read(IntPtr lpRes)
46 | {
47 | lpRes = base.Read(lpRes);
48 |
49 | lpRes = ResourceUtil.Align(lpRes);
50 | _dwHelpId = (UInt32) Marshal.ReadInt32(lpRes);
51 | lpRes = new IntPtr(lpRes.ToInt64() + 4);
52 |
53 | return _subMenuItems.Read(lpRes);
54 | }
55 |
56 | ///
57 | /// Write the menu item to a binary stream.
58 | ///
59 | /// Binary stream.
60 | internal override void Write(BinaryWriter w)
61 | {
62 | base.Write(w);
63 | ResourceUtil.PadToDWORD(w);
64 | w.Write(_dwHelpId);
65 | _subMenuItems.Write(w);
66 | }
67 |
68 | ///
69 | /// String representation in the MENUEX format.
70 | ///
71 | /// String representation.
72 | public override string ToString(int indent)
73 | {
74 | StringBuilder sb = new StringBuilder();
75 | sb.AppendLine(string.Format("{0}POPUP \"{1}\"",
76 | new String(' ', indent),
77 | _menuString == null ? string.Empty : _menuString.Replace("\t", @"\t")));
78 | sb.Append(_subMenuItems.ToString(indent));
79 | return sb.ToString();
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/ResourceLib/MenuResource.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace Vestris.ResourceLib
7 | {
8 | ///
9 | /// A generic resource.
10 | ///
11 | public class MenuResource : Resource
12 | {
13 | private MenuTemplateBase _menu = null;
14 |
15 | ///
16 | /// Menu template.
17 | ///
18 | public MenuTemplateBase Menu
19 | {
20 | get
21 | {
22 | return _menu;
23 | }
24 | set
25 | {
26 | _menu = value;
27 | }
28 | }
29 |
30 | ///
31 | /// A structured menu resource.
32 | ///
33 | public MenuResource()
34 | : base(IntPtr.Zero,
35 | IntPtr.Zero,
36 | new ResourceId(Kernel32.ResourceTypes.RT_MENU),
37 | null,
38 | ResourceUtil.NEUTRALLANGID,
39 | 0)
40 | {
41 |
42 | }
43 |
44 | ///
45 | /// A structured menu resource embedded in an executable module.
46 | ///
47 | /// Module handle.
48 | /// Resource handle.
49 | /// Type of resource.
50 | /// Resource name.
51 | /// Language id.
52 | /// Resource size.
53 | public MenuResource(IntPtr hModule, IntPtr hResource, ResourceId type, ResourceId name, UInt16 language, int size)
54 | : base(hModule, hResource, type, name, language, size)
55 | {
56 |
57 | }
58 |
59 | ///
60 | /// Read a menu resource.
61 | ///
62 | /// Module handle.
63 | /// Pointer to the beginning of a resource.
64 | /// Pointer to the end of the resource.
65 | internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
66 | {
67 | UInt16 version = (UInt16) Marshal.ReadInt16(lpRes);
68 | switch (version)
69 | {
70 | case 0:
71 | _menu = new MenuTemplate();
72 | break;
73 | case 1:
74 | _menu = new MenuExTemplate();
75 | break;
76 | default:
77 | throw new NotSupportedException(string.Format(
78 | "Unexpected menu header version {0}", version));
79 | }
80 |
81 | return _menu.Read(lpRes);
82 | }
83 |
84 | ///
85 | /// Write the menu resource to a binary stream.
86 | ///
87 | /// Binary stream.
88 | internal override void Write(BinaryWriter w)
89 | {
90 | _menu.Write(w);
91 | }
92 |
93 | ///
94 | /// String representation of the menu resource in the MENU format.
95 | ///
96 | /// String representation of the menu resource.
97 | public override string ToString()
98 | {
99 | return string.Format("{0} {1}", Name, Menu.ToString());
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/ResourceLib/MenuTemplate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// Standard menu template.
11 | ///
12 | public class MenuTemplate : MenuTemplateBase
13 | {
14 | private User32.MENUTEMPLATE _header = new User32.MENUTEMPLATE();
15 | private MenuTemplateItemCollection _menuItems = new MenuTemplateItemCollection();
16 |
17 | ///
18 | /// Menu items.
19 | ///
20 | public MenuTemplateItemCollection MenuItems
21 | {
22 | get
23 | {
24 | return _menuItems;
25 | }
26 | set
27 | {
28 | _menuItems = value;
29 | }
30 | }
31 |
32 | ///
33 | /// Read the menu template.
34 | ///
35 | /// Address in memory.
36 | internal override IntPtr Read(IntPtr lpRes)
37 | {
38 | _header = (User32.MENUTEMPLATE) Marshal.PtrToStructure(
39 | lpRes, typeof(User32.MENUTEMPLATE));
40 |
41 | IntPtr lpMenuItem = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header) + _header.wOffset);
42 | return _menuItems.Read(lpMenuItem);
43 | }
44 |
45 | ///
46 | /// Write menu template to a binary stream.
47 | ///
48 | /// Binary stream.
49 | internal override void Write(BinaryWriter w)
50 | {
51 | w.Write(_header.wVersion);
52 | w.Write(_header.wOffset);
53 | ResourceUtil.Pad(w, _header.wOffset);
54 | _menuItems.Write(w);
55 | }
56 |
57 | ///
58 | /// String representation of the menu in the MENU format.
59 | ///
60 | /// String representation of the menu.
61 | public override string ToString()
62 | {
63 | StringBuilder sb = new StringBuilder();
64 | sb.AppendLine("MENU");
65 | sb.Append(_menuItems.ToString());
66 | return sb.ToString();
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/ResourceLib/MenuTemplateBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Vestris.ResourceLib
7 | {
8 | ///
9 | /// A menu template header.
10 | ///
11 | public abstract class MenuTemplateBase
12 | {
13 | ///
14 | /// Read the menu template header.
15 | ///
16 | /// Address in memory.
17 | internal abstract IntPtr Read(IntPtr lpRes);
18 |
19 | ///
20 | /// Write the menu to a binary stream.
21 | ///
22 | /// Binary stream.
23 | internal abstract void Write(BinaryWriter w);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ResourceLib/MenuTemplateItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// A base menu template item.
11 | ///
12 | public abstract class MenuTemplateItem
13 | {
14 | ///
15 | /// Menu item header.
16 | ///
17 | protected User32.MENUITEMTEMPLATE _header = new User32.MENUITEMTEMPLATE();
18 |
19 | ///
20 | /// Menu string.
21 | ///
22 | protected string _menuString = null;
23 |
24 | ///
25 | /// Menu text.
26 | ///
27 | public string MenuString
28 | {
29 | get
30 | {
31 | return _menuString;
32 | }
33 | set
34 | {
35 | _menuString = value;
36 | }
37 | }
38 |
39 | ///
40 | /// Read the menu item.
41 | ///
42 | /// Address in memory.
43 | /// End of the menu item structure.
44 | internal virtual IntPtr Read(IntPtr lpRes)
45 | {
46 | switch ((UInt16) Marshal.ReadInt16(lpRes))
47 | {
48 | case 0:
49 | lpRes = new IntPtr(lpRes.ToInt64() + 2);
50 | break;
51 | default:
52 | _menuString = Marshal.PtrToStringUni(lpRes);
53 | lpRes = new IntPtr(lpRes.ToInt64() +
54 | (_menuString.Length + 1) * Marshal.SystemDefaultCharSize);
55 | break;
56 | }
57 |
58 | return lpRes;
59 | }
60 |
61 | internal virtual void Write(BinaryWriter w)
62 | {
63 | // menu string
64 | if (_menuString == null)
65 | {
66 | w.Write((UInt16) 0);
67 | }
68 | else
69 | {
70 | w.Write(Encoding.Unicode.GetBytes(_menuString));
71 | w.Write((UInt16) 0);
72 | ResourceUtil.PadToWORD(w);
73 | }
74 | }
75 |
76 | ///
77 | /// String representation in the MENU format.
78 | ///
79 | /// Indent.
80 | /// String representation.
81 | public abstract string ToString(int indent);
82 |
83 | ///
84 | /// String representation in the MENU format.
85 | ///
86 | /// String representation.
87 | public override string ToString()
88 | {
89 | return ToString(0);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/ResourceLib/MenuTemplateItemCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// A collection of menu items.
11 | ///
12 | public class MenuTemplateItemCollection : List
13 | {
14 | ///
15 | /// A collection of menu items.
16 | ///
17 | public MenuTemplateItemCollection()
18 | {
19 |
20 | }
21 |
22 | ///
23 | /// Read the menu item collection.
24 | ///
25 | /// Address in memory.
26 | /// End of the menu item structure.
27 | internal IntPtr Read(IntPtr lpRes)
28 | {
29 | while(true)
30 | {
31 | User32.MENUITEMTEMPLATE childItem = (User32.MENUITEMTEMPLATE)Marshal.PtrToStructure(
32 | lpRes, typeof(User32.MENUITEMTEMPLATE));
33 |
34 | MenuTemplateItem childMenu = null;
35 | if ((childItem.mtOption & (uint)User32.MenuFlags.MF_POPUP) > 0)
36 | childMenu = new MenuTemplateItemPopup();
37 | else
38 | childMenu = new MenuTemplateItemCommand();
39 |
40 | lpRes = childMenu.Read(lpRes);
41 | Add(childMenu);
42 |
43 | if ((childItem.mtOption & (uint)User32.MenuFlags.MF_END) != 0)
44 | break;
45 | }
46 |
47 | return lpRes;
48 | }
49 |
50 | ///
51 | /// Write the menu collection to a binary stream.
52 | ///
53 | /// Binary stream.
54 | internal void Write(BinaryWriter w)
55 | {
56 | foreach (MenuTemplateItem menuItem in this)
57 | {
58 | menuItem.Write(w);
59 | }
60 | }
61 |
62 | ///
63 | /// String representation in the MENU format.
64 | ///
65 | /// String representation.
66 | public override string ToString()
67 | {
68 | return ToString(0);
69 | }
70 |
71 | ///
72 | /// String representation in the MENU format.
73 | ///
74 | /// Indent.
75 | /// String representation.
76 | public string ToString(int indent)
77 | {
78 | StringBuilder sb = new StringBuilder();
79 | if (Count > 0)
80 | {
81 | sb.AppendLine(string.Format("{0}BEGIN", new String(' ', indent)));
82 | foreach (MenuTemplateItem child in this)
83 | {
84 | sb.Append(child.ToString(indent + 1));
85 | }
86 | sb.AppendLine(string.Format("{0}END", new String(' ', indent)));
87 | }
88 | return sb.ToString();
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/ResourceLib/MenuTemplateItemCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// A command menu item.
11 | ///
12 | public class MenuTemplateItemCommand : MenuTemplateItem
13 | {
14 | private UInt16 _menuId = 0;
15 |
16 | ///
17 | /// Command menu id.
18 | ///
19 | public UInt16 MenuId
20 | {
21 | get
22 | {
23 | return _menuId;
24 | }
25 | set
26 | {
27 | _menuId = value;
28 | }
29 | }
30 |
31 | ///
32 | /// A command menu item.
33 | ///
34 | public MenuTemplateItemCommand()
35 | {
36 |
37 | }
38 |
39 | ///
40 | /// Read a command menu item.
41 | ///
42 | /// Address in memory.
43 | /// End of the menu item structure.
44 | internal override IntPtr Read(IntPtr lpRes)
45 | {
46 | _header = (User32.MENUITEMTEMPLATE)Marshal.PtrToStructure(
47 | lpRes, typeof(User32.MENUITEMTEMPLATE));
48 |
49 | lpRes = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header));
50 |
51 | _menuId = (UInt16) Marshal.ReadInt16(lpRes);
52 | lpRes = new IntPtr(lpRes.ToInt64() + 2);
53 |
54 | lpRes = base.Read(lpRes);
55 |
56 | return lpRes;
57 | }
58 |
59 | ///
60 | /// Write menu item to a binary stream.
61 | ///
62 | /// Binary stream.
63 | internal override void Write(BinaryWriter w)
64 | {
65 | w.Write(_header.mtOption);
66 | w.Write(_menuId);
67 | base.Write(w);
68 | }
69 |
70 | ///
71 | /// Returns true if the item is a separator.
72 | ///
73 | public bool IsSeparator
74 | {
75 | get
76 | {
77 | return ((_header.mtOption & (uint)User32.MenuFlags.MF_SEPARATOR) > 0) ||
78 | (_header.mtOption == 0 && _menuString == null && _menuId == 0);
79 | }
80 | }
81 |
82 | ///
83 | /// String representation in the MENU format.
84 | ///
85 | /// Indent.
86 | /// String representation.
87 | public override string ToString(int indent)
88 | {
89 | StringBuilder sb = new StringBuilder();
90 | if (IsSeparator)
91 | {
92 | sb.AppendLine(string.Format("{0}MENUITEM SEPARATOR",
93 | new String(' ', indent)));
94 | }
95 | else
96 | {
97 | sb.AppendLine(string.Format("{0}MENUITEM \"{1}\", {2}",
98 | new String(' ', indent),
99 | _menuString == null ? string.Empty : _menuString.Replace("\t", @"\t"), _menuId));
100 | }
101 | return sb.ToString();
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/ResourceLib/MenuTemplateItemPopup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 | using System.Collections.Generic;
5 | using System.Runtime.InteropServices;
6 |
7 | namespace Vestris.ResourceLib
8 | {
9 | ///
10 | /// A popup menu item.
11 | ///
12 | public class MenuTemplateItemPopup : MenuTemplateItem
13 | {
14 | MenuTemplateItemCollection _subMenuItems = new MenuTemplateItemCollection();
15 |
16 | ///
17 | /// Sub menu items.
18 | ///
19 | public MenuTemplateItemCollection SubMenuItems
20 | {
21 | get
22 | {
23 | return _subMenuItems;
24 | }
25 | set
26 | {
27 | _subMenuItems = value;
28 | }
29 | }
30 |
31 | ///
32 | /// A popup menu item.
33 | ///
34 | public MenuTemplateItemPopup()
35 | {
36 |
37 | }
38 |
39 | ///
40 | /// Read a popup menu item.
41 | ///
42 | /// Address in memory.
43 | /// End of the menu item structure.
44 | internal override IntPtr Read(IntPtr lpRes)
45 | {
46 | _header = (User32.MENUITEMTEMPLATE) Marshal.PtrToStructure(
47 | lpRes, typeof(User32.MENUITEMTEMPLATE));
48 |
49 | lpRes = new IntPtr(lpRes.ToInt64() + Marshal.SizeOf(_header));
50 | lpRes = base.Read(lpRes);
51 |
52 | return _subMenuItems.Read(lpRes);
53 | }
54 |
55 | ///
56 | /// Write menu item to a binary stream.
57 | ///
58 | /// Binary stream.
59 | internal override void Write(BinaryWriter w)
60 | {
61 | w.Write(_header.mtOption);
62 | base.Write(w);
63 | _subMenuItems.Write(w);
64 | }
65 |
66 | ///
67 | /// String representation in the MENU format.
68 | ///
69 | /// String representation.
70 | public override string ToString(int indent)
71 | {
72 | StringBuilder sb = new StringBuilder();
73 | sb.AppendLine(string.Format("{0}POPUP \"{1}\"",
74 | new String(' ', indent),
75 | _menuString == null ? string.Empty : _menuString.Replace("\t", @"\t")));
76 | sb.Append(_subMenuItems.ToString(indent));
77 | return sb.ToString();
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/ResourceLib/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("ResourceLib")]
6 | [assembly: Guid("7126e1f4-8620-484c-806e-7f4e51524709")]
7 |
--------------------------------------------------------------------------------
/ResourceLib/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Sevenzip/Sevenzip.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sevenzip", "Sevenzip\Sevenzip.csproj", "{233FA980-EF10-4BA7-8C4A-63F5D6D09925}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {233FA980-EF10-4BA7-8C4A-63F5D6D09925}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {233FA980-EF10-4BA7-8C4A-63F5D6D09925}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {233FA980-EF10-4BA7-8C4A-63F5D6D09925}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {233FA980-EF10-4BA7-8C4A-63F5D6D09925}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/Sevenzip/Sevenzip/CRC.cs:
--------------------------------------------------------------------------------
1 | // Common/CRC.cs
2 |
3 | namespace SevenZipLib
4 | {
5 | public class CRC
6 | {
7 | public static readonly uint[] Table;
8 |
9 | static CRC()
10 | {
11 | Table = new uint[256];
12 | const uint kPoly = 0xEDB88320;
13 | for (uint i = 0; i < 256; i++)
14 | {
15 | uint r = i;
16 | for (int j = 0; j < 8; j++)
17 | if ((r & 1) != 0)
18 | r = (r >> 1) ^ kPoly;
19 | else
20 | r >>= 1;
21 | Table[i] = r;
22 | }
23 | }
24 |
25 | uint _value = 0xFFFFFFFF;
26 |
27 | public void Init() { _value = 0xFFFFFFFF; }
28 |
29 | public void UpdateByte(byte b)
30 | {
31 | _value = Table[(((byte)(_value)) ^ b)] ^ (_value >> 8);
32 | }
33 |
34 | public void Update(byte[] data, uint offset, uint size)
35 | {
36 | for (uint i = 0; i < size; i++)
37 | _value = Table[(((byte)(_value)) ^ data[offset + i])] ^ (_value >> 8);
38 | }
39 |
40 | public uint GetDigest() { return _value ^ 0xFFFFFFFF; }
41 |
42 | static uint CalculateDigest(byte[] data, uint offset, uint size)
43 | {
44 | CRC crc = new CRC();
45 | // crc.Init();
46 | crc.Update(data, offset, size);
47 | return crc.GetDigest();
48 | }
49 |
50 | static bool VerifyDigest(uint digest, byte[] data, uint offset, uint size)
51 | {
52 | return (CalculateDigest(data, offset, size) == digest);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Sevenzip/Sevenzip/IMatchFinder.cs:
--------------------------------------------------------------------------------
1 | // IMatchFinder.cs
2 |
3 | using System;
4 |
5 | namespace SevenZipLib
6 | {
7 | interface IInWindowStream
8 | {
9 | void SetStream(System.IO.Stream inStream);
10 | void Init();
11 | void ReleaseStream();
12 | Byte GetIndexByte(Int32 index);
13 | UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit);
14 | UInt32 GetNumAvailableBytes();
15 | }
16 |
17 | interface IMatchFinder : IInWindowStream
18 | {
19 | void Create(UInt32 historySize, UInt32 keepAddBufferBefore,
20 | UInt32 matchMaxLen, UInt32 keepAddBufferAfter);
21 | UInt32 GetMatches(UInt32[] distances);
22 | void Skip(UInt32 num);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Sevenzip/Sevenzip/LzOutWindow.cs:
--------------------------------------------------------------------------------
1 | // LzOutWindow.cs
2 |
3 | namespace SevenZipLib
4 | {
5 | public class LZOutWindow
6 | {
7 | byte[] _buffer = null;
8 | uint _pos;
9 | uint _windowSize = 0;
10 | uint _streamPos;
11 | System.IO.Stream _stream;
12 |
13 | public void Create(uint windowSize)
14 | {
15 | if (_windowSize != windowSize)
16 | {
17 | // System.GC.Collect();
18 | _buffer = new byte[windowSize];
19 | }
20 | _windowSize = windowSize;
21 | _pos = 0;
22 | _streamPos = 0;
23 | }
24 |
25 | public void Init(System.IO.Stream stream, bool solid)
26 | {
27 | ReleaseStream();
28 | _stream = stream;
29 | if (!solid)
30 | {
31 | _streamPos = 0;
32 | _pos = 0;
33 | }
34 | }
35 |
36 | public void Init(System.IO.Stream stream) { Init(stream, false); }
37 |
38 | public void ReleaseStream()
39 | {
40 | Flush();
41 | _stream = null;
42 | }
43 |
44 | public void Flush()
45 | {
46 | uint size = _pos - _streamPos;
47 | if (size == 0)
48 | return;
49 | _stream.Write(_buffer, (int)_streamPos, (int)size);
50 | if (_pos >= _windowSize)
51 | _pos = 0;
52 | _streamPos = _pos;
53 | }
54 |
55 | public void CopyBlock(uint distance, uint len)
56 | {
57 | uint pos = _pos - distance - 1;
58 | if (pos >= _windowSize)
59 | pos += _windowSize;
60 | for (; len > 0; len--)
61 | {
62 | if (pos >= _windowSize)
63 | pos = 0;
64 | _buffer[_pos++] = _buffer[pos++];
65 | if (_pos >= _windowSize)
66 | Flush();
67 | }
68 | }
69 |
70 | public void PutByte(byte b)
71 | {
72 | _buffer[_pos++] = b;
73 | if (_pos >= _windowSize)
74 | Flush();
75 | }
76 |
77 | public byte GetByte(uint distance)
78 | {
79 | uint pos = _pos - distance - 1;
80 | if (pos >= _windowSize)
81 | pos += _windowSize;
82 | return _buffer[pos];
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/Sevenzip/Sevenzip/LzmaBase.cs:
--------------------------------------------------------------------------------
1 | // LzmaBase.cs
2 |
3 | namespace SevenZipLib
4 | {
5 | public class LZMABase
6 | {
7 | public const uint kNumRepDistances = 4;
8 | public const uint kNumStates = 12;
9 |
10 | // static byte []kLiteralNextStates = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5};
11 | // static byte []kMatchNextStates = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
12 | // static byte []kRepNextStates = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
13 | // static byte []kShortRepNextStates = {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
14 |
15 | public struct State
16 | {
17 | public uint Index;
18 | public void Init() { Index = 0; }
19 | public void UpdateChar()
20 | {
21 | if (Index < 4) Index = 0;
22 | else if (Index < 10) Index -= 3;
23 | else Index -= 6;
24 | }
25 | public void UpdateMatch() { Index = (uint)(Index < 7 ? 7 : 10); }
26 | public void UpdateRep() { Index = (uint)(Index < 7 ? 8 : 11); }
27 | public void UpdateShortRep() { Index = (uint)(Index < 7 ? 9 : 11); }
28 | public bool IsCharState() { return Index < 7; }
29 | }
30 |
31 | public const int kNumPosSlotBits = 6;
32 | public const int kDicLogSizeMin = 0;
33 | // public const int kDicLogSizeMax = 30;
34 | // public const uint kDistTableSizeMax = kDicLogSizeMax * 2;
35 |
36 | public const int kNumLenToPosStatesBits = 2; // it's for speed optimization
37 | public const uint kNumLenToPosStates = 1 << kNumLenToPosStatesBits;
38 |
39 | public const uint kMatchMinLen = 2;
40 |
41 | public static uint GetLenToPosState(uint len)
42 | {
43 | len -= kMatchMinLen;
44 | if (len < kNumLenToPosStates)
45 | return len;
46 | return (uint)(kNumLenToPosStates - 1);
47 | }
48 |
49 | public const int kNumAlignBits = 4;
50 | public const uint kAlignTableSize = 1 << kNumAlignBits;
51 | public const uint kAlignMask = (kAlignTableSize - 1);
52 |
53 | public const uint kStartPosModelIndex = 4;
54 | public const uint kEndPosModelIndex = 14;
55 | public const uint kNumPosModels = kEndPosModelIndex - kStartPosModelIndex;
56 |
57 | public const uint kNumFullDistances = 1 << ((int)kEndPosModelIndex / 2);
58 |
59 | public const uint kNumLitPosStatesBitsEncodingMax = 4;
60 | public const uint kNumLitContextBitsMax = 8;
61 |
62 | public const int kNumPosStatesBitsMax = 4;
63 | public const uint kNumPosStatesMax = (1 << kNumPosStatesBitsMax);
64 | public const int kNumPosStatesBitsEncodingMax = 4;
65 | public const uint kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax);
66 |
67 | public const int kNumLowLenBits = 3;
68 | public const int kNumMidLenBits = 3;
69 | public const int kNumHighLenBits = 8;
70 | public const uint kNumLowLenSymbols = 1 << kNumLowLenBits;
71 | public const uint kNumMidLenSymbols = 1 << kNumMidLenBits;
72 | public const uint kNumLenSymbols = kNumLowLenSymbols + kNumMidLenSymbols +
73 | (1 << kNumHighLenBits);
74 | public const uint kMatchMaxLen = kMatchMinLen + kNumLenSymbols - 1;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Sevenzip/Sevenzip/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Les informations générales relatives à un assembly dépendent de
6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7 | // associées à un assembly.
8 | [assembly: AssemblyTitle("Sevenzip")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Sevenzip")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type.
20 | [assembly: ComVisible(false)]
21 |
22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
23 | [assembly: Guid("4016e3e9-f9a7-4c8a-adbc-7d934ebe1d0e")]
24 |
25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes :
26 | //
27 | // Version principale
28 | // Version secondaire
29 | // Numéro de build
30 | // Révision
31 | //
32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
33 | // en utilisant '*', comme indiqué ci-dessous :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Sevenzip/Sevenzip/SevenZipHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 |
5 | namespace SevenZipLib
6 | {
7 | public static class SevenZipHelper
8 | {
9 |
10 | static int dictionary = 1 << 23;
11 |
12 | // static Int32 posStateBits = 2;
13 | // static Int32 litContextBits = 3; // for normal files
14 | // UInt32 litContextBits = 0; // for 32-bit data
15 | // static Int32 litPosBits = 0;
16 | // UInt32 litPosBits = 2; // for 32-bit data
17 | // static Int32 algorithm = 2;
18 | // static Int32 numFastBytes = 128;
19 |
20 | static bool eos = false;
21 |
22 |
23 |
24 |
25 |
26 | static CoderPropID[] propIDs =
27 | {
28 | CoderPropID.DictionarySize,
29 | CoderPropID.PosStateBits,
30 | CoderPropID.LitContextBits,
31 | CoderPropID.LitPosBits,
32 | CoderPropID.Algorithm,
33 | CoderPropID.NumFastBytes,
34 | CoderPropID.MatchFinder,
35 | CoderPropID.EndMarker
36 | };
37 |
38 | // these are the default properties, keeping it simple for now:
39 | static object[] properties =
40 | {
41 | (Int32)(dictionary),
42 | (Int32)(2),
43 | (Int32)(3),
44 | (Int32)(0),
45 | (Int32)(2),
46 | (Int32)(128),
47 | "bt4",
48 | eos
49 | };
50 |
51 |
52 | public static byte[] Compress(byte[] inputBytes)
53 | {
54 |
55 | MemoryStream inStream = new MemoryStream(inputBytes);
56 | MemoryStream outStream = new MemoryStream();
57 | LZMAEncoder encoder = new LZMAEncoder();
58 | encoder.SetCoderProperties(propIDs, properties);
59 | encoder.WriteCoderProperties(outStream);
60 | long fileSize = inStream.Length;
61 | for (int i = 0; i < 8; i++)
62 | outStream.WriteByte((Byte)(fileSize >> (8 * i)));
63 | encoder.Code(inStream, outStream, -1, -1, null);
64 | return outStream.ToArray();
65 | }
66 |
67 | //public static byte[] Decompress(byte[] inputBytes)
68 | //{
69 | // MemoryStream newInStream = new MemoryStream(inputBytes);
70 |
71 | // LZMADecoder decoder = new LZMADecoder();
72 |
73 | // newInStream.Seek(0, 0);
74 | // MemoryStream newOutStream = new MemoryStream();
75 |
76 | // byte[] properties2 = new byte[5];
77 | // if (newInStream.Read(properties2, 0, 5) != 5)
78 | // throw (new Exception("input .lzma is too short"));
79 | // long outSize = 0;
80 | // for (int i = 0; i < 8; i++)
81 | // {
82 | // int v = newInStream.ReadByte();
83 | // if (v < 0)
84 | // throw (new Exception("Can't Read 1"));
85 | // outSize |= ((long)(byte)v) << (8 * i);
86 | // }
87 | // decoder.SetDecoderProperties(properties2);
88 |
89 | // long compressedSize = newInStream.Length - newInStream.Position;
90 | // decoder.Code(newInStream, newOutStream, compressedSize, outSize, null);
91 |
92 | // byte[] b = newOutStream.ToArray();
93 |
94 | // return b;
95 |
96 |
97 |
98 | //}
99 |
100 |
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Sevenzip/Sevenzip/Sevenzip.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {233FA980-EF10-4BA7-8C4A-63F5D6D09925}
8 | Library
9 | Properties
10 | SevenzipLib
11 | SevenzipLib
12 | v4.0
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | Code
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
66 |
--------------------------------------------------------------------------------