MCPcopy Create free account
hub / github.com/ajkhoury/ReClassEx / UpdateExports

Function UpdateExports

ReClass/stdafx.cpp:693–855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

691}
692
693BOOLEAN UpdateExports( )
694{
695 g_Exports.clear( );
696
697 //if (!g_bExports)
698 // return;
699
700 PPROCESS_BASIC_INFORMATION ProcessInfo = NULL;
701 PEB Peb;
702 PEB_LDR_DATA LdrData;
703
704 // Try to allocate buffer
705 DWORD dwSize = sizeof( PROCESS_BASIC_INFORMATION );
706 ProcessInfo = (PPROCESS_BASIC_INFORMATION)malloc( dwSize );
707 if (!ProcessInfo)
708 {
709 #ifdef _DEBUG
710 PrintOut( _T( "[UpdateExports]: Couldn't allocate heap buffer!" ) );
711 #endif
712 return FALSE;
713 }
714
715 ULONG dwSizeNeeded = 0;
716 NTSTATUS status = ntdll::NtQueryInformationProcess( g_hProcess, ProcessBasicInformation, ProcessInfo, dwSize, &dwSizeNeeded );
717 if (status >= 0 && dwSize < dwSizeNeeded)
718 {
719 if (ProcessInfo)
720 free( ProcessInfo );
721
722 ProcessInfo = (PPROCESS_BASIC_INFORMATION)malloc( dwSizeNeeded );
723 if (!ProcessInfo)
724 {
725 #ifdef _DEBUG
726 PrintOut( _T( "[UpdateExports]: Couldn't allocate heap buffer!" ) );
727 #endif
728 return FALSE;
729 }
730
731 status = ntdll::NtQueryInformationProcess( g_hProcess, ProcessBasicInformation, ProcessInfo, dwSizeNeeded, &dwSizeNeeded );
732 }
733
734 // Did we successfully get basic info on process
735 if (NT_SUCCESS( status ))
736 {
737 // Check for PEB
738 if (!ProcessInfo->PebBaseAddress)
739 {
740 #ifdef _DEBUG
741 PrintOut( _T( "[UpdateExports]: PEB is null! Aborting..." ) );
742 #endif
743 if (ProcessInfo)
744 free( ProcessInfo );
745 return FALSE;
746 }
747
748 // Read Process Environment Block (PEB)
749 SIZE_T dwBytesRead = 0;
750 if (ReClassReadMemory( (LPVOID)ProcessInfo->PebBaseAddress, &Peb, sizeof( PEB ), &dwBytesRead ) == 0)

Callers

nothing calls this directly

Calls 3

ReClassReadMemoryFunction · 0.85
GetLastErrorStringFunction · 0.85
clearMethod · 0.80

Tested by

no test coverage detected