mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 00:50:23 +00:00
- Delete regtests framework by Casper. It's useless.
svn path=/trunk/; revision=40349
This commit is contained in:
parent
86cfbadb1f
commit
3147006bd2
8 changed files with 0 additions and 766 deletions
|
@ -10,9 +10,6 @@
|
|||
<directory name="dxtest">
|
||||
<xi:include href="dxtest/directory.rbuild" />
|
||||
</directory>
|
||||
<directory name="regtests_by_casper">
|
||||
<xi:include href="regtests_by_casper/directory.rbuild" />
|
||||
</directory>
|
||||
<directory name="rosautotest">
|
||||
<xi:include href="rosautotest/rosautotest.rbuild" />
|
||||
</directory>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE group SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<group xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<directory name="regtests">
|
||||
<xi:include href="regtests/regtests.rbuild" />
|
||||
</directory>
|
||||
<directory name="shared">
|
||||
<xi:include href="shared/rtshared.rbuild" />
|
||||
</directory>
|
||||
</group>
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: regtests/regtests/regtests.c
|
||||
* PURPOSE: Regression testing framework
|
||||
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* UPDATE HISTORY:
|
||||
* 23-10-2004 CSH Created
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
HMODULE WINAPI
|
||||
_GetModuleHandleA(LPCSTR lpModuleName)
|
||||
{
|
||||
return GetModuleHandleA(lpModuleName);
|
||||
}
|
||||
|
||||
FARPROC WINAPI
|
||||
_GetProcAddress(HMODULE hModule,
|
||||
LPCSTR lpProcName)
|
||||
{
|
||||
return GetProcAddress(hModule, lpProcName);
|
||||
}
|
||||
|
||||
HINSTANCE WINAPI
|
||||
_LoadLibraryA(LPCSTR lpLibFileName)
|
||||
{
|
||||
return LoadLibraryA(lpLibFileName);
|
||||
}
|
||||
|
||||
VOID WINAPI
|
||||
_ExitProcess(UINT uExitCode)
|
||||
{
|
||||
ExitProcess(uExitCode);
|
||||
}
|
||||
|
||||
HANDLE WINAPI
|
||||
_CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize,
|
||||
LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter,
|
||||
DWORD dwCreationFlags, LPDWORD lpThreadId)
|
||||
{
|
||||
return CreateThread(lpThreadAttributes, dwStackSize, lpStartAddress,
|
||||
lpParameter, dwCreationFlags, lpThreadId);
|
||||
}
|
||||
|
||||
WINBOOL WINAPI
|
||||
_TerminateThread(HANDLE hThread, DWORD dwExitCode)
|
||||
{
|
||||
return TerminateThread(hThread, dwExitCode);
|
||||
}
|
||||
|
||||
DWORD WINAPI
|
||||
_WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
|
||||
{
|
||||
return WaitForSingleObject(hHandle, dwMilliseconds);
|
||||
}
|
||||
|
||||
DWORD WINAPI
|
||||
_GetLastError()
|
||||
{
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
VOID WINAPI
|
||||
_CloseHandle(HANDLE handle)
|
||||
{
|
||||
CloseHandle (handle);
|
||||
}
|
||||
|
||||
BOOL WINAPI
|
||||
_GetThreadTimes(HANDLE hThread, LPFILETIME lpCreationTime,
|
||||
LPFILETIME lpExitTime, LPFILETIME lpKernelTime,
|
||||
LPFILETIME lpUserTime)
|
||||
{
|
||||
return GetThreadTimes(hThread, lpCreationTime, lpExitTime,
|
||||
lpKernelTime, lpUserTime);
|
||||
}
|
||||
|
||||
BOOL WINAPI
|
||||
_SetPriorityClass(HANDLE hProcess, DWORD dwPriorityClass)
|
||||
{
|
||||
return SetPriorityClass(hProcess, dwPriorityClass);
|
||||
}
|
||||
|
||||
BOOL WINAPI
|
||||
_SetThreadPriority(HANDLE hThread, int nPriority)
|
||||
{
|
||||
return SetThreadPriority(hThread, nPriority);
|
||||
}
|
||||
|
||||
HANDLE WINAPI
|
||||
_GetCurrentProcess()
|
||||
{
|
||||
return GetCurrentProcess();
|
||||
}
|
||||
|
||||
HANDLE WINAPI
|
||||
_GetCurrentThread()
|
||||
{
|
||||
return GetCurrentThread();
|
||||
}
|
||||
|
||||
VOID WINAPI
|
||||
_Sleep(DWORD dwMilliseconds)
|
||||
{
|
||||
return Sleep(dwMilliseconds);
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
LIBRARY REGTESTS.DLL
|
||||
EXPORTS
|
||||
_ExitProcess@4
|
||||
_GetModuleHandleA@4
|
||||
_GetProcAddress@8
|
||||
_LoadLibraryA@4
|
||||
_CreateThread@24
|
||||
_TerminateThread@8
|
||||
_WaitForSingleObject@8
|
||||
_GetLastError@0
|
||||
_CloseHandle@4
|
||||
_GetThreadTimes@20
|
||||
_SetPriorityClass@8
|
||||
_SetThreadPriority@8
|
||||
_GetCurrentProcess@0
|
||||
_GetCurrentThread@0
|
||||
_Sleep@4
|
|
@ -1,7 +0,0 @@
|
|||
<module name="regtests" type="win32dll" baseaddress="${BASEADDRESS_REGTESTS}">
|
||||
<importlibrary definition="regtests.def" />
|
||||
<include base="regtests">.</include>
|
||||
<define name="__USE_W32API" />
|
||||
<library>kernel32</library>
|
||||
<file>regtests.c</file>
|
||||
</module>
|
|
@ -1,234 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: regtests/shared/regtests.c
|
||||
* PURPOSE: Regression testing framework
|
||||
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* UPDATE HISTORY:
|
||||
* 06-07-2003 CSH Created
|
||||
*/
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/ntndk.h>
|
||||
#include <pseh/pseh.h>
|
||||
#include "regtests.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
typedef struct _PERFORM_TEST_ARGS
|
||||
{
|
||||
TestOutputRoutine OutputRoutine;
|
||||
_PTEST Test;
|
||||
LPSTR TestName;
|
||||
DWORD Result;
|
||||
char Buffer[5000];
|
||||
DWORD Time;
|
||||
} PERFORM_TEST_ARGS;
|
||||
|
||||
int _Result;
|
||||
char *_Buffer;
|
||||
|
||||
static LIST_ENTRY AllTests;
|
||||
|
||||
VOID
|
||||
InitializeTests()
|
||||
{
|
||||
InitializeListHead(&AllTests);
|
||||
}
|
||||
|
||||
char*
|
||||
FormatExecutionTime(char *buffer, ULONG milliseconds)
|
||||
{
|
||||
sprintf(buffer,
|
||||
"%ldms",
|
||||
milliseconds);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
DWORD WINAPI
|
||||
PerformTest(PVOID _arg)
|
||||
{
|
||||
PERFORM_TEST_ARGS *Args = (PERFORM_TEST_ARGS *)_arg;
|
||||
_PTEST Test = Args->Test;
|
||||
|
||||
_SetThreadPriority(_GetCurrentThread(), THREAD_PRIORITY_IDLE);
|
||||
|
||||
memset(Args->Buffer, 0, sizeof(Args->Buffer));
|
||||
|
||||
_SEH_TRY {
|
||||
_Result = TS_OK;
|
||||
_Buffer = Args->Buffer;
|
||||
(Test->Routine)(TESTCMD_RUN);
|
||||
Args->Result = _Result;
|
||||
} _SEH_HANDLE {
|
||||
Args->Result = TS_FAILED;
|
||||
sprintf(Args->Buffer, "due to exception 0x%lx", _SEH_GetExceptionCode());
|
||||
} _SEH_END;
|
||||
return 1;
|
||||
}
|
||||
|
||||
VOID
|
||||
ControlNormalTest(HANDLE hThread,
|
||||
PERFORM_TEST_ARGS *Args,
|
||||
DWORD TimeOut)
|
||||
{
|
||||
_FILETIME time;
|
||||
_FILETIME executionTime;
|
||||
DWORD status;
|
||||
|
||||
status = _WaitForSingleObject(hThread, TimeOut);
|
||||
if (status == WAIT_TIMEOUT)
|
||||
{
|
||||
_TerminateThread(hThread, 0);
|
||||
Args->Result = TS_TIMEDOUT;
|
||||
}
|
||||
status = _GetThreadTimes(hThread,
|
||||
&time,
|
||||
&time,
|
||||
&time,
|
||||
&executionTime);
|
||||
Args->Time = executionTime.dwLowDateTime / 10000;
|
||||
}
|
||||
|
||||
VOID
|
||||
DisplayResult(PERFORM_TEST_ARGS* Args,
|
||||
LPSTR OutputBuffer)
|
||||
{
|
||||
char Format[100];
|
||||
|
||||
if (Args->Result == TS_OK)
|
||||
{
|
||||
sprintf(OutputBuffer,
|
||||
"[%s] Success [%s]\n",
|
||||
Args->TestName,
|
||||
FormatExecutionTime(Format,
|
||||
Args->Time));
|
||||
}
|
||||
else if (Args->Result == TS_TIMEDOUT)
|
||||
{
|
||||
sprintf(OutputBuffer,
|
||||
"[%s] Timed out [%s]\n",
|
||||
Args->TestName,
|
||||
FormatExecutionTime(Format,
|
||||
Args->Time));
|
||||
}
|
||||
else
|
||||
sprintf(OutputBuffer, "[%s] Failed (%s)\n", Args->TestName, Args->Buffer);
|
||||
|
||||
if (Args->OutputRoutine != NULL)
|
||||
(*Args->OutputRoutine)(OutputBuffer);
|
||||
else
|
||||
DbgPrint(OutputBuffer);
|
||||
}
|
||||
|
||||
VOID
|
||||
ControlTest(HANDLE hThread,
|
||||
PERFORM_TEST_ARGS *Args,
|
||||
DWORD TestType,
|
||||
DWORD TimeOut)
|
||||
{
|
||||
switch (TestType)
|
||||
{
|
||||
case TT_NORMAL:
|
||||
ControlNormalTest(hThread, Args, TimeOut);
|
||||
break;
|
||||
default:
|
||||
printf("Unknown test type %ld\n", TestType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
PerformTests(TestOutputRoutine OutputRoutine, LPSTR TestName)
|
||||
{
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
PLIST_ENTRY NextEntry;
|
||||
_PTEST Current;
|
||||
PERFORM_TEST_ARGS Args;
|
||||
HANDLE hThread;
|
||||
char OutputBuffer[1024];
|
||||
char Name[200];
|
||||
DWORD TestType;
|
||||
DWORD TimeOut;
|
||||
|
||||
Args.OutputRoutine = OutputRoutine;
|
||||
Args.TestName = Name;
|
||||
Args.Time = 0;
|
||||
|
||||
CurrentEntry = AllTests.Flink;
|
||||
for (; CurrentEntry != &AllTests; CurrentEntry = NextEntry)
|
||||
{
|
||||
NextEntry = CurrentEntry->Flink;
|
||||
Current = CONTAINING_RECORD(CurrentEntry, _TEST, ListEntry);
|
||||
Args.Test = Current;
|
||||
|
||||
/* Get name of test */
|
||||
memset(Name, 0, sizeof(Name));
|
||||
|
||||
_Result = TS_OK;
|
||||
_Buffer = Name;
|
||||
(Current->Routine)(TESTCMD_TESTNAME);
|
||||
if (_Result != TS_OK)
|
||||
{
|
||||
if (TestName != NULL)
|
||||
continue;
|
||||
strcpy(Name, "Unnamed");
|
||||
}
|
||||
|
||||
if ((TestName != NULL) && (_stricmp(Name, TestName) != 0))
|
||||
continue;
|
||||
|
||||
TestType = TT_NORMAL;
|
||||
_Result = TS_OK;
|
||||
_Buffer = (char *)&TestType;
|
||||
(Current->Routine)(TESTCMD_TESTTYPE);
|
||||
if (_Result != TS_OK)
|
||||
TestType = TT_NORMAL;
|
||||
|
||||
/* Get timeout for test */
|
||||
TimeOut = 0;
|
||||
_Result = TS_OK;
|
||||
_Buffer = (char *)&TimeOut;
|
||||
(Current->Routine)(TESTCMD_TIMEOUT);
|
||||
if (_Result != TS_OK || TimeOut == INFINITE)
|
||||
TimeOut = 5000;
|
||||
|
||||
/* Run test in a separate thread */
|
||||
hThread = _CreateThread(NULL, 0, PerformTest, (PVOID)&Args, 0, NULL);
|
||||
if (hThread == NULL)
|
||||
{
|
||||
printf("[%s] Failed (CreateThread() failed: %ld)\n",
|
||||
Name,
|
||||
_GetLastError());
|
||||
Args.Result = TS_FAILED;
|
||||
}
|
||||
else
|
||||
ControlTest(hThread, &Args, TestType, TimeOut);
|
||||
|
||||
DisplayResult(&Args, OutputBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
AddTest(TestRoutine Routine)
|
||||
{
|
||||
_PTEST Test;
|
||||
|
||||
Test = (_PTEST) malloc(sizeof(_TEST));
|
||||
if (Test == NULL)
|
||||
{
|
||||
DbgPrint("Out of memory");
|
||||
return;
|
||||
}
|
||||
|
||||
Test->Routine = Routine;
|
||||
|
||||
InsertTailList(&AllTests, &Test->ListEntry);
|
||||
}
|
||||
|
||||
PVOID WINAPI
|
||||
FrameworkGetHook(ULONG index)
|
||||
{
|
||||
return FrameworkGetHookInternal(index);
|
||||
}
|
|
@ -1,384 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: regtests/shared/regtests.h
|
||||
* PURPOSE: Regression testing
|
||||
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* UPDATE HISTORY:
|
||||
* 06-07-2003 CSH Created
|
||||
*/
|
||||
#ifndef __REGTESTS_H
|
||||
#define __REGTESTS_H
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef DWORD (WINAPI _LPTHREAD_START_ROUTINE)(LPVOID lpParameter);
|
||||
|
||||
typedef struct __FILETIME
|
||||
{
|
||||
DWORD dwLowDateTime;
|
||||
DWORD dwHighDateTime;
|
||||
} _FILETIME, *_PFILETIME, *_LPFILETIME;
|
||||
|
||||
extern void SetupOnce();
|
||||
|
||||
#define _SetupOnce() \
|
||||
void SetupOnce()
|
||||
|
||||
/* Valid values for Command parameter of TestRoutine */
|
||||
#define TESTCMD_RUN 0 /* Buffer contains information about what failed */
|
||||
#define TESTCMD_TESTTYPE 1 /* Buffer contains type of test */
|
||||
#define TESTCMD_TESTNAME 2 /* Buffer contains description of test */
|
||||
#define TESTCMD_TIMEOUT 3 /* Buffer contains timeout for test (DWORD, default is 5000 ms) */
|
||||
|
||||
/* Test types */
|
||||
#define TT_NORMAL 0
|
||||
|
||||
/* Valid values for return values of TestRoutine */
|
||||
#define TS_TIMEDOUT ((DWORD)-2)
|
||||
#define TS_EXCEPTION ((DWORD)-1)
|
||||
#define TS_OK 0
|
||||
#define TS_FAILED 1
|
||||
|
||||
extern int _Result;
|
||||
extern char *_Buffer;
|
||||
|
||||
/* Macros to simplify tests */
|
||||
#define _DispatcherTypeTimeout(FunctionName, TestName, TestType, TimeOut) \
|
||||
void \
|
||||
FunctionName(int Command) \
|
||||
{ \
|
||||
switch (Command) \
|
||||
{ \
|
||||
case TESTCMD_RUN: \
|
||||
RunTest(); \
|
||||
break; \
|
||||
case TESTCMD_TESTTYPE: \
|
||||
*(PDWORD)_Buffer = (DWORD)TestType; \
|
||||
break; \
|
||||
case TESTCMD_TESTNAME: \
|
||||
strcpy(_Buffer, TestName); \
|
||||
break; \
|
||||
case TESTCMD_TIMEOUT: \
|
||||
*(PDWORD)_Buffer = (DWORD)TimeOut; \
|
||||
break; \
|
||||
default: \
|
||||
_Result = TS_FAILED; \
|
||||
break; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _DispatcherTimeout(FunctionName, TestName, TimeOut) \
|
||||
_DispatcherTypeTimeout(FunctionName, TestName, TT_NORMAL, TimeOut)
|
||||
|
||||
#define _DispatcherType(FunctionName, TestName, TestType) \
|
||||
_DispatcherTypeTimeout(FunctionName, TestName, TestType, 5000)
|
||||
|
||||
#define _Dispatcher(FunctionName, TestName) \
|
||||
_DispatcherTimeout(FunctionName, TestName, 5000)
|
||||
|
||||
static __inline void
|
||||
AppendAssertion(char *message)
|
||||
{
|
||||
if (strlen(_Buffer) != 0)
|
||||
strcat(_Buffer, "\n");
|
||||
strcat(_Buffer, message);
|
||||
_Result = TS_FAILED;
|
||||
}
|
||||
|
||||
#define _AssertTrue(_Condition) \
|
||||
{ \
|
||||
if (!(_Condition)) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Condition was not true at %s:%d", \
|
||||
__FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _AssertFalse(_Condition) \
|
||||
{ \
|
||||
if (_Condition) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Condition was not false at %s:%d", \
|
||||
__FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _AssertEqualValue(_Expected, _Actual) \
|
||||
{ \
|
||||
ULONG __Expected = (ULONG) (_Expected); \
|
||||
ULONG __Actual = (ULONG) (_Actual); \
|
||||
if ((__Expected) != (__Actual)) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Expected %ld/0x%.08lx was %ld/0x%.08lx at %s:%d", \
|
||||
(__Expected), (__Expected), (__Actual), (__Actual), __FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _AssertEqualWideString(_Expected, _Actual) \
|
||||
{ \
|
||||
LPWSTR __Expected = (LPWSTR) (_Expected); \
|
||||
LPWSTR __Actual = (LPWSTR) (_Actual); \
|
||||
if (wcscmp((__Expected), (__Actual)) != 0) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Expected %S was %S at %s:%d", \
|
||||
(__Expected), (__Actual), __FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _AssertNotEqualValue(_Expected, _Actual) \
|
||||
{ \
|
||||
ULONG __Expected = (ULONG) (_Expected); \
|
||||
ULONG __Actual = (ULONG) (_Actual); \
|
||||
if ((__Expected) == (__Actual)) \
|
||||
{ \
|
||||
char _message[100]; \
|
||||
sprintf(_message, "Actual value expected to be different from %ld/0x%.08lx at %s:%d", \
|
||||
(__Expected), (__Expected), __FILE__, __LINE__); \
|
||||
AppendAssertion(_message); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Test routine prototype
|
||||
* Command - The command to process
|
||||
*/
|
||||
typedef void (*TestRoutine)(int Command);
|
||||
|
||||
/*
|
||||
* Test output routine prototype
|
||||
* Buffer - Address of buffer with text to output
|
||||
*/
|
||||
typedef void (*TestOutputRoutine)(char *Buffer);
|
||||
|
||||
/*
|
||||
* Test driver entry routine.
|
||||
* OutputRoutine - Output routine.
|
||||
* TestName - If NULL all tests are run. If non-NULL specifies the test to be run
|
||||
*/
|
||||
typedef void (WINAPI *TestDriverMain)(TestOutputRoutine OutputRoutine, char *TestName);
|
||||
|
||||
typedef struct __TEST
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
TestRoutine Routine;
|
||||
} _TEST, *_PTEST;
|
||||
|
||||
extern VOID InitializeTests();
|
||||
extern VOID RegisterTests();
|
||||
extern VOID PerformTests(TestOutputRoutine OutputRoutine, LPSTR TestName);
|
||||
|
||||
|
||||
typedef struct __API_DESCRIPTION
|
||||
{
|
||||
PCHAR FileName;
|
||||
PCHAR FunctionName;
|
||||
PCHAR ForwardedFunctionName;
|
||||
PVOID FunctionAddress;
|
||||
PVOID MockFunctionAddress;
|
||||
} _API_DESCRIPTION, *_PAPI_DESCRIPTION;
|
||||
|
||||
extern _API_DESCRIPTION ExternalDependencies[];
|
||||
extern ULONG MaxExternalDependency;
|
||||
|
||||
HANDLE WINAPI
|
||||
_GetModuleHandleA(LPCSTR lpModuleName);
|
||||
|
||||
PVOID WINAPI
|
||||
_GetProcAddress(HANDLE hModule,
|
||||
LPCSTR lpProcName);
|
||||
|
||||
HANDLE WINAPI
|
||||
_LoadLibraryA(LPCSTR lpLibFileName);
|
||||
|
||||
VOID WINAPI
|
||||
_ExitProcess(UINT uExitCode);
|
||||
|
||||
HANDLE WINAPI
|
||||
_CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize,
|
||||
_LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter,
|
||||
DWORD dwCreationFlags, LPDWORD lpThreadId);
|
||||
|
||||
BOOL WINAPI
|
||||
_TerminateThread(HANDLE hThread, DWORD dwExitCode);
|
||||
|
||||
DWORD WINAPI
|
||||
_WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
|
||||
|
||||
DWORD WINAPI
|
||||
_GetLastError();
|
||||
|
||||
VOID WINAPI
|
||||
_CloseHandle(HANDLE handle);
|
||||
|
||||
BOOL WINAPI
|
||||
_GetThreadTimes(HANDLE hThread,
|
||||
_LPFILETIME lpCreationTime,
|
||||
_LPFILETIME lpExitTime,
|
||||
_LPFILETIME lpKernelTime,
|
||||
_LPFILETIME lpUserTime);
|
||||
|
||||
BOOL WINAPI
|
||||
_SetPriorityClass(HANDLE hProcess, DWORD dwPriorityClass);
|
||||
|
||||
BOOL WINAPI
|
||||
_SetThreadPriority(HANDLE hThread, int nPriority);
|
||||
|
||||
HANDLE WINAPI
|
||||
_GetCurrentProcess();
|
||||
|
||||
HANDLE WINAPI
|
||||
_GetCurrentThread();
|
||||
|
||||
VOID WINAPI
|
||||
_Sleep(DWORD dwMilliseconds);
|
||||
|
||||
|
||||
static __inline PCHAR
|
||||
FrameworkGetExportedFunctionNameInternal(_PAPI_DESCRIPTION ApiDescription)
|
||||
{
|
||||
if (ApiDescription->ForwardedFunctionName != NULL)
|
||||
{
|
||||
return ApiDescription->ForwardedFunctionName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ApiDescription->FunctionName;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline PVOID
|
||||
FrameworkGetFunction(_PAPI_DESCRIPTION ApiDescription)
|
||||
{
|
||||
HANDLE hModule;
|
||||
PVOID function = NULL;
|
||||
PCHAR exportedFunctionName;
|
||||
|
||||
exportedFunctionName = FrameworkGetExportedFunctionNameInternal(ApiDescription);
|
||||
|
||||
hModule = _GetModuleHandleA(ApiDescription->FileName);
|
||||
if (hModule != NULL)
|
||||
{
|
||||
function = _GetProcAddress(hModule, exportedFunctionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
hModule = _LoadLibraryA(ApiDescription->FileName);
|
||||
if (hModule != NULL)
|
||||
{
|
||||
function = _GetProcAddress(hModule, exportedFunctionName);
|
||||
//FreeLibrary(hModule);
|
||||
}
|
||||
}
|
||||
return function;
|
||||
}
|
||||
|
||||
static __inline PVOID
|
||||
FrameworkGetHookInternal(ULONG index)
|
||||
{
|
||||
PVOID address;
|
||||
PCHAR exportedFunctionName;
|
||||
|
||||
if (index > MaxExternalDependency)
|
||||
return NULL;
|
||||
|
||||
if (ExternalDependencies[index].MockFunctionAddress != NULL)
|
||||
return ExternalDependencies[index].MockFunctionAddress;
|
||||
|
||||
if (ExternalDependencies[index].FunctionAddress != NULL)
|
||||
return ExternalDependencies[index].FunctionAddress;
|
||||
|
||||
exportedFunctionName = FrameworkGetExportedFunctionNameInternal(&ExternalDependencies[index]);
|
||||
|
||||
printf("Calling function '%s' in DLL '%s'.\n",
|
||||
exportedFunctionName,
|
||||
ExternalDependencies[index].FileName);
|
||||
|
||||
address = FrameworkGetFunction(&ExternalDependencies[index]);
|
||||
|
||||
if (address == NULL)
|
||||
{
|
||||
printf("Function '%s' not found in DLL '%s'.\n",
|
||||
exportedFunctionName,
|
||||
ExternalDependencies[index].FileName);
|
||||
}
|
||||
ExternalDependencies[index].FunctionAddress = address;
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
|
||||
static __inline VOID
|
||||
_SetHook(PCHAR name,
|
||||
PVOID address)
|
||||
{
|
||||
_PAPI_DESCRIPTION api;
|
||||
ULONG index;
|
||||
|
||||
for (index = 0; index <= MaxExternalDependency; index++)
|
||||
{
|
||||
api = &ExternalDependencies[index];
|
||||
if (strcmp(api->FunctionName, name) == 0)
|
||||
{
|
||||
api->MockFunctionAddress = address;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct __HOOK
|
||||
{
|
||||
PCHAR FunctionName;
|
||||
PVOID FunctionAddress;
|
||||
} _HOOK, *_PHOOK;
|
||||
|
||||
static __inline VOID
|
||||
_SetHooks(_PHOOK hookTable)
|
||||
{
|
||||
_PHOOK hook;
|
||||
|
||||
hook = &hookTable[0];
|
||||
while (hook->FunctionName != NULL)
|
||||
{
|
||||
_SetHook(hook->FunctionName,
|
||||
hook->FunctionAddress);
|
||||
hook++;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline VOID
|
||||
_UnsetHooks(_PHOOK hookTable)
|
||||
{
|
||||
_PHOOK hook;
|
||||
|
||||
hook = &hookTable[0];
|
||||
while (hook->FunctionName != NULL)
|
||||
{
|
||||
_SetHook(hook->FunctionName,
|
||||
NULL);
|
||||
hook++;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline VOID
|
||||
_UnsetAllHooks()
|
||||
{
|
||||
_PAPI_DESCRIPTION api;
|
||||
ULONG index;
|
||||
|
||||
for (index = 0; index <= MaxExternalDependency; index++)
|
||||
{
|
||||
api = &ExternalDependencies[index];
|
||||
api->MockFunctionAddress = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __REGTESTS_H */
|
|
@ -1,5 +0,0 @@
|
|||
<module name="rtshared" type="staticlibrary" allowwarnings="true">
|
||||
<include base="rtshared">.</include>
|
||||
<define name="__USE_W32API" />
|
||||
<file>regtests.c</file>
|
||||
</module>
|
Loading…
Reference in a new issue