int main(int argc, char * argv[])
{
	unsigned long procid = 0;
	WCHAR path[MAX_PATH] = {0};
	WCHAR params[MAX_PATH] = {0};
	if(argc > 1)
	{
		mbstowcs(path,argv[1],MAX_PATH);
	}
	if(argc == 2)
	{
		NTSTATUS temp = RhCreateAndInject(path,NULL,NULL,NULL,L"Hooking.dll",NULL,NULL,NULL,&procid);
	}
	else if(argc == 3)
	{
		mbstowcs(params,argv[2],MAX_PATH);
		NTSTATUS temp = RhCreateAndInject(path,params,NULL,NULL,L"Hooking.dll",NULL,NULL,NULL,&procid);
	}
	else
	{
		printf("Usage is \"This Prog.exe \"c:\\fullpath_and_name_of_exe\" [OPTIONAL]\"cmdlineparams\" ");
		printf("Usage: \"Hooking.dll\" must exist in the same directory as this executable");
	}
	return 0;
}
Esempio n. 2
0
int wmain(int argc, WCHAR* argv[])
{
	if (argc < 3) {
		std::wcout << argv[0] << " dll command_line\n";
		return 1;
	}
	std::wstring dllToInject (argv[1]);
  std::wstring exe (argv[2]);
  exe = exe.substr (0, exe.find (' '));
  std::wstring command_line (argv[2]);
  command_line = command_line.substr (command_line.find (' ') + 1);
        
  ULONG pid;
	NTSTATUS nt = RhCreateAndInject
    ( const_cast<WCHAR*> (exe.c_str())
    , const_cast<WCHAR*> (command_line.c_str())
    , 0
		, EASYHOOK_INJECT_DEFAULT
		, const_cast<WCHAR*> (dllToInject.c_str())
		, nullptr
		, nullptr
		, 0
    , &pid
	  );

	if (nt != 0)
	{
		std::wcout << "RhCreateAndInject failed with error code = " << nt << "\n  " << RtlGetLastErrorString() << "\n";
		return 1;
	}
  	
	return 0;
}