/// <summary> /// Handles information coming from outside the program (not contained, thus unsafe). /// </summary> /// <returns>Returns a reference to the dimensions of the sought-for window.</returns> unsafe public static Rect UnsafeRect() { // TODO : Check if injection could ever happen here - such as manipulating the - // parameters of a window? Rect sendRect = new Rect(0, 0, 0, 0); CustRect simpleRect = new CustRect(); HandleRef hRef = new HandleRef(runningProc, runningProc.MainWindowHandle); // TODO : Put this into a Try/Catch if (!GetWindowRect(hRef, out simpleRect)) { ProcessStopped(); return(sendRect); } sendRect = new Rect(Convert.ToDouble(simpleRect.Left), Convert.ToDouble(simpleRect.Top), Convert.ToDouble(simpleRect.Right - simpleRect.Left), Convert.ToDouble(simpleRect.Bottom - simpleRect.Top) ); return(sendRect); }
static extern bool GetWindowRect(HandleRef hWnd, // JMC out CustRect lpRect);