Esta función modifica el valor de algun registro en runtime, puedes usar openprocess o algun sleep si quieres obtener/escribir el valor en algun evento jeje yo cambié el entrypoint haciendo que al cargar el programa eax cambie de valor en el ejemplo, utilicé la estructura CONTEXT para evitarme líos
#include <stdio.h>
#include <windows.h>
/*
USOS:
Para obtener el valor de otro registro
cambiar donde dice con.Eax por
con.Registro_que_quieras
*/
DWORD ObtenerRegistro(LPSTR proceso)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
CONTEXT con;
memset(&si, 0, sizeof(si));
si.cb = sizeof(STARTUPINFO);
con.ContextFlags = CONTEXT_FULL;
if(CreateProcess(NULL, proceso, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi)==0)
{
return 0;
}
GetThreadContext(pi.hThread, &con);
ResumeThread(pi.hThread);
return con.Eax;
}
BOOL EscribirRegistro(LPSTR proceso,DWORD valor)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
CONTEXT con;
memset(&si, 0, sizeof(si));
si.cb = sizeof(STARTUPINFO);
con.ContextFlags = CONTEXT_FULL;
if(CreateProcess(NULL, proceso, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi)==0)
{
return FALSE;
}
GetThreadContext(pi.hThread, &con);
con.Eax = valor;
SetThreadContext(pi.hThread,&con);
ResumeThread(pi.hThread);
return TRUE;
}
//->EJEMPLO DE USO
int main()
{
DWORD eax;
//Cambiamos el valor eax (el entrypoint)
EscribirRegistro("c:\\final.exe",0x413b72f);
eax=ObtenerRegistro("c:\\final.exe");
printf("%x",eax);
getchar();
return 0;
}