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
8f3afb41
Commit
8f3afb41
authored
Dec 02, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Dec 03, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Implement and test {G, S}etConsoleInputExeName{A, W}.
parent
8487c2dd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
33 deletions
+108
-33
console.c
dlls/kernel32/console.c
+55
-33
console.c
dlls/kernel32/tests/console.c
+53
-0
No files found.
dlls/kernel32/console.c
View file @
8f3afb41
...
...
@@ -55,6 +55,15 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
console
);
static
CRITICAL_SECTION
CONSOLE_CritSect
;
static
CRITICAL_SECTION_DEBUG
critsect_debug
=
{
0
,
0
,
&
CONSOLE_CritSect
,
{
&
critsect_debug
.
ProcessLocksList
,
&
critsect_debug
.
ProcessLocksList
},
0
,
0
,
{
(
DWORD_PTR
)(
__FILE__
": CONSOLE_CritSect"
)
}
};
static
CRITICAL_SECTION
CONSOLE_CritSect
=
{
&
critsect_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
const
WCHAR
coninW
[]
=
{
'C'
,
'O'
,
'N'
,
'I'
,
'N'
,
'$'
,
0
};
static
const
WCHAR
conoutW
[]
=
{
'C'
,
'O'
,
'N'
,
'O'
,
'U'
,
'T'
,
'$'
,
0
};
...
...
@@ -982,23 +991,35 @@ BOOL WINAPI GetConsoleKeyboardLayoutNameW(LPWSTR layoutName)
return
TRUE
;
}
static
WCHAR
input_exe
[
MAX_PATH
+
1
];
/***********************************************************************
* GetConsoleInputExeName
A
(KERNEL32.@)
* GetConsoleInputExeName
W
(KERNEL32.@)
*/
DWORD
WINAPI
GetConsoleInputExeNameA
(
DWORD
BufferLength
,
LPSTR
lpB
uffer
)
BOOL
WINAPI
GetConsoleInputExeNameW
(
DWORD
buflen
,
LPWSTR
b
uffer
)
{
DWORD
ret
=
0
;
FIXME
(
"stub %u %p
\n
"
,
BufferLength
,
lpBuffer
);
return
ret
;
TRACE
(
"%u %p
\n
"
,
buflen
,
buffer
);
RtlEnterCriticalSection
(
&
CONSOLE_CritSect
);
if
(
buflen
>
strlenW
(
input_exe
))
strcpyW
(
buffer
,
input_exe
);
else
SetLastError
(
ERROR_BUFFER_OVERFLOW
);
RtlLeaveCriticalSection
(
&
CONSOLE_CritSect
);
return
TRUE
;
}
/***********************************************************************
* GetConsoleInputExeName
W
(KERNEL32.@)
* GetConsoleInputExeName
A
(KERNEL32.@)
*/
DWORD
WINAPI
GetConsoleInputExeNameW
(
DWORD
BufferLength
,
LPWSTR
lpB
uffer
)
BOOL
WINAPI
GetConsoleInputExeNameA
(
DWORD
buflen
,
LPSTR
b
uffer
)
{
DWORD
ret
=
0
;
FIXME
(
"stub %u %p
\n
"
,
BufferLength
,
lpBuffer
);
WCHAR
*
bufferW
;
BOOL
ret
;
if
(
!
(
bufferW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
WCHAR
)
*
buflen
)))
return
FALSE
;
if
((
ret
=
GetConsoleInputExeNameW
(
buflen
,
bufferW
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
bufferW
,
-
1
,
buffer
,
buflen
,
NULL
,
NULL
);
HeapFree
(
GetProcessHeap
(),
0
,
bufferW
);
return
ret
;
}
...
...
@@ -1467,35 +1488,45 @@ BOOL WINAPI GetNumberOfConsoleMouseButtons(LPDWORD nrofbuttons)
/******************************************************************************
* SetConsoleInputExeNameW [KERNEL32.@]
*
* BUGS
* Unimplemented
*/
BOOL
WINAPI
SetConsoleInputExeNameW
(
LPCWSTR
name
)
{
FIXME
(
"(%s): stub!
\n
"
,
debugstr_w
(
name
));
TRACE
(
"(%s)
\n
"
,
debugstr_w
(
name
));
if
(
!
name
||
!
name
[
0
])
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
RtlEnterCriticalSection
(
&
CONSOLE_CritSect
);
if
(
strlenW
(
name
)
<
sizeof
(
input_exe
)
/
sizeof
(
WCHAR
))
strcpyW
(
input_exe
,
name
);
RtlLeaveCriticalSection
(
&
CONSOLE_CritSect
);
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
return
TRUE
;
}
/******************************************************************************
* SetConsoleInputExeNameA [KERNEL32.@]
*
* BUGS
* Unimplemented
*/
BOOL
WINAPI
SetConsoleInputExeNameA
(
LPCSTR
name
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
NULL
,
0
)
;
LPWSTR
xptr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
))
;
BOOL
ret
;
int
len
;
LPWSTR
nameW
;
BOOL
ret
;
if
(
!
xptr
)
return
FALSE
;
if
(
!
name
||
!
name
[
0
])
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
NULL
,
0
);
if
(
!
(
nameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
))))
return
FALSE
;
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
xptr
,
len
);
ret
=
SetConsoleInputExeNameW
(
xptr
);
HeapFree
(
GetProcessHeap
(),
0
,
xptr
);
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
nameW
,
len
);
ret
=
SetConsoleInputExeNameW
(
nameW
);
HeapFree
(
GetProcessHeap
(),
0
,
nameW
);
return
ret
;
}
...
...
@@ -1534,15 +1565,6 @@ struct ConsoleHandler
static
struct
ConsoleHandler
CONSOLE_DefaultConsoleHandler
=
{
CONSOLE_DefaultHandler
,
NULL
};
static
struct
ConsoleHandler
*
CONSOLE_Handlers
=
&
CONSOLE_DefaultConsoleHandler
;
static
CRITICAL_SECTION
CONSOLE_CritSect
;
static
CRITICAL_SECTION_DEBUG
critsect_debug
=
{
0
,
0
,
&
CONSOLE_CritSect
,
{
&
critsect_debug
.
ProcessLocksList
,
&
critsect_debug
.
ProcessLocksList
},
0
,
0
,
{
(
DWORD_PTR
)(
__FILE__
": CONSOLE_CritSect"
)
}
};
static
CRITICAL_SECTION
CONSOLE_CritSect
=
{
&
critsect_debug
,
-
1
,
0
,
0
,
0
,
0
};
/*****************************************************************************/
/******************************************************************
...
...
dlls/kernel32/tests/console.c
View file @
8f3afb41
...
...
@@ -23,6 +23,11 @@
#include <windows.h>
#include <stdio.h>
BOOL
WINAPI
GetConsoleInputExeNameA
(
DWORD
,
LPSTR
);
BOOL
WINAPI
GetConsoleInputExeNameW
(
DWORD
,
LPWSTR
);
BOOL
WINAPI
SetConsoleInputExeNameA
(
LPCSTR
);
BOOL
WINAPI
SetConsoleInputExeNameW
(
LPCWSTR
);
/* DEFAULT_ATTRIB is used for all initial filling of the console.
* all modifications are made with TEST_ATTRIB so that we could check
* what has to be modified or not
...
...
@@ -746,6 +751,52 @@ static void testScreenBuffer(HANDLE hConOut)
SetConsoleOutputCP
(
oldcp
);
}
static
void
test_GetSetConsoleInputExeName
(
void
)
{
BOOL
ret
;
DWORD
error
;
char
buffer
[
MAX_PATH
],
module
[
MAX_PATH
],
*
p
;
static
char
input_exe
[
MAX_PATH
]
=
"winetest.exe"
;
SetLastError
(
0xdeadbeef
);
ret
=
GetConsoleInputExeNameA
(
0
,
NULL
);
error
=
GetLastError
();
ok
(
ret
,
"GetConsoleInputExeNameA failed
\n
"
);
ok
(
error
==
ERROR_BUFFER_OVERFLOW
,
"got %u expected ERROR_BUFFER_OVERFLOW
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
GetConsoleInputExeNameA
(
0
,
buffer
);
error
=
GetLastError
();
ok
(
ret
,
"GetConsoleInputExeNameA failed
\n
"
);
ok
(
error
==
ERROR_BUFFER_OVERFLOW
,
"got %u expected ERROR_BUFFER_OVERFLOW
\n
"
,
error
);
GetModuleFileNameA
(
GetModuleHandle
(
NULL
),
module
,
sizeof
(
module
));
p
=
strrchr
(
module
,
'\\'
)
+
1
;
ret
=
GetConsoleInputExeNameA
(
sizeof
(
buffer
)
/
sizeof
(
buffer
[
0
]),
buffer
);
ok
(
ret
,
"GetConsoleInputExeNameA failed
\n
"
);
todo_wine
ok
(
!
lstrcmpA
(
buffer
,
p
),
"got %s expected %s
\n
"
,
buffer
,
p
);
SetLastError
(
0xdeadbeef
);
ret
=
SetConsoleInputExeNameA
(
NULL
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetConsoleInputExeNameA failed
\n
"
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u expected ERROR_INVALID_PARAMETER
\n
"
,
error
);
SetLastError
(
0xdeadbeef
);
ret
=
SetConsoleInputExeNameA
(
""
);
error
=
GetLastError
();
ok
(
!
ret
,
"SetConsoleInputExeNameA failed
\n
"
);
ok
(
error
==
ERROR_INVALID_PARAMETER
,
"got %u expected ERROR_INVALID_PARAMETER
\n
"
,
error
);
ret
=
SetConsoleInputExeNameA
(
input_exe
);
ok
(
ret
,
"SetConsoleInputExeNameA failed
\n
"
);
ret
=
GetConsoleInputExeNameA
(
sizeof
(
buffer
)
/
sizeof
(
buffer
[
0
]),
buffer
);
ok
(
ret
,
"GetConsoleInputExeNameA failed
\n
"
);
ok
(
!
lstrcmpA
(
buffer
,
input_exe
),
"got %s expected %s
\n
"
,
buffer
,
input_exe
);
}
START_TEST
(
console
)
{
HANDLE
hConIn
,
hConOut
;
...
...
@@ -784,4 +835,6 @@ START_TEST(console)
testScreenBuffer
(
hConOut
);
testCtrlHandler
();
/* still to be done: access rights & access on objects */
test_GetSetConsoleInputExeName
();
}
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