Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.Framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘龙飞
VIZ.Framework
Commits
9b4bb25b
Commit
9b4bb25b
authored
Apr 07, 2023
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DLL 安全校验
parent
8a28afd4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
119 additions
and
0 deletions
+119
-0
VIZ.Framework.Core/Core/Safe/ApplicationDllCheckAttribute.cs
+20
-0
VIZ.Framework.Core/VIZ.Framework.Core.csproj
+1
-0
VIZ.Framework.Module/Setup/Provider/AppSetup_DllSafeBase.cs
+97
-0
VIZ.Framework.Module/VIZ.Framework.Module.csproj
+1
-0
No files found.
VIZ.Framework.Core/Core/Safe/ApplicationDllCheckAttribute.cs
0 → 100644
View file @
9b4bb25b
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// 应用程序DLL检测
/// </summary>
[
AttributeUsage
(
AttributeTargets
.
Assembly
,
Inherited
=
false
,
AllowMultiple
=
false
)]
public
class
ApplicationDllCheckAttribute
:
Attribute
{
/// <summary>
/// 键
/// </summary>
public
string
Key
{
get
;
set
;
}
}
}
VIZ.Framework.Core/VIZ.Framework.Core.csproj
View file @
9b4bb25b
...
@@ -133,6 +133,7 @@
...
@@ -133,6 +133,7 @@
<Compile Include="Core\Net\NetHelperMacInfo.cs" />
<Compile Include="Core\Net\NetHelperMacInfo.cs" />
<Compile Include="Core\Object\IObjectPoolManager.cs" />
<Compile Include="Core\Object\IObjectPoolManager.cs" />
<Compile Include="Core\Object\ObjectPoolManager.cs" />
<Compile Include="Core\Object\ObjectPoolManager.cs" />
<Compile Include="Core\Safe\ApplicationDllCheckAttribute.cs" />
<Compile Include="Core\Safe\ApplicationMacCheckAttribute.cs" />
<Compile Include="Core\Safe\ApplicationMacCheckAttribute.cs" />
<Compile Include="Core\Safe\ApplicationTimeCheckAttribute.cs" />
<Compile Include="Core\Safe\ApplicationTimeCheckAttribute.cs" />
<Compile Include="Core\Image\ImageHelperExpand.cs" />
<Compile Include="Core\Image\ImageHelperExpand.cs" />
...
...
VIZ.Framework.Module/Setup/Provider/AppSetup_DllSafeBase.cs
0 → 100644
View file @
9b4bb25b
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Management
;
using
VIZ.Framework.Core
;
using
VIZ.Framework.Connection
;
using
VIZ.Framework.Module
;
using
System.Reflection
;
namespace
VIZ.Framework.Module
{
/// <summary>
/// 应用程序启动 -- Dll安全
/// </summary>
public
abstract
class
AppSetup_DllSafeBase
:
AppSetupBase
{
/// <summary>
/// 日志
/// </summary>
private
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
AppSetup_DllSafeBase
));
/// <summary>
/// 描述
/// </summary>
public
override
string
Detail
{
get
;
}
=
"应用程序启动 -- Dll安全"
;
/// <summary>
/// 执行启动
/// </summary>
/// <param name="context">应用程序启动上下文</param>
/// <returns>是否成功执行</returns>
public
override
bool
Setup
(
AppSetupContext
context
)
{
// 入口
ApplicationDllCheckAttribute
entry_attribute
=
Assembly
.
GetEntryAssembly
().
GetCustomAttribute
<
ApplicationDllCheckAttribute
>();
if
(
entry_attribute
==
null
||
string
.
IsNullOrWhiteSpace
(
entry_attribute
.
Key
))
{
log
.
Error
(
"dll check error."
);
return
false
;
}
// 模块
ApplicationDllCheckAttribute
module_attribute
=
this
.
GetType
().
Assembly
.
GetCustomAttribute
<
ApplicationDllCheckAttribute
>();
if
(
module_attribute
==
null
||
string
.
IsNullOrWhiteSpace
(
module_attribute
.
Key
))
{
log
.
Error
(
"dll check error."
);
return
false
;
}
// 不匹配
if
(!
string
.
Equals
(
entry_attribute
.
Key
,
module_attribute
.
Key
))
{
log
.
Error
(
"dll check error."
);
return
false
;
}
return
true
;
}
/// <summary>
/// 执行关闭
/// </summary>
/// <param name="context">应用程序启动上下文</param>
public
override
void
Shutdown
(
AppSetupContext
context
)
{
}
/// <summary>
/// 获取所有用于MAC地址校验的值
/// </summary>
/// <returns>用于MAC地址校验的值</returns>
private
List
<
string
>
getAllMacAddressForCheck
()
{
List
<
string
>
list
=
new
List
<
string
>();
foreach
(
NetHelperMacInfo
info
in
NetHelper
.
GetAllMacAddressWithDefaultFilter
())
{
if
(!
string
.
IsNullOrWhiteSpace
(
info
.
PhysicalAddress
))
{
list
.
Add
(
info
.
PhysicalAddress
);
}
if
(!
string
.
IsNullOrWhiteSpace
(
info
.
DHCPv6ClientDUID
))
{
list
.
Add
(
info
.
DHCPv6ClientDUID
);
}
}
return
list
;
}
}
}
VIZ.Framework.Module/VIZ.Framework.Module.csproj
View file @
9b4bb25b
...
@@ -102,6 +102,7 @@
...
@@ -102,6 +102,7 @@
<Compile Include="Setup\AppSetupContext.cs" />
<Compile Include="Setup\AppSetupContext.cs" />
<Compile Include="Setup\IAppSetup.cs" />
<Compile Include="Setup\IAppSetup.cs" />
<Compile Include="Setup\Message\AppShutDownMessage.cs" />
<Compile Include="Setup\Message\AppShutDownMessage.cs" />
<Compile Include="Setup\Provider\AppSetup_DllSafeBase.cs" />
<Compile Include="Setup\Provider\Setup\AppSetup_TimerInit.cs" />
<Compile Include="Setup\Provider\Setup\AppSetup_TimerInit.cs" />
<Compile Include="Setup\Provider\Setup\AppSetup_ObjectPool.cs" />
<Compile Include="Setup\Provider\Setup\AppSetup_ObjectPool.cs" />
<Compile Include="Setup\Provider\Setup\AppSetup_ApplicationSafe.cs" />
<Compile Include="Setup\Provider\Setup\AppSetup_ApplicationSafe.cs" />
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment