Example #1
0
BOOL WINAPI EjectLibA(DWORD dwProcessId, PCSTR pszLibFile) {

   // Allocate a (stack) buffer for the Unicode version of the pathname
   PWSTR pszLibFileW = (PWSTR) 
      _alloca((lstrlenA(pszLibFile) + 1) * sizeof(WCHAR));

   // Convert the ANSI pathname to its Unicode equivalent
   wsprintfW(pszLibFileW, L"%S", pszLibFile);

   // Call the Unicode version of the function to actually do the work.
   return(EjectLibW(dwProcessId, pszLibFileW));
}
Example #2
0
BOOL WINAPI EjectLibA(DWORD dwProcessId, PCSTR pszLibFile)
{

    // Allocate a (stack) buffer for the Unicode version of the pathname
    SIZE_T cchSize = lstrlenA(pszLibFile) + 1;
    PWSTR pszLibFileW = (PWSTR)
                        _alloca(cchSize * sizeof(wchar_t));

    // Convert the ANSI pathname to its Unicode equivalent
    StringCchPrintfW(pszLibFileW, cchSize, L"%S", pszLibFile);

    // Call the Unicode version of the function to actually do the work.
    return(EjectLibW(dwProcessId, pszLibFileW));
}
Example #3
0
int WINAPI _tWinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) 
{
	//процесс
	HANDLE handle = processHandle(L"DllProject.exe"); //куда внедряем
	DWORD dwProcessId = GetProcessId(handle);
	CloseHandle(handle);

	//dll
	TCHAR szLibFile[MAX_PATH];
	//GetModuleFileName(NULL, szLibFile, sizeof(szLibFile));
	//_tcscpy(_tcsrchr(szLibFile, TEXT('\\')) + 1, TEXT("Dll.dll"));
	_tcscpy(szLibFile, TEXT("C:\\Projects\\InjectDll\\Dll\\Debug\\ImportDll.dll")); //что внедряем

	//инжектируем
	if (InjectLibW(dwProcessId, szLibFile)) 
	{
		MessageBox(NULL,L"DLL Injection/Ejection successful. Pause!",NULL,MB_OK); 
		EjectLibW(dwProcessId, szLibFile);
	} 
	else 
	{
		MessageBox(NULL,L"DLL Injection/Ejection failed.",NULL,MB_OK);
	}
}