-
Notifications
You must be signed in to change notification settings - Fork 12
Fix uncaught exception when trying to retrieve negative addresses #3
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
Conversation
Did you test a negative address intentional or how did you get this exception? Your patch doesn't fix the problem. Now you can't access offsets greater than int.MaxValue (2GB). I'm a little bit shocked that y and z are both negative...
I expected z to show a large number instead of -1. |
I think I got the exception when the program tried to construct a BaseHexCommentNode, presumably dereferencing an address, my file is exactly 2,147,516,415 bytes in size. |
I think the problem with this is that when pointer in IntPtr is 0x8000_0000, the ToInt64() operation does not cast bit-wise, resulting in same negative value |
I think this should work. The plugin fails to read valid bytes if you try to read after the file, but that's a different issue, I think I saw 64 byte blocks hardcoded somewhere, this might be related to that. |
LoadBinaryPluginExt.cs
Outdated
stream.Read(buffer, 0, size); | ||
|
||
return true; | ||
} | ||
using (var stream = info.File.CreateViewStream(address.ToInt64(), size)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you are missing the addressInt64 here.
There are some places in C# library methods I really wish that would just accept or provide |
I will add a new extension method for IntPtr in the ReClass.NET project to make the logic reusable. |
No description provided.