Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6334

Kernel Mode DLL Injection ERROR: Unable to parse imports

$
0
0

In c++ I am trying Inject a Dll file from Kernel Mode Driver to csgo.exeWhen I try to inject Windows Apps like notepad.exe it works but games it don't. Tried x86 and x64 DLL files both are not works

I am taking this error. Console Logs ;

Attached to process csgo.exe successfully...Image base: 0x000000001C800000Stub base: 0x000000001C820000Solving imports...Solving relocations...ERROR: Unable to parse imports!

Parse Imports Code ;

bool mmap::parse_imports() {auto base{ proc->get_module_base(process_name.c_str()) };if (!base) {    LOG_ERROR("Cannot get module base");    return false;}auto dos_header{ read_memory< IMAGE_DOS_HEADER >(base) };auto nt_headers{ read_memory< IMAGE_NT_HEADERS >(base + dos_header.e_lfanew) };auto descriptor{ read_memory< IMAGE_IMPORT_DESCRIPTOR >(base + nt_headers.OptionalHeader.DataDirectory[1].VirtualAddress) };int descriptor_count{ 0 };int thunk_count{ 0 };while (descriptor.Name) {    auto first_thunk{ read_memory< IMAGE_THUNK_DATA >(base + descriptor.FirstThunk) };    auto original_first_thunk{ read_memory< IMAGE_THUNK_DATA >(base + descriptor.OriginalFirstThunk) };    thunk_count = 0;    while (original_first_thunk.u1.AddressOfData) {        char name[256];        proc->read_memory(base + original_first_thunk.u1.AddressOfData + 0x2, (uintptr_t)name, 256);        std::string str_name(name);        auto thunk_offset{ thunk_count * sizeof(uintptr_t) };        if (str_name.length() > 0)            imports[str_name] = base + descriptor.FirstThunk + thunk_offset; ++thunk_count;        first_thunk = read_memory< IMAGE_THUNK_DATA >(base + descriptor.FirstThunk + sizeof(IMAGE_THUNK_DATA) * thunk_count);        original_first_thunk = read_memory< IMAGE_THUNK_DATA >(base + descriptor.OriginalFirstThunk + sizeof(IMAGE_THUNK_DATA) * thunk_count);    }++descriptor_count;    descriptor = read_memory< IMAGE_IMPORT_DESCRIPTOR >(base + nt_headers.OptionalHeader.DataDirectory[1].VirtualAddress + sizeof(IMAGE_IMPORT_DESCRIPTOR) * descriptor_count);}return (imports.size() > 0);

Solving Imports Code

if (nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size) {    LOG("Solving imports...");    solve_imports(raw_data, nt_header, import_descriptor);}

Error Log Code

    if (!parse_imports()) {    LOG_ERROR("Unable to parse imports!");    return false;} uint64_t iat_function_ptr{ imports["TranslateMessage"] };if (!iat_function_ptr) {     LOG_ERROR("Cannot find import");    return false;}

Viewing all articles
Browse latest Browse all 6334

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>