Path: blob/master/external/source/HostingCLR_inject/HostingCLR/Executer.cpp
19535 views
// Author: B4rtik (@b4rtik)1// Project: Execute-dotnet-assembly (https://github.com/b4rtik/metasploit-execute-assembly)2// License: BSD 3-Clause34#include "stdafx.h"5#include "ReflectiveLoader.h"6#include "ReflectiveFree.h"7#include "HostingCLR.h"89extern HINSTANCE hAppInstance;1011BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved)12{13BOOL bReturnValue = TRUE;14switch (dwReason)15{16case DLL_QUERY_HMODULE:17if (lpReserved != NULL)18*(HMODULE *)lpReserved = hAppInstance;19break;20case DLL_PROCESS_ATTACH:21hAppInstance = hinstDLL;22Execute(lpReserved);23fflush(stdout);2425// Free the assembly and parameters26VirtualFree(lpReserved, 0, MEM_RELEASE);2728ReflectiveFree(hinstDLL);2930break;31case DLL_PROCESS_DETACH:32ReflectiveFree(hinstDLL);33break;34case DLL_THREAD_ATTACH:35case DLL_THREAD_DETACH:36break;37}38return bReturnValue;39}404142