Click here to Skip to main content
15,894,405 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Multiple includes Pin
Aescleal31-Aug-10 0:30
Aescleal31-Aug-10 0:30 
GeneralRe: Multiple includes Pin
Tim Craig31-Aug-10 8:59
Tim Craig31-Aug-10 8:59 
GeneralRe: Multiple includes Pin
Aescleal31-Aug-10 9:13
Aescleal31-Aug-10 9:13 
GeneralRe: Multiple includes Pin
Paul Michalik31-Aug-10 12:35
Paul Michalik31-Aug-10 12:35 
GeneralRe: Multiple includes Pin
Tim Craig31-Aug-10 13:12
Tim Craig31-Aug-10 13:12 
GeneralRe: Multiple includes Pin
Paul Michalik31-Aug-10 21:29
Paul Michalik31-Aug-10 21:29 
GeneralRe: Multiple includes [modified] Pin
Paul Michalik31-Aug-10 6:28
Paul Michalik31-Aug-10 6:28 
GeneralRe: Multiple includes Pin
Shy Agam31-Aug-10 21:27
Shy Agam31-Aug-10 21:27 
GeneralRe: Multiple includes Pin
Paul Michalik31-Aug-10 23:57
Paul Michalik31-Aug-10 23:57 
GeneralRe: Multiple includes Pin
Shy Agam1-Sep-10 2:13
Shy Agam1-Sep-10 2:13 
QuestionIs there any difference in drawing emf on CDC and Bitmap? Pin
Sameerkumar Namdeo29-Aug-10 21:46
Sameerkumar Namdeo29-Aug-10 21:46 
Questionhow to find memory leaks in attached dll Pin
ganesh.dp29-Aug-10 20:02
ganesh.dp29-Aug-10 20:02 
AnswerRe: how to find memory leaks in attached dll Pin
Eugen Podsypalnikov29-Aug-10 20:18
Eugen Podsypalnikov29-Aug-10 20:18 
AnswerRe: how to find memory leaks in attached dll PinPopular
Niklas L29-Aug-10 20:41
Niklas L29-Aug-10 20:41 
AnswerRe: how to find memory leaks in attached dll Pin
ThatsAlok29-Aug-10 20:54
ThatsAlok29-Aug-10 20:54 
AnswerRe: how to find memory leaks in attached dll Pin
rp_suman30-Aug-10 4:14
rp_suman30-Aug-10 4:14 
QuestionBlackBerry IMEI Number Pin
MsmVc29-Aug-10 18:55
MsmVc29-Aug-10 18:55 
AnswerRe: BlackBerry IMEI Number Pin
ThatsAlok29-Aug-10 23:19
ThatsAlok29-Aug-10 23:19 
GeneralRe: BlackBerry IMEI Number Pin
MsmVc29-Aug-10 23:21
MsmVc29-Aug-10 23:21 
GeneralRe: BlackBerry IMEI Number Pin
sayonee30-Aug-10 1:30
sayonee30-Aug-10 1:30 
GeneralRe: BlackBerry IMEI Number Pin
MsmVc30-Aug-10 1:34
MsmVc30-Aug-10 1:34 
GeneralRe: BlackBerry IMEI Number Pin
enhzflep30-Aug-10 16:24
enhzflep30-Aug-10 16:24 
QuestionHooking OleGetClipboard Pin
Member 382162029-Aug-10 10:28
Member 382162029-Aug-10 10:28 
Hello everyone,

I would like to hook OleGetClipboard to return a custom IDataObject.
Injecting my code in the target application and hooking the function is quite easy and works pretty well. However, things get messy after the code of the function has been executed (app crash after a few seconds).

Here is the code of the MyOleGetClipboard function:

HRESULT MyOleGetClipboard(LPDATAOBJECT *ppDataObj)
{
FORMATETC f = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
STGMEDIUM s = { TYMED_HGLOBAL, { 0 }, 0 };

s.hGlobal = GetFileToPaste(); // Returns the handle to the DROPFILES structure (memory allocated with GlobalAlloc)

*ppDataObj = new MyDataObject(&f, &s, 1);
return (*ppDataObject) ? S_OK : E_OUTOFMEMORY;
}


The target application calls the methods from the returned object successfully, but I suspect some memory-related problem. For instance, the following code will also lead to a crash after a few seconds:


struct CFoo
{
CFoo()
{
m_i = new int[512];
}

~CFoo()
{
delete [] m_i;
}

int *m_i;
};

HRESULT MyOleGetClipboard(LPDATAOBJECT *ppDataObj)
{
CFoo *f = new CFoo();
delete f;

return fpOleGetClipboard(ppDataObj); // Call the original implementation
}



Do you have any idea on how I should deal with this?
Any help or hint would be greatly appreciated.

Thank you!
AnswerRe: Hooking OleGetClipboard Pin
Code-o-mat29-Aug-10 22:12
Code-o-mat29-Aug-10 22:12 
GeneralRe: Hooking OleGetClipboard Pin
Member 382162030-Aug-10 0:19
Member 382162030-Aug-10 0:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.