News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

using flash player in a window

Started by TouEnMasm, February 19, 2014, 07:56:29 PM

Previous topic - Next topic

TouEnMasm

Hello,
I try to do this with masm.
I am at the start point,that is a successful connection to the IShockwaveFlash interface.
I don't know if the best way is to implement the Ioleclientsite interface or to use atl.
Some good samples will be of good help.
ToutEnmasm
Fa is a musical note to play with CL

ragdog

Hi

I use a flash player with AtlAxWin but with  IShockwaveFlash interface have i not see any example


GoneFishing

#2
You may explore the internal working of ANY OCX control with the help of   OCX Container by Japheth.
I think it's the only (and  the best) ShockwaveFlash Player asm example  for you
Enjoy it :t

[EDIT]:
A little tutorial on how to use it:
- Menu Edit -> Insert Control ...
- Scroll down in the list of available controls, find the Shockwave Flash Object , double-click it
- Menu Options -> TypeInfo ... -> double-click IShockwaveFlash
- Scroll down to LoadMovie method -> RMB click -> Execute
- Fill in the parameters (I used "http://astro.unl.edu/naap/motion3/animations/sunmotions.swf" as url) and press Execute

P.S.: wanna more amazing Astronomy Simulations and Animations ?

TouEnMasm


Thanks for answers.
The sample with the ocx container made the job.
Fa is a musical note to play with CL

TouEnMasm


ATL do the same in a very simple way

Invoke CoInitialize,NULL            ;Ex,NULL,NULL
invoke OleInitialize,NULL
;---------------------dynamic load----------------------------
invoke SearchAdresse,SADR("atl.dll"),addr hAtl ,addr ADRAtlAxDialogBoxW
invoke AtlAxWinInit
invoke GetModuleHandle, NULL
mov hInstance,eax
;---------- full path of the flash player file ----------------
invoke lstrcpy,addr ModulePath,SADR("C:\Temp\sunmotions.swf")
;***** ModulePath = full path of a file usable with any kind of control *********
;***** can be a html file,a .swf (flash player file).... ******************
invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW ,SADR("AtlAxWin"),addr ModulePath,\
WS_OVERLAPPEDWINDOW,0,0,730,550,NULL,NULL,hInstance,NULL
mov Hfenetre,eax
;get the window events
invoke SetWindowLong,Hfenetre,GWL_WNDPROC,EventWnd
mov lpWindows,eax
INVOKE  ShowWindow,Hfenetre, SW_SHOWNORMAL
INVOKE  UpdateWindow,Hfenetre
;invoke PostMessage,Hfenetre,WM_COMMAND,1001,0
;----------------------------------------------------------------------
;invoke AtlWaitWithMessageLoop,Hfenetre
invoke waiting_loop


I have tried to get an interface to resize the window (for example) but could only get the Iunknown.
Any idea how to use the Iunknown ?
Quote
   invoke AtlAxGetControl,Hfenetre,addr ppvIUnknown
   IUnknown QueryInterface,addr IID_IUnknown,addr ppvIUnknown

Fa is a musical note to play with CL

GoneFishing


IUnknown QueryInterface,addr IID_Whatever, addr ppvIWhatever


Seems like  ATL makes using OCX controls simple but it's more C++ way of coding   

TouEnMasm

This way use also ATL ,IShockwaveFlash and offer more features.

Init:
Quote
   invoke CoInitializeEx,NULL,COINIT_APARTMENTTHREADED            ;Ex,NULL,NULL
   invoke OleInitialize,NULL
   invoke AtlAxWinInit      

create a normal window,Hwnd
put this code in a WM_COMMAND

.if eax == 1001
invoke CoCreateInstance,addr CLSID_ShockwaveFlash,NULL,CLSCTX_ALL,\
addr IID_IShockwaveFlash,addr ppvIShockwaveFlash
.if ppvIShockwaveFlash == 0
jmp finatl
.endif
invoke AtlAxAttachControl,ppvIShockwaveFlash,hwnd,addr ppvIUnknown
invoke CreateSingleBstr,SADR("C:\Temp\sunmotions.swf")
mov ebx,eax
IShockwaveFlash LoadMovie,NULL,ebx
invoke SysFreeString,ebx
.endif


Quote
   .ELSEIF uMsg == WM_CLOSE ;return zero
      .if ppvIUnknown != 0
         IUnknown Release
      .endif
      .if ppvIShockwaveFlash != 0
         IShockwaveFlash Release
      .endif

Fa is a musical note to play with CL

TouEnMasm

Making an execute file with a .swf file
-- The .swf is put on RCDATA resource
Quote
500 RCDATA DISCARDABLE "sunmotions.swf"
we use the upper code and add a IPersistStreamInit interface
Quote
invoke CoCreateInstance,addr CLSID_ShockwaveFlash,NULL,CLSCTX_ALL,\
      addr IID_IShockwaveFlash,addr ppvIShockwaveFlash
invoke AtlAxAttachControl,ppvIShockwaveFlash,hwnd,addr ppvIUnknown
IShockwaveFlash QueryInterface,addr IID_IPersistStreamInit,addr ppvIPersistStreamInit
invoke CreateStream
IPersistStreamInit Load,ppvIStream
The Istream need to point on a header followed by the .swf data file.
Quote
FLASH_STREAM_HEADER   STRUCT DEFALIGNMASM
   m_dwSignature DWORD ?
   m_dwDataSize DWORD ?
FLASH_STREAM_HEADER      ENDS


CreateStream PROC uses esi edi ebx
Local fsh:FLASH_STREAM_HEADER
Local uli:QWORD,abuffer[200]:BYTE
Local  retour:DWORD,Hglobafixed,Hglobalmov,hResource,dwResourceDataSize,pres,pHglobal
         mov retour,1
invoke FindResource,hInstance,500,RT_RCDATA
mov hResource,eax
invoke SizeofResource,hInstance,hResource
mov dwResourceDataSize,eax
invoke LoadResource,hInstance,hResource
mov Hglobafixed,eax
invoke LockResource,eax
mov pres,eax
mov edx,dwResourceDataSize
add edx,sizeof fsh
;round
add edx,32
and edx,0FFFFFFF0h
invoke GlobalAlloc,GHND or GMEM_NODISCARD ,edx
mov Hglobalmov,eax
invoke CreateStreamOnHGlobal,Hglobalmov,TRUE,addr ppvIStream
;fill the FLASH_STREAM_HEADER
mov fsh.m_dwSignature,055665566h
PuPo fsh.m_dwDataSize,dwResourceDataSize
;-------- one method to create the data = fsh+.swf data file -----------------
comment µ
invoke GlobalLock,Hglobalmov
mov edi,eax
;copy the header
lea esi,fsh
mov ecx,sizeof fsh
rep movsb
;copy the data the .swf file
mov esi,pres
mov ecx,dwResourceDataSize
rep movsb
µ
;----- second method -----------------
IStream Write,addr fsh, sizeof fsh, NULL
IStream Write,Hglobafixed,dwResourceDataSize,NULL
;-------- Stream pointer at the start of data ----
mov DWORD ptr[uli+4],0
mov DWORD ptr[uli],0
IStream Seek,uli,STREAM_SEEK_SET, NULL

FindeCreateStream:
         mov eax,retour
ret






Fa is a musical note to play with CL

dedndave

someplace, i saw a tool that could be used to "de-compile" SWF files
you might search around, if you are interested

ragdog

Hello Yves

I have found a other example about play swf
http://www.asmcommunity.net//forums/topic/?id=29472

http://www.asmcommunity.net//forums/attachments/?id=2830


greets,

TouEnMasm

#10
For those who just want to put a .swf in an execute,here the source code.
Modify the name zodiac in the .rc   and recompile (vc express 2010)

500 RCDATA DISCARDABLE "zodiac.swf"

Other includes http://masm32.com/board/index.php?topic=563.msg4563#msg4563


I have added a second soluce to do it,The code is already compiled in an object file,and there is just to compile the modified resource .rc
You need zero include (resource.h is in the zip)

Fa is a musical note to play with CL