# Path: sark/data.py
# def get_string(ea):
#     """Read the string at the given ea.
# 
#     This function uses IDA's string APIs and does not implement any special logic.
#     """
#     # We get the item-head because the `GetStringType` function only works on the head of an item.
#     string_type = idc.get_str_type(idaapi.get_item_head(ea))
# 
#     if string_type is None:
#         raise exceptions.SarkNoString("No string at 0x{:08X}".format(ea))
# 
#     string = idc.get_strlit_contents(ea, strtype=string_type)
# 
#     if not string:
#         raise exceptions.SarkNoString("No string at 0x{:08X}".format(ea))
# 
#     return string
# 
# Path: sark/exceptions.py
# class SarkException(Exception):
# class SarkError(SarkException):
# class SarkNoSelection(SarkError):
# class SarkNoFunction(SarkError):
# class SarkAddFunctionFailed(SarkError):
# class SarkFunctionExists(SarkError):
# class SarkStructError(SarkError):
# class SarkInvalidRegisterName(SarkError):
# class SarkStructAlreadyExists(SarkStructError):
# class SarkStructCreationFailed(SarkStructError):
# class SarkStructNotFound(SarkStructError):
# class SarkErrorAddStructMemeberFailed(SarkStructError):
# class SarkErrorStructMemberName(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberOffset(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberSize(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberTinfo(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberStruct(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberUnivar(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberVarlast(SarkErrorAddStructMemeberFailed):
# class SarkEnumError(SarkError):
# class SarkErrorAddEnumMemeberFailed(SarkEnumError):
# class SarkErrorEnumMemberName(SarkErrorAddEnumMemeberFailed):
# class SarkErrorEnumMemberValue(SarkErrorAddEnumMemeberFailed):
# class SarkErrorEnumMemberEnum(SarkErrorAddEnumMemeberFailed):
# class SarkErrorEnumMemberMask(SarkErrorAddEnumMemeberFailed):
# class SarkErrorEnumMemberIllv(SarkErrorAddEnumMemeberFailed):
# class EnumNotFound(SarkEnumError):
# class EnumCreationFailed(SarkEnumError):
# class EnumAlreadyExists(SarkEnumError):
# class CantRenameEnumMember(SarkEnumError):
# class CantSetEnumMemberComment(SarkEnumError):
# class SarkErrorNameAlreadyExists(SarkError):
# class SarkSetNameFailed(SarkError):
# class SarkSwitchError(SarkError):
# class SarkNotASwitch(SarkSwitchError):
# class SarkNoInstruction(SarkError):
# class SarkOperandError(SarkError):
# class SarkOperandWithoutReg(SarkOperandError):
# class CantSetEnumComment(SarkEnumError):
# class CantDeleteEnumMember(SarkEnumError):
# class CantSetEnumBitfield(SarkEnumError):
# class CantRenameEnum(SarkEnumError):
# class SarkGuiError(SarkError):
# class SarkMenuError(SarkGuiError):
# class MenuAlreadyExists(SarkMenuError):
# class MenuNotFound(SarkMenuError):
# class FormNotFound(SarkGuiError):
# class InvalidStructOffset(SarkStructError):
# class SegmentError(SarkError):
# class NoMoreSegments(SegmentError):
# class InvalidBitness(SegmentError):
# class NoFileOffset(SarkError):
# class SarkNoString(SarkError):
# class SarkExpectedPatchedByte(SarkError):
# class PhraseError(SarkOperandError):
# class OperandNotPhrase(PhraseError):
# class PhraseNotSupported(PhraseError):
# class PhraseProcessorNotSupported(PhraseNotSupported):
# class SetTypeFailed(SarkError):
#     def __init__(self, ea, c_signature):


import idaapi
import idc
import sark
import sark.ui
from sark.data import get_string
from sark import exceptions
    idaapi.msg("------------------------------------------\n")

    for xref in function.xrefs_from:
        if xref.type.is_code:
            try:
                name = get_name(xref.to)
            except NoName:
                continue

            idaapi.msg("code    0x{:08X}    0x{:08X}    {}\n".format(xref.frm, xref.to, name))

        else:
            try:
                string = get_string(xref.to)
            except exceptions.SarkNoString:
                continue

            # Trim the string for easier display
            string = string[:100]

            idaapi.msg("data    0x{:08X}    {}    {}\n".format(xref.frm, sark.core.get_name_or_address(xref.to), repr(string)))

    idaapi.msg("\n\n")


def show_current_function_meaningful():
    try:
        function = sark.Function(idc.here())
        show_meaningful_in_function(function)


# Path: sark/data.py
# def get_string(ea):
#     """Read the string at the given ea.
# 
#     This function uses IDA's string APIs and does not implement any special logic.
#     """
#     # We get the item-head because the `GetStringType` function only works on the head of an item.
#     string_type = idc.get_str_type(idaapi.get_item_head(ea))
# 
#     if string_type is None:
#         raise exceptions.SarkNoString("No string at 0x{:08X}".format(ea))
# 
#     string = idc.get_strlit_contents(ea, strtype=string_type)
# 
#     if not string:
#         raise exceptions.SarkNoString("No string at 0x{:08X}".format(ea))
# 
#     return string
# 
# Path: sark/exceptions.py
# class SarkException(Exception):
# class SarkError(SarkException):
# class SarkNoSelection(SarkError):
# class SarkNoFunction(SarkError):
# class SarkAddFunctionFailed(SarkError):
# class SarkFunctionExists(SarkError):
# class SarkStructError(SarkError):
# class SarkInvalidRegisterName(SarkError):
# class SarkStructAlreadyExists(SarkStructError):
# class SarkStructCreationFailed(SarkStructError):
# class SarkStructNotFound(SarkStructError):
# class SarkErrorAddStructMemeberFailed(SarkStructError):
# class SarkErrorStructMemberName(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberOffset(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberSize(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberTinfo(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberStruct(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberUnivar(SarkErrorAddStructMemeberFailed):
# class SarkErrorStructMemberVarlast(SarkErrorAddStructMemeberFailed):
# class SarkEnumError(SarkError):
# class SarkErrorAddEnumMemeberFailed(SarkEnumError):
# class SarkErrorEnumMemberName(SarkErrorAddEnumMemeberFailed):
# class SarkErrorEnumMemberValue(SarkErrorAddEnumMemeberFailed):
# class SarkErrorEnumMemberEnum(SarkErrorAddEnumMemeberFailed):
# class SarkErrorEnumMemberMask(SarkErrorAddEnumMemeberFailed):
# class SarkErrorEnumMemberIllv(SarkErrorAddEnumMemeberFailed):
# class EnumNotFound(SarkEnumError):
# class EnumCreationFailed(SarkEnumError):
# class EnumAlreadyExists(SarkEnumError):
# class CantRenameEnumMember(SarkEnumError):
# class CantSetEnumMemberComment(SarkEnumError):
# class SarkErrorNameAlreadyExists(SarkError):
# class SarkSetNameFailed(SarkError):
# class SarkSwitchError(SarkError):
# class SarkNotASwitch(SarkSwitchError):
# class SarkNoInstruction(SarkError):
# class SarkOperandError(SarkError):
# class SarkOperandWithoutReg(SarkOperandError):
# class CantSetEnumComment(SarkEnumError):
# class CantDeleteEnumMember(SarkEnumError):
# class CantSetEnumBitfield(SarkEnumError):
# class CantRenameEnum(SarkEnumError):
# class SarkGuiError(SarkError):
# class SarkMenuError(SarkGuiError):
# class MenuAlreadyExists(SarkMenuError):
# class MenuNotFound(SarkMenuError):
# class FormNotFound(SarkGuiError):
# class InvalidStructOffset(SarkStructError):
# class SegmentError(SarkError):
# class NoMoreSegments(SegmentError):
# class InvalidBitness(SegmentError):
# class NoFileOffset(SarkError):
# class SarkNoString(SarkError):
# class SarkExpectedPatchedByte(SarkError):
# class PhraseError(SarkOperandError):
# class OperandNotPhrase(PhraseError):
# class PhraseNotSupported(PhraseError):
# class PhraseProcessorNotSupported(PhraseNotSupported):
# class SetTypeFailed(SarkError):
#     def __init__(self, ea, c_signature):


# Path: plugins/meaningful.py
import idaapi
import idc
import sark
import sark.ui
from sark.data import get_string
from sark import exceptions

    idaapi.msg("------------------------------------------\n")

    for xref in function.xrefs_from:
        if xref.type.is_code:
            try:
                name = get_name(xref.to)
            except NoName:
                continue

            idaapi.msg("code    0x{:08X}    0x{:08X}    {}\n".format(xref.frm, xref.to, name))

        else:
            try:
                string = get_string(xref.to)
            except exceptions.SarkNoString:
                continue

            # Trim the string for easier display
            string = string[:100]

            idaapi.msg("data    0x{:08X}    {}    {}\n".format(xref.frm, sark.core.get_name_or_address(xref.to), repr(string)))

    idaapi.msg("\n\n")


def show_current_function_meaningful():
    try:
        function = sark.Function(idc.here())
        show_meaningful_in_function(function)


    except sark.exceptions.SarkNoFunction: