Modify

Opened 18 years ago

Closed 18 years ago

#517 closed Bug (Fixed)

WinAPI UDF - bad error checking after DllCall()

Reported by: Zedna Owned by: Gary
Milestone: 3.2.13.8 Component: Standard UDFs
Version: 3.2.12.1 Severity: None
Keywords: Cc:

Description

This line is missing in many functions after DllCall:

If @error Then Return SetError(@error, 0, 0)

Original:

Func _WinAPI_LoadLibrary($sFileName)
	Local $aResult

	$aResult = DllCall("Kernel32.dll", "hwnd", "LoadLibraryA", "str", $sFileName)
	Return $aResult[0]
EndFunc   ;==>_WinAPI_LoadLibrary

Correct way:

Func _WinAPI_LoadLibrary($sFileName)
	Local $aResult

	$aResult = DllCall("Kernel32.dll", "hwnd", "LoadLibraryA", "str", $sFileName)
	If @error Then Return SetError(@error, 0, 0)
	Return $aResult[0]
EndFunc   ;==>_WinAPI_LoadLibrary

Mainly it should be corrected in these functions (but this is missing in many others):

_WinAPI_LoadImage
_WinAPI_LoadLibrary
_WinAPI_LoadLibraryEx
_WinAPI_FreeLibrary

I need to have a chance to check if @error occured when calling these functions:

$hInstance = _WinAPI_LoadLibrary("some.dll")
If @error Then ...

Note: If error occurs during DllCall() then accesing $aResult[0] will hard crash my script.

Attachments (0)

Change History (1)

comment:1 by Gary, 18 years ago

Milestone: 3.2.13.8
Resolution: Fixed
Status: newclosed

Fixed in version: 3.2.13.8

Modify Ticket

Action
as closed The owner will remain Gary.

Add Comment


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