mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
dynamically import functions from ntdll on startup
svn path=/trunk/; revision=16878
This commit is contained in:
parent
209e4c128e
commit
e069829247
1 changed files with 33 additions and 29 deletions
|
@ -164,10 +164,10 @@ HANDLE hIn;
|
||||||
HANDLE hOut;
|
HANDLE hOut;
|
||||||
HANDLE hConsole;
|
HANDLE hConsole;
|
||||||
HANDLE CMD_ModuleHandle;
|
HANDLE CMD_ModuleHandle;
|
||||||
|
HMODULE NtDllModule;
|
||||||
|
|
||||||
static NtQueryInformationProcessProc NtQueryInformationProcessPtr;
|
static NtQueryInformationProcessProc NtQueryInformationProcessPtr = NULL;
|
||||||
static NtReadVirtualMemoryProc NtReadVirtualMemoryPtr;
|
static NtReadVirtualMemoryProc NtReadVirtualMemoryPtr = NULL;
|
||||||
static BOOL NtDllChecked = FALSE;
|
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_COLOR
|
#ifdef INCLUDE_CMD_COLOR
|
||||||
WORD wColor; /* current color */
|
WORD wColor; /* current color */
|
||||||
|
@ -193,28 +193,6 @@ static BOOL IsConsoleProcess(HANDLE Process)
|
||||||
PROCESS_BASIC_INFORMATION Info;
|
PROCESS_BASIC_INFORMATION Info;
|
||||||
PEB ProcessPeb;
|
PEB ProcessPeb;
|
||||||
ULONG BytesRead;
|
ULONG BytesRead;
|
||||||
HMODULE NtDllModule;
|
|
||||||
|
|
||||||
/* Some people like to run ReactOS cmd.exe on Win98, it helps in the
|
|
||||||
build process. So don't link implicitly against ntdll.dll, load it
|
|
||||||
dynamically instead */
|
|
||||||
if (! NtDllChecked)
|
|
||||||
{
|
|
||||||
NtDllChecked = TRUE;
|
|
||||||
NtDllModule = LoadLibrary(_T("ntdll.dll"));
|
|
||||||
if (NULL == NtDllModule)
|
|
||||||
{
|
|
||||||
/* Probably non-WinNT system. Just wait for the commands
|
|
||||||
to finish. */
|
|
||||||
NtQueryInformationProcessPtr = NULL;
|
|
||||||
NtReadVirtualMemoryPtr = NULL;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
NtQueryInformationProcessPtr = (NtQueryInformationProcessProc)
|
|
||||||
GetProcAddress(NtDllModule, "NtQueryInformationProcess");
|
|
||||||
NtReadVirtualMemoryPtr = (NtReadVirtualMemoryProc)
|
|
||||||
GetProcAddress(NtDllModule, "NtReadVirtualMemory");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL == NtQueryInformationProcessPtr || NULL == NtReadVirtualMemoryPtr)
|
if (NULL == NtQueryInformationProcessPtr || NULL == NtReadVirtualMemoryPtr)
|
||||||
{
|
{
|
||||||
|
@ -1258,6 +1236,31 @@ Initialize (int argc, TCHAR* argv[])
|
||||||
|
|
||||||
//INT len;
|
//INT len;
|
||||||
//TCHAR *ptr, *cmdLine;
|
//TCHAR *ptr, *cmdLine;
|
||||||
|
|
||||||
|
/* get version information */
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
GetVersionEx (&osvi);
|
||||||
|
|
||||||
|
/* Some people like to run ReactOS cmd.exe on Win98, it helps in the
|
||||||
|
build process. So don't link implicitly against ntdll.dll, load it
|
||||||
|
dynamically instead */
|
||||||
|
|
||||||
|
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||||
|
{
|
||||||
|
/* ntdll is always present on NT */
|
||||||
|
NtDllModule = GetModuleHandle(TEXT("ntdll.dll"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* not all 9x versions have a ntdll.dll, try to load it */
|
||||||
|
NtDllModule = LoadLibrary(TEXT("ntdll.dll"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NtDllModule != NULL)
|
||||||
|
{
|
||||||
|
NtQueryInformationProcessPtr = (NtQueryInformationProcessProc)GetProcAddress(NtDllModule, "NtQueryInformationProcess");
|
||||||
|
NtReadVirtualMemoryPtr = (NtReadVirtualMemoryProc)GetProcAddress(NtDllModule, "NtReadVirtualMemory");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
@ -1271,10 +1274,6 @@ Initialize (int argc, TCHAR* argv[])
|
||||||
DebugPrintf (_T("]\n"));
|
DebugPrintf (_T("]\n"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* get version information */
|
|
||||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
||||||
GetVersionEx (&osvi);
|
|
||||||
|
|
||||||
InitLocale ();
|
InitLocale ();
|
||||||
|
|
||||||
/* get default input and output console handles */
|
/* get default input and output console handles */
|
||||||
|
@ -1478,6 +1477,11 @@ static VOID Cleanup (int argc, TCHAR *argv[])
|
||||||
RemoveBreakHandler ();
|
RemoveBreakHandler ();
|
||||||
SetConsoleMode( GetStdHandle( STD_INPUT_HANDLE ),
|
SetConsoleMode( GetStdHandle( STD_INPUT_HANDLE ),
|
||||||
ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT );
|
ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT );
|
||||||
|
|
||||||
|
if (NtDllModule != NULL)
|
||||||
|
{
|
||||||
|
FreeLibrary(NtDllModule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
|
|
Loading…
Reference in a new issue