Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
SetSharedMem writes what is passed in the variable lpszBuf (up to character bufLength) into a shared memory location referenced by shareIndexint __export __stdcall SetSharedMem(const int shareIndex, const void* +lpszBuf, const DWORD bufLength) int __export __stdcall GetSharedMem(const int shareIndex,void* lpszBuf +, const DWORD bufLength)
I don't seem to be having a problem setting the shared memory location but when I get the shared memory location using:$SetSharedMem = Win32::API->new('shmdll', 'int SetSharedMem(int shareI +ndex, VOID* lpszBuf, DWORD bufLength)'); $GetSharedMem = Win32::API->new('shmdll', 'int GetSharedMem(int shareI +ndex,VOID* lpszBuf, DWORD bufLength)');
it seems to stop before first null character. I dumped (using Devel::Peek Dump command) the buffer when the shared memory is being set and what was returned. That looks like the following:$returnBuff = " " x ($str_length);<br> $return = $GetSharedMem->Call(0,$returnBuff,$str_length);<br><br>
Getting:SV = PV(0x1abed40) at 0x1dea898<br> REFCNT = 1<br> FLAGS = (POK,pPOK)<br> PV = 0x1dda434 "\4\4\0041234\4\4\4\10\3\2\0\0\0\n\r20\0asdfasdfaf\3\0 +\0\0Red\4 \2\1\0\0\0\n\01710|\0|Asdfasdfaf\4\0\0\0Blue"\0<br> CUR = 69<br> LEN = 70<br><br>
As you can see by the PV value it cuts off before the three nulls in a row. I am using a memcpy in the GetSharedMemory routine like:SV = PV(0x1abed64) at 0x1dea94c<br> REFCNT = 1<br> FLAGS = (POK,pPOK)<br> PV = 0x1dda218 "\4\4\0041234\4\4\4\10\3\2"\0<br> CUR = 13<br> LEN = 71<br><br>
20040204 Edit by Corion Added code tags
|
|---|