Jump to content

FlashMemoryStream


wolf9228
 Share

Recommended Posts

 

In the new versions of Autoit, the code does not work... The code has been updated... and now it works... Thanks.

FlashMemoryStream.zip

 

download intro.swf

https://www.w3schools.com/html/intro.swf

#AutoIt3Wrapper_Res_File_Add=intro.swf,FILES,SWF,0
#include <WinAPI.au3>
#include <Memory.au3>
#include <GUIConstantsEx.au3>

;https://www.w3schools.com/html/intro.swf

Global $cNewMemStream[1],$ClassFlashMemoryStream[1],$Atl = DllOpen("Atl.dll"),$Ole32 = DllOpen("Ole32.dll")
Global $RegReadMethod  =  DllCallbackRegister( "Read","LONG","PTR;PTR;ULONG;PTR" ) , $WinInit  =  False

$Gui = GUICreate("My GUI",450,400,100,50)
$hMemory = ResToGlobalAlloc("SWF","FILES")
if Not($hMemory) Then $hMemory = FileToGlobalAlloc("intro.swf")
if @error Then Exit
$ReturnArray = GUICtrlCreateFlashFromMem($hMemory,10,10,430,300)
$CtrlId = $ReturnArray[0]
$FlashCOMobject = $ReturnArray[1]
$Button_1 = GUICtrlCreateButton("Button",175,330,100,40)
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
MsgBox(0,"Msg","OK")
EndSelect
WEnd
Exit

Func GUICtrlCreateFlashFromMem($hMemory,$L,$T,$W,$H)
$StreamData = _MemGlobalLock($hMemory)
if Not($StreamData) Then Return SetError(1,0,0)
$StreamSize = _MemGlobalSize($hMemory)
if Not($StreamSize) Then Return SetError(2,0,0)
if Not($WinInit) Then
$Return = DllCall($Ole32,"long","CoInitialize","ptr",0)
if @error Or ($Return[0] <> 0 And $Return[0] <> 1) Then Return SetError(3,0,0)
$Return = DllCall($Atl,"BOOL","AtlAxWinInit")
if @error Or $Return[0] = 0 Then Return SetError(4,0,0)
$WinInit = True
EndIf
$CtrlId = GUICtrlCreateLabel("",$L,$T,$W,$H)
if @error Then Return SetError(5,0,0)
$CtrlHandle = GUICtrlGetHandle($CtrlId)
$Return = DllCall($Atl,"long","AtlAxCreateControl","wstr","ShockwaveFlash.ShockwaveFlash" _
,"ptr",$CtrlHandle,"ptr",0,"ptr*",0)
if @error Or $Return[0] <> 0 Then
GUICtrlDelete($CtrlId)
Return SetError(6,0,0)
EndIf

$IUnknown = $Return[4]
;Release Method = 3
InterfaceCall($IUnknown,"long",3)
$Return = DllCall($Atl,"long","AtlAxGetControl","ptr",$CtrlHandle,"ptr*",0)
if @error Or $Return[0] <> 0 Then
GUICtrlDelete($CtrlId)
Return SetError(7,0,0)
EndIf
$ShockwaveFlash = $Return[2]

$IID_IDispatch =  IIDFromString("{00020400-0000-0000-C000-000000000046}")
;QueryInterface Method = 1
$Return = InterfaceCall($ShockwaveFlash,"long",1,"struct*",$IID_IDispatch,"idispatch*",0)
if @error Or $Return[0] <> 0 Then
GUICtrlDelete($CtrlId)
Return SetError(8,0,0)
EndIf
$DisphShockwaveFlash = $Return[2]
$IID_IPersistStreamInit =  IIDFromString("{7FD52380-4E07-101B-AE2D-08002B2EC713}")
;QueryInterface Method = 1
$Return = InterfaceCall($ShockwaveFlash,"long",1,"struct*",$IID_IPersistStreamInit,"ptr*",0)
if @error Or $Return[0] <> 0 Then
GUICtrlDelete($CtrlId)
Return SetError(9,0,0)
EndIf
$IPersistStreamInit = $Return[2]
$RtArray = ClassFlashMemoryStream($StreamData,$StreamSize)
if @error Then
;Release Method = 3
InterfaceCall($IPersistStreamInit,"long",3)
Return SetError(10,0,0)
EndIf
$CFlashMemoryStream = $RtArray[0]
$IStream = $RtArray[1]
; InitNew Method = 9
$Return = InterfaceCall($IPersistStreamInit,"long",9)
if @error Or $Return[0] <> 0 Then
;Release Method = 3
InterfaceCall($IPersistStreamInit,"long",3)
;Release Method = 3
InterfaceCall($IStream,"long",3)
ReDim $ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 1]
Return SetError(11,0,0)
EndIf
;load Method = 3
$Return = InterfaceCall($IPersistStreamInit,"long",6,"ptr",DllStructGetPtr($CFlashMemoryStream))
if @error Or $Return[0] <> 0 Then
;Release Method = 3
InterfaceCall($IPersistStreamInit,"long",3)
;Release Method = 3
InterfaceCall($IStream,"long",3)
ReDim $ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 1]
Return SetError(12,0,0)
EndIf

Local $ReturnArray[6]
$ReturnArray[0] = $CtrlId ; Ctrl Id Of Label (ShockwaveFlash Window)
$ReturnArray[1] = $DisphShockwaveFlash ;ShockwaveFlash COM object
$ReturnArray[2] = $ShockwaveFlash ;ShockwaveFlash Interface
$ReturnArray[3] = $CFlashMemoryStream ;Class FlashMemoryStream Struct
$ReturnArray[4] = $IPersistStreamInit ;IPersistStreamInit Interface
$ReturnArray[5] = $IStream ;$IStream Interface
Return $ReturnArray
EndFunc


Func FileToGlobalAlloc($FileName)
Local $nBytes
$FileSize = FileGetSize($FileName)
if @error Then Return SetError(1,0,0)
$hMemory = _MemGlobalAlloc($FileSize,$GHND)
if Not($hMemory) Then Return SetError(2,0,0)
$GlobalLock = _MemGlobalLock($hMemory)
if Not($GlobalLock) Then
_MemGlobalFree($hMemory)
Return SetError(3,0,0)
EndIf
$hFile = _WinAPI_CreateFile($FileName,2,2)
if Not($hFile) Then
_MemGlobalFree($hMemory)
Return SetError(4,0,0)
EndIf
$BOOL =_WinAPI_ReadFile($hFile,$GlobalLock,$FileSize,$nBytes)
if Not($BOOL) Then
_MemGlobalFree($hMemory)
_WinAPI_CloseHandle($hFile)
Return SetError(5,0,0)
EndIf
_WinAPI_CloseHandle($hFile)
Return $hMemory
EndFunc

Func ResToGlobalAlloc($ResName,$ResType,$ResLanguage = -1)
$ByteStruct = ResGet($ResName,$ResType,$ResLanguage)
if @error Then Return SetError(1,0,0)
$ResSize = @extended
$hMemory = _MemGlobalAlloc($ResSize,$GHND)
if Not($hMemory) Then Return SetError(2,0,0)
$GlobalLock = _MemGlobalLock($hMemory)
if Not($GlobalLock) Then
_MemGlobalFree($hMemory)
Return SetError(3,0,0)
EndIf
_MemMoveMemory(DllStructGetPtr($ByteStruct),$GlobalLock,$ResSize)
Return $hMemory
EndFunc

Func ResGet($ResName,$ResType,$ResLanguage = -1,$HModule = 0)
Local $DataType1 = "LONG",$DataType2 = "LONG"
Local $LPVOID,$HRSRC,$ResSize,$HGLOBAL

if IsString($ResName) Then
$ResName = StringUpper($ResName)
$DataType1 = "WSTR"
EndIf
If IsString($ResType) Then
$ResType = StringUpper($ResType)
$DataType2 = "WSTR"
EndIf
if ($HModule = 0) Then $HModule = _WinAPI_GetModuleHandle(0)

if ($ResLanguage <> -1) Then
$HRSRC = DllCall("Kernel32.dll","ptr","FindResourceExW","ptr",$HModule,$DataType2, _
$ResType,$DataType1,$ResName,"WORD",$ResLanguage)
if @error Or $HRSRC[0] = 0 Then Return SetError(1,0,0)
Else
$HRSRC = DllCall("Kernel32.dll","ptr","FindResourceW","ptr",$HModule,$DataType1,$ResName,$DataType2, _
$ResType)
if @error Or $HRSRC[0] = 0 Then Return SetError(1,0,0)
EndIf

$HRSRC = $HRSRC[0]
$ResSize = DllCall("Kernel32.dll","DWORD","SizeofResource","ptr",$HModule,"ptr",$HRSRC)
if (@error Or $ResSize[0] = 0) Then Return SetError(2,0,0)
$ResSize = $ResSize[0]

$HGLOBAL = DllCall("Kernel32.dll","ptr","LoadResource","ptr",$HModule,"ptr",$HRSRC)
if @error Or $HGLOBAL[0] = 0 Then Return SetError(3,0,0)
$HGLOBAL = $HGLOBAL[0]

$LPVOID = DllCall("Kernel32.dll","ptr","LockResource","ptr",$HGLOBAL)
if @error Or $LPVOID[0] = 0 Then
$BOOL = DllCall("Kernel32.dll","BOOL","FreeResource","ptr",$HGLOBAL)
Return SetError(4,0,0)
EndIf
$LPVOID = $LPVOID[0]

$ByteStruct =  DllStructCreate("BYTE[" & $ResSize & "]")
_MemMoveMemory($LPVOID,DllStructGetPtr($ByteStruct),$ResSize)
$BOOL = DllCall("Kernel32.dll","BOOL","FreeResource","ptr",$HGLOBAL)

Return SetError(0,$ResSize,$ByteStruct)
EndFunc

Func ClassFlashMemoryStream($StreamData,$StreamSize)
Global $tagClassFlashMemoryStream = _
"ULONG_PTR QueryInterface;ULONG_PTR AddRef;ULONG_PTR Release;ULONG_PTR Read;ULONG_PTR Write;" & _
"ULONG_PTR Seek;ULONG_PTR SetSize;ULONG_PTR CopyTo;ULONG_PTR Commit;ULONG_PTR Revert;ULONG_PTR" & _
" LockRegion;ULONG_PTR UnlockRegion;ULONG_PTR Stat;ULONG_PTR Clone;PTR data;ULONG size;ULONG pos"
$NewMemStream = DllStructCreate($tagClassFlashMemoryStream)
$cNewMemStream[UBound($cNewMemStream) - 1] = $NewMemStream
ReDim $cNewMemStream[UBound($cNewMemStream) + 1]
Local $grfMode = BitOR(0x00000002,0x00001000,0x00000010)
Local $HRESULT = DllCall("Ole32.dll","long","StgCreateDocfile","int",0,"DWORD",$grfMode _
,"DWORD",0,"ptr*",0)
if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0)
Local $pIStorage = $HRESULT[4]
$grfMode = BitOR(0x00000002,0x00000010)
$HRESULT = InterfaceCall($pIStorage,"long",4,"wstr","FlashStream","DWORD",$grfMode, _
"DWORD",0,"DWORD",0,"ptr*",0) ;CreateStream METHOD
if @error Or $HRESULT[0] <> 0 Then
;Release Method = 3
InterfaceCall($pIStorage,"long",3)
Return SetError(2,0,0)
EndIf
;Release Method = 3
InterfaceCall($pIStorage,"long",3)
Local $IStream = $HRESULT[5]
$QueryInterface = GetMethodAddress($IStream,1)
DllStructSetData($NewMemStream,1,$QueryInterface)
$AddRef = GetMethodAddress($IStream,2)
DllStructSetData($NewMemStream,2,$AddRef)
$Release = GetMethodAddress($IStream,3)
DllStructSetData($NewMemStream,3,$Release)
;----------------------------------------;
$Read = DllCallbackGetPtr($RegReadMethod)
DllStructSetData($NewMemStream,4,$Read)
;----------------------------------------;
$Write = GetMethodAddress($IStream,5)
DllStructSetData($NewMemStream,5,$Write)
$Seek = GetMethodAddress($IStream,6)
DllStructSetData($NewMemStream,6,$Seek)
$SetSize = GetMethodAddress($IStream,7)
DllStructSetData($NewMemStream,7,$SetSize)
$CopyTo = GetMethodAddress($IStream,8)
DllStructSetData($NewMemStream,8,$CopyTo)
$Commit = GetMethodAddress($IStream,9)
DllStructSetData($NewMemStream,9,$Commit)
$Revert = GetMethodAddress($IStream,10)
DllStructSetData($NewMemStream,10,$Revert)
$LockRegion = GetMethodAddress($IStream,11)
DllStructSetData($NewMemStream,11,$LockRegion)
$UnlockRegion = GetMethodAddress($IStream,12)
DllStructSetData($NewMemStream,12,$UnlockRegion)
$Stat = GetMethodAddress($IStream,13)
DllStructSetData($NewMemStream,13,$Stat)
$Clone = GetMethodAddress($IStream,14)
DllStructSetData($NewMemStream,14,$Clone)
DllStructSetData($NewMemStream,15,$StreamData)
DllStructSetData($NewMemStream,16,$StreamSize)
DllStructSetData($NewMemStream,17,0) ; $StreamiPos = 0
$NewMemStreamPtr = DllStructGetPtr($NewMemStream)
$ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 1] = DllStructCreate("ULONG_PTR")
DllStructSetData($ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 1],1,$NewMemStreamPtr)
ReDim $ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) + 1]
Local $RtArray[2]
$RtArray[0] = $ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 2] ;Class FlashMemoryStream Struct
$RtArray[1] = $IStream ;$IStream Interface
Return $RtArray
EndFunc

Func Read($Inface,$pv,$cb,$pcbRead)
Global $tagClassFlashMemoryStream = _
"ULONG_PTR QueryInterface;ULONG_PTR AddRef;ULONG_PTR Release;ULONG_PTR Read;ULONG_PTR Write;" & _
"ULONG_PTR Seek;ULONG_PTR SetSize;ULONG_PTR CopyTo;ULONG_PTR Commit;ULONG_PTR Revert;ULONG_PTR" & _
" LockRegion;ULONG_PTR UnlockRegion;ULONG_PTR Stat;ULONG_PTR Clone;PTR data;ULONG size;ULONG pos"
$OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface)
$OutCast1 = DllStructGetData($OutCastStruct1,1)
$CFlashMemoryStream = DllStructCreate($tagClassFlashMemoryStream,$OutCast1)
$StreamData = DllStructGetData($CFlashMemoryStream,"data")
$StreamSize = DllStructGetData($CFlashMemoryStream,"size")
$StreamiPos = DllStructGetData($CFlashMemoryStream,"pos")
if($StreamiPos == 0 And $cb == 4) Then
$String = DllStructCreate("char[4]")
DllStructSetData($String,1,"fUfU")
_MemMoveMemory(DllStructGetPtr($String),$pv,4)
DllStructSetData($CFlashMemoryStream,"pos",$StreamiPos + 4)
return 0
ElseIf ($StreamiPos == 4 And $cb == 4) Then
$IntSize = DllStructCreate("int")
DllStructSetData($IntSize,1,$StreamSize)
_MemMoveMemory(DllStructGetPtr($IntSize),$pv,4)
DllStructSetData($CFlashMemoryStream,"size",$StreamSize + 8)
DllStructSetData($CFlashMemoryStream,"pos",$StreamiPos + 4)
return 0
Else
if(($StreamiPos + $cb) > $StreamSize) Then $cb = ($StreamSize - $StreamiPos)
if($cb == 0) Then return 1
_MemMoveMemory($StreamData + ($StreamiPos - 8),$pv,$cb)
$IntCb = DllStructCreate("int")
DllStructSetData($IntCb,1,$cb)
if($pcbRead) Then _MemMoveMemory(DllStructGetPtr($IntCb),$pcbRead,4)
DllStructSetData($CFlashMemoryStream,"pos",$StreamiPos + $cb)
return 0
EndIf
EndFunc

Func InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0,$Type2 = 0,$Param2 = 0 _
,$Type3 = 0,$Param3 = 0, $Type4 = 0,$Param4 = 0 ,$Type5 = 0 ,$Param5 = 0,$Type6 = 0,$Param6 = 0 _
,$Type7 = 0,$Param7 = 0, $Type8 = 0,$Param8 = 0,$Type9 = 0,$Param9 = 0,$Type10 = 0,$Param10 = 0 _
,$Type11= 0,$Param11= 0,$Type12= 0,$Param12= 0,$Type13= 0,$Param13 = 0,$Type14 = 0,$Param14 = 0 _
,$Type15= 0,$Param15= 0,$Type16= 0,$Param16= 0,$Type17= 0,$Param17 = 0,$Type18 = 0,$Param18 = 0 _
,$Type19= 0,$Param19= 0,$Type20= 0,$Param20= 0,$Type21= 0,$Param21 = 0,$Type22 = 0,$Param22 = 0 _
,$Type23= 0,$Param23= 0,$Type24= 0,$Param24= 0,$Type25= 0,$Param25 = 0,$Type26 = 0,$Param26 = 0 _
,$Type27= 0,$Param27= 0,$Type28= 0,$Param28= 0,$Type29= 0,$Param29 = 0,$Type30 = 0,$Param30 = 0)
;;Return Array Of DllCallAddress
;Only Call Virtual Method Form any Class Or From any Interface
;$MethodNum ==> Virtual Method Number In (Virtual Methods Table) ;See the examples
;-------------------------------------------------------------------;C++ Example1
;C++ Example1
;class iClass
;{
;public:
;void MethodA()
;{
;MessageBox(0,"MethodA","MSG",0);
;}
;virtual void VirtualMethodB()
;{
;MessageBox(0,"VirtualMethodB","MSG",0);
;}
;virtual void VirtualMethodC()
;{
;MessageBox(0,"VirtualMethodC","MSG",0);
;}
;void MethodB()
;{
;MessageBox(0,"MethodB","MSG",0);
;}
;virtual void VirtualMethodA()
;{
;MessageBox(0,"VirtualMethodA","MSG",0);
;}
;};
;-----------------------------------------------------------;Virtual Methods Table
;Virtual Methods Table
;virtual void VirtualMethodB() ==> Virtual Method Number Is 1
;virtual void VirtualMethodC() ==> Virtual Method Number Is 2
;virtual void VirtualMethodA() ==> Virtual Method Number Is 3
;-----------------------------------------------------------;Virtual Methods Table
;-------------------------------------------------------------------;C++ Example1

;////////////////////////////////////////////////////////////////////////////////

;-------------------------------------------------------------------;C++ Example2
;C++ Example2
;class iClassA
;{
;public:
;void MethodA()
;{
;MessageBox(0,"MethodA","MSG",0);
;}
;virtual void VirtualMethodB()
;{
;MessageBox(0,"VirtualMethodB","MSG",0);
;}
;virtual void VirtualMethodC()
;{
;MessageBox(0,"VirtualMethodC","MSG",0);
;}
;};

;class iClassB : public iClassA
;{
;public:
;void MethodD()
;{
;MessageBox(0,"MethodD","MSG",0);
;}
;virtual void VirtualMethodF()
;{
;MessageBox(0,"VirtualMethodF","MSG",0);
;}
;virtual void VirtualMethodE()
;{
;MessageBox(0,"VirtualMethodE","MSG",0);
;}
;};
;////////////////////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////////////////////
;------------------------------------------;Virtual Methods Table Of iClassA Class
;Virtual Methods Table Of iClassA Class
;virtual void VirtualMethodB() ==> Virtual Method Number Is 1
;virtual void VirtualMethodC() ==> Virtual Method Number Is 2
;------------------------------------------;Virtual Methods Table Of iClassA Class
;////////////////////////////////////////////////////////////////////////////////
;///////////////////////////////////////////////////////////////////////////////
;------------------------------------------;Virtual Methods Table Of iClassB Class
;class iClassB : public iClassA
;base class ==> iClassA
;derived class ==> iClassB
;http://msdn.microsoft.com/en-us/library/hzk8a7d3.aspx
;When preceding the name of a base class, the public keyword specifies that the public
;and protected members of the base class are public and protected members, respectively,
;of the derived class.
;-------------------------------------------------------------------------------------
;Virtual Methods Table Of iClassB Class
;virtual void VirtualMethodB() In (iClassA) ==> Virtual Method Number Is 1
;virtual void VirtualMethodC() In (iClassA) ==> Virtual Method Number Is 2
;virtual void VirtualMethodF() In (iClassB) ==> Virtual Method Number Is 3
;virtual void VirtualMethodE() In (iClassB) ==> Virtual Method Number Is 4
;------------------------------------------;Virtual Methods Table Of iClassB Class
;-------------------------------------------------------------------;C++ Example2
;////////////////////////////////////////////////////////////////////////////////
if Not IsPtr($Inface) Or ($MethodNum < 1) Then Return SetError(1,0,0)
if (@NumParams > 3) And (Mod((@NumParams - 3),2) <> 0) Then Return SetError(2,0,0)
Local $iMethAddress = GetMethodAddress($Inface,$MethodNum)
if Not ($iMethAddress) Then Return SetError(3,0,0)
Local $iDataType = "",$iFuncParam = "",$iCommand = "",$iReturn = 0
;Why use Inface Param In DllCallAddress Function Because the Function of the method
;starts from the (Interface Or class)
;See here
;int class::MethodFunction( int Param ){return 0;};
$iCommand = 'DllCallAddress("' & $ReturnType & '",Eval("iMethAddress"),"ptr",Eval("Inface"),'
For $i = 1 To ((@NumParams - 3) / 2)
$iDataType = Eval("Type" & $i)
$iCommand &= '"' & $iDataType & '",'
$iFuncParam = 'Eval("Param' & $i & '"),'
$iCommand &= $iFuncParam
Next
$iCommand = StringTrimRight($iCommand,1)
$iCommand &= ")"
$iReturn = Execute($iCommand)
if @error Then Return SetError(4,0,0)
Local $nReturn[UBound($iReturn) -1] , $j = 0
For $i = 0 To UBound($iReturn) - 1
if ($i = 1) Then ContinueLoop ;Skip $Inface Element
$nReturn[$j] = $iReturn[$i]
$j += 1
Next
Return SetError(0,0,$nReturn)
EndFunc

Func GetMethodAddress($Inface,$MethodNum)
;$MethodNum ==> Virtual Method Number In (Virtual Methods Table)
Local $SizeOfUlong_Ptr = 4,$iMethAddress = 0,$OutCastStruct1 = 0
Local $OutCast1 = 0 , $OutCastStruct2 = 0
if Not IsPtr($Inface) Or ($MethodNum < 1) Then Return SetError(1,0,0)
;-------------------------------------------------------
$OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface)
$OutCast1 = DllStructGetData($OutCastStruct1,1)
;In C++ ==> unsigned long** OutCast1 = *(unsigned long***)Inface;
;--------------------------------------------------------
;-------------------------------------------------------
$OutCastStruct2 = DllStructCreate("ULONG_PTR",$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1)))
$iMethAddress = DllStructGetData($OutCastStruct2,1)
;$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1)) ==> $OutCast1 Is PTR Array Of Virtual Methods Table // Method PTR = Array[MethodNum - 1]
;In C++ ==> unsigned long* iMethAddress = *(unsigned long**)((BYTE*)OutCast1 + (SizeOfUlong_Ptr * (MethodNum - 1)));
;Or In C++ ==> unsigned long* iMethAddress = OutCast1[MethodNum - 1];
;--------------------------------------------------------
if (IsBadCodePtr($iMethAddress)) Then Return SetError(2,0,0)
Return SetError(0,0,$iMethAddress)
EndFunc

Func GetCount_Of_VirtualMethods($Inface)
Local $SizeOfUlong_Ptr = 4,$iMethAddress = 0,$OutCastStruct1 = 0
Local $OutCast1 = 0 , $OutCastStruct2 = 0 , $MethodNum = 1
if Not IsPtr($Inface) Then Return SetError(1,0,0)
;-------------------------------------------------------
$OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface)
$OutCast1 = DllStructGetData($OutCastStruct1,1)
;In C++ ==> unsigned long** OutCast1 = *(unsigned long***)Inface;
;--------------------------------------------------------
While 1
;-------------------------------------------------------
$OutCastStruct2 = DllStructCreate("ULONG_PTR",DllStructGetData($OutCastStruct1,1) + ($SizeOfUlong_Ptr * ($MethodNum - 1)))
$iMethAddress = DllStructGetData($OutCastStruct2,1)
;$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1)) ==> $OutCast1 Is PTR Array Of Virtual Methods Table // Method PTR = Array[MethodNum - 1]
;In C++ ==> unsigned long* iMethAddress = *(unsigned long**)((BYTE*)OutCast1 + (SizeOfUlong_Ptr * (MethodNum - 1)));
;Or In C++ ==> unsigned long* iMethAddress = OutCast1[MethodNum - 1];
;--------------------------------------------------------
if (IsBadCodePtr($iMethAddress)) Then
$MethodNum -= 1
ExitLoop
Else
$MethodNum += 1
EndIf
WEnd
Return SetError(0,0,$MethodNum)
EndFunc

Func IsBadCodePtr($lpfn)
Local $iReturn
$iReturn = DllCall("Kernel32.dll","BOOL","IsBadCodePtr","ptr",$lpfn)
if @error Then Return SetError(1,0,0)
Return SetError(0,0,$iReturn[0])
EndFunc

Func CLSIDFromString($psz)
$GUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]")
$Oleerror = DllCall("Ole32.dll","int","CLSIDFromString","WSTR",$psz,"struct*",$GUID)
if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0)
Return SetError(0,0,$Oleerror[2])
EndFunc

Func IIDFromString($psz)
$GUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]")
$Oleerror = DllCall("Ole32.dll","int","IIDFromString","WSTR",$psz,"struct*",$GUID)
if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0)
Return SetError(0,0,$Oleerror[2])
EndFunc


;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 wolf9228
Changed [ code ] tags to [ autoit ] tags, and indented with tidy.

صرح السماء كان هنا

 

Link to comment
Share on other sites

  • Moderators

wolf9228,

I have already asked you to add some words of explanation when you post scripts - I am now telling you. The idea here is that people have some idea what the script does and how to use it without having to run it - just saying FlashMemoryStream is not sufficient. :(

If you do it again you risk having the thread removed. :naughty:

Looks like I am in a minority of one! :D

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Now that looks really nice :), 5 stars from me.

Download the .swf file from the location provided and compile the script. The code plays the flash file in the GUI from the resource embedded into the compiled script.

post-40098-0-80807900-1359284536_thumb.j

@Melba: Don't be too harsh with him, I guess his English isn't just that good. He's always providing high quality code with fresh ideas, not suited for those who can't read the code anyhow.

@wolf9228: Keep posting, when needed I'll take over the part of adding some explanations :)...

P.S.: Better use the [ autoit ] code tags than [ code ]

Edited by KaFu
Link to comment
Share on other sites

Cool down Melba23. wolf9228 is non-english speaker, I'm sure you can understand how hard for him is to articulate correctly in English. Really, there's nothing you should be worrying about here, his code is there, anyone with interest can understand what' this about.

Last time he also posted complete code, really you shouldn't be that hard on him.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

wolf9228,

I have already asked you to add some words of explanation when you post scripts - I am now telling you. The idea here is that people have some idea what the script does and how to use it without having to run it - just saying FlashMemoryStream is not sufficient. :(

If you do it again you risk having the thread removed. :naughty:

Looks like I am in a minority of one! :D

M23

Thanks for the note :bye:

صرح السماء كان هنا

 

Link to comment
Share on other sites

Now that looks really nice :), 5 stars from me.

Download the .swf file from the location provided and compile the script. The code plays the flash file in the GUI from the resource embedded into the compiled script.

post-40098-0-80807900-1359284536_thumb.j

@Melba: Don't be too harsh with him, I guess his English isn't just that good. He's always providing high quality code with fresh ideas, not suited for those who can't read the code anyhow.

@wolf9228: Keep posting, when needed I'll take over the part of adding some explanations :)...

P.S.: Better use the [ autoit ] code tags than [ code ]

Thank you for this wonderful explanation really :bye:

صرح السماء كان هنا

 

Link to comment
Share on other sites

Cool down Melba23. wolf9228 is non-english speaker, I'm sure you can understand how hard for him is to articulate correctly in English. Really, there's nothing you should be worrying about here, his code is there, anyone with interest can understand what' this about.Last time he also posted complete code, really you shouldn't be that hard on him.

Discreet opinion totally agree with you thank you. :bye:

Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
Share on other sites

Very interesting code again wolf9228! Thanks for sharing it. I can remeber that trancexx did and I used that code to play a swf from memory.

I agree that without any description a lot of users here will skip your topic beside that it is very hard to understand when not dealing with winapi stuff daily.

التحيات،,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 8 months later...

nice

my autoit version 3.3.9.4

with old version Autoit3Wrapper.exe worked

but with new version Autoit3Wrapper.exe dont worked

new version Autoit3Wrapper.exe

http://www.autoitscript.com/autoit3/scite/download/AutoIt3Wrapper.exe

error line 2326

 

Install Adobe Flash Player Must from Internet Explorer And Not From other Web browsers Such as fireFox

http://get.adobe.com/flashplayer/

the FlashMemoryStream.au3 Script in the latest version of the Autoit3Wrapper.exe is converted

But without UPX The problem in the Autoit3Wrapper.exe program I think Sometimes does not

convert because the device memory is not enough

Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
Share on other sites

nice

my autoit version 3.3.9.4

with old version Autoit3Wrapper.exe worked

but with new version Autoit3Wrapper.exe dont worked

new version Autoit3Wrapper.exe

http://www.autoitscript.com/autoit3/scite/download/AutoIt3Wrapper.exe

error line 2326

 

 

OK

first msg is

Line 2326  (File "C:UsershggfdftrereeDownloadsFlashMemoryStreamFlashMemoryStream.exe"):

Error: Subscript used with non-Array variable.

 

 

second msg is

 

Line 2472  (File "C:UsershggfdftrereeDownloadsFlashMemoryStreamFlashMemoryStream.exe"):

 

Error.Subscript used on non-accessible variable

 

The first message stating array variable not Assigns

Make access to the error number during a call to 

$ReturnArray = GUICtrlCreateFlashFromMem($hMemory,10,10,430,300) function

Use this code

$Gui = GUICreate("My GUI",450,400,100,50)
$hMemory = ResToGlobalAlloc("SWF","FILES")
if Not($hMemory) Then $hMemory = FileToGlobalAlloc("intro.swf")
if @error Then Exit
$ReturnArray = GUICtrlCreateFlashFromMem($hMemory,10,10,430,300)
MsgBox(0,@error,@error)
Exit
$CtrlId = $ReturnArray[0]
$FlashCOMobject = $ReturnArray[1]
$Button_1 = GUICtrlCreateButton("Button",175,330,100,40)
GUISetState(@SW_SHOW)

And told us what the error number

the script on my PC works without problems using the latest version of the Autoit3Wrapper.exe program

Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
Share on other sites

  • 7 years later...

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...