C++: Dynamic DLL Usage

Objective

Increasing functionality of malware by using external DLL files.-

To do list

  • Create a dll.

  • Import dll into an external CPP program.

  • Call a function from imported dll in external CPP program.

Functions

  • LoadLibrary: Import dll into running process.

    • Header: libloaderapi.h

    • Definition: HMODULE LoadLibraryA(LPCSTR lpLibFileName);

      • lpLibFileName: Path of dll file.

  • GetProcAddress: Retrieve the address of a function inside the dll.

    • Header: libloaderapi.h

    • Definition: FARPROC GetProcAddress(HMODULE hModule,LPCSTR lpProcName);

      • hModule: DLL handle.

      • lpProcName: Name of the function to retrieve.

Application

DLL

Compile as dll: g++ -shared -o launcher.dll dll.cpp -std=c++11

CPP

compile: g++ executer.cpp -o execute.exe

References

Last updated

Was this helpful?