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

import KernelEx-4.5-Final

This commit is contained in:
UzixLS
2018-11-03 16:23:17 +03:00
parent 309977e788
commit 7571e3c60d
125 changed files with 11876 additions and 9943 deletions

View File

@ -1,3 +1,37 @@
KernelEx v4.5 Final by Xeno86
2010-12-30
setup: Start Menu shortcuts, included Release Notes.txt
verifier: new welcome screen
core/setup: make KernelEx compatible with kernel32.dll updates:
- uninstalling KernelEx won't revert kernel32 updates anymore;
- KernelEx doesn't need to be reinstalled anymore if kernel32 is updated
- kernel32 backup is now stored in sysbckup directory
core: don't load api libraries if resolver failed to initialize
SystemParametersInfo: fix SPI_GETCARETWIDTH erroneous zero caret width return
kernel32.TlsFree(ext) fixes:
- fixed a possible deadlock situation which could lead to system hang
- return error if TLS index has already been freed
- return 1 for success consistently for better compatibility
comdlg32 GetOpen[Save]FileName: avoid HeapFree(null), changes last-error
MSI shim database integration
MSI shim database: transforms for office 2003; office 2007 converters; google earth 5.1,5.2,6.0b; acrobat reader 7
settings: force Windows Installer into default configuration
gdi32/textout: don't hold Win16Lock while calling GDI apis
added Shim database create utility SDBcreate for MSI installer files patching
settings: set GTAPI.DLL in Win2000 mode (Google Earth setup)
implemented cryptui.CryptUIDlgViewContext (Google Earth 5.2)
implemented kernel32.FindFirstFileExA/W (Opera)
user32: per-thread keyboard state is now updated for left/right modifier keys (Qt 4.6+ hotkeys)
user32: MapVirtualKey now maps left/right modifier key codes to AT keyboard scan codes.
gdi32 unicode APIs: wrong conversion macros were used;
gdi32: rewritten EnumFont*W APIs, FONTSIGNATURE is now passed to callback function; populated in registry cache (affects Qt 4.6+)
DC objects are revalidated after text API calls
replace MSLU's shell32.DragQueryFileW with custom implementation (fixes Foxit Reader 3.1 drag&drop crash)
minor GDI text api fixes
---------------------------------------
KernelEx v4.5 RC 5 by Xeno86
2010-11-02

View File

@ -135,6 +135,18 @@ Package=<4>
###############################################################################
Project: "sdbcreate"=.\util\sdbcreate\sdbcreate.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>

View File

@ -1,4 +1,4 @@
!define _VERSION '4.5 RC 5'
!define _VERSION '4.5 Final'
!ifndef _DEBUG
!define FLAVOUR 'Release'
@ -37,6 +37,7 @@
Var ENABLEBUTTON
Var WARNING_TEXT
Var StartMenuFolder
;--------------------------------
;Interface Settings
@ -50,6 +51,13 @@
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "License.txt"
;Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\KernelEx"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "SMDir"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
Page custom PageDefConfig PageLeaveDefConfig
!insertmacro MUI_PAGE_FINISH
@ -209,24 +217,38 @@ Section "Install"
SetOutPath "$INSTDIR"
SetOverwrite on
File setup\${FLAVOUR}\setupkex.exe
SetOverwrite lastused
GetTempFileName $R0 "$INSTDIR"
File /oname=$R0 "setup\${FLAVOUR}\setupkex.exe"
StrCpy $R1 "none"
IfFileExists "$INSTDIR\kernel32.bak" 0 +6
StrCpy $R1 "copy"
ClearErrors
CopyFiles /SILENT "$INSTDIR\kernel32.bak" "$WINDIR\SYSBCKUP\KERNEL32.DLL"
IfErrors 0 +2
StrCpy $R1 "exist" ;File already exists
!ifdef _DEBUG
nsExec::ExecToLog '"$INSTDIR\setupkex.exe" "$INSTDIR\kernel32.bak"'
nsExec::ExecToLog '"$R0"'
Pop $0
!else
ExecWait '"$INSTDIR\setupkex.exe" "$INSTDIR\kernel32.bak"' $0
ExecWait '"$R0"' $0
StrCmp $0 "" 0 +2
StrCpy $0 "error"
!endif
DetailPrint " setup returned: $0"
Delete "$INSTDIR\setupkex.exe"
StrCmp $0 "0" +3
StrCmp $0 "0" +6
Delete $R0 ;delete temporary setupkex.exe
StrCmp $R1 "copy" 0 +2 ;undo copy
Delete "$WINDIR\SYSBCKUP\KERNEL32.DLL"
RMDir "$INSTDIR"
Abort
Rename /REBOOTOK $R0 "$INSTDIR\setupkex.exe"
StrCmp $R1 "copy" +2 0
StrCmp $R1 "exist" 0 +2
Delete /REBOOTOK "$INSTDIR\kernel32.bak" ;delete deprecated update file
;Files to install
;UpdateDLL_Func params:
@ -271,6 +293,7 @@ Section "Install"
File apilibs\core.ini
File apilibs\settings.reg
File license.txt
File "Release Notes.txt"
GetTempFileName $0 "$INSTDIR"
File /oname=$0 auxiliary\msimg32.dll
@ -319,6 +342,12 @@ Section "Install"
ExecWait '"$WINDIR\regedit.exe" /s "$INSTDIR\settings.reg"'
Delete "$INSTDIR\settings.reg"
CreateDirectory $WINDIR\AppPatch\Custom
File /oname=$WINDIR\AppPatch\Custom\KernelEx.sdb "util\sdbcreate\sdbdb\KernelEx.sdb"
File "util\sdbcreate\sdbdb\kexsdb.i.reg"
ExecWait '"$WINDIR\regedit.exe" /s "$INSTDIR\kexsdb.i.reg"'
Delete "$INSTDIR\kexsdb.i.reg"
;Store installation folder
WriteRegStr HKLM "Software\KernelEx" "InstallDir" $INSTDIR
@ -341,7 +370,16 @@ Section "Install"
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunServicesOnce" "KexNeedsReboot" ""
;Create shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Release Notes.lnk" "$INSTDIR\Release Notes.txt"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Verify Installation.lnk" "$INSTDIR\verify.exe"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\KernelEx Home Page.lnk" "http://kernelex.sourceforge.net/"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\KernelEx Wiki.lnk" "http://kernelex.sourceforge.net/wiki/"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SetRebootFlag true
SectionEnd
@ -361,10 +399,10 @@ Section "Uninstall"
Abort
;Files to uninstall
IfFileExists "$INSTDIR\kernel32.bak" 0 +5
IfFileExists "$WINDIR\SYSBCKUP\KERNEL32.DLL" 0 +5
GetTempFileName $0 "$SYSDIR"
Delete $0
Rename "$INSTDIR\kernel32.bak" $0
CopyFiles /SILENT "$WINDIR\SYSBCKUP\KERNEL32.DLL" $0
Rename /REBOOTOK $0 "$SYSDIR\kernel32.dll"
Delete /REBOOTOK "$INSTDIR\KernelEx.dll"
@ -376,6 +414,7 @@ Section "Uninstall"
UnRegDLL "$INSTDIR\kexCOM.dll"
Delete /REBOOTOK "$INSTDIR\kexCOM.dll"
Delete "$INSTDIR\license.txt"
Delete "$INSTDIR\Release Notes.txt"
Delete /REBOOTOK "$INSTDIR\msimg32.dll"
DeleteRegValue HKLM "Software\KernelEx\KnownDLLs" "MSIMG32"
@ -390,6 +429,12 @@ Section "Uninstall"
Delete /REBOOTOK "$INSTDIR\userenv.dll"
DeleteRegValue HKLM "Software\KernelEx\KnownDLLs" "USERENV"
File "util\sdbcreate\sdbdb\kexsdb.u.reg"
ExecWait '"$WINDIR\regedit.exe" /s "$INSTDIR\kexsdb.u.reg"'
Delete "$INSTDIR\kexsdb.u.reg"
Delete /REBOOTOK "$WINDIR\AppPatch\Custom\KernelEx.sdb"
RMDir "$WINDIR\AppPatch\Custom"
Delete "$INSTDIR\verify.exe"
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "KexVerify"
@ -398,6 +443,10 @@ Section "Uninstall"
RMDir /r "$INSTDIR\MSLU"
WriteINIStr $WINDIR\wininit.ini Rename DIRNUL $INSTDIR
;remove Start Menu shortcuts
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
RMDir /r "$SMPROGRAMS\$StartMenuFolder"
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(DESC_SETTINGS_PRESERVE)" IDYES +2 IDNO 0
DeleteRegKey HKLM "Software\KernelEx"

253
Release Notes.txt Executable file
View File

@ -0,0 +1,253 @@
KernelEx v4.5 Final by Xeno86
2010-12-30
What's new:
----------------------------------
* Reworked installer (should be more compatible with kernel32 updates)
* New welcome screen
* Fixed stability of extended TLS code
* Fixed hang issues with printers
* Added Windows Installer compatibility database for MSI files patching
Apps fixed / now working:
-------------------------
* Fixed: Foxit Reader 3.1 drag-and-drop crash
* Fixed: Qt 4.6+ hotkey issues
* Fixed: Opera 11 'about:' pages
* Fixed: Firefox displaying file save dialog twice
* Fixed: caret not showing on some configurations (Opera)
* Now working: Google Earth 5.2 (6.0 beta experimentally)
#################################################
KernelEx v4.5 RC 5 by Xeno86
2010-11-02
What's new:
----------------------------------
* KernelEx should now work better with Windows 95 shell
* Fixed stability issues with GDI anti-leaking code
Apps fixed / now working:
-------------------------
* Fixed: OpenOffice.org often crashed on closing
* Fixed: VLC 1.1.x crashed on DVD playback on windows 98 shell
* Fixed: MAME insufficient memory error
* Fixed: Inkscape 0.47 invisible save dialog problem
* Fixed: Foxit Reader 3,4 resource leaks and random scrolling crashes
* Fixed: Opera crashed in 'Windows 2000' mode when trying to save file
* Fixed: Qt4 apps not showing interface fonts
* Fixed: AkelPad had broken national input
* Fixed: Easy Assembler Shell installer crash
* Now working: Media Player Classic Home Cinema rev 2374+
* Now working: MS Office 2003 Word/Excel + Viewers (experimental)
* Now working: MS Office 2007 converters [docx only] (experimental)
#################################################
KernelEx v4.5 RC 4 by Xeno86
2010-09-21
What's new:
-----------
* Fixed: missing background colors and images in Mozilla Firefox 3.6.9/3.6.10
* Fixed: MSIMG32 warning and menu icon transparency issues in Opera 10.62
* Fixed: crashes introduced in RC 3
* KernelEx auxiliary libraries weren't loaded when full path to system file was passed in call to LoadLibary
#################################################
KernelEx v4.5 RC 3 by Xeno86
2010-09-10
hotfix to prevent DLL circular-references causing crashes on certain configurations
#################################################
KernelEx v4.5 RC 2 by Xeno86
2010-09-08
What's new:
-----------
* Implemented SysLink common control class
Apps fixed / now working:
-------------------------
* Fixed: Google Picasa options dialog (empty tabs)
* Fixed: Adobe Flash Player crashes (reported by mailcat via sf.net forum)
* Fixed: Adobe Flash Player 10.1 volume control
* Fixed: Wizard101 game crash (bug #3041092)
* Fixed: Maxthon browser (freezing)
* Now working: Maxthon 1.6.7
* Now working: VLC 1.1.2 (without RP9)
#################################################
KernelEx v4.5 RC 1 by Xeno86
2010-07-30
What's new:
----------------------------------
* Reworked 'Compatibility' tab to allow resetting compatibility settings to default values
* Resources with high ID are disallowed when KernelEx is disabled
* Platform check is now re-enabled when KernelEx is disabled
* Fixed settings not applied for applications with international characters in path
* Implemented get-post I/O completion ports functionality
Apps fixed / now working:
-------------------------
* Fixed: MSYS (broken)
* Fixed: Microsoft Access XP (crashing)
* Fixed: Rally Championship '99 (crashing)
* Fixed: GTA San Andreas (crashing)
* Fixed: VLC 1.0+ (UI)
* Fixed: Firefox 3.6.4+ (high cpu usage)
* Now working: Adobe Flash 10.1 plugin
* Now working: Mozilla Firefox 4.0 Beta 2
* Now working: Artweaver 1.0
* Now working: MPC-HC (newer builds, svn build 1391+)
#################################################
KernelEx v4.5 Beta 2 by Xeno86
2010-02-14
What's new:
----------------------------------
* Implemented Uniscribe font caching (improves Firefox 3 performance).
* New thread pool implementation (fixes IE6 problems).
* Fixed rare font related Firefox 3 crash.
* Implemented timer queue APIs.
* Implemented SHParseDisplayName and restricted to XP+ configs to fix Firefox mailto issues.
* Fixed premature kexCOM unloading crashing Photoshop 5 and other buggy apps.
* Updated jemalloc to version from FF3.6.
* Fixed jemalloc sensitiveness to invalid pointers. Fixes vmwareuser, cvtaplog crashing.
* Implemented EnumPrintersW (Foxit 3.1 Unicode printing support).
* Fixed Opera 10.50 Beta Acid3 crash.
* Other small fixes / stubs.
#################################################
KernelEx v4.5 Beta 1 by Xeno86
2010-01-18
What's new:
----------------------------------
* Noticeably improved speed of applications which make extensive use of memory.
This was made possible by introducing new memory allocator originating from FreeBSD - jemalloc.
It improves heap memory allocation/free speed and reduces virtual memory fragmentation.
* Improved compatibility with Unicode applications by implementing new windowing layer
which provides NT-consistent way to work with Unicode window procedures.
* Extended TLS slot limitation from 80 to 1000+, for some heavy apps.
* Lifted PE loader named resource limitation, allowing named resource-heavy libraries to load.
* Changed kernel obfuscator to produce positive object (process, thread) IDs in order to improve compatibility.
* Introduced kexCOM - new library to take care of missing COM interfaces. Fixes creating shell shortcuts in newer installers.
* GDI object destroying rules adjusted in order to fix certain resource leaks or unstability with Flash and other apps.
* Implemented certain userenv, unicode winspool, thread pool functions.
* Lot of API fixes and stubs.
* Improved Compatibility tab.
* Various architecture improvements.
* Fixed uninstall kernel32.bak not restoring reliably issue.
Apps now working / fixed:
-------------------------
* .NET Framework 2 (fixed install/uninstall and apps)
* AbiWord 2.8 (usable, minor problems)
* Adobe Flash 10.1 beta
* Adobe Acrobat Reader 9 (very unstable)
* Adobe ImageReady CS2 (no Photoshop yet)
* Arora (WebKit Internet Browser)
* FastStone Image Viewer (fixed plugin crash)
* Foxit Reader 3.1
* ICQ 6.5 / ICQLite
* InkScape (usable)
* GIMP 2.6 (usable, fixed brush trace)
* Half-Life 2 Episode One/Two
* Miranda IM 0.8.x Unicode
* Mozilla Thunderbird 3 (fixed out of space errors)
* Nero DiscSpeed 4
* QtCreator 1.2.1
* SoftMaker Office 2008 (fixed input bugs)
* WinAmp 5.5x (fixed ML crash, charset problems)
* X-Moto
Notes:
------
* This release is beta quality in order to test several major changes in KernelEx.
Please test the apps which were working before. Compare the performance and memory usage of any heavy apps you use.
Pay attention to possible national language input problems.
* If you want to downgrade to Final 2, you have to uninstall this beta first.
* Enjoy this great release. win9x 4ever.
#################################################
KernelEx v4.0 Final 2 by Xeno86
2009-08-20
Major changes:
--------------
* system won't try to load auxiliary libraries (PSAPI, MSIMG32, PDH, UXTHEME, WTSAPI32) when extensions are disabled
Fixed regressions:
------------------
* fixed ZoneAlarm not working properly
* Firefox 3 couldn't be uninstalled if KernelEx was installed with extensions disabled
* Foobar2000 v0.9.6.x installer was crashing
#################################################
KernelEx v4.0 Final by Xeno86
2009-07-23
Now working on Windows 98/Me:
-----------------------------
* Flash 10 in Internet Explorer
Major changes:
--------------
* added option to installer to select between enabling KernelEx extensions for all applications and disabling them
* added installation verifier
* printer driver software no longer running in NT mode
* file select dialogs in Flash applets and certain applications should work correctly now
* improved RP9 compatibility
* loading MSLU altered floating point unit flags and caused certain programs to crash
* MSLU (Unicows.dll) is no longer loaded right on startup and should be seen referenced less often in system
* Dependency Walker is no longer slow when profiling
* startup speed improvements
* stability improvements
* tons of small changes
#################################################
KernelEx v4.0 RC 2 by Xeno86
2009-03-21
Now working on Windows 98/Me:
-----------------------------
* The Chronicles of Riddick EFBB Demo
* QEmu 0.9
Fixed regressions:
------------------
* fixed Adobe Acrobat Reader 7.0 not working with RC 1
* .Net framework was broken in RC 1 now should work correctly
* input issue in Firefox 3 affecting special characters
* eMule couldn't complete downloads in RC 1, now fixed
* transparency issue in Firefox 3
* incompatibility with Norton Utilities
#################################################
KernelEx v4.0 RC 1 by Xeno86
2009-03-10
Now working on Windows 98/Me:
-----------------------------
* Firefox 3.6 alpha
* JDK 6 / JRE 6 works fine with the exception of Java applets which don't work (reason: missing proper named-pipe support in the system)
* PDF-XChange Viewer now works
Fixed regressions:
------------------
* Sysinternals TCPView display fix

View File

@ -104,7 +104,7 @@ static int strlenWW(LPWSTR strWW)
//misc
#define StrAllocA(size) (LPSTR)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size)
#define StrFree(ptr) HeapFree(GetProcessHeap(),0,ptr)
#define StrFree(ptr) if (ptr) HeapFree(GetProcessHeap(),0,ptr)
BOOL WINAPI GetSaveFileNameA_fix(LPOPENFILENAMEA lpofn);
BOOL WINAPI GetOpenFileNameA_fix(LPOPENFILENAMEA lpofn);

View File

@ -0,0 +1,120 @@
/*
* KernelEx
* Copyright 2010, Tihiy
*
* 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 <wintrust.h>
typedef struct {
DWORD dwSize;
HWND hwndParent;
DWORD dwFlags;
LPCWSTR szTitle;
PCCTL_CONTEXT pCtlContext;
DWORD unknown[6];
} CRYPTUI_VIEWCTL_STRUCTW; //size = 0x2C
typedef struct {
DWORD dwSize;
HWND hwndParent;
DWORD dwFlags;
LPCWSTR szTitle;
PCCRL_CONTEXT pCtlContext;
DWORD unknown[4];
} CRYPTUI_VIEWCRL_STRUCTW; //size = 0x24
typedef struct tagCRYPTUI_VIEWCERTIFICATE_STRUCTW {
DWORD dwSize;
HWND hwndParent;
DWORD dwFlags;
LPCWSTR szTitle;
PCCERT_CONTEXT pCertContext;
LPCSTR* rgszPurposes;
DWORD cPurposes;
union
{
CRYPT_PROVIDER_DATA const* pCryptProviderData;
HANDLE hWVTStateData;
};
BOOL fpCryptProviderDataTrustedUsage;
DWORD idxSigner;
DWORD idxCert;
BOOL fCounterSigner;
DWORD idxCounterSigner;
DWORD cStores;
HCERTSTORE* rghStores;
DWORD cPropSheetPages;
LPCPROPSHEETPAGEW rgPropSheetPages;
DWORD nStartPage;
} CRYPTUI_VIEWCERTIFICATE_STRUCTW,*PCRYPTUI_VIEWCERTIFICATE_STRUCTW;
typedef const CRYPTUI_VIEWCERTIFICATE_STRUCTW *PCCRYPTUI_VIEWCERTIFICATE_STRUCTW;
#ifdef __cplusplus
extern "C" {
#endif
BOOL WINAPI CryptUIDlgViewCertificateW(PCCRYPTUI_VIEWCERTIFICATE_STRUCTW, BOOL*);
BOOL WINAPI CryptUIDlgViewCTLW(CRYPTUI_VIEWCTL_STRUCTW*);
BOOL WINAPI CryptUIDlgViewCRLW(CRYPTUI_VIEWCRL_STRUCTW*);
#ifdef __cplusplus
}
#endif
/* MAKE_EXPORT CryptUIDlgViewContext_new=CryptUIDlgViewContext */
BOOL WINAPI CryptUIDlgViewContext_new( DWORD dwContextType, const void *pvContext,
HWND hwnd, LPCWSTR pwszTitle, DWORD dwFlags, void *pvReserved)
{
switch (dwContextType) {
case CERT_STORE_CERTIFICATE_CONTEXT:
{
CRYPTUI_VIEWCERTIFICATE_STRUCTW certW;
memset(&certW,0,sizeof(certW));
certW.dwSize = sizeof(certW);
certW.hwndParent = hwnd;
certW.szTitle = pwszTitle;
certW.pCertContext = (PCERT_CONTEXT)pvContext;
return CryptUIDlgViewCertificateW(&certW,NULL);
}
break;
case CERT_STORE_CTL_CONTEXT:
{
CRYPTUI_VIEWCTL_STRUCTW ctlW;
memset(&ctlW,0,sizeof(ctlW));
ctlW.dwSize = sizeof(ctlW);
ctlW.hwndParent = hwnd;
ctlW.szTitle = pwszTitle;
ctlW.pCtlContext = (PCCTL_CONTEXT)pvContext;
return CryptUIDlgViewCTLW(&ctlW);
}
break;
case CERT_STORE_CRL_CONTEXT:
{
CRYPTUI_VIEWCRL_STRUCTW crlW;
memset(&crlW,0,sizeof(crlW));
crlW.dwSize = sizeof(crlW);
crlW.hwndParent = hwnd;
crlW.szTitle = pwszTitle;
crlW.pCtlContext = (PCCRL_CONTEXT)pvContext;
return CryptUIDlgViewCRLW(&crlW);
}
break;
default:
return FALSE;
}
}

View File

@ -0,0 +1,45 @@
/*
* KernelEx
* Copyright (C) 2010, Tihiy
*
* 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 "common.h"
#include "_cryptui_apilist.h"
BOOL init_cryptui()
{
return TRUE;
}
static const apilib_named_api cryptui_named_apis[] =
{
/*** AUTOGENERATED APILIST NAMED EXPORTS BEGIN ***/
DECL_API("CryptUIDlgViewContext", CryptUIDlgViewContext_new),
/*** AUTOGENERATED APILIST NAMED EXPORTS END ***/
};
#if 0
static const apilib_unnamed_api cryptui_ordinal_apis[] =
{
/*** AUTOGENERATED APILIST ORDINAL EXPORTS BEGIN ***/
/*** AUTOGENERATED APILIST ORDINAL EXPORTS END ***/
};
#endif
const apilib_api_table apitable_cryptui = DECL_TAB("CRYPTUI.DLL", cryptui_named_apis, 0 /*cryptui_ordinal_apis*/);

View File

@ -0,0 +1,34 @@
/*
* KernelEx
* Copyright (C) 2010, Tihiy
*
* 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 _CRYPTUI_APILIST_H
#define _CRYPTUI_APILIST_H
#include "kexcoresdk.h"
BOOL init_cryptui();
extern const apilib_api_table apitable_cryptui;
/*** AUTOGENERATED APILIST DECLARATIONS BEGIN ***/
BOOL WINAPI CryptUIDlgViewContext_new(DWORD dwContextType, const void *pvContext, HWND hwnd, LPCWSTR pwszTitle, DWORD dwFlags, void *pvReserved);
/*** AUTOGENERATED APILIST DECLARATIONS END ***/
#endif

View File

@ -10,3 +10,4 @@ shfolder
winmm
ws2_32
ole32
cryptui

View File

@ -56,7 +56,7 @@ int WINAPI GetGlyphIndicesW_new(
)
{
HRESULT result;
if (!hdc || !pgi || (UINT)lpstr<0xFFFFu || !c) return GDI_ERROR;
if (!hdc || !pgi || (UINT)lpstr<0xFFFFu || c<=0) return GDI_ERROR;
ScriptCache::instance.Lock();
FONTUID hFont = GetHDCFontUID(hdc);
SCRIPT_CACHE cache = ScriptCache::instance.GetCache(hFont);
@ -117,15 +117,14 @@ int WINAPI GetGlyphIndicesA_new(
DWORD fl // glyph options
)
{
int result;
LPWSTR lpstrwide;
if (!hdc || !pgi || (UINT)lpstr<0xFFFF || c<=0) return GDI_ERROR;
lpstrwide = (LPWSTR)alloca(c*sizeof(WCHAR));
if (MultiByteToWideChar(GdiGetCodePage(hdc),0,lpstr,c,lpstrwide,c))
result = GetGlyphIndicesW_new(hdc,lpstrwide,c,pgi,fl);
else
result = GDI_ERROR;
return result;
c = MultiByteToWideChar(GdiGetCodePage(hdc),0,lpstr,c,lpstrwide,c);
if (!c)
return GDI_ERROR;
return GetGlyphIndicesW_new(hdc,lpstrwide,c,pgi,fl);
}
/* MAKE_EXPORT GetTextExtentExPointI_new=GetTextExtentExPointI */
@ -139,12 +138,11 @@ BOOL WINAPI GetTextExtentExPointI_new(
LPSIZE lpSize // string dimensions
)
{
ABC abc;
WORD* glyph = pgiIn;
int* dxs = alpDx;
int i;
int sum = 0;
int glyphwidth;
int charextra = GetTextCharacterExtra(hdc);
ABC abc;
BOOL unfit = FALSE;
if ( !hdc || !pgiIn || cgi<=0 || !lpSize)
@ -157,20 +155,25 @@ BOOL WINAPI GetTextExtentExPointI_new(
FONTUID hFont = GetHDCFontUID(hdc);
SCRIPT_CACHE cache = ScriptCache::instance.GetCache(hFont);
//in UberKern, ScriptPlace was used. However, it's too costly...
//so let's compute the info ourselves
if (lpnFit) *lpnFit = cgi;
for (i = 0; i < cgi; i++)
{
if ( ScriptGetGlyphABCWidth(hdc,&cache,*glyph,&abc) != S_OK ) break;
glyphwidth = abc.abcA + abc.abcB + abc.abcC;
if ( ScriptGetGlyphABCWidth(hdc,&cache,*pgiIn,&abc) != S_OK ) break;
glyphwidth = abc.abcA + abc.abcB + abc.abcC + charextra;
sum += glyphwidth;
if ( !unfit )
{
unfit = ( sum > nMaxExtent );
if (alpDx) {*dxs = sum; dxs++;}
if (unfit && lpnFit) *lpnFit = i+1; //test test!
if (unfit)
{
if ( lpnFit ) *lpnFit = i;
}
glyph++;
else
{
if ( alpDx ) *alpDx++ = sum;
}
}
pgiIn++;
}
lpSize->cx = sum;
@ -189,7 +192,7 @@ BOOL WINAPI GetTextExtentPointI_new(
LPSIZE lpSize // string size
)
{
return GetTextExtentExPointI_new(hdc,pgiIn,cgi,32768,0,0,lpSize);
return GetTextExtentExPointI_new(hdc,pgiIn,cgi,0,0,0,lpSize);
}
/* MAKE_EXPORT GetCharWidthI_new=GetCharWidthI */
@ -283,6 +286,33 @@ BOOL WINAPI GetCharABCWidthsI_new(
return TRUE;
}
/* MAKE_EXPORT GetCharABCWidthsW_new=GetCharABCWidthsW */
BOOL WINAPI GetCharABCWidthsW_new(
HDC hdc, // handle to DC
UINT uFirstChar, // first character in range
UINT uLastChar, // last character in range
LPABC lpabc // array of character widths
)
{
if ( !hdc || !lpabc || uFirstChar>uLastChar )
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
UINT c = uLastChar-uFirstChar+1;
LPWORD glyphs = (LPWORD)alloca(c*sizeof(WORD));
LPWSTR chrW = (LPWSTR)alloca(c*sizeof(WCHAR));
LPWSTR strW = chrW;
for (int i = uFirstChar; i<=uLastChar; i++)
{
*chrW=(WCHAR)i;
chrW++;
}
if ( GetGlyphIndicesW_new(hdc,strW,c,glyphs,0) == GDI_ERROR )
return FALSE;
return GetCharABCWidthsI_new(hdc,0,c,glyphs,lpabc);
}
/* MAKE_EXPORT GetGlyphOutlineW_new=GetGlyphOutlineW */
DWORD WINAPI GetGlyphOutlineW_new(
HDC hdc, // handle to DC
@ -327,7 +357,7 @@ DWORD WINAPI GetGlyphOutlineW_new(
lpgm->gmBlackBoxY = sz.cy;
lpgm->gmptGlyphOrigin.x = 0;
lpgm->gmptGlyphOrigin.y = sz.cy;
lpgm->gmCellIncX = sz.cx;
lpgm->gmCellIncX = (short) sz.cx;
lpgm->gmCellIncY = 0;
ret = 1;
}

View File

@ -43,10 +43,9 @@ static const apilib_named_api gdi32_named_apis[] =
DECL_API("CreateICW", CreateICW_fwd),
DECL_API("CreateMetaFileW", CreateMetaFileW_fwd),
DECL_API("CreateScalableFontResourceW", CreateScalableFontResourceW_fwd),
DECL_API("EnumFontsW", EnumFontsW_fwd),
DECL_API("EnumICMProfilesW", EnumICMProfilesW_fwd),
DECL_API("GetCharABCWidthsI", GetCharABCWidthsI_new),
DECL_API("GetCharABCWidthsW", GetCharABCWidthsW_fwd),
DECL_API("GetCharABCWidthsW", GetCharABCWidthsW_new),
DECL_API("GetCharWidthI", GetCharWidthI_new),
DECL_API("GetCharacterPlacementW", GetCharacterPlacementW_fwd),
DECL_API("GetEnhMetaFileDescriptionW", GetEnhMetaFileDescriptionW_fwd),

View File

@ -34,6 +34,7 @@ BOOL WINAPI GetTextExtentExPointI_new(HDC hdc, LPWORD pgiIn, int cgi, int nMaxEx
BOOL WINAPI GetTextExtentPointI_new(HDC hdc, LPWORD pgiIn, int cgi, LPSIZE lpSize);
BOOL WINAPI GetCharWidthI_new(HDC hdc, UINT giFirst, UINT cgi, WORD* pgi, INT* lpBuffer);
BOOL WINAPI GetCharABCWidthsI_new(HDC hdc, UINT giFirst, UINT cgi, LPWORD pgi, LPABC lpabc);
BOOL WINAPI GetCharABCWidthsW_new(HDC hdc, UINT uFirstChar, UINT uLastChar, LPABC lpabc);
DWORD WINAPI GetGlyphOutlineW_new(HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpvBuffer, CONST MAT2 *lpmat2);
FWDPROC CopyEnhMetaFileW_fwd;
FWDPROC CopyMetaFileW_fwd;
@ -45,9 +46,7 @@ FWDPROC CreateFontW_fwd;
FWDPROC CreateICW_fwd;
FWDPROC CreateMetaFileW_fwd;
FWDPROC CreateScalableFontResourceW_fwd;
FWDPROC EnumFontsW_fwd;
FWDPROC EnumICMProfilesW_fwd;
FWDPROC GetCharABCWidthsW_fwd;
FWDPROC GetCharacterPlacementW_fwd;
FWDPROC GetEnhMetaFileDescriptionW_fwd;
FWDPROC GetEnhMetaFileW_fwd;

View File

@ -31,9 +31,7 @@ FORWARD_TO_UNICOWS(CreateFontW);
FORWARD_TO_UNICOWS(CreateICW);
FORWARD_TO_UNICOWS(CreateMetaFileW);
FORWARD_TO_UNICOWS(CreateScalableFontResourceW);
FORWARD_TO_UNICOWS(EnumFontsW);
FORWARD_TO_UNICOWS(EnumICMProfilesW);
FORWARD_TO_UNICOWS(GetCharABCWidthsW);
FORWARD_TO_UNICOWS(GetCharacterPlacementW);
FORWARD_TO_UNICOWS(GetEnhMetaFileDescriptionW);
FORWARD_TO_UNICOWS(GetEnhMetaFileW);

View File

@ -48,13 +48,15 @@
#define TPS_EXECUTEIO 0x00000001
#define TPS_LONGEXECTIME 0x00000008
typedef BOOL (WINAPI* SHQueueUserWorkItem_API) (LPTHREAD_START_ROUTINE pfnCallback,
typedef BOOL (WINAPI* SHQueueUserWorkItem_API) (
LPTHREAD_START_ROUTINE pfnCallback,
LPVOID pContext,
LONG lPriority,
PDWORD dwTag,
PDWORD * pdwId,
LPCSTR pszModule,
DWORD dwFlags);
DWORD dwFlags
);
static SHQueueUserWorkItem_API SHQueueUserWorkItem;

View File

@ -109,14 +109,8 @@ BOOL init_exttls(void)
void detach_exttls(void)
{
TDB98* tdb;
LPVOID* ext;
__asm mov eax, fs:18h;
__asm sub eax, 8;
__asm mov tdb, eax;
ext = (LPVOID*) tdb->TlsSlots[TLS_SIZE-1];
TDB98* tdb = get_tdb();
LPVOID ext = tdb->TlsSlots[TLS_SIZE-1];
if (ext)
{
HeapFree(GetProcessHeap(), 0, ext);
@ -176,38 +170,38 @@ DWORD WINAPI TlsAlloc_new(void)
/* MAKE_EXPORT TlsFree_new=TlsFree */
BOOL WINAPI TlsFree_new(DWORD dwTlsIndex)
{
int ret;
int ret = 0;
PDB98* pdb = get_pdb();
_EnterSysLevel(k32lock);
_EnterSysLevel(TlsLock);
if (dwTlsIndex < TLS_SIZE-1)
{
int rem = dwTlsIndex % (sizeof(DWORD) * 8);
int div = dwTlsIndex / (sizeof(DWORD) * 8);
if (pdb->tlsInUseBits[div] & (1 << rem))
{
pdb->tlsInUseBits[div] &= ~(1 << rem);
ret = 1;
}
}
else if (dwTlsIndex < TOTAL_TLS_SIZE)
{
dwTlsIndex -= TLS_SIZE-1;
int rem = dwTlsIndex % (sizeof(DWORD) * 8);
int div = dwTlsIndex / (sizeof(DWORD) * 8);
if (ExtTlsBitmap[div] & (1 << rem))
{
ExtTlsBitmap[div] &= ~(1 << rem);
ret = 2;
}
else
{
SetLastError(ERROR_INVALID_PARAMETER);
ret = 0;
}
if (ret)
{
const NODE* thread;
_EnterSysLevel(k32lock);
for (thread = pdb->ThreadList->firstNode ; thread != NULL ; thread = thread->next)
{
TDB98* tdb = (TDB98*) thread->data;
@ -220,13 +214,14 @@ BOOL WINAPI TlsFree_new(DWORD dwTlsIndex)
ext[dwTlsIndex] = 0;
}
}
_LeaveSysLevel(k32lock);
}
_LeaveSysLevel(TlsLock);
_LeaveSysLevel(k32lock);
return ret;
if (!ret)
SetLastError(ERROR_INVALID_PARAMETER);
return (ret != 0);
}
#ifdef __ASM_IS_L33T__
@ -315,11 +310,7 @@ static inline void SetLastError_fast(TDB98* tdb, DWORD error)
LPVOID WINAPI TlsGetValue_new2(DWORD dwTlsIndex)
{
TDB98* tdb;
__asm mov eax, fs:18h;
__asm sub eax, 8;
__asm mov tdb, eax;
TDB98* tdb = get_tdb();
if (dwTlsIndex < TLS_SIZE-1)
{
@ -344,11 +335,7 @@ LPVOID WINAPI TlsGetValue_new2(DWORD dwTlsIndex)
BOOL WINAPI TlsSetValue_new2(DWORD dwTlsIndex, LPVOID lpTlsValue)
{
TDB98* tdb;
__asm mov eax, fs:18h;
__asm sub eax, 8;
__asm mov tdb, eax;
TDB98* tdb = get_tdb();
if (dwTlsIndex < TLS_SIZE-1)
{

View File

@ -53,7 +53,7 @@ BSC32=bscmake.exe
# 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 winspool.lib comdlg32.lib advapi32.lib shlwapi.lib shell32.lib rpcrt4.lib usp10.lib winmm.lib ws2_32.lib ../../common/KernelEx.lib ../../kexcrt/kexcrt.lib libc.lib delayimp.lib /nologo /dll /map /machine:I386 /nodefaultlib /OPT:NOWIN98 /DELAYLOAD:shell32.dll /DELAYLOAD:rpcrt4.dll /DELAYLOAD:usp10.dll /DELAYLOAD:comdlg32.dll /DELAYLOAD:winspool.drv /DELAYLOAD:shlwapi.dll /DELAYLOAD:winmm.dll /DELAYLOAD:ws2_32.dll
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib cryptui.lib comdlg32.lib advapi32.lib shlwapi.lib shell32.lib rpcrt4.lib usp10.lib winmm.lib ws2_32.lib ../../common/KernelEx.lib ../../kexcrt/kexcrt.lib libc.lib delayimp.lib /nologo /dll /map /machine:I386 /nodefaultlib /OPT:NOWIN98 /DELAYLOAD:shell32.dll /DELAYLOAD:rpcrt4.dll /DELAYLOAD:usp10.dll /DELAYLOAD:comdlg32.dll /DELAYLOAD:winspool.drv /DELAYLOAD:shlwapi.dll /DELAYLOAD:winmm.dll /DELAYLOAD:ws2_32.dll /DELAYLOAD:cryptui.dll
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "KernelEx Base NonShared - Win32 Debug"
@ -80,7 +80,7 @@ BSC32=bscmake.exe
# 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 winspool.lib comdlg32.lib advapi32.lib shlwapi.lib shell32.lib rpcrt4.lib usp10.lib winmm.lib ws2_32.lib ../../common/KernelEx.lib ../../kexcrt/kexcrt.lib libc.lib delayimp.lib /nologo /dll /map /debug /machine:I386 /nodefaultlib /OPT:NOWIN98 /DELAYLOAD:shell32.dll /DELAYLOAD:rpcrt4.dll /DELAYLOAD:usp10.dll /DELAYLOAD:comdlg32.dll /DELAYLOAD:winspool.drv /DELAYLOAD:shlwapi.dll /DELAYLOAD:winmm.dll /DELAYLOAD:ws2_32.dll
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib cryptui.lib comdlg32.lib advapi32.lib shlwapi.lib shell32.lib rpcrt4.lib usp10.lib winmm.lib ws2_32.lib ../../common/KernelEx.lib ../../kexcrt/kexcrt.lib libc.lib delayimp.lib /nologo /dll /map /debug /machine:I386 /nodefaultlib /OPT:NOWIN98 /DELAYLOAD:shell32.dll /DELAYLOAD:rpcrt4.dll /DELAYLOAD:usp10.dll /DELAYLOAD:comdlg32.dll /DELAYLOAD:winspool.drv /DELAYLOAD:shlwapi.dll /DELAYLOAD:winmm.dll /DELAYLOAD:ws2_32.dll /DELAYLOAD:cryptui.dll
# SUBTRACT LINK32 /pdb:none
!ENDIF
@ -364,6 +364,22 @@ SOURCE=.\ole32\_ole32_apilist.h
SOURCE=.\ole32\CoWaitForMultipleHandles.c
# End Source File
# End Group
# Begin Group "cryptui"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\cryptui\_cryptui_apilist.c
# End Source File
# Begin Source File
SOURCE=.\cryptui\_cryptui_apilist.h
# End Source File
# Begin Source File
SOURCE=.\cryptui\CryptUIDlgViewContext.c
# End Source File
# End Group
# Begin Source File
SOURCE=..\..\common\common.c

View File

@ -34,9 +34,10 @@
#include "winmm/_winmm_apilist.h"
#include "ws2_32/_ws2_32_apilist.h"
#include "ole32/_ole32_apilist.h"
#include "cryptui/_cryptui_apilist.h"
//#include "/__apilist.h"
static apilib_api_table api_table[13];
static apilib_api_table api_table[14];
static void fill_apitable()
{
@ -52,6 +53,7 @@ static void fill_apitable()
api_table[9] = apitable_winmm;
api_table[10] = apitable_ws2_32;
api_table[11] = apitable_ole32;
api_table[12] = apitable_cryptui;
//last entry is null terminator
}

View File

@ -30,9 +30,9 @@ extern const apilib_api_table apitable_rpcrt4;
/*** AUTOGENERATED APILIST DECLARATIONS BEGIN ***/
HRESULT WINAPI NdrDllGetClassObject_new(REFCLSID rclsid, REFIID riid, void **ppv, PVOID pVoidProxyFileList, const CLSID *pclsid, PVOID pVoidPSFactoryBuffer);
RPC_STATUS RPC_ENTRY RpcStringFreeW_new(IN OUT unsigned short ** String);
RPC_STATUS RPC_ENTRY UuidFromStringW_new(IN unsigned short * StringUuidW, OUT UUID * Uuid);
RPC_STATUS RPC_ENTRY UuidToStringW_new(IN UUID * Uuid, OUT unsigned short ** StringUuid);
RPC_STATUS RPC_ENTRY RpcStringFreeW_new(IN OUT LPWSTR * String);
RPC_STATUS RPC_ENTRY UuidFromStringW_new(IN LPWSTR StringUuidW, OUT UUID * Uuid);
RPC_STATUS RPC_ENTRY UuidToStringW_new(IN UUID * Uuid, OUT LPWSTR * StringUuid);
/*** AUTOGENERATED APILIST DECLARATIONS END ***/
#endif

View File

@ -25,7 +25,7 @@
/* MAKE_EXPORT RpcStringFreeW_new=RpcStringFreeW */
RPC_STATUS
RPC_ENTRY
RpcStringFreeW_new(IN OUT unsigned short ** String)
RpcStringFreeW_new(IN OUT LPWSTR * String)
{
HeapFree(GetProcessHeap(), 0, *String);
return RPC_S_OK;
@ -34,7 +34,7 @@ RpcStringFreeW_new(IN OUT unsigned short ** String)
/* MAKE_EXPORT UuidFromStringW_new=UuidFromStringW */
RPC_STATUS
RPC_ENTRY
UuidFromStringW_new(IN unsigned short * StringUuidW, OUT UUID * Uuid)
UuidFromStringW_new(IN LPWSTR StringUuidW, OUT UUID * Uuid)
{
ALLOC_WtoA(StringUuid);
return UuidFromStringA((unsigned char*) StringUuidA, Uuid);
@ -43,7 +43,7 @@ UuidFromStringW_new(IN unsigned short * StringUuidW, OUT UUID * Uuid)
/* MAKE_EXPORT UuidToStringW_new=UuidToStringW */
RPC_STATUS
RPC_ENTRY
UuidToStringW_new(IN UUID * Uuid, OUT unsigned short ** StringUuid)
UuidToStringW_new(IN UUID * Uuid, OUT LPWSTR * StringUuid)
{
RPC_STATUS ret;
unsigned char* uuidA;
@ -51,7 +51,7 @@ UuidToStringW_new(IN UUID * Uuid, OUT unsigned short ** StringUuid)
if (ret == RPC_S_OK)
{
int size = (strlen((char*) uuidA) + 1) * sizeof(short);
*StringUuid = (unsigned short*) HeapAlloc(GetProcessHeap(), 0, size);
*StringUuid = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, size);
if (!*StringUuid)
{
RpcStringFreeA(&uuidA);

View File

@ -30,7 +30,7 @@
* SHCreateDirectoryEx is in ME shell but no security anyway.
*/
static inline SHCreateDirectoryA(HWND hwnd, LPCSTR pszPath)
static inline int SHCreateDirectoryA(HWND hwnd, LPCSTR pszPath)
{
return SHCreateDirectory(hwnd, (LPCWSTR)pszPath);
}

View File

@ -38,7 +38,7 @@ void uninit_shell32()
static const apilib_named_api shell32_named_apis[] =
{
/*** AUTOGENERATED APILIST NAMED EXPORTS BEGIN ***/
DECL_API("DragQueryFileW", DragQueryFileW_fwd),
DECL_API("DragQueryFileW", DragQueryFileW_new),
DECL_API("ExtractIconExW", ExtractIconExW_fwd),
DECL_API("ExtractIconW", ExtractIconW_fwd),
DECL_API("FindExecutableW", FindExecutableW_fwd),

View File

@ -23,6 +23,7 @@
#define _SHELL32_APILIST_H
#include <shlobj.h>
#include <shellapi.h>
#include "kexcoresdk.h"
BOOL init_shell32();
@ -40,7 +41,6 @@ HRESULT WINAPI SHGetSpecialFolderLocation_fix(HWND hwndOwner, int nFolder, LPVOI
BOOL WINAPI SHGetSpecialFolderPathA_new(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
BOOL WINAPI SHGetSpecialFolderPathW_new(HWND hwndOwner, LPWSTR lpszPathW, int nFolder, BOOL fCreate);
HRESULT WINAPI SHParseDisplayName_new(PCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut);
FWDPROC DragQueryFileW_fwd;
FWDPROC ExtractIconExW_fwd;
FWDPROC ExtractIconW_fwd;
FWDPROC FindExecutableW_fwd;
@ -52,6 +52,7 @@ FWDPROC ShellExecuteW_fwd;
FWDPROC SHFileOperationW_fwd;
FWDPROC SHGetFileInfoW_fwd;
FWDPROC SHGetNewLinkInfoW_fwd;
UINT WINAPI DragQueryFileW_new(HDROP hDrop, UINT iFile, LPWSTR lpszFileW, UINT cch);
/*** AUTOGENERATED APILIST DECLARATIONS END ***/
#endif

View File

@ -1,6 +1,6 @@
/*
* KernelEx
* Copyright (C) 2008, Xeno86
* Copyright (C) 2008, 2010 Xeno86
*
* This file is part of KernelEx source code.
*
@ -20,8 +20,34 @@
*/
#include "unifwd.h"
#include "common.h"
#include <shellapi.h>
#include <shlwapi.h>
/* MAKE_EXPORT DragQueryFileW_new=DragQueryFileW */
UINT WINAPI DragQueryFileW_new(HDROP hDrop, UINT iFile, LPWSTR lpszFileW, UINT cch)
{
UINT ret;
ALLOC_A(lpszFile, cch * 2);
ret = DragQueryFileA(hDrop, iFile, lpszFileA, cch);
if (ret && lpszFileA && iFile != 0xffffffff)
{
DWORD lasterr = GetLastError();
ret = AtoW(lpszFile, cch);
if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
ret = cch;
if (ret) ret--;
SetLastError(lasterr);
}
return ret;
}
FORWARD_TO_UNICOWS(DragQueryFileW);
FORWARD_TO_UNICOWS(ExtractIconExW);
FORWARD_TO_UNICOWS(ExtractIconW);
FORWARD_TO_UNICOWS(FindExecutableW);

View File

@ -91,8 +91,10 @@ static void convert_printerinfo_WtoA(LPBYTE outW, LPBYTE pPrintersA,
/* copy the numbers of all PRINTER_INFO_* first */
memcpy(outW, pPrintersA, len);
while (id < numentries) {
switch (level) {
while (id < numentries)
{
switch (level)
{
case 1:
{
PRINTER_INFO_1W * piW = (PRINTER_INFO_1W *) outW;

171
apilibs/kexbases/Gdi32/EnumFont.c Executable file
View File

@ -0,0 +1,171 @@
/*
* KernelEx
* Copyright (C) 2010, Xeno86, Tihiy
*
* 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 "common.h"
typedef struct
{
FONTENUMPROCW procW;
LPARAM lParam;
HKEY hKey;
ENUMLOGFONTEXDVW elfW;
ENUMTEXTMETRICW etmW;
} EnumHelperW_t;
static const char regfontsig[] = "SOFTWARE\\KernelEx\\FontSignature";
static const char regttfcachesize[] = "ttfCacheSize";
static inline void GetFontSignature(HKEY hkey, LOGFONTA* plfA, FONTSIGNATURE* sig)
{
DWORD sz = sizeof(FONTSIGNATURE);
if ( RegQueryValueEx(hkey,plfA->lfFaceName,0,NULL,(LPBYTE)sig,&sz) != ERROR_SUCCESS )
{
DBGPRINTF(("Querying signature from font %s",plfA->lfFaceName));
HDC hdc = CreateCompatibleDC(0);
HFONT fnt = CreateFontIndirect(plfA);
HGDIOBJ old = SelectObject(hdc,fnt);
GetTextCharsetInfo(hdc,sig,0);
SelectObject(hdc,old);
DeleteObject(fnt);
DeleteDC(hdc);
sz = sizeof(FONTSIGNATURE);
RegSetValueEx(hkey,plfA->lfFaceName,0,REG_BINARY,(LPBYTE)sig,sz);
}
}
static inline void ENUMLOGFONTEXAtoW(ENUMLOGFONTEXA* fontA, ENUMLOGFONTEXW* fontW)
{
memcpy(&fontW->elfLogFont, &fontA->elfLogFont, FIELD_OFFSET(LOGFONT,lfFaceName));
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) fontA->elfLogFont.lfFaceName, -1,
fontW->elfLogFont.lfFaceName, LF_FACESIZE);
fontW->elfLogFont.lfFaceName[LF_FACESIZE - 1] = 0;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) fontA->elfFullName, -1,
fontW->elfFullName, LF_FULLFACESIZE);
fontW->elfFullName[LF_FULLFACESIZE - 1] = 0;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) fontA->elfStyle, -1,
fontW->elfStyle, LF_FACESIZE);
fontW->elfStyle[LF_FACESIZE - 1] = 0;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) fontA->elfScript, -1,
fontW->elfScript, LF_FACESIZE);
fontW->elfScript[LF_FACESIZE - 1] = 0;
}
static inline void NEWTEXTMETRICAtoW(NEWTEXTMETRICA* tmA, NEWTEXTMETRICW* tmW)
{
memcpy(tmW,tmA,FIELD_OFFSET(NEWTEXTMETRICA,tmFirstChar));
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) &tmA->tmFirstChar, 1,
&tmW->tmFirstChar, 1);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) &tmA->tmLastChar, 1,
&tmW->tmLastChar, 1);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) &tmA->tmDefaultChar, 1,
&tmW->tmDefaultChar, 1);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) &tmA->tmBreakChar, 1,
&tmW->tmBreakChar, 1);
memcpy(&tmW->tmItalic,&tmA->tmItalic,sizeof(NEWTEXTMETRICA) - FIELD_OFFSET(NEWTEXTMETRICA,tmItalic));
}
int WINAPI EnumFontWHelper( CONST LOGFONTA *lfA, CONST TEXTMETRICA *tmA, DWORD FontType, LPARAM lParam )
{
ENUMLOGFONTEXA* lpelfA = (ENUMLOGFONTEXA*)lfA;
NEWTEXTMETRICA* lpntmA = (NEWTEXTMETRICA*)tmA;
EnumHelperW_t* params = (EnumHelperW_t*)lParam;
ENUMLOGFONTEXAtoW(lpelfA,&params->elfW.elfEnumLogfontEx);
NEWTEXTMETRICAtoW(lpntmA,&params->etmW.etmNewTextMetricEx.ntmTm);
if ( FontType == TRUETYPE_FONTTYPE )
GetFontSignature(params->hKey,&lpelfA->elfLogFont,&params->etmW.etmNewTextMetricEx.ntmFontSig);
else
memset(&params->etmW.etmNewTextMetricEx.ntmFontSig,0,sizeof(FONTSIGNATURE));
return params->procW((LOGFONTW*)&params->elfW,(TEXTMETRICW*)&params->etmW,FontType,params->lParam);
}
/* MAKE_EXPORT EnumFontFamiliesExA_new=EnumFontFamiliesExA */
int WINAPI EnumFontFamiliesExA_new(HDC hdc, LPLOGFONTA pLogfontA,
FONTENUMPROCA pEnumFontFamExProc, LPARAM lParam, DWORD dwFlags)
{
LOGFONTA logfont;
if (!pLogfontA)
{
memset(&logfont, 0, sizeof(logfont));
logfont.lfCharSet = DEFAULT_CHARSET;
pLogfontA = &logfont;
}
return EnumFontFamiliesExA(hdc, pLogfontA, pEnumFontFamExProc, lParam, dwFlags);
}
/* MAKE_EXPORT EnumFontFamiliesExW_new=EnumFontFamiliesExW */
int WINAPI EnumFontFamiliesExW_new(HDC hdc, LPLOGFONTW pLogfontW,
FONTENUMPROCW pEnumFontFamExProc, LPARAM lParam, DWORD dwFlags)
{
LOGFONTA logfont;
if (pLogfontW)
{
memcpy(&logfont, pLogfontW, FIELD_OFFSET(LOGFONT,lfFaceName));
WideCharToMultiByte(CP_ACP, 0, pLogfontW->lfFaceName, -1, logfont.lfFaceName,
LF_FACESIZE, NULL, NULL);
logfont.lfFaceName[LF_FACESIZE - 1] = '\0';
}
else
{
memset(&logfont, 0, sizeof(logfont));
logfont.lfCharSet = DEFAULT_CHARSET;
}
EnumHelperW_t params = {0};
params.procW = pEnumFontFamExProc;
params.lParam = lParam;
RegCreateKey(HKEY_LOCAL_MACHINE,regfontsig,&params.hKey);
int ret = EnumFontFamiliesExA(hdc,&logfont,EnumFontWHelper,(LPARAM)&params,dwFlags);
RegCloseKey(params.hKey);
return ret;
}
/* MAKE_EXPORT EnumFontFamiliesW_new=EnumFontFamiliesW */
int WINAPI EnumFontFamiliesW_new( HDC hdc, LPCWSTR lpszFamilyW,
FONTENUMPROCW lpEnumFontFamProc, LPARAM lParam)
{
LPSTR lpszFamilyA;
STACK_WtoA(lpszFamilyW,lpszFamilyA);
EnumHelperW_t params = {0};
params.procW = lpEnumFontFamProc;
params.lParam = lParam;
RegCreateKey(HKEY_LOCAL_MACHINE,regfontsig,&params.hKey);
int ret = EnumFontFamiliesA(hdc,lpszFamilyA,EnumFontWHelper,(LPARAM)&params);
RegCloseKey(params.hKey);
return ret;
}
/* MAKE_EXPORT EnumFontsW_new=EnumFontsW */
int WINAPI EnumFontsW_new( HDC hdc, LPCWSTR lpFaceNameW,
FONTENUMPROCW lpFontFunc, LPARAM lParam)
{
LPSTR lpFaceNameA;
STACK_WtoA(lpFaceNameW,lpFaceNameA);
EnumHelperW_t params = {0};
params.procW = lpFontFunc;
params.lParam = lParam;
RegCreateKey(HKEY_LOCAL_MACHINE,regfontsig,&params.hKey);
int ret = EnumFontsA(hdc,lpFaceNameA,EnumFontWHelper,(LPARAM)&params);
RegCloseKey(params.hKey);
return ret;
}

View File

@ -149,17 +149,13 @@ DWORD WINAPI GetObjectType_fix( HGDIOBJ hgdiobj )
return result;
}
__declspec(naked)
#pragma warning (disable:4035) //xeno approves
static inline
WORD GetCurrentTDB()
{
__asm
{
mov ax, fs:[0Ch]
movzx eax, ax
ret
}
__asm mov ax, fs:[0Ch]
}
#pragma warning (default:4035)
/************************************************************************
The purpose of GdiObjects is to simulate NT GDI object rules, which

View File

@ -129,10 +129,13 @@ BOOL WINAPI SetWorldTransform_NT(
//hack DC mode to anisotropic to make Set*ExtEx work
savemapmode = dcobj->mapmode;
dcobj->mapmode = MM_ANISOTROPIC;
ReleaseWin16Lock();
SetWindowExtEx(hdc,wx,wy,NULL);
SetViewportExtEx(hdc,vx,vy,NULL);
SetViewportOrgEx(hdc,(int)lpXform->eDx,(int)lpXform->eDy,NULL);
//set it back
GrabWin16Lock();
dcobj = GetDCObj(hdc);
dcobj->mapmode = savemapmode;
ReleaseWin16Lock();
return TRUE;
@ -170,13 +173,15 @@ BOOL WINAPI GetTextMetricsA_NT(
}
if ( dcobj->ViewportExtX != 1 || dcobj->ViewportExtY != 1 || dcobj->WindowExtX != 1 || dcobj->WindowExtY != 1 )
{
ReleaseWin16Lock();
saved = SaveDC(hdc);
ResetMapMode(hdc);
}
else
ReleaseWin16Lock();
retval = GetTextMetricsA(hdc,lptm);
if ( saved )
RestoreDC(hdc,-1);
ReleaseWin16Lock();
return retval;
}
@ -328,11 +333,15 @@ BOOL WINAPI ExtTextOutW_new(
savemapmode = dcobj->mapmode;
dcobj->mapmode = MM_ANISOTROPIC;
}
ReleaseWin16Lock();
result = ExtTextOutW(hdc,X,Y,fuOptions,lprc,lpString,cbCount,lpDx);
if ( savemapmode )
{
GrabWin16Lock();
dcobj = GetDCObj( hdc );
dcobj->mapmode = savemapmode;
ReleaseWin16Lock();
}
if ( buffer && cbCount>128 )
HeapFree(GetProcessHeap(),0,buffer);
return result;

View File

@ -47,6 +47,7 @@ static const apilib_named_api gdi32_named_apis[] =
DECL_API("EnumFontFamiliesExA", EnumFontFamiliesExA_new),
DECL_API("EnumFontFamiliesExW", EnumFontFamiliesExW_new),
DECL_API("EnumFontFamiliesW", EnumFontFamiliesW_new),
DECL_API("EnumFontsW", EnumFontsW_new),
DECL_API("ExtCreatePen", ExtCreatePen_fix),
DECL_API("ExtTextOutA", ExtTextOutA_new),
DECL_API("ExtTextOutW", ExtTextOutW_new),

View File

@ -28,6 +28,10 @@ BOOL init_gdi32();
extern const apilib_api_table apitable_gdi32;
/*** AUTOGENERATED APILIST DECLARATIONS BEGIN ***/
int WINAPI EnumFontFamiliesExA_new(HDC hdc, LPLOGFONTA pLogfontA, FONTENUMPROCA pEnumFontFamExProc, LPARAM lParam, DWORD dwFlags);
int WINAPI EnumFontFamiliesExW_new(HDC hdc, LPLOGFONTW pLogfontW, FONTENUMPROCW pEnumFontFamExProc, LPARAM lParam, DWORD dwFlags);
int WINAPI EnumFontFamiliesW_new(HDC hdc, LPCWSTR lpszFamilyW, FONTENUMPROCW lpEnumFontFamProc, LPARAM lParam);
int WINAPI EnumFontsW_new(HDC hdc, LPCWSTR lpFaceNameW, FONTENUMPROCW lpFontFunc, LPARAM lParam);
INT WINAPI AddFontResourceExA_new(LPCSTR str, DWORD fl, PVOID pdv);
BOOL WINAPI RemoveFontResourceExA_new(LPCSTR str, DWORD fl, PVOID pdv);
HANDLE WINAPI AddFontMemResourceEx_stub(PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD *pcFonts);
@ -59,9 +63,6 @@ STUB GetDCBrushColor_stub;
STUB GetDCPenColor_stub;
INT WINAPI AddFontResourceExW_new(LPCWSTR strW, DWORD fl, PVOID pdv);
INT WINAPI AddFontResourceW_new(LPCWSTR strW);
int WINAPI EnumFontFamiliesExA_new(HDC hdc, LPLOGFONTA pLogfontA, FONTENUMPROCA pEnumFontFamExProc, LPARAM lParam, DWORD dwFlags);
int WINAPI EnumFontFamiliesExW_new(HDC hdc, LPLOGFONTW pLogfontW, FONTENUMPROCW pEnumFontFamExProc, LPARAM lParam, DWORD dwFlags);
int WINAPI EnumFontFamiliesW_new(HDC hdc, LPCWSTR lpszFamily, FONTENUMPROCW lpEnumFontFamProc, LPARAM lParam);
BOOL WINAPI RemoveFontResourceExW_new(LPCWSTR strW, DWORD fl, PVOID pdv);
BOOL WINAPI RemoveFontResourceW_new(LPCWSTR strW);
HPEN WINAPI ExtCreatePen_fix(DWORD dwPenStyle, DWORD dwWidth, CONST LOGBRUSH *lplb, DWORD dwStyleCount, CONST DWORD *lpStyle);

View File

@ -22,183 +22,36 @@
#include "common.h"
#include "_gdi32_apilist.h"
#include "../kernel32/_kernel32_apilist.h"
typedef struct
{
FONTENUMPROCW EnumProcW;
LPARAM lParam;
} EnumFamilies_t;
//MAKE_EXPORT AddFontResourceExW_new=AddFontResourceExW
INT WINAPI AddFontResourceExW_new(LPCWSTR strW, DWORD fl, PVOID pdv)
{
file_GetCP();
file_ALLOC_WtoA(str);
LPSTR strA;
STACK_WtoA(strW,strA)
return AddFontResourceExA_new(strA, fl, pdv);
}
//MAKE_EXPORT AddFontResourceW_new=AddFontResourceW
INT WINAPI AddFontResourceW_new(LPCWSTR strW)
{
file_GetCP();
file_ALLOC_WtoA(str);
LPSTR strA;
STACK_WtoA(strW,strA)
return AddFontResourceA(strA);
}
static int CALLBACK EnumFontFamExConv(const LOGFONTA *plfA,
const TEXTMETRICA* ptmA, DWORD FontType, LPARAM lParam)
{
const ENUMLOGFONTEXA* fontA = (const ENUMLOGFONTEXA*) plfA;
const NEWTEXTMETRICEXA* tmA = (const NEWTEXTMETRICEXA*) ptmA;
ENUMLOGFONTEXW elfeW;
NEWTEXTMETRICEXW ntmeW;
ENUMLOGFONTEXW* fontW = &elfeW;
NEWTEXTMETRICEXW* tmW = &ntmeW;
EnumFamilies_t* pef = (EnumFamilies_t*) lParam;
memcpy(&fontW->elfLogFont, &fontA->elfLogFont, sizeof(LOGFONTA) - LF_FACESIZE);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) fontA->elfLogFont.lfFaceName, -1,
fontW->elfLogFont.lfFaceName, LF_FACESIZE);
fontW->elfLogFont.lfFaceName[LF_FACESIZE - 1] = 0;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) fontA->elfFullName, -1,
fontW->elfFullName, LF_FULLFACESIZE);
fontW->elfFullName[LF_FULLFACESIZE - 1] = 0;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) fontA->elfStyle, -1,
fontW->elfStyle, LF_FACESIZE);
fontW->elfStyle[LF_FACESIZE - 1] = 0;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) fontA->elfScript, -1,
fontW->elfScript, LF_FACESIZE);
fontW->elfScript[LF_FACESIZE - 1] = 0;
tmW->ntmTm.tmHeight = tmA->ntmTm.tmHeight;
tmW->ntmTm.tmAscent = tmA->ntmTm.tmAscent;
tmW->ntmTm.tmDescent = tmA->ntmTm.tmDescent;
tmW->ntmTm.tmInternalLeading = tmA->ntmTm.tmInternalLeading;
tmW->ntmTm.tmExternalLeading = tmA->ntmTm.tmExternalLeading;
tmW->ntmTm.tmAveCharWidth = tmA->ntmTm.tmAveCharWidth;
tmW->ntmTm.tmMaxCharWidth = tmA->ntmTm.tmMaxCharWidth;
tmW->ntmTm.tmWeight = tmA->ntmTm.tmWeight;
tmW->ntmTm.tmOverhang = tmA->ntmTm.tmOverhang;
tmW->ntmTm.tmDigitizedAspectX = tmA->ntmTm.tmDigitizedAspectX;
tmW->ntmTm.tmDigitizedAspectY = tmA->ntmTm.tmDigitizedAspectY;
tmW->ntmTm.tmItalic = tmA->ntmTm.tmItalic;
tmW->ntmTm.tmUnderlined = tmA->ntmTm.tmUnderlined;
tmW->ntmTm.tmStruckOut = tmA->ntmTm.tmStruckOut;
tmW->ntmTm.tmPitchAndFamily = tmA->ntmTm.tmPitchAndFamily;
tmW->ntmTm.tmCharSet = tmA->ntmTm.tmCharSet;
//needs review - are this conversions necessary or is it enough to just copy?
#if 1
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) &tmA->ntmTm.tmFirstChar, 1,
&tmW->ntmTm.tmFirstChar, 1);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) &tmA->ntmTm.tmLastChar, 1,
&tmW->ntmTm.tmLastChar, 1);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) &tmA->ntmTm.tmDefaultChar, 1,
&tmW->ntmTm.tmDefaultChar, 1);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) &tmA->ntmTm.tmBreakChar, 1,
&tmW->ntmTm.tmBreakChar, 1);
#else
tmW->ntmTm.tmFirstChar = tmA->ntmTm.tmFirstChar;
tmW->ntmTm.tmLastChar = tmA->ntmTm.tmLastChar;
tmW->ntmTm.tmDefaultChar = tmA->ntmTm.tmDefaultChar;
tmW->ntmTm.tmBreakChar = tmA->ntmTm.tmBreakChar;
#endif
if (FontType == TRUETYPE_FONTTYPE)
{
tmW->ntmTm.ntmFlags = tmA->ntmTm.ntmFlags;
tmW->ntmTm.ntmSizeEM = tmA->ntmTm.ntmSizeEM;
tmW->ntmTm.ntmCellHeight = tmA->ntmTm.ntmCellHeight;
tmW->ntmTm.ntmAvgWidth = tmA->ntmTm.ntmAvgWidth;
memset(&tmW->ntmFontSig, 0, sizeof(FONTSIGNATURE));
}
else
{
memset(&tmW->ntmTm.ntmFlags, 0, sizeof(NEWTEXTMETRICEXW)
- FIELD_OFFSET(NEWTEXTMETRICEXW, ntmTm.ntmFlags));
}
return pef->EnumProcW((LOGFONTW*) &elfeW, (TEXTMETRICW*) &ntmeW, FontType, pef->lParam);
}
/* Surprise surprise!
* logfont* is optional in EnumFontFamiliesEx on NT
* and means - all fonts, all charsets
*/
/* MAKE_EXPORT EnumFontFamiliesExA_new=EnumFontFamiliesExA */
int WINAPI EnumFontFamiliesExA_new(HDC hdc, LPLOGFONTA pLogfontA,
FONTENUMPROCA pEnumFontFamExProc, LPARAM lParam, DWORD dwFlags)
{
LOGFONTA logfont;
if (!pLogfontA)
{
memset(&logfont, 0, sizeof(logfont));
logfont.lfCharSet = DEFAULT_CHARSET;
pLogfontA = &logfont;
}
return EnumFontFamiliesExA(hdc, pLogfontA, pEnumFontFamExProc, lParam, dwFlags);
}
/* MAKE_EXPORT EnumFontFamiliesExW_new=EnumFontFamiliesExW */
int WINAPI EnumFontFamiliesExW_new(HDC hdc, LPLOGFONTW pLogfontW,
FONTENUMPROCW pEnumFontFamExProc, LPARAM lParam, DWORD dwFlags)
{
EnumFamilies_t ef;
LOGFONTA logfont;
if (pLogfontW)
{
memcpy(&logfont, pLogfontW, sizeof(LOGFONTA) - LF_FACESIZE);
WideCharToMultiByte(CP_ACP, 0, pLogfontW->lfFaceName, -1, logfont.lfFaceName,
LF_FACESIZE, NULL, NULL);
logfont.lfFaceName[LF_FACESIZE - 1] = '\0';
}
else
{
memset(&logfont, 0, sizeof(logfont));
logfont.lfCharSet = DEFAULT_CHARSET;
}
ef.EnumProcW = pEnumFontFamExProc;
ef.lParam = lParam;
return EnumFontFamiliesExA(hdc, &logfont, EnumFontFamExConv, (LPARAM) &ef, dwFlags);
}
/* MAKE_EXPORT EnumFontFamiliesW_new=EnumFontFamiliesW */
int WINAPI EnumFontFamiliesW_new(HDC hdc, LPCWSTR lpszFamily,
FONTENUMPROCW lpEnumFontFamProc, LPARAM lParam)
{
LOGFONTW lf;
LOGFONTW* plf = NULL;
if (lpszFamily)
{
if (!*lpszFamily)
return 1;
lstrcpynW_new(lf.lfFaceName, lpszFamily, LF_FACESIZE);
lf.lfCharSet = DEFAULT_CHARSET;
lf.lfPitchAndFamily = 0;
plf = &lf;
}
return EnumFontFamiliesExW_new(hdc, plf, lpEnumFontFamProc, lParam, 0);
}
//MAKE_EXPORT RemoveFontResourceExW_new=RemoveFontResourceExW
BOOL WINAPI RemoveFontResourceExW_new(LPCWSTR strW, DWORD fl, PVOID pdv)
{
file_GetCP();
file_ALLOC_WtoA(str);
LPSTR strA;
STACK_WtoA(strW,strA)
return RemoveFontResourceExA_new(strA, fl, pdv);
}
//MAKE_EXPORT RemoveFontResourceW_new=RemoveFontResourceW
BOOL WINAPI RemoveFontResourceW_new(LPCWSTR strW)
{
file_GetCP();
file_ALLOC_WtoA(str);
LPSTR strA;
STACK_WtoA(strW,strA)
return RemoveFontResourceA(strA);
}

View File

@ -0,0 +1,39 @@
/*
* KernelEx
* Copyright (C) 2010, Tihiy
*
* 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 "common.h"
#include "_kernel32_apilist.h"
/* MAKE_EXPORT FindFirstFileExA_new=FindFirstFileExA */
HANDLE WINAPI FindFirstFileExA_new( LPCSTR lpFileNameA, FINDEX_INFO_LEVELS fInfoLevelId,
LPWIN32_FIND_DATAA lpFindFileDataA, FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter, DWORD dwAdditionalFlags)
{
return FindFirstFileA(lpFileNameA,lpFindFileDataA);
}
/* MAKE_EXPORT FindFirstFileExW_new=FindFirstFileExW */
HANDLE WINAPI FindFirstFileExW_new( LPWSTR lpFileNameW, FINDEX_INFO_LEVELS fInfoLevelId,
LPWIN32_FIND_DATAW lpFindFileDataW, FINDEX_SEARCH_OPS fSearchOp,
LPVOID lpSearchFilter, DWORD dwAdditionalFlags)
{
return FindFirstFileW_new(lpFileNameW,lpFindFileDataW);
}

View File

@ -82,9 +82,11 @@ void get_cpuinfo()
if (regs[1] == AUTH &&
regs[3] == ENTI &&
regs[2] == CAMD) {
regs[2] == CAMD)
{
do_cpuid(0x80000000, regs); /* get vendor cpuid level */
if (regs[0]>=0x80000001) {
if (regs[0]>=0x80000001)
{
do_cpuid(0x80000001, regs2); /* get vendor features */
PF[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 31)) >> 31;
}

View File

@ -22,15 +22,24 @@
#include <windows.h>
/* MAKE_EXPORT LockFileEx_new=LockFileEx */
BOOL WINAPI LockFileEx_new(HANDLE hFile, DWORD dwFlags, DWORD dwReserved, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped)
BOOL WINAPI LockFileEx_new(
HANDLE hFile,
DWORD dwFlags,
DWORD dwReserved,
DWORD nNumberOfBytesToLockLow,
DWORD nNumberOfBytesToLockHigh,
LPOVERLAPPED lpOverlapped
)
{
/* FIXME: flags LOCKFILE_FAIL_IMMEDIATELY and LOCKFILE_EXCLUSIVE_LOCK not supported (always set),
Event signalling not supported
/*
* FIXME: flags LOCKFILE_FAIL_IMMEDIATELY and LOCKFILE_EXCLUSIVE_LOCK not supported (always set),
* Event signalling not supported
*/
if (dwReserved)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return LockFile(hFile, lpOverlapped->Offset, lpOverlapped->OffsetHigh, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh);
return LockFile(hFile, lpOverlapped->Offset, lpOverlapped->OffsetHigh,
nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh);
}

View File

@ -77,7 +77,8 @@ static const apilib_named_api kernel32_named_apis[] =
DECL_API("ExitProcess", ExitProcess_fix),
DECL_API("FindAtomW", FindAtomW_new),
DECL_API("FindFirstChangeNotificationW", FindFirstChangeNotificationW_new),
DECL_API("FindFirstFileExW", FindFirstFileExW_stub),
DECL_API("FindFirstFileExA", FindFirstFileExA_new),
DECL_API("FindFirstFileExW", FindFirstFileExW_new),
DECL_API("FindFirstFileW", FindFirstFileW_new),
DECL_API("FindNextFileW", FindNextFileW_new),
DECL_API("FindResourceExW", FindResourceExW_new),

View File

@ -44,6 +44,8 @@ BOOL WINAPI WriteFile_fix(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesTo
UINT WINAPI GetTempFileNameA_fix(LPCSTR lpPathName, LPCSTR lpPrefixString, UINT uUnique, LPTSTR lpTempFileName);
BOOL WINAPI GetDiskFreeSpaceA_fix(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters);
BOOL WINAPI GetDiskFreeSpaceExA_fix(LPCSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes);
HANDLE WINAPI FindFirstFileExA_new(LPCSTR lpFileNameA, FINDEX_INFO_LEVELS fInfoLevelId, LPWIN32_FIND_DATAA lpFindFileDataA, FINDEX_SEARCH_OPS fSearchOp, LPVOID lpSearchFilter, DWORD dwAdditionalFlags);
HANDLE WINAPI FindFirstFileExW_new(LPWSTR lpFileNameW, FINDEX_INFO_LEVELS fInfoLevelId, LPWIN32_FIND_DATAW lpFindFileDataW, FINDEX_SEARCH_OPS fSearchOp, LPVOID lpSearchFilter, DWORD dwAdditionalFlags);
HWND WINAPI GetConsoleWindow_new();
BOOL WINAPI GetFileSizeEx_new(HANDLE hFile, PLARGE_INTEGER lpFileSize);
BOOL WINAPI GetModuleHandleExA_new(DWORD dwFlags, LPCSTR lpModuleName, HMODULE* phModule);
@ -85,7 +87,6 @@ STUB CreateHardLinkW_stub;
STUB IsValidLanguageGroup_stub;
STUB ReplaceFileA_stub;
STUB ReplaceFileW_stub;
STUB FindFirstFileExW_stub;
STUB HeapSetInformation_stub;
STUB GetProcessIoCounters_stub;
STUB RtlCaptureStackBackTrace_stub;

View File

@ -26,7 +26,6 @@ UNIMPL_FUNC(CreateHardLinkW, 3);
UNIMPL_FUNC(IsValidLanguageGroup, 2);
UNIMPL_FUNC(ReplaceFileA, 6);
UNIMPL_FUNC(ReplaceFileW, 6);
UNIMPL_FUNC(FindFirstFileExW, 6);
UNIMPL_FUNC(HeapSetInformation, 4);
UNIMPL_FUNC(GetProcessIoCounters, 2);
UNIMPL_FUNC(RtlCaptureStackBackTrace, 4);

View File

@ -442,4 +442,3 @@ int WINAPI lstrcmpiW_new(LPCWSTR str1, LPCWSTR str2)
return ret;
}

View File

@ -32,75 +32,6 @@ ATOM WINAPI AddAtomW_new(LPCWSTR strW)
return AddAtomA(strA);
}
/* something seems to be wrong with this and I don't know what
INT WINAPI CompareStringW_new(LCID lcid, DWORD style,
LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
{
CHAR buf1A[BUFSIZE];
CHAR buf2A[BUFSIZE];
LPSTR str1A, str2A;
INT len1A, len2A, ret;
UINT locale_cp = CP_ACP;
int lasterr;
DBGMSGW((L"CompareStringW(0x%1!x!,0x%2!x!,%3!s!,%4!d!,%5!s!,%6!d!)\n",lcid,style,str1,len1,str2,len2));
lasterr = GetLastError();
if (lcid == LANG_INVARIANT) lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
if (!str1 || !str2)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
if (!(style & LOCALE_USE_CP_ACP))
if (!GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE|LOCALE_RETURN_NUMBER,
(CHAR *)&locale_cp, sizeof(locale_cp)/sizeof(CHAR))) locale_cp = 0;
str1A = buf1A;
if (len1 != 0)
{
len1A = WideCharToMultiByte(locale_cp, 0, str1, len1, buf1A, BUFSIZE, NULL, NULL);
if (!len1A)
{
len1A = WideCharToMultiByte(locale_cp, 0, str1, len1, NULL, 0, NULL, NULL);
str1A = HeapAlloc(GetProcessHeap(), 0, len1A);
if (!str1A)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
WideCharToMultiByte(locale_cp, 0, str1, len1, str1A, len1A, NULL, NULL);
}
}
str2A = buf2A;
if (len2 != 0)
{
len2A = WideCharToMultiByte(locale_cp, 0, str2, len2, buf2A, BUFSIZE, NULL, NULL);
if (!len2A)
{
len2A = WideCharToMultiByte(locale_cp, 0, str2, len2, NULL, 0, NULL, NULL);
str2A = HeapAlloc(GetProcessHeap(), 0, len2A);
if (!str2A)
{
if (str1A != buf1A) HeapFree(GetProcessHeap(), 0, str1A);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
WideCharToMultiByte(locale_cp, 0, str2, len2, str2A, len2A, NULL, NULL);
}
}
SetLastError(lasterr);
ret = CompareStringA(lcid, style, str1A, len1A, str2A, len2A);
if (str1A != buf1A) HeapFree(GetProcessHeap(), 0, str1A);
if (str2A != buf2A) HeapFree(GetProcessHeap(), 0, str2A);
return ret;
}
*/
//MAKE_EXPORT CopyFileExW_new=CopyFileExW
BOOL WINAPI CopyFileExW_new(LPCWSTR lpExistingFileNameW, LPCWSTR lpNewFileNameW, LPPROGRESS_ROUTINE lpProgressRoutine, LPVOID lpData, LPBOOL pbCancel, DWORD dwCopyFlags)
{

View File

@ -234,7 +234,8 @@ static BOOL common_GetVersionEx(WINDOWS_VERSION version, void* buf, BOOL unicode
static DWORD version_compare_values(ULONG left, ULONG right, UCHAR condition)
{
switch (condition) {
switch (condition)
{
case VER_EQUAL:
if (left != right) return ERROR_OLD_WIN_VERSION;
break;

View File

@ -1,6 +1,7 @@
/*
* KernelEx
* Copyright (C) 2008, Xeno86
* Copyright (C) 2010, Tihiy
*
* This file is part of KernelEx source code.
*
@ -28,22 +29,109 @@
#define MAPVK_VSC_TO_VK_EX 3
#define MAPVK_VK_TO_VSC_EX 4
/* Scan codes for standard keyboard */
#define VSC_LSHIFT 0x002A
#define VSC_RSHIFT 0x0036
#define VSC_LALT 0x0038
#define VSC_RALT 0xE038
#define VSC_LCONTROL 0x001D
#define VSC_RCONTROL 0xE01D
/*
From MS keyboard docs:
Under all Microsoft operating systems, all keyboards actually transmit Scan Code Set 2 values down
the wire from the keyboard to the keyboard port. These values are translated to Scan Code Set 1 by
the i8042 port chip.
The rest of the operating system, and all applications that handle scan codes
expect the values to be from Scan Code Set 1.
From other MS docs about USB keyboards:
The mapper driver translates the Keyboard Page HID usages to PS/2 Set 1 scan codes and forwards them
to the keyboard class driver.
Nice link btw: http://www.microsoft.com/taiwan/whdc/archive/w2kbd.mspx
So we have guarantee AT set (Set 1) will be in scancode.
*/
static inline int NoLeftRightVK(int nVirtKey)
{
switch(nVirtKey)
{
case VK_LSHIFT:
case VK_RSHIFT:
nVirtKey = VK_SHIFT;
break;
case VK_LCONTROL:
case VK_RCONTROL:
nVirtKey = VK_CONTROL;
break;
case VK_LMENU:
case VK_RMENU:
nVirtKey = VK_MENU;
break;
}
return nVirtKey;
}
/* MAKE_EXPORT MapVirtualKeyA_new=MapVirtualKeyA */
UINT WINAPI MapVirtualKeyA_new(UINT uCode, UINT uMapType)
{
if (uMapType == MAPVK_VK_TO_VSC_EX)
uMapType = MAPVK_VK_TO_VSC;
else if (uMapType == MAPVK_VSC_TO_VK_EX)
switch(uMapType) {
case MAPVK_VK_TO_VSC_EX:
if ( uCode == VK_RCONTROL ) return VSC_RCONTROL;
if ( uCode == VK_RMENU ) return VSC_RALT;
//fall down
case MAPVK_VK_TO_VSC:
if ( uCode == VK_RSHIFT ) return VSC_RSHIFT; //separate scan code
return MapVirtualKeyA(NoLeftRightVK(uCode),MAPVK_VK_TO_VSC);
case MAPVK_VSC_TO_VK_EX:
switch(uCode) {
case VSC_RSHIFT:
return VK_RSHIFT;
case VSC_LSHIFT:
return VK_LSHIFT;
case VSC_LCONTROL:
return VK_LCONTROL;
case VSC_RCONTROL:
return VK_RCONTROL;
case VSC_LALT:
return VK_LMENU;
case VSC_RALT:
return VK_RMENU;
default:
uMapType = MAPVK_VSC_TO_VK;
return MapVirtualKeyA(uCode, uMapType);
}
}
return MapVirtualKeyA(uCode,uMapType);
}
/* MAKE_EXPORT MapVirtualKeyExA_new=MapVirtualKeyExA */
UINT WINAPI MapVirtualKeyExA_new(UINT uCode, UINT uMapType, HKL dwhkl)
{
if (uMapType == MAPVK_VK_TO_VSC_EX)
uMapType = MAPVK_VK_TO_VSC;
else if (uMapType == MAPVK_VSC_TO_VK_EX)
switch(uMapType) {
case MAPVK_VK_TO_VSC_EX:
if ( uCode == VK_RCONTROL ) return VSC_RCONTROL;
if ( uCode == VK_RMENU ) return VSC_RALT;
//fall down
case MAPVK_VK_TO_VSC:
if ( uCode == VK_RSHIFT ) return VSC_RSHIFT; //separate scan code
return MapVirtualKeyExA(NoLeftRightVK(uCode),MAPVK_VK_TO_VSC,dwhkl);
case MAPVK_VSC_TO_VK_EX:
switch(uCode) {
case VSC_RSHIFT:
return VK_RSHIFT;
case VSC_LSHIFT:
return VK_LSHIFT;
case VSC_LCONTROL:
return VK_LCONTROL;
case VSC_RCONTROL:
return VK_RCONTROL;
case VSC_LALT:
return VK_LMENU;
case VSC_RALT:
return VK_RMENU;
default:
uMapType = MAPVK_VSC_TO_VK;
return MapVirtualKeyExA(uCode, uMapType, dwhkl);
}
}
return MapVirtualKeyExA(uCode,uMapType,dwhkl);
}

View File

@ -20,25 +20,7 @@
*/
#include <windows.h>
#include "k32ord.h"
#include "hwnd9x.h"
static DWORD g_UserBase;
static HTOP_API HWNDtoPWND;
//those are in thunilay
void GrabWin16Lock();
void ReleaseWin16Lock();
#define REBASEUSER(x) ((x) != 0 ? g_UserBase + (DWORD)(x) : 0)
BOOL SetParent_fix_init()
{
g_UserBase = MapSL(LoadLibrary16("user") << 16);
/* IsWindow returns PWND */
HWNDtoPWND = (HTOP_API)IsWindow;
return (g_UserBase != 0 && HWNDtoPWND != 0);
}
#include "thuni_layer.h"
/* returns TRUE if hwnd is a parent of hwndNewParent */
static BOOL WINAPI TestChild(HWND hwnd, HWND hwndNewParent)

View File

@ -44,5 +44,15 @@ BOOL WINAPI SystemParametersInfoA_fix(
ret = TRUE;
}
if (ret && uiAction == SPI_GETCARETWIDTH && pvParam)
{
//there's a bug in USER: default caret width is 0
//(should be 1). although NT can be forced to set
//caret width to 0, it's not sane so we fix this.
DWORD* pCaretWidth = (DWORD*)pvParam;
if (*pCaretWidth == 0)
*pCaretWidth = 1;
}
return ret;
}

View File

@ -38,7 +38,7 @@ BOOL init_user32()
GetMouseMovePoints_pfn = (GetMouseMovePoints_t)kexGetProcAddress(hUser32, "GetMouseMovePoints");
return IsHungThread_pfn && DrawCaptionTempA_pfn && GetMouseMovePoints_pfn
&& InitUniThunkLayer() && SetParent_fix_init();
&& InitUniThunkLayer();
}
/* APIs which don't require Unicode implementations in thuni model

View File

@ -65,17 +65,16 @@ typedef struct _WND
WORD classAtom; // 56h See also offs. 2 in the field 24 struct ptr
} WND, *PWND;
typedef struct _MSGQUEUE
{
WORD nextQueue; // 00h next queue in the list
WORD hTask; // 02h Task that this queue is associated with
WORD headMsg; // 04h Near ptr to head of linked list of QUEUEMSGs
WORD tailMsg; // 06h Near ptr to end of list of QUEUEMSGs
WORD lastMsg; // 08h Near ptr to last msg retrieved (not really!)
WORD cMsgs; // 0Ah Number of messages (not really for win98?)
WORD cMsgs; // 08h Number of posted messages (98,Me)
WORD nilword; // 0Ah ???
BYTE un1; // 0Ch ???
BYTE sig[3]; // 0Dh "MJT" (Jon Thomason?)
BYTE sig[3]; // 0Dh "MJT" (Michael Jackson ..??)
WORD npPerQueue; // 10h 16 bit offset in USER DGROUP to PERQUEUEDATA
// type == LT_USER_VWININFO???
WORD un2; // 12h ???
@ -87,7 +86,9 @@ typedef struct _MSGQUEUE
WORD un4; // 2Ch ??? (seems to always be 0)
WORD lastMsg2; // 2Eh Near ptr to last retrieved QUEUEMSG
DWORD extraInfo; // 30h returned by GetMessageExtraInfo()
DWORD un5[2]; // 34h ???
DWORD un5; // 34h ???
WORD cQuit; // 38h PostQuitMessage
WORD exitCode; // 3Ah same
DWORD threadId; // 3Ch See GetWindowProcessThreadId
WORD un6; // 40h ??
WORD expWinVer; // 42h Version of Windows this app expects
@ -98,7 +99,8 @@ typedef struct _MSGQUEUE
// waiting for
WORD un8; // 4Eh ???
WORD hQueueSend; // 50h App that's in SendMessage to this queue
DWORD un9; // 52h ???
WORD hSMS; // 52h SMS (inter-thread sendmessage) struct ptr
WORD dunno; // 54h ???
WORD sig2; // 56h "HQ"
HKL hkl; // 58h current thread HKL (keyboard layout)
DWORD un10[3]; // 5Ch ??? filler
@ -107,8 +109,38 @@ typedef struct _MSGQUEUE
DWORD un12[3]; // 5Eh+0Ah+4 ??? filler
WORD block2; // 5Eh+1Ah block for SendMessageA (event?)
} MSGQUEUE, *PMSGQUEUE;
typedef struct _PERQUEUEDATA
{
WORD npNext; // 00h a USER heap handle (type == LT_USER_VWININFO)
WORD un2; // 02h
WORD wSumFlags; // 04h
WORD npQMsg; // 06h type == LT_USER_QMSG
WORD un5; // 08h
WORD un6; // 0Ah
WORD un7; // 0Ch
WORD un8; // 0Eh
WORD un9; // 10h
WORD un10; // 12h
WORD somehQueue1; // 14h a msg queue handle
WORD somehQueue2; // 16h a msg queue handle
DWORD hWndCapture; // 18h
DWORD hWndFocus; // 1Ch
DWORD hWndActive; // 20h
BYTE filler[0x34]; // 24h
DWORD keysbuffer; // 58h 16:16 keyboard state ptr
} PERQUEUEDATA, *PPERQUEUEDATA;
typedef struct _QUEUEKEYBUFFER
{
BYTE filler[0x20]; // 00h sth
BYTE keystate[0xFF]; // 20h keys state (0x80-pressed, 0x1-toggled)
} QUEUEKEYBUFFER, *PQUEUEKEYBUFFER;
#pragma pack()
typedef PWND (WINAPI *HTOP_API) (HWND hwnd);
/* IsWindow returns PWND */
#define HWNDtoPWND(hwnd) (PWND)IsWindow(hwnd)
#endif

View File

@ -26,47 +26,6 @@
#include "thuni_macro.h"
#include "thuni_thunk.h"
__declspec(naked)
LRESULT WINAPI CallWindowProc_stdcall( WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
__asm {
push ebp
mov ebp, esp
push edi
push esi
push ebx
sub esp, 12
push [ebp+24]
push [ebp+20]
push [ebp+16]
push [ebp+12]
mov eax, [ebp+8]
call eax
lea esp, [ebp-12]
pop ebx
pop esi
pop edi
leave
ret 20
}
}
int GetCPFromLocale(LCID Locale)
{
int cp;
Locale = LOWORD(Locale);
if (GetLocaleInfoA(Locale,LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,(LPSTR)&cp,sizeof(int)))
return cp;
else
return CP_ACP;
}
static UINT GetCurrentKeyboardCP()
{
return GetCPFromLocale((LCID)GetKeyboardLayout(0));
}
WPARAM wparam_AtoW( HWND hwnd, UINT message, WPARAM wParam, BOOL messDBCS )
{
WPARAM newwParam = wParam;
@ -441,4 +400,3 @@ LRESULT WINAPI CallProcUnicodeWithAnsi( WNDPROC callback, HWND hwnd, UINT msg, W
}
return CallWindowProc_stdcall(callback,hwnd,msg,wParam,lParam);
}

View File

@ -22,45 +22,18 @@
#include <windows.h>
#include <commctrl.h>
#include "k32ord.h"
#include "thuni_thunk.h"
#include "thuni_layer.h"
#include "thuni_macro.h"
static GCQ_API GetCurrentThreadQueue;
static HTOP_API HWNDtoPWND;
static LPCRITICAL_SECTION pWin16Mutex;
static CRITICAL_SECTION wndproc_cs;
static HMODULE g_hUser32;
#define SetWinCreateEvent(proc) SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE, g_hUser32, \
(WINEVENTPROC)(proc), GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT)
BOOL InitUniThunkLayer()
{
g_hUser32 = GetModuleHandleA("user32");
/* Returns current thread hQueue 32-bit pointer */
GetCurrentThreadQueue = (GCQ_API) RELTOABS( (DWORD)GetMessageExtraInfo + 7 );
/* IsWindow returns PWND */
HWNDtoPWND = (HTOP_API)IsWindow;
_GetpWin16Lock( &pWin16Mutex );
InitializeCriticalSection( &wndproc_cs );
MakeCriticalSectionGlobal( &wndproc_cs );
return TRUE;
}
void GrabWin16Lock()
{
_EnterSysLevel(pWin16Mutex);
}
void ReleaseWin16Lock()
{
_LeaveSysLevel(pWin16Mutex);
return InitUniThunkLayerStuff();
}
static WNDPROC WINAPI _GetWindowProc32(PWND pwnd)

View File

@ -1,14 +1,9 @@
#include "k32ord.h"
#include "hwnd9x.h"
static const char c_szDBCSProp[]="kexDBCS";
static DWORD GetWindowProcessId( HWND hwnd )
{
DWORD procID = 0;
GetWindowThreadProcessId( hwnd, &procID );
return procID;
}
#define REBASEUSER(x) ((x) != 0 ? g_UserBase + (DWORD)(x) : 0)
#define ISOURPROCESSHWND(hwnd) ( GetWindowProcessId(hwnd) == GetCurrentProcessId() )
#define IS_SHARED(x) (((DWORD)x) & 0x80000000)
@ -20,29 +15,41 @@ static DWORD GetWindowProcessId( HWND hwnd )
#define IS32BITWIN(pwnd) (pwnd->dwFlags & WF_EX_WIN32)
#define ISDIALOG(pwnd) (pwnd->moreFlags & WF_M_DIALOG)
typedef PMSGQUEUE (WINAPI *GCQ_API) ();
#define RELTOABS(x) ( (DWORD)(x) + *(DWORD*)(x) + 4 )
int GetCPFromLocale(LCID Locale);
#define SetWinCreateEvent(proc) SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE, g_hUser32, \
(WINEVENTPROC)(proc), GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT)
//stuff
extern DWORD g_UserBase;
extern HMODULE g_hUser32;
BOOL InitUniThunkLayerStuff();
void GrabWin16Lock();
void ReleaseWin16Lock();
DWORD GetWindowProcessId( HWND hwnd );
LRESULT WINAPI CallWindowProc_stdcall( WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
int GetCPFromLocale(LCID Locale);
UINT GetCurrentKeyboardCP();
PMSGQUEUE GetCurrentThreadQueue();
void UpdateLRKeyState(LPMSG msg);
//conv
WPARAM wparam_AtoW( HWND hwnd, UINT message, WPARAM wParam, BOOL messDBCS );
WPARAM wparam_WtoA( UINT message, WPARAM wParam );
LRESULT WINAPI CallProcUnicodeWithAnsi( WNDPROC callback, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT WINAPI CallProcAnsiWithUnicode( WNDPROC callback, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
//proc
LRESULT WINAPI DefWindowProcW_NEW( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
LRESULT WINAPI DefDlgProcW_NEW( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
LRESULT WINAPI DefMDIChildProcW_NEW( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
//layer
BOOL IsWindowReallyUnicode(HWND hwnd);
BOOL WINAPI IsWindowUnicode_NEW( HWND hWnd );
BOOL InitUniThunkLayer();
//sendmessage_fix
LRESULT WINAPI SendMessageA_fix(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
BOOL InitUniThunkLayer();
#ifdef __cplusplus
extern "C"

View File

@ -1,7 +1,7 @@
/*
* KernelEx
*
* Copyright (C) 2009, Tihiy
* Copyright (C) 2009-2010, Tihiy
*
* This file is part of KernelEx source code.
*
@ -119,7 +119,10 @@ BOOL WINAPI GetMessageA_NEW( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wM
if ( !lpMsg ) return -1; //9x fails to check that
ret = GetMessageA( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax );
if ( ret && ((lpMsg->message>=WM_KEYFIRST && lpMsg->message<=WM_KEYLAST)||(lpMsg->message>=WM_MOUSEFIRST && lpMsg->message<=WM_MOUSELAST)) )
{
g_LastInputTime = GetTickCount();
UpdateLRKeyState(lpMsg);
}
return ret;
}
@ -130,7 +133,10 @@ BOOL WINAPI PeekMessageA_NEW( LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT w
if ( !lpMsg ) return FALSE; //9x fails to check that
ret = PeekMessageA( lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg );
if ( ret && ((lpMsg->message>=WM_KEYFIRST && lpMsg->message<=WM_KEYLAST)||(lpMsg->message>=WM_MOUSEFIRST && lpMsg->message<=WM_MOUSELAST)) )
{
g_LastInputTime = GetTickCount();
UpdateLRKeyState(lpMsg);
}
return ret;
}

View File

@ -0,0 +1,165 @@
/*
* KernelEx
*
* Copyright (C) 2010, Tihiy
*
* 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.
*
*/
/* various thuni routines here */
#include <windows.h>
#include "thuni_layer.h"
static LPCRITICAL_SECTION pWin16Mutex;
DWORD g_UserBase;
HMODULE g_hUser32;
BOOL InitUniThunkLayerStuff()
{
_GetpWin16Lock( &pWin16Mutex );
g_UserBase = MapSL(LoadLibrary16("user") << 16);
g_hUser32 = GetModuleHandleA("user32");
return (g_UserBase && g_hUser32);
}
void GrabWin16Lock()
{
_EnterSysLevel(pWin16Mutex);
}
void ReleaseWin16Lock()
{
_LeaveSysLevel(pWin16Mutex);
}
DWORD GetWindowProcessId( HWND hwnd )
{
DWORD procID = 0;
GetWindowThreadProcessId( hwnd, &procID );
return procID;
}
__declspec(naked)
LRESULT WINAPI CallWindowProc_stdcall( WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
__asm {
push ebp
mov ebp, esp
push edi
push esi
push ebx
sub esp, 12
push [ebp+24]
push [ebp+20]
push [ebp+16]
push [ebp+12]
mov eax, [ebp+8]
call eax
lea esp, [ebp-12]
pop ebx
pop esi
pop edi
leave
ret 20
}
}
int GetCPFromLocale(LCID Locale)
{
int cp;
Locale = LOWORD(Locale);
if (GetLocaleInfoA(Locale,LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,(LPSTR)&cp,sizeof(int)))
return cp;
else
return CP_ACP;
}
UINT GetCurrentKeyboardCP()
{
return GetCPFromLocale((LCID)GetKeyboardLayout(0));
}
#pragma warning (disable:4035)
static inline
WORD GetCurrentThreadhQueue()
{
__asm mov ax, fs:[28h]
}
#pragma warning (default:4035)
PMSGQUEUE GetCurrentThreadQueue()
{
return (PMSGQUEUE)MapSL( GetCurrentThreadhQueue() << 16 );
}
//per-thread keyboard state
static PQUEUEKEYBUFFER GetCurrentThreadKeyBuffer()
{
PMSGQUEUE msgq = GetCurrentThreadQueue();
if (!msgq) return NULL;
PPERQUEUEDATA queuedata = (PPERQUEUEDATA)REBASEUSER(msgq->npPerQueue);
if (!queuedata) return NULL;
return (PQUEUEKEYBUFFER)MapSL(queuedata->keysbuffer);
}
void UpdateLRKeyState(LPMSG msg)
{
switch(msg->message) {
case WM_KEYDOWN:
case WM_KEYUP:
case WM_SYSKEYDOWN:
case WM_SYSKEYUP:
if (msg->wParam == VK_SHIFT)
{
PQUEUEKEYBUFFER keybuffer = GetCurrentThreadKeyBuffer();
if (keybuffer)
{
BYTE scancode = LOBYTE(HIWORD(msg->lParam));
if ( scancode == MapVirtualKey(VK_SHIFT,0) ) //left shift
keybuffer->keystate[VK_LSHIFT] = keybuffer->keystate[VK_SHIFT];
else
keybuffer->keystate[VK_RSHIFT] = keybuffer->keystate[VK_SHIFT];
}
}
else if (msg->wParam == VK_CONTROL)
{
PQUEUEKEYBUFFER keybuffer = GetCurrentThreadKeyBuffer();
if (keybuffer)
{
if ( msg->lParam & 0x1000000 ) //extended bit -> right
keybuffer->keystate[VK_RCONTROL] = keybuffer->keystate[VK_CONTROL];
else
keybuffer->keystate[VK_LCONTROL] = keybuffer->keystate[VK_CONTROL];
}
}
else if (msg->wParam == VK_MENU)
{
PQUEUEKEYBUFFER keybuffer = GetCurrentThreadKeyBuffer();
if (keybuffer)
{
if ( msg->lParam & 0x1000000 ) //extended bit -> right
keybuffer->keystate[VK_RMENU] = keybuffer->keystate[VK_MENU];
else
keybuffer->keystate[VK_LMENU] = keybuffer->keystate[VK_MENU];
}
}
break;
}
}

View File

@ -58,15 +58,15 @@ int WINAPI StrCmpNIW(LPCWSTR lpStr1,LPCWSTR lpStr2,int nChar)
static CC361 StrCmpNIW_dld;
if (!StrCmpNIW_dld)
StrCmpNIW_dld = (CC361)kexGetProcAddress(GetModuleHandle("COMCTL32.DLL"),(LPSTR)361);
StrCmpNIW_dld = (CC361) kexGetProcAddress(GetModuleHandle("COMCTL32.DLL"),(LPSTR)361);
return StrCmpNIW_dld(lpStr1,lpStr2,nChar);
}
BOOL WINAPI GetTextExtentExPointW_lame( HDC hdc, LPCWSTR lpszStr, int cchString, int nMaxExtent,
BOOL WINAPI GetTextExtentExPointW_lame (HDC hdc, LPCWSTR lpszStr, int cchString, int nMaxExtent,
LPINT lpnFit, LPINT alpDx, LPSIZE lpSize)
{
if ( GetTextExtentPointW(hdc,lpszStr,cchString,lpSize) )
if (GetTextExtentPointW(hdc,lpszStr,cchString,lpSize))
{
if (lpnFit)
{

View File

@ -137,6 +137,10 @@ SOURCE=.\Kernel32\FileApis_fix.c
# End Source File
# Begin Source File
SOURCE=.\Kernel32\FindFirstFileEx.c
# End Source File
# Begin Source File
SOURCE=.\Kernel32\GetConsoleWindow.c
# End Source File
# Begin Source File
@ -317,10 +321,6 @@ SOURCE=.\User32\GetNextDlgTabItem_fix.c
# End Source File
# Begin Source File
SOURCE=.\User32\hwnd9x.h
# End Source File
# Begin Source File
SOURCE=.\User32\IsHungAppWindow.c
# End Source File
# Begin Source File
@ -377,6 +377,10 @@ SOURCE=.\User32\thuni_proc.c
# End Source File
# Begin Source File
SOURCE=.\User32\thuni_stuff.c
# End Source File
# Begin Source File
SOURCE=.\User32\thuni_thunk.c
# End Source File
# Begin Source File
@ -409,6 +413,10 @@ SOURCE=.\Gdi32\_gdi32_stubs.c
# End Source File
# Begin Source File
SOURCE=.\Gdi32\EnumFont.c
# End Source File
# Begin Source File
SOURCE=.\Gdi32\FontResourceEx.c
# End Source File
# Begin Source File
@ -668,6 +676,10 @@ SOURCE=..\..\common\common.h
# End Source File
# Begin Source File
SOURCE=.\User32\hwnd9x.h
# End Source File
# Begin Source File
SOURCE=..\..\common\k32ord.def
# PROP Exclude_From_Build 1
# End Source File

View File

@ -43,6 +43,11 @@ REGEDIT4
;-Office 2007
"*\\OFFICE12\\MSO.DLL"="NT2K"
"*\\OFFICE12\\WORDCONV.EXE"="NT2K"
;-Google Earth setup
"%TEMP%\\GTAPI.DLL"="NT2K"
;-Windows Installer
"%WINDIR%\\SYSTEM\\MSI.DLL"="DCFG1"
"%WINDIR%\\SYSTEM\\MSIEXEC.EXE"="DCFG1"
[HKEY_LOCAL_MACHINE\Software\KernelEx\AppSettings\Flags]
;DISABLE KERNELEX FOR:

View File

@ -44,7 +44,8 @@ int WINAPI CommonUnimpStub(void);
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason) {
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
OSVERSIONINFO osv;

View File

@ -71,7 +71,8 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
switch (fdwReason) {
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
OSVERSIONINFO osv;
@ -90,7 +91,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
}
return TRUE;
}
}
/************************************************************
* WTSCloseServer (WTSAPI32.@)
@ -277,8 +278,12 @@ BOOL WINAPI WTSQuerySessionInformationW(
/************************************************************
* WTSQueryUserConfigA (WTSAPI32.@)
*/
BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName,
WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer, DWORD* pBytesReturned)
BOOL WINAPI WTSQueryUserConfigA(
LPSTR pServerName,
LPSTR pUserName,
WTS_CONFIG_CLASS WTSConfigClass,
LPSTR* ppBuffer,
DWORD* pBytesReturned)
{
FIXME("Stub %s %s 0x%08lx %p %p\n", debugstr_a(pServerName), debugstr_a(pUserName),
WTSConfigClass, ppBuffer, pBytesReturned);
@ -288,8 +293,12 @@ BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName,
/************************************************************
* WTSQueryUserConfigW (WTSAPI32.@)
*/
BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName,
WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, DWORD* pBytesReturned)
BOOL WINAPI WTSQueryUserConfigW(
LPWSTR pServerName,
LPWSTR pUserName,
WTS_CONFIG_CLASS WTSConfigClass,
LPWSTR* ppBuffer,
DWORD* pBytesReturned)
{
FIXME("Stub %s %s 0x%08lx %p %p\n", debugstr_w(pServerName), debugstr_w(pUserName),
WTSConfigClass, ppBuffer, pBytesReturned);

View File

@ -22,9 +22,9 @@
#ifndef __VERSION_H
#define __VERSION_H
#define VERSION_STR "4.5 RC 5"
#define VERSION_CODE 0x0405000F
#define RCVERSION 4, 5, 1, 5
#define _RCVERSION_ "4, 5, 1, 5"
#define VERSION_STR "4.5 Final"
#define VERSION_CODE 0x04050065
#define RCVERSION 4, 5, 10, 1
#define _RCVERSION_ "4, 5, 10, 1"
#endif

View File

@ -23,6 +23,7 @@
#include <stdio.h>
#include <malloc.h>
#include "debug.h"
#include "SettingsDB.h"
#include "internals.h"
#include "resolver.h"
#include "apiconfmgr.h"
@ -174,6 +175,9 @@ __error:
DBGPRINTF(("Default api configuration is: %s\n", default_apiconf->get_name()));
DBGPRINTF(("API extensions are by default: %s\n",
disable_extensions ? "disabled" : "enabled"));
SettingsDB::instance.flush_all();
return true;
}

View File

@ -72,6 +72,24 @@ void ShowError(UINT id, ...)
MessageBox(NULL, out, "KernelEx Core", MB_OK | MB_ICONERROR);
}
bool rerun_setup()
{
char cmd[MAX_PATH];
STARTUPINFO si;
PROCESS_INFORMATION pi;
strcpy(cmd, "\"");
strcat(cmd, kernelex_dir);
strcat(cmd, "setupkex.exe\" /R");
GetStartupInfo(&si);
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
return false;
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
return true;
}
DWORD* find_unique_pattern(void* start, int size, const short* pattern, int pat_len, const char* pat_name)
{
unsigned char* pos = (unsigned char*) start;

View File

@ -44,6 +44,7 @@ extern sstring kernelex_dir;
extern sstring own_path;
void ShowError(UINT id, ...);
bool rerun_setup();
bool isWinMe();
typedef MODREF* (__stdcall *MRFromHLib_t)(HMODULE);

View File

@ -1,6 +1,6 @@
/*
* KernelEx
* Copyright (C) 2008-2009, Xeno86
* Copyright (C) 2008-2010, Xeno86
*
* This file is part of KernelEx source code.
*
@ -53,12 +53,12 @@ int kexInit()
if (!internals_init())
goto __error1;
if (!apiconfmgr.load_api_configurations())
goto __error2;
if (!resolver_init())
goto __error2;
if (!apiconfmgr.load_api_configurations())
goto __error3;
resolver_hook();
#ifdef _DEBUG
@ -68,6 +68,8 @@ int kexInit()
DBGPRINTF(("Initialized successfully\n"));
return ++init_count;
__error3:
resolver_uninit();
__error2:
internals_uninit();
__error1:

View File

@ -879,6 +879,7 @@ int resolver_init()
if (!dseg)
{
DBGPRINTF(("Signature not found\n"));
if (!rerun_setup())
ShowError(IDS_NOTREADY);
return 0;
}
@ -889,6 +890,7 @@ int resolver_init()
{
DBGPRINTF(("Wrong stub version, expected: %d, got: %d\n",
KEX_STUB_VER, dseg->version));
if (!rerun_setup())
ShowError(IDS_STUBMISMATCH, KEX_STUB_VER, dseg->version);
return 0;
}
@ -899,8 +901,6 @@ int resolver_init()
system_path_len = GetSystemDirectory(system_path, sizeof(system_path));
RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\KernelEx\\KnownDLLs", &known_dlls_key);
SettingsDB::instance.flush_all();
return 1;
}

View File

@ -24,7 +24,7 @@
#define KEX_SIGNATURE "KrnlEx"
/* Update this whenever patching functions are changed. */
#define KEX_STUB_VER 9
#define KEX_STUB_VER 10
#define JTAB_SIZE 8
#define JTAB_EFO_DYN 0

577
setup/patch.cpp Executable file
View File

@ -0,0 +1,577 @@
/*
* KernelEx
* Copyright (C) 2010, 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 <cassert>
#include "patch.h"
#include "debug.h"
#include "loadstub.h"
#include "pemanip.h"
#include "resource.h"
#define CODE_SEG ".text"
#define DATA_SEG ".data"
#define INIT_SEG "_INIT"
void ShowError(UINT id, ...);
Patch::Patch(PEmanip& pem) : pefile(pem)
{
}
void Patch::apply()
{
find_ExportFromX();
find_IsKnownDLL();
find_FLoadTreeNotify1();
find_FLoadTreeNotify2();
prepare_subsystem_check();
find_resource_check1();
find_resource_check2();
disable_named_and_rcdata_resources_mirroring();
mod_imte_alloc();
mod_mr_alloc();
mod_pdb_alloc();
KernelEx_codeseg* cseg;
KernelEx_dataseg* dseg;
if (!pefile.AllocSectionSpace(CODE_SEG,
sizeof(KernelEx_codeseg), (void**) &cseg, sizeof(DWORD)))
ShowError(IDS_FAILSEC, CODE_SEG);
if (!pefile.AllocSectionSpace(DATA_SEG,
sizeof(KernelEx_dataseg), (void**) &dseg, sizeof(DWORD)))
ShowError(IDS_FAILSEC, DATA_SEG);
memcpy(cseg->signature, "KrnlEx", 6);
cseg->version = KEX_STUB_VER;
for (int i = 0 ; i < JTAB_SIZE ; i++)
{
cseg->jmp_stub[i].opcode = 0x25ff;
cseg->jmp_stub[i].addr = (DWORD)
pefile.PointerToRva(&dseg->jtab[i]) + pefile.GetImageBase();
cseg->jmp_stub[i].nop = 0x9090;
}
memcpy(dseg->signature, "KrnlEx", 6);
dseg->version = KEX_STUB_VER;
dseg->jtab[JTAB_EFO_DYN] = _ExportFromOrdinal + pefile.GetImageBase();
dseg->jtab[JTAB_EFO_STA] = _ExportFromOrdinal + pefile.GetImageBase();
dseg->jtab[JTAB_EFN_DYN] = _ExportFromName + pefile.GetImageBase();
dseg->jtab[JTAB_EFN_STA] = _ExportFromName + pefile.GetImageBase();
dseg->jtab[JTAB_KNO_DLL] = _IsKnownDLL + pefile.GetImageBase();
dseg->jtab[JTAB_FLD_TRN] = _FLoadTreeNotify + pefile.GetImageBase();
dseg->jtab[JTAB_SYS_CHK] = _SubsysCheckPerform + pefile.GetImageBase();
dseg->jtab[JTAB_RES_CHK] = _GetOrdinal + pefile.GetImageBase();
//exportfromx patch
DWORD code = (DWORD) pefile.GetSectionByName(CODE_SEG);
int code_size = pefile.GetSectionSize(CODE_SEG);
int efo_cnt = 0;
int efn_cnt = 0;
for (DWORD a = code ; a < code + code_size ; a++)
{
if (is_call_ref(a, _ExportFromOrdinal))
{
DWORD file_loc = a;
if (a == EFN_EFO_call)
continue;
if (a == gpa_ExportFromOrdinal_call)
set_call_ref(file_loc, (DWORD) &cseg->jmp_stub[JTAB_EFO_DYN]);
else
set_call_ref(file_loc, (DWORD) &cseg->jmp_stub[JTAB_EFO_STA]);
DBGPRINTF(("%s: address 0x%08x\n", "EFO", pefile.PointerToRva((void*) a)
+ pefile.GetImageBase()));
efo_cnt++;
}
else if (is_call_ref(a, _ExportFromName))
{
DWORD file_loc = a;
if (is_fixupc(a))
continue;
if (a == gpa_ExportFromName_call)
set_call_ref(file_loc, (DWORD) &cseg->jmp_stub[JTAB_EFN_DYN]);
else
set_call_ref(file_loc, (DWORD) &cseg->jmp_stub[JTAB_EFN_STA]);
DBGPRINTF(("%s: address 0x%08x\n", "EFN", pefile.PointerToRva((void*) a)
+ pefile.GetImageBase()));
efn_cnt++;
}
}
if (efo_cnt != 2 || efn_cnt != 2)
ShowError(IDS_ERRCHECK);
//isknowndll patch
set_call_ref(IsKnownDLL_call, (DWORD) &cseg->jmp_stub[JTAB_KNO_DLL]);
DBGPRINTF(("%s: address 0x%08x\n", "KNO_DLL", pefile.PointerToRva((void*) IsKnownDLL_call)
+ pefile.GetImageBase()));
//FLoadTreeNotify patch
set_call_ref(FLoadTreeNotify_call1, (DWORD) &cseg->jmp_stub[JTAB_FLD_TRN]);
DBGPRINTF(("%s: address 0x%08x\n", "FLD_TRN1", pefile.PointerToRva((void*) FLoadTreeNotify_call1)
+ pefile.GetImageBase()));
set_call_ref(FLoadTreeNotify_call2, (DWORD) &cseg->jmp_stub[JTAB_FLD_TRN]);
DBGPRINTF(("%s: address 0x%08x\n", "FLD_TRN2", pefile.PointerToRva((void*) FLoadTreeNotify_call2)
+ pefile.GetImageBase()));
//subsys check patch
set_jmp_ref(SubsysCheck_jmp, (DWORD) &cseg->jmp_stub[JTAB_SYS_CHK]);
DBGPRINTF(("%s: address 0x%08x\n", "SYS_CHK", pefile.PointerToRva((void*) SubsysCheck_jmp)
+ pefile.GetImageBase()));
//resource check patch
set_call_ref(GetOrdinal_call1, (DWORD) &cseg->jmp_stub[JTAB_RES_CHK]);
DBGPRINTF(("%s: address 0x%08x\n", "RES_CHK1", pefile.PointerToRva((void*) GetOrdinal_call1)
+ pefile.GetImageBase()));
set_call_ref(GetOrdinal_call2, (DWORD) &cseg->jmp_stub[JTAB_RES_CHK]);
DBGPRINTF(("%s: address 0x%08x\n", "RES_CHK2", pefile.PointerToRva((void*) GetOrdinal_call2)
+ pefile.GetImageBase()));
}
int Patch::find_pattern(DWORD offset, int size, const short* pattern,
int pat_len, DWORD* found_loc)
{
DWORD end_offset = offset + size - pat_len;
int found = 0;
for (DWORD i = offset ; i <= end_offset ; i++)
{
if (pattern[0] < 0 || *(unsigned char*)i == pattern[0])
{
int j;
for (j = 1 ; j < pat_len ; j++)
{
if (pattern[j] >= 0 && *(unsigned char*)(i + j) != pattern[j])
break;
}
if (j == pat_len) //pattern found
{
*found_loc = i;
found++;
}
}
}
return found;
}
void Patch::set_pattern(DWORD loc, const short* new_pattern, int pat_len)
{
unsigned char* offset = (unsigned char*) loc;
const short* pat_ptr = new_pattern;
while (pat_len--)
{
if (*pat_ptr != -1)
*offset = *pat_ptr & 0xff;
offset++;
pat_ptr++;
}
}
void Patch::prepare_subsystem_check()
{
static const short pattern[] = {
0x66,0x8b,0x46,0x48,0x66,0x3d,0x04,0x00,0x0f,0x87,0x9c,0x01,0x00,0x00,
0x75,0x0b,0x66,0x83,0x7e,0x4a,0x0a,0x0f,0x87,0x8f,0x01,0x00,0x00,0x66,
0x81,0x7e,0x04,0x4c,0x01,
};
static const short after[] = {
0x66,0x83,0x7E,0x48,0x04,0x75,0x05,0x66,0x83,0x7E,0x4A,0x0A,0xE9,0x00,
0x00,0x00,0x00,0x0F,0x87,0x93,0x01,0x00,0x00,0x90,0x90,0x90,0x90,0x66,
0x81,0x7e,0x04,0x4c,0x01,
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "subsystem_check");
else ShowError(IDS_MULPAT, "subsystem_check");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "subsystem_check",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
SubsysCheck_jmp = found_loc + 12;
_SubsysCheckPerform = decode_jmp(SubsysCheck_jmp, 5);
}
void Patch::find_resource_check1()
{
static const short pattern[] = {
0x6A,0x00,0x8D,0x45,0xE0,0x50,0xFF,0x75,0xA4,0xFF,0x75,0xD0,0x8D,0x45,
0xCC,0x50,0xFF,0x75,0x08,0xE8,-2,-2,-2,-2,0x85,0xC0
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "resource_check1");
else ShowError(IDS_MULPAT, "resource_check1");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "resource_check1",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
GetOrdinal_call1 = found_loc + 19;
_GetOrdinal = decode_call(GetOrdinal_call1, 5);
}
void Patch::find_resource_check2()
{
static const short pattern[] = {
0x66,0x8B,0x45,0xE0,0x66,0x2D,0x06,0x80,0x66,0x3D,0x01,0x00,0x1B,0xC0,
0xF7,0xD8,0x50,0x8D,0x45,0xDE,0x50,0xFF,0x75, -1,0xFF,0x75,0xD0,0x8D,
0x45,0xCC,0x50,0xFF,0x75,0x08,0xE8, -2, -2, -2, -2,0x85,0xC0
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "resource_check2");
else ShowError(IDS_MULPAT, "resource_check2");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "resource_check2",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
GetOrdinal_call2 = found_loc + 34;
}
//no named/rcdata resource types mirroring
void Patch::disable_named_and_rcdata_resources_mirroring()
{
static const short pattern[] = {
0x66,0x8B,0x40,0x0E,0x66,0x89,0x45,0xDA,0x8B,0x45, -1,0x66,0x8B,0x48,
0x0C,0x66,0x89,0x4D,0xD8,0x66,0x8B,0x45,0xE0,0x8B,0x4D,0xD4,0x66,0x89,
0x01,0x83,0x45,0xD4,0x02,0x66,0x8B,0x45,0xDA,0x66,0x03,0x45,0xD8,0x66,
0x89,0x45,0x8C,0x8B,0x4D,0xD4,0x66,0x89,0x01,0x83,0x45,0xD4,0x02
};
static const short after[] = {
0x66,0x8B,0x48,0x0E,0x66,0x03,0x48,0x0C,0x66,0x89,0x4D,0x8C,0x8B,0x45,
0xA4,0x83,0x38,0x0A,0x74,0x40,0x83,0x38,0x00,0x79,0x04,0x3B,0xC0,0xEB,
0x37,0x66,0x8B,0x45,0xE0,0x8B,0x4D,0xD4,0x66,0x89,0x01,0x83,0xC1,0x02,
0x66,0x8B,0x45,0x8C,0x66,0x89,0x01,0x83,0xC1,0x02,0x89,0x4D,0xD4
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "disable_named_and_rcdata_resources_mirroring");
else ShowError(IDS_MULPAT, "disable_named_and_rcdata_resources_mirroring");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "disable_named_and_rcdata_resources_mirroring",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
}
void Patch::mod_imte_alloc()
{
//VA BFF8745C, RVA 1745C, file 15A5C, sec E45C
static const short pattern[] = {
0x66,0xff,0x05,-1,-1,-1,0xbf,0x6a,0x3c,0xe8,
};
static const short after[] = {
0x66,0xff,0x05,-1,-1,-1,0xbf,0x6a,0x40,0xe8,
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "mod_imte_alloc");
else ShowError(IDS_MULPAT, "mod_imte_alloc");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "mod_imte_alloc",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
}
void Patch::mod_mr_alloc()
{
static const short pattern[] = {
0x75,0xF6,0x8D,0x04,-1,0x1C,0x00,0x00,0x00,0x50
};
static const short after[] = {
0x75,0xF6,0x8D,0x04,-1,0x24,0x00,0x00,0x00,0x50
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "mod_mr_alloc");
else ShowError(IDS_MULPAT, "mod_mr_alloc");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "mod_mr_alloc",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
}
void Patch::mod_pdb_alloc()
{
static const short pattern[] = {
0x53,0x56,0x57,0x6A,0x06,0x68,0xC4,0x00,0x00,0x00,0xE8
};
static const short after[] = {
0x53,0x56,0x57,0x6A,0x06,0x68,0xC8,0x00,0x00,0x00,0xE8
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "mod_pdb_alloc");
else ShowError(IDS_MULPAT, "mod_pdb_alloc");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "mod_pdb_alloc",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
}
void Patch::find_ExportFromX()
{
static const short pattern[] = {
0x8B,0x0D,-1,-1,-1,-1,0x0F,0xBF,0x40,0x10,0x8B,0x14,0x81,0x8B,0x44,
0x24,0x14,0x3D,0x00,0x00,0x01,0x00,0x8B,0x4A,0x04,0x73,0x15,-1,0x1D,
-1,-1,-1,-1,0x75,0x04,0x6A,0x32,0xEB,0x3E,0x50,0x51,0xE8,-2,-2,-2,-2,
0xEB,0x0C,0xFF,0x74,0x24,0x14,0x6A,0x00,0x51,0xE8,-2,-2,-2,-2,0x83,
0x7F,0x54,0x00,0x8B,0xF0
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "exportfromX");
else ShowError(IDS_MULPAT, "exportfromX");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "exportfromX",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
gpa_ExportFromOrdinal_call = found_loc + 0x29;
gpa_ExportFromName_call = found_loc + 0x37;
_ExportFromOrdinal = decode_call(gpa_ExportFromOrdinal_call, 5);
_ExportFromName = decode_call(gpa_ExportFromName_call, 5);
DWORD start = (DWORD) pefile.RvaToPointer(_ExportFromName);
for (DWORD a = start ; a < start + 0x100 ; a++)
if (is_call_ref(a, _ExportFromOrdinal))
EFN_EFO_call = a;
}
void Patch::find_IsKnownDLL()
{
static const short pattern[] = {
0xFF,0x75,0xFC,0x8D,0x8D,0xF0,0xFE,0xFF,0xFF,0x51,0xE8,-2,-2,-2,-2,
0x85,0xC0,0x75,0x1E,0x8D,0x85,0xE8,0xFD,0xFF,0xFF,
0x8D,0x8D,0xF0,0xFE,0xFF,0xFF,0x50,0x51
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "IsKnownDLL");
else ShowError(IDS_MULPAT, "IsKnownDLL");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "IsKnownDLL",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
IsKnownDLL_call = found_loc + 10;
_IsKnownDLL = decode_call(IsKnownDLL_call, 5);
}
void Patch::find_FLoadTreeNotify1()
{
static const short pattern[] = {
0x56,0xA1,-1,-1,-1,-1,0x6A,0x01,0x8B,0x08,0xFF,0xB1,0x98,0x00,0x00,
0x00,0xE8,-2,-2,-2,-2,0x83,0xF8,0x01,0x1B,0xF6,0xF7,0xDE
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "FLoadTreeNotify1");
else ShowError(IDS_MULPAT, "FLoadTreeNotify1");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "FLoadTreeNotify1",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
FLoadTreeNotify_call1 = found_loc + 16;
_FLoadTreeNotify = decode_call(FLoadTreeNotify_call1, 5);
}
void Patch::find_FLoadTreeNotify2()
{
static const short pattern[] = {
0x6A,0x00,0x57,0xE8,-1,-1,-1,-1,0x6A,0x00,0x56,0xE8,-2,-2,-2,-2,
0x85,0xC0,0x74,0x12,0x56,0xE8,-1,-1,-1,-1,0x68,0x5A,0x04,0x00,0x00,
0x33,0xF6,0xE8,-1,-1,-1,-1
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "FLoadTreeNotify2");
else ShowError(IDS_MULPAT, "FLoadTreeNotify2");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "FLoadTreeNotify2",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
FLoadTreeNotify_call2 = found_loc + 11;
}
DWORD Patch::decode_call(DWORD addr, int len)
{
unsigned char* code = (unsigned char*)addr;
/* CALL rel32 */
if (code[0] == 0xe8)
{
if (len && len == 5 || !len)
return (DWORD)(pefile.PointerToRva(code) + 5 + *(INT32*)(code + 1));
}
/* CALL imm32 */
else if (code[0] == 0xff && code[1] == 0x15)
{
if (len && len == 6 || !len)
return *(DWORD*)(code + 2);
}
/* unmatched */
return 0;
}
DWORD Patch::decode_jmp(DWORD addr, int len)
{
unsigned char* code = (unsigned char*)addr;
/* JMP rel8 */
if (code[0] == 0xeb)
{
if (len && len == 2 || !len)
return (DWORD)(pefile.PointerToRva(code) + 2 + *(INT8*)(code + 1));
}
/* JMP rel32 */
else if (code[0] == 0xe9)
{
if (len && len == 5 || !len)
return (DWORD)(pefile.PointerToRva(code) + 5 + *(INT32*)(code + 1));
}
/* JMP imm32 */
else if (code[0] == 0xff && code[1] == 0x25)
{
if (len && len == 6 || !len)
return *(DWORD*)(code + 2);
}
/* Jxx rel8 */
else if (code[0] >= 0x70 && code[0] < 0x7f || code[0] == 0xe3)
{
if (len && len == 2 || !len)
return (DWORD)(pefile.PointerToRva(code) + 2 + *(INT8*)(code + 1));
}
/* Jxx rel32 */
else if (code[0] == 0x0f && code[1] >= 0x80 && code[1] <= 0x8f)
{
if (len && len == 6 || !len)
return (DWORD)(pefile.PointerToRva(code) + 6 + *(INT32*)(code + 2));
}
/* unmatched */
return 0;
}
bool Patch::is_call_ref(DWORD loc, DWORD target)
{
DWORD addr = decode_call(loc, 5); // size of call imm32 opcode
if (addr == target)
return true;
return false;
}
// Both addresses have to be from the same section!
void Patch::set_call_ref(DWORD loc, DWORD target)
{
DWORD rel;
assert(*(BYTE*) loc == 0xe8);
rel = target - (loc + 5);
*(DWORD*)(loc + 1) = rel;
}
// Both addresses have to be from the same section!
void Patch::set_jmp_ref(DWORD loc, DWORD target)
{
DWORD rel;
unsigned char* code = (unsigned char*)loc;
if (code[0] == 0xe9)
{
rel = target - (loc + 5);
*(DWORD*)(loc + 1) = rel;
}
else if (code[0] == 0x0f && code[1] >= 0x80 && code[1] <= 0x8f)
{
rel = target - (loc + 6);
*(DWORD*)(loc + 2) = rel;
}
else assert(false);
}
bool Patch::is_fixupc(DWORD addr)
{
if (*(DWORD*)(addr - 5) == 0xDAC)
return true;
return false;
}

72
setup/patch.h Executable file
View File

@ -0,0 +1,72 @@
/*
* KernelEx
* Copyright (C) 2010, 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 __PATCH_H
#define __PATCH_H
class PEmanip;
class Patch
{
public:
Patch(PEmanip& pem);
void apply();
private:
int find_pattern(DWORD offset, int size, const short* pattern, int pat_len, DWORD* found_loc);
void set_pattern(DWORD loc, const short* new_pattern, int pat_len);
void prepare_subsystem_check();
void find_resource_check1();
void find_resource_check2();
void disable_named_and_rcdata_resources_mirroring();
void mod_imte_alloc();
void mod_mr_alloc();
void mod_pdb_alloc();
void find_ExportFromX();
void find_IsKnownDLL();
void find_FLoadTreeNotify1();
void find_FLoadTreeNotify2();
DWORD decode_call(DWORD addr, int len = 0);
DWORD decode_jmp(DWORD addr, int len = 0);
bool is_call_ref(DWORD loc, DWORD target);
void set_call_ref(DWORD loc, DWORD target);
void set_jmp_ref(DWORD loc, DWORD target);
bool is_fixupc(DWORD addr);
PEmanip& pefile;
DWORD _GetOrdinal;
DWORD _ExportFromOrdinal;
DWORD _ExportFromName;
DWORD _IsKnownDLL;
DWORD _FLoadTreeNotify;
DWORD _SubsysCheckPerform;
DWORD GetOrdinal_call1;
DWORD GetOrdinal_call2;
DWORD gpa_ExportFromOrdinal_call;
DWORD gpa_ExportFromName_call;
DWORD EFN_EFO_call;
DWORD IsKnownDLL_call;
DWORD FLoadTreeNotify_call1;
DWORD FLoadTreeNotify_call2;
DWORD SubsysCheck_jmp;
};
#endif

View File

@ -12,6 +12,7 @@
#define IDS_FAILOPENBACKUP 8
#define IDS_WINVER 9
#define IDS_DOWNGRADE 10
#define IDS_REBOOT 11
// Next default values for new objects
//

View File

@ -21,22 +21,37 @@
#include <windows.h>
#include <tlhelp32.h>
#include <cassert>
#include <cstdio>
#include <cstdarg>
#include "debug.h"
#include "pemanip.h"
#include "loadstub.h"
#include "pemanip.h"
#include "setup.h"
#include "wininit.h"
#include "version.h"
#include "resource.h"
#include "patch.h"
#define CODE_SEG ".text"
#define DATA_SEG ".data"
#define INIT_SEG "_INIT"
void ShowError(UINT id, ...)
{
char format[512];
char out[512];
va_list vargs;
va_start(vargs, id);
if (!LoadString(GetModuleHandle(NULL), id, format, sizeof(format)))
sprintf(out, "ERROR: Missing string resource %d", id);
else
_vsnprintf(out, sizeof(out), format, vargs);
va_end(vargs);
DBGPRINTF(("%s\n", out));
MessageBox(NULL, out, "KernelEx Setup", MB_OK | MB_ICONERROR);
exit(id);
}
Setup::Setup(char* _backup_file) : backup_file(strupr(_backup_file))
{
h_kernel32 = GetModuleHandle("KERNEL32");
@ -44,10 +59,6 @@ Setup::Setup(char* _backup_file) : backup_file(strupr(_backup_file))
detect_old_version();
detect_downgrade();
pemem.OpenMemory(h_kernel32);
if (!pemem.HasTarget())
ShowError(IDS_FAILOPEN, "KERNEL32 memory image");
version = get_signature_ver();
OSVERSIONINFOA osv;
@ -111,52 +122,17 @@ void Setup::detect_downgrade()
ShowError(IDS_DOWNGRADE);
}
int Setup::find_pattern(DWORD offset, int size, const short* pattern,
int pat_len, DWORD* found_loc)
{
DWORD end_offset = offset + size - pat_len;
int found = 0;
for (DWORD i = offset ; i <= end_offset ; i++)
{
if (pattern[0] < 0 || *(unsigned char*)i == pattern[0])
{
int j;
for (j = 1 ; j < pat_len ; j++)
{
if (pattern[j] >= 0 && *(unsigned char*)(i + j) != pattern[j])
break;
}
if (j == pat_len) //pattern found
{
*found_loc = i;
found++;
}
}
}
return found;
}
void Setup::set_pattern(DWORD loc, const short* new_pattern, int pat_len)
{
unsigned char* offset = (unsigned char*) loc;
const short* pat_ptr = new_pattern;
while (pat_len--)
{
if (*pat_ptr != -1)
*offset = *pat_ptr & 0xff;
offset++;
pat_ptr++;
}
}
int Setup::get_signature_ver()
{
DWORD ptr;
KernelEx_dataseg* dseg = NULL;
DWORD sign_len = sizeof(KEX_SIGNATURE) - 1;
PEmanip pemem;
pemem.OpenMemory(h_kernel32);
if (!pemem.HasTarget())
ShowError(IDS_FAILOPEN, "KERNEL32 memory image");
DWORD data = (DWORD) pemem.GetSectionByName(DATA_SEG);
int data_size = pemem.GetSectionSize(DATA_SEG);
@ -182,289 +158,6 @@ int Setup::get_signature_ver()
return dseg->version;
}
void Setup::prepare_subsystem_check()
{
static const short pattern[] = {
0x66,0x8b,0x46,0x48,0x66,0x3d,0x04,0x00,0x0f,0x87,0x9c,0x01,0x00,0x00,
0x75,0x0b,0x66,0x83,0x7e,0x4a,0x0a,0x0f,0x87,0x8f,0x01,0x00,0x00,0x66,
0x81,0x7e,0x04,0x4c,0x01,
};
static const short after[] = {
0x66,0x83,0x7E,0x48,0x04,0x75,0x05,0x66,0x83,0x7E,0x4A,0x0A,0xE9,0x00,
0x00,0x00,0x00,0x0F,0x87,0x93,0x01,0x00,0x00,0x90,0x90,0x90,0x90,0x66,
0x81,0x7e,0x04,0x4c,0x01,
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "subsystem_check");
else ShowError(IDS_MULPAT, "subsystem_check");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "subsystem_check",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
SubsysCheck_jmp = found_loc + 12;
_SubsysCheckPerform = decode_jmp(SubsysCheck_jmp, 5);
}
void Setup::find_resource_check1()
{
static const short pattern[] = {
0x6A,0x00,0x8D,0x45,0xE0,0x50,0xFF,0x75,0xA4,0xFF,0x75,0xD0,0x8D,0x45,
0xCC,0x50,0xFF,0x75,0x08,0xE8,-2,-2,-2,-2,0x85,0xC0
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "resource_check1");
else ShowError(IDS_MULPAT, "resource_check1");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "resource_check1",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
GetOrdinal_call1 = found_loc + 19;
_GetOrdinal = decode_call(GetOrdinal_call1, 5);
}
void Setup::find_resource_check2()
{
static const short pattern[] = {
0x66,0x8B,0x45,0xE0,0x66,0x2D,0x06,0x80,0x66,0x3D,0x01,0x00,0x1B,0xC0,
0xF7,0xD8,0x50,0x8D,0x45,0xDE,0x50,0xFF,0x75, -1,0xFF,0x75,0xD0,0x8D,
0x45,0xCC,0x50,0xFF,0x75,0x08,0xE8, -2, -2, -2, -2,0x85,0xC0
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "resource_check2");
else ShowError(IDS_MULPAT, "resource_check2");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "resource_check2",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
GetOrdinal_call2 = found_loc + 34;
}
//no named/rcdata resource types mirroring
void Setup::disable_named_and_rcdata_resources_mirroring()
{
static const short pattern[] = {
0x66,0x8B,0x40,0x0E,0x66,0x89,0x45,0xDA,0x8B,0x45, -1,0x66,0x8B,0x48,
0x0C,0x66,0x89,0x4D,0xD8,0x66,0x8B,0x45,0xE0,0x8B,0x4D,0xD4,0x66,0x89,
0x01,0x83,0x45,0xD4,0x02,0x66,0x8B,0x45,0xDA,0x66,0x03,0x45,0xD8,0x66,
0x89,0x45,0x8C,0x8B,0x4D,0xD4,0x66,0x89,0x01,0x83,0x45,0xD4,0x02
};
static const short after[] = {
0x66,0x8B,0x48,0x0E,0x66,0x03,0x48,0x0C,0x66,0x89,0x4D,0x8C,0x8B,0x45,
0xA4,0x83,0x38,0x0A,0x74,0x40,0x83,0x38,0x00,0x79,0x04,0x3B,0xC0,0xEB,
0x37,0x66,0x8B,0x45,0xE0,0x8B,0x4D,0xD4,0x66,0x89,0x01,0x83,0xC1,0x02,
0x66,0x8B,0x45,0x8C,0x66,0x89,0x01,0x83,0xC1,0x02,0x89,0x4D,0xD4
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "disable_named_and_rcdata_resources_mirroring");
else ShowError(IDS_MULPAT, "disable_named_and_rcdata_resources_mirroring");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "disable_named_and_rcdata_resources_mirroring",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
}
void Setup::mod_imte_alloc()
{
//VA BFF8745C, RVA 1745C, file 15A5C, sec E45C
static const short pattern[] = {
0x66,0xff,0x05,-1,-1,-1,0xbf,0x6a,0x3c,0xe8,
};
static const short after[] = {
0x66,0xff,0x05,-1,-1,-1,0xbf,0x6a,0x40,0xe8,
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "mod_imte_alloc");
else ShowError(IDS_MULPAT, "mod_imte_alloc");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "mod_imte_alloc",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
}
void Setup::mod_mr_alloc()
{
static const short pattern[] = {
0x75,0xF6,0x8D,0x04,-1,0x1C,0x00,0x00,0x00,0x50
};
static const short after[] = {
0x75,0xF6,0x8D,0x04,-1,0x24,0x00,0x00,0x00,0x50
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "mod_mr_alloc");
else ShowError(IDS_MULPAT, "mod_mr_alloc");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "mod_mr_alloc",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
}
void Setup::mod_pdb_alloc()
{
static const short pattern[] = {
0x53,0x56,0x57,0x6A,0x06,0x68,0xC4,0x00,0x00,0x00,0xE8
};
static const short after[] = {
0x53,0x56,0x57,0x6A,0x06,0x68,0xC8,0x00,0x00,0x00,0xE8
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size, pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "mod_pdb_alloc");
else ShowError(IDS_MULPAT, "mod_pdb_alloc");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "mod_pdb_alloc",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
set_pattern(found_loc, after, length);
}
void Setup::find_ExportFromX()
{
static const short pattern[] = {
0x8B,0x0D,-1,-1,-1,-1,0x0F,0xBF,0x40,0x10,0x8B,0x14,0x81,0x8B,0x44,
0x24,0x14,0x3D,0x00,0x00,0x01,0x00,0x8B,0x4A,0x04,0x73,0x15,-1,0x1D,
-1,-1,-1,-1,0x75,0x04,0x6A,0x32,0xEB,0x3E,0x50,0x51,0xE8,-2,-2,-2,-2,
0xEB,0x0C,0xFF,0x74,0x24,0x14,0x6A,0x00,0x51,0xE8,-2,-2,-2,-2,0x83,
0x7F,0x54,0x00,0x8B,0xF0
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "exportfromX");
else ShowError(IDS_MULPAT, "exportfromX");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "exportfromX",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
gpa_ExportFromOrdinal_call = found_loc + 0x29;
gpa_ExportFromName_call = found_loc + 0x37;
_ExportFromOrdinal = decode_call(gpa_ExportFromOrdinal_call, 5);
_ExportFromName = decode_call(gpa_ExportFromName_call, 5);
DWORD start = (DWORD) pefile.RvaToPointer(_ExportFromName);
for (DWORD a = start ; a < start + 0x100 ; a++)
if (is_call_ref(a, _ExportFromOrdinal))
EFN_EFO_call = a;
}
void Setup::find_IsKnownDLL()
{
static const short pattern[] = {
0xFF,0x75,0xFC,0x8D,0x8D,0xF0,0xFE,0xFF,0xFF,0x51,0xE8,-2,-2,-2,-2,
0x85,0xC0,0x75,0x1E,0x8D,0x85,0xE8,0xFD,0xFF,0xFF,
0x8D,0x8D,0xF0,0xFE,0xFF,0xFF,0x50,0x51
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "IsKnownDLL");
else ShowError(IDS_MULPAT, "IsKnownDLL");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "IsKnownDLL",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
IsKnownDLL_call = found_loc + 10;
_IsKnownDLL = decode_call(IsKnownDLL_call, 5);
}
void Setup::find_FLoadTreeNotify1()
{
static const short pattern[] = {
0x56,0xA1,-1,-1,-1,-1,0x6A,0x01,0x8B,0x08,0xFF,0xB1,0x98,0x00,0x00,
0x00,0xE8,-2,-2,-2,-2,0x83,0xF8,0x01,0x1B,0xF6,0xF7,0xDE
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "FLoadTreeNotify1");
else ShowError(IDS_MULPAT, "FLoadTreeNotify1");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "FLoadTreeNotify1",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
FLoadTreeNotify_call1 = found_loc + 16;
_FLoadTreeNotify = decode_call(FLoadTreeNotify_call1, 5);
}
void Setup::find_FLoadTreeNotify2()
{
static const short pattern[] = {
0x6A,0x00,0x57,0xE8,-1,-1,-1,-1,0x6A,0x00,0x56,0xE8,-2,-2,-2,-2,
0x85,0xC0,0x74,0x12,0x56,0xE8,-1,-1,-1,-1,0x68,0x5A,0x04,0x00,0x00,
0x33,0xF6,0xE8,-1,-1,-1,-1
};
DWORD offset = (DWORD) pefile.GetSectionByName(CODE_SEG);
int size = pefile.GetSectionSize(CODE_SEG);
int length = sizeof(pattern) / sizeof(short);
DWORD found_loc;
int found = find_pattern(offset, size,pattern, length, &found_loc);
if (found != 1)
{
if (!found) ShowError(IDS_NOPAT, "FLoadTreeNotify2");
else ShowError(IDS_MULPAT, "FLoadTreeNotify2");
}
DBGPRINTF(("%s: pattern found @ 0x%08x\n", "FLoadTreeNotify2",
pefile.PointerToRva((void*) found_loc) + pefile.GetImageBase()));
FLoadTreeNotify_call2 = found_loc + 11;
}
void Setup::kill_process(const char* name)
{
PROCESSENTRY32 pe32;
@ -499,109 +192,6 @@ void Setup::kill_process(const char* name)
CloseHandle(h);
}
DWORD Setup::decode_call(DWORD addr, int len)
{
unsigned char* code = (unsigned char*)addr;
/* CALL rel32 */
if (code[0] == 0xe8)
{
if (len && len == 5 || !len)
return (DWORD)(pefile.PointerToRva(code) + 5 + *(INT32*)(code + 1));
}
/* CALL imm32 */
else if (code[0] == 0xff && code[1] == 0x15)
{
if (len && len == 6 || !len)
return *(DWORD*)(code + 2);
}
/* unmatched */
return 0;
}
DWORD Setup::decode_jmp(DWORD addr, int len)
{
unsigned char* code = (unsigned char*)addr;
/* JMP rel8 */
if (code[0] == 0xeb)
{
if (len && len == 2 || !len)
return (DWORD)(pefile.PointerToRva(code) + 2 + *(INT8*)(code + 1));
}
/* JMP rel32 */
else if (code[0] == 0xe9)
{
if (len && len == 5 || !len)
return (DWORD)(pefile.PointerToRva(code) + 5 + *(INT32*)(code + 1));
}
/* JMP imm32 */
else if (code[0] == 0xff && code[1] == 0x25)
{
if (len && len == 6 || !len)
return *(DWORD*)(code + 2);
}
/* Jxx rel8 */
else if (code[0] >= 0x70 && code[0] < 0x7f || code[0] == 0xe3)
{
if (len && len == 2 || !len)
return (DWORD)(pefile.PointerToRva(code) + 2 + *(INT8*)(code + 1));
}
/* Jxx rel32 */
else if (code[0] == 0x0f && code[1] >= 0x80 && code[1] <= 0x8f)
{
if (len && len == 6 || !len)
return (DWORD)(pefile.PointerToRva(code) + 6 + *(INT32*)(code + 2));
}
/* unmatched */
return 0;
}
bool Setup::is_call_ref(DWORD loc, DWORD target)
{
DWORD addr = decode_call(loc, 5); // size of call imm32 opcode
if (addr == target)
return true;
return false;
}
// Both addresses have to be from the same section!
void Setup::set_call_ref(DWORD loc, DWORD target)
{
DWORD rel;
assert(*(BYTE*) loc == 0xe8);
rel = target - (loc + 5);
*(DWORD*)(loc + 1) = rel;
}
// Both addresses have to be from the same section!
void Setup::set_jmp_ref(DWORD loc, DWORD target)
{
DWORD rel;
unsigned char* code = (unsigned char*)loc;
if (code[0] == 0xe9)
{
rel = target - (loc + 5);
*(DWORD*)(loc + 1) = rel;
}
else if (code[0] == 0x0f && code[1] >= 0x80 && code[1] <= 0x8f)
{
rel = target - (loc + 6);
*(DWORD*)(loc + 2) = rel;
}
else assert(false);
}
bool Setup::is_fixupc(DWORD addr)
{
if (*(DWORD*)(addr - 5) == 0xDAC)
return true;
return false;
}
sstring Setup::get_temp_file_name()
{
char tmpdir[MAX_PATH];
@ -613,23 +203,6 @@ sstring Setup::get_temp_file_name()
return target;
}
void Setup::ShowError(UINT id, ...)
{
char format[512];
char out[512];
va_list vargs;
va_start(vargs, id);
if (!LoadString(GetModuleHandle(NULL), id, format, sizeof(format)))
sprintf(out, "ERROR: Missing string resource %d", id);
else
_vsnprintf(out, sizeof(out), format, vargs);
va_end(vargs);
DBGPRINTF(("%s\n", out));
MessageBox(NULL, out, "KernelEx Setup", MB_OK | MB_ICONERROR);
exit(id);
}
void Setup::install()
{
upgrade = false;
@ -650,6 +223,7 @@ void Setup::install()
char kernel32path[MAX_PATH];
GetModuleFileName(h_kernel32, kernel32path, sizeof(kernel32path));
PEmanip pefile;
pefile.OpenFile(upgrade ? backup_file : kernel32path, 0x10000);
if (!pefile.HasTarget())
{
@ -659,113 +233,8 @@ void Setup::install()
ShowError(IDS_FAILOPEN, kernel32path);
}
find_ExportFromX();
find_IsKnownDLL();
find_FLoadTreeNotify1();
find_FLoadTreeNotify2();
prepare_subsystem_check();
find_resource_check1();
find_resource_check2();
disable_named_and_rcdata_resources_mirroring();
mod_imte_alloc();
mod_mr_alloc();
mod_pdb_alloc();
KernelEx_codeseg* cseg;
KernelEx_dataseg* dseg;
if (!pefile.AllocSectionSpace(CODE_SEG,
sizeof(KernelEx_codeseg), (void**) &cseg, sizeof(DWORD)))
ShowError(IDS_FAILSEC, CODE_SEG);
if (!pefile.AllocSectionSpace(DATA_SEG,
sizeof(KernelEx_dataseg), (void**) &dseg, sizeof(DWORD)))
ShowError(IDS_FAILSEC, DATA_SEG);
memcpy(cseg->signature, "KrnlEx", 6);
cseg->version = KEX_STUB_VER;
for (int i = 0 ; i < JTAB_SIZE ; i++)
{
cseg->jmp_stub[i].opcode = 0x25ff;
cseg->jmp_stub[i].addr = (DWORD)
pefile.PointerToRva(&dseg->jtab[i]) + pefile.GetImageBase();
cseg->jmp_stub[i].nop = 0x9090;
}
memcpy(dseg->signature, "KrnlEx", 6);
dseg->version = KEX_STUB_VER;
dseg->jtab[JTAB_EFO_DYN] = _ExportFromOrdinal + pefile.GetImageBase();
dseg->jtab[JTAB_EFO_STA] = _ExportFromOrdinal + pefile.GetImageBase();
dseg->jtab[JTAB_EFN_DYN] = _ExportFromName + pefile.GetImageBase();
dseg->jtab[JTAB_EFN_STA] = _ExportFromName + pefile.GetImageBase();
dseg->jtab[JTAB_KNO_DLL] = _IsKnownDLL + pefile.GetImageBase();
dseg->jtab[JTAB_FLD_TRN] = _FLoadTreeNotify + pefile.GetImageBase();
dseg->jtab[JTAB_SYS_CHK] = _SubsysCheckPerform + pefile.GetImageBase();
dseg->jtab[JTAB_RES_CHK] = _GetOrdinal + pefile.GetImageBase();
//exportfromx patch
DWORD code = (DWORD) pefile.GetSectionByName(CODE_SEG);
int code_size = pefile.GetSectionSize(CODE_SEG);
int efo_cnt = 0;
int efn_cnt = 0;
for (DWORD a = code ; a < code + code_size ; a++)
{
if (is_call_ref(a, _ExportFromOrdinal))
{
DWORD file_loc = a;
if (a == EFN_EFO_call)
continue;
if (a == gpa_ExportFromOrdinal_call)
set_call_ref(file_loc, (DWORD) &cseg->jmp_stub[JTAB_EFO_DYN]);
else
set_call_ref(file_loc, (DWORD) &cseg->jmp_stub[JTAB_EFO_STA]);
DBGPRINTF(("%s: address 0x%08x\n", "EFO", pefile.PointerToRva((void*) a)
+ pefile.GetImageBase()));
efo_cnt++;
}
else if (is_call_ref(a, _ExportFromName))
{
DWORD file_loc = a;
if (is_fixupc(a))
continue;
if (a == gpa_ExportFromName_call)
set_call_ref(file_loc, (DWORD) &cseg->jmp_stub[JTAB_EFN_DYN]);
else
set_call_ref(file_loc, (DWORD) &cseg->jmp_stub[JTAB_EFN_STA]);
DBGPRINTF(("%s: address 0x%08x\n", "EFN", pefile.PointerToRva((void*) a)
+ pefile.GetImageBase()));
efn_cnt++;
}
}
if (efo_cnt != 2 || efn_cnt != 2)
ShowError(IDS_ERRCHECK);
//isknowndll patch
set_call_ref(IsKnownDLL_call, (DWORD) &cseg->jmp_stub[JTAB_KNO_DLL]);
DBGPRINTF(("%s: address 0x%08x\n", "KNO_DLL", pefile.PointerToRva((void*) IsKnownDLL_call)
+ pefile.GetImageBase()));
//FLoadTreeNotify patch
set_call_ref(FLoadTreeNotify_call1, (DWORD) &cseg->jmp_stub[JTAB_FLD_TRN]);
DBGPRINTF(("%s: address 0x%08x\n", "FLD_TRN1", pefile.PointerToRva((void*) FLoadTreeNotify_call1)
+ pefile.GetImageBase()));
set_call_ref(FLoadTreeNotify_call2, (DWORD) &cseg->jmp_stub[JTAB_FLD_TRN]);
DBGPRINTF(("%s: address 0x%08x\n", "FLD_TRN2", pefile.PointerToRva((void*) FLoadTreeNotify_call2)
+ pefile.GetImageBase()));
//subsys check patch
set_jmp_ref(SubsysCheck_jmp, (DWORD) &cseg->jmp_stub[JTAB_SYS_CHK]);
DBGPRINTF(("%s: address 0x%08x\n", "SYS_CHK", pefile.PointerToRva((void*) SubsysCheck_jmp)
+ pefile.GetImageBase()));
//resource check patch
set_call_ref(GetOrdinal_call1, (DWORD) &cseg->jmp_stub[JTAB_RES_CHK]);
DBGPRINTF(("%s: address 0x%08x\n", "RES_CHK1", pefile.PointerToRva((void*) GetOrdinal_call1)
+ pefile.GetImageBase()));
set_call_ref(GetOrdinal_call2, (DWORD) &cseg->jmp_stub[JTAB_RES_CHK]);
DBGPRINTF(("%s: address 0x%08x\n", "RES_CHK2", pefile.PointerToRva((void*) GetOrdinal_call2)
+ pefile.GetImageBase()));
Patch patch(pefile);
patch.apply();
// backup original file
if (!upgrade)
@ -802,14 +271,82 @@ void Setup::install()
Wininit.save();
}
void Setup::set_reboot_flag()
{
HKEY hkey;
if (RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\"
"CurrentVersion\\RunServicesOnce", &hkey) == ERROR_SUCCESS)
{
RegSetValueEx(hkey, "KexNeedsReboot", 0, REG_SZ, (const BYTE*) "", 1);
RegCloseKey(hkey);
}
}
void Setup::register_verify()
{
HKEY hkey;
DWORD type;
char verify_path[MAX_PATH];
DWORD size = sizeof(verify_path);
LONG res;
res = RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\KernelEx", &hkey);
if (res != ERROR_SUCCESS)
return;
res = RegQueryValueEx(hkey, "InstallDir", 0, &type, (BYTE*) verify_path, &size);
RegCloseKey(hkey);
if (res != ERROR_SUCCESS)
return;
strcat(verify_path, "\\verify.exe");
if (RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\"
"CurrentVersion\\Run", &hkey) == ERROR_SUCCESS)
{
RegSetValueEx(hkey, "KexVerify", 0, REG_SZ, (BYTE*) verify_path,
strlen(verify_path) + 1);
RegCloseKey(hkey);
}
}
void Setup::reboot()
{
char out[512];
if (!LoadString(GetModuleHandle(NULL), IDS_REBOOT, out, sizeof(out)))
sprintf(out, "ERROR: Missing string resource %d", IDS_REBOOT);
int res = MessageBox(NULL, out, "KernelEx Setup", MB_OKCANCEL | MB_ICONQUESTION);
if (res == IDOK)
{
DBGPRINTF(("Rebooting...\n"));
ExitWindowsEx(EWX_REBOOT, 0);
}
}
int main(int argc, char** argv)
{
bool reboot = false;
DBGPRINTF(("KernelEx setup program running\n"));
if (argc != 2)
if (argc != 1 && argc != 2)
return 1;
if (argc == 2 && !strcmp(argv[1], "/R"))
reboot = true;
Setup setup(argv[1]);
char backup_path[MAX_PATH];
GetWindowsDirectory(backup_path, MAX_PATH);
if (backup_path[strlen(backup_path)-1] != '\\')
strcat(backup_path, "\\");
strcat(backup_path, "SYSBCKUP\\KERNEL32.DLL");
Setup setup(backup_path);
setup.install();
DBGPRINTF(("Setup finished\n"));
if (reboot)
setup.reboot();
setup.set_reboot_flag();
setup.register_verify();
return 0;
}

View File

@ -89,6 +89,10 @@ LINK32=link.exe
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\patch.cpp
# End Source File
# Begin Source File
SOURCE=..\common\pemanip.cpp
# End Source File
# Begin Source File
@ -109,6 +113,10 @@ SOURCE=.\loadstub.h
# End Source File
# Begin Source File
SOURCE=.\patch.h
# End Source File
# Begin Source File
SOURCE=..\common\pemanip.h
# End Source File
# Begin Source File

View File

@ -24,62 +24,29 @@
#include "sstring.hpp"
void ShowError(UINT id, ...);
class Setup
{
public:
Setup(char* _backup_file);
int get_signature_ver();
void install();
void set_reboot_flag();
void register_verify();
void reboot();
protected:
private:
sstring backup_file;
DWORD _GetOrdinal;
DWORD _ExportFromOrdinal;
DWORD _ExportFromName;
DWORD _IsKnownDLL;
DWORD _FLoadTreeNotify;
DWORD _SubsysCheckPerform;
HMODULE h_kernel32;
PEmanip pemem;
PEmanip pefile;
DWORD GetOrdinal_call1;
DWORD GetOrdinal_call2;
DWORD gpa_ExportFromOrdinal_call;
DWORD gpa_ExportFromName_call;
DWORD EFN_EFO_call;
DWORD IsKnownDLL_call;
DWORD FLoadTreeNotify_call1;
DWORD FLoadTreeNotify_call2;
DWORD SubsysCheck_jmp;
int version;
bool is_winme;
bool upgrade;
bool detect_old_version();
void detect_downgrade();
int find_pattern(DWORD offset, int size, const short* pattern, int pat_len, DWORD* found_loc);
void set_pattern(DWORD loc, const short* new_pattern, int pat_len);
void prepare_subsystem_check();
void find_resource_check1();
void find_resource_check2();
void disable_named_and_rcdata_resources_mirroring();
void mod_imte_alloc();
void mod_mr_alloc();
void mod_pdb_alloc();
void find_ExportFromX();
void find_IsKnownDLL();
void find_FLoadTreeNotify1();
void find_FLoadTreeNotify2();
void kill_process(const char* name);
DWORD decode_call(DWORD addr, int len = 0);
DWORD decode_jmp(DWORD addr, int len = 0);
bool is_call_ref(DWORD loc, DWORD target);
void set_call_ref(DWORD loc, DWORD target);
void set_jmp_ref(DWORD loc, DWORD target);
bool is_fixupc(DWORD addr);
sstring get_temp_file_name();
void ShowError(UINT id, ...);
};
#endif

View File

@ -38,6 +38,7 @@ BEGIN
IDS_FAILOPENBACKUP "ERROR: Failed to open backup file %s.\nPossible causes: previous version not uninstalled correctly or file has been deleted.\nRestore %s manually from install media."
IDS_WINVER "Incompatible Windows version"
IDS_DOWNGRADE "Can't downgrade. Please uninstall currently installed version of KernelEx before continuing."
IDS_REBOOT "KernelEx has to restart this computer in order to complete setup.\nDo you wish to do this now?"
END
#endif // Neutral resources

View File

@ -1,6 +1,6 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
* Copyright (C) 2009-2010, Xeno86
*
* This file is part of KernelEx source code.
*
@ -73,17 +73,26 @@ FileFinder::~FileFinder()
}
void FileFinder::search_for(const string& fn)
{
search_for(&fn, 1);
}
void FileFinder::search_for(const string fns[], int num)
{
WIN32_FIND_DATA find_data;
files.clear();
pos = 0;
for (int i = 0 ; i < num ; i++)
{
const string& fn = fns[i];
HANDLE h = FindFirstFile(fn.c_str(), &find_data);
if (h == INVALID_HANDLE_VALUE)
return;
continue;
do
files.push_back(find_data.cFileName);
while (FindNextFile(h, &find_data));
CloseHandle(h);
FindClose(h);
}
stable_sort(files.begin(), files.end());
}
@ -503,7 +512,8 @@ bool is_uptodate_dir(const string& path)
FileFinder ff;
struct _stat st;
ff.search_for(path + "*.c");
string patterns[] = { path + "*.c", path + "*.cpp" };
ff.search_for(patterns, sizeof(patterns)/sizeof(patterns[0]));
while (!(file = ff.get_next_file()).empty())
{
_stat((path + file).c_str(), &st);
@ -557,7 +567,8 @@ void work()
continue;
}
ff.search_for(path + "*.c");
string patterns[] = { path + "*.c", path + "*.cpp" };
ff.search_for(patterns, sizeof(patterns)/sizeof(patterns[0]));
//read declarations
while (!(file = ff.get_next_file()).empty())

View File

@ -50,7 +50,7 @@ BSC32=bscmake.exe
# 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 /subsystem:console /machine:I386
# ADD 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 /subsystem:console /machine:I386 /OPT:NOWIN98
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /machine:I386 /OPT:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "prep - Win32 Debug"
@ -75,7 +75,7 @@ BSC32=bscmake.exe
# 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD 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 /subsystem:console /debug /machine:I386 /pdbtype:sept /OPT:NOWIN98
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /OPT:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ENDIF

View File

@ -48,6 +48,7 @@ public:
FileFinder(const string& fn);
~FileFinder();
void search_for(const string& fn);
void search_for(const string fns[], int num);
string get_next_file();
private:

1
util/sdbcreate/readme.txt Executable file
View File

@ -0,0 +1 @@
This program requires Windows NT 6.0 or higher to function.

17
util/sdbcreate/sdbapi.def Executable file
View File

@ -0,0 +1,17 @@
LIBRARY APPHELP.DLL
EXPORTS
SdbCreateDatabase
SdbDeclareIndex
SdbCloseDatabase
SdbCloseDatabaseWrite
SdbCommitIndexes
SdbStartIndexing
SdbStopIndexing
SdbBeginWriteListTag
SdbEndWriteListTag
SdbWriteBinaryTag
SdbWriteBinaryTagFromFile
SdbWriteStringTag
SdbWriteDWORDTag
SdbGUIDFromString

113
util/sdbcreate/sdbapi.h Executable file
View File

@ -0,0 +1,113 @@
/*
* KernelEx
* Copyright (C) 2010, Tihiy
*
* 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 __SDBAPI_H
#define __SDBAPI_H
#include <windows.h>
#ifdef SDBAPI_IMPLIB
#ifdef _MSC_VER
#pragma warning(disable:4716)
#endif
#define MAKE_HEADER(decl) \
__declspec(dllexport) decl {}
#else
#define MAKE_HEADER(decl) \
__declspec(dllimport) decl ;
#endif
#ifdef __cplusplus
extern "C" {
#endif
//types
typedef PVOID PDB;
typedef DWORD INDEXID;
typedef DWORD TAGID;
typedef DWORD TAG;
//enums
typedef enum _PATH_TYPE {
DOS_PATH,
NT_PATH
} PATH_TYPE;
//tags
#define TAG_DWORD 0x4000
#define TAG_MSI_TRANSFORM_TAGID 0x401B
#define TAG_STRING 0x6000
#define TAG_NAME 0x6001
#define TAG_APP_NAME 0x6006
#define TAG_MSI_TRANSFORM_FILE 0x601F
#define TAG_COMPILER_VERSION 0x6022
#define TAG_LIST 0x7000
#define TAG_DATABASE 0x7001
#define TAG_LIBRARY 0x7002
#define TAG_FILE 0x700C
#define TAG_MSI_TRANSFORM 0x7010
#define TAG_MSI_TRANSFORM_REF 0x7011
#define TAG_MSI_PACKAGE 0x7012
#define TAG_BINARY 0x9000
#define TAG_FILE_BITS 0x9003
#define TAG_EXE_ID 0x9004
#define TAG_MSI_PACKAGE_ID 0x9006
#define TAG_DATABASE_ID 0x9007
//functions
MAKE_HEADER(PDB WINAPI SdbCreateDatabase(LPCWSTR pwszPath, PATH_TYPE eType))
MAKE_HEADER(void WINAPI SdbCloseDatabase(PDB pdb))
MAKE_HEADER(void WINAPI SdbCloseDatabaseWrite(PDB pdb))
MAKE_HEADER(BOOL WINAPI SdbDeclareIndex(PDB pdb,TAG tWhich,TAG tKey,DWORD dwEntries,BOOL bUniqueKey,INDEXID *piiIndex))
MAKE_HEADER(BOOL WINAPI SdbCommitIndexes(PDB pdb))
MAKE_HEADER(BOOL WINAPI SdbStartIndexing(PDB pdb,INDEXID iiWhich))
MAKE_HEADER(BOOL WINAPI SdbStopIndexing(PDB pdb,INDEXID iiWhich))
MAKE_HEADER(TAGID WINAPI SdbBeginWriteListTag(PDB pdb,TAG tTag))
MAKE_HEADER(BOOL WINAPI SdbEndWriteListTag(PDB pdb,TAGID tiList))
MAKE_HEADER(BOOL WINAPI SdbWriteBinaryTag(PDB pdb,TAG tTag,PBYTE pBuffer,DWORD dwSize))
MAKE_HEADER(BOOL WINAPI SdbWriteBinaryTagFromFile(PDB pdb,TAG tTag,LPCWSTR pwszPath))
MAKE_HEADER(BOOL WINAPI SdbWriteStringTag(PDB pdb,TAG tTag,LPCWSTR pwszData))
MAKE_HEADER(BOOL WINAPI SdbWriteDWORDTag(PDB pdb,TAG tTag,DWORD dwData))
MAKE_HEADER(BOOL WINAPI SdbGUIDFromString(LPWSTR str, GUID* guid))
/*
MAKE_HEADER(
MAKE_HEADER(
MAKE_HEADER(
MAKE_HEADER(
MAKE_HEADER(
MAKE_HEADER(*/
#ifdef __cplusplus
}
#endif
#endif

284
util/sdbcreate/sdbcreate.cpp Executable file
View File

@ -0,0 +1,284 @@
/*
* KernelEx
* Copyright(C) 2010, Tihiy, 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 <map>
#include "sdbapi.h"
#include "wstring.hpp"
using namespace std;
typedef void (*STRPROC) (wchar_t*);
static int sections;
static PDB pdb;
static wchar_t* sdbfile;
static wchar_t inifile[MAX_PATH];
static FILE *regfilei;
static FILE *regfileu;
static map<wstring, TAGID> tagidmap;
void fail()
{
SdbCloseDatabase(pdb);
DeleteFileW(sdbfile);
exit(-1);
}
void WriteTransform(wchar_t* section)
{
//query file name
wchar_t filebuf[MAX_PATH];
wchar_t filepath[MAX_PATH];
wchar_t name[MAX_PATH];
if (!GetPrivateProfileStringW(section, L"Transform", NULL, filebuf, MAX_PATH, inifile))
{
printf("Section %ls does not specify file!\n", section);
fail();
}
//build path to file relative to ini
lstrcpyW(filepath, inifile);
PathRemoveFileSpecW(filepath);
PathAppendW(filepath, filebuf);
wchar_t* filename = PathFindFileNameW(filepath);
lstrcpyW(name, filepath);
PathRemoveExtensionW(name);
PathStripPathW(name);
if (tagidmap.count(name) > 0)
return; //already have it
printf("Adding %ls...", filepath);
//write FILE
TAGID filetagid = SdbBeginWriteListTag(pdb, TAG_FILE);
SdbWriteStringTag(pdb, TAG_NAME, filename);
if (SdbWriteBinaryTagFromFile(pdb, TAG_FILE_BITS, filepath))
printf("Success!\n");
else
{
printf("Failure!\n");
fail();
}
SdbEndWriteListTag(pdb, filetagid);
//write MSI_TRANSFORM
TAGID transfid = SdbBeginWriteListTag(pdb, TAG_MSI_TRANSFORM);
SdbWriteStringTag(pdb, TAG_NAME, name);
SdbWriteStringTag(pdb, TAG_MSI_TRANSFORM_FILE, filename);
SdbWriteDWORDTag(pdb, TAG_MSI_TRANSFORM_TAGID, filetagid);
SdbEndWriteListTag(pdb, transfid);
//add transform tagid to name - tagid map
tagidmap[name] = transfid;
}
void WritePackage(wchar_t* section)
{
//query file name
wchar_t filebuf[MAX_PATH];
wchar_t filepath[MAX_PATH];
wchar_t name[MAX_PATH];
GetPrivateProfileStringW(section, L"Transform", NULL, filebuf, MAX_PATH, inifile);
//build path to file relative to ini
lstrcpyW(filepath, inifile);
PathRemoveFileSpecW(filepath);
PathAppendW(filepath, filebuf);
wchar_t* filename = PathFindFileNameW(filepath);
lstrcpyW(name, filepath);
PathRemoveExtensionW(name);
PathStripPathW(name);
TAGID transfid = tagidmap[name];
//query attributes
wchar_t appname[200];
wchar_t packagecode[100];
GUID guid;
GetPrivateProfileStringW(section, L"AppName", section, appname, 200, inifile);
GetPrivateProfileStringW(section, L"ProductCode", NULL, packagecode, 100, inifile);
if (!SdbGUIDFromString(packagecode, &guid))
{
printf("Section %ls specifies invalid ProductCode!\n", section);
fail();
}
printf("Writing section %ls\n", section);
//write MSI_PACKAGE
TAGID tagid = SdbBeginWriteListTag(pdb, TAG_MSI_PACKAGE);
SdbWriteStringTag(pdb, TAG_NAME, section);
SdbWriteStringTag(pdb, TAG_APP_NAME, appname);
SdbWriteBinaryTag(pdb, TAG_MSI_PACKAGE_ID,(PBYTE) & guid, sizeof(GUID));
//write MSI_TRANSFORM_REF
TAGID reftagid = SdbBeginWriteListTag(pdb, TAG_MSI_TRANSFORM_REF);
SdbWriteStringTag(pdb, TAG_NAME, name);
SdbWriteDWORDTag(pdb, TAG_MSI_TRANSFORM_TAGID, transfid);
SdbEndWriteListTag(pdb, reftagid);
SdbEndWriteListTag(pdb, tagid);
//write registry
if (regfilei)
{
fprintf(regfilei, "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\"
"CurrentVersion\\AppCompatFlags\\Custom\\%ls]\n", packagecode);
fprintf(regfilei, "\"%ls\"=\"%ls\"\n", PathFindFileNameW(sdbfile), appname);
fprintf(regfilei, "\n");
}
if (regfileu)
{
fprintf(regfileu, "[-HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\"
"CurrentVersion\\AppCompatFlags\\Custom\\%ls]\n\n", packagecode);
}
}
void ForEachSection(STRPROC proc)
{
wchar_t sections[0x10000] = { 0 };
wchar_t* strW = sections;
GetPrivateProfileSectionNamesW(strW, 0x10000, inifile);
for(; *strW; strW += lstrlenW(strW) + 1)
proc(strW);
}
void CountSection(wchar_t* section)
{
sections++;
}
void WriteTransforms()
{
TAGID tagid = SdbBeginWriteListTag(pdb, TAG_LIBRARY);
ForEachSection(WriteTransform);
SdbEndWriteListTag(pdb, tagid);
}
void WritePackages()
{
ForEachSection(WritePackage);
}
void WriteDatabase()
{
//count number of sections
sections = 0;
ForEachSection(CountSection);
sections = (sections + 15) & ~15;
//create indexes
INDEXID idx1;
INDEXID idx2;
INDEXID idx3;
SdbDeclareIndex(pdb, TAG_MSI_TRANSFORM, TAG_NAME, sections, TRUE, &idx1);
SdbDeclareIndex(pdb, TAG_MSI_PACKAGE, TAG_MSI_PACKAGE_ID, sections, FALSE, &idx2);
SdbDeclareIndex(pdb, TAG_MSI_PACKAGE, TAG_EXE_ID, sections, TRUE, &idx3);
SdbCommitIndexes(pdb);
//enable indexing
SdbStartIndexing(pdb, idx1);
SdbStartIndexing(pdb, idx2);
SdbStartIndexing(pdb, idx3);
//create database
TAGID tagid = SdbBeginWriteListTag(pdb, TAG_DATABASE);
WriteTransforms();
WritePackages();
SdbEndWriteListTag(pdb, tagid);
//disable indexing
SdbStopIndexing(pdb, idx1);
SdbStopIndexing(pdb, idx2);
SdbStopIndexing(pdb, idx3);
}
int wmain(int argc, wchar_t* argv[])
{
if (argc != 3 && argc != 4)
{
printf("Usage: sdbcreate.exe dbspec.ini out.sdb [out.reg]\n");
return 1;
}
//check ini
GetFullPathNameW(argv[1], MAX_PATH, inifile, NULL);
if (GetFileAttributesW(inifile) == INVALID_FILE_ATTRIBUTES)
{
printf("Failed to open %ls!\n", inifile);
return 2;
}
//create sdb
sdbfile = argv[2];
printf("Creating %ls...\n", sdbfile);
pdb = SdbCreateDatabase(sdbfile, DOS_PATH);
if (!pdb)
{
printf("Failed to create database!\n");
return 3;
}
//create reg
if (argc == 4)
{
wchar_t regpath[MAX_PATH];
lstrcpyW(regpath, argv[3]);
PathRemoveExtensionW(regpath);
lstrcatW(regpath, L".i.reg");
regfilei = _wfopen(regpath, L"w");
fprintf(regfilei, "REGEDIT4\n\n");
lstrcpyW(regpath, argv[3]);
PathRemoveExtensionW(regpath);
lstrcatW(regpath, L".u.reg");
regfileu = _wfopen(regpath, L"w");
fprintf(regfileu, "REGEDIT4\n\n");
}
//write
WriteDatabase();
//close
SdbCloseDatabaseWrite(pdb);
if (regfilei)
fclose(regfilei);
if (regfileu)
fclose(regfilei);
printf("Finished.");
return 0;
}

159
util/sdbcreate/sdbcreate.dsp Executable file
View File

@ -0,0 +1,159 @@
# Microsoft Developer Studio Project File - Name="sdbcreate" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=sdbcreate - 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 "sdbcreate.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 "sdbcreate.mak" CFG="sdbcreate - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "sdbcreate - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "sdbcreate - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "sdbcreate - 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 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /W3 /GX /O2 /FI"../../common/msvc_quirks.h" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /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 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 /subsystem:console /machine:I386
# ADD LINK32 shlwapi.lib kernel32.lib shell32.lib /nologo /subsystem:console /machine:I386
# Begin Special Build Tool
ProjDir=.
TargetPath=.\Release\sdbcreate.exe
SOURCE="$(InputPath)"
PostBuild_Cmds=$(TargetPath) $(ProjDir)\sdbdb\kexsdb.ini $(ProjDir)\sdbdb\KernelEx.sdb $(ProjDir)\sdbdb\kexsdb.reg
# End Special Build Tool
!ELSEIF "$(CFG)" == "sdbcreate - 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 /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /FI"../../common/msvc_quirks.h" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /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 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 /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 shlwapi.lib kernel32.lib shell32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# Begin Special Build Tool
ProjDir=.
TargetPath=.\Debug\sdbcreate.exe
SOURCE="$(InputPath)"
PostBuild_Cmds=$(TargetPath) $(ProjDir)\sdbdb\kexsdb.ini $(ProjDir)\sdbdb\KernelEx.sdb $(ProjDir)\sdbdb\kexsdb.reg
# End Special Build Tool
!ENDIF
# Begin Target
# Name "sdbcreate - Win32 Release"
# Name "sdbcreate - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\sdbcreate.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\sdbapi.h
!IF "$(CFG)" == "sdbcreate - Win32 Release"
# PROP Ignore_Default_Tool 1
# Begin Custom Build
OutDir=.\Release
ProjDir=.
InputPath=.\sdbapi.h
"$(OutDir)\sdbapi.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl /nologo /c /TC /DSDBAPI_IMPLIB /Fo$(OutDir)\sdbapi.obj "$(ProjDir)\sdbapi.h"
link /DLL /NOENTRY /NOLOGO /IGNORE:4070 /MACHINE:IX86 /DEF:"$(ProjDir)\sdbapi.def" /OUT:$(OutDir)\sdbapi.dll /IMPLIB:$(OutDir)\sdbapi.lib $(OutDir)\sdbapi.obj
del $(OutDir)\sdbapi.exp
del $(OutDir)\sdbapi.obj
del $(OutDir)\sdbapi.dll
# End Custom Build
!ELSEIF "$(CFG)" == "sdbcreate - Win32 Debug"
# PROP Ignore_Default_Tool 1
# Begin Custom Build
OutDir=.\Debug
ProjDir=.
InputPath=.\sdbapi.h
"$(OutDir)\sdbapi.lib" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl /nologo /c /TC /DSDBAPI_IMPLIB /Fo$(OutDir)\sdbapi.obj "$(ProjDir)\sdbapi.h"
link /DLL /NOENTRY /NOLOGO /IGNORE:4070 /MACHINE:IX86 /DEF:"$(ProjDir)\sdbapi.def" /OUT:$(OutDir)\sdbapi.dll /IMPLIB:$(OutDir)\sdbapi.lib $(OutDir)\sdbapi.obj
del $(OutDir)\sdbapi.exp
del $(OutDir)\sdbapi.obj
del $(OutDir)\sdbapi.dll
# End Custom Build
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\wstring.hpp
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

BIN
util/sdbcreate/sdbdb/gearth.mst Executable file

Binary file not shown.

39
util/sdbcreate/sdbdb/kexsdb.ini Executable file
View File

@ -0,0 +1,39 @@
[office2007conv]
AppName=Office 2007 File Format Converters
ProductCode={90120000-0020-0409-0000-0000000FF1CE}
Transform=o12conv.mst
[wordview2003]
AppName=Word Viewer 2003
ProductCode={90850409-6000-11D3-8CFE-0150048383C9}
Transform=office2003.mst
[xlview2003]
AppName=Excel Viewer 2003
ProductCode={90840409-6000-11D3-8CFE-0150048383C9}
Transform=office2003.mst
[office2003pro]
AppName=Office 2003 Professional
ProductCode={90110409-6000-11D3-8CFE-0150048383C9}
Transform=office2003.mst
[gearth51]
AppName=Google Earth 5.1
ProductCode={B59EF430-4849-11DF-B1EC-005056806466}
Transform=gearth.mst
[gearth52]
AppName=Google Earth 5.2
ProductCode={2EAF7E61-068E-11DF-953C-005056806466}
Transform=gearth.mst
[gearth6]
AppName=Google Earth 6 beta
ProductCode={6DB7AD00-F781-11DF-9EEF-001279CD8240}
Transform=gearth.mst
[acroread7]
AppName=Acrobat Reader 7
ProductCode={AC76BA86-7AD7-1033-7B44-A70900000002}
Transform=reader7.mst

BIN
util/sdbcreate/sdbdb/o12conv.mst Executable file

Binary file not shown.

Binary file not shown.

BIN
util/sdbcreate/sdbdb/reader7.mst Executable file

Binary file not shown.

89
util/sdbcreate/wstring.hpp Executable file
View File

@ -0,0 +1,89 @@
/*
* KernelEx
* Copyright (C) 2009, Xeno86
* Copyright (C) 2010, Tihiy
*
* 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 __WSTRING_HPP
#define __WSTRING_HPP
#include <string.h>
/** Simple string container class. */
class wstring
{
public:
wstring(const WCHAR* src)
{
len = lstrlenW(src);
storage = new WCHAR[len + 1];
lstrcpyW(storage, src);
}
wstring(const wstring& src)
{
len = src.len;
storage = new WCHAR[len + 1];
lstrcpyW(storage, src.storage);
}
~wstring()
{
delete [] storage;
}
wstring& operator=(const wstring& src)
{
len = src.len;
delete [] storage;
storage = new WCHAR[len + 1];
lstrcpyW(storage, src.storage);
return *this;
}
wstring& operator=(const WCHAR* src)
{
len = lstrlenW(src);
delete [] storage;
storage = new WCHAR[len + 1];
lstrcpyW(storage, src);
return *this;
}
bool operator<(const wstring& a) const
{
return lstrcmpiW(storage, a.storage) < 0;
}
operator const WCHAR*() const
{
return storage;
}
int length() const
{
return len;
}
private:
int len;
WCHAR* storage;
};
#endif

200
verify/main.c Executable file
View File

@ -0,0 +1,200 @@
/*
* KernelEx
* Copyright (C) 2010, 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.
*
*/
#define _WIN32_WINNT 0x0501
#define _WIN32_IE 0x0500
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include "resource.h"
/* Program used to verify KernelEx installation.
* If it annoys you add DWORD value "NoVerify"
* under HKLM\Software\KernelEx and set it to 1.
*/
HINSTANCE hInstance;
unsigned long core_version;
typedef unsigned long (*kexVersion_t)();
int snprintf(char*, size_t, const char*, ...);
void install_failure()
{
char msg[256];
char title[100];
LoadString(hInstance, IDS_FAILURETITLE, title, sizeof(title));
LoadString(hInstance, IDS_FAILURE, msg, sizeof(msg));
MessageBox(NULL, msg, title, MB_OK | MB_ICONERROR);
}
void erase_from_startup()
{
HKEY key;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
0, KEY_ALL_ACCESS, &key) != ERROR_SUCCESS)
return;
RegDeleteValue(key, "KexVerify");
RegCloseKey(key);
}
int is_disable_verify()
{
HKEY key;
DWORD type;
DWORD data;
LONG ret;
DWORD size = sizeof(data);
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\KernelEx",
0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS)
return 0;
ret = RegQueryValueEx(key, "NoVerify", NULL, &type, (BYTE*) &data, &size);
RegCloseKey(key);
if (ret != ERROR_SUCCESS || type != REG_DWORD || size != sizeof(DWORD) || data == 0)
return 0;
return 1;
}
int test_core()
{
HMODULE h = GetModuleHandle("KERNELEX.DLL");
kexVersion_t getver = (kexVersion_t)GetProcAddress(h, "kexGetKEXVersion");
if (!getver)
return 0;
core_version = getver();
return 1;
}
int test_apis()
{
HMODULE h = GetModuleHandle("KERNEL32.DLL");
PROC proc = GetProcAddress(h, "GetSystemWindowsDirectoryA");
if (!proc)
return 0;
h = LoadLibrary("GDI32.DLL");
proc = GetProcAddress(h, "GetGlyphIndicesW");
FreeLibrary(h);
if (!proc)
return 0;
return 1;
}
BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
{
char ver_s[32];
snprintf(ver_s, sizeof(ver_s), "v%d.%d.%d",
core_version>>24, (core_version>>16) & 0xff, core_version & 0xffff);
SendMessage(GetDlgItem(hwnd, IDC_VERSION), WM_SETTEXT, 0, (LPARAM) ver_s);
return TRUE;
}
case WM_COMMAND:
case WM_CLOSE:
EndDialog(hwnd, 0);
return TRUE;
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code)
{
case NM_CLICK:
case NM_RETURN:
{
PNMLINK pNMLink = (PNMLINK)lParam;
LITEM item = pNMLink->item;
if (((LPNMHDR)lParam)->idFrom == IDC_LINK)
{
ShellExecuteW(NULL, L"open", item.szUrl, NULL, NULL, SW_SHOW);
return TRUE;
}
break;
}
}
break;
}
return FALSE;
}
int are_extensions_enabled()
{
HKEY key;
DWORD type, data, size = sizeof(data);
LONG res;
res = RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\KernelEx", &key);
if (res != ERROR_SUCCESS)
return 1;
res = RegQueryValueEx(key, "DisableExtensions", NULL, &type, (char*)&data, &size);
if (res == ERROR_SUCCESS && type == REG_DWORD && size == sizeof(data) && data == 1)
return 0;
RegCloseKey(key);
return 1;
}
__declspec(noreturn)
void entrypoint()
{
INITCOMMONCONTROLSEX iccex;
hInstance = GetModuleHandle(NULL);
erase_from_startup();
if (!is_disable_verify())
{
int okay = 0;
if (test_core() && test_apis())
{
iccex.dwSize = sizeof(iccex);
iccex.dwICC = ICC_LINK_CLASS;
if (InitCommonControlsEx(&iccex))
{
int dialog;
if (are_extensions_enabled())
dialog = IDD_DIALOG1;
else
dialog = IDD_DIALOG2;
if (!DialogBoxParam(hInstance, MAKEINTRESOURCE(dialog), NULL, DlgProc, 0))
okay = 1;
}
}
if (!okay)
install_failure();
}
ExitProcess(0);
}

View File

@ -1,108 +0,0 @@
#include <windows.h>
#include "resource.h"
/* Program used to verify KernelEx installation.
* If it annoys you add DWORD value "NoVerify"
* under HKLM\Software\KernelEx and set it to 1.
*/
HINSTANCE hInstance;
void install_success()
{
char msg[256];
char title[100];
LoadString(hInstance, IDS_TITLE, title, sizeof(title));
LoadString(hInstance, IDS_SUCCESS, msg, sizeof(msg));
MessageBox(NULL, msg, title, MB_OK | MB_ICONINFORMATION);
}
void install_failure()
{
char msg[256];
char title[100];
LoadString(hInstance, IDS_TITLE, title, sizeof(title));
LoadString(hInstance, IDS_FAILURE, msg, sizeof(msg));
MessageBox(NULL, msg, title, MB_OK | MB_ICONERROR);
}
void erase_from_startup()
{
HKEY key;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
0, KEY_ALL_ACCESS, &key) != ERROR_SUCCESS)
return;
RegDeleteValue(key, "KexVerify");
RegCloseKey(key);
}
bool is_disable_verify()
{
HKEY key;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\KernelEx",
0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS)
return false;
DWORD type;
DWORD data;
DWORD size = sizeof(data);
LONG ret = RegQueryValueEx(key, "NoVerify", NULL, &type, (BYTE*) &data, &size);
RegCloseKey(key);
if (ret != ERROR_SUCCESS || type != REG_DWORD || size != sizeof(DWORD) || data == 0)
return false;
return true;
}
bool test_core()
{
HMODULE h = LoadLibrary("KERNELEX.DLL");
PROC proc = GetProcAddress(h, "kexGetKEXVersion");
FreeLibrary(h);
if (!proc)
return false;
return true;
}
bool test_apis()
{
HMODULE h = GetModuleHandle("KERNEL32.DLL");
PROC proc = GetProcAddress(h, "GetSystemWindowsDirectoryA");
if (!proc)
return false;
h = LoadLibrary("GDI32.DLL");
proc = GetProcAddress(h, "GetGlyphIndicesW");
FreeLibrary(h);
if (!proc)
return false;
return true;
}
__declspec(noreturn)
void entrypoint()
{
hInstance = GetModuleHandle(NULL);
erase_from_startup();
if (!is_disable_verify())
{
if (test_core() && test_apis())
install_success();
else
install_failure();
}
ExitProcess(0);
}

View File

@ -2,17 +2,21 @@
// Microsoft Developer Studio generated include file.
// Used by verify.rc
//
#define IDS_SUCCESS 1
#define IDS_FAILURE 2
#define IDS_TITLE 3
#define IDS_FAILURE 1
#define IDS_FAILURETITLE 2
#define IDD_DIALOG1 101
#define IDD_DIALOG2 102
#define IDC_CHECK1 1000
#define IDC_LINK 1001
#define IDC_VERSION 1003
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -53,7 +53,7 @@ BSC32=bscmake.exe
# 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 /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib advapi32.lib libc.lib /nologo /entry:"entrypoint" /subsystem:windows /machine:I386 /nodefaultlib /OPT:NOWIN98
# ADD LINK32 kernel32.lib user32.lib advapi32.lib comctl32.lib shell32.lib ..\kexcrt\kexcrt.lib libc.lib /nologo /entry:"entrypoint" /subsystem:windows /machine:I386 /nodefaultlib /OPT:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "verify - Win32 Debug"
@ -80,7 +80,7 @@ BSC32=bscmake.exe
# 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 /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib advapi32.lib libc.lib /nologo /entry:"entrypoint" /subsystem:windows /debug /machine:I386 /nodefaultlib /pdbtype:sept /OPT:NOWIN98
# ADD LINK32 kernel32.lib user32.lib advapi32.lib comctl32.lib shell32.lib ..\kexcrt\kexcrt.lib libc.lib /nologo /entry:"entrypoint" /subsystem:windows /debug /machine:I386 /nodefaultlib /pdbtype:sept /OPT:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ENDIF
@ -94,20 +94,24 @@ LINK32=link.exe
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\main.cpp
# End Source File
# Begin Source File
SOURCE=.\verify.rc
SOURCE=.\main.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\resource.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=.\verify.rc
# End Source File
# End Group
# End Target
# End Project

View File

@ -21,6 +21,67 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1250)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 296, 78
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "KernelEx"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,122,57,50,14
ICON 32516,IDC_STATIC,7,7,20,20
LTEXT "KernelEx has been successfully installed and is now enabled for all applications.\nTo make newer applications run or fix old applications crash, you may need to go to the KernelEx tab in the properties of application executable or its shortcut.",
IDC_STATIC,36,7,253,34
CONTROL "To learn more about KernelEx, pay a visit to <a href=""http://kernelex.sourceforge.net/wiki/"">KernelEx Wiki</a>",
IDC_LINK,"SysLink",WS_TABSTOP,36,39,253,10
RTEXT "VERSIONSTR",IDC_VERSION,224,62,65,9,WS_DISABLED
END
IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 296, 78
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "KernelEx"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,122,57,50,14
ICON 32516,IDC_STATIC,7,7,20,20
LTEXT "KernelEx has been successfully installed but is disabled by default and only enabled for some applications. To enable KernelEx for newer applications, go to the KernelEx tab in the properties of application executable or its shortcut.",
IDC_STATIC,36,7,253,34
CONTROL "To learn more about KernelEx, pay a visit to <a href=""http://kernelex.sourceforge.net/wiki/"">KernelEx Wiki</a>",
IDC_LINK,"SysLink",WS_TABSTOP,36,39,253,10
RTEXT "VERSIONSTR",IDC_VERSION,224,62,65,9,WS_DISABLED
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_DIALOG1, DIALOG
BEGIN
LEFTMARGIN, 36
RIGHTMARGIN, 289
TOPMARGIN, 7
BOTTOMMARGIN, 71
END
IDD_DIALOG2, DIALOG
BEGIN
LEFTMARGIN, 36
RIGHTMARGIN, 289
TOPMARGIN, 7
BOTTOMMARGIN, 71
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
@ -28,9 +89,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
STRINGTABLE DISCARDABLE
BEGIN
IDS_SUCCESS "KernelEx installed successfully and functional."
IDS_FAILURE "KernelEx has not been properly installed."
IDS_TITLE "KernelEx installation verify"
IDS_FAILURETITLE "KernelEx installation error"
END
#endif // Neutral resources
@ -40,7 +100,7 @@ END
/////////////////////////////////////////////////////////////////////////////
// Polish resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_POL)
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK)
#ifdef _WIN32
LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
#pragma code_page(1250)