void SetupCRT(const CommandLine& parsed_command_line) { #if defined(OS_WIN) #ifdef _CRTDBG_MAP_ALLOC _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); #else if (!parsed_command_line.HasSwitch(switches::kDisableBreakpad)) { _CrtSetReportMode(_CRT_ASSERT, 0); } #endif // Enable the low fragmentation heap for the CRT heap. The heap is not changed // if the process is run under the debugger is enabled or if certain gflags // are set. bool use_lfh = false; if (parsed_command_line.HasSwitch(switches::kUseLowFragHeapCrt)) use_lfh = parsed_command_line.GetSwitchValue(switches::kUseLowFragHeapCrt) != L"false"; if (use_lfh) { void* crt_heap = reinterpret_cast<void*>(_get_heap_handle()); ULONG enable_lfh = 2; HeapSetInformation(crt_heap, HeapCompatibilityInformation, &enable_lfh, sizeof(enable_lfh)); } #endif }
//used if windows subsystem int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { //notify user if heap is corrupt HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL,0); // Enable run-time memory leak check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif MainEngine engine; //AbstractGame *gamePtr = new Test(); //AbstractGame *gamePtr = new RType(); //AbstractGame *gamePtr = new BouncingBall(); //AbstractGame *gamePtr = new BouncingBalls(); //AbstractGame *gamePtr = new Goniometry(); AbstractGame *gamePtr = new Chainreaction(); //AbstractGame *gamePtr = new SolarSystem(); //AbstractGame *gamePtr = new ButtonTextBoxTestApp(); //AbstractGame *gamePtr = new LineCollision(); //AbstractGame *gamePtr = new FollowMouse(); //AbstractGame *gamePtr = new PolygonTester(); //AbstractGame *gamePtr = new AlteredBeast(); //AbstractGame *gamePtr = new CaveApp(); //AbstractGame *gamePtr = new AudioTester(); engine.SetGame(gamePtr); if (SUCCEEDED(engine.Initialize())) { engine.RunMessageLoop(); } delete gamePtr; return 0; }
// Program's main entry point int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow) { #ifdef _DEBUG AllocConsole(); HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE); int hCrt = _open_osfhandle((long) handle_out, _O_TEXT); FILE* hf_out = _fdopen(hCrt, "w"); setvbuf(hf_out, NULL, _IONBF, 1); *stdout = *hf_out; HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE); hCrt = _open_osfhandle((long) handle_in, _O_TEXT); FILE* hf_in = _fdopen(hCrt, "r"); setvbuf(hf_in, NULL, _IONBF, 128); *stdin = *hf_in; #endif UNREFERENCED_PARAMETER(hPrevInstance); SingleFace app; HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); return app.Run(hInstance, lpCmdLine, nCmdShow); }
// Provides the application entry point. int WINAPI WinMain( HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */ ) { // Use HeapSetInformation to specify that the process should // terminate if the heap manager detects an error in any heap used // by the process. // The return value is ignored, because we want to continue running in the // unlikely event that HeapSetInformation fails. HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); if (SUCCEEDED(CoInitialize(NULL))) { { DemoApp app; if (SUCCEEDED(app.Initialize())) { app.RunMessageLoop(); } } CoUninitialize(); } return 0; }
//------------------------------------------------------------------------------ void CvDllGameContext::InitializeSingleton() { if(s_pSingleton == NULL) { FAssert(s_hHeap == INVALID_HANDLE_VALUE); s_hHeap = HeapCreate(0, 0, 0); // // Enable the low-fragmentation heap (LFH). Starting with Windows Vista, // the LFH is enabled by default but this call does not cause an error. // ULONG HeapInformation = 2; //Low Fragmentation Heap HeapSetInformation(s_hHeap, HeapCompatibilityInformation, &HeapInformation, sizeof(HeapInformation)); } s_pSingleton = FNEW(CvDllGameContext(), c_eCiv5GameplayDLL, 0); #if defined(CUSTOM_MODS_H) CUSTOMLOG("%s - Startup (Version %u%s - Build %s %s%s)", MOD_DLL_NAME, MOD_DLL_VERSION_NUMBER, MOD_DLL_VERSION_STATUS, __DATE__, __TIME__, MOD_DLL_CUSTOM_BUILD_NAME); #if defined(MOD_GLOBAL_MAX_MAJOR_CIVS) CUSTOMLOG(" - supporting %i major civilizations", MAX_MAJOR_CIVS); #endif #endif }
/* * http://msdn.microsoft.com/en-us/library/windows/desktop/aa366750(v=vs.85).aspx */ void CMemorymgt::EnableLFH() { // get default heaps while (true) { DWORD lTotalHeapNum = ::GetProcessHeaps(mHeapHandleCount, mHeapHandle.begin()); if (lTotalHeapNum == 0) { return; } if (lTotalHeapNum != mHeapHandleCount) { mHeapHandleCount = lTotalHeapNum; mHeapHandle.reset(mHeapHandleCount); } else break; } // enable low fragmentation heap unsigned long lHeapFragValue = 2; for (int iter = 0; iter < mHeapHandleCount; ++iter) { if (!HeapSetInformation( mHeapHandle[iter], HeapCompatibilityInformation, &lHeapFragValue, sizeof(lHeapFragValue) )) { } } }
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(nCmdShow); UNREFERENCED_PARAMETER(pCmdLine); //notify user if heap is corrupt HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL,0); // Enable run-time memory leak check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); typedef HRESULT(__stdcall *fPtr)(const IID&, void**); HMODULE hDll = LoadLibrary(L"dxgidebug.dll"); fPtr DXGIGetDebugInterface = (fPtr)GetProcAddress(hDll, "DXGIGetDebugInterface"); IDXGIDebug* pDXGIDebug; DXGIGetDebugInterface(__uuidof(IDXGIDebug), (void**)&pDXGIDebug); //_CrtSetBreakAlloc(4039); #endif auto pGame = new MainGame(); auto result = pGame->Run(hInstance); UNREFERENCED_PARAMETER(result); delete pGame; return 0; }
int WINAPI WinMain( HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */ ) { // Ignoring the return value because we want to continue running even in the // unlikely event that HeapSetInformation fails. HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); if (SUCCEEDED(CoInitialize(NULL))) { { DemoApp app; if (SUCCEEDED(app.Initialize())) { app.RunMessageLoop(); } } CoUninitialize(); } return 0; }
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PWSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); if (!CoInitializeSingle::Initialize()){ } HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); Metro::MUI::muiController.Init(); _Module.Init(nullptr, hInstance); MSG msg; ::InitCommonControls(); Metro::MetroWindow iMetroWindow; RECT rect = { (::GetSystemMetrics(SM_CXSCREEN) - 720) / 2, (::GetSystemMetrics(SM_CYSCREEN) - 450) / 2, (::GetSystemMetrics(SM_CXSCREEN) + 720) / 2, (::GetSystemMetrics(SM_CYSCREEN) + 450) / 2 }; if (iMetroWindow.Create(nullptr, rect, METRO_INTERNAL_WINDOWLNAME, WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_ACCEPTFILES) == nullptr) { return -1; } DWORD dwExit = 0; iMetroWindow.ShowWindow(nCmdShow); iMetroWindow.UpdateWindow(); while (GetMessage(&msg, nullptr, 0, 0)>0) { TranslateMessage(&msg); DispatchMessage(&msg); } dwExit = iMetroWindow.GetExitCode(); _Module.Term(); return dwExit; }
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR, int nCmdShow) { HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); MSG msg; ZeroMemory(&msg, sizeof(msg)); // Perform application initialization. if (!InitInstance(hInstance, nCmdShow)) { NotifyError(NULL, L"Could not initialize the application.", HRESULT_FROM_WIN32(GetLastError())); return FALSE; } // Main message loop. while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } // Clean up. if (g_pPlayer) { g_pPlayer->Shutdown(); SafeRelease(&g_pPlayer); } return 0; }
inline static void _win32_initHeap( void ) { g_privateHeap = HeapCreate( 0, 0, 0 ); unsigned int info = 0; HeapSetInformation( g_privateHeap, HeapCompatibilityInformation, &info, sizeof(info) ); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hInstance); UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(nCmdShow); #if defined (DEBUG) | (_DEBUG) HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); //Enable run-time memory leak check for debug builds. //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); //_CrtSetBreakAlloc(0) #endif //Create the engine //Engine* pEngine = ne Engine(); //Kick of the game //int result = pEngine->RunLoop(); //Delete the engine //delete pEngine; //return result; return 0; }
static int subsys_winprocess_initialize(void) { #ifndef HeapEnableTerminationOnCorruption #define HeapEnableTerminationOnCorruption 1 #endif /* On heap corruption, just give up; don't try to play along. */ HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); /* SetProcessDEPPolicy is only supported on 32-bit Windows. * (On 64-bit Windows it always fails, and some compilers don't like the * PSETDEP cast.) * 32-bit Windows defines _WIN32. * 64-bit Windows defines _WIN32 and _WIN64. */ #ifndef _WIN64 /* Call SetProcessDEPPolicy to permanently enable DEP. The function will not resolve on earlier versions of Windows, and failure is not dangerous. */ HMODULE hMod = GetModuleHandleA("Kernel32.dll"); if (hMod) { typedef BOOL (WINAPI *PSETDEP)(DWORD); PSETDEP setdeppolicy = (PSETDEP)GetProcAddress(hMod, "SetProcessDEPPolicy"); if (setdeppolicy) { /* PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION */ setdeppolicy(3); } } #endif /* !defined(_WIN64) */ return 0; }
bool AL_CALLTYPE alHeapWin32_SetLowFragmentation(void* _this, bool bEnableLowFragmantation) { alHeapWin32i* _data = (alHeapWin32i*)_this; ULONG HeapFragValue = bEnableLowFragmantation ? 2 : 0; if (!_data->heap) return false; return !!HeapSetInformation(_data->heap, HeapCompatibilityInformation, &HeapFragValue, sizeof(HeapFragValue)); }
// Program's main entry point int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); MultiFace app; HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); return app.Run(hInstance, lpCmdLine, nCmdShow); }
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR pszCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(pszCmdLine); UNREFERENCED_PARAMETER(nCmdShow); HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (SUCCEEDED(hr)) { { DemoApp app; HWND hWndMain = NULL; hWndMain = app.Initialize(hInstance); hr = hWndMain ? S_OK : E_FAIL; if (SUCCEEDED(hr)) { BOOL fRet; MSG msg; // Load accelerator table HACCEL haccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_ACCEL_TABLE)); if (haccel == NULL) { hr = E_FAIL; } // Main message loop: while ((fRet = GetMessage(&msg, NULL, 0, 0)) != 0) { if (fRet == -1) { break; } else { if (!TranslateAccelerator(hWndMain, haccel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } } } } CoUninitialize(); } return 0; }
void _gum_memory_init (void) { ULONG heap_frag_value = 2; _gum_memory_heap = HeapCreate (HEAP_GENERATE_EXCEPTIONS, 0, 0); HeapSetInformation (_gum_memory_heap, HeapCompatibilityInformation, &heap_frag_value, sizeof (heap_frag_value)); }
AutoDiscoveryServerImpl::AutoDiscoveryServerImpl(const std::string& type, unsigned int port) { HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); std::ostringstream ss; ss << port; DNSServiceErrorType err = RegisterService(&client, "", type.c_str(), "", NULL, ss.str().c_str(), this); if (!client || err != kDNSServiceErr_NoError) { OSG_WARN << "AutoDiscoveryImpl :: DNSService call failed " << (long int)err << std::endl; } }
int WINAPI wWinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPWSTR lpCmdLine, int /* nCmdShow */) { LPWSTR* arg_list; int arg_num = 0; // Ignore the return value because we want to continue running even in the // unlikely event that HeapSetInformation fails. HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); if (SUCCEEDED(CoInitialize(NULL))) { App *app = new App(); arg_list = CommandLineToArgvW(lpCmdLine, &arg_num); if (arg_num == 2) { CardData data; strcpy_s(data.username, ws2s(arg_list[0]).c_str()); strcpy_s(data.password, ws2s(arg_list[1]).c_str()); try { NFC_READER->Initialize(); NFC_READER->Write(data); NFC_READER->Uninitialize(); } catch (...) { MessageBox(NULL, L"שגיאה התרחשה בכתיבה לכרטיס או שלא נמצא כרטיס...", L"שים/י לב!", STDMSGBOX | MB_ICONWARNING); return 1; } return 0; } if (SUCCEEDED(app->Initialize())) { app->ChangeScreenTo(App::Screens::WaitingToCardScreen); MSG msg; memset(&msg, 0, sizeof(msg)); while (app->AppMode != -1) { if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } app->Update(); app->Render(); } } delete app; CoUninitialize(); } return 0; }
TEST(MallocTests, HeapInformation) { HANDLE heap = GetProcessHeap(); ASSERT_NE(heap, (HANDLE)NULL); ULONG heap_type; SIZE_T got; BOOL res = HeapQueryInformation(heap, HeapCompatibilityInformation, &heap_type, sizeof(heap_type), &got); ASSERT_EQ(res, TRUE); ASSERT_EQ(got, sizeof(heap_type)); ASSERT_LT(heap_type, 3); /* 0, 1, 2 are the only valid values */ heap_type = 2; res = HeapSetInformation(heap, HeapCompatibilityInformation, &heap_type, sizeof(heap_type)); ASSERT_EQ(res, TRUE); heap_type = 2; res = HeapSetInformation(heap, HeapEnableTerminationOnCorruption, NULL, 0); ASSERT_EQ(res, TRUE); }
int WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, PVOID pvNothing) { CFilePathTranslator FileTranslator; std::string WorkingDirectory; if ( dwReason == DLL_PROCESS_ATTACH ) { WriteDebugEvent( SString( "DLL_PROCESS_ATTACH %08x", pvNothing ) ); if ( IsGTAProcess() ) { WriteDebugEvent( SString( "ModuleFileName: %s", *GetLaunchPathFilename() ) ); AddUtf8FileHooks(); // Set low frag heap for XP ULONG heapInfo = 2 ; HeapSetInformation( GetProcessHeap(), HeapCompatibilityInformation, &heapInfo, sizeof( heapInfo ) ); FileTranslator.GetGTARootDirectory ( WorkingDirectory ); SetCurrentDirectory ( WorkingDirectory.c_str ( ) ); // For dll searches, this call replaces the current directory entry and turns off 'SafeDllSearchMode' // Meaning it will search the supplied path before the system and windows directory. // http://msdn.microsoft.com/en-us/library/ms682586%28VS.85%29.aspx SetDllDirectory( CalcMTASAPath ( "MTA" ) ); g_pCore = new CCore; FileTranslator.GetGTARootDirectory ( WorkingDirectory ); SetCurrentDirectory ( WorkingDirectory.c_str ( ) ); } } else if (dwReason == DLL_PROCESS_DETACH) { WriteDebugEvent( SString( "DLL_PROCESS_DETACH %08x", pvNothing ) ); if ( IsGTAProcess () ) { RemoveUtf8FileHooks(); AddReportLog( 7102, "Core - PROCESS_DETACH" ); // For now, TerminateProcess if any destruction is attempted (or we'll crash) TerminateProcess ( GetCurrentProcess (), 0 ); if ( g_pCore ) { delete g_pCore; g_pCore = NULL; } } } return TRUE; }
BOOL CEngine::CheckLFH() { // Low-Fragmentation Heap의 사용 // 프로그램이 시작할때 한번호출해준다. // 디버거가 연결되면(F5) 디버그 힙을 사용하므로 CTRL+F5를 눌러야 // Low-Fragmentation Heap이 사용되고, TRUE가 리턴되는것을 알수있다. // Low-Fragmentation Heap의 장점 // 특별히 프로그래머는 신경쓰지 않아도, 메모리풀을 사용, // 프로그램의 질을 높일수있다. // 메모리 단편화를 예방할수있고, 힙메모리생성, 삭제시 효율이 높아진다. // 특히, 멀티코어 시스템에서 높은 성능향상이 있다. // Low-Fragmentation Heap사용시 참고 // 이 함수가 호출되지 않아도, 이코드가 있으면 Win2000Pro Sp4이상의 // OS에서만 동작하므로, Win98을 지원하려고 한다면, 주석화시켜야 한다. // 비스타는 이함수를 호출하지 않아도 기본동작한다. // 이 함수는 하나의 프로세스에 메모리풀을 사용함으로 멀티프로세스로 동작하려면, 수정이필요하다. // 16K보다 작은 메모리를 할당하면, LFH에 메모리가 할당, 그이상은 기존힙에서 할당된다. // 하나의 프로세스에서만 사용시 ULONG HeapFragValue = 2; if(HeapSetInformation(GetProcessHeap(), HeapCompatibilityInformation, &HeapFragValue, sizeof(HeapFragValue)) ) { return TRUE; } return FALSE; // 다수의 프로세스에서 사용시 //HANDLE hHeap[1025]; //UINT uEA = GetProcessHeaps(1024, hHeap); //for (UINT i=0; i<uEA; ++i) //{ // ULONG HeapFragValue = 2; // if(HeapSetInformation(hHeap[i], // HeapCompatibilityInformation, // &HeapFragValue, // sizeof(HeapFragValue) )) // { // return TRUE; // } //} //return FALSE; }
int __cdecl _heap_init ( int mtflag ) { #if defined _M_AMD64 || defined _M_IA64 // HEAP_NO_SERIALIZE is incompatible with the LFH heap mtflag = 1; #endif /* defined _M_AMD64 || defined _M_IA64 */ // Initialize the "big-block" heap first. if ( (_crtheap = HeapCreate( mtflag ? 0 : HEAP_NO_SERIALIZE, BYTES_PER_PAGE, 0 )) == NULL ) return 0; #ifndef _WIN64 // Pick a heap, any heap __active_heap = __heap_select(); if ( __active_heap == __V6_HEAP ) { // Initialize the small-block heap if (__sbh_heap_init(MAX_ALLOC_DATA_SIZE) == 0) { HeapDestroy(_crtheap); _crtheap=NULL; return 0; } } #ifdef CRTDLL else if ( __active_heap == __V5_HEAP ) { if ( __old_sbh_new_region() == NULL ) { HeapDestroy( _crtheap ); _crtheap=NULL; return 0; } } #endif /* CRTDLL */ #elif defined _M_AMD64 || defined _M_IA64 { // Enable the Low Fragmentation Heap for AMD64 and IA64 by default // It's the 8 byte overhead heap, and has generally better // performance charateristics than the 16 byte overhead heap, // particularly for apps that perform lots of small allocations ULONG HeapType = 2; HeapSetInformation(_crtheap, HeapCompatibilityInformation, &HeapType, sizeof(HeapType)); } #endif /* defined _M_AMD64 || defined _M_IA64 */ return 1; }
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(nCmdShow); UNREFERENCED_PARAMETER(hInstance); DotComInitialize dot; HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); return WindowMessageRunLoop(); }
INT WINAPI wWinMain(HINSTANCE,HINSTANCE,LPWSTR,INT) { (void)HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); Application application; // Manages the application logic. if (application.Initialize()) { application.MessageLoop(); } return 0; }
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { if (!IsWindows7SP1OrGreater()) { MessageBoxW(nullptr, L"You need at least Windows 10.", L"Version Not Supported", MB_OK | MB_ICONERROR); return -1; } DotComInitialize dot; HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); return MetroWindowRunLoop(); }
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { unsigned old_fp_state; _controlfp_s(&old_fp_state, _PC_53, _MCW_PC); /*Array<int> test1; std::vector<int> test2; LARGE_INTEGER pc1,pc2; QueryPerformanceCounter(&pc1); for (int i=0;i<9999999;++i) test1.Add(i); QueryPerformanceCounter(&pc2); auto d1 = pc2.QuadPart - pc1.QuadPart; QueryPerformanceCounter(&pc1); for (int i=0;i<9999999;++i) test2.push_back(i); QueryPerformanceCounter(&pc2); auto d2 = pc2.QuadPart - pc1.QuadPart; char debug_str[256]; sprintf(debug_str,"speed1:%llu - speed2:%llu\n",d1,d2); OutputDebugString(debug_str); sprintf(debug_str,"size1:%d - size2:%d\n",test1.size(), test2.capacity()); OutputDebugString(debug_str);*/ HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); MSG msg; //cdioInit(); //cdioTest(); //cdioDeinit(); if (SUCCEEDED(CoInitialize(NULL))) { my_app::DisplayWindow display_window; display_window.Initialize(); do { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { //display_window.Step(); } } while(msg.message!=WM_QUIT); CoUninitialize(); } //Return the exit code to the system. return static_cast<int>(msg.wParam); }
int aa() { HINSTANCE hInstance; HINSTANCE hPrevInstance; PWSTR lpCmdLine; int nCmdShow=SW_SHOWNA; UNREFERENCED_PARAMETER(hPrevInstance); SingleFace app; HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); return app.Run(hInstance, lpCmdLine, nCmdShow); }
int __cdecl wmain() { // Ignoring the return value because we want to continue running even in the // unlikely event that HeapSetInformation fails. HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); if (SUCCEEDED(CoInitialize(NULL))) { PlotData data1(200); for(size_t i = 0; i < 200; ++i) { data1[i * 2] = i / 200.0f; data1[i * 2 + 1] = pow(i, 1.6f) / 8.0f; } PlotData data2(200); for(size_t i = 0; i < 200; ++i) { data2[i * 2] = i / 200.0f; data2[i * 2 + 1] = i; //data2[100 + i * 2] = 1; //data2[101 + i * 2] = 1; } PlotData data3(200); for(size_t i = 0; i < 200; ++i) { data3[i * 2] = i / 200.0f; data3[i * 2 + 1] = i * 2; } PlotData data4(200); for(size_t i = 0; i < 200; ++i) { data4[i * 2 ] = i / 200.0f; data4[i * 2 + 1] = 0.125f * pow(i, 1.3f); } PlotData *data[] = { &data1, &data2, &data3, &data4, 0 }; HRESULT hr = SaveToImageFile(data, 800, 600, 1.0f, 600.0f, 50.0f, 40.0f, 0.1f, 100.0f); if (FAILED(hr)) { wprintf(L"Unexpected error: 0x%x", hr); } CoUninitialize(); } return 0; }
void *Hunk_Begin (int maxsize, int precommit) { // reserve a huge chunk of memory, but don't commit any yet bytes_used = 0; bytes_allocated = 0; #ifdef VIRTUAL_ALLOC_PROFILE small_hits = 0; #endif if (!pagesize) { SYSTEM_INFO sSysInfo; // useful information about the system GetSystemInfo (&sSysInfo); // initialize the structure pagesize = sSysInfo.dwPageSize; } // tempBuff = NULL; // tempBuffSize = TBUFFERLEN; hunkmaxsize = maxsize; #if VIRTUAL_ALLOC if (precommit == maxsize) { membase = VirtualAlloc (NULL, precommit, MEM_COMMIT, PAGE_READWRITE); bytes_allocated = precommit; } else { membase = VirtualAlloc (NULL, maxsize, MEM_RESERVE, PAGE_NOACCESS); if (precommit) { VirtualAlloc (membase, precommit, MEM_COMMIT, PAGE_READWRITE); bytes_allocated = precommit; } } #elif CREATE_HEAP { ULONG lfh = 2; membase = HeapCreate (HEAP_NO_SERIALIZE, 524288, 0); HeapSetInformation (membase, HeapCompatibilityInformation, &lfh, sizeof(lfh)); } #else membase = malloc (maxsize); #endif if (!membase) Sys_Error ("VirtualAlloc reserve failed"); return (void *)membase; }