ReactOS  0.4.13-dev-479-gec9c8fd
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))
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
int WINAPI SHIM_OBJ_NAME() SHStringFromGUIDA(REFGUID guid, LPSTR lpszDest, INT cchMax)
Definition: shimtest.c:51
const char * PCSTR
Definition: typedefs.h:51

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:");
45  StringCchLengthA(lpBuffer, *lpnSize, &cchLen);
46  *lpnSize = (DWORD)cchLen;
47  return TRUE;
48 }
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
#define DWORD
Definition: nt_native.h:44
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
static LPSTR PULONG lpnSize
Definition: secur32.c:50
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
STRSAFEAPI StringCchLengthA(STRSAFE_LPCSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:832
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by CookupNodeId(), ElfReportEventA(), find_local_server(), is_local_machineA(), ncacn_pipe_name(), PrintSystemInfo(), rpcrt4_ncacn_np_handoff(), rpcrt4_ncalrpc_handoff(), test_GetComputerName(), test_GetLongPathNameA(), test_LookupAccountName(), test_MsiSourceListAddSource(), 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 TRUE
Definition: types.h:120
#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 }
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