Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for possible System.OverflowException with IntPtr.ToInt32() on Win 8 or Win Server 2012 #1996

Merged
merged 6 commits into from
Jun 21, 2015

Conversation

punker76
Copy link
Member

Closes #1993 Why did I get an errorwhen I run the sample on windows 8.1?

@punker76 punker76 added this to the 1.2.0 milestone Jun 20, 2015
@@ -133,7 +133,8 @@ private bool _ModifyStyle(Standard.WS removeStyle, Standard.WS addStyle)
{
return false;
}
var dwStyle = (Standard.WS)Standard.NativeMethods.GetWindowLongPtr(this.handle, Standard.GWL.STYLE).ToInt32();
var intPtr = Standard.NativeMethods.GetWindowLongPtr(this.handle, Standard.GWL.STYLE);
var dwStyle = (Standard.WS)(uint)(Environment.Is64BitProcess ? intPtr.ToInt64() : intPtr.ToInt32());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're casting the result of ToInt64() back to a uint so you'll still end up getting an OverflowException?

punker76 added a commit that referenced this pull request Jun 21, 2015
Fix for possible System.OverflowException with IntPtr.ToInt32() on Win 8 or Win Server 2012
@punker76 punker76 merged commit 3d094c2 into master Jun 21, 2015
@punker76 punker76 deleted the IntPtr-ToInt32-Win8-Win2012-bugfix branch July 1, 2015 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants