Creating Win32 files to create / resize / query

I am trying to "stretch" an existing application.

The goal is to make the existing application grow without changing the code of this application.
Cosntraint is that the stretched application will not โ€œnoticeโ€ it, so if the application asks for the size of the created window, it will see the original size, not the size.

I managed to resize windows using SetWindowsHookEx:

HHOOK hMessHook = SetWindowsHookEx(WH_CBT,CBTProc, hInst, 0);

and

LRESULT CALLBACK CBTProc( __in  int nCode,
                          __in  WPARAM wParam, 
                          __in  LPARAM lParam)
{
   if (HCBT_CREATEWND == nCode)
   {
      CBT_CREATEWND *WndData = (CBT_CREATEWND*) lParam;
      // Calculate newWidth and newHeight values...
      WndData->lpcs->cx = newWidth;
      WndData->lpcs->cy = newHeight;
   }

   CallNextHookEx(hMessHook, nCode, wParam, lParam);
}

The problem I am facing is that I cannot get the stretched application to see the original sizes.

For example, if you created a .NET form:

public class SimpleForm : Form
{
    public SimpleForm()
    {
        Width = 100;
        Height = 200;
    }
}

And then the size is requested:

void QuerySize(SimpleForm form)
{
   int width = form.Width;
   int height = form.Height;
}

width height 100 200, . , .

?

+3
1

, - API, GetWindowRect - Windows. , Detours API, Win32. ( Detours )

+7

Source: https://habr.com/ru/post/1796507/


All Articles