1
0
mirror of https://github.com/UzixLS/KernelEx.git synced 2025-07-19 07:21:20 +03:00

import KernelEx-4.0-RC1

This commit is contained in:
UzixLS
2018-11-03 16:18:57 +03:00
commit d4e0420295
295 changed files with 28034 additions and 0 deletions

111
sheet/KexLinkage.cpp Normal file
View File

@ -0,0 +1,111 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
*
* This file is part of KernelEx source code.
*
* KernelEx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* KernelEx 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <windows.h>
#include "KexLinkage.h"
KexLinkage KexLinkage::instance;
KexLinkage::KexLinkage()
{
m_ready = Prepare();
}
KexLinkage::~KexLinkage()
{
if (hKernelEx)
FreeLibrary(hKernelEx);
}
bool KexLinkage::Prepare()
{
char core_conf_file[MAX_PATH];
HKEY key;
DWORD type;
DWORD len = sizeof(core_conf_file);
hKernelEx = LoadLibrary("KERNELEX.DLL");
if (!hKernelEx)
return false;
m_kexGetModuleSettings = (kexGetModuleSettings_t) GetProcAddress(hKernelEx,
"kexGetModuleSettings");
m_kexSetModuleSettings = (kexSetModuleSettings_t) GetProcAddress(hKernelEx,
"kexSetModuleSettings");
m_kexGetKEXVersion = (kexGetKEXVersion_t) GetProcAddress(hKernelEx,
"kexGetKEXVersion");
if (!m_kexGetModuleSettings || !m_kexSetModuleSettings || !m_kexGetKEXVersion)
return false;
//read config file location from registry
long result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\KernelEx",
0, KEY_QUERY_VALUE, &key);
if (result != ERROR_SUCCESS)
return false;
result = RegQueryValueEx(key, "InstallDir", NULL, &type,
(BYTE*)core_conf_file, &len);
RegCloseKey(key);
if (result != ERROR_SUCCESS || type != REG_SZ || len == 0)
return false;
strcat(core_conf_file, "\\core.ini");
if (GetFileAttributes(core_conf_file) == 0xffffffff)
return false;
//parse config file
default_index = GetPrivateProfileInt("ApiConfigurations",
"default", 0, core_conf_file);
for (int i = 0 ; i < 65536 ; i++)
{
char num[6];
char conf_name[256];
char conf_desc[256];
sprintf(num, "%d", i);
if (!GetPrivateProfileString("ApiConfigurations", num, "",
conf_name, sizeof(conf_name), core_conf_file))
break;
if (GetPrivateProfileInt(conf_name, "noshow", 0, core_conf_file))
continue;
GetPrivateProfileString(conf_name, "desc", conf_name,
conf_desc, sizeof(conf_desc), core_conf_file);
conf c(conf_name, conf_desc);
confs.push_back(c);
}
return true;
}
bool KexLinkage::IsReady()
{
return m_ready;
}

67
sheet/KexLinkage.h Normal file
View File

@ -0,0 +1,67 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
*
* This file is part of KernelEx source code.
*
* KernelEx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* KernelEx 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __KEXLINKAGE_H
#define __KEXLINKAGE_H
#pragma warning(disable:4530) //exceptions within strings class which we don't use
#include <vector>
#pragma warning(default:4530)
#include "sstring.hpp"
#include "kexcoresdk.h"
using namespace std;
class KexLinkage
{
typedef void (*kexGetModuleSettings_t)(const char* module,
char* conf_name, BYTE* ldr_flags);
typedef void (*kexSetModuleSettings_t)(const char* module,
const char* conf_name, BYTE ldr_flags);
typedef unsigned long (*kexGetKEXVersion_t)(void);
struct conf
{
conf(const char* n, const char* d) : name(n), desc(d) {}
sstring name;
sstring desc;
};
public:
~KexLinkage();
bool IsReady();
static KexLinkage instance;
vector<conf> confs;
int default_index;
kexGetModuleSettings_t m_kexGetModuleSettings;
kexSetModuleSettings_t m_kexSetModuleSettings;
kexGetKEXVersion_t m_kexGetKEXVersion;
protected:
KexLinkage();
bool Prepare();
HMODULE hKernelEx;
bool m_ready;
};
#endif

96
sheet/factory.cpp Normal file
View File

@ -0,0 +1,96 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
*
* This file is part of KernelEx source code.
*
* KernelEx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* KernelEx 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <windows.h>
#include "factory.h"
#include "server.h"
#include "sheet.h"
#include "KexLinkage.h"
Factory::Factory()
{
m_RefCount = 0;
}
STDMETHODIMP_(ULONG) Factory::AddRef()
{
g_LockCount++;
return ++m_RefCount;
}
STDMETHODIMP_(ULONG) Factory::Release()
{
g_LockCount--;
return --m_RefCount;
}
STDMETHODIMP Factory::QueryInterface(REFIID riid,LPVOID *ppv)
{
if (riid==IID_IUnknown)
*ppv = static_cast<IUnknown*>(this);
else if (riid==IID_IClassFactory)
*ppv = static_cast<IClassFactory*>(this);
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
STDMETHODIMP Factory::LockServer(BOOL bLock)
{
if (bLock==TRUE)
g_LockCount++;
else
g_LockCount--;
return S_OK;
}
STDMETHODIMP Factory::CreateInstance(IUnknown *pUnkOuter,REFIID riid, LPVOID *ppv)
{
*ppv = NULL;
if (pUnkOuter != NULL)
return CLASS_E_NOAGGREGATION;
if (!KexLinkage::instance.IsReady())
return E_ACCESSDENIED;
KexShlExt* pShlExt = new KexShlExt;
if (pShlExt == NULL)
return E_OUTOFMEMORY;
HRESULT hr = pShlExt->QueryInterface(riid,ppv);
if (FAILED(hr))
{
delete pShlExt;
return E_NOINTERFACE;
}
return S_OK;
}

42
sheet/factory.h Normal file
View File

@ -0,0 +1,42 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
*
* This file is part of KernelEx source code.
*
* KernelEx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* KernelEx 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef _FACTORY_H
#define _FACTORY_H
class Factory : public IClassFactory
{
ULONG m_RefCount;
public:
Factory();
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid,LPVOID *ppv);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IClassFactory
STDMETHODIMP CreateInstance(IUnknown *pUnkOuter,REFIID riid, LPVOID *ppv);
STDMETHODIMP LockServer(BOOL bLock);
};
#endif // _FACTORY_H

24
sheet/resource.h Normal file
View File

@ -0,0 +1,24 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by sheet.rc
//
#define IDD_PROPPAGE 102
#define IDC_CHECK 1000
#define IDC_COMPAT 1000
#define IDC_SYSTEM 1001
#define IDC_DISABLE 1003
#define IDC_HORIZ1 1004
#define IDC_KEXVER 1005
#define IDC_GCOMPAT 1006
#define IDC_TCOMPAT 1007
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1008
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

192
sheet/server.cpp Normal file
View File

@ -0,0 +1,192 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
*
* This file is part of KernelEx source code.
*
* KernelEx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* KernelEx 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <windows.h>
#include <olectl.h>
#include "server.h"
#include "factory.h"
#include "sheet.h"
UINT g_LockCount;
HMODULE g_hModule;
// {2338519D-676A-4ff8-99B9-924252B43710}
static const GUID CLSID_KexShlExt =
{ 0x2338519d, 0x676a, 0x4ff8, { 0x99, 0xb9, 0x92, 0x42, 0x52, 0xb4, 0x37, 0x10 } };
static const char sCLSID_KexShlExt[] = { "{2338519D-676A-4ff8-99B9-924252B43710}" };
STDAPI DllCanUnloadNow()
{
return (g_LockCount > 0) ? S_FALSE : S_OK;
}
STDAPI DllRegisterServer()
{
bool result = true;
HKEY hkey, hkey2, keyCLSID;
if (RegOpenKey(HKEY_CLASSES_ROOT, "CLSID", &keyCLSID)
!= ERROR_SUCCESS)
result = false;
if (result)
{
if (RegCreateKey(keyCLSID, sCLSID_KexShlExt, &hkey) != ERROR_SUCCESS)
result = false;
if (result)
{
RegSetValueEx(hkey, NULL, 0, REG_SZ, (LPBYTE)"KernelEx Shell Extension",
sizeof("KernelEx Shell Extension"));
if (RegCreateKey(hkey, "InProcServer32", &hkey2) != ERROR_SUCCESS)
result = false;
if (result)
{
char filename[MAX_PATH];
GetModuleFileName(g_hModule, filename, sizeof(filename));
RegSetValueEx(hkey2, NULL, 0, REG_SZ, (LPBYTE)filename, strlen(filename) + 1);
RegSetValueEx(hkey2, "ThreadingModel", 0, REG_SZ, (LPBYTE)"Apartment",
sizeof("Apartment"));
RegCloseKey(hkey2);
}
RegCloseKey(hkey);
}
RegCloseKey(keyCLSID);
}
if (RegCreateKey(HKEY_CLASSES_ROOT, "exefile\\shellex\\PropertySheetHandlers",
&hkey) != ERROR_SUCCESS)
result = false;
if (result)
{
if (RegCreateKey(hkey, sCLSID_KexShlExt, &hkey2) != ERROR_SUCCESS)
result = false;
if (result)
{
RegSetValueEx(hkey2, NULL, 0, REG_SZ, (LPBYTE)"", sizeof(""));
RegCloseKey(hkey2);
}
RegCloseKey(hkey);
}
if (RegCreateKey(HKEY_CLASSES_ROOT, "lnkfile\\shellex\\PropertySheetHandlers",
&hkey) != ERROR_SUCCESS)
result = false;
if (result)
{
if (RegCreateKey(hkey, sCLSID_KexShlExt, &hkey2) != ERROR_SUCCESS)
result = false;
if (result)
{
RegSetValueEx(hkey2, NULL, 0, REG_SZ, (LPBYTE)"", sizeof(""));
RegCloseKey(hkey2);
}
RegCloseKey(hkey);
}
return result ? S_OK : SELFREG_E_CLASS;
}
STDAPI DllUnregisterServer()
{
bool result = true;
HKEY hkey, keyCLSID;
if (RegOpenKey(HKEY_CLASSES_ROOT, "CLSID", &keyCLSID)
!= ERROR_SUCCESS)
result = false;
if (result)
{
if (RegOpenKey(keyCLSID, sCLSID_KexShlExt, &hkey) != ERROR_SUCCESS)
result = false;
if (result)
{
RegDeleteKey(hkey, "InProcServer32");
RegCloseKey(hkey);
}
RegDeleteKey(keyCLSID, sCLSID_KexShlExt);
RegCloseKey(keyCLSID);
}
if (RegOpenKey(HKEY_CLASSES_ROOT, "exefile\\shellex\\PropertySheetHandlers",
&hkey) != ERROR_SUCCESS)
result = false;
if (result)
{
RegDeleteKey(hkey, sCLSID_KexShlExt);
RegCloseKey(hkey);
}
if (RegOpenKey(HKEY_CLASSES_ROOT, "lnkfile\\shellex\\PropertySheetHandlers",
&hkey) != ERROR_SUCCESS)
result = false;
if (result)
{
RegDeleteKey(hkey, sCLSID_KexShlExt);
RegCloseKey(hkey);
}
return S_OK;
}
STDAPI DllGetClassObject(REFCLSID rclsid,REFIID riid,LPVOID * ppv)
{
static Factory factory;
*ppv = NULL;
if (rclsid != CLSID_KexShlExt)
return CLASS_E_CLASSNOTAVAILABLE;
return factory.QueryInterface(riid,ppv);
}
BOOL APIENTRY DllMain(HINSTANCE hModule,DWORD dwReason,LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
g_hModule = hModule;
DisableThreadLibraryCalls(hModule);
}
return TRUE;
}

6
sheet/server.def Normal file
View File

@ -0,0 +1,6 @@
EXPORTS
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE

28
sheet/server.h Normal file
View File

@ -0,0 +1,28 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
*
* This file is part of KernelEx source code.
*
* KernelEx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* KernelEx 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef _SERVER_H
#define _SERVER_H
extern UINT g_LockCount;
extern HMODULE g_hModule;
#endif // _SERVER_H

388
sheet/sheet.cpp Normal file
View File

@ -0,0 +1,388 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
*
* This file is part of KernelEx source code.
*
* KernelEx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* KernelEx 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <windows.h>
#include <stdio.h>
#include <shlwapi.h>
#include "sheet.h"
#include "server.h"
#include "resource.h"
#include "KexLinkage.h"
KexShlExt::KexShlExt()
{
g_LockCount++;
m_RefCount = 0;
}
KexShlExt::~KexShlExt()
{
g_LockCount--;
}
STDMETHODIMP KexShlExt::QueryInterface(REFIID riid,LPVOID *ppv)
{
if (riid == IID_IUnknown)
*ppv = static_cast<IUnknown*>(static_cast<IShellExtInit*>(this));
else if (riid == IID_IShellExtInit)
*ppv = static_cast<IShellExtInit*>(this);
else if (riid == IID_IShellPropSheetExt)
*ppv = static_cast<IShellPropSheetExt*>(this);
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
STDMETHODIMP_(ULONG) KexShlExt::AddRef()
{
return ++m_RefCount;
}
STDMETHODIMP_(ULONG) KexShlExt::Release()
{
if (!--m_RefCount)
{
delete this;
return 0;
}
return m_RefCount;
}
bool KexShlExt::IsPEModule(const char* path)
{
IMAGE_DOS_HEADER MZh;
IMAGE_NT_HEADERS PEh;
FILE* f;
bool result = false;
f = fopen(path, "rb");
if (!f)
return false;
if (fread(&MZh, sizeof(MZh), 1, f) != 1)
goto __end;
if (MZh.e_magic != IMAGE_DOS_SIGNATURE)
goto __end;
if (fseek(f, MZh.e_lfanew, SEEK_SET))
goto __end;
if (fread(&PEh, sizeof(PEh), 1, f) != 1)
goto __end;
if ((PEh.Signature != IMAGE_NT_SIGNATURE)
|| (PEh.FileHeader.Machine != IMAGE_FILE_MACHINE_I386)
|| (PEh.OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC))
goto __end;
result = true;
__end:
fclose(f);
return result;
}
bool KexShlExt::ResolveShortcut(const char* shortcutPath, char* filePath)
{
HRESULT result;
IShellLink* shellLink;
IPersistFile* persistFile;
char path[MAX_PATH];
WCHAR tmp[MAX_PATH];
result = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void**) &shellLink);
if (FAILED(result))
return false;
result = shellLink->QueryInterface(IID_IPersistFile, (void**) &persistFile);
if (SUCCEEDED(result))
{
MultiByteToWideChar(CP_ACP, 0, shortcutPath, -1, tmp, MAX_PATH);
result = persistFile->Load(tmp, STGM_READ);
if (SUCCEEDED(result))
{
result = shellLink->Resolve(NULL, SLR_UPDATE);
if (SUCCEEDED(result))
{
result = shellLink->GetPath(path,
MAX_PATH, NULL, SLGP_RAWPATH);
if (SUCCEEDED(result))
lstrcpyn(filePath, path, MAX_PATH);
}
}
persistFile->Release();
}
shellLink->Release();
return SUCCEEDED(result);
}
STDMETHODIMP KexShlExt::Initialize(LPCITEMIDLIST pidlFolder,
LPDATAOBJECT pDataObj, HKEY hProgID)
{
FORMATETC etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
STGMEDIUM stg;
HDROP hdrop;
HRESULT result = S_OK;
if (KexLinkage::instance.confs.empty())
return E_FAIL;
InitCommonControls();
if (FAILED(pDataObj->GetData(&etc, &stg)))
return E_INVALIDARG;
// Get an HDROP handle.
hdrop = (HDROP) GlobalLock (stg.hGlobal);
if (!hdrop)
{
ReleaseStgMedium(&stg);
return E_INVALIDARG;
}
ms = new ModuleSetting;
if (!ms)
return E_OUTOFMEMORY;
// Determine how many files are involved in this operation.
UINT numFiles = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
if (numFiles != 1)
result = E_FAIL;
else
{
// Get the filename.
if (!DragQueryFile(hdrop, 0, ms->file, MAX_PATH) || PathIsDirectory(ms->file))
result = E_FAIL;
else
{
char* ext = PathFindExtension(ms->file);
if (!lstrcmpi(ext, ".lnk"))
{
if (!ResolveShortcut(ms->file, ms->file))
result = E_FAIL;
}
if (!IsPEModule(ms->file))
result = E_FAIL;
}
}
// Release resources.
GlobalUnlock(stg.hGlobal);
ReleaseStgMedium(&stg);
strupr(ms->file);
return result;
}
STDMETHODIMP KexShlExt::AddPages(LPFNADDPROPSHEETPAGE lpfnAddPageProc, LPARAM lParam)
{
PROPSHEETPAGE psp;
HPROPSHEETPAGE hPage;
memset(&psp, 0, sizeof(psp));
psp.dwSize = sizeof(psp);
psp.dwFlags = PSP_USEREFPARENT | PSP_USECALLBACK;
psp.hInstance = g_hModule;
psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE);
psp.pfnDlgProc = DlgProc;
psp.pfnCallback = CallbackProc;
psp.lParam = (LPARAM) ms;
psp.pcRefParent = &g_LockCount;
hPage = CreatePropertySheetPage(&psp);
if (hPage)
{
if (!lpfnAddPageProc(hPage, lParam))
DestroyPropertySheetPage(hPage);
}
return S_OK;
}
STDMETHODIMP KexShlExt::ReplacePage(UINT, LPFNADDPROPSHEETPAGE, LPARAM)
{
return E_NOTIMPL;
}
BOOL CALLBACK KexShlExt::DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
PROPSHEETPAGE* ppsp = (PROPSHEETPAGE*) lParam;
OnInitDialog(hwnd, (ModuleSetting*) ppsp->lParam);
}
break;
case WM_SIZE:
{
WORD h = HIWORD(lParam);
WORD w = LOWORD(lParam);
RECT r;
POINT p;
GetWindowRect(GetDlgItem(hwnd, IDC_GCOMPAT), &r);
p.x = r.left;
p.y = r.top;
ScreenToClient(hwnd, &p);
//reposition horizontal spacer and version text
MoveWindow(GetDlgItem(hwnd, IDC_GCOMPAT), p.x, p.y, w - 2 * p.x, r.bottom - r.top, TRUE);
MoveWindow(GetDlgItem(hwnd, IDC_HORIZ1), p.x, h - 14 - p.x, w - 2 * p.x, 1, TRUE);
MoveWindow(GetDlgItem(hwnd, IDC_KEXVER), p.x, h - 12 - p.x, w - 2 * p.x, 12, TRUE);
GetWindowRect(GetDlgItem(hwnd, IDC_TCOMPAT), &r);
MoveWindow(GetDlgItem(hwnd, IDC_TCOMPAT), p.x, p.x, w - 2 * p.x, r.bottom - r.top, TRUE);
}
break;
case WM_NOTIFY:
{
NMHDR* phdr = (NMHDR*) lParam;
if (phdr->code == PSN_APPLY)
OnApply(hwnd);
}
break;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDC_DISABLE:
if (IsDlgButtonChecked(hwnd, IDC_DISABLE))
{
EnableWindow(GetDlgItem(hwnd, IDC_COMPAT), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_SYSTEM), FALSE);
}
else
{
EnableWindow(GetDlgItem(hwnd, IDC_COMPAT), TRUE);
EnableWindow(GetDlgItem(hwnd, IDC_SYSTEM),
IsDlgButtonChecked(hwnd, IDC_COMPAT));
}
PropSheet_Changed(GetParent(hwnd), hwnd);
break;
case IDC_COMPAT:
EnableWindow(GetDlgItem(hwnd, IDC_SYSTEM),
IsDlgButtonChecked(hwnd, IDC_COMPAT));
PropSheet_Changed(GetParent(hwnd), hwnd);
break;
case IDC_SYSTEM:
PropSheet_Changed(GetParent(hwnd), hwnd);
break;
}
}
break;
}
return FALSE;
}
void KexShlExt::OnInitDialog(HWND hwnd, ModuleSetting* ms)
{
SetWindowLong(hwnd, GWL_USERDATA, (LONG) ms);
vector<KexLinkage::conf>::const_iterator it;
for (it = KexLinkage::instance.confs.begin() ;
it != KexLinkage::instance.confs.end() ; it++)
SendMessage(GetDlgItem(hwnd, IDC_SYSTEM), CB_ADDSTRING,
0, (LPARAM) it->desc.get());
if (KexLinkage::instance.default_index >= 0
&& KexLinkage::instance.default_index < KexLinkage::instance.confs.size())
SendMessage(GetDlgItem(hwnd, IDC_SYSTEM), CB_SETCURSEL,
KexLinkage::instance.default_index, 0);
else
SendMessage(GetDlgItem(hwnd, IDC_SYSTEM), CB_SETCURSEL, 0, 0);
KexLinkage::instance.m_kexGetModuleSettings(ms->file, ms->conf, &ms->flags);
for (int i = 0 ; i < KexLinkage::instance.confs.size() ; i++)
if (!strcmp(ms->conf, KexLinkage::instance.confs[i].name.get()))
{
CheckDlgButton(hwnd, IDC_COMPAT, BST_CHECKED);
EnableWindow(GetDlgItem(hwnd, IDC_SYSTEM), TRUE);
SendMessage(GetDlgItem(hwnd, IDC_SYSTEM), CB_SETCURSEL, i, 0);
break;
}
if (ms->flags & 1)
{
CheckDlgButton(hwnd, IDC_DISABLE, BST_CHECKED);
EnableWindow(GetDlgItem(hwnd, IDC_COMPAT), FALSE);
EnableWindow(GetDlgItem(hwnd, IDC_SYSTEM), FALSE);
}
//set KernelEx version
unsigned long ver = KexLinkage::instance.m_kexGetKEXVersion();
char ver_s[32];
sprintf(ver_s, "KernelEx Core v%d.%d.%d", ver>>24, (ver>>16) & 0xff, ver & 0xffff);
SendMessage(GetDlgItem(hwnd, IDC_KEXVER), WM_SETTEXT, 0, (LPARAM) ver_s);
}
void KexShlExt::OnApply(HWND hwnd)
{
ModuleSetting* ms = (ModuleSetting*) GetWindowLong(hwnd, GWL_USERDATA);
BYTE flags = 0;
const char* conf = "default";
if (IsDlgButtonChecked(hwnd, IDC_DISABLE))
flags |= 1;
if (IsDlgButtonChecked(hwnd, IDC_COMPAT))
conf = KexLinkage::instance.confs[SendMessage(
GetDlgItem(hwnd, IDC_SYSTEM), CB_GETCURSEL, 0, 0)].name.get();
if (flags != ms->flags || strcmp(conf, ms->conf) != 0)
KexLinkage::instance.m_kexSetModuleSettings(ms->file, conf, flags);
}
UINT CALLBACK KexShlExt::CallbackProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
{
if (uMsg == PSPCB_RELEASE)
delete (ModuleSetting*) ppsp->lParam;
return 1; // used for PSPCB_CREATE - let the page be created
}

149
sheet/sheet.dsp Normal file
View File

@ -0,0 +1,149 @@
# Microsoft Developer Studio Project File - Name="sheet" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=sheet - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "sheet.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "sheet.mak" CFG="sheet - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "sheet - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "sheet - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "sheet - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHEET_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /O2 /I "../common" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHEET_EXPORTS" /YX /FD /GF /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x415 /d "NDEBUG"
# ADD RSC /l 0x415 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib advapi32.lib shell32.lib shlwapi.lib ole32.lib /nologo /dll /machine:I386 /OPT:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "sheet - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHEET_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MD /W3 /Gm /ZI /Od /I "../common" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHEET_EXPORTS" /YX /FD /GZ /GF /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x415 /d "_DEBUG"
# ADD RSC /l 0x415 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comctl32.lib advapi32.lib shell32.lib shlwapi.lib ole32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /OPT:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "sheet - Win32 Release"
# Name "sheet - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\factory.cpp
# End Source File
# Begin Source File
SOURCE=.\KexLinkage.cpp
# End Source File
# Begin Source File
SOURCE=.\server.cpp
# End Source File
# Begin Source File
SOURCE=.\server.def
# End Source File
# Begin Source File
SOURCE=.\sheet.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\factory.h
# End Source File
# Begin Source File
SOURCE=.\KexLinkage.h
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\server.h
# End Source File
# Begin Source File
SOURCE=.\sheet.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\sheet.rc
# End Source File
# End Group
# End Target
# End Project

65
sheet/sheet.h Normal file
View File

@ -0,0 +1,65 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
*
* This file is part of KernelEx source code.
*
* KernelEx is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; version 2 of the License.
*
* KernelEx 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef _SHEET_H
#define _SHEET_H
#include <shlobj.h>
struct ModuleSetting
{
char file[MAX_PATH];
char conf[256];
BYTE flags;
};
class KexShlExt : public IShellExtInit,
public IShellPropSheetExt
{
protected:
ULONG m_RefCount;
ModuleSetting* ms;
bool IsPEModule(const char* path);
bool ResolveShortcut(const char* shortcutPath, char* filePath);
static BOOL CALLBACK DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static UINT CALLBACK CallbackProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp);
static void OnInitDialog(HWND hwnd, ModuleSetting* ms);
static void OnApply(HWND hwnd);
public:
KexShlExt();
~KexShlExt();
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid,LPVOID *ppv);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IShellExtInit
STDMETHODIMP Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY);
// IShellPropSheetExt
STDMETHODIMP AddPages(LPFNADDPROPSHEETPAGE, LPARAM);
STDMETHODIMP ReplacePage(UINT, LPFNADDPROPSHEETPAGE, LPARAM);
};
#endif // _SHEET_H

165
sheet/sheet.rc Normal file
View File

@ -0,0 +1,165 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Polish resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK)
#ifdef _WIN32
LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
#pragma code_page(1250)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,2
PRODUCTVERSION 1,0,0,2
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "Xeno86\0"
VALUE "FileDescription", "sheet\0"
VALUE "FileVersion", "1, 0, 0, 2\0"
VALUE "InternalName", "sheet\0"
VALUE "LegalCopyright", "Copyright <20> 2009, Xeno86\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "sheet.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "KernelEx\0"
VALUE "ProductVersion", "1, 0, 0, 2\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
#endif // !_MAC
#endif // Polish resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PROPPAGE DIALOG DISCARDABLE 0, 0, 190, 127
STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Compatibility"
FONT 8, "MS Sans Serif"
BEGIN
GROUPBOX "Compatibility mode",IDC_GCOMPAT,7,30,176,64
CONTROL "Run this program in compatibility mode for:",IDC_COMPAT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,57,164,10
COMBOBOX IDC_SYSTEM,15,70,157,60,CBS_DROPDOWNLIST | WS_DISABLED |
WS_VSCROLL | WS_TABSTOP
CONTROL "Disable KernelEx extensions for this program",
IDC_DISABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,43,
165,10
GROUPBOX "",IDC_HORIZ1,7,108,172,9
LTEXT "kexver here",IDC_KEXVER,7,111,71,9,WS_DISABLED
LTEXT "If you have problems with this program, try selecting\na different compatibility mode.",
IDC_TCOMPAT,7,7,175,22
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_PROPPAGE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 183
TOPMARGIN, 7
BOTTOMMARGIN, 120
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED