diff options
Diffstat (limited to 'ext/detours/samples/comeasy/comeasy.cpp')
-rw-r--r-- | ext/detours/samples/comeasy/comeasy.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/ext/detours/samples/comeasy/comeasy.cpp b/ext/detours/samples/comeasy/comeasy.cpp new file mode 100644 index 0000000..e5c66e8 --- /dev/null +++ b/ext/detours/samples/comeasy/comeasy.cpp @@ -0,0 +1,69 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Detour Test Program (comeasy.cpp of comeasy.exe) +// +// Microsoft Research Detours Package +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +#include <ole2.h> +#include <windows.h> +#include <stdio.h> + +////////////////////////////////////////////////////////////////////////////// +// +int __cdecl main(int argc, char **argv) +{ + HRESULT hr; + + (void)argc; + (void)argv; + + LPSTREAM pStream = NULL; + ULARGE_INTEGER ul; + LARGE_INTEGER li; + + printf("comeasy.exe: Starting (at %p).\n", main); + + CoInitialize(NULL); + + hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream); + + ul.QuadPart = 512; + hr = pStream->SetSize(ul); + + li.QuadPart = 0; + hr = pStream->Seek(li, STREAM_SEEK_SET, NULL); + + printf("comeasy.exe: First write.\n"); + fflush(stdout); + + li.QuadPart = 0; + hr = pStream->Write(&ul, sizeof(ul), NULL); + + printf("comeasy.exe: Second write.\n"); + fflush(stdout); + + li.QuadPart = 1; + hr = pStream->Write(&li, sizeof(li), NULL); + + printf("comeasy.exe: Third write.\n"); + fflush(stdout); + + li.QuadPart = 2; + hr = pStream->Write(&li, sizeof(li), NULL); + + pStream->Release(); + pStream = NULL; + + CoUninitialize(); + + printf("comeasy.exe: Exiting.\n\n"); + fflush(stdout); + + return 0; +} + +// +///////////////////////////////////////////////////////////////// End of File. |