1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 05:52:11 +01:00

[util] Add helpers for GDI/DDI interop

This commit is contained in:
Joshua Ashton 2019-05-26 19:30:06 +01:00 committed by Philip Rebohle
parent c9a0f06ff4
commit 014870b1ff
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 66 additions and 0 deletions

View File

@ -1,6 +1,7 @@
util_src = files([
'util_env.cpp',
'util_string.cpp',
'util_gdi.cpp',
'com/com_guid.cpp',
'com/com_private_data.cpp',

33
src/util/util_gdi.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "util_gdi.h"
#include "log/log.h"
namespace dxvk {
HMODULE GetGDIModule() {
static HMODULE module = LoadLibraryA("gdi32.dll");
return module;
}
NTSTATUS D3DKMTCreateDCFromMemory(D3DKMT_CREATEDCFROMMEMORY* Arg1) {
static auto func = (D3DKMTCreateDCFromMemoryType)
GetProcAddress(GetGDIModule(), "D3DKMTCreateDCFromMemory");
if (func != nullptr)
return func(Arg1);
Logger::warn("D3DKMTCreateDCFromMemory: Unable to query proc address.");
return -1;
}
NTSTATUS D3DKMTDestroyDCFromMemory(D3DKMT_DESTROYDCFROMMEMORY* Arg1) {
static auto func = (D3DKMTDestroyDCFromMemoryType)
GetProcAddress(GetGDIModule(), "D3DKMTDestroyDCFromMemory");
if (func != nullptr)
return func(Arg1);
Logger::warn("D3DKMTDestroyDCFromMemory: Unable to query proc address.");
return -1;
}
}

32
src/util/util_gdi.h Normal file
View File

@ -0,0 +1,32 @@
#pragma once
#include <d3d9.h>
namespace dxvk {
using NTSTATUS = LONG;
// Slightly modified definitions...
struct D3DKMT_CREATEDCFROMMEMORY {
void* pMemory;
D3DFORMAT Format;
UINT Width;
UINT Height;
UINT Pitch;
HDC hDeviceDc;
PALETTEENTRY* pColorTable;
HDC hDc;
HANDLE hBitmap;
};
struct D3DKMT_DESTROYDCFROMMEMORY {
HDC hDC = nullptr;
HANDLE hBitmap = nullptr;
};
using D3DKMTCreateDCFromMemoryType = NTSTATUS(STDMETHODCALLTYPE*) (D3DKMT_CREATEDCFROMMEMORY*);
NTSTATUS D3DKMTCreateDCFromMemory (D3DKMT_CREATEDCFROMMEMORY* Arg1);
using D3DKMTDestroyDCFromMemoryType = NTSTATUS(STDMETHODCALLTYPE*) (D3DKMT_DESTROYDCFROMMEMORY*);
NTSTATUS D3DKMTDestroyDCFromMemory(D3DKMT_DESTROYDCFROMMEMORY* Arg1);
}