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;
}
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;
}