ReactOS 0.4.15-dev-8241-g63935f8
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[] 
)

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  guid,
LPSTR  lpszDest,
INT  cchMax 
)

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}
UINT cchMax
WCHAR lpszDest[260]
Definition: bufpool.h:45
const GUID * guid
#define SHIM_INFO(fmt,...)
Definition: sdbpapi.h:78
INT(WINAPI * tSHStringFromGUIDA)(REFGUID guid, LPSTR lpszDest, INT cchMax)
Definition: shimtest.c:50
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:320
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
char CHAR
Definition: xmlstorage.h:175

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];
32 BOOL (WINAPI *p_GetComputerNameA)(LPSTR lpBuffer, LPDWORD lpnSize);
33
34 /* Call it directly */
35 ZeroMemory(buf, sizeof(buf));
36 dwSize = sizeof(buf);
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}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static int mod
Definition: i386-dis.c:1288
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define BOOL
Definition: nt_native.h:43
static LPSTR PULONG lpnSize
Definition: secur32.c:50
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
uint32_t * LPDWORD
Definition: typedefs.h:59
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
char * LPSTR
Definition: xmlstorage.h:182

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;
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}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define INT
Definition: polytest.cpp:20
INT WINAPI SHStringFromGUIDA(REFGUID, LPSTR, INT)
Definition: shimtest.c:51
#define _countof(array)
Definition: sndvol32.h:70
Definition: scsiwmi.h:51
int32_t INT
Definition: typedefs.h:58
const char * LPCSTR
Definition: xmlstorage.h:183

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}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
#define DPFLTR_ERROR_LEVEL
Definition: shimtest_ros.c:15
Definition: dsound.c:943
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

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