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

推荐订阅源

V
Vulnerabilities – Threatpost
F
Fortinet All Blogs
Vercel News
Vercel News
C
Check Point Blog
P
Privacy International News Feed
Know Your Adversary
Know Your Adversary
Google DeepMind News
Google DeepMind News
T
Troy Hunt's Blog
TaoSecurity Blog
TaoSecurity Blog
I
Intezer
T
The Exploit Database - CXSecurity.com
Security Archives - TechRepublic
Security Archives - TechRepublic
H
Hacker News: Front Page
P
Proofpoint News Feed
GbyAI
GbyAI
Engineering at Meta
Engineering at Meta
Attack and Defense Labs
Attack and Defense Labs
S
Security @ Cisco Blogs
IT之家
IT之家
D
DataBreaches.Net
Hacker News: Ask HN
Hacker News: Ask HN
SecWiki News
SecWiki News
Y
Y Combinator Blog
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
Lohrmann on Cybersecurity
T
Tenable Blog
大猫的无限游戏
大猫的无限游戏
L
LINUX DO - 最新话题
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
Recorded Future
Recorded Future
有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler
K
Kaspersky official blog
PCI Perspectives
PCI Perspectives
A
Arctic Wolf
Latest news
Latest news
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
Netflix TechBlog - Medium
雷峰网
雷峰网
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
P
Palo Alto Networks Blog
The Hacker News
The Hacker News
WordPress大学
WordPress大学
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
月光博客
月光博客
Schneier on Security
Schneier on Security
M
MIT News - Artificial intelligence

博客园 - 紫雨轩 .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。