convert LARGE_INTEGER to DWORD

Actually, there were a large number of OS’es that were developing new
components in C and which had done this long before Cutler did it to annoy
you. Part of the reasoning behind the types was that the companies doing it
had 16 and 32 bit systems, and people hated C when they found that the size
of int changed depending on the system. Another reason this was commonly
done was that we were writing code that communicated from one system to
another, it was better to have one ULONG32 type that you knew was 32-bits
always than having to worry what the compiler guys choose.

As I stated in my earlier post, there was actually a lot of this being done
in some of the earliest Unix ports, since the original Unix code was pretty
hard coded to a PDP-11 (i.e. 16-bit, byte addressing and little endian).
Having been drafted in the mid-70’s to help on some of these ports, you get
a very different view of Unix than those who came along say 8 to 10 years
later when Unix was considered the great portable OS (and even then had a
ton of warts).

There were multiple books and articles on writing portable C code back in
the late 70’s early 80’s since this was considered a black art, and
consultants made a ton going in and fixing attempts of some firms.

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Tuesday, May 05, 2015 11:26 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] convert LARGE_INTEGER to DWORD

Well, I am afraid the only people in the world who can explain it to you are
the ones who had actually invented the above “masterpieces”.The only thing
left to us is to speculate about it.

If you asked me about it, my suggestion would be pretty much the same as
the one that I had made earlier on this thread.

Don’t forget that C and UNIX are closely related. Apparently, the inventors
of the above “masterpieces” would have preferred to write their kernel in
some language other than C, but writing a compiler and a new language was,
apparently, considered to be a bit to the extreme. After all, it would
require quite a bit of extra resources, so that NT architects would have to
justify it somehow. Lets face it - if you are asked why C is unfit for the
purpose of designing a kernel, saying " just because C is closely related to
UNIX, and I hate UNIX" would hardly provide a viable justification for
hiring a compiler team. Therefore, they had to do it in C.

In order to alleviate the pain that they had to endure, they decided to make
it look as C-unlike as possible. To be honest, I just don’t see any other
explanation as to why someone may want to rename all internal C datatypes.

Concerning the choice of names, I guess they chose these names simply to
make the whole thing as programmer-unfriendly as possible, effectively
ensuring that “By programmers, for programmers”
principle definitely does not apply to their “creation”. To be honest, I
just don’t see any other explanation as to why someone may want to chose
something as ridiculous as “typedef unsigned __int64 DWORDLONG;”

Concerning the actual style, I guess they chose it because they wanted to
make Windows programming particularly enjoyable to those folks who prefer to
have CapsLock key on 90% of the time. If you read NTDEV on regular basis you
must that these folks tend to be “MSFT aficinados”…

Anton Bassov


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

“First learn how to put 10 pounds of sh*t into a 5 pound bag.”

Hahaha. Love this !
Lately these threads become funnier and funnier. Pure gold :slight_smile:

> “First learn how to put 10 pounds of sh*t into a 5 pound bag.”

Hahaha. Love this !
Lately these threads become funnier and funnier. Pure gold :slight_smile:

The OP could have been honoured instead if he asked an “intelligent” question , such as :
“Does exist a very , very strong compression technic which is able to shrivel up a 64 bit value into a 32 bit variable”
Hahaaa !

Christiaan

This reminds me of a University of Illinois Computer Science Graduate School
Qualifying Exam question:

What is a compressor?

a. A part of a refrigerator
b. An algorithm to put N bits of data in less than N bits of space
c. …

It is amazing how many potential grad students answered b, when the correct
answer was a

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Christiaan
Ghijselinck
Sent: Wednesday, May 06, 2015 7:12 AM
To: Windows System Software Devs Interest List
Subject: Re: RE:[ntdev] convert LARGE_INTEGER to DWORD

“First learn how to put 10 pounds of sh*t into a 5 pound bag.”

Hahaha. Love this !
Lately these threads become funnier and funnier. Pure gold :slight_smile:

The OP could have been honoured instead if he asked an “intelligent”
question , such as :
“Does exist a very , very strong compression technic which is able to
shrivel up a 64 bit value into a 32 bit variable”
Hahaaa !

Christiaan


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Actually, to make ‘b’ a wrong option one would have to point out that the the compression is meant to be lossless. As long as you allow for the possibility of lossy compression option ‘b’ is not all that wrong. For example, you could sacrifice few rightmost bits in a situation when extreme precision
is not that important…

Anton Bassov

[quote]

Actually, there were a large number of OS’es that were developing new
components in C and which had done this long before Cutler did it to annoy
you. Part of the reasoning behind the types was that the companies doing it
had 16 and 32 bit systems, and people hated C when they found that the size
of int changed depending on the system.

[quote]

… Well, I don’t really know what these OSes were doing, but I strongly suspect that they were NOT trying to address the issue that you have mention above the “Cutler’s way”, i.e. with “typedef unsigned int UINT;”-like definitions, for the (hopefully) obvious reasons…

Anton Bassov

> Hahaha @Peter always make my day, not that he is impressive knowledgeable

individual, yet humor sense ads that perfection. I_LOVE_OSR (y)

Vow!!! It looks like we have one more arse-licker on NTDEV…

You seem to be on the right way for becoming an MVP, Zach…

BTW, if you are interested I could give you a couple more tips about how you can succeed with your task.

I would say 90+% of the questions being asked here are basically the same. What you have to do is just to read the archives, to memorize few recipes like “use KMDF instead of WDM”, “use inverted call instead of events”, “sharing memory between the kernel and a process is a security risk”, etc. There are not so many of them anyway (around a dozen or so), so that you can memorize them fairly easily. At this point you can already start “helping people” by repeating the above mantras like a parrot and throwing them in whenever and wherever it applies.

Another important thing is to learn “who is who” here, so that you are able to stay “on the right side of a discussion” all the time - if you never argue with what the “right people” say and repeat everything after them all the time you will be just fine…

Good luck with your task, matie…

Anton Bassov

Hey Anton,

I’m not ****, I’m just trying to say the truth, Peter he is impressively knowledgeable individual, have you seen his books? He is like a Hero for me as beginner, I want to be like him one day, like so many others including you respectively .

By the way I will check out all of the recipes that you have mentioned .

Yeah I got the point, by the way I don’t argue I justify myself, yet

I figured out this is how beginners are treated in mailing lists and I have to accept it if I want to learn and carry on .

Anyhow, thanks for the advice .

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: 06 May 2015 14:21
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] convert LARGE_INTEGER to DWORD

Hahaha @Peter always make my day, not that he is impressive
knowledgeable individual, yet humor sense ads that perfection.
I_LOVE_OSR (y)

Vow!!! It looks like we have one more arse-licker on NTDEV…

You seem to be on the right way for becoming an MVP, Zach…

BTW, if you are interested I could give you a couple more tips about how you can succeed with your task.

I would say 90+% of the questions being asked here are basically the same. What you have to do is just to read the archives, to memorize few recipes like “use KMDF instead of WDM”, “use inverted call instead of events”, “sharing memory between the kernel and a process is a security risk”, etc. There are not so many of them anyway (around a dozen or so), so that you can memorize them fairly easily. At this point you can already start “helping people” by repeating the above mantras like a parrot and throwing them in whenever and wherever it applies.

Another important thing is to learn “who is who” here, so that you are able to stay “on the right side of a discussion” all the time - if you never argue with what the “right people” say and repeat everything after them all the time you will be just fine…

Good luck with your task, matie…

Anton Bassov


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Micron Europe Limited
Registered in England, Company No. 02341071
Registered Office: L’Avenir, Opladen Way
Bracknell, Berkshire RG12 0PH, UK

Actually, Anton that was the recommended standard approach to making C
portable at a time that Dave Cutler was still off working on a PL/1 compiler
port. It is amazing how many OS guys in the past had actually worked in the
languages world.

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@hotmail.com
Sent: Wednesday, May 06, 2015 8:55 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] convert LARGE_INTEGER to DWORD

[quote]

Actually, there were a large number of OS’es that were developing new
components in C and which had done this long before Cutler did it to annoy
you. Part of the reasoning behind the types was that the companies doing it
had 16 and 32 bit systems, and people hated C when they found that the size
of int changed depending on the system.

[quote]

… Well, I don’t really know what these OSes were doing, but I strongly
suspect that they were NOT trying to address the issue that you have
mention above the “Cutler’s way”, i.e. with “typedef unsigned int
UINT;”-like definitions, for the (hopefully) obvious reasons…

Anton Bassov


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> It goes back farther than that. Point me to serious C-coded OS or systems

project which doesn?t have concrete datatypes for specific sizes of the loosely
defined C types.

The above statement makes sense only as long as you are speaking about definitions like
" typedef __int64 whatever". The ones like “typedef unsigned int UINT;” (i.e. renaming a type that happens to be loosely-sized anyway) does not seem to apply here, does it…

Anton Bassov

> Actually, Anton that was the recommended standard approach to making C portable

???

What is the point of redefining a type if its size is compiler-dependent anyway???

Although " typedef unsigned __int32 UINT32" definition makes a perfect sense, the ones like “typedef unsigned int UINT;” does not seem to(at least to me)…

It is amazing how many OS guys in the past had actually worked in the
languages world

It must have been a truly exciting time when designing your own OS or a compiled language
was a kind of a standard assignment, so that one could reasonably expect to work on multiple OSes and compilers throughout a career…

Anton Bassov

Don Burn wrote:

40+ years ago when Unix was first escaping Bell Labs, it did not have
concrete datatypes for C specific (or at least in all cases), but that was
one of the first things people were fixing due to all the problems of
porting this supposedly “portable OS”. I like a lot of others got drafted
to fix pieces for given ports.

<stdint.h> is one of the greatest advances in this regard, and should
have been done long ago. I now using uint8_t and uint32_t in virtually
all of my projects. They are clear and unambiguous.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.</stdint.h>

The problem was everyone had an opinion. I remember Thomas Plum proposed “tiny” for numerical char values. He also proposed that there be macros such as SHORT(x) as a way to specify a “((short) x)”. Now Plum was consider a pioneer in a lot of things, but I sure would not have wanted to see this.

The C language that most of us know went through a lot of mistakes like many languages in their early years. It isn’t easy to design a language or even an extension for a language that gets popular approval. It was hard enough to get acceptance when it was a compiler extension for a specific firms hardware, once you moved into the standard realm things get crazy.

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Wednesday, May 06, 2015 12:48 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] convert LARGE_INTEGER to DWORD

Don Burn wrote:

40+ years ago when Unix was first escaping Bell Labs, it did not
have concrete datatypes for C specific (or at least in all cases), but
that was one of the first things people were fixing due to all the
problems of porting this supposedly “portable OS”. I like a lot of
others got drafted to fix pieces for given ports.

<stdint.h> is one of the greatest advances in this regard, and should have been done long ago. I now using uint8_t and uint32_t in virtually all of my projects. They are clear and unambiguous.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</stdint.h>

On 04-May-2015 17:32, xxxxx@gmail.com wrote:

Hello all

Is there any way to convert LARGE_INTEGER to DWORD?

Look in the intsafe.h file in the SDK.
It has all kinds of such conversions.

  • pa

On 06-May-2015 13:36, xxxxx@gmail.com wrote:

“First learn how to put 10 pounds of sh*t into a 5 pound bag.”

Hahaha. Love this !
Lately these threads become funnier and funnier. Pure gold :slight_smile:

And you know what “gold” is an euphemism for :wink:

– pa

> we have all sorts of hacks, including the ones derided by Anton, to work around

the fact that a particular algorithm makes assumptions that might not be true in
another compilation environment.

Please note that I DO NOT deride the “hacks” that actually provide a workaround for the issue mentioned above. As Peter (from MSFT) pointed out, this is a standard approach for any project that targets more than one architecture. The only thing I am trying to point out (although, as I can see, without any visible progress - you cannot question anything designed by Cutler in this NG, can you) that simply redefining built-in C types like int and long does NOT provide any workaround and serves no practical purpose other than making the whole thing look ugly…

Anton Bassov

By the way - opensource stdint.h and inttypes.h for older MSC compilers
are here:
http://code.google.com/p/msinttypes

  • pa

> And you know what “gold” is an euphemism for :wink:

IIRC, this is something from XIX-century Russian language. However, AFAIK, the word referred not to the substance in itself but rather to people who were actually handling it - they were referred to (more or less) as “goldminers”…

Anton Bassov

> If you want an unsigned value that is pointer width that you can do arithmetic with, the data type is

ULONG_PTR. I agree this is a confusing name, but there really *is* no name

size_t is another name, which is also portable to Linux.

It is a good idea to use size_t (and ssize_t) for ALL your integers.

If you need explicit exact bitness (which is a rare case) - use __int32 and such and create the Linux portable typedefs for them.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

> “auto” is a fabulous tool when working with STL and template types,

…and is more like a copy-paste from C#'s “var” keyword.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com