Ildasm.Disassembler.GetExportedMethods C# (CSharp) Method

GetExportedMethods() static private method

static private GetExportedMethods ( Module module ) : List>.Dictionary
module Module
return List>.Dictionary
        static Dictionary<int, List<ExportedMethod>> GetExportedMethods(Module module)
        {
            int rva;
            int length;
            module.__GetDataDirectoryEntry(0, out rva, out length);

            if (rva == 0 || length < 40)
            {
                return new Dictionary<int, List<ExportedMethod>>();
            }

            ExportDirectoryTable edt = new ExportDirectoryTable();
            byte[] buf = new byte[512];
            module.__ReadDataFromRVA(rva, buf, 0, 40);
            edt.Read(new BinaryReader(new MemoryStream(buf)));

            var methods = new Dictionary<int, List<ExportedMethod>>();
            for (int i = 0; i < edt.NumberOfNamePointers; i++)
            {
                module.__ReadDataFromRVA((int)edt.OrdinalTableRVA + i * 2, buf, 0, 2);
                int ordinal = BitConverter.ToInt16(buf, 0) + (int)edt.OrdinalBase;
                string name = null;
                if (edt.NamePointerRVA != 0)
                {
                    module.__ReadDataFromRVA((int)edt.NamePointerRVA + i * 4, buf, 0, 4);
                    module.__ReadDataFromRVA(BitConverter.ToInt32(buf, 0), buf, 0, buf.Length);
                    int len = 0;
                    while (buf[len] != 0) len++;
                    name = Encoding.ASCII.GetString(buf, 0, len);
                }
                int token = GetTokenFromExportOrdinal(module, edt, ordinal);
                if (token == -1)
                {
                    continue;
                }
                List<ExportedMethod> list;
                if (!methods.TryGetValue(token, out list))
                {
                    list = new List<ExportedMethod>();
                    methods.Add(token, list);
                }
                ExportedMethod method;
                method.name = name;
                method.ordinal = ordinal;
                list.Add(method);
            }
            return methods;
        }