Ver Mensaje Individual
  #3  
Antiguo 18-08-2020
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Reputación: 14
aguml Va por buen camino
He conseguido que me funcione en x32 con esto:
Código PHP:
DWORD GetBaseAddressFromProcessHandle(HANDLE process_handle)
{
    
PROCESS_BASIC_INFORMATION pbi = {};
    
ULONG ulSize;
    
DWORD dwReturn=0;
    
SIZE_T nRead;
    
LONG (WINAPI *NtQueryInformationProcess)(HANDLE ProcessHandle,
          
ULONG ProcessInformationClassPVOID ProcessInformation,
          
ULONG ProcessInformationLengthPULONG ReturnLength);

    *(
FARPROC *) &NtQueryInformationProcess GetProcAddress(
        
LoadLibrary(L"ntdll"), "NtQueryInformationProcess");
    if (
NtQueryInformationProcess == NULL) {
        return 
0;
    }

    if(    
NtQueryInformationProcess != NULL &&
        
NtQueryInformationProcess(process_handle0, &pbisizeof(pbi), &ulSize) >= &&
        
ulSize == sizeof(pbi)) {

        
ReadProcessMemory(process_handle, ((PVOID)((DWORD)pbi.PebBaseAddress 0x8)), &dwReturnsizeof(dwReturn), &nRead);
        return 
dwReturn;
    }
    return 
0;

El caso que cogiendo el mismo codigo y usandolo para x64 con los minimos cambios no me funciona en x64:
Código PHP:
DWORD64 GetBaseAddressFromProcessHandle(HANDLE process_handle)
{
    
PROCESS_BASIC_INFORMATION pbi = {};
    
ULONG ulSize;
    
DWORD64 dwReturn=0;
    
SIZE_T nRead;
    
LONG (WINAPI *NtQueryInformationProcess)(HANDLE ProcessHandle,
          
ULONG ProcessInformationClassPVOID ProcessInformation,
          
ULONG ProcessInformationLengthPULONG ReturnLength);

    *(
FARPROC *) &NtQueryInformationProcess GetProcAddress(
        
LoadLibrary(L"ntdll"), "NtQueryInformationProcess");
    if (
NtQueryInformationProcess == NULL) {
        return 
0;
    }
    if(    
NtQueryInformationProcess != NULL &&
        
NtQueryInformationProcess(process_handle0, &pbisizeof(pbi), &ulSize) >= &&
        
ulSize == sizeof(pbi)) {

        
ReadProcessMemory(process_handle, ((PVOID)(pbi.PebBaseAddress 0x10)), &dwReturnsizeof(dwReturn), &nRead);
        return 
dwReturn;
    }
    return 
0;

Todo parece ir bien pero el valor que obtiene en dwReturn es 0.
¿Alguien me puede ayudar con esto?
Responder Con Cita