lundi 19 octobre 2020

Powershell reflection finding function

[Windows.Forms.Form].
Assembly.GetType(
    'System.Windows.Forms.UnsafeNativeMethods'
).GetMethod('GetAsyncKeyState').Invoke($null,
    @(
        0x09 # Tab key code
    )
)

I found this code. It works. My question is how i can find where is function stored?

Image, that I want to use the GetAsyncKeyState method without knowing about the code above: How can I find out what type in what assembly provides this method?

May be there is some function like:

function Get-win32FunctionLocation($fName){
    #...
}

Get-win32FunctionLocation 'GetAsyncKeyState'

<#Output:

    location  : [Windows.Forms.Form]
    TypeName  : System.Windows.Forms.UnsafeNativeMethods

#>

Or may be some other source of this information...

P.S. I know about Add-Type, but my interest is in this code.





Aucun commentaire:

Enregistrer un commentaire