Exemplo n.º 1
0
static int OnRelativeFileHelp(HWND hDlg)
{
    TFileTestData * pData = GetDialogData(hDlg);
    LPTSTR szBuffer;
    TCHAR szDesiredAccess[0x100];
    TCHAR szShareAccess[0x100];
    TCHAR szOpenOptions[0x100];
    TCHAR szMsgFormat[512];
    size_t cchBuffer = 0x1000;
    int nLength = 0;

    // Load both parts of the message
    nLength = LoadString(g_hInst, IDS_RELATIVE_FILE_HELP, szMsgFormat, _maxchars(szMsgFormat));
    if(nLength > 0)
    {
        // Allocate big buffer for the entire text
        szBuffer = new TCHAR[cchBuffer];
        if(szBuffer != NULL)
        {
            // Format the result string
            StringCchPrintf(szBuffer, cchBuffer, szMsgFormat,
                            pData->dwDesiredAccessRF, FlagsToString(DesiredAccessValues, szDesiredAccess, _countof(szDesiredAccess), pData->dwDesiredAccessRF, false),
                            pData->dwShareAccessRF,   FlagsToString(ShareAccessValues,   szShareAccess, _countof(szShareAccess), pData->dwShareAccessRF, false),
                            pData->dwOpenOptionsRF,   FlagsToString(CreateOptionsValues, szOpenOptions, _countof(szOpenOptions), pData->dwOpenOptionsRF, false));

            // Display the message box
            MessageBoxRc(hDlg, IDS_INFO, (UINT_PTR)szBuffer);
            delete [] szBuffer;
        }
    }
    return TRUE;
}
Exemplo n.º 2
0
// Not really a test, but a useful debugging tool.
TEST(ifaddrs, dump) {
  ifaddrs* addrs;
  ASSERT_EQ(0, getifaddrs(&addrs));

  for (ifaddrs* ifa = addrs; ifa != nullptr; ifa = ifa->ifa_next) {
    int family = ifa->ifa_addr ? ifa->ifa_addr->sa_family :
                                 ifa->ifa_broadaddr ? ifa->ifa_broadaddr->sa_family : AF_UNSPEC;

    printf("\t%s\n"
           "\t\t%s (%d) flags=%#x%s\n",
           ifa->ifa_name, FamilyToName(family), family,
           ifa->ifa_flags, FlagsToString(ifa->ifa_flags).c_str());

    if (family == AF_PACKET) {
      if (ifa->ifa_addr) print_sockaddr_ll("hwaddr", ifa->ifa_addr);
      if (ifa->ifa_broadaddr) print_sockaddr_ll("hwbroad", ifa->ifa_addr);
    } else if (family == AF_INET || family == AF_INET6) {
      if (ifa->ifa_addr) print_sockaddr_inet("address", ifa->ifa_addr);
      if (ifa->ifa_broadaddr && (ifa->ifa_flags & (IFF_BROADCAST | IFF_POINTOPOINT)) != 0) {
        print_sockaddr_inet((ifa->ifa_flags & IFF_BROADCAST) ? "broadcast" : "destination",
                            ifa->ifa_broadaddr);
      }
    }

    fflush(stdout);
  }

  freeifaddrs(addrs);
}
//@Override
String DisplayDeviceInfo::ToString()
{
    StringBuilder sb("DisplayDeviceInfo{\"");
    sb += mName;
    sb += "\": ";
    sb += mWidth;
    sb += " x ";
    sb += mHeight;
    sb += ", ";
    sb += mRefreshRate;
    sb += " fps, ";
    sb += "density ";
    sb += mDensityDpi;
    sb += ", ";
    sb += mXDpi;
    sb += " x ";
    sb += mYDpi;
    sb += " dpi, touch ";
    sb += TouchToString(mTouch);
    sb += FlagsToString(mFlags);
    sb += ", rotation ";
    sb += mRotation;
    sb += ", type ";
    sb += mType;//Display.typeToString(type)
    sb += ", address ";
    sb += mAddress;
    sb += "}";

    return sb.ToString();
}
Exemplo n.º 4
0
const good::string& CTypeToString::EntityClassFlagsToString( TEntityFlags iItemFlags )
{
	if ( iItemFlags == 0 )
		return sNone;
	else
		return FlagsToString( iItemFlags, FEntityTotal, aEntityClassFlags );
}
HRESULT __stdcall DDRAW4_HOOK_CreateSurface(LPVOID *ppvOut, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE4 FAR *lplpDDSurface4, IUnknown FAR *pUnkOuter) {
	const unsigned int hpos = 6;

	DDRAW4_CreateSurface_Type ofn = (DDRAW4_CreateSurface_Type)ddraw4_hooks[hpos].oldFunc;
	HRESULT ret = ofn(ppvOut, lpDDSurfaceDesc, lplpDDSurface4, pUnkOuter);
	LogDXError(ret);
	
	Log("IDirectDraw4::%s(this=%#010lx, lpDDSurfaceDesc=%#010lx, lplpDDSurface=%#010lx *[%#010lx], pUnkOuter=%#010lx)\n", ddraw4_hooks[hpos].name, ppvOut, lpDDSurfaceDesc, lplpDDSurface4, (lplpDDSurface4 != NULL ? *lplpDDSurface4 : NULL), pUnkOuter);
	if(lpDDSurfaceDesc != NULL) {
		char dwFlags_buffer[LOGBUFFER_MAX], ddscaps1_buffer[LOGBUFFER_MAX], ddpf_buffer[LOGBUFFER_MAX];
		FlagsToString(FLAGS_DDSD, CFLAGS_DDSD, lpDDSurfaceDesc->dwFlags, (char *)&dwFlags_buffer, LOGBUFFER_MAX);
		FlagsToString(FLAGS_DDSCAPS1, CFLAGS_DDSCAPS1, lpDDSurfaceDesc->ddsCaps.dwCaps, (char *)&ddscaps1_buffer, LOGBUFFER_MAX);
		FlagsToString(FLAGS_DDPF, CFLAGS_DDPF, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, (char *)&ddpf_buffer, LOGBUFFER_MAX);

		Log("->lpDDSurfaceDesc { dwSize=%#010lx, dwFlags=%#010lx (%s), dwWidth=%#010lx (%d), dwHeight=%#010lx (%d), lPitch=%#010lx , dwLinearSize=%#010lx, dwBackBufferCount=%#010lx, dwMipMapCount=%#010lx, dwRefreshRate=%#010lx, dwAlphaBitDepth=%#010lx, dwReserved=%#010lx,\n"
			"  lpSurface=%#010lx, ddckCKDestOverlay={ %#010lx, %#010lx }, ddckCKDestBlt={ %#010lx, %#010lx }, ddckCKSrcOverlay={ %#010lx, %#010lx }, ddckCKSrcBlt={ %#010lx, %#010lx },\n"
			"  ddpfPixelFormat={ dwSize=%#010lx, dwFlags=%#010lx (%s), dwFourCC=%#010lx, dwRGBBitCount=%#010lx, dwYUVBitCount=%#010lx, dwZBufferBitDepth=%#010lx, dwAlphaBitDepth=%#010lx, dwLuminanceBitCount=%#010lx, dwBumpBitCount=%#010lx, dwRBitMask=%#010lx,\n"
			"    dwYBitMask=%#010lx, dwStencilBitDepth=%#010lx, dwLuminanceBitMask=%#010lx, dwBumpDuBitMask=%#010lx, dwGBitMask=%#010lx, dwUBitMask=%#010lx, dwZBitMask=%#010lx, dwBumpDvBitMask=%#010lx, dwBBitMask=%#010lx, dwVBitMask=%#010lx, dwStencilBitMask=%#010lx,\n"
			"    dwBumpLuminanceBitMask=%#010lx, dwRGBAlphaBitMask=%#010lx, dwYUVAlphaBitMask=%#010lx, dwLuminanceAlphaBitMask=%#010lx, dwRGBZBitMask=%#010lx, dwYUVZBitMask=%#010lx },\n"
			"  ddsCaps={ %#010lx (%s), %#010lx, %#010lx, %#010lx }, dwTextureStage=%#010lx }\n",
			lpDDSurfaceDesc->dwSize, lpDDSurfaceDesc->dwFlags, dwFlags_buffer, lpDDSurfaceDesc->dwWidth, (unsigned int)lpDDSurfaceDesc->dwWidth, lpDDSurfaceDesc->dwHeight, (unsigned int)lpDDSurfaceDesc->dwHeight, lpDDSurfaceDesc->lPitch,
			lpDDSurfaceDesc->dwLinearSize, lpDDSurfaceDesc->dwBackBufferCount, lpDDSurfaceDesc->dwMipMapCount, lpDDSurfaceDesc->dwRefreshRate, lpDDSurfaceDesc->dwAlphaBitDepth, lpDDSurfaceDesc->dwReserved, lpDDSurfaceDesc->lpSurface,
			lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceHighValue,
			lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceHighValue,
			
			lpDDSurfaceDesc->ddpfPixelFormat.dwSize, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, ddpf_buffer, lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVBitCount,
			lpDDSurfaceDesc->ddpfPixelFormat.dwZBufferBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwAlphaBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpBitCount,
			lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDuBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwUBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwZBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDvBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwVBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpLuminanceBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBZBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwYUVZBitMask,
			
			lpDDSurfaceDesc->ddsCaps.dwCaps, ddscaps1_buffer, lpDDSurfaceDesc->ddsCaps.dwCaps2, lpDDSurfaceDesc->ddsCaps.dwCaps3, lpDDSurfaceDesc->ddsCaps.dwCaps4, lpDDSurfaceDesc->dwTextureStage
		);
	}
	if(ret == S_OK && ishooked_ddrawsurface4_hooks == false) {
		HookVTBLCalls((LPVOID *)lplpDDSurface4, ddrawsurface4_hooks, count_ddrawsurface4_hooks, "IDirectDrawSurface4");
		ishooked_ddrawsurface4_hooks = true;
	}

	return ret;
}
HRESULT __stdcall DDRAWPALETTE_HOOK_GetCaps(LPVOID *ppvOut, LPDWORD lpdwCaps) {
	const unsigned int hpos = 3;

	DDRAWPALETTE_GetCaps_Type ofn = (DDRAWPALETTE_GetCaps_Type)ddrawpalette_hooks[hpos].oldFunc;
	HRESULT ret = ofn(ppvOut, lpdwCaps);
	LogDXError(ret);

	char dwCaps_buffer[LOGBUFFER_MAX];
	if(lpdwCaps != NULL) FlagsToString(FLAGS_DDPCAPS, CFLAGS_DDPCAPS, *lpdwCaps, (char *)&dwCaps_buffer, LOGBUFFER_MAX);
	Log("IDirectDrawPalette::%s(this=%#010lx, lpdwCaps=%#010lx *[%#010lx]%s%s%s)\n", ddrawpalette_hooks[hpos].name, ppvOut, lpdwCaps, (lpdwCaps != NULL ? *lpdwCaps : NULL), (lpdwCaps != NULL ? " (" : ""), dwCaps_buffer, (lpdwCaps != NULL ? ")" : ""));

	return ret;
}
HRESULT __stdcall DDRAW4_HOOK_GetAvailableVidMem(LPVOID *ppvOut, LPDDSCAPS2 lpDDSCaps2, LPDWORD lpdwTotal, LPDWORD lpdwFree) {
	const unsigned int hpos = 23;

	DDRAW4_GetAvailableVidMem_Type ofn = (DDRAW4_GetAvailableVidMem_Type)ddraw4_hooks[hpos].oldFunc;
	HRESULT ret = ofn(ppvOut, lpDDSCaps2, lpdwTotal, lpdwFree);
	LogDXError(ret);

	Log("IDirectDraw4::%s(this=%#010lx, lpDDSCaps=%#010lx, lpdwTotal=%#010lx (%d), lpdwFree=%#010lx (%d))\n", ddraw4_hooks[hpos].name, ppvOut, lpDDSCaps2, lpdwTotal, lpdwTotal, lpdwFree, lpdwFree);
	if(lpDDSCaps2 != NULL) {
		char ddscaps1_buffer[LOGBUFFER_MAX];
		FlagsToString(FLAGS_DDSCAPS1, CFLAGS_DDSCAPS1, lpDDSCaps2->dwCaps, (char *)&ddscaps1_buffer, LOGBUFFER_MAX);

		Log("->lpDDSCaps2 { %#010lx (%s), %#010lx, %#010lx, %#010lx }\n",
			lpDDSCaps2->dwCaps, ddscaps1_buffer, lpDDSCaps2->dwCaps2, lpDDSCaps2->dwCaps3, lpDDSCaps2->dwCaps4
		);
	}
	return ret;
}
Exemplo n.º 8
0
const good::string& CTypeToString::WaypointFlagsToString(TWaypointFlags iFlags)
{
	return FlagsToString( iFlags, FWaypointTotal, aWaypointFlags );
}
HRESULT __stdcall DDRAW4_HOOK_CreateSurface(LPVOID *ppvOut, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE4 FAR *lplpDDSurface4, IUnknown FAR *pUnkOuter)
{
	const unsigned int hpos = 6;

	if(g_config.displaymode != 0)
	{
		/*if((void *)lpDDSurfaceDesc == (void *)0x00134518) {
				lpDDSurfaceDesc->dwWidth = displaymode_options[g_config.displaymode].resX;
				lpDDSurfaceDesc->dwHeight = displaymode_options[g_config.displaymode].resY;
		}*/
		if(lpDDSurfaceDesc != NULL && lpDDSurfaceDesc->dwWidth == 640 && lpDDSurfaceDesc->dwHeight == 480) {
				lpDDSurfaceDesc->dwWidth = displaymode_options[g_config.displaymode].resX;
				lpDDSurfaceDesc->dwHeight = displaymode_options[g_config.displaymode].resY;
		}
	}

	// 8-bit Paletted Textures Fix (VISTA Compatible)
	if(g_config.b8_paletted_textures_fix >= 1)
	{
		if(lpDDSurfaceDesc != NULL && (lpDDSurfaceDesc->ddsCaps.dwCaps & (DDSCAPS_ALLOCONLOAD | DDSCAPS_TEXTURE)) == (DDSCAPS_ALLOCONLOAD | DDSCAPS_TEXTURE)) {
			lpDDSurfaceDesc->dwFlags |= DDSD_CKSRCBLT;
			lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceLowValue = 0x000000;
			lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceHighValue = 0x000000;
		}
	}

#ifdef FF8_WINDOWED
	if((void *)lpDDSurfaceDesc == (void *)0x00134658)
	{
		Log("IF[lpDDSurfaceDesc == 0x00134658] THEN\n");
		lpDDSurfaceDesc->dwFlags &= ~(DDSD_BACKBUFFERCOUNT);
		//lpDDSurfaceDesc->dwFlags |= (DDSD_WIDTH | DDSD_HEIGHT);
		lpDDSurfaceDesc->dwWidth = 0;
		lpDDSurfaceDesc->dwHeight = 0;
		lpDDSurfaceDesc->dwBackBufferCount = 0;
		lpDDSurfaceDesc->ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_PRIMARYSURFACE );
		lpDDSurfaceDesc->ddsCaps.dwCaps |= (DDSCAPS_PRIMARYSURFACE);
	} /*else if((lpDDSurfaceDesc->ddsCaps.dwCaps & (DDSCAPS_ALLOCONLOAD | DDSCAPS_TEXTURE)) && (lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT) && (lpDDSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) && lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask == 0x7c00 && lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask == 0x3e0 && lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask == 0x1f) {
		lpDDSurfaceDesc->ddpfPixelFormat.dwFlags &= ~(DDPF_ALPHAPIXELS);
		lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwYUVAlphaBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceAlphaBitMask = 
			lpDDSurfaceDesc->ddpfPixelFormat.dwRGBZBitMask = 
			lpDDSurfaceDesc->ddpfPixelFormat.dwYUVZBitMask = 0x00;
	//Does not work: Crash in battle swirl
	}*/ /*else if((lpDDSurfaceDesc->ddsCaps.dwCaps & (DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE)) && (lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT) && (lpDDSurfaceDesc->ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) && lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount == 0x020) {
		lpDDSurfaceDesc->ddpfPixelFormat.dwFlags &= ~(DDPF_ALPHAPIXELS);
		lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount =
			lpDDSurfaceDesc->ddpfPixelFormat.dwYUVBitCount =
			lpDDSurfaceDesc->ddpfPixelFormat.dwZBufferBitDepth =
			lpDDSurfaceDesc->ddpfPixelFormat.dwAlphaBitDepth =
			lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitCount =
			lpDDSurfaceDesc->ddpfPixelFormat.dwBumpBitCount = 0x10;
		lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwYBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitDepth =
			lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDuBitMask = 0xf800;
		lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwUBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwZBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDvBitMask = 0x7e0;
		lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwVBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwBumpLuminanceBitMask = 0x1f;
		lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwYUVAlphaBitMask =
			lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceAlphaBitMask = 
			lpDDSurfaceDesc->ddpfPixelFormat.dwRGBZBitMask = 
			lpDDSurfaceDesc->ddpfPixelFormat.dwYUVZBitMask = 0x00;
	}*/

/*
16BIT
->lpDDSurfaceDesc { dwSize=0x0000007c, dwFlags=0x00001007 (DDSD_CAPS | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_WIDTH), dwWidth=0x00000100 (256), dwHeight=0x00000100 (256), lPitch=0000000000 , dwLinearSize=0000000000, dwBackBufferCount=0000000000, dwMipMapCount=0000000000, dwRefreshRate=0000000000, dwAlphaBitDepth=0000000000, dwReserved=0000000000,
lpSurface=0000000000, ddckCKDestOverlay={ 0000000000, 0000000000 }, ddckCKDestBlt={ 0000000000, 0000000000 }, ddckCKSrcOverlay={ 0000000000, 0000000000 }, ddckCKSrcBlt={ 0000000000, 0000000000 },
ddpfPixelFormat={ dwSize=0x00000020, dwFlags=0x00000040 (DDPF_RGB), dwFourCC=0000000000, dwRGBBitCount=0x00000010, dwYUVBitCount=0x00000010, dwZBufferBitDepth=0x00000010, dwAlphaBitDepth=0x00000010, dwLuminanceBitCount=0x00000010, dwBumpBitCount=0x00000010, dwRBitMask=0x0000f800,
dwYBitMask=0x0000f800, dwStencilBitDepth=0x0000f800, dwLuminanceBitMask=0x0000f800, dwBumpDuBitMask=0x0000f800, dwGBitMask=0x000007e0, dwUBitMask=0x000007e0, dwZBitMask=0x000007e0, dwBumpDvBitMask=0x000007e0, dwBBitMask=0x0000001f, dwVBitMask=0x0000001f, dwStencilBitMask=0x0000001f,
dwBumpLuminanceBitMask=0x0000001f, dwRGBAlphaBitMask=0000000000, dwYUVAlphaBitMask=0000000000, dwLuminanceAlphaBitMask=0000000000, dwRGBZBitMask=0000000000, dwYUVZBitMask=0000000000 },
ddsCaps={ 0x00001800 (DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE), 0000000000, 0000000000, 0000000000 }, dwTextureStage=0000000000 }

32BIT
->lpDDSurfaceDesc { dwSize=0x0000007c, dwFlags=0x00001007 (DDSD_CAPS | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_WIDTH), dwWidth=0x00000100 (256), dwHeight=0x00000100 (256), lPitch=0000000000 , dwLinearSize=0000000000, dwBackBufferCount=0000000000, dwMipMapCount=0000000000, dwRefreshRate=0000000000, dwAlphaBitDepth=0000000000, dwReserved=0000000000,
lpSurface=0000000000, ddckCKDestOverlay={ 0000000000, 0000000000 }, ddckCKDestBlt={ 0000000000, 0000000000 }, ddckCKSrcOverlay={ 0000000000, 0000000000 }, ddckCKSrcBlt={ 0000000000, 0000000000 },
ddpfPixelFormat={ dwSize=0x00000020, dwFlags=0x00000041 (DDPF_ALPHAPIXELS | DDPF_RGB), dwFourCC=0000000000, dwRGBBitCount=0x00000020, dwYUVBitCount=0x00000020, dwZBufferBitDepth=0x00000020, dwAlphaBitDepth=0x00000020, dwLuminanceBitCount=0x00000020, dwBumpBitCount=0x00000020, dwRBitMask=0x00ff0000,
dwYBitMask=0x00ff0000, dwStencilBitDepth=0x00ff0000, dwLuminanceBitMask=0x00ff0000, dwBumpDuBitMask=0x00ff0000, dwGBitMask=0x0000ff00, dwUBitMask=0x0000ff00, dwZBitMask=0x0000ff00, dwBumpDvBitMask=0x0000ff00, dwBBitMask=0x000000ff, dwVBitMask=0x000000ff, dwStencilBitMask=0x000000ff,
dwBumpLuminanceBitMask=0x000000ff, dwRGBAlphaBitMask=0xff000000, dwYUVAlphaBitMask=0xff000000, dwLuminanceAlphaBitMask=0xff000000, dwRGBZBitMask=0xff000000, dwYUVZBitMask=0xff000000 },
ddsCaps={ 0x00001800 (DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE), 0000000000, 0000000000, 0000000000 }, dwTextureStage=0000000000 }
*/
#endif

	DDRAW4_CreateSurface_Type ofn = (DDRAW4_CreateSurface_Type)ddraw4_hooks[hpos].oldFunc;
	HRESULT ret = ofn(ppvOut, lpDDSurfaceDesc, lplpDDSurface4, pUnkOuter);
	LogDXError(ret);
	
	Log("IDirectDraw4::%s(this=%#010lx, lpDDSurfaceDesc=%#010lx, lplpDDSurface=%#010lx *[%#010lx], pUnkOuter=%#010lx)\n", ddraw4_hooks[hpos].name, ppvOut, lpDDSurfaceDesc, lplpDDSurface4, (lplpDDSurface4 != NULL ? *lplpDDSurface4 : NULL), pUnkOuter);
	if(lpDDSurfaceDesc != NULL)
	{
		char dwFlags_buffer[LOGBUFFER_MAX], ddscaps1_buffer[LOGBUFFER_MAX], ddpf_buffer[LOGBUFFER_MAX];
		FlagsToString(FLAGS_DDSD, CFLAGS_DDSD, lpDDSurfaceDesc->dwFlags, (char *)&dwFlags_buffer, LOGBUFFER_MAX);
		FlagsToString(FLAGS_DDSCAPS1, CFLAGS_DDSCAPS1, lpDDSurfaceDesc->ddsCaps.dwCaps, (char *)&ddscaps1_buffer, LOGBUFFER_MAX);
		FlagsToString(FLAGS_DDPF, CFLAGS_DDPF, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, (char *)&ddpf_buffer, LOGBUFFER_MAX);

		Log("->lpDDSurfaceDesc { dwSize=%#010lx, dwFlags=%#010lx (%s), dwWidth=%#010lx (%d), dwHeight=%#010lx (%d), lPitch=%#010lx , dwLinearSize=%#010lx, dwBackBufferCount=%#010lx, dwMipMapCount=%#010lx, dwRefreshRate=%#010lx, dwAlphaBitDepth=%#010lx, dwReserved=%#010lx,\n"
			"  lpSurface=%#010lx, ddckCKDestOverlay={ %#010lx, %#010lx }, ddckCKDestBlt={ %#010lx, %#010lx }, ddckCKSrcOverlay={ %#010lx, %#010lx }, ddckCKSrcBlt={ %#010lx, %#010lx },\n"
			"  ddpfPixelFormat={ dwSize=%#010lx, dwFlags=%#010lx (%s), dwFourCC=%#010lx, dwRGBBitCount=%#010lx, dwYUVBitCount=%#010lx, dwZBufferBitDepth=%#010lx, dwAlphaBitDepth=%#010lx, dwLuminanceBitCount=%#010lx, dwBumpBitCount=%#010lx, dwRBitMask=%#010lx,\n"
			"    dwYBitMask=%#010lx, dwStencilBitDepth=%#010lx, dwLuminanceBitMask=%#010lx, dwBumpDuBitMask=%#010lx, dwGBitMask=%#010lx, dwUBitMask=%#010lx, dwZBitMask=%#010lx, dwBumpDvBitMask=%#010lx, dwBBitMask=%#010lx, dwVBitMask=%#010lx, dwStencilBitMask=%#010lx,\n"
			"    dwBumpLuminanceBitMask=%#010lx, dwRGBAlphaBitMask=%#010lx, dwYUVAlphaBitMask=%#010lx, dwLuminanceAlphaBitMask=%#010lx, dwRGBZBitMask=%#010lx, dwYUVZBitMask=%#010lx },\n"
			"  ddsCaps={ %#010lx (%s), %#010lx, %#010lx, %#010lx }, dwTextureStage=%#010lx }\n",
			lpDDSurfaceDesc->dwSize, lpDDSurfaceDesc->dwFlags, dwFlags_buffer, lpDDSurfaceDesc->dwWidth, (unsigned int)lpDDSurfaceDesc->dwWidth, lpDDSurfaceDesc->dwHeight, (unsigned int)lpDDSurfaceDesc->dwHeight, lpDDSurfaceDesc->lPitch,
			lpDDSurfaceDesc->dwLinearSize, lpDDSurfaceDesc->dwBackBufferCount, lpDDSurfaceDesc->dwMipMapCount, lpDDSurfaceDesc->dwRefreshRate, lpDDSurfaceDesc->dwAlphaBitDepth, lpDDSurfaceDesc->dwReserved, lpDDSurfaceDesc->lpSurface,
			lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceHighValue,
			lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceHighValue,
			
			lpDDSurfaceDesc->ddpfPixelFormat.dwSize, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, ddpf_buffer, lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVBitCount,
			lpDDSurfaceDesc->ddpfPixelFormat.dwZBufferBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwAlphaBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpBitCount,
			lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDuBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwUBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwZBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDvBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwVBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpLuminanceBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBZBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwYUVZBitMask,
			
			lpDDSurfaceDesc->ddsCaps.dwCaps, ddscaps1_buffer, lpDDSurfaceDesc->ddsCaps.dwCaps2, lpDDSurfaceDesc->ddsCaps.dwCaps3, lpDDSurfaceDesc->ddsCaps.dwCaps4, lpDDSurfaceDesc->dwTextureStage
		);
	}
	if(ishooked_ddrawsurface4_hooks == false)
	{
		HookVTBLCalls((LPVOID *)lplpDDSurface4, ddrawsurface4_hooks, count_ddrawsurface4_hooks, "IDirectDrawSurface4");
		ishooked_ddrawsurface4_hooks = true;
	}

	// ------------------------------------------------------------------
	// Create a DirectX window
	// ----------------------------
#ifdef FF8_WINDOWED
	if((void *)lpDDSurfaceDesc == (void *)0x00134658)
	{
		Log("IF[lpDDSurfaceDesc == 0x00134658] THEN\n");
		if(SUCCEEDED(ret))
		{

			LPDIRECTDRAWCLIPPER pcClipper;
			if(FAILED(((LPDIRECTDRAW4)ppvOut)->CreateClipper(0, &pcClipper, NULL)))
			{
				Log("ERROR: Couldn't create clipper\n");
			}

			// Associate the clipper with the window
			Log("g_hwnd=%#01lx\n", g_hwnd);
			pcClipper->SetHWnd(0, g_hwnd);
			(*lplpDDSurface4)->SetClipper(pcClipper);
			//SAFE_RELEASE(pcClipper);

			HRESULT hr = 0;
			LPDIRECTDRAWSURFACE4 lpddsB = NULL;
			LPDIRECTDRAWSURFACE4 lpddsZ = NULL;
			DDSURFACEDESC2 ddsd;
			ZeroMemory(&ddsd, sizeof(ddsd));
			ddsd.dwSize = sizeof(ddsd);
			ddsd.dwFlags = (DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT);
			ddsd.ddsCaps.dwCaps    = (lpDDSurfaceDesc->ddsCaps.dwCaps);
			ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_PRIMARYSURFACE);
			ddsd.ddsCaps.dwCaps |= (DDSCAPS_OFFSCREENPLAIN);
			ddsd.dwWidth           = 640;
			ddsd.dwHeight          = 480;
			//hRes = lpdd->lpVtbl->CreateSurface(lpdd, &ddsd, &lpddZBuffer,NULL);
			hr = ((LPDIRECTDRAW4)ppvOut)->CreateSurface(&ddsd, &lpddsB, NULL);
			if(FAILED(hr))
			{
				Log("ERROR: Failed to create WINDOWED backbuffer!");
			} else {
				//hr = (*lplpDDSurface4)->AddAttachedSurface(lpddsB);
				//if(FAILED(hr)) {
				//	Log("ERROR: Failed to attach WINDOWED backbuffer to frontbuffer!");
				//} else {
					g_frontbuffer = (*lplpDDSurface4);
					g_backbuffer = lpddsB;
					/*hr = ((LPDIRECTDRAW4)ppvOut)->CreateSurface(&ddsd, &lpddsZ, NULL);
					if(FAILED(hr)) {
						Log("ERROR: Failed to create WINDOWED z-buffer!");
					} else {
						hr = lpddsB->AddAttachedSurface(lpddsZ);
						if(FAILED(hr)) {
							Log("ERROR: Failed to attach WINDOWED z-buffer to backbuffer!");
						} else {
							
						}
					}*/
				//}
			}
		}
	}
#endif
	// ----------------------------------

	return ret;
}
Exemplo n.º 10
0
const good::string& CTypeToString::PathFlagsToString( TPathFlags iFlags )
{
	return FlagsToString( iFlags, FPathTotal, aPathFlags );
}
Exemplo n.º 11
0
VOID NTAPI DotNetEventCallback(
    _In_ PEVENT_RECORD EventRecord
    )
{
    PASMPAGE_QUERY_CONTEXT context = EventRecord->UserContext;
    PEVENT_HEADER eventHeader = &EventRecord->EventHeader;
    PEVENT_DESCRIPTOR eventDescriptor = &eventHeader->EventDescriptor;

    if (UlongToHandle(eventHeader->ProcessId) == context->ProcessId)
    {
        // .NET 4.0+

        switch (eventDescriptor->Id)
        {
        case RuntimeInformationDCStart:
            {
                PRuntimeInformationRundown data = EventRecord->UserData;
                PDNA_NODE node;
                PPH_STRING startupFlagsString;
                PPH_STRING startupModeString;

                // Check for duplicates.
                if (FindClrNode(context, data->ClrInstanceID))
                    break;

                node = AddNode(context);
                node->Type = DNA_TYPE_CLR;
                node->u.Clr.ClrInstanceID = data->ClrInstanceID;
                node->u.Clr.DisplayName = PhFormatString(L"CLR v%u.%u.%u.%u", data->VMMajorVersion, data->VMMinorVersion, data->VMBuildNumber, data->VMQfeNumber);
                node->StructureText = node->u.Clr.DisplayName->sr;
                node->IdText = PhFormatString(L"%u", data->ClrInstanceID);

                startupFlagsString = FlagsToString(data->StartupFlags, StartupFlagsMap, sizeof(StartupFlagsMap));
                startupModeString = FlagsToString(data->StartupMode, StartupModeMap, sizeof(StartupModeMap));

                if (startupFlagsString->Length != 0 && startupModeString->Length != 0)
                {
                    node->FlagsText = PhConcatStrings(3, startupFlagsString->Buffer, L", ", startupModeString->Buffer);
                    PhDereferenceObject(startupFlagsString);
                    PhDereferenceObject(startupModeString);
                }
                else if (startupFlagsString->Length != 0)
                {
                    node->FlagsText = startupFlagsString;
                    PhDereferenceObject(startupModeString);
                }
                else if (startupModeString->Length != 0)
                {
                    node->FlagsText = startupModeString;
                    PhDereferenceObject(startupFlagsString);
                }

                if (data->CommandLine[0])
                    node->PathText = PhCreateString(data->CommandLine);

                PhAddItemList(context->NodeRootList, node);
            }
            break;
        case AppDomainDCStart_V1:
            {
                PAppDomainLoadUnloadRundown_V1 data = EventRecord->UserData;
                SIZE_T appDomainNameLength;
                USHORT clrInstanceID;
                PDNA_NODE parentNode;
                PDNA_NODE node;

                appDomainNameLength = PhCountStringZ(data->AppDomainName) * sizeof(WCHAR);
                clrInstanceID = *(PUSHORT)((PCHAR)data + FIELD_OFFSET(AppDomainLoadUnloadRundown_V1, AppDomainName) + appDomainNameLength + sizeof(WCHAR) + sizeof(ULONG));

                // Find the CLR node to add the AppDomain node to.
                parentNode = FindClrNode(context, clrInstanceID);

                if (parentNode)
                {
                    // Check for duplicates.
                    if (FindAppDomainNode(parentNode, data->AppDomainID))
                        break;

                    node = AddNode(context);
                    node->Type = DNA_TYPE_APPDOMAIN;
                    node->u.AppDomain.AppDomainID = data->AppDomainID;
                    node->u.AppDomain.DisplayName = PhConcatStrings2(L"AppDomain: ", data->AppDomainName);
                    node->StructureText = node->u.AppDomain.DisplayName->sr;
                    node->IdText = PhFormatString(L"%I64u", data->AppDomainID);
                    node->FlagsText = FlagsToString(data->AppDomainFlags, AppDomainFlagsMap, sizeof(AppDomainFlagsMap));

                    PhAddItemList(parentNode->Children, node);
                }
            }
            break;
        case AssemblyDCStart_V1:
            {
                PAssemblyLoadUnloadRundown_V1 data = EventRecord->UserData;
                SIZE_T fullyQualifiedAssemblyNameLength;
                USHORT clrInstanceID;
                PDNA_NODE parentNode;
                PDNA_NODE node;
                PH_STRINGREF remainingPart;

                fullyQualifiedAssemblyNameLength = PhCountStringZ(data->FullyQualifiedAssemblyName) * sizeof(WCHAR);
                clrInstanceID = *(PUSHORT)((PCHAR)data + FIELD_OFFSET(AssemblyLoadUnloadRundown_V1, FullyQualifiedAssemblyName) + fullyQualifiedAssemblyNameLength + sizeof(WCHAR));

                // Find the AppDomain node to add the Assembly node to.

                parentNode = FindClrNode(context, clrInstanceID);

                if (parentNode)
                    parentNode = FindAppDomainNode(parentNode, data->AppDomainID);

                if (parentNode)
                {
                    // Check for duplicates.
                    if (FindAssemblyNode(parentNode, data->AssemblyID))
                        break;

                    node = AddNode(context);
                    node->Type = DNA_TYPE_ASSEMBLY;
                    node->u.Assembly.AssemblyID = data->AssemblyID;
                    node->u.Assembly.FullyQualifiedAssemblyName = PhCreateStringEx(data->FullyQualifiedAssemblyName, fullyQualifiedAssemblyNameLength);

                    // Display only the assembly name, not the whole fully qualified name.
                    if (!PhSplitStringRefAtChar(&node->u.Assembly.FullyQualifiedAssemblyName->sr, ',', &node->StructureText, &remainingPart))
                        node->StructureText = node->u.Assembly.FullyQualifiedAssemblyName->sr;

                    node->IdText = PhFormatString(L"%I64u", data->AssemblyID);
                    node->FlagsText = FlagsToString(data->AssemblyFlags, AssemblyFlagsMap, sizeof(AssemblyFlagsMap));

                    PhAddItemList(parentNode->Children, node);
                }
            }
            break;
        case ModuleDCStart_V1:
            {
                PModuleLoadUnloadRundown_V1 data = EventRecord->UserData;
                PWSTR moduleILPath;
                SIZE_T moduleILPathLength;
                PWSTR moduleNativePath;
                SIZE_T moduleNativePathLength;
                USHORT clrInstanceID;
                PDNA_NODE node;

                moduleILPath = data->ModuleILPath;
                moduleILPathLength = PhCountStringZ(moduleILPath) * sizeof(WCHAR);
                moduleNativePath = (PWSTR)((PCHAR)moduleILPath + moduleILPathLength + sizeof(WCHAR));
                moduleNativePathLength = PhCountStringZ(moduleNativePath) * sizeof(WCHAR);
                clrInstanceID = *(PUSHORT)((PCHAR)moduleNativePath + moduleNativePathLength + sizeof(WCHAR));

                // Find the Assembly node to set the path on.

                node = FindClrNode(context, clrInstanceID);

                if (node)
                    node = FindAssemblyNode2(node, data->AssemblyID);

                if (node)
                {
                    PhMoveReference(&node->PathText, PhCreateStringEx(moduleILPath, moduleILPathLength));

                    if (moduleNativePathLength != 0)
                        PhMoveReference(&node->NativePathText, PhCreateStringEx(moduleNativePath, moduleNativePathLength));
                }
            }
            break;
        case DCStartComplete_V1:
            {
                if (_InterlockedExchange(&context->TraceHandleActive, 0) == 1)
                {
                    CloseTrace(context->TraceHandle);
                }
            }
            break;
        }

        // .NET 2.0

        if (eventDescriptor->Id == 0)
        {
            switch (eventDescriptor->Opcode)
            {
            case CLR_MODULEDCSTART_OPCODE:
                {
                    PModuleLoadUnloadRundown_V1 data = EventRecord->UserData;
                    PWSTR moduleILPath;
                    SIZE_T moduleILPathLength;
                    PWSTR moduleNativePath;
                    SIZE_T moduleNativePathLength;
                    PDNA_NODE node;
                    ULONG_PTR indexOfBackslash;
                    ULONG_PTR indexOfLastDot;

                    moduleILPath = data->ModuleILPath;
                    moduleILPathLength = PhCountStringZ(moduleILPath) * sizeof(WCHAR);
                    moduleNativePath = (PWSTR)((PCHAR)moduleILPath + moduleILPathLength + sizeof(WCHAR));
                    moduleNativePathLength = PhCountStringZ(moduleNativePath) * sizeof(WCHAR);

                    if (context->ClrV2Node && (moduleILPathLength != 0 || moduleNativePathLength != 0))
                    {
                        node = AddNode(context);
                        node->Type = DNA_TYPE_ASSEMBLY;
                        node->FlagsText = FlagsToString(data->ModuleFlags, ModuleFlagsMap, sizeof(ModuleFlagsMap));
                        node->PathText = PhCreateStringEx(moduleILPath, moduleILPathLength);

                        if (moduleNativePathLength != 0)
                            node->NativePathText = PhCreateStringEx(moduleNativePath, moduleNativePathLength);

                        // Use the name between the last backslash and the last dot for the structure column text.
                        // (E.g. C:\...\AcmeSoft.BigLib.dll -> AcmeSoft.BigLib)

                        indexOfBackslash = PhFindLastCharInString(node->PathText, 0, '\\');
                        indexOfLastDot = PhFindLastCharInString(node->PathText, 0, '.');

                        if (indexOfBackslash != -1)
                        {
                            node->StructureText.Buffer = node->PathText->Buffer + indexOfBackslash + 1;

                            if (indexOfLastDot != -1 && indexOfLastDot > indexOfBackslash)
                            {
                                node->StructureText.Length = (indexOfLastDot - indexOfBackslash - 1) * sizeof(WCHAR);
                            }
                            else
                            {
                                node->StructureText.Length = node->PathText->Length - indexOfBackslash * sizeof(WCHAR) - sizeof(WCHAR);
                            }
                        }
                        else
                        {
                            node->StructureText = node->PathText->sr;
                        }

                        PhAddItemList(context->ClrV2Node->Children, node);
                    }
                }
                break;
            case CLR_METHODDC_DCSTARTCOMPLETE_OPCODE:
                {
                    if (_InterlockedExchange(&context->TraceHandleActive, 0) == 1)
                    {
                        CloseTrace(context->TraceHandle);
                    }
                }
                break;
            }
        }
    }
}
Exemplo n.º 12
0
const good::string& CTypeToString::WaypointDrawFlagsToString( TWaypointDrawFlags iFlags )
{
	return FlagsToString( iFlags, FWaypointDrawTotal, aDrawTypeFlags );
}
Exemplo n.º 13
0
		ZED_UINT32 XboxRenderer::Create( GraphicsAdapter *p_Adapter,
			const CanvasDescription &p_Canvas )
		{
			ZED_UINT32 ReturnStatus = ZED_FAIL;

			if( NULL ==( m_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) )
			{
				return ZED_FAIL;
			}

			m_Canvas = p_Canvas;

			m_PresentParams.BackBufferWidth = m_Canvas.GetWidth( );
			m_PresentParams.BackBufferHeight = m_Canvas.GetHeight( );
			m_PresentParams.BackBufferCount = m_Canvas.GetBackBufferCount( );
			m_PresentParams.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

			// Get the colour
			switch( m_Canvas.GetBPP( ) )
			{
			case ZED_FORMAT_ARGB8:
				{
					m_PresentParams.BackBufferFormat = D3DFMT_A8R8G8B8;
					ReturnStatus = ZED_OK;
					break;
				}
			default:
				{
					zedTrace( "Failed to set the back buffer format" );
					return ZED_FAIL;
				}
			}

			// Get the Depth/Stencil
			switch( m_Canvas.GetDepthStencil( ) )
			{
			case ZED_FORMAT_D24S8:
				{
					m_PresentParams.EnableAutoDepthStencil = ZED_TRUE;
					m_PresentParams.AutoDepthStencilFormat = D3DFMT_D24S8;
					ReturnStatus = ZED_OK;
					break;
				}
			default:
				{
					zedTrace( "Failed to set the depth/stencil format" );
					return ZED_FAIL;
				}
			}

			// This needs to be exposed, but how?
			m_PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;

			if( FAILED( m_pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, NULL,
				D3DCREATE_HARDWARE_VERTEXPROCESSING, &m_PresentParams,
				&m_pDevice ) ) )
			{
				zedTrace( "Failed to create device" );
				return ZED_FAIL;
			}

#ifdef ZED_BUILD_DEBUG
			ZED_UINT32 ModeCount = m_pD3D->GetAdapterModeCount( D3DADAPTER_DEFAULT );
			D3DDISPLAYMODE *pModes = new D3DDISPLAYMODE[ ModeCount ];
			for( ZED_MEMSIZE i = 0; i < ModeCount; i++ )
			{
				if( FAILED( m_pD3D->EnumAdapterModes( D3DADAPTER_DEFAULT, i,
					&pModes[ i ] ) ) )
				{
					delete pModes;
					return ZED_FAIL;
				}

				ZED_MEMSIZE Len = strlen( FlagsToString( pModes[ i ].Flags ) );
				char *pFlags;
			
				if( Len > 0 )
				{
					pFlags = new char[ Len ];
					strncpy( pFlags, FlagsToString( pModes[ i ].Flags ), Len-1 );
					pFlags[ Len-1 ] = '\0';
				}
				if( Len == 0 )
				{
					// Add one for null-termination
					Len = strlen( "NO FLAGS" )+1;
					pFlags = new char[ Len ];
					strncpy( pFlags, "NO FLAGS", Len );
				}	

				// Print out the adapter's capabilities
				zedTrace( "Mode %d:\n"
					"\tWidth: %d | Height: %d | Refresh Rate: %d | Flags: %s \n",
					i,
					pModes[ i ].Width, pModes[ i ].Height,
					pModes[ i ].RefreshRate,
					pFlags );

				delete pFlags;
			}
#endif

			return ReturnStatus;
		}
Exemplo n.º 14
0
const good::string& CTypeToString::PathDrawFlagsToString( TPathDrawFlags iFlags )
{
	return FlagsToString( iFlags, FPathDrawTotal, aDrawTypeFlags );
}
Exemplo n.º 15
0
const good::string& CTypeToString::AccessFlagsToString( TCommandAccessFlags iFlags )
{
	return FlagsToString( iFlags, FCommandAccessTotal, aAccessFlags );
}
HRESULT __stdcall DDRAWSURFACE4_HOOK_GetSurfaceDesc(LPVOID *ppvOut, LPDDSURFACEDESC2 lpDDSurfaceDesc) {
	const unsigned int hpos = 22;

	DDRAWSURFACE4_GetSurfaceDesc_Type ofn = (DDRAWSURFACE4_GetSurfaceDesc_Type)ddrawsurface4_hooks[hpos].oldFunc;
	HRESULT ret = ofn(ppvOut, lpDDSurfaceDesc);
	LogDXError(ret);

	DDSURFACEDESC2 & sd = *lpDDSurfaceDesc;
	if((!g_config.fullscreen && (LPDIRECTDRAWSURFACE4)ppvOut == g_backbuffer) ||
	  (sd.dwWidth == displaymode_options[g_config.displaymode].resX &&
	   sd.dwHeight == displaymode_options[g_config.displaymode].resY &&
	   (sd.ddsCaps.dwCaps & DDSCAPS_BACKBUFFER))) {
		sd.ddpfPixelFormat.dwFlags = DDPF_RGB;
		sd.ddpfPixelFormat.dwFourCC = 0;
		sd.ddpfPixelFormat.dwRGBBitCount = 16;
		sd.ddpfPixelFormat.dwRBitMask = 0xf800;
		sd.ddpfPixelFormat.dwGBitMask = 0x07e0;
		sd.ddpfPixelFormat.dwBBitMask = 0x001f;
		sd.dwWidth = 640;
		sd.dwHeight = 480;
		Log("Backbuffer info adjustment\n");
	}
	// Similarily, the frontbuffer is read for special effects which also depend on the fixed size.
	if((!g_config.fullscreen && (LPDIRECTDRAWSURFACE4)ppvOut == g_frontbuffer) ||
	  (sd.dwWidth == displaymode_options[g_config.displaymode].resX &&
	   sd.dwHeight == displaymode_options[g_config.displaymode].resY &&
	   (sd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))) {
		sd.ddpfPixelFormat.dwFlags = DDPF_RGB;
		sd.ddpfPixelFormat.dwFourCC = 0;
		sd.ddpfPixelFormat.dwRGBBitCount = 16;
		sd.ddpfPixelFormat.dwRBitMask = 0xf800;
		sd.ddpfPixelFormat.dwGBitMask = 0x07e0;
		sd.ddpfPixelFormat.dwBBitMask = 0x001f;
		sd.dwWidth = 640;
		sd.dwHeight = 480;
		Log("Frontbuffer info adjustment\n");
	}

	Log("IDirectDrawSurface4::%s(this=%#010lx, lpDDSurfaceDesc=%#010lx)\n", ddrawsurface4_hooks[hpos].name, ppvOut, lpDDSurfaceDesc);
	if(lpDDSurfaceDesc != NULL) {
		char dwFlags_buffer[LOGBUFFER_MAX], ddscaps1_buffer[LOGBUFFER_MAX], ddpf_buffer[LOGBUFFER_MAX];
		FlagsToString(FLAGS_DDSD, CFLAGS_DDSD, lpDDSurfaceDesc->dwFlags, (char *)&dwFlags_buffer, LOGBUFFER_MAX);
		FlagsToString(FLAGS_DDSCAPS1, CFLAGS_DDSCAPS1, lpDDSurfaceDesc->ddsCaps.dwCaps, (char *)&ddscaps1_buffer, LOGBUFFER_MAX);
		FlagsToString(FLAGS_DDPF, CFLAGS_DDPF, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, (char *)&ddpf_buffer, LOGBUFFER_MAX);

		Log("->lpDDSurfaceDesc { dwSize=%#010lx, dwFlags=%#010lx (%s), dwWidth=%#010lx (%d), dwHeight=%#010lx (%d), lPitch=%#010lx , dwLinearSize=%#010lx, dwBackBufferCount=%#010lx, dwMipMapCount=%#010lx, dwRefreshRate=%#010lx, dwAlphaBitDepth=%#010lx, dwReserved=%#010lx,\n"
			"  lpSurface=%#010lx, ddckCKDestOverlay={ %#010lx, %#010lx }, ddckCKDestBlt={ %#010lx, %#010lx }, ddckCKSrcOverlay={ %#010lx, %#010lx }, ddckCKSrcBlt={ %#010lx, %#010lx },\n"
			"  ddpfPixelFormat={ dwSize=%#010lx, dwFlags=%#010lx (%s), dwFourCC=%#010lx, dwRGBBitCount=%#010lx, dwYUVBitCount=%#010lx, dwZBufferBitDepth=%#010lx, dwAlphaBitDepth=%#010lx, dwLuminanceBitCount=%#010lx, dwBumpBitCount=%#010lx, dwRBitMask=%#010lx,\n"
			"    dwYBitMask=%#010lx, dwStencilBitDepth=%#010lx, dwLuminanceBitMask=%#010lx, dwBumpDuBitMask=%#010lx, dwGBitMask=%#010lx, dwUBitMask=%#010lx, dwZBitMask=%#010lx, dwBumpDvBitMask=%#010lx, dwBBitMask=%#010lx, dwVBitMask=%#010lx, dwStencilBitMask=%#010lx,\n"
			"    dwBumpLuminanceBitMask=%#010lx, dwRGBAlphaBitMask=%#010lx, dwYUVAlphaBitMask=%#010lx, dwLuminanceAlphaBitMask=%#010lx, dwRGBZBitMask=%#010lx, dwYUVZBitMask=%#010lx },\n"
			"  ddsCaps={ %#010lx (%s), %#010lx, %#010lx, %#010lx }, dwTextureStage=%#010lx }\n",
			lpDDSurfaceDesc->dwSize, lpDDSurfaceDesc->dwFlags, dwFlags_buffer, lpDDSurfaceDesc->dwWidth, (unsigned int)lpDDSurfaceDesc->dwWidth, lpDDSurfaceDesc->dwHeight, (unsigned int)lpDDSurfaceDesc->dwHeight, lpDDSurfaceDesc->lPitch,
			lpDDSurfaceDesc->dwLinearSize, lpDDSurfaceDesc->dwBackBufferCount, lpDDSurfaceDesc->dwMipMapCount, lpDDSurfaceDesc->dwRefreshRate, lpDDSurfaceDesc->dwAlphaBitDepth, lpDDSurfaceDesc->dwReserved, lpDDSurfaceDesc->lpSurface,
			lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceHighValue,
			lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceHighValue,
			
			lpDDSurfaceDesc->ddpfPixelFormat.dwSize, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, ddpf_buffer, lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVBitCount,
			lpDDSurfaceDesc->ddpfPixelFormat.dwZBufferBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwAlphaBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpBitCount,
			lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDuBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwUBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwZBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDvBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwVBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpLuminanceBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBZBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwYUVZBitMask,
			
			lpDDSurfaceDesc->ddsCaps.dwCaps, ddscaps1_buffer, lpDDSurfaceDesc->ddsCaps.dwCaps2, lpDDSurfaceDesc->ddsCaps.dwCaps3, lpDDSurfaceDesc->ddsCaps.dwCaps4, lpDDSurfaceDesc->dwTextureStage
		);
	}

	return ret;
}
Exemplo n.º 17
0
const good::string& CTypeToString::ItemDrawFlagsToString( TItemDrawFlags iFlags )
{
	return FlagsToString( iFlags, EItemDrawTotal, aItemDrawFlags );
}
Exemplo n.º 18
0
const good::string& CTypeToString::EntityTypeFlagsToString( TEntityTypeFlags iItemTypeFlags )
{
	return FlagsToString( iItemTypeFlags, EEntityTypeTotal+1, aItemTypes );
}
HRESULT __stdcall DDRAWSURFACE4_HOOK_Lock(LPVOID *ppvOut, LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) {
	const unsigned int hpos = 25;
	
	char dwFlags_buffer[LOGBUFFER_MAX];
	FlagsToString(FLAGS_DDLOCK, CFLAGS_DDLOCK, dwFlags, dwFlags_buffer, LOGBUFFER_MAX);

	Log("IDirectDrawSurface4::%s(this=%#010lx, lpDestRect=%#010lx { left=%d, right=%d, top=%d, bottom=%d }, lpDDSurfaceDesc=%#010lx, dwFlags=%#010lx (%s), hEvent=%#010lx)", ddrawsurface4_hooks[hpos].name, ppvOut, lpDestRect, (lpDestRect != NULL ? lpDestRect->left : NULL), (lpDestRect != NULL ? lpDestRect->right : NULL), (lpDestRect != NULL ? lpDestRect->top : NULL), (lpDestRect != NULL ? lpDestRect->bottom : NULL), lpDDSurfaceDesc, dwFlags, dwFlags_buffer, hEvent);

	//dwFlags |= DDLOCK_NOSYSLOCK;
	if (g_config.displaymode && lpDDSurfaceDesc) {
		DDSURFACEDESC2 sd;
		memset(&sd, 0, sizeof(DDSURFACEDESC2));
		sd.dwSize = sizeof(sd);
		((IDirectDrawSurface4 *)ppvOut)->GetSurfaceDesc(&sd);
		LPDIRECTDRAWSURFACE4 * ppDecoySurface = 0;
		// If the game is locking the backbuffer, it can do arbitrary stuff in there,
		// which this wrapper has no chance of making scaled properly.
		// So the game is given a surface with the dimension it expects, and the wrapper will
		// scale it up in the UnLock function.
		// Luckily, this appears to be only used for videos, where simple upscaling is the only option anyway.
		if((!g_config.fullscreen && (LPDIRECTDRAWSURFACE4)ppvOut == g_backbuffer) ||
		  (sd.dwWidth == 640 &&
		   sd.dwHeight == 480 &&
		   (sd.ddsCaps.dwCaps & DDSCAPS_BACKBUFFER))) {
			ppDecoySurface = &g_decoyBackBuffer;
			g_decoyBackLockFlags = dwFlags;
			Log("Backbuffer locking: substitute decoy surface\n");
		}
		// Similarily, the frontbuffer is read for special effects which also depend on the fixed size.
		if((!g_config.fullscreen && (LPDIRECTDRAWSURFACE4)ppvOut == g_frontbuffer) ||
		  (sd.dwWidth == 640 &&
		   sd.dwHeight == 480 &&
		   (sd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))) {
			ppDecoySurface = &g_decoyFrontBuffer;
			g_decoyFrontLockFlags = dwFlags;
			Log("Frontbuffer locking: substitute decoy surface\n");
		}
		if(ppDecoySurface) {
			DDSURFACEDESC2 ddsd;
			memset(&ddsd, 0, sizeof(DDSURFACEDESC2));
			ddsd.dwSize = sizeof(ddsd);
			if((*ppDecoySurface) == NULL) {
				LPDIRECTDRAW4 lpDD = NULL;
				ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
				ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
				ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
				ddsd.ddpfPixelFormat.dwFourCC = 0;
				ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
				ddsd.ddpfPixelFormat.dwRBitMask = 0xf800;
				ddsd.ddpfPixelFormat.dwGBitMask = 0x07e0;
				ddsd.ddpfPixelFormat.dwBBitMask = 0x001f;
				ddsd.dwWidth = 640;
				ddsd.dwHeight = 480;
				ddsd.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_OFFSCREENPLAIN;
				((IDirectDrawSurface4 *)ppvOut)->GetDDInterface((LPVOID *)&lpDD);
				lpDD->CreateSurface(&ddsd, ppDecoySurface, NULL);
				SAFE_RELEASE(lpDD);
			}
			if((*ppDecoySurface)->IsLost())
				(*ppDecoySurface)->Restore();
			RECT rcDest, rcSource;
			sd.dwHeight = displaymode_options[g_config.displaymode].resY;
			sd.dwWidth = displaymode_options[g_config.displaymode].resX;
			// FIXME: In windowed mode, the front buffer probably contains the whole screen or something
			if(sd.dwHeight >= g_game.height) {
				rcSource.top = (sd.dwHeight - g_game.height)/2; rcSource.bottom = sd.dwHeight - rcSource.top;
				rcDest.top = 0; rcDest.bottom = 480;
			} else {
				rcSource.top = 0; rcSource.bottom = sd.dwHeight;
				rcDest.top = (LONG)((g_game.height - sd.dwHeight) / (2 * g_game.modY)); rcDest.bottom = 480 - rcDest.top;
			}
			if(sd.dwWidth >= g_game.width) {
				rcSource.left = (sd.dwWidth - g_game.width)/2; rcSource.right = sd.dwWidth - rcSource.left;
				rcDest.left = 0; rcDest.right = 640;
			} else {
				rcSource.left = 0; rcSource.right = sd.dwWidth;
				rcDest.left = (LONG)((g_game.width - sd.dwWidth) / (2 * g_game.modX)); rcDest.bottom = 640 - rcDest.left;
			}
			if(~dwFlags & DDLOCK_WRITEONLY)
				(*ppDecoySurface)->Blt(&rcDest, (IDirectDrawSurface4 *)ppvOut, &rcSource, DDBLT_WAIT, NULL);
			HRESULT ret = (*ppDecoySurface)->Lock(lpDestRect, lpDDSurfaceDesc, dwFlags | DDLOCK_WAIT, 0);
			return ret;
		}
	}

	DDRAWSURFACE4_Lock_Type ofn = (DDRAWSURFACE4_Lock_Type)ddrawsurface4_hooks[hpos].oldFunc;
	HRESULT ret = ofn(ppvOut, lpDestRect, lpDDSurfaceDesc, dwFlags, hEvent);
	LogDXError(ret);
	Log("\n");
	
	if(lpDDSurfaceDesc != NULL) {
		char dwFlags_buffer[LOGBUFFER_MAX], ddscaps1_buffer[LOGBUFFER_MAX], ddpf_buffer[LOGBUFFER_MAX];
		FlagsToString(FLAGS_DDSD, CFLAGS_DDSD, lpDDSurfaceDesc->dwFlags, (char *)&dwFlags_buffer, LOGBUFFER_MAX);
		FlagsToString(FLAGS_DDSCAPS1, CFLAGS_DDSCAPS1, lpDDSurfaceDesc->ddsCaps.dwCaps, (char *)&ddscaps1_buffer, LOGBUFFER_MAX);
		FlagsToString(FLAGS_DDPF, CFLAGS_DDPF, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, (char *)&ddpf_buffer, LOGBUFFER_MAX);

		Log("->lpDDSurfaceDesc { dwSize=%#010lx, dwFlags=%#010lx (%s), dwWidth=%#010lx (%d), dwHeight=%#010lx (%d), lPitch=%#010lx , dwLinearSize=%#010lx, dwBackBufferCount=%#010lx, dwMipMapCount=%#010lx, dwRefreshRate=%#010lx, dwAlphaBitDepth=%#010lx, dwReserved=%#010lx,\n"
			"  lpSurface=%#010lx, ddckCKDestOverlay={ %#010lx, %#010lx }, ddckCKDestBlt={ %#010lx, %#010lx }, ddckCKSrcOverlay={ %#010lx, %#010lx }, ddckCKSrcBlt={ %#010lx, %#010lx },\n"
			"  ddpfPixelFormat={ dwSize=%#010lx, dwFlags=%#010lx (%s), dwFourCC=%#010lx, dwRGBBitCount=%#010lx, dwYUVBitCount=%#010lx, dwZBufferBitDepth=%#010lx, dwAlphaBitDepth=%#010lx, dwLuminanceBitCount=%#010lx, dwBumpBitCount=%#010lx, dwRBitMask=%#010lx,\n"
			"    dwYBitMask=%#010lx, dwStencilBitDepth=%#010lx, dwLuminanceBitMask=%#010lx, dwBumpDuBitMask=%#010lx, dwGBitMask=%#010lx, dwUBitMask=%#010lx, dwZBitMask=%#010lx, dwBumpDvBitMask=%#010lx, dwBBitMask=%#010lx, dwVBitMask=%#010lx, dwStencilBitMask=%#010lx,\n"
			"    dwBumpLuminanceBitMask=%#010lx, dwRGBAlphaBitMask=%#010lx, dwYUVAlphaBitMask=%#010lx, dwLuminanceAlphaBitMask=%#010lx, dwRGBZBitMask=%#010lx, dwYUVZBitMask=%#010lx },\n"
			"  ddsCaps={ %#010lx (%s), %#010lx, %#010lx, %#010lx }, dwTextureStage=%#010lx }\n",
			lpDDSurfaceDesc->dwSize, lpDDSurfaceDesc->dwFlags, dwFlags_buffer, lpDDSurfaceDesc->dwWidth, (unsigned int)lpDDSurfaceDesc->dwWidth, lpDDSurfaceDesc->dwHeight, (unsigned int)lpDDSurfaceDesc->dwHeight, lpDDSurfaceDesc->lPitch,
			lpDDSurfaceDesc->dwLinearSize, lpDDSurfaceDesc->dwBackBufferCount, lpDDSurfaceDesc->dwMipMapCount, lpDDSurfaceDesc->dwRefreshRate, lpDDSurfaceDesc->dwAlphaBitDepth, lpDDSurfaceDesc->dwReserved, lpDDSurfaceDesc->lpSurface,
			lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceHighValue,
			lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceHighValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceLowValue, lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceHighValue,
			
			lpDDSurfaceDesc->ddpfPixelFormat.dwSize, lpDDSurfaceDesc->ddpfPixelFormat.dwFlags, ddpf_buffer, lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVBitCount,
			lpDDSurfaceDesc->ddpfPixelFormat.dwZBufferBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwAlphaBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitCount, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpBitCount,
			lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitDepth, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDuBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwUBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwZBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpDvBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwVBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwStencilBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwBumpLuminanceBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwYUVAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwLuminanceAlphaBitMask, lpDDSurfaceDesc->ddpfPixelFormat.dwRGBZBitMask,
			lpDDSurfaceDesc->ddpfPixelFormat.dwYUVZBitMask,
			
			lpDDSurfaceDesc->ddsCaps.dwCaps, ddscaps1_buffer, lpDDSurfaceDesc->ddsCaps.dwCaps2, lpDDSurfaceDesc->ddsCaps.dwCaps3, lpDDSurfaceDesc->ddsCaps.dwCaps4, lpDDSurfaceDesc->dwTextureStage
		);
		g_lockedSurface = (LPDIRECTDRAWSURFACE4)ppvOut;
		g_lpSurface = lpDDSurfaceDesc->lpSurface;
	}

	return ret;
}
Exemplo n.º 20
0
void HK_CALL DumpHavokClassImpl(hkClass* hclass)
{
   char fbuffer[260], buffer[1024];
   const char *ptr = hclass->getName();
   int ver = hclass->getDescribedVersion();
   sprintf_s(fbuffer, 256, "%s\\%s_%d.cpp", s_rootPath, ptr, ver);

   char outdir[MAX_PATH];
   strcpy(outdir, fbuffer);
   PathRemoveFileSpec(outdir);
   CreateDirectories(outdir);

   hkClass* pParent = hclass->getParent();
   FILE *hFile = NULL; fopen_s(&hFile, fbuffer, "wt" );
   if ( hFile != NULL )
   {
      PrintLine(hFile, "#include \"StdAfx.h\"");
      PrintLine(hFile, "#include \"%s_%d.h\"", ptr, ver);
      PrintLine(hFile, "");
      PrintLine(hFile, "#include <Common/Serialize/hkSerialize.h>");
      PrintLine(hFile, "#include <Common/Serialize/Util/hkSerializeUtil.h>");
      PrintLine(hFile, "#include <Common/Serialize/Version/hkVersionPatchManager.h>");
      PrintLine(hFile, "#include <Common/Serialize/Data/Dict/hkDataObjectDict.h>");
      PrintLine(hFile, "#include <Common/Serialize/Data/Native/hkDataObjectNative.h>");
      PrintLine(hFile, "#include <Common/Serialize/Data/Util/hkDataObjectUtil.h>");
      PrintLine(hFile, "#include <Common/Base/Reflection/Registry/hkDynamicClassNameRegistry.h>");
      PrintLine(hFile, "#include <Common/Base/Reflection/Registry/hkVtableClassRegistry.h>");
      PrintLine(hFile, "#include <Common/Base/Reflection/hkClass.h>");
      PrintLine(hFile, "#include <Common/Base/Reflection/hkInternalClassMember.h>");
      PrintLine(hFile, "#include <Common/Serialize/Util/hkSerializationCheckingUtils.h>");
      PrintLine(hFile, "#include <Common/Serialize/Util/hkVersionCheckingUtils.h>");
      PrintLine(hFile, "");
      PrintLine(hFile, "");

      if ( 0 < hclass->getNumDeclaredEnums())
      {
         for (int i=0,n=hclass->getNumDeclaredEnums();i<n;++i)
         {
            const hkClassEnum &hEnum = hclass->getDeclaredEnum(i);

            PrintLine(hFile, "static const hkInternalClassEnumItem %sEnumItems[] =", hEnum.getName());
            PrintLine(hFile, "{");
            for (int j=0,m=hEnum.getNumItems();j<m;++j)
            {
               const hkClassEnum::Item& item = hEnum.getItem(j);
               PrintLine(hFile, "   {%d, \"%s\"},", item.getValue(), item.getName());
            }
            PrintLine(hFile, "};");
            PrintLine(hFile, "");
         }

         PrintLine(hFile, "static const hkInternalClassEnum %sClass_Enums[] = {", ptr);
         for (int i=0,n=hclass->getNumDeclaredEnums();i<n;++i)
         {
            const hkClassEnum &hEnum = hclass->getDeclaredEnum(i);
            PrintLine(hFile, "   {\"%s\", %sEnumItems, _countof(%sEnumItems), HK_NULL, %d },", hEnum.getName(),hEnum.getName(),hEnum.getName(), hEnum.getFlags());
         }
         PrintLine(hFile, "};");
         for (int i=0,n=hclass->getNumDeclaredEnums();i<n;++i)
         {
            const hkClassEnum &hEnum = hclass->getDeclaredEnum(i);
            PrintLine(hFile, "const hkClassEnum* %sEnum = reinterpret_cast<const hkClassEnum*>(&%sClass_Enums[%d]);", hEnum.getName(), ptr, i);
         }         
         PrintLine(hFile, "");
      }

      if ( hclass->getNumDeclaredMembers() > 0)
      {
         PrintLine(hFile, "static const hkInternalClassMember %sClass_Members[] =", ptr);
         PrintLine(hFile, "{");
         for (int i=0,n=hclass->getNumDeclaredMembers();i<n;++i)
         {
            const hkClassMember &mem = hclass->getDeclaredMember(i);
            mem.getTypeName(buffer, 1024);
            fprintf(hFile, "   { \"%s\"", mem.getName());

            if ( !mem.hasClass() ) fprintf(hFile, ",HK_NULL");
            else if (const hkClass* mclass = mem.getClass()) fprintf(hFile, ",&%sClass", mclass->getName());
            else fprintf(hFile, ",HK_NULL");

            if ( !mem.hasEnumClass() ) fprintf(hFile, ",HK_NULL");
            else fprintf(hFile, ",%sEnum", mem.getEnumClass().getName());

            string typeStr = EnumToString(mem.getType(), TypeEnums);
            fprintf(hFile, ",%s", typeStr.c_str());
            string subTypeStr = EnumToString(mem.getSubType(), TypeEnums);
            fprintf(hFile, ",%s", subTypeStr.c_str());
            fprintf(hFile, ",%d", mem.getCstyleArraySize());

            string flagsStr = FlagsToString((int)*(short*)&mem.getFlags(), TypeFlags);
            fprintf(hFile, ",%s", flagsStr.c_str());
            fprintf(hFile, ",HK_OFFSET_OF(%s,m_%s) /*%d*/", ptr, mem.getName(), mem.getOffset());
            if ( hclass->hasDeclaredDefault(i) )
            {
               //hkTypedUnion value;
               //if (HK_SUCCESS == hclass->getDeclaredDefault(i, value))
               //   fprintf(hFile, ",%08lx", value.getStorage().m_int32);
               //else 
               fprintf(hFile, ",HK_NULL");
            }
            else fprintf(hFile, ",HK_NULL");
            fprintf(hFile, "},\n");
         }
         PrintLine(hFile, "};");
         PrintLine(hFile, "");
      }


      PrintLine(hFile, "// Signature:  %08lx", hclass->getSignature());

      if (pParent != NULL)
         PrintLine(hFile, "extern const hkClass %sClass;", pParent->getName());

      PrintLine(hFile, "extern const hkClass %sClass;", ptr);
      PrintLine(hFile, "const hkClass %sClass(", ptr);
      PrintLine(hFile, "    \"%s\",", ptr);
      if (pParent == NULL) PrintLine(hFile, "    HK_NULL, // parent");
      else PrintLine(hFile, "    &%sClass, // parent", pParent->getName());
      PrintLine(hFile, "    sizeof(%s),", ptr);
      if (hclass->getNumDeclaredInterfaces() > 0)
         PrintLine(hFile, "    reinterpret_cast<const hkClassMember*>(%sClass_IFaces), HK_COUNT_OF(%sClass_IFaces),", ptr, ptr);
      else
         PrintLine(hFile, "    HK_NULL, 0, // interfaces");

      if (hclass->getNumDeclaredEnums() > 0)
         PrintLine(hFile, "    reinterpret_cast<const hkClassEnum*>(%sClass_Enums), HK_COUNT_OF(%sClass_Enums),", ptr, ptr);
      else
         PrintLine(hFile, "    HK_NULL, 0, // enums");
      if (hclass->getNumDeclaredMembers() > 0)
         PrintLine(hFile, "    reinterpret_cast<const hkClassMember*>(%sClass_Members), HK_COUNT_OF(%sClass_Members),", ptr, ptr);
      else
         PrintLine(hFile, "    HK_NULL, 0, // members");
      PrintLine(hFile, "    HK_NULL, // defaults");
      PrintLine(hFile, "    HK_NULL, // attributes");
      PrintLine(hFile, "    %d, // flags", hclass->getFlags());
      PrintLine(hFile, "    %d // version", ver);
      PrintLine(hFile, " );");
      if (hclass->hasVtable())
         PrintLine(hFile, "HK_REFLECTION_DEFINE_VIRTUAL(%s, %s);", ptr, ptr);
      else
         PrintLine(hFile, "HK_REFLECTION_DEFINE_SIMPLE(%s, %s);", ptr, ptr);
      PrintLine(hFile, "");
      fflush(hFile);
      fclose(hFile);
   }
}