Is there a way to do pointers memory access?

Blitz3D Forums/Blitz3D Programming/Is there a way to do pointers memory access?

dman(Posted 2011) [#1]
How can I use the bank command to create an effect like a pointer?


Yasha(Posted 2011) [#2]
There are two main ways to play with pointers:

1) Use the RtlMoveMemory2 function in Kernel32.dll. This is the method you'll commonly see in code archive examples because it doesn't require you to distribute a DLL, but it's messy and slower than the alternative. Recommend against, search for RtlMoveMemory on these forums for many examples if you decide you really want this.

2) Use the FastPointer library by MikhailV: http://www.fastlibs.com/index.php

It's free to download, although not open-sourced. It provides several functions to get variable, array and function pointers, as well as support for multithreading. It's an essential part of the advanced B3D-er's armoury (especially once you get function pointers, you'll wonder how you ever lived without them - basically necessary for scripting and GUI).

As you may have noticed, neither of these involves using banks the way they were intended; banks are "closed", and can't be used as general purpose pointers in unmodified B3D.

Last edited 2011


_PJ_(Posted 2011) [#3]
Just curious here, what do you mean by "closed"?
Is that that on compilation their addressses are somehow inaccessible except by the compiled code itself?


Rroff(Posted 2011) [#4]
He means banks are a gated area of memory, and you can't use the bank access commands to manipulate system memory locations in general.


Yasha(Posted 2011) [#5]
"Closed" meaning that what you can do with the bank commands is limited to the extent of the bank itself. e.g. CreateBank() returns a new block of memory, in an unpredictable location: you can't create a bank "over" some other object to use it as a window onto its bytes (although this is precisely what RtlMoveMemory does). Once a bank is created, Peek and Poke are limited to accessing memory within that bank's block, so you can't create a bank of size 12 and then peek bytes at offset -5 or 14; similarly you can only Peek and Poke objects created as banks, and not e.g. Entities.

In other words, I was just stating the obvious, badly.

EDIT: Yeah, what Rroff said.

Last edited 2011


Rroff(Posted 2011) [#6]
I've never actually tried peeking/poking entity objects using the bank commands lol, never even ocurred to me to try.