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
Releases
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
Felix Münchhalfen
wine
Commits
8c7f7e4d
Commit
8c7f7e4d
authored
25 years ago
by
Alexandre Julliard
Browse files
Options
Downloads
Patches
Plain Diff
Use a linked list instead of a DPA for the hook list.
parent
96ebf15e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/ole32/ole2.c
+22
-53
22 additions, 53 deletions
dlls/ole32/ole2.c
with
22 additions
and
53 deletions
dlls/ole32/ole2.c
+
22
−
53
View file @
8c7f7e4d
...
...
@@ -64,12 +64,10 @@ typedef struct tagOleMenuHookItem /* OleMenu hook item in per thread hook list
HANDLE
hHeap
;
/* Heap this is allocated from */
HHOOK
GetMsg_hHook
;
/* message hook for WH_GETMESSAGE */
HHOOK
CallWndProc_hHook
;
/* message hook for WH_CALLWNDPROC */
struct
tagOleMenuHookItem
*
next
;
}
OleMenuHookItem
;
/*
* Dynamic pointer array of per thread message hooks (maintained by OleSetMenuDescriptor)
*/
static
HDPA
OLEMenu_MsgHookDPA
=
NULL
;
static
OleMenuHookItem
*
hook_list
;
/*
* This is the lock count on the OLE library. It is controlled by the
...
...
@@ -99,7 +97,7 @@ static void OLEMenu_Initialize();
static
void
OLEMenu_UnInitialize
();
BOOL
OLEMenu_InstallHooks
(
DWORD
tid
);
BOOL
OLEMenu_UnInstallHooks
(
DWORD
tid
);
OleMenuHookItem
*
OLEMenu_IsHookInstalled
(
DWORD
tid
,
INT
*
pixHook
);
OleMenuHookItem
*
OLEMenu_IsHookInstalled
(
DWORD
tid
);
static
BOOL
OLEMenu_FindMainMenuIndex
(
HMENU
hMainMenu
,
HMENU
hPopupMenu
,
UINT
*
pnPos
);
BOOL
OLEMenu_SetIsServerMenu
(
HMENU
hmenu
,
OleMenuDescriptor
*
pOleMenuDescriptor
);
LRESULT
CALLBACK
OLEMenu_CallWndProc
(
INT
code
,
WPARAM
wParam
,
LPARAM
lParam
);
...
...
@@ -822,9 +820,6 @@ HRESULT WINAPI OleSave(
*/
static
void
OLEMenu_Initialize
()
{
/* Create a dynamic pointer array to store the hook handles */
if
(
!
OLEMenu_MsgHookDPA
)
OLEMenu_MsgHookDPA
=
DPA_CreateEx
(
2
,
GetProcessHeap
()
);
}
/***
...
...
@@ -834,11 +829,6 @@ static void OLEMenu_Initialize()
*/
static
void
OLEMenu_UnInitialize
()
{
/* Release the hook table */
if
(
OLEMenu_MsgHookDPA
)
DPA_Destroy
(
OLEMenu_MsgHookDPA
);
OLEMenu_MsgHookDPA
=
NULL
;
}
/*************************************************************************
...
...
@@ -852,13 +842,6 @@ BOOL OLEMenu_InstallHooks( DWORD tid )
{
OleMenuHookItem
*
pHookItem
=
NULL
;
if
(
!
OLEMenu_MsgHookDPA
)
/* No hook table? Create one */
{
/* Create a dynamic pointer array to store the hook handles */
if
(
!
(
OLEMenu_MsgHookDPA
=
DPA_CreateEx
(
2
,
GetProcessHeap
()
))
)
return
FALSE
;
}
/* Create an entry for the hook table */
if
(
!
(
pHookItem
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
OleMenuHookItem
))
)
)
...
...
@@ -880,8 +863,8 @@ BOOL OLEMenu_InstallHooks( DWORD tid )
goto
CLEANUP
;
/* Insert the hook table entry */
if
(
-
1
==
DPA_InsertPtr
(
OLEMenu_MsgHookDPA
,
0
,
pHookItem
)
)
goto
CLEANUP
;
pHookItem
->
next
=
hook_list
;
hook_list
=
pHookItem
;
return
TRUE
;
...
...
@@ -906,19 +889,20 @@ CLEANUP:
*/
BOOL
OLEMenu_UnInstallHooks
(
DWORD
tid
)
{
INT
ixHook
;
OleMenuHookItem
*
pHookItem
=
NULL
;
OleMenuHookItem
**
ppHook
=
&
hook_list
;
if
(
!
OLEMenu_MsgHookDPA
)
/* No hooks set */
return
TRUE
;
/* Lookup the hHook index for this tid */
if
(
!
OLEMenu_IsHookInstalled
(
tid
,
&
ixHook
)
)
return
TRUE
;
/* Remove the hook entry from the table(the pointer itself is not deleted) */
if
(
!
(
pHookItem
=
DPA_DeletePtr
(
OLEMenu_MsgHookDPA
,
ixHook
)
)
)
return
FALSE
;
while
(
*
ppHook
)
{
if
((
*
ppHook
)
->
tid
==
tid
)
{
pHookItem
=
*
ppHook
;
*
ppHook
=
pHookItem
->
next
;
break
;
}
ppHook
=
&
(
*
ppHook
)
->
next
;
}
if
(
!
pHookItem
)
return
FALSE
;
/* Uninstall the hooks installed for this thread */
if
(
!
UnhookWindowsHookEx
(
pHookItem
->
GetMsg_hHook
)
)
...
...
@@ -946,31 +930,16 @@ CLEANUP:
* RETURNS: The pointer and index of the hook table entry for the tid
* NULL and -1 for the index if no hooks were installed for this thread
*/
OleMenuHookItem
*
OLEMenu_IsHookInstalled
(
DWORD
tid
,
INT
*
pixHook
)
OleMenuHookItem
*
OLEMenu_IsHookInstalled
(
DWORD
tid
)
{
INT
ixHook
;
OleMenuHookItem
*
pHookItem
=
NULL
;
if
(
pixHook
)
*
pixHook
=
-
1
;
if
(
!
OLEMenu_MsgHookDPA
)
/* No hooks set */
return
NULL
;
/* Do a simple linear search for an entry whose tid matches ours.
* We really need a map but efficiency is not a concern here. */
for
(
ixHook
=
0
;
;
ixHook
++
)
for
(
pHookItem
=
hook_list
;
pHookItem
;
pHookItem
=
pHookItem
->
next
)
{
/* Retrieve the hook entry */
if
(
!
(
pHookItem
=
DPA_GetPtr
(
OLEMenu_MsgHookDPA
,
ixHook
)
)
)
return
NULL
;
if
(
tid
==
pHookItem
->
tid
)
{
if
(
pixHook
)
*
pixHook
=
ixHook
;
return
pHookItem
;
}
}
return
NULL
;
...
...
@@ -1155,7 +1124,7 @@ NEXTHOOK:
GlobalUnlock
(
hOleMenu
);
/* Lookup the hook item for the current thread */
if
(
!
(
pHookItem
=
OLEMenu_IsHookInstalled
(
GetCurrentThreadId
()
,
NULL
)
)
)
if
(
!
(
pHookItem
=
OLEMenu_IsHookInstalled
(
GetCurrentThreadId
()
)
)
)
{
/* This should never fail!! */
WARN
(
"could not retrieve hHook for current thread!
\n
"
);
...
...
@@ -1229,7 +1198,7 @@ NEXTHOOK:
GlobalUnlock
(
hOleMenu
);
/* Lookup the hook item for the current thread */
if
(
!
(
pHookItem
=
OLEMenu_IsHookInstalled
(
GetCurrentThreadId
()
,
NULL
)
)
)
if
(
!
(
pHookItem
=
OLEMenu_IsHookInstalled
(
GetCurrentThreadId
()
)
)
)
{
/* This should never fail!! */
WARN
(
"could not retrieve hHook for current thread!
\n
"
);
...
...
@@ -1345,7 +1314,7 @@ HRESULT WINAPI OleSetMenuDescriptor(
* Note: This effectively means that OleSetMenuDescriptor cannot
* be called twice in succession on the same frame window
* without first calling it with a null hOleMenu to uninstall */
if
(
OLEMenu_IsHookInstalled
(
GetCurrentThreadId
()
,
NULL
)
)
if
(
OLEMenu_IsHookInstalled
(
GetCurrentThreadId
()
)
)
return
E_FAIL
;
/* Get the menu descriptor */
...
...
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