如何通过读取co-classs'es vtable来获取函数名称对函数地址? [英] How to get function name against function address by reading co-classs'es vtable?

查看:325
本文介绍了如何通过读取co-classs'es vtable来获取函数名称对函数地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过从COM暴露的接口方法的vtable读取其地址来调用co-class函数。我需要一些通用的方法来读取地址。

I need to call the co-class function by reading its address from vtable of COM exposed interface methods. I need some generic way to read addresses.

现在我需要调用该函数,它将具有特定的地址(NOT KNOWN)参数TLB和名称。这个地址对应于我要调用的那个函数名。

Now I need to call the function, which would have specific address(NOT KNOWN) arguments(parameters) which I have collected from TLB, and name as well. How that address corresponds to that function name to which I am going to call.

对于这个,我需要遍历一个保存函数地址的vtable,LASTLY需要对应函数地址与该函数的NAME。这是我不知道。怎么样?更多具有相同名称的函数可能出现在vtable中(重载大小写)。在这种情况下,我们需要区分函数名称w.r.t它们的地址。如何解决?
尊敬的
Usman

For this I need to traverse vtable which is holding functional addresses, LASTLY need to correspond function address with NAME of that function. This is I dont know. How? More over one function with the same name may appear in vtable(Overloading case). In that case we need to distinguish function names w.r.t their addresses. How to tackle ? Regards Usman

尊敬的先生。

我正在设计一个单元测试框架,我需要拉出某些COM Exe或COM DLL的所有函数签名,以显示在网格或任何接口给用户,以便以后通过选择某些函数签名在将该参数(数据作为参数)提供给该函数之后,他/她可以执行该函数。所有这些将在运行时动态完成,运行时函数将被调用任何用户想要的。

I am designing a Unit Testing framework for which I need to pull out all function signatures of certain COM Exe or COM DLL to show in the grid or whatever interface to user, so that later by selecting certain function signature from that list, He/She can execute that function after providing the arguments(data as parameters) to that function. All this would be done dynamically at runtime, on runtime function will be called whatever user wants.

这可以通过各种方式实现。

This can be achieved from various ways.

通过提供TLB(类型库),我们可以拉每个函数签名,并可以显示每个签名到网格控制或树控件。第二步是通过提供数据在运行时调用这些函数。调用需要函数的数据和地址(或名称)。我会有一些GUI面板或控件,它将从用户的数据,然后该数据将成为参数。

By providing TLB(Type libraries) we can pull every function signature and can show every signature to Grid control or on Tree control. Second step is to call these functions at runtime by providing data. Calling require data and address of functions(or Names). I would have some GUI panel or control which will take the data from user and that data would then become as arguments.

现在真正的问题是我之前发布的。调用由co-class实现的COM组件公开的接口的函数/方法。这需要跟踪由组件暴露的接口的vtable,找到该功能的地址,然后需要知道是真的地址,我将要调用作为功能?因此,这需要将该地址转换为函数名,然后比较一些字符串比较将决定它是否真的那个用户从树控件中选择显示签名的函数名。

Now real problem comes for which I posted earlier. Call to functions/methods of that interface exposed by COM component implemented by co-class. This requires to trail down vtable of interface exposed by component , finding the address of that function and then need to know IS IT REALLY THAT ADDRESS TO WHICH I AM GOING TO CALL AS FUNCTION? So this requires to translate that address to function name and then comparison some string comparison would decide that whether it was really that function name which USER CLICKED from Tree Control showing signatures.

建议或建议?

推荐答案

致电每个函数的ITypeInfo :: GetFuncDesc ,并且您获得的FUNCDESC结构包含oVft成员中的vtable索引。

Call ITypeInfo::GetFuncDesc for each function and the FUNCDESC structure you get back contains the vtable index in the oVft member. Cast an interfaces vtable to void** and just use it as an index.

当然,为什么你需要这样做我不知道:)

Of course quite why you need to do this I do not know :)

这篇关于如何通过读取co-classs'es vtable来获取函数名称对函数地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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