digitalmars.D.learn - accessing memory from address
- bojoe (5/5) Aug 30 2014 I am interfacing with a dll that returns a pointer to an int.
- Rikki Cattermole (11/16) Aug 30 2014 In the c world integral types are a bit more complicated. So for
- bojoe (3/8) Aug 30 2014 that was silly - looks like I just needed to do this:
I am interfacing with a dll that returns a pointer to an int. In python, I can use from_address: shape=list((c_int*rank).from_address(pi[2].contents.value)) Is there something equivalent in d? Or do I need to manually call ReadProcessMemory at that location?
Aug 30 2014
On 31/08/2014 1:41 a.m., bojoe wrote:I am interfacing with a dll that returns a pointer to an int. In python, I can use from_address: shape=list((c_int*rank).from_address(pi[2].contents.value)) Is there something equivalent in d? Or do I need to manually call ReadProcessMemory at that location?In the c world integral types are a bit more complicated. So for reference take a look at the table on [0]. As long as you have a pointer to a piece of data such as int* or void* you should be free to dereference it to get the value. Such as: extern(C) int* myCFunc(); void main() { int value = *myCFunc(); } [0] http://dlang.org/interfaceToC.html
Aug 30 2014
On Saturday, 30 August 2014 at 13:41:27 UTC, bojoe wrote:I am interfacing with a dll that returns a pointer to an int. In python, I can use from_address: shape=list((c_int*rank).from_address(pi[2].contents.value)) Is there something equivalent in d? Or do I need to manually call ReadProcessMemory at that location?that was silly - looks like I just needed to do this: int shapex = *(cast(int*)shape);
Aug 30 2014