forked from crosire/reshade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dll_resources.cpp
37 lines (29 loc) · 1.06 KB
/
dll_resources.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* Copyright (C) 2014 Patrick Mours. All rights reserved.
* License: https://github.com/crosire/reshade#license
*/
#include "dll_resources.hpp"
#include <Windows.h>
extern HMODULE g_module_handle;
reshade::resources::data_resource reshade::resources::load_data_resource(unsigned int id)
{
const HRSRC info = FindResource(g_module_handle, MAKEINTRESOURCE(id), RT_RCDATA);
const HGLOBAL handle = LoadResource(g_module_handle, info);
data_resource result;
result.data = LockResource(handle);
result.data_size = SizeofResource(g_module_handle, info);
return result;
}
reshade::resources::image_resource reshade::resources::load_image_resource(unsigned int id)
{
DIBSECTION dib = {};
const HANDLE handle = LoadImage(g_module_handle, MAKEINTRESOURCE(id), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
GetObject(handle, sizeof(dib), &dib);
image_resource result;
result.width = dib.dsBm.bmWidth;
result.height = dib.dsBm.bmHeight;
result.bits_per_pixel = dib.dsBm.bmBitsPixel;
result.data = dib.dsBm.bmBits;
result.data_size = dib.dsBmih.biSizeImage;
return result;
}