Git Product home page Git Product logo

manual-dll-loader's Introduction

Banner

Manual DLL Loader

C++ Windows x86 x64

๐Ÿ“– Project Overview :

Custom LoadLibrary / GetProcAddress

This is a custom implementation of different Windows functions :

  • LoadLibraryA

  • GetProcAddress

  • FreeLibrary

You can manualy map DLL into your program, retrieve functions by name or ordinal and free the library.

The loader perform the relocations, and it is fully functionnal with x86 and x64 PE images.

Loading steps :

  1. Copy PE image in memory
  2. Perform the relocations
  3. Resolve imports (IAT)
  4. Execute TLS callbacks
  5. Execute DLL's entry point

The GetFunctionAddress can also be used with a library imported with LoadLibraryA official Windows function.

๐Ÿš€ Getting Started

Visual Studio :

  1. Open the solution file (.sln).
  2. Build the project in Release (x86 or x64)

The loader can be compiled in x86 or x64.

๐Ÿงช Example

You can import DLL and functions easily like when you use LoadLibraryA and GetProcAddress.

//Function pointer
using MessageFncPtr = void (*)();

int main()
{
	const auto lpModule = MemoryLoader::LoadDLL((LPSTR)"test.dll");
	if (lpModule == nullptr)
		return -1;

	auto MessageFnc = (MessageFncPtr)MemoryLoader::GetFunctionAddress((LPVOID)lpModule, (const LPSTR)"Message");
	if (MessageFnc == nullptr)
		return -1;

	MessageFnc();

	MessageFnc = (MessageFncPtr)MemoryLoader::GetFunctionAddressByOrdinal((LPVOID)lpModule, 1);
	if (MessageFnc == nullptr)
		return -1;

	MessageFnc();

	MemoryLoader::FreeDLL(lpModule);

	return 0;
}
Demo.mp4

manual-dll-loader's People

Contributors

adamhlt avatar

Stargazers

ElementDemons avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.