ReactOS  0.4.14-dev-583-g2a1ba2c
genral_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 genral_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 (genral_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 genral_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 55 of file genral_hooks.c.

56 {
57  DWORD num;
58  for (num = 0; num < _countof(data->hooks) && data->hooks[num].Library;)
59  {
60  ++num;
61  }
62  return num;
63 }
#define _countof(array)
Definition: fontsub.cpp:30
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

Referenced by START_TEST().

◆ safe_str()

static const char* safe_str ( const char ptr)
static

Definition at line 65 of file genral_hooks.c.

66 {
67  static char buffer[2][30];
68  static int index = 0;
69  if (HIWORD(ptr))
70  return ptr;
71 
72  index ^= 1;
74  return buffer[index];
75 }
#define _countof(array)
Definition: fontsub.cpp:30
GLuint buffer
Definition: glext.h:5915
static PVOID ptr
Definition: dispmode.c:27
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:520
GLuint index
Definition: glext.h:6031
int intptr_t
Definition: crtdefs.h:283
#define index(s, c)
Definition: various.h:29
#define HIWORD(l)
Definition: typedefs.h:246

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( genral_hooks  )

Definition at line 77 of file genral_hooks.c.

78 {
79  RTL_OSVERSIONINFOEXW rtlinfo = {0};
80  size_t n, h;
81 
82  tGETHOOKAPIS pGetHookAPIs = LoadShimDLL2(L"AcGenral.dll");
83  if (!pGetHookAPIs)
84  return;
85 
86  rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
88  g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
89 
90 
91 
92  for (n = 0; n < _countof(data); ++n)
93  {
95  DWORD num_shims = 0, expected_shims = count_shims(current);
96 
97  PHOOKAPI hook = pGetHookAPIs("", current->ShimName, &num_shims);
98 
99  if (current->MinVersion > g_WinVersion && !hook)
100  {
101  skip("Shim %s not present\n", wine_dbgstr_w(current->ShimName));
102  continue;
103  }
104 
105  ok(!!hook, "Expected a valid pointer, got nothing for %s\n", wine_dbgstr_w(current->ShimName));
106  ok(num_shims == expected_shims, "Expected %u shims, got %u for %s\n",
107  expected_shims, num_shims, wine_dbgstr_w(current->ShimName));
108  for (h = 0; h < min(num_shims, expected_shims); ++h)
109  {
110  expect_shim_hook* expect_hk = current->hooks + h;
111  PHOOKAPI got_hk = hook+h;
112  int lib = lstrcmpA(expect_hk->Library, got_hk->LibraryName);
113  int fn = lstrcmpA(safe_str(expect_hk->Function), safe_str(got_hk->FunctionName));
114  ok(lib == 0, "Expected LibraryName to be %s, was: %s for %s\n",
115  expect_hk->Library, got_hk->LibraryName, wine_dbgstr_w(current->ShimName));
116  ok(fn == 0, "Expected FunctionName to be %s, was: %s for %s\n",
117  safe_str(expect_hk->Function), safe_str(got_hk->FunctionName), wine_dbgstr_w(current->ShimName));
118  }
119  if (num_shims > expected_shims)
120  {
121  for (h = expected_shims; h < num_shims; ++h)
122  {
123  PHOOKAPI got_hk = hook+h;
124 
125  ok(0, "Extra shim: %s!%s for %s\n",
126  got_hk->LibraryName, safe_str(got_hk->FunctionName), wine_dbgstr_w(current->ShimName));
127  }
128  }
129  else
130  {
131  for (h = num_shims; h < expected_shims; ++h)
132  {
133  expect_shim_hook* expect_hk = current->hooks + h;
134 
135  ok(0, "Missing shim: %s!%s for %s\n",
136  expect_hk->Library, safe_str(expect_hk->Function), wine_dbgstr_w(current->ShimName));
137  }
138  }
139  }
140 }
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:265
const char * Library
Definition: genral_hooks.c:22
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
ULONG dwMinorVersion
Definition: rtltypes.h:267
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
PCSTR LibraryName
Definition: shimlib.h:18
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define _countof(array)
Definition: fontsub.cpp:30
GLdouble n
Definition: glext.h:7729
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
ULONG dwMajorVersion
Definition: rtltypes.h:266
static DWORD count_shims(expect_shim_data *data)
Definition: genral_hooks.c:55
tGETHOOKAPIS LoadShimDLL2(PCWSTR ShimDll)
Definition: versionlie.c:365
const char * Function
Definition: genral_hooks.c:23
static const char * safe_str(const char *ptr)
Definition: genral_hooks.c:65
Definition: msg.h:42
PHOOKAPI(WINAPI * tGETHOOKAPIS)(LPCSTR szCommandLine, LPCWSTR wszShimName, PDWORD pdwHookCount)
#define for
Definition: utility.h:88
unsigned long DWORD
Definition: ntddk_ex.h:95
static tGETHOOKAPIS pGetHookAPIs
Definition: dispmode.c:26
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const WCHAR L[]
Definition: oid.c:1250
#define ok(value,...)
Definition: atltest.h:57
PCSTR FunctionName
Definition: shimlib.h:19
#define min(a, b)
Definition: monoChain.cc:55
#define skip(...)
Definition: atltest.h:64
static DWORD g_WinVersion
Definition: genral_hooks.c:17
struct task_struct * current
Definition: linux.c:32

Variable Documentation

◆ data

Initial value:
=
{
{
L"IgnoreChromeSandbox",
{
{ "KERNEL32.DLL", "CreateProcessW" },
}
},
{
L"AddProcessParametersFlags",
0,
},
{
L"DisableThemes",
0,
},
}
#define _WIN32_WINNT_WIN8
Definition: sdkddkver.h:29
static const WCHAR L[]
Definition: oid.c:1250

Definition at line 34 of file genral_hooks.c.

◆ g_WinVersion

DWORD g_WinVersion
static

Definition at line 17 of file genral_hooks.c.

Referenced by START_TEST().