some code reformatting of slayer.dll and make it build again

svn path=/trunk/; revision=18128
This commit is contained in:
Thomas Bluemel 2005-09-27 20:22:25 +00:00
parent 116b8b7916
commit 1d982cb8e9
5 changed files with 963 additions and 745 deletions

View file

@ -227,6 +227,9 @@
<directory name="shell32"> <directory name="shell32">
<xi:include href="shell32/shell32.xml" /> <xi:include href="shell32/shell32.xml" />
</directory> </directory>
<directory name="shellext">
<xi:include href="shellext/directory.xml" />
</directory>
<directory name="shfolder"> <directory name="shfolder">
<xi:include href="shfolder/shfolder.xml" /> <xi:include href="shfolder/shfolder.xml" />
</directory> </directory>

View file

@ -0,0 +1,3 @@
<directory name="slayer">
<xi:include href="slayer/slayer.xml" />
</directory>

View file

@ -1,4 +1,3 @@
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#define INITGUID #define INITGUID
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
@ -7,7 +6,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <objbase.h> #include <objbase.h>
#include <basetyps.h>
#include <unknwn.h> #include <unknwn.h>
#include "resource.h" #include "resource.h"
#include "slayer.h" #include "slayer.h"

View file

@ -1,6 +1,6 @@
/* /*
* ReactOS Compatibility Layer Shell Extension * ReactOS Compatibility Layer Shell Extension
* Copyright (C) 2004 ReactOS Team * Copyright (C) 2004 - 2005 ReactOS Team
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -25,14 +25,14 @@
* UPDATE HISTORY: * UPDATE HISTORY:
* 09/25/2004 Created * 09/25/2004 Created
*/ */
#include "precomp.h" #include <precomp.h>
HINSTANCE hInstance = NULL; HINSTANCE hInstance = NULL;
LONG dllrefs = 0; LONG dllrefs = 0;
/* FIXME - they should be exported somewhere instead of defined here... */ /* FIXME - they should be exported somewhere instead of defined here... */
DEFINE_SHLGUID(IID_IPropSheetPage, 0x000214F6L, 0, 0); DEFINE_GUID(IID_IClassFactory, 0x00000001, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
DEFINE_SHLGUID(IID_IShellPropSheetExt, 0x000214E9L, 0, 0); DEFINE_GUID(IID_IUnknown, 0x00000000, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
static ifaceICompatibilityPageVbtl efvt = static ifaceICompatibilityPageVbtl efvt =
{ {
@ -76,7 +76,9 @@ ClearCItemList(LPCOMPATIBILITYPAGE info)
item = next) item = next)
{ {
next = item->next; next = item->next;
HeapFree(GetProcessHeap(), 0, item); HeapFree(GetProcessHeap(),
0,
item);
} }
info->CSelectedItem = NULL; info->CSelectedItem = NULL;
@ -85,7 +87,10 @@ ClearCItemList(LPCOMPATIBILITYPAGE info)
} }
static BOOL static BOOL
ReadDWORDFlag(HKEY hk, LPTSTR szValueName, LPDWORD lpOutValue, DWORD dwDefault) ReadDWORDFlag(HKEY hk,
LPTSTR szValueName,
LPDWORD lpOutValue,
DWORD dwDefault)
{ {
DWORD dwType, dwSize = sizeof(DWORD); DWORD dwType, dwSize = sizeof(DWORD);
LONG e = RegQueryValueEx(hk, LONG e = RegQueryValueEx(hk,
@ -106,7 +111,8 @@ ReadDWORDFlag(HKEY hk, LPTSTR szValueName, LPDWORD lpOutValue, DWORD dwDefault)
} }
static BOOL static BOOL
LoadAndParseAppCompatibilityFlags(LPCOMPATIBILITYPAGE info, LPTSTR szValueName) LoadAndParseAppCompatibilityFlags(LPCOMPATIBILITYPAGE info,
LPTSTR szValueName)
{ {
LONG e; LONG e;
HKEY hk; HKEY hk;
@ -119,17 +125,21 @@ LoadAndParseAppCompatibilityFlags(LPCOMPATIBILITYPAGE info, LPTSTR szValueName)
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
dwSize = sizeof(szStr); dwSize = sizeof(szStr);
e = RegQueryValueEx(hk, e = RegQueryValueEx(hk,
szValueName, szValueName,
0, 0,
&dwType, &dwType,
(LPBYTE)szStr, (LPBYTE)szStr,
&dwSize); &dwSize);
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
/* FIXME - make sure the string is NULL-terminated! */ /* FIXME - make sure the string is NULL-terminated! */
TCHAR *c; TCHAR *c;
for(c = szStr; *c != TEXT('\0'); c++) for (c = szStr;
*c != TEXT('\0');
c++)
{ {
/* only the first word represents the compatibility mode */ /* only the first word represents the compatibility mode */
/* FIXME - parse all words! */ /* FIXME - parse all words! */
@ -145,7 +155,9 @@ LoadAndParseAppCompatibilityFlags(LPCOMPATIBILITYPAGE info, LPTSTR szValueName)
{ {
PCITEM item; PCITEM item;
for(item = info->CItems; item != NULL; item = item->next) for (item = info->CItems;
item != NULL;
item = item->next)
{ {
if (!_tcsicmp(szStr, item->szKeyName)) if (!_tcsicmp(szStr, item->szKeyName))
{ {
@ -174,6 +186,7 @@ LoadCompatibilityModes(LPCOMPATIBILITYPAGE info)
e = RegOpenKey(HKEY_CURRENT_USER, e = RegOpenKey(HKEY_CURRENT_USER,
TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"), TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),
&hk); &hk);
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
DWORD i; DWORD i;
@ -186,6 +199,7 @@ LoadCompatibilityModes(LPCOMPATIBILITYPAGE info)
e = RegOpenKey(hk, e = RegOpenKey(hk,
szKey, szKey,
&hk2); &hk2);
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
DWORD dwType; DWORD dwType;
@ -196,11 +210,14 @@ LoadCompatibilityModes(LPCOMPATIBILITYPAGE info)
&dwType, &dwType,
NULL, NULL,
NULL); NULL);
if (e != ERROR_SUCCESS || (e == ERROR_SUCCESS && dwType == REG_SZ)) if (e != ERROR_SUCCESS || (e == ERROR_SUCCESS && dwType == REG_SZ))
{ {
PCITEM item; PCITEM item;
item = HeapAlloc(GetProcessHeap(), 0, sizeof(CITEM)); item = HeapAlloc(GetProcessHeap(),
0,
sizeof(CITEM));
if (item != NULL) if (item != NULL)
{ {
DWORD cdb = sizeof(item->szName); DWORD cdb = sizeof(item->szName);
@ -218,21 +235,41 @@ LoadCompatibilityModes(LPCOMPATIBILITYPAGE info)
{ {
item->szName[(sizeof(item->szName) / sizeof(item->szName[0])) - 1] = TEXT('\0'); item->szName[(sizeof(item->szName) / sizeof(item->szName[0])) - 1] = TEXT('\0');
} }
if (e != ERROR_SUCCESS || if (e != ERROR_SUCCESS ||
cdb < sizeof(item->szName[0])) cdb < sizeof(item->szName[0]))
{ {
_tcscpy(item->szName, szKey); _tcscpy(item->szName, szKey);
e = ERROR_SUCCESS; e = ERROR_SUCCESS;
} }
_tcscpy(item->szKeyName, szKey); _tcscpy(item->szKeyName, szKey);
info->nItems++; info->nItems++;
ReadDWORDFlag(hk2, TEXT("MajorVersion"), &item->MajorVersion, 0); ReadDWORDFlag(hk2,
ReadDWORDFlag(hk2, TEXT("MinorVersion"), &item->MinorVersion, 0); TEXT("MajorVersion"),
ReadDWORDFlag(hk2, TEXT("BuildNumber"), &item->BuildNumber, 0); &item->MajorVersion,
ReadDWORDFlag(hk2, TEXT("PlatformId"), &item->PlatformId, 0); 0);
ReadDWORDFlag(hk2, TEXT("SPMajorVersion"), &item->SPMajorVersion, 0); ReadDWORDFlag(hk2,
ReadDWORDFlag(hk2, TEXT("SPMinorVersion"), &item->SPMinorVersion, 0); TEXT("MinorVersion"),
&item->MinorVersion,
0);
ReadDWORDFlag(hk2,
TEXT("BuildNumber"),
&item->BuildNumber,
0);
ReadDWORDFlag(hk2,
TEXT("PlatformId"),
&item->PlatformId,
0);
ReadDWORDFlag(hk2,
TEXT("SPMajorVersion"),
&item->SPMajorVersion,
0);
ReadDWORDFlag(hk2,
TEXT("SPMinorVersion"),
&item->SPMinorVersion,
0);
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
@ -249,7 +286,9 @@ LoadCompatibilityModes(LPCOMPATIBILITYPAGE info)
} }
else else
{ {
HeapFree(GetProcessHeap(), 0, item); HeapFree(GetProcessHeap(),
0,
item);
} }
} }
} }
@ -271,20 +310,36 @@ LoadCompatibilityModes(LPCOMPATIBILITYPAGE info)
} }
static VOID static VOID
FillComboBoxWithCompatibilityModes(LPCOMPATIBILITYPAGE info, HWND hwndDlg, HWND hCombo, BOOL bSelectItem, BOOL bDisableControlsIfEmpty) FillComboBoxWithCompatibilityModes(LPCOMPATIBILITYPAGE info,
HWND hwndDlg,
HWND hCombo,
BOOL bSelectItem,
BOOL bDisableControlsIfEmpty)
{ {
PCITEM item; PCITEM item;
int i = 0; int i = 0;
BOOL sel = FALSE; BOOL sel = FALSE;
SendMessage(hCombo, CB_RESETCONTENT, 0, 0); SendMessage(hCombo,
CB_RESETCONTENT,
0,
0);
for(item = info->CItems; item != NULL; item = item->next) for (item = info->CItems;
item != NULL;
item = item->next)
{ {
int iIndex = (int)SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)item->szName); int iIndex = (int)SendMessage(hCombo,
CB_ADDSTRING,
0,
(LPARAM)item->szName);
if (item == info->CSelectedItem && bSelectItem) if (item == info->CSelectedItem && bSelectItem)
{ {
SendMessage(hCombo, CB_SETCURSEL, (WPARAM)iIndex, 0); SendMessage(hCombo,
CB_SETCURSEL,
(WPARAM)iIndex,
0);
sel = TRUE; sel = TRUE;
} }
i++; i++;
@ -293,31 +348,55 @@ FillComboBoxWithCompatibilityModes(LPCOMPATIBILITYPAGE info, HWND hwndDlg, HWND
if (!sel && bSelectItem && i > 0) if (!sel && bSelectItem && i > 0)
{ {
/* select the first item */ /* select the first item */
SendMessage(hCombo, CB_SETCURSEL, 0, 0); SendMessage(hCombo,
CB_SETCURSEL,
0,
0);
} }
if (bDisableControlsIfEmpty) if (bDisableControlsIfEmpty)
{ {
BOOL enable = (i > 0); BOOL enable = (i > 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_COMPATGROUP), enable);
EnableWindow(hCombo, (enable && sel)); EnableWindow(GetDlgItem(hwndDlg,
EnableWindow(GetDlgItem(hwndDlg, IDC_CHKRUNCOMPATIBILITY), enable); IDC_COMPATGROUP),
CheckDlgButton(hwndDlg, IDC_CHKRUNCOMPATIBILITY, ((enable && sel) ? BST_CHECKED : BST_UNCHECKED)); enable);
EnableWindow(hCombo,
(enable && sel));
EnableWindow(GetDlgItem(hwndDlg,
IDC_CHKRUNCOMPATIBILITY),
enable);
CheckDlgButton(hwndDlg,
IDC_CHKRUNCOMPATIBILITY,
((enable && sel) ? BST_CHECKED : BST_UNCHECKED));
} }
} }
static VOID static VOID
FillEditListBoxWithCompatibilityModes(LPCOMPATIBILITYPAGE info, HWND hwndDlg, HWND hListBox, BOOL bDisableControlsIfEmpty) FillEditListBoxWithCompatibilityModes(LPCOMPATIBILITYPAGE info,
HWND hwndDlg,
HWND hListBox,
BOOL bDisableControlsIfEmpty)
{ {
PCITEM item; PCITEM item;
int i = 0; int i;
SendMessage(hListBox, LB_RESETCONTENT, 0, 0); SendMessage(hListBox,
LB_RESETCONTENT,
0,
0);
for(item = info->CItems; item != NULL; item = item->next) for (item = info->CItems, i = 0;
item != NULL;
item = item->next, i++)
{ {
SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)item->szName); SendMessage(hListBox,
i++; LB_ADDSTRING,
0,
(LPARAM)item->szName);
} }
if (bDisableControlsIfEmpty) if (bDisableControlsIfEmpty)
@ -325,8 +404,11 @@ FillEditListBoxWithCompatibilityModes(LPCOMPATIBILITYPAGE info, HWND hwndDlg, HW
} }
} }
INT_PTR CALLBACK static INT_PTR CALLBACK
EditCompatibilityModesProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) EditCompatibilityModesProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{ {
LPCOMPATIBILITYPAGE this; LPCOMPATIBILITYPAGE this;
@ -337,58 +419,87 @@ EditCompatibilityModesProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
switch(LOWORD(wParam)) switch(LOWORD(wParam))
{ {
case IDOK: case IDOK:
EndDialog(hwndDlg, IDOK); EndDialog(hwndDlg,
IDOK);
break; break;
case IDCANCEL: case IDCANCEL:
EndDialog(hwndDlg, IDCANCEL); EndDialog(hwndDlg,
IDCANCEL);
break; break;
} }
break; break;
} }
case WM_CLOSE: case WM_CLOSE:
{ {
EndDialog(hwndDlg, IDCANCEL); EndDialog(hwndDlg,
IDCANCEL);
break; break;
} }
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
HWND hList = GetDlgItem(hwndDlg, IDC_COMPATIBILITYMODE); HWND hList = GetDlgItem(hwndDlg,
IDC_COMPATIBILITYMODE);
this = (LPCOMPATIBILITYPAGE)lParam; this = (LPCOMPATIBILITYPAGE)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)this); SetWindowLongPtr(hwndDlg,
FillEditListBoxWithCompatibilityModes(this, hwndDlg, hList, FALSE); GWLP_USERDATA,
(LONG_PTR)this);
FillEditListBoxWithCompatibilityModes(this,
hwndDlg,
hList,
FALSE);
break; break;
} }
} }
return FALSE; return FALSE;
} }
static VOID static VOID
InitializePage(LPCOMPATIBILITYPAGE this, HWND hwndDlg) InitializePage(LPCOMPATIBILITYPAGE this,
HWND hwndDlg)
{ {
HWND hList; HWND hList;
LoadCompatibilityModes(this); LoadCompatibilityModes(this);
/* initialize the controls */ /* initialize the controls */
hList = GetDlgItem(hwndDlg, IDC_COMPATIBILITYMODE); hList = GetDlgItem(hwndDlg,
LoadAndParseAppCompatibilityFlags(this, this->szFile); IDC_COMPATIBILITYMODE);
FillComboBoxWithCompatibilityModes(this, hwndDlg, hList, TRUE, TRUE);
LoadAndParseAppCompatibilityFlags(this,
this->szFile);
FillComboBoxWithCompatibilityModes(this,
hwndDlg,
hList,
TRUE,
TRUE);
} }
static VOID static VOID
ReportPropertyChange(LPCOMPATIBILITYPAGE this, HWND hwndDlg) ReportPropertyChange(LPCOMPATIBILITYPAGE this,
HWND hwndDlg)
{ {
this->Changed = TRUE; this->Changed = TRUE;
SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
SendMessage(GetParent(hwndDlg),
PSM_CHANGED,
(WPARAM)hwndDlg,
0);
} }
static BOOL static BOOL
ComposeFlags(LPCOMPATIBILITYPAGE this, LPTSTR szFlags) ComposeFlags(LPCOMPATIBILITYPAGE this,
LPTSTR szFlags)
{ {
if (this->CSelectedItem != NULL) if (this->CSelectedItem != NULL)
{ {
_tcscpy(szFlags, this->CSelectedItem->szKeyName); _tcscpy(szFlags,
this->CSelectedItem->szKeyName);
return TRUE; return TRUE;
} }
@ -396,24 +507,32 @@ ComposeFlags(LPCOMPATIBILITYPAGE this, LPTSTR szFlags)
} }
static BOOL static BOOL
ApplySettings(LPCOMPATIBILITYPAGE this, HWND hwndDlg) ApplySettings(LPCOMPATIBILITYPAGE this,
HWND hwndDlg)
{ {
HKEY hk; HKEY hk;
LONG e; LONG e;
TCHAR szFlags[256]; TCHAR szFlags[256];
BOOL enabled = IsDlgButtonChecked(hwndDlg, IDC_CHKRUNCOMPATIBILITY) == BST_CHECKED; BOOL enabled = IsDlgButtonChecked(hwndDlg,
IDC_CHKRUNCOMPATIBILITY) == BST_CHECKED;
if (enabled) if (enabled)
{ {
HWND hCombo = GetDlgItem(hwndDlg, IDC_COMPATIBILITYMODE); HWND hCombo = GetDlgItem(hwndDlg,
int index = (int)SendMessage(hCombo, CB_GETCURSEL, 0, 0); IDC_COMPATIBILITYMODE);
int index = (int)SendMessage(hCombo,
CB_GETCURSEL,
0,
0);
if (index >= 0) if (index >= 0)
{ {
int i; int i;
PCITEM sel = this->CItems; PCITEM sel = this->CItems;
/* map the index to a CITEM structure */ /* map the index to a CITEM structure */
for(i = index; i > 0 && sel != NULL; i--) for(i = index;
i > 0 && sel != NULL;
i--)
{ {
sel = sel->next; sel = sel->next;
} }
@ -433,11 +552,13 @@ ApplySettings(LPCOMPATIBILITYPAGE this, HWND hwndDlg)
if (!enabled) if (!enabled)
{ {
/* FIXME - only delete if nothing else is selected! */ /* FIXME - only delete if nothing else is selected! */
e = RegDeleteValue(hk, this->szFile); e = RegDeleteValue(hk,
this->szFile);
} }
else else
{ {
if(ComposeFlags(this, szFlags)) if (ComposeFlags(this,
szFlags))
{ {
e = RegSetValueEx(hk, e = RegSetValueEx(hk,
this->szFile, this->szFile,
@ -448,7 +569,8 @@ ApplySettings(LPCOMPATIBILITYPAGE this, HWND hwndDlg)
} }
else else
{ {
e = RegDeleteValue(hk, this->szFile); e = RegDeleteValue(hk,
this->szFile);
} }
} }
@ -459,10 +581,14 @@ ApplySettings(LPCOMPATIBILITYPAGE this, HWND hwndDlg)
return (e == ERROR_SUCCESS); return (e == ERROR_SUCCESS);
} }
INT_PTR CALLBACK static INT_PTR CALLBACK
CompatibilityPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) CompatibilityPageProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{ {
LPCOMPATIBILITYPAGE this = (LPCOMPATIBILITYPAGE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); LPCOMPATIBILITYPAGE this = (LPCOMPATIBILITYPAGE)GetWindowLongPtr(hwndDlg,
GWLP_USERDATA);
switch (uMsg) switch (uMsg)
{ {
@ -470,7 +596,8 @@ CompatibilityPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_COMPATIBILITYMODE) if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_COMPATIBILITYMODE)
{ {
ReportPropertyChange(this, hwndDlg); ReportPropertyChange(this,
hwndDlg);
} }
else else
{ {
@ -478,18 +605,25 @@ CompatibilityPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
case IDC_CHKRUNCOMPATIBILITY: case IDC_CHKRUNCOMPATIBILITY:
{ {
HWND hList = GetDlgItem(hwndDlg, IDC_COMPATIBILITYMODE); HWND hList = GetDlgItem(hwndDlg,
IDC_COMPATIBILITYMODE);
if (hList != NULL) if (hList != NULL)
{ {
EnableWindow(hList, IsDlgButtonChecked(hwndDlg, IDC_CHKRUNCOMPATIBILITY) == BST_CHECKED); EnableWindow(hList,
IsDlgButtonChecked(hwndDlg,
IDC_CHKRUNCOMPATIBILITY) == BST_CHECKED);
} }
/* fall through */ /* fall through */
} }
case IDC_CHKRUNIN256COLORS: case IDC_CHKRUNIN256COLORS:
case IDC_CHKRUNIN640480RES: case IDC_CHKRUNIN640480RES:
case IDC_CHKDISABLEVISUALTHEMES: case IDC_CHKDISABLEVISUALTHEMES:
ReportPropertyChange(this, hwndDlg); ReportPropertyChange(this,
hwndDlg);
break; break;
case IDC_EDITCOMPATIBILITYMODES: case IDC_EDITCOMPATIBILITYMODES:
{ {
if (DialogBoxParam(hInstance, if (DialogBoxParam(hInstance,
@ -498,7 +632,8 @@ CompatibilityPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
EditCompatibilityModesProc, EditCompatibilityModesProc,
(LPARAM)this) == IDOK) (LPARAM)this) == IDOK)
{ {
InitializePage(this, hwndDlg); InitializePage(this,
hwndDlg);
} }
break; break;
} }
@ -515,7 +650,8 @@ CompatibilityPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case PSN_APPLY: case PSN_APPLY:
if (this->Changed) if (this->Changed)
{ {
return ApplySettings(this, hwndDlg); return ApplySettings(this,
hwndDlg);
} }
break; break;
} }
@ -526,9 +662,12 @@ CompatibilityPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam; LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam;
this = (LPCOMPATIBILITYPAGE)psp->lParam; this = (LPCOMPATIBILITYPAGE)psp->lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)this); SetWindowLongPtr(hwndDlg,
GWLP_USERDATA,
(LONG_PTR)this);
InitializePage(this, hwndDlg); InitializePage(this,
hwndDlg);
break; break;
} }
} }
@ -536,8 +675,10 @@ CompatibilityPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
return FALSE; return FALSE;
} }
UINT CALLBACK static UINT CALLBACK
CompatibilityPageCallback(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp) CompatibilityPageCallback(HWND hwnd,
UINT uMsg,
LPPROPSHEETPAGE ppsp)
{ {
LPCOMPATIBILITYPAGE this = (LPCOMPATIBILITYPAGE)ppsp->lParam; LPCOMPATIBILITYPAGE this = (LPCOMPATIBILITYPAGE)ppsp->lParam;
@ -560,7 +701,9 @@ ICompatibilityPage_fnConstructor(VOID)
{ {
LPCOMPATIBILITYPAGE cp; LPCOMPATIBILITYPAGE cp;
cp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(COMPATIBILITYPAGE)); cp = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(COMPATIBILITYPAGE));
if (cp != NULL) if (cp != NULL)
{ {
cp->lpVtbl = &efvt; cp->lpVtbl = &efvt;
@ -573,30 +716,36 @@ ICompatibilityPage_fnConstructor(VOID)
} }
HRESULT STDMETHODCALLTYPE HRESULT STDMETHODCALLTYPE
ICompatibilityPage_fnQueryInterface(LPCOMPATIBILITYPAGE this, REFIID iid, PVOID *pvObject) ICompatibilityPage_fnQueryInterface(LPCOMPATIBILITYPAGE this,
REFIID iid,
PVOID *pvObject)
{ {
if(IsEqualIID(iid, &IID_IShellPropSheetExt)) if (IsEqualIID(iid,
&IID_IShellPropSheetExt))
{ {
this->lpVtbl->fn.IShellPropSheetExt = efvtIShellPropSheetExt; this->lpVtbl->fn.IShellPropSheetExt = efvtIShellPropSheetExt;
ICompatibilityPage_fnAddRef(this); ICompatibilityPage_fnAddRef(this);
*pvObject = this; *pvObject = this;
return S_OK; return S_OK;
} }
else if(IsEqualIID(iid, &IID_IShellExtInit)) else if (IsEqualIID(iid,
&IID_IShellExtInit))
{ {
this->lpVtbl->fn.IShellExtInit = efvtIShellExtInit; this->lpVtbl->fn.IShellExtInit = efvtIShellExtInit;
ICompatibilityPage_fnAddRef(this); ICompatibilityPage_fnAddRef(this);
*pvObject = this; *pvObject = this;
return S_OK; return S_OK;
} }
else if(IsEqualIID(iid, &IID_IClassFactory)) else if (IsEqualIID(iid,
&IID_IClassFactory))
{ {
this->lpVtbl->fn.IClassFactory = efvtIClassFactory; this->lpVtbl->fn.IClassFactory = efvtIClassFactory;
ICompatibilityPage_fnAddRef(this); ICompatibilityPage_fnAddRef(this);
*pvObject = this; *pvObject = this;
return S_OK; return S_OK;
} }
else if(IsEqualIID(iid, &IID_IUnknown)) else if (IsEqualIID(iid,
&IID_IUnknown))
{ {
ICompatibilityPage_fnAddRef(this); ICompatibilityPage_fnAddRef(this);
*pvObject = this; *pvObject = this;
@ -621,20 +770,22 @@ ICompatibilityPage_fnRelease(LPCOMPATIBILITYPAGE this)
rfc = (ULONG)InterlockedDecrement(&this->ref); rfc = (ULONG)InterlockedDecrement(&this->ref);
if (rfc == 0) if (rfc == 0)
{ {
HeapFree(GetProcessHeap(), 0, this); HeapFree(GetProcessHeap(),
0,
this);
InterlockedDecrement(&dllrefs); InterlockedDecrement(&dllrefs);
} }
return rfc; return rfc;
} }
HRESULT STDMETHODCALLTYPE HRESULT STDMETHODCALLTYPE
ICompatibilityPage_fnAddPages(LPCOMPATIBILITYPAGE this, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam) ICompatibilityPage_fnAddPages(LPCOMPATIBILITYPAGE this,
LPFNADDPROPSHEETPAGE lpfnAddPage,
LPARAM lParam)
{ {
PROPSHEETPAGE psp; PROPSHEETPAGE psp = {0};
HPROPSHEETPAGE hPage; HPROPSHEETPAGE hPage;
ZeroMemory(&psp, sizeof(psp));
psp.dwSize = sizeof(psp); psp.dwSize = sizeof(psp);
psp.dwFlags = PSP_DEFAULT | PSP_USECALLBACK; psp.dwFlags = PSP_DEFAULT | PSP_USECALLBACK;
psp.hInstance = hInstance; psp.hInstance = hInstance;
@ -647,7 +798,8 @@ ICompatibilityPage_fnAddPages(LPCOMPATIBILITYPAGE this, LPFNADDPROPSHEETPAGE lpf
if (hPage != NULL) if (hPage != NULL)
{ {
if(!lpfnAddPage(hPage, lParam)) if (!lpfnAddPage(hPage,
lParam))
{ {
DestroyPropertySheetPage(hPage); DestroyPropertySheetPage(hPage);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -661,7 +813,10 @@ ICompatibilityPage_fnAddPages(LPCOMPATIBILITYPAGE this, LPFNADDPROPSHEETPAGE lpf
} }
HRESULT STDMETHODCALLTYPE HRESULT STDMETHODCALLTYPE
ICompatibilityPage_fnReplacePage(LPCOMPATIBILITYPAGE this, UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplacePage, LPARAM lParam) ICompatibilityPage_fnReplacePage(LPCOMPATIBILITYPAGE this,
UINT uPageID,
LPFNADDPROPSHEETPAGE lpfnReplacePage,
LPARAM lParam)
{ {
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -686,13 +841,20 @@ ICompatibilityPage_fnInitialize(LPCOMPATIBILITYPAGE this,
fetc.lindex = -1; fetc.lindex = -1;
fetc.tymed = TYMED_HGLOBAL; fetc.tymed = TYMED_HGLOBAL;
if(SUCCEEDED(pdtobj->lpVtbl->GetData(pdtobj, &fetc, &smdm))) if (SUCCEEDED(pdtobj->lpVtbl->GetData(pdtobj,
&fetc,
&smdm)))
{ {
UINT nFiles = DragQueryFile(smdm.hGlobal, 0xFFFFFFFF, this->szFile, sizeof(this->szFile) / sizeof(this->szFile[0])); UINT nFiles = DragQueryFile(smdm.hGlobal,
0xFFFFFFFF,
this->szFile,
sizeof(this->szFile) / sizeof(this->szFile[0]));
if (nFiles == 1) if (nFiles == 1)
{ {
/* FIXME - support editing of multiple files later */ /* FIXME - support editing of multiple files later */
DragQueryFile(smdm.hGlobal, 0, this->szFile, sizeof(this->szFile) / sizeof(this->szFile[0])); DragQueryFile(smdm.hGlobal,
0, this->szFile,
sizeof(this->szFile) / sizeof(this->szFile[0]));
ReleaseStgMedium(&smdm); ReleaseStgMedium(&smdm);
return S_OK; return S_OK;
@ -711,7 +873,8 @@ ICompatibilityPage_fnCreateInstance(LPCOMPATIBILITYPAGE this,
LPCOMPATIBILITYPAGE cp; LPCOMPATIBILITYPAGE cp;
if (pUnkOuter != NULL && if (pUnkOuter != NULL &&
!IsEqualIID(riid, &IID_IUnknown)) !IsEqualIID(riid,
&IID_IUnknown))
{ {
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
} }
@ -719,7 +882,9 @@ ICompatibilityPage_fnCreateInstance(LPCOMPATIBILITYPAGE this,
cp = ICompatibilityPage_fnConstructor(); cp = ICompatibilityPage_fnConstructor();
if (cp != NULL) if (cp != NULL)
{ {
HRESULT ret = ICompatibilityPage_fnQueryInterface(cp, riid, ppvObject); HRESULT ret = ICompatibilityPage_fnQueryInterface(cp,
riid,
ppvObject);
ICompatibilityPage_fnRelease(cp); ICompatibilityPage_fnRelease(cp);
return ret; return ret;
} }
@ -748,19 +913,24 @@ ICompatibilityPage_fnLockServer(LPCOMPATIBILITYPAGE this,
******************************************************************************/ ******************************************************************************/
HRESULT STDCALL HRESULT STDCALL
DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) DllGetClassObject(REFCLSID rclsid,
REFIID iid,
LPVOID *ppv)
{ {
if (ppv == NULL) if (ppv == NULL)
{ {
return E_INVALIDARG; return E_INVALIDARG;
} }
if(IsEqualCLSID(&CLSID_ICompatibilityPage, rclsid)) if (IsEqualCLSID(&CLSID_ICompatibilityPage,
rclsid))
{ {
LPCOMPATIBILITYPAGE iface = ICompatibilityPage_fnConstructor(); LPCOMPATIBILITYPAGE iface = ICompatibilityPage_fnConstructor();
if (iface != NULL) if (iface != NULL)
{ {
HRESULT ret = ICompatibilityPage_fnQueryInterface(iface, iid, ppv); HRESULT ret = ICompatibilityPage_fnQueryInterface(iface,
iid,
ppv);
ICompatibilityPage_fnRelease(iface); ICompatibilityPage_fnRelease(iface);
return ret; return ret;
} }
@ -781,7 +951,10 @@ UnregisterPropSheetHandler(LPTSTR szType)
{ {
TCHAR szKey[255]; TCHAR szKey[255];
_stprintf(szKey, TEXT("%s\\shellex\\PropertySheetHandlers\\Compatibility Property Page"), szType); _stprintf(szKey,
TEXT("%s\\shellex\\PropertySheetHandlers\\Compatibility Property Page"),
szType);
return RegDeleteKey(HKEY_CLASSES_ROOT, return RegDeleteKey(HKEY_CLASSES_ROOT,
szKey); szKey);
} }
@ -793,13 +966,17 @@ DllUnregisterServer(VOID)
HKEY hk; HKEY hk;
WCHAR szGuid[40]; WCHAR szGuid[40];
StringFromGUID2(&CLSID_ICompatibilityPage, szGuid, sizeof(szGuid) / sizeof(szGuid[0])); StringFromGUID2(&CLSID_ICompatibilityPage,
szGuid,
sizeof(szGuid) / sizeof(szGuid[0]));
e = RegOpenKey(HKEY_LOCAL_MACHINE, e = RegOpenKey(HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
&hk); &hk);
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
e = RegDeleteValueW(hk, szGuid); e = RegDeleteValueW(hk,
szGuid);
RegCloseKey(hk); RegCloseKey(hk);
} }
@ -816,7 +993,10 @@ DllUnregisterServer(VOID)
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
TCHAR szInprocKey[255]; TCHAR szInprocKey[255];
_stprintf(szInprocKey, TEXT("%ws\\InprocServer32"), szGuid);
_stprintf(szInprocKey,
TEXT("%ws\\InprocServer32"),
szGuid);
e = RegDeleteKey(hk, e = RegDeleteKey(hk,
szInprocKey); szInprocKey);
@ -833,13 +1013,17 @@ DllUnregisterServer(VOID)
} }
static int static int
RegisterPropSheetHandler(LPTSTR szType, LPWSTR szGuid) RegisterPropSheetHandler(LPTSTR szType,
LPWSTR szGuid)
{ {
TCHAR szKey[255]; TCHAR szKey[255];
HKEY hk; HKEY hk;
int e; int e;
_stprintf(szKey, TEXT("%s\\shellex\\PropertySheetHandlers\\Compatibility Property Page"), szType); _stprintf(szKey,
TEXT("%s\\shellex\\PropertySheetHandlers\\Compatibility Property Page"),
szType);
e = RegCreateKey(HKEY_CLASSES_ROOT, e = RegCreateKey(HKEY_CLASSES_ROOT,
szKey, szKey,
&hk); &hk);
@ -867,7 +1051,9 @@ DllRegisterServer(VOID)
TCHAR szModule[MAX_PATH + 1]; TCHAR szModule[MAX_PATH + 1];
int lnszDescription; int lnszDescription;
if(!GetModuleFileName(hInstance, szModule, sizeof(szModule) / sizeof(szModule[0]))) if(!GetModuleFileName(hInstance,
szModule,
sizeof(szModule) / sizeof(szModule[0])))
{ {
return E_ACCESSDENIED; return E_ACCESSDENIED;
} }
@ -875,10 +1061,14 @@ DllRegisterServer(VOID)
/* unregister first */ /* unregister first */
DllUnregisterServer(); DllUnregisterServer();
lnszDescription = LoadStringW(hInstance, IDS_DESCRIPTION, szDescription, sizeof(szDescription) / sizeof(szDescription[0])); lnszDescription = LoadStringW(hInstance,
IDS_DESCRIPTION,
szDescription, sizeof(szDescription) / sizeof(szDescription[0]));
if (lnszDescription > 0) if (lnszDescription > 0)
{ {
StringFromGUID2(&CLSID_ICompatibilityPage, szGuid, sizeof(szGuid) / sizeof(szGuid[0])); StringFromGUID2(&CLSID_ICompatibilityPage,
szGuid,
sizeof(szGuid) / sizeof(szGuid[0]));
e = RegOpenKey(HKEY_LOCAL_MACHINE, e = RegOpenKey(HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
@ -897,7 +1087,10 @@ DllRegisterServer(VOID)
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
TCHAR szInprocKey[255]; TCHAR szInprocKey[255];
_stprintf(szInprocKey, TEXT("CLSID\\%ws\\InprocServer32"), szGuid);
_stprintf(szInprocKey,
TEXT("CLSID\\%ws\\InprocServer32"),
szGuid);
e = RegCreateKey(HKEY_CLASSES_ROOT, e = RegCreateKey(HKEY_CLASSES_ROOT,
szInprocKey, szInprocKey,
@ -912,7 +1105,8 @@ DllRegisterServer(VOID)
(_tcslen(szModule) + 1) * sizeof(TCHAR)); (_tcslen(szModule) + 1) * sizeof(TCHAR));
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
const LPTSTR szApartment = TEXT("Apartment"); const TCHAR szApartment[] = TEXT("Apartment");
e = RegSetValueEx(hk, e = RegSetValueEx(hk,
TEXT("ThreadingModel"), TEXT("ThreadingModel"),
0, 0,
@ -927,7 +1121,8 @@ DllRegisterServer(VOID)
if (e == ERROR_SUCCESS) if (e == ERROR_SUCCESS)
{ {
e = RegisterPropSheetHandler(TEXT("exefile"), szGuid); e = RegisterPropSheetHandler(TEXT("exefile"),
szGuid);
} }
} }
@ -946,6 +1141,7 @@ DllMain(HINSTANCE hinstDLL,
DisableThreadLibraryCalls(hInstance); DisableThreadLibraryCalls(hInstance);
break; break;
} }
return TRUE; return TRUE;
} }

View file

@ -0,0 +1,18 @@
<module name="slayer" type="win32dll" baseaddress="${BASEADDRESS_SLAYER}" installbase="system32" installname="slayer.dll">
<importlibrary definition="slayer.def" />
<include base="slayer">.</include>
<define name="UNICODE" />
<define name="_UNICODE" />
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x601</define>
<library>kernel32</library>
<library>user32</library>
<library>comctl32</library>
<library>advapi32</library>
<library>ole32</library>
<library>shell32</library>
<file>slayer.c</file>
<file>slayer.rc</file>
<pch>precomp.h</pch>
</module>