summaryrefslogtreecommitdiff
path: root/drivers/pe_bliss/resource_cursor_icon_reader.h
blob: 25a59baa274490e1fd261f9374372612faa2c553 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <string>
#include "stdint_defs.h"

namespace pe_bliss
{
class pe_resource_viewer;

class resource_cursor_icon_reader
{
public:
	resource_cursor_icon_reader(const pe_resource_viewer& res);

	//Returns single icon data by ID and language (minimum checks of format correctness)
	const std::string get_single_icon_by_id_lang(uint32_t language, uint32_t id) const;
	//Returns single icon data by ID and index in language directory (instead of language) (minimum checks of format correctness)
	const std::string get_single_icon_by_id(uint32_t id, uint32_t index = 0) const;

	//Returns icon data of group of icons by name and language (minimum checks of format correctness)
	const std::string get_icon_by_name(uint32_t language, const std::wstring& icon_group_name) const;
	//Returns icon data of group of icons by name and index in language directory (instead of language) (minimum checks of format correctness)
	const std::string get_icon_by_name(const std::wstring& icon_group_name, uint32_t index = 0) const;
	//Returns icon data of group of icons by ID and language (minimum checks of format correctness)
	const std::string get_icon_by_id_lang(uint32_t language, uint32_t icon_group_id) const;
	//Returns icon data of group of icons by ID and index in language directory (instead of language) (minimum checks of format correctness)
	const std::string get_icon_by_id(uint32_t icon_group_id, uint32_t index = 0) const;
	
	//Returns single cursor data by ID and language (minimum checks of format correctness)
	const std::string get_single_cursor_by_id_lang(uint32_t language, uint32_t id) const;
	//Returns single cursor data by ID and index in language directory (instead of language) (minimum checks of format correctness)
	const std::string get_single_cursor_by_id(uint32_t id, uint32_t index = 0) const;

	//Returns cursor data by name and language (minimum checks of format correctness)
	const std::string get_cursor_by_name(uint32_t language, const std::wstring& cursor_group_name) const;
	//Returns cursor data by name and index in language directory (instead of language) (minimum checks of format correctness)
	const std::string get_cursor_by_name(const std::wstring& cursor_group_name, uint32_t index = 0) const;
	//Returns cursor data by ID and language (minimum checks of format correctness)
	const std::string get_cursor_by_id_lang(uint32_t language, uint32_t cursor_group_id) const;
	//Returns cursor data by ID and index in language directory (instead of language) (minimum checks of format correctness)
	const std::string get_cursor_by_id(uint32_t cursor_group_id, uint32_t index = 0) const;

private:
	const pe_resource_viewer& res_;

	//Helper function of creating icon headers from ICON_GROUP resource data
	//Returns icon count
	static uint16_t format_icon_headers(std::string& ico_data, const std::string& resource_data);
	
	//Helper function of creating cursor headers from CURSOR_GROUP resource data
	//Returns cursor count
	uint16_t format_cursor_headers(std::string& cur_data, const std::string& resource_data, uint32_t language, uint32_t index = 0xFFFFFFFF) const;

	//Looks up icon group by icon id and returns full icon headers if found
	const std::string lookup_icon_group_data_by_icon(uint32_t icon_id, uint32_t language) const;
	//Checks for icon presence inside icon group, fills icon headers if found
	static bool check_icon_presence(const std::string& icon_group_resource_data, uint32_t icon_id, std::string& ico_data);

	//Looks up cursor group by cursor id and returns full cursor headers if found
	const std::string lookup_cursor_group_data_by_cursor(uint32_t cursor_id, uint32_t language, const std::string& raw_cursor_data) const;
	//Checks for cursor presence inside cursor group, fills cursor headers if found
	static bool check_cursor_presence(const std::string& icon_group_resource_data, uint32_t cursor_id, std::string& cur_header_data, const std::string& raw_cursor_data);
};
}