Platform Invocation Services 'pinvokeimpl' instruction's problem in Skater

Platform Invocation Services (PInvoke) allows managed code to call unmanaged methods that are compiled in a DLL. Platform is based on the metadata to find the exported functions and direct their arguments at run time.
By using the P/Invoke methods you provide the .NET compiler (C# or VB) with a declaration of the unmanaged function, and you may also need to provide the compiler with a description of how to marshal the parameters and return value from the unmanaged code (DLL).
When P/Invoke calls an unmanaged function, it performs the following steps:

Finds the unmanaged DLL containing the function.
Loads the whole DLL into memory.
Identifies the function address in memory and sends its arguments to the stack marshaling data as required.
Transfers control to the unmanaged function.

Platform invoke throws exceptions generated by the unmanaged function to the managed caller.
You can specify custom marshaling attributes for fields of classes and structures pushed to or from unmanaged methods. You do this by adding MarshalAs attributes to the fields of the class or structure. You must also use the StructLayout attribute to set the layout of the structure, optionally to control the default marshaling of string members, and to set the default packing size.
In MSIL script Skater sees the 'pinvokeimpl' constructions like the following:

.method assembly hidebysig static pinvokeimpl("user32.dll" autochar lasterr winapi)
            native int RegisterDeviceNotification(native int hRecipient,
                        native int NotificationFilter,
                        int32 Flags) cil managed preservesig

Order Skater .NET obfuscator

Read the Skater .NET obfuscator documentation

.NET compiler calls user32.dll in this particular example and uses the RegisterDeviceNotification method. It was generating a problem when a programmer used the same RegisterDeviceNotification name in .NET application code as a name of managed methods or fields. Skater .NET obfuscator development team figured out the issue and the problem has been fixed.

Download demo-trial now!

Copyright © 2001-2021 Rustemsoft LLC All Rights Reserved.