aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGeoff Voelker1995-11-07 07:34:42 +0000
committerGeoff Voelker1995-11-07 07:34:42 +0000
commitcd6885f37c17ed21bc57882986f8260ae1595271 (patch)
treef44379554015b952387fff878df295b31af7f5a1 /src
parent4a1ba22262721654a4e1e4138fd23740ce9d726e (diff)
downloademacs-cd6885f37c17ed21bc57882986f8260ae1595271.tar.gz
emacs-cd6885f37c17ed21bc57882986f8260ae1595271.zip
[HAVE_NTGUI] (WinMain): New procedure.
[HAVE_NTGUI] (hinst, hprevinst, lpCmdLine, nCmdShow): New variables. [HAVE_NTGUI] (_start): Invoke WinMainCRTStartup.
Diffstat (limited to 'src')
-rw-r--r--src/unexw32.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/src/unexw32.c b/src/unexw32.c
index cf89f031bb9..475fcf8cf96 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -63,6 +63,30 @@ DWORD data_size = 0;
63PUCHAR bss_start = 0; 63PUCHAR bss_start = 0;
64DWORD bss_size = 0; 64DWORD bss_size = 0;
65 65
66#ifdef HAVE_NTGUI
67HINSTANCE hinst = NULL;
68HINSTANCE hprevinst = NULL;
69LPSTR lpCmdLine = "";
70int nCmdShow = 0;
71
72int __stdcall
73WinMain (_hinst, _hPrevInst, _lpCmdLine, _nCmdShow)
74 HINSTANCE _hinst;
75 HINSTANCE _hPrevInst;
76 LPSTR _lpCmdLine;
77 int _nCmdShow;
78{
79 /* Need to parse command line */
80
81 hinst = _hinst;
82 hprevinst = _hPrevInst;
83 lpCmdLine = _lpCmdLine;
84 nCmdShow = _nCmdShow;
85
86 return (main (__argc,__argv,_environ));
87}
88#endif /* HAVE_NTGUI */
89
66/* Startup code for running on NT. When we are running as the dumped 90/* Startup code for running on NT. When we are running as the dumped
67 version, we need to bootstrap our heap and .bss section into our 91 version, we need to bootstrap our heap and .bss section into our
68 address space before we can actually hand off control to the startup 92 address space before we can actually hand off control to the startup
@@ -70,7 +94,11 @@ DWORD bss_size = 0;
70void 94void
71_start (void) 95_start (void)
72{ 96{
97#ifdef HAVE_NTGUI
98 extern void WinMainCRTStartup (void);
99#else
73 extern void mainCRTStartup (void); 100 extern void mainCRTStartup (void);
101#endif /* HAVE_NTGUI */
74 102
75 /* Cache system info, e.g., the NT page size. */ 103 /* Cache system info, e.g., the NT page size. */
76 cache_system_info (); 104 cache_system_info ();
@@ -103,7 +131,11 @@ _start (void)
103 131
104 /* Invoke the NT CRT startup routine now that our housecleaning 132 /* Invoke the NT CRT startup routine now that our housecleaning
105 is finished. */ 133 is finished. */
134#ifdef HAVE_NTGUI
135 WinMainCRTStartup ();
136#else
106 mainCRTStartup (); 137 mainCRTStartup ();
138#endif /* HAVE_NTGUI */
107} 139}
108 140
109/* Dump out .data and .bss sections into a new exectubale. */ 141/* Dump out .data and .bss sections into a new exectubale. */
@@ -209,13 +241,15 @@ open_output_file (file_data *p_file, char *filename, unsigned long size)
209 HANDLE file; 241 HANDLE file;
210 HANDLE file_mapping; 242 HANDLE file_mapping;
211 void *file_base; 243 void *file_base;
212 244 int i;
245
213 file = CreateFile (filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, 246 file = CreateFile (filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
214 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); 247 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
215 if (file == INVALID_HANDLE_VALUE) 248 if (file == INVALID_HANDLE_VALUE)
216 { 249 {
250 i = GetLastError ();
217 printf ("open_output_file: Failed to open %s (%d).\n", 251 printf ("open_output_file: Failed to open %s (%d).\n",
218 filename, GetLastError ()); 252 filename, i);
219 exit (1); 253 exit (1);
220 } 254 }
221 255
@@ -223,16 +257,18 @@ open_output_file (file_data *p_file, char *filename, unsigned long size)
223 0, size, NULL); 257 0, size, NULL);
224 if (!file_mapping) 258 if (!file_mapping)
225 { 259 {
260 i = GetLastError ();
226 printf ("open_output_file: Failed to create file mapping of %s (%d).\n", 261 printf ("open_output_file: Failed to create file mapping of %s (%d).\n",
227 filename, GetLastError ()); 262 filename, i);
228 exit (1); 263 exit (1);
229 } 264 }
230 265
231 file_base = MapViewOfFile (file_mapping, FILE_MAP_WRITE, 0, 0, size); 266 file_base = MapViewOfFile (file_mapping, FILE_MAP_WRITE, 0, 0, size);
232 if (file_base == 0) 267 if (file_base == 0)
233 { 268 {
269 i = GetLastError ();
234 printf ("open_output_file: Failed to map view of file of %s (%d).\n", 270 printf ("open_output_file: Failed to map view of file of %s (%d).\n",
235 filename, GetLastError ()); 271 filename, i);
236 exit (1); 272 exit (1);
237 } 273 }
238 274