annotate OSAPI.cpp @ 2575:a76d408c5132 tip

DrawTranslucent -> DrawTextureGrayShade Removed old texture drawing stuff
author a.parshin
date Wed, 09 Mar 2016 01:39:52 +0200
parents d87bfbd3bb3b
children
rev   line source
2415
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2412
diff changeset
1 #define _CRTDBG_MAP_ALLOC
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2412
diff changeset
2 #include <stdlib.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2412
diff changeset
3 #include <crtdbg.h>
f4af3b203f65 LOD.cpp cleaned and search memory corrupt
Ritor1
parents: 2412
diff changeset
4
2253
aff7a7b072b7 adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents: 2152
diff changeset
5 #define _CRT_SECURE_NO_WARNINGS
0
Ritor1
parents:
diff changeset
6 #include "OSAPI.h"
Ritor1
parents:
diff changeset
7 #include "OSInfo.h"
2499
68cdef6879a0 engine folder
Ritor1
parents: 2461
diff changeset
8 #include "Engine/Log.h"
0
Ritor1
parents:
diff changeset
9
Ritor1
parents:
diff changeset
10
2152
d44b7775fc06 Removed DirectDraw2 compatibility.
Nomad
parents: 2059
diff changeset
11 bool OSInfo::initialized = false;
d44b7775fc06 Removed DirectDraw2 compatibility.
Nomad
parents: 2059
diff changeset
12 OSVERSIONINFOA OSInfo::info;
0
Ritor1
parents:
diff changeset
13
Ritor1
parents:
diff changeset
14
1926
3eb0c4f3d899 Woops, debug stuff.
Nomad
parents: 1924
diff changeset
15
1038
39f42990698f Cleanings
Nomad
parents: 28
diff changeset
16
2575
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
17
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
18
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
19 bool ReadWindowsRegistryStringRecursive(HKEY parent_key, const char *path, char *out_string, int out_string_size)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
20 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
21 char current_key[128];
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
22 char path_tail[1024];
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
23
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
24 const char *delimiter = strstr(path, "/");
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
25 if (delimiter)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
26 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
27 strncpy(current_key, path, delimiter - path);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
28 current_key[delimiter - path] = '\0';
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
29
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
30 strcpy(path_tail, delimiter + 1);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
31
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
32 if (!parent_key)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
33 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
34 if (!strcmpi(current_key, "HKEY_CLASSES_ROOT"))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
35 parent_key = HKEY_CLASSES_ROOT;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
36 else if (!strcmpi(current_key, "HKEY_CURRENT_CONFIG"))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
37 parent_key = HKEY_CURRENT_CONFIG;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
38 else if (!strcmpi(current_key, "HKEY_CURRENT_USER"))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
39 parent_key = HKEY_CURRENT_USER;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
40 else if (!strcmpi(current_key, "HKEY_LOCAL_MACHINE"))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
41 parent_key = HKEY_LOCAL_MACHINE;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
42 else if (!strcmpi(current_key, "HKEY_USERS"))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
43 parent_key = HKEY_USERS;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
44 else return false;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
45
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
46 delimiter = strstr(path_tail, "/");
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
47 if (delimiter)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
48 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
49 strncpy(current_key, path_tail, delimiter - path_tail);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
50 current_key[delimiter - path_tail] = '\0';
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
51
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
52 strcpy(path_tail, delimiter + 1);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
53 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
54 else return false;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
55 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
56
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
57 bool result = false;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
58 HKEY key;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
59 if (!RegOpenKeyExA(parent_key, current_key, 0, KEY_READ | KEY_WOW64_32KEY, &key))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
60 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
61 /*int idx = 0, r;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
62 do {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
63 char value_name[1024];
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
64 DWORD value_name_size = sizeof(value_name);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
65 r = RegEnumValueA(key, idx++, value_name, &value_name_size, nullptr, nullptr, nullptr, nullptr);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
66 __debugbreak();
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
67 } while (r == ERROR_SUCCESS);*/
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
68
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
69 result = ReadWindowsRegistryStringRecursive(key, path_tail, out_string, out_string_size);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
70 RegCloseKey(key);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
71 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
72
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
73 return result;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
74 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
75 else
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
76 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
77 DWORD data_size = out_string_size;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
78 if (RegQueryValueExA(parent_key, path, nullptr, nullptr, (LPBYTE)out_string, &data_size))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
79 return false;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
80 return true;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
81 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
82 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
83
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
84 bool ReadWindowsRegistryString(const char *path, char *out_string, int out_string_size)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
85 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
86 return ReadWindowsRegistryStringRecursive(nullptr, path, out_string, out_string_size);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
87 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
88
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
89
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
90
0
Ritor1
parents:
diff changeset
91 //----- (00462C94) --------------------------------------------------------
2461
ff7f4995aa25 function MakeScreenshot()
Ritor1
parents: 2415
diff changeset
92 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hprevinstance, wchar_t *lpCmdLine, int nShowCmd)
0
Ritor1
parents:
diff changeset
93 {
2572
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2499
diff changeset
94 #ifndef NDEBUG
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2499
diff changeset
95 {
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2499
diff changeset
96 //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF);
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2499
diff changeset
97 }
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2499
diff changeset
98 #endif
d87bfbd3bb3b Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents: 2499
diff changeset
99
0
Ritor1
parents:
diff changeset
100 Log::Initialize();
2575
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
101
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
102 bool mm7_installation_found = false;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
103 char mm7_path[2048];
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
104
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
105 // standard 1.0 installation
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
106 if (!mm7_installation_found)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
107 mm7_installation_found = ReadWindowsRegistryString("HKEY_LOCAL_MACHINE/SOFTWARE/New World Computing/Might and Magic VII/1.0/AppPath", mm7_path, sizeof(mm7_path));
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
108
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
109 // GoG version
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
110 if (!mm7_installation_found)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
111 mm7_installation_found = ReadWindowsRegistryString("HKEY_LOCAL_MACHINE/SOFTWARE/GOG.com/GOGMM7/PATH", mm7_path, sizeof(mm7_path));
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
112
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
113
2461
ff7f4995aa25 function MakeScreenshot()
Ritor1
parents: 2415
diff changeset
114 if (HWND hMM7Window = FindWindowW(L"M&MTrilogy", 0))//check whether the window is open
0
Ritor1
parents:
diff changeset
115 {
Ritor1
parents:
diff changeset
116 if (IsIconic(hMM7Window))
Ritor1
parents:
diff changeset
117 ShowWindow(hMM7Window, SW_RESTORE);
Ritor1
parents:
diff changeset
118 SetForegroundWindow(GetLastActivePopup(hMM7Window));
Ritor1
parents:
diff changeset
119 return 0;
Ritor1
parents:
diff changeset
120 }
2461
ff7f4995aa25 function MakeScreenshot()
Ritor1
parents: 2415
diff changeset
121
0
Ritor1
parents:
diff changeset
122 HWND hPrevWindow = GetActiveWindow();
2412
e7a551f458e1 LoadSound - cause of the crash exe file
Ritor1
parents: 2253
diff changeset
123 if (!hPrevWindow)
0
Ritor1
parents:
diff changeset
124 {
Ritor1
parents:
diff changeset
125 Log::Warning(L"OS init: ok");
Ritor1
parents:
diff changeset
126 extern bool MM_Main(const wchar_t *pCmdLine);
Ritor1
parents:
diff changeset
127 MM_Main(lpCmdLine);
Ritor1
parents:
diff changeset
128 }
Ritor1
parents:
diff changeset
129 if (hPrevWindow)
Ritor1
parents:
diff changeset
130 SetActiveWindow(hPrevWindow);
Ritor1
parents:
diff changeset
131
2152
d44b7775fc06 Removed DirectDraw2 compatibility.
Nomad
parents: 2059
diff changeset
132 return GetLastError();
0
Ritor1
parents:
diff changeset
133 }
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1038
diff changeset
134
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1038
diff changeset
135
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1038
diff changeset
136
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1038
diff changeset
137
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1038
diff changeset
138 void MsgBox(const wchar_t *msg, const wchar_t *title)
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1038
diff changeset
139 {
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1038
diff changeset
140 MessageBoxW(nullptr, msg, title, 0);
2575
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
141 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
142
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
143
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
144
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
145
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
146 //----- (004649EF) --------------------------------------------------------
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
147 int ReadWindowsRegistryInt(const char *pKey, int uDefValue)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
148 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
149 DWORD cbData; // [sp+8h] [bp-20h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
150 LPCSTR lpValueName; // [sp+Ch] [bp-1Ch]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
151 DWORD dwDisposition; // [sp+10h] [bp-18h]@2
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
152 BYTE Data[4]; // [sp+14h] [bp-14h]@5
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
153 HKEY hKey; // [sp+18h] [bp-10h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
154 HKEY phkResult; // [sp+1Ch] [bp-Ch]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
155 HKEY v10; // [sp+20h] [bp-8h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
156 HKEY v11; // [sp+24h] [bp-4h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
157
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
158 lpValueName = pKey;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
159 v11 = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
160 v10 = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
161 hKey = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
162 phkResult = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
163 cbData = 4;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
164 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ | KEY_WOW64_32KEY, &hKey))// for 64 bit
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
165 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
166 if (!RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
167 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
168 if (!RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v10, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
169 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
170 if (!RegCreateKeyExA(v10, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v11, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
171 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
172 LSTATUS status;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
173 if (status = RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
174 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
175 status;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
176 GetLastError();
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
177
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
178 *(int *)Data = uDefValue;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
179 RegSetValueExA(v11, lpValueName, 0, 4, Data, 4);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
180 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
181 RegCloseKey(v11);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
182 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
183 RegCloseKey(v10);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
184 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
185 RegCloseKey(phkResult);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
186 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
187 RegCloseKey(hKey);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
188 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
189 return *(int *)Data;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
190 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
191
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
192 //----- (00464B02) --------------------------------------------------------
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
193 void WriteWindowsRegistryString(const char *pKey, const char *pString)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
194 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
195 size_t v2; // eax@5
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
196 const char *lpValueName; // [sp+4h] [bp-1Ch]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
197 const char *Str; // [sp+8h] [bp-18h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
198 DWORD dwDisposition; // [sp+Ch] [bp-14h]@2
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
199 HKEY hKey; // [sp+10h] [bp-10h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
200 HKEY phkResult; // [sp+14h] [bp-Ch]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
201 HKEY v8; // [sp+18h] [bp-8h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
202 HKEY v9; // [sp+1Ch] [bp-4h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
203
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
204 Str = pString;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
205 lpValueName = pKey;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
206 v9 = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
207 v8 = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
208 hKey = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
209 phkResult = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
210 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ | KEY_WOW64_32KEY, &hKey))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
211 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
212 if (!RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
213 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
214 if (!RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
215 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
216 if (!RegCreateKeyExA(v8, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v9, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
217 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
218 v2 = strlen(Str);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
219 RegSetValueExA(v9, lpValueName, 0, 1, (const BYTE *)Str, v2 + 1);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
220 RegCloseKey(v9);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
221 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
222 RegCloseKey(v8);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
223 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
224 RegCloseKey(phkResult);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
225 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
226 RegCloseKey(hKey);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
227 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
228 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
229
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
230
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
231 //----- (00464BEF) --------------------------------------------------------
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
232 void ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
233 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
234 //LSTATUS (__stdcall *v4)(HKEY); // esi@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
235 LSTATUS result; // eax@7
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
236 DWORD Type; // [sp+Ch] [bp-24h]@5
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
237 LPCSTR lpValueName; // [sp+10h] [bp-20h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
238 DWORD cbData; // [sp+14h] [bp-1Ch]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
239 LPBYTE Dest; // [sp+18h] [bp-18h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
240 DWORD dwDisposition; // [sp+1Ch] [bp-14h]@2
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
241 HKEY phkResult; // [sp+20h] [bp-10h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
242 HKEY hKey; // [sp+24h] [bp-Ch]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
243 HKEY v13; // [sp+28h] [bp-8h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
244 HKEY v14; // [sp+2Ch] [bp-4h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
245
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
246 cbData = uBufLen;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
247 Dest = (LPBYTE)pOutString;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
248 lpValueName = pKeyName;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
249 v14 = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
250 v13 = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
251 hKey = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
252 phkResult = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
253 result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
254 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ | KEY_WOW64_32KEY, &hKey))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
255 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
256 if (!RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
257 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
258 if (!RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v13, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
259 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
260 if (!RegCreateKeyExA(v13, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v14, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
261 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
262 if (RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
263 GetLastError();
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
264 RegCloseKey(v14);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
265 v14 = NULL;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
266 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
267 RegCloseKey(v13);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
268 v13 = NULL;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
269 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
270 RegCloseKey(phkResult);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
271 phkResult = NULL;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
272 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
273 RegCloseKey(hKey);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
274 hKey = NULL;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
275 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
276 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
277
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
278 //----- (00464D32) --------------------------------------------------------
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
279 void WriteWindowsRegistryInt(const char *pKey, int val)
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
280 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
281 const char *lpValueName; // [sp+4h] [bp-1Ch]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
282 BYTE Data[4]; // [sp+8h] [bp-18h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
283 DWORD dwDisposition; // [sp+Ch] [bp-14h]@2
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
284 HKEY hKey; // [sp+10h] [bp-10h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
285 HKEY phkResult; // [sp+14h] [bp-Ch]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
286 HKEY v7; // [sp+18h] [bp-8h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
287 HKEY v8; // [sp+1Ch] [bp-4h]@1
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
288
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
289 *(int *)Data = val;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
290 lpValueName = pKey;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
291 v8 = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
292 v7 = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
293 hKey = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
294 phkResult = 0;
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
295 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ | KEY_WOW64_32KEY, &hKey))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
296 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
297 if (!RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
298 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
299 if (!RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v7, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
300 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
301 if (!RegCreateKeyExA(v7, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition))
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
302 {
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
303 RegSetValueExA(v8, lpValueName, 0, 4, Data, 4);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
304 RegCloseKey(v8);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
305 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
306 RegCloseKey(v7);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
307 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
308 RegCloseKey(phkResult);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
309 }
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
310 RegCloseKey(hKey);
a76d408c5132 DrawTranslucent -> DrawTextureGrayShade
a.parshin
parents: 2572
diff changeset
311 }
1545
c4ab816fcc5e assert, Abortf, AbortWithError -> Assert, Error
Nomad
parents: 1038
diff changeset
312 }