如何从Python中的指针地址读取? [英] How to read from pointer address in Python?

查看:847
本文介绍了如何从Python中的指针地址读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Python脚本中读取从特定地址开始的多个字节.例如,我要读取从0x561124456开始的40000个字节.

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.

指针是从C#应用程序给出的.我想使用此方法在应用程序和脚本之间传递数据.我已经通过本地主机使用了TCP套接字,但是我也想尝试这种方法.

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.

我该怎么做?

推荐答案

如果您真的想要,请享受:

If you really want to, enjoy:

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

看起来像段错误的乐趣.两种语言都有很好的套接字连接库(套接字,RPC等),因此如果这是针对某个大型项目的话,我会再考虑一下.

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.

这篇关于如何从Python中的指针地址读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆