Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

markdezonia

what is (HWND) really?

This topic is 5291 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
Google lead me here, I was trying to understand what DECLARE_HANDLE actually was too.

Looks to me like it''s mostly used to enforce type checking.

But the technical answer appears to be: "it''s a thang".

Sigh...I''ve been coding so long I guess...back in the day when we _did_ bother to understand such...thangs.

Cya

MikeInDallas

Share this post


Link to post
Share on other sites
Advertisement
When expanded, the DECLARE_HANDLE(HWND) line looks like:

struct HWND__
{
int unused;
};

typedef HWND__ *HWND


The ## preprocesser token is like the function strcat, except instead of concatenating strings at runtime, in concatenates strings at compile-time. When used cleverly with macros, you can easily create new variable or struct names.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
A handle can bee seen as a user-mode identifier of a kernel-mode object.

For instance, if you call CreateFile (which is a function exported from kernel32.dll), that function is a thin wrapper that will cause a kernel-mode transition. The kernel will (via some drivers) open the file requested and keep some data related to that file (where it is on disk etc.). The "return value" from the kernel is some value, so that ReadFile/CloseHandle etc. can operate on that file.

What the handle actually is in the kernel isn''t really something you need to know about and in theory it could change. It could as mentioned be some index to a table, or a memory pointer used by the kernel.

The kernel obviously needs to do thorough checking to validate the pointer when you call CloseHandle etc. so you don''t pass a malicious value, or call CloseHandle twice with the same value.1

You can read about the "Object Manager" in Windows here: http://www.winntmag.com/

The object manager does not handle graphics, but you should get an understanding about how user-mode and kernel-mode relate to each other.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!