Class UnmanglerService

java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.mangling.UnmanglerService

public class UnmanglerService extends Object
The service offers access to a set of IManglingEngine for a INativeCodeUnit.
  • Field Details

    • MANGLING_ENGINE_MSVC

      public static final int MANGLING_ENGINE_MSVC
      MSVC C mangling engine.
      See Also:
    • MANGLING_ENGINE_MSVCPP

      public static final int MANGLING_ENGINE_MSVCPP
      MSVC C++ mangling engine.
      See Also:
    • MANGLING_ENGINE_MSVCPP_V2

      public static final int MANGLING_ENGINE_MSVCPP_V2
      MSVC C++ mangling engine, version 2.
      See Also:
    • MANGLING_ENGINE_CXXA

      public static final int MANGLING_ENGINE_CXXA
      Itanium C++ ABI mangling engine.
      See Also:
  • Constructor Details

    • UnmanglerService

      public UnmanglerService(INativeCodeUnit<?> codeUnit)
      Create an unmangler service.
      Parameters:
      codeUnit - native code unit
  • Method Details

    • getRegisteredEngine

      public IManglingEngine getRegisteredEngine(int manglingEngineId)
      Get a registered mangling engine.
      Parameters:
      manglingEngineId - mangling engine identifier
      Returns:
      engine, or null if none is registered for the identifier
    • registerEngine

      public boolean registerEngine(int manglingEngineId)
      Register a mangling engine.
      Parameters:
      manglingEngineId - mangling engine identifier
      Returns:
      true if the engine was registered
    • unregisterEngine

      public boolean unregisterEngine(int manglingEngineId)
      Unregister a mangling engine.
      Parameters:
      manglingEngineId - mangling engine identifier
      Returns:
      true if an engine was removed
    • unregisterAllEngines

      public void unregisterAllEngines()
      Unregister all mangling engines.
    • importUnmangledRoutineName

      public boolean importUnmangledRoutineName(INativeMethodItem routine, String mangledName, IUnmangledRoutine unmangledRoutine, boolean changeRoutineName)
      Applies unmangled routine declaration to a native routine item. This method only takes care of applying the name-related changes, i.e. setting the new routine name and the related attributes.

      See importUnmangledRoutinePrototype(INativeMethodItem, IUnmangledRoutine).

      Parameters:
      routine - routine item to update
      mangledName - the mangled declaration for this routine
      unmangledRoutine - the unmangled declaration for this routine (computed from the mangled name)
      changeRoutineName - if true the name of the routine will be changed, otherwise it will be kept as-is and only the attributes will be set
      Returns:
      true if the import was successfully done, false otherwise
    • importUnmangledRoutinePrototype

      public boolean importUnmangledRoutinePrototype(INativeMethodItem routine, IUnmangledRoutine unmangledRoutine)
      Applies unmangled routine declaration to a native routine item. This method only takes care of applying the prototype change.

      important:

      • only strict C prototypes are applied
      • mangled prototypes usually do not contain attributes, such as noreturn. Therefore the typelib prototype should be preferred to this one, if existing.

      See importUnmangledRoutineName(INativeMethodItem, String, IUnmangledRoutine, boolean).

      Parameters:
      routine - routine item to update
      unmangledRoutine - unmangled declaration for this routine
      Returns:
      true if the import was successfully done, false otherwise (e.g. because the prototype application failed)
    • unmangleRoutine

      public IUnmangledRoutine unmangleRoutine(String mangledName, boolean returnFirstResult)
      Unmangle a mangled string representing a routine.
      Parameters:
      mangledName - mangled routine name
      returnFirstResult - if true the first engine to provide a result will have the last word, otherwise a result is returned only if all engines agree (or provide no result)
      Returns:
      unmangled string if the given string can be unmangled as a routine, null otherwise
    • unmangleData

      public IUnmangledData unmangleData(String mangledName, boolean returnFirstResult)
      Unmangle a mangled string representing a data.
      Parameters:
      mangledName - mangled data name
      returnFirstResult - if true the first engine to provide a result will have the last word, otherwise a result is returned only if all engines agree (or provide no result)
      Returns:
      unmangled string if the given string can be unmangled as a data, null otherwise
    • unmangle

      public IUnmangledData unmangle(String mangledName, boolean returnFirstResult)
      Unmangle a mangled string.
      Parameters:
      mangledName - mangled name
      returnFirstResult - if true the first engine to provide a result will have the last word, otherwise a result is returned only if all engines agree (or provide no result)
      Returns:
      unmangled string if the given string can be unmangled, null otherwise