News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

64-Bit COM Servers

Started by Zen, June 09, 2015, 03:59:31 AM

Previous topic - Next topic

Zen

Just curious,...do any of you guys write 64-Bit COM code ???


Zen

MIKI__,
Thanks.
I read the source code (briefly), and then ran the app. OpenFile Dialog Box works, I selected 'movie', and a MessageBox popped up with this message:
Error Íå óäàëîñü îòêðûòü âèäåî ôàéë   (szAVIOpenError)

Obviously, I'm missing a couple of the include files,...I remember from an earlier post:
http://dsmhelp.narod.ru/environment.htm

Mikl__

Hi, Zen!
especially for you OPTION DOTNAME
include temphls.inc
include win64.inc
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
include comctl32.inc
includelib comctl32.lib
include comdlg32.inc
includelib comdlg32.lib
include ole32.inc
includelib ole32.lib
OPTION PROLOGUE:none
OPTION EPILOGUE:none
IMAGE_BASE equ 400000h
;-------------------------------
CLSCTX_INPROC_SERVER equ  1
WM_GRAPHNOTIFY equ 40Dh
Size_of_buffer equ 100h
;-------------------------------
;  IGraphBuilder  virtual method table
;-------------------------------
IGraphBuilderVtbl STRUCT
;IUnknown methods
QueryInterface QWORD ?
AddRef QWORD ?
Release QWORD ?
;IGraphBuilder methods
AddFilter QWORD ?
RemoveFilter QWORD ?
EnumFilters QWORD ?
FindFilterByName QWORD ?
ConnectDirect QWORD ?
Reconnect QWORD ?
Disconnect QWORD ?
SetDefaultSyncSource QWORD ?
Connect QWORD ?
Render QWORD ?
RenderFile QWORD ?
AddSourceFilter QWORD ?
SetLogFile QWORD ?
Abort QWORD ?
ShouldOperationContinue QWORD ?
IGraphBuilderVtbl ENDS
;-------------------------------
IMediaControlVtbl STRUCT
;IUnknown methods
QueryInterface QWORD ?
AddRef QWORD ?
Release QWORD ?
;IMediaControl methods
GetTypeInfoCount QWORD ?
GetTypeInfo QWORD ?
GetIDsOfNames QWORD ?
Invoke_ QWORD ?
Run QWORD ?
Pause_ QWORD ?
Stop QWORD ?
GetState QWORD ?
RenderFile QWORD ?
    AddSourceFilter QWORD ?
    get_FilterCollection QWORD ?
    get_RegFilterCollection QWORD ?
    StopWhenReady QWORD ?
IMediaControlVtbl ENDS
;-------------------------------
;  IMediaEventEx  virtual method table
;-------------------------------
IMediaEventExVtbl STRUCT
;IUnknown methods
    QueryInterface QWORD ?
    AddRef QWORD ?
    Release QWORD ?
;IMediaEventEx methods
    GetTypeInfoCount QWORD ?
    GetTypeInfo QWORD ?
    GetIDsOfNames QWORD ?
    Invoke_ QWORD ?
    GetEventHandle QWORD ?
    GetEvent QWORD ?
    WaitForCompletion QWORD ?
    CancelDefaultHandling QWORD ?
    RestoreDefaultHandling QWORD ?
    FreeEventParams QWORD ?
    SetNotifyWindow QWORD ?
    SetNotifyFlags QWORD ?
    GetNotifyFlags QWORD ?
IMediaEventExVtbl ENDS
;-----------------------------------------------------
;  IGraphBuilder  virtual method table
;-----------------------------------------------------
IGraphBuilderVtbl STRUCT
;IUnknown methods
    QueryInterface QWORD ?
    AddRef QWORD ?
    Release QWORD ?
;IGraphBuilder methods
    AddFilter         QWORD ?
    RemoveFilter QWORD ?
    EnumFilters             QWORD ?
FindFilterByName        QWORD ?
ConnectDirect           QWORD ?
Reconnect               QWORD ?
Disconnect QWORD ?
SetDefaultSyncSource    QWORD ?
Connect         QWORD ?
Render         QWORD ?
RenderFile QWORD ?
AddSourceFilter QWORD ?
SetLogFile QWORD ?
Abort         QWORD ?
ShouldOperationContinue QWORD ?
IGraphBuilderVtbl ENDS
;-----------------------------------------------------
;  IVideoWindow  virtual method table
;------------------------------------------------
IVideoWindowVtbl STRUCT
;IUnknown methods
    QueryInterface QWORD ?
    AddRef QWORD ?
    Release QWORD ?
;IVideoWindow methods
    GetTypeInfoCount       QWORD ?
    GetTypeInfo       QWORD ?
    GetIDsOfNames                QWORD ?
    Invoke_                      QWORD ?
    put_Caption                  QWORD ?
    get_Caption                  QWORD ?
    put_WindowStyle              QWORD ?
    get_WindowStyle              QWORD ?
    put_WindowStyleEx            QWORD ?
    get_WindowStyleEx            QWORD ?
    put_AutoShow                 QWORD ?
    get_AutoShow                 QWORD ?
    put_WindowState              QWORD ?
    get_WindowState              QWORD ?
    put_BackgroundPalette        QWORD ?
    get_BackgroundPalette        QWORD ?
    put_Visible                  QWORD ?
    get_Visible                  QWORD ?
    put_Left                     QWORD ?
    get_Left                     QWORD ?
    put_Width                    QWORD ?
    get_Width                    QWORD ?
    put_Top                      QWORD ?
    get_Top                      QWORD ?
    put_Height                   QWORD ?
    get_Height                   QWORD ?
    put_Owner                    QWORD ?
    get_Owner                    QWORD ?
    put_MessageDrain             QWORD ?
    get_MessageDrain             QWORD ?
    get_BorderColor              QWORD ?
    put_BorderColor QWORD ?
    get_FullScreenMode QWORD ?
    put_FullScreenMode QWORD ?
    SetWindowForeground QWORD ?
    NotifyOwnerMessage QWORD ?
    SetWindowPosition QWORD ?
    GetWindowPosition QWORD ?
    GetMinIdealImageSize QWORD ?
    GetMaxIdealImageSize QWORD ?
    GetRestorePosition QWORD ?
    HideCursor QWORD ?
    IsCursorHidden QWORD ?
IVideoWindowVtbl ENDS
.code
WinMain proc
local bufferANSI[Size_of_buffer]:BYTE
local bufferUNICODE[Size_of_buffer*2]:BYTE
local pGraph:QWORD
local pControl:QWORD
local pEvent:QWORD
local pWindow:QWORD

push rbp
mov ebp,esp
sub esp,(30h+4*8+sizeof Size_of_buffer*3+15)and(-16)
;AVIOpenFile-------------------------------------------------
;fill OPENFILENAME
push rbx ;<--- align 16 bytes

push rbx;lpTemplateName
push rbx;lpfnHook
push rbx;lCustData
push rbx;lpstrDefExt
push OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST or OFN_LONGNAMES or \
OFN_EXPLORER or OFN_HIDEREADONLY;Flags & nFileOffset & nFileExtension
push rbx;lpstrTitle
push rbx;lpstrInitialDir
push rbx;nMaxFileTitle
push rbx;lpstrFileTitle
push Size_of_buffer;nMaxFile
lea eax,bufferANSI
push rax;lpstrFile
push rbx;nMaxCustFilter & nFilterIndex
push rbx;lpstrCustomFilter
mov eax,offset Filter
push rax;lpstrFilter
push IMAGE_BASE;hInstance
push rbx;hwndOwner
push sizeof OPENFILENAME;lStructSize
;----------------------------------------------------
mov ecx,esp;адрес OPENFILENAME
mov esi,ecx;
call GetOpenFileName
test eax,eax
jz Exit ; user clicks "Cancel"
inc count
mov qword ptr [rsp+28h],Size_of_buffer*2
lea eax,bufferUNICODE
mov [rsp+20h],rax
or r9d,-1
lea r8d,bufferANSI
xor edx,edx
xor ecx,ecx
call MultiByteToWideChar
;AVIInit -----------------------------------------
xor ecx,ecx
call CoInitialize
lea eax,pGraph
mov [rsp+20h],rax
mov r9d,offset ID_IGraphBuilder
mov r8d,CLSCTX_INPROC_SERVER
xor edx,edx
mov ecx,offset CLSID_FilterGraph
call CoCreateInstance
test eax,eax
jnz Exit ;Unable to create GraphBuilder
inc count
lea r8d,pControl
        mov edx,offset ID_IMediaControl
        mov rcx,pGraph
        mov eax,[rcx]
        call [rax].IMediaControlVtbl.QueryInterface;pMC->QueryInterface(IID_IMediaEventEx, (void **)&pME);
test eax,eax
jnz Exit ;Unable to get interface IMediaControl
inc count
lea r8d,pEvent
        mov edx,offset ID_IMediaEventEx
        mov rcx,pGraph
        mov eax,[rcx]
        call [rax].IMediaEventExVtbl.QueryInterface
test eax,eax
jnz Exit ;Unable to get interface IMediaEventEx
inc count
        lea r8d,pWindow
mov edx,offset ID_IVideoWindow
mov rcx,pGraph
mov eax,[rcx]
call [rax].IVideoWindowVtbl.QueryInterface;pMC->QueryInterface(IID_IVideoWindow, (void**)&pVW);
;AVIRenderFile----------------------------------------------
xor r8d,r8d
lea rdx,bufferUNICODE
mov rcx,pGraph
mov eax,[rcx]
call [rax].IGraphBuilderVtbl.RenderFile;pGB->RenderFile(FileNameW, NULL);
        test eax,eax
jnz Exit ;We can not open file
inc count
;AVIPlay-----------------------------------
mov rcx,pControl
        mov eax,[rcx]
        call [rax].IMediaControlVtbl.Run ;pMC->Run()
;------------------------------------------
lea r8d,pWindow
mov edx,INFINITE
        mov rcx,pEvent
        mov eax,[rcx]
        call [rax].IMediaEventExVtbl.WaitForCompletion
;AVIClose------------------------------------------
mov rcx,pControl
mov eax,[rcx]
call [rax].IMediaControlVtbl.Release
mov rcx,pEvent
mov eax,[rcx]
call [rax].IMediaEventExVtbl.Release
mov rcx,pGraph
mov eax,[rcx]
call [rax].IGraphBuilderVtbl.Release
call CoUninitialize
;---------------------------------------
Exit: xor r9d,r9d
xor r8d,r8d
mov eax,count
mov rdx,[hande+rax*8]
xor ecx,ecx
call MessageBox
xor ecx,ecx
        call ExitProcess
WinMain endp
;---------------------------------------
CLSID_FilterGraph GUID  <0E436EBB3h,524Fh,11CEh,{09Fh,053h,0,020h,0AFh,0Bh,0A7h,70h}>
;db "NB10"; dd 3031424Eh
ID_IGraphBuilder  GUID  <056A868A9h,0AD4h,11CEh,{0B0h,03Ah,0,20h,0AFh,0Bh,0A7h,70h}>;56A868A9h, 11CE0AD4h, 20003AB0h, 70A70BAFh
ID_IMediaControl  GUID  <056A868B1h,0AD4h,11CEh,{0B0h,03Ah,0,20h,0AFh,0Bh,0A7h,70h}>;56A868B1h, 11CE0AD4h, 20003AB0h, 70A70BAFh
ID_IMediaEventEx  GUID  <056A868B6h,0AD4h,11CEh,{0B0h,03Ah,0,20h,0AFh,0Bh,0A7h,70h}>;56A868C0h, 11CE0AD4h, 20003AB0h, 70A70BAFh
ID_IVideoWindow   GUID  <056A868B4h,0AD4h,11CEh,{0B0h,03Ah,0,20h,0AFh,0Bh,0A7h,70h}>
Filter db "Video files *.avi; *.qt; *.mov; *.mpg; *.mpeg; *.m1v; *.vob",0
                db "*.qt; *.mov; *.mpg; *.mpeg; *.m1v; *.vob; *.wmv",0,0
szAVIOpenError db "Unable to open the video file",0
szGoodbye db "Bye-bye!",0
hande dq str1,str2,str3,str4,szAVIOpenError,szGoodbye
str1 db "Do not select any media files!",0
str2 db "Unable to create GraphBuilder",0
str3 db "Unable to get interface IMediaControl",0
str4 db 'Unable to get interface IMEdiaEvent',0
count dd 0
end

Mikl__

include-files
The program was written and tested in Windows Seven pro, how the program will work in Windows eight I don't know

Zen

MIKI__,
Thanks for the feedback. I'm also running Windows Seven Professional,...but, I'm using a public terminal at a public library, somewhere in California,...I assume that their security software is interfering with Tutorial 37f somehow,...
I'll play around with it and see what I can come up with. :bgrin: