コード例 #1
0
ファイル: Memory.cs プロジェクト: soknifedev/samp-guard
        public static void WriteMemory(GTAMemoryAddresses ad, float value)
        {
            byte   i = Convert.ToByte(ad);
            UInt32 maxSize = Convert.ToUInt32(MemoryData[i, 1]);
            int    bytesout = 0, offset = Convert.ToInt32(MemoryData[i, 2]), binpos = Convert.ToInt32(MemoryData[i, 3]);

            if (offset != 0)
            {
                offset = Convert.ToInt32(ValueOf(ReadMemory(Convert.ToInt32(MemoryData[i, 2]), sizeof(uint))));
            }
            if (binpos == -1)
            {
                WriteProcessMemory(handle, offset + Convert.ToInt32(MemoryData[i, 0]), BitConverter.GetBytes(value), maxSize, out bytesout);
            }
            else
            {
                byte[] array = Memory.ReadMemory(offset + Convert.ToInt32(MemoryData[i, 0]), maxSize);
                array[Convert.ToInt32(MemoryData[i, 3])] = Convert.ToByte(value);
                Memory.WriteMemory(offset + Convert.ToInt32(MemoryData[i, 0]), maxSize, BitConverter.ToUInt32(array, 0));
            }
        }
コード例 #2
0
ファイル: Memory.cs プロジェクト: soknifedev/samp-guard
        public static byte[] ReadMemory(GTAMemoryAddresses ad)
        {
            byte   i       = Convert.ToByte(ad);
            UInt32 maxSize = Convert.ToUInt32(MemoryData[i, 1]);

            byte[] answer = new byte[maxSize];
            int    offset = Convert.ToInt32(MemoryData[i, 2]), binpos = Convert.ToInt32(MemoryData[i, 3]);

            if (offset != 0)
            {
                offset = Convert.ToInt32(ValueOf(ReadMemory(Convert.ToInt32(MemoryData[i, 2]), sizeof(uint))));
            }
            if (binpos == -1)
            {
                ReadProcessMemory(handle, offset + Convert.ToInt32(MemoryData[i, 0]), answer, maxSize, 0);
            }
            else
            {
                answer = Memory.ReadMemory(offset + Convert.ToInt32(MemoryData[i, 0]), maxSize);
                return(new byte[] { answer[binpos] });
            }
            return(answer);
        }