2006-06-24 10:33:29 +02:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static IUnknown *GetInterface(void)
|
2006-06-24 10:33:29 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-01-07 12:23:42 +01:00
|
|
|
static INT_PTR CALLBACK InterfaceViewerProc(HWND hDlgWnd, UINT uMsg,
|
2006-06-24 10:33:29 +02:00
|
|
|
WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
DIALOG_INFO *di;
|
|
|
|
HWND hObject;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hRes;
|
|
|
|
ULARGE_INTEGER size;
|
|
|
|
WCHAR wszSize[MAX_LOAD_STRING];
|
2006-06-24 13:19:12 +02:00
|
|
|
WCHAR wszBuf[MAX_LOAD_STRING];
|
|
|
|
WCHAR wszFormat[] = { '%','d',' ','%','s','\0' };
|
2006-06-24 10:33:29 +02:00
|
|
|
|
|
|
|
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);
|
2006-06-24 13:19:12 +02:00
|
|
|
if(hRes == S_OK)
|
|
|
|
LoadString(globals.hMainInst, IDS_FALSE, wszBuf,
|
2008-10-27 22:12:03 +01:00
|
|
|
sizeof(wszBuf)/sizeof(wszBuf[0]));
|
2006-06-24 13:19:12 +02:00
|
|
|
else LoadString(globals.hMainInst, IDS_TRUE, wszBuf,
|
2008-10-27 22:12:03 +01:00
|
|
|
sizeof(wszBuf)/sizeof(wszBuf[0]));
|
2006-06-24 10:33:29 +02:00
|
|
|
hObject = GetDlgItem(hDlgWnd, IDC_ISDIRTY);
|
2006-06-24 13:19:12 +02:00
|
|
|
SetWindowText(hObject, wszBuf);
|
2006-06-24 10:33:29 +02:00
|
|
|
return TRUE;
|
|
|
|
case IDC_GETSIZEMAX_BUTTON:
|
|
|
|
unk = GetInterface();
|
|
|
|
IPersistStream_GetSizeMax((IPersistStream *)unk, &size);
|
|
|
|
IUnknown_Release(unk);
|
2006-06-24 13:19:12 +02:00
|
|
|
LoadString(globals.hMainInst, IDS_BYTES, wszBuf,
|
2008-10-27 22:12:03 +01:00
|
|
|
sizeof(wszBuf)/sizeof(wszBuf[0]));
|
2006-06-24 13:19:12 +02:00
|
|
|
wsprintfW(wszSize, wszFormat, U(size).LowPart, wszBuf);
|
2006-06-24 10:33:29 +02:00
|
|
|
hObject = GetDlgItem(hDlgWnd, IDC_GETSIZEMAX);
|
|
|
|
SetWindowText(hObject, wszSize);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void IPersistStreamInterfaceViewer(WCHAR *clsid, WCHAR *wszName)
|
2006-06-24 10:33:29 +02:00
|
|
|
{
|
|
|
|
DIALOG_INFO di;
|
|
|
|
WCHAR wszClassMoniker[] = { 'C','l','a','s','s','M','o','n','i','k','e','r','\0' };
|
|
|
|
|
2006-06-24 11:56:55 +02:00
|
|
|
if(wszName[0] == '{')
|
|
|
|
di.wszLabel = wszClassMoniker;
|
|
|
|
else di.wszLabel = wszName;
|
2006-06-24 10:33:29 +02:00
|
|
|
di.wszIdentifier = clsid;
|
|
|
|
|
|
|
|
DialogBoxParam(0, MAKEINTRESOURCE(DLG_IPERSISTSTREAM_IV),
|
|
|
|
globals.hMainWnd, InterfaceViewerProc, (LPARAM)&di);
|
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void IPersistInterfaceViewer(WCHAR *clsid, WCHAR *wszName)
|
2006-06-24 10:33:29 +02:00
|
|
|
{
|
|
|
|
DIALOG_INFO di;
|
|
|
|
WCHAR wszClassMoniker[] = { 'C','l','a','s','s','M','o','n','i','k','e','r','\0' };
|
|
|
|
|
2006-06-24 11:56:55 +02:00
|
|
|
if(wszName[0] == '{')
|
|
|
|
di.wszLabel = wszClassMoniker;
|
|
|
|
else di.wszLabel = wszName;
|
2006-06-24 10:33:29 +02:00
|
|
|
di.wszIdentifier = clsid;
|
|
|
|
|
|
|
|
DialogBoxParam(0, MAKEINTRESOURCE(DLG_IPERSIST_IV),
|
|
|
|
globals.hMainWnd, InterfaceViewerProc, (LPARAM)&di);
|
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void DefaultInterfaceViewer(WCHAR *clsid, WCHAR *wszName)
|
2006-06-24 10:33:29 +02:00
|
|
|
{
|
|
|
|
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];
|
2006-06-24 11:56:55 +02:00
|
|
|
WCHAR wszParent[MAX_LOAD_STRING];
|
2006-06-24 10:33:29 +02:00
|
|
|
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;
|
|
|
|
|
2006-06-24 11:56:55 +02:00
|
|
|
memset(&tvi, 0, sizeof(TVITEM));
|
|
|
|
tvi.mask = TVIF_TEXT;
|
|
|
|
tvi.hItem = TreeView_GetParent(globals.hTree, item);
|
|
|
|
tvi.cchTextMax = MAX_LOAD_STRING;
|
|
|
|
tvi.pszText = wszParent;
|
|
|
|
|
|
|
|
SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
|
|
|
|
|
2006-06-24 10:33:29 +02:00
|
|
|
if(!memcmp(clsid, wszIPersistStream, sizeof(wszIPersistStream)))
|
2006-06-24 11:56:55 +02:00
|
|
|
IPersistStreamInterfaceViewer(clsid, wszParent);
|
2006-06-24 10:33:29 +02:00
|
|
|
|
|
|
|
else if(!memcmp(clsid, wszIPersist, sizeof(wszIPersist)))
|
2006-06-24 11:56:55 +02:00
|
|
|
IPersistInterfaceViewer(clsid, wszParent);
|
2006-06-24 10:33:29 +02:00
|
|
|
|
|
|
|
else DefaultInterfaceViewer(clsid, wszName);
|
|
|
|
}
|