Writing to memory buffer in a .dll?

Brad Basler <[email protected]> Fri, 30 Aug 2013 13:47:58 -0700
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
I am attempting to use Python w/ctypes to control an embedded 
programming tool (see UM0151, STMicroelectronics).

I had this working before as a basic test, but not really realizing what 
I'm doing differently now. I do not seem to be writing to the code image.

Here's the function prototype I am trying to interface with.
Prototype: char far *EGetImagePtr(DWORD dwAreaId, long *MemSize)

This returns a pointer that is allocated on the heap by the .dll

I can read from this buffer, but I don't appear to be able to write to it.


where my function was defined by:
     EPRCore.dll_eprcore.EGetImagePtr.argtypes = 
[ctypes.c_uint,ctypes.c_void_p]

     EPRCore.dll_eprcore.EGetImagePtr.restype = 
ctypes.POINTER(ctypes.c_char)




ptr = self.myEPR.EGetImagePtr(self.memHandle,ctypes.byref(self.memSize))
ptr[0x8112] = 0x00;
ptr[0x8113] = 0x01;
ptr[0x8114] = 0x02;
ptr[0x8115] = 0x03;

When I program the board, the values aren't modified (serial number). 
What's going on here?

-Thanks
-Brad


-- 
Brad Basler
[email protected]
360-403-7207 Ext. 27


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk