-
Notifications
You must be signed in to change notification settings - Fork 0
/
ntvdm.patch
199 lines (181 loc) · 5.39 KB
/
ntvdm.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b66140..3997973 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.2.1)
cmake_policy(VERSION 3.2.1)
+set(NO_ROSSYM TRUE)
+
if(NOT CMAKE_VERSION MATCHES "ReactOS")
message(WARNING "Building with \"${CMAKE_COMMAND}\", which is not the custom CMake included in RosBE, might cause build issues...")
diff --git a/sdk/cmake/localization.cmake b/sdk/cmake/localization.cmake
index 220243c..16ea486 100644
--- a/sdk/cmake/localization.cmake
+++ b/sdk/cmake/localization.cmake
@@ -1,6 +1,6 @@
if(NOT DEFINED I18N_LANG)
- set(I18N_LANG all)
+ set(I18N_LANG en-US)
endif()
function(set_i18n_language I18N_LANG)
diff --git a/subsystems/mvdm/ntvdm/CMakeLists.txt b/subsystems/mvdm/ntvdm/CMakeLists.txt
index ff102d8..ae8653e 100644
--- a/subsystems/mvdm/ntvdm/CMakeLists.txt
+++ b/subsystems/mvdm/ntvdm/CMakeLists.txt
@@ -68,10 +68,12 @@ list(APPEND SOURCE
file(GLOB ntvdm_rc_deps res/*.*)
add_rc_deps(ntvdm.rc ${ntvdm_rc_deps})
+
add_executable(ntvdm
${SOURCE}
ntvdm.rc
- ${CMAKE_CURRENT_BINARY_DIR}/ntvdm.def)
+ #${CMAKE_CURRENT_BINARY_DIR}/ntvdm.def
+ )
add_pch(ntvdm ntvdm.h SOURCE)
set_module_type(ntvdm win32cui UNICODE IMAGEBASE 0x0F000000)
diff --git a/subsystems/mvdm/ntvdm/hardware/cmos.c b/subsystems/mvdm/ntvdm/hardware/cmos.c
index 8482553..dc45c36 100644
--- a/subsystems/mvdm/ntvdm/hardware/cmos.c
+++ b/subsystems/mvdm/ntvdm/hardware/cmos.c
@@ -450,7 +450,7 @@ VOID CmosInitialize(VOID)
/* Always open (and if needed, create) a RAM file with shared access */
SetLastError(0); // For debugging purposes
- hCmosRam = CreateFileW(L"cmos.ram",
+ /*hCmosRam = CreateFileW(L"cmos.ram",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
@@ -458,7 +458,8 @@ VOID CmosInitialize(VOID)
FILE_ATTRIBUTE_NORMAL,
NULL);
DPRINT1("CMOS opening %s (Error: %u)\n", hCmosRam != INVALID_HANDLE_VALUE ? "succeeded" : "failed", GetLastError());
-
+ */
+
if (hCmosRam != INVALID_HANDLE_VALUE)
{
BOOL Success;
diff --git a/subsystems/mvdm/ntvdm/ntvdm.c b/subsystems/mvdm/ntvdm/ntvdm.c
index 4e5cd99..c9c2941 100644
--- a/subsystems/mvdm/ntvdm/ntvdm.c
+++ b/subsystems/mvdm/ntvdm/ntvdm.c
@@ -12,6 +12,7 @@
#define NDEBUG
#include <debug.h>
+#include <stdlib.h>
#include "emulator.h"
@@ -470,11 +471,87 @@ PrintMessageAnsi(IN CHAR_PRINT CharPrint,
#endif
}
+static
+void* get_dos_exe_sect(int* size)
+{
+ /* get pointer to section table */
+ PIMAGE_DOS_HEADER dosHead = (PIMAGE_DOS_HEADER)GetModuleHandle(0);
+ PIMAGE_NT_HEADERS ntHead = (PIMAGE_NT_HEADERS)((char*)dosHead + dosHead->e_lfanew);
+ PIMAGE_SECTION_HEADER sects = IMAGE_FIRST_SECTION(ntHead);
+ PIMAGE_SECTION_HEADER sendEnd = sects + ntHead->FileHeader.NumberOfSections;
+
+ /* locate dos section */
+ for(;sects < sendEnd; sects++)
+ if(!strcmp((char*)sects->Name, ".dosEx")) {
+ *size = sects->Misc.VirtualSize;
+ return ((char*)dosHead + sects->VirtualAddress);
+ }
+ return NULL;
+}
+
+
+WCHAR g_embedExeDir[MAX_PATH];
+WCHAR g_embedExeName[MAX_PATH];
+WCHAR* g_embedExeArgs[3];
+
+void embed_delete()
+{
+ DeleteFileW(g_embedExeName);
+ RemoveDirectoryW(g_embedExeDir);
+}
+
+void tempDir(WCHAR* buff)
+{
+ int len = GetTempPathW(MAX_PATH, buff);
+ do{ wsprintfW(buff+len, L"dex%X", rand());
+ } while(!CreateDirectoryW(g_embedExeDir, NULL));
+}
+
+void embed_check()
+{
+ int dosExSize;
+ void* sect = get_dos_exe_sect(&dosExSize);
+ if(!sect) return;
+
+ /* get temp filename */
+ tempDir(g_embedExeDir);
+ { WCHAR buff[MAX_PATH];
+ GetModuleFileNameW(NULL, buff, MAX_PATH);
+ wcscpy(g_embedExeName, g_embedExeDir);
+ wcscat(g_embedExeName, wcsrchr(buff, '\\')); }
+
+ /* write embedded */
+ { FILE* fp = _wfopen(g_embedExeName, L"wb");
+ fwrite(sect, dosExSize, 1, fp);
+ fclose(fp); }
+
+ /* set arguments */
+ { WCHAR* argPos = GetCommandLineW();
+ WCHAR endCH = ' ';
+ if(*argPos == '"') { endCH = '"'; argPos++; }
+ while(*argPos && (*argPos++ != endCH));
+ g_embedExeArgs[1] = g_embedExeName;
+ g_embedExeArgs[2] = argPos;
+ NtVdmArgv = g_embedExeArgs;
+ NtVdmArgc = g_embedExeArgs[2] ? 3 : 2;
+ }
+
+ atexit(embed_delete);
+}
+
+
INT
wmain(INT argc, WCHAR *argv[])
{
+
+
+
NtVdmArgc = argc;
NtVdmArgv = argv;
+
+ embed_check();
+ argc = NtVdmArgc;
+
#ifdef STANDALONE
diff --git a/subsystems/mvdm/ntvdm/ntvdm.h b/subsystems/mvdm/ntvdm/ntvdm.h
index 17dbd8d..e2299ae 100644
--- a/subsystems/mvdm/ntvdm/ntvdm.h
+++ b/subsystems/mvdm/ntvdm/ntvdm.h
@@ -49,7 +49,7 @@ DWORD WINAPI SetLastConsoleEventActive(VOID);
* Activate this line if you want to run NTVDM in standalone mode with:
* ntvdm.exe <program>
*/
-// #define STANDALONE
+#define STANDALONE
/*
* Activate this line for Win2k compliancy
diff --git a/subsystems/mvdm/ntvdm/ntvdm.rc b/subsystems/mvdm/ntvdm/ntvdm.rc
index 431641d..87b7a74 100644
--- a/subsystems/mvdm/ntvdm/ntvdm.rc
+++ b/subsystems/mvdm/ntvdm/ntvdm.rc
@@ -11,6 +11,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#define REACTOS_STR_ORIGINAL_FILENAME "ntvdm.exe"
#include <reactos/version.rc>
+#if 0
/* Icons */
/* Icons for the PC-AT (most recent IBM-PC version) */
@@ -28,6 +29,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
/* Embedded products */
11 ICON "res/ros_dos.ico"
12 ICON "res/vdm_dos.ico"
+#endif
/* UTF-8 */