private static void InternalSetValue(ApiRecord record, IntPtr address, uint value) { uint storage; uint max; if (!ApiProxy.IsEnabled) { return; } max = (uint)(Math.Pow(2, record.Size) - 1); if (value < record.Min || value > record.Max) { throw new ArgumentException(nameof(value)); } storage = ApiProxy.InternalGetValue(0, 32, address); storage &= ~(max << record.Shift); storage |= (value << record.Shift); unsafe { *(uint *)(address.ToPointer()) = storage; } }
public static uint GetValue(ApiParameter parameter, IntPtr address) { ApiRecord record; IntPtr realAddress; record = ApiInfo.Instance[parameter]; realAddress = ApiProxy.GetAddress(record.Group, address); return(ApiProxy.InternalGetValue(record.Shift, record.Size, IntPtr.Add(realAddress, record.Offset))); }
public static void SetValue(ApiParameter parameter, IntPtr address, uint value) { ApiRecord record; IntPtr realAddress; record = ApiInfo.Instance[parameter]; realAddress = ApiProxy.GetAddress(record.Group, address); ApiProxy.InternalSetValue(record, IntPtr.Add(realAddress, record.Offset), value); }