Getting the object from a memory address using ctype python
up vote
0
down vote
favorite
Basically I have a ctype structure like below:
class A(Structure):
fields = [('x', c_uint),
('y', c_uint),
('z', c_char_p),
('a', c_wchar_p),
('b', c_uint),
('c', c_uint),
('d', c_uint),
('e', c_uint),
('f', c_uint),
('g', c_uint)]
pack = 1
Now i have a below function where i am instantiating the class and setting the values
def func( self,x,y):
ins = A()
ins.x = 3
ins.y = 4
now i need to pass the pointer to the memory location of the structure
ptr = pointer(ins) also tried addressof
passing the pointer to a function(memory address basically)
func2(param1,ptr)
now i want to check the all values like x,y,z etc from the pointer if there are any changes
ptr.contents()-->not working for me
so if anyone know how to get the values back , that would be great help.
i know there are may be any methods that i can use, also tried. but everything fails
python pointers memory ctype
add a comment |
up vote
0
down vote
favorite
Basically I have a ctype structure like below:
class A(Structure):
fields = [('x', c_uint),
('y', c_uint),
('z', c_char_p),
('a', c_wchar_p),
('b', c_uint),
('c', c_uint),
('d', c_uint),
('e', c_uint),
('f', c_uint),
('g', c_uint)]
pack = 1
Now i have a below function where i am instantiating the class and setting the values
def func( self,x,y):
ins = A()
ins.x = 3
ins.y = 4
now i need to pass the pointer to the memory location of the structure
ptr = pointer(ins) also tried addressof
passing the pointer to a function(memory address basically)
func2(param1,ptr)
now i want to check the all values like x,y,z etc from the pointer if there are any changes
ptr.contents()-->not working for me
so if anyone know how to get the values back , that would be great help.
i know there are may be any methods that i can use, also tried. but everything fails
python pointers memory ctype
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Basically I have a ctype structure like below:
class A(Structure):
fields = [('x', c_uint),
('y', c_uint),
('z', c_char_p),
('a', c_wchar_p),
('b', c_uint),
('c', c_uint),
('d', c_uint),
('e', c_uint),
('f', c_uint),
('g', c_uint)]
pack = 1
Now i have a below function where i am instantiating the class and setting the values
def func( self,x,y):
ins = A()
ins.x = 3
ins.y = 4
now i need to pass the pointer to the memory location of the structure
ptr = pointer(ins) also tried addressof
passing the pointer to a function(memory address basically)
func2(param1,ptr)
now i want to check the all values like x,y,z etc from the pointer if there are any changes
ptr.contents()-->not working for me
so if anyone know how to get the values back , that would be great help.
i know there are may be any methods that i can use, also tried. but everything fails
python pointers memory ctype
Basically I have a ctype structure like below:
class A(Structure):
fields = [('x', c_uint),
('y', c_uint),
('z', c_char_p),
('a', c_wchar_p),
('b', c_uint),
('c', c_uint),
('d', c_uint),
('e', c_uint),
('f', c_uint),
('g', c_uint)]
pack = 1
Now i have a below function where i am instantiating the class and setting the values
def func( self,x,y):
ins = A()
ins.x = 3
ins.y = 4
now i need to pass the pointer to the memory location of the structure
ptr = pointer(ins) also tried addressof
passing the pointer to a function(memory address basically)
func2(param1,ptr)
now i want to check the all values like x,y,z etc from the pointer if there are any changes
ptr.contents()-->not working for me
so if anyone know how to get the values back , that would be great help.
i know there are may be any methods that i can use, also tried. but everything fails
python pointers memory ctype
python pointers memory ctype
edited Nov 11 at 6:00
asked Nov 10 at 15:28
Bikash Dash
14
14
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240427%2fgetting-the-object-from-a-memory-address-using-ctype-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown