Example #1
0
        InfoAccessType hookConstructStr(IntPtr self, IntPtr module, uint metaTok, out IntPtr pobj)
        {
            if ((metaTok & 0x00800000) != 0)
            {
                uint offset = metaTok & 0x007FFFFF;

                if (!gcHnds.ContainsKey(offset))
                {
                    uint length = (uint)(BitConverter.ToUInt32(data, (int)offset) & ~1);
                    if (length < 1)
                    {
                        pins.Add(GCHandle.Alloc(string.Empty, GCHandleType.Pinned));
                        gcHnds[offset] = tbl.AddHandle(Obj2Ptr(string.Empty));
                    }

                    var chars = new char[length / 2];

                    for (uint i = offset + 4, j = 0; i < offset + 4 + length; i += 2)
                    {
                        chars[j++] = (char)((data[i] | (data[i + 1] << 8)) ^ Mutation.Key5I);
                    }

                    string c = new string(chars);
                    pins.Add(GCHandle.Alloc(c, GCHandleType.Pinned));
                    gcHnds[offset] = tbl.AddHandle(Obj2Ptr(c));
                }
                pobj = gcHnds[offset];
                return(InfoAccessType.PVALUE);
            }
            InfoAccessType ret = o_constructStringLiteral(self, module, metaTok, out pobj);

            return(ret);
        }