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
3280bfe6
Commit
3280bfe6
authored
Apr 21, 2009
by
Aric Stewart
Committed by
Alexandre Julliard
Apr 22, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msctf: Helper functions for generating DWORD cookies.
parent
3e235cc3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
0 deletions
+104
-0
msctf.c
dlls/msctf/msctf.c
+98
-0
msctf_internal.h
dlls/msctf/msctf_internal.h
+6
-0
No files found.
dlls/msctf/msctf.c
View file @
3280bfe6
...
...
@@ -43,6 +43,17 @@ static LONG MSCTF_refCount;
static
HINSTANCE
MSCTF_hinstance
;
typedef
struct
{
DWORD
id
;
DWORD
magic
;
LPVOID
data
;
}
CookieInternal
;
static
CookieInternal
*
cookies
;
static
UINT
id_last
;
static
UINT
array_size
;
DWORD
tlsIndex
=
0
;
const
WCHAR
szwSystemTIPKey
[]
=
{
'S'
,
'O'
,
'F'
,
'T'
,
'W'
,
'A'
,
'R'
,
'E'
,
'\\'
,
'M'
,
'i'
,
'c'
,
'r'
,
'o'
,
's'
,
'o'
,
'f'
,
't'
,
'\\'
,
'C'
,
'T'
,
'F'
,
'\\'
,
'T'
,
'I'
,
'P'
,
0
};
...
...
@@ -155,6 +166,93 @@ static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
}
/*************************************************************************
* DWORD Cookie Management
*/
DWORD
generate_Cookie
(
DWORD
magic
,
LPVOID
data
)
{
int
i
;
/* try to reuse IDs if possible */
for
(
i
=
0
;
i
<
id_last
;
i
++
)
if
(
cookies
[
i
].
id
==
0
)
break
;
if
(
i
==
array_size
)
{
if
(
!
array_size
)
{
cookies
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
CookieInternal
)
*
10
);
if
(
!
cookies
)
{
ERR
(
"Out of memory, Unable to alloc cookies array
\n
"
);
return
0
;
}
array_size
=
10
;
}
else
{
CookieInternal
*
new_cookies
=
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
cookies
,
sizeof
(
CookieInternal
)
*
(
array_size
*
2
));
if
(
!
new_cookies
)
{
ERR
(
"Out of memory, Unable to realloc cookies array
\n
"
);
return
0
;
}
cookies
=
new_cookies
;
array_size
*=
2
;
}
}
cookies
[
i
].
id
=
i
+
1
;
/* a return of 0 is used for failure */
cookies
[
i
].
magic
=
magic
;
cookies
[
i
].
data
=
data
;
if
(
i
==
id_last
)
id_last
++
;
return
cookies
[
i
].
id
;
}
DWORD
get_Cookie_magic
(
DWORD
id
)
{
UINT
index
=
id
-
1
;
if
(
index
>=
id_last
)
return
0
;
if
(
cookies
[
index
].
id
==
0
)
return
0
;
return
cookies
[
index
].
magic
;
}
LPVOID
get_Cookie_data
(
DWORD
id
)
{
UINT
index
=
id
-
1
;
if
(
index
>=
id_last
)
return
NULL
;
if
(
cookies
[
index
].
id
==
0
)
return
NULL
;
return
cookies
[
index
].
data
;
}
LPVOID
remove_Cookie
(
DWORD
id
)
{
UINT
index
=
id
-
1
;
if
(
index
>=
id_last
)
return
NULL
;
if
(
cookies
[
index
].
id
==
0
)
return
NULL
;
cookies
[
index
].
id
=
0
;
return
cookies
[
index
].
data
;
}
/*************************************************************************
* MSCTF DllMain
*/
BOOL
WINAPI
DllMain
(
HINSTANCE
hinst
,
DWORD
fdwReason
,
LPVOID
fImpLoad
)
...
...
dlls/msctf/msctf_internal.h
View file @
3280bfe6
...
...
@@ -28,5 +28,11 @@ extern HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfConte
extern
HRESULT
InputProcessorProfiles_Constructor
(
IUnknown
*
pUnkOuter
,
IUnknown
**
ppOut
);
extern
HRESULT
CategoryMgr_Constructor
(
IUnknown
*
pUnkOuter
,
IUnknown
**
ppOut
);
/* cookie function */
extern
DWORD
generate_Cookie
(
DWORD
magic
,
LPVOID
data
);
extern
DWORD
get_Cookie_magic
(
DWORD
id
);
extern
LPVOID
get_Cookie_data
(
DWORD
id
);
extern
LPVOID
remove_Cookie
(
DWORD
id
);
extern
const
WCHAR
szwSystemTIPKey
[];
#endif
/* __WINE_MSCTF_I_H */
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