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

AddressTransformation integer handling does the opposite of what it is supposed to #46

Open
Zhentar opened this issue Oct 29, 2018 · 2 comments
Assignees

Comments

@Zhentar
Copy link
Contributor

Zhentar commented Oct 29, 2018

I had figured that the inconsistent handling between addresses with only decimal digits was just an unfortunate cost of PowerShell, until I saw the AddressTransformation... so I poked at it a bit more:

> Read-DbgMemory -Address 0x17409680
17409680  "󸇳."

> 0x17409680 | Read-DbgMemory
Read-DbgMemory : Could not access memory: 90108800
At line:1 char:14
+ 0x17409680 | Read-DbgMemory
+              ~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (15301904384:UInt64) [Read-DbgMemory], DbgMemoryAccessException
    + FullyQualifiedErrorId : MemoryAccessFailure,MS.Dbg.Commands.ReadDbgMemoryCommand

> Read-DbgMemory -Address 17409680
Read-DbgMemory : Could not access memory: 0109a690
At line:1 char:1
+ Read-DbgMemory -Address 17409680
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (17409680:UInt64) [Read-DbgMemory], DbgMemoryAccessException
    + FullyQualifiedErrorId : MemoryAccessFailure,MS.Dbg.Commands.ReadDbgMemoryCommand
@jazzdelightsme
Copy link
Member

Thanks for the report!

The relevant code is:

if( (pso.BaseObject is int) ||
    (pso.BaseObject is long) ||
    (pso.BaseObject is double) ||
    (pso.BaseObject is float) )
{
    // This will get what the user actually typed (if it was typed).
    var asTyped = LanguagePrimitives.ConvertTo< string >( pso );

And the problem is that the comment is wrong in the case of pipelining: if the value was piped in, LanguagePrimitives.ConvertTo succeeds in returning a string, but that string does not match what was originally typed (it's been converted into a decimal string representation instead of the "0x..." that was typed). :'(

I have some ideas of some more tricks we could play.

@Zhentar
Copy link
Contributor Author

Zhentar commented Oct 30, 2018

For the Read-DbgMemory -Address 17409680 case, the problem was that var pso = inputData as PSObject; returned null - Powershell is just passing in a boxed int, not a PSObject.

jazzdelightsme added a commit that referenced this issue Nov 13, 2018
Unfortunately this uses private reflection, and there are still cases
that it can't handle.

Also fixed a sign extension booboo.

Helps with #46, but we can't totally fix it without some changes in
PowerShell.
@jazzdelightsme jazzdelightsme self-assigned this Nov 14, 2018
jazzdelightsme added a commit that referenced this issue Nov 14, 2018
Unfortunately this uses private reflection, and there are still cases
that it can't handle.

Also fixed a sign extension booboo.

Helps with #46, but we can't totally fix it without some changes in
PowerShell.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants