阅读:1971回复:7
请教如何在中间层使用htons()!
各位大虾:我在中间层要更改包头,要进行字节顺序的转换,可是不能使用htons,各位高手帮帮忙!小弟在此先谢过!
|
|
|
沙发#
发布于:2007-06-05 12:02
谢谢楼上,我也在为这个烦恼,我什么时候也能像他们一样能指点指点别人啊 努力ing
|
|
板凳#
发布于:2007-05-25 18:38
路过...呵呵,还有一种方法,就是把MS的代码直接反汇编,嵌到内联中去...
|
|
|
地板#
发布于:2007-05-24 13:09
谢谢大家!问题解决了!
|
|
|
地下室#
发布于:2007-05-23 15:57
在Precomp.h中添加
#include <ntddk.h> 在passthru.h中添加如下内容,就可以使用了 #define htons(a) RtlUshortByteSwap(a) #define ntohs(a) RtlUshortByteSwap(a) #define htonl(a) RtlUlongByteSwap(a) #define ntohl(a) RtlUlongByteSwap(a) |
|
5楼#
发布于:2007-05-23 15:49
RtlUshortByteSwap
The RtlUshortByteSwap routine converts a USHORT from little-endian to big-endian, and vice versa. USHORT RtlUshortByteSwap( IN USHORT Source ); Parameters Source Specifies a USHORT value to convert. Return Value The converted USHORT value. Headers Declared in wdm.h. Include wdm.h, ntddk.h, or ntifs.h. Comments This routine is not supported on Windows 98 or Windows Me. Use this function instead of ntohs or htons. |
|
6楼#
发布于:2007-05-23 10:18
谢谢!
|
|
|
7楼#
发布于:2007-05-22 22:20
这个,自己写吧
#define k_ntohs(a) (( (a)>>8) &0xff)| ( ((a)<<8 )& 0xff00) #define k_htons(a) k_ntohs(a) |
|
|