Mercurial > mm7
comparison Engine/Registry.cpp @ 2575:a76d408c5132 tip
DrawTranslucent -> DrawTextureGrayShade
Removed old texture drawing stuff
author | a.parshin |
---|---|
date | Wed, 09 Mar 2016 01:39:52 +0200 |
parents | dd36326a9994 |
children |
comparison
equal
deleted
inserted
replaced
2574:dd36326a9994 | 2575:a76d408c5132 |
---|---|
1 #define _CRTDBG_MAP_ALLOC | |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
5 #define _CRT_SECURE_NO_WARNINGS | |
6 #include <stdio.h> | |
7 #include <array> | |
8 #include <windows.h> | |
9 | |
10 #include "Registry.h" | |
11 #include "Engine/ErrorHandling.h" | |
12 | |
13 //----- (004649EF) -------------------------------------------------------- | |
14 int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue) | |
15 { | |
16 DWORD cbData; // [sp+8h] [bp-20h]@1 | |
17 LPCSTR lpValueName; // [sp+Ch] [bp-1Ch]@1 | |
18 DWORD dwDisposition; // [sp+10h] [bp-18h]@2 | |
19 BYTE Data[4]; // [sp+14h] [bp-14h]@5 | |
20 HKEY hKey; // [sp+18h] [bp-10h]@1 | |
21 HKEY phkResult; // [sp+1Ch] [bp-Ch]@1 | |
22 HKEY v10; // [sp+20h] [bp-8h]@1 | |
23 HKEY v11; // [sp+24h] [bp-4h]@1 | |
24 | |
25 lpValueName = pKey; | |
26 v11 = 0; | |
27 v10 = 0; | |
28 hKey = 0; | |
29 phkResult = 0; | |
30 cbData = 4; | |
31 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) )// for 64 bit | |
32 { | |
33 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) ) | |
34 { | |
35 if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v10, &dwDisposition) ) | |
36 { | |
37 if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v11, &dwDisposition) ) | |
38 { | |
39 LSTATUS status; | |
40 if ( status = RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData) ) | |
41 { | |
42 status; | |
43 GetLastError(); | |
44 | |
45 *(int *)Data = uDefValue; | |
46 RegSetValueExA(v11, lpValueName, 0, 4, Data, 4); | |
47 } | |
48 RegCloseKey(v11); | |
49 } | |
50 RegCloseKey(v10); | |
51 } | |
52 RegCloseKey(phkResult); | |
53 } | |
54 RegCloseKey(hKey); | |
55 } | |
56 return *(int *)Data; | |
57 } | |
58 | |
59 //----- (00464B02) -------------------------------------------------------- | |
60 void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString) | |
61 { | |
62 size_t v2; // eax@5 | |
63 const char *lpValueName; // [sp+4h] [bp-1Ch]@1 | |
64 const char *Str; // [sp+8h] [bp-18h]@1 | |
65 DWORD dwDisposition; // [sp+Ch] [bp-14h]@2 | |
66 HKEY hKey; // [sp+10h] [bp-10h]@1 | |
67 HKEY phkResult; // [sp+14h] [bp-Ch]@1 | |
68 HKEY v8; // [sp+18h] [bp-8h]@1 | |
69 HKEY v9; // [sp+1Ch] [bp-4h]@1 | |
70 | |
71 Str = pString; | |
72 lpValueName = pKey; | |
73 v9 = 0; | |
74 v8 = 0; | |
75 hKey = 0; | |
76 phkResult = 0; | |
77 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) ) | |
78 { | |
79 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) ) | |
80 { | |
81 if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition) ) | |
82 { | |
83 if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v9, &dwDisposition) ) | |
84 { | |
85 v2 = strlen(Str); | |
86 RegSetValueExA(v9, lpValueName, 0, 1, (const BYTE *)Str, v2 + 1); | |
87 RegCloseKey(v9); | |
88 } | |
89 RegCloseKey(v8); | |
90 } | |
91 RegCloseKey(phkResult); | |
92 } | |
93 RegCloseKey(hKey); | |
94 } | |
95 } | |
96 | |
97 //----- (00464BEF) -------------------------------------------------------- | |
98 void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue) | |
99 { | |
100 //LSTATUS (__stdcall *v4)(HKEY); // esi@1 | |
101 LSTATUS result; // eax@7 | |
102 DWORD Type; // [sp+Ch] [bp-24h]@5 | |
103 LPCSTR lpValueName; // [sp+10h] [bp-20h]@1 | |
104 DWORD cbData; // [sp+14h] [bp-1Ch]@1 | |
105 LPBYTE Dest; // [sp+18h] [bp-18h]@1 | |
106 DWORD dwDisposition; // [sp+1Ch] [bp-14h]@2 | |
107 HKEY phkResult; // [sp+20h] [bp-10h]@1 | |
108 HKEY hKey; // [sp+24h] [bp-Ch]@1 | |
109 HKEY v13; // [sp+28h] [bp-8h]@1 | |
110 HKEY v14; // [sp+2Ch] [bp-4h]@1 | |
111 | |
112 cbData = uBufLen; | |
113 Dest = (LPBYTE)pOutString; | |
114 lpValueName = pKeyName; | |
115 v14 = 0; | |
116 v13 = 0; | |
117 hKey = 0; | |
118 phkResult = 0; | |
119 result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); | |
120 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) ) | |
121 { | |
122 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition)) | |
123 { | |
124 if (!RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v13, &dwDisposition)) | |
125 { | |
126 if( !RegCreateKeyExA(v13, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v14, &dwDisposition) ) | |
127 { | |
128 if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) | |
129 GetLastError(); | |
130 RegCloseKey(v14); | |
131 v14 = NULL; | |
132 } | |
133 RegCloseKey(v13); | |
134 v13 = NULL; | |
135 } | |
136 RegCloseKey(phkResult); | |
137 phkResult = NULL; | |
138 } | |
139 RegCloseKey(hKey); | |
140 hKey = NULL; | |
141 } | |
142 } | |
143 | |
144 //----- (00464D32) -------------------------------------------------------- | |
145 void __fastcall WriteWindowsRegistryInt(const char *pKey, int val) | |
146 { | |
147 const char *lpValueName; // [sp+4h] [bp-1Ch]@1 | |
148 BYTE Data[4]; // [sp+8h] [bp-18h]@1 | |
149 DWORD dwDisposition; // [sp+Ch] [bp-14h]@2 | |
150 HKEY hKey; // [sp+10h] [bp-10h]@1 | |
151 HKEY phkResult; // [sp+14h] [bp-Ch]@1 | |
152 HKEY v7; // [sp+18h] [bp-8h]@1 | |
153 HKEY v8; // [sp+1Ch] [bp-4h]@1 | |
154 | |
155 *(int *)Data = val; | |
156 lpValueName = pKey; | |
157 v8 = 0; | |
158 v7 = 0; | |
159 hKey = 0; | |
160 phkResult = 0; | |
161 if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) ) | |
162 { | |
163 if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) ) | |
164 { | |
165 if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v7, &dwDisposition) ) | |
166 { | |
167 if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition) ) | |
168 { | |
169 RegSetValueExA(v8, lpValueName, 0, 4, Data, 4); | |
170 RegCloseKey(v8); | |
171 } | |
172 RegCloseKey(v7); | |
173 } | |
174 RegCloseKey(phkResult); | |
175 } | |
176 RegCloseKey(hKey); | |
177 } | |
178 } |