Byte Order APIs.

Hi All,

What are the APIs for byte order conversion in drivers. i.e. I am looking
for replacements for ntohs, ntohl etc. in kernel mode. I want to convert the
length (of type WORD) in network byte order. or I need to write my own
functions for the same?

Any ideas?

Amit Manocha

Have to roll your own, try

WORD my_htons (WORD hostshort)
{
return (hostshort << 8 | (hostshort >> 8 & 0xff);
}

At 10:15 AM 5/14/2003, Amit Manocha wrote:

Hi All,

What are the APIs for byte order conversion in drivers. i.e. I am looking
for replacements for ntohs, ntohl etc. in kernel mode. I want to convert the
length (of type WORD) in network byte order. or I need to write my own
functions for the same?

Any ideas?

Amit Manocha

Thanks Mark.
----- Original Message -----
From: “Mark S. Edwards”
To: “NT Developers Interest List”
Sent: Wednesday, May 14, 2003 2:52 PM
Subject: [ntdev] Re: Byte Order APIs.

> Have to roll your own, try
>
> WORD my_htons (WORD hostshort)
> {
> return (hostshort << 8 | (hostshort >> 8 & 0xff);
> }
>
>
> At 10:15 AM 5/14/2003, Amit Manocha wrote:
> >Hi All,
> >
> >What are the APIs for byte order conversion in drivers. i.e. I am looking
> >for replacements for ntohs, ntohl etc. in kernel mode. I want to convert
the
> >length (of type WORD) in network byte order. or I need to write my own
> >functions for the same?
> >
> >Any ideas?
> >
> >Amit Manocha
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@mynetsec.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

“Mark S. Edwards” wrote:

Have to roll your own, try

No you don’t – RTFM and find RtlUlongByteSwap and related functions.


Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Now teaming with John Hyde for USB Device Engineering Seminars
Check out our schedule at http://www.oneysoft.com

Amit,

       There is no such type of KPIs… so u can build ur own. U can i think?

Good Luck,



From: “Amit Manocha”

>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] Byte Order APIs.
>Date: Wed, 14 May 2003 14:45:28 +0530
>
>Hi All,
>
>What are the APIs for byte order conversion in drivers. i.e. I am looking
>for replacements for ntohs, ntohl etc. in kernel mode. I want to convert the
>length (of type WORD) in network byte order. or I need to write my own
>functions for the same?
>
>Any ideas?
>
>Amit Manocha
>
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


It’s spooky. It’s a thriller. See Bhoot slideshow

In case of using both RtlUlongByteSwap c.s. and these “home-made” functions
you assume that the host-byte order is little endian.

See also this Fine Material: :wink:

http://www.cs.rpi.edu/courses/sysprog/sockets/byteorder.html

So you might take some care here. Is your software supposed to work on
non-i368 platforms?

Jan Roeloffzen.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Walter Oney
Sent: Wednesday, May 14, 2003 12:08 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

“Mark S. Edwards” wrote:
> Have to roll your own, try

No you don’t – RTFM and find RtlUlongByteSwap and related functions.


Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Now teaming with John Hyde for USB Device Engineering Seminars
Check out our schedule at http://www.oneysoft.com


You are currently subscribed to ntdev as: xxxxx@planet.nl
To unsubscribe send a blank email to xxxxx@lists.osr.com

You use the DDK versions and the DDK versions do the appropriate thing for
the platform. Besides, all NT platforms are little endian, always have been,
and for the foreseeable future, always will be.

-----Original Message-----
From: xxxxx@planet.nl [mailto:xxxxx@planet.nl]
Sent: Wednesday, May 14, 2003 8:50 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

In case of using both RtlUlongByteSwap c.s. and these
“home-made” functions you assume that the host-byte order is
little endian.

See also this Fine Material: :wink:

http://www.cs.rpi.edu/courses/sysprog/sockets/byteorder.html

So you might take some care here. Is your software supposed to work on
non-i368 platforms?

Jan Roeloffzen.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Walter Oney
Sent: Wednesday, May 14, 2003 12:08 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

“Mark S. Edwards” wrote:
> Have to roll your own, try

No you don’t – RTFM and find RtlUlongByteSwap and related functions.


Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Now teaming with John Hyde for USB Device Engineering Seminars Check
out our schedule at http://www.oneysoft.com


You are currently subscribed to ntdev as: xxxxx@planet.nl To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

RtlUlongByteSwap and friends.

----- Original Message -----
From: “Amit Manocha”
Newsgroups: ntdev
To: “NT Developers Interest List”
Sent: Wednesday, May 14, 2003 1:15 PM
Subject: [ntdev] Byte Order APIs.

> Hi All,
>
> What are the APIs for byte order conversion in drivers. i.e. I am
looking
> for replacements for ntohs, ntohl etc. in kernel mode. I want to
convert the
> length (of type WORD) in network byte order. or I need to write my
own
> functions for the same?
>
> Any ideas?
>
> Amit Manocha
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com

Too bad RtlUlongByteSwap() and such are not implemented in 98/me…

In a past project, we used to have a piece of code that was meant to be run
on both types of processors (little AND big endian). We could not directly
use a byte swap function or macro because swapping was not always required:
the intent was to convert from data in a known byte-ordering format to the
format of the platform on which the code was running.

Ultimately, we had a macro called something like LITTLEENDIAN_TO_PLATFORM
that resolved to something different depending of the platform for which the
code was compiled. That was pretty neat actually. It’s a little bit like
the ntohl and similar functions, I guess.

System support for swapping is not a bad thing, but OTOH, I find it weird to
call a function for performing such a basic operation; it feels weird, like
calling a function to add two values…

I wish there was an assembly operation to do byte swaps! That would be so
quicker to do, instead of shifting and ORing.

Mat

-----Original Message-----
From: Roddy, Mark [mailto:xxxxx@stratus.com]
Sent: Wednesday, May 14, 2003 9:10 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

You use the DDK versions and the DDK versions do the appropriate thing for
the platform. Besides, all NT platforms are little endian, always have been,
and for the foreseeable future, always will be.

-----Original Message-----
From: xxxxx@planet.nl [mailto:xxxxx@planet.nl]
Sent: Wednesday, May 14, 2003 8:50 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

In case of using both RtlUlongByteSwap c.s. and these
“home-made” functions you assume that the host-byte order is
little endian.

See also this Fine Material: :wink:

http://www.cs.rpi.edu/courses/sysprog/sockets/byteorder.html

So you might take some care here. Is your software supposed to work on
non-i368 platforms?

Jan Roeloffzen.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Walter Oney
Sent: Wednesday, May 14, 2003 12:08 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

“Mark S. Edwards” wrote:
> Have to roll your own, try

No you don’t – RTFM and find RtlUlongByteSwap and related functions.


Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Now teaming with John Hyde for USB Device Engineering Seminars Check
out our schedule at http://www.oneysoft.com


You are currently subscribed to ntdev as: xxxxx@planet.nl To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@guillemot.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

x86 supports bswap, like “bswap eax”. This can be wrapped by the appropriate c/c++ wrapper incantations so that it works inline.

-----Original Message-----
From: Mathieu Routhier [mailto:xxxxx@guillemot.com]
Sent: Wednesday, May 14, 2003 8:44 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

Too bad RtlUlongByteSwap() and such are not implemented in 98/me…

In a past project, we used to have a piece of code that was meant to be run
on both types of processors (little AND big endian). We could not directly
use a byte swap function or macro because swapping was not always required:
the intent was to convert from data in a known byte-ordering format to the
format of the platform on which the code was running.

Ultimately, we had a macro called something like LITTLEENDIAN_TO_PLATFORM
that resolved to something different depending of the platform for which the
code was compiled. That was pretty neat actually. It’s a little bit like
the ntohl and similar functions, I guess.

System support for swapping is not a bad thing, but OTOH, I find it weird to
call a function for performing such a basic operation; it feels weird, like
calling a function to add two values…

I wish there was an assembly operation to do byte swaps! That would be so
quicker to do, instead of shifting and ORing.

Mat

-----Original Message-----
From: Roddy, Mark [mailto:xxxxx@stratus.com]
Sent: Wednesday, May 14, 2003 9:10 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

You use the DDK versions and the DDK versions do the appropriate thing for
the platform. Besides, all NT platforms are little endian, always have been,
and for the foreseeable future, always will be.

-----Original Message-----
From: xxxxx@planet.nl [mailto:xxxxx@planet.nl]
Sent: Wednesday, May 14, 2003 8:50 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

In case of using both RtlUlongByteSwap c.s. and these
“home-made” functions you assume that the host-byte order is
little endian.

See also this Fine Material: :wink:

http://www.cs.rpi.edu/courses/sysprog/sockets/byteorder.html

So you might take some care here. Is your software supposed to work on
non-i368 platforms?

Jan Roeloffzen.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Walter Oney
Sent: Wednesday, May 14, 2003 12:08 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

“Mark S. Edwards” wrote:
> Have to roll your own, try

No you don’t – RTFM and find RtlUlongByteSwap and related functions.


Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Now teaming with John Hyde for USB Device Engineering Seminars Check
out our schedule at http://www.oneysoft.com


You are currently subscribed to ntdev as: xxxxx@planet.nl To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@guillemot.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@interactivesi.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

I make you happy :

bswap eax
rol ax,8
rol WORD PTR variable,8

----- Original Message -----
From: “Mathieu Routhier”
To: “NT Developers Interest List”
Sent: Wednesday, May 14, 2003 3:44 PM
Subject: [ntdev] Re: Byte Order APIs.

>
> I wish there was an assembly operation to do byte swaps! That would be so
> quicker to do, instead of shifting and ORing.
>
> Mat
>
> -----Original Message-----
> From: Roddy, Mark [mailto:xxxxx@stratus.com]
> Sent: Wednesday, May 14, 2003 9:10 AM
> To: NT Developers Interest List
> Subject: [ntdev] Re: Byte Order APIs.
>
> You use the DDK versions and the DDK versions do the appropriate thing for
> the platform. Besides, all NT platforms are little endian, always have been,
> and for the foreseeable future, always will be.
>
> > -----Original Message-----
> > From: xxxxx@planet.nl [mailto:xxxxx@planet.nl]
> > Sent: Wednesday, May 14, 2003 8:50 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: Byte Order APIs.
> >
> >
> > In case of using both RtlUlongByteSwap c.s. and these
> > “home-made” functions you assume that the host-byte order is
> > little endian.
> >
> > See also this Fine Material: :wink:
> >
> http://www.cs.rpi.edu/courses/sysprog/sockets/byteorder.html
>
> So you might take some care here. Is your software supposed to work on
> non-i368 platforms?
>
> Jan Roeloffzen.
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Walter Oney
> > Sent: Wednesday, May 14, 2003 12:08 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: Byte Order APIs.
> >
> >
> > “Mark S. Edwards” wrote:
> > > Have to roll your own, try
> >
> > No you don’t – RTFM and find RtlUlongByteSwap and related functions.
> >
> > –
> > Walter Oney, Consulting and Training
> > Basic and Advanced Driver Programming Seminars
> > Now teaming with John Hyde for USB Device Engineering Seminars Check
> > out our schedule at http://www.oneysoft.com
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@planet.nl To
> > unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@stratus.com To
> unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@guillemot.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

True … until one needs to dink with the contents of a CDB … then one can
quickly get tripped up in Big to Little and Little to Big.

Hmmm, at 5’9" and 330# am I LittleBig or BigLittle? :slight_smile:


Gary G. Little
Have Computer, will travel …
www.wd-3.com

“Roddy, Mark” wrote in message news:xxxxx@ntdev…
>
> You use the DDK versions and the DDK versions do the appropriate thing for
> the platform. Besides, all NT platforms are little endian, always have
been,
> and for the foreseeable future, always will be.
>
> > -----Original Message-----
> > From: xxxxx@planet.nl [mailto:xxxxx@planet.nl]
> > Sent: Wednesday, May 14, 2003 8:50 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: Byte Order APIs.
> >
> >
> > In case of using both RtlUlongByteSwap c.s. and these
> > “home-made” functions you assume that the host-byte order is
> > little endian.
> >
> > See also this Fine Material: :wink:
> >
> http://www.cs.rpi.edu/courses/sysprog/sockets/byteorder.html
>
> So you might take some care here. Is your software supposed to work on
> non-i368 platforms?
>
> Jan Roeloffzen.
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Walter Oney
> > Sent: Wednesday, May 14, 2003 12:08 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: Byte Order APIs.
> >
> >
> > “Mark S. Edwards” wrote:
> > > Have to roll your own, try
> >
> > No you don’t – RTFM and find RtlUlongByteSwap and related functions.
> >
> > –
> > Walter Oney, Consulting and Training
> > Basic and Advanced Driver Programming Seminars
> > Now teaming with John Hyde for USB Device Engineering Seminars Check
> > out our schedule at http://www.oneysoft.com
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@planet.nl To
> > unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@stratus.com To
> unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>

Not if you want to play nicely in the sandbox. Use the Rtl function.


Gary G. Little
Have Computer, will travel …
www.wd-3.com

“Christiaan Ghijselinck” wrote in
message news:xxxxx@ntdev…
>
>
>
> I make you happy :
>
> bswap eax
> rol ax,8
> rol WORD PTR variable,8
>
>
>
> ----- Original Message -----
> From: “Mathieu Routhier”
> To: “NT Developers Interest List”
> Sent: Wednesday, May 14, 2003 3:44 PM
> Subject: [ntdev] Re: Byte Order APIs.
>
>
> >
> > I wish there was an assembly operation to do byte swaps! That would be
so
> > quicker to do, instead of shifting and ORing.
> >
> > Mat
> >
> > -----Original Message-----
> > From: Roddy, Mark [mailto:xxxxx@stratus.com]
> > Sent: Wednesday, May 14, 2003 9:10 AM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: Byte Order APIs.
> >
> > You use the DDK versions and the DDK versions do the appropriate thing
for
> > the platform. Besides, all NT platforms are little endian, always have
been,
> > and for the foreseeable future, always will be.
> >
> > > -----Original Message-----
> > > From: xxxxx@planet.nl [mailto:xxxxx@planet.nl]
> > > Sent: Wednesday, May 14, 2003 8:50 AM
> > > To: NT Developers Interest List
> > > Subject: [ntdev] Re: Byte Order APIs.
> > >
> > >
> > > In case of using both RtlUlongByteSwap c.s. and these
> > > “home-made” functions you assume that the host-byte order is
> > > little endian.
> > >
> > > See also this Fine Material: :wink:
> > >
> > http://www.cs.rpi.edu/courses/sysprog/sockets/byteorder.html
> >
> > So you might take some care here. Is your software supposed to work on
> > non-i368 platforms?
> >
> > Jan Roeloffzen.
> >
> > > -----Original Message-----
> > > From: xxxxx@lists.osr.com
> > > [mailto:xxxxx@lists.osr.com]On Behalf Of Walter Oney
> > > Sent: Wednesday, May 14, 2003 12:08 PM
> > > To: NT Developers Interest List
> > > Subject: [ntdev] Re: Byte Order APIs.
> > >
> > >
> > > “Mark S. Edwards” wrote:
> > > > Have to roll your own, try
> > >
> > > No you don’t – RTFM and find RtlUlongByteSwap and related functions.
> > >
> > > –
> > > Walter Oney, Consulting and Training
> > > Basic and Advanced Driver Programming Seminars
> > > Now teaming with John Hyde for USB Device Engineering Seminars Check
> > > out our schedule at http://www.oneysoft.com
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@planet.nl To
> > > unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@stratus.com To
> > unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@guillemot.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> > —
> > You are currently subscribed to ntdev as:
xxxxx@compaqnet.be
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>

Also see:

RtlUlonglongByteSwap, RtlUlongByteSwap and RtlUshortByteSwap in the DDK
documentation.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Amit Manocha
Sent: Wednesday, May 14, 2003 4:34 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

Thanks Mark.
----- Original Message -----
From: “Mark S. Edwards”
> To: “NT Developers Interest List”
> Sent: Wednesday, May 14, 2003 2:52 PM
> Subject: [ntdev] Re: Byte Order APIs.
>
>
> > Have to roll your own, try
> >
> > WORD my_htons (WORD hostshort)
> > {
> > return (hostshort << 8 | (hostshort >> 8 & 0xff);
> > }
> >
> >
> > At 10:15 AM 5/14/2003, Amit Manocha wrote:
> > >Hi All,
> > >
> > >What are the APIs for byte order conversion in drivers. i.e. I am
> > >looking for replacements for ntohs, ntohl etc. in kernel
> mode. I want
> > >to convert
> the
> > >length (of type WORD) in network byte order. or I need to write my
> > >own functions for the same?
> > >
> > >Any ideas?
> > >
> > >Amit Manocha
> > >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as:
> xxxxx@mynetsec.com To
> > unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@transat-tech.com To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

> Too bad RtlUlongByteSwap() and such are not implemented in 98/me…

Code your own using BSWAP opcode.

Max

What could exactly be wrong with it ? The “RtlUshortByteSwap” just inserts - -inline- - ASM instructions :

USHORT input_word , output_word ;

output_word = RtlUshortByteSwap ( input_word ) ;

// results in :

mov dx, word ptr input_word
mov ah, dl
mov al, dh
mov word ptr output_word , ax

----- Original Message -----
From: “Gary G. Little”
Newsgroups: ntdev
To: “NT Developers Interest List”
Sent: Wednesday, May 14, 2003 5:57 PM
Subject: [ntdev] Re: Byte Order APIs.

> Not if you want to play nicely in the sandbox. Use the Rtl function.
>
> –
> Gary G. Little
> Have Computer, will travel …
> www.wd-3.com
>
> “Christiaan Ghijselinck” wrote in
> message news:xxxxx@ntdev…
> >
> >
> >
> > I make you happy :
> >
> > bswap eax
> > rol ax,8
> > rol WORD PTR variable,8
> >
> >
> >
> > ----- Original Message -----
> > From: “Mathieu Routhier”
> > To: “NT Developers Interest List”
> > Sent: Wednesday, May 14, 2003 3:44 PM
> > Subject: [ntdev] Re: Byte Order APIs.
> >
> >
> > >
> > > I wish there was an assembly operation to do byte swaps! That would be
> so
> > > quicker to do, instead of shifting and ORing.
> > >
> > > Mat
> > >
> > > -----Original Message-----
> > > From: Roddy, Mark [mailto:xxxxx@stratus.com]
> > > Sent: Wednesday, May 14, 2003 9:10 AM
> > > To: NT Developers Interest List
> > > Subject: [ntdev] Re: Byte Order APIs.
> > >
> > > You use the DDK versions and the DDK versions do the appropriate thing
> for
> > > the platform. Besides, all NT platforms are little endian, always have
> been,
> > > and for the foreseeable future, always will be.
> > >
> > > > -----Original Message-----
> > > > From: xxxxx@planet.nl [mailto:xxxxx@planet.nl]
> > > > Sent: Wednesday, May 14, 2003 8:50 AM
> > > > To: NT Developers Interest List
> > > > Subject: [ntdev] Re: Byte Order APIs.
> > > >
> > > >
> > > > In case of using both RtlUlongByteSwap c.s. and these
> > > > “home-made” functions you assume that the host-byte order is
> > > > little endian.
> > > >
> > > > See also this Fine Material: :wink:
> > > >
> > > http://www.cs.rpi.edu/courses/sysprog/sockets/byteorder.html
> > >
> > > So you might take some care here. Is your software supposed to work on
> > > non-i368 platforms?
> > >
> > > Jan Roeloffzen.
> > >
> > > > -----Original Message-----
> > > > From: xxxxx@lists.osr.com
> > > > [mailto:xxxxx@lists.osr.com]On Behalf Of Walter Oney
> > > > Sent: Wednesday, May 14, 2003 12:08 PM
> > > > To: NT Developers Interest List
> > > > Subject: [ntdev] Re: Byte Order APIs.
> > > >
> > > >
> > > > “Mark S. Edwards” wrote:
> > > > > Have to roll your own, try
> > > >
> > > > No you don’t – RTFM and find RtlUlongByteSwap and related functions.
> > > >
> > > > –
> > > > Walter Oney, Consulting and Training
> > > > Basic and Advanced Driver Programming Seminars
> > > > Now teaming with John Hyde for USB Device Engineering Seminars Check
> > > > out our schedule at http://www.oneysoft.com
> > > >
> > > > —
> > > > You are currently subscribed to ntdev as: xxxxx@planet.nl To
> > > > unsubscribe send a blank email to xxxxx@lists.osr.com
> > >
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@stratus.com To
> > > unsubscribe send a blank email to xxxxx@lists.osr.com
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@guillemot.com
> > > To unsubscribe send a blank email to xxxxx@lists.osr.com
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as:
> xxxxx@compaqnet.be
> > > To unsubscribe send a blank email to xxxxx@lists.osr.com
> > >
> >
> >
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Be careful of RtlUlonglongByteSwap on win2k. Only the bottom dword is
passed in so the return value has a trashed upper word. All of the
other byte swap functions are OK though. Also, on new ntddk.h’s, the
Rtl functions have become compiler #defines to intrinsic functions.

d

-----Original Message-----
From: Chapman Mays [mailto:xxxxx@transat-tech.com]
Sent: Wednesday, May 14, 2003 9:02 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

Also see:

RtlUlonglongByteSwap, RtlUlongByteSwap and RtlUshortByteSwap in the DDK
documentation.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Amit Manocha
Sent: Wednesday, May 14, 2003 4:34 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Byte Order APIs.

Thanks Mark.
----- Original Message -----
From: “Mark S. Edwards”
> To: “NT Developers Interest List”
> Sent: Wednesday, May 14, 2003 2:52 PM
> Subject: [ntdev] Re: Byte Order APIs.
>
>
> > Have to roll your own, try
> >
> > WORD my_htons (WORD hostshort)
> > {
> > return (hostshort << 8 | (hostshort >> 8 & 0xff);
> > }
> >
> >
> > At 10:15 AM 5/14/2003, Amit Manocha wrote:
> > >Hi All,
> > >
> > >What are the APIs for byte order conversion in drivers. i.e. I am
> > >looking for replacements for ntohs, ntohl etc. in kernel
> mode. I want
> > >to convert
> the
> > >length (of type WORD) in network byte order. or I need to write my
> > >own functions for the same?
> > >
> > >Any ideas?
> > >
> > >Amit Manocha
> > >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as:
> xxxxx@mynetsec.com To
> > unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
> —
> You are currently subscribed to ntdev as:
> xxxxx@transat-tech.com To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>


You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Mathieu Routhier wrote:

I wish there was an assembly operation to do byte swaps! That would be so
quicker to do, instead of shifting and ORing.

But there is! It’s called BSWAP EAX for 32-bits and XCHG AH, AL for 16.


Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Now teaming with John Hyde for USB Device Engineering Seminars
Check out our schedule at http://www.oneysoft.com