Coder Social home page Coder Social logo

Comments (5)

Aaron-Junker avatar Aaron-Junker commented on June 15, 2024 1

So hey, I'd like to work on this, thus as mandated in #28769, here's my request of an attempt to fix it.

Good catch. Yes, absolutely, do implement it! Thank you!

from powertoys.

github-actions avatar github-actions commented on June 15, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

from powertoys.

z4pf1sh avatar z4pf1sh commented on June 15, 2024

I did some debugging myself, and the faulty line turns out to be:

int hwnd = Convert.ToInt32(args[1], 16);

... where it assumes that the passed window handle is a signed 32-bit number.

This should not be how it's implemented. This time, Windows passed a 64-bit handle to the process, with args[1] = FFFF FFFF A290 0D2C, as shown in my Immediate Window:

image

And the process promptly crashed, with an exception of "Value was either too large or too small for a UInt32."

The confusing thing for me is this line below, where it's explicitly converted to IntPtr, when the hwnd is actually used:

_previewHandlerControl.SetWindow((IntPtr)hwnd, s);

With reference from Microsoft Learn on the IntPtr struct:

The IntPtr type is designed to be an integer whose size is the same as a pointer. That is, an instance of this type is expected to be 32 bits in a 32-bit process and 64 bits in a 64-bit process.

Here's my thinking: why don't just convert the input string to a IntPtr at the very beginning, instead of the flow of: A Potentially 64-bit Hexadecimal String -> A Signed 32-bit Integer -> A Platform-dependent Handle Type, when you can parse it at the first shot? I think this should be a relatively easy fix, and I will try to fix it with a PR once approved.

from powertoys.

z4pf1sh avatar z4pf1sh commented on June 15, 2024

So hey, I'd like to work on this, thus as mandated in #28769, here's my request of an attempt to fix it.

from powertoys.

z4pf1sh avatar z4pf1sh commented on June 15, 2024

According to comments in the PR #32826 (comment), this affects all other preview handlers as well. I will work on applying the same fix to all other affected handlers as well once I got the approval.

from powertoys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.