Código
#include <string.h> #include <stdio.h> #include <windows.h> int main() { const char libreria[]="KERNEL32.dll"; const char funcion[]="ExitProcess"; DWORD image_base=(DWORD)GetModuleHandleA(0); PIMAGE_DOS_HEADER DOS; PIMAGE_NT_HEADERS NT; PIMAGE_IMPORT_DESCRIPTOR IT; PIMAGE_IMPORT_BY_NAME *IMPORTED_FUNCTIONS; PIMAGE_THUNK_DATA Funcion; DWORD *IMPORTED_DLL_NAME; DWORD *IMPORTED_FUNCTION_NAME; unsigned int i=0; DOS=(PIMAGE_DOS_HEADER)image_base; NT=(PIMAGE_NT_HEADERS)(DOS->e_lfanew + image_base); IT=(PIMAGE_IMPORT_DESCRIPTOR)(NT->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress + image_base); IMPORTED_DLL_NAME=(DWORD *)(IT->Name + image_base); while( (IT->Name) != 0 ) { IMPORTED_DLL_NAME=(DWORD *)(IT->Name + image_base); { break; } IT++; } IMPORTED_FUNCTIONS=(PIMAGE_IMPORT_BY_NAME *)(IT->Characteristics + image_base); for(i=0;;i++) { IMPORTED_FUNCTION_NAME=(DWORD *)((*IMPORTED_FUNCTIONS)->Name + image_base); { break; } IMPORTED_FUNCTIONS++; } Funcion=(PIMAGE_THUNK_DATA)(IT->FirstThunk + image_base); Funcion+=i; return 0; }
Sa1uDoS