Exemple #1
0
    public static void memcpy(byte[] bytes, int off, int addr, int size)
    {
        while (size > 0)
        {
            bytes[off++] = (byte)CRunTime.memoryReadByte(addr);
            addr++;
            size--;
        }

        return;
    }
Exemple #2
0
    /* Misc. utils */
    public static String charPtrToString(int address)
    {
        int startAddress = address;
        int i            = 0;
        int len          = 0;

        if (address == 0)
        {
            return("");
        }

        while (CRunTime.memoryReadByte(startAddress + len) != 0)
        {
            len++;
        }

        if (len == 0)
        {
            return("");
        }

        byte[] vec = new byte[len];

        for (i = 0; i < len; i++)
        {
            vec[i] = (byte)CRunTime.memoryReadByte(startAddress + i);
        }
        try
        {
            String str;
            if (CibylConfig.stringEncoding == null)
            {
                str = new System.Text.UTF8Encoding().GetString(vec, 0, vec.Length);
            }
            else
            {
                str = BitConverter.ToString(vec);     // tofix new String(vec, CibylConfig.stringEncoding);
            }
            return(str);
        }
        catch (Exception e)
        {
            Logger.log(e.ToString());
            return("UnSupportedEncodingException happened");
        }
    }