Linux下的虚拟表挂钩 [英] Virtual Table hook under linux

查看:90
本文介绍了Linux下的虚拟表挂钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我有一个用于在Windows x86下挂接虚拟功能的小功能.
我必须移植它或linux x86,我知道我必须使用mprotect,但这对我来说是抽象的,我整夜都在google,这里和其他网站上进行搜索,但是... wtf ...在没有答案全部 ?? Linux不存在或有什么??

Hi !

I have a little function which is used to hook virtual functions under Windows x86.
I have to port it or linux x86, I know I have to use mprotect but this is abstract for me, I''ve searched all the night on google, here and on other site but ... wtf ... no answer at all ?? Linux doesn''t exists or what ??

DWORD VirtualTableHook( DWORD* pdwNewInterface, int vtable, DWORD newInterface )
{
	DWORD dwOld, dwStor = 0x0;
#ifdef WIN32
	VirtualProtect( &pdwNewInterface[vtable], 4, PAGE_EXECUTE_READWRITE, &dwOld );
#else

#endif
	dwStor = pdwNewInterface[vtable];
	*(DWORD*)&pdwNewInterface[vtable] = newInterface;
#ifdef WIN32
	VirtualProtect(&pdwNewInterface[vtable], 4, dwOld, &dwOld);
#else

#endif
	return dwStor;
}



我不知道我是否可以在Linux下使用DWORD,我也不知道如何确切地使用mprotect,即使我看了一下男人……所以如果有人可以帮助我,将不胜感激.谢谢:o



I don''t know if I can use DWORD under Linux, I don''t know how to use mprotect exactly, even if I take a look at man ... so if someone could help me it will be much appreciated. Thanks :o

推荐答案

尝试此示例 [ ^ ].我不认为DWORD是在任何Linux C/C ++头文件中定义的,但是您可以自己轻松地添加它.
Try this sample[^]. I do not think that DWORD is defined in any of the Linux C/C++ headers, but you can add it yourself quite easily.


x86上的DWORD是32位无符号整数.很容易找到定义.将光标放在VisualStudio中的DWORD上,然后按F12.
DWORD on x86 is a 32 bit unsigned integer. Is easy to find definition. Put cursor on DWORD in VisualStudio and press F12.


这篇关于Linux下的虚拟表挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆