Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2003

Tip: Looking for answers? Try searching our database.

Memory access violations and Managed C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BillyO - 17 Sep 2003 01:28 GMT
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;
}
Ronald Laeremans [MSFT] - 30 Sep 2003 00:36 GMT
Verifiable managed code does. Your example does not.

Ronald Laeremans
Visual C++ team

> In the attached code fragment I have a buffer overflow and
> a memory access violation. When I run the code .Net fails to
[quoted text clipped - 36 lines]
>     return 0;
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.