Hello
I have been working on creating a file format converter for dissassmbing java .class files into jasmin assembly language so that I can see how different two java classes are. I have been using the d-java program for that, however the program always writes the disassembled output to stdout, and there is no option in BC3 to capture stdout instead of using an output file, so I had to create a perl wrapper script:
This program is necessary because BC3 requires conversion programs to take their input from a file, and emit it to another file. Can we have a type of conversion where the text to be converted is piped through the conversion program instead of requiring temporary files? This could be done by having a pair of checkboxes on the conversion dialog, one labeled "pipe original to stdin" the other labeled "read output from stdout".
You can also see in the above program that I had to create a copy of the input file with the correct extension. This is because if the input is passed to d-java as a file rather than a pipe, it will only convert files with a .class extension, and because I was comparing files in an archive (a java .jar file). BC3 had to extract a copy which got a .tmp extension.
I have been working on creating a file format converter for dissassmbing java .class files into jasmin assembly language so that I can see how different two java classes are. I have been using the d-java program for that, however the program always writes the disassembled output to stdout, and there is no option in BC3 to capture stdout instead of using an output file, so I had to create a perl wrapper script:
Code:
#!/bin/perl use File::Copy; use File::Basename; my ($src, $dest) = @ARGV; open DEBUGOUT, '>>', 'C:\\Program Files\\d-java\\d-java_DEBUG.txt'; print DEBUGOUT "Args:\n\tsrc = $src\n\tdest = $dest\n"; # Copy the src file to .class so that the dissasmber will load it. my ($name,$path,$suffix) = fileparse($src, qr/\.[^.]*/); my $newName = $path.$name.'.class'; copy $src, $newName; print DEBUGOUT "\t$src coppied to $newName\n"; chdir "C:/Program Files/d-java"; my $cmd = sprintf 'D-Java.exe -e C:\\Temp\\d-java_DEBUG.log -o jasmin -n lvt -n lnt "%s"', $newName; print DEBUGOUT "\tDissaembly command: \"$cmd\"\n"; open CMDOUT, '-|', $cmd or die "Error running d-java dissassember $!"; my @jasminLines = <CMDOUT>; close CMDOUT; printf DEBUGOUT "\t%d lines of jasmin disassmbly produced\n", scalar @jasminLines; open OUTFILE, '>', $dest or die "Error writing output to $dest $!"; print OUTFILE @jasminLines; close OUTFILE; print DEBUGOUT "Written to $dest\n\n"; close DEBUGOUT;
You can also see in the above program that I had to create a copy of the input file with the correct extension. This is because if the input is passed to d-java as a file rather than a pipe, it will only convert files with a .class extension, and because I was comparing files in an archive (a java .jar file). BC3 had to extract a copy which got a .tmp extension.
Comment