ReactOS  0.4.14-dev-323-g6fe6a88
shimtest_ros.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <ntndk.h>
#include <winbase.h>
Include dependency graph for shimtest_ros.c:

Go to the source code of this file.

Macros

#define DPFLTR_ERROR_LEVEL   0
 

Functions

NTSYSAPI ULONG NTAPI vDbgPrintEx (_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
 
void xprintf (const char *fmt,...)
 
void test_normal_imports ()
 
INT WINAPI SHStringFromGUIDA (REFGUID, LPSTR, INT)
 
void test_ordinal_imports ()
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ DPFLTR_ERROR_LEVEL

#define DPFLTR_ERROR_LEVEL   0

Definition at line 15 of file shimtest_ros.c.

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com

Definition at line 112 of file shimtest_ros.c.

113 {
114  xprintf("Normal import (kernel32!GetComputerNameA)\n");
116  xprintf("\nOrdinal import (shlwapi!#23)\n");
118 
119  return 0;
120 }
void test_normal_imports()
Definition: shimtest_ros.c:27
void xprintf(const char *fmt,...)
Definition: shimtest_ros.c:17
void test_ordinal_imports()
Definition: shimtest_ros.c:69

◆ SHStringFromGUIDA()

INT WINAPI SHStringFromGUIDA ( REFGUID  ,
LPSTR  ,
INT   
)

Definition at line 51 of file shimtest.c.

52 {
53  CHAR Buffer[100] = {0};
54 
55  if (CALL_SHIM(1, tSHStringFromGUIDA)(guid, Buffer, sizeof(Buffer)-1))
56  {
57  SHIM_INFO("Original function returned: '%s'\n", Buffer);
58  }
59  else
60  {
61  SHIM_INFO("Original function failed\n");
62  Buffer[0] = '\0';
63  }
64 
65  StringCchCopyA(lpszDest, cchMax, "ShimTest:");
67  return 0;
68 }
char CHAR
Definition: xmlstorage.h:175
const GUID * guid
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:320
WCHAR lpszDest[260]
Definition: bufpool.h:45
INT(WINAPI * tSHStringFromGUIDA)(REFGUID guid, LPSTR lpszDest, INT cchMax)
Definition: shimtest.c:50
UINT cchMax
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145

Referenced by SHPinDllOfCLSID(), and test_ordinal_imports().

◆ test_normal_imports()

void test_normal_imports ( )

Definition at line 27 of file shimtest_ros.c.

28 {
29  char buf[100];
30  DWORD dwSize;
31  HMODULE mod;
32  BOOL (WINAPI *p_GetComputerNameA)(LPSTR lpBuffer, LPDWORD lpnSize);
33 
34  /* Call it directly */
35  ZeroMemory(buf, sizeof(buf));
36  dwSize = sizeof(buf);
37  if (!GetComputerNameA(buf, &dwSize))
38  {
39  xprintf("GetComputerNameA failed: %d\n", GetLastError());
40  }
41  else
42  {
43  xprintf("GetComputerNameA returned: '%s'\n", buf);
44  }
45 
46  /* Call it using GetProcAddress */
47  mod = GetModuleHandleA("kernel32.dll");
48  p_GetComputerNameA = (void*)GetProcAddress(mod, "GetComputerNameA");
49  if (p_GetComputerNameA == NULL)
50  {
51  xprintf("GetProcAddress failed: %d\n", GetLastError());
52  }
53  else
54  {
55  ZeroMemory(buf, sizeof(buf));
56  dwSize = sizeof(buf);
57  if (!p_GetComputerNameA(buf, &dwSize))
58  {
59  xprintf("p_GetComputerNameA failed: %d\n", GetLastError());
60  }
61  else
62  {
63  xprintf("p_GetComputerNameA returned: '%s'\n", buf);
64  }
65  }
66 }
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
char * LPSTR
Definition: xmlstorage.h:182
#define BOOL
Definition: nt_native.h:43
static LPSTR PULONG lpnSize
Definition: secur32.c:50
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
void xprintf(const char *fmt,...)
Definition: shimtest_ros.c:17
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
uint32_t * LPDWORD
Definition: typedefs.h:57
#define GetProcAddress(x, y)
Definition: compat.h:410
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
static int mod
Definition: i386-dis.c:1273

Referenced by main().

◆ test_ordinal_imports()

void test_ordinal_imports ( )

Definition at line 69 of file shimtest_ros.c.

70 {
71  GUID guid = { 0x11223344, 0x5566, 0x7788 };
72  char buf[100];
73  int r;
74  HMODULE mod;
75  INT (WINAPI *p_SHStringFromGUIDA)(REFGUID guid, LPSTR lpszDest, INT cchMax);
76 
77  /* Call it directly */
78  ZeroMemory(buf, sizeof(buf));
80  if (r)
81  {
82  xprintf("SHStringFromGUIDA failed (%d)\n", r);
83  }
84  else
85  {
86  xprintf("SHStringFromGUIDA returned: '%s'\n", buf);
87  }
88 
89  /* Call it using GetProcAddress */
90  mod = GetModuleHandleA("shlwapi.dll");
91  p_SHStringFromGUIDA = (void*)GetProcAddress(mod, (LPCSTR)23);
92  if (p_SHStringFromGUIDA == NULL)
93  {
94  xprintf("GetProcAddress failed: %d\n", GetLastError());
95  }
96  else
97  {
98  ZeroMemory(buf, sizeof(buf));
99  r = p_SHStringFromGUIDA(&guid, buf, _countof(buf)-1);
100  if (r)
101  {
102  xprintf("p_SHStringFromGUIDA failed (%d)\n", r);
103  }
104  else
105  {
106  xprintf("p_SHStringFromGUIDA returned: '%s'\n", buf);
107  }
108  }
109 }
INT WINAPI SHStringFromGUIDA(REFGUID, LPSTR, INT)
Definition: shimtest.c:51
Definition: scsiwmi.h:51
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define _countof(array)
Definition: fontsub.cpp:30
#define INT
Definition: polytest.cpp:20
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1642
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
const GUID * guid
smooth NULL
Definition: ftsmooth.c:416
WCHAR lpszDest[260]
const char * LPCSTR
Definition: xmlstorage.h:183
void xprintf(const char *fmt,...)
Definition: shimtest_ros.c:17
#define WINAPI
Definition: msvc.h:8
UINT cchMax
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
#define GetProcAddress(x, y)
Definition: compat.h:410
static int mod
Definition: i386-dis.c:1273

Referenced by main().

◆ vDbgPrintEx()

NTSYSAPI ULONG NTAPI vDbgPrintEx ( _In_ ULONG  ComponentId,
_In_ ULONG  Level,
_In_z_ PCCH  Format,
_In_ va_list  ap 
)

Referenced by xprintf().

◆ xprintf()

void xprintf ( const char fmt,
  ... 
)

Definition at line 17 of file shimtest_ros.c.

18 {
19  va_list ap;
20 
21  va_start(ap, fmt);
22  vprintf(fmt, ap);
24  va_end(ap);
25 }
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
#define DPFLTR_ERROR_LEVEL
Definition: shimtest_ros.c:15
#define va_start(ap, A)
Definition: acmsvcex.h:91
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
Definition: dsound.c:943

Referenced by main(), test_normal_imports(), and test_ordinal_imports().