BOOL CSysinfo::GetProcessName (pid_t pid, char *dest, int sz) { // this code is deprecated. It was causing ACCESS_VIOLATIONS // on Windows XP. #if 0 DWORD *block; Refresh(); block = FindBlock (pid); if (!block) { dest[0] = '\0'; return FALSE; } MakeAnsiString ((WORD*)(*(block+15)), dest); #endif HANDLE Hnd; if( ! (Hnd = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid))) { return FALSE; } if ( ! GetModuleBaseName(Hnd, NULL, dest, sz) ) { return FALSE; } return TRUE; }
int32 App::Run() { try { if(createConsole) { Win32Call(AllocConsole()); Win32Call(SetConsoleTitle(applicationName.c_str())); FILE* consoleFile = nullptr; freopen_s(&consoleFile, "CONOUT$", "wb", stdout); } window.SetClientArea(deviceManager.BackBufferWidth(), deviceManager.BackBufferHeight()); deviceManager.Initialize(window); if(showWindow) window.ShowWindow(); blendStates.Initialize(deviceManager.Device()); rasterizerStates.Initialize(deviceManager.Device()); depthStencilStates.Initialize(deviceManager.Device()); samplerStates.Initialize(deviceManager.Device()); // Create a font + SpriteRenderer font.Initialize(L"Arial", 18, SpriteFont::Regular, true, deviceManager.Device()); spriteRenderer.Initialize(deviceManager.Device()); Profiler::GlobalProfiler.Initialize(deviceManager.Device(), deviceManager.ImmediateContext()); window.RegisterMessageCallback(WM_SIZE, OnWindowResized, this); // Initialize AntTweakBar TwCall(TwInit(TW_DIRECT3D11, deviceManager.Device())); // Create a tweak bar tweakBar = TwNewBar("Settings"); std::string helpTextDefinition = MakeAnsiString(" GLOBAL help='%s' ", globalHelpText.c_str()); TwCall(TwDefine(helpTextDefinition.c_str())); TwCall(TwDefine(" GLOBAL fontsize=3 ")); Settings.Initialize(tweakBar); TwHelper::SetValuesWidth(Settings.TweakBar(), 120, false); AppSettings::Initialize(deviceManager.Device()); Initialize(); AfterReset(); while(window.IsAlive()) { if(!window.IsMinimized()) { timer.Update(); Settings.Update(); CalculateFPS(); AppSettings::Update(); Update(timer); UpdateShaders(deviceManager.Device()); AppSettings::UpdateCBuffer(deviceManager.ImmediateContext()); Render(timer); // Render the profiler text spriteRenderer.Begin(deviceManager.ImmediateContext(), SpriteRenderer::Point); Profiler::GlobalProfiler.EndFrame(spriteRenderer, font); spriteRenderer.End(); { PIXEvent pixEvent(L"Ant Tweak Bar"); // Render the TweakBar UI TwCall(TwDraw()); } deviceManager.Present(); } window.MessageLoop(); } } catch(SampleFramework11::Exception exception) { exception.ShowErrorMessage(); return -1; } ShutdownShaders(); TwCall(TwTerminate()); if(createConsole) { fclose(stdout); FreeConsole(); } return returnCode; }