diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100755 index 0000000..0ce4d9c --- /dev/null +++ b/CHANGELOG.txt @@ -0,0 +1,31 @@ +KernelEx v4.0 RC 2 by Xeno86 +2009-03-21 + +fixed uxtheme version check +added compilation instructions +fixed msimg32.AlphaBlend bug incorrectly calculating transparency +added kernel32.GetVersionW to default configuration +added advapi32.OpenSCManager stubs +implemented kernel32.GetConsoleWindow +modified CreateFile, ReadFile and WriteFile so that they now accept overlapped flag +fixed non-working MoveFileWithProgressA +fix: DirectX setup has disabled extensions +added psapi.EmptyWorkingSet stub +change: KernelEx will first load any other MPRServices before initializing +added workaround for situation where some kernel driver hijacked system functions +added missing disable resource check fix +removed GetMessageW from kexbasen (already in kexbases) +fixed issue where installer wouldn't complete on fresh system +fixed BSOD or crashes on shutdown on certain configurations by preventing early unload +fixed compatibility sheet not working properly for shortcuts +implemented kernel32.IsProcessorFeaturePresent +fix: check if last element in merge list does repeat +fixed compilation issue with PSDK 2003 +fixed Core not displaying error messages correctly + +--------------------------------------- + +KernelEx v4.0 RC 1 by Xeno86 +2009-03-10 + +First public release of KernelEx rewritten from scratch and based on new architecture diff --git a/COMPATIBILITY.txt b/COMPATIBILITY.txt new file mode 100755 index 0000000..6707e1a --- /dev/null +++ b/COMPATIBILITY.txt @@ -0,0 +1,30 @@ +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: +------------------ +* .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 diff --git a/COMPILE.TXT b/COMPILE.TXT new file mode 100755 index 0000000..78c947c --- /dev/null +++ b/COMPILE.TXT @@ -0,0 +1,6 @@ +To compile you need Microsoft Visual C++ 6.0 SP6 +First you need to compile KEXCRT project as other projects rely on it. +To build KEXCONTROL you have to build debug CORE first. +KEXBASES and KEXBASEN projects rely on CORE be built first. + +-Xeno86 diff --git a/KernelEx.nsi b/KernelEx.nsi index 38a21ad..e8bd6f1 100755 --- a/KernelEx.nsi +++ b/KernelEx.nsi @@ -1,4 +1,4 @@ - !define VERSION '4.0 RC 1' + !define VERSION '4.0 RC 2' ;-------------------------------- ;Includes @@ -10,6 +10,8 @@ ;-------------------------------- ;General + SetCompressor /SOLID lzma + ;Name and file Name "KernelEx" Caption "KernelEx ${VERSION} Setup" diff --git a/apilibs/CORE.INI b/apilibs/CORE.INI old mode 100644 new mode 100755 index 6207c9c..0955e22 --- a/apilibs/CORE.INI +++ b/apilibs/CORE.INI @@ -17,8 +17,6 @@ noshow=1 [DCFG1.names.98] KERNEL32.GetVersion=std -KERNEL32.GetVersionExA=std -KERNEL32.GetVersionExW=std GDI32.SetWorldTransform=kexbases.0 GDI32.GetRandomRgn=std GDI32.SetGraphicsMode=std @@ -28,8 +26,6 @@ KERNEL32.VerifyVersionInfoW=none [DCFG1.names.Me] KERNEL32.GetVersion=std -KERNEL32.GetVersionExA=std -KERNEL32.GetVersionExW=std GDI32.SetWorldTransform=kexbases.0 GDI32.GetRandomRgn=std GDI32.SetGraphicsMode=std @@ -46,8 +42,8 @@ desc=Windows 95 [WIN95.names] KERNEL32.GetVersion=kexbases.0 -KERNEL32.GetVersionExA=kexbases.0 -KERNEL32.GetVersionExW=kexbases.0 +KERNEL32.GetVersionExA=kexbases.1 +KERNEL32.GetVersionExW=kexbases.1 [WIN98] inherit=WIN95 @@ -55,8 +51,8 @@ desc=Windows 98 SE [WIN98.names] KERNEL32.GetVersion=kexbases.1 -KERNEL32.GetVersionExA=kexbases.1 -KERNEL32.GetVersionExW=kexbases.1 +KERNEL32.GetVersionExA=kexbases.2 +KERNEL32.GetVersionExW=kexbases.2 [WINME] inherit=WIN98 @@ -64,8 +60,8 @@ desc=Windows Millennium [WINME.names] KERNEL32.GetVersion=kexbases.2 -KERNEL32.GetVersionExA=kexbases.2 -KERNEL32.GetVersionExW=kexbases.2 +KERNEL32.GetVersionExA=kexbases.3 +KERNEL32.GetVersionExW=kexbases.3 [NT40] inherit=WIN95 @@ -73,8 +69,8 @@ desc=Windows NT 4.0 SP6 [NT40.names] KERNEL32.GetVersion=kexbases.3 -KERNEL32.GetVersionExA=kexbases.3 -KERNEL32.GetVersionExW=kexbases.3 +KERNEL32.GetVersionExA=kexbases.4 +KERNEL32.GetVersionExW=kexbases.4 [NT2K] inherit=NT40 @@ -82,8 +78,8 @@ desc=Windows 2000 SP4 [NT2K.names] KERNEL32.GetVersion=kexbases.4 -KERNEL32.GetVersionExA=kexbases.4 -KERNEL32.GetVersionExW=kexbases.4 +KERNEL32.GetVersionExA=kexbases.5 +KERNEL32.GetVersionExW=kexbases.5 GDI32.SetWorldTransform=kexbases.1 GDI32.GetRandomRgn=kexbases.0 GDI32.SetGraphicsMode=kexbases.0 @@ -97,8 +93,8 @@ desc=Windows XP SP2 [WINXP.names] KERNEL32.GetVersion=kexbases.5 -KERNEL32.GetVersionExA=kexbases.5 -KERNEL32.GetVersionExW=kexbases.5 +KERNEL32.GetVersionExA=kexbases.6 +KERNEL32.GetVersionExW=kexbases.6 KERNEL32.VerifyVersionInfoA=kexbases.1 KERNEL32.VerifyVersionInfoW=kexbases.1 @@ -108,8 +104,8 @@ desc=Windows 2003 SP1 [WIN2K3.names] KERNEL32.GetVersion=kexbases.6 -KERNEL32.GetVersionExA=kexbases.6 -KERNEL32.GetVersionExW=kexbases.6 +KERNEL32.GetVersionExA=kexbases.7 +KERNEL32.GetVersionExW=kexbases.7 KERNEL32.VerifyVersionInfoA=kexbases.2 KERNEL32.VerifyVersionInfoW=kexbases.2 @@ -119,8 +115,8 @@ desc=Windows Vista [VISTA.names] KERNEL32.GetVersion=kexbases.7 -KERNEL32.GetVersionExA=kexbases.7 -KERNEL32.GetVersionExW=kexbases.7 +KERNEL32.GetVersionExA=kexbases.8 +KERNEL32.GetVersionExW=kexbases.8 KERNEL32.VerifyVersionInfoA=kexbases.3 KERNEL32.VerifyVersionInfoW=kexbases.3 @@ -130,7 +126,7 @@ desc=Windows 2008 SP1 [WIN2K8.names] KERNEL32.GetVersion=kexbases.8 -KERNEL32.GetVersionExA=kexbases.8 -KERNEL32.GetVersionExW=kexbases.8 +KERNEL32.GetVersionExA=kexbases.9 +KERNEL32.GetVersionExW=kexbases.9 KERNEL32.VerifyVersionInfoA=kexbases.4 KERNEL32.VerifyVersionInfoW=kexbases.4 diff --git a/apilibs/kexbasen/advapi32/_advapi32_apilist.c b/apilibs/kexbasen/advapi32/_advapi32_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/advapi32/_advapi32_apilist.h b/apilibs/kexbasen/advapi32/_advapi32_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/advapi32/uniadvapi32.c b/apilibs/kexbasen/advapi32/uniadvapi32.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/auxdecl.h b/apilibs/kexbasen/auxdecl.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/comdlg32/_comdlg32_apilist.c b/apilibs/kexbasen/comdlg32/_comdlg32_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/comdlg32/_comdlg32_apilist.h b/apilibs/kexbasen/comdlg32/_comdlg32_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/comdlg32/unicomdlg32.c b/apilibs/kexbasen/comdlg32/unicomdlg32.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/common.c b/apilibs/kexbasen/common.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/common.h b/apilibs/kexbasen/common.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/dirlist b/apilibs/kexbasen/dirlist old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/gdi32/UberGDI.c b/apilibs/kexbasen/gdi32/UberGDI.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/gdi32/_gdi32_apilist.c b/apilibs/kexbasen/gdi32/_gdi32_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/gdi32/_gdi32_apilist.h b/apilibs/kexbasen/gdi32/_gdi32_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/gdi32/unigdi32.c b/apilibs/kexbasen/gdi32/unigdi32.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/kernel32/_kernel32_apilist.c b/apilibs/kexbasen/kernel32/_kernel32_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/kernel32/_kernel32_apilist.h b/apilibs/kexbasen/kernel32/_kernel32_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/kernel32/unikernel32.c b/apilibs/kexbasen/kernel32/unikernel32.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/kexbasen.def b/apilibs/kexbasen/kexbasen.def old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/kexbasen.dsp b/apilibs/kexbasen/kexbasen.dsp old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/kexbasen.rc b/apilibs/kexbasen/kexbasen.rc old mode 100644 new mode 100755 index 1c374ea..9cebaad --- a/apilibs/kexbasen/kexbasen.rc +++ b/apilibs/kexbasen/kexbasen.rc @@ -54,8 +54,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,0,1,0 - PRODUCTVERSION 4,0,1,0 + FILEVERSION 4,0,1,2 + PRODUCTVERSION 4,0,1,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -73,14 +73,14 @@ BEGIN VALUE "Comments", "\0" VALUE "CompanyName", "Xeno86\0" VALUE "FileDescription", "KernelEx Base Non-shared Api Library\0" - VALUE "FileVersion", "4, 0, 1, 0\0" + VALUE "FileVersion", "4, 0, 1, 2\0" VALUE "InternalName", "kexbasen\0" VALUE "LegalCopyright", "Copyright © 2009, Xeno86\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "kexbasen.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "KernelEx\0" - VALUE "ProductVersion", "4, 0, 1, 0\0" + VALUE "ProductVersion", "4, 0, 1, 2\0" VALUE "SpecialBuild", "\0" END END diff --git a/apilibs/kexbasen/main.c b/apilibs/kexbasen/main.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/resource.h b/apilibs/kexbasen/resource.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/shell32/SHGetFolderLocation.c b/apilibs/kexbasen/shell32/SHGetFolderLocation.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/shell32/SHGetFolderPath.c b/apilibs/kexbasen/shell32/SHGetFolderPath.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/shell32/_shell32_apilist.c b/apilibs/kexbasen/shell32/_shell32_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/shell32/_shell32_apilist.h b/apilibs/kexbasen/shell32/_shell32_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/shell32/auxshlguid.h b/apilibs/kexbasen/shell32/auxshlguid.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/shell32/pidl.h b/apilibs/kexbasen/shell32/pidl.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/shell32/unishell32.c b/apilibs/kexbasen/shell32/unishell32.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/shell32ord.def b/apilibs/kexbasen/shell32ord.def old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/unifwd.c b/apilibs/kexbasen/unifwd.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/unifwd.h b/apilibs/kexbasen/unifwd.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbasen/user32/_user32_apilist.c b/apilibs/kexbasen/user32/_user32_apilist.c old mode 100644 new mode 100755 index dd76168..1ee7eb2 --- a/apilibs/kexbasen/user32/_user32_apilist.c +++ b/apilibs/kexbasen/user32/_user32_apilist.c @@ -87,7 +87,6 @@ static const apilib_named_api user32_named_apis[] = DECL_API("GetKeyboardLayoutNameW", GetKeyboardLayoutNameW_fwd), DECL_API("GetMenuItemInfoW", GetMenuItemInfoW_fwd), DECL_API("GetMenuStringW", GetMenuStringW_fwd), - DECL_API("GetMessageW", GetMessageW_fwd), DECL_API("GetMonitorInfoW", GetMonitorInfoW_fwd), DECL_API("GetPropW", GetPropW_fwd), DECL_API("GetTabbedTextExtentW", GetTabbedTextExtentW_fwd), diff --git a/apilibs/kexbasen/user32/_user32_apilist.h b/apilibs/kexbasen/user32/_user32_apilist.h old mode 100644 new mode 100755 index 923d2e4..2d11c4e --- a/apilibs/kexbasen/user32/_user32_apilist.h +++ b/apilibs/kexbasen/user32/_user32_apilist.h @@ -83,7 +83,6 @@ FWDPROC GetKeyboardLayoutNameW_fwd; FWDPROC GetKeyNameTextW_fwd; FWDPROC GetMenuItemInfoW_fwd; FWDPROC GetMenuStringW_fwd; -FWDPROC GetMessageW_fwd; FWDPROC GetMonitorInfoW_fwd; FWDPROC GetPropW_fwd; FWDPROC GetTabbedTextExtentW_fwd; diff --git a/apilibs/kexbasen/user32/uniuser32.c b/apilibs/kexbasen/user32/uniuser32.c old mode 100644 new mode 100755 index 8357a78..43b18f6 --- a/apilibs/kexbasen/user32/uniuser32.c +++ b/apilibs/kexbasen/user32/uniuser32.c @@ -106,7 +106,6 @@ FORWARD_TO_UNICOWS(GetKeyboardLayoutNameW); FORWARD_TO_UNICOWS(GetKeyNameTextW); FORWARD_TO_UNICOWS(GetMenuItemInfoW); FORWARD_TO_UNICOWS(GetMenuStringW); -FORWARD_TO_UNICOWS(GetMessageW); FORWARD_TO_UNICOWS(GetMonitorInfoW); FORWARD_TO_UNICOWS(GetPropW); FORWARD_TO_UNICOWS(GetTabbedTextExtentW); diff --git a/apilibs/kexbases/Advapi32/OpenSCManager_stub.c b/apilibs/kexbases/Advapi32/OpenSCManager_stub.c new file mode 100755 index 0000000..014b240 --- /dev/null +++ b/apilibs/kexbases/Advapi32/OpenSCManager_stub.c @@ -0,0 +1,36 @@ +/* + * KernelEx + * Copyright (C) 2009, Xeno86 + * + * This file is part of KernelEx source code. + * + * KernelEx is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * KernelEx is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include + +/* MAKE_EXPORT OpenSCManagerA_stub=OpenSCManagerA */ +SC_HANDLE WINAPI OpenSCManagerA_stub(LPCSTR lpMachineName, LPCSTR lpDatabaseName, + DWORD dwDesiredAccess) +{ + return (SC_HANDLE) 0xCAFE; +} + +/* MAKE_EXPORT OpenSCManagerW_stub=OpenSCManagerW */ +SC_HANDLE WINAPI OpenSCManagerW_stub(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, + DWORD dwDesiredAccess) +{ + return (SC_HANDLE) 0xCAFE; +} diff --git a/apilibs/kexbases/Advapi32/RegDisablePredefinedCache.c b/apilibs/kexbases/Advapi32/RegDisablePredefinedCache.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Advapi32/RegOpenCurrentUser.c b/apilibs/kexbases/Advapi32/RegOpenCurrentUser.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Advapi32/TraceMessage.c b/apilibs/kexbases/Advapi32/TraceMessage.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Advapi32/_advapi32_apilist.c b/apilibs/kexbases/Advapi32/_advapi32_apilist.c old mode 100644 new mode 100755 index cca4c64..96105a6 --- a/apilibs/kexbases/Advapi32/_advapi32_apilist.c +++ b/apilibs/kexbases/Advapi32/_advapi32_apilist.c @@ -89,6 +89,8 @@ static const apilib_named_api advapi32_named_apis[] = DECL_API("MakeSelfRelativeSD", MakeSelfRelativeSD_new), DECL_API("NotifyBootConfigStatus", NotifyBootConfigStatus_new), DECL_API("OpenProcessToken", OpenProcessToken_new), + DECL_API("OpenSCManagerA", OpenSCManagerA_stub), + DECL_API("OpenSCManagerW", OpenSCManagerW_stub), DECL_API("OpenThreadToken", OpenThreadToken_new), DECL_API("PrivilegeCheck", PrivilegeCheck_new), DECL_API("QueryServiceStatusEx", QueryServiceStatusEx_stub), diff --git a/apilibs/kexbases/Advapi32/_advapi32_apilist.h b/apilibs/kexbases/Advapi32/_advapi32_apilist.h old mode 100644 new mode 100755 index 279899b..b40041e --- a/apilibs/kexbases/Advapi32/_advapi32_apilist.h +++ b/apilibs/kexbases/Advapi32/_advapi32_apilist.h @@ -29,6 +29,8 @@ BOOL init_advapi32(); extern const apilib_api_table apitable_advapi32; /*** AUTOGENERATED APILIST DECLARATIONS BEGIN ***/ +SC_HANDLE WINAPI OpenSCManagerA_stub(LPCSTR lpMachineName, LPCSTR lpDatabaseName, DWORD dwDesiredAccess); +SC_HANDLE WINAPI OpenSCManagerW_stub(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess); BOOL WINAPI RegDisablePredefinedCache_new(); LONG WINAPI RegOpenCurrentUser_new(REGSAM access, PHKEY retkey); ULONG CDECL TraceMessage_new(ULONG64 LoggerHandle, ULONG MessageFlags, LPGUID MessageGuid, USHORT MessageNumber, ...); diff --git a/apilibs/kexbases/Advapi32/_advapi32_stubs.c b/apilibs/kexbases/Advapi32/_advapi32_stubs.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Advapi32/security.c b/apilibs/kexbases/Advapi32/security.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Advapi32/uniadvapi32.c b/apilibs/kexbases/Advapi32/uniadvapi32.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Gdi32/FontResourceExA.c b/apilibs/kexbases/Gdi32/FontResourceExA.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Gdi32/GetGlyphOutlineA_fix.c b/apilibs/kexbases/Gdi32/GetGlyphOutlineA_fix.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Gdi32/TextOut.c b/apilibs/kexbases/Gdi32/TextOut.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Gdi32/_gdi32_apilist.c b/apilibs/kexbases/Gdi32/_gdi32_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Gdi32/_gdi32_apilist.h b/apilibs/kexbases/Gdi32/_gdi32_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Gdi32/_gdi32_stubs.c b/apilibs/kexbases/Gdi32/_gdi32_stubs.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Gdi32/unigdi32.c b/apilibs/kexbases/Gdi32/unigdi32.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/CopyFileEx.c b/apilibs/kexbases/Kernel32/CopyFileEx.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/CreateFileA_fix.c b/apilibs/kexbases/Kernel32/CreateFileA_fix.c deleted file mode 100644 index 6f178fa..0000000 --- a/apilibs/kexbases/Kernel32/CreateFileA_fix.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * KernelEx - * Copyright (C) 2008-2009, Xeno86 - * - * This file is part of KernelEx source code. - * - * KernelEx is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; version 2 of the License. - * - * KernelEx is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include - -/* MAKE_EXPORT CreateFileA_fix=CreateFileA */ -HANDLE WINAPI CreateFileA_fix(LPCSTR lpFileName, DWORD dwDesiredAccess, - DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, - DWORD dwCreationDistribution, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) -{ - /* translate NT-specific access rights to generic ones */ - if (dwDesiredAccess & ~0xf0010100) - { - DWORD oldaccess = dwDesiredAccess; - dwDesiredAccess &= 0xf0010100; - if (oldaccess & FILE_READ_DATA) - dwDesiredAccess |= GENERIC_READ; - if (oldaccess & FILE_WRITE_DATA) - dwDesiredAccess |= GENERIC_WRITE; - if (oldaccess & FILE_EXECUTE) - dwDesiredAccess |= GENERIC_EXECUTE; - } - // hTemplate has to be NULL on 9x - return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, - dwCreationDistribution, dwFlagsAndAttributes, NULL); -} diff --git a/apilibs/kexbases/Kernel32/CreateThread_fix.c b/apilibs/kexbases/Kernel32/CreateThread_fix.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/DeleteCriticalSection.c b/apilibs/kexbases/Kernel32/DeleteCriticalSection.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/FileApis_fix.c b/apilibs/kexbases/Kernel32/FileApis_fix.c new file mode 100755 index 0000000..f3aef18 --- /dev/null +++ b/apilibs/kexbases/Kernel32/FileApis_fix.c @@ -0,0 +1,107 @@ +/* + * KernelEx + * Copyright (C) 2008-2009, Xeno86 + * + * This file is part of KernelEx source code. + * + * KernelEx is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * KernelEx is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include + +/* MAKE_EXPORT CreateFileA_fix=CreateFileA */ +HANDLE WINAPI CreateFileA_fix(LPCSTR lpFileName, DWORD dwDesiredAccess, + DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDistribution, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) +{ + /* translate NT-specific access rights to generic ones */ + if (dwDesiredAccess & ~0xf0010100) + { + DWORD oldaccess = dwDesiredAccess; + dwDesiredAccess &= 0xf0010100; + if (oldaccess & FILE_READ_DATA) + dwDesiredAccess |= GENERIC_READ; + if (oldaccess & FILE_WRITE_DATA) + dwDesiredAccess |= GENERIC_WRITE; + if (oldaccess & FILE_EXECUTE) + dwDesiredAccess |= GENERIC_EXECUTE; + } + // hTemplate has to be NULL on 9x + hTemplateFile = NULL; + // special case: overlapped I/O + if (dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED) + { + DWORD lasterr = GetLastError(); + HANDLE h; + h = CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, + dwCreationDistribution, dwFlagsAndAttributes, hTemplateFile); + if (h != INVALID_HANDLE_VALUE) + return h; + SetLastError(lasterr); + dwFlagsAndAttributes &= ~FILE_FLAG_OVERLAPPED; + } + return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, + dwCreationDistribution, dwFlagsAndAttributes, hTemplateFile); +} + +/* MAKE_EXPORT ReadFile_fix=ReadFile */ +BOOL WINAPI ReadFile_fix(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped) +{ + DWORD lasterr = GetLastError(); + + if (ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, + lpOverlapped)) + return TRUE; + + if (lpOverlapped && GetLastError() == ERROR_INVALID_PARAMETER) + { + LONG high = lpOverlapped->OffsetHigh; + DWORD nr; + SetLastError(lasterr); + if ((SetFilePointer(hFile, lpOverlapped->Offset, &high, FILE_BEGIN) + == (DWORD)-1 && GetLastError() != NO_ERROR) || + (ReadFile(hFile, lpBuffer, nNumberOfBytesToRead, &nr, 0) && !nr)) + { + SetLastError(ERROR_HANDLE_EOF); + return FALSE; + } + *lpNumberOfBytesRead = nr; + return TRUE; + } + return FALSE; +} + +/* MAKE_EXPORT WriteFile_fix=WriteFile */ +BOOL WINAPI WriteFile_fix(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped) +{ + DWORD lasterr = GetLastError(); + + if (WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, + lpNumberOfBytesWritten, lpOverlapped)) + return TRUE; + + if (lpOverlapped && GetLastError() == ERROR_INVALID_PARAMETER) + { + LONG high = lpOverlapped->OffsetHigh; + SetLastError(lasterr); + if ((SetFilePointer(hFile, lpOverlapped->Offset, &high, FILE_BEGIN) + == (DWORD)-1 && GetLastError() != NO_ERROR)) + return FALSE; + return WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, 0); + } + return FALSE; +} diff --git a/apilibs/kexbases/Kernel32/GetConsoleWindow.c b/apilibs/kexbases/Kernel32/GetConsoleWindow.c new file mode 100755 index 0000000..3602b18 --- /dev/null +++ b/apilibs/kexbases/Kernel32/GetConsoleWindow.c @@ -0,0 +1,47 @@ +/* + * KernelEx + * Copyright (C) 2009, Xeno86 + * + * This file is part of KernelEx source code. + * + * KernelEx is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * KernelEx is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include + +BOOL CALLBACK GetConsoleWindowEnum(HWND hwnd, LPARAM lparam) +{ + char name[5]; + if (GetClassName(hwnd, name, sizeof(name)) == (sizeof("tty")-1) + && !strcmp(name, "tty")) + { + DWORD pid; + GetWindowThreadProcessId(hwnd, &pid); + if (pid == GetCurrentProcessId()) + { + *(HWND*) lparam = hwnd; + return FALSE; + } + } + return TRUE; +} + +/* MAKE_EXPORT GetConsoleWindow_new=GetConsoleWindow */ +HWND WINAPI GetConsoleWindow_new() +{ + HWND window = NULL; + EnumWindows(GetConsoleWindowEnum, (LPARAM) &window); + return window; +} diff --git a/apilibs/kexbases/Kernel32/GetFileSizeEx.c b/apilibs/kexbases/Kernel32/GetFileSizeEx.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/GlobalMemoryStatusEx.c b/apilibs/kexbases/Kernel32/GlobalMemoryStatusEx.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/HeapLocks.c b/apilibs/kexbases/Kernel32/HeapLocks.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/InitializeCriticalSectionAndSpinCount.c b/apilibs/kexbases/Kernel32/InitializeCriticalSectionAndSpinCount.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/IsProcessorFeaturePresent.c b/apilibs/kexbases/Kernel32/IsProcessorFeaturePresent.c new file mode 100755 index 0000000..269323b --- /dev/null +++ b/apilibs/kexbases/Kernel32/IsProcessorFeaturePresent.c @@ -0,0 +1,102 @@ +/* + * Copyright 2009 Xeno86 + * Copyright 1995,1997 Morten Welinder + * Copyright 1997-1998 Marcus Meissner + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +/* Processor feature flags. */ +#define PF_FLOATING_POINT_PRECISION_ERRATA 0 +#define PF_FLOATING_POINT_EMULATED 1 +#define PF_COMPARE_EXCHANGE_DOUBLE 2 +#define PF_MMX_INSTRUCTIONS_AVAILABLE 3 +#define PF_PPC_MOVEMEM_64BIT_OK 4 +#define PF_ALPHA_BYTE_INSTRUCTIONS 5 +#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 +#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 +#define PF_RDTSC_INSTRUCTION_AVAILABLE 8 +#define PF_PAE_ENABLED 9 +#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 +#define PF_SSE_DAZ_MODE_AVAILABLE 11 +#define PF_NX_ENABLED 12 +#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 +#define PF_COMPARE_EXCHANGE128 14 +#define PF_COMPARE64_EXCHANGE128 15 +#define PF_CHANNELS_ENABLED 16 + +#define AUTH 0x68747541 /* "Auth" */ +#define ENTI 0x69746e65 /* "enti" */ +#define CAMD 0x444d4163 /* "cAMD" */ + +static BYTE PF[17] = {0,}; + +static void do_cpuid(unsigned int _eax, unsigned int *p) +{ +#ifdef __GNUC__ + __asm__("cpuid" + : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) + : "a" (_eax)); +#else + __asm { + mov eax, _eax + mov edi, p + cpuid + mov [edi], eax + mov [edi+4], ebx + mov [edi+8], ecx + mov [edi+12], edx + } +#endif +} + +void get_cpuinfo() +{ + unsigned int regs[4], regs2[4]; + + do_cpuid(0x00000000, regs); /* get standard cpuid level and vendor name */ + if (regs[0]>=0x00000001) /* Check for supported cpuid version */ + { + do_cpuid(0x00000001, regs2); /* get cpu features */ + PF[PF_FLOATING_POINT_EMULATED] = !(regs2[3] & 1); + PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = (regs2[3] & (1 << 4 )) >> 4; + PF[PF_COMPARE_EXCHANGE_DOUBLE] = (regs2[3] & (1 << 8 )) >> 8; + PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 23)) >> 23; + PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 25)) >> 25; + PF[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 26)) >> 26; + PF[PF_SSE3_INSTRUCTIONS_AVAILABLE] = (regs2[2] & 1); + + if (regs[1] == AUTH && + regs[3] == ENTI && + regs[2] == CAMD) { + do_cpuid(0x80000000, regs); /* get vendor cpuid level */ + if (regs[0]>=0x80000001) { + do_cpuid(0x80000001, regs2); /* get vendor features */ + PF[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (regs2[3] & (1 << 31)) >> 31; + } + } + } +} + +/* MAKE_EXPORT IsProcessorFeaturePresent_new=IsProcessorFeaturePresent */ +BOOL WINAPI IsProcessorFeaturePresent_new(DWORD feature) +{ + if (feature < 17) + return PF[feature]; + else + return FALSE; +} diff --git a/apilibs/kexbases/Kernel32/Jobs.c b/apilibs/kexbases/Kernel32/Jobs.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/KEXVersion.c b/apilibs/kexbases/Kernel32/KEXVersion.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/LockFileEx.c b/apilibs/kexbases/Kernel32/LockFileEx.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/MapViewOfFile.c b/apilibs/kexbases/Kernel32/MapViewOfFile.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/MoveFileExA.c b/apilibs/kexbases/Kernel32/MoveFileExA.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/MoveFileWithProgressA.c b/apilibs/kexbases/Kernel32/MoveFileWithProgressA.c old mode 100644 new mode 100755 index 8b21ec0..c72e2dc --- a/apilibs/kexbases/Kernel32/MoveFileWithProgressA.c +++ b/apilibs/kexbases/Kernel32/MoveFileWithProgressA.c @@ -20,9 +20,11 @@ */ #include +#include +#include "_kernel32_apilist.h" /* MAKE_EXPORT MoveFileWithProgressA_new=MoveFileWithProgressA */ BOOL WINAPI MoveFileWithProgressA_new(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, LPPROGRESS_ROUTINE lpProgressRoutine, LPVOID lpData, DWORD dwFlags) { - return MoveFileExA(lpExistingFileName, lpNewFileName, dwFlags); + return MoveFileExA_new(lpExistingFileName, lpNewFileName, dwFlags); } diff --git a/apilibs/kexbases/Kernel32/OpenThread.c b/apilibs/kexbases/Kernel32/OpenThread.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/SetFilePointerEx.c b/apilibs/kexbases/Kernel32/SetFilePointerEx.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/ThreadPool.c b/apilibs/kexbases/Kernel32/ThreadPool.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/TryEnterCriticalSection.c b/apilibs/kexbases/Kernel32/TryEnterCriticalSection.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/VirtualAllocEx.c b/apilibs/kexbases/Kernel32/VirtualAllocEx.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/_kernel32_apilist.c b/apilibs/kexbases/Kernel32/_kernel32_apilist.c old mode 100644 new mode 100755 index a878c22..4f678b3 --- a/apilibs/kexbases/Kernel32/_kernel32_apilist.c +++ b/apilibs/kexbases/Kernel32/_kernel32_apilist.c @@ -28,11 +28,13 @@ http://17slon.com/blogs/gabr/2007/02/four-ways-to-detect-vista.html #include "kexcoresdk.h" #include "_kernel32_apilist.h" +void get_cpuinfo(); BOOL init_tryentercritsec(); BOOL init_openthread(); BOOL init_kernel32() { + get_cpuinfo(); return init_tryentercritsec() && init_openthread(); } @@ -73,7 +75,7 @@ static const apilib_named_api kernel32_named_apis[] = DECL_API("FindResourceExW", FindResourceExW_new), DECL_API("FindResourceW", FindResourceW_new), DECL_API("FreeEnvironmentStringsW", FreeEnvironmentStringsW_new), - DECL_API("GetConsoleWindow", GetConsoleWindow_stub), + DECL_API("GetConsoleWindow", GetConsoleWindow_new), DECL_API("GetCurrentDirectoryW", GetCurrentDirectoryW_new), DECL_API("GetDefaultCommConfigW", GetDefaultCommConfigW_new), DECL_API("GetDiskFreeSpaceExW", GetDiskFreeSpaceExW_new), @@ -103,6 +105,7 @@ static const apilib_named_api kernel32_named_apis[] = DECL_API("GetVersion", GetVersion_WIN2K3), DECL_API("GetVersion", GetVersion_VISTA), DECL_API("GetVersion", GetVersion_WIN2K8), + DECL_API("GetVersionExA", GetVersionExA_ORIG), DECL_API("GetVersionExA", GetVersionExA_WIN95), DECL_API("GetVersionExA", GetVersionExA_WIN98), DECL_API("GetVersionExA", GetVersionExA_WINME), @@ -112,6 +115,7 @@ static const apilib_named_api kernel32_named_apis[] = DECL_API("GetVersionExA", GetVersionExA_WIN2K3), DECL_API("GetVersionExA", GetVersionExA_VISTA), DECL_API("GetVersionExA", GetVersionExA_WIN2K8), + DECL_API("GetVersionExW", GetVersionExW_ORIG), DECL_API("GetVersionExW", GetVersionExW_WIN95), DECL_API("GetVersionExW", GetVersionExW_WIN98), DECL_API("GetVersionExW", GetVersionExW_WINME), @@ -130,6 +134,7 @@ static const apilib_named_api kernel32_named_apis[] = DECL_API("HeapUnlock", HeapUnlock_new), DECL_API("InitializeCriticalSectionAndSpinCount", InitializeCriticalSectionAndSpinCount_new), DECL_API("IsProcessInJob", IsProcessInJob_new), + DECL_API("IsProcessorFeaturePresent", IsProcessorFeaturePresent_new), DECL_API("IsValidLanguageGroup", IsValidLanguageGroup_stub), DECL_API("KEXVersion", KEXVersion), DECL_API("LockFileEx", LockFileEx_new), @@ -149,6 +154,7 @@ static const apilib_named_api kernel32_named_apis[] = DECL_API("Process32NextW", Process32NextW_new), DECL_API("QueryInformationJobObject", QueryInformationJobObject_new), DECL_API("QueueUserWorkItem", QueueUserWorkItem_stub), + DECL_API("ReadFile", ReadFile_fix), DECL_API("RegisterWaitForSingleObject", RegisterWaitForSingleObject_new), DECL_API("RegisterWaitForSingleObjectEx", RegisterWaitForSingleObjectEx_new), DECL_API("RemoveDirectoryW", RemoveDirectoryW_new), @@ -179,6 +185,7 @@ static const apilib_named_api kernel32_named_apis[] = DECL_API("VerifyVersionInfoW", VerifyVersionInfoW_WIN2K8), DECL_API("VirtualAllocEx", VirtualAllocEx_new), DECL_API("VirtualFreeEx", VirtualFreeEx_new), + DECL_API("WriteFile", WriteFile_fix), DECL_API("lstrcpynW", lstrcpynW_new), /*** AUTOGENERATED APILIST NAMED EXPORTS END ***/ }; diff --git a/apilibs/kexbases/Kernel32/_kernel32_apilist.h b/apilibs/kexbases/Kernel32/_kernel32_apilist.h old mode 100644 new mode 100755 index 2c24e1c..a341ac8 --- a/apilibs/kexbases/Kernel32/_kernel32_apilist.h +++ b/apilibs/kexbases/Kernel32/_kernel32_apilist.h @@ -31,14 +31,18 @@ extern const apilib_api_table apitable_kernel32; /*** AUTOGENERATED APILIST DECLARATIONS BEGIN ***/ BOOL WINAPI CopyFileExA_new(LPCSTR lpExistingFileNameA, LPCSTR lpNewFileNameA, LPPROGRESS_ROUTINE lpProgressRoutine, LPVOID lpData, LPBOOL pbCancel, DWORD dwCopyFlags); -HANDLE WINAPI CreateFileA_fix(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDistribution, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); HANDLE WINAPI CreateThread_fix(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); void WINAPI DeleteCriticalSection_new(PCRITICAL_SECTION lpCriticalSection); +HANDLE WINAPI CreateFileA_fix(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDistribution, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile); +BOOL WINAPI ReadFile_fix(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); +BOOL WINAPI WriteFile_fix(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped); +HWND WINAPI GetConsoleWindow_new(); BOOL WINAPI GetFileSizeEx_new(HANDLE hFile, PLARGE_INTEGER lpFileSize); BOOL WINAPI GlobalMemoryStatusEx_new(LPMEMORYSTATUSEX lpmemex); BOOL WINAPI HeapLock_new(HANDLE hHeap); BOOL WINAPI HeapUnlock_new(HANDLE hHeap); BOOL WINAPI InitializeCriticalSectionAndSpinCount_new(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount); +BOOL WINAPI IsProcessorFeaturePresent_new(DWORD feature); HANDLE WINAPI CreateJobObjectA_new(LPSECURITY_ATTRIBUTES sa, LPCSTR name); HANDLE WINAPI CreateJobObjectW_new(LPSECURITY_ATTRIBUTES sa, LPCWSTR name); BOOL WINAPI TerminateJobObject_new(HANDLE job, UINT exit_code); @@ -64,7 +68,6 @@ LPVOID WINAPI VirtualAllocEx_new(HANDLE hProcess, LPVOID lpAddress, DWORD dwSize BOOL WINAPI VirtualFreeEx_new(HANDLE hProcess, LPVOID lpAddress, DWORD dwSize, DWORD dwFreeType); STUB CreateHardLinkA_stub; STUB CreateHardLinkW_stub; -STUB GetConsoleWindow_stub; STUB IsValidLanguageGroup_stub; STUB QueueUserWorkItem_stub; STUB ReplaceFileA_stub; @@ -132,6 +135,8 @@ DWORD WINAPI GetVersion_WINXP(void); DWORD WINAPI GetVersion_WIN2K3(void); DWORD WINAPI GetVersion_VISTA(void); DWORD WINAPI GetVersion_WIN2K8(void); +BOOL WINAPI GetVersionExA_ORIG(LPOSVERSIONINFOA lpVersionInfo); +BOOL WINAPI GetVersionExW_ORIG(LPOSVERSIONINFOW lpVersionInfo); BOOL WINAPI GetVersionExA_WIN95(LPOSVERSIONINFOA lpVersionInfo); BOOL WINAPI GetVersionExW_WIN95(LPOSVERSIONINFOW lpVersionInfo); BOOL WINAPI GetVersionExA_WIN98(LPOSVERSIONINFOA lpVersionInfo); diff --git a/apilibs/kexbases/Kernel32/_kernel32_stubs.c b/apilibs/kexbases/Kernel32/_kernel32_stubs.c old mode 100644 new mode 100755 index 5972330..ec4fa01 --- a/apilibs/kexbases/Kernel32/_kernel32_stubs.c +++ b/apilibs/kexbases/Kernel32/_kernel32_stubs.c @@ -23,7 +23,6 @@ UNIMPL_FUNC(CreateHardLinkA, 3); UNIMPL_FUNC(CreateHardLinkW, 3); -UNIMPL_FUNC(GetConsoleWindow, 0); UNIMPL_FUNC(IsValidLanguageGroup, 2); UNIMPL_FUNC(QueueUserWorkItem, 3); UNIMPL_FUNC(ReplaceFileA, 6); diff --git a/apilibs/kexbases/Kernel32/uilang.c b/apilibs/kexbases/Kernel32/uilang.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/unikernel32.c b/apilibs/kexbases/Kernel32/unikernel32.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/Kernel32/version.c b/apilibs/kexbases/Kernel32/version.c old mode 100644 new mode 100755 index 312a138..b663d36 --- a/apilibs/kexbases/Kernel32/version.c +++ b/apilibs/kexbases/Kernel32/version.c @@ -109,6 +109,64 @@ static const OSVERSIONINFOEXA_PRIV VersionData[NB_WINDOWS_VERSIONS] = } }; +static BOOL original_GetVersionEx(void* buf, BOOL unicode) +{ + BOOL ret; + OSVERSIONINFOA* ver = (OSVERSIONINFOA*) buf; + DWORD structsize = ver->dwOSVersionInfoSize; + + if (!unicode) + { + if (structsize != sizeof(OSVERSIONINFOA) && structsize != sizeof(OSVERSIONINFOEXA)) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return FALSE; + } + } + else + { + if (structsize != sizeof(OSVERSIONINFOW) && structsize != sizeof(OSVERSIONINFOEXW)) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return FALSE; + } + } + + ver->dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); + ret = GetVersionExA(ver); + if (ret) + { + char csdVer[128]; + OSVERSIONINFOEXA* verexA = (OSVERSIONINFOEXA*) ver; + OSVERSIONINFOEXW* verexW = (OSVERSIONINFOEXW*) ver; + + switch (structsize) + { + case sizeof(OSVERSIONINFOEXA): + verexA->wServicePackMajor = 0; + verexA->wServicePackMinor = 0; + verexA->wSuiteMask = 0; + verexA->wProductType = 0; + verexA->wReserved = 0; + case sizeof(OSVERSIONINFOA): + break; + case sizeof(OSVERSIONINFOEXW): + verexW->wServicePackMajor = 0; + verexW->wServicePackMinor = 0; + verexW->wSuiteMask = 0; + verexW->wProductType = 0; + verexW->wReserved = 0; + case sizeof(OSVERSIONINFOW): + strcpy(csdVer, ver->szCSDVersion); + MultiByteToWideChar(CP_ACP, 0, csdVer, -1, verexW->szCSDVersion, + sizeof(csdVer)); + break; + } + } + ver->dwOSVersionInfoSize = structsize; + return ret; +} + static DWORD common_GetVersion(WINDOWS_VERSION version) { const OSVERSIONINFOEXA_PRIV* osv = &VersionData[version]; @@ -404,6 +462,18 @@ DWORD WINAPI GetVersion_WIN2K8(void) return common_GetVersion(WIN2K8); } +/* MAKE_EXPORT GetVersionExA_ORIG=GetVersionExA */ +BOOL WINAPI GetVersionExA_ORIG(LPOSVERSIONINFOA lpVersionInfo) +{ + return original_GetVersionEx(lpVersionInfo, FALSE); +} + +/* MAKE_EXPORT GetVersionExW_ORIG=GetVersionExW */ +BOOL WINAPI GetVersionExW_ORIG(LPOSVERSIONINFOW lpVersionInfo) +{ + return original_GetVersionEx(lpVersionInfo, TRUE); +} + /* MAKE_EXPORT GetVersionExA_WIN95=GetVersionExA */ BOOL WINAPI GetVersionExA_WIN95(LPOSVERSIONINFOA lpVersionInfo) { diff --git a/apilibs/kexbases/User32/CallWindowProcA_fix.c b/apilibs/kexbases/User32/CallWindowProcA_fix.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/DisableProcessWindowsGhosting.c b/apilibs/kexbases/User32/DisableProcessWindowsGhosting.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/EnableWindow.c b/apilibs/kexbases/User32/EnableWindow.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/ForegroundWindow.c b/apilibs/kexbases/User32/ForegroundWindow.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/GetAncestor.c b/apilibs/kexbases/User32/GetAncestor.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/GetMouseMovePointsEx.c b/apilibs/kexbases/User32/GetMouseMovePointsEx.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/IsHungAppWindow.c b/apilibs/kexbases/User32/IsHungAppWindow.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/LockWorkStation.c b/apilibs/kexbases/User32/LockWorkStation.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/MapVirtualKey_fix.c b/apilibs/kexbases/User32/MapVirtualKey_fix.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/SendMessage_fix.c b/apilibs/kexbases/User32/SendMessage_fix.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/UberUSER.c b/apilibs/kexbases/User32/UberUSER.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/UpdateLayeredWindow.c b/apilibs/kexbases/User32/UpdateLayeredWindow.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/_user32_apilist.c b/apilibs/kexbases/User32/_user32_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/_user32_apilist.h b/apilibs/kexbases/User32/_user32_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/_user32_stubs.c b/apilibs/kexbases/User32/_user32_stubs.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/User32/uniuser32.c b/apilibs/kexbases/User32/uniuser32.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/auxdecl.h b/apilibs/kexbases/auxdecl.h old mode 100644 new mode 100755 index 5f0e8eb..df1b2a5 --- a/apilibs/kexbases/auxdecl.h +++ b/apilibs/kexbases/auxdecl.h @@ -109,7 +109,6 @@ typedef void *LPMOUSEMOVEPOINT; EXTERN_C int WINAPI GetRandomRgn(HDC hdc, HRGN hrgn, INT iNum); EXTERN_C HRESULT WINAPI SHGetFolderPathA(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPSTR pszPath); EXTERN_C HWND WINAPI GetAncestor(HWND hwnd, UINT gaFlags); -EXTERN_C UINT WINAPI RealGetWindowClass(HWND hwnd, LPTSTR pszType, UINT cchType); #endif /* defined (_MSC_VER) && (WINVER < 0x0500) */ @@ -131,6 +130,13 @@ typedef struct { #endif /* __MINGW32_VERSION */ /* declarations for everyone */ +#ifdef GetAltTabInfo +#undef GetAltTabInfo +#endif EXTERN_C BOOL WINAPI GetAltTabInfo(HWND,int,PVOID,LPSTR,UINT); +#ifdef RealGetWindowClass +#undef RealGetWindowClass +#endif +EXTERN_C UINT WINAPI RealGetWindowClass(HWND hwnd, LPTSTR pszType, UINT cchType); #endif /* __AUXDECL_H */ diff --git a/apilibs/kexbases/comdlg32/PrintDlgEx.c b/apilibs/kexbases/comdlg32/PrintDlgEx.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/comdlg32/_comdlg32_apilist.c b/apilibs/kexbases/comdlg32/_comdlg32_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/comdlg32/_comdlg32_apilist.h b/apilibs/kexbases/comdlg32/_comdlg32_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/common.c b/apilibs/kexbases/common.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/common.h b/apilibs/kexbases/common.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/dirlist b/apilibs/kexbases/dirlist old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/kernel32ord.def b/apilibs/kexbases/kernel32ord.def old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/kexbases.def b/apilibs/kexbases/kexbases.def old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/kexbases.dsp b/apilibs/kexbases/kexbases.dsp old mode 100644 new mode 100755 index f684c1a..7def755 --- a/apilibs/kexbases/kexbases.dsp +++ b/apilibs/kexbases/kexbases.dsp @@ -113,10 +113,6 @@ SOURCE=.\Kernel32\CopyFileEx.c # End Source File # Begin Source File -SOURCE=.\Kernel32\CreateFileA_fix.c -# End Source File -# Begin Source File - SOURCE=.\Kernel32\CreateThread_fix.c # End Source File # Begin Source File @@ -125,6 +121,14 @@ SOURCE=.\Kernel32\DeleteCriticalSection.c # End Source File # Begin Source File +SOURCE=.\Kernel32\FileApis_fix.c +# End Source File +# Begin Source File + +SOURCE=.\Kernel32\GetConsoleWindow.c +# End Source File +# Begin Source File + SOURCE=.\Kernel32\GetFileSizeEx.c # End Source File # Begin Source File @@ -141,6 +145,10 @@ SOURCE=.\Kernel32\InitializeCriticalSectionAndSpinCount.c # End Source File # Begin Source File +SOURCE=.\Kernel32\IsProcessorFeaturePresent.c +# End Source File +# Begin Source File + SOURCE=.\Kernel32\Jobs.c # End Source File # Begin Source File @@ -313,6 +321,10 @@ SOURCE=.\Advapi32\_advapi32_stubs.c # End Source File # Begin Source File +SOURCE=.\Advapi32\OpenSCManager_stub.c +# End Source File +# Begin Source File + SOURCE=.\Advapi32\RegDisablePredefinedCache.c # End Source File # Begin Source File diff --git a/apilibs/kexbases/kexbases.rc b/apilibs/kexbases/kexbases.rc old mode 100644 new mode 100755 index 91a409e..be69f0c --- a/apilibs/kexbases/kexbases.rc +++ b/apilibs/kexbases/kexbases.rc @@ -54,8 +54,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,0,1,0 - PRODUCTVERSION 4,0,1,0 + FILEVERSION 4,0,1,2 + PRODUCTVERSION 4,0,1,2 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -73,14 +73,14 @@ BEGIN VALUE "Comments", "\0" VALUE "CompanyName", "Xeno86\0" VALUE "FileDescription", "KernelEx Base Shared Api Library\0" - VALUE "FileVersion", "4, 0, 1, 0\0" + VALUE "FileVersion", "4, 0, 1, 2\0" VALUE "InternalName", "kexbases\0" VALUE "LegalCopyright", "Copyright © 2009, Xeno86\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "kexbases.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "KernelEx\0" - VALUE "ProductVersion", "4, 0, 1, 0\0" + VALUE "ProductVersion", "4, 0, 1, 2\0" VALUE "SpecialBuild", "\0" END END diff --git a/apilibs/kexbases/main.c b/apilibs/kexbases/main.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/resource.h b/apilibs/kexbases/resource.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/shell32/CommandLineToArgvW.c b/apilibs/kexbases/shell32/CommandLineToArgvW.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/shell32/IsUserAnAdmin.c b/apilibs/kexbases/shell32/IsUserAnAdmin.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/shell32/_shell32_apilist.c b/apilibs/kexbases/shell32/_shell32_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/shell32/_shell32_apilist.h b/apilibs/kexbases/shell32/_shell32_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/shell32/_shell32_stubs.c b/apilibs/kexbases/shell32/_shell32_stubs.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/version/_version_apilist.c b/apilibs/kexbases/version/_version_apilist.c old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/version/_version_apilist.h b/apilibs/kexbases/version/_version_apilist.h old mode 100644 new mode 100755 diff --git a/apilibs/kexbases/version/universion.c b/apilibs/kexbases/version/universion.c old mode 100644 new mode 100755 diff --git a/apilibs/settings.reg b/apilibs/settings.reg old mode 100644 new mode 100755 index 6d79823..caa381a --- a/apilibs/settings.reg +++ b/apilibs/settings.reg @@ -37,4 +37,6 @@ REGEDIT4 "*\\PBAGS.DLL"=dword:00000001 "*\\PBSV.DLL"=dword:00000001 "*\\PBSVS.DLL"=dword:00000001 +;-DirectX installer +"*\\DXSETUP.EXE"=dword:00000001 diff --git a/auxiliary/auxiliary.dsp b/auxiliary/auxiliary.dsp old mode 100644 new mode 100755 diff --git a/auxiliary/makefile b/auxiliary/makefile old mode 100644 new mode 100755 diff --git a/auxiliary/makefile.msv b/auxiliary/makefile.msv old mode 100644 new mode 100755 diff --git a/auxiliary/msimg32/makefile b/auxiliary/msimg32/makefile old mode 100644 new mode 100755 diff --git a/auxiliary/msimg32/makefile.msv b/auxiliary/msimg32/makefile.msv old mode 100644 new mode 100755 diff --git a/auxiliary/msimg32/msimg32.c b/auxiliary/msimg32/msimg32.c old mode 100644 new mode 100755 index ee3e54b..5919454 --- a/auxiliary/msimg32/msimg32.c +++ b/auxiliary/msimg32/msimg32.c @@ -30,13 +30,6 @@ bInfo.bmiHeader.biHeight = cy; \ bInfo.bmiHeader.biPlanes = 1; \ bInfo.bmiHeader.biBitCount = 32; - -typedef struct tagRGBALPHA { - byte rgbRed; - byte rgbGreen; - byte rgbBlue; - byte rgbReserved; -} RGBALPHA,*PRGBALPHA; #ifndef GRADIENT_FILL_RECT_H #define GRADIENT_FILL_RECT_H 0x00 @@ -70,16 +63,17 @@ BOOL WINAPI AlphaBlend_NEW( HDC hdcDest, // handle to destination DC BITMAPINFO bmi; HBITMAP srcBM, dstBM, dcBM; HDC srcDC, dstDC; - PRGBALPHA srcPixel, dstPixel; + RGBQUAD *srcPixel, *dstPixel; INITBITMAPINFO(bmi,nWidthDest,nHeightDest); - if ( !hdcDest || !hdcSrc || blendFunction.BlendOp != AC_SRC_OVER ) + if ( !hdcDest || !hdcSrc || blendFunction.BlendOp != AC_SRC_OVER + || nWidthDest < 0 || nHeightDest < 0 || nWidthSrc < 0 || nHeightSrc < 0) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } if ( !blendFunction.SourceConstantAlpha ) return TRUE; //nothing to do - if ( !blendFunction.AlphaFormat && blendFunction.SourceConstantAlpha == 0xFF ) //no alpha work + if ( !(blendFunction.AlphaFormat & AC_SRC_ALPHA) && blendFunction.SourceConstantAlpha == 0xFF ) //no alpha work return StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, SRCCOPY ); srcBM = CreateDIBSection(hdcSrc, &bmi, DIB_RGB_COLORS, (void*)&srcPixel, NULL, 0); @@ -102,7 +96,7 @@ BOOL WINAPI AlphaBlend_NEW( HDC hdcDest, // handle to destination DC dcBM = SelectObject(dstDC, dstBM); BitBlt(dstDC, 0, 0, nWidthDest, nHeightDest, hdcDest, nXOriginDest, nYOriginDest, SRCCOPY); //workwork - if ( !blendFunction.AlphaFormat ) //no alpha channel + if ( !(blendFunction.AlphaFormat & AC_SRC_ALPHA) ) //no alpha channel { srcalpha = blendFunction.SourceConstantAlpha; dstalpha = 255 - srcalpha; @@ -122,8 +116,7 @@ BOOL WINAPI AlphaBlend_NEW( HDC hdcDest, // handle to destination DC srcalpha = blendFunction.SourceConstantAlpha; for (i = 0; i < (nWidthDest*nHeightDest); i++) { - - dstalpha = 255 - srcPixel->rgbReserved; + dstalpha = 255 - (srcPixel->rgbReserved * srcalpha / 255); tmp = ((srcPixel->rgbRed * srcalpha) + (dstPixel->rgbRed * dstalpha)) / 255; if (tmp > 255) tmp = 255; dstPixel->rgbRed = tmp; diff --git a/auxiliary/msimg32/msimg32.def b/auxiliary/msimg32/msimg32.def old mode 100644 new mode 100755 diff --git a/auxiliary/msimg32/msimgme.rc b/auxiliary/msimg32/msimgme.rc old mode 100644 new mode 100755 diff --git a/auxiliary/pdh/kord.def b/auxiliary/pdh/kord.def old mode 100644 new mode 100755 diff --git a/auxiliary/pdh/makefile b/auxiliary/pdh/makefile old mode 100644 new mode 100755 diff --git a/auxiliary/pdh/makefile.msv b/auxiliary/pdh/makefile.msv old mode 100644 new mode 100755 diff --git a/auxiliary/pdh/pdh.c b/auxiliary/pdh/pdh.c old mode 100644 new mode 100755 diff --git a/auxiliary/pdh/pdh.def b/auxiliary/pdh/pdh.def old mode 100644 new mode 100755 diff --git a/auxiliary/psapi/makefile b/auxiliary/psapi/makefile old mode 100644 new mode 100755 diff --git a/auxiliary/psapi/makefile.msv b/auxiliary/psapi/makefile.msv old mode 100644 new mode 100755 diff --git a/auxiliary/psapi/psapi.c b/auxiliary/psapi/psapi.c old mode 100644 new mode 100755 index 4113941..a5698ee --- a/auxiliary/psapi/psapi.c +++ b/auxiliary/psapi/psapi.c @@ -346,3 +346,9 @@ BOOL WINAPI EnumPageFilesW( PVOID callback, LPVOID context ) SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } + +BOOL WINAPI EmptyWorkingSet( HANDLE hProcess ) +{ + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} diff --git a/auxiliary/psapi/psapi.def b/auxiliary/psapi/psapi.def old mode 100644 new mode 100755 index 6bd8490..7db34f3 --- a/auxiliary/psapi/psapi.def +++ b/auxiliary/psapi/psapi.def @@ -16,3 +16,4 @@ EXPORTS InitializeProcessForWsWatch EnumPageFilesA EnumPageFilesW + EmptyWorkingSet diff --git a/auxiliary/uxtheme/kord.def b/auxiliary/uxtheme/kord.def old mode 100644 new mode 100755 diff --git a/auxiliary/uxtheme/makefile b/auxiliary/uxtheme/makefile old mode 100644 new mode 100755 diff --git a/auxiliary/uxtheme/makefile.msv b/auxiliary/uxtheme/makefile.msv old mode 100644 new mode 100755 diff --git a/auxiliary/uxtheme/uxtheme.c b/auxiliary/uxtheme/uxtheme.c old mode 100644 new mode 100755 index 0423a62..fbb1ff8 --- a/auxiliary/uxtheme/uxtheme.c +++ b/auxiliary/uxtheme/uxtheme.c @@ -49,7 +49,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) OSVERSIONINFO osv; osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osv); - if (osv.dwMajorVersion < 5 || osv.dwMinorVersion < 1) + if (osv.dwMajorVersion < 5 || (osv.dwMajorVersion == 5 && osv.dwMinorVersion == 0)) return FALSE; DisableThreadLibraryCalls(hinstDLL); } diff --git a/auxiliary/uxtheme/uxtheme.def b/auxiliary/uxtheme/uxtheme.def old mode 100644 new mode 100755 diff --git a/auxiliary/wtsapi32/makefile b/auxiliary/wtsapi32/makefile old mode 100644 new mode 100755 diff --git a/auxiliary/wtsapi32/makefile.msv b/auxiliary/wtsapi32/makefile.msv old mode 100644 new mode 100755 diff --git a/auxiliary/wtsapi32/wtsapi32.c b/auxiliary/wtsapi32/wtsapi32.c old mode 100644 new mode 100755 index f4e2db3..0fbd36f --- a/auxiliary/wtsapi32/wtsapi32.c +++ b/auxiliary/wtsapi32/wtsapi32.c @@ -28,6 +28,7 @@ #ifdef _MSC_VER +#pragma warning(disable:4002) #define TRACE() #define FIXME() diff --git a/auxiliary/wtsapi32/wtsapi32.def b/auxiliary/wtsapi32/wtsapi32.def old mode 100644 new mode 100755 diff --git a/auxiliary/wtsapi32/wtsapi32.h b/auxiliary/wtsapi32/wtsapi32.h old mode 100644 new mode 100755 diff --git a/common/is_sorted.hpp b/common/is_sorted.hpp old mode 100644 new mode 100755 diff --git a/common/kexcoresdk.h b/common/kexcoresdk.h old mode 100644 new mode 100755 diff --git a/common/pemanip.cpp b/common/pemanip.cpp old mode 100644 new mode 100755 diff --git a/common/pemanip.h b/common/pemanip.h old mode 100644 new mode 100755 diff --git a/common/sstring.hpp b/common/sstring.hpp old mode 100644 new mode 100755 diff --git a/core/Core.rc b/core/Core.rc old mode 100644 new mode 100755 diff --git a/core/SettingsDB.cpp b/core/SettingsDB.cpp old mode 100644 new mode 100755 diff --git a/core/SettingsDB.h b/core/SettingsDB.h old mode 100644 new mode 100755 diff --git a/core/apiconf.cpp b/core/apiconf.cpp old mode 100644 new mode 100755 index 71ce427..cbacce8 --- a/core/apiconf.cpp +++ b/core/apiconf.cpp @@ -32,8 +32,6 @@ using namespace std; ApiConfiguration::ApiConfiguration(const char* name) { initialized = prepare(name); - if (!initialized) - DBGPRINTF(("Failed to allocate memory\n")); } ApiConfiguration::ApiConfiguration(const char* new_name, const ApiConfiguration& src) @@ -81,7 +79,6 @@ ApiConfiguration::ApiConfiguration(const char* new_name, const ApiConfiguration& return; __error: - DBGPRINTF(("Failed to allocate memory\n")); initialized = false; } @@ -220,6 +217,8 @@ bool ApiConfiguration::merge(const ApiLibrary* apilib) { sfirst++; space++; + while (sfirst != slast && !strcmp(sfirst->name, (sfirst - 1)->name)) + sfirst++; } //allocate new mem @@ -272,6 +271,8 @@ bool ApiConfiguration::merge(const ApiLibrary* apilib) dfirst->address = encode_address(sfirst->addr, apilib); dfirst++; sfirst++; + while (sfirst != slast && !strcmp(sfirst->name, (sfirst - 1)->name)) + sfirst++; } break; diff --git a/core/apiconf.h b/core/apiconf.h old mode 100644 new mode 100755 diff --git a/core/apiconfmgr.cpp b/core/apiconfmgr.cpp old mode 100644 new mode 100755 index 8af169d..3c04aa3 --- a/core/apiconfmgr.cpp +++ b/core/apiconfmgr.cpp @@ -459,10 +459,7 @@ bool ApiConfigurationManager::commit_changes() ApiConfiguration** new_prev; new_prev = (ApiConfiguration**) malloc(used * sizeof(ApiConfiguration*)); if (!new_prev) - { - DBGPRINTF(("Failed to allocate memory\n")); return false; - } int cnt = 0; @@ -499,12 +496,14 @@ bool ApiConfigurationManager::commit_changes() } //replace prev with new_prev - free(prev_apiconf_ptrs); + if (prev_apiconf_ptrs) + free(prev_apiconf_ptrs); prev_apiconf_ptrs = new_prev; prev_apiconf_cnt = cnt; //replace curr with new - free(curr_apiconf_ptrs); + if (curr_apiconf_ptrs) + free(curr_apiconf_ptrs); curr_apiconf_ptrs = new_apiconf_ptrs; curr_apiconf_cnt = new_apiconf_cnt; new_apiconf_ptrs = NULL; diff --git a/core/apiconfmgr.h b/core/apiconfmgr.h old mode 100644 new mode 100755 diff --git a/core/apilib.cpp b/core/apilib.cpp old mode 100644 new mode 100755 index b4176db..f902202 --- a/core/apilib.cpp +++ b/core/apilib.cpp @@ -161,10 +161,7 @@ bool ApiLibraryManager::load_apilib(const char* apilib_name) apilib = (ApiLibrary*) malloc(size); if (!apilib) - { - DBGPRINTF(("Failed to allocate memory\n")); goto __error; - } strcpy(apilib->apilib_name, apilib_name); @@ -215,10 +212,7 @@ bool ApiLibraryManager::load_apilib(const char* apilib_name) (new_apilib_cnt + ALLOC_CAPACITY) * sizeof(ApiLibrary*)); if (!new_block) - { - DBGPRINTF(("Failed to allocate memory\n")); goto __error; - } new_apilib_ptrs = (ApiLibrary**) new_block; } @@ -227,7 +221,11 @@ bool ApiLibraryManager::load_apilib(const char* apilib_name) for (apilib_api_table* p = apilib->api_tables ; p->target_library ; p++) { // DBGPRINTF((" * %s\n", p->target_library)); - add_overridden_module(p->target_library); + if (!add_overridden_module(p->target_library)) + { + DBGPRINTF(("Failed to add overridden module %s\n", p->target_library)); + goto __error; + } } //set or update index value which is used by encode_address() @@ -372,16 +370,6 @@ apilib_api_table* ApiLibraryManager::make_shared_api_tables(const apilib_api_tab } } -// //sort the tables -// if (!sorted) -// { -// while (pout-- != out) -// { -// stable_sort(pout->named_apis, pout->named_apis + pout->named_apis_count); -// stable_sort(pout->ordinal_apis, pout->ordinal_apis + pout->ordinal_apis_count); -// } -// } - //finish line return out; } @@ -426,10 +414,7 @@ bool ApiLibraryManager::add_overridden_module(const char* mod) (new_overridden_mod_cnt + ALLOC_CAPACITY) * sizeof(char*)); if (!new_block) - { - DBGPRINTF(("Failed to allocate memory\n")); return false; - } new_overridden_mod_nms = (const char**) new_block; @@ -438,16 +423,16 @@ bool ApiLibraryManager::add_overridden_module(const char* mod) //+ 1 because api_tables are NULL terminated if (!new_block) - { - DBGPRINTF(("Failed to allocate memory\n")); return false; - } std_api_table = (apilib_api_table*) new_block; } if (!parse_system_dll(mod, &std_api_table[new_overridden_mod_cnt])) + { + DBGPRINTF(("Failed to parse system DLL: %s\n", mod)); return false; + } //add to table of overridden modules new_overridden_mod_nms[new_overridden_mod_cnt] @@ -564,10 +549,8 @@ bool ApiLibraryManager::parse_system_dll(const char* dll_name, apilib_api_table* char* new_mod = (char*) malloc(strlen(dll_name) + 1); if (!new_mod) - { - DBGPRINTF(("Failed to allocate memory\n")); return false; - } + strcpy(new_mod, dll_name); strupr(new_mod); api_tab->target_library = new_mod; @@ -632,7 +615,8 @@ void ApiLibraryManager::commit_changes() //LOCK ALL CRITICAL SECTIONS! apilib_ptrs = new_apilib_ptrs; apilib_cnt = new_apilib_cnt; - free(overridden_module_names); + if (overridden_module_names) + free(overridden_module_names); overridden_module_names = new_overridden_mod_nms; overridden_module_count = new_overridden_mod_cnt; @@ -697,7 +681,8 @@ void ApiLibraryManager::commit_changes() free(old_apilib_ptrs[i]); } - free(old_apilib_ptrs); + if (old_apilib_ptrs) + free(old_apilib_ptrs); initialized = false; } diff --git a/core/apilib.h b/core/apilib.h old mode 100644 new mode 100755 diff --git a/core/core.def b/core/core.def old mode 100644 new mode 100755 diff --git a/core/core.dsp b/core/core.dsp old mode 100644 new mode 100755 diff --git a/core/core.ini b/core/core.ini old mode 100644 new mode 100755 diff --git a/core/debug.cpp b/core/debug.cpp old mode 100644 new mode 100755 diff --git a/core/debug.h b/core/debug.h old mode 100644 new mode 100755 diff --git a/core/debugproto.cpp b/core/debugproto.cpp old mode 100644 new mode 100755 diff --git a/core/debugproto.h b/core/debugproto.h old mode 100644 new mode 100755 diff --git a/core/internals.cpp b/core/internals.cpp old mode 100644 new mode 100755 index 0d6c7db..57fc915 --- a/core/internals.cpp +++ b/core/internals.cpp @@ -28,6 +28,7 @@ #include "pemanip.h" static bool is_winme; +HINSTANCE hInstance; IMTE*** ppmteModTable = NULL; HMODULE h_kernel32; @@ -119,7 +120,7 @@ void ShowError(UINT id, ...) va_list vargs; va_start(vargs, id); - if (!LoadString(GetModuleHandle(NULL), id, format, sizeof(format))) + if (!LoadString(hInstance, id, format, sizeof(format))) sprintf(out, "ERROR: Missing string resource %d", id); else _vsnprintf(out, sizeof(out), format, vargs); @@ -476,6 +477,7 @@ static bool find_kernelex_install_dir() int internals_init() { + DBGPRINTF(("KernelEx loaded @ %08x\n", hInstance)); DBGPRINTF(("internals_init()\n")); h_kernel32 = GetModuleHandle("kernel32"); ppmteModTable = find_mod_table(); diff --git a/core/internals.h b/core/internals.h old mode 100644 new mode 100755 index d651e86..32a7ad9 --- a/core/internals.h +++ b/core/internals.h @@ -34,6 +34,8 @@ #endif #endif +extern HINSTANCE hInstance; + extern IMTE*** ppmteModTable; extern HMODULE h_kernel32; extern CRITICAL_SECTION* krnl32lock; diff --git a/core/k32ord.def b/core/k32ord.def old mode 100644 new mode 100755 diff --git a/core/kexcoresdk.cpp b/core/kexcoresdk.cpp old mode 100644 new mode 100755 diff --git a/core/main.cpp b/core/main.cpp old mode 100644 new mode 100755 index 89485e9..68c8798 --- a/core/main.cpp +++ b/core/main.cpp @@ -97,6 +97,33 @@ DWORD WINAPI MprStart(LPVOID) return 0; } +void load_MPRServices() +{ + char subkey[200]; + char dllname[MAX_PATH]; + HKEY hk_serv; + HKEY hk_this; + DWORD size; + DWORD index = 0; + + if (RegOpenKey(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\MPRServices", + &hk_serv) != ERROR_SUCCESS) + return; + while (RegEnumKey(hk_serv, index, subkey, sizeof(subkey)) == ERROR_SUCCESS) + { + RegOpenKey(hk_serv, subkey, &hk_this); + size = sizeof(dllname); + if (RegQueryValueEx(hk_this, "DllName", NULL, NULL, (BYTE*)dllname, &size) + == ERROR_SUCCESS && strcmpi(dllname, own_path.get()) != 0) + { + LoadLibrary(dllname); + } + RegCloseKey(hk_this); + index++; + } + RegCloseKey(hk_serv); +} + /** Check if loaded into shared memory area. * @param addr Address to which loaded. * @return TRUE if loaded to shared memory, FALSE otherwise. @@ -125,10 +152,10 @@ static int load_count(DWORD addr) return pmteModTable[MRfromCallerAddr(addr)->mteIndex]->cUsage; } -static void get_own_path(HMODULE base) +static void get_own_path() { char path[MAX_PATH]; - GetModuleFileName(base, path, sizeof(path)); + GetModuleFileName(hInstance, path, sizeof(path)); own_path = path; } @@ -170,6 +197,8 @@ BOOL APIENTRY PreDllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) if (load_count((DWORD) instance) == 1) { + hInstance = instance; + if (detect_old_version()) return FALSE; @@ -181,7 +210,7 @@ BOOL APIENTRY PreDllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) //globally (by default it would be called on every process attach) ret = _DllMainCRTStartup(instance, reason, reserved); - get_own_path(instance); + get_own_path(); } } else if (reason == DLL_PROCESS_DETACH) @@ -202,7 +231,23 @@ BOOL APIENTRY DllMain(HINSTANCE instance, DWORD reason, BOOL load_static) { if (reason == DLL_PROCESS_ATTACH && GetModuleHandle("MPREXE.EXE")) { - return kexInit(); + //load all other MPR services before further execution + load_MPRServices(); + + //initialize + if (!kexInit()) + return FALSE; + + //in case KernelEx was loaded globally we don't want to unload it ever + IMTE** pmteModTable = *ppmteModTable; + pmteModTable[MRFromHLib(hInstance)->mteIndex]->cUsage++; + + //we don't want to unload the api libraries as well + ApiLibrary* apilib; + for (int i = 1 ; apilib = ApiLibraryManager::get_apilib(i) ; i++) + pmteModTable[MRFromHLib(apilib->mod_handle)->mteIndex]->cUsage++; + + return TRUE; } //for additional safety - auto uninit on core unload diff --git a/core/resolver.cpp b/core/resolver.cpp old mode 100644 new mode 100755 index fd415a7..c7198e9 --- a/core/resolver.cpp +++ b/core/resolver.cpp @@ -371,7 +371,15 @@ DWORD encode_address(DWORD addr, const ApiLibrary* apilib) //STD apilib if (index == 0) - return addr; + { + if (addr < 0xc0000000) + return addr; + + //extremely rare scenario: driver hijacked apis so the address is now + //above 0xc0000000 and we use these for encoded apilib addresses + //so we have to create a stub in shared arena with proper address + return (DWORD) new redir_stub(addr); + } //non-shared apilib if ((DWORD) apilib->mod_handle < 0x80000000) diff --git a/core/resolver.h b/core/resolver.h old mode 100644 new mode 100755 index 7a18746..1be874e --- a/core/resolver.h +++ b/core/resolver.h @@ -47,6 +47,18 @@ struct IMTE_KEX : public IMTE * 0 - not checked, 0xffff - not an overridden module */ }; +/* Creates a stub that calls address specified in the constructor. */ +class redir_stub +{ +public: + redir_stub(unsigned long target) : c_eax(0xb8), v_eax(target), c_jmp(0xe0ff) {} + +private: + unsigned char c_eax; + unsigned long v_eax; + unsigned short c_jmp; +}; + #pragma pack(pop) DWORD encode_address(DWORD addr, const ApiLibrary* apilib); diff --git a/core/resource.h b/core/resource.h old mode 100644 new mode 100755 diff --git a/core/sharedmem.cpp b/core/sharedmem.cpp old mode 100644 new mode 100755 index 137dd34..05bcafb --- a/core/sharedmem.cpp +++ b/core/sharedmem.cpp @@ -40,48 +40,58 @@ void destroy_shared_heap() void* malloc(size_t size) { - return HeapAlloc(shared_heap, 0, size); + void* ptr = HeapAlloc(shared_heap, 0, size); + if (!ptr) + DBGPRINTF(("ERROR: malloc failed (%d B)\n", size)); + return ptr; } void* calloc(size_t count, size_t size) { - return HeapAlloc(shared_heap, HEAP_ZERO_MEMORY, count * size); + void* ptr = HeapAlloc(shared_heap, HEAP_ZERO_MEMORY, count * size); + if (!ptr) + DBGPRINTF(("ERROR: malloc failed (%d B)\n", size)); + return ptr; } void free(void* ptr) { - DBGASSERT(ptr == NULL || (DWORD)ptr >= 0x80000000); if (ptr) HeapFree(shared_heap, 0, ptr); + else + DBGPRINTF(("ERROR: trying to free NULL\n")); } void* realloc(void* ptr, size_t size) { - DBGASSERT(ptr == NULL || (DWORD)ptr >= 0x80000000); + void* nptr; if (ptr) - return HeapReAlloc(shared_heap, 0, ptr, size); + nptr = HeapReAlloc(shared_heap, 0, ptr, size); else - return HeapAlloc(shared_heap, 0, size); + nptr = HeapAlloc(shared_heap, 0, size); + if (!nptr) + DBGPRINTF(("ERROR: malloc failed (%d B)\n", size)); + return nptr; } void* recalloc(void* ptr, size_t size) { - DBGASSERT(ptr == NULL || (DWORD)ptr >= 0x80000000); + void* nptr; if (ptr) - return HeapReAlloc(shared_heap, HEAP_ZERO_MEMORY, ptr, size); + nptr = HeapReAlloc(shared_heap, HEAP_ZERO_MEMORY, ptr, size); else - return HeapAlloc(shared_heap, HEAP_ZERO_MEMORY, size); + nptr = HeapAlloc(shared_heap, HEAP_ZERO_MEMORY, size); + if (!nptr) + DBGPRINTF(("ERROR: malloc failed (%d B)\n", size)); + return nptr; } void* operator new(size_t size) { - void* mem = malloc(size); - DBGASSERT(mem); - return mem; + return malloc(size); } void operator delete(void* ptr) { - DBGASSERT((DWORD)ptr >= 0x80000000); free(ptr); } diff --git a/core/sharedmem.h b/core/sharedmem.h old mode 100644 new mode 100755 diff --git a/core/structs.h b/core/structs.h old mode 100644 new mode 100755 diff --git a/core/thunks.cpp b/core/thunks.cpp old mode 100644 new mode 100755 diff --git a/core/thunks.h b/core/thunks.h old mode 100644 new mode 100755 diff --git a/core/version.h b/core/version.h old mode 100644 new mode 100755 index 7f429ee..46e108c --- a/core/version.h +++ b/core/version.h @@ -22,8 +22,8 @@ #ifndef __VERSION_H #define __VERSION_H -#define VERSION_STR "4.0 RC 1" -#define VERSION_CODE 0x0400000B -#define RCVERSION 4, 0, 1, 0 +#define VERSION_STR "4.0 RC 2" +#define VERSION_CODE 0x0400000C +#define RCVERSION 4, 0, 1, 2 #endif diff --git a/core/wildcmp.cpp b/core/wildcmp.cpp old mode 100644 new mode 100755 diff --git a/core/wildcmp.h b/core/wildcmp.h old mode 100644 new mode 100755 diff --git a/kexcontrol/kexcontrol.cpp b/kexcontrol/kexcontrol.cpp old mode 100644 new mode 100755 diff --git a/kexcontrol/kexcontrol.dsp b/kexcontrol/kexcontrol.dsp old mode 100644 new mode 100755 diff --git a/kexcrt/LICENSE b/kexcrt/LICENSE old mode 100644 new mode 100755 diff --git a/kexcrt/README b/kexcrt/README old mode 100644 new mode 100755 diff --git a/kexcrt/_vsnprintf.c b/kexcrt/_vsnprintf.c old mode 100644 new mode 100755 diff --git a/kexcrt/atoi.c b/kexcrt/atoi.c old mode 100644 new mode 100755 diff --git a/kexcrt/atol.c b/kexcrt/atol.c old mode 100644 new mode 100755 diff --git a/kexcrt/atoll.c b/kexcrt/atoll.c old mode 100644 new mode 100755 diff --git a/kexcrt/atox.c b/kexcrt/atox.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/ctypefunc.h b/kexcrt/ctype/ctypefunc.h old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isalnum.c b/kexcrt/ctype/isalnum.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isalpha.c b/kexcrt/ctype/isalpha.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isascii.c b/kexcrt/ctype/isascii.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isblank.c b/kexcrt/ctype/isblank.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/iscntrl.c b/kexcrt/ctype/iscntrl.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isdigit.c b/kexcrt/ctype/isdigit.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isgraph.c b/kexcrt/ctype/isgraph.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/islower.c b/kexcrt/ctype/islower.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isprint.c b/kexcrt/ctype/isprint.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/ispunct.c b/kexcrt/ctype/ispunct.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isspace.c b/kexcrt/ctype/isspace.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isupper.c b/kexcrt/ctype/isupper.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/isxdigit.c b/kexcrt/ctype/isxdigit.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/tolower.c b/kexcrt/ctype/tolower.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctype/toupper.c b/kexcrt/ctype/toupper.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctypes.c b/kexcrt/ctypes.c old mode 100644 new mode 100755 diff --git a/kexcrt/ctypes.h b/kexcrt/ctypes.h old mode 100644 new mode 100755 diff --git a/kexcrt/kexcrt.dsp b/kexcrt/kexcrt.dsp old mode 100644 new mode 100755 diff --git a/kexcrt/makefile b/kexcrt/makefile old mode 100644 new mode 100755 diff --git a/kexcrt/makefile.msv b/kexcrt/makefile.msv old mode 100644 new mode 100755 diff --git a/kexcrt/memccpy.c b/kexcrt/memccpy.c old mode 100644 new mode 100755 diff --git a/kexcrt/memchr.c b/kexcrt/memchr.c old mode 100644 new mode 100755 diff --git a/kexcrt/memcmp.c b/kexcrt/memcmp.c old mode 100644 new mode 100755 diff --git a/kexcrt/memcpy.c b/kexcrt/memcpy.c old mode 100644 new mode 100755 diff --git a/kexcrt/memmem.c b/kexcrt/memmem.c old mode 100644 new mode 100755 diff --git a/kexcrt/memmove.c b/kexcrt/memmove.c old mode 100644 new mode 100755 diff --git a/kexcrt/memrchr.c b/kexcrt/memrchr.c old mode 100644 new mode 100755 diff --git a/kexcrt/memset.c b/kexcrt/memset.c old mode 100644 new mode 100755 diff --git a/kexcrt/memswap.c b/kexcrt/memswap.c old mode 100644 new mode 100755 diff --git a/kexcrt/msvc/STDINT.H b/kexcrt/msvc/STDINT.H old mode 100644 new mode 100755 diff --git a/kexcrt/msvc/argcargv.c b/kexcrt/msvc/argcargv.c old mode 100644 new mode 100755 diff --git a/kexcrt/msvc/argcargv.h b/kexcrt/msvc/argcargv.h old mode 100644 new mode 100755 diff --git a/kexcrt/msvc/concrt0.c b/kexcrt/msvc/concrt0.c old mode 100644 new mode 100755 diff --git a/kexcrt/msvc/dllcrt0.c b/kexcrt/msvc/dllcrt0.c old mode 100644 new mode 100755 diff --git a/kexcrt/msvc/init.c b/kexcrt/msvc/init.c old mode 100644 new mode 100755 diff --git a/kexcrt/msvc/init.h b/kexcrt/msvc/init.h old mode 100644 new mode 100755 diff --git a/kexcrt/msvc/wincrt0.c b/kexcrt/msvc/wincrt0.c old mode 100644 new mode 100755 diff --git a/kexcrt/snprintf.c b/kexcrt/snprintf.c old mode 100644 new mode 100755 diff --git a/kexcrt/sprintf.c b/kexcrt/sprintf.c old mode 100644 new mode 100755 diff --git a/kexcrt/sscanf.c b/kexcrt/sscanf.c old mode 100644 new mode 100755 diff --git a/kexcrt/strcat.c b/kexcrt/strcat.c old mode 100644 new mode 100755 diff --git a/kexcrt/strchr.c b/kexcrt/strchr.c old mode 100644 new mode 100755 diff --git a/kexcrt/strcmp.c b/kexcrt/strcmp.c old mode 100644 new mode 100755 diff --git a/kexcrt/strcmpi.c b/kexcrt/strcmpi.c old mode 100644 new mode 100755 diff --git a/kexcrt/strcpy.c b/kexcrt/strcpy.c old mode 100644 new mode 100755 diff --git a/kexcrt/strlen.c b/kexcrt/strlen.c old mode 100644 new mode 100755 diff --git a/kexcrt/strncat.c b/kexcrt/strncat.c old mode 100644 new mode 100755 diff --git a/kexcrt/strncmp.c b/kexcrt/strncmp.c old mode 100644 new mode 100755 diff --git a/kexcrt/strncpy.c b/kexcrt/strncpy.c old mode 100644 new mode 100755 diff --git a/kexcrt/strnicmp.c b/kexcrt/strnicmp.c old mode 100644 new mode 100755 diff --git a/kexcrt/strnlen.c b/kexcrt/strnlen.c old mode 100644 new mode 100755 diff --git a/kexcrt/strntoimax.c b/kexcrt/strntoimax.c old mode 100644 new mode 100755 diff --git a/kexcrt/strntoumax.c b/kexcrt/strntoumax.c old mode 100644 new mode 100755 diff --git a/kexcrt/strpbrk.c b/kexcrt/strpbrk.c old mode 100644 new mode 100755 diff --git a/kexcrt/strrchr.c b/kexcrt/strrchr.c old mode 100644 new mode 100755 diff --git a/kexcrt/strsep.c b/kexcrt/strsep.c old mode 100644 new mode 100755 diff --git a/kexcrt/strstr.c b/kexcrt/strstr.c old mode 100644 new mode 100755 diff --git a/kexcrt/strtok.c b/kexcrt/strtok.c old mode 100644 new mode 100755 diff --git a/kexcrt/strtol.c b/kexcrt/strtol.c old mode 100644 new mode 100755 diff --git a/kexcrt/strtoll.c b/kexcrt/strtoll.c old mode 100644 new mode 100755 diff --git a/kexcrt/strtoul.c b/kexcrt/strtoul.c old mode 100644 new mode 100755 diff --git a/kexcrt/strtoull.c b/kexcrt/strtoull.c old mode 100644 new mode 100755 diff --git a/kexcrt/strtoumax.c b/kexcrt/strtoumax.c old mode 100644 new mode 100755 diff --git a/kexcrt/strtox.c b/kexcrt/strtox.c old mode 100644 new mode 100755 diff --git a/kexcrt/strupr.c b/kexcrt/strupr.c old mode 100644 new mode 100755 diff --git a/kexcrt/strxspn.c b/kexcrt/strxspn.c old mode 100644 new mode 100755 diff --git a/kexcrt/strxspn.h b/kexcrt/strxspn.h old mode 100644 new mode 100755 diff --git a/kexcrt/vsnprintf.c b/kexcrt/vsnprintf.c old mode 100644 new mode 100755 diff --git a/kexcrt/vsprintf.c b/kexcrt/vsprintf.c old mode 100644 new mode 100755 diff --git a/kexcrt/vsscanf.c b/kexcrt/vsscanf.c old mode 100644 new mode 100755 diff --git a/setup/debug.h b/setup/debug.h old mode 100644 new mode 100755 diff --git a/setup/loadstub.h b/setup/loadstub.h old mode 100644 new mode 100755 diff --git a/setup/resource.h b/setup/resource.h old mode 100644 new mode 100755 diff --git a/setup/setup.cpp b/setup/setup.cpp old mode 100644 new mode 100755 index 3e59423..162770f --- a/setup/setup.cpp +++ b/setup/setup.cpp @@ -186,6 +186,30 @@ void Setup::disable_platform_check() set_pattern(found_loc, after, length); } +void Setup::disable_resource_check() +{ + static const short pattern[] = { + 0x3d,0x00,0x80,0x00,0x00,0x72, + }; + static const short after[] = { + 0x3d,0x00,0x80,0x00,0x00,0xeb, + }; + + 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_resource_check"); + else ShowError(IDS_MULPAT, "disable_resource_check"); + } + DBGPRINTF(("%s: pattern found @ 0x%08x\n", "disable_resource_check", + 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 @@ -350,9 +374,6 @@ void Setup::install() { upgrade = false; - if (version == KEX_STUB_VER) - return; - if (version >= 0) { if (version > KEX_STUB_VER) @@ -366,10 +387,15 @@ void Setup::install() pefile.OpenFile(upgrade ? backup_file.c_str() : kernel32path, 0x10000); if (!pefile.HasTarget()) + { + if (version == KEX_STUB_VER) + return; ShowError(IDS_FAILOPEN, upgrade ? backup_file.c_str() : kernel32path); + } find_ExportFromX(); disable_platform_check(); + disable_resource_check(); mod_imte_alloc(); KernelEx_codeseg* cseg; diff --git a/setup/setup.dsp b/setup/setup.dsp old mode 100644 new mode 100755 index 1f68033..848aae4 --- a/setup/setup.dsp +++ b/setup/setup.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "../common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GF /c +# ADD CPP /nologo /W3 /GX /O2 /I "." /I "../common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GF /c # ADD BASE RSC /l 0x415 /d "NDEBUG" # ADD RSC /l 0x415 /d "NDEBUG" BSC32=bscmake.exe diff --git a/setup/setup.h b/setup/setup.h old mode 100644 new mode 100755 index 080b477..72f2beb --- a/setup/setup.h +++ b/setup/setup.h @@ -52,6 +52,7 @@ 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 disable_platform_check(); + void disable_resource_check(); void mod_imte_alloc(); void find_ExportFromX(); DWORD find_ExportFromOrdinal(); diff --git a/setup/setup.rc b/setup/setup.rc old mode 100644 new mode 100755 diff --git a/setup/wininit.h b/setup/wininit.h old mode 100644 new mode 100755 diff --git a/sheet/KexLinkage.cpp b/sheet/KexLinkage.cpp old mode 100644 new mode 100755 diff --git a/sheet/KexLinkage.h b/sheet/KexLinkage.h old mode 100644 new mode 100755 diff --git a/sheet/factory.cpp b/sheet/factory.cpp old mode 100644 new mode 100755 diff --git a/sheet/factory.h b/sheet/factory.h old mode 100644 new mode 100755 diff --git a/sheet/resource.h b/sheet/resource.h old mode 100644 new mode 100755 diff --git a/sheet/server.cpp b/sheet/server.cpp old mode 100644 new mode 100755 diff --git a/sheet/server.def b/sheet/server.def old mode 100644 new mode 100755 diff --git a/sheet/server.h b/sheet/server.h old mode 100644 new mode 100755 diff --git a/sheet/sheet.cpp b/sheet/sheet.cpp old mode 100644 new mode 100755 index afed3a6..2141922 --- a/sheet/sheet.cpp +++ b/sheet/sheet.cpp @@ -120,11 +120,16 @@ bool KexShlExt::ResolveShortcut(const char* shortcutPath, char* filePath) char path[MAX_PATH]; WCHAR tmp[MAX_PATH]; + CoInitialize(NULL); + result = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**) &shellLink); if (FAILED(result)) + { + CoUninitialize(); return false; + } result = shellLink->QueryInterface(IID_IPersistFile, (void**) &persistFile); if (SUCCEEDED(result)) @@ -149,6 +154,8 @@ bool KexShlExt::ResolveShortcut(const char* shortcutPath, char* filePath) shellLink->Release(); + CoUninitialize(); + return SUCCEEDED(result); } diff --git a/sheet/sheet.dsp b/sheet/sheet.dsp old mode 100644 new mode 100755 diff --git a/sheet/sheet.h b/sheet/sheet.h old mode 100644 new mode 100755 diff --git a/sheet/sheet.rc b/sheet/sheet.rc old mode 100644 new mode 100755 index 43a1399..bf64029 --- a/sheet/sheet.rc +++ b/sheet/sheet.rc @@ -123,10 +123,11 @@ BEGIN CONTROL "Disable KernelEx extensions for this program", IDC_DISABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,43, 165,10 - GROUPBOX "",IDC_HORIZ1,7,108,172,9 LTEXT "kexver here",IDC_KEXVER,7,111,71,9,WS_DISABLED LTEXT "If you have problems with this program, try selecting\na different compatibility mode.", IDC_TCOMPAT,7,7,175,22 + CONTROL "",IDC_HORIZ1,"Static",SS_BLACKFRAME | SS_SUNKEN,7,109, + 176,1 END diff --git a/util/dumpconf.c b/util/dumpconf.c old mode 100644 new mode 100755 diff --git a/util/dumpimte.c b/util/dumpimte.c old mode 100644 new mode 100755 diff --git a/util/dumpsett.c b/util/dumpsett.c old mode 100644 new mode 100755 diff --git a/util/funique.cpp b/util/funique.cpp old mode 100644 new mode 100755 diff --git a/util/load.c b/util/load.c old mode 100644 new mode 100755 diff --git a/util/patterns.txt b/util/patterns.txt old mode 100644 new mode 100755 diff --git a/util/prep/prep.cpp b/util/prep/prep.cpp old mode 100644 new mode 100755 diff --git a/util/prep/prep.dsp b/util/prep/prep.dsp old mode 100644 new mode 100755 diff --git a/util/prep/prep.h b/util/prep/prep.h old mode 100644 new mode 100755 diff --git a/util/prep/test/_te_apilist.c b/util/prep/test/_te_apilist.c old mode 100644 new mode 100755 diff --git a/util/prep/test/dirlist b/util/prep/test/dirlist old mode 100644 new mode 100755 diff --git a/util/prep/test/junk.c b/util/prep/test/junk.c old mode 100644 new mode 100755 diff --git a/util/prep/test/test.c b/util/prep/test/test.c old mode 100644 new mode 100755