Author: mjansen
Date: Thu Aug 17 11:06:46 2017
New Revision: 75587
URL:
http://svn.reactos.org/svn/reactos?rev=75587&view=rev
Log:
[ADVAPI32_APITEST] Addendum to 75585, use void pointers to work around gcc ignoring
pshpack1.
Modified:
trunk/rostests/apitests/advapi32/RegOpenKeyExW.c
Modified: trunk/rostests/apitests/advapi32/RegOpenKeyExW.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/RegOpen…
==============================================================================
--- trunk/rostests/apitests/advapi32/RegOpenKeyExW.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/RegOpenKeyExW.c [iso-8859-1] Thu Aug 17 11:06:46
2017
@@ -2,25 +2,12 @@
* PROJECT: ReactOS api tests
* LICENSE: GPLv2+ - See COPYING in the top level directory
* PURPOSE: Test for the RegOpenKeyExW alignment
- * PROGRAMMER: Mark Jansen <mark.jansen(a)reactos.org>
+ * PROGRAMMER: Mark Jansen (mark.jansen(a)reactos.org)
*/
#include <apitest.h>
#define WIN32_NO_STATUS
#include <winreg.h>
-
-#include <pshpack1.h>
-struct Unalignment1
-{
- char dum;
- WCHAR buffer[20];
-} Unalignment1;
-struct Unalignment2
-{
- char dum;
- HKEY hk;
-} Unalignment2;
-#include <poppack.h>
#define TEST_STR L".exe"
@@ -28,13 +15,14 @@
START_TEST(RegOpenKeyExW)
{
- struct Unalignment1 un;
- struct Unalignment2 un2;
+ char GccShouldNotAlignThis[20 * 2];
+ char GccShouldNotAlignThis2[20];
+ PVOID Alias = GccShouldNotAlignThis + 1;
+ PVOID UnalignedKey = GccShouldNotAlignThis2 + 1;
HKEY hk;
LONG lRes;
- memcpy(un.buffer, TEST_STR, sizeof(TEST_STR));
- un2.hk = 0;
+ memcpy(Alias, TEST_STR, sizeof(TEST_STR));
lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, TEST_STR, 0, KEY_READ, &hk);
ok_int(lRes, ERROR_SUCCESS);
@@ -42,18 +30,17 @@
return;
RegCloseKey(hk);
- ok_hex(((ULONG_PTR)un.buffer) % 2, 1);
- lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, un.buffer, 0, KEY_READ, &hk);
+ ok_hex(((ULONG_PTR)Alias) % 2, 1);
+ lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, Alias, 0, KEY_READ, &hk);
ok_int(lRes, ERROR_SUCCESS);
if (!lRes)
RegCloseKey(hk);
- ok_hex(((ULONG_PTR)&un2.hk) % 2, 1);
- lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, TEST_STR, 0, KEY_READ, &un2.hk);
+ ok_hex(((ULONG_PTR)UnalignedKey) % 2, 1);
+ lRes = RegOpenKeyExW(HKEY_CLASSES_ROOT, TEST_STR, 0, KEY_READ, UnalignedKey);
ok_int(lRes, ERROR_SUCCESS);
if (!lRes)
{
- hk = un2.hk;
- RegCloseKey(hk);
+ RegCloseKey(*(HKEY*)(UnalignedKey));
}
}