# Peek & poke from/to a MemoryBlock

**URL:** <https://forum.xojo.com/t/peek-poke-from-to-a-memoryblock/64815>\
**Category:** SDKs\
**Created:** [July 31, 2021, 9:50am UTC](https://forum.xojo.com/t/peek-poke-from-to-a-memoryblock/64815 "2021-07-31T09:50:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierre\_Vareilles](https://forum.xojo.com/letter_avatar_proxy/v4/letter/p/3be4f8/32.png) [@Pierre\_Vareilles](https://forum.xojo.com/u/Pierre_Vareilles)\
**Post date:** [July 31, 2021, 9:50am UTC](https://forum.xojo.com/t/peek-poke-from-to-a-memoryblock/64815/1 "2021-07-31T09:50:45Z")

</div>

Can anyone tell me why I can’t get function pointer to get/set values of a MemoryBlock. Thanks

 

```nohighlight
REALobject mb = NULL;

mb = REALnewInstanceWithClass(memoryblockRef);
if (!mb)
   return NULL;

typedef void (*setByte)(REALobject obj, RBInteger offset, unsigned char val);
setByte mbSetByte = (setByte)REALLoadObjectMethod(mb, "Byte(offset As Integer, Assigns val As UInt8)");
    
typedef RBInteger (*getByte)(REALobject obj, RBInteger offset);
getByte mbGetByte = (getByte)REALLoadObjectMethod(mb, "Byte(offset As Integer)");

if ((!mbGetByte) || (!mbSetByte))
    return mb; // return NULL ??????
    
REALSetPropValueInteger(mb, "Size", bufSize);

..........
..........
..........
```

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [July 31, 2021, 10:06am UTC](https://forum.xojo.com/t/peek-poke-from-to-a-memoryblock/64815/2 "2021-07-31T10:06:30Z")

</div>

Please read older thread first

> [@REALMemoryBlockGetPtr replacement](https://forum.xojo.com/t/realmemoryblockgetptr-replacement/22688/16):
>
> If you mean poking inside the REALobject itself, don’t. The internals are subject to change and it will only hurt users. I would recommend against this too, though more of an academic point to warn about doing this in other situations. It’s possible, albeit very unlikely, that you could get given a subclass of MemoryBlock that overrides this method.

---

<div class="post-metadata">

**Author:** ![Pierre\_Vareilles](https://forum.xojo.com/letter_avatar_proxy/v4/letter/p/3be4f8/32.png) [@Pierre\_Vareilles](https://forum.xojo.com/u/Pierre_Vareilles)\
**Post date:** [July 31, 2021, 11:32am UTC](https://forum.xojo.com/t/peek-poke-from-to-a-memoryblock/64815/3 "2021-07-31T11:32:34Z")

</div>

Thanks Christian. Invaluable help as usual.
