本文介绍了如何找到用户空间在Linux中变量的物理地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一个用户空间程序中定义的变量的物理地址?有什么办法使用root权限才能做到这一点?

I want to find the physical address of a variable defined in a user-space process? Is there any way to do it using root privileges?

推荐答案

首先,你为什么要这么做?现代VM系统的目的是从physocal存储器布局的复杂性删除该应用程序的程序员。 Gving他们每一个自己统一的地址空间,使他们的生活easyer。

First, why would you want to do this? The purpose of modern VM systems is to remove the application programmer from the complexity of physocal memory layout. Gving them each their own uniform address space to make their life easyer.

如果你确实想做到这一点,你就几乎certanly需要使用一个内核模块。得到以正常的方式可变的虚拟地址,使用这个索引进程的页表并读取找到的值(帧的物理地址)。然后添加页面偏移,以获得完整的物理地址。注意:您将无法使用这个地址,而分页被启用。

If you did want to do this you would almost certanly need to use a kernel module. Get the virtual address of the variable in the normal way, use this to index into the processes page tables and read the value you find(the physical address of the frame). Then add the page offset to get the complete physical address. Note you wont be able to use this address while paging is enabled.

(如果你的运气好,你可能能够得到从/ proc文件系统中的VM区的帧地址,因此需要难道不写一个内核模块。)

(If your lucky you may be able to get the frame address of a VM region from the /proc file system and thus wouldnt require to write a kernel module.)

这篇关于如何找到用户空间在Linux中变量的物理地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-08 09:15