buggy vc7 code? HELP!!!

G

Guest

I've built wizard application in .NET 2003. In the CPropertyPage constructor,
last param is passed by default as sizeof(PROPSHEETPAGE). Since I have
defined _WIN32_WINNT as 0x0500, this size is passed in as 48 (which is fine).
AllocPSP() in the constructor is now allocating 48 bytes. When I stepped during runtime into constructor code and further, in the following function:
void CPropertyPage::CommonConstruct(LPCTSTR lpszTemplateName, UINT

nIDCaption, UINT nIDHeaderTitle, UINT nIDHeaderSubTitle

CommonConstruct(lpszTemplateName, nIDCaption)

if (nIDHeaderTitle != 0

VERIFY(m_strHeaderTitle.LoadString(nIDHeaderTitle))
m_psp.dwSize = sizeof(m_psp); //here the size is always 52 bytes

if (nIDHeaderSubTitle != 0

VERIFY(m_strHeaderSubTitle.LoadString(nIDHeaderSubTitle))
m_psp.dwSize = sizeof(m_psp);//here the size is always 52 bytes



m_psp.dwSize is overwritten as 52, since sizeof(m_psp) is compiled in the lib
as 52 bytes. In the disassembly, you can clearly see it
Eventually my application is crashing because of corrupted memory.

So if I build my application with _WIN32_WINNT defined as 0x0500, I have
buffer read overrun problems. Maybe Microsoft people should check this and
verify

At the moment, how do I solve this problem?
 
D

David Lowndes

I've built wizard application in .NET 2003. In the CPropertyPage constructor,
last param is passed by default as sizeof(PROPSHEETPAGE). Since I have
defined _WIN32_WINNT as 0x0500, this size is passed in as 48 (which is fine).
AllocPSP() in the constructor is now allocating 48 bytes. When I stepped during runtime into constructor code and further, >in the following function:
..
m_psp.dwSize is overwritten as 52, since sizeof(m_psp) is compiled in the lib
as 52 bytes. In the disassembly, you can clearly see it.
Eventually my application is crashing because of corrupted memory.

So if I build my application with _WIN32_WINNT defined as 0x0500, I have
buffer read overrun problems.

Do you have a few lines of code that uses CPropertySheet that
illustrates the problem you're seeing?

Dave
 
D

David Lowndes

That´s it. in Property Sheet DoModal, I´m getting a crash. Note that my
wizard is opened from a different application using ShellExecute. Double
clicking on the wiz exe itself does not give the crash.

Before we get embroiled in code, it strikes me that you should be
looking at what relevance that has to your code - it should have none,
so why is it only crashing in that circumstance?

Dave
 
G

Guest

Before we get embroiled in code, it strikes me that you should b
looking at what relevance that has to your code - it should have none
so why is it only crashing in that circumstance

I looked into it and really don't know why it crashes only when opening fro
different application. In the other application (Dialog based) I simply click o
button which calls shellexecute and opens my wizard. Only common thing betwee
both is they use same com DLL (ours) which has crypto functionality
But that aside, do you think what I observed in Vc7 CPropertyPage code can be safely ignored
Maybe memory allocated by a function in our com DLL is close to the area where propertypage/sheet code is trying to overread? We are always getting crash in memcpy function of msvcr71.dll called from BuildPropPageArray() in CPropertySheet class.
 
D

David Lowndes

I looked into it and really don't know why it crashes only when opening from
different application. In the other application (Dialog based) I simply click on
button which calls shellexecute and opens my wizard. Only common thing between
both is they use same com DLL (ours) which has crypto functionality.
But that aside, do you think what I observed in Vc7 CPropertyPage code can be safely ignored?

I don't know what to suggest, you can't ignore it though!

Can you reproduce a problem regarding the CPropertySheet/Page issue
you initially indicated in a minimal new MFC project?

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top