Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: Hooking OleGetClipboard Pin
Code-o-mat30-Aug-10 0:38
Code-o-mat30-Aug-10 0:38 
GeneralRe: Hooking OleGetClipboard Pin
Member 382162030-Aug-10 2:02
Member 382162030-Aug-10 2:02 
GeneralRe: Hooking OleGetClipboard Pin
Code-o-mat30-Aug-10 2:30
Code-o-mat30-Aug-10 2:30 
GeneralRe: Hooking OleGetClipboard Pin
Member 382162030-Aug-10 3:17
Member 382162030-Aug-10 3:17 
GeneralRe: Hooking OleGetClipboard Pin
Code-o-mat30-Aug-10 3:30
Code-o-mat30-Aug-10 3:30 
GeneralRe: Hooking OleGetClipboard Pin
Member 382162030-Aug-10 4:32
Member 382162030-Aug-10 4:32 
GeneralRe: Hooking OleGetClipboard Pin
Code-o-mat30-Aug-10 4:37
Code-o-mat30-Aug-10 4:37 
QuestionThe header file process.h Pin
Danzy8328-Aug-10 3:41
Danzy8328-Aug-10 3:41 
AnswerRe: The header file process.h Pin
«_Superman_»28-Aug-10 4:47
professional«_Superman_»28-Aug-10 4:47 
GeneralRe: The header file process.h Pin
markkuk28-Aug-10 5:30
markkuk28-Aug-10 5:30 
AnswerRe: The header file process.h PinPopular
Aescleal28-Aug-10 5:00
Aescleal28-Aug-10 5:00 
GeneralRe: The header file process.h Pin
Sauro Viti28-Aug-10 6:00
professionalSauro Viti28-Aug-10 6:00 
GeneralRe: The header file process.h Pin
Paul Michalik29-Aug-10 1:07
Paul Michalik29-Aug-10 1:07 
Questionhow do I handle the VSCROLL from CMFCRibbonEdit on ribbon in CMainFrame? Pin
andrewxiang27-Aug-10 17:58
andrewxiang27-Aug-10 17:58 
QuestionHow to declare pointer to member function Pin
Danzy8327-Aug-10 14:02
Danzy8327-Aug-10 14:02 

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.