mirror of
https://github.com/UzixLS/KernelEx.git
synced 2025-07-18 23:11:19 +03:00
import KernelEx-4.5.2
This commit is contained in:
@ -69,9 +69,10 @@ END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_NOTREADY "System is not KernelEx-ready.\nPlease reinstall KernelEx."
|
||||
IDS_NODRIVER "KernelEx was unable to find its kernel driver counterpart.\nPlease reinstall KernelEx."
|
||||
IDS_STUBMISMATCH "Stub version mismatch (expected: %d, got: %d).\nPlease reinstall KernelEx."
|
||||
IDS_OLDVER "Another KernelEx version has been detected: %s.\nPlease uninstall all other versions and reinstall latest version."
|
||||
IDS_DRIVERINITFAIL "KernelEx Virtual Device has failed to initialize."
|
||||
END
|
||||
|
||||
#endif // Neutral resources
|
||||
|
@ -552,7 +552,7 @@ void ApiConfiguration::dump()
|
||||
api_tables[i].named_apis[j].address);
|
||||
printf("Unnamed apis (count = %d)\n", api_tables[i].unnamed_apis_count);
|
||||
for (int j = 0 ; j < api_tables[i].unnamed_apis_count ; j++)
|
||||
printf("\t%-5d %08x\n", j, api_tables[i].unnamed_apis[j]);
|
||||
printf("\t%-5d %08x\n", j + 1, api_tables[i].unnamed_apis[j]);
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
|
@ -68,7 +68,7 @@ PROC apihook::prepare(BOOL is_static)
|
||||
|
||||
if (hApiHookDll)
|
||||
{
|
||||
init_once = (init_once_t) GetProcAddress(hApiHookDll, "kexApiHook_initonce");
|
||||
init_once = (init_once_t) iGetProcAddress(hApiHookDll, "kexApiHook_initonce");
|
||||
__try
|
||||
{
|
||||
if (!init_once || !init_once())
|
||||
@ -93,7 +93,7 @@ PROC apihook::prepare(BOOL is_static)
|
||||
}
|
||||
|
||||
if (hApiHookDll)
|
||||
ah_reg = GetProcAddress(hApiHookDll, "kexApiHook_register");
|
||||
ah_reg = iGetProcAddress(hApiHookDll, "kexApiHook_register");
|
||||
|
||||
if (!hApiHookDll || !init_once || !ah_reg)
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KERNELEX_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /ML /W3 /Gm /Zi /Od /I "." /I "../common" /FI"msvc_quirks.h" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEXCORE_EXPORTS" /YX /FD /GZ /GF /c
|
||||
# ADD CPP /nologo /ML /W3 /Gm /Zi /Od /I "." /I "../common" /FI"msvc_quirks.h" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KEXCORE_EXPORTS" /D "_ENABLE_APIHOOK" /YX /FD /GZ /GF /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x415 /d "_DEBUG"
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "pemanip.h"
|
||||
#include "ModInit.h"
|
||||
|
||||
extern "C" int snprintf(char*, size_t, const char*, ...);
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define _D(x) x
|
||||
#else
|
||||
@ -72,21 +74,32 @@ void ShowError(UINT id, ...)
|
||||
MessageBox(NULL, out, "KernelEx Core", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
bool rerun_setup()
|
||||
bool VKernelEx_ioctl(DWORD command, PVOID buffer, DWORD buffer_size)
|
||||
{
|
||||
char cmd[MAX_PATH];
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
BOOL result;
|
||||
DWORD retlen;
|
||||
HANDLE VKernelEx;
|
||||
|
||||
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))
|
||||
char vxdpath[MAX_PATH];
|
||||
snprintf(vxdpath, sizeof(vxdpath), "\\\\.\\%sVKRNLEX.VXD",
|
||||
(const char*) kernelex_dir);
|
||||
|
||||
VKernelEx = CreateFile(vxdpath, 0, 0, 0, 0, FILE_FLAG_DELETE_ON_CLOSE, 0);
|
||||
|
||||
if (VKernelEx == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DBGPRINTF(("Failed to connect to VKernelEx!\n"));
|
||||
return false;
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
}
|
||||
|
||||
result = DeviceIoControl(VKernelEx, command, NULL, 0,
|
||||
buffer, buffer_size, &retlen, NULL);
|
||||
|
||||
CloseHandle(VKernelEx);
|
||||
|
||||
if (!result || retlen > buffer_size)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ extern sstring kernelex_dir;
|
||||
extern sstring own_path;
|
||||
|
||||
void ShowError(UINT id, ...);
|
||||
bool rerun_setup();
|
||||
bool VKernelEx_ioctl(DWORD command, PVOID buffer, DWORD buffer_size);
|
||||
bool isWinMe();
|
||||
|
||||
typedef MODREF* (__stdcall *MRFromHLib_t)(HMODULE);
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "apiconf.h"
|
||||
#include "apiconfmgr.h"
|
||||
#include "internals.h"
|
||||
#include "../setup/loadstub.h"
|
||||
#include "../vxd/interface.h"
|
||||
#include "thunks.h"
|
||||
#include "SettingsDB.h"
|
||||
#include "ModInit.h"
|
||||
@ -775,6 +775,8 @@ PROC WINAPI iGetProcAddress(HMODULE hModule, LPCSTR lpProcName)
|
||||
DBGASSERT(ppmteModTable != NULL);
|
||||
|
||||
MODREF* mr = MRFromHLib(hModule);
|
||||
if (mr == NULL)
|
||||
return NULL;
|
||||
IMTE* imte = (*ppmteModTable)[mr->mteIndex];
|
||||
IMAGE_NT_HEADERS* nt_hdr = imte->pNTHdr;
|
||||
|
||||
@ -783,25 +785,6 @@ PROC WINAPI iGetProcAddress(HMODULE hModule, LPCSTR lpProcName)
|
||||
return OriExportFromName(nt_hdr, 0, lpProcName);
|
||||
}
|
||||
|
||||
static IMAGE_SECTION_HEADER* get_data_section()
|
||||
{
|
||||
int i;
|
||||
IMAGE_DOS_HEADER* MZh = (IMAGE_DOS_HEADER*) GetModuleHandle("kernel32");
|
||||
IMAGE_NT_HEADERS* PEh = (IMAGE_NT_HEADERS*) ((int)MZh + MZh->e_lfanew);
|
||||
IMAGE_SECTION_HEADER* section = (IMAGE_SECTION_HEADER*)
|
||||
((int)PEh
|
||||
+ PEh->FileHeader.SizeOfOptionalHeader
|
||||
+ sizeof(IMAGE_FILE_HEADER)
|
||||
+ sizeof(DWORD));
|
||||
for (i = 0 ; i < PEh->FileHeader.NumberOfSections ; i++)
|
||||
{
|
||||
if (!strcmpi((char*) section->Name, ".data"))
|
||||
return section;
|
||||
section++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void reset_imtes()
|
||||
{
|
||||
DBGPRINTF(("Reseting IMTEs\n"));
|
||||
@ -863,41 +846,38 @@ void dump_imtes(void)
|
||||
int resolver_init()
|
||||
{
|
||||
DBGPRINTF(("resolver_init()\n"));
|
||||
DWORD ptr;
|
||||
KernelEx_dataseg* dseg = NULL;
|
||||
IMAGE_SECTION_HEADER* section = get_data_section();
|
||||
DWORD sign_len = sizeof(KEX_SIGNATURE) - 1;
|
||||
|
||||
if (!section)
|
||||
return 0;
|
||||
|
||||
ptr = (DWORD) h_kernel32 + section->VirtualAddress + section->Misc.VirtualSize - sign_len;
|
||||
while (ptr >= (DWORD) h_kernel32 + section->VirtualAddress)
|
||||
ioctl_connect_params params;
|
||||
if (!VKernelEx_ioctl(IOCTL_CONNECT, ¶ms, sizeof(params)))
|
||||
{
|
||||
if (!memcmp((void*)ptr, KEX_SIGNATURE, sign_len))
|
||||
{
|
||||
dseg = (KernelEx_dataseg*) ptr;
|
||||
break;
|
||||
}
|
||||
ptr--;
|
||||
DBGPRINTF(("IOCTL_Connect failed!\n"));
|
||||
ShowError(IDS_NODRIVER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
KernelEx_dataseg* dseg = params.stub_ptr;
|
||||
|
||||
if (!params.status)
|
||||
{
|
||||
DBGPRINTF(("VKRNLEX failed to initialize!\n"));
|
||||
ShowError(IDS_DRIVERINITFAIL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!dseg)
|
||||
{
|
||||
DBGPRINTF(("Signature not found\n"));
|
||||
if (!rerun_setup())
|
||||
ShowError(IDS_NOTREADY);
|
||||
DBGPRINTF(("Stub not found\n"));
|
||||
ShowError(IDS_DRIVERINITFAIL);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
DBGPRINTF(("Signature found @ 0x%08x\n", ptr));
|
||||
DBGPRINTF(("Stub found @ 0x%08x\n", dseg));
|
||||
|
||||
if (dseg->version != KEX_STUB_VER)
|
||||
{
|
||||
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);
|
||||
ShowError(IDS_STUBMISMATCH, KEX_STUB_VER, dseg->version);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,10 @@
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Core.rc
|
||||
//
|
||||
#define IDS_NOTREADY 1
|
||||
#define IDS_NODRIVER 1
|
||||
#define IDS_STUBMISMATCH 2
|
||||
#define IDS_OLDVER 3
|
||||
#define IDS_DRIVERINITFAIL 4
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "thunks.h"
|
||||
#include "internals.h"
|
||||
#include "resolver.h"
|
||||
#include "../setup/loadstub.h"
|
||||
#include "../vxd/interface.h"
|
||||
|
||||
__declspec(naked)
|
||||
PROC ExportFromOrdinalStatic_thunk(IMAGE_NT_HEADERS* PEh, WORD ordinal)
|
||||
|
Reference in New Issue
Block a user