Modify

Opened 16 years ago

Closed 15 years ago

#1410 closed Bug (Fixed)

Using Pointer type with COM-object throws error.

Reported by: monoceres Owned by: Jon
Milestone: 3.3.7.9 Component: AutoIt
Version: 3.3.3.3 Severity: None
Keywords: com pointer idispatch Cc:

Description

AutoIt doesn't seem to have any code dealing with variables of pointer type when using COM, the following simple example throws com error 00000005.

$oMyError = ObjEvent("AutoIt.Error", "_Au3Obj_Err")
Func _Au3Obj_Err()
	MsgBox(48, 'COM Error', 'An error occured:' & @CRLF & $oMyError.description    & @CRLF & _
             "err.number is: "         & @TAB & hex($oMyError.number,8))
EndFunc   ;==>_Au3Obj_Err


$sh = ObjCreate("ScriptControl")
$sh.Language="VbScript"
$sh.Eval(Ptr(0))

Attachments (0)

Change History (6)

in reply to:  description comment:1 by anonymous, 16 years ago

Replying to monoceres:

$sh.Eval(Ptr(0))

What is it, what you are trying to do here?
I personally would expect this code to crash: Eval() apparently needs a string (Variant/VT_BSTR) and you submit a pointer (VT_PTR). COM error is the most harmless case here, if ScriptControl didn't validate arguments you would end up with access violation, since memory at address 0x00000000 isn't a valid read pointer.

comment:2 by ProgAndy, 16 years ago

The example is bad. This example is straight forward and fails, too.

$oMyError = ObjEvent("AutoIt.Error", "_Au3Obj_Err")
Func _Au3Obj_Err()
	MsgBox(48, 'COM Error', 'An error occured:' & @CRLF & $oMyError.description    & @CRLF & _
             "err.number is: "         & @TAB & hex($oMyError.number,8))
EndFunc   ;==>_Au3Obj_Err


$oDict = ObjCreate("Scripting.Dictionary")
; just to show the objetc works:
$oDict.add("valname", "test")
MsgBox(0, 'The object works:', "'valname' has the value: " & $oDict.Item('valname'))

;Error (crash without ErrorHandler): 
$oDict.add("ptr", Ptr(1234)) ; save a pointer in the dictionary object
MsgBox(0, 'Ptr does not work:', "'ptr' has the value: " & $oDict.Item('ptr'))

in reply to:  2 ; comment:3 by doudou, 16 years ago

Replying to ProgAndy:

The example is bad. This example is straight forward and fails, too.

I see what you mean, but comment on the 1st example applies here too: you convert the parameter to VT_PTR and the COM object tries to read the memory from that pointer (not the pointer value) which results in a crash. Not only you both supply an imaginary (invalid) memory address, I would also suspect no normally programmed COM component (at least none I've ever encountered) would expect VT_PTR and would know what do with it.

in reply to:  3 comment:4 by monoceres, 16 years ago

Replying to doudou:

Replying to ProgAndy:

The example is bad. This example is straight forward and fails, too.

I see what you mean, but comment on the 1st example applies here too: you convert the parameter to VT_PTR and the COM object tries to read the memory from that pointer (not the pointer value) which results in a crash. Not only you both supply an imaginary (invalid) memory address, I would also suspect no normally programmed COM component (at least none I've ever encountered) would expect VT_PTR and would know what do with it.

Come on! What the pointer points to is irrelevant. We just supplied imaginary pointers to display the issue. There are components that need the value in the field that is guarantied to be the same size as the pointer size on the system. Taking a window handle (HWND) is a good example.

comment:5 by J-Paul Mesnage, 16 years ago

Owner: set to Jon
Status: newassigned

comment:6 by Jon, 15 years ago

Milestone: 3.3.7.9
Resolution: Fixed
Status: assignedclosed

Fixed by revision [6124] in version: 3.3.7.9

Modify Ticket

Action
as closed The owner will remain Jon.

Add Comment


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