示例#1
0
void Setting::Log(const ablib::string &log){
	if(::GetFileAttributes(m_logfile.c_str()) == -1){
		boost::filesystem::path l(m_logfile);
		::CreateDirectoryReflex(l.parent_path().wstring().c_str());
	}
	static std::wofstream ofs;
	if(!ofs){
		ofs.imbue(std::locale("Japanese",std::locale::ctype));
		ofs.open(m_logfile,std::ios::out | std::ios::app);
	}
	if(ofs){
		ofs << log << std::endl;
	}
#ifndef NDEBUG
	::OutputDebugString(log.c_str());::OutputDebugString(_T("\n"));
#endif
	return;
}
示例#2
0
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,PWSTR pCmdLine, int nShowCmd)
{
	logstream.open("InjectHelper.log", std::ios_base::trunc);
	int argc = 0;
	LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
	if (argc < 1)
	{
		LocalFree(argv);
		return -1;
	}
	logstream << L"Parse Params" << std::endl;
	for (unsigned i = 0; i != argc; ++i)
		logstream << '\t' << i << L". "<<argv[i]<<std::endl;
	logstream << std::endl;
	DWORD processId = wcstoul(argv[0], NULL,10);

	LocalFree(argv);

	h3d::AdjustToken();
	HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);
	if (!hProcess) {
		logstream << L"OpenProcess Failed PID = " << processId <<L" Error Code = " <<GetLastError()<<std::endl;
		return ERROR_INVALID_HANDLE;
	}

	wchar_t directory[MAX_PATH] = {};
	GetCurrentDirectoryW(MAX_PATH, directory);
#ifndef	_WIN64
#ifndef _DEBUG
	bool inject_result = h3d::InjectDLL(OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId), std::wstring(directory) + L"/CaptureHook.x86.dll");
#else
	bool inject_result = h3d::InjectDLL(OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId), std::wstring(directory) + L"/CaptureHook.x86.debug.dll");
#endif
#else
#ifdef _DEBUG
	bool inject_result = h3d::InjectDLL(OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId), std::wstring(directory) + L"/CaptureHook.x64.debug.dll");
#else
	bool inject_result = h3d::InjectDLL(OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId), std::wstring(directory) + L"/CaptureHook.x64.dll");
#endif
#endif
	if (logstream.is_open())
		logstream.close();
	return !inject_result;
}
int mainRoutine()
{
	TraceAntiDebug.open("logs\\antidebug_routines.out");
	TraceAntiVirtual.open("logs\\antivirtual_routines.out");
	TraceAntiSandbox.open("logs\\antisandbox_routines.out");
	TraceRegistry.open("logs\\registry.out");
	RTN_AddInstrumentFunction(Routine, 0);
    PIN_AddFiniFunction(RoutinesFini, 0);
	IMG_AddInstrumentFunction(Image, (VOID *) 1);
    PIN_AddFiniFunction(Fini, 0);
    
    return 0;
}