user32/tests: initial hotpatch testing
André Hentschel
nerv at dawncrow.de
Sun Jun 12 13:36:05 CDT 2011
---
dlls/user32/tests/Makefile.in | 1 +
dlls/user32/tests/hotpatch.c | 67 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 0 deletions(-)
create mode 100644 dlls/user32/tests/hotpatch.c
diff --git a/dlls/user32/tests/Makefile.in b/dlls/user32/tests/Makefile.in
index eb5789a..2e2a2a1 100644
--- a/dlls/user32/tests/Makefile.in
+++ b/dlls/user32/tests/Makefile.in
@@ -12,6 +12,7 @@ C_SRCS = \
dialog.c \
edit.c \
generated.c \
+ hotpatch.c \
input.c \
listbox.c \
menu.c \
diff --git a/dlls/user32/tests/hotpatch.c b/dlls/user32/tests/hotpatch.c
new file mode 100644
index 0000000..0729533
--- /dev/null
+++ b/dlls/user32/tests/hotpatch.c
@@ -0,0 +1,67 @@
+/* Unit test suite for hookable prolog.
+ *
+ * Copyright 2011, André Hentschel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <windows.h>
+#include "wine/test.h"
+
+static void test_hotpatch(void)
+{
+#ifdef __i386__
+ HMODULE user32 = LoadLibraryA("user32.dll");
+ LPCSTR proc[]=
+ {
+ "DispatchMessageA",
+ "DispatchMessageW",
+ "GetAsyncKeyState",
+ "GetCursorPos",
+ "GetKeyState",
+ "GetMessageA",
+ "GetMessageW",
+ "GetRawInputBuffer",
+ "PeekMessageA",
+ "PeekMessageW",
+ "SetCursorPos",
+ "ShowCursor",
+ };
+ DWORD i;
+ void *ptr;
+ /* see git://github.com/atgreen/moxiedev.git/gcc/gcc/testsuite/gcc.target/i386/ms_hook_prologue.c */
+ BYTE hotpatch_prolog[] = {0x8B, 0xFF, 0x55, 0x8B, 0xEC};
+
+ /* expect the first one to be valid */
+ ptr = (void *)GetProcAddress(user32, proc[0]);
+ if (!ptr || memcmp(ptr, hotpatch_prolog, sizeof(hotpatch_prolog)))
+ {
+ skip( "Hotpatching not supported\n" );
+ return;
+ }
+
+ for(i = 1; i < sizeof(proc) / sizeof(proc[0]); i++)
+ {
+ if (!(ptr = (void *)GetProcAddress(user32, proc[i]))) continue;
+ ok(!memcmp(ptr, hotpatch_prolog, sizeof(hotpatch_prolog)),
+ "Hotpatching not supported for %s\n", proc[i]);
+ }
+#endif
+}
+
+START_TEST(hotpatch)
+{
+ test_hotpatch();
+}
--
Best Regards, André Hentschel
More information about the wine-patches
mailing list