Giter VIP home page Giter VIP logo

Comments (6)

Zeex avatar Zeex commented on August 16, 2024

Are you using Y_Less's variant of GetAmxBase or something similar? I once made a JIT-compatible version which reads the function address direcrly from code rather than the stack (I think you remember) but as far as I can see from YSI AMX_GetGlobal uses the old method.

from samp-plugin-jit.

oscar-broman avatar oscar-broman commented on August 16, 2024

The only script actually reading/writing using GetAmxBase is SQLitei, which has your JIT compatible version.

I'm still trying to find the point where it stops working in the script.. So far I've found it executes OnScriptInit in y_masteronce.inc`, but after that I'm unsure.

from samp-plugin-jit.

Zeex avatar Zeex commented on August 16, 2024

After rewriting AMX_GetGlobal it crashed in another place (seems like a problem with return address) and this time I'm not sure where it happens as Visual Studio can't show me the stack trace so this becomes a bit tricky.

static AMX_DoNothing() {
    return 0;
}

static AMX_GetGlobal()
{
    new
        addr = -1;
    // Call dummy function and read its (absolute) address from code.
    AMX_DoNothing();
    #emit LCTRL      6
    #emit CONST.alt  12
    #emit SUB
    #emit LOAD.alt   AMX_HEADER_COD
    #emit ADD
    #emit STOR.S.pri addr
    #emit LREF.S.pri addr
    // Get difference between absolute and relative addresses.
    #emit SUB
    #emit CONST.alt  AMX_DoNothing
    #emit SUB
    #emit MOVE.alt
    #emit LCTRL      1
    #emit XCHG
    #emit SUB
    // Return
    #emit STACK 4
    #emit RETN
    return 0;
}

from samp-plugin-jit.

oscar-broman avatar oscar-broman commented on August 16, 2024

Well, y_hooks does alter the addresses in the publics table. Perhaps it could be related to that.

from samp-plugin-jit.

jte avatar jte commented on August 16, 2024

The return address at the time of a crash is 10c18 which is after instruction "call 0x100013CA" EDIT: That call is actually calling jit::JIT::doJump. These instructions are in "0xdeb8" procedure.
You can inspect crash and acquire info as follows, you first need IDA Pro Advanced(the newer -- the better), then you download PAWN-Boilerplate and compile it(of course, include jit plugin). Now you need to open IDA Pro Advanced and load up samp-server.exe into it. Then start samp-server.exe with debugger and wait for exception. When it happens, you have clear view at stack in the window "Stack view". You can know what address is where in generated code if you turn on generating .asm in jit settings(server.cfg).
EDIT 2: It crashes somewhere in YSI's OnScriptInit. It jumps to it successfully.
EDIT 3: It returns from OnScriptInit.
EDIT 4: Found it, 'eax' that was returned from OnScriptInit is invalid. Or it was changed in unpredictable ways. My conclusion is that 'eax' was needed after call but was saved across-function boundary ??? seems so though i am confused :O
EDIT 5: Null pointer dereference(crash) is at 10c1d. Scrap that. It seems that return address is getting overwritten, thus it returns in a section where Unicode text resides.
Suggestion: You better track it yourself the way i described above because you will have all the info you need :)

from samp-plugin-jit.

Y-Less avatar Y-Less commented on August 16, 2024

See #51 for why I think this is happening and my proposed solution (implemented in #52)

from samp-plugin-jit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.