[32] | 1 | #ifdef USERLOG_EXPORTS
|
---|
| 2 | #define USERLOG_API __declspec(dllexport)
|
---|
| 3 | #else
|
---|
| 4 | #define USERLOG_API __declspec(dllimport)
|
---|
| 5 | #endif
|
---|
| 6 |
|
---|
| 7 | #include <iostream>
|
---|
| 8 | #include <fstream>
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | //#define __USING_MTRACE__
|
---|
| 13 | #define __USING_COSTUMLOG__
|
---|
| 14 | #define __INCLUDEHOOKINFO__
|
---|
| 15 | //#define __TIMING__
|
---|
| 16 | #define __ENCODE_BASE64__
|
---|
| 17 |
|
---|
| 18 | #define LOGPREFIX " UL: "
|
---|
| 19 | #define LOGPREFIXCONT " ULC: "
|
---|
| 20 | #define LOGPREFIXWSTRING L" UL: "
|
---|
| 21 |
|
---|
| 22 | #define NUMHOOKS 2
|
---|
| 23 |
|
---|
| 24 | #define CALLWNDHOOKID 0
|
---|
| 25 | #define GETMSGHOOKID 1
|
---|
| 26 |
|
---|
| 27 | #ifdef __USING_COSTUMLOG__
|
---|
| 28 | #define LOGFILE "usagelog.txt"
|
---|
| 29 | #endif
|
---|
| 30 |
|
---|
| 31 | typedef struct _HOOKDATA {
|
---|
| 32 | int nType;
|
---|
| 33 | HOOKPROC hkproc;
|
---|
| 34 | HHOOK hookhandle;
|
---|
| 35 | bool active;
|
---|
| 36 | } HOOKDATA;
|
---|
| 37 |
|
---|
| 38 | HOOKDATA myhookdata[NUMHOOKS];
|
---|
| 39 |
|
---|
| 40 | #ifdef __cplusplus
|
---|
| 41 | extern "C" {
|
---|
| 42 | #endif
|
---|
| 43 |
|
---|
| 44 | /**
|
---|
| 45 | * API function that starts the logging of messages.
|
---|
| 46 | * All required hooks and logging mechanisms are initialized.
|
---|
| 47 | */
|
---|
| 48 | USERLOG_API void __cdecl InitUsagelog();
|
---|
| 49 |
|
---|
| 50 | /**
|
---|
| 51 | * API function that stopts the logging of messages.
|
---|
| 52 | * All existing hooks are released and if required, logging mechnisms are stopped.
|
---|
| 53 | */
|
---|
| 54 | USERLOG_API void __cdecl ReleaseUsagelog();
|
---|
| 55 |
|
---|
| 56 | #ifdef __cplusplus
|
---|
| 57 | } // extern "C"
|
---|
| 58 | #endif
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | void InitHookdata();
|
---|
| 62 |
|
---|
| 63 | void InitHooks();
|
---|
| 64 |
|
---|
| 65 | void ReleaseHooks();
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 | LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam);
|
---|
| 69 |
|
---|
| 70 | LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
|
---|
| 71 |
|
---|
| 72 | void HookProc(int nFrom, int nCode, PMSG msg);
|
---|
| 73 |
|
---|
| 74 | /**
|
---|
| 75 | * Compares two messages parameter-wise.
|
---|
| 76 | * TODO: Check if this works better, if MSG.time and MSG.pt are ignored in the comparison, as they are missing in CWPSTRUCT.
|
---|
| 77 | * TODO: In case of CWPSTRICT both values are per default -1.
|
---|
| 78 | */
|
---|
| 79 | bool MessageEquals(const MSG & msg1, const MSG & msg2);
|
---|
| 80 |
|
---|
| 81 | void WriteLogentryWString(PMSG msg, int nFrom);
|
---|
| 82 |
|
---|
| 83 | int replaceWithXmlEntitiesWString(const wchar_t * source, wchar_t ** target, size_t sourceLength);
|
---|
| 84 |
|
---|
| 85 | #ifdef __USING_COSTUMLOG__
|
---|
| 86 | void InitLogfile();
|
---|
| 87 |
|
---|
| 88 | void CloseLogfile();
|
---|
| 89 | #endif |
---|