JNA - Getting Base address

后端 未结 1 1586
南笙
南笙 2021-01-22 13:16

Recently I have been working on a little project of mine, which is Memory reading/writing in java for native games (C/C++/etc).

At the moment I have a base where I can r

相关标签:
1条回答
  • 2021-01-22 13:38

    I got it working after a bit of messing around with what Alex posted, and managed to get it working.

    for anyone else who wanted to get something like this working, have a look at that project that Alex posted and you will see the required classes you will need. then I just used this:

    public int getBaseAddress() {
            try {
                    Pointer hProcess = gethProcess();
                    List<Module> hModules = PsapiHandler.getInstance().EnumProcessModules(hProcess);
    
                    for(Module m: hModules){
                            if(m.getFileName().contains(exeName)){
                                    misc.log(m.getFileName() + ": 0x" + Long.toHexString(Pointer.nativeValue(m.getEntryPoint())));
                                    return Integer.valueOf("" + Pointer.nativeValue(m.getLpBaseOfDll()));
                            }
                    }
            } catch (Exception e) {  e.printStackTrace(); }
            return -1;
    }
    
    0 讨论(0)
提交回复
热议问题