请教多个进程如何读写共享内存?
DECLARE INTEGER GetLastError IN win32apiDeclare Long OpenFileMapping In WIN32API Long, Long, String
Declare Long CreateFileMapping In WIN32API Long, Long, Long, Long, Long, String
DECLARE INTEGER CloseHandle IN kernel32.DLL INTEGER hObject
DECLARE integer GetProcessHeap IN WIN32API
DECLARE integer HeapAlloc IN WIN32API Long,Long,Long
DECLARE integer HeapFree IN WIN32API integer,integer,integer
Declare long MapViewOfFile IN WIN32API long hFileMappingObject,Long dwDesiredAccess, Long dwFileOffsetHigh, Long dwFileOffsetLow, Long dwNumberOfBytesToMap
Declare Long UnmapViewOfFile in win32api long lpBaseAddress
**申明可能有错
Declare Long WriteProcessMemory in win32api long @hProcess, Long lpBaseAddress ,long @lpBuffer ,long nSize , Long @lpNumberOfBytesWritten
Declare long ReadProcessMemory in WIN32API long hProcess , Long lpBaseAddress ,long lpBuffer,long nSize ,Long @lpNumberOfBytesWritten
cPID = "争王"
hmap = OpenFileMapping(983071, 0, cPID) &&读
If 0 == hmap &&没有创建
hmap = CreateFileMapping(-1, 0,4, 0, 40, cPID) &&读写
pmap=MapViewOfFile(hMap, 0xF0000+1+2+4+8+0x10, 0, 0, 4)
hProcHeap=GetProcessHeap()
lhMemPtr=HeapAlloc(hProcHeap,0,4)
SYS(2600,lhMemPtr,4,"1234")
lpnum=0
SYS(2600,pmap,0,,"123") &&也出错
**写内存,出错,句柄无效
* ?hmap
* ?WriteProcessMemory(@pmap,0,@lhMemPtr,4,@lpnum)
* ?lpnum
?GetLastError()
HeapFree(hProcHeap,0,lhMemPtr)
UnmapViewOfFile(pmap)
ELSE
**读内存
pmap=MapViewOfFile(hMap, 983071, 0, 0, 0)
?SYS(2600,pmap,4)
UnmapViewOfFile(pmap)
=CloseHandle(hmap)
Endif
retu