Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e5288bf4
Commit
e5288bf4
authored
Oct 08, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Move the DOS file handle functions to file16.c.
parent
86c6021c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
109 deletions
+103
-109
file.c
dlls/kernel32/file.c
+0
-104
file16.c
dlls/kernel32/file16.c
+103
-1
kernel_private.h
dlls/kernel32/kernel_private.h
+0
-4
No files found.
dlls/kernel32/file.c
View file @
e5288bf4
...
...
@@ -49,8 +49,6 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
file
);
HANDLE
dos_handles
[
DOS_TABLE_SIZE
];
/* info structure for FindFirstFile handle */
typedef
struct
{
...
...
@@ -316,32 +314,6 @@ BOOL WINAPI AreFileApisANSI(void)
* Operations on file handles *
**************************************************************************/
/***********************************************************************
* FILE_InitProcessDosHandles
*
* Allocates the default DOS handles for a process. Called either by
* Win32HandleToDosFileHandle below or by the DOSVM stuff.
*/
static
void
FILE_InitProcessDosHandles
(
void
)
{
static
BOOL
init_done
/* = FALSE */
;
HANDLE
cp
=
GetCurrentProcess
();
if
(
init_done
)
return
;
init_done
=
TRUE
;
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_INPUT_HANDLE
),
cp
,
&
dos_handles
[
0
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_OUTPUT_HANDLE
),
cp
,
&
dos_handles
[
1
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_ERROR_HANDLE
),
cp
,
&
dos_handles
[
2
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_ERROR_HANDLE
),
cp
,
&
dos_handles
[
3
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_ERROR_HANDLE
),
cp
,
&
dos_handles
[
4
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
}
/******************************************************************
* FILE_ReadWriteApc (internal)
*/
...
...
@@ -1205,59 +1177,6 @@ BOOL WINAPI UnlockFileEx( HANDLE hFile, DWORD reserved, DWORD count_low, DWORD c
}
/***********************************************************************
* Win32HandleToDosFileHandle (KERNEL32.21)
*
* Allocate a DOS handle for a Win32 handle. The Win32 handle is no
* longer valid after this function (even on failure).
*
* Note: this is not exactly right, since on Win95 the Win32 handles
* are on top of DOS handles and we do it the other way
* around. Should be good enough though.
*/
HFILE
WINAPI
Win32HandleToDosFileHandle
(
HANDLE
handle
)
{
int
i
;
if
(
!
handle
||
(
handle
==
INVALID_HANDLE_VALUE
))
return
HFILE_ERROR
;
FILE_InitProcessDosHandles
();
for
(
i
=
0
;
i
<
DOS_TABLE_SIZE
;
i
++
)
if
(
!
dos_handles
[
i
])
{
dos_handles
[
i
]
=
handle
;
TRACE
(
"Got %d for h32 %p
\n
"
,
i
,
handle
);
return
(
HFILE
)
i
;
}
CloseHandle
(
handle
);
SetLastError
(
ERROR_TOO_MANY_OPEN_FILES
);
return
HFILE_ERROR
;
}
/***********************************************************************
* DosFileHandleToWin32Handle (KERNEL32.20)
*
* Return the Win32 handle for a DOS handle.
*
* Note: this is not exactly right, since on Win95 the Win32 handles
* are on top of DOS handles and we do it the other way
* around. Should be good enough though.
*/
HANDLE
WINAPI
DosFileHandleToWin32Handle
(
HFILE
handle
)
{
HFILE16
hfile
=
(
HFILE16
)
handle
;
if
(
hfile
<
5
)
FILE_InitProcessDosHandles
();
if
((
hfile
>=
DOS_TABLE_SIZE
)
||
!
dos_handles
[
hfile
])
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
INVALID_HANDLE_VALUE
;
}
return
dos_handles
[
hfile
];
}
/*************************************************************************
* SetHandleCount (KERNEL32.@)
*/
...
...
@@ -1267,29 +1186,6 @@ UINT WINAPI SetHandleCount( UINT count )
}
/***********************************************************************
* DisposeLZ32Handle (KERNEL32.22)
*
* Note: this is not entirely correct, we should only close the
* 32-bit handle and not the 16-bit one, but we cannot do
* this because of the way our DOS handles are implemented.
* It shouldn't break anything though.
*/
void
WINAPI
DisposeLZ32Handle
(
HANDLE
handle
)
{
int
i
;
if
(
!
handle
||
(
handle
==
INVALID_HANDLE_VALUE
))
return
;
for
(
i
=
5
;
i
<
DOS_TABLE_SIZE
;
i
++
)
if
(
dos_handles
[
i
]
==
handle
)
{
dos_handles
[
i
]
=
0
;
CloseHandle
(
handle
);
break
;
}
}
/**************************************************************************
* Operations on file names *
**************************************************************************/
...
...
dlls/kernel32/file16.c
View file @
e5288bf4
...
...
@@ -37,12 +37,114 @@
#include "winbase.h"
#include "winternl.h"
#include "wine/winbase16.h"
#include "kernel_private.h"
#include "kernel
16
_private.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
file
);
#define DOS_TABLE_SIZE 256
static
HANDLE
dos_handles
[
DOS_TABLE_SIZE
];
/***********************************************************************
* FILE_InitProcessDosHandles
*
* Allocates the default DOS handles for a process. Called either by
* Win32HandleToDosFileHandle below or by the DOSVM stuff.
*/
static
void
FILE_InitProcessDosHandles
(
void
)
{
static
BOOL
init_done
/* = FALSE */
;
HANDLE
cp
=
GetCurrentProcess
();
if
(
init_done
)
return
;
init_done
=
TRUE
;
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_INPUT_HANDLE
),
cp
,
&
dos_handles
[
0
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_OUTPUT_HANDLE
),
cp
,
&
dos_handles
[
1
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_ERROR_HANDLE
),
cp
,
&
dos_handles
[
2
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_ERROR_HANDLE
),
cp
,
&
dos_handles
[
3
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
DuplicateHandle
(
cp
,
GetStdHandle
(
STD_ERROR_HANDLE
),
cp
,
&
dos_handles
[
4
],
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
}
/***********************************************************************
* DosFileHandleToWin32Handle (KERNEL32.20)
*
* Return the Win32 handle for a DOS handle.
*
* Note: this is not exactly right, since on Win95 the Win32 handles
* are on top of DOS handles and we do it the other way
* around. Should be good enough though.
*/
HANDLE
WINAPI
DosFileHandleToWin32Handle
(
HFILE
handle
)
{
HFILE16
hfile
=
(
HFILE16
)
handle
;
if
(
hfile
<
5
)
FILE_InitProcessDosHandles
();
if
((
hfile
>=
DOS_TABLE_SIZE
)
||
!
dos_handles
[
hfile
])
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
INVALID_HANDLE_VALUE
;
}
return
dos_handles
[
hfile
];
}
/***********************************************************************
* Win32HandleToDosFileHandle (KERNEL32.21)
*
* Allocate a DOS handle for a Win32 handle. The Win32 handle is no
* longer valid after this function (even on failure).
*
* Note: this is not exactly right, since on Win95 the Win32 handles
* are on top of DOS handles and we do it the other way
* around. Should be good enough though.
*/
HFILE
WINAPI
Win32HandleToDosFileHandle
(
HANDLE
handle
)
{
int
i
;
if
(
!
handle
||
(
handle
==
INVALID_HANDLE_VALUE
))
return
HFILE_ERROR
;
FILE_InitProcessDosHandles
();
for
(
i
=
0
;
i
<
DOS_TABLE_SIZE
;
i
++
)
if
(
!
dos_handles
[
i
])
{
dos_handles
[
i
]
=
handle
;
TRACE
(
"Got %d for h32 %p
\n
"
,
i
,
handle
);
return
(
HFILE
)
i
;
}
CloseHandle
(
handle
);
SetLastError
(
ERROR_TOO_MANY_OPEN_FILES
);
return
HFILE_ERROR
;
}
/***********************************************************************
* DisposeLZ32Handle (KERNEL32.22)
*
* Note: this is not entirely correct, we should only close the
* 32-bit handle and not the 16-bit one, but we cannot do
* this because of the way our DOS handles are implemented.
* It shouldn't break anything though.
*/
void
WINAPI
DisposeLZ32Handle
(
HANDLE
handle
)
{
int
i
;
if
(
!
handle
||
(
handle
==
INVALID_HANDLE_VALUE
))
return
;
for
(
i
=
5
;
i
<
DOS_TABLE_SIZE
;
i
++
)
if
(
dos_handles
[
i
]
==
handle
)
{
dos_handles
[
i
]
=
0
;
CloseHandle
(
handle
);
break
;
}
}
/***********************************************************************
* GetProfileInt (KERNEL.57)
...
...
dlls/kernel32/kernel_private.h
View file @
e5288bf4
...
...
@@ -65,10 +65,6 @@ static inline obj_handle_t console_handle_unmap(HANDLE h)
extern
HMODULE
kernel32_handle
;
/* Size of per-process table of DOS handles */
#define DOS_TABLE_SIZE 256
extern
HANDLE
dos_handles
[
DOS_TABLE_SIZE
];
extern
const
WCHAR
*
DIR_Windows
;
extern
const
WCHAR
*
DIR_System
;
extern
const
WCHAR
*
DIR_SysWow64
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment