如何通过读取 co-classs vtable 来根据函数地址获取函数名称?
我需要通过从 COM 公开接口方法的 vtable 读取其地址来调用 co-class 函数。我需要一些通用的方法来读取地址。
现在我需要调用该函数,该函数将具有我从 TLB 收集的特定地址(未知)参数(参数)以及名称。该地址如何与我要调用的函数名称相对应。
为此,我需要遍历保存功能地址的 vtable,最后需要将函数地址与该函数的名称相对应。这是我不知道的。如何? vtable 中可能会出现多个同名函数(重载情况)。在这种情况下,我们需要区分函数名称和地址。如何应对? 问候 乌斯曼
尊敬的先生!
我正在设计一个单元测试框架,我需要提取某些 COM Exe 或 COM DLL 的所有函数签名以在网格或任何用户界面中显示,以便稍后从该列表中选择某些函数签名,他/她可以在向该函数提供参数(数据作为参数)后执行该函数。所有这些都将在运行时动态完成,运行时函数将根据用户的需要被调用。
这可以通过多种方式实现。
通过提供 TLB(类型库),我们可以提取每个函数签名,并可以向网格控件或树控件显示每个签名。第二步是通过提供数据在运行时调用这些函数。调用需要数据和函数地址(或名称)。我会有一些 GUI 面板或控件,它将从用户那里获取数据,然后该数据将成为参数。
现在真正的问题来了,我之前发布过。调用由共同类实现的 COM 组件公开的接口的函数/方法。这需要追踪组件公开的接口的虚函数表,找到该函数的地址,然后需要知道它真的是我要作为函数调用的地址吗?因此,这需要将该地址转换为函数名称,然后比较一些字符串比较,以决定它是否真的是用户从显示签名的树控件中单击的函数名称。
有建议或推荐吗?
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.
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.
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
Respectfully Sir.!!
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.
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.
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.
Suggestions or reccommendations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用 ITypeInfo::GetFuncDesc每个函数和您返回的 FUNCDESC 结构都包含 oVft 成员中的 vtable 索引。将接口 vtable 转换为 void** 并仅将其用作索引。
当然,我不知道为什么你需要这样做:)
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 :)