From: Rémi Bernon rbernon@codeweavers.com
--- dlls/ntdll/tests/atom.c | 516 +++++++++++++++++----------------------- 1 file changed, 223 insertions(+), 293 deletions(-)
diff --git a/dlls/ntdll/tests/atom.c b/dlls/ntdll/tests/atom.c index a93a76eef2f..3837dfacd3b 100644 --- a/dlls/ntdll/tests/atom.c +++ b/dlls/ntdll/tests/atom.c @@ -38,26 +38,6 @@ #include "wine/test.h" #include "winternl.h"
-#ifndef __WINE_WINTERNL_H -typedef unsigned short RTL_ATOM, *PRTL_ATOM; -typedef struct atom_table *RTL_ATOM_TABLE, **PRTL_ATOM_TABLE; -#endif - -/* Function pointers for ntdll calls */ -static HMODULE hntdll = 0; -static NTSTATUS (WINAPI *pRtlCreateAtomTable)(ULONG,PRTL_ATOM_TABLE); -static NTSTATUS (WINAPI *pRtlDestroyAtomTable)(RTL_ATOM_TABLE); -static NTSTATUS (WINAPI *pRtlEmptyAtomTable)(RTL_ATOM_TABLE,BOOLEAN); -static NTSTATUS (WINAPI *pRtlAddAtomToAtomTable)(RTL_ATOM_TABLE,PCWSTR,PRTL_ATOM); -static NTSTATUS (WINAPI *pRtlDeleteAtomFromAtomTable)(RTL_ATOM_TABLE,RTL_ATOM); -static NTSTATUS (WINAPI *pRtlLookupAtomInAtomTable)(RTL_ATOM_TABLE,PCWSTR,PRTL_ATOM); -static NTSTATUS (WINAPI *pRtlPinAtomInAtomTable)(RTL_ATOM_TABLE,RTL_ATOM); -static NTSTATUS (WINAPI *pRtlQueryAtomInAtomTable)(RTL_ATOM_TABLE,RTL_ATOM,PULONG,PULONG,PWSTR,PULONG); - -static NTSTATUS (WINAPI* pNtAddAtom)(LPCWSTR,ULONG,RTL_ATOM*); -static NTSTATUS (WINAPI* pNtAddAtomNT4)(LPCWSTR,RTL_ATOM*); -static NTSTATUS (WINAPI* pNtQueryInformationAtom)(RTL_ATOM,DWORD,void*,ULONG,PULONG); - static const WCHAR EmptyAtom[] = {0}; static const WCHAR testAtom1[] = {'H','e','l','l','o',' ','W','o','r','l','d',0}; static const WCHAR testAtom2[] = {'H','e','l','l','o',' ','W','o','r','l','d','2',0}; @@ -70,27 +50,6 @@ static const WCHAR testAtomInt[] = {'#','1','3','2',0}; static const WCHAR testAtomIntInv[] = {'#','2','3','4','z',0}; static const WCHAR testAtomOTT[] = {'#','1','2','3',0};
-static void InitFunctionPtr(void) -{ - hntdll = LoadLibraryA("ntdll.dll"); - ok(hntdll != 0, "Unable to load ntdll.dll\n"); - - if (hntdll) - { - pRtlCreateAtomTable = (void *)GetProcAddress(hntdll, "RtlCreateAtomTable"); - pRtlDestroyAtomTable = (void *)GetProcAddress(hntdll, "RtlDestroyAtomTable"); - pRtlEmptyAtomTable = (void *)GetProcAddress(hntdll, "RtlEmptyAtomTable"); - pRtlAddAtomToAtomTable = (void *)GetProcAddress(hntdll, "RtlAddAtomToAtomTable"); - pRtlDeleteAtomFromAtomTable = (void *)GetProcAddress(hntdll, "RtlDeleteAtomFromAtomTable"); - pRtlLookupAtomInAtomTable = (void *)GetProcAddress(hntdll, "RtlLookupAtomInAtomTable"); - pRtlPinAtomInAtomTable = (void *)GetProcAddress(hntdll, "RtlPinAtomInAtomTable"); - pRtlQueryAtomInAtomTable = (void *)GetProcAddress(hntdll, "RtlQueryAtomInAtomTable"); - - pNtAddAtom = (void *)GetProcAddress(hntdll, "NtAddAtom"); - pNtQueryInformationAtom = (void *)GetProcAddress(hntdll, "NtQueryInformationAtom"); - } -} - static DWORD WINAPI RtlAtomTestThread(LPVOID Table) { RTL_ATOM_TABLE AtomTable = *(PRTL_ATOM_TABLE)Table; @@ -99,17 +58,17 @@ static DWORD WINAPI RtlAtomTestThread(LPVOID Table) ULONG RefCount = 0, PinCount = 0, Len = 0; WCHAR Name[64];
- res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1, &Atom); + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1, &Atom ); ok(!res, "Unable to find atom from another thread, retval: %lx\n", res);
- res = pRtlLookupAtomInAtomTable(AtomTable, testAtom2, &Atom); + res = RtlLookupAtomInAtomTable( AtomTable, testAtom2, &Atom ); ok(!res, "Unable to lookup pinned atom in table, retval: %lx\n", res);
- res = pRtlQueryAtomInAtomTable(AtomTable, Atom, &RefCount, &PinCount, Name, &Len); + res = RtlQueryAtomInAtomTable( AtomTable, Atom, &RefCount, &PinCount, Name, &Len ); ok(res == STATUS_BUFFER_TOO_SMALL, "We got wrong retval: %lx\n", res);
Len = 64; - res = pRtlQueryAtomInAtomTable(AtomTable, Atom, &RefCount, &PinCount, Name, &Len); + res = RtlQueryAtomInAtomTable( AtomTable, Atom, &RefCount, &PinCount, Name, &Len ); ok(!res, "Failed with long enough buffer, retval: %lx\n", res); ok(RefCount == 1, "Refcount was not 1 but %lx\n", RefCount); ok(PinCount == 1, "Pincount was not 1 but %lx\n", PinCount); @@ -117,12 +76,12 @@ static DWORD WINAPI RtlAtomTestThread(LPVOID Table) ok((lstrlenW(testAtom2) * sizeof(WCHAR)) == Len, "Returned wrong length %ld\n", Len);
Len = 64; - res = pRtlQueryAtomInAtomTable(AtomTable, Atom, NULL, NULL, Name, &Len); + res = RtlQueryAtomInAtomTable( AtomTable, Atom, NULL, NULL, Name, &Len ); ok(!res, "RtlQueryAtomInAtomTable with optional args invalid failed, retval: %lx\n", res); ok(!lstrcmpW(Name, testAtom2), "Found Wrong atom!\n"); ok((lstrlenW(testAtom2) * sizeof(WCHAR)) == Len, "Returned wrong length %ld\n", Len);
- res = pRtlPinAtomInAtomTable(AtomTable, Atom); + res = RtlPinAtomInAtomTable( AtomTable, Atom ); ok(!res, "Unable to pin atom in atom table, retval: %lx\n", res);
return 0; @@ -139,157 +98,149 @@ static void test_NtAtom(void)
/* If we pass a non-null string to create atom table, then it thinks that we * have passed it an already allocated atom table */ - res = pRtlCreateAtomTable(0, &AtomTable); + res = RtlCreateAtomTable( 0, &AtomTable ); ok(!res, "RtlCreateAtomTable should succeed with an atom table size of 0\n"); - - if (!res) - { - res = pRtlDestroyAtomTable(AtomTable); - ok(!res, "We could create the atom table, but we couldn't destroy it! retval: %lx\n", res); - } + res = RtlDestroyAtomTable( AtomTable ); + ok( !res, "We could create the atom table, but we couldn't destroy it! retval: %lx\n", res );
AtomTable = NULL; - res = pRtlCreateAtomTable(37, &AtomTable); + res = RtlCreateAtomTable( 37, &AtomTable ); ok(!res, "We're unable to create an atom table with a valid table size retval: %lx\n", res); - if (!res) - { - ok( *(DWORD *)AtomTable == 0x6d6f7441, "wrong signature %lx\n", *(DWORD *)AtomTable ); - - res = pRtlAddAtomToAtomTable(AtomTable, testAtom1, &Atom1); - ok(!res, "We were unable to add a simple atom to the atom table, retval: %lx\n", res); - - res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1Cap, &testAtom); - ok(!res, "We were unable to find capital version of the atom, retval: %lx\n", res); - ok(Atom1 == testAtom, "Found wrong atom in table when querying capital atom\n"); - - res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1Low, &testAtom); - ok(!res, "Unable to find lowercase version of the atom, retval: %lx\n", res); - ok(testAtom == Atom1, "Found wrong atom when querying lowercase atom\n"); - - res = pRtlAddAtomToAtomTable(AtomTable, EmptyAtom, &testEAtom); - ok(res == STATUS_OBJECT_NAME_INVALID, "Got wrong retval, retval: %lx\n", res); - - res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1, &testAtom); - ok(!res, "Failed to find totally legitimate atom, retval: %lx\n", res); - ok(testAtom == Atom1, "Found wrong atom!\n"); - - res = pRtlAddAtomToAtomTable(AtomTable, testAtom2, &Atom2); - ok(!res, "Unable to add other legitimate atom to table, retval: %lx\n", res); - - res = pRtlPinAtomInAtomTable(AtomTable, Atom2); - ok(!res, "Unable to pin atom in atom table, retval: %lx\n", res); - - testThread = CreateThread(NULL, 0, RtlAtomTestThread, &AtomTable, 0, NULL); - WaitForSingleObject(testThread, INFINITE); - CloseHandle(testThread); - - Len = 64; - res = pRtlQueryAtomInAtomTable(AtomTable, Atom2, &RefCount, &PinCount, Name, &Len); - ok(!res, "Unable to query atom in atom table, retval: %lx\n", res); - ok(RefCount == 1, "RefCount is not 1 but %lx\n", RefCount); - ok(PinCount == 1, "PinCount is not 1 but %lx\n", PinCount); - ok(!lstrcmpW(Name, testAtom2), "We found wrong atom\n"); - ok((lstrlenW(testAtom2) * sizeof(WCHAR)) == Len, "Returned wrong length %ld\n", Len); - - res = pRtlEmptyAtomTable(AtomTable, FALSE); - ok(!res, "Unable to empty atom table, retval %lx\n", res); - - Len = 64; - res = pRtlQueryAtomInAtomTable(AtomTable, Atom2, &RefCount, &PinCount, Name, &Len); - ok(!res, "It seems RtlEmptyAtomTable deleted our pinned atom eaven though we asked it not to, retval: %lx\n", res); - ok(RefCount == 1, "RefCount is not 1 but %lx\n", RefCount); - ok(PinCount == 1, "PinCount is not 1 but %lx\n", PinCount); - ok(!lstrcmpW(Name, testAtom2), "We found wrong atom\n"); - ok((lstrlenW(testAtom2) * sizeof(WCHAR)) == Len, "Returned wrong length %ld\n", Len); - - Len = 8; - Name[0] = Name[1] = Name[2] = Name[3] = Name[4] = 0x1337; - res = pRtlQueryAtomInAtomTable(AtomTable, Atom2, NULL, NULL, Name, &Len); - ok(!res, "query atom %lx\n", res); - ok(Len == 6, "wrong length %lu\n", Len); - ok(!memcmp(Name, testAtom2, Len), "wrong atom string\n"); - ok(!Name[3], "wrong string termination\n"); - ok(Name[4] == 0x1337, "buffer overwrite\n"); - - Len = lstrlenW(testAtom2) * sizeof(WCHAR); - memset(Name, '.', sizeof(Name)); - res = pRtlQueryAtomInAtomTable( AtomTable, Atom2, NULL, NULL, Name, &Len ); - ok(!res, "query atom %lx\n", res); - ok(Len == (lstrlenW(testAtom2) - 1) * sizeof(WCHAR), "wrong length %lu\n", Len); - ok(!memcmp(testAtom2, Name, (lstrlenW(testAtom2) - 1) * sizeof(WCHAR)), "wrong atom name\n"); - ok(Name[lstrlenW(testAtom2) - 1] == '\0', "wrong char\n"); - ok(Name[lstrlenW(testAtom2)] == ('.' << 8) + '.', "wrong char\n"); - - res = pRtlLookupAtomInAtomTable(AtomTable, testAtom2, &testAtom); - ok(!res, "We can't find our pinned atom!! retval: %lx\n", res); - ok(testAtom == Atom2, "We found wrong atom!!!\n"); - - res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1, &testAtom); - ok(res == STATUS_OBJECT_NAME_NOT_FOUND, "We found the atom in our table eaven though we asked RtlEmptyAtomTable to remove it, retval: %lx\n", res); - - res = pRtlAddAtomToAtomTable(AtomTable, testAtom3, &Atom3); - ok(!res, "Unable to add atom to table, retval: %lx\n", res); - - res = pRtlEmptyAtomTable(AtomTable, TRUE); - ok(!res, "Unable to empty atom table, retval: %lx\n", res); - - res = pRtlLookupAtomInAtomTable(AtomTable, testAtom2, &testAtom); - ok(res == STATUS_OBJECT_NAME_NOT_FOUND, "The pinned atom should be removed, retval: %lx\n", res); - - res = pRtlLookupAtomInAtomTable(AtomTable, testAtom3, &testAtom); - ok(res == STATUS_OBJECT_NAME_NOT_FOUND, "Non pinned atom should also be removed, retval: %lx\n", res); - - res = pRtlDestroyAtomTable(AtomTable); - ok(!res, "Can't destroy atom table, retval: %lx\n", res); - } + ok( *(DWORD *)AtomTable == 0x6d6f7441, "wrong signature %lx\n", *(DWORD *)AtomTable ); + + res = RtlAddAtomToAtomTable( AtomTable, testAtom1, &Atom1 ); + ok( !res, "We were unable to add a simple atom to the atom table, retval: %lx\n", res ); + + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1Cap, &testAtom ); + ok( !res, "We were unable to find capital version of the atom, retval: %lx\n", res ); + ok( Atom1 == testAtom, "Found wrong atom in table when querying capital atom\n" ); + + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1Low, &testAtom ); + ok( !res, "Unable to find lowercase version of the atom, retval: %lx\n", res ); + ok( testAtom == Atom1, "Found wrong atom when querying lowercase atom\n" ); + + res = RtlAddAtomToAtomTable( AtomTable, EmptyAtom, &testEAtom ); + ok( res == STATUS_OBJECT_NAME_INVALID, "Got wrong retval, retval: %lx\n", res ); + + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1, &testAtom ); + ok( !res, "Failed to find totally legitimate atom, retval: %lx\n", res ); + ok( testAtom == Atom1, "Found wrong atom!\n" ); + + res = RtlAddAtomToAtomTable( AtomTable, testAtom2, &Atom2 ); + ok( !res, "Unable to add other legitimate atom to table, retval: %lx\n", res ); + + res = RtlPinAtomInAtomTable( AtomTable, Atom2 ); + ok( !res, "Unable to pin atom in atom table, retval: %lx\n", res ); + + testThread = CreateThread( NULL, 0, RtlAtomTestThread, &AtomTable, 0, NULL ); + WaitForSingleObject( testThread, INFINITE ); + CloseHandle( testThread ); + + Len = 64; + res = RtlQueryAtomInAtomTable( AtomTable, Atom2, &RefCount, &PinCount, Name, &Len ); + ok( !res, "Unable to query atom in atom table, retval: %lx\n", res ); + ok( RefCount == 1, "RefCount is not 1 but %lx\n", RefCount ); + ok( PinCount == 1, "PinCount is not 1 but %lx\n", PinCount ); + ok( !lstrcmpW( Name, testAtom2 ), "We found wrong atom\n" ); + ok( (lstrlenW( testAtom2 ) * sizeof(WCHAR)) == Len, "Returned wrong length %ld\n", Len ); + + res = RtlEmptyAtomTable( AtomTable, FALSE ); + ok( !res, "Unable to empty atom table, retval %lx\n", res ); + + Len = 64; + res = RtlQueryAtomInAtomTable( AtomTable, Atom2, &RefCount, &PinCount, Name, &Len ); + ok( !res, "It seems RtlEmptyAtomTable deleted our pinned atom eaven though we asked it not to, retval: %lx\n", res ); + ok( RefCount == 1, "RefCount is not 1 but %lx\n", RefCount ); + ok( PinCount == 1, "PinCount is not 1 but %lx\n", PinCount ); + ok( !lstrcmpW( Name, testAtom2 ), "We found wrong atom\n" ); + ok( (lstrlenW( testAtom2 ) * sizeof(WCHAR)) == Len, "Returned wrong length %ld\n", Len ); + + Len = 8; + Name[0] = Name[1] = Name[2] = Name[3] = Name[4] = 0x1337; + res = RtlQueryAtomInAtomTable( AtomTable, Atom2, NULL, NULL, Name, &Len ); + ok( !res, "query atom %lx\n", res ); + ok( Len == 6, "wrong length %lu\n", Len ); + ok( !memcmp( Name, testAtom2, Len ), "wrong atom string\n" ); + ok( !Name[3], "wrong string termination\n" ); + ok( Name[4] == 0x1337, "buffer overwrite\n" ); + + Len = lstrlenW( testAtom2 ) * sizeof(WCHAR); + memset( Name, '.', sizeof(Name) ); + res = RtlQueryAtomInAtomTable( AtomTable, Atom2, NULL, NULL, Name, &Len ); + ok( !res, "query atom %lx\n", res ); + ok( Len == (lstrlenW( testAtom2 ) - 1) * sizeof(WCHAR), "wrong length %lu\n", Len ); + ok( !memcmp( testAtom2, Name, (lstrlenW( testAtom2 ) - 1) * sizeof(WCHAR) ), + "wrong atom name\n" ); + ok( Name[lstrlenW( testAtom2 ) - 1] == '\0', "wrong char\n" ); + ok( Name[lstrlenW( testAtom2 )] == ('.' << 8) + '.', "wrong char\n" ); + + res = RtlLookupAtomInAtomTable( AtomTable, testAtom2, &testAtom ); + ok( !res, "We can't find our pinned atom!! retval: %lx\n", res ); + ok( testAtom == Atom2, "We found wrong atom!!!\n" ); + + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1, &testAtom ); + ok( res == STATUS_OBJECT_NAME_NOT_FOUND, "We found the atom in our table eaven though we asked RtlEmptyAtomTable to remove it, retval: %lx\n", + res ); + + res = RtlAddAtomToAtomTable( AtomTable, testAtom3, &Atom3 ); + ok( !res, "Unable to add atom to table, retval: %lx\n", res ); + + res = RtlEmptyAtomTable( AtomTable, TRUE ); + ok( !res, "Unable to empty atom table, retval: %lx\n", res ); + + res = RtlLookupAtomInAtomTable( AtomTable, testAtom2, &testAtom ); + ok( res == STATUS_OBJECT_NAME_NOT_FOUND, "The pinned atom should be removed, retval: %lx\n", res ); + + res = RtlLookupAtomInAtomTable( AtomTable, testAtom3, &testAtom ); + ok( res == STATUS_OBJECT_NAME_NOT_FOUND, "Non pinned atom should also be removed, retval: %lx\n", res ); + + res = RtlDestroyAtomTable( AtomTable ); + ok( !res, "Can't destroy atom table, retval: %lx\n", res );
AtomTable = NULL; - res = pRtlCreateAtomTable(37, &AtomTable); + res = RtlCreateAtomTable( 37, &AtomTable ); ok(!res, "Unable to create atom table, retval: %lx\n", res);
- if (!res) - { - res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1, &testAtom); - ok(res == STATUS_OBJECT_NAME_NOT_FOUND, "Didn't get expected retval with querying an empty atom table, retval: %lx\n", res); + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1, &testAtom ); + ok( res == STATUS_OBJECT_NAME_NOT_FOUND, + "Didn't get expected retval with querying an empty atom table, retval: %lx\n", res );
- res = pRtlAddAtomToAtomTable(AtomTable, testAtom1, &Atom1); - ok(!res, "Unable to add atom to atom table, retval %lx\n", res); + res = RtlAddAtomToAtomTable( AtomTable, testAtom1, &Atom1 ); + ok( !res, "Unable to add atom to atom table, retval %lx\n", res );
- res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1, &testAtom); - ok(!res, "Can't find previously added atom in table, retval: %lx\n", res); - ok(testAtom == Atom1, "Found wrong atom! retval: %lx\n", res); + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1, &testAtom ); + ok( !res, "Can't find previously added atom in table, retval: %lx\n", res ); + ok( testAtom == Atom1, "Found wrong atom! retval: %lx\n", res );
- res = pRtlDeleteAtomFromAtomTable(AtomTable, Atom1); - ok(!res, "Unable to delete atom from table, retval: %lx\n", res); + res = RtlDeleteAtomFromAtomTable( AtomTable, Atom1 ); + ok( !res, "Unable to delete atom from table, retval: %lx\n", res );
- res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1, &testAtom); - ok(res == STATUS_OBJECT_NAME_NOT_FOUND, "Able to find previously deleted atom in table, retval: %lx\n", res); + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1, &testAtom ); + ok( res == STATUS_OBJECT_NAME_NOT_FOUND, "Able to find previously deleted atom in table, retval: %lx\n", res );
- res = pRtlAddAtomToAtomTable(AtomTable, testAtom1, &Atom1); - ok(!res, "Unable to add atom to atom table, retval: %lx\n", res); + res = RtlAddAtomToAtomTable( AtomTable, testAtom1, &Atom1 ); + ok( !res, "Unable to add atom to atom table, retval: %lx\n", res );
- Len = 0; - res = pRtlQueryAtomInAtomTable(AtomTable, Atom1, NULL, NULL, Name, &Len); - ok(res == STATUS_BUFFER_TOO_SMALL, "Got wrong retval, retval: %lx\n", res); - ok((lstrlenW(testAtom1) * sizeof(WCHAR)) == Len || broken(!Len) /* nt4 */, "Got wrong length %lx\n", Len); - if (!Len) pNtAddAtomNT4 = (void *)pNtAddAtom; + Len = 0; + res = RtlQueryAtomInAtomTable( AtomTable, Atom1, NULL, NULL, Name, &Len ); + ok( res == STATUS_BUFFER_TOO_SMALL, "Got wrong retval, retval: %lx\n", res ); + ok( lstrlenW( testAtom1 ) * sizeof(WCHAR) == Len, "Got wrong length %lx\n", Len );
- res = pRtlPinAtomInAtomTable(AtomTable, Atom1); - ok(!res, "Unable to pin atom in atom table, retval: %lx\n", res); + res = RtlPinAtomInAtomTable( AtomTable, Atom1 ); + ok( !res, "Unable to pin atom in atom table, retval: %lx\n", res );
- res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1, &testAtom); - ok(!res, "Unable to find atom in atom table, retval: %lx\n", res); - ok(testAtom == Atom1, "Wrong atom found\n"); + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1, &testAtom ); + ok( !res, "Unable to find atom in atom table, retval: %lx\n", res ); + ok( testAtom == Atom1, "Wrong atom found\n" );
- res = pRtlDeleteAtomFromAtomTable(AtomTable, Atom1); - ok(res == STATUS_WAS_LOCKED, "Unable to delete atom from table, retval: %lx\n", res); + res = RtlDeleteAtomFromAtomTable( AtomTable, Atom1 ); + ok( res == STATUS_WAS_LOCKED, "Unable to delete atom from table, retval: %lx\n", res );
- res = pRtlLookupAtomInAtomTable(AtomTable, testAtom1, &testAtom); - ok(!res, "Able to find deleted atom in table\n"); + res = RtlLookupAtomInAtomTable( AtomTable, testAtom1, &testAtom ); + ok( !res, "Able to find deleted atom in table\n" );
- res = pRtlDestroyAtomTable(AtomTable); - ok(!res, "Unable to destroy atom table\n"); - } + res = RtlDestroyAtomTable( AtomTable ); + ok( !res, "Unable to destroy atom table\n" ); }
/* Test Adding integer atoms to atom table */ @@ -304,84 +255,76 @@ static void test_NtIntAtom(void) ULONG Len;
AtomTable = NULL; - res = pRtlCreateAtomTable(37, &AtomTable); + res = RtlCreateAtomTable( 37, &AtomTable ); ok(!res, "Unable to create atom table, %lx\n", res);
- if (!res) + /* According to the kernel32 functions, integer atoms are only allowed from + * 0x0001 to 0xbfff and not 0xc000 to 0xffff, which is correct */ + res = RtlAddAtomToAtomTable( AtomTable, NULL, &testAtom ); + ok( res == STATUS_INVALID_PARAMETER, "Didn't get expected result from adding 0 int atom, retval: %lx\n", res ); + for (i = 1; i <= 0xbfff; i++) { - /* According to the kernel32 functions, integer atoms are only allowed from - * 0x0001 to 0xbfff and not 0xc000 to 0xffff, which is correct */ - res = pRtlAddAtomToAtomTable(AtomTable, NULL, &testAtom); - ok(res == STATUS_INVALID_PARAMETER, "Didn't get expected result from adding 0 int atom, retval: %lx\n", res); - for (i = 1; i <= 0xbfff; i++) - { - res = pRtlAddAtomToAtomTable(AtomTable, (LPWSTR)i, &testAtom); - ok(!res, "Unable to add valid integer atom %Ii, retval: %lx\n", i, res); - } - - for (i = 1; i <= 0xbfff; i++) - { - res = pRtlLookupAtomInAtomTable(AtomTable, (LPWSTR)i, &testAtom); - ok(!res, "Unable to find int atom %Ii, retval: %lx\n", i, res); - if (!res) - { - res = pRtlPinAtomInAtomTable(AtomTable, testAtom); - ok(!res, "Unable to pin int atom %Ii, retval: %lx\n", i, res); - } - } - - for (i = 0xc000; i <= 0xffff; i++) - { - res = pRtlAddAtomToAtomTable(AtomTable, (LPWSTR)i, &testAtom); - ok(res, "Able to illeageal integer atom %Ii, retval: %lx\n", i, res); - } - - res = pRtlDestroyAtomTable(AtomTable); - ok(!res, "Unable to destroy atom table, retval: %lx\n", res); + res = RtlAddAtomToAtomTable( AtomTable, (LPWSTR)i, &testAtom ); + ok( !res, "Unable to add valid integer atom %Ii, retval: %lx\n", i, res ); }
- AtomTable = NULL; - res = pRtlCreateAtomTable(37, &AtomTable); - ok(!res, "Unable to create atom table, %lx\n", res); - if (!res) + for (i = 1; i <= 0xbfff; i++) { - res = pRtlLookupAtomInAtomTable(AtomTable, (PWSTR)123, &testAtom); - ok(!res, "Unable to query atom in atom table, retval: %lx\n", res); + res = RtlLookupAtomInAtomTable( AtomTable, (LPWSTR)i, &testAtom ); + ok( !res, "Unable to find int atom %Ii, retval: %lx\n", i, res ); + res = RtlPinAtomInAtomTable( AtomTable, testAtom ); + ok( !res, "Unable to pin int atom %Ii, retval: %lx\n", i, res ); + }
- res = pRtlAddAtomToAtomTable(AtomTable, testAtomInt, &testAtom); - ok(!res, "Unable to add int atom to table, retval: %lx\n", res); + for (i = 0xc000; i <= 0xffff; i++) + { + res = RtlAddAtomToAtomTable( AtomTable, (LPWSTR)i, &testAtom ); + ok( res, "Able to illeageal integer atom %Ii, retval: %lx\n", i, res ); + }
- res = pRtlAddAtomToAtomTable(AtomTable, testAtomIntInv, &testAtom); - ok(!res, "Unable to add int atom to table, retval: %lx\n", res); + res = RtlDestroyAtomTable( AtomTable ); + ok( !res, "Unable to destroy atom table, retval: %lx\n", res );
- res = pRtlAddAtomToAtomTable(AtomTable, (PWSTR)123, &testAtom); - ok(!res, "Unable to add int atom to table, retval: %lx\n", res); + AtomTable = NULL; + res = RtlCreateAtomTable( 37, &AtomTable ); + ok( !res, "Unable to create atom table, %lx\n", res );
- res = pRtlAddAtomToAtomTable(AtomTable, (PWSTR)123, &testAtom); - ok(!res, "Unable to re-add int atom to table, retval: %lx\n", res); + res = RtlLookupAtomInAtomTable( AtomTable, (PWSTR)123, &testAtom ); + ok( !res, "Unable to query atom in atom table, retval: %lx\n", res );
- Len = 64; - res = pRtlQueryAtomInAtomTable(AtomTable, testAtom, &RefCount, &PinCount, Name, &Len); - ok(!res, "Unable to query atom in atom table, retval: %lx\n", res); - ok(PinCount == 1, "Expected pincount 1 but got %lx\n", PinCount); - ok(RefCount == 1, "Expected refcount 1 but got %lx\n", RefCount); - ok(!lstrcmpW(testAtomOTT, Name), "Got wrong atom name\n"); - ok((lstrlenW(testAtomOTT) * sizeof(WCHAR)) == Len, "Got wrong len %ld\n", Len); + res = RtlAddAtomToAtomTable( AtomTable, testAtomInt, &testAtom ); + ok( !res, "Unable to add int atom to table, retval: %lx\n", res );
- res = pRtlPinAtomInAtomTable(AtomTable, testAtom); - ok(!res, "Unable to pin int atom, retval: %lx\n", res); + res = RtlAddAtomToAtomTable( AtomTable, testAtomIntInv, &testAtom ); + ok( !res, "Unable to add int atom to table, retval: %lx\n", res );
- res = pRtlPinAtomInAtomTable(AtomTable, testAtom); - ok(!res, "Unable to pin int atom, retval: %lx\n", res); + res = RtlAddAtomToAtomTable( AtomTable, (PWSTR)123, &testAtom ); + ok( !res, "Unable to add int atom to table, retval: %lx\n", res );
- res = pRtlQueryAtomInAtomTable(AtomTable, testAtom, &RefCount, &PinCount, NULL, NULL); - ok(!res, "Unable to query atom in atom table, retval: %lx\n", res); - ok(PinCount == 1, "Expected pincount 1 but got %lx\n", PinCount); - ok(RefCount == 1, "Expected refcount 1 but got %lx\n", RefCount); + res = RtlAddAtomToAtomTable( AtomTable, (PWSTR)123, &testAtom ); + ok( !res, "Unable to re-add int atom to table, retval: %lx\n", res );
- res = pRtlDestroyAtomTable(AtomTable); - ok(!res, "Unable to destroy atom table, retval: %lx\n", res); - } + Len = 64; + res = RtlQueryAtomInAtomTable( AtomTable, testAtom, &RefCount, &PinCount, Name, &Len ); + ok( !res, "Unable to query atom in atom table, retval: %lx\n", res ); + ok( PinCount == 1, "Expected pincount 1 but got %lx\n", PinCount ); + ok( RefCount == 1, "Expected refcount 1 but got %lx\n", RefCount ); + ok( !lstrcmpW( testAtomOTT, Name ), "Got wrong atom name\n" ); + ok( (lstrlenW( testAtomOTT ) * sizeof(WCHAR)) == Len, "Got wrong len %ld\n", Len ); + + res = RtlPinAtomInAtomTable( AtomTable, testAtom ); + ok( !res, "Unable to pin int atom, retval: %lx\n", res ); + + res = RtlPinAtomInAtomTable( AtomTable, testAtom ); + ok( !res, "Unable to pin int atom, retval: %lx\n", res ); + + res = RtlQueryAtomInAtomTable( AtomTable, testAtom, &RefCount, &PinCount, NULL, NULL ); + ok( !res, "Unable to query atom in atom table, retval: %lx\n", res ); + ok( PinCount == 1, "Expected pincount 1 but got %lx\n", PinCount ); + ok( RefCount == 1, "Expected refcount 1 but got %lx\n", RefCount ); + + res = RtlDestroyAtomTable( AtomTable ); + ok( !res, "Unable to destroy atom table, retval: %lx\n", res ); }
/* Tests to see how the pincount and refcount actually works */ @@ -393,42 +336,39 @@ static void test_NtRefPinAtom(void) NTSTATUS res;
AtomTable = NULL; - res = pRtlCreateAtomTable(37, &AtomTable); + res = RtlCreateAtomTable( 37, &AtomTable ); ok(!res, "Unable to create atom table, %lx\n", res);
- if (!res) - { - res = pRtlAddAtomToAtomTable(AtomTable, testAtom1, &Atom); - ok(!res, "Unable to add our atom to the atom table, retval: %lx\n", res); + res = RtlAddAtomToAtomTable( AtomTable, testAtom1, &Atom ); + ok( !res, "Unable to add our atom to the atom table, retval: %lx\n", res );
- res = pRtlAddAtomToAtomTable(AtomTable, testAtom1, &Atom); - ok(!res, "Unable to add our atom to the atom table, retval: %lx\n", res); + res = RtlAddAtomToAtomTable( AtomTable, testAtom1, &Atom ); + ok( !res, "Unable to add our atom to the atom table, retval: %lx\n", res );
- res = pRtlAddAtomToAtomTable(AtomTable, testAtom1, &Atom); - ok(!res, "Unable to add our atom to the atom table, retval: %lx\n", res); + res = RtlAddAtomToAtomTable( AtomTable, testAtom1, &Atom ); + ok( !res, "Unable to add our atom to the atom table, retval: %lx\n", res );
- res = pRtlQueryAtomInAtomTable(AtomTable, Atom, &RefCount, &PinCount, NULL, NULL); - ok(!res, "Unable to query atom in atom table, retval: %lx\n", res); - ok(PinCount == 0, "Expected pincount 0 but got %lx\n", PinCount); - ok(RefCount == 3, "Expected refcount 3 but got %lx\n", RefCount); + res = RtlQueryAtomInAtomTable( AtomTable, Atom, &RefCount, &PinCount, NULL, NULL ); + ok( !res, "Unable to query atom in atom table, retval: %lx\n", res ); + ok( PinCount == 0, "Expected pincount 0 but got %lx\n", PinCount ); + ok( RefCount == 3, "Expected refcount 3 but got %lx\n", RefCount );
- res = pRtlPinAtomInAtomTable(AtomTable, Atom); - ok(!res, "Unable to pin atom in atom table, retval: %lx\n", res); + res = RtlPinAtomInAtomTable( AtomTable, Atom ); + ok( !res, "Unable to pin atom in atom table, retval: %lx\n", res );
- res = pRtlPinAtomInAtomTable(AtomTable, Atom); - ok(!res, "Unable to pin atom in atom table, retval: %lx\n", res); + res = RtlPinAtomInAtomTable( AtomTable, Atom ); + ok( !res, "Unable to pin atom in atom table, retval: %lx\n", res );
- res = pRtlPinAtomInAtomTable(AtomTable, Atom); - ok(!res, "Unable to pin atom in atom table, retval: %lx\n", res); + res = RtlPinAtomInAtomTable( AtomTable, Atom ); + ok( !res, "Unable to pin atom in atom table, retval: %lx\n", res );
- res = pRtlQueryAtomInAtomTable(AtomTable, Atom, &RefCount, &PinCount, NULL, NULL); - ok(!res, "Unable to query atom in atom table, retval: %lx\n", res); - ok(PinCount == 1, "Expected pincount 1 but got %lx\n", PinCount); - ok(RefCount == 3, "Expected refcount 3 but got %lx\n", RefCount); + res = RtlQueryAtomInAtomTable( AtomTable, Atom, &RefCount, &PinCount, NULL, NULL ); + ok( !res, "Unable to query atom in atom table, retval: %lx\n", res ); + ok( PinCount == 1, "Expected pincount 1 but got %lx\n", PinCount ); + ok( RefCount == 3, "Expected refcount 3 but got %lx\n", RefCount );
- res = pRtlDestroyAtomTable(AtomTable); - ok(!res, "Unable to destroy atom table, retval: %lx\n", res); - } + res = RtlDestroyAtomTable( AtomTable ); + ok( !res, "Unable to destroy atom table, retval: %lx\n", res ); }
static void test_Global(void) @@ -439,15 +379,11 @@ static void test_Global(void) ATOM_BASIC_INFORMATION* abi = (ATOM_BASIC_INFORMATION*)ptr; ULONG ptr_size = sizeof(ptr);
- if (pNtAddAtomNT4) - res = pNtAddAtomNT4(testAtom1, &atom); - else - res = pNtAddAtom(testAtom1, lstrlenW(testAtom1) * sizeof(WCHAR), &atom); - + res = NtAddAtom( testAtom1, lstrlenW( testAtom1 ) * sizeof(WCHAR), &atom ); ok(!res, "Added atom (%lx)\n", res);
memset( ptr, 0xcc, sizeof(ptr) ); - res = pNtQueryInformationAtom( atom, AtomBasicInformation, (void*)ptr, ptr_size, NULL ); + res = NtQueryInformationAtom( atom, AtomBasicInformation, (void *)ptr, ptr_size, NULL ); ok(!res, "atom lookup\n"); ok(!lstrcmpW(abi->Name, testAtom1), "ok strings\n"); ok(abi->NameLength == lstrlenW(testAtom1) * sizeof(WCHAR), "wrong string length\n"); @@ -455,14 +391,14 @@ static void test_Global(void) ok(abi->Name[lstrlenW(testAtom1) + 1] == 0xcccc, "buffer overwrite %x\n", abi->Name[lstrlenW(testAtom1) + 1]);
ptr_size = sizeof(ATOM_BASIC_INFORMATION); - res = pNtQueryInformationAtom( atom, AtomBasicInformation, (void*)ptr, ptr_size, NULL ); + res = NtQueryInformationAtom( atom, AtomBasicInformation, (void *)ptr, ptr_size, NULL ); ok(res == STATUS_BUFFER_TOO_SMALL, "wrong return status (%lx)\n", res); ok(abi->NameLength == lstrlenW(testAtom1) * sizeof(WCHAR) || broken(abi->NameLength == sizeof(WCHAR)), /* nt4 */ "string length %u\n",abi->NameLength);
memset( ptr, 0xcc, sizeof(ptr) ); ptr_size = sizeof(ATOM_BASIC_INFORMATION) + lstrlenW(testAtom1) * sizeof(WCHAR); - res = pNtQueryInformationAtom( atom, AtomBasicInformation, (void*)ptr, ptr_size, NULL ); + res = NtQueryInformationAtom( atom, AtomBasicInformation, (void *)ptr, ptr_size, NULL ); ok(!res, "atom lookup %lx\n", res); ok(!lstrcmpW(abi->Name, testAtom1), "strings don't match\n"); ok(abi->NameLength == lstrlenW(testAtom1) * sizeof(WCHAR), "wrong string length\n"); @@ -471,28 +407,22 @@ static void test_Global(void)
memset( ptr, 0xcc, sizeof(ptr) ); ptr_size = sizeof(ATOM_BASIC_INFORMATION) + 4 * sizeof(WCHAR); - res = pNtQueryInformationAtom( atom, AtomBasicInformation, (void*)ptr, ptr_size, NULL ); + res = NtQueryInformationAtom( atom, AtomBasicInformation, (void *)ptr, ptr_size, NULL ); ok(!res, "couldn't find atom\n"); ok(abi->NameLength == 8, "wrong string length %u\n", abi->NameLength); ok(!memcmp(abi->Name, testAtom1, 8), "strings don't match\n"); + + NtDeleteAtom( atom ); }
START_TEST(atom) { - InitFunctionPtr(); - if (pRtlCreateAtomTable) - { - /* Global atom table seems to be available to GUI apps only in - Win7, so let's turn this app into a GUI app */ - GetDesktopWindow(); - - test_NtAtom(); - test_NtIntAtom(); - test_NtRefPinAtom(); - test_Global(); - } - else - win_skip("Needed atom functions are not available\n"); - - FreeLibrary(hntdll); + /* Global atom table seems to be available to GUI apps only in + Win7, so let's turn this app into a GUI app */ + GetDesktopWindow(); + + test_NtAtom(); + test_NtIntAtom(); + test_NtRefPinAtom(); + test_Global(); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/ntdll/tests/atom.c | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+)
diff --git a/dlls/ntdll/tests/atom.c b/dlls/ntdll/tests/atom.c index 3837dfacd3b..4fbf602ef20 100644 --- a/dlls/ntdll/tests/atom.c +++ b/dlls/ntdll/tests/atom.c @@ -246,6 +246,53 @@ static void test_NtAtom(void) /* Test Adding integer atoms to atom table */ static void test_NtIntAtom(void) { + struct atom_test + { + const WCHAR *str; + NTSTATUS status; + UINT value; + } + integral_atom_tests[] = + { + {(PWSTR)0, STATUS_INVALID_PARAMETER, 0}, + {L"#", STATUS_SUCCESS, 0xc000}, + {L"0", STATUS_SUCCESS, 0xc000}, + {L"#0", STATUS_INVALID_PARAMETER, 0}, + {L"#0000", STATUS_INVALID_PARAMETER, 0}, + {L"0x0", STATUS_SUCCESS, 0xc000}, + {(PWSTR)1, STATUS_SUCCESS, 1}, + {L"1", STATUS_SUCCESS, 0xc000}, + {L"#1", STATUS_SUCCESS, 1}, + {L"0x1", STATUS_SUCCESS, 0xc000}, + {L"#01", STATUS_SUCCESS, 1}, + {L"#00001", STATUS_SUCCESS, 1}, + {L"#00001", STATUS_SUCCESS, 1}, + {L"#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000000000000000000000000001", STATUS_SUCCESS, 1}, + {(PWSTR)123, STATUS_SUCCESS, 123}, + {L"123", STATUS_SUCCESS, 0xc000}, + {L"#123", STATUS_SUCCESS, 123}, + {L"#0123", STATUS_SUCCESS, 123}, + {L"#0000123", STATUS_SUCCESS, 123}, + {L"#7b", STATUS_SUCCESS, 0xc000}, + {L"#0x7b", STATUS_SUCCESS, 0xc000}, + {L"# 123", STATUS_SUCCESS, 0xc000}, + {L"#+123", STATUS_SUCCESS, 0xc000}, + {(PWSTR)49151, STATUS_SUCCESS, 49151}, + {L"#49151", STATUS_SUCCESS, 49151}, + {L"#0xbfff", STATUS_SUCCESS, 0xc000}, + {(PWSTR)49152, STATUS_ACCESS_VIOLATION, 0xdead}, + {L"#49152", STATUS_INVALID_PARAMETER, 0}, + {L"#c000", STATUS_SUCCESS, 0xc000}, + {L"#0xc000", STATUS_SUCCESS, 0xc000}, + {L"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000", STATUS_SUCCESS, 0xc000}, + {L"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "00000000000000000000000000000000000000000000000000000000", STATUS_INVALID_PARAMETER, 0xdead}, + }; NTSTATUS res; RTL_ATOM_TABLE AtomTable; RTL_ATOM testAtom; @@ -325,6 +372,46 @@ static void test_NtIntAtom(void)
res = RtlDestroyAtomTable( AtomTable ); ok( !res, "Unable to destroy atom table, retval: %lx\n", res ); + + + AtomTable = NULL; + res = RtlCreateAtomTable( 37, &AtomTable ); + ok(!res, "Unable to create atom table, %lx\n", res); + + res = RtlQueryAtomInAtomTable( AtomTable, 0, &RefCount, &PinCount, NULL, NULL ); + ok( res == STATUS_INVALID_PARAMETER, "got status %#lx\n", res ); + res = RtlQueryAtomInAtomTable( AtomTable, 1, &RefCount, &PinCount, NULL, NULL ); + ok( !res, "got status %#lx\n", res ); + ok( PinCount == 1, "Expected pincount 1 but got %lx\n", PinCount ); + ok( RefCount == 1, "Expected refcount 1 but got %lx\n", RefCount ); + res = RtlQueryAtomInAtomTable( AtomTable, 0xbfff, &RefCount, &PinCount, NULL, NULL ); + ok( !res, "got status %#lx\n", res ); + ok( PinCount == 1, "Expected pincount 1 but got %lx\n", PinCount ); + ok( RefCount == 1, "Expected refcount 1 but got %lx\n", RefCount ); + res = RtlQueryAtomInAtomTable( AtomTable, 0xc000, &RefCount, &PinCount, NULL, NULL ); + ok( res == STATUS_INVALID_HANDLE, "got status %#lx\n", res ); + + for (int i = 0; i < ARRAY_SIZE(integral_atom_tests); i++) + { + struct atom_test *test = integral_atom_tests + i; + + winetest_push_context( "%s", debugstr_w(test->str) ); + + testAtom = 0xdead; + res = RtlAddAtomToAtomTable( AtomTable, test->str, &testAtom ); + todo_wine_if( test->status == STATUS_ACCESS_VIOLATION ) + ok( res == test->status, "RtlAddAtomToAtomTable returned %#lx\n", res ); + todo_wine_if( test->value != 0xdead ) + ok( testAtom == test->value, "got %#x\n", testAtom ); + res = RtlDeleteAtomFromAtomTable( AtomTable, testAtom ); + if (testAtom && testAtom != 0xdead) todo_wine_if( testAtom < 0xc000 ) ok( !res, "RtlDeleteAtomFromAtomTable returned %#lx\n", res ); + else ok( res == STATUS_INVALID_HANDLE, "RtlDeleteAtomFromAtomTable returned %#lx\n", res ); + + winetest_pop_context(); + } + + res = RtlDestroyAtomTable( AtomTable ); + ok( !res, "Unable to destroy atom table, retval: %lx\n", res ); }
/* Tests to see how the pincount and refcount actually works */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/ntdll/atom.c | 6 +++--- dlls/ntdll/tests/atom.c | 1 - dlls/ntdll/unix/sync.c | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/atom.c b/dlls/ntdll/atom.c index 45f5771e252..9d611f2e7fd 100644 --- a/dlls/ntdll/atom.c +++ b/dlls/ntdll/atom.c @@ -145,10 +145,10 @@ static NTSTATUS is_integral_atom( LPCWSTR atomstr, size_t len, RTL_ATOM* pAtom ) if (len > MAX_ATOM_LEN) return STATUS_INVALID_PARAMETER; return STATUS_MORE_ENTRIES; } - else atom = LOWORD( atomstr ); + else if ((atom = LOWORD( atomstr )) >= MAXINTATOM) return STATUS_INVALID_PARAMETER; done: - if (!atom || atom >= MAXINTATOM) return STATUS_INVALID_PARAMETER; - *pAtom = atom; + if (atom >= MAXINTATOM) atom = 0; + if (!(*pAtom = atom)) return STATUS_INVALID_PARAMETER; return STATUS_SUCCESS; }
diff --git a/dlls/ntdll/tests/atom.c b/dlls/ntdll/tests/atom.c index 4fbf602ef20..bcb3a25daa9 100644 --- a/dlls/ntdll/tests/atom.c +++ b/dlls/ntdll/tests/atom.c @@ -401,7 +401,6 @@ static void test_NtIntAtom(void) res = RtlAddAtomToAtomTable( AtomTable, test->str, &testAtom ); todo_wine_if( test->status == STATUS_ACCESS_VIOLATION ) ok( res == test->status, "RtlAddAtomToAtomTable returned %#lx\n", res ); - todo_wine_if( test->value != 0xdead ) ok( testAtom == test->value, "got %#x\n", testAtom ); res = RtlDeleteAtomFromAtomTable( AtomTable, testAtom ); if (testAtom && testAtom != 0xdead) todo_wine_if( testAtom < 0xc000 ) ok( !res, "RtlDeleteAtomFromAtomTable returned %#lx\n", res ); diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index a16507155c8..4be22454369 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -2403,10 +2403,10 @@ static unsigned int is_integral_atom( const WCHAR *atomstr, ULONG len, RTL_ATOM if (len > MAX_ATOM_LEN) return STATUS_INVALID_PARAMETER; return STATUS_MORE_ENTRIES; } - else atom = LOWORD( atomstr ); + else if ((atom = LOWORD( atomstr )) >= MAXINTATOM) return STATUS_INVALID_PARAMETER; done: - if (!atom || atom >= MAXINTATOM) return STATUS_INVALID_PARAMETER; - *ret_atom = atom; + if (atom >= MAXINTATOM) atom = 0; + if (!(*ret_atom = atom)) return STATUS_INVALID_PARAMETER; return STATUS_SUCCESS; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/ntdll/atom.c | 5 +++-- dlls/ntdll/tests/atom.c | 2 +- dlls/ntdll/unix/sync.c | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/atom.c b/dlls/ntdll/atom.c index 9d611f2e7fd..d609904ddae 100644 --- a/dlls/ntdll/atom.c +++ b/dlls/ntdll/atom.c @@ -162,8 +162,9 @@ NTSTATUS WINAPI RtlDeleteAtomFromAtomTable( RTL_ATOM_TABLE table, RTL_ATOM atom
if ((status = lock_atom_table( table ))) return status;
- if (atom >= MAXINTATOM && RtlIsValidIndexHandle( &table->HandleTable, atom - MAXINTATOM, - (RTL_HANDLE **)&handle )) + if (!atom) status = STATUS_INVALID_HANDLE; + else if (atom < MAXINTATOM) status = STATUS_SUCCESS; + else if (RtlIsValidIndexHandle( &table->HandleTable, atom - MAXINTATOM, (RTL_HANDLE **)&handle )) { if (handle->entry->Flags) status = STATUS_WAS_LOCKED; else if (!--handle->entry->ReferenceCount) diff --git a/dlls/ntdll/tests/atom.c b/dlls/ntdll/tests/atom.c index bcb3a25daa9..8febaae4e6a 100644 --- a/dlls/ntdll/tests/atom.c +++ b/dlls/ntdll/tests/atom.c @@ -403,7 +403,7 @@ static void test_NtIntAtom(void) ok( res == test->status, "RtlAddAtomToAtomTable returned %#lx\n", res ); ok( testAtom == test->value, "got %#x\n", testAtom ); res = RtlDeleteAtomFromAtomTable( AtomTable, testAtom ); - if (testAtom && testAtom != 0xdead) todo_wine_if( testAtom < 0xc000 ) ok( !res, "RtlDeleteAtomFromAtomTable returned %#lx\n", res ); + if (testAtom && testAtom != 0xdead) ok( !res, "RtlDeleteAtomFromAtomTable returned %#lx\n", res ); else ok( res == STATUS_INVALID_HANDLE, "RtlDeleteAtomFromAtomTable returned %#lx\n", res );
winetest_pop_context(); diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index 4be22454369..3ad06e1f720 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -2455,7 +2455,9 @@ NTSTATUS WINAPI NtDeleteAtom( RTL_ATOM atom ) { unsigned int status;
- SERVER_START_REQ( delete_atom ) + if (!atom) status = STATUS_INVALID_HANDLE; + else if (atom < MAXINTATOM) status = STATUS_SUCCESS; + else SERVER_START_REQ( delete_atom ) { req->atom = atom; status = wine_server_call( req );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/user32/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/user32/class.c b/dlls/user32/class.c index 9c7bd3a5c6b..3ace0d5528f 100644 --- a/dlls/user32/class.c +++ b/dlls/user32/class.c @@ -52,7 +52,7 @@ ATOM get_int_atom_value( UNICODE_STRING *name ) { if (*ptr < '0' || *ptr > '9') return 0; ret = ret * 10 + *ptr++ - '0'; - if (ret > 0xffff) return 0; + if (ret >= MAXINTATOM) return 0; } return ret; }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index c62e920b77e..1180a62d055 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -297,7 +297,7 @@ ATOM get_int_atom_value( UNICODE_STRING *name ) { if (*ptr < '0' || *ptr > '9') return 0; ret = ret * 10 + *ptr++ - '0'; - if (ret > 0xffff) return 0; + if (ret >= MAXINTATOM) return 0; } return ret; }