#include <ddraw.h>
#pragma comment(lib, "dxguid.lib")
typedef HRESULT (WINAPI* T_GetCaps)(LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps, DWORD dwUnknown);
PDWORD g_pFuncGetCaps = NULL;
T_GetCaps g_FuncGetCaps = NULL;
HRESULT WINAPI My_GetCaps(LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps, DWORD dwUnknown)
{
HRESULT hResult = g_FuncGetCaps(lpDDDriverCaps, lpDDHELCaps, NULL);
if (S_OK == hResult) {
lpDDHELCaps->dwVidMemTotal = 1000;
}
return hResult;
}
void vmem()
{
LPDIRECTDRAW2 lpdd = NULL;
::CoInitialize(NULL);
HRESULT ddrval = ::CoCreateInstance(CLSID_DirectDraw, NULL, CLSCTX_ALL, IID_IDirectDraw2, (void**)&lpdd);
if(!FAILED(ddrval)) {
ddrval = IDirectDraw2_Initialize(lpdd, NULL);
}
g_pFuncGetCaps = (PDWORD)(*(PDWORD)lpdd + 0x2C);
g_FuncGetCaps = (T_GetCaps)*g_pFuncGetCaps;
*g_pFuncGetCaps = (DWORD)My_GetCaps;
DDCAPS ddcaps;
ddcaps.dwSize = sizeof DDCAPS;
lpdd->GetCaps(&ddcaps, NULL);
lpdd->Release();
printf("display memory is %d ", ddcaps.dwVidMemTotal);
printf("display memory free is %d ", ddcaps.dwVidMemFree);
::CoUninitialize();
}
int _tmain(int argc, _TCHAR* argv[])
{
vmem();
getchar();
return 0;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课