Example #1
0
        public static T Reader <T>(ulong w_read)
        {
            var output    = default(T);
            var size      = Marshal.SizeOf(typeof(T));
            var writeAddr = Marshal.AllocHGlobal(size);

            try
            {
                ReadStruct rStruct = new ReadStruct()
                {
                    UserBufferAdress  = (ulong)writeAddr,
                    GameAddressOffset = (ulong)w_read,
                    ReadSize          = (ulong)size,
                    UserPID           = CommonUtil.GetCurrentProcessId(),
                    GamePID           = 0,
                    WriteOrRead       = true,
                    ProtocolMsg       = 0,
                    WriteOrRead2      = true,
                    ProtocolMsg2      = 0
                };

                WriteFile(handle, &rStruct, ReadStruct.Size, null, 0);
                output = Marshal.PtrToStructure <T>(writeAddr);
            }
            catch (Exception e)
            {
                //todo:loging the excption
            }
            finally
            {
                Marshal.FreeHGlobal(writeAddr);
            }
            return(output);
        }
Example #2
0
        public static char readChar(ulong w_read, int sdf = 0)
        {
            char writeMe;

            ReadStruct rStruct = new ReadStruct()
            {
                UserBufferAdress  = (ulong)&writeMe,
                GameAddressOffset = (ulong)w_read,
                ReadSize          = (ulong)Marshal.SizeOf(typeof(char)),
                UserPID           = CommonUtil.GetCurrentProcessId(),
                GamePID           = 0,
                WriteOrRead       = true,
                ProtocolMsg       = 0,
                WriteOrRead2      = true,
                ProtocolMsg2      = 0
            };

            WriteFile(handle, &rStruct, ReadStruct.Size, null, 0);
            return(writeMe);
        }