惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - 紫雨轩 .Net

DNGuard Enterprise v3.56 released DNGuard Enterprise v3.30 released ComboBox 使用数据绑定时 Sorted 属性的bug DNGuard Enterprise v3.2 released DNGuard 企业版 v3.1 发布 DNGuard 专业版 v2.95 发布 DNGuard Enterprise v2.95 released 在 FlexGrid 控件中指定最右侧显示的列 .Net 中枚举AppDomains Windows 2003 上使用 Windows Live Writer .Net程序集的不同加载方式,以及其在内存中格式 DNGuard Enterprise v2.92 released - 紫雨轩 .Net DNGuard 标准版 v2.90发布 DNGuard Enterprise v2.90 released DNGuard Enterprise v2.82 released 采用Native 引导方式的.Net加密保护 C#中使用晚绑定实现压缩Access数据库 C#复杂表达式的问题 DNGuard HVM Trial V2.82 发布
直接在.Net程序(C#)中执行 native code
紫雨轩 .Net · 2008-01-22 · via 博客园 - 紫雨轩 .Net

不使用C++CLI,不使用 native dll.
直接在 .Net 程序 中之行 native code。

在vb时代就曾经有不少好事者做过在vb中直接调用之行汇编代码。
还专门做出了通用的模块来进行汇编代码的动态生成。

实际上这就是执行 inline asm 。

.Net 中这个老方法仍然有效。不过今天要介绍的不是这个,而是一个函数接口更多样的方式。

大概是06年写过一个帖子 在 C# 中动态调用 native dll 的导出函数  。

今天介绍的方法和这个有一个公共点,都是利用了.Net 2.0的一个新特性。

Marshal.GetDelegateForFunctionPointer

和动态调用api不一样的是,函数指针不是从外部 dll 获取的,而是.Net程序动态分配的。
实际上也是执行  inline asm。

它相比vb时代的老方法,优点是,函数原型可以多样化,
调用可以通过委托方式,参数中的.Net类型到本地类型由框架自动转换。

可能这个一般人可能会很少用到。

实际用途有哪些呢?
拿来玩玩,显摆显摆;)

在安全保护方面还是可以适当利用利用。
如纯开发员的角度来看,可以将这个应用到注册授权认证的代码中。

另外可以用在 .Net 安全保护工具上,加密工具加密.Net程序后自动给程序集中注入这些调用。
甚至可以把一些简单方法体在加密时就编译成native代码插入。
而且可以不用附带一个native dll。