You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The sample uses a magic string in its Startup.removeSparsePackage method rather than obtaining the package's full name so that it can be uninstalled. It also defines the P/Invoke for kernel32.dll's GetCurrentPackageFullName function in the ExecuteMode class incorrectly.
The sample defines the StringBuilder parameter for GetCurrentPackageFullName using ref, which causes an HRESULT 0x80004003 "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." when trying to use it to actually get the package name (in the sample it never attempts to write to the StringBuilder's memory when it calls it so the problem never surfaces). Removing ref solves the problem because the .NET marshaler handles StringBuilder specially. All that needs to be done is ensure it has the minimum required capacity, pass it in without using ref, and the marshaler will write the string directly to the StringBuilder's internal memory.
Fixing that makes it possible to modify Startup.removeSparsePackage to get the actual package name and use that to remove the package. I resolved these issues and will be sending a pull request with the fixes.
The text was updated successfully, but these errors were encountered:
The sample uses a magic string in its Startup.removeSparsePackage method rather than obtaining the package's full name so that it can be uninstalled. It also defines the P/Invoke for kernel32.dll's GetCurrentPackageFullName function in the ExecuteMode class incorrectly.
The sample defines the StringBuilder parameter for GetCurrentPackageFullName using ref, which causes an HRESULT 0x80004003 "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." when trying to use it to actually get the package name (in the sample it never attempts to write to the StringBuilder's memory when it calls it so the problem never surfaces). Removing ref solves the problem because the .NET marshaler handles StringBuilder specially. All that needs to be done is ensure it has the minimum required capacity, pass it in without using ref, and the marshaler will write the string directly to the StringBuilder's internal memory.
Fixing that makes it possible to modify Startup.removeSparsePackage to get the actual package name and use that to remove the package. I resolved these issues and will be sending a pull request with the fixes.
The text was updated successfully, but these errors were encountered: