├── .gitattributes
├── .gitignore
├── BinTest_x64
├── ComForHook.dll
├── DotNetDetour.dll
├── Hook.dll
├── HookMain.exe
├── Inject.dll
├── Target.exe
├── copy.bat
├── monitors
│ └── CustomMonitor.dll
└── shellcode.bin
├── ComForHook
├── ComForHook.csproj
├── Hook.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── CustomMonitor
├── CustomMonitor.cs
├── CustomMonitor.csproj
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── DotNetInjector.sln
├── Hook
├── Hook.vcxproj
├── Hook.vcxproj.filters
├── hook.cpp
└── hook.h
├── HookMain
├── App.config
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── HookMain.csproj
├── Program.cs
└── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Inject
├── Inject.vcxproj
├── Inject.vcxproj.filters
├── inject.cpp
└── inject.h
├── README.md
├── ShellCode
├── ShellCode.vcxproj
├── ShellCode.vcxproj.filters
├── code.asm
├── main.cpp
├── shellcode.bin
└── shellcode.h
└── Target
├── App.config
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
└── Target.csproj
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | # DNX
42 | project.lock.json
43 | artifacts/
44 |
45 | *_i.c
46 | *_p.c
47 | *_i.h
48 | *.ilk
49 | *.meta
50 | *.obj
51 | *.pch
52 | *.pdb
53 | *.pgc
54 | *.pgd
55 | *.rsp
56 | *.sbr
57 | *.tlb
58 | *.tli
59 | *.tlh
60 | *.tmp
61 | *.tmp_proj
62 | *.log
63 | *.vspscc
64 | *.vssscc
65 | .builds
66 | *.pidb
67 | *.svclog
68 | *.scc
69 |
70 | # Chutzpah Test files
71 | _Chutzpah*
72 |
73 | # Visual C++ cache files
74 | ipch/
75 | *.aps
76 | *.ncb
77 | *.opensdf
78 | *.sdf
79 | *.cachefile
80 |
81 | # Visual Studio profiler
82 | *.psess
83 | *.vsp
84 | *.vspx
85 |
86 | # TFS 2012 Local Workspace
87 | $tf/
88 |
89 | # Guidance Automation Toolkit
90 | *.gpState
91 |
92 | # ReSharper is a .NET coding add-in
93 | _ReSharper*/
94 | *.[Rr]e[Ss]harper
95 | *.DotSettings.user
96 |
97 | # JustCode is a .NET coding add-in
98 | .JustCode
99 |
100 | # TeamCity is a build add-in
101 | _TeamCity*
102 |
103 | # DotCover is a Code Coverage Tool
104 | *.dotCover
105 |
106 | # NCrunch
107 | _NCrunch_*
108 | .*crunch*.local.xml
109 |
110 | # MightyMoose
111 | *.mm.*
112 | AutoTest.Net/
113 |
114 | # Web workbench (sass)
115 | .sass-cache/
116 |
117 | # Installshield output folder
118 | [Ee]xpress/
119 |
120 | # DocProject is a documentation generator add-in
121 | DocProject/buildhelp/
122 | DocProject/Help/*.HxT
123 | DocProject/Help/*.HxC
124 | DocProject/Help/*.hhc
125 | DocProject/Help/*.hhk
126 | DocProject/Help/*.hhp
127 | DocProject/Help/Html2
128 | DocProject/Help/html
129 |
130 | # Click-Once directory
131 | publish/
132 |
133 | # Publish Web Output
134 | *.[Pp]ublish.xml
135 | *.azurePubxml
136 | ## TODO: Comment the next line if you want to checkin your
137 | ## web deploy settings but do note that will include unencrypted
138 | ## passwords
139 | #*.pubxml
140 |
141 | *.publishproj
142 |
143 | # NuGet Packages
144 | *.nupkg
145 | # The packages folder can be ignored because of Package Restore
146 | **/packages/*
147 | # except build/, which is used as an MSBuild target.
148 | !**/packages/build/
149 | # Uncomment if necessary however generally it will be regenerated when needed
150 | #!**/packages/repositories.config
151 |
152 | # Windows Azure Build Output
153 | csx/
154 | *.build.csdef
155 |
156 | # Windows Store app package directory
157 | AppPackages/
158 |
159 | # Visual Studio cache files
160 | # files ending in .cache can be ignored
161 | *.[Cc]ache
162 | # but keep track of directories ending in .cache
163 | !*.[Cc]ache/
164 |
165 | # Others
166 | ClientBin/
167 | [Ss]tyle[Cc]op.*
168 | ~$*
169 | *~
170 | *.dbmdl
171 | *.dbproj.schemaview
172 | *.pfx
173 | *.publishsettings
174 | node_modules/
175 | orleans.codegen.cs
176 |
177 | # RIA/Silverlight projects
178 | Generated_Code/
179 |
180 | # Backup & report files from converting an old project file
181 | # to a newer Visual Studio version. Backup files are not needed,
182 | # because we have git ;-)
183 | _UpgradeReport_Files/
184 | Backup*/
185 | UpgradeLog*.XML
186 | UpgradeLog*.htm
187 |
188 | # SQL Server files
189 | *.mdf
190 | *.ldf
191 |
192 | # Business Intelligence projects
193 | *.rdl.data
194 | *.bim.layout
195 | *.bim_*.settings
196 |
197 | # Microsoft Fakes
198 | FakesAssemblies/
199 |
200 | # Node.js Tools for Visual Studio
201 | .ntvs_analysis.dat
202 |
203 | # Visual Studio 6 build log
204 | *.plg
205 |
206 | # Visual Studio 6 workspace options file
207 | *.opt
208 |
209 | # LightSwitch generated files
210 | GeneratedArtifacts/
211 | _Pvt_Extensions/
212 | ModelManifest.xml
213 | /DotNetInjector.VC.VC.opendb
214 | /DotNetInjector.VC.db
215 |
--------------------------------------------------------------------------------
/BinTest_x64/ComForHook.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/BinTest_x64/ComForHook.dll
--------------------------------------------------------------------------------
/BinTest_x64/DotNetDetour.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/BinTest_x64/DotNetDetour.dll
--------------------------------------------------------------------------------
/BinTest_x64/Hook.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/BinTest_x64/Hook.dll
--------------------------------------------------------------------------------
/BinTest_x64/HookMain.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/BinTest_x64/HookMain.exe
--------------------------------------------------------------------------------
/BinTest_x64/Inject.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/BinTest_x64/Inject.dll
--------------------------------------------------------------------------------
/BinTest_x64/Target.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/BinTest_x64/Target.exe
--------------------------------------------------------------------------------
/BinTest_x64/copy.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | copy ..\ComForHook\bin\Release\ComForHook.dll
3 | copy ..\DotNetDetour\bin\Release\DotNetDetour.dll
4 | copy ..\x64\Release\Hook.dll
5 | copy ..\x64\Release\shellcode.bin
6 | copy ..\x64\Release\Inject.dll
7 | copy ..\Target\bin\Release\Target.exe
8 | copy ..\HookMain\bin\Release\HookMain.exe
9 | copy ..\CustomMonitor\bin\Release\CustomMonitor.dll monitors\
--------------------------------------------------------------------------------
/BinTest_x64/monitors/CustomMonitor.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/BinTest_x64/monitors/CustomMonitor.dll
--------------------------------------------------------------------------------
/BinTest_x64/shellcode.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/BinTest_x64/shellcode.bin
--------------------------------------------------------------------------------
/ComForHook/ComForHook.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}
8 | Library
9 | Properties
10 | ComForHook
11 | ComForHook
12 | v4.6
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 | x64
34 |
35 |
36 |
37 | ..\packages\DotNetDetour.1.0.3.0\lib\net45\DotNetDetour.dll
38 | True
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
64 |
--------------------------------------------------------------------------------
/ComForHook/Hook.cs:
--------------------------------------------------------------------------------
1 | using DotNetDetour;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Reflection;
6 | using System.Runtime.InteropServices;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.IO;
10 |
11 | namespace ComForHook
12 | {
13 | [Guid("00C74C42-D58C-40E9-B09F-B09D129A4057")]
14 | public interface IHook
15 | {
16 | void Apply();
17 | }
18 |
19 | [Guid("56C2BC3F-942F-4967-BFD2-D5E07281DB49")]
20 | public class Hook : IHook
21 | {
22 | public void Apply()
23 | {
24 | Monitor.Install("monitors");
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ComForHook/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ComForHook")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ComForHook")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(true)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("dc9d8338-c2c5-45d3-b0af-f05219dd2639")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ComForHook/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/CustomMonitor/CustomMonitor.cs:
--------------------------------------------------------------------------------
1 | using DotNetDetour;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Runtime.CompilerServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace CustomMonitor
10 | {
11 | public class CustomMonitor:IMethodMonitor
12 | {
13 | [Monitor("Target","TargetClass")]
14 | public string Get()
15 | {
16 | return "竟然被hook了";
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/CustomMonitor/CustomMonitor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}
8 | Library
9 | Properties
10 | CustomMonitor
11 | CustomMonitor
12 | v4.6
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 | ..\packages\DotNetDetour.1.0.3.0\lib\net45\DotNetDetour.dll
35 | True
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
61 |
--------------------------------------------------------------------------------
/CustomMonitor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CustomMonitor")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CustomMonitor")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("855267d1-7e36-4dee-9b3f-7bf19553ba3c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/CustomMonitor/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/DotNetInjector.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hook", "Hook\Hook.vcxproj", "{00BA4F88-EEEC-4986-83EF-FE60BAA17504}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639} = {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}
9 | EndProjectSection
10 | EndProject
11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Inject", "Inject\Inject.vcxproj", "{FD2ECC74-A52D-4348-9A7A-6A402E355CF7}"
12 | EndProject
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HookMain", "HookMain\HookMain.csproj", "{F6C02642-5C3F-42B0-B43D-AED7917BD58F}"
14 | EndProject
15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ShellCode", "ShellCode\ShellCode.vcxproj", "{30A61740-06F1-459D-B4AD-9A7D267DA3C0}"
16 | EndProject
17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComForHook", "ComForHook\ComForHook.csproj", "{DC9D8338-C2C5-45D3-B0AF-F05219DD2639}"
18 | EndProject
19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Target", "Target\Target.csproj", "{BC04117C-8D0D-4633-9747-917AC4964BB8}"
20 | EndProject
21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomMonitor", "CustomMonitor\CustomMonitor.csproj", "{855267D1-7E36-4DEE-9B3F-7BF19553BA3C}"
22 | EndProject
23 | Global
24 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
25 | Debug|Any CPU = Debug|Any CPU
26 | Debug|x64 = Debug|x64
27 | Debug|x86 = Debug|x86
28 | Release|Any CPU = Release|Any CPU
29 | Release|x64 = Release|x64
30 | Release|x86 = Release|x86
31 | EndGlobalSection
32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
33 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Debug|Any CPU.ActiveCfg = Debug|Win32
34 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Debug|x64.ActiveCfg = Debug|x64
35 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Debug|x64.Build.0 = Debug|x64
36 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Debug|x86.ActiveCfg = Debug|Win32
37 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Debug|x86.Build.0 = Debug|Win32
38 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Release|Any CPU.ActiveCfg = Release|Win32
39 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Release|x64.ActiveCfg = Release|x64
40 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Release|x64.Build.0 = Release|x64
41 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Release|x86.ActiveCfg = Release|Win32
42 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}.Release|x86.Build.0 = Release|Win32
43 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Debug|Any CPU.ActiveCfg = Debug|Win32
44 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Debug|x64.ActiveCfg = Debug|x64
45 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Debug|x64.Build.0 = Debug|x64
46 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Debug|x86.ActiveCfg = Debug|Win32
47 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Debug|x86.Build.0 = Debug|Win32
48 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Release|Any CPU.ActiveCfg = Release|Win32
49 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Release|x64.ActiveCfg = Release|x64
50 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Release|x64.Build.0 = Release|x64
51 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Release|x86.ActiveCfg = Release|Win32
52 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}.Release|x86.Build.0 = Release|Win32
53 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Debug|Any CPU.Build.0 = Debug|Any CPU
55 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Debug|x64.ActiveCfg = Debug|Any CPU
56 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Debug|x64.Build.0 = Debug|Any CPU
57 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Debug|x86.ActiveCfg = Debug|Any CPU
58 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Debug|x86.Build.0 = Debug|Any CPU
59 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Release|Any CPU.ActiveCfg = Release|Any CPU
60 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Release|Any CPU.Build.0 = Release|Any CPU
61 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Release|x64.ActiveCfg = Release|Any CPU
62 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Release|x64.Build.0 = Release|Any CPU
63 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Release|x86.ActiveCfg = Release|Any CPU
64 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}.Release|x86.Build.0 = Release|Any CPU
65 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Debug|Any CPU.ActiveCfg = Debug|Win32
66 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Debug|x64.ActiveCfg = Debug|x64
67 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Debug|x64.Build.0 = Debug|x64
68 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Debug|x86.ActiveCfg = Debug|Win32
69 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Debug|x86.Build.0 = Debug|Win32
70 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Release|Any CPU.ActiveCfg = Release|Win32
71 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Release|x64.ActiveCfg = Release|x64
72 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Release|x64.Build.0 = Release|x64
73 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Release|x86.ActiveCfg = Release|Win32
74 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}.Release|x86.Build.0 = Release|Win32
75 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Debug|Any CPU.Build.0 = Debug|Any CPU
77 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Debug|x64.ActiveCfg = Debug|Any CPU
78 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Debug|x64.Build.0 = Debug|Any CPU
79 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Debug|x86.ActiveCfg = Debug|Any CPU
80 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Debug|x86.Build.0 = Debug|Any CPU
81 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Release|Any CPU.ActiveCfg = Release|Any CPU
82 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Release|Any CPU.Build.0 = Release|Any CPU
83 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Release|x64.ActiveCfg = Release|Any CPU
84 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Release|x64.Build.0 = Release|Any CPU
85 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Release|x86.ActiveCfg = Release|Any CPU
86 | {DC9D8338-C2C5-45D3-B0AF-F05219DD2639}.Release|x86.Build.0 = Release|Any CPU
87 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
88 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
89 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Debug|x64.ActiveCfg = Debug|Any CPU
90 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Debug|x64.Build.0 = Debug|Any CPU
91 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Debug|x86.ActiveCfg = Debug|Any CPU
92 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Debug|x86.Build.0 = Debug|Any CPU
93 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
94 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Release|Any CPU.Build.0 = Release|Any CPU
95 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Release|x64.ActiveCfg = Release|Any CPU
96 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Release|x64.Build.0 = Release|Any CPU
97 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Release|x86.ActiveCfg = Release|Any CPU
98 | {BC04117C-8D0D-4633-9747-917AC4964BB8}.Release|x86.Build.0 = Release|Any CPU
99 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
100 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
101 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Debug|x64.ActiveCfg = Debug|Any CPU
102 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Debug|x64.Build.0 = Debug|Any CPU
103 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Debug|x86.ActiveCfg = Debug|Any CPU
104 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Debug|x86.Build.0 = Debug|Any CPU
105 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
106 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Release|Any CPU.Build.0 = Release|Any CPU
107 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Release|x64.ActiveCfg = Release|Any CPU
108 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Release|x64.Build.0 = Release|Any CPU
109 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Release|x86.ActiveCfg = Release|Any CPU
110 | {855267D1-7E36-4DEE-9B3F-7BF19553BA3C}.Release|x86.Build.0 = Release|Any CPU
111 | EndGlobalSection
112 | GlobalSection(SolutionProperties) = preSolution
113 | HideSolutionNode = FALSE
114 | EndGlobalSection
115 | EndGlobal
116 |
--------------------------------------------------------------------------------
/Hook/Hook.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {00BA4F88-EEEC-4986-83EF-FE60BAA17504}
23 | Win32Proj
24 | Hook
25 | 8.1
26 | Hook
27 |
28 |
29 |
30 | DynamicLibrary
31 | true
32 | v140
33 | Unicode
34 |
35 |
36 | DynamicLibrary
37 | false
38 | v140
39 | true
40 | Unicode
41 |
42 |
43 | DynamicLibrary
44 | true
45 | v140
46 | Unicode
47 |
48 |
49 | DynamicLibrary
50 | false
51 | v140
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | true
78 |
79 |
80 | false
81 |
82 |
83 | false
84 |
85 |
86 |
87 |
88 |
89 | Level3
90 | Disabled
91 | WIN32;_DEBUG;_WINDOWS;_USRDLL;HOOK_EXPORTS;%(PreprocessorDefinitions)
92 | MultiThreaded
93 |
94 |
95 | Windows
96 | true
97 |
98 |
99 |
100 |
101 |
102 |
103 | Level3
104 | Disabled
105 | _DEBUG;_WINDOWS;_USRDLL;HOOK_EXPORTS;%(PreprocessorDefinitions)
106 |
107 |
108 | Windows
109 | true
110 |
111 |
112 |
113 |
114 | Level3
115 |
116 |
117 | MaxSpeed
118 | true
119 | true
120 | WIN32;NDEBUG;_WINDOWS;_USRDLL;HOOK_EXPORTS;%(PreprocessorDefinitions)
121 |
122 |
123 | Windows
124 | true
125 | true
126 | true
127 |
128 |
129 |
130 |
131 | Level3
132 |
133 |
134 | MaxSpeed
135 | true
136 | true
137 | NDEBUG;_WINDOWS;_USRDLL;HOOK_EXPORTS;%(PreprocessorDefinitions)
138 | MultiThreaded
139 |
140 |
141 | Windows
142 | true
143 | true
144 | true
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
--------------------------------------------------------------------------------
/Hook/Hook.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Hook/hook.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/Hook/hook.cpp
--------------------------------------------------------------------------------
/Hook/hook.h:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/HookMain/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HookMain/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace HookMain
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.button1 = new System.Windows.Forms.Button();
32 | this.SuspendLayout();
33 | //
34 | // button1
35 | //
36 | this.button1.Location = new System.Drawing.Point(82, 119);
37 | this.button1.Name = "button1";
38 | this.button1.Size = new System.Drawing.Size(109, 45);
39 | this.button1.TabIndex = 0;
40 | this.button1.Text = "注入";
41 | this.button1.UseVisualStyleBackColor = true;
42 | this.button1.Click += new System.EventHandler(this.button1_Click);
43 | //
44 | // Form1
45 | //
46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
48 | this.ClientSize = new System.Drawing.Size(284, 262);
49 | this.Controls.Add(this.button1);
50 | this.Name = "Form1";
51 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
52 | this.Text = "Form1";
53 | this.ResumeLayout(false);
54 |
55 | }
56 |
57 | #endregion
58 |
59 | private System.Windows.Forms.Button button1;
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/HookMain/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Diagnostics;
6 | using System.Drawing;
7 | using System.Linq;
8 | using System.Runtime.InteropServices;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 | using System.Windows.Forms;
12 |
13 | namespace HookMain
14 | {
15 | public partial class Form1 : Form
16 | {
17 | public Form1()
18 | {
19 | InitializeComponent();
20 | }
21 |
22 | [DllImport("Inject", CallingConvention = CallingConvention.Cdecl)]
23 | static extern bool Inject(uint pid);
24 |
25 | private void button1_Click(object sender, EventArgs e)
26 | {
27 | Inject((uint)Process.GetProcessesByName("Target").First().Id);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/HookMain/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/HookMain/HookMain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F6C02642-5C3F-42B0-B43D-AED7917BD58F}
8 | WinExe
9 | Properties
10 | HookMain
11 | HookMain
12 | v4.6
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | x64
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Form
51 |
52 |
53 | Form1.cs
54 |
55 |
56 |
57 |
58 | Form1.cs
59 |
60 |
61 | ResXFileCodeGenerator
62 | Resources.Designer.cs
63 | Designer
64 |
65 |
66 | True
67 | Resources.resx
68 |
69 |
70 | SettingsSingleFileGenerator
71 | Settings.Designer.cs
72 |
73 |
74 | True
75 | Settings.settings
76 | True
77 |
78 |
79 |
80 |
81 |
82 |
83 |
90 |
--------------------------------------------------------------------------------
/HookMain/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace HookMain
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/HookMain/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("HookMain")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("HookMain")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f6c02642-5c3f-42b0-b43d-aed7917bd58f")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/HookMain/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace HookMain.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HookMain.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/HookMain/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/HookMain/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace HookMain.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/HookMain/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Inject/Inject.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {FD2ECC74-A52D-4348-9A7A-6A402E355CF7}
23 | Win32Proj
24 | Inject
25 | 8.1
26 |
27 |
28 |
29 | DynamicLibrary
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | DynamicLibrary
36 | false
37 | v140
38 | true
39 | Unicode
40 |
41 |
42 | DynamicLibrary
43 | true
44 | v140
45 | Unicode
46 |
47 |
48 | DynamicLibrary
49 | false
50 | v140
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | true
74 |
75 |
76 | true
77 |
78 |
79 | false
80 |
81 |
82 | false
83 |
84 |
85 |
86 |
87 |
88 | Level3
89 | Disabled
90 | WIN32;_DEBUG;_WINDOWS;_USRDLL;INJECT_EXPORTS;%(PreprocessorDefinitions)
91 |
92 |
93 | Windows
94 | true
95 |
96 |
97 |
98 |
99 |
100 |
101 | Level3
102 | Disabled
103 | _DEBUG;_WINDOWS;_USRDLL;INJECT_EXPORTS;%(PreprocessorDefinitions)
104 |
105 |
106 | Windows
107 | true
108 |
109 |
110 |
111 |
112 | Level3
113 |
114 |
115 | MaxSpeed
116 | true
117 | true
118 | WIN32;NDEBUG;_WINDOWS;_USRDLL;INJECT_EXPORTS;%(PreprocessorDefinitions)
119 |
120 |
121 | Windows
122 | true
123 | true
124 | true
125 |
126 |
127 |
128 |
129 | Level3
130 |
131 |
132 | MaxSpeed
133 | true
134 | true
135 | NDEBUG;_WINDOWS;_USRDLL;INJECT_EXPORTS;%(PreprocessorDefinitions)
136 | MultiThreaded
137 |
138 |
139 | Windows
140 | true
141 | true
142 | true
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/Inject/Inject.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 | Header Files
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Inject/inject.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/Inject/inject.cpp
--------------------------------------------------------------------------------
/Inject/inject.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #define DLLExport EXTERN_C __declspec(dllexport)
4 |
5 | DLLExport bool Inject(DWORD pid);
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## DotNetInjector
2 | DotNetInjector是一个用于.net程序dll注入的类库
3 |
4 | ##使用示例
5 | 1. 进入BinTest_x64,这里有我编译后的完整测试文件
6 | 2. 运行Target.exe并点击【Call】,提示“想hook我没戏!”
7 | 3. 运行HookMain.exe,点击【注入】
8 | 4. 再点击【Call】按钮,提示"竟然被hook了"
9 |
--------------------------------------------------------------------------------
/ShellCode/ShellCode.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {30A61740-06F1-459D-B4AD-9A7D267DA3C0}
23 | Win32Proj
24 | ShellCode
25 | 8.1
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v140
45 | Unicode
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | true
78 |
79 |
80 | false
81 |
82 |
83 | false
84 |
85 |
86 |
87 |
88 |
89 | Level3
90 | Disabled
91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
92 |
93 |
94 | Console
95 | true
96 |
97 |
98 |
99 |
100 |
101 |
102 | Level3
103 | Disabled
104 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
105 |
106 |
107 | Console
108 | true
109 |
110 |
111 |
112 |
113 | Level3
114 |
115 |
116 | Disabled
117 | true
118 | true
119 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
120 | false
121 |
122 |
123 | Console
124 | true
125 | true
126 | true
127 |
128 |
129 |
130 |
131 | Level3
132 |
133 |
134 | Disabled
135 | true
136 | true
137 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
138 | false
139 |
140 |
141 | Console
142 | true
143 | true
144 | true
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/ShellCode/ShellCode.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ShellCode/code.asm:
--------------------------------------------------------------------------------
1 | .data
2 | .code
3 | PUBLIC get_peb
4 | get_peb PROC
5 | mov rax,qword ptr gs:[60h]
6 | ret
7 | get_peb ENDP
8 | END
--------------------------------------------------------------------------------
/ShellCode/main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/ShellCode/main.cpp
--------------------------------------------------------------------------------
/ShellCode/shellcode.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bigbaldy1128/DotNetInjector/0e21f85ef63051ed910329fad21424cee44f044b/ShellCode/shellcode.bin
--------------------------------------------------------------------------------
/ShellCode/shellcode.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | DWORD __stdcall unicode_ror13_hash(const WCHAR *unicode_string);
4 | DWORD __stdcall ror13_hash(const char *string);
5 | PPEB __declspec(naked) get_peb(void);
6 | HMODULE __stdcall find_kernel32(void);
7 | HMODULE __stdcall find_module_by_hash(DWORD hash)
--------------------------------------------------------------------------------
/Target/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Target/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Target
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.button1 = new System.Windows.Forms.Button();
32 | this.SuspendLayout();
33 | //
34 | // button1
35 | //
36 | this.button1.Location = new System.Drawing.Point(82, 102);
37 | this.button1.Name = "button1";
38 | this.button1.Size = new System.Drawing.Size(111, 67);
39 | this.button1.TabIndex = 0;
40 | this.button1.Text = "Call";
41 | this.button1.UseVisualStyleBackColor = true;
42 | this.button1.Click += new System.EventHandler(this.button1_Click);
43 | //
44 | // Form1
45 | //
46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
48 | this.ClientSize = new System.Drawing.Size(284, 262);
49 | this.Controls.Add(this.button1);
50 | this.Name = "Form1";
51 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
52 | this.Text = "Form1";
53 | this.ResumeLayout(false);
54 |
55 | }
56 |
57 | #endregion
58 |
59 | private System.Windows.Forms.Button button1;
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/Target/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Reflection;
8 | using System.Runtime.CompilerServices;
9 | using System.Runtime.InteropServices;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 | using System.Windows.Forms;
13 |
14 | namespace Target
15 | {
16 | public class TargetClass
17 | {
18 | [MethodImpl(MethodImplOptions.NoInlining)]
19 | public string Get()
20 | {
21 | return "想hook我没戏!";
22 | }
23 | }
24 |
25 | public partial class Form1 : Form
26 | {
27 | public Form1()
28 | {
29 | InitializeComponent();
30 | }
31 |
32 | private void button1_Click(object sender, EventArgs e)
33 | {
34 | MessageBox.Show(new TargetClass().Get());
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Target/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Target/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace Target
5 | {
6 | static class Program
7 | {
8 | ///
9 | /// The main entry point for the application.
10 | ///
11 | [STAThread]
12 | static void Main()
13 | {
14 | Application.EnableVisualStyles();
15 | Application.SetCompatibleTextRenderingDefault(false);
16 | Application.Run(new Form1());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Target/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Target")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Target")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("bc04117c-8d0d-4633-9747-917ac4964bb8")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Target/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Target.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Target.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Target/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Target/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Target.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Target/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Target/Target.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {BC04117C-8D0D-4633-9747-917AC4964BB8}
8 | WinExe
9 | Properties
10 | Target
11 | Target
12 | v4.6
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | false
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | Form
53 |
54 |
55 | Form1.cs
56 |
57 |
58 |
59 |
60 | Form1.cs
61 |
62 |
63 | ResXFileCodeGenerator
64 | Resources.Designer.cs
65 | Designer
66 |
67 |
68 | True
69 | Resources.resx
70 |
71 |
72 | SettingsSingleFileGenerator
73 | Settings.Designer.cs
74 |
75 |
76 | True
77 | Settings.settings
78 | True
79 |
80 |
81 |
82 |
83 |
84 |
85 |
92 |
--------------------------------------------------------------------------------