aboutsummaryrefslogtreecommitdiffhomepage
path: root/ext/detours/samples/comeasy/comeasy.cpp
blob: e5c66e842a57a048d907bb3b9b4889b47d32c5cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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.