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