实例句柄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 ...
随机推荐
- 编程语言和python介绍, 变量,小整数池,垃圾回收机制
1.编程语言的发展史 计算机是基于电工作(基于高.低电平)1010010101011 1.机器语言 优点:执行速度够快 缺点:开发效率非常低 2.汇编语言(通过英文字符组成) 优点:执行效率相较于机器 ...
- redux学你参考网站
redux官方网站 http://cn.redux.js.org/docs/api/combineReducers.html https://www.redux.org.cn 从设计的角度看Redux ...
- python - 将天数转换成日期
# 如果是 0 则为今天 def getdate(day): today = datetime.datetime.now() deviation = datetime.timedelta(days=- ...
- Connected Component in Undirected Graph
Description Find connected component in undirected graph. Each node in the graph contains a label an ...
- Laravel 自定义公共函数全局使用,并设置自定加载
开发中经常定义一些公共函数(如:获取用户信息.csv导入导出等常用函数),方便控制层,模型层调用. 那么在Laravle框架中怎么使用? 方法如下: 1.在根目录app下新建公共目录Library/U ...
- drf常用方法
1.认证 2.权限 3.序列化 4.分页 5.限流
- 洛谷 P2356 【弹珠游戏】题解
自我感觉应该没有用结构体做的吧 这道题其实非常水 很适合初学贪心的同学做一下 我好像没有用贪心做,嘻嘻 首先先读题, 题目中说这个游戏只能消灭当前所在位置的行.列的敌人 首先特判一下: if(tt== ...
- hive基础知识二
1. Hive的分区表 1.1 hive的分区表的概念 在文件系统上建立文件夹,把表的数据放在不同文件夹下面,加快查询速度. 1.2 hive分区表的构建 创建一个分区字段的分区表 hive> ...
- python 获取文件本身的绝对路径
tester.py: import os print (os.path.dirname(__file__)) print (os.path.abspath(__file__)) print (os.p ...
- 在error日志打印异常
在日志中打印异常,经常会看到以下的写法: logger.error(e.getMessage()); 或者是: e.printStackTrace(); 这两种其实都不太好. e.getMessage ...