COM接口Hook的用法
来源:互联网 发布:蚁群算法详解 编辑:程序博客网 时间:2024/05/28 15:45
// Dsound.h 中的定义
HRESULT CreateSoundBuffer(
LPCDSBUFFERDESC pcDSBufferDesc,
LPDIRECTSOUNDBUFFER * ppDSBuffer,
LPUNKNOWN pUnkOuter
);
// 我定义的替代函数
HRESULT __stdcall PASCAL fakeIDirectSound8_CreateSoundBuffer(
LPCDSBUFFERDESC pcDSBufferDesc,
LPDIRECTSOUNDBUFFER * ppDSBuffer,
LPUNKNOWN pUnkOuter
);
当应用程序调用IDirectSound::CreateSoundBuffer的时候,跳转到了我自己的写 fakeIDirectSound8_CreateSoundBuffer,但是我调试的时候发现,传到 fakeIDirectSound8_CreateSoundBuffer的参数出错了,顺序乱了
lpDS->CreateSoundBuffer(NULL, &lpDSB, NULL);
0042EC18 mov esi,esp
0042EC1A push 0
0042EC1C lea eax,[lpDSB]
0042EC1F push eax
0042EC20 push 0
0042EC22 mov ecx,dword ptr [lpDS]
0042EC25 mov edx,dword ptr [ecx]
0042EC27 mov eax,dword ptr [lpDS]
0042EC2A push eax
0042EC2B mov ecx,dword ptr [edx+0Ch]
0042EC2E call ecx
0042EC30 cmp esi,esp
0042EC32 call @ILT+3545(__RTC_CheckEsp) (42CDDEh)
参数压栈时为: 0, 0x0049964c, 0x0018fd60
eax = 0x02610ac8
#define CMCALLTYPE STDMETHODCALLTYPE
HRESULT CMCALLTYPE Hook::fakeIDirectSound_CreateSoundBuffer(
LPCDSBUFFERDESC pcDSBufferDesc,
LPDIRECTSOUNDBUFFER *ppDSBuffer,
LPUNKNOWN pUnkOuter)
{
10033CA0 push ebp
10033CA1 mov ebp,esp
10033CA3 sub esp,0CCh
10033CA9 push ebx
10033CAA push esi
10033CAB push edi
10033CAC lea edi,[ebp-0CCh]
10033CB2 mov ecx,33h
10033CB7 mov eax,0CCCCCCCCh
10033CBC rep stos dword ptr es:[edi]
跳转到我自己写的函数后,检查各个参数发现出错了。
pcDSBufferDesc = 0x0210ac8
ppDSBuffer = 0x0018fd60
pUnkOuter = 0x0049964c
运行后出现以下错误提示:Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
根据提示分析应该是我自己写的函数声明的call方式错误引起的,因此我将CMCALLTYPE 修改成
1、 __cdecl
2、 __stdcall
3、 __fastcall
4、 WINAPI
运行还是出现错误。
请问下到底出什么问题了,thx in advance。
HRESULT CreateSoundBuffer(
LPCDSBUFFERDESC pcDSBufferDesc,
LPDIRECTSOUNDBUFFER * ppDSBuffer,
LPUNKNOWN pUnkOuter
);
// 我定义的替代函数
HRESULT __stdcall PASCAL fakeIDirectSound8_CreateSoundBuffer(
LPCDSBUFFERDESC pcDSBufferDesc,
LPDIRECTSOUNDBUFFER * ppDSBuffer,
LPUNKNOWN pUnkOuter
);
当应用程序调用IDirectSound::CreateSoundBuffer的时候,跳转到了我自己的写 fakeIDirectSound8_CreateSoundBuffer,但是我调试的时候发现,传到 fakeIDirectSound8_CreateSoundBuffer的参数出错了,顺序乱了
lpDS->CreateSoundBuffer(NULL, &lpDSB, NULL);
0042EC18 mov esi,esp
0042EC1A push 0
0042EC1C lea eax,[lpDSB]
0042EC1F push eax
0042EC20 push 0
0042EC22 mov ecx,dword ptr [lpDS]
0042EC25 mov edx,dword ptr [ecx]
0042EC27 mov eax,dword ptr [lpDS]
0042EC2A push eax
0042EC2B mov ecx,dword ptr [edx+0Ch]
0042EC2E call ecx
0042EC30 cmp esi,esp
0042EC32 call @ILT+3545(__RTC_CheckEsp) (42CDDEh)
参数压栈时为: 0, 0x0049964c, 0x0018fd60
eax = 0x02610ac8
#define CMCALLTYPE STDMETHODCALLTYPE
HRESULT CMCALLTYPE Hook::fakeIDirectSound_CreateSoundBuffer(
LPCDSBUFFERDESC pcDSBufferDesc,
LPDIRECTSOUNDBUFFER *ppDSBuffer,
LPUNKNOWN pUnkOuter)
{
10033CA0 push ebp
10033CA1 mov ebp,esp
10033CA3 sub esp,0CCh
10033CA9 push ebx
10033CAA push esi
10033CAB push edi
10033CAC lea edi,[ebp-0CCh]
10033CB2 mov ecx,33h
10033CB7 mov eax,0CCCCCCCCh
10033CBC rep stos dword ptr es:[edi]
跳转到我自己写的函数后,检查各个参数发现出错了。
pcDSBufferDesc = 0x0210ac8
ppDSBuffer = 0x0018fd60
pUnkOuter = 0x0049964c
运行后出现以下错误提示:Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
根据提示分析应该是我自己写的函数声明的call方式错误引起的,因此我将CMCALLTYPE 修改成
1、 __cdecl
2、 __stdcall
3、 __fastcall
4、 WINAPI
运行还是出现错误。
请问下到底出什么问题了,thx in advance。
[公告]如果你觉得有人语言挑衅,请点每帖右上角的“举报”按钮!
最佳答案 - 作者: cherryExCOM里面的函数都是__stdcall的,
并且有隐藏参数,第一个参数都是 this ,
lpDS->CreateSoundBuffer(NULL, &lpDSB, NULL);
=
CreateSoundBuffer(lpDS, NULL, &lpDSB, NULL);
普通会员
2 2012-08-08, 12:44:51
COM里面的函数都是__stdcall的,
并且有隐藏参数,第一个参数都是 this ,
lpDS->CreateSoundBuffer(NULL, &lpDSB, NULL);
=
CreateSoundBuffer(lpDS, NULL, &lpDSB, NULL);
并且有隐藏参数,第一个参数都是 this ,
lpDS->CreateSoundBuffer(NULL, &lpDSB, NULL);
=
CreateSoundBuffer(lpDS, NULL, &lpDSB, NULL);
0 0
- COM接口Hook的用法
- Hook Com接口函数
- COM HOOK的原理
- Intercepting Calls to COM Interfaces(hook com接口)
- 关于HOOK的用法
- hook的LD_PRELOAD用法
- 如何分析解决COM接口IFileOperation的hook去支持vista、win7、win8、win10 x86 x64系统
- 如何分析解决COM接口IFileOperation的hook去支持vista、win7、win8、win10 x86 x64系统
- com接口的使用
- COM接口的背后
- Runtime中 shutdown hook的用法
- COM Hook原理
- COM Hook原理
- COM Hook原理
- COM 组件接口的 IUnKnown 接口介绍
- COM接口指针的传递
- 对Com接口的使用
- com的主要接口介绍
- iOS 地图(Map)与地理信息反编码
- java程序打包成为可运行的exe文件
- 在C++中嵌入V8
- android v7兼容包RecyclerView的使用(二)
- 分布式编译IncredBuild
- COM接口Hook的用法
- [Leetcode 24 链表]Swap Nodes in Pairs
- DBCP,CP30及proxool连接池在spring+hibernate中的配置
- hdu 1223 最小生成树 (MST)
- SpringMVC学习系列(12) 完结篇 之 基于Hibernate+Spring+Spring MVC+Bootstrap的管理系统实现
- js写的留言板。
- 一个让老程序员都汗颜的应届生——传智播客iOS二期学员常小帅自述
- Notepad++ 快捷键 大全
- 让图片DIV竖向滑动的JavaScript特效代码