// bottuum.cpp : Defines the entry point for the console application. // #include #include #include "stdafx.h" #include int main(int argc, TCHAR* argv[]) { if (argc != 3) { fprintf(stderr, "Usage: %s executable dll\n", argv[0]); return 1; } TCHAR* exe = argv[1]; TCHAR* dll = argv[2]; fprintf(stdout, "Running: %s // %s", exe, dll); STARTUPINFO sInfo; PROCESS_INFORMATION pInfo; ZeroMemory(&sInfo, sizeof(sInfo)); ZeroMemory(&pInfo, sizeof(pInfo)); sInfo.cb = sizeof(sInfo); if(!CreateProcess(exe, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pInfo)) { TCHAR szBuf[180]; LPVOID lpMsgBuf; DWORD dw = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); wsprintf(szBuf, L"failed with error %d: %s", dw, lpMsgBuf); MessageBox(NULL, szBuf, L"Error", MB_OK); } WaitForSingleObject( pInfo.hProcess, INFINITE ); CloseHandle( pInfo.hProcess ); CloseHandle( pInfo.hThread ); return 0; }