bool_t xdr_authdes_cred (XDR *xdrs, struct authdes_cred *cred) { /* * Unrolled xdr */ ATTEMPT (INTUSE(xdr_enum) (xdrs, (enum_t *) & cred->adc_namekind)); switch (cred->adc_namekind) { case ADN_FULLNAME: ATTEMPT (INTUSE(xdr_string) (xdrs, &cred->adc_fullname.name, MAXNETNAMELEN)); ATTEMPT (INTUSE(xdr_opaque) (xdrs, (caddr_t) & cred->adc_fullname.key, sizeof (des_block))); ATTEMPT (INTUSE(xdr_opaque) (xdrs, (caddr_t) & cred->adc_fullname.window, sizeof (cred->adc_fullname.window))); return (TRUE); case ADN_NICKNAME: ATTEMPT (INTUSE(xdr_opaque) (xdrs, (caddr_t) & cred->adc_nickname, sizeof (cred->adc_nickname))); return TRUE; default: return FALSE; } }
bool xdr_authdes_cred(XDR *xdrs, struct authdes_cred *cred) { /* * Unrolled xdr */ ATTEMPT(inline_xdr_enum(xdrs, (enum_t *) &cred->adc_namekind)); switch (cred->adc_namekind) { case ADN_FULLNAME: ATTEMPT(inline_xdr_string (xdrs, &cred->adc_fullname.name, MAXNETNAMELEN)); ATTEMPT(inline_xdr_opaque (xdrs, (caddr_t) &cred->adc_fullname.key, sizeof(des_block))); ATTEMPT(inline_xdr_opaque (xdrs, (caddr_t) &cred->adc_fullname.window, sizeof(cred->adc_fullname.window))); return (true); case ADN_NICKNAME: ATTEMPT(inline_xdr_opaque (xdrs, (caddr_t) &cred->adc_nickname, sizeof(cred->adc_nickname))); return (true); default: return (false); } }
bool xdr_authdes_verf(XDR *xdrs, struct authdes_verf *verf) { /* * Unrolled xdr */ ATTEMPT(inline_xdr_opaque (xdrs, (caddr_t) &verf->adv_xtimestamp, sizeof(des_block))); ATTEMPT(inline_xdr_opaque (xdrs, (caddr_t) &verf->adv_int_u, sizeof(verf->adv_int_u))); return (true); }
bool_t xdr_authdes_verf (register XDR *xdrs, register struct authdes_verf *verf) { /* * Unrolled xdr */ ATTEMPT (INTUSE(xdr_opaque) (xdrs, (caddr_t) & verf->adv_xtimestamp, sizeof (des_block))); ATTEMPT (INTUSE(xdr_opaque) (xdrs, (caddr_t) & verf->adv_int_u, sizeof (verf->adv_int_u))); return TRUE; }
void DDReleaseSurface ( LPDIRECTDRAWSURFACE *ppOldSurface1, LPDIRECTDRAWSURFACE2 *ppOldSurface2 ) { Assert ( ppOldSurface1 != NULL ); Assert ( ppOldSurface2 != NULL ); Assert ( *ppOldSurface1 != NULL ); Assert ( *ppOldSurface2 != NULL ); ATTEMPT ( IDirectDrawSurface2_Release ( *ppOldSurface2 ) ); ATTEMPT ( IDirectDrawSurface_Release ( *ppOldSurface1 ) ); *ppOldSurface1 = NULL; *ppOldSurface2 = NULL; }
void DDSetClipperList( LPDIRECTDRAWCLIPPER pDDClipper, LPRGNDATA pClipList, UINT32 uiFlags) { Assert( pDDClipper != NULL ); Assert( pClipList != NULL ); ATTEMPT( IDirectDrawClipper_SetClipList( pDDClipper, pClipList, uiFlags ) ); }
void DDGetDDInterface( LPDIRECTDRAWSURFACE2 pSurface, LPDIRECTDRAW *ppDirectDraw ) { Assert( pSurface != NULL ); Assert( ppDirectDraw != NULL ); ATTEMPT( IDirectDrawSurface2_GetDDInterface( pSurface, ppDirectDraw ) ); }
void DDUnlockSurface( LPDIRECTDRAWSURFACE2 pSurface, PTR pSurfaceData ) { Assert( pSurface != NULL ); ATTEMPT( IDirectDrawSurface2_Unlock( pSurface, pSurfaceData ) ); }
// Clipper FUnctions void DDCreateClipper( LPDIRECTDRAW2 pDirectDraw, UINT32 fFlags, LPDIRECTDRAWCLIPPER *pDDClipper ) { Assert( pDirectDraw != NULL ); Assert( pDDClipper != NULL ); ATTEMPT( IDirectDraw2_CreateClipper( pDirectDraw, 0, pDDClipper, NULL ) ); }
void DDSetSurfaceColorKey( LPDIRECTDRAWSURFACE2 pSurface, UINT32 uiFlags, LPDDCOLORKEY pDDColorKey ) { Assert( pSurface != NULL ); Assert( pDDColorKey != NULL ); ATTEMPT( IDirectDrawSurface2_SetColorKey( pSurface, uiFlags, pDDColorKey ) ); }
void DDGetSurfaceCaps ( LPDIRECTDRAWSURFACE2 pSurface, DDSCAPS *pSurfaceCaps ) { Assert( pSurface != NULL ); Assert( pSurfaceCaps != NULL ); ATTEMPT( IDirectDrawSurface2_GetCaps( pSurface, pSurfaceCaps ) ); }
void DDGetSurfacePalette( LPDIRECTDRAWSURFACE2 pSurface, LPDIRECTDRAWPALETTE *ppDDPalette ) { Assert( ppDDPalette != NULL ); Assert( pSurface != NULL ); ATTEMPT( IDirectDrawSurface2_GetPalette( pSurface, ppDDPalette ) ); }
void DDReleaseDC( LPDIRECTDRAWSURFACE2 pSurface, HDC hDC ) { Assert( pSurface != NULL ); ATTEMPT( IDirectDrawSurface2_ReleaseDC( pSurface, hDC ) ); }
void DDSetClipper( LPDIRECTDRAWSURFACE2 pSurface, LPDIRECTDRAWCLIPPER pDDClipper ) { Assert( pSurface != NULL ); Assert( pDDClipper != NULL ); ATTEMPT( IDirectDrawSurface2_SetClipper( pSurface, pDDClipper ) ); }
void DDGetDC( LPDIRECTDRAWSURFACE2 pSurface, HDC *phDC ) { Assert( pSurface != NULL ); Assert( phDC != NULL ); ATTEMPT( IDirectDrawSurface2_GetDC( pSurface, phDC ) ); }
void DDCreatePalette( LPDIRECTDRAW2 pDirectDraw, UINT32 uiFlags, LPPALETTEENTRY pColorTable, LPDIRECTDRAWPALETTE FAR *ppDDPalette, IUnknown FAR * pUnkOuter) { Assert( pDirectDraw != NULL ); ATTEMPT( IDirectDraw2_CreatePalette( pDirectDraw, uiFlags, pColorTable, ppDDPalette, pUnkOuter ) ); }
// DirectDrawSurface2 Calls void DDCreateSurface ( LPDIRECTDRAW2 pExistingDirectDraw, DDSURFACEDESC *pNewSurfaceDesc, LPDIRECTDRAWSURFACE *ppNewSurface1, LPDIRECTDRAWSURFACE2 *ppNewSurface2 ) { Assert ( pExistingDirectDraw != NULL ); Assert ( pNewSurfaceDesc != NULL ); Assert ( ppNewSurface1 != NULL ); Assert ( ppNewSurface2 != NULL ); // create the directdraw surface ATTEMPT ( IDirectDraw2_CreateSurface ( pExistingDirectDraw, pNewSurfaceDesc, ppNewSurface1, NULL ) ); //get the direct draw surface 2 interface ATTEMPT ( IDirectDrawSurface_QueryInterface ( *ppNewSurface1, &IID_IDirectDrawSurface2, (LPVOID*) ppNewSurface2 ) ); }
void DDSetPaletteEntries( LPDIRECTDRAWPALETTE pPalette, UINT32 uiFlags, UINT32 uiStartingEntry, UINT32 uiCount, LPPALETTEENTRY pEntries ) { Assert( pPalette != NULL ); Assert( pEntries != NULL ); ATTEMPT( IDirectDrawPalette_SetEntries( pPalette, uiFlags, uiStartingEntry, uiCount, pEntries ) ); }
void DDGetPaletteEntries( LPDIRECTDRAWPALETTE pPalette, UINT32 uiFlags, UINT32 uiBase, UINT32 uiNumEntries, LPPALETTEENTRY pEntries ) { Assert( pPalette != NULL ); Assert( pEntries != NULL ); ATTEMPT( IDirectDrawPalette_GetEntries( pPalette, uiFlags, uiBase, uiNumEntries, pEntries ) ); }
void DDGetSurfaceDescription ( LPDIRECTDRAWSURFACE2 pSurface, DDSURFACEDESC *pSurfaceDesc ) { Assert ( pSurface != NULL ); Assert ( pSurfaceDesc != NULL ); ZEROMEM ( *pSurfaceDesc ); pSurfaceDesc->dwSize = sizeof ( DDSURFACEDESC ); ATTEMPT ( IDirectDrawSurface2_GetSurfaceDesc ( pSurface, pSurfaceDesc ) ); }
void DDDeleteAttachedSurface ( LPDIRECTDRAWSURFACE2 pParentSurface, LPDIRECTDRAWSURFACE2 pDeleteChildSurface ) { Assert ( pParentSurface != NULL ); Assert ( pDeleteChildSurface != NULL ); // seperate the z buffer surface from the raster surface ATTEMPT ( IDirectDrawSurface2_DeleteAttachedSurface ( pParentSurface, 0, pDeleteChildSurface ) ); }
void DDAddAttachedSurface ( LPDIRECTDRAWSURFACE2 pParentSurface, LPDIRECTDRAWSURFACE2 pAddChildSurface ) { Assert ( pParentSurface != NULL ); Assert ( pAddChildSurface != NULL ); // attach the child to the parent surface ATTEMPT ( IDirectDrawSurface2_AddAttachedSurface ( pParentSurface, pAddChildSurface ) ); }
void DDBltSurface( LPDIRECTDRAWSURFACE2 pDestSurface, LPRECT pDestRect, LPDIRECTDRAWSURFACE2 pSrcSurface, LPRECT pSrcRect, UINT32 uiFlags, LPDDBLTFX pDDBltFx ) { HRESULT ReturnCode; Assert( pDestSurface != NULL ); do { ReturnCode = IDirectDrawSurface2_SGPBlt( pDestSurface, pDestRect, pSrcSurface, pSrcRect, uiFlags, pDDBltFx ); } while( ReturnCode == DDERR_WASSTILLDRAWING ); ATTEMPT( ReturnCode ); }
// Lock, unlock calls void DDLockSurface ( LPDIRECTDRAWSURFACE2 pSurface, LPRECT pDestRect, LPDDSURFACEDESC pSurfaceDesc, UINT32 uiFlags, HANDLE hEvent ) { HRESULT ReturnCode; Assert( pSurface != NULL ); Assert( pSurfaceDesc != NULL ); ZEROMEM ( *pSurfaceDesc ); pSurfaceDesc->dwSize = sizeof(DDSURFACEDESC); do { ReturnCode = IDirectDrawSurface2_Lock( pSurface, pDestRect, pSurfaceDesc, uiFlags, hEvent); } while( ReturnCode == DDERR_WASSTILLDRAWING ); ATTEMPT( ReturnCode ); }
/* * 2. Marshal */ static bool_t authdes_marshal(AUTH *auth, XDR *xdrs) { /* LINTED pointer alignment */ struct ad_private *ad = AUTH_PRIVATE(auth); struct authdes_cred *cred = &ad->ad_cred; struct authdes_verf *verf = &ad->ad_verf; des_block cryptbuf[2]; des_block ivec; int status; int len; rpc_inline_t *ixdr; /* * Figure out the "time", accounting for any time difference * with the server if necessary. */ (void)gettimeofday(&ad->ad_timestamp, NULL); ad->ad_timestamp.tv_sec += ad->ad_timediff.tv_sec; ad->ad_timestamp.tv_usec += ad->ad_timediff.tv_usec; while (ad->ad_timestamp.tv_usec >= USEC_PER_SEC) { ad->ad_timestamp.tv_usec -= USEC_PER_SEC; ad->ad_timestamp.tv_sec++; } /* * XDR the timestamp and possibly some other things, then * encrypt them. */ ixdr = (rpc_inline_t *)cryptbuf; IXDR_PUT_INT32(ixdr, ad->ad_timestamp.tv_sec); IXDR_PUT_INT32(ixdr, ad->ad_timestamp.tv_usec); if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { IXDR_PUT_U_INT32(ixdr, ad->ad_window); IXDR_PUT_U_INT32(ixdr, ad->ad_window - 1); ivec.key.high = ivec.key.low = 0; status = cbc_crypt((char *)&auth->ah_key, (char *)cryptbuf, (u_int) 2 * sizeof (des_block), DES_ENCRYPT | DES_HW, (char *)&ivec); } else { status = ecb_crypt((char *)&auth->ah_key, (char *)cryptbuf, (u_int) sizeof (des_block), DES_ENCRYPT | DES_HW); } if (DES_FAILED(status)) { syslog(LOG_ERR, "authdes_marshal: DES encryption failure"); return (FALSE); } ad->ad_verf.adv_xtimestamp = cryptbuf[0]; if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { ad->ad_cred.adc_fullname.window = cryptbuf[1].key.high; ad->ad_verf.adv_winverf = cryptbuf[1].key.low; } else { ad->ad_cred.adc_nickname = ad->ad_nickname; ad->ad_verf.adv_winverf = 0; } /* * Serialize the credential and verifier into opaque * authentication data. */ if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { len = ((1 + 1 + 2 + 1)*BYTES_PER_XDR_UNIT + ad->ad_fullnamelen); } else { len = (1 + 1)*BYTES_PER_XDR_UNIT; } if ((ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT))) { IXDR_PUT_INT32(ixdr, AUTH_DES); IXDR_PUT_INT32(ixdr, len); } else { ATTEMPT(xdr_putint32(xdrs, (int *)&auth->ah_cred.oa_flavor)); ATTEMPT(xdr_putint32(xdrs, &len)); } ATTEMPT(xdr_authdes_cred(xdrs, cred)); len = (2 + 1)*BYTES_PER_XDR_UNIT; if ((ixdr = xdr_inline(xdrs, 2*BYTES_PER_XDR_UNIT))) { IXDR_PUT_INT32(ixdr, AUTH_DES); IXDR_PUT_INT32(ixdr, len); } else { ATTEMPT(xdr_putint32(xdrs, (int *)&auth->ah_verf.oa_flavor)); ATTEMPT(xdr_putint32(xdrs, &len)); } ATTEMPT(xdr_authdes_verf(xdrs, verf)); return (TRUE); }
void DDReleaseClipper( LPDIRECTDRAWCLIPPER pDDClipper ) { Assert( pDDClipper != NULL ); ATTEMPT( IDirectDrawClipper_Release( pDDClipper ) ); }
void DDRestoreSurface( LPDIRECTDRAWSURFACE2 pSurface ) { Assert( pSurface != NULL ); ATTEMPT( IDirectDrawSurface2_Restore( pSurface ) ); }
/* * D3DAppIHandleWM_SIZE * Processes the WM_SIZE message. Resizes all the buffers and re-creates * device if necessary. */ BOOL D3DAppIHandleWM_SIZE(LRESULT* lresult, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { int w, h; /* * If we have minimzied, take note and call the default window proc */ if (wParam == SIZE_MINIMIZED) { StoreMyShieldHull(); d3dappi.bMinimized = TRUE; *lresult = DefWindowProc(hwnd, message, wParam, lParam); return TRUE; } /* * In fullscreen mode, restore our surfaces and let DDraw take * care of the rest. */ if (d3dappi.bFullscreen) { D3DAppCheckForLostSurfaces(); d3dappi.bMinimized = FALSE; *lresult = DefWindowProc(hwnd, message, wParam, lParam); return TRUE; } /* * If we are minimized, this is the un-minimized size message. */ if (d3dappi.bMinimized) { /* * Restore our surfaces */ ReStoreMyShieldHull(); D3DAppCheckForLostSurfaces(); d3dappi.bMinimized = FALSE; *lresult = DefWindowProc(hwnd, message, wParam, lParam); return TRUE; } /* * Since we are still here, this must be a regular, window resize * message. A new viewport will definitely be needed, but the * device and buffers will only be re-created if they have gotten bigger * or change size by a very large amount. */ D3DAppIGetClientWin(hwnd); w = LOWORD(lParam); h = HIWORD(lParam); /* * If w and h are under the minimum, create buffers of the minimum size */ if (w < D3DAPP_WINDOWMINIMUM) w = D3DAPP_WINDOWMINIMUM; if (h < D3DAPP_WINDOWMINIMUM) h = D3DAPP_WINDOWMINIMUM; /* * Destroy the viewport and all execute buffers */ d3dappi.bRenderingIsOK = FALSE; ATTEMPT(D3DAppICallDeviceDestroyCallback()); /* * Only create a new device and buffers if they changed significantly, * otherwise just make sure the old buffers aren't lost. */ if ((w > szBuffers.cx || h > szBuffers.cy) || (w < szBuffers.cx / 2 || h < szBuffers.cy / 2)) { /* * Release the device */ RELEASE(d3dappi.lpD3DDevice); /* * Release the old buffers */ RELEASE(d3dappi.lpZBuffer); RELEASE(lpPalette); RELEASE(lpClipper); RELEASE(d3dappi.lpBackBuffer); RELEASE(d3dappi.lpFrontBuffer); /* * Create new ones */ ATTEMPT(D3DAppICreateBuffers(hwnd, w, h, D3DAPP_BOGUS, FALSE)); ATTEMPT(D3DAppICheckForPalettized()); ATTEMPT(D3DAppICreateZBuffer(w, h, d3dappi.CurrDriver)); /* * Create the driver */ ATTEMPT(D3DAppICreateDevice(d3dappi.CurrDriver)); /* * Since the driver did not change, the texture surfaces are still valid. * We just need to get new handles. */ if (d3dappi.ThisDriver.bDoesTextures) { } } else { D3DAppCheckForLostSurfaces(); } /* * Call the device create callback to create the viewport, set the render * state */ ATTEMPT(D3DAppICallDeviceCreateCallback(w, h)); ATTEMPT(D3DAppISetRenderState()); d3dappi.bRenderingIsOK = TRUE; /* * Call the default window proc */ *lresult = DefWindowProc(hwnd, message, wParam, lParam); return TRUE; exit_with_error: D3DAppICallDeviceDestroyCallback(); RELEASE(d3dappi.lpD3DDevice); RELEASE(d3dappi.lpZBuffer); RELEASE(lpPalette); RELEASE(lpClipper); RELEASE(d3dappi.lpBackBuffer); RELEASE(d3dappi.lpFrontBuffer); return FALSE; }
void DDReleasePalette( LPDIRECTDRAWPALETTE pPalette ) { Assert( pPalette != NULL ); ATTEMPT( IDirectDrawPalette_Release( pPalette ) ); }
/* * 2. Marshal */ static bool_t authdes_marshal (AUTH *auth, XDR *xdrs) { struct ad_private *ad = AUTH_PRIVATE (auth); struct authdes_cred *cred = &ad->ad_cred; struct authdes_verf *verf = &ad->ad_verf; des_block cryptbuf[2]; des_block ivec; int status; int len; register int32_t *ixdr; struct timeval tval; /* * Figure out the "time", accounting for any time difference * with the server if necessary. */ __gettimeofday (&tval, (struct timezone *) NULL); ad->ad_timestamp.tv_sec = tval.tv_sec + ad->ad_timediff.tv_sec; ad->ad_timestamp.tv_usec = tval.tv_usec + ad->ad_timediff.tv_usec; if (ad->ad_timestamp.tv_usec >= MILLION) { ad->ad_timestamp.tv_usec -= MILLION; ad->ad_timestamp.tv_sec += 1; } /* * XDR the timestamp and possibly some other things, then * encrypt them. * XXX We have a real Year 2038 problem here. */ ixdr = (int32_t *) cryptbuf; IXDR_PUT_INT32 (ixdr, ad->ad_timestamp.tv_sec); IXDR_PUT_INT32 (ixdr, ad->ad_timestamp.tv_usec); if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { IXDR_PUT_U_INT32 (ixdr, ad->ad_window); IXDR_PUT_U_INT32 (ixdr, ad->ad_window - 1); ivec.key.high = ivec.key.low = 0; status = cbc_crypt ((char *) &auth->ah_key, (char *) cryptbuf, 2 * sizeof (des_block), DES_ENCRYPT | DES_HW, (char *) &ivec); } else status = ecb_crypt ((char *) &auth->ah_key, (char *) cryptbuf, sizeof (des_block), DES_ENCRYPT | DES_HW); if (DES_FAILED (status)) { debug ("authdes_marshal: DES encryption failure"); return FALSE; } ad->ad_verf.adv_xtimestamp = cryptbuf[0]; if (ad->ad_cred.adc_namekind == ADN_FULLNAME) { ad->ad_cred.adc_fullname.window = cryptbuf[1].key.high; ad->ad_verf.adv_winverf = cryptbuf[1].key.low; } else { ad->ad_cred.adc_nickname = ad->ad_nickname; ad->ad_verf.adv_winverf = 0; } /* * Serialize the credential and verifier into opaque * authentication data. */ if (ad->ad_cred.adc_namekind == ADN_FULLNAME) len = ((1 + 1 + 2 + 1) * BYTES_PER_XDR_UNIT + ad->ad_fullnamelen); else len = (1 + 1) * BYTES_PER_XDR_UNIT; if ((ixdr = xdr_inline (xdrs, 2 * BYTES_PER_XDR_UNIT)) != NULL) { IXDR_PUT_INT32 (ixdr, AUTH_DES); IXDR_PUT_U_INT32 (ixdr, len); } else { ATTEMPT (xdr_putint32 (xdrs, &auth->ah_cred.oa_flavor)); ATTEMPT (xdr_putint32 (xdrs, &len)); } ATTEMPT (xdr_authdes_cred (xdrs, cred)); len = (2 + 1) * BYTES_PER_XDR_UNIT; if ((ixdr = xdr_inline (xdrs, 2 * BYTES_PER_XDR_UNIT)) != NULL) { IXDR_PUT_INT32 (ixdr, AUTH_DES); IXDR_PUT_U_INT32 (ixdr, len); } else { ATTEMPT (xdr_putint32 (xdrs, &auth->ah_verf.oa_flavor)); ATTEMPT (xdr_putint32 (xdrs, &len)); } ATTEMPT (xdr_authdes_verf (xdrs, verf)); return TRUE; }