What happens at the machine level when you attach an event handler?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Merad

Platinum Member
May 31, 2010
2,586
19
81
Where is the address for the message queue? That's what I want to know.

We don't know. Somewhere in the kernel. We don't access the message queue directly, we talk to it by calling functions like GetMessage or PeekMessage. The same applies so an assembly program.

According to MSDN GetMessage is defined in Winuser.h and included in User32.lib/User32.dll. You will have to figure out how to link your assembly program against external libraries, and you should be able call the function.

You keep passing pointers to the message to functions that will read / interpret the message. Where do those pointers point?

Do you understand how pointers work in C? If so that should answer your question.

Code:
MSG msg;  // allocate space on the stack for a MSG struct
GetMessage(&msg, ...) // pass the address of msg to the function

You can do the same in hand coded assembly as I mentioned a few posts back.
 

chrstrbrts

Senior member
Aug 12, 2014
522
3
81
We don't know. Somewhere in the kernel. We don't access the message queue directly, we talk to it by calling functions like GetMessage or PeekMessage. The same applies so an assembly program.

Code:
MSG msg;  // allocate space on the stack for a MSG struct
GetMessage(&msg, ...) // pass the address of msg to the function

You can do the same in hand coded assembly as I mentioned a few posts back.

Whoa, whoa, whoa......hold on here.

Are you telling me that the &msg pointer points to a location in RAM that the getMessage function writes to and not reads from?

So, you're saying that the getMessage function goes to some kernel address to grab the message from the queue and then writes a copy of the message where &msg points?!

Merad, WHY DIDN'T YOU SAY SO?!

This entire time I thought you were passing a pointer to the function that pointed to where the message was to be read from.

That's why I kept asking about where &msg points.

I thought that &msg was pointing to the queue.

Jesus.....
 
Last edited: