Beispiel #1
0
        private void FrmLyrics_Load(object sender, EventArgs e)
        {
            var scrBounds = Screen.PrimaryScreen.Bounds;

            Width  = scrBounds.Width;
            Height = 150;
            if (_settings.PosY < 0)
            {
                Top  = scrBounds.Height - Height - 150;
                Left = 0;
            }
            else
            {
                Top  = _settings.PosY;
                Left = _settings.PosX;
            }

            TopMost = true;

            UnmanagedHelper.SetTopMost(this);
            UpdateFromSettings(_settings);

            Move += (o, args) =>
            {
                _settings.PosX = Left;
                _settings.PosY = Top;
            };
            FormClosing += (o, args) =>
            {
                if (args.CloseReason == CloseReason.UserClosing)
                {
                    args.Cancel = true;
                }
            };
        }
Beispiel #2
0
        internal static Type LookUp(int id)
        {
            if (!_typeLookup.TryGetValue(id, out var type))
            {
                return(UnmanagedHelper.LookUp(id));
            }

            return(type);
        }
Beispiel #3
0
        static void Main()
        {
            CallbackDelegate @delegate = new CallbackDelegate(Callback);
            IntPtr           callback  = Marshal.GetFunctionPointerForDelegate(@delegate);
            int returnedVal            = return_callback_val(callback);
            var e = UnmanagedHelper.GetLastException();

            Console.WriteLine("exception: {0}", e);
        }
Beispiel #4
0
 static int Callback()
 {
     try {
         throw new Exception("something went wrong");
     }
     catch (Exception e) {
         UnmanagedHelper.SetLastException(e);
     }
     return(0);
 }
Beispiel #5
0
        private void FrmLyrics_Load(object sender, EventArgs e)
        {
            var scrBounds = Screen.PrimaryScreen.Bounds;

            Width  = scrBounds.Width;
            Height = 150;
            try
            {
                var coord = File.ReadAllText(_path).Split(' ');
                Left = int.Parse(coord[0]);
                Top  = int.Parse(coord[1]);
            }
            catch (Exception)
            {
                Top  = scrBounds.Height - Height - 150;
                Left = 0;
            }

            TopMost = true;

            UnmanagedHelper.SetTopMost(this);
            UpdateFromSettings(_startupSettings);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="Detour" /> class.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="hook">The hook.</param>
        /// <param name="name">The name.</param>
        /// <param name="memory">The memory.</param>
        public Detour(Delegate target, Delegate hook, string name, MemoryPlus memory)
        {
            ProcessMemory = memory;
            Name          = name;

            TargetDelegate = target;
            Target         = UnmanagedHelper.GetDelegatePointer(target);

            _hookDelegate = hook;
            Hook          = UnmanagedHelper.GetDelegatePointer(hook);

            //Store the orginal bytes
            Orginal = new List <byte>();
            Orginal.AddRange(memory.ReadBytes(Target, 6));

            //Setup the detour bytes
            New = new List <byte> {
                0x68
            };
            var tmp = BitConverter.GetBytes(Hook.ToInt32());

            New.AddRange(tmp);
            New.Add(0xC3);
        }