Jump to content

Help with Memory or Resource or Stream


Recommended Posts

Hi, everybody. Can you help me... :P

Not fortunatelly, I don't have knowledge about C++ or even C#. :)

This sourcecode are possible translate to AutoIt3 and how...? .... :)

void flash_load_memory(FlashWidget* w, void* data, ULONG size) {
        FlashMemoryStream fStream = FlashMemoryStream(data, size);
        IPersistStreamInit* psStreamInit = NULL;
        w->mFlashInterface->QueryInterface(IID_IPersistStreamInit,(LPVOID*) &psStreamInit);
        if(psStreamInit) {
            psStreamInit->InitNew();
            psStreamInit->Load((LPSTREAM)&fStream);
            psStreamInit->Release();
        }
    }

class FlashMemoryStream : IStream {
    public:
        FlashMemoryStream(void* data,ULONG size) {
            this->data = data;
            this->size = size;
            this->pos = 0;
        }

        HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID* ppv) {
            return E_NOTIMPL;
        }

        ULONG STDMETHODCALLTYPE AddRef() {  
            return E_NOTIMPL;
        }

        ULONG STDMETHODCALLTYPE Release() {  
            return E_NOTIMPL;
        }

        // IStream methods
        STDMETHOD(Read) (void *pv,ULONG cb,ULONG *pcbRead) {
            if(pos == 0 && cb == 4) {
                memcpy(pv,"fUfU",4);
                pos += 4;
                return S_OK;
            }
            else if(pos == 4 && cb == 4) {
                memcpy(pv,&size,4);
                size += 8;
                pos += 4;
                return S_OK;
            }
            else {
                if(pos + cb > size) cb = size - pos;
                if(cb == 0) return S_FALSE;
                memcpy(pv,(char*)data + pos - 8,cb);
                if(pcbRead) (*pcbRead) = cb;
                pos += cb;
                return S_OK;
            }
        }

        STDMETHOD(Write) (void const *pv,ULONG cb,ULONG *pcbWritten) { return E_NOTIMPL; }
        STDMETHOD(Seek) (LARGE_INTEGER dlibMove,DWORD dwOrigin,ULARGE_INTEGER *plibNewPosition) { return E_NOTIMPL; }
        STDMETHOD(SetSize) (ULARGE_INTEGER libNewSize) { return E_NOTIMPL; }
        STDMETHOD(CopyTo) (IStream *pstm,ULARGE_INTEGER cb,ULARGE_INTEGER *pcbRead,ULARGE_INTEGER *pcbWritten) { return E_NOTIMPL; }
        STDMETHOD(Commit) (DWORD grfCommitFlags) { return E_NOTIMPL; }
        STDMETHOD(Revert) (void) { return E_NOTIMPL; }
        STDMETHOD(LockRegion) (ULARGE_INTEGER libOffset,ULARGE_INTEGER cb,DWORD dwLockType) { return E_NOTIMPL; }
        STDMETHOD(UnlockRegion) (ULARGE_INTEGER libOffset,ULARGE_INTEGER cb,DWORD dwLockType) { return E_NOTIMPL; }
        STDMETHOD(Stat) (STATSTG *pstatstg,DWORD grfStatFlag) { return E_NOTIMPL; }
        STDMETHOD(Clone) (IStream **ppstm) { return E_NOTIMPL; }

        void* data;
        ULONG size;
        ULONG pos;
    };
Edited by prazetto

# Button. Progressbar - Graphical AutoIt3 Control (UDF) # GTK on AutoIt3 - GTK+ Framework | Widgets

Link to comment
Share on other sites

Let me demonstrate the power of AutoItObject.

...Who knows, maybe some eyes will get opened afterwards.

#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <GUIConstantsEx.au3>
#include "AutoitObject.au3"

;===============================================================================
#interface "IPersist"
Global Const $sIID_IPersist = "{0000010c-0000-0000-C000-000000000046}"
; Definition
Global $dtagIPersist = $dtagIUnknown & _
        "GetClassID hresult(ptr*);"
; List
Global $ltagIPersist = $ltagIUnknown & _
        "GetClassID;"
;===============================================================================

;===============================================================================
#interface "IPersistStream"
Global Const $sIID_IPersistStream = "{00000109-0000-0000-C000-000000000046}"
; Definition
Global $dtagIPersistStream = $dtagIPersist & _
        "IsDirty hresult(ptr);" & _
        "Load hresult(ptr);" & _
        "Save hresult(ptr;bool);" & _
        "GetSizeMax hresult(uint64*);"
; List
Global $ltagIPersistStream = $ltagIPersist & _
        "IsDirty;" & _
        "Load;" & _
        "Save;" & _
        "GetSizeMax;"
;===============================================================================

;===============================================================================
#interface "IPersistStreamInit"
Global Const $sIID_IPersistStreamInit = "{7FD52380-4E07-101B-AE2D-08002B2EC713}"
; Definition
Global $dtagIPersistStreamInit = $dtagIPersistStream & _
        "InitNew hresult();"
; List
Global $ltagIPersistStreamInit = $ltagIPersistStream & _
        "InitNew;"
;===============================================================================

;===============================================================================
#interface "ISequentialStream"
Global Const $sIID_ISequentialStream = "{0C733A30-2A1C-11CE-ADE5-00AA0044773D}"
; Definition
Global $dtagISequentialStream = $dtagIUnknown & _
        "Read hresult(ptr;dword;dword*);" & _
        "Write hresult(ptr;dword;dword*);"
; List
Global $ltagISequentialStream = $ltagIUnknown & _
        "Read;" & _
        "Write;"
;===============================================================================

;===============================================================================
#interface "IStream"
Global Const $sIID_IStream = "{0000000C-0000-0000-C000-000000000046}"
; Definition
Global $dtagIStream = $dtagISequentialStream & _
        "Seek hresult(int64;dword;int64);" & _
        "SetSize hresult(int64);" & _
        "CopyTo hresult(ptr;int64;int64*;int64*);" & _
        "Commit hresult(dword);" & _
        "Revert none();" & _
        "LockRegion hresult(int64;int64;dword);" & _
        "UnlockRegion hresult(int64;int64;dword);" & _
        "Stat hresult(ptr;dword);" & _
        "Clone hresult(ptr*);"
; List
Global $ltagIStream = $ltagISequentialStream & _
        "Seek;" & _
        "SetSize;" & _
        "CopyTo;" & _
        "Commit;" & _
        "Revert;" & _
        "LockRegion;" & _
        "UnlockRegion;" & _
        "Stat;" & _
        "Clone;"
;===============================================================================

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")

; Let's Start
_AutoItObject_Startup()

Global Const $sCLSID_ShockwaveFlash = "{D27CDB6E-AE6D-11CF-96B8-444553540000}"
Global Const $sIID_IShockwaveFlash = "{D27CDB6C-AE6D-11CF-96B8-444553540000}"
Global $oShockwaveFlash

; There are several available ways to create desired object:
; 1. Built-in function:
$oShockwaveFlash = ObjCreate("ShockwaveFlash.ShockwaveFlash") ;

; 2. AutoItObject's pandan:
;~ $oShockwaveFlash = _AutoItObject_ObjCreate("ShockwaveFlash.ShockwaveFlash")

; 3. The same function but this time passing CLSID:
;~ $oShockwaveFlash = _AutoItObject_ObjCreate($sCLSID_ShockwaveFlash)

; 4. _AutoItObject_ObjCreateEx. This one works from server file directly (doesn't require installed flash)
;~ $oShockwaveFlash = _AutoItObject_ObjCreateEx(@ScriptDir & "\Flash10m.ocx", $sCLSID_ShockwaveFlash, $sIID_IShockwaveFlash)

If Not IsObj($oShockwaveFlash) Then Exit -11

; GUI
Global $GUI = GUICreate("Test", 600, 453)
Global $hControl = GUICtrlCreateObj($oShockwaveFlash, 0, 0, 600, 453)
GUICtrlSetState($hControl, $GUI_DISABLE) ; Not to intrract

Global $iPos = 0, $iSizeData
Global $vVar ; Some variable
$vVar = InetRead("http://bytescout.com/files/demo/swfscout_VideoSample.swf") ; data
;~ $vVar = FileRead(@DesktopDir & "\Action.swf") ; Some file to load
Global $pData = _MemoryFromVar($vVar, $iSizeData)

GUISetState()

_FlashLoadMemory($oShockwaveFlash, $pData, $iSizeData, $iPos)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd




Func _FlashLoadMemory($oShockwaveFlash, ByRef $pData, ByRef $iSizeData, ByRef $iPos)
    #forceref $pData, $iSizeData, $iPos
    If Not IsObj($oShockwaveFlash) Then Return SetError(1, 0, False)
    _AutoItObject_IUnknownAddRef($oShockwaveFlash) ; Add reference
    Local $oFlashInterface = _AutoItObject_WrapperCreate(_AutoItObject_IDispatchToPtr($oShockwaveFlash), $dtagIUnknown)
    If Not IsObj($oFlashInterface) Then Return SetError(2, 0, False)
    Local $oFlashMemoryStream = _AutoItObject_ObjectFromDtag("_FlashMemoryStream_", $dtagIStream)
    Local $tIID_IPersistStreamInit = _AutoItObject_CLSIDFromString($sIID_IPersistStreamInit)
    Local $aCall = $oFlashInterface.QueryInterface(Number(DllStructGetPtr($tIID_IPersistStreamInit)), 0)
    Local $pPersistStreamInit = $aCall[2]
    Local $oPersistStreamInit = _AutoItObject_WrapperCreate($pPersistStreamInit, $dtagIPersistStreamInit)
    $oPersistStreamInit.InitNew()
    $oPersistStreamInit.Load(Number($oFlashMemoryStream.__ptr__))
    Return True
EndFunc   ;==>_FlashLoadMemory

; IStream definition, custom implementation:
Func _FlashMemoryStream_QueryInterface($pSelf, $pRIID, $pObj)
    #forceref $pSelf, $pRIID, $pObj
    Return 0x80004002 ; E_NOINTERFACE
EndFunc   ;==>_FlashMemoryStream_QueryInterface
Func _FlashMemoryStream_AddRef($pSelf)
    #forceref $pSelf
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_AddRef
Func _FlashMemoryStream_Release($pSelf)
    #forceref $pSelf
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Release
Func _FlashMemoryStream_Read($pSelf, $pBuffer, $iCb, $pRead)
    #forceref $pSelf
    If $iPos = 0 And $iCb = 4 Then
        DllStructSetData(DllStructCreate("char[4]", $pBuffer), 1, "fUfU")
        $iPos += 4
    ElseIf $iPos = 4 And $iCb = 4 Then
        DllStructSetData(DllStructCreate("dword", $pBuffer), 1, $iSizeData)
        $iSizeData += 8
        $iPos += 4
    Else
        If $iPos + $iCb > $iSizeData Then $iCb = $iSizeData - $iPos
        If $iCb = 0 Then Return 1 ; S_FALSE
        DllStructSetData(DllStructCreate("byte[" & $iCb & "]", $pBuffer), 1, DllStructGetData(DllStructCreate("byte[" & $iCb & "]", $pData + $iPos - 8), 1))
        If $pRead Then DllStructSetData(DllStructCreate("dword", $pRead), 1, $iCb)
        $iPos += $iCb
    EndIf
    Return 0 ; S_OK
EndFunc   ;==>_FlashMemoryStream_Read
Func _FlashMemoryStream_Write($pSelf, $pBuffer, $iCb, $iWritten)
    #forceref $pSelf, $pBuffer, $iCb, $iWritten
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Write
Func _FlashMemoryStream_Seek($pSelf, $iMove, $iOrigin, $iNewPos)
    #forceref $pSelf, $iMove, $iOrigin, $iNewPos
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Seek
Func _FlashMemoryStream_SetSize($pSelf, $iNewSize)
    #forceref $pSelf, $iNewSize
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_SetSize
Func _FlashMemoryStream_CopyTo($pSelf, $pStream, $iCb, $pRead, $pWritten)
    #forceref $pSelf, $pStream, $iCb, $pRead, $pWritten
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_CopyTo
Func _FlashMemoryStream_Commit($pSelf, $iCommitFlags)
    #forceref $pSelf, $iCommitFlags
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Commit
Func _FlashMemoryStream_Revert($pSelf)
    #forceref $pSelf
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Revert
Func _FlashMemoryStream_LockRegion($pSelf, $iOffset, $iCb, $iLockSize)
    #forceref $pSelf, $iOffset, $iCb, $iLockSize
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_LockRegion
Func _FlashMemoryStream_UnlockRegion($pSelf, $iOffset, $iCb, $iLockSize)
    #forceref $pSelf, $iOffset, $iCb, $iLockSize
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_UnlockRegion
Func _FlashMemoryStream_Stat($pSelf, $pStatstg, $iFlag)
    #forceref $pSelf, $pStatstg, $iFlag
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Stat
Func _FlashMemoryStream_Clone($pSelf, $pStream)
    #forceref $pSelf, $pStream
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Clone


; Some function to load data to memory:
Func _MemoryFromVar($vVar, ByRef $iSize)
    Local Static $tData ; Static to keep it alive after the return of the function
    $tData = DllStructCreate("byte[" & BinaryLen($vVar) & "]")
    DllStructSetData($tData, 1, $vVar)
    $iSize = DllStructGetSize($tData)
    Return DllStructGetPtr($tData)
EndFunc   ;==>_MemoryFromVar


; On Error
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc

COM beyond imaginable.

edit: or maybe this:

#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <GUIConstantsEx.au3>
#include "AutoitObject.au3"

;===============================================================================
#interface "IPersist"
Global Const $sIID_IPersist = "{0000010c-0000-0000-C000-000000000046}"
; Definition
Global $dtagIPersist = $dtagIUnknown & _
        "GetClassID hresult(ptr*);"
; List
Global $ltagIPersist = $ltagIUnknown & _
        "GetClassID;"
;===============================================================================

;===============================================================================
#interface "IPersistStream"
Global Const $sIID_IPersistStream = "{00000109-0000-0000-C000-000000000046}"
; Definition
Global $dtagIPersistStream = $dtagIPersist & _
        "IsDirty hresult(ptr);" & _
        "Load hresult(ptr);" & _
        "Save hresult(ptr;bool);" & _
        "GetSizeMax hresult(uint64*);"
; List
Global $ltagIPersistStream = $ltagIPersist & _
        "IsDirty;" & _
        "Load;" & _
        "Save;" & _
        "GetSizeMax;"
;===============================================================================

;===============================================================================
#interface "IPersistStreamInit"
Global Const $sIID_IPersistStreamInit = "{7FD52380-4E07-101B-AE2D-08002B2EC713}"
; Definition
Global $dtagIPersistStreamInit = $dtagIPersistStream & _
        "InitNew hresult();"
; List
Global $ltagIPersistStreamInit = $ltagIPersistStream & _
        "InitNew;"
;===============================================================================

;===============================================================================
#interface "ISequentialStream"
Global Const $sIID_ISequentialStream = "{0C733A30-2A1C-11CE-ADE5-00AA0044773D}"
; Definition
Global $dtagISequentialStream = $dtagIUnknown & _
        "Read hresult(ptr;dword;dword*);" & _
        "Write hresult(ptr;dword;dword*);"
; List
Global $ltagISequentialStream = $ltagIUnknown & _
        "Read;" & _
        "Write;"
;===============================================================================

;===============================================================================
#interface "IStream"
Global Const $sIID_IStream = "{0000000C-0000-0000-C000-000000000046}"
; Definition
Global $dtagIStream = $dtagISequentialStream & _
        "Seek hresult(int64;dword;int64);" & _
        "SetSize hresult(int64);" & _
        "CopyTo hresult(ptr;int64;int64*;int64*);" & _
        "Commit hresult(dword);" & _
        "Revert none();" & _
        "LockRegion hresult(int64;int64;dword);" & _
        "UnlockRegion hresult(int64;int64;dword);" & _
        "Stat hresult(ptr;dword);" & _
        "Clone hresult(ptr*);"
; List
Global $ltagIStream = $ltagISequentialStream & _
        "Seek;" & _
        "SetSize;" & _
        "CopyTo;" & _
        "Commit;" & _
        "Revert;" & _
        "LockRegion;" & _
        "UnlockRegion;" & _
        "Stat;" & _
        "Clone;"
;===============================================================================

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")

; Let's Start
_AutoItObject_Startup()

Global Const $sCLSID_ShockwaveFlash = "{D27CDB6E-AE6D-11CF-96B8-444553540000}"
Global Const $sIID_IShockwaveFlash = "{D27CDB6C-AE6D-11CF-96B8-444553540000}"
Global $oShockwaveFlash

; There are several available ways to create desired object:
; 1. Built-in function:
$oShockwaveFlash = ObjCreate("ShockwaveFlash.ShockwaveFlash") ;

; 2. AutoItObject's pandan:
;~ $oShockwaveFlash = _AutoItObject_ObjCreate("ShockwaveFlash.ShockwaveFlash")

; 3. The same function but this time passing CLSID:
;~ $oShockwaveFlash = _AutoItObject_ObjCreate($sCLSID_ShockwaveFlash)

; 4. _AutoItObject_ObjCreateEx. This one works from server file directly (doesn't require installed flash)
;~ $oShockwaveFlash = _AutoItObject_ObjCreateEx(@ScriptDir & "\Flash10m.ocx", $sCLSID_ShockwaveFlash, $sIID_IShockwaveFlash)

If Not IsObj($oShockwaveFlash) Then Exit -11

; GUI
Global $GUI = GUICreate("Test inline", 600, 453)
Global $hControl = GUICtrlCreateObj($oShockwaveFlash, 0, 0, 600, 453)
GUICtrlSetState($hControl, $GUI_DISABLE) ; Not to interact

Global $iPos = 0
Global $vVar = Binary("0x435753085D07000078DA7D555B73DB4414FE2CCB91EC5CDA9AB626E0A40ED03230533B49C76DE84069702EE399C4364EA7C09347B6D6B2125912D2DA897E00439FF2A8191EE0B7F0D4BF15CEAE94D8A5143FACF6DCBF3DDF9EF505165E02C5BF810719ECDD01FDBECFFE9601E21DC09E040E30E2DC7F5EABD94FAA11B7C75675E08D6B53BB76F0AC5DDF7CF2F366D76CD646BF9A6C684C1C5E3DF52DACC52B00A34836EE33D36426697460C82E7C4ABF163F02B8CD1D061C388CF173CF332BC7C6A0F2B8F2836D558EBC29AB6C7DB3F38C3C098F31B57A81C16DD702EAD54D529680A96D32AF679B946186824CF70087B9161FF54236F05C3304B6B7B7C8709B12398E77DE939000A1AB03E1F9F0E67CE1DCF1225E2353DF766B033F7C3C1D3ADB9D9DAD1F77ABC27F2DFE9202CF80236B72368A46A7AF7FD91FB79F1A3F4DB7EAD6ABFA249AF291B933ED8E1AE45ABCAE9B1C214C2A533302D19F74CF649B69BF4CDE13EEF98E1149231ACAD5D5D5DB3C3A4408EEAFD0DAE9F53AC6E0CCB058581D58D1E4A483AB152D47E6CE9BD7994748753DCBF1FA86033FF0B8C7239F616CD82E1CCF301B8EED63209780199CED8F7D1E1D7B539B49CBCDEE887C5900C3341B74843E1505738DBEC34E43C3B709DED031C211D80567814BA5F6D34DD3A5EFD01830A2CEB01D110123B02663E6F2104317260B79E04598B8028EAC47ED1813ED3314A2052C90104CD861675E1424D410FA8ECD13EEE41A3EC71C8310A4C1764D76D11E42F2466879335510AB08277DC221EE554FF4BF56C335E7D83D3961BC1378FE81631067B1021DE562F14F057F658590294BD5A52EC625BB4ACBEF444D3B56A142575A24644A8990BDA451C860690349CB9B59BA8ABAAA093EE9A3884F4E665BE87E1B6BD044465D7B49299492502746FD7249A4C9521A6AE05BCC2CF996580BCD23816E153266515A96A46559AE2B2D61BE4C112B1B68CB14B7CA710E5A9654AD99A8BC2B66DE15214502AACEA0DF2E775F248035A88A7469247AE128D2FF0724BD5B6ACF8E712745F6159EE2A60D6A62EA96FEA529BEA7F968968C9A7E3787B9D4F76E522FCFF5ED6EEBC59CCF7DC159B614E7A197126EAEF562FDB84B56559E4E4D1A40724E329CD3579B45D9FB0252C527CD62228BD0D5C453462A69E482745CD03F4D1C2B1951B6FC7ED935515693A0D63F60D53F04F941F79ABB4372CBCB6B51A15D4162D1347A56AE2C51FD21E24552A8F9F9BB98E4D8E8CA803F149A7511A5CFA22A324AFF9FA8395C09459FA5ADBCB962E4B698B6ECF343B2A98B62D5BF90FB82DCAF1F26B428320955CCCA5055D15541F8ADE4848A9A492ED9C3EF4AF4E7B547DB37EB347CC7AF764F1ABDE3DD660B7C6487D74FA37C08E5FC8AA12DA5F3AC25B9744582CD764BA88B51C5D7891E2751C8D918E5B8408F3F1B4C029B473408CBE9FBBEE7C9B41446FFA6F807C9748D3A") ; Some inline swf
Global $iSizeData = BinaryLen($vVar)

GUISetState()

_FlashLoadMemory($oShockwaveFlash, $vVar, $iSizeData, $iPos)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd




Func _FlashLoadMemory($oShockwaveFlash, ByRef $vData, ByRef $iSizeData, ByRef $iPos)
    #forceref $vData, $iSizeData, $iPos
    If Not IsObj($oShockwaveFlash) Then Return SetError(1, 0, False)
    _AutoItObject_IUnknownAddRef($oShockwaveFlash) ; Add reference
    Local $oFlashInterface = _AutoItObject_WrapperCreate(_AutoItObject_IDispatchToPtr($oShockwaveFlash), $dtagIUnknown)
    If Not IsObj($oFlashInterface) Then Return SetError(2, 0, False)
    Local $oFlashMemoryStream = _AutoItObject_ObjectFromDtag("_FlashMemoryStream_", $dtagIStream)
    Local $tIID_IPersistStreamInit = _AutoItObject_CLSIDFromString($sIID_IPersistStreamInit)
    Local $aCall = $oFlashInterface.QueryInterface(Number(DllStructGetPtr($tIID_IPersistStreamInit)), 0)
    Local $pPersistStreamInit = $aCall[2]
    Local $oPersistStreamInit = _AutoItObject_WrapperCreate($pPersistStreamInit, $dtagIPersistStreamInit)
    $oPersistStreamInit.InitNew()
    $oPersistStreamInit.Load(Number($oFlashMemoryStream.__ptr__))
    Return True
EndFunc   ;==>_FlashLoadMemory

; IStream definition, custom implementation:
Func _FlashMemoryStream_QueryInterface($pSelf, $pRIID, $pObj)
    #forceref $pSelf, $pRIID, $pObj
    Return 0x80004002 ; E_NOINTERFACE
EndFunc   ;==>_FlashMemoryStream_QueryInterface
Func _FlashMemoryStream_AddRef($pSelf)
    #forceref $pSelf
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_AddRef
Func _FlashMemoryStream_Release($pSelf)
    #forceref $pSelf
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Release
Func _FlashMemoryStream_Read($pSelf, $pBuffer, $iCb, $pRead)
    #forceref $pSelf
    If $iPos = 0 And $iCb = 4 Then
        DllStructSetData(DllStructCreate("char[4]", $pBuffer), 1, "fUfU")
        $iPos += 4
    ElseIf $iPos = 4 And $iCb = 4 Then
        DllStructSetData(DllStructCreate("dword", $pBuffer), 1, $iSizeData)
        $iSizeData += 8
        $iPos += 4
    Else
        If $iPos + $iCb > $iSizeData Then $iCb = $iSizeData - $iPos
        If $iCb = 0 Then Return 1 ; S_FALSE
        DllStructSetData(DllStructCreate("byte[" & $iCb & "]", $pBuffer), 1, BinaryMid($vVar, 1 + $iPos - 8, $iCb))
        If $pRead Then DllStructSetData(DllStructCreate("dword", $pRead), 1, $iCb)
        $iPos += $iCb
    EndIf
    Return 0 ; S_OK
EndFunc   ;==>_FlashMemoryStream_Read
Func _FlashMemoryStream_Write($pSelf, $pBuffer, $iCb, $iWritten)
    #forceref $pSelf, $pBuffer, $iCb, $iWritten
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Write
Func _FlashMemoryStream_Seek($pSelf, $iMove, $iOrigin, $iNewPos)
    #forceref $pSelf, $iMove, $iOrigin, $iNewPos
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Seek
Func _FlashMemoryStream_SetSize($pSelf, $iNewSize)
    #forceref $pSelf, $iNewSize
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_SetSize
Func _FlashMemoryStream_CopyTo($pSelf, $pStream, $iCb, $pRead, $pWritten)
    #forceref $pSelf, $pStream, $iCb, $pRead, $pWritten
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_CopyTo
Func _FlashMemoryStream_Commit($pSelf, $iCommitFlags)
    #forceref $pSelf, $iCommitFlags
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Commit
Func _FlashMemoryStream_Revert($pSelf)
    #forceref $pSelf
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Revert
Func _FlashMemoryStream_LockRegion($pSelf, $iOffset, $iCb, $iLockSize)
    #forceref $pSelf, $iOffset, $iCb, $iLockSize
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_LockRegion
Func _FlashMemoryStream_UnlockRegion($pSelf, $iOffset, $iCb, $iLockSize)
    #forceref $pSelf, $iOffset, $iCb, $iLockSize
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_UnlockRegion
Func _FlashMemoryStream_Stat($pSelf, $pStatstg, $iFlag)
    #forceref $pSelf, $pStatstg, $iFlag
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Stat
Func _FlashMemoryStream_Clone($pSelf, $pStream)
    #forceref $pSelf, $pStream
    Return 0x80004001 ; E_NOTIMPL
EndFunc   ;==>_FlashMemoryStream_Clone


; On Error
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc
Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...