/* ###
 * IP: GHIDRA
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nsis;

import ghidra.app.services.AbstractAnalyzer;
import ghidra.app.services.AnalyzerType;
import ghidra.app.util.importer.MessageLog;
import ghidra.framework.options.Options;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.Program;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;

/**
 * TODO: Provide class-level documentation that describes what this analyzer
 * does.
 */
public class NsisAnalyzer extends AbstractAnalyzer {

	public NsisAnalyzer() {

		// TODO: Name the analyzer and give it a description.

		super("Nsis", "Analyzer description goes here",
				AnalyzerType.BYTE_ANALYZER);
	}

	@Override
	public boolean getDefaultEnablement(Program program) {

		// TODO: Return true if analyzer should be enabled by default

		return false;
	}

	@Override
	public boolean canAnalyze(Program program) {

		// TODO: Examine 'program' to determine of this analyzer should analyze
		// it.
		// Return true
		// if it can.

		return false;
	}

	@Override
	public void registerOptions(Options options, Program program) {

		// TODO: If this analyzer has custom options, register them here

		options.registerOption("Option name goes here", false, null,
				"Option description goes here");
	}

	@Override
	public boolean added(Program program, AddressSetView set,
			TaskMonitor monitor, MessageLog log) throws CancelledException {

		// TODO: Perform analysis when things get added to the 'program'. Return
		// true if
		// the
		// analysis succeeded.

		return false;
	}
}

@@ -961,88 +961,102 @@
  * T
-ODO: Provide class-level documentation that describes what this analyzer%0A * does
+his analyzer finds NSIS bytecode and will try to decompile it into the%0A * original NSIS script
 .%0A *
@@ -1140,152 +1140,194 @@
 ) %7B%0A
-%0A
 %09%09
-// TODO: Name the analyzer and give it a description.%0A%0A%09%09super(%22Nsis%22, %22Analyzer description goes here%22,%0A%09%09%09%09AnalyzerType.BYTE_ANALYZER);%0A%09%7D%0A
+super(%22NSIS script decompiler%22, %22Decompiles NSIS bytecode into NSIS script.%22,%0A%09%09%09%09AnalyzerType.BYTE_ANALYZER);%0A%09%7D%0A%0A%09/**%0A%09 * Determines if the analyzer should be enabled by default%0A%09 */
 %0A%09@O
@@ -1394,93 +1394,99 @@
 ) %7B%0A
-%0A
 %09%09
-// TODO: Return true if analyzer should be enabled by default%0A%0A%09%09return false;%0A%09%7D%0A
+return true;%0A%09%7D%0A%0A%09/**%0A%09 * Determines if this analyzer can analyze the given program.%0A%09 */
 %0A%09@O
@@ -1543,394 +1543,409 @@
 ) %7B%0A
-%0A
 %09%09
-// TODO: Examine 'program' to determine of this analyzer should analyze%0A%09%09// it.%0A%09%09// Return true%0A%09%09// if it can.%0A%0A%09%09return false;%0A%09%7D%0A%0A%09@Override%0A%09public void registerOptions(Options options, Program program) %7B%0A%0A%09%09// TODO: If this analyzer has custom options, register them here%0A%0A%09%09options.registerOption(%22Option name goes here%22, false, null,%0A%09%09%09%09%22Option description goes here%22);%0A%09%7D%0A
+String format = program.getExecutableFormat();%0A%09%09if (format.equals(NsisLoader.NE_NAME)) %7B%0A%09%09%09return true;%0A%09%09%7D%0A%09%09return false;%0A%09%7D%0A%0A%09/**%0A%09 * Registers the options provided to the user for this analyzer.%0A%09 */%0A%09@Override%0A%09public void registerOptions(Options options, Program program) %7B%0A%09%7D%0A%0A%09/**%0A%09 * Perform analysis when things get added to the 'program'. Return true if the%0A%09 * analysis succeeded.%0A%09 */
 %0A%09@O
@@ -2010,20 +2010,17 @@
 iew set,
-%0A%09%09%09
+ 
 TaskMoni
@@ -2047,17 +2047,20 @@
 Log log)
- 
+%0A%09%09%09
 throws C

Integrate analyzer (#45)