Embedding-friendly overhaul: exceptions, bulk I/O, cross-platform AOB & memprotect#4
Closed
ChristopherProject wants to merge 1 commit into
Closed
Embedding-friendly overhaul: exceptions, bulk I/O, cross-platform AOB & memprotect#4ChristopherProject wants to merge 1 commit into
ChristopherProject wants to merge 1 commit into
Conversation
The pom targets Java 11; without this file JitPack would build the artifact on its default JDK 8 toolchain and fail with 'release version 11 not supported'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Indirizza la roadmap "cosa manca a Mem4J" portando 3 commit incrementali su
experimental.1.
Add MIT LICENSE and CHANGELOGIl README diceva "all rights reserved": senza licenza la lib non era integrabile legalmente in progetti seri. Aggiunti
LICENSE(MIT) eCHANGELOG.md(Keep-a-Changelog).2.
Library overhaul: exceptions, bulk I/O, cross-platform AOB and memprotectit.adrian.code.exceptions):Mem4JExceptionroot →PrivilegeException,ProcessNotFoundException,ModuleNotFoundException,MemoryAccessException. Niente piùSystem.exit(-1)/MessageBox: la libreria è ora embeddabile.AutoCloseable—close()rilascia handle / fd.longend-to-end (prima troncato aintsilenziosamente).readBytes/writeBytes,readString/writeStringconCharset,readByte/Short+ write.PointerviawithByteOrder(ByteOrder).indirect32()per target a 32 bit.MemoryAccessException(prima ritornavano 0 silenziosamente).Pointer.force()— sibling pointer le cui scritture flippano la pagina aPAGE_EXECUTE_READWRITE, scrivono, ripristinano la protection (patch in.text!). No-op su Linux perché/proc/<pid>/memconCAP_SYS_PTRACEignora già la protection.NativeAccess.listModules(pid)+ProcessUtil.listModules(pid)→List<ModuleInfo>{ name, path, baseAddress, size }. Funziona su entrambi i backend.SignatureUtil.findSignature(ProcessSession, …)(legge a chunk di 64 KiB), nuovi costruttoriSignatureManager(Pointer)/SignatureManager(ProcessSession, moduleName). Le firmeWinNT.HANDLErestano come@Deprecated.NativeAccess.protect / allocate / free / queryProtection. Windows wrappaVirtualProtectEx/VirtualAllocEx/VirtualFreeEx/VirtualQueryEx. Linux supportaqueryProtectionvia/proc/<pid>/maps; le altre tre lancianoUnsupportedOperationException(servirebbe injection di syscall via ptrace).3.
Build: sources & javadoc jars, CI matrix, README overhaulmaven-source-plugin+maven-javadoc-plugin: ora la build produceMem4J-x.y.z.jar,-sources.jare-javadoc.jar— IDE dei consumer mostrano docs e codice navigabile.ubuntu-latest+windows-latest. Submission del dependency graph solo da Linux su push (evita duplicate).force(), AOB cross-platform, wrapper memprotect, sezione "Linux examples" con 3 esempi end-to-end + note suCAP_SYS_PTRACE/ptrace_scope.Breaking changes
Memory.readMemory/writeMemoryora rispettanolong offset(prima truncato).MemoryAccessExceptioninvece di restituire 0.System.exit: errori → eccezioni.Pointer.add(int)→add(long)con overloadintmantenuto.Out of scope (intenzionale)
Test plan
mvn -B packagesu Linux JDK 11/21: BUILD SUCCESS, 3 jar generati.NativeAccess.get() == LinuxAccess,listModules(pid)ritorna 19 moduli,Pointer.getBaseAddress("definitely-not-a-process-xyz")→ProcessNotFoundException, lettura ELF magic OK, read di indirizzo non mappato →MemoryAccessException,queryProtectionritornaREADper la prima mappatura del binariojava,force()non solleva su Linux.windows-latestbuilda anche lui (i wrapperVirtualProtectEx/AllocEx/FreeEx/QueryExnon sono stati testati su Windows reale)..textdi un eseguibile Windows conforce().writeBytes(...)per validare il dance di protezione.