Package cuchaz.enigma.analysis

Examples of cuchaz.enigma.analysis.SourceIndex


  }
 
  public SourceIndex getSourceIndex( CompilationUnit sourceTree, String source )
  {
    // build the source index
    SourceIndex index = new SourceIndex( source );
    sourceTree.acceptVisitor( new SourceIndexVisitor(), index );
   
    // DEBUG
    //sourceTree.acceptVisitor( new TreeDumpVisitor( new File( "tree.txt" ) ), null );
   
    // resolve all the classes in the source references
    for( Token token : index.referenceTokens() )
    {
      EntryReference<Entry,Entry> deobfReference = index.getDeobfReference( token );
     
      // get the obfuscated entry
      Entry obfEntry = obfuscateEntry( deobfReference.entry );
     
      // try to resolve the class
      ClassEntry resolvedObfClassEntry = m_jarIndex.resolveEntryClass( obfEntry );
      if( resolvedObfClassEntry != null && !resolvedObfClassEntry.equals( obfEntry.getClassEntry() ) )
      {
        // change the class of the entry
        obfEntry = obfEntry.cloneToNewClass( resolvedObfClassEntry );
       
        // save the new deobfuscated reference
        deobfReference.entry = deobfuscateEntry( obfEntry );
        index.replaceDeobfReference( token, deobfReference );
      }
     
      // DEBUG
      //System.out.println( token + " -> " + reference + " -> " + index.getReferenceToken( reference ) );
    }
View Full Code Here


    // decompile the class
    CompilationUnit tree = m_deobfuscator.getSourceTree( entry.getClassName() );
    // DEBUG
    //tree.acceptVisitor( new TreeDumpVisitor( new File( "tree." + entry.getClassName().replace( '/', '.' ) + ".txt" ) ), null );
    String source = m_deobfuscator.getSource( tree );
    SourceIndex index = m_deobfuscator.getSourceIndex( tree, source );
   
    // get the token value
    Token token = index.getDeclarationToken( entry );
    if( token == null )
    {
      return null;
    }
    return source.substring( token.start, token.end );
View Full Code Here

  protected Collection<String> getReferenceTokens( EntryReference<? extends Entry,? extends Entry> reference )
  {
    // decompile the class
    CompilationUnit tree = m_deobfuscator.getSourceTree( reference.context.getClassName() );
    String source = m_deobfuscator.getSource( tree );
    SourceIndex index = m_deobfuscator.getSourceIndex( tree, source );
   
    // get the token values
    List<String> values = Lists.newArrayList();
    for( Token token : index.getReferenceTokens( (EntryReference<Entry,Entry>)reference ) )
    {
      values.add( source.substring( token.start, token.end ) );
    }
    return values;
  }
View Full Code Here

TOP

Related Classes of cuchaz.enigma.analysis.SourceIndex

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.