This commit implements the correct reference-based signature for WNetAddConnection2. On 32-bit systems, the previous implementation led to a significant issue when mapping network drives, causing memory layout corruption and resulting in the function failing with error 487. This commit resolves that issue and corrects the behavior.
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
It's about win_mapped_drive that fails on any 32 bit platform because of using the wrong method signature. Check P/Invoke for reference.
ADDITIONAL INFORMATION
Example log output of failure:
Exception calling "Invoke" with "2" argument(s): "Failed to map Z: to '\\TESTBOX1\Share' with WNetAddConnection2W() (Attempt to access invalid address, Win32ErrorCode 487)"
At line:422 char:17
+ ... $add_method.Invoke($null, [Object[]]@($letter_root, $path ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : Win32Exception
ScriptStackTrace:
at <ScriptBlock>, <No file>: line 422
fatal: [TW10B-903-1]: FAILED! => {
"changed": false,
"msg": "Unhandled exception while executing module: Exception calling \"Invoke\" with \"2\" argument(s): \"Failed to map Z: to '\\\\TESTBOX1\\Share' with WNetAddConnection2W() (Attempt to access invalid address, Win32ErrorCode 487)\""
}
SUMMARY
This commit implements the correct reference-based signature for WNetAddConnection2. On 32-bit systems, the previous implementation led to a significant issue when mapping network drives, causing memory layout corruption and resulting in the function failing with error 487. This commit resolves that issue and corrects the behavior.
ISSUE TYPE
COMPONENT NAME
It's about
win_mapped_drive
that fails on any 32 bit platform because of using the wrong method signature. Check P/Invoke for reference.ADDITIONAL INFORMATION
Example log output of failure: