mirror of
https://github.com/reactos/reactos.git
synced 2025-05-17 16:27:00 +00:00
Updates to the VDM support. Improvemnts to the new wine-debug-channels supprt.
svn path=/trunk/; revision=3991
This commit is contained in:
parent
1028fc6755
commit
329c896e1f
9 changed files with 391 additions and 172 deletions
|
@ -1,23 +1,20 @@
|
|||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
INT
|
||||
STDCALL
|
||||
DllMain (
|
||||
PVOID hinstDll,
|
||||
ULONG dwReason,
|
||||
PVOID reserved
|
||||
)
|
||||
DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
|
||||
{
|
||||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return(1);
|
||||
switch (dwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
break;
|
||||
case DLL_THREAD_DETACH:
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
# $Id: Makefile,v 1.1 2003/01/08 19:52:22 robd Exp $
|
||||
# $Id: Makefile,v 1.2 2003/01/12 01:54:39 robd Exp $
|
||||
|
||||
PATH_TO_TOP = ../..
|
||||
|
||||
TARGET_DEFONLY = yes
|
||||
|
||||
TARGET_TYPE = dynlink
|
||||
|
||||
TARGET_NAME = winedbgc
|
||||
|
||||
#TARGET_CFLAGS = -fno-rtti -D_ROS_ -D__WINE__
|
||||
|
||||
TARGET_CFLAGS = -g -D__NTDLL__
|
||||
#TARGET_CFLAGS = -g -D__NTDLL__
|
||||
TARGET_CFLAGS = -D__NTDLL__
|
||||
|
||||
TARGET_LFLAGS = -Wl,--file-alignment,0x1000 \
|
||||
-Wl,--section-alignment,0x1000 \
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
#include <ntddk.h>
|
||||
#include <wine/debugtools.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -25,7 +25,10 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "porting.h"
|
||||
/*
|
||||
#include "config.h"
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <ntddk.h>
|
||||
#include <wine/debugtools.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <windows.h>
|
||||
//#include <ntddk.h>
|
||||
//#include <wine/debugtools.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <stdio.h>
|
||||
//#include <stdarg.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
/*
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
@ -57,21 +58,21 @@ WINE_DEFAULT_DEBUG_CHANNEL(winedbgc);
|
|||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
|
||||
/*
|
||||
TRACE("Initializing or Finalizing proxy winedbgc: %p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
|
||||
|
||||
// TRACE("Initializing or Finalizing winedbgc: %p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
TRACE("Loading winedbgc...\n");
|
||||
// TRACE("Loading winedbgc...\n");
|
||||
/*
|
||||
#ifndef __REACTOS__
|
||||
if (winedbgc_LoadDriverManager())
|
||||
winedbgc_LoadDMFunctions();
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
TRACE("Unloading winedbgc...\n");
|
||||
// TRACE("Unloading winedbgc...\n");
|
||||
/*
|
||||
#ifndef __REACTOS__
|
||||
if (gProxyHandle.bFunctionReady)
|
||||
{
|
||||
|
@ -87,8 +88,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
gProxyHandle.dmHandle = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,15 +18,10 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <ntddk.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <stdio.h>
|
||||
//#include <stdarg.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include "porting.h"
|
||||
|
||||
|
||||
static int interlocked_mutex;
|
||||
void _lwp_mutex_lock(int* interlocked_mutex) {}
|
||||
void _lwp_mutex_unlock(int* interlocked_mutex) {}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
/*
|
||||
* Debugging channels functions for WINE
|
||||
*/
|
||||
#include <ntddk.h>
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "porting.h"
|
||||
|
||||
//#include <ntddk.h>
|
||||
#include <wine/debugtools.h>
|
||||
|
||||
//DECLARE_DEBUG_CHANNEL(tid);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: winedbgc.def,v 1.1 2003/01/08 19:52:22 robd Exp $
|
||||
; $Id: winedbgc.def,v 1.2 2003/01/12 01:54:39 robd Exp $
|
||||
;
|
||||
; ReactOS Operating System
|
||||
;
|
||||
|
@ -6,59 +6,32 @@ LIBRARY winedbgc.dll
|
|||
|
||||
EXPORTS
|
||||
|
||||
;wine_dbgstr_an
|
||||
;wine_dbgstr_wn
|
||||
;wine_dbgstr_guid
|
||||
;wine_dbg_vprintf
|
||||
;wine_dbg_printf
|
||||
;wine_dbg_log
|
||||
wine_dbg_log
|
||||
wine_dbg_printf
|
||||
wine_dbgstr_an
|
||||
wine_dbgstr_guid
|
||||
wine_dbgstr_wn
|
||||
__wine_dbg_register
|
||||
__wine_dbg_unregister
|
||||
__wine_dbg_vlog DATA
|
||||
__wine_dbg_vprintf DATA
|
||||
__wine_dbgstr_an DATA
|
||||
__wine_dbgstr_guid DATA
|
||||
__wine_dbgstr_wn DATA
|
||||
|
||||
wine_dbg_log @ 1 ;
|
||||
__wine_dbg_register @ 2 ;
|
||||
__wine_dbg_unregister @ 3 ;
|
||||
__wine_dbg_vlog @ 4 DATA ;
|
||||
__wine_dbg_vprintf @ 5 DATA ;
|
||||
__wine_dbgstr_an @ 6 DATA ;
|
||||
__wine_dbgstr_guid @ 7 DATA ;
|
||||
__wine_dbgstr_wn @ 8 DATA ;
|
||||
__wine_dll_register @ 9 ;
|
||||
__wine_main_argc @ 10 DATA ;
|
||||
__wine_main_argv @ 11 DATA ;
|
||||
__wine_main_wargv @ 12 DATA ;
|
||||
interlocked_cmpxchg @ 20 ;
|
||||
interlocked_cmpxchg_ptr @ 21 ;
|
||||
interlocked_xchg @ 22 ;
|
||||
interlocked_xchg_add @ 23 ;
|
||||
interlocked_xchg_ptr @ 24 ;
|
||||
wine_anon_mmap @ 30 ;
|
||||
wine_dbg_add_option @ 31 ;
|
||||
wine_dbg_parse_options @ 33 ;
|
||||
wine_dbg_printf @ 34 ;
|
||||
wine_dbgstr_a @ 35 ;
|
||||
wine_dbgstr_an @ 36 ;
|
||||
wine_dbgstr_guid @ 37 ;
|
||||
wine_dbgstr_w @ 38 ;
|
||||
wine_dbgstr_wn @ 39 ;
|
||||
wine_dlclose @ 40 ;
|
||||
wine_dll_load @ 41 ;
|
||||
wine_dll_load_main_exe @ 42 ;
|
||||
wine_dll_set_callback @ 43 ;
|
||||
wine_dll_unload @ 44 ;
|
||||
wine_dlopen @ 45 ;
|
||||
wine_dlsym @ 46 ;
|
||||
wine_errno_location @ 47 DATA ;
|
||||
wine_get_config_dir @ 48 ;
|
||||
wine_get_cs @ 49 ;
|
||||
wine_get_ds @ 50 ;
|
||||
wine_get_es @ 51 ;
|
||||
wine_get_fs @ 52 ;
|
||||
wine_get_gs @ 53 ;
|
||||
wine_get_server_dir @ 54 ;
|
||||
wine_get_ss @ 55 ;
|
||||
wine_h_errno_location @ 56 DATA ;
|
||||
wine_ldt_copy @ 57 DATA ;
|
||||
wine_ldt_get_entry @ 58 ;
|
||||
wine_ldt_set_entry @ 59 ;
|
||||
wine_rewrite_s4tos2 @ 60 ;
|
||||
wine_set_fs @ 61 ;
|
||||
wine_set_gs @ 62 ;
|
||||
|
||||
;
|
||||
;wine_dbg_log @1
|
||||
;__wine_dbg_register @2
|
||||
;__wine_dbg_unregister @3
|
||||
;__wine_dbg_vlog @4 DATA
|
||||
;__wine_dbg_vprintf @5 DATA
|
||||
;__wine_dbgstr_an @6 DATA
|
||||
;__wine_dbgstr_guid @7 DATA
|
||||
;__wine_dbgstr_wn @8 DATA
|
||||
;
|
||||
;wine_dbg_printf @34
|
||||
;wine_dbgstr_an @36
|
||||
;wine_dbgstr_guid @37
|
||||
;wine_dbgstr_wn @39
|
||||
;
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: winedbgc.edf,v 1.1 2003/01/08 19:52:22 robd Exp $
|
||||
; $Id: winedbgc.edf,v 1.2 2003/01/12 01:54:39 robd Exp $
|
||||
;
|
||||
; ReactOS Operating System
|
||||
;
|
||||
|
@ -6,6 +6,21 @@ LIBRARY winedbgc.dll
|
|||
|
||||
EXPORTS
|
||||
|
||||
wine_dbg_log
|
||||
wine_dbg_printf
|
||||
wine_dbgstr_an
|
||||
wine_dbgstr_guid
|
||||
wine_dbgstr_wn
|
||||
__wine_dbg_register
|
||||
__wine_dbg_unregister
|
||||
__wine_dbg_vlog DATA
|
||||
__wine_dbg_vprintf DATA
|
||||
__wine_dbgstr_an DATA
|
||||
__wine_dbgstr_guid DATA
|
||||
__wine_dbgstr_wn DATA
|
||||
|
||||
|
||||
|
||||
;wine_dbgstr_an
|
||||
;wine_dbgstr_wn
|
||||
;wine_dbgstr_guid
|
||||
|
@ -13,52 +28,54 @@ EXPORTS
|
|||
;wine_dbg_printf
|
||||
;wine_dbg_log
|
||||
|
||||
wine_dbg_log @ 1 ;
|
||||
__wine_dbg_register @ 2 ;
|
||||
__wine_dbg_unregister @ 3 ;
|
||||
__wine_dbg_vlog @ 4 DATA ;
|
||||
__wine_dbg_vprintf @ 5 DATA ;
|
||||
__wine_dbgstr_an @ 6 DATA ;
|
||||
__wine_dbgstr_guid @ 7 DATA ;
|
||||
__wine_dbgstr_wn @ 8 DATA ;
|
||||
;__wine_dll_register @ 9 ;
|
||||
;__wine_main_argc @ 10 DATA ;
|
||||
;__wine_main_argv @ 11 DATA ;
|
||||
;__wine_main_wargv @ 12 DATA ;
|
||||
;interlocked_cmpxchg @ 20 ;
|
||||
;interlocked_cmpxchg_ptr @ 21 ;
|
||||
;interlocked_xchg @ 22 ;
|
||||
;interlocked_xchg_add @ 23 ;
|
||||
;interlocked_xchg_ptr @ 24 ;
|
||||
;wine_anon_mmap @ 30 ;
|
||||
;wine_dbg_add_option @ 31 ;
|
||||
;wine_dbg_parse_options @ 33 ;
|
||||
wine_dbg_printf @ 34 ;
|
||||
;wine_dbgstr_a @ 35 ;
|
||||
wine_dbgstr_an @ 36 ;
|
||||
wine_dbgstr_guid @ 37 ;
|
||||
;wine_dbgstr_w @ 38 ;
|
||||
wine_dbgstr_wn @ 39 ;
|
||||
;wine_dlclose @ 40 ;
|
||||
;wine_dll_load @ 41 ;
|
||||
;wine_dll_load_main_exe @ 42 ;
|
||||
;wine_dll_set_callback @ 43 ;
|
||||
;wine_dll_unload @ 44 ;
|
||||
;wine_dlopen @ 45 ;
|
||||
;wine_dlsym @ 46 ;
|
||||
;wine_errno_location @ 47 DATA ;
|
||||
;wine_get_config_dir @ 48 ;
|
||||
;wine_get_cs @ 49 ;
|
||||
;wine_get_ds @ 50 ;
|
||||
;wine_get_es @ 51 ;
|
||||
;wine_get_fs @ 52 ;
|
||||
;wine_get_gs @ 53 ;
|
||||
;wine_get_server_dir @ 54 ;
|
||||
;wine_get_ss @ 55 ;
|
||||
;wine_h_errno_location @ 56 DATA ;
|
||||
;wine_ldt_copy @ 57 DATA ;
|
||||
;wine_ldt_get_entry @ 58 ;
|
||||
;wine_ldt_set_entry @ 59 ;
|
||||
;wine_rewrite_s4tos2 @ 60 ;
|
||||
;wine_set_fs @ 61 ;
|
||||
;wine_set_gs @ 62 ;
|
||||
; wine_dbg_log @1
|
||||
; __wine_dbg_register @2
|
||||
; __wine_dbg_unregister @3
|
||||
; __wine_dbg_vlog @4 DATA
|
||||
; __wine_dbg_vprintf @5 DATA
|
||||
; __wine_dbgstr_an @6 DATA
|
||||
; __wine_dbgstr_guid @7 DATA
|
||||
; __wine_dbgstr_wn @8 DATA
|
||||
;__wine_dll_register @9
|
||||
;__wine_main_argc @10 DATA
|
||||
;__wine_main_argv @11 DATA
|
||||
;__wine_main_wargv @12 DATA
|
||||
|
||||
|
||||
;interlocked_cmpxchg @20
|
||||
;interlocked_cmpxchg_ptr @21
|
||||
;interlocked_xchg @22
|
||||
;interlocked_xchg_add @23
|
||||
;interlocked_xchg_ptr @24
|
||||
;wine_anon_mmap @30
|
||||
;wine_dbg_add_option @31
|
||||
;wine_dbg_parse_options @33
|
||||
; wine_dbg_printf @34
|
||||
;wine_dbgstr_a @35
|
||||
; wine_dbgstr_an @36
|
||||
; wine_dbgstr_guid @37
|
||||
;wine_dbgstr_w @38
|
||||
; wine_dbgstr_wn @39
|
||||
;wine_dlclose @40
|
||||
;wine_dll_load @41
|
||||
;wine_dll_load_main_exe @42
|
||||
;wine_dll_set_callback @43
|
||||
;wine_dll_unload @44
|
||||
;wine_dlopen @45
|
||||
;wine_dlsym @46
|
||||
;wine_errno_location @47 DATA
|
||||
;wine_get_config_dir @48
|
||||
;wine_get_cs @49
|
||||
;wine_get_ds @50
|
||||
;wine_get_es @51
|
||||
;wine_get_fs @52
|
||||
;wine_get_gs @53
|
||||
;wine_get_server_dir @54
|
||||
;wine_get_ss @55
|
||||
;wine_h_errno_location @56 DATA
|
||||
;wine_ldt_copy @57 DATA
|
||||
;wine_ldt_get_entry @58
|
||||
;wine_ldt_set_entry @59
|
||||
;wine_rewrite_s4tos2 @60
|
||||
;wine_set_fs @61
|
||||
;wine_set_gs @62
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* $Id: ntvdm.c,v 1.1 2002/10/28 13:59:59 robd Exp $
|
||||
/* $Id: ntvdm.c,v 1.2 2003/01/12 01:54:40 robd Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: subsys/ntvdm/ntvdm.c
|
||||
* FILE: subsys/ntvdm/ntvdm->c
|
||||
* PURPOSE: Virtual DOS Machine
|
||||
* PROGRAMMER: Robert Dickenson (robd@mok.lvcm.com)
|
||||
* UPDATE HISTORY:
|
||||
|
@ -62,19 +62,40 @@ NtUnmapViewOfSection
|
|||
|
||||
NtVdmControl
|
||||
*/
|
||||
typedef struct tag_VDM_CONFIG {
|
||||
int dos_options;
|
||||
int files;
|
||||
int buffers;
|
||||
WCHAR** device_list;
|
||||
//dos=high, umb
|
||||
//device=%SystemRoot%\system32\himem.sys
|
||||
//files=40
|
||||
} VDM_CONFIG, *PVDM_CONFIG;
|
||||
|
||||
BOOLEAN
|
||||
StartVirtualMachine(VOID)
|
||||
typedef struct tag_VDM_AUTOEXEC {
|
||||
WCHAR** load_list;
|
||||
//lh %SystemRoot%\system32\mscdexnt.exe
|
||||
//lh %SystemRoot%\system32\redir
|
||||
//lh %SystemRoot%\system32\dosx
|
||||
} VDM_AUTOEXEC, *PVDM_AUTOEXEC;
|
||||
|
||||
typedef struct tag_VDM_CONTROL_BLOCK {
|
||||
HANDLE hHeap;
|
||||
PVOID ImageMem;
|
||||
VDM_CONFIG vdmConfig;
|
||||
VDM_AUTOEXEC vdmAutoexec;
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
CHAR CommandLine[MAX_PATH];
|
||||
CHAR CurrentDirectory[MAX_PATH];
|
||||
|
||||
} VDM_CONTROL_BLOCK, *PVDM_CONTROL_BLOCK;
|
||||
|
||||
|
||||
BOOL
|
||||
StartVDM(PVDM_CONTROL_BLOCK vdm)
|
||||
{
|
||||
BOOLEAN Result;
|
||||
BOOL Result;
|
||||
STARTUPINFO StartupInfo;
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
CHAR CommandLine[MAX_PATH];
|
||||
CHAR CurrentDirectory[MAX_PATH];
|
||||
|
||||
GetSystemDirectory(CommandLine, MAX_PATH);
|
||||
strcat(CommandLine, "\\hello.exe");
|
||||
GetWindowsDirectory(CurrentDirectory, MAX_PATH);
|
||||
|
||||
StartupInfo.cb = sizeof(StartupInfo);
|
||||
StartupInfo.lpReserved = NULL;
|
||||
|
@ -84,7 +105,7 @@ StartVirtualMachine(VOID)
|
|||
StartupInfo.cbReserved2 = 0;
|
||||
StartupInfo.lpReserved2 = 0;
|
||||
|
||||
Result = CreateProcess(CommandLine,
|
||||
Result = CreateProcess(vdm->CommandLine,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -93,35 +114,205 @@ StartVirtualMachine(VOID)
|
|||
NULL,
|
||||
NULL,
|
||||
&StartupInfo,
|
||||
&ProcessInformation);
|
||||
&vdm->ProcessInformation);
|
||||
if (!Result) {
|
||||
PrintString("WL: Failed to execute target process\n");
|
||||
PrintString("VDM: Failed to execute target process\n");
|
||||
return FALSE;
|
||||
}
|
||||
WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
|
||||
CloseHandle(ProcessInformation.hProcess);
|
||||
CloseHandle(ProcessInformation.hThread);
|
||||
WaitForSingleObject(vdm->ProcessInformation.hProcess, INFINITE);
|
||||
CloseHandle(vdm->ProcessInformation.hProcess);
|
||||
CloseHandle(vdm->ProcessInformation.hThread);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
ShutdownVDM(PVDM_CONTROL_BLOCK vdm)
|
||||
{
|
||||
BOOL result = TRUE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL ReadConfigForVDM(PVDM_CONTROL_BLOCK vdm)
|
||||
{
|
||||
BOOL result = TRUE;
|
||||
DWORD dwError;
|
||||
HANDLE hFile;
|
||||
|
||||
hFile = CreateFileW(L"\\system32\\config.nt",
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_ALWAYS /*OPEN_EXISTING*/,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
0);
|
||||
dwError = GetLastError();
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
// error with file path or system problem?
|
||||
} else {
|
||||
if (dwError == 0L) {
|
||||
// we just created a new file, perhaps we should set/write some defaults?
|
||||
}
|
||||
if (dwError == ERROR_ALREADY_EXISTS) {
|
||||
// read the line entries and cache in some struct...
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
hFile = CreateFileW(L"\\system32\\autoexec.nt",
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
0);
|
||||
dwError = GetLastError();
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
// error with file path or system problem?
|
||||
} else {
|
||||
if (dwError == 0L) {
|
||||
// we just created a new file, perhaps we should set/write some defaults?
|
||||
}
|
||||
if (dwError == ERROR_ALREADY_EXISTS) {
|
||||
// read the line entries and cache in some struct...
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL
|
||||
LoadConfigDriversForVDM(PVDM_CONFIG vdmConfig)
|
||||
{
|
||||
BOOL result = TRUE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL
|
||||
SetConfigOptionsForVDM(PVDM_AUTOEXEC vdmAutoexec)
|
||||
{
|
||||
BOOL result = TRUE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CreateVDM(PVDM_CONTROL_BLOCK vdm)
|
||||
{
|
||||
// BOOL result = TRUE;
|
||||
SYSTEM_INFO inf;
|
||||
MEMORYSTATUS stat;
|
||||
PVOID lpMem = NULL;
|
||||
|
||||
GlobalMemoryStatus(&stat);
|
||||
if (stat.dwLength != sizeof(MEMORYSTATUS)) {
|
||||
printf("WARNING: GlobalMemoryStatus() returned unknown structure version, size %ld, expected %d.\n", stat.dwLength, sizeof(stat));
|
||||
} else {
|
||||
printf("Memory Load: %ld percent in use.\n", stat.dwMemoryLoad);
|
||||
printf("\t%ld total bytes physical memory.\n", stat.dwTotalPhys);
|
||||
printf("\t%ld available physical memory.\n", stat.dwAvailPhys);
|
||||
printf("\t%ld total bytes paging file.\n", stat.dwTotalPageFile);
|
||||
printf("\t%ld available paging file.\n", stat.dwAvailPageFile);
|
||||
printf("\t%lx total bytes virtual memory.\n", stat.dwTotalVirtual);
|
||||
printf("\t%lx available bytes virtual memory.\n", stat.dwAvailVirtual);
|
||||
|
||||
#define OUT_OF_HEADROOM 90
|
||||
if (stat.dwMemoryLoad > OUT_OF_HEADROOM) {
|
||||
DPRINT("VDM: system resources deemed to low to start VDM.\n");
|
||||
//SetLastError();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
GetSystemInfo(&inf);
|
||||
vdm->hHeap = HeapCreate(0, inf.dwAllocationGranularity, 0);
|
||||
if (vdm->hHeap == NULL) {
|
||||
DPRINT("VDM: failed to create heap.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define DEFAULT_VDM_IMAGE_SIZE 2000000
|
||||
vdm->ImageMem = HeapAlloc(vdm->hHeap, 0, DEFAULT_VDM_IMAGE_SIZE);
|
||||
if (vdm->ImageMem == NULL) {
|
||||
DPRINT("VDM: failed to allocate image memory from heap %x.\n", vdm->hHeap);
|
||||
HeapDestroy(vdm->hHeap);
|
||||
vdm->hHeap = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
DestroyVDM(PVDM_CONTROL_BLOCK vdm)
|
||||
{
|
||||
BOOL result = TRUE;
|
||||
|
||||
if (vdm->ImageMem != NULL) {
|
||||
if (HeapFree(vdm->hHeap, 0, vdm->ImageMem) != FALSE) {
|
||||
DPRINT("VDM: failed to free memory from heap %x.\n", vdm->hHeap);
|
||||
result = FALSE;
|
||||
}
|
||||
vdm->ImageMem = NULL;
|
||||
}
|
||||
if (vdm->hHeap != NULL) {
|
||||
if (!HeapDestroy(vdm->hHeap)) {
|
||||
DPRINT("VDM: failed to destroy heap %x.\n", vdm->hHeap);
|
||||
result = FALSE;
|
||||
}
|
||||
vdm->hHeap = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int STDCALL
|
||||
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||
{
|
||||
VDM_CONTROL_BLOCK VdmCB;
|
||||
DWORD Result;
|
||||
BOOL Success;
|
||||
ULONG i;
|
||||
NTSTATUS Status;
|
||||
BOOL vdmStarted = FALSE;
|
||||
|
||||
CHAR WelcomeMsg[] = "ReactOS Virtual DOS Machine support.\nType q<cr> to quit.";
|
||||
CHAR WelcomeMsg[] = "ReactOS Virtual DOS Machine support.\n";
|
||||
CHAR PromptMsg[] = "Type r<cr> to run, s<cr> to shutdown or q<cr> to quit now.";
|
||||
CHAR InputBuffer[255];
|
||||
|
||||
AllocConsole();
|
||||
SetConsoleTitle("ntvdm");
|
||||
StartVirtualMachine();
|
||||
|
||||
|
||||
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||
WelcomeMsg, strlen(WelcomeMsg), // wcslen(WelcomeMsg),
|
||||
&Result, NULL);
|
||||
|
||||
if (!CreateVDM(&VdmCB)) {
|
||||
DPRINT("VDM: failed to create VDM.\n");
|
||||
//SetLastError();
|
||||
return 2;
|
||||
}
|
||||
|
||||
ReadConfigForVDM(&VdmCB);
|
||||
|
||||
if (!LoadConfigDriversForVDM(&(VdmCB.vdmConfig))) {
|
||||
DPRINT("VDM: failed to load configuration drivers.\n");
|
||||
//SetLastError();
|
||||
return 2;
|
||||
}
|
||||
if (!SetConfigOptionsForVDM(&(VdmCB.vdmAutoexec))) {
|
||||
DPRINT("VDM: failed to set configuration options.\n");
|
||||
//SetLastError();
|
||||
return 3;
|
||||
}
|
||||
|
||||
GetSystemDirectory(VdmCB.CommandLine, MAX_PATH);
|
||||
strcat(VdmCB.CommandLine, "\\hello.exe");
|
||||
GetWindowsDirectory(VdmCB.CurrentDirectory, MAX_PATH);
|
||||
|
||||
for (;;) {
|
||||
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||
WelcomeMsg, strlen(WelcomeMsg), // wcslen(WelcomeMsg),
|
||||
PromptMsg, strlen(PromptMsg), // wcslen(PromptMsg),
|
||||
&Result, NULL);
|
||||
i = 0;
|
||||
do {
|
||||
|
@ -134,11 +325,45 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nSho
|
|||
} while (InputBuffer[i - 1] != '\n');
|
||||
InputBuffer[i - 1] = '\0';
|
||||
|
||||
if (InputBuffer[0] == 'r' || InputBuffer[0] == 'R') {
|
||||
if (!vdmStarted) {
|
||||
if (StartVDM(&VdmCB)) {
|
||||
vdmStarted = TRUE;
|
||||
} else {
|
||||
DPRINT("VDM: failed to start.\n");
|
||||
}
|
||||
} else {
|
||||
DPRINT("VDM: already started.\n");
|
||||
}
|
||||
}
|
||||
if (InputBuffer[0] == 's' || InputBuffer[0] == 'S') {
|
||||
if (vdmStarted) {
|
||||
if (ShutdownVDM(&VdmCB)) {
|
||||
vdmStarted = FALSE;
|
||||
} else {
|
||||
DPRINT("VDM: failed to shutdown.\n");
|
||||
}
|
||||
} else {
|
||||
DPRINT("VDM: not started.\n");
|
||||
}
|
||||
}
|
||||
if (InputBuffer[0] == 'q' || InputBuffer[0] == 'Q') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ShutdownVDM(&VdmCB)) {
|
||||
DPRINT("VDM: failed to cleanly shutdown VDM.\n");
|
||||
//SetLastError();
|
||||
return 5;
|
||||
}
|
||||
|
||||
if (!DestroyVDM(&VdmCB)) {
|
||||
DPRINT("VDM: failed to cleanly destroy VDM.\n");
|
||||
//SetLastError();
|
||||
return 6;
|
||||
}
|
||||
|
||||
ExitProcess(0);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue