Windows Magnifier Window Cause exception when setting MagSetImageScalingCallback


I have been using a magnifier code from this github link : Magnify
I am trying to set MagImageScaling callback and i was able to get the bitmap through this callback.

Once the MagImageScaling Callback is set and if i try to move the window the the right side of the desktop. The Program throws an exception like this:

Exception thrown at 0x00007FFDA8724452 (msvcrt.dll) in Magnify10.exe: 0xC0000005: Access violation reading location 0x000001749E708FA4.

I'm not posting the complete code because it's too large.

The Callback Definition

BOOL MagImageScaling(HWND hwnd, void* srcdata, MAGIMAGEHEADER srcheader, void* destdata, MAGIMAGEHEADER destheader, RECT unclipped, RECT clipped, HRGN dirty)
    //Here i was able to receive the bitmap through srcdata
    return TRUE;

This is how i set the callback:

if (!MagSetImageScalingCallback(magActive->GetHandle(), (MagImageScalingCallback)MagImageScaling))
   return FALSE;


The above diagram shows the actual problem:

The yellow frame is the host window.
The Green frame is the magnifier window which is a child of host window.
The RED frame is the desktop rect.
The blue line is a random boundary.

When the window crosses the blue boundary it causes exception.

I think when the Window is moved, the magnifier window resizes itself and try to cross the Blue Boundary and Desktop boundary which causes this issue.

so i think if we were able to identify when the MagnifyWindow touching the desktop boundary and stop the movement of Mangnifier window then we might be able to stop it.

So is there any way to achieve this?

Here is the complete code of the project to reproduce this issue:
Magnify Bug Project

asked on Stack Overflow Oct 12, 2020 by trickymind

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0