实例句柄0x10000000有什么特别之处?What is so special about the instance handle 0x10000000?
当LoadLibrary函数返回特殊值时,客户想知道它意味着什么0x10000000。
嗯,这意味着LIB被加载进了0x10000000?
好的,这里有一些更多的信息:“我们正在尝试调试一个加载DLL的应用程序,并试图在他们调用时挂钩他们的注册表访问DllRegisterServer。看起来当从特殊句柄返回时LoadLibrary,注册表写入通过并绕过钩子。另一方面,当返回正常值时LoadLibrary,钩子起作用。“
值没有什么特别之处0x10000000。这是一个像任何其他地址一样的地址。
在这一点上,你的精神力量可能会开始刺痛。每个进行Win32编程的人都应该认识到这一点0x10000000是链接器分配的默认DLL基址。如果您未指定自定义基址,则链接器将以您为基础0x10000000。
现在情况开始变得有意义了。被监视的DLL可能是使用默认的基址构建的。该值0x10000000是特殊的,不是因为它的数值,而是因为它匹配DLL的首选地址,这意味着没有发生变基。这反过来表明,如果DLL在其首选地址加载,则注册表挂钩中存在错误。
有问题的代码是从书中复制的,所以现在他们可以调试从书中复制的代码。
等等,我们还没完成。
您可能已经回答了客户的问题,但您还没有解决他们的问题。
不支持挂钩和修补这样的DLL。但是,什么是支持的是RegOverridePredefKey功能。事实上,这RegOverridePredefKey是专门为解决这个问题而设计的:
该RegOverridePredefKey功能可用于软件安装程序。它允许它们重新映射预定义的密钥,加载将安装在系统上的DLL组件,调用DLL中的入口点,并检查组件尝试进行的注册表更改。
文档继续,解释了这样的安装程序如何使用该RegOverridePredefKey函数来完成所需的任务。
A customer wanted to know what it means when the LoadLibrary function returns the special value 0x10000000.
Um, it means that the library was loaded at 0x10000000?
Okay, here’s some more information: “We’re trying to debug an application which loads DLLs and attempts to hook their registry accesses when they call DllRegisterServer. It looks like when the special handle is returned from LoadLibrary, the registry writes go through and bypass the hook. On the other hand, when a normal value is returned by LoadLibrary, the hook works.”
There is nothing special about the value 0x10000000. It’s an address like any other address.
At this point, your psychic powers might start tingling. Everybody who does Win32 programming should recognize that 0x10000000 is the default DLL base address assigned by the linker. If you don’t specify a custom base address, the linker will base you at 0x10000000.
Now things are starting to make sense. The DLL being monitored was probably built with the default base address. The value 0x10000000 is special not because of its numeric value, but because it matches the DLL’s preferred address, which means that no rebasing has occurred. And this in turn suggests that there’s a bug in the registry hooks if the DLL is loaded at its preferred address.
The code in question was copied from a book, so now they get to debug code copied from a book.
Wait, we’re not finished yet.
You may have answered the customer’s question, but you haven’t solved their problem.
Hooking and patching DLLs like this is not supported. But what is supported is the RegOverridePredefKey function. In fact, the RegOverridePredefKey was designed specifically to solve this very problem:
The RegOverridePredefKey function is intended for software installation programs. It allows them to remap a predefined key, load a DLL component that will be installed on the system, call an entry point in the DLL, and examine the changes to the registry that the component attempted to make.
The documentation continues, explaining how such an installation program might use the RegOverridePredefKey function to accomplish the desired task.
实例句柄0x10000000有什么特别之处?What is so special about the instance handle 0x10000000?的更多相关文章
- Lua语言的特别之处
所谓特别,是相对的,是相对别的主流语言而言,有些也可能只是我个人看法. 1. 函数定义与调用,与代码位置的先后顺序有关,例如 calculate() function calculate() .... ...
- xx.exe 中的 0x7c92e4df 处最可能的异常: 0xC0000008: An invalid handle was specified
今天遇到个超级奇怪的问题,昨天还好端端的程序,今天用VS打开后,在关闭主窗口的时候居然弹出错误提示:xx.exe 中的 0x7c92e4df 处最可能的异常: "0xC0000008: An ...
- 主函数特别之处:public static void main(String[] args)
public static void main(String[] args) public class Test_java {//主函数特殊之处 public static void main(Str ...
- JDK8下的HashMap有什么特别之处?
一.前言 上篇认真的分析了在JDK7下的HashMap, 如果还没看过的或者忘记了的可以先去回顾下,这样可以更好的了解JDK8下的HashMap基于JDK7做了什么改动.分析JDK8下的HashMap ...
- 【笨木头Lua专栏】基础补充02:函数的几个特别之处
没想到距离上一篇基础补充已经过了1年多了,近期准备捡回Lua,把基础都补补,今天来聊聊Lua的函数吧~ 0.环境 我突然对Lua又大感兴趣的最主要原因是,Cocos Code IDE開始浮出水面了,它 ...
- main特别之处
//package new_Object; public class Main{ public static void main(String[] args) { System.out.println ...
- 01:main特别之处
有点意思的main 图解运行结果解释:[:数组L:长类型ava.lang:包名String:字符串类型元素@:分界符667262b6:哈希值主函数特殊之处:public static void mai ...
- Python中作用域的特别之处
def a(): a = [] def aappend(): a.append(1) aappend() print a def b(): b = 1 def bchange(): b += 1 # ...
- Javascript里的if判断与逻辑运算符(||, &&)和比较运算符的特别之处
写JS时不可避免要用到 if 与 逻辑运算符( ||, &&). 如果你经常阅读Js的第三方组件源码, 会发现有一种写法作为初始化变量的方法经常出现. var variable = v ...
随机推荐
- PAT 乙级 1012.数字分类 C++/Java
题目来源 给定一系列正整数,请按要求对数字进行分类,并输出以下 5 个数字: A1 = 能被 5 整除的数字中所有偶数的和: A2 = 将被 5 除后余 1 的数字按给出顺序进行交错求和, ...
- 推荐系统(recommender systems):预测电影评分--构造推荐系统的一种方法:低秩矩阵分解(low rank matrix factorization)
如上图中的predicted ratings矩阵可以分解成X与ΘT的乘积,这个叫做低秩矩阵分解. 我们先学习出product的特征参数向量,在实际应用中这些学习出来的参数向量可能比较难以理解,也很难可 ...
- python中的raw string的使用
背景 我们经常需要使用raw string,在应用过程中,比如要使字符串中带一些转义字符或者其他的一些符号,我们就需要保持我们的字符成为raw string. 实例 输入 s = 'fadfafa\n ...
- vscode React编程配置
2.添加RN开发插件 React Native Tools:微软官方出的ReactNative插件,非常好用Reactjs code snippets:react的代码提示,如componentWil ...
- (1)IdentityServer4 V3.0.2-安装模板
控制台运行命令: dotnet new -i IdentityServer4.Templates
- haproxy 2.0 dataplaneapi rest api 转为graphql docker 镜像
为了方便直接使用haproxy dataplaneapi graphql 格式的查询,制作了一个简单的docker 镜像 基于dotenv 进行配置管理,可以直接通过环境变量传入参数,处理不同hapr ...
- 洛谷 P2872 【[USACO07DEC]道路建设Building Roads】
P2872 传送门 首先 题目概括:题目让着求使所有牧场都联通.需要修建多长的路. 显然这是一道最小生成树板子题(推荐初学者做). 那我就说一下kruskal吧. Kruskal算法是一种用来查找最小 ...
- nginx 日志之 error_log
Nginx错误日志平时不用太关注,但是一旦出了问题,就需要借助错误日志来判断问题所在. 配置参数格式:error_log /path/to/log level; Nginx错误日志级别 常见的错误日志 ...
- Android Studio 之 DataBing ,不需要再一个个findViewById了
使用DataBinding,不需要再一个个findViewById了 1.在 build.gradel 中 添加下面语句 dataBinding{ enabled true } 2.在 activit ...
- kafka(二) 高性能技术分析
参考文章: http://www.infoq.com/cn/articles/kafka-analysis-part-6 Partition提供并行处理的能力 Kafka是一个Pub-Sub的消息系统 ...