Problem with access to shared memory(W2K) / ORIGINALLY (win32) speedfan api control

Claudio Grondi claudio.grondi at freenet.de
Wed Apr 6 17:30:21 EDT 2005


> For the mistake you made see below, hope that helps.
It doesn't.

> >     pBuf_buf = cast(pBuf, Buffer)
> Here's the problem.  pBuf is a pointer to a Buffer structure, not the
> buffer structure itself.
> Something like
>     pBuf_buf = Buffer.from_address(pBuf)
> may work.
If I currently understand it right, cast() should
do exactly this, i.e. should write the content
pointed to by pBuf to a Python variable
pBuf_buf which is an object of the Buffer
class, where I can access the single
components like any other Python
variables - am I right or wrong?

How can I access content at any
real memory address in Python
like you suggest with the
fictive(?) .from_address(memPointer)
method?
Wouldn't it be anyway protected?
Is not cast() a kind of solution to this
problem?

Because the exepected buffer
contains zero bytes I can't use
cast(pBuf, c_char_p) to get the entire
content as it is done in the recipe
provided by Srijit Kumar Bhadra.
At least the .Data0 value is set by cast()
in my trials, but it seems, that this has
nothing to do with the shared memory
area content.

> For the general way to solve this problem you should know that you can
> access a shared memory area with a certain name also with Python's mmap
> module, although that is probably not documented very good.  There was a
> recipe posted a few days ago which showed different ways to acces shared
> memory, with or without ctypes.

> > The code I use is provided also here:
> >  http://www.codecomments.com/Python/message430495.html
> >  http://mail.python.org/pipermail/python-list/2005-March/271853.html
> > (the mmap part of it doesn't work at all)

So I am already using the recipe, right?
But it doesn't work as expected.
mmap doesn't work at all failing in
shmem = mmap.mmap(0, 0, "$M$B$M$5$S$D$", mmap.ACCESS_READ)
with WindowsError: [Errno 87] wrong parameter

I am on Windows 2000 SP 4, Pyhon version 2.3.5
using ctypes version 0.9.5 .

Any further hints?

Claudio





More information about the Python-list mailing list