コード例 #1
0
ファイル: MethodHasher.cs プロジェクト: dwjsong/AuthPlatelet
        public static void saveMethod(MethodRecord mr)
        {
            if (!Directory.Exists(methodsFolder))
            {
                Directory.CreateDirectory(methodsFolder);
            }

            try
            {
                System.IO.StreamWriter file = new System.IO.StreamWriter(methodsFolder + @"\" + mr.getSHA() + ".txt");

                file.Write(mr.ToString());
                file.Close();
            }
            catch (IOException)
            {
            }
        }
コード例 #2
0
ファイル: CST_Ops.cs プロジェクト: dwjsong/AuthPlatelet
        public static void recordme(Object o, CST_MSG in_msg, CST_MSG out_msg, MethodInfo mi, string partyName, bool signed, bool server_to_server)
        {
            Type objT = o.GetType();
            var  t    = mi.ReflectedType;

            string rootClass = GetRootClassName(t);

            string className = objT.FullName;

            className = className.Replace("\\", string.Empty).Replace('+', '.');

            string methodName = mi.Name;

            ParameterInfo[] pi      = mi.GetParameters();
            string[]        args    = new string[pi.Length];
            string          argType = "";

            if (pi.Length > 0)
            {
                argType = pi[0].ParameterType.FullName;
                argType = argType.Replace("\\", string.Empty).Replace('+', '.');
            }

            string returnType = mi.ReturnType.FullName;

            returnType = returnType.Replace("\\", string.Empty).Replace('+', '.');

            string methodkey = returnType + " " + className + " " + rootClass + "." + methodName + "(" + argType + ")";
            string sha       = "0000000000000000000000000000000000000000";

            if (!methodSHADict.ContainsKey(methodkey))
            {
                string dllName = objT.Module.FullyQualifiedName;

                string path = Path.GetDirectoryName(dllName);
                string name = Path.GetFileNameWithoutExtension(dllName);

                var descriptionAttribute = objT.Module.Assembly
                                           .GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)
                                           .OfType <AssemblyDescriptionAttribute>()
                                           .FirstOrDefault();

                if (descriptionAttribute != null)
                {
                    sha = descriptionAttribute.Description;
                }

                MethodRecord mr = new MethodRecord(className, rootClass, methodName, argType, returnType, name + "." + sha);

                MethodHasher.saveMethod(mr);

                uploader.uploadMethodRecord(MethodHasher.methodsFolder + "\\" + mr.getSHA() + ".txt", mr.getSHA());

                methodSHADict.AddOrUpdate(methodkey, mr, (k, v) => v);
                methodSHADictKEYSHA.AddOrUpdate(mr.getSHA(), mr, (k, v) => v);

                sha = mr.getSHA();
            }
            else
            {
                sha = methodSHADict[methodkey].getSHA();
            }

            string colons = ":";

            if (signed)
            {
                colons = "::";
            }

            string in_msg_symT = in_msg.SymT;

            if (server_to_server)
            {
                int idx = in_msg_symT.IndexOf('(');

                if (idx != -1)
                {
                    in_msg_symT = '(' + in_msg_symT.Substring(0, idx) + '(' + in_msg_symT.Substring(idx, in_msg_symT.Length - idx) + "))";
                }
            }

            out_msg.SymT = partyName + colons + sha + "(" + in_msg_symT + ")";
        }