44#include < string>
55#pragma comment(lib,"ntdll.lib")
66
7- static void DisplayStatus () {
7+ static int DisplayStatus () {
8+ const auto gdp = GetMmpGlobalDataPtr ();
9+ if ( !gdp ) {
10+ printf (" failed GetMmpGlobalDataPtr().\n " );
11+ return -1 ;
12+ }
813 printf (
914 " \
1015MemoryModulePP [Version %d.%d%s]\n\n\t \
@@ -16,17 +21,18 @@ RtlRbRemoveNode = %p\n\n\t\
1621LdrpInvertedFunctionTable = %p\n\n\t \
1722LdrpHashTable = %p\n\n \
1823" ,
19- MmpGlobalDataPtr ->MajorVersion ,
20- MEMORY_MODULE_GET_MINOR_VERSION (MmpGlobalDataPtr ->MinorVersion ),
21- MEMORY_MODULE_IS_PREVIEW (MmpGlobalDataPtr ->MinorVersion ) ? " Preview" : " " ,
22- MmpGlobalDataPtr ->MmpFeatures ,
23- MmpGlobalDataPtr ->MmpBaseAddressIndex ->LdrpModuleBaseAddressIndex ,
24- MmpGlobalDataPtr ->MmpBaseAddressIndex ->NtdllLdrEntry ,
25- MmpGlobalDataPtr ->MmpBaseAddressIndex ->_RtlRbInsertNodeEx ,
26- MmpGlobalDataPtr ->MmpBaseAddressIndex ->_RtlRbRemoveNode ,
27- MmpGlobalDataPtr ->MmpInvertedFunctionTable ->LdrpInvertedFunctionTable ,
28- MmpGlobalDataPtr ->MmpLdrEntry ->LdrpHashTable
24+ gdp ->MajorVersion ,
25+ MEMORY_MODULE_GET_MINOR_VERSION (gdp ->MinorVersion ),
26+ MEMORY_MODULE_IS_PREVIEW (gdp ->MinorVersion ) ? " Preview" : " " ,
27+ gdp ->MmpFeatures ,
28+ (PVOID)gdp ->MmpBaseAddressIndex ->LdrpModuleBaseAddressIndex ,
29+ (PVOID)gdp ->MmpBaseAddressIndex ->NtdllLdrEntry ,
30+ gdp ->MmpBaseAddressIndex ->_RtlRbInsertNodeEx ,
31+ gdp ->MmpBaseAddressIndex ->_RtlRbRemoveNode ,
32+ gdp ->MmpInvertedFunctionTable ->LdrpInvertedFunctionTable ,
33+ (PVOID)gdp ->MmpLdrEntry ->LdrpHashTable
2934 );
35+ return 0 ;
3036}
3137
3238static PVOID ReadDllFile (const std::string& FilePath) {
@@ -141,7 +147,10 @@ int test(const std::string& dll_path) {
141147
142148int main (int argc, char * argv[]) {
143149
144- DisplayStatus ();
150+ // check MemoryModulePP initialization
151+ if ( DisplayStatus () ) {
152+ return -1 ;
153+ }
145154
146155 std::string dll_path (" a.dll" ); // default
147156 dll_path = argc > 1 ? argv[1 ] : ResolveWithModulePath (dll_path);
0 commit comments