开发者

How do I get a value from an address using Java?

For an obfuscation program I am writing in Java, I need to find a way to get a value at a specific address. For example, in a program I opened in a hex editor, at the address 0000001F is the hex value "00". Furthermore, is it possible to write to a specific memory address? For example 开发者_运维问答writing to 0000001F and changing it from "00" to for example, "FF"


To answer your first question, you can open a file as a binary stream and read whatever you want from it. That won't do much in the way of the classloader, but if you have a custom classloader that manipulates the file and converts it at runtime into a class that is valid and loaded by the JVM, that is certainly theoretically possible. I would wonder what the point is, though, as the classloader itself would not be obfuscated in this manner.

To answer your second question, no you cannot write directly to a memory address with Java. You could call a function via JNI which could do so (outside of the JVM memory allocation).

It sounds to me like you are using the wrong language for what you want to do.


You are using the wrong language. C or C++ would be better choices because you can easily call operating system libraries (on most systems) and attempt to access the memory at a particular location.

Most POSIX-compliant operating systems implement mmap which allows you to map memory at a particular location in the current processes address space.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜