#!/usr/bin/perl -w
$file = $ARGV[0];
open (ORIG, $file);

while ($line = <ORIG>) {
	if ( $line =~ /(\.custom instance void)(class| .*)(Microsoft\.VisualBasic\.CompilerServices\.__DefaultArgumentValueAttribute::\.ctor)(.*)/) { 

		@type = split (/[()]/, $4);
		if ($type[1] =~ /string/) {
			@str = split (/ /, $type[3]);
			$size = hex $str [3];
			
			if ($size == 0){
				print ("=\"\"\n");
			}elsif ($size == 255) {
				print ("= nullref\n");
			}else{	
				print " = bytearray ( ";
				print LOG " = bytearray ( ";
				for ($i = 4; $i < @str - 2; $i ++) {
						print $str [$i] . " 00 ";
						print LOG $str [$i] . " 00 ";
				}
				print LOG "00 00 )\n";
				print "00 00 )\n";
			}
		}elsif ($type [1] =~ /object/){
			#Check for null, Eg. Collection.Add method			
			@str = split (/ /, $type[3]);
			$size = hex $str [3];

			if ($size == 14 && hex $str [4] == 255) {
				#0x0E(14) - String
				print " = nullref\n";
			}else{
				print "= " . $type [1] ."(0x";
			
				@str = split (/ /, $type[3]);
				for ($i = @str - 2 -1; $i >= 4;$i --) {
					print $str [$i] ;
				}

				print ")\n";
			}
		}elsif ($type [1] =~ /bool/) {
			@str = split (/ /, $type[3]);
			if ($str [3] == 01) {
				print "= bool(true)\n";	
			}else {
				print "= bool(false)\n";	
			}
		}else {
			print "= " . $type [1] ."(0x";
			
			@str = split (/ /, $type[3]);
			for ($i = @str - 2 -1; $i >= 3;$i --) {
						print $str [$i] ;
				}

			print ")\n";
		}
	}else{
		print $line;
	}
}

close (ORIG);
