在程序分配的内存之外访问.(访问其他应用程序的内存) [英] Accessing outside the memory allocated by the program. (Accessing other app's memory)

查看:35
本文介绍了在程序分配的内存之外访问.(访问其他应用程序的内存)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以访问(读取或释放)位于为程序分配的内存之外的内存块,而不会出现访问冲突异常.好吧,除此之外,我实际上想了解的是内存清理器(系统垃圾收集器)是如何工作的.我一直想写一个这样的程序.(语言不是问题)

Is there a way to access (read or free) memory chunks that are outside the memory that is allocated for the program without getting access violation exceptions. Well what I actually would like to understand apart from this, is how a memory cleaner (system garbage collector) works. I've always wanted to write such a program. (The language isn't an issue)

提前致谢:)

推荐答案

简单的答案(我没看错),不.通常这不是一个好主意,原因有两个.首先是因为它会导致您的程序和其他程序之间出现信任问题(更不用说我们人类也不会信任您的应用程序).其次,如果您能够访问另一个应用程序的内存并在应用程序不知情的情况下进行更改,您将导致应用程序崩溃(病毒也会这样做).

The simple answer (less I'm mistaken), no. Generally it's not a good idea for 2 reasons. First is because it causes a trust problem between your program and other programs (not to mention us humans won't trust your application either). second is if you were able to access another applications memory and make a change without the application knowing about it, you will cause the application to crash (also viruses do this).

从运行时调用垃圾收集器.运行时拥有"内存空间并允许其他应用程序在该内存空间中生存".这就是垃圾收集器可以存在的原因.您将必须创建操作系统为其分配内存的运行时,让运行时在其权限下执行应用程序并在其权限下使用 GC.您需要允许一些工具或 API 允许应用程序开发人员从您的运行时(而不是操作系统)请求"内存,并且您的运行时不仅可以响应此类请求,还可以跟踪它的内存空间分配给该应用程序.您可能需要一个框架(一组 DLL)来使应用程序可以使用这些调用(开发人员将使用它们在其应用程序内形成请求).

A garbage collector is called from a runtime. The runtime "owns" the memory space and allows other applications to "live" within that memory space. This is why the garbage collector can exist. You will have to create a runtime that the OS allocates memory to, have the runtime execute the application under it's authority and use the GC under it's authority as well. You will need to allow some instrumentation or API that allows the application developer to "request" memory from your runtime (not the OS) and your runtime have a way to not only response to such a request but also keep track of the memory space it's allocating to that application. You will probably need to have a framework (set of DLL's) that makes these calls available to the application (the developer would use them to form the request inside their application).

您必须确保垃圾收集器不会删除正在执行的应用程序使用的内存之外的内存,因为您的运行时中可能同时运行超过 1 个应用程序.

You have to be sure that your garbage collector does not remove memory other then the memory that is used by the application being executed, as you may have more then 1 application running within your runtime at the same time.

希望这会有所帮助.

这篇关于在程序分配的内存之外访问.(访问其他应用程序的内存)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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