Attempted to read or write protected memory. This is often an indication that other m
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Attempted to read or write protected memory. This is often an indication that other m

  1. #1
    Join Date
    Oct 2009
    Posts
    1

    Attempted to read or write protected memory. This is often an indication that other m

    Hi,

    I have this error in "CopyMemory".
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    #region API
    [DllImport("Kernel32.dll", EntryPoint = "RtlMoveMemory")]
    private static extern void CopyMemory(IntPtr Destination, IntPtr Source, [MarshalAs(UnmanagedType.U4)] uint Length);
    #endregion


    IntPtr ipSource = m_bmdLogo.Scan0;
    IntPtr ipDest = (IntPtr)(pBuffer.ToInt32() + ((w * 3) * N));

    CopyMemory(ipDest, ipSource, ((uint)m_bmdLogo.Stride));

    please help regarding this issue

    Thanks !
    dhemittal@gmail.com

  2. #2
    Join Date
    May 2007
    Posts
    1,546

    Re: Attempted to read or write protected memory. This is often an indication that oth

    What exactly is it you're trying to accomplish? I suspect that you can accomplish your task without having to P/Invoke anything.
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

  3. #3
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    422

    Re: Attempted to read or write protected memory. This is often an indication that oth

    Code:
     [DllImport("Kernel32.dll", EntryPoint = "RtlMoveMemory")]
    private static extern void CopyMemory(IntPtr Destination, IntPtr Source, [MarshalAs(UnmanagedType.U4)] uint Length);
    Here entry point should be the same name as the native function you are calling is n't it ??

    also have you allocated memory for the destination pointer beforing passing it ??

  4. #4
    Join Date
    May 2007
    Posts
    1,546

    Re: Attempted to read or write protected memory. This is often an indication that oth

    The whole point of 'EntryPoint' is so you can name the C# method whatever you want and still get the correct native function.
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center