-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTRIMCORE_Describe_Ptr.h
38 lines (32 loc) · 1.6 KB
/
TRIMCORE_Describe_Ptr.h
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
#ifndef TRIMCORE_DLL_DESCRIBE_PTR_H
#define TRIMCORE_DLL_DESCRIBE_PTR_H
namespace TRIMCORE {
// Describe pointer
// - supported format parameters:
// - details - attempts to localize the pointer, appends results as follow:
// - global/function/resource pointers: "!module.dll[.section+offset]"
// - sections names are retrieved from module header, typically are:
// - .text for code,
// - .rdata for constants
// - .data for global
// - .rsrc for resources
// - offset is hexadecimal offset into the section
// - pointer to stack: "!module.dll:12345-offset" - module that created the thread and thread info
// - number represents thread ID, offset is hexadecimal offset into the stack
// - if present, thread's description is appended enclosed in double quotes
// - process heap pointer: ":heap"
inline std::wstring Describe (const void * ptr, DescriptionFormatting * format = nullptr);
inline std::wstring Describe (void * ptr, DescriptionFormatting * format = nullptr) {
return Describe (const_cast <const void *> (ptr), format);
}
// DescriptionLengthEst pointer
// - 64-bit is truncated to 48 actually used bits
inline std::size_t DescriptionLengthEst (const void *) {
return (sizeof (void *) > sizeof (std::uint32_t)) ? 12 : 8;
}
inline std::size_t DescriptionLengthEst (void * p) {
return DescriptionLengthEst (const_cast <const void *> (p));
}
}
#include "TRIMCORE_Describe_Ptr.tcc"
#endif