public unsafe string GetSymbolName(int symbolIndex) { // check symbol range if (symbolIndex < 0) { return(null); } if (symbolIndex >= SymbolTable.nsyms) { // handle special symbols SpecialSymbol specialSymbol = (SpecialSymbol)(symbolIndex - (int)SymbolTable.nsyms); switch (specialSymbol) { case SpecialSymbol.SegmentStart: return("_start"); case SpecialSymbol.SegmentEnd: return(null); default: // out of range? return(null); } } IntPtr baseaddr = Slide + (int)(LinkEdit.vmaddr - LinkEdit.fileoff); IntPtr straddr = baseaddr + (int)SymbolTable.stroff; IntPtr symaddr = baseaddr + (int)SymbolTable.symoff; nlist n = (nlist)Marshal.PtrToStructure(symaddr + symbolIndex * sizeof(nlist), typeof(nlist)); var symbolName = Marshal.PtrToStringAnsi(straddr + n.n_strx); return(symbolName); }
/** * Changes an int into a Greek letter combination. * @param index the original number * @return the letter combination */ public static String GetString(int index, bool lowercase) { if (index < 1) return ""; index--; int bytes = 1; int start = 0; int symbols = 24; while (index >= symbols + start) { bytes++; start += symbols; symbols *= 24; } int c = index - start; char[] value = new char[bytes]; while (bytes > 0) { bytes--; value[bytes] = (char)(c % 24); if (value[bytes] > 16) value[bytes]++; value[bytes] += (char)(lowercase ? 945 : 913); value[bytes] = SpecialSymbol.GetCorrespondingSymbol(value[bytes]); c /= 24; } return new String(value); }
/// <summary> /// Changes an int into a Greek letter combination. /// </summary> /// <param name="index">the original number</param> /// <param name="lowercase"></param> /// <returns>the letter combination</returns> public static string GetString(int index, bool lowercase) { if (index < 1) { return(""); } index--; var bytes = 1; var start = 0; var symbols = 24; while (index >= symbols + start) { bytes++; start += symbols; symbols *= 24; } var c = index - start; var value = new char[bytes]; while (bytes > 0) { bytes--; value[bytes] = (char)(c % 24); if (value[bytes] > 16) { value[bytes]++; } value[bytes] += (char)(lowercase ? 945 : 913); value[bytes] = SpecialSymbol.GetCorrespondingSymbol(value[bytes]); c /= 24; } return(new string(value)); }