Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read from pointer address in Python?

I want to read in a Python script a number of bytes starting from a specific address. E.g., I want to read 40000 bytes starting from 0x561124456.

The pointer is given from a C# app. I want to use this method to pass data between the app and script. I've used a TCP socket via localhost, but I want to try this method also.

How can I do this?

like image 204
Cristian M Avatar asked Dec 18 '22 01:12

Cristian M


1 Answers

If you really want to, enjoy:

import ctypes
g = (ctypes.c_char*40000).from_address(0x561124456)

Looks like segfault fun. There are good socket-connection libraries on both languages (sockets, RPC etc...), so I would think about this again if this is for some large project.

like image 163
kabanus Avatar answered Dec 27 '22 02:12

kabanus