int main(int argc, char **argv) { elfdesc_t elf; if (argc < 2) { printf("Usage: %s <executable>\n", argv[0]); exit(0); } if (load_executable(argv[1], &elf) < 0) { printf("Failed to load executable: %s\n", argv[1]); exit(-1); } if (test_for_skeksi(&elf) == 0) { printf("File: %s, is not infected with the Skeksi virus\n", argv[1]); exit(-1); } printf("File: %s, is infected with the skeksi virus! Attempting to disinfect\n", argv[1]); if (disinfect(&elf) < 0) { printf("Failed to disinfect file: %s\n", argv[1]); exit(-1); } printf("Successfully disinfected: %s\n", argv[1]); }
/* * Load the program from specified ELF image stored in memory. * The boot information is filled after loading the program. */ int load_elf(char *img, struct module *m) { Elf32_Ehdr *ehdr; Elf32_Phdr *phdr; ELFDBG(("\nelf_load\n")); ehdr = (Elf32_Ehdr *)img; /* Check ELF header */ if ((ehdr->e_ident[EI_MAG0] != ELFMAG0) || (ehdr->e_ident[EI_MAG1] != ELFMAG1) || (ehdr->e_ident[EI_MAG2] != ELFMAG2) || (ehdr->e_ident[EI_MAG3] != ELFMAG3)) { DPRINTF(("Invalid ELF image\n")); return -1; } phdr = (Elf32_Phdr *)((paddr_t)ehdr + ehdr->e_ehsize); if (nr_img == 0) { /* Initialize the load address */ load_base = (vaddr_t)ptokv(phdr->p_paddr); if (load_base == 0) { DPRINTF(("Invalid load address\n")); return -1; } ELFDBG(("kernel base=%lx\n", load_base)); load_start = load_base; } else if (nr_img == 1) { /* 2nd image => Driver */ ELFDBG(("driver base=%lx\n", load_base)); } else { /* Other images => Boot tasks */ ELFDBG(("task base=%lx\n", load_base)); } switch (ehdr->e_type) { case ET_EXEC: if (load_executable(img, m) != 0) return -1; break; case ET_REL: if (load_relocatable(img, m) != 0) return -1; break; default: ELFDBG(("Unsupported file type\n")); return -1; } nr_img++; return 0; }
int main() { if (load_executable(RA2_EXE)) { return 0; } std::cout << "Patching engine symbols..." << std::endl; patch_engine_symbols(); //Fool the engine that the launcher is running CreateMutexA(0, 0, "48BC11BD-C4D7-466b-8A31-C6ABBAD47B3E"); std::cout << "Start engine..." << std::endl; start_engine(); return 0; }
uint64_t exec(char* filename) { // find file dir_entry* file = find_file(filename); // not found? exit if (!file) return 0; clean_user_space(); // let's load it! void* entry = load_executable(file->filename); // can't load but already cleaned everything :( //if (!entry) exit(); // jump switch_to_user_mode(entry); }