diff options
author | Andrzej Janik <[email protected]> | 2021-01-03 17:52:14 +0100 |
---|---|---|
committer | Andrzej Janik <[email protected]> | 2021-01-03 17:52:14 +0100 |
commit | dabc40cb19bf4e297c32284d26c74adbd6775e49 (patch) | |
tree | 6f71c14ef264998a9bccb3b6891c71542d9ace7a /samples/traceapi/testapi.cpp | |
download | ZLUDA-dabc40cb19bf4e297c32284d26c74adbd6775e49.tar.gz ZLUDA-dabc40cb19bf4e297c32284d26c74adbd6775e49.zip |
Squashed 'ext/detours/' content from commit 39aa864
git-subtree-dir: ext/detours
git-subtree-split: 39aa864d2985099c8d847e29a5fb86618039b9c4
Diffstat (limited to 'samples/traceapi/testapi.cpp')
-rw-r--r-- | samples/traceapi/testapi.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/samples/traceapi/testapi.cpp b/samples/traceapi/testapi.cpp new file mode 100644 index 0000000..d85fc02 --- /dev/null +++ b/samples/traceapi/testapi.cpp @@ -0,0 +1,94 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Detours Test Program (testapi.cpp of testapi.exe) +// +// Microsoft Research Detours Package +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +#include "trcapi.cpp" + +#if (_MSC_VER < 1299) +typedef ULONG * PULONG_PTR; +typedef ULONG ULONG_PTR; +typedef LONG * PLONG_PTR; +typedef LONG LONG_PTR; +#endif + +VOID SyelogOpen(PCSTR pszIdentifier, BYTE nFacility) +{ + (void)pszIdentifier; + (void)nFacility; +} + +VOID SyelogExV(BOOL fTerminate, BYTE nSeverity, PCSTR pszMsgf, va_list args) +{ + (void)fTerminate; + + CHAR szBuffer[1024]; + PCHAR psz = szBuffer; + BOOL fLf = FALSE; + + StringCchPrintfA(psz, szBuffer + sizeof(szBuffer) - psz, "--.%02x: ", nSeverity); + while (*psz) { + psz++; + } + + StringCchVPrintfA(psz, szBuffer + sizeof(szBuffer) - psz, pszMsgf, args); + for (psz = szBuffer; *psz; psz++) { + if (*psz == '\n') { + if (fLf) { + *psz = '\0'; + break; + } + fLf = TRUE; + } + } + if (!fLf) { + *psz++ = '\n'; + *psz = '\0'; + } + printf("%s", szBuffer); + Real_OutputDebugStringA(szBuffer); +} + +VOID SyelogV(BYTE nSeverity, PCSTR pszMsgf, va_list args) +{ + SyelogExV(FALSE, nSeverity, pszMsgf, args); +} + +VOID Syelog(BYTE nSeverity, PCSTR pszMsgf, ...) +{ + va_list args; + va_start(args, pszMsgf); + SyelogExV(FALSE, nSeverity, pszMsgf, args); + va_end(args); +} + +VOID SyelogEx(BOOL fTerminate, BYTE nSeverity, PCSTR pszMsgf, ...) +{ + va_list args; + va_start(args, pszMsgf); + SyelogExV(fTerminate, nSeverity, pszMsgf, args); + va_end(args); +} + +VOID SyelogClose(BOOL fTerminate) +{ + (void)fTerminate; +} + +DWORD main(int argc, char **argv) +{ + (void)argc; + (void)argv; + + printf("testapi: Starting\n"); + ProcessAttach(NULL); + Sleep(100); + ProcessDetach(NULL); + + return 0; +} +// +////////////////////////////////////////////////////////////////////////////// |