Пример #1
0
HRESULT WINAPI extDSSetCooperativeLevel(void *lpds, HWND hwnd, DWORD dwLevel)
{
	HRESULT res;

	OutTrace("DirectSound::SetCooperativeLevel: lpds=%x hwnd=%x level=%x(%s)\n", lpds, hwnd, dwLevel, ExplainLevel(dwLevel));
	if(dwLevel == DSSCL_EXCLUSIVE) {
		OutTrace("DirectSound::SetCooperativeLevel: PATCH\n");
		dwLevel=DSSCL_PRIORITY; // Arxel Tribe patch
		//dwLevel=DSSCL_NORMAL; // Arxel Tribe patch
		hwnd=dxw.GethWnd();
		//hwnd=(*pGetDesktopWindow)();
		//hwnd=0;
	}
	res = (*pDSSetCooperativeLevel)(lpds, hwnd, dwLevel);
	if(res){
		OutTraceE("DirectSound::SetCooperativeLevel ERROR: res=%x(%s)\n", res, ExplainDDError(res));
	}
	return res;
}
Пример #2
0
void* WINAPI extDirect3DCreate8(UINT sdkversion)
{
	void *lpd3d;
	void *tmp;

	dwD3DVersion = 8;
	lpd3d = (*pDirect3DCreate8)(sdkversion);
	if(!lpd3d) return 0;
	tmp = SetHook((void *)(*(DWORD *)lpd3d + 60), extCreateDevice);
	if(tmp) pCreateDevice = (CreateDevice_Type)tmp;

	OutTrace("Direct3DCreate8: SDKVERSION = %x pCreateDevice = %x\n",
		sdkversion, pCreateDevice);
	return lpd3d;
}
Пример #3
0
HRESULT WINAPI extCreateDevice(void *lpd3d, UINT adapter, D3DDEVTYPE devicetype,
	HWND hfocuswindow, DWORD behaviorflags, D3DPRESENT_PARAMETERS *ppresentparam, void **ppd3dd)
{
	HRESULT res;
	DWORD param[64], *tmp;
	D3DDISPLAYMODE mode;

	if(dwD3DVersion == 9){
		memcpy(param, ppresentparam, 56);
		OutTrace("D3D9::CreateDevice\n");
	}
	else{
		memcpy(param, ppresentparam, 52);
		OutTrace("D3D8::CreateDevice\n");
	}

	hWnd = hfocuswindow;
	dwWidth = param[0];
	dwHeight = param[1];
	AdjustWindowFrame(hWnd, dwWidth, dwHeight);

	tmp = param;
	OutTrace("  Adapter = %i\n", adapter);
	OutTrace("  DeviceType = %i\n", devicetype);
	OutTrace("  hFocusWindow = 0x%x\n", hfocuswindow);
	OutTrace("  BehaviorFlags = 0x%x\n", behaviorflags);
	OutTrace("    BackBufferWidth = %i\n", *(tmp ++));
	OutTrace("    BackBufferHeight = %i\n", *(tmp ++));
	OutTrace("    BackBufferFormat = %i\n", *(tmp ++));
	OutTrace("    BackBufferCount = %i\n", *(tmp ++));
	OutTrace("    MultiSampleType = %i\n", *(tmp ++));
	if(dwD3DVersion == 9) OutTrace("    MultiSampleQuality = %i\n", *(tmp ++));
	OutTrace("    SwapEffect = 0x%x\n", *(tmp ++));
	OutTrace("    hDeviceWindow = 0x%x\n", *(tmp ++));
	OutTrace("    Windowed = %i\n", *(tmp ++));
	OutTrace("    EnableAutoDepthStencil = %i\n", *(tmp ++));
	OutTrace("    AutoDepthStencilFormat = %i\n", *(tmp ++));
	OutTrace("    Flags = 0x%x\n", *(tmp ++));
	OutTrace("    FullScreen_RefreshRateInHz = %i\n", *(tmp ++));
	OutTrace("    PresentationInterval = 0x%x\n", *(tmp ++));

	((LPDIRECT3D9)lpd3d)->GetAdapterDisplayMode(0, &mode);
	param[2] = mode.Format;
	if(dwD3DVersion == 9){
		param[7] = 0;			//hDeviceWindow
		param[8] = 1;			//Windowed
		param[12] = 0;			//FullScreen_RefreshRateInHz;
		param[13] = D3DPRESENT_INTERVAL_DEFAULT;	//PresentationInterval
	}
	else{
		param[6] = 0;			//hDeviceWindow
		param[7] = 1;			//Windowed
		param[11] = 0;			//FullScreen_RefreshRateInHz;
		param[12] = D3DPRESENT_INTERVAL_DEFAULT;	//PresentationInterval
	}

	res = (*pCreateDevice)(lpd3d, 0, devicetype, hfocuswindow, behaviorflags, param, ppd3dd);
	if(res){
		OutTrace("FAILED! %x\n", res);
		return res;
	}
	OutTrace("SUCCESS!\n");
	return 0;
}
Пример #4
0
void DDrawScreenShot(int dxversion)
{
	LPDIRECTDRAWSURFACE s;
	DDSURFACEDESC2 ddsd;
	int w, h, iSurfaceSize, iScanLineSize;
	HRESULT res;
	static int MinTexX, MinTexY, MaxTexX, MaxTexY;
	static BOOL DoOnce = TRUE;
	char pszFile[MAX_PATH];
	static int hash = 0;

	if(DoOnce){
		sprintf_s(pszFile, MAX_PATH, "%s\\screenshot.out", GetDxWndPath());
		CreateDirectory(pszFile, NULL);
		while(TRUE){	
			sprintf_s(pszFile, MAX_PATH, "%s\\screenshot.out\\shot.%08d.bmp", GetDxWndPath(), hash);
			if(GetFileAttributes(pszFile) == INVALID_FILE_ATTRIBUTES) break;
			hash++;
		}
		DoOnce = FALSE;
	}

	if(dxw.dwFlags5 & GDIMODE){
		s = dxwss.GetBackBufferSurface();
	}
	else{
		s = dxwss.GetPrimarySurface();
	}
	if(!s) return;

	memset(&ddsd,0,sizeof(DDSURFACEDESC2));
	ddsd.dwSize = Set_dwSize_From_Surface();
	ddsd.dwFlags = DDSD_LPSURFACE | DDSD_PITCH;
	if(res=(*pLockMethod(dxversion))(s, 0, (LPDDSURFACEDESC)&ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY|DDLOCK_WAIT, 0)){	
		OutTraceE("ScreenShot: Lock ERROR res=%x(%s) at %d\n", res, ExplainDDError(res), __LINE__);
		return;
	}

	while (TRUE) { // fake loop
		OutTrace("ScreenShot: lpdds=%x BitCount=%d size=(%dx%d)\n", 
			s, ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.dwWidth, ddsd.dwHeight);
		w = ddsd.dwWidth;
		h = ddsd.dwHeight;
		if(ddsd.ddpfPixelFormat.dwRGBBitCount == 0) {
			OutTrace("ScreenShot: SKIP 0BPP texture\n");
			break;
		}

		iSurfaceSize = ddsd.dwHeight * ddsd.lPitch;

		FILE *hf;
		BITMAPFILEHEADER hdr;       // bitmap file-header 
		BITMAPV4HEADER pbi;			// bitmap info-header  

		memset((void *)&pbi, 0, sizeof(BITMAPV4HEADER));
		pbi.bV4Size = sizeof(BITMAPV4HEADER); 
		pbi.bV4Width = ddsd.dwWidth;
		pbi.bV4Height = ddsd.dwHeight;
		pbi.bV4BitCount = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount;
		pbi.bV4SizeImage = ((pbi.bV4Width * pbi.bV4BitCount + 0x1F) & ~0x1F)/8 * pbi.bV4Height; 
		pbi.bV4Height = - pbi.bV4Height;
		pbi.bV4Planes = 1;
		pbi.bV4V4Compression = BI_BITFIELDS;
		if(pbi.bV4BitCount == 8) pbi.bV4V4Compression = BI_RGB;
		pbi.bV4XPelsPerMeter = 1;
		pbi.bV4YPelsPerMeter = 1;
		pbi.bV4ClrUsed = 0;
		if(pbi.bV4BitCount == 8) pbi.bV4ClrUsed = 256;
		pbi.bV4ClrImportant = 0;
		pbi.bV4RedMask = ddsd.ddpfPixelFormat.dwRBitMask;
		pbi.bV4GreenMask = ddsd.ddpfPixelFormat.dwGBitMask;
		pbi.bV4BlueMask = ddsd.ddpfPixelFormat.dwBBitMask;
		pbi.bV4AlphaMask = ddsd.ddpfPixelFormat.dwRGBAlphaBitMask;
		pbi.bV4CSType = LCS_CALIBRATED_RGB;
		iScanLineSize = ((pbi.bV4Width * pbi.bV4BitCount + 0x1F) & ~0x1F)/8;

		// Create the .BMP file. 
		sprintf_s(pszFile, MAX_PATH, "%s\\screenshot.out\\shot.%08d.bmp", GetDxWndPath(), hash++);
		hf = fopen(pszFile, "wb");
		if(!hf) break;

		hdr.bfType = 0x4d42;        // 0x42 = "B" 0x4d = "M"  
		// Compute the size of the entire file.  
		hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + pbi.bV4Size + pbi.bV4ClrUsed * sizeof(RGBQUAD) + pbi.bV4SizeImage); 
		hdr.bfReserved1 = 0; 
		hdr.bfReserved2 = 0; 

		// Compute the offset to the array of color indices.  
		hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + pbi.bV4Size + pbi.bV4ClrUsed * sizeof (RGBQUAD); 

		// Copy the BITMAPFILEHEADER into the .BMP file.  
		fwrite((LPVOID)&hdr, sizeof(BITMAPFILEHEADER), 1, hf);

		// Copy the BITMAPINFOHEADER array into the file.  
		fwrite((LPVOID)&pbi, sizeof(BITMAPV4HEADER), 1, hf);

		// Copy the RGBQUAD array into the file.  
		if(pbi.bV4ClrUsed){
			extern DWORD PaletteEntries[256];
			fwrite((LPVOID)PaletteEntries, pbi.bV4ClrUsed * sizeof (RGBQUAD), 1, hf);
		}

		// Copy the array of color indices into the .BMP file.  
		for(int y=0; y<(int)ddsd.dwHeight; y++)
			fwrite((BYTE *)ddsd.lpSurface + (y*ddsd.lPitch), iScanLineSize, 1, hf);

		// Close the .BMP file.  
		fclose(hf);
		break;
	}
	res=(*pUnlockMethod(dxversion))(s, NULL);
	if (res) OutTraceE("ScreenShot: Unlock ERROR lpdds=%x res=%x(%s) at %d\n", s, res, ExplainDDError(res), __LINE__);
}