Barebones library to launch a process with a DLL injected. Intended use-case is to be invoked from C# P/Invoke.

injector.h 721B

12345678910111213141516171819202122232425262728293031
  1. #ifndef INJECTOR_H_
  2. #define INJECTOR_H_
  3. #include <cstdint>
  4. #if defined(INJECTOR_EXPORTS)
  5. #define INJECTOR_EXPORT __declspec(dllexport)
  6. #else
  7. #define INJECTOR_EXPORT __declspec(dllimport)
  8. #endif
  9. #if defined(__cplusplus)
  10. extern "C" {
  11. #endif
  12. // Launches `command_line` from `working_directory` and injects `injected_dll`,
  13. // optionally calling `initialize_function` in after injection. If everything
  14. // goes off without a hitch the process ID will be returned, otherwise 0.
  15. INJECTOR_EXPORT uint32_t LaunchInjected(
  16. wchar_t const* command_line,
  17. wchar_t const* working_directory,
  18. wchar_t const* injected_dll,
  19. char const* initialize_function
  20. );
  21. #if defined(__cplusplus)
  22. }
  23. #endif
  24. #endif // INJECTOR_H_