Modify

#4106 new Bug

_WinAPI_RegEnumKey() Returns Incorrect @extended Value

Reported by: tukangusil7@… Owned by:
Milestone: Component: AutoIt
Version: 3.3.18.0 Severity: None
Keywords: _WinAPI_RegEnumKey Cc:

Description

The current implementation of _WinAPI_RegEnumKey() returns $aCall[8] as @extended, which corresponds to the pointer to the FILETIME structure (lpftLastWriteTime), not the character count. The correct index for the character count (lpcchName output parameter) is $aCall[4].

This causes @extended to contain a large memory address (e.g., 1234567890) instead of a small integer representing the string length.

Current Code (Buggy)

Line 
1Func _WinAPI_RegEnumKey($hKey, $iIndex)
2 Local $tLastWriteTime = DllStructCreate($tagFILETIME)
3 Local $aCall = DllCall('advapi32.dll', 'long', 'RegEnumKeyExW', 'ulong_ptr', $hKey, 'dword', $iIndex, 'wstr', '', _
4 'dword*', 256, 'dword', 0, 'ptr', 0, 'ptr', 0, 'ptr', DllStructGetPtr($tLastWriteTime))
5 If @error Then Return SetError(@error, @extended, '')
6 If $aCall[0] Then Return SetError(10, $aCall[0], '')
7
8 Return SetExtended($aCall[8], $aCall[3]) ; Wrong: $aCall[8] is lpftLastWriteTime pointer
9EndFunc ;==>_WinAPI_RegEnumKey

Proposed Fix

Line 
1Func _WinAPI_RegEnumKey($hKey, $iIndex)
2 Local $tLastWriteTime = DllStructCreate($tagFILETIME)
3 Local $aCall = DllCall('advapi32.dll', 'long', 'RegEnumKeyExW', 'ulong_ptr', $hKey, 'dword', $iIndex, 'wstr', '', _
4 'dword*', 256, 'dword', 0, 'ptr', 0, 'ptr', 0, 'ptr', DllStructGetPtr($tLastWriteTime))
5 If @error Then Return SetError(@error, @extended, '')
6 If $aCall[0] Then Return SetError(10, $aCall[0], '')
7
8 Return SetExtended($aCall[4], $aCall[3]) ; $aCall[4] is lpcchName (character count)
9EndFunc ;==>_WinAPI_RegEnumKey

Attachments (0)

Change History (0)

Modify Ticket

Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.