Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
56193df2
Commit
56193df2
authored
14 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
winevdm: Try to exec dosbox if DOS is not supported natively.
parent
cf1cd335
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
programs/winevdm/winevdm.c
+94
-0
94 additions, 0 deletions
programs/winevdm/winevdm.c
with
94 additions
and
0 deletions
programs/winevdm/winevdm.c
+
94
−
0
View file @
56193df2
...
...
@@ -18,14 +18,19 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include
"config.h"
#include
"wine/port.h"
#include
<stdarg.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
"windef.h"
#include
"winbase.h"
#include
"wine/winbase16.h"
#include
"winuser.h"
#include
"wincon.h"
#include
"wine/unicode.h"
#include
"wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
winevdm
);
...
...
@@ -101,6 +106,93 @@ typedef struct {
#include
"poppack.h"
/***********************************************************************
* find_dosbox
*/
static
char
*
find_dosbox
(
void
)
{
const
char
*
envpath
=
getenv
(
"PATH"
);
struct
stat
st
;
char
*
path
,
*
p
,
*
buffer
,
*
dir
;
if
(
!
envpath
)
return
NULL
;
path
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
envpath
)
);
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
path
)
+
sizeof
(
"/dosbox"
)
);
strcpy
(
path
,
envpath
);
p
=
path
;
while
(
*
p
)
{
while
(
*
p
==
':'
)
p
++
;
if
(
!*
p
)
break
;
dir
=
p
;
while
(
*
p
&&
*
p
!=
':'
)
p
++
;
*
p
++
=
0
;
strcpy
(
buffer
,
dir
);
strcat
(
buffer
,
"/dosbox"
);
if
(
!
stat
(
buffer
,
&
st
))
{
HeapFree
(
GetProcessHeap
(),
0
,
path
);
return
buffer
;
}
}
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
HeapFree
(
GetProcessHeap
(),
0
,
path
);
return
NULL
;
}
/***********************************************************************
* start_dosbox
*/
static
void
start_dosbox
(
const
char
*
appname
,
const
char
*
args
)
{
static
const
WCHAR
cfgW
[]
=
{
'c'
,
'f'
,
'g'
,
0
};
const
char
*
config_dir
=
wine_get_config_dir
();
WCHAR
path
[
MAX_PATH
],
config
[
MAX_PATH
];
HANDLE
file
;
char
*
p
,
*
buffer
;
int
i
;
int
ret
=
1
;
DWORD
written
,
drives
=
GetLogicalDrives
();
char
*
dosbox
=
find_dosbox
();
if
(
!
dosbox
)
return
;
if
(
!
GetTempPathW
(
MAX_PATH
,
path
))
return
;
if
(
!
GetTempFileNameW
(
path
,
cfgW
,
0
,
config
))
return
;
if
(
!
GetCurrentDirectoryW
(
MAX_PATH
,
path
))
return
;
file
=
CreateFileW
(
config
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
if
(
file
==
INVALID_HANDLE_VALUE
)
return
;
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
"[autoexec]"
)
+
25
*
(
strlen
(
config_dir
)
+
sizeof
(
"mount c /dosdevices/c:"
))
+
4
*
strlenW
(
path
)
+
6
+
strlen
(
appname
)
+
strlen
(
args
)
+
20
);
p
=
buffer
;
p
+=
sprintf
(
p
,
"[autoexec]
\n
"
);
for
(
i
=
0
;
i
<
25
;
i
++
)
if
(
drives
&
(
1
<<
i
))
p
+=
sprintf
(
p
,
"mount %c %s/dosdevices/%c:
\n
"
,
'a'
+
i
,
config_dir
,
'a'
+
i
);
p
+=
sprintf
(
p
,
"%c:
\n
cd "
,
path
[
0
]
);
p
+=
WideCharToMultiByte
(
CP_UNIXCP
,
0
,
path
+
2
,
-
1
,
p
,
4
*
strlenW
(
path
),
NULL
,
NULL
)
-
1
;
p
+=
sprintf
(
p
,
"
\n
%s %s
\n
"
,
appname
,
args
);
p
+=
sprintf
(
p
,
"exit
\n
"
);
if
(
WriteFile
(
file
,
buffer
,
strlen
(
buffer
),
&
written
,
NULL
)
&&
written
==
strlen
(
buffer
))
{
const
char
*
args
[
4
];
char
*
config_file
=
wine_get_unix_file_name
(
config
);
args
[
0
]
=
dosbox
;
args
[
1
]
=
"-conf"
;
args
[
2
]
=
config_file
;
args
[
3
]
=
NULL
;
ret
=
spawnvp
(
_P_WAIT
,
args
[
0
],
args
);
}
CloseHandle
(
file
);
DeleteFileW
(
config
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
ExitProcess
(
ret
);
}
/***********************************************************************
* start_dos_exe
*/
...
...
@@ -119,6 +211,8 @@ static void start_dos_exe( LPCSTR filename, LPCSTR cmdline )
}
else
reason
=
"because the DOS memory range is unavailable"
;
start_dosbox
(
filename
,
cmdline
);
WINE_MESSAGE
(
"winevdm: Cannot start DOS application %s
\n
"
,
filename
);
WINE_MESSAGE
(
" %s.
\n
"
,
reason
);
WINE_MESSAGE
(
" Try running this application with DOSBox.
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment