1
0

obs-windows.c 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include "util/windows/win-registry.h"
  15. #include "util/windows/win-version.h"
  16. #include "util/platform.h"
  17. #include "util/dstr.h"
  18. #include "obs.h"
  19. #include "obs-internal.h"
  20. #include <windows.h>
  21. #include <wscapi.h>
  22. #include <iwscapi.h>
  23. static uint32_t win_ver = 0;
  24. const char *get_module_extension(void)
  25. {
  26. return ".dll";
  27. }
  28. #ifdef _WIN64
  29. #define BIT_STRING "64bit"
  30. #else
  31. #define BIT_STRING "32bit"
  32. #endif
  33. static const char *module_bin[] = {
  34. "../../obs-plugins/" BIT_STRING,
  35. };
  36. static const char *module_data[] = {"../../data/obs-plugins/%module%"};
  37. static const int module_patterns_size =
  38. sizeof(module_bin) / sizeof(module_bin[0]);
  39. void add_default_module_paths(void)
  40. {
  41. for (int i = 0; i < module_patterns_size; i++)
  42. obs_add_module_path(module_bin[i], module_data[i]);
  43. }
  44. /* on windows, points to [base directory]/data/libobs */
  45. char *find_libobs_data_file(const char *file)
  46. {
  47. struct dstr path;
  48. dstr_init(&path);
  49. if (check_path(file, "../../data/libobs/", &path))
  50. return path.array;
  51. dstr_free(&path);
  52. return NULL;
  53. }
  54. static void log_processor_info(void)
  55. {
  56. HKEY key;
  57. wchar_t data[1024];
  58. char *str = NULL;
  59. DWORD size, speed;
  60. LSTATUS status;
  61. memset(data, 0, sizeof(data));
  62. status = RegOpenKeyW(
  63. HKEY_LOCAL_MACHINE,
  64. L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &key);
  65. if (status != ERROR_SUCCESS)
  66. return;
  67. size = sizeof(data);
  68. status = RegQueryValueExW(key, L"ProcessorNameString", NULL, NULL,
  69. (LPBYTE)data, &size);
  70. if (status == ERROR_SUCCESS) {
  71. os_wcs_to_utf8_ptr(data, 0, &str);
  72. blog(LOG_INFO, "CPU Name: %s", str);
  73. bfree(str);
  74. }
  75. size = sizeof(speed);
  76. status = RegQueryValueExW(key, L"~MHz", NULL, NULL, (LPBYTE)&speed,
  77. &size);
  78. if (status == ERROR_SUCCESS)
  79. blog(LOG_INFO, "CPU Speed: %ldMHz", speed);
  80. RegCloseKey(key);
  81. }
  82. static void log_processor_cores(void)
  83. {
  84. blog(LOG_INFO, "Physical Cores: %d, Logical Cores: %d",
  85. os_get_physical_cores(), os_get_logical_cores());
  86. }
  87. static void log_available_memory(void)
  88. {
  89. MEMORYSTATUSEX ms;
  90. ms.dwLength = sizeof(ms);
  91. GlobalMemoryStatusEx(&ms);
  92. #ifdef _WIN64
  93. const char *note = "";
  94. #else
  95. const char *note = " (NOTE: 32bit programs cannot use more than 3gb)";
  96. #endif
  97. blog(LOG_INFO, "Physical Memory: %luMB Total, %luMB Free%s",
  98. (DWORD)(ms.ullTotalPhys / 1048576),
  99. (DWORD)(ms.ullAvailPhys / 1048576), note);
  100. }
  101. extern const char *get_win_release_id();
  102. static void log_windows_version(void)
  103. {
  104. struct win_version_info ver;
  105. get_win_ver(&ver);
  106. const char *release_id = get_win_release_id();
  107. bool b64 = is_64_bit_windows();
  108. const char *windows_bitness = b64 ? "64" : "32";
  109. blog(LOG_INFO,
  110. "Windows Version: %d.%d Build %d (release: %s; revision: %d; %s-bit)",
  111. ver.major, ver.minor, ver.build, release_id, ver.revis,
  112. windows_bitness);
  113. }
  114. static void log_admin_status(void)
  115. {
  116. SID_IDENTIFIER_AUTHORITY auth = SECURITY_NT_AUTHORITY;
  117. PSID admin_group;
  118. BOOL success;
  119. success = AllocateAndInitializeSid(&auth, 2,
  120. SECURITY_BUILTIN_DOMAIN_RID,
  121. DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0,
  122. 0, 0, &admin_group);
  123. if (success) {
  124. if (!CheckTokenMembership(NULL, admin_group, &success))
  125. success = false;
  126. FreeSid(admin_group);
  127. }
  128. blog(LOG_INFO, "Running as administrator: %s",
  129. success ? "true" : "false");
  130. }
  131. typedef HRESULT(WINAPI *dwm_is_composition_enabled_t)(BOOL *);
  132. static void log_aero(void)
  133. {
  134. dwm_is_composition_enabled_t composition_enabled = NULL;
  135. const char *aeroMessage =
  136. win_ver >= 0x602
  137. ? " (Aero is always on for windows 8 and above)"
  138. : "";
  139. HMODULE dwm = LoadLibraryW(L"dwmapi");
  140. BOOL bComposition = true;
  141. if (!dwm) {
  142. return;
  143. }
  144. composition_enabled = (dwm_is_composition_enabled_t)GetProcAddress(
  145. dwm, "DwmIsCompositionEnabled");
  146. if (!composition_enabled) {
  147. FreeLibrary(dwm);
  148. return;
  149. }
  150. composition_enabled(&bComposition);
  151. blog(LOG_INFO, "Aero is %s%s", bComposition ? "Enabled" : "Disabled",
  152. aeroMessage);
  153. }
  154. #define WIN10_GAME_BAR_REG_KEY \
  155. L"Software\\Microsoft\\Windows\\CurrentVersion\\GameDVR"
  156. #define WIN10_GAME_DVR_POLICY_REG_KEY \
  157. L"SOFTWARE\\Policies\\Microsoft\\Windows\\GameDVR"
  158. #define WIN10_GAME_DVR_REG_KEY L"System\\GameConfigStore"
  159. #define WIN10_GAME_MODE_REG_KEY L"Software\\Microsoft\\GameBar"
  160. static void log_gaming_features(void)
  161. {
  162. if (win_ver < 0xA00)
  163. return;
  164. struct reg_dword game_bar_enabled;
  165. struct reg_dword game_dvr_allowed;
  166. struct reg_dword game_dvr_enabled;
  167. struct reg_dword game_dvr_bg_recording;
  168. struct reg_dword game_mode_enabled;
  169. get_reg_dword(HKEY_CURRENT_USER, WIN10_GAME_BAR_REG_KEY,
  170. L"AppCaptureEnabled", &game_bar_enabled);
  171. get_reg_dword(HKEY_CURRENT_USER, WIN10_GAME_DVR_POLICY_REG_KEY,
  172. L"AllowGameDVR", &game_dvr_allowed);
  173. get_reg_dword(HKEY_CURRENT_USER, WIN10_GAME_DVR_REG_KEY,
  174. L"GameDVR_Enabled", &game_dvr_enabled);
  175. get_reg_dword(HKEY_CURRENT_USER, WIN10_GAME_BAR_REG_KEY,
  176. L"HistoricalCaptureEnabled", &game_dvr_bg_recording);
  177. get_reg_dword(HKEY_CURRENT_USER, WIN10_GAME_MODE_REG_KEY,
  178. L"AllowAutoGameMode", &game_mode_enabled);
  179. if (game_mode_enabled.status != ERROR_SUCCESS) {
  180. get_reg_dword(HKEY_CURRENT_USER, WIN10_GAME_MODE_REG_KEY,
  181. L"AutoGameModeEnabled", &game_mode_enabled);
  182. }
  183. blog(LOG_INFO, "Windows 10 Gaming Features:");
  184. if (game_bar_enabled.status == ERROR_SUCCESS) {
  185. blog(LOG_INFO, "\tGame Bar: %s",
  186. (bool)game_bar_enabled.return_value ? "On" : "Off");
  187. }
  188. if (game_dvr_allowed.status == ERROR_SUCCESS) {
  189. blog(LOG_INFO, "\tGame DVR Allowed: %s",
  190. (bool)game_dvr_allowed.return_value ? "Yes" : "No");
  191. }
  192. if (game_dvr_enabled.status == ERROR_SUCCESS) {
  193. blog(LOG_INFO, "\tGame DVR: %s",
  194. (bool)game_dvr_enabled.return_value ? "On" : "Off");
  195. }
  196. if (game_dvr_bg_recording.status == ERROR_SUCCESS) {
  197. blog(LOG_INFO, "\tGame DVR Background Recording: %s",
  198. (bool)game_dvr_bg_recording.return_value ? "On" : "Off");
  199. }
  200. if (game_mode_enabled.status == ERROR_SUCCESS) {
  201. blog(LOG_INFO, "\tGame Mode: %s",
  202. (bool)game_mode_enabled.return_value ? "On" : "Off");
  203. }
  204. }
  205. static const char *get_str_for_state(int state)
  206. {
  207. switch (state) {
  208. case WSC_SECURITY_PRODUCT_STATE_ON:
  209. return "enabled";
  210. case WSC_SECURITY_PRODUCT_STATE_OFF:
  211. return "disabled";
  212. case WSC_SECURITY_PRODUCT_STATE_SNOOZED:
  213. return "temporarily disabled";
  214. case WSC_SECURITY_PRODUCT_STATE_EXPIRED:
  215. return "expired";
  216. default:
  217. return "unknown";
  218. }
  219. }
  220. static const char *get_str_for_type(int type)
  221. {
  222. switch (type) {
  223. case WSC_SECURITY_PROVIDER_ANTIVIRUS:
  224. return "AV";
  225. case WSC_SECURITY_PROVIDER_FIREWALL:
  226. return "FW";
  227. case WSC_SECURITY_PROVIDER_ANTISPYWARE:
  228. return "ASW";
  229. default:
  230. return "unknown";
  231. }
  232. }
  233. static void log_security_products_by_type(IWSCProductList *prod_list, int type)
  234. {
  235. HRESULT hr;
  236. LONG count = 0;
  237. IWscProduct *prod;
  238. BSTR name;
  239. WSC_SECURITY_PRODUCT_STATE prod_state;
  240. hr = prod_list->lpVtbl->Initialize(prod_list, type);
  241. if (FAILED(hr))
  242. return;
  243. hr = prod_list->lpVtbl->get_Count(prod_list, &count);
  244. if (FAILED(hr)) {
  245. prod_list->lpVtbl->Release(prod_list);
  246. return;
  247. }
  248. for (int i = 0; i < count; i++) {
  249. hr = prod_list->lpVtbl->get_Item(prod_list, i, &prod);
  250. if (FAILED(hr))
  251. continue;
  252. hr = prod->lpVtbl->get_ProductName(prod, &name);
  253. if (FAILED(hr))
  254. continue;
  255. hr = prod->lpVtbl->get_ProductState(prod, &prod_state);
  256. if (FAILED(hr)) {
  257. SysFreeString(name);
  258. continue;
  259. }
  260. blog(LOG_INFO, "\t%S: %s (%s)", name,
  261. get_str_for_state(prod_state), get_str_for_type(type));
  262. SysFreeString(name);
  263. prod->lpVtbl->Release(prod);
  264. }
  265. prod_list->lpVtbl->Release(prod_list);
  266. }
  267. static void log_security_products(void)
  268. {
  269. IWSCProductList *prod_list = NULL;
  270. HMODULE h_wsc;
  271. HRESULT hr;
  272. /* We load the DLL rather than import wcsapi.lib because the clsid /
  273. * iid only exists on Windows 8 or higher. */
  274. h_wsc = LoadLibraryW(L"wscapi.dll");
  275. if (!h_wsc)
  276. return;
  277. const CLSID *prod_list_clsid =
  278. (const CLSID *)GetProcAddress(h_wsc, "CLSID_WSCProductList");
  279. const IID *prod_list_iid =
  280. (const IID *)GetProcAddress(h_wsc, "IID_IWSCProductList");
  281. if (prod_list_clsid && prod_list_iid) {
  282. blog(LOG_INFO, "Sec. Software Status:");
  283. hr = CoCreateInstance(prod_list_clsid, NULL,
  284. CLSCTX_INPROC_SERVER, prod_list_iid,
  285. &prod_list);
  286. if (!FAILED(hr)) {
  287. log_security_products_by_type(
  288. prod_list, WSC_SECURITY_PROVIDER_ANTIVIRUS);
  289. }
  290. hr = CoCreateInstance(prod_list_clsid, NULL,
  291. CLSCTX_INPROC_SERVER, prod_list_iid,
  292. &prod_list);
  293. if (!FAILED(hr)) {
  294. log_security_products_by_type(
  295. prod_list, WSC_SECURITY_PROVIDER_FIREWALL);
  296. }
  297. hr = CoCreateInstance(prod_list_clsid, NULL,
  298. CLSCTX_INPROC_SERVER, prod_list_iid,
  299. &prod_list);
  300. if (!FAILED(hr)) {
  301. log_security_products_by_type(
  302. prod_list, WSC_SECURITY_PROVIDER_ANTISPYWARE);
  303. }
  304. }
  305. FreeLibrary(h_wsc);
  306. }
  307. void log_system_info(void)
  308. {
  309. struct win_version_info ver;
  310. get_win_ver(&ver);
  311. win_ver = (ver.major << 8) | ver.minor;
  312. log_processor_info();
  313. log_processor_cores();
  314. log_available_memory();
  315. log_windows_version();
  316. log_admin_status();
  317. log_aero();
  318. log_gaming_features();
  319. log_security_products();
  320. }
  321. struct obs_hotkeys_platform {
  322. int vk_codes[OBS_KEY_LAST_VALUE];
  323. };
  324. static int get_virtual_key(obs_key_t key)
  325. {
  326. switch (key) {
  327. case OBS_KEY_RETURN:
  328. return VK_RETURN;
  329. case OBS_KEY_ESCAPE:
  330. return VK_ESCAPE;
  331. case OBS_KEY_TAB:
  332. return VK_TAB;
  333. case OBS_KEY_BACKTAB:
  334. return VK_OEM_BACKTAB;
  335. case OBS_KEY_BACKSPACE:
  336. return VK_BACK;
  337. case OBS_KEY_INSERT:
  338. return VK_INSERT;
  339. case OBS_KEY_DELETE:
  340. return VK_DELETE;
  341. case OBS_KEY_PAUSE:
  342. return VK_PAUSE;
  343. case OBS_KEY_PRINT:
  344. return VK_SNAPSHOT;
  345. case OBS_KEY_CLEAR:
  346. return VK_CLEAR;
  347. case OBS_KEY_HOME:
  348. return VK_HOME;
  349. case OBS_KEY_END:
  350. return VK_END;
  351. case OBS_KEY_LEFT:
  352. return VK_LEFT;
  353. case OBS_KEY_UP:
  354. return VK_UP;
  355. case OBS_KEY_RIGHT:
  356. return VK_RIGHT;
  357. case OBS_KEY_DOWN:
  358. return VK_DOWN;
  359. case OBS_KEY_PAGEUP:
  360. return VK_PRIOR;
  361. case OBS_KEY_PAGEDOWN:
  362. return VK_NEXT;
  363. case OBS_KEY_SHIFT:
  364. return VK_SHIFT;
  365. case OBS_KEY_CONTROL:
  366. return VK_CONTROL;
  367. case OBS_KEY_ALT:
  368. return VK_MENU;
  369. case OBS_KEY_CAPSLOCK:
  370. return VK_CAPITAL;
  371. case OBS_KEY_NUMLOCK:
  372. return VK_NUMLOCK;
  373. case OBS_KEY_SCROLLLOCK:
  374. return VK_SCROLL;
  375. case OBS_KEY_F1:
  376. return VK_F1;
  377. case OBS_KEY_F2:
  378. return VK_F2;
  379. case OBS_KEY_F3:
  380. return VK_F3;
  381. case OBS_KEY_F4:
  382. return VK_F4;
  383. case OBS_KEY_F5:
  384. return VK_F5;
  385. case OBS_KEY_F6:
  386. return VK_F6;
  387. case OBS_KEY_F7:
  388. return VK_F7;
  389. case OBS_KEY_F8:
  390. return VK_F8;
  391. case OBS_KEY_F9:
  392. return VK_F9;
  393. case OBS_KEY_F10:
  394. return VK_F10;
  395. case OBS_KEY_F11:
  396. return VK_F11;
  397. case OBS_KEY_F12:
  398. return VK_F12;
  399. case OBS_KEY_F13:
  400. return VK_F13;
  401. case OBS_KEY_F14:
  402. return VK_F14;
  403. case OBS_KEY_F15:
  404. return VK_F15;
  405. case OBS_KEY_F16:
  406. return VK_F16;
  407. case OBS_KEY_F17:
  408. return VK_F17;
  409. case OBS_KEY_F18:
  410. return VK_F18;
  411. case OBS_KEY_F19:
  412. return VK_F19;
  413. case OBS_KEY_F20:
  414. return VK_F20;
  415. case OBS_KEY_F21:
  416. return VK_F21;
  417. case OBS_KEY_F22:
  418. return VK_F22;
  419. case OBS_KEY_F23:
  420. return VK_F23;
  421. case OBS_KEY_F24:
  422. return VK_F24;
  423. case OBS_KEY_SPACE:
  424. return VK_SPACE;
  425. case OBS_KEY_APOSTROPHE:
  426. return VK_OEM_7;
  427. case OBS_KEY_PLUS:
  428. return VK_OEM_PLUS;
  429. case OBS_KEY_COMMA:
  430. return VK_OEM_COMMA;
  431. case OBS_KEY_MINUS:
  432. return VK_OEM_MINUS;
  433. case OBS_KEY_PERIOD:
  434. return VK_OEM_PERIOD;
  435. case OBS_KEY_SLASH:
  436. return VK_OEM_2;
  437. case OBS_KEY_0:
  438. return '0';
  439. case OBS_KEY_1:
  440. return '1';
  441. case OBS_KEY_2:
  442. return '2';
  443. case OBS_KEY_3:
  444. return '3';
  445. case OBS_KEY_4:
  446. return '4';
  447. case OBS_KEY_5:
  448. return '5';
  449. case OBS_KEY_6:
  450. return '6';
  451. case OBS_KEY_7:
  452. return '7';
  453. case OBS_KEY_8:
  454. return '8';
  455. case OBS_KEY_9:
  456. return '9';
  457. case OBS_KEY_NUMASTERISK:
  458. return VK_MULTIPLY;
  459. case OBS_KEY_NUMPLUS:
  460. return VK_ADD;
  461. case OBS_KEY_NUMMINUS:
  462. return VK_SUBTRACT;
  463. case OBS_KEY_NUMPERIOD:
  464. return VK_DECIMAL;
  465. case OBS_KEY_NUMSLASH:
  466. return VK_DIVIDE;
  467. case OBS_KEY_NUM0:
  468. return VK_NUMPAD0;
  469. case OBS_KEY_NUM1:
  470. return VK_NUMPAD1;
  471. case OBS_KEY_NUM2:
  472. return VK_NUMPAD2;
  473. case OBS_KEY_NUM3:
  474. return VK_NUMPAD3;
  475. case OBS_KEY_NUM4:
  476. return VK_NUMPAD4;
  477. case OBS_KEY_NUM5:
  478. return VK_NUMPAD5;
  479. case OBS_KEY_NUM6:
  480. return VK_NUMPAD6;
  481. case OBS_KEY_NUM7:
  482. return VK_NUMPAD7;
  483. case OBS_KEY_NUM8:
  484. return VK_NUMPAD8;
  485. case OBS_KEY_NUM9:
  486. return VK_NUMPAD9;
  487. case OBS_KEY_SEMICOLON:
  488. return VK_OEM_1;
  489. case OBS_KEY_A:
  490. return 'A';
  491. case OBS_KEY_B:
  492. return 'B';
  493. case OBS_KEY_C:
  494. return 'C';
  495. case OBS_KEY_D:
  496. return 'D';
  497. case OBS_KEY_E:
  498. return 'E';
  499. case OBS_KEY_F:
  500. return 'F';
  501. case OBS_KEY_G:
  502. return 'G';
  503. case OBS_KEY_H:
  504. return 'H';
  505. case OBS_KEY_I:
  506. return 'I';
  507. case OBS_KEY_J:
  508. return 'J';
  509. case OBS_KEY_K:
  510. return 'K';
  511. case OBS_KEY_L:
  512. return 'L';
  513. case OBS_KEY_M:
  514. return 'M';
  515. case OBS_KEY_N:
  516. return 'N';
  517. case OBS_KEY_O:
  518. return 'O';
  519. case OBS_KEY_P:
  520. return 'P';
  521. case OBS_KEY_Q:
  522. return 'Q';
  523. case OBS_KEY_R:
  524. return 'R';
  525. case OBS_KEY_S:
  526. return 'S';
  527. case OBS_KEY_T:
  528. return 'T';
  529. case OBS_KEY_U:
  530. return 'U';
  531. case OBS_KEY_V:
  532. return 'V';
  533. case OBS_KEY_W:
  534. return 'W';
  535. case OBS_KEY_X:
  536. return 'X';
  537. case OBS_KEY_Y:
  538. return 'Y';
  539. case OBS_KEY_Z:
  540. return 'Z';
  541. case OBS_KEY_BRACKETLEFT:
  542. return VK_OEM_4;
  543. case OBS_KEY_BACKSLASH:
  544. return VK_OEM_5;
  545. case OBS_KEY_BRACKETRIGHT:
  546. return VK_OEM_6;
  547. case OBS_KEY_ASCIITILDE:
  548. return VK_OEM_3;
  549. case OBS_KEY_HENKAN:
  550. return VK_CONVERT;
  551. case OBS_KEY_MUHENKAN:
  552. return VK_NONCONVERT;
  553. case OBS_KEY_KANJI:
  554. return VK_KANJI;
  555. case OBS_KEY_TOUROKU:
  556. return VK_OEM_FJ_TOUROKU;
  557. case OBS_KEY_MASSYO:
  558. return VK_OEM_FJ_MASSHOU;
  559. case OBS_KEY_HANGUL:
  560. return VK_HANGUL;
  561. case OBS_KEY_BACKSLASH_RT102:
  562. return VK_OEM_102;
  563. case OBS_KEY_MOUSE1:
  564. return VK_LBUTTON;
  565. case OBS_KEY_MOUSE2:
  566. return VK_RBUTTON;
  567. case OBS_KEY_MOUSE3:
  568. return VK_MBUTTON;
  569. case OBS_KEY_MOUSE4:
  570. return VK_XBUTTON1;
  571. case OBS_KEY_MOUSE5:
  572. return VK_XBUTTON2;
  573. case OBS_KEY_VK_CANCEL:
  574. return VK_CANCEL;
  575. case OBS_KEY_0x07:
  576. return 0x07;
  577. case OBS_KEY_0x0A:
  578. return 0x0A;
  579. case OBS_KEY_0x0B:
  580. return 0x0B;
  581. case OBS_KEY_0x0E:
  582. return 0x0E;
  583. case OBS_KEY_0x0F:
  584. return 0x0F;
  585. case OBS_KEY_0x16:
  586. return 0x16;
  587. case OBS_KEY_VK_JUNJA:
  588. return VK_JUNJA;
  589. case OBS_KEY_VK_FINAL:
  590. return VK_FINAL;
  591. case OBS_KEY_0x1A:
  592. return 0x1A;
  593. case OBS_KEY_VK_ACCEPT:
  594. return VK_ACCEPT;
  595. case OBS_KEY_VK_MODECHANGE:
  596. return VK_MODECHANGE;
  597. case OBS_KEY_VK_SELECT:
  598. return VK_SELECT;
  599. case OBS_KEY_VK_PRINT:
  600. return VK_PRINT;
  601. case OBS_KEY_VK_EXECUTE:
  602. return VK_EXECUTE;
  603. case OBS_KEY_VK_HELP:
  604. return VK_HELP;
  605. case OBS_KEY_0x30:
  606. return 0x30;
  607. case OBS_KEY_0x31:
  608. return 0x31;
  609. case OBS_KEY_0x32:
  610. return 0x32;
  611. case OBS_KEY_0x33:
  612. return 0x33;
  613. case OBS_KEY_0x34:
  614. return 0x34;
  615. case OBS_KEY_0x35:
  616. return 0x35;
  617. case OBS_KEY_0x36:
  618. return 0x36;
  619. case OBS_KEY_0x37:
  620. return 0x37;
  621. case OBS_KEY_0x38:
  622. return 0x38;
  623. case OBS_KEY_0x39:
  624. return 0x39;
  625. case OBS_KEY_0x3A:
  626. return 0x3A;
  627. case OBS_KEY_0x3B:
  628. return 0x3B;
  629. case OBS_KEY_0x3C:
  630. return 0x3C;
  631. case OBS_KEY_0x3D:
  632. return 0x3D;
  633. case OBS_KEY_0x3E:
  634. return 0x3E;
  635. case OBS_KEY_0x3F:
  636. return 0x3F;
  637. case OBS_KEY_0x40:
  638. return 0x40;
  639. case OBS_KEY_0x41:
  640. return 0x41;
  641. case OBS_KEY_0x42:
  642. return 0x42;
  643. case OBS_KEY_0x43:
  644. return 0x43;
  645. case OBS_KEY_0x44:
  646. return 0x44;
  647. case OBS_KEY_0x45:
  648. return 0x45;
  649. case OBS_KEY_0x46:
  650. return 0x46;
  651. case OBS_KEY_0x47:
  652. return 0x47;
  653. case OBS_KEY_0x48:
  654. return 0x48;
  655. case OBS_KEY_0x49:
  656. return 0x49;
  657. case OBS_KEY_0x4A:
  658. return 0x4A;
  659. case OBS_KEY_0x4B:
  660. return 0x4B;
  661. case OBS_KEY_0x4C:
  662. return 0x4C;
  663. case OBS_KEY_0x4D:
  664. return 0x4D;
  665. case OBS_KEY_0x4E:
  666. return 0x4E;
  667. case OBS_KEY_0x4F:
  668. return 0x4F;
  669. case OBS_KEY_0x50:
  670. return 0x50;
  671. case OBS_KEY_0x51:
  672. return 0x51;
  673. case OBS_KEY_0x52:
  674. return 0x52;
  675. case OBS_KEY_0x53:
  676. return 0x53;
  677. case OBS_KEY_0x54:
  678. return 0x54;
  679. case OBS_KEY_0x55:
  680. return 0x55;
  681. case OBS_KEY_0x56:
  682. return 0x56;
  683. case OBS_KEY_0x57:
  684. return 0x57;
  685. case OBS_KEY_0x58:
  686. return 0x58;
  687. case OBS_KEY_0x59:
  688. return 0x59;
  689. case OBS_KEY_0x5A:
  690. return 0x5A;
  691. case OBS_KEY_VK_LWIN:
  692. return VK_LWIN;
  693. case OBS_KEY_VK_RWIN:
  694. return VK_RWIN;
  695. case OBS_KEY_VK_APPS:
  696. return VK_APPS;
  697. case OBS_KEY_0x5E:
  698. return 0x5E;
  699. case OBS_KEY_VK_SLEEP:
  700. return VK_SLEEP;
  701. case OBS_KEY_VK_SEPARATOR:
  702. return VK_SEPARATOR;
  703. case OBS_KEY_0x88:
  704. return 0x88;
  705. case OBS_KEY_0x89:
  706. return 0x89;
  707. case OBS_KEY_0x8A:
  708. return 0x8A;
  709. case OBS_KEY_0x8B:
  710. return 0x8B;
  711. case OBS_KEY_0x8C:
  712. return 0x8C;
  713. case OBS_KEY_0x8D:
  714. return 0x8D;
  715. case OBS_KEY_0x8E:
  716. return 0x8E;
  717. case OBS_KEY_0x8F:
  718. return 0x8F;
  719. case OBS_KEY_VK_OEM_FJ_JISHO:
  720. return VK_OEM_FJ_JISHO;
  721. case OBS_KEY_VK_OEM_FJ_LOYA:
  722. return VK_OEM_FJ_LOYA;
  723. case OBS_KEY_VK_OEM_FJ_ROYA:
  724. return VK_OEM_FJ_ROYA;
  725. case OBS_KEY_0x97:
  726. return 0x97;
  727. case OBS_KEY_0x98:
  728. return 0x98;
  729. case OBS_KEY_0x99:
  730. return 0x99;
  731. case OBS_KEY_0x9A:
  732. return 0x9A;
  733. case OBS_KEY_0x9B:
  734. return 0x9B;
  735. case OBS_KEY_0x9C:
  736. return 0x9C;
  737. case OBS_KEY_0x9D:
  738. return 0x9D;
  739. case OBS_KEY_0x9E:
  740. return 0x9E;
  741. case OBS_KEY_0x9F:
  742. return 0x9F;
  743. case OBS_KEY_VK_LSHIFT:
  744. return VK_LSHIFT;
  745. case OBS_KEY_VK_RSHIFT:
  746. return VK_RSHIFT;
  747. case OBS_KEY_VK_LCONTROL:
  748. return VK_LCONTROL;
  749. case OBS_KEY_VK_RCONTROL:
  750. return VK_RCONTROL;
  751. case OBS_KEY_VK_LMENU:
  752. return VK_LMENU;
  753. case OBS_KEY_VK_RMENU:
  754. return VK_RMENU;
  755. case OBS_KEY_VK_BROWSER_BACK:
  756. return VK_BROWSER_BACK;
  757. case OBS_KEY_VK_BROWSER_FORWARD:
  758. return VK_BROWSER_FORWARD;
  759. case OBS_KEY_VK_BROWSER_REFRESH:
  760. return VK_BROWSER_REFRESH;
  761. case OBS_KEY_VK_BROWSER_STOP:
  762. return VK_BROWSER_STOP;
  763. case OBS_KEY_VK_BROWSER_SEARCH:
  764. return VK_BROWSER_SEARCH;
  765. case OBS_KEY_VK_BROWSER_FAVORITES:
  766. return VK_BROWSER_FAVORITES;
  767. case OBS_KEY_VK_BROWSER_HOME:
  768. return VK_BROWSER_HOME;
  769. case OBS_KEY_VK_VOLUME_MUTE:
  770. return VK_VOLUME_MUTE;
  771. case OBS_KEY_VK_VOLUME_DOWN:
  772. return VK_VOLUME_DOWN;
  773. case OBS_KEY_VK_VOLUME_UP:
  774. return VK_VOLUME_UP;
  775. case OBS_KEY_VK_MEDIA_NEXT_TRACK:
  776. return VK_MEDIA_NEXT_TRACK;
  777. case OBS_KEY_VK_MEDIA_PREV_TRACK:
  778. return VK_MEDIA_PREV_TRACK;
  779. case OBS_KEY_VK_MEDIA_STOP:
  780. return VK_MEDIA_STOP;
  781. case OBS_KEY_VK_MEDIA_PLAY_PAUSE:
  782. return VK_MEDIA_PLAY_PAUSE;
  783. case OBS_KEY_VK_LAUNCH_MAIL:
  784. return VK_LAUNCH_MAIL;
  785. case OBS_KEY_VK_LAUNCH_MEDIA_SELECT:
  786. return VK_LAUNCH_MEDIA_SELECT;
  787. case OBS_KEY_VK_LAUNCH_APP1:
  788. return VK_LAUNCH_APP1;
  789. case OBS_KEY_VK_LAUNCH_APP2:
  790. return VK_LAUNCH_APP2;
  791. case OBS_KEY_0xB8:
  792. return 0xB8;
  793. case OBS_KEY_0xB9:
  794. return 0xB9;
  795. case OBS_KEY_0xC1:
  796. return 0xC1;
  797. case OBS_KEY_0xC2:
  798. return 0xC2;
  799. case OBS_KEY_0xC3:
  800. return 0xC3;
  801. case OBS_KEY_0xC4:
  802. return 0xC4;
  803. case OBS_KEY_0xC5:
  804. return 0xC5;
  805. case OBS_KEY_0xC6:
  806. return 0xC6;
  807. case OBS_KEY_0xC7:
  808. return 0xC7;
  809. case OBS_KEY_0xC8:
  810. return 0xC8;
  811. case OBS_KEY_0xC9:
  812. return 0xC9;
  813. case OBS_KEY_0xCA:
  814. return 0xCA;
  815. case OBS_KEY_0xCB:
  816. return 0xCB;
  817. case OBS_KEY_0xCC:
  818. return 0xCC;
  819. case OBS_KEY_0xCD:
  820. return 0xCD;
  821. case OBS_KEY_0xCE:
  822. return 0xCE;
  823. case OBS_KEY_0xCF:
  824. return 0xCF;
  825. case OBS_KEY_0xD0:
  826. return 0xD0;
  827. case OBS_KEY_0xD1:
  828. return 0xD1;
  829. case OBS_KEY_0xD2:
  830. return 0xD2;
  831. case OBS_KEY_0xD3:
  832. return 0xD3;
  833. case OBS_KEY_0xD4:
  834. return 0xD4;
  835. case OBS_KEY_0xD5:
  836. return 0xD5;
  837. case OBS_KEY_0xD6:
  838. return 0xD6;
  839. case OBS_KEY_0xD7:
  840. return 0xD7;
  841. case OBS_KEY_0xD8:
  842. return 0xD8;
  843. case OBS_KEY_0xD9:
  844. return 0xD9;
  845. case OBS_KEY_0xDA:
  846. return 0xDA;
  847. case OBS_KEY_VK_OEM_8:
  848. return VK_OEM_8;
  849. case OBS_KEY_0xE0:
  850. return 0xE0;
  851. case OBS_KEY_VK_OEM_AX:
  852. return VK_OEM_AX;
  853. case OBS_KEY_VK_ICO_HELP:
  854. return VK_ICO_HELP;
  855. case OBS_KEY_VK_ICO_00:
  856. return VK_ICO_00;
  857. case OBS_KEY_VK_PROCESSKEY:
  858. return VK_PROCESSKEY;
  859. case OBS_KEY_VK_ICO_CLEAR:
  860. return VK_ICO_CLEAR;
  861. case OBS_KEY_VK_PACKET:
  862. return VK_PACKET;
  863. case OBS_KEY_0xE8:
  864. return 0xE8;
  865. case OBS_KEY_VK_OEM_RESET:
  866. return VK_OEM_RESET;
  867. case OBS_KEY_VK_OEM_JUMP:
  868. return VK_OEM_JUMP;
  869. case OBS_KEY_VK_OEM_PA1:
  870. return VK_OEM_PA1;
  871. case OBS_KEY_VK_OEM_PA2:
  872. return VK_OEM_PA2;
  873. case OBS_KEY_VK_OEM_PA3:
  874. return VK_OEM_PA3;
  875. case OBS_KEY_VK_OEM_WSCTRL:
  876. return VK_OEM_WSCTRL;
  877. case OBS_KEY_VK_OEM_CUSEL:
  878. return VK_OEM_CUSEL;
  879. case OBS_KEY_VK_OEM_ATTN:
  880. return VK_OEM_ATTN;
  881. case OBS_KEY_VK_OEM_FINISH:
  882. return VK_OEM_FINISH;
  883. case OBS_KEY_VK_OEM_COPY:
  884. return VK_OEM_COPY;
  885. case OBS_KEY_VK_OEM_AUTO:
  886. return VK_OEM_AUTO;
  887. case OBS_KEY_VK_OEM_ENLW:
  888. return VK_OEM_ENLW;
  889. case OBS_KEY_VK_ATTN:
  890. return VK_ATTN;
  891. case OBS_KEY_VK_CRSEL:
  892. return VK_CRSEL;
  893. case OBS_KEY_VK_EXSEL:
  894. return VK_EXSEL;
  895. case OBS_KEY_VK_EREOF:
  896. return VK_EREOF;
  897. case OBS_KEY_VK_PLAY:
  898. return VK_PLAY;
  899. case OBS_KEY_VK_ZOOM:
  900. return VK_ZOOM;
  901. case OBS_KEY_VK_NONAME:
  902. return VK_NONAME;
  903. case OBS_KEY_VK_PA1:
  904. return VK_PA1;
  905. case OBS_KEY_VK_OEM_CLEAR:
  906. return VK_OEM_CLEAR;
  907. /* TODO: Implement keys for non-US keyboards */
  908. default:;
  909. }
  910. return 0;
  911. }
  912. bool obs_hotkeys_platform_init(struct obs_core_hotkeys *hotkeys)
  913. {
  914. hotkeys->platform_context = bzalloc(sizeof(obs_hotkeys_platform_t));
  915. for (size_t i = 0; i < OBS_KEY_LAST_VALUE; i++)
  916. hotkeys->platform_context->vk_codes[i] = get_virtual_key(i);
  917. return true;
  918. }
  919. void obs_hotkeys_platform_free(struct obs_core_hotkeys *hotkeys)
  920. {
  921. bfree(hotkeys->platform_context);
  922. hotkeys->platform_context = NULL;
  923. }
  924. static bool vk_down(DWORD vk)
  925. {
  926. short state = GetAsyncKeyState(vk);
  927. bool down = (state & 0x8000) != 0;
  928. return down;
  929. }
  930. bool obs_hotkeys_platform_is_pressed(obs_hotkeys_platform_t *context,
  931. obs_key_t key)
  932. {
  933. if (key == OBS_KEY_META) {
  934. return vk_down(VK_LWIN) || vk_down(VK_RWIN);
  935. }
  936. UNUSED_PARAMETER(context);
  937. return vk_down(obs_key_to_virtual_key(key));
  938. }
  939. void obs_key_to_str(obs_key_t key, struct dstr *str)
  940. {
  941. wchar_t name[128] = L"";
  942. UINT scan_code;
  943. int vk;
  944. if (key == OBS_KEY_NONE) {
  945. return;
  946. } else if (key >= OBS_KEY_MOUSE1 && key <= OBS_KEY_MOUSE29) {
  947. if (obs->hotkeys.translations[key]) {
  948. dstr_copy(str, obs->hotkeys.translations[key]);
  949. } else {
  950. dstr_printf(str, "Mouse %d",
  951. (int)(key - OBS_KEY_MOUSE1 + 1));
  952. }
  953. return;
  954. }
  955. if (key == OBS_KEY_PAUSE) {
  956. dstr_copy(str, obs_get_hotkey_translation(key, "Pause"));
  957. return;
  958. } else if (key == OBS_KEY_META) {
  959. dstr_copy(str, obs_get_hotkey_translation(key, "Windows"));
  960. return;
  961. }
  962. vk = obs_key_to_virtual_key(key);
  963. scan_code = MapVirtualKey(vk, 0) << 16;
  964. switch (vk) {
  965. case VK_HOME:
  966. case VK_END:
  967. case VK_LEFT:
  968. case VK_UP:
  969. case VK_RIGHT:
  970. case VK_DOWN:
  971. case VK_PRIOR:
  972. case VK_NEXT:
  973. case VK_INSERT:
  974. case VK_DELETE:
  975. case VK_NUMLOCK:
  976. scan_code |= 0x01000000;
  977. }
  978. if ((key < OBS_KEY_VK_CANCEL || key > OBS_KEY_VK_OEM_CLEAR) &&
  979. scan_code != 0 && GetKeyNameTextW(scan_code, name, 128) != 0) {
  980. dstr_from_wcs(str, name);
  981. } else if (key != OBS_KEY_NONE) {
  982. dstr_copy(str, obs_key_to_name(key));
  983. }
  984. }
  985. obs_key_t obs_key_from_virtual_key(int code)
  986. {
  987. obs_hotkeys_platform_t *platform = obs->hotkeys.platform_context;
  988. for (size_t i = 0; i < OBS_KEY_LAST_VALUE; i++) {
  989. if (platform->vk_codes[i] == code) {
  990. return (obs_key_t)i;
  991. }
  992. }
  993. return OBS_KEY_NONE;
  994. }
  995. int obs_key_to_virtual_key(obs_key_t key)
  996. {
  997. if (key == OBS_KEY_META)
  998. return VK_LWIN;
  999. return obs->hotkeys.platform_context->vk_codes[(int)key];
  1000. }
  1001. static inline void add_combo_key(obs_key_t key, struct dstr *str)
  1002. {
  1003. struct dstr key_str = {0};
  1004. obs_key_to_str(key, &key_str);
  1005. if (!dstr_is_empty(&key_str)) {
  1006. if (!dstr_is_empty(str)) {
  1007. dstr_cat(str, " + ");
  1008. }
  1009. dstr_cat_dstr(str, &key_str);
  1010. }
  1011. dstr_free(&key_str);
  1012. }
  1013. void obs_key_combination_to_str(obs_key_combination_t combination,
  1014. struct dstr *str)
  1015. {
  1016. if ((combination.modifiers & INTERACT_CONTROL_KEY) != 0) {
  1017. add_combo_key(OBS_KEY_CONTROL, str);
  1018. }
  1019. if ((combination.modifiers & INTERACT_COMMAND_KEY) != 0) {
  1020. add_combo_key(OBS_KEY_META, str);
  1021. }
  1022. if ((combination.modifiers & INTERACT_ALT_KEY) != 0) {
  1023. add_combo_key(OBS_KEY_ALT, str);
  1024. }
  1025. if ((combination.modifiers & INTERACT_SHIFT_KEY) != 0) {
  1026. add_combo_key(OBS_KEY_SHIFT, str);
  1027. }
  1028. if (combination.key != OBS_KEY_NONE) {
  1029. add_combo_key(combination.key, str);
  1030. }
  1031. }
  1032. bool sym_initialize_called = false;
  1033. void reset_win32_symbol_paths(void)
  1034. {
  1035. static BOOL(WINAPI * sym_initialize_w)(HANDLE, const wchar_t *, BOOL);
  1036. static BOOL(WINAPI * sym_set_search_path_w)(HANDLE, const wchar_t *);
  1037. static bool funcs_initialized = false;
  1038. static bool initialize_success = false;
  1039. struct obs_module *module = obs->first_module;
  1040. struct dstr path_str = {0};
  1041. DARRAY(char *) paths;
  1042. wchar_t *path_str_w = NULL;
  1043. char *abspath;
  1044. da_init(paths);
  1045. if (!funcs_initialized) {
  1046. HMODULE mod;
  1047. funcs_initialized = true;
  1048. mod = LoadLibraryW(L"DbgHelp");
  1049. if (!mod)
  1050. return;
  1051. sym_initialize_w =
  1052. (void *)GetProcAddress(mod, "SymInitializeW");
  1053. sym_set_search_path_w =
  1054. (void *)GetProcAddress(mod, "SymSetSearchPathW");
  1055. if (!sym_initialize_w || !sym_set_search_path_w) {
  1056. FreeLibrary(mod);
  1057. return;
  1058. }
  1059. initialize_success = true;
  1060. // Leaks 'mod' once.
  1061. }
  1062. if (!initialize_success)
  1063. return;
  1064. abspath = os_get_abs_path_ptr(".");
  1065. if (abspath)
  1066. da_push_back(paths, &abspath);
  1067. while (module) {
  1068. bool found = false;
  1069. struct dstr path = {0};
  1070. char *path_end;
  1071. dstr_copy(&path, module->bin_path);
  1072. dstr_replace(&path, "/", "\\");
  1073. path_end = strrchr(path.array, '\\');
  1074. if (!path_end) {
  1075. module = module->next;
  1076. dstr_free(&path);
  1077. continue;
  1078. }
  1079. *path_end = 0;
  1080. for (size_t i = 0; i < paths.num; i++) {
  1081. const char *existing_path = paths.array[i];
  1082. if (astrcmpi(path.array, existing_path) == 0) {
  1083. found = true;
  1084. break;
  1085. }
  1086. }
  1087. if (!found) {
  1088. abspath = os_get_abs_path_ptr(path.array);
  1089. if (abspath)
  1090. da_push_back(paths, &abspath);
  1091. }
  1092. dstr_free(&path);
  1093. module = module->next;
  1094. }
  1095. for (size_t i = 0; i < paths.num; i++) {
  1096. const char *path = paths.array[i];
  1097. if (path && *path) {
  1098. if (i != 0)
  1099. dstr_cat(&path_str, ";");
  1100. dstr_cat(&path_str, paths.array[i]);
  1101. }
  1102. }
  1103. if (path_str.array) {
  1104. os_utf8_to_wcs_ptr(path_str.array, path_str.len, &path_str_w);
  1105. if (path_str_w) {
  1106. if (!sym_initialize_called) {
  1107. sym_initialize_w(GetCurrentProcess(),
  1108. path_str_w, false);
  1109. sym_initialize_called = true;
  1110. } else {
  1111. sym_set_search_path_w(GetCurrentProcess(),
  1112. path_str_w);
  1113. }
  1114. bfree(path_str_w);
  1115. }
  1116. }
  1117. for (size_t i = 0; i < paths.num; i++)
  1118. bfree(paths.array[i]);
  1119. dstr_free(&path_str);
  1120. da_free(paths);
  1121. }
  1122. extern void initialize_crash_handler(void);
  1123. void obs_init_win32_crash_handler(void)
  1124. {
  1125. initialize_crash_handler();
  1126. }
  1127. bool initialize_com(void)
  1128. {
  1129. const HRESULT hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
  1130. const bool success = SUCCEEDED(hr);
  1131. if (success)
  1132. blog(LOG_INFO, "CoInitializeEx succeeded: 0x%08X", hr);
  1133. else
  1134. blog(LOG_ERROR, "CoInitializeEx failed: 0x%08X", hr);
  1135. return success;
  1136. }
  1137. void uninitialize_com(void)
  1138. {
  1139. CoUninitialize();
  1140. }