//***************************************************************************** // // The UART interrupt handler. // //***************************************************************************** void UART0IntHandler(void) { unsigned long ulStatus; tBoolean bRc; // // Get the interrrupt status. // ulStatus = UARTIntStatus(UART0_BASE, true); // // Clear the asserted interrupts. // UARTIntClear(UART0_BASE, ulStatus); // // Check what is the source of the interrupt // //if(ulStatus & UART_INT_OE) //{ //} //else if(ulStatus & UART_INT_BE) //{ //} //else if(ulStatus & UART_INT_PE) //{ //} if(ulStatus & UART_INT_TX) { // TX int // Push next char to transmitter bRc = true; while(m_nTxBuffIn > 0 && bRc == true) { bRc = UARTCharPutNonBlocking(UART0_BASE,m_tTxBuff[m_nTxNextNdx]); if(bRc == true) { m_nTxNextNdx++; m_nTxBuffIn--; } } } else if(ulStatus & UART_INT_RX || ulStatus & UART_INT_RT) { // RX int // Read all RX fifo data while(UARTCharsAvail(UART0_BASE)) { // Read the next character from the UART // (and write it back to the UART) ? #if defined(stabilizition) ContropMessageLoop(UART0_BASE,0); #else MessageLoop(UART0_BASE,0); #endif } } }
static DWORD WINAPI ThreadProc(_In_ LPVOID lpParameter) { MessageLoop(); //send a message to the other thread to synchronize the shutdown of this thread //after that message is received, this thread (and the whole dll instance) is dead. WritePipe(eMessage_BRK_Complete); return 0; }
int App::Run() { if (InitInstance()) { return MessageLoop(); } else { ::PostQuitMessage(-1); return -1; } }
/* * SetGrepDialogFile - set the current file being used by the dialog */ bool SetGrepDialogFile( char *str ) { if( grepHwnd != NULL ) { SetDlgItemText( grepHwnd, GREP_CURRENT_FILE, str ); MessageLoop( false ); } return( cancelPressed ); } /* SetGrepDialogFile */
//--------------------------------------------------------------------------------------------------------------------- void CApplication::Run(HINSTANCE hInstance) { m_hAppInstance = hInstance; Initialize(); MessageLoop(); Shutdown(); }
/* * MySpawn - spawn a windows app */ int MySpawn( char *cmd ) { FARPROC proc; HANDLE inst; cmd_struct cmds; char path[FILENAME_MAX]; #ifndef __WINDOWS_386__ char buffer[FILENAME_MAX]; #endif int rc; GetSpawnCommandLine( path, cmd, &cmds ); cmds.cmd[cmds.len] = 0; proc = MakeProcInstance( (FARPROC)NotifyHandler, InstanceHandle ); if( !NotifyRegister( (HANDLE)NULLHANDLE, (LPFNNOTIFYCALLBACK)proc, NF_NORMAL ) ) { FreeProcInstance( proc ); return( -1 ); } strcat( path, " " ); strcat( path, &(cmds.cmd[0]) ); inst = (HANDLE) WinExec( (LPCSTR)path, SW_SHOWNORMAL ); if( inst > (HANDLE)32 ) { union REGS in_regs, out_regs; doneExec = FALSE; #ifdef __WINDOWS_386__ moduleHandle = GetModuleHandle( PASS_WORD_AS_POINTER( inst ) ); #else GetModuleFileName( inst, buffer, FILENAME_MAX - 1 ); moduleHandle = GetModuleHandle( buffer ); #endif // waiting doesn't work under win-os2 so don't wait! in_regs.h.ah = 0x30; in_regs.h.al = 0x0; intdos( &in_regs, &out_regs ); if( out_regs.h.al == 20 ) { doneExec = TRUE; } instanceHandle = inst; EditFlags.HoldEverything = TRUE; while( !doneExec ) { MessageLoop( TRUE ); Yield(); } EditFlags.HoldEverything = FALSE; rc = 0; } else { rc = -1; } NotifyUnRegister( (HANDLE)NULLHANDLE ); FreeProcInstance( proc ); return( rc ); } /* MySpawn */
LRESULT CWindow::Show(HINSTANCE hInstance, int nShow, TCHAR *szClassName, TCHAR *szWindowName) { MSG msg; if (RegisterClass(hInstance, szClassName) == NULL) return -1; if (InitInstance(hInstance, nShow, szClassName, szWindowName) == False) return -1; return MessageLoop(&msg); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdline, int show) { instance = hInstance; hFont = CreateFont(-17, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana"); hFont2 = CreateFont(-11, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana"); RegisterClasses(); hwndmain = CreateMainWindow(); CreateWindowContent(hwndmain); return MessageLoop(); }
//------------------------------------------------------------------------ int CEGForm::EnterMessageLoop() { MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { MessageLoop(msg); } return (int) msg.wParam; }
/* Initializes instances, creating and displaying their main window (calls InitApplication for the first executing instance; calls InitInstance for all instances).Runs the application. Enters message loop if initialization was successful. */ void TApplication::Run() { if ( !hPrevInstance ) InitApplication(); if (Status == 0 ) InitInstance(); if (Status == 0) MessageLoop(); else Error(Status); }
int main(void) { #if BC5_MODULE /* Prevent the LED0 flashing during charging */ ChargerConfigure(CHARGER_SUPPRESS_LED0, 1); #endif MessageSend( &led_controller1_task, 0 , 0 ); MessageLoop(); return 0; }
/* * KeyboardHit - test for a waiting key */ bool KeyboardHit( void ) { if( bufferTop != bufferBottom ) { return( TRUE ); } MessageLoop( TRUE ); if( bufferTop != bufferBottom ) { return( TRUE ); } return( FALSE ); } /* KeyboardHit */
void Main() { Window wnd; wnd.Create("‚Ä‚·‚Æ", 0, 0, 100, 100, WindowOption::StandardStyle| WindowOption::ClientSize| WindowOption::Centering); wnd.Show(); MessageLoop(); //MainLoop(Run); }
void fatal( void ) { #if defined( __WINDOWS__ ) WaitForFirst = FALSE; MessageLoop(); CloseShop(); MsgFini(); exit( 0 ); #else MsgFini(); _exit( 1 ); #endif }
void Input::Poll() { // poll input window messages #if defined(_WIN32) MessageLoop(); #elif defined(__linux__) CheckMonitor(); #endif // input device handling for(int i = 0; i < numControllers; ++i) { Controller& pad = controllers[i]; switch(pad.type) { case KEYBOARD_AND_MOUSE: PollKeyboardAndMouse(); break; case GAMEPAD_XINPUT: PollXInputGamepad(i); break; case GAMEPAD_EVDEV: PollEvDevGamepad(i); break; } pad.Update(); } // mouse position handling #if defined(WIN32) POINT mouseScreenPosition; if(GetCursorPos(&mouseScreenPosition)) { mousePosition[0] = mouseScreenPosition.x; mousePosition[1] = mouseScreenPosition.y; } #elif defined(X11) { Window root, child; int rootCoords[2]; int windowCoords[2]; unsigned int mask; XQueryPointer(display, window, &root, &child, &rootCoords[0], &rootCoords[1], &windowCoords[0], &windowCoords[1], &mask); mousePosition[0] = windowCoords[0]; mousePosition[1] = windowCoords[1]; } #endif }
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { WindowsInitialization(); gen_tabs(); // initialize AES tables CheckSpecialArgs(); // handle commandline std::auto_ptr<document::Document> doc(new document::Document); if(g_documentFilePath.empty()) { // haven't got a filename, check for embedded data. If we've got embedded data, // make a temp copy of our exe, and launch that with "-edit". If no embedded data, // we'll end up with a blank note instead. FileEndData::FileEndData fed( xstring(g_moduleName), true ); if(fed.HasData()) return CopyAndSpawn() ? 0 : -1; } else { // We've got a filename from commandline, work with that file. if(!CheckAndLoadEmbeddedDocument(g_documentFilePath, doc)) { util::error_box(strErrorLoad); return -1; } } // Now doc is either loaded from our own executable, or blank - start the editor. editor::Editor edit(doc); if(!g_documentFilePath.empty()) edit.UpdateTitle(g_documentFilePath.c_str()); MessageLoop(edit.GetHWND()); if(g_editorMode) { // We were originally launched with "-edit" argument, which means we're running // from a temp file that should be erased. Launch original process to delete temp. //TODO: what if a nosy user is messing with commandline args? xstring args(_T("-erase:\"")); args.append(g_moduleName); args.append(_T("\"")); util::launch(g_documentFilePath, args, false); } return 0; }
void SimpleDeviceWindow::Play() { CreateNativeWindow(); CreateInterface(); CreateDevice(); Init3D(); m_timer.Reset(); while(!m_exit) { m_timer.Set(); MessageLoop(); Render(m_timer.m_elapsed); } Dispose(); }
INT WINAPI wWinMain(HINSTANCE,HINSTANCE,LPWSTR,INT) { (void)HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); HWND hwnd = 0; if (InitializeApp() && InitializeWindow(&hwnd)) { MessageLoop(hwnd); } CleanUp(); return 0; }
int main(void) { /* Set app_handler() function to handle app's messages */ app.task.handler = app_handler; /* Set app task to receive PIO messages */ MessagePioTask(&app.task); /* Setup PIO interrupt messages */ PioDebounce32(BUTTON_A | BUTTON_B, /* PIO pins we are interested in */ 2, 20); /* 2 reads and 20ms between them */ MessageLoop(); return 0; }
DWORD WINAPI MyMouseLogger(LPVOID lpParm) { HINSTANCE hInstance = GetModuleHandle(NULL); if (!hInstance) hInstance = LoadLibrary((LPCSTR) lpParm); if (!hInstance) return 1; hMouseHook = SetWindowsHookEx ( WH_MOUSE_LL, (HOOKPROC) KeyboardEvent, hInstance, NULL ); MessageLoop(); UnhookWindowsHookEx(hMouseHook); return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int cmdShow) { static TCHAR szAppName[] = TEXT("SampleSRS"); if (!_RegisterClass(szAppName)) { return 1; } if (!_CreateWindow(szAppName, cmdShow)) { return 1; } init_log(); return MessageLoop(); }
// /// Runs this message thread, returns when the message queue quits. Initializes /// instances. Runs the thread's message loop. Each of the virtual functions called /// are expected to throw an exception if there is an error. /// Exceptions that are not handled, that is, where the status remains non-zero, are /// propagated out of this function. The message queue is still flushed and /// TermInstance called. // int TMsgThread::Run() { int status = 0; try { InitInstance(); LoopRunning = true; status = MessageLoop(); } catch (...) { LoopRunning = false; FlushQueue(); TermInstance(status); throw; } LoopRunning = false; FlushQueue(); return TermInstance(status); }
void handle_ver_dlg(BOOL kill) { static HWND hwnd; if (kill) { if (hwnd) DestroyWindow(hwnd); hwnd = NULL; return; } if (hwnd) { MessageLoop(0); } else if (GetTickCount() > verify_time) { #ifdef NSIS_COMPRESS_WHOLE if (g_hwnd) { if (g_exec_flags.status_update & 1) { TCHAR bt[64]; wsprintf(bt, _T("... %d%%"), calc_percent()); update_status_text(0, bt); } } else #endif { hwnd = CreateDialog( g_hInstance, MAKEINTRESOURCE(IDD_VERIFY), 0, verProc ); ShowWindow(hwnd, SW_SHOW); } } }
int CradleGame::Start() { HRESULT hr = E_FAIL; wchar_t* filePath = L"D:\\Dropbox\\Dropbox\\_DirectX\\Source\\Cradle\\Debug\\Content\\Shaders\\SolidColor.hlsl"; if (!m_Resources->LoadShaders()) { Sleep(5000); return 0; } m_Resources->LoadMeshes(); /* D3D11_INPUT_ELEMENT_DESC vertexLayout[] = { { "POSITION" // Semantic name , 0 // Semantic index , DXGI_FORMAT_R32G32B32_FLOAT // Format , 0 // Input slot , 0 // Aligned byte offset , D3D11_INPUT_PER_VERTEX_DATA // Input slot class , 0 // Instance data step rate } , { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; unsigned int totalLayoutElements = ARRAYSIZE(vertexLayout); hr = m_cd3d->m_d3dDevice->CreateInputLayout(vertexLayout , totalLayoutElements , vsBuffer->GetBufferPointer() , vsBuffer->GetBufferSize() , &m_inputLayout); HRPRINT(hr, L"Failed to create InputLayout\n", L"Created InputLayout\n"); D3D11_SAMPLER_DESC colorMapDesc; ZeroMemory(&colorMapDesc, sizeof(colorMapDesc)); colorMapDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; colorMapDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; colorMapDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; colorMapDesc.ComparisonFunc = D3D11_COMPARISON_NEVER; colorMapDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; colorMapDesc.MaxLOD = D3D11_FLOAT32_MAX; hr = m_cd3d->m_d3dDevice->CreateSamplerState(&colorMapDesc, &m_samplerState); HRPRINT(hr, L"Failed to create sampler\n", L"Created sampler\n"); */ m_Actor = new CradleActor[m_numActors]; srand(time(NULL)); for (int i = 0; i < m_numActors; i++) { int j = rand(); double r = rand() / ((double)(RAND_MAX + 1)); if (r > 0.75) { m_Actor[i].SetMesh((CradleMesh*)m_Resources->GetMesh(L"monkey")); } else if (r > 0.50) { m_Actor[i].SetMesh((CradleMesh*)m_Resources->GetMesh(L"monkey_smooth")); } else if (r > 0.25) { m_Actor[i].SetMesh((CradleMesh*)m_Resources->GetMesh(L"cube")); } else { m_Actor[i].SetMesh((CradleMesh*)m_Resources->GetMesh(L"cylinder")); } m_Actor[i].m_Offset.x = (((float)i - ((float)m_numActors * 0.5f))* 5.0f) / 50.0f; m_Actor[i].m_Offset.y = (i % 50) * 5.0f; // wprintf_s(L"RANDOM: float(%f) int(%d)\n", r, j); m_Actor[i].m_rotationRate = (float)((float)r * 1.0f + 1.0f); } m_camera = new CradleCamera(this); m_camera->Initialize(60.0f * 3.14f / 180, (float)((float)m_cWindow->GetClientWidth() / (float)m_cWindow->GetClientHeight()), 0.1f, 1000.0f); wprintf_s(L"Created camera with (%d, %d)\n", m_cWindow->GetClientWidth(), m_cWindow->GetClientHeight()); unsigned int stride = sizeof(CradleVertexDeclarations::VertexPosTex); unsigned int offset = 0; ID3D11InputLayout* il = m_Resources->GetInputLayout(L"SolidColor"); CradleMesh* mesh = (CradleMesh*)m_Resources->GetMesh(m_meshToUse); ID3D11Buffer* vb = ((CradleMesh*)m_Resources->GetMesh(m_meshToUse))->GetVertexBuffer(); m_cd3d->m_d3dContext->IASetInputLayout(il); m_cd3d->m_d3dContext->IASetVertexBuffers(0, 1, &vb, &stride, &offset); m_cd3d->m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); ID3D11RasterizerState* rState; CD3D11_RASTERIZER_DESC rDesc; rDesc.AntialiasedLineEnable = false; rDesc.CullMode = D3D11_CULL_BACK; rDesc.DepthBias = 0; rDesc.DepthBiasClamp = 0.0f; rDesc.DepthClipEnable = true; rDesc.FillMode = D3D11_FILL_SOLID; rDesc.FrontCounterClockwise = false; rDesc.MultisampleEnable = false; rDesc.ScissorEnable = false; rDesc.SlopeScaledDepthBias = 0.0f; m_cd3d->m_d3dDevice->CreateRasterizerState(&rDesc, &rState); m_cd3d->m_d3dContext->RSSetState(rState); m_cd3d->m_d3dContext->VSSetShader(m_Resources->GetVertexShader(L"SolidColor"), 0, 0); m_cd3d->m_d3dContext->PSSetShader(m_Resources->GetPixelShader(L"SolidColor"), 0, 0); // m_cd3d->m_d3dContext->PSSetShaderResources(0, 1, &m_texture->m_colorData); // m_cd3d->m_d3dContext->PSSetSamplers(0, 1, &m_samplerState); // */ D3D11_BUFFER_DESC instanceBufferDesc; D3D11_SUBRESOURCE_DATA instanceData; m_instanceData = new CradleVertexDeclarations::InstanceData[m_numActors]; for (int i = 0; i < m_numActors; i++) { m_instanceData[i].world0 = DirectX::XMFLOAT4( m_Actor[i].m_mWorld.m[0][0], m_Actor[i].m_mWorld.m[0][1], m_Actor[i].m_mWorld.m[0][2], m_Actor[i].m_mWorld.m[0][3] ); m_instanceData[i].world1 = DirectX::XMFLOAT4( m_Actor[i].m_mWorld.m[1][0], m_Actor[i].m_mWorld.m[1][1], m_Actor[i].m_mWorld.m[1][2], m_Actor[i].m_mWorld.m[1][3] ); m_instanceData[i].world2 = DirectX::XMFLOAT4( m_Actor[i].m_mWorld.m[2][0], m_Actor[i].m_mWorld.m[2][1], m_Actor[i].m_mWorld.m[2][2], m_Actor[i].m_mWorld.m[2][3] ); m_instanceData[i].world3 = DirectX::XMFLOAT4( m_Actor[i].m_mWorld.m[3][0], m_Actor[i].m_mWorld.m[3][1], m_Actor[i].m_mWorld.m[3][2], m_Actor[i].m_mWorld.m[3][3] ); } instanceBufferDesc.Usage = D3D11_USAGE_DYNAMIC; instanceBufferDesc.ByteWidth = sizeof(CradleVertexDeclarations::InstanceData) * m_numActors; instanceBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; instanceBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; instanceBufferDesc.MiscFlags = 0; instanceBufferDesc.StructureByteStride = 0; instanceData.pSysMem = m_instanceData; instanceData.SysMemPitch = 0; instanceData.SysMemSlicePitch = 0; // Create the instance buffer. // HRESULT result = m_cd3d->m_d3dDevice->CreateBuffer(&instanceBufferDesc, &instanceData, &m_instanceBuffer); // HRPRINT(result, L"FAILED TO CREATE INSTANCE BUFFER\n", L"CREATED INSTANCE\n"); Update(); /* ID3D11Buffer* vb_ = ((CradleMesh*)m_Resources->GetMesh(m_meshToUse))->GetVertexBuffer(); ID3D11Buffer* indexBuffer = ((CradleMesh*)m_Resources->GetMesh(m_meshToUse))->GetIndexBuffer(); m_cd3d->m_d3dContext->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R32_UINT, 0); unsigned int strides[2]; unsigned int offsets[2]; ID3D11Buffer* bufferPointers[2]; strides[0] = sizeof(CradleVertexDeclarations::VertexPosTex); strides[1] = sizeof(CradleVertexDeclarations::InstanceData); offsets[0] = 0; offsets[1] = 0; bufferPointers[0] = vb_; bufferPointers[1] = m_instanceBuffer; m_cd3d->m_d3dContext->IASetVertexBuffers(0, 2, bufferPointers, strides, offsets); */ // Enter game loop MessageLoop(); return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { // Register window class WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WindowProcedure; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(GetModuleHandle(NULL), TEXT("ID")); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); wc.lpszMenuName = NULL; wc.lpszClassName = szClassName; wc.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), TEXT("ID"), IMAGE_ICON, 16, 16, 0); if(!RegisterClassEx(&wc)) return 0; #ifdef USE_POIS0N pois0n_init(); pois0n_set_callback(&ProgressCallback, NULL); #endif INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_PROGRESS_CLASS; InitCommonControlsEx(&icex); // Main window window = CreateWindowEx(0, szClassName, TEXT("greenpois0n"), WS_OVERLAPPED | WS_SYSMENU | SS_OWNERDRAW, CW_USEDEFAULT, CW_USEDEFAULT, 520 + GetSystemMetrics(SM_CXFIXEDFRAME), 260 + GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION), HWND_DESKTOP, NULL, hInstance, NULL); // Jailbreak button nButton = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Jailbreak"), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, 20, 205, 138, 25, window, (HMENU) 1, NULL, NULL); SendMessage(nButton, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), FALSE); // Progress bar progress = CreateWindowEx(0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 165, 206, 335, 23, window, NULL, NULL, NULL); SendMessage(progress, PBM_SETPOS, 0, 0); EnableWindow(progress, FALSE); // Title title = CreateWindowEx(0, TEXT("STATIC"), TEXT("greenpois0n"), WS_VISIBLE | WS_CHILD | SS_CENTER, 141, 2, 257, 44, window, NULL, NULL, NULL); SendMessage(title, WM_SETFONT, (WPARAM) CreateFont(/*the*/42/*answer*/, 0, 0, 0, FW_EXTRALIGHT, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")), TRUE); // Subtitle subtitle = CreateWindowEx(0, TEXT("STATIC"), TEXT("Please power off your device and connect it to begin."), WS_VISIBLE | WS_CHILD | SS_CENTER, 20, 52, 480, 17, window, NULL, NULL, NULL); SendMessage(subtitle, WM_SETFONT, (WPARAM) CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")), TRUE); // Copyright warning copyright = CreateWindowEx(0, TEXT("STATIC"), TEXT("(c) 2009-2010 chronic-dev team (http://chronic-dev.org/blog/). Beware the copyright monster!"), WS_VISIBLE | WS_CHILD | SS_NOTIFY | SS_CENTER, 20, 236, 480, 13, window, (HMENU) 4, NULL, NULL); SendMessage(copyright, WM_SETFONT, (WPARAM) CreateFont(12, 0, 0, 0, FW_DONTCARE, FALSE, TRUE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")), TRUE); // DFU group box group = CreateWindowEx(0, TEXT("BUTTON"), TEXT(""), BS_GROUPBOX | WS_VISIBLE | WS_CHILD, 20, 70, 480, 125, window, NULL, NULL, NULL); // Label #1 first = CreateWindowEx(0, TEXT("STATIC"), dfutext[0], WS_VISIBLE | WS_CHILD | SS_CENTER, 5, 20, 370, 17, group, NULL, NULL, NULL); SendMessage(first, WM_SETFONT, (WPARAM) CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")), TRUE); // Label #2 second = CreateWindowEx(0, TEXT("STATIC"), dfutext[1], WS_VISIBLE | WS_CHILD | SS_CENTER, 5, 45, 370, 17, group, NULL, NULL, NULL); SendMessage(second, WM_SETFONT, (WPARAM) CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")), TRUE); // Label #3 third = CreateWindowEx(0, TEXT("STATIC"), dfutext[2], WS_VISIBLE | WS_CHILD | SS_CENTER, 5, 70, 370, 17, group, NULL, NULL, NULL); SendMessage(third, WM_SETFONT, (WPARAM) CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")), TRUE); // Label #4 fourth = CreateWindowEx(0, TEXT("STATIC"), dfutext[3], WS_VISIBLE | WS_CHILD | SS_CENTER, 5, 95, 370, 17, group, NULL, NULL, NULL); SendMessage(fourth, WM_SETFONT, (WPARAM) CreateFont(14, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")), TRUE); // Countdown timer counter = CreateWindowEx(0, TEXT("STATIC"), TEXT(""), WS_VISIBLE | WS_CHILD | SS_CENTER, 390, 15, 60, 60, group, NULL, NULL, NULL); SendMessage(counter, WM_SETFONT, (WPARAM) CreateFont(64, 0, 0, 0, FW_EXTRALIGHT, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")), TRUE); // Seconds label seconds = CreateWindowEx(0, TEXT("STATIC"), TEXT("Seconds"), WS_VISIBLE | WS_CHILD | SS_CENTER, 390, 75, 60, 15, group, NULL, NULL, NULL); SendMessage(seconds, WM_SETFONT, (WPARAM) CreateFont(12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma")), TRUE); // Reset button reset = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Reset"), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, 20 + 390, 70 + 95, 60, 20, window, (HMENU) 2, NULL, NULL); SendMessage(reset, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), FALSE); // Enter button enter = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Prepare to Jailbreak (DFU)"), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD, 20 + 176, 70 + 50, 160, 25, window, (HMENU) 3, NULL, NULL); SendMessage(enter, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), FALSE); // donate button hImage = (HBITMAP)LoadImage(GetModuleHandle(NULL), TEXT("donate"), IMAGE_BITMAP, 0, 0, 0); // Show the window CenterWindow(window); ShowWindow(window, nFunsterStil); UpdateJailbreakStatus(); ToggleDFUTimers(FALSE); // Run the main runloop. while(MessageLoop(TRUE)); #ifdef USE_POIS0N pois0n_exit(); #endif return 0; }
/* * WinMain - main windows entry point */ int PASCAL WinMain( HINSTANCE inst, HINSTANCE previnst, LPSTR cmd, int show) { HINSTANCE newinst; HANDLE h; MSG msg; parm_data parm; command_data cmddat; char FAR_PTR *cmdline; char filename[_MAX_PATH]; /* * are we the first? if so, winexec another one of ourselves * and then start sampling */ if( !previnst ) { SharedMemory = NULL; StartWDebug386(); if( !WDebug386 ) { WinMessage( "Could not find WDEBUG.386" ); return( FALSE ); } if( !MsgInit( inst ) ) fatal(); cmddat.nCmdShow = SW_NORMAL; if( cmd == NULL || cmd[0] == 0 ) { if( !GetFileName( inst, show, filename ) ) { CloseShop(); return( FALSE ); } cmdline = filename; } else { cmddat.nCmdShow = SW_MINIMIZE; cmdline = cmd; } h = GlobalAlloc( GMEM_SHARE | GMEM_FIXED | GMEM_ZEROINIT, sizeof( shared_data ) ); if( h == NULL ) { CloseShop(); return( FALSE ); } SharedMemory = MK_FP( h,0 ); WaitForFirst = TRUE; /* tell our counterpart to wait for us before starting the timer */ cmddat.always2= 2; parm.wEnvSeg = 0; parm.lpCmdLine = (char far *) ""; parm.lpCmdShow = (void far *) &cmddat; parm.dwReserved = 0; newinst = LoadModule( "wsamplew.exe", (LPVOID) &parm ); if( (UINT)newinst < 32 ) { WinMessage( MsgArray[MSG_SAMPLE_12-ERR_FIRST_MESSAGE] ); CloseShop(); return( FALSE ); } /* * wait for our counterpart to initialize - if he fails, * then we must die too */ do { GetIData( newinst, (void near *)&IsSecondOK, sizeof( IsSecondOK ) ); MessageLoop(); } while( !IsSecondOK ); if( IsSecondOK == NOT_OK ) { WinMessage( MsgArray[MSG_SAMPLE_12-ERR_FIRST_MESSAGE] ); CloseShop(); return( FALSE ); } /* * get data created by our counterpart */ GetIData( newinst, &OutputWindow, sizeof( OutputWindow ) ); GetIData( newinst, &MainWindowHandle, sizeof( MainWindowHandle ) ); GetIData( newinst, &SampSave, sizeof( SampSave) ); /* * start the sampler - our other half will be re-started * once we have loaded the task to be sampled. */ sample_main( cmdline ); CloseShop(); SendMessage( MainWindowHandle, WM_CLOSE, 0, 0 ); return( FALSE ); } else { /* * we are the second instance (the guy who waits for * timer events and then tries to write the sample file) * init our windows stuff, then wait for the first instance * to start the samplee, set a timer, and go */ PrevInstance = previnst; if( !MsgInit( inst ) ) fatal(); if( !WindowsInit( inst, show ) ) { IsSecondOK = NOT_OK; return( FALSE ); } IsSecondOK = A_OK; do { GetIData( previnst, (void near *)&WaitForFirst, sizeof( WaitForFirst ) ); MessageLoop(); } while( WaitForFirst ); GetIData( previnst, (void near *) &Samples, sizeof( Samples ) ); GetIData( previnst, &SharedMemory, sizeof( SharedMemory ) ); KillTimer( MainWindowHandle, TIMER_ID ); SetTimer( MainWindowHandle, TIMER_ID, 4500, 0L); /* 4.5 seconds */ } /* * main message loop for the second instance */ while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } return( FALSE ); } /* WinMain */
// This Routine sets the View which controls the program int GLWindow::startApp(AppGameController& dE) { MessageManager::setView(&dE); return MessageLoop(); }
// ------------------------------------------------------------------------------------------------ int main(int argc, char* argv[]) { memset(&g_settings, 0, sizeof(vktrace_settings)); vktrace_LogSetCallback(loggingCallback); vktrace_LogSetLevel(VKTRACE_LOG_ERROR); // setup defaults memset(&g_default_settings, 0, sizeof(vktrace_settings)); g_default_settings.output_trace = vktrace_allocate_and_copy("vktrace_out.vktrace"); g_default_settings.verbosity = "errors"; g_default_settings.screenshotList = NULL; if (vktrace_SettingGroup_init(&g_settingGroup, NULL, argc, argv, &g_settings.arguments) != 0) { // invalid cmd-line parameters vktrace_SettingGroup_delete(&g_settingGroup); vktrace_free(g_default_settings.output_trace); return -1; } else { // Validate vktrace inputs BOOL validArgs = TRUE; if (g_settings.output_trace == NULL || strlen (g_settings.output_trace) == 0) { validArgs = FALSE; } else { size_t len = strlen(g_settings.output_trace); if (strncmp(&g_settings.output_trace[len-8], ".vktrace", 8) != 0) { // output trace filename does not end in .vktrace vktrace_LogError("Output trace file specified with -o parameter must have a '.vktrace' extension."); validArgs = FALSE; } } if (strcmp(g_settings.verbosity, "quiet") == 0) vktrace_LogSetLevel(VKTRACE_LOG_NONE); else if (strcmp(g_settings.verbosity, "errors") == 0) vktrace_LogSetLevel(VKTRACE_LOG_ERROR); else if (strcmp(g_settings.verbosity, "warnings") == 0) vktrace_LogSetLevel(VKTRACE_LOG_WARNING); else if (strcmp(g_settings.verbosity, "full") == 0) vktrace_LogSetLevel(VKTRACE_LOG_VERBOSE); #if _DEBUG else if (strcmp(g_settings.verbosity, "debug") == 0) vktrace_LogSetLevel(VKTRACE_LOG_DEBUG); #endif else { vktrace_LogSetLevel(VKTRACE_LOG_ERROR); validArgs = FALSE; } vktrace_set_global_var("_VK_TRACE_VERBOSITY", g_settings.verbosity); if (validArgs == FALSE) { vktrace_SettingGroup_print(&g_settingGroup); return -1; } if (g_settings.program == NULL || strlen(g_settings.program) == 0) { vktrace_LogWarning("No program (-p) parameter found: Will run vktrace as server."); printf("Running vktrace as server...\n"); fflush(stdout); g_settings.arguments = NULL; } else { if (g_settings.working_dir == NULL || strlen(g_settings.working_dir) == 0) { CHAR* buf = VKTRACE_NEW_ARRAY(CHAR, 4096); vktrace_LogVerbose("No working directory (-w) parameter found: Assuming executable's path as working directory."); vktrace_platform_full_path(g_settings.program, 4096, buf); g_settings.working_dir = vktrace_platform_extract_path(buf); VKTRACE_DELETE(buf); } vktrace_LogVerbose("Running vktrace as parent process will spawn child process: %s", g_settings.program); if (g_settings.arguments != NULL && strlen(g_settings.arguments) > 0) { vktrace_LogVerbose("Args to be passed to child process: '%s'", g_settings.arguments); } } } if (g_settings.screenshotList) { // Export list to screenshot layer vktrace_set_global_var("_VK_SCREENSHOT", g_settings.screenshotList); } else { vktrace_set_global_var("_VK_SCREENSHOT",""); } unsigned int serverIndex = 0; do { // Create and start the process or run in server mode BOOL procStarted = TRUE; vktrace_process_info procInfo; memset(&procInfo, 0, sizeof(vktrace_process_info)); if (g_settings.program != NULL) { procInfo.exeName = vktrace_allocate_and_copy(g_settings.program); procInfo.processArgs = vktrace_allocate_and_copy(g_settings.arguments); procInfo.fullProcessCmdLine = vktrace_copy_and_append(g_settings.program, " ", g_settings.arguments); procInfo.workingDirectory = vktrace_allocate_and_copy(g_settings.working_dir); procInfo.traceFilename = vktrace_allocate_and_copy(g_settings.output_trace); } else { const char *pExtension = strrchr(g_settings.output_trace, '.'); char *basename = vktrace_allocate_and_copy_n(g_settings.output_trace, (int) ((pExtension == NULL) ? strlen(g_settings.output_trace) : pExtension - g_settings.output_trace)); char num[16]; #ifdef PLATFORM_LINUX snprintf(num, 16, "%u", serverIndex); #elif defined(WIN32) _snprintf_s(num, 16, _TRUNCATE, "%u", serverIndex); #endif procInfo.traceFilename = vktrace_copy_and_append(basename, num, pExtension); } procInfo.parentThreadId = vktrace_platform_get_thread_id(); // setup tracer, only Vulkan tracer suppported PrepareTracers(&procInfo.pCaptureThreads); if (g_settings.program != NULL) { char *instEnv = vktrace_get_global_var("VK_INSTANCE_LAYERS"); // Add ScreenShot layer if enabled if (g_settings.screenshotList && (!instEnv || !strstr(instEnv, "VK_LAYER_LUNARG_screenshot"))) { if (!instEnv || strlen(instEnv) == 0) vktrace_set_global_var("VK_INSTANCE_LAYERS", "VK_LAYER_LUNARG_screenshot"); else { char *newEnv = vktrace_copy_and_append(instEnv, VKTRACE_LIST_SEPARATOR, "VK_LAYER_LUNARG_screenshot"); vktrace_set_global_var("VK_INSTANCE_LAYERS", newEnv); } instEnv = vktrace_get_global_var("VK_INSTANCE_LAYERS"); } char *devEnv = vktrace_get_global_var("VK_DEVICE_LAYERS"); if (g_settings.screenshotList && (!devEnv || !strstr(devEnv, "VK_LAYER_LUNARG_screenshot"))) { if (!devEnv || strlen(devEnv) == 0) vktrace_set_global_var("VK_DEVICE_LAYERS", "VK_LAYER_LUNARG_screenshot"); else { char *newEnv = vktrace_copy_and_append(devEnv, VKTRACE_LIST_SEPARATOR, "VK_LAYER_LUNARG_screenshot"); vktrace_set_global_var("VK_DEVICE_LAYERS", newEnv); } devEnv = vktrace_get_global_var("VK_DEVICE_LAYERS"); } // Add vktrace_layer enable env var if needed if (!instEnv || strlen(instEnv) == 0) { vktrace_set_global_var("VK_INSTANCE_LAYERS", "VK_LAYER_LUNARG_vktrace"); } else if (instEnv != strstr(instEnv, "VK_LAYER_LUNARG_vktrace")) { char *newEnv = vktrace_copy_and_append("VK_LAYER_LUNARG_vktrace", VKTRACE_LIST_SEPARATOR, instEnv); vktrace_set_global_var("VK_INSTANCE_LAYERS", newEnv); } if (!devEnv || strlen(devEnv) == 0) { vktrace_set_global_var("VK_DEVICE_LAYERS", "VK_LAYER_LUNARG_vktrace"); } else if (devEnv != strstr(devEnv, "VK_LAYER_LUNARG_vktrace")) { char *newEnv = vktrace_copy_and_append("VK_LAYER_LUNARG_vktrace", VKTRACE_LIST_SEPARATOR, devEnv); vktrace_set_global_var("VK_DEVICE_LAYERS", newEnv); } // call CreateProcess to launch the application procStarted = vktrace_process_spawn(&procInfo); } if (procStarted == FALSE) { vktrace_LogError("Failed to setup remote process."); } else { if (InjectTracersIntoProcess(&procInfo) == FALSE) { vktrace_LogError("Failed to setup tracer communication threads."); return -1; } // create watchdog thread to monitor existence of remote process if (g_settings.program != NULL) procInfo.watchdogThread = vktrace_platform_create_thread(Process_RunWatchdogThread, &procInfo); #if defined(PLATFORM_LINUX) // Sync wait for local threads and remote process to complete. vktrace_platform_sync_wait_for_thread(&(procInfo.pCaptureThreads[0].recordingThread)); if (g_settings.program != NULL) vktrace_platform_sync_wait_for_thread(&procInfo.watchdogThread); #else vktrace_platform_resume_thread(&procInfo.hThread); // Now into the main message loop, listen for hotkeys to send over. MessageLoop(); #endif } vktrace_process_info_delete(&procInfo); serverIndex++; } while (g_settings.program == NULL); vktrace_SettingGroup_delete(&g_settingGroup); vktrace_free(g_default_settings.output_trace); return 0; }
static int NSISCALL __ensuredata(int amount) { #ifdef NSIS_CONFIG_VISIBLE_SUPPORT HWND hwnd=NULL; unsigned int verify_time=GetTickCount()+500; #endif int needed=amount-(dbd_size-dbd_pos); if (needed>0) { SetSelfFilePointer(dbd_srcpos); SetFilePointer(dbd_hFile,dbd_size,NULL,FILE_BEGIN); m_length=needed; m_pos=0; for (;;) { int err; int l=min(IBUFSIZE,dbd_fulllen-dbd_srcpos); if (!ReadSelfFile((LPVOID)_inbuffer,l)) return -1; dbd_srcpos+=l; g_inflate_stream.next_in=_inbuffer; g_inflate_stream.avail_in=l; do { DWORD r,t; #ifdef NSIS_CONFIG_VISIBLE_SUPPORT if (g_header) #ifdef NSIS_CONFIG_SILENT_SUPPORT if (!g_exec_flags.silent) #endif { if (hwnd) { m_pos=m_length-(amount-(dbd_size-dbd_pos)); MessageLoop(0); } else if (GetTickCount() > verify_time) { hwnd = CreateDialogParam( g_hInstance, MAKEINTRESOURCE(IDD_VERIFY), 0, verProc, g_hwnd ? 0 : (LPARAM)_LANG_UNPACKING ); } } #endif//NSIS_CONFIG_VISIBLE_SUPPORT g_inflate_stream.next_out=_outbuffer; g_inflate_stream.avail_out=OBUFSIZE; err=inflate(&g_inflate_stream); if (err<0) { return -3; } r=(DWORD)g_inflate_stream.next_out-(DWORD)_outbuffer; if (r) { if (!WriteFile(dbd_hFile,_outbuffer,r,&t,NULL) || r != t) { return -2; } dbd_size+=r; } else if (g_inflate_stream.avail_in || !l) return -3; else break; } while (g_inflate_stream.avail_in); if (amount-(dbd_size-dbd_pos) <= 0) break; } SetFilePointer(dbd_hFile,dbd_pos,NULL,FILE_BEGIN); } #ifdef NSIS_CONFIG_VISIBLE_SUPPORT if (hwnd) { m_pos=m_length; SendMessage(hwnd,WM_TIMER,0,0); DestroyWindow(hwnd); } #endif//NSIS_CONFIG_VISIBLE_SUPPORT return 0; }
const char * NSISCALL loadHeaders(int cl_flags) { #ifdef NSIS_CONFIG_CRC_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT HWND hwnd = 0; unsigned int verify_time = GetTickCount() + 1000; #endif crc32_t crc = 0; int do_crc = 0; #endif//NSIS_CONFIG_CRC_SUPPORT int left; void *data; firstheader h; header *header; HANDLE db_hFile; GetModuleFileName(NULL, state_exe_path, NSIS_MAX_STRLEN); g_db_hFile = db_hFile = myOpenFile(state_exe_path, GENERIC_READ, OPEN_EXISTING); if (db_hFile == INVALID_HANDLE_VALUE) { return _LANG_CANTOPENSELF; } mystrcpy(state_exe_directory, state_exe_path); mystrcpy(state_exe_file, trimslashtoend(state_exe_directory)); left = m_length = GetFileSize(db_hFile,NULL); while (left > 0) { static char temp[32768]; DWORD l = min(left, (g_filehdrsize ? 32768 : 512)); if (!ReadSelfFile(temp, l)) { #if defined(NSIS_CONFIG_CRC_SUPPORT) && defined(NSIS_CONFIG_VISIBLE_SUPPORT) if (hwnd) DestroyWindow(hwnd); #endif//NSIS_CONFIG_CRC_SUPPORT return _LANG_INVALIDCRC; } if (!g_filehdrsize) { mini_memcpy(&h, temp, sizeof(firstheader)); if ( (h.flags & (~FH_FLAGS_MASK)) == 0 && h.siginfo == FH_SIG && h.nsinst[2] == FH_INT3 && h.nsinst[1] == FH_INT2 && h.nsinst[0] == FH_INT1 ) { g_filehdrsize = m_pos; #if defined(NSIS_CONFIG_CRC_SUPPORT) || defined(NSIS_CONFIG_SILENT_SUPPORT) cl_flags |= h.flags; #endif #ifdef NSIS_CONFIG_SILENT_SUPPORT g_exec_flags.silent |= cl_flags & FH_FLAGS_SILENT; #endif if (h.length_of_all_following_data > left) return _LANG_INVALIDCRC; #ifdef NSIS_CONFIG_CRC_SUPPORT if ((cl_flags & FH_FLAGS_FORCE_CRC) == 0) { if (cl_flags & FH_FLAGS_NO_CRC) break; } do_crc++; #ifndef NSIS_CONFIG_CRC_ANAL left = h.length_of_all_following_data - 4; // end crc checking at crc :) this means you can tack shit on the end and it'll still work. #else //!NSIS_CONFIG_CRC_ANAL left -= 4; #endif//NSIS_CONFIG_CRC_ANAL // this is in case the end part is < 512 bytes. if (l > (DWORD)left) l=(DWORD)left; #else//!NSIS_CONFIG_CRC_SUPPORT // no crc support, no need to keep on reading break; #endif//!NSIS_CONFIG_CRC_SUPPORT } } #ifdef NSIS_CONFIG_CRC_SUPPORT #ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_SILENT_SUPPORT else if ((cl_flags & FH_FLAGS_SILENT) == 0) #endif//NSIS_CONFIG_SILENT_SUPPORT { if (hwnd) { MessageLoop(0); } else if (GetTickCount() > verify_time) hwnd = CreateDialogParam( g_hInstance, MAKEINTRESOURCE(IDD_VERIFY), 0, verProc, (LPARAM)_LANG_VERIFYINGINST ); } #endif//NSIS_CONFIG_VISIBLE_SUPPORT #ifndef NSIS_CONFIG_CRC_ANAL if (left < m_length) #endif//NSIS_CONFIG_CRC_ANAL crc = CRC32(crc, temp, l); #endif//NSIS_CONFIG_CRC_SUPPORT m_pos += l; left -= l; } #ifdef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_CRC_SUPPORT if (hwnd) { DestroyWindow(hwnd); } #endif//NSIS_CONFIG_CRC_SUPPORT #endif//NSIS_CONFIG_VISIBLE_SUPPORT if (!g_filehdrsize) return _LANG_INVALIDCRC; #ifdef NSIS_CONFIG_CRC_SUPPORT if (do_crc) { crc32_t fcrc; SetSelfFilePointer(m_pos); if (!ReadSelfFile(&fcrc, sizeof(crc32_t)) || crc != fcrc) return _LANG_INVALIDCRC; } #endif//NSIS_CONFIG_CRC_SUPPORT data = (void *)GlobalAlloc(GPTR,h.length_of_header); #ifdef NSIS_COMPRESS_WHOLE inflateReset(&g_inflate_stream); { char fno[MAX_PATH]; my_GetTempFileName(fno, state_temp_dir); dbd_hFile=CreateFile(fno,GENERIC_WRITE|GENERIC_READ,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE,NULL); if (dbd_hFile == INVALID_HANDLE_VALUE) return _LANG_ERRORWRITINGTEMP; } dbd_srcpos = SetSelfFilePointer(g_filehdrsize + sizeof(firstheader)); #ifdef NSIS_CONFIG_CRC_SUPPORT dbd_fulllen = dbd_srcpos - sizeof(h) + h.length_of_all_following_data - ((h.flags & FH_FLAGS_NO_CRC) ? 0 : sizeof(crc32_t)); #else dbd_fulllen = dbd_srcpos - sizeof(h) + h.length_of_all_following_data; #endif//NSIS_CONFIG_CRC_SUPPORT #else SetSelfFilePointer(g_filehdrsize + sizeof(firstheader)); #endif//NSIS_COMPRESS_WHOLE if (GetCompressedDataFromDataBlockToMemory(-1, data, h.length_of_header) != h.length_of_header) { return _LANG_INVALIDCRC; } header = g_header = data; g_flags = header->flags; #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT if (h.flags & FH_FLAGS_UNINSTALL) g_is_uninstaller++; #endif // set offsets to real memory offsets rather than installer's header offset left = BLOCKS_NUM; while (left--) header->blocks[left].offset += (int)data; #ifdef NSIS_COMPRESS_WHOLE header->blocks[NB_DATA].offset = dbd_pos; #else header->blocks[NB_DATA].offset = SetFilePointer(db_hFile,0,NULL,FILE_CURRENT); #endif mini_memcpy(&g_blocks, &header->blocks, sizeof(g_blocks)); return 0; }