some helper functions
| 327 | |
| 328 | // some helper functions |
| 329 | LAZY_IMPORTER_FORCEINLINE const win::PEB_T* peb() noexcept |
| 330 | { |
| 331 | #if defined(_M_X64) || defined(__amd64__) |
| 332 | return reinterpret_cast<const win::PEB_T*>(__readgsqword(0x60)); |
| 333 | #elif defined(_M_IX86) || defined(__i386__) |
| 334 | return reinterpret_cast<const win::PEB_T*>(__readfsdword(0x30)); |
| 335 | #elif defined(_M_ARM) || defined(__arm__) |
| 336 | return *reinterpret_cast<const win::PEB_T**>(_MoveFromCoprocessor(15, 0, 13, 0, 2) + 0x30); |
| 337 | #elif defined(_M_ARM64) || defined(__aarch64__) |
| 338 | return *reinterpret_cast<const win::PEB_T**>(__getReg(18) + 0x60); |
| 339 | #elif defined(_M_IA64) || defined(__ia64__) |
| 340 | return *reinterpret_cast<const win::PEB_T**>(static_cast<char*>(_rdteb()) + 0x60); |
| 341 | #else |
| 342 | #error Unsupported platform. Open an issue and I'll probably add support. |
| 343 | #endif |
| 344 | } |
| 345 | |
| 346 | LAZY_IMPORTER_FORCEINLINE const win::PEB_LDR_DATA_T* ldr() |
| 347 | { |