Memory access violations and Managed C++

B

BillyO

In the attached code fragment I have a buffer overflow and
a memory access violation. When I run the code .Net fails to
verify the IL because of the buffer overflow and I get an exception
as expected. My question relates to the memory access violation,
specfically, what should happen? My guess is that since the good
ole new operator allocates the memory we get an SEH memory access
violation exception. Given that this can occur in my managed
code fragment, what assurances do I have when running such code?
I had thought that managed code prevented this kind of access
violation.

Thanks for your help, and sorry for the dumb question, I'm a little
late to the party.



// This is the main project file for VC++ application project
// generated using an Application Wizard.

#include "stdafx.h"

#using <mscorlib.dll>
#include <tchar.h>

using namespace System;

// This is the entry point for this application
int _tmain(void)
{
// TODO: Please replace the sample code below with your own.
int* pInt=new int;

// bad boy
pInt[0xA]=0x999;

int Buffer[0xA];
Buffer[0xAA]=0xDDDD;

//String* pTempStr=new String("Hello world");
//Console::WriteLine(pTempStr);
return 0;
}
 
R

Ronald Laeremans [MSFT]

Verifiable managed code does. Your example does not.

Ronald Laeremans
Visual C++ team
 

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