Global access to allocated memory from 2 different programs
Posted: Wed Sep 11, 2013 3:01 pm
Hello PB Lovers!
I have a question regarding accessing allocated memory from 2 different programs - maybe its a silly quation so please excuse me:
If I allocate a memory block on the HEAP with AllocateMemory() Function and I save the adrees in a *MemID variable and I let the program wait
so that this memory will not be freed - is it possible to access this memory an its contents from a second launched PB exe?
Example:
exe1:
<code>
*MemoryID = AllocateMemory(5000)
If *MemoryID
Debug "Startadresse des 5000 Byte Speicherbereichs ist:"
Debug *MemoryID
PokeS(*MemoryID, "Wir speichern diesen String im Speicherbereich")
wait until Keypressed() // pseudo code program - shall wait until a key is pressed
FreeMemory(*MemoryID) ; wird am Ende des Programms auch automatisch erledigt
Else
Debug "Konnte den angeforderten Speicher nicht reservieren!"
EndIf
</code>
Let's assume the *MemoryID is 230440
Now I let this program run an launch a second exe:
exe2:
<code>
*MemoryID = 230440
Text.s = peeks(*MemoryID)
Debug Text
</code>
I don't see the TExt - maybe nothiung or maybe weird characters.
Is this possible at all or isn't it possible beacause of mem protection from the OS?
Thanx a lot for your time!
Greets
andi
I have a question regarding accessing allocated memory from 2 different programs - maybe its a silly quation so please excuse me:
If I allocate a memory block on the HEAP with AllocateMemory() Function and I save the adrees in a *MemID variable and I let the program wait
so that this memory will not be freed - is it possible to access this memory an its contents from a second launched PB exe?
Example:
exe1:
<code>
*MemoryID = AllocateMemory(5000)
If *MemoryID
Debug "Startadresse des 5000 Byte Speicherbereichs ist:"
Debug *MemoryID
PokeS(*MemoryID, "Wir speichern diesen String im Speicherbereich")
wait until Keypressed() // pseudo code program - shall wait until a key is pressed
FreeMemory(*MemoryID) ; wird am Ende des Programms auch automatisch erledigt
Else
Debug "Konnte den angeforderten Speicher nicht reservieren!"
EndIf
</code>
Let's assume the *MemoryID is 230440
Now I let this program run an launch a second exe:
exe2:
<code>
*MemoryID = 230440
Text.s = peeks(*MemoryID)
Debug Text
</code>
I don't see the TExt - maybe nothiung or maybe weird characters.
Is this possible at all or isn't it possible beacause of mem protection from the OS?
Thanx a lot for your time!
Greets
andi