ReactOS 0.4.15-dev-7953-g1f49173
layer_hooks.c File Reference
#include <ntstatus.h>
#include <windows.h>
#include <ndk/rtlfuncs.h>
#include <strsafe.h>
#include "wine/test.h"
#include "appshim_apitest.h"
Include dependency graph for layer_hooks.c:

Go to the source code of this file.

Classes

struct  expect_shim_hook
 
struct  expect_shim_data
 

Macros

#define WIN32_NO_STATUS
 

Typedefs

typedef struct expect_shim_hook expect_shim_hook
 
typedef struct expect_shim_data expect_shim_data
 

Functions

static DWORD count_shims (expect_shim_data *data)
 
static const charsafe_str (const char *ptr)
 
 START_TEST (layer_hooks)
 

Variables

static DWORD g_WinVersion
 
static expect_shim_data data []
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 9 of file layer_hooks.c.

Typedef Documentation

◆ expect_shim_data

◆ expect_shim_hook

Function Documentation

◆ count_shims()

static DWORD count_shims ( expect_shim_data data)
static

Definition at line 67 of file layer_hooks.c.

68{
69 DWORD num;
70 for (num = 0; num < _countof(data->hooks) && data->hooks[num].Library;)
71 {
72 ++num;
73 }
74 return num;
75}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint GLuint num
Definition: glext.h:9618
#define _countof(array)
Definition: sndvol32.h:68

Referenced by START_TEST().

◆ safe_str()

static const char * safe_str ( const char ptr)
static

Definition at line 77 of file layer_hooks.c.

78{
79 static char buffer[2][30];
80 static int index = 0;
81 if (HIWORD(ptr))
82 return ptr;
83
84 index ^= 1;
86 return buffer[index];
87}
#define index(s, c)
Definition: various.h:29
int intptr_t
Definition: crtdefs.h:304
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
static PVOID ptr
Definition: dispmode.c:27
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:520
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( layer_hooks  )

Definition at line 89 of file layer_hooks.c.

90{
91 RTL_OSVERSIONINFOEXW rtlinfo = {0};
92 size_t n, h;
93
94 tGETHOOKAPIS pGetHookAPIs = LoadShimDLL2(L"AcLayers.dll");
95 if (!pGetHookAPIs)
96 return;
97
98 rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
100 g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
101
102
103
104 for (n = 0; n < _countof(data); ++n)
105 {
107 DWORD num_shims = 0, expected_shims = count_shims(current);
108
109 PHOOKAPI hook = pGetHookAPIs("", current->ShimName, &num_shims);
110
111 if (current->MinVersion > g_WinVersion && !hook)
112 {
113 skip("Shim %s not present\n", wine_dbgstr_w(current->ShimName));
114 continue;
115 }
116
117 ok(!!hook, "Expected a valid pointer, got nothing for %s\n", wine_dbgstr_w(current->ShimName));
118 ok(num_shims == expected_shims, "Expected %u shims, got %u for %s\n",
119 expected_shims, num_shims, wine_dbgstr_w(current->ShimName));
120 for (h = 0; h < min(num_shims, expected_shims); ++h)
121 {
122 expect_shim_hook* expect_hk = current->hooks + h;
123 PHOOKAPI got_hk = hook+h;
124 int lib = lstrcmpA(expect_hk->Library, got_hk->LibraryName);
125 int fn = lstrcmpA(safe_str(expect_hk->Function), safe_str(got_hk->FunctionName));
126 ok(lib == 0, "Expected LibraryName to be %s, was: %s for %s\n",
127 expect_hk->Library, got_hk->LibraryName, wine_dbgstr_w(current->ShimName));
128 ok(fn == 0, "Expected FunctionName to be %s, was: %s for %s\n",
129 safe_str(expect_hk->Function), safe_str(got_hk->FunctionName), wine_dbgstr_w(current->ShimName));
130 }
131 if (num_shims > expected_shims)
132 {
133 for (h = expected_shims; h < num_shims; ++h)
134 {
135 PHOOKAPI got_hk = hook+h;
136
137 ok(0, "Extra shim: %s!%s for %s\n",
138 got_hk->LibraryName, safe_str(got_hk->FunctionName), wine_dbgstr_w(current->ShimName));
139 }
140 }
141 else
142 {
143 for (h = num_shims; h < expected_shims; ++h)
144 {
145 expect_shim_hook* expect_hk = current->hooks + h;
146
147 ok(0, "Missing shim: %s!%s for %s\n",
148 expect_hk->Library, safe_str(expect_hk->Function), wine_dbgstr_w(current->ShimName));
149 }
150 }
151 }
152}
@ hook
Definition: SystemMenu.c:35
PHOOKAPI(WINAPI * tGETHOOKAPIS)(LPCSTR szCommandLine, LPCWSTR wszShimName, PDWORD pdwHookCount)
tGETHOOKAPIS LoadShimDLL2(PCWSTR ShimDll)
Definition: versionlie.c:369
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
GLdouble n
Definition: glext.h:7729
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define wine_dbgstr_w
Definition: kernel32.h:34
static DWORD count_shims(expect_shim_data *data)
Definition: layer_hooks.c:67
static const char * safe_str(const char *ptr)
Definition: layer_hooks.c:77
static DWORD g_WinVersion
Definition: layer_hooks.c:17
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
struct task_struct * current
Definition: linux.c:32
#define for
Definition: utility.h:88
static tGETHOOKAPIS pGetHookAPIs
Definition: dispmode.c:26
#define min(a, b)
Definition: monoChain.cc:55
#define L(x)
Definition: ntvdm.h:50
ULONG dwMajorVersion
Definition: rtltypes.h:270
ULONG dwMinorVersion
Definition: rtltypes.h:271
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:269
const char * Function
Definition: genral_hooks.c:23
const char * Library
Definition: genral_hooks.c:22
PCSTR LibraryName
Definition: shimlib.h:18
PCSTR FunctionName
Definition: shimlib.h:19
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159

Variable Documentation

◆ data

Definition at line 34 of file layer_hooks.c.

◆ g_WinVersion

DWORD g_WinVersion
static

Definition at line 17 of file layer_hooks.c.

Referenced by START_TEST().