Create you own structure derived from OVERLAPPED
:
struct MyOverlapped : OVERLAPPED
{
CALLBACK MyCallback;
};
Now use this instead:
MyOverlapped *o=new MyOverlapped;
o->MyCallback=CallbackHandler;
WriteFile(..,..,MyOverlapped);
Then when you get the OVERLAPPED
back you can cast it to your derived version:
MyOverlapped *o=static_cast<MyOverlapped*>(overlapped);
And now you can access the callback. I'm guessing you're getting the OVERLAPPED
instance back from a call to GetQueuedCompletionStatus
where the pointer you get back will actually point to your derived structure.