Thread overview | |||||
---|---|---|---|---|---|
|
August 30, 2014 accessing memory from address | ||||
---|---|---|---|---|
| ||||
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? |
August 30, 2014 Re: accessing memory from address | ||||
---|---|---|---|---|
| ||||
Posted in reply to bojoe | 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 |
August 30, 2014 Re: accessing memory from address | ||||
---|---|---|---|---|
| ||||
Posted in reply to bojoe | 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);
|
Copyright © 1999-2021 by the D Language Foundation