oleview: Added interface viewer.
This commit is contained in:
parent
495e46197a
commit
72d454ab87
|
@ -141,3 +141,44 @@ FONT 8, "MS Shell Dlg"
|
|||
DEFPUSHBUTTON "&OK", IDOK, 70, 80, 45, 14
|
||||
PUSHBUTTON "&Cancel", IDCANCEL, 120, 80, 45, 14
|
||||
}
|
||||
|
||||
DLG_DEFAULT_IV DIALOG DISCARDABLE 0, 0, 280, 50
|
||||
STYLE DS_MODALFRAME | DS_NOIDLEMSG | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Default Interface Viewer"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
LTEXT "Interface", IDIGNORE, 5, 6, 50, 8
|
||||
LTEXT "", IDC_LABEL, 60, 6, 145, 8
|
||||
LTEXT "IID:", IDIGNORE, 5, 16, 50, 8
|
||||
LTEXT "", IDC_IDENTIFIER, 60, 16, 165, 8
|
||||
DEFPUSHBUTTON "&Close", IDCANCEL, 230, 6, 45, 14
|
||||
PUSHBUTTON "&View Type Info", IDC_VIEWTYPEINFO, 6, 31, 70, 14, WS_DISABLED
|
||||
}
|
||||
|
||||
DLG_IPERSIST_IV DIALOG DISCARDABLE 0, 0, 280, 29
|
||||
STYLE DS_MODALFRAME | DS_NOIDLEMSG | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "IPersist Interface Viewer"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
LTEXT "Class Name:", IDIGNORE, 5, 6, 50, 8
|
||||
LTEXT "", IDC_LABEL, 60, 6, 145, 8
|
||||
LTEXT "CLSID:", IDIGNORE, 5, 16, 50, 8
|
||||
LTEXT "", IDC_IDENTIFIER, 60, 16, 165, 8
|
||||
DEFPUSHBUTTON "&Close", IDCANCEL, 230, 6, 45, 14
|
||||
}
|
||||
|
||||
DLG_IPERSISTSTREAM_IV DIALOG DISCARDABLE 0, 0, 280, 68
|
||||
STYLE DS_MODALFRAME | DS_NOIDLEMSG | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "IPersistStream Interface Viewer"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
LTEXT "Class Name:", IDIGNORE, 5, 6, 50, 8
|
||||
LTEXT "", IDC_LABEL, 60, 6, 145, 8
|
||||
LTEXT "CLSID:", IDIGNORE, 5, 16, 50, 8
|
||||
LTEXT "", IDC_IDENTIFIER, 60, 16, 165, 8
|
||||
DEFPUSHBUTTON "&Close", IDCANCEL, 230, 6, 45, 14
|
||||
PUSHBUTTON "&IsDirty", IDC_ISDIRTY_BUTTON, 6, 31, 50, 14
|
||||
LTEXT "???", IDC_ISDIRTY, 60, 34, 145, 8
|
||||
PUSHBUTTON "&GetSizeMax", IDC_GETSIZEMAX_BUTTON, 6, 49, 50, 14
|
||||
LTEXT "???", IDC_GETSIZEMAX, 60, 52, 145, 8
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ EXTRADEFS = -DUNICODE
|
|||
|
||||
C_SRCS = \
|
||||
details.c \
|
||||
interface.c \
|
||||
oleview.c \
|
||||
pane.c \
|
||||
tree.c
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* OleView (interface.c)
|
||||
*
|
||||
* Copyright 2006 Piotr Caban
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WCHAR *wszLabel;
|
||||
WCHAR *wszIdentifier;
|
||||
}DIALOG_INFO;
|
||||
|
||||
BOOL IsInterface(HTREEITEM item)
|
||||
{
|
||||
TVITEM tvi;
|
||||
|
||||
memset(&tvi, 0, sizeof(TVITEM));
|
||||
tvi.hItem = item;
|
||||
|
||||
SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
|
||||
if(!tvi.lParam) return FALSE;
|
||||
|
||||
if(((ITEM_INFO*)tvi.lParam)->cFlag & INTERFACE) return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
IUnknown *GetInterface(void)
|
||||
{
|
||||
HTREEITEM hSelect;
|
||||
TVITEM tvi;
|
||||
CLSID clsid;
|
||||
IUnknown *unk;
|
||||
|
||||
hSelect = TreeView_GetSelection(globals.hTree);
|
||||
|
||||
memset(&tvi, 0, sizeof(TVITEM));
|
||||
tvi.hItem = hSelect;
|
||||
SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
|
||||
CLSIDFromString(((ITEM_INFO *)tvi.lParam)->clsid, &clsid);
|
||||
|
||||
memset(&tvi, 0, sizeof(TVITEM));
|
||||
tvi.hItem = TreeView_GetParent(globals.hTree, hSelect);
|
||||
SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
|
||||
|
||||
IUnknown_QueryInterface(((ITEM_INFO *)tvi.lParam)->pU, &clsid, (void *)&unk);
|
||||
|
||||
return unk;
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK InterfaceViewerProc(HWND hDlgWnd, UINT uMsg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
DIALOG_INFO *di;
|
||||
HWND hObject;
|
||||
IUnknown *unk;
|
||||
HRESULT hRes;
|
||||
ULARGE_INTEGER size;
|
||||
WCHAR wszSize[MAX_LOAD_STRING];
|
||||
WCHAR wszTRUE[] = { 'T','R','U','E','\0' };
|
||||
WCHAR wszFALSE[] = { 'F','A','L','S','E','\0' };
|
||||
WCHAR wszFormat[] = { '%','d',' ','b','y','t','e','s','\0' };
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
di = (DIALOG_INFO *)lParam;
|
||||
hObject = GetDlgItem(hDlgWnd, IDC_LABEL);
|
||||
SetWindowText(hObject, di->wszLabel);
|
||||
hObject = GetDlgItem(hDlgWnd, IDC_IDENTIFIER);
|
||||
SetWindowText(hObject, di->wszIdentifier);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(wParam)) {
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlgWnd, IDCANCEL);
|
||||
return TRUE;
|
||||
case IDC_ISDIRTY_BUTTON:
|
||||
unk = GetInterface();
|
||||
hRes = IPersistStream_IsDirty((IPersistStream *)unk);
|
||||
IUnknown_Release(unk);
|
||||
hObject = GetDlgItem(hDlgWnd, IDC_ISDIRTY);
|
||||
SetWindowText(hObject, hRes == S_OK ? wszFALSE : wszTRUE);
|
||||
return TRUE;
|
||||
case IDC_GETSIZEMAX_BUTTON:
|
||||
unk = GetInterface();
|
||||
IPersistStream_GetSizeMax((IPersistStream *)unk, &size);
|
||||
IUnknown_Release(unk);
|
||||
wsprintfW(wszSize, wszFormat, size);
|
||||
hObject = GetDlgItem(hDlgWnd, IDC_GETSIZEMAX);
|
||||
SetWindowText(hObject, wszSize);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void IPersistStreamInterfaceViewer(WCHAR *clsid)
|
||||
{
|
||||
DIALOG_INFO di;
|
||||
WCHAR wszClassMoniker[] = { 'C','l','a','s','s','M','o','n','i','k','e','r','\0' };
|
||||
|
||||
di.wszLabel = wszClassMoniker;
|
||||
di.wszIdentifier = clsid;
|
||||
|
||||
DialogBoxParam(0, MAKEINTRESOURCE(DLG_IPERSISTSTREAM_IV),
|
||||
globals.hMainWnd, InterfaceViewerProc, (LPARAM)&di);
|
||||
}
|
||||
|
||||
void IPersistInterfaceViewer(WCHAR *clsid)
|
||||
{
|
||||
DIALOG_INFO di;
|
||||
WCHAR wszClassMoniker[] = { 'C','l','a','s','s','M','o','n','i','k','e','r','\0' };
|
||||
|
||||
di.wszLabel = wszClassMoniker;
|
||||
di.wszIdentifier = clsid;
|
||||
|
||||
DialogBoxParam(0, MAKEINTRESOURCE(DLG_IPERSIST_IV),
|
||||
globals.hMainWnd, InterfaceViewerProc, (LPARAM)&di);
|
||||
}
|
||||
|
||||
void DefaultInterfaceViewer(WCHAR *clsid, WCHAR *wszName)
|
||||
{
|
||||
DIALOG_INFO di;
|
||||
|
||||
di.wszLabel = wszName;
|
||||
di.wszIdentifier = clsid;
|
||||
|
||||
DialogBoxParam(0, MAKEINTRESOURCE(DLG_DEFAULT_IV),
|
||||
globals.hMainWnd, InterfaceViewerProc, (LPARAM)&di);
|
||||
}
|
||||
|
||||
void InterfaceViewer(HTREEITEM item)
|
||||
{
|
||||
TVITEM tvi;
|
||||
WCHAR *clsid;
|
||||
WCHAR wszName[MAX_LOAD_STRING];
|
||||
WCHAR wszIPersistStream[] = { '{','0','0','0','0','0','1','0','9','-',
|
||||
'0','0','0','0','-','0','0','0','0','-','C','0','0','0','-',
|
||||
'0','0','0','0','0','0','0','0','0','0','4','6','}','\0' };
|
||||
WCHAR wszIPersist[] = { '{','0','0','0','0','0','1','0','C','-',
|
||||
'0','0','0','0','-','0','0','0','0','-','C','0','0','0','-',
|
||||
'0','0','0','0','0','0','0','0','0','0','4','6','}','\0' };
|
||||
|
||||
memset(&tvi, 0, sizeof(TVITEM));
|
||||
tvi.mask = TVIF_TEXT;
|
||||
tvi.hItem = item;
|
||||
tvi.cchTextMax = MAX_LOAD_STRING;
|
||||
tvi.pszText = wszName;
|
||||
|
||||
SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
|
||||
clsid = ((ITEM_INFO*)tvi.lParam)->clsid;
|
||||
|
||||
if(!memcmp(clsid, wszIPersistStream, sizeof(wszIPersistStream)))
|
||||
IPersistStreamInterfaceViewer(clsid);
|
||||
|
||||
else if(!memcmp(clsid, wszIPersist, sizeof(wszIPersist)))
|
||||
IPersistInterfaceViewer(clsid);
|
||||
|
||||
else DefaultInterfaceViewer(clsid, wszName);
|
||||
}
|
|
@ -118,3 +118,7 @@ HWND CreateTreeWindow(HINSTANCE hInst);
|
|||
BOOL CreateRegPath(HTREEITEM item, WCHAR *buffer, int bufSize);
|
||||
void CreateInst(HTREEITEM item, WCHAR *wszMachineName);
|
||||
void ReleaseInst(HTREEITEM item);
|
||||
|
||||
/* interface.h */
|
||||
BOOL IsInterface(HTREEITEM item);
|
||||
void InterfaceViewer(HTREEITEM item);
|
||||
|
|
|
@ -203,6 +203,8 @@ void RefreshMenu(HTREEITEM item)
|
|||
tvi.hItem = item;
|
||||
SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
|
||||
|
||||
parent = TreeView_GetParent(globals.hTree, item);
|
||||
|
||||
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, FALSE);
|
||||
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, FALSE);
|
||||
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, FALSE);
|
||||
|
@ -228,7 +230,8 @@ void RefreshMenu(HTREEITEM item)
|
|||
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, TRUE);
|
||||
}
|
||||
}
|
||||
else if(tvi.lParam && ((ITEM_INFO *)tvi.lParam)->cFlag&INTERFACE)
|
||||
else if(tvi.lParam &&
|
||||
(((ITEM_INFO *)tvi.lParam)->cFlag&INTERFACE || parent==tree.hTL))
|
||||
{
|
||||
EnableMenuItem(hMenu, IDM_TYPEINFO, MF_GRAYED);
|
||||
EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
|
||||
|
@ -249,8 +252,8 @@ void RefreshMenu(HTREEITEM item)
|
|||
EnableMenuItem(hMenu, IDM_HTMLTAG, MF_GRAYED);
|
||||
EnableMenuItem(hMenu, IDM_VIEW, MF_GRAYED);
|
||||
}
|
||||
parent = TreeView_GetParent(globals.hTree, item);
|
||||
if(parent==tree.hAID || parent==tree.hGBCC || parent==tree.hTL)
|
||||
|
||||
if(parent==tree.hAID || parent==tree.hGBCC)
|
||||
EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
|
||||
}
|
||||
|
||||
|
@ -377,6 +380,10 @@ int MenuCommand(WPARAM wParam, HWND hWnd)
|
|||
vis ? MF_UNCHECKED : MF_CHECKED);
|
||||
ResizeChild();
|
||||
break;
|
||||
case IDM_VIEW:
|
||||
hSelect = TreeView_GetSelection(globals.hTree);
|
||||
if(IsInterface(hSelect)) InterfaceViewer(hSelect);
|
||||
break;
|
||||
case IDM_EXIT:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
|
|
|
@ -74,3 +74,16 @@
|
|||
#define DLG_SYSCONF 1010
|
||||
#define IDC_ENABLEDCOM 1011
|
||||
#define IDC_ENABLEREMOTE 1012
|
||||
|
||||
#define DLG_IPERSIST_IV 1020
|
||||
|
||||
#define DLG_DEFAULT_IV 1030
|
||||
#define IDC_VIEWTYPEINFO 1031
|
||||
#define IDC_LABEL 1032
|
||||
#define IDC_IDENTIFIER 1033
|
||||
|
||||
#define DLG_IPERSISTSTREAM_IV 1040
|
||||
#define IDC_ISDIRTY 1041
|
||||
#define IDC_GETSIZEMAX 1042
|
||||
#define IDC_ISDIRTY_BUTTON 1043
|
||||
#define IDC_GETSIZEMAX_BUTTON 1044
|
||||
|
|
Loading…
Reference in New Issue