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
8802f84c
Commit
8802f84c
authored
May 04, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
May 06, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setupapi: Implement a binary compatible string table.
parent
351fae12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
57 deletions
+91
-57
stringtable.c
dlls/setupapi/stringtable.c
+0
-0
stringtable.c
dlls/setupapi/tests/stringtable.c
+91
-57
No files found.
dlls/setupapi/stringtable.c
View file @
8802f84c
This diff is collapsed.
Click to expand it.
dlls/setupapi/tests/stringtable.c
View file @
8802f84c
...
@@ -29,11 +29,11 @@
...
@@ -29,11 +29,11 @@
#include "wingdi.h"
#include "wingdi.h"
#include "winuser.h"
#include "winuser.h"
#include "winreg.h"
#include "winreg.h"
#include "winnls.h"
#include "setupapi.h"
#include "setupapi.h"
#include "wine/test.h"
#include "wine/test.h"
DECLARE_HANDLE
(
HSTRING_TABLE
);
DECLARE_HANDLE
(
HSTRING_TABLE
);
/* Flags for StringTableAddString and StringTableLookUpString */
/* Flags for StringTableAddString and StringTableLookUpString */
...
@@ -48,57 +48,35 @@ static HSTRING_TABLE (WINAPI *pStringTableInitializeEx)(DWORD, DWORD);
...
@@ -48,57 +48,35 @@ static HSTRING_TABLE (WINAPI *pStringTableInitializeEx)(DWORD, DWORD);
static
DWORD
(
WINAPI
*
pStringTableLookUpString
)(
HSTRING_TABLE
,
LPWSTR
,
DWORD
);
static
DWORD
(
WINAPI
*
pStringTableLookUpString
)(
HSTRING_TABLE
,
LPWSTR
,
DWORD
);
static
DWORD
(
WINAPI
*
pStringTableLookUpStringEx
)(
HSTRING_TABLE
,
LPWSTR
,
DWORD
,
LPVOID
,
DWORD
);
static
DWORD
(
WINAPI
*
pStringTableLookUpStringEx
)(
HSTRING_TABLE
,
LPWSTR
,
DWORD
,
LPVOID
,
DWORD
);
static
LPWSTR
(
WINAPI
*
pStringTableStringFromId
)(
HSTRING_TABLE
,
DWORD
);
static
LPWSTR
(
WINAPI
*
pStringTableStringFromId
)(
HSTRING_TABLE
,
DWORD
);
static
BOOL
(
WINAPI
*
pStringTableGetExtraData
)(
HSTRING_TABLE
,
ULONG
,
void
*
,
ULONG
);
static
HMODULE
hdll
;
static
WCHAR
string
[]
=
{
's'
,
't'
,
'r'
,
'i'
,
'n'
,
'g'
,
0
};
static
WCHAR
string
[]
=
{
's'
,
't'
,
'r'
,
'i'
,
'n'
,
'g'
,
0
};
static
WCHAR
String
[]
=
{
'S'
,
't'
,
'r'
,
'i'
,
'n'
,
'g'
,
0
};
static
WCHAR
String
[]
=
{
'S'
,
't'
,
'r'
,
'i'
,
'n'
,
'g'
,
0
};
static
WCHAR
foo
[]
=
{
'f'
,
'o'
,
'o'
,
0
};
static
WCHAR
foo
[]
=
{
'f'
,
'o'
,
'o'
,
0
};
static
void
load_it_up
(
void
)
static
void
load_it_up
(
void
)
{
{
hdll
=
GetModuleHandleA
(
"setupapi.dll"
);
HMODULE
hdll
=
GetModuleHandleA
(
"setupapi.dll"
);
pStringTableInitialize
=
(
void
*
)
GetProcAddress
(
hdll
,
"StringTableInitialize"
);
#define X(f) if (!(p##f = (void*)GetProcAddress(hdll, #f))) \
if
(
!
pStringTableInitialize
)
p##f = (void*)GetProcAddress(hdll, "pSetup"#f);
pStringTableInitialize
=
(
void
*
)
GetProcAddress
(
hdll
,
"pSetupStringTableInitialize"
);
X
(
StringTableInitialize
);
X
(
StringTableInitializeEx
);
pStringTableInitializeEx
=
(
void
*
)
GetProcAddress
(
hdll
,
"StringTableInitializeEx"
);
X
(
StringTableAddString
);
if
(
!
pStringTableInitializeEx
)
X
(
StringTableAddStringEx
);
pStringTableInitializeEx
=
(
void
*
)
GetProcAddress
(
hdll
,
"pSetupStringTableInitializeEx"
);
X
(
StringTableDuplicate
);
X
(
StringTableDestroy
);
pStringTableAddString
=
(
void
*
)
GetProcAddress
(
hdll
,
"StringTableAddString"
);
X
(
StringTableLookUpString
);
if
(
!
pStringTableAddString
)
X
(
StringTableLookUpStringEx
);
pStringTableAddString
=
(
void
*
)
GetProcAddress
(
hdll
,
"pSetupStringTableAddString"
);
X
(
StringTableStringFromId
);
X
(
StringTableGetExtraData
);
pStringTableAddStringEx
=
(
void
*
)
GetProcAddress
(
hdll
,
"StringTableAddStringEx"
);
#undef X
if
(
!
pStringTableAddStringEx
)
pStringTableAddStringEx
=
(
void
*
)
GetProcAddress
(
hdll
,
"pSetupStringTableAddStringEx"
);
pStringTableDuplicate
=
(
void
*
)
GetProcAddress
(
hdll
,
"StringTableDuplicate"
);
if
(
!
pStringTableDuplicate
)
pStringTableDuplicate
=
(
void
*
)
GetProcAddress
(
hdll
,
"pSetupStringTableDuplicate"
);
pStringTableDestroy
=
(
void
*
)
GetProcAddress
(
hdll
,
"StringTableDestroy"
);
if
(
!
pStringTableDestroy
)
pStringTableDestroy
=
(
void
*
)
GetProcAddress
(
hdll
,
"pSetupStringTableDestroy"
);
pStringTableLookUpString
=
(
void
*
)
GetProcAddress
(
hdll
,
"StringTableLookUpString"
);
if
(
!
pStringTableLookUpString
)
pStringTableLookUpString
=
(
void
*
)
GetProcAddress
(
hdll
,
"pSetupStringTableLookUpString"
);
pStringTableLookUpStringEx
=
(
void
*
)
GetProcAddress
(
hdll
,
"StringTableLookUpStringEx"
);
if
(
!
pStringTableLookUpStringEx
)
pStringTableLookUpStringEx
=
(
void
*
)
GetProcAddress
(
hdll
,
"pSetupStringTableLookUpStringEx"
);
pStringTableStringFromId
=
(
void
*
)
GetProcAddress
(
hdll
,
"StringTableStringFromId"
);
if
(
!
pStringTableStringFromId
)
pStringTableStringFromId
=
(
void
*
)
GetProcAddress
(
hdll
,
"pSetupStringTableStringFromId"
);
}
}
static
void
test_StringTableAddString
(
void
)
static
void
test_StringTableAddString
(
void
)
{
{
DWORD
retval
,
hstring
,
hString
,
hfoo
;
DWORD
retval
,
hstring
,
hString
,
hfoo
;
H
AND
LE
table
;
H
STRING_TAB
LE
table
;
table
=
pStringTableInitialize
();
table
=
pStringTableInitialize
();
ok
(
table
!=
NULL
,
"failed to initialize string table
\n
"
);
ok
(
table
!=
NULL
,
"failed to initialize string table
\n
"
);
...
@@ -124,22 +102,23 @@ static void test_StringTableAddString(void)
...
@@ -124,22 +102,23 @@ static void test_StringTableAddString(void)
static
void
test_StringTableAddStringEx
(
void
)
static
void
test_StringTableAddStringEx
(
void
)
{
{
DWORD
retval
,
hstring
,
hString
,
hfoo
;
DWORD
retval
,
hstring
,
hString
,
hfoo
,
extra
;
HANDLE
table
;
HANDLE
table
;
BOOL
ret
;
table
=
pStringTableInitialize
();
table
=
pStringTableInitialize
();
ok
(
table
!=
NULL
,
"Failed to Initialize String Table
\n
"
);
ok
(
table
!=
NULL
,
"Failed to Initialize String Table
\n
"
);
/* case insensitive */
/* case insensitive */
hstring
=
pStringTableAddStringEx
(
table
,
string
,
0
,
NULL
,
0
);
hstring
=
pStringTableAddStringEx
(
table
,
string
,
0
,
NULL
,
0
);
ok
(
hstring
!=
~
0u
,
"Failed to add string to String Table
\n
"
);
ok
(
hstring
!=
-
1
,
"Failed to add string to String Table
\n
"
);
retval
=
pStringTableAddStringEx
(
table
,
String
,
0
,
NULL
,
0
);
retval
=
pStringTableAddStringEx
(
table
,
String
,
0
,
NULL
,
0
);
ok
(
retval
!=
~
0u
,
"Failed to add String to String Table
\n
"
);
ok
(
retval
!=
-
1
,
"Failed to add String to String Table
\n
"
);
ok
(
hstring
==
retval
,
"string handle %x != String handle %x in String Table
\n
"
,
hstring
,
retval
);
ok
(
hstring
==
retval
,
"string handle %x != String handle %x in String Table
\n
"
,
hstring
,
retval
);
hfoo
=
pStringTableAddStringEx
(
table
,
foo
,
0
,
NULL
,
0
);
hfoo
=
pStringTableAddStringEx
(
table
,
foo
,
0
,
NULL
,
0
);
ok
(
hfoo
!=
~
0u
,
"Failed to add foo to String Table
\n
"
);
ok
(
hfoo
!=
-
1
,
"Failed to add foo to String Table
\n
"
);
ok
(
hfoo
!=
hstring
,
"foo and string share the same ID %x in String Table
\n
"
,
hfoo
);
ok
(
hfoo
!=
hstring
,
"foo and string share the same ID %x in String Table
\n
"
,
hfoo
);
/* case sensitive */
/* case sensitive */
...
@@ -147,11 +126,33 @@ static void test_StringTableAddStringEx(void)
...
@@ -147,11 +126,33 @@ static void test_StringTableAddStringEx(void)
ok
(
hstring
!=
hString
,
"String handle and string share same ID %x in Table
\n
"
,
hstring
);
ok
(
hstring
!=
hString
,
"String handle and string share same ID %x in Table
\n
"
,
hstring
);
pStringTableDestroy
(
table
);
pStringTableDestroy
(
table
);
/* set same string twice but with different extra */
table
=
pStringTableInitializeEx
(
4
,
0
);
ok
(
table
!=
NULL
,
"Failed to Initialize String Table
\n
"
);
extra
=
10
;
hstring
=
pStringTableAddStringEx
(
table
,
string
,
0
,
&
extra
,
4
);
ok
(
hstring
!=
-
1
,
"failed to add string, %d
\n
"
,
hstring
);
extra
=
0
;
ret
=
pStringTableGetExtraData
(
table
,
hstring
,
&
extra
,
4
);
ok
(
ret
&&
extra
==
10
,
"got %d, extra %d
\n
"
,
ret
,
extra
);
extra
=
11
;
hstring
=
pStringTableAddStringEx
(
table
,
string
,
0
,
&
extra
,
4
);
ok
(
hstring
!=
-
1
,
"failed to add string, %d
\n
"
,
hstring
);
extra
=
0
;
ret
=
pStringTableGetExtraData
(
table
,
hstring
,
&
extra
,
4
);
ok
(
ret
&&
extra
==
10
,
"got %d, extra %d
\n
"
,
ret
,
extra
);
pStringTableDestroy
(
table
);
}
}
static
void
test_StringTableDuplicate
(
void
)
static
void
test_StringTableDuplicate
(
void
)
{
{
H
AND
LE
table
,
table2
;
H
STRING_TAB
LE
table
,
table2
;
table
=
pStringTableInitialize
();
table
=
pStringTableInitialize
();
ok
(
table
!=
NULL
,
"Failed to Initialize String Table
\n
"
);
ok
(
table
!=
NULL
,
"Failed to Initialize String Table
\n
"
);
...
@@ -166,7 +167,7 @@ static void test_StringTableDuplicate(void)
...
@@ -166,7 +167,7 @@ static void test_StringTableDuplicate(void)
static
void
test_StringTableLookUpString
(
void
)
static
void
test_StringTableLookUpString
(
void
)
{
{
DWORD
retval
,
retval2
,
hstring
,
hString
,
hfoo
;
DWORD
retval
,
retval2
,
hstring
,
hString
,
hfoo
;
H
AND
LE
table
,
table2
;
H
STRING_TAB
LE
table
,
table2
;
table
=
pStringTableInitialize
();
table
=
pStringTableInitialize
();
ok
(
table
!=
NULL
,
"failed to initialize string table
\n
"
);
ok
(
table
!=
NULL
,
"failed to initialize string table
\n
"
);
...
@@ -224,7 +225,7 @@ static void test_StringTableLookUpStringEx(void)
...
@@ -224,7 +225,7 @@ static void test_StringTableLookUpStringEx(void)
{
{
static
WCHAR
uilevel
[]
=
{
'U'
,
'I'
,
'L'
,
'E'
,
'V'
,
'E'
,
'L'
,
0
};
static
WCHAR
uilevel
[]
=
{
'U'
,
'I'
,
'L'
,
'E'
,
'V'
,
'E'
,
'L'
,
0
};
DWORD
retval
,
retval2
,
hstring
,
hString
,
hfoo
,
data
;
DWORD
retval
,
retval2
,
hstring
,
hString
,
hfoo
,
data
;
H
AND
LE
table
,
table2
;
H
STRING_TAB
LE
table
,
table2
;
char
buffer
[
4
];
char
buffer
[
4
];
table
=
pStringTableInitialize
();
table
=
pStringTableInitialize
();
...
@@ -305,23 +306,55 @@ static void test_StringTableLookUpStringEx(void)
...
@@ -305,23 +306,55 @@ static void test_StringTableLookUpStringEx(void)
static
void
test_StringTableStringFromId
(
void
)
static
void
test_StringTableStringFromId
(
void
)
{
{
HANDLE
table
;
HSTRING_TABLE
table
;
DWORD
hstring
;
WCHAR
*
string2
;
WCHAR
*
string2
;
int
result
;
DWORD
id
,
id2
;
table
=
pStringTableInitialize
();
table
=
pStringTableInitialize
();
ok
(
table
!=
NULL
,
"Failed to Initialize String Table
\n
"
);
ok
(
table
!=
NULL
,
"Failed to Initialize String Table
\n
"
);
hstring
=
pStringTableAddString
(
table
,
string
,
0
);
id
=
pStringTableAddString
(
table
,
string
,
0
);
ok
(
hstring
!=
~
0u
,
"failed to add 'string' to string table
\n
"
);
ok
(
id
!=
-
1
,
"failed to add 'string' to string table
\n
"
);
/* correct */
/* correct */
string2
=
pStringTableStringFromId
(
table
,
pStringTableLookUpString
(
table
,
string
,
0
));
id2
=
pStringTableLookUpString
(
table
,
string
,
0
);
ok
(
string2
!=
NULL
,
"Failed to look up string by ID from String Table
\n
"
);
ok
(
id2
==
id
,
"got %d and %d
\n
"
,
id2
,
id
);
string2
=
pStringTableStringFromId
(
table
,
id2
);
ok
(
string2
!=
NULL
,
"failed to lookup string %d
\n
"
,
id2
);
ok
(
!
lstrcmpiW
(
string
,
string2
),
"got %s, expected %s
\n
"
,
wine_dbgstr_w
(
string2
),
wine_dbgstr_w
(
string
));
pStringTableDestroy
(
table
);
}
struct
stringtable
{
char
*
data
;
ULONG
nextoffset
;
ULONG
allocated
;
DWORD_PTR
unk
[
2
];
ULONG
max_extra_size
;
LCID
lcid
;
};
static
void
test_stringtable_layout
(
void
)
{
struct
stringtable
*
ptr
;
HSTRING_TABLE
table
;
result
=
lstrcmpiW
(
string
,
string2
);
table
=
pStringTableInitialize
();
ok
(
result
==
0
,
"StringID %p does not match requested StringID %p
\n
"
,
string
,
string2
);
ok
(
table
!=
NULL
,
"failed to initialize string table
\n
"
);
ptr
=
(
struct
stringtable
*
)
table
;
ok
(
ptr
->
data
!=
NULL
,
"got %p
\n
"
,
ptr
->
data
);
/* first data offset is right after bucket area */
ok
(
ptr
->
nextoffset
==
509
*
sizeof
(
DWORD
),
"got %d
\n
"
,
ptr
->
nextoffset
);
ok
(
ptr
->
allocated
!=
0
,
"got %d
\n
"
,
ptr
->
allocated
);
todo_wine
{
ok
(
ptr
->
unk
[
0
]
!=
0
,
"got %lx
\n
"
,
ptr
->
unk
[
0
]);
ok
(
ptr
->
unk
[
1
]
!=
0
,
"got %lx
\n
"
,
ptr
->
unk
[
1
]);
}
ok
(
ptr
->
max_extra_size
==
0
,
"got %d
\n
"
,
ptr
->
max_extra_size
);
ok
(
ptr
->
lcid
==
GetThreadLocale
(),
"got %x, thread lcid %x
\n
"
,
ptr
->
lcid
,
GetThreadLocale
());
pStringTableDestroy
(
table
);
pStringTableDestroy
(
table
);
}
}
...
@@ -336,4 +369,5 @@ START_TEST(stringtable)
...
@@ -336,4 +369,5 @@ START_TEST(stringtable)
test_StringTableLookUpString
();
test_StringTableLookUpString
();
test_StringTableLookUpStringEx
();
test_StringTableLookUpStringEx
();
test_StringTableStringFromId
();
test_StringTableStringFromId
();
test_stringtable_layout
();
}
}
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