void AudioProvider::GetAudio(void *buf, int64_t start, int64_t count) const { if (start < 0) { ZeroFill(buf, std::min(-start, count)); buf = static_cast<char *>(buf) + -start * bytes_per_sample * channels; count += start; start = 0; } if (start + count > num_samples) { int64_t zero_count = std::min(count, start + count - num_samples); count -= zero_count; ZeroFill(static_cast<char *>(buf) + count * bytes_per_sample * channels, zero_count); } if (count <= 0) return; try { FillBuffer(buf, start, count); } catch (AudioDecodeError const& e) { // We don't have any good way to report errors here, so just log the // failure and return silence LOG_E("audio_provider") << e.GetMessage(); ZeroFill(buf, count); return; } catch (...) { LOG_E("audio_provider") << "Unknown audio decoding error"; ZeroFill(buf, count); return; } }
void AudioProvider::GetAudio(void *buf, int64_t start, int64_t count) const { if (start < 0) { ZeroFill(buf, std::min(-start, count)); buf = static_cast<char *>(buf) + -start * bytes_per_sample * channels; count += start; start = 0; } if (start + count > num_samples) { int64_t zero_count = std::min(count, start + count - num_samples); count -= zero_count; ZeroFill(static_cast<char *>(buf) + count * bytes_per_sample * channels, zero_count); } if (count <= 0) return; try { FillBuffer(buf, start, count); } catch (AudioDecodeError const& e) { LOG_E("audio_provider") << e.GetChainedMessage(); ZeroFill(buf, count); return; } catch (...) { // FIXME: Poor error handling though better than none, to patch issue #800. // Just return blank audio if real provider fails. LOG_E("audio_provider") << "Unknown audio decoding error"; ZeroFill(buf, count); return; } }
CInput::CInput() { m_pCurrentState = m_szKeyBuffer1; m_pPreviousState = m_szKeyBuffer2; ZeroFill( m_pCurrentState, sizeof(m_szKeyBuffer1) ); ZeroFill( m_pPreviousState, sizeof(m_szKeyBuffer2) ); }
static HTREEITEM EhTreeViewItemSearch(HWND hWnd,HTREEITEM hItem,LONG lParam) { HTREEITEM hChild,hOk; static INT iLevel=0; TVITEM pItem; iLevel++; while (hItem) { ZeroFill(pItem); pItem.hItem=hItem; pItem.state=TVIF_PARAM; pItem.stateMask=TVIF_PARAM; if (!TreeView_GetItem(hWnd,&pItem)) return NULL; //win_infoarg("%d: %d <> %d",iLevel,pItem.lParam,lParam); if (pItem.lParam==lParam) {iLevel--; return hItem;} hChild=TreeView_GetNextItem(hWnd,hItem,TVGN_CHILD); hItem=TreeView_GetNextItem(hWnd,hItem,TVGN_NEXT); if (hChild) { hOk=EhTreeViewItemSearch(hWnd,hChild,lParam); if (hOk) {iLevel--; return hOk;} } } iLevel--; return NULL; }
static void Main_OnMouseMove(HWND hwndParent, HWND hwndTV, LONG xCur, LONG yCur) { HTREEITEM htiTarget; // handle to target item TVHITTESTINFO tvht; // hit test information //POINT Pos; INT iIndex; struct OBJ *poj; // xCur,yCur sono della parent // Drag the item to the current position of the mouse cursor. // Muove l'immagine del Drag nella posizione del cursore iIndex=TVFind(TV_FINDHWND,hwndTV); poj=TVList[iIndex].lpObj; xCur-=poj->px; yCur-=poj->py; //GetCursorPos(&Pos); //ImageList_DragMove(Pos.x,Pos.y); ImageList_DragMove(xCur+12,yCur+12); // Find out if the cursor is on the item. If it is, highlight // the item as a drop target. ZeroFill(tvht); tvht.pt.x=xCur; tvht.pt.y=yCur; tvht.flags=TVHT_ONITEM|TVHT_ONITEMLABEL; if ((hDropItem = htiTarget = TreeView_HitTest(hwndTV, &tvht)) != NULL) { ImageList_DragShowNolock(FALSE); TreeView_SelectDropTarget(hwndTV, htiTarget); //hDropItem=htiTarget; ImageList_DragShowNolock(TRUE); } return; }
void* CLR_RT_Memory::Allocate_And_Erase( size_t len, CLR_UINT32 flags ) { NATIVE_PROFILE_CLR_CORE(); void* ptr = CLR_RT_Memory::Allocate( len, flags ); if(ptr) ZeroFill( ptr, len ); return ptr; }
void Entry(void) { HANDLE hMutex; int result=1; Options options; g_controlMsg=RegisterWindowMessageA(CONTROL_MESSAGE_NAME); ZeroFill(&options,sizeof options); ProcessCommandLine(&options); #ifdef _DEBUG options.showWindow=TRUE; #endif hMutex=OpenMutexA(MUTEX_ALL_ACCESS,FALSE,MUTEX_NAME); if(hMutex) { // Already running. ApplyOptions(&options); } else { if(options.nextLayout||options.prevLayout) { // Don't do anything. } else { hMutex=CreateMutexA(0,FALSE,MUTEX_NAME); if(!RunHelpers()) result=1; else { result=Main(&options); ReleaseMutex(hMutex); hMutex=NULL; } PostMessage(HWND_BROADCAST,g_controlMsg,CONTROL_QUIT,0); } } LocalFree(options.pLayoutToSet); options.pLayoutToSet=NULL; ExitProcess(result); }
void ODBCStart(SINT cmd) { // Ultima chiamata if (cmd!=WS_LAST) return; ZeroFill(EhOdbc); // Alloca Ambiente ODBC LSQLTRY("SQLAllocHandleEnv", SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &EhOdbc.hEnv)); // SQLTRY("SQLSetEnvAttr", SQLSetEnvAttr(EhOdbc.hEnv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0)); LSQLTRY("SQLSetEnvAttr", SQLSetEnvAttr(EhOdbc.hEnv, SQL_ATTR_ODBC_VERSION, (void*) SQL_OV_ODBC3, 0)); /* Set login timeout to 5 seconds. */ //SQLTRY("SQLAllocHandleConn", SQLSetConnectAttr(EhOdbc.hConn, (void*) SQL_LOGIN_TIMEOUT, 5, 0)); LSQLTRY("SQLAllocHandleConn", SQLAllocHandle(SQL_HANDLE_DBC, EhOdbc.hEnv, &EhOdbc.hConn)); EhOdbc.lpSQLCommand=GlobalAlloc(GPTR,5000); }
static void CursorAutoSelect(INT xCur,INT yCur,INT iTVIndex)//HWND hwndTV,struct OBJ *poj) { HTREEITEM htiTarget; // handle to target item TVHITTESTINFO tvht; // hit test information //xCur-=TVList[iTVIndex].lpObj->px; //yCur-=TVList[iTVIndex].lpObj->py; ZeroFill(tvht); tvht.pt.x=xCur; tvht.pt.y=yCur; tvht.flags=TVHT_ONITEM|TVHT_ONITEMLABEL; if ((htiTarget = TreeView_HitTest(TVList[iTVIndex].hWndList, &tvht)) != NULL) { TreeView_SelectDropTarget(TVList[iTVIndex].hWndList, htiTarget); TreeView_SelectItem(TVList[iTVIndex].hWndList,htiTarget); } }
static void Main_EndDrag(void)//HWND hwndTV, LPNMTREEVIEW lpnmtv) { INT iIndex; CHAR szServ[80]; //static EHDRAGDROP EhDD; //ImageList_DragLeave(NULL); ImageList_DragLeave(hDragWnd); ImageList_EndDrag(); ReleaseCapture(); //ShowCursor(TRUE); fDragging = FALSE; // Genero il messaggio di Drag&Drop iIndex=TVFind(TV_FINDHWND,hDragWnd); ZeroFill(EhDD); EhDD.hDrag=hDragItem; EhDD.hDrop=hDropItem; OBJ_key=(LONG) &EhDD; sprintf(szServ,"%sDD",TVList[iIndex].lpObj->nome); obj_addevent(szServ); }
static void NotifyCtl(DWORD action,const wchar_t *pTip,UINT extraFlags) { NOTIFYICONDATAW nid; ZeroFill(&nid,sizeof nid); nid.cbSize=sizeof nid; nid.hWnd=g_hWnd; nid.uID=NOTIFY_ID; nid.uFlags=NIF_ICON|NIF_MESSAGE|extraFlags; nid.uCallbackMessage=NOTIFY_MSG; nid.hIcon=LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICON1)); nid.uTimeout=500; if(pTip) { enum { MAX_TIP_SIZE=sizeof nid.szTip/sizeof nid.szTip[0], MAX_INFO_SIZE=sizeof nid.szInfo/sizeof nid.szInfo[0], MAX_INFO_TITLE_SIZE=sizeof nid.szInfoTitle/sizeof nid.szInfoTitle[0], }; nid.uFlags|=NIF_TIP; lstrcpynW(nid.szTip,pTip,MAX_TIP_SIZE); nid.szTip[MAX_TIP_SIZE-1]=0; lstrcpynW(nid.szInfo,pTip,MAX_INFO_SIZE); nid.szInfo[MAX_INFO_SIZE-1]=0; lstrcpynW(nid.szInfoTitle,L"kbswitch2",MAX_INFO_TITLE_SIZE); nid.szInfoTitle[MAX_INFO_TITLE_SIZE-1]=0; } Shell_NotifyIconW(action,&nid); }
// we don't need any runtime initialization; only use Win32 API! void __cdecl WinMainCRTStartup(void) { // variable for ExitProcess UINT exitCode; // variables for Tokenize LPTSTR infName; // variables for GetFullPathName LPTSTR fullPath; LPTSTR filePart; // variables for lstrcpy, lstrcat DWORD len; LPTSTR fixCmd; LPTSTR argList; // variables for ShellExecuteEx SHELLEXECUTEINFO shExec; // variables for Wow64DisableWow64FsRedirection PVOID OldWow64FsRedirectionValue; // variables for VerifyVersionInfo OSVERSIONINFOEX verInfo; // declare these functions as pointers to load dynamically PW64DW64FR Wow64DisableWow64FsRedirection; PW64RW64FR Wow64RevertWow64FsRedirection; // attempt to load functions and store pointer in variable Wow64DisableWow64FsRedirection = (PW64DW64FR) GetProcAddress( GetModuleHandle(TEXT("kernel32.dll")), "Wow64DisableWow64FsRedirection"); Wow64RevertWow64FsRedirection = (PW64RW64FR) GetProcAddress( GetModuleHandle(TEXT("kernel32.dll")), "Wow64RevertWow64FsRedirection"); // get the command line buffer from the environment infName = Tokenize (GetCommandLine ()); // standard prefix to run an installer. first argument is a tuple of // the library name and the entry point; there must be a comma // between them and no spaces. rest of the command is passed to that // entry point. DefaultInstall is the name of the section, 128 is // flags, and the .inf name must be specified using a path to avoid // having it search for files in default directories. fixCmd = TEXT("setupapi.dll,InstallHinfSection DefaultInstall 128 "); // get canonical path of the argument len = GetFullPathName (infName, 0, NULL, NULL); // file does not exist? if (len == 0) { exitCode = 0xFE; goto cleanupFullPath; } fullPath = (LPTSTR) HeapAlloc (GetProcessHeap (), 0, (len+1) * sizeof(TCHAR)); GetFullPathName (infName, len, fullPath, &filePart); // only directory was specified if (*filePart == '\0') { exitCode = 0xFD; goto cleanupFullPath; } // put all portions together to a total command line. note that the // InstallHinfSection argument list is not a regular command line. there // are always three fields: Section (DefaultInstall), Flags (128) and // Path, which are separated with a space. No quotes should be put around // the path, nor is the short name really necessary (on Windows 7 64-bit // there may not be a short name version available). len = lstrlen (fixCmd) + lstrlen (fullPath); argList = (LPTSTR) HeapAlloc (GetProcessHeap (), 0, (len+1) * sizeof(TCHAR)); lstrcpy (argList, fixCmd); lstrcat (argList, fullPath); //MessageBox(NULL, argList, TEXT("argList"), MB_ICONINFORMATION | MB_OK); ZeroFill (&shExec, sizeof(SHELLEXECUTEINFO)); shExec.cbSize = sizeof(SHELLEXECUTEINFO); shExec.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT | SEE_MASK_DOENVSUBST; // <http://codefromthe70s.org/vistatutorial.aspx> // <http://www.wintellect.com/cs/blogs/jrobbins/archive/2007/03/27/elevate-a-process-at-the-command-line-in-vista.aspx> ZeroFill (&verInfo, sizeof(OSVERSIONINFOEX)); verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); verInfo.dwMajorVersion = 6; // Vista if (VerifyVersionInfo (&verInfo, VER_MAJORVERSION, VerSetConditionMask (0, VER_MAJORVERSION, VER_GREATER_EQUAL))) { shExec.lpVerb = TEXT("runas"); } // instead of calling InstallHinfSection ourself, we need to execute // the external program so that the native version (32- or 64-bits) // is run. it is always in system32, even on Windows x64! (folder // redirection is deactivated, so we'll get the native version). shExec.lpFile = TEXT("%SystemRoot%\\system32\\rundll32.exe"); shExec.lpParameters = argList; shExec.nShow = SW_SHOWDEFAULT; // only call the WoW64 functions if they are available on our system if(NULL != Wow64DisableWow64FsRedirection) Wow64DisableWow64FsRedirection (&OldWow64FsRedirectionValue); // launch process and "inherit" exit code ShellExecuteEx (&shExec); WaitForSingleObject (shExec.hProcess, INFINITE); GetExitCodeProcess (shExec.hProcess, &exitCode); CloseHandle (shExec.hProcess); if (NULL != Wow64RevertWow64FsRedirection) Wow64RevertWow64FsRedirection (OldWow64FsRedirectionValue); // not really necessary, but it's a habit hard to turn HeapFree (GetProcessHeap (), 0, argList); cleanupFullPath: HeapFree (GetProcessHeap (), 0, fullPath); ExitProcess (exitCode); }
static LRESULT TreeViewNotify(HWND hWnd, LPARAM lParam,INT iLVIndex,LPNMHDR pnmh) { LPNMLVKEYDOWN pnkd; struct OBJ *poj; CHAR szServ[20]; LPNMHDR lpnmh; HTREEITEM hItem; LPNMTREEVIEW lpnmtv; TVITEM item; BOOL fReturn; LRESULT lRes; if (iLVIndex>100||iLVIndex<0) return 0; poj=TVList[iLVIndex].lpObj; if (pnmh->code==0) efx2(); lpnmh = (LPNMHDR) lParam; // Lancio se connessa la procedura di controllo esterna if (TVList[iLVIndex].subPostNotify) { fReturn=FALSE; lRes=(*TVList[iLVIndex].subPostNotify)(poj,&fReturn, EXT_PREV,hWnd,0,0,lParam); if (fReturn) return lRes; } switch(pnmh->code) { case TVN_SELCHANGING: lpnmtv = (LPNMTREEVIEW) lParam; TreeView_SelectDropTarget(lpnmh->hwndFrom,lpnmtv->itemNew.hItem); ZeroFill(item); hItem=TreeView_GetSelection(lpnmh->hwndFrom); item.mask=TVIF_PARAM; item.hItem=hItem; item.pszText=szServ; item.cchTextMax=sizeof(szServ); TreeView_GetItem(lpnmh->hwndFrom,&item); OBJ_key=item.lParam; sprintf(szServ,"%sSEL",poj->nome); obj_addevent(szServ); break; case NM_DBLCLK : ZeroFill(item); hItem=TreeView_GetSelection(lpnmh->hwndFrom); item.mask=TVIF_PARAM; item.hItem=hItem; item.pszText=szServ; item.cchTextMax=sizeof(szServ); TreeView_GetItem(lpnmh->hwndFrom,&item); OBJ_key=item.lParam; sprintf(szServ,"%sDCLK",poj->nome); obj_addevent(szServ); break; case NM_RCLICK: hItem=TreeView_GetSelection(lpnmh->hwndFrom); if (hItem==NULL) break; //memset(&item,0,sizeof(item)); ZeroFill(item); item.mask=TVIF_TEXT|TVIF_PARAM; item.hItem=hItem; item.pszText=szServ; item.cchTextMax=sizeof(szServ); TreeView_GetItem(lpnmh->hwndFrom,&item); //_d_("[%s] ",szServ); OBJ_key=item.lParam; sprintf(szServ,"%sRC",poj->nome); obj_addevent(szServ); break; case TVN_BEGINDRAG: //case TVN_BEGINRDRAG: Main_OnBeginDrag(lpnmh->hwndFrom, (LPNMTREEVIEW) lParam); break; //efx1(); //break; case TVN_KEYDOWN: pnkd = (LPNMLVKEYDOWN) lParam; if (pnkd->wVKey==ESC) winSetFocus(WindowNow()); if ((pnkd->wVKey>=' ')&&(pnkd->wVKey<='<')) { //efx1(); } break; } // Lancio se connessa la procedura di controllo esterna if (TVList[iLVIndex].subPostNotify) { fReturn=FALSE; lRes=(*TVList[iLVIndex].subPostNotify)(poj,&fReturn, EXT_AFTER,hWnd,0,0,lParam); // (TVSUB_POST,poj,hWnd,lParam,pnmh,&fReturn); if (fReturn) return lRes; } return 0; }
static void TextProcessor(INT hdlImage,CHAR *lpText) { BYTE *lp; CHAR szTesto[1024]; POINT pt; IMGHEADER *Img; HDC hDC,hDClone; HBITMAP hbCopy; BYTE *lpSorg; INT iLx,iLy; BITMAPINFOHEADER *BmpHeader; BITMAPINFO *BmpInfo; INT iAlt=12; INT iCol1=0; INT iCol2=-1; BOOL fBold=FALSE; // ---------------------------------------------------------------------------- // Creo una zona di memoria tipo video delle dimensioni dell'immagine // //memcpy(&ImgHeader,memoLock(hdlImage),sizeof(IMGHEADER)); printf("Elaborazione TextProcessor [%s]" CRLF,lpText); //Sleep(2000); //ehLogWrite("> %s" CRLF,lpText); if (!*lpText) return; Img=memoLock(hdlImage); BmpInfo=(BITMAPINFO *) &Img->bmiHeader; BmpHeader=(BITMAPINFOHEADER *) &Img->bmiHeader; iLy=BmpHeader->biHeight; if (iLy<0) iLy=-BmpHeader->biHeight; iLx=BmpHeader->biWidth; hDC=GetDC(NULL); hDClone=CreateCompatibleDC(hDC); SetMapMode(hDClone, MM_TEXT); hbCopy = CreateCompatibleBitmap(hDC, iLx, iLy); SelectObject(hDClone, hbCopy); ReleaseDC(NULL,hDC); lpSorg=(BYTE *) Img; lpSorg+=Img->Offset; // Scrivo l'immagine in questa zona di memoria if (StretchDIBits(hDClone, // Coordinate e dimensioni di stampa a video 0,0, iLx, iLy, // Coordinate e dimensioni di lettura nel sorgente 0, iLy+1, iLx, -iLy, lpSorg, (BITMAPINFO *) &Img->bmiHeader, DIB_RGB_COLORS, SRCCOPY) == GDI_ERROR) {printf("StretchDIBits Failed");} // Ci faccio quello che ci devo fare con i comandi lp=strtok(lpText,"|"); *szTesto=0; ZeroFill(pt); while (lp) { //printf("[%s]" CRLF,lp); if (!memcmp(lp,"TEXT=",5)) strcpy(szTesto,lp+5); if (!memcmp(lp,"PX=",3)) pt.x=atoi(lp+3); if (!memcmp(lp,"PY=",3)) pt.y=atoi(lp+3); if (!memcmp(lp,"ALT=",3)) iAlt=atoi(lp+3); if (!memcmp(lp,"COL=",4)) iCol1=ColorConvert(lp+4); if (!memcmp(lp,"BG=",3)) iCol2=ColorConvert(lp+3); if (!memcmp(lp,"BOLD=",5)) fBold=atoi(lp+5); if (*lp=='*') { //printf("Stampo: %d,%d,%s" CRLF,pt.x,pt.y,szTesto); //ehLogWrite("Stampo: %d,%d,%s",pt.x,pt.y,szTesto); LPrint(hDClone,pt.x,pt.y,iCol1,iCol2,"Arial",iAlt,fBold,szTesto); } lp=strtok(NULL,"|"); } // Mi riprendo la zona di memoria video e la rimetto nell'immagine //BmpHeader->biHeight*=-1; GetDIBits( hDClone, // handle to device context hbCopy, // handle to bitmap 0, // first scan line to set in destination bitmap iLy, // number of scan lines to copy lpSorg, // address of array for bitmap bits (BITMAPINFO *) &Img->bmiHeader, // address of structure with bitmap data DIB_RGB_COLORS // RGB or palette index ); if (!DeleteDC(hDClone)) { ehLogWrite("Errore in cancellazione DC %d",GetLastError()); ehExit("Errore in cancellazione DC"); } if (!DeleteObject(hbCopy)) { ehLogWrite("Errore in cancellazione Bitmap %d",GetLastError()); ehExit("Errore in cancellazione Bitmap"); } memoUnlockEx(hdlImage,"A5"); IMGMirrorY(hdlImage); // Libero le risorse //TextOut( }