使用python写入内存地址

时间:2020-08-17 12:53:13

标签: python dma

我正在使用一些内存地址,需要读取和写入这些位置。从主系统中,我正在访问linux子系统,并尝试写入仅该子系统可访问的内存位置

计划是从主系统ssh并使用python脚本执行一些任务,这将要求python从基地址开始将一个结构写入该内存中

到目前为止,我一直使用C ++实际上直接从起始基地址 _location_I_wish_to_write 分配一些内存,因为现在内存只能由子系统访问,我正在考虑编写一个Python脚本,该脚本将确实在做同样的事情,但是找不到合适的参考书

如果python想要简单,有没有一种方法可以使用C ++将 _location_I_wish_to_write 实际映射到 some_struct ,并简单地分配结构值,如下面给出的代码片段?

// need to set the struct here at _location_I_wish_to_write
some_struct * some_struct_name = (some_struct *)&_location_I_wish_to_write[0];
memset(some_struct_name , 0x00, sizeof(some_struct ));
some_struct_name->some_value = 0x1;

0 个答案:

没有答案