Example #1
0
        public static string ReadJavaString(HeapObject stringObj)
        {
            FieldReferenceValue charArrayReference = (FieldReferenceValue)stringObj.GetField("value", "[C");
            HeapArray           charArray          = (HeapArray)Heap.GetItem(charArrayReference.Address);

            return(new string((char[])charArray.Array));
        }
Example #2
0
        private static void WriteObjectValue(string type, int argument)
        {
            if (argument == 0)
            {
                Console.ForegroundColor = classNameColor;
                Console.Write(type);

                Console.ForegroundColor = separatorColor;
                Console.Write('/');

                Console.ForegroundColor = nullColor;
                Console.Write("Null");
            }
            else
            {
                ClassFile argCFile = Heap.GetObject(argument).ClassFile;
                if (argCFile.Name == "java/lang/String")
                {
                    Console.ForegroundColor = stringColor;
                    FieldReferenceValue charArr = (FieldReferenceValue)Heap.GetObject(argument).GetField("value", "[C");
                    if (charArr.Address == 0)
                    {
                        Console.ForegroundColor = classNameColor;
                        Console.Write(Heap.GetObject(argument).ClassFile.Name);
                    }
                    else
                    {
                        Console.Write('"' + JavaHelper.ReadJavaString(argument) + '"');
                    }
                }
                else if (argCFile.Name == "java/lang/Class")
                {
                    Console.ForegroundColor = classObjColor;
                    Console.Write(JavaHelper.ClassObjectName(argument));
                }
                else
                {
                    Console.ForegroundColor = classNameColor;
                    Console.Write(Heap.GetObject(argument).ClassFile.Name);
                }
                Console.ForegroundColor = separatorColor;
                Console.Write('/');

                Console.ForegroundColor = objAddrColor;
                Console.Write(argument);
            }
        }