Announcement

Collapse
No announcement yet.

CopyMemory: Memory Access Violation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CopyMemory: Memory Access Violation

    The whole error message:
    Originally posted by PBWin Debugger Output
    Exception: Memory Access Violation
    Program tried to read or write an invalid memory address
    The code that causes it:
    Code:
    PROPERTY SET MemoryBuffer(BYVAL dwLength AS DWORD, BYVAL dwData AS DWORD)
    ' note that depending on what you're passing
    ' length needs to be ZERO based
        LOCAL pBuffer, pSource AS BYTE POINTER, pLength, pIndex AS DWORD
        REDIM memBuffer(dwLength)
        pSource = dwData
        pBuffer = VARPTR(memBuffer(0))
        pLength = dwLength ' + 1
        CopyMemory(pBuffer,pSource,pLength)
    END PROPERTY
    dwData is a pointer to STRPTR(dynamicstring$)
    dwLength is the length of the string -1

    If I replace the CopyMemory with this:
    Code:
        FOR pIndex = 0 TO dwLength
            memBuffer(pIndex) = @pSource[pIndex]
        NEXT pIndex
    It works, so it must be something in the way I'm passing the pointers to CopyMemory that's wrong.

    Anyone out there can Clue/4 me?
    Furcadia, an interesting online MMORPG in which you can create and program your own content.

  • #2
    Use BYVAL on parameters 1 and 2. CopyMemory is simply an encapsulation of the MoveMemory API function (ie. they are exactly the same)
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Well, that worked, now to work around another issue, and that is, you can't pass FreeImage_GetFileTypeFromHandle a reference to an Object and expect the object to pass through unscathed, apparently FreeImage is calling the Object's DESTROY mechanism somewhere.
      Furcadia, an interesting online MMORPG in which you can create and program your own content.

      Comment


      • #4
        Originally posted by colin glenn View Post
        Well, that worked, now to work around another issue
        Colin, you would probably get more exposure if you post the new issue in a seperate thread. Also, as FreeImage is a bit of a minority interest, it might be worth posting the function prototype and the code which you are using. HTH.

        Comment

        Working...
        X