ReactOS 0.4.16-dev-295-g4aee028
shimtest.c File Reference
#include <windef.h>
#include <winbase.h>
#include <shimlib.h>
#include <strsafe.h>
#include <setup_shim.inl>
#include <implement_shim.inl>
Include dependency graph for shimtest.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define SHIM_NS   ShimTest
 
#define SHIM_NOTIFY_FN   SHIM_OBJ_NAME(Notify)
 
#define SHIM_NUM_HOOKS   2
 
#define SHIM_SETUP_HOOKS
 

Typedefs

typedef BOOL(WINAPItGetComputerNameA) (LPSTR lpBuffer, LPDWORD lpnSize)
 
typedef INT(WINAPItSHStringFromGUIDA) (REFGUID guid, LPSTR lpszDest, INT cchMax)
 

Functions

BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA (LPSTR lpBuffer, LPDWORD lpnSize)
 
int WINAPI SHIM_OBJ_NAME() SHStringFromGUIDA (REFGUID guid, LPSTR lpszDest, INT cchMax)
 
BOOL WINAPI SHIM_OBJ_NAME() Notify (DWORD fdwReason, PVOID ptr)
 

Macro Definition Documentation

◆ SHIM_NOTIFY_FN

#define SHIM_NOTIFY_FN   SHIM_OBJ_NAME(Notify)

Definition at line 80 of file shimtest.c.

◆ SHIM_NS

#define SHIM_NS   ShimTest

Definition at line 15 of file shimtest.c.

◆ SHIM_NUM_HOOKS

#define SHIM_NUM_HOOKS   2

Definition at line 81 of file shimtest.c.

◆ SHIM_SETUP_HOOKS

#define SHIM_SETUP_HOOKS
Value:
SHIM_HOOK(0, "KERNEL32.DLL", "GetComputerNameA", SHIM_OBJ_NAME(GetComputerNameA)) \
SHIM_HOOK(1, "SHLWAPI.DLL", (PCSTR)23, SHIM_OBJ_NAME(SHStringFromGUIDA))
int WINAPI SHIM_OBJ_NAME() SHStringFromGUIDA(REFGUID guid, LPSTR lpszDest, INT cchMax)
Definition: shimtest.c:51
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
const char * PCSTR
Definition: typedefs.h:52

Definition at line 82 of file shimtest.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 8 of file shimtest.c.

Typedef Documentation

◆ tGetComputerNameA

typedef BOOL(WINAPI * tGetComputerNameA) (LPSTR lpBuffer, LPDWORD lpnSize)

Definition at line 19 of file shimtest.c.

◆ tSHStringFromGUIDA

typedef INT(WINAPI * tSHStringFromGUIDA) (REFGUID guid, LPSTR lpszDest, INT cchMax)

Definition at line 50 of file shimtest.c.

Function Documentation

◆ GetComputerNameA()

BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA ( LPSTR  lpBuffer,
LPDWORD  lpnSize 
)

Definition at line 21 of file shimtest.c.

22{
23 CHAR Buffer[100] = {0};
24 DWORD dwSize = sizeof(Buffer) - 1;
25 size_t cchLen;
26
27 if (CALL_SHIM(0, tGetComputerNameA)(Buffer, &dwSize))
28 {
29 SHIM_INFO("Original function returned: '%s'\n", Buffer);
30 }
31 else
32 {
33 SHIM_INFO("Original function failed\n");
34 Buffer[0] = '\0';
35 }
36
37 if (!lpnSize)
38 {
39 SHIM_WARN("No lpnSize\n");
40 return FALSE;
41 }
42
43 StringCchCopyA(lpBuffer, *lpnSize, "ShimTest:");
46 *lpnSize = (DWORD)cchLen;
47 return TRUE;
48}
Definition: bufpool.h:45
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define DWORD
Definition: nt_native.h:44
#define SHIM_INFO(fmt,...)
Definition: sdbpapi.h:78
#define SHIM_WARN(fmt,...)
Definition: sdbpapi.h:77
static LPSTR PULONG lpnSize
Definition: secur32.c:50
BOOL(WINAPI * tGetComputerNameA)(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:19
STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:320
STRSAFEAPI StringCchLengthA(STRSAFE_LPCSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:832
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
char CHAR
Definition: xmlstorage.h:175

Referenced by CookupNodeId(), ElfReportEventA(), find_local_server(), SEALED_::IMsTscAx::Connect(), is_local_machineA(), ncacn_pipe_name(), PrintSystemInfo(), rpcrt4_ncacn_np_handoff(), rpcrt4_ncalrpc_handoff(), test_GetComputerName(), test_GetLongPathNameA(), test_LookupAccountName(), test_normal_imports(), test_readwrite(), test_regconnectregistry(), and wWinMain().

◆ Notify()

BOOL WINAPI SHIM_OBJ_NAME() Notify ( DWORD  fdwReason,
PVOID  ptr 
)

Definition at line 71 of file shimtest.c.

72{
73 if (fdwReason == SHIM_REASON_INIT)
74 {
75 SHIM_MSG("SHIM_REASON_INIT\n");
76 }
77 return TRUE;
78}
#define SHIM_REASON_INIT
Definition: shimlib.h:45
#define SHIM_MSG(fmt,...)
Definition: shimlib.h:75

◆ SHStringFromGUIDA()

int WINAPI SHIM_OBJ_NAME() 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]
const GUID * guid
INT(WINAPI * tSHStringFromGUIDA)(REFGUID guid, LPSTR lpszDest, INT cchMax)
Definition: shimtest.c:50