On 05/09/2012 07:10, bulk 88 wrote:

Since Callback is crashing, I dont know whether to try to fix it, so I have a 
question, did 02_Callback.t ever not crash with a certain version number of 
Win32::API, with a certain compiler, etc?

Or should I forget about callback and try and fix the 3 other bugs (func not 
found dll handle leak, no unsigned return values, no shorts) which are easier 
targets to kill than Callback and then try Callback if I have the time?

By the way - not to make your job more difficult or anything, but
there's a situation that isn't currently being handled.  Some OS calls
can return a pointer to another function which you would then use to
call that function to get more info.

An example would be IShellFolder::BindToObject which returns a 'void
**ppvOut' parameter that is to then be used to iterate over the objects
in question.  What would need to be done is to treat that returned ptr
as though it were a named library routine that could be looked up in
the DLL and instead just assume it has already been looked up and just
use the returned address and associate it with the name supplied.

IShellFolder interface method:

Method          Description
BindToObject    Retrieves a handler, typically the Shell folder object that
                implements IShellFolder for a particular item. Optional
                parameters that control the construction of the handler are
                passed in the bind context.

In order to iterate over these objects, you need to be able to treat
that returned pointer from BindToObject as a new API function addr.  I
would think it would be pretty easy to do - just bypass all the code
that looks up the function name in the DLL and use the pointer (and an
arbitrary name supplied by the caller to associate the pointer to) as
though it had actually been looked up (maybe check for 0 etc).

Here's an AutoIt example of using the IShellFolder interface (note the
use of the returned function ptr $IEnumIDList to iterate further into
the shell interface):

; Create an IDispatch-Object for the IShellFolder Interface
$IShellFolder = ObjCreateInterface( $pParentFolder, $sIID_IShellFolder, 
$dtagIShellFolder )

; $pIEnumIDList is the address that receives an IEnumIDList interface pointer 
of the enumeration object
If $IShellFolder.EnumObjects( $NULL, BitOR( $SHCONTF_FOLDERS, 
$SHCONTF_INCLUDEHIDDEN ), $pIEnumIDList ) = $S_OK Then

    ; Create an IDispatch-Object for the IEnumIDList Interface
    $IEnumIDList = ObjCreateInterface( $pIEnumIDList, $sIID_IEnumIDList, 
$dtagIEnumIDList )

    ; Enumerate the folders                                   ; Param 1 [in] : 
Step value as in a For-loop
    While $IEnumIDList.Next( 1, $pidlRel, $iFetched ) = $S_OK ; Param 2 [out]: 
PIDL relative to parent folder
        $iFolders += 1                                        ; Param 3 [out]: 
0 if no more PIDLs, 1 else
           ...
           ...
           ...
    WEnd
EndIf

I wanted to use this technique to iterate over the Recycle bin and
look for a specific item or optionally list the items found using
Win32API calls but got short-circuited by that returned function
ptr and no way to use it.

Reply via email to