[ACGENRAL] Add a test shim

This commit is contained in:
Mark Jansen 2019-04-30 22:51:28 +02:00
parent 0e9ca37517
commit 575ab6c760
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
3 changed files with 103 additions and 0 deletions

View file

@ -7,6 +7,7 @@ list(APPEND SOURCE
ignoredbgout.c ignoredbgout.c
ignorefreelib.c ignorefreelib.c
main.c main.c
shimtest.c
themes.c themes.c
genral.spec) genral.spec)

View file

@ -0,0 +1,88 @@
/*
* PROJECT: ReactOS 'General' Shim library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Test shim used to verify the inner working of the shim engine
* COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
*/
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
#include <shimlib.h>
#include <strsafe.h>
#define SHIM_NS ShimTest
#include <setup_shim.inl>
typedef BOOL (WINAPI *tGetComputerNameA)(LPSTR lpBuffer, LPDWORD lpnSize);
BOOL WINAPI SHIM_OBJ_NAME(GetComputerNameA)(LPSTR lpBuffer, LPDWORD lpnSize)
{
CHAR Buffer[100] = {0};
DWORD dwSize = sizeof(Buffer) - 1;
size_t cchLen;
if (CALL_SHIM(0, tGetComputerNameA)(Buffer, &dwSize))
{
SHIM_INFO("Original function returned: '%s'\n", Buffer);
}
else
{
SHIM_INFO("Original function failed\n");
Buffer[0] = '\0';
}
if (!lpnSize)
{
SHIM_WARN("No lpnSize\n");
return FALSE;
}
StringCchCopyA(lpBuffer, *lpnSize, "ShimTest:");
StringCchCatA(lpBuffer, *lpnSize, Buffer);
StringCchLengthA(lpBuffer, *lpnSize, &cchLen);
*lpnSize = (DWORD)cchLen;
return TRUE;
}
typedef INT (WINAPI *tSHStringFromGUIDA)(REFGUID guid, LPSTR lpszDest, INT cchMax);
int WINAPI SHIM_OBJ_NAME(SHStringFromGUIDA)(REFGUID guid, LPSTR lpszDest, INT cchMax)
{
CHAR Buffer[100] = {0};
if (CALL_SHIM(1, tSHStringFromGUIDA)(guid, Buffer, sizeof(Buffer)-1))
{
SHIM_INFO("Original function returned: '%s'\n", Buffer);
}
else
{
SHIM_INFO("Original function failed\n");
Buffer[0] = '\0';
}
StringCchCopyA(lpszDest, cchMax, "ShimTest:");
StringCchCatA(lpszDest, cchMax, Buffer);
return 0;
}
BOOL WINAPI SHIM_OBJ_NAME(Notify)(DWORD fdwReason, PVOID ptr)
{
if (fdwReason == SHIM_REASON_INIT)
{
SHIM_MSG("SHIM_REASON_INIT\n");
}
return TRUE;
}
#define SHIM_NOTIFY_FN SHIM_OBJ_NAME(Notify)
#define SHIM_NUM_HOOKS 2
#define SHIM_SETUP_HOOKS \
SHIM_HOOK(0, "KERNEL32.DLL", "GetComputerNameA", SHIM_OBJ_NAME(GetComputerNameA)) \
SHIM_HOOK(1, "SHLWAPI.DLL", (PCSTR)23, SHIM_OBJ_NAME(SHStringFromGUIDA))
#include <implement_shim.inl>

View file

@ -225,6 +225,10 @@
<SHIM NAME="IgnoreLoadLibrary"> <SHIM NAME="IgnoreLoadLibrary">
<DLLFILE>aclayers.dll</DLLFILE> <DLLFILE>aclayers.dll</DLLFILE>
</SHIM> </SHIM>
<SHIM NAME="ShimTest">
<DLLFILE>acgenral.dll</DLLFILE>
<DESCRIPTION>Shim used to test ReactOS shim engine functionality</DESCRIPTION>
</SHIM>
<SHIM NAME="VMHorizonSetup"> <SHIM NAME="VMHorizonSetup">
<DLLFILE>aclayers.dll</DLLFILE> <DLLFILE>aclayers.dll</DLLFILE>
</SHIM> </SHIM>
@ -405,5 +409,15 @@
<SHIM_REF NAME="IgnoreFreeLibrary" COMMAND_LINE="libpng12.dll" /> <SHIM_REF NAME="IgnoreFreeLibrary" COMMAND_LINE="libpng12.dll" />
</EXE> </EXE>
<!-- ReactOS shim used to test the shim engine -->
<EXE NAME="shimtest_ros.exe" APP_NAME="Shim test application" VENDOR="ReactOS">
<MATCHING_FILE NAME="*">
<FILE_DESCRIPTION>ReactOS Shim Engine test utility</FILE_DESCRIPTION>
<ORIGINAL_FILENAME>shimtest_ros.exe</ORIGINAL_FILENAME>
<INTERNAL_NAME>shimtest_ros</INTERNAL_NAME>
<COMPANY_NAME>ReactOS - test</COMPANY_NAME>
</MATCHING_FILE>
<SHIM_REF NAME="ShimTest" />
</EXE>
</DATABASE> </DATABASE>
</SDB> </SDB>