Package cuchaz.enigma.mapping

Examples of cuchaz.enigma.mapping.ClassEntry


    // get all the child nodes
    List<MethodInheritanceTreeNode> nodes = Lists.newArrayList();
    for( String subclassName : index.getTranslationIndex().getSubclassNames( m_entry.getClassName() ) )
    {
      MethodEntry methodEntry = new MethodEntry(
        new ClassEntry( subclassName ),
        m_entry.getName(),
        m_entry.getSignature()
      );
      nodes.add( new MethodInheritanceTreeNode(
        m_deobfuscatingTranslator,
View Full Code Here


        return (T)renames.get( stringEntry );
      }
    }
    else if( thing instanceof ClassEntry )
    {
      ClassEntry classEntry = (ClassEntry)thing;
      return (T)new ClassEntry( renameClassesInThing( renames, classEntry.getClassName() ) );
    }
    else if( thing instanceof FieldEntry )
    {
      FieldEntry fieldEntry = (FieldEntry)thing;
      return (T)new FieldEntry(
View Full Code Here

  }
 
  public void write( CtClass c )
  {
    // is this an inner or outer class?
    String obfInnerClassName = new ClassEntry( Descriptor.toJvmName( c.getName() ) ).getSimpleName();
    String obfOuterClassName = m_jarIndex.getOuterClass( obfInnerClassName );
    if( obfOuterClassName == null )
    {
      // this is an outer class
      obfOuterClassName = Descriptor.toJvmName( c.getName() );
    }
    else
    {
      // this is an inner class, rename it to outer$inner
      ClassEntry obfClassEntry = new ClassEntry( obfOuterClassName + "$" + obfInnerClassName );
      c.setName( obfClassEntry.getName() );
     
      BehaviorEntry caller = m_jarIndex.getAnonymousClassCaller( obfInnerClassName );
      if( caller != null )
      {
        // write the enclosing method attribute
View Full Code Here

    InnerClassesAttribute attr = new InnerClassesAttribute( c.getClassFile().getConstPool() );
    c.getClassFile().addAttribute( attr );
    for( String obfInnerClassName : obfInnerClassNames )
    {
      // get the new inner class name
      ClassEntry obfClassEntry = new ClassEntry( obfOuterClassName + "$" + obfInnerClassName );
     
      // here's what the JVM spec says about the InnerClasses attribute
      // append( inner, outer of inner if inner is member of outer 0 ow, name after $ if inner not anonymous 0 ow, flags );
     
      // update the attribute with this inner class
      ConstPool constPool = c.getClassFile().getConstPool();
      int innerClassIndex = constPool.addClassInfo( obfClassEntry.getName() );
      int outerClassIndex = 0;
      int innerClassSimpleNameIndex = 0;
      if( !m_jarIndex.isAnonymousClass( obfInnerClassName ) )
      {
        outerClassIndex = constPool.addClassInfo( obfClassEntry.getOuterClassName() );
        innerClassSimpleNameIndex = constPool.addUtf8Info( obfClassEntry.getInnerClassName() );
      }
     
      attr.append(
        innerClassIndex,
        outerClassIndex,
        innerClassSimpleNameIndex,
        c.getClassFile().getAccessFlags() & ~AccessFlag.SUPER
      );
     
      /* DEBUG
      System.out.println( String.format( "\tOBF: %s -> ATTR: %s,%s,%s (replace %s with %s)",
        obfClassEntry,
        attr.outerClass( attr.tableLength() - 1 ),
        attr.innerClass( attr.tableLength() - 1 ),
        attr.innerName( attr.tableLength() - 1 ),
        Constants.NonePackage + "/" + obfInnerClassName,
        obfClassEntry.getName()
      ) );
      */
     
      // make sure the outer class references only the new inner class names
      c.replaceClassName( Constants.NonePackage + "/" + obfInnerClassName, obfClassEntry.getName() );
    }
  }
View Full Code Here

  {
    m_namer = namer;
   
    // stuff from the bytecode
   
    m_classEntry = new ClassEntry( Descriptor.toJvmName( c.getName() ) );
    m_fields = HashMultiset.create();
    for( CtField field : c.getDeclaredFields() )
    {
      m_fields.add( scrubSignature( field.getSignature() ) );
    }
View Full Code Here

     
      @Override
      public String update( String className )
      {
        // classes not in the none package can be passed through
        ClassEntry classEntry = new ClassEntry( className );
        if( !classEntry.getPackageName().equals( Constants.NonePackage ) )
        {
          return className;
        }
       
        // is this class ourself?
View Full Code Here

   
    // check the method matches
    System.out.println( "Checking methods..." );
    for( ClassMapping classMapping : mappings.classes() )
    {
      ClassEntry classEntry = new ClassEntry( classMapping.getObfName() );
      for( MethodMapping methodMapping : classMapping.methods() )
      {
        // skip constructors
        if( methodMapping.getObfName().equals( "<init>" ) )
        {
          continue;
        }
       
        MethodEntry methodEntry = new MethodEntry(
          classEntry,
          methodMapping.getObfName(),
          methodMapping.getObfSignature()
        );
        if( !destIndex.containsObfBehavior( methodEntry ) )
        {
          System.err.println( "WARNING: method doesn't match: " + methodEntry );
         
          // show the available methods
          System.err.println( "\tAvailable dest methods:" );
          CtClass c = destLoader.loadClass( classMapping.getObfName() );
          for( CtBehavior behavior : c.getDeclaredBehaviors() )
          {
            MethodEntry declaredMethodEntry = new MethodEntry(
              new ClassEntry( classMapping.getObfName() ),
              behavior.getName(),
              behavior.getSignature()
            );
            System.err.println( "\t\t" + declaredMethodEntry );
          }
         
          System.err.println( "\tAvailable source methods:" );
          c = sourceLoader.loadClass( matchedClassNames.inverse().get( classMapping.getObfName() ) );
          for( CtBehavior behavior : c.getDeclaredBehaviors() )
          {
            MethodEntry declaredMethodEntry = new MethodEntry(
              new ClassEntry( classMapping.getObfName() ),
              behavior.getName(),
              behavior.getSignature()
            );
            System.err.println( "\t\t" + declaredMethodEntry );
          }
View Full Code Here

      case Opcode.INVOKEDYNAMIC:
      case Opcode.INVOKESPECIAL:
      {
        int index = m_iter.s16bitAt( pos + 1 );
        return new MethodEntry(
          new ClassEntry( Descriptor.toJvmName( m_constants.getMethodrefClassName( index ) ) ),
          m_constants.getMethodrefName( index ),
          m_constants.getMethodrefType( index )
        );
      }
     
      case Opcode.INVOKEINTERFACE:
      {
        int index = m_iter.s16bitAt( pos + 1 );
        return new MethodEntry(
          new ClassEntry( Descriptor.toJvmName( m_constants.getInterfaceMethodrefClassName( index ) ) ),
          m_constants.getInterfaceMethodrefName( index ),
          m_constants.getInterfaceMethodrefType( index )
        );
      }
    }
View Full Code Here

    InnerClassesAttribute attr = (InnerClassesAttribute)c.getClassFile().getAttribute( InnerClassesAttribute.tag );
    if( attr != null )
    {
      for( int i=0; i<attr.tableLength(); i++ )
      {
        ClassEntry classEntry = new ClassEntry( Descriptor.toJvmName( attr.innerClass( i ) ) );
        if( attr.innerNameIndex( i ) != 0 )
        {
          attr.setInnerNameIndex( i, constants.addUtf8Info( classEntry.getInnerClassName() ) );
        }
       
        /* DEBUG
        System.out.println( String.format( "\tDEOBF: %s-> ATTR: %s,%s,%s",
          classEntry,
View Full Code Here

         
          // convert path/to/class.inner to path/to/class$inner
          str = str.replace( '.', '$' );
         
          // remember everything else
          entries.add( new ClassEntry( str ) );
        }
        return null;
      }
      private static final long serialVersionUID = -202160293602070641L;
    };
View Full Code Here

TOP

Related Classes of cuchaz.enigma.mapping.ClassEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.