Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
f7a3fc10
Commit
f7a3fc10
authored
Aug 15, 1999
by
Juergen Schmied
Committed by
Alexandre Julliard
Aug 15, 1999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed ascii/unicode issue for naming of the mutexes.
Made mutex handles global. Fixed incorrect interpretation of return values of WaitForSingleObject.
parent
2259e44e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
100 deletions
+88
-100
ddeml.c
misc/ddeml.c
+88
-100
No files found.
misc/ddeml.c
View file @
f7a3fc10
...
...
@@ -76,10 +76,8 @@ typedef struct DDE_HANDLE_ENTRY {
static
DDE_HANDLE_ENTRY
*
DDE_Handle_Table_Base
=
NULL
;
static
DWORD
DDE_Max_Assigned_Instance
=
0
;
/* OK for present, may have to worry about wrap-around later */
static
const
char
inst_string
[]
=
"DDEMaxInstance"
;
static
LPCWSTR
DDEInstanceAccess
=
(
LPCWSTR
)
&
inst_string
;
static
const
char
handle_string
[]
=
"DDEHandleAccess"
;
static
LPCWSTR
DDEHandleAccess
=
(
LPCWSTR
)
&
handle_string
;
static
const
char
*
DDEInstanceAccess
=
"DDEMaxInstance"
;
static
const
char
*
DDEHandleAccess
=
"DDEHandleAccess"
;
static
HANDLE
inst_count_mutex
=
0
;
static
HANDLE
handle_mutex
=
0
;
...
...
@@ -296,16 +294,15 @@ static void InsertHSZNode( HSZ hsz, DDE_HANDLE_ENTRY * reference_inst )
*
* 1.0 Jan 1999 Keith Matthews Initial version
* 1.1 Mar 1999 Keith Matthews Corrected Heap handling. Corrected re-initialisation handling
* 1.2 Aug 1999 Jürgen Schmied Corrected error handling
*
*/
static
DWORD
Release_reserved_mutex
(
HANDLE
mutex
,
LPSTR
mutex_name
,
BOOL
release_handle_m
,
BOOL
release_this_i
,
DDE_HANDLE_ENTRY
*
this_instance
)
{
DWORD
err_no
=
0
;
ReleaseMutex
(
mutex
);
if
(
(
err_no
=
GetLastError
())
!=
0
)
if
(
!
ReleaseMutex
(
mutex
))
{
ERR
(
"ReleaseMutex failed - %s mutex %li
\n
"
,
mutex_name
,
err_no
);
ERR
(
"ReleaseMutex failed - %s mutex %li
\n
"
,
mutex_name
,
GetLastError
()
);
HeapFree
(
SystemHeap
,
0
,
this_instance
);
if
(
release_handle_m
)
{
...
...
@@ -321,6 +318,41 @@ static DWORD Release_reserved_mutex (HANDLE mutex, LPSTR mutex_name, BOOL releas
}
/******************************************************************************
* WaitForMutex
*
* generic routine to wait for the mutex
*
*
******************************************************************************
*
* Change History
*
* Vn Date Author Comment
*
* 1.0 Aug 1999 Juergen Schmied Initial version
*
*/
static
BOOL
WaitForMutex
(
HANDLE
mutex
)
{
DWORD
result
;
result
=
WaitForSingleObject
(
mutex
,
1000
);
/* both errors should never occur */
if
(
WAIT_TIMEOUT
==
result
)
{
ERR
(
"WaitForSingleObject timed out
\n
"
);
return
FALSE
;
}
if
(
WAIT_FAILED
==
result
)
{
ERR
(
"WaitForSingleObject failed - error %li
\n
"
,
GetLastError
());
return
FALSE
;
}
return
TRUE
;
}
/******************************************************************************
* IncrementInstanceId
*
* generic routine to increment the max instance Id and allocate a new application instance
...
...
@@ -337,7 +369,7 @@ static DWORD Release_reserved_mutex (HANDLE mutex, LPSTR mutex_name, BOOL releas
DWORD
IncrementInstanceId
(
DDE_HANDLE_ENTRY
*
this_instance
)
{
SECURITY_ATTRIBUTES
s_attrib
;
DWORD
err_no
=
0
;
/* Need to set up Mutex in case it is not already present */
/* increment handle count & get value */
if
(
!
inst_count_mutex
)
...
...
@@ -345,15 +377,18 @@ DWORD IncrementInstanceId( DDE_HANDLE_ENTRY *this_instance)
s_attrib
.
bInheritHandle
=
TRUE
;
s_attrib
.
lpSecurityDescriptor
=
NULL
;
s_attrib
.
nLength
=
sizeof
(
s_attrib
);
inst_count_mutex
=
CreateMutexW
(
&
s_attrib
,
1
,
DDEInstanceAccess
);
/* 1st time through */
inst_count_mutex
=
CreateMutexA
(
&
s_attrib
,
1
,
DDEInstanceAccess
);
/* 1st time through */
inst_count_mutex
=
ConvertToGlobalHandle
(
inst_count_mutex
);
/* fixme when having seperate adresspaces*/
}
else
{
WaitForSingleObject
(
inst_count_mutex
,
1000
);
/* subsequent calls */
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
if
(
!
WaitForMutex
(
inst_count_mutex
)
)
{
return
DMLERR_SYS_ERROR
;
}
}
if
(
(
err_no
=
GetLastError
())
!=
0
)
if
(
!
inst_count_mutex
)
{
ERR
(
"CreateMutex failed - inst_count %li
\n
"
,
err_no
);
err_no
=
Release_reserved_mutex
(
handle_mutex
,
"handle_mutex"
,
0
,
1
,
this_instance
);
ERR
(
"CreateMutex failed - inst_count %li
\n
"
,
GetLastError
()
);
Release_reserved_mutex
(
handle_mutex
,
"handle_mutex"
,
0
,
1
,
this_instance
);
return
DMLERR_SYS_ERROR
;
}
DDE_Max_Assigned_Instance
++
;
...
...
@@ -584,21 +619,16 @@ UINT WINAPI DdeInitializeW( LPDWORD pidInst, PFNCALLBACK pfnCallback,
s_att
->
bInheritHandle
=
TRUE
;
s_att
->
lpSecurityDescriptor
=
NULL
;
s_att
->
nLength
=
sizeof
(
s_att
);
handle_mutex
=
CreateMutex
W
(
s_att
,
1
,
DDEHandleAccess
);
if
(
(
err_no
=
GetLastError
())
!=
0
)
{
ERR
(
"CreateMutex failed - handle list %li
\n
"
,
err_no
);
handle_mutex
=
CreateMutex
A
(
s_att
,
1
,
DDEHandleAccess
);
handle_mutex
=
ConvertToGlobalHandle
(
handle_mutex
);
/* fixme when having seperate adresspaces*/
if
(
!
handle_mutex
)
{
ERR
(
"CreateMutex failed - handle list %li
\n
"
,
GetLastError
()
);
HeapFree
(
SystemHeap
,
0
,
this_instance
);
return
DMLERR_SYS_ERROR
;
}
}
else
{
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
(
err_no
=
GetLastError
())
!=
0
)
}
else
{
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
return
DMLERR_SYS_ERROR
;
}
}
...
...
@@ -680,16 +710,13 @@ UINT WINAPI DdeInitializeW( LPDWORD pidInst, PFNCALLBACK pfnCallback,
}
else
{
/* Reinitialisation situation --- FIX */
TRACE
(
"reinitialisation of (%p,%p,0x%lx,%ld): stub
\n
"
,
pidInst
,
pfnCallback
,
afCmd
,
ulRes
);
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
(
err_no
=
GetLastError
())
!=
0
)
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
HeapFree
(
SystemHeap
,
0
,
this_instance
);
return
DMLERR_SYS_ERROR
;
}
if
(
DDE_Handle_Table_Base
==
NULL
)
{
if
(
Release_reserved_mutex
(
handle_mutex
,
"handle_mutex"
,
0
,
1
,
this_instance
))
return
DMLERR_SYS_ERROR
;
...
...
@@ -792,7 +819,6 @@ BOOL WINAPI DdeUninitialize( DWORD idInst )
{
/* Stage one - check if we have a handle for this instance
*/
DWORD
err_no
=
0
;
SECURITY_ATTRIBUTES
*
s_att
=
NULL
;
SECURITY_ATTRIBUTES
s_attrib
;
DDE_HANDLE_ENTRY
*
this_instance
;
...
...
@@ -804,12 +830,9 @@ BOOL WINAPI DdeUninitialize( DWORD idInst )
/* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
return
TRUE
;
}
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
(
err_no
=
GetLastError
())
!=
0
)
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
return
DMLERR_SYS_ERROR
;
}
TRACE
(
"Handle Mutex created/reserved
\n
"
);
...
...
@@ -933,7 +956,6 @@ HCONV WINAPI DdeQueryNextServer( HCONVLIST hConvList, HCONV hConvPrev )
*/
DWORD
WINAPI
DdeQueryStringA
(
DWORD
idInst
,
HSZ
hsz
,
LPSTR
psz
,
DWORD
cchMax
,
INT
iCodePage
)
{
DWORD
err_no
=
0
;
DWORD
ret
=
0
;
CHAR
pString
[
MAX_BUFFER_LEN
];
DDE_HANDLE_ENTRY
*
reference_inst
;
...
...
@@ -951,15 +973,12 @@ DWORD WINAPI DdeQueryStringA(DWORD idInst, HSZ hsz, LPSTR psz, DWORD cchMax, INT
/* needs something for DdeGetLAstError even if the manual doesn't say so */
return
FALSE
;
}
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
(
err_no
=
GetLastError
())
!=
0
)
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
/* needs something for DdeGetLAstError even if the manual doesn't say so */
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
return
FALSE
;
}
TRACE
(
"Handle Mutex created/reserved
\n
"
);
/* First check instance
...
...
@@ -1228,7 +1247,6 @@ HSZ WINAPI DdeCreateStringHandle16( DWORD idInst, LPCSTR str, INT16 codepage )
*/
HSZ
WINAPI
DdeCreateStringHandleA
(
DWORD
idInst
,
LPCSTR
psz
,
INT
codepage
)
{
DWORD
err_no
=
0
;
HSZ
hsz
=
0
;
DDE_HANDLE_ENTRY
*
reference_inst
;
TRACE
(
"(%ld,%s,%d): partial stub
\n
"
,
idInst
,
debugstr_a
(
psz
),
codepage
);
...
...
@@ -1239,14 +1257,12 @@ HSZ WINAPI DdeCreateStringHandleA( DWORD idInst, LPCSTR psz, INT codepage )
/* Nothing has been initialised - exit now ! can return FALSE since effect is the same */
return
FALSE
;
}
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
(
err_no
=
GetLastError
())
!=
0
)
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
return
DMLERR_SYS_ERROR
;
}
TRACE
(
"Handle Mutex created/reserved
\n
"
);
/* First check instance
...
...
@@ -1306,7 +1322,6 @@ HSZ WINAPI DdeCreateStringHandleW(
LPCWSTR
psz
,
/* [in] Pointer to string */
INT
codepage
)
/* [in] Code page identifier */
{
DWORD
err_no
=
0
;
DDE_HANDLE_ENTRY
*
reference_inst
;
HSZ
hsz
=
0
;
...
...
@@ -1318,14 +1333,12 @@ HSZ WINAPI DdeCreateStringHandleW(
/* Nothing has been initialised - exit now ! can return FALSE since effect is the same */
return
FALSE
;
}
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
(
err_no
=
GetLastError
())
!=
0
)
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
return
DMLERR_SYS_ERROR
;
}
TRACE
(
"CreateString - Handle Mutex created/reserved
\n
"
);
/* First check instance
...
...
@@ -1394,8 +1407,6 @@ BOOL16 WINAPI DdeFreeStringHandle16( DWORD idInst, HSZ hsz )
*/
BOOL
WINAPI
DdeFreeStringHandle
(
DWORD
idInst
,
HSZ
hsz
)
{
DWORD
err_no
=
0
;
DWORD
prev_err
=
0
;
DDE_HANDLE_ENTRY
*
reference_inst
;
TRACE
(
"(%ld,%ld):
\n
"
,
idInst
,
hsz
);
if
(
DDE_Max_Assigned_Instance
==
0
)
...
...
@@ -1403,19 +1414,12 @@ BOOL WINAPI DdeFreeStringHandle( DWORD idInst, HSZ hsz )
/* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
return
TRUE
;
}
if
(
(
prev_err
=
GetLastError
())
!=
0
)
{
/* something earlier failed !! */
ERR
(
"Error %li before WaitForSingleObject - trying to continue
\n
"
,
prev_err
);
}
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
((
err_no
=
GetLastError
())
!=
0
)
&&
(
err_no
!=
prev_err
))
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
return
DMLERR_SYS_ERROR
;
}
TRACE
(
"Handle Mutex created/reserved
\n
"
);
/* First check instance
...
...
@@ -1488,8 +1492,6 @@ BOOL16 WINAPI DdeKeepStringHandle16( DWORD idInst, HSZ hsz )
BOOL
WINAPI
DdeKeepStringHandle
(
DWORD
idInst
,
HSZ
hsz
)
{
DWORD
prev_err
=
0
;
DWORD
err_no
=
0
;
DDE_HANDLE_ENTRY
*
reference_inst
;
TRACE
(
"(%ld,%ld):
\n
"
,
idInst
,
hsz
);
if
(
DDE_Max_Assigned_Instance
==
0
)
...
...
@@ -1497,19 +1499,13 @@ BOOL WINAPI DdeKeepStringHandle( DWORD idInst, HSZ hsz )
/* Nothing has been initialised - exit now ! can return FALSE since effect is the same */
return
FALSE
;
}
if
(
(
prev_err
=
GetLastError
())
!=
0
)
{
/* something earlier failed !! */
ERR
(
"Error %li before WaitForSingleObject - trying to continue
\n
"
,
prev_err
);
}
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
((
err_no
=
GetLastError
())
!=
0
)
&&
(
err_no
!=
prev_err
))
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
return
FALSE
;
}
TRACE
(
"Handle Mutex created/reserved
\n
"
);
/* First check instance
...
...
@@ -1826,25 +1822,24 @@ HDDEDATA WINAPI DdeNameService( DWORD idInst, HSZ hsz1, HSZ hsz2,
ServiceNode
*
this_service
,
*
reference_service
;
CHAR
SNameBuffer
[
MAX_BUFFER_LEN
];
UINT
rcode
;
DWORD
err_no
=
0
;
DDE_HANDLE_ENTRY
*
this_instance
;
DDE_HANDLE_ENTRY
*
reference_inst
;
this_service
=
NULL
;
FIXME
(
"(%ld,%ld,%ld,%d): stub
\n
"
,
idInst
,
hsz1
,
hsz2
,
afCmd
);
if
(
DDE_Max_Assigned_Instance
==
0
)
{
/* Nothing has been initialised - exit now !
* needs something for DdeGetLastError */
return
0L
;
}
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
(
err_no
=
GetLastError
())
!=
0
)
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
return
DMLERR_SYS_ERROR
;
}
}
TRACE
(
"Handle Mutex created/reserved
\n
"
);
/* First check instance
...
...
@@ -2074,28 +2069,21 @@ UINT16 WINAPI DdeGetLastError16( DWORD idInst )
UINT
WINAPI
DdeGetLastError
(
DWORD
idInst
)
{
DWORD
error_code
;
DWORD
err_no
=
0
;
DWORD
prev_err
=
0
;
DDE_HANDLE_ENTRY
*
reference_inst
;
FIXME
(
"(%ld): stub
\n
"
,
idInst
);
if
(
DDE_Max_Assigned_Instance
==
0
)
{
/* Nothing has been initialised - exit now ! */
return
DMLERR_DLL_NOT_INITIALIZED
;
}
if
(
(
prev_err
=
GetLastError
())
!=
0
)
{
/* something earlier failed !! */
ERR
(
"Error %li before WaitForSingleObject - trying to continue
\n
"
,
prev_err
);
}
WaitForSingleObject
(
handle_mutex
,
1000
);
if
(
((
err_no
=
GetLastError
())
!=
0
)
&&
(
err_no
!=
prev_err
))
{
/* FIXME - needs refinement with popup for timeout, also is timeout interval OK */
ERR
(
"WaitForSingleObject failed - handle list %li
\n
"
,
err_no
);
if
(
!
WaitForMutex
(
handle_mutex
)
)
{
return
DMLERR_SYS_ERROR
;
}
TRACE
(
"Handle Mutex created/reserved
\n
"
);
/* First check instance
...
...
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