DWORD_PTR和unsigned __int3264,由COM / RPC编组__int3264作为64位值或32位值编组? [英] Are DWORD_PTR and unsigned __int3264, signed __int3264 marshalled by COM/RPC as 64-bit values or 32-bit values?

查看:189
本文介绍了DWORD_PTR和unsigned __int3264,由COM / RPC编组__int3264作为64位值或32位值编组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看MIDL 64位移植指南,似乎指出应该在COM接口上使用DWORD_PTR类型传递指针值,以便以独立于平台的方式成功处理32位和64位平台。但是,一些实验似乎是
,表明如果在高4字节中有非0值,则由16位平台上的MIDL生成的代理/存根代码执行的编组不能成功编组64位值(即实际只发送低32位。)

Looking at the MIDL 64-bit porting guide, it seems to direct that pointer values should be passed using DWORD_PTR type on COM interfaces to successfully handle 32-bit and 64-bit platforms in a platform-independent way. However, some experimentation seems to indicate that the marshalling performed by MIDL-generated proxy/stub code on a 64-bit platform does not successfully marshal 64-bit values if they have non-0 values in the upper 4 bytes (i.e. only the lower 32-bits are actually transmitted).

例如,服务器想要返回[out] DWORD_PTR * pPointerValue:

* pPointerValue = 0x123456789ab ; $


在客户端,我看到值0x456789ab(高4字节的0x123丢失并替换为0)。



这是预期的吗?如果是这样,为什么MIDL移植指南表明DWORD_PTR对于在编组接口上传输8字节指针值有用呢?

For example, server would like to return [out] DWORD_PTR * pPointerValue:
*pPointerValue = 0x123456789ab;

On the client side, I see value 0x456789ab (the 0x123 in upper 4bytes is lost and replaced with 0).

Is this expected? If so, why does the MIDL porting guide indicate that DWORD_PTR should be useful for transmitting 8-byte pointer values across a marshalled interface?

是否有一些MIDL / IDL机制支持这一点特定于平台的方式(即32位平台上的32位和64位平台上的64位)?

Is there some MIDL/IDL mechanism to support this in a platform-specific way (i.e. 32 bits on 32-bit platform and 64 bits on 64-bit platform)?

如果我将无符号__in64 *指定为idl中的类型,则它会正确传输,但我希望有一个平台相关的数据类型,适用于两种类型的平台。

If I specify unsigned __in64 * as the type in idl, then it transmits correctly, but I would like to have a platform-dependent data type that works correctly for both types of platforms.

谢谢和问候,

Jon

推荐答案

感谢您在这里发帖。

>> DWORD_PTR和无符号__int3264,已签名__int3264由COM / RPC编组为64位值还是32位值?

DWORD_PTR是指针精度的无符号长类型,具有足够的位,以便指针可以转换为该类型并返回而不会丢失信息。它声明如下:

The DWORD_PTR is a unsigned long type for pointer precision with enough bits so that a pointer can be converted to that type and back without losing information. It's declared as below:

typedef ULONG_PTR DWORD_PTR;




#if defined(_WIN64)
 typedef unsigned __int64 ULONG_PTR;
#else
 typedef unsigned long ULONG_PTR;
#endif

每种类型INT_PTR,UINT_PTR,LONG_PTR,ULONG_PTR和DWORD_PTR都是一个整数类型,与指针大小相同:32位32位位代码或64位代码中的64位。  .NET Framework中的相应类型是System.IntPtr或System.UIntPtr。

Each of the types INT_PTR, UINT_PTR, LONG_PTR, ULONG_PTR, and DWORD_PTR is an integer type with the same size as a pointer: 32 bits in 32-bit code or 64 bits in 64-bit code.  The corresponding type in the .NET Framework is System.IntPtr or System.UIntPtr.

有关详细信息,请参阅下面的类似案例。

For more information, you could refer to this similar case below.

https://social.msdn.microsoft.com/Forums/en-US/fa7625e7-5001-4e15-a75a-83ead88f26a5/marshalling-dwordptr-used-in-dll-to-c

希望这可以帮助你。

最好的问候,

Baron Bi


这篇关于DWORD_PTR和unsigned __int3264,由COM / RPC编组__int3264作为64位值或32位值编组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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