blob: 88a6fa417b782c15597c52380bf076ee6f235015 [file] [log] [blame]
Vadim Iosevichd50ea462017-03-30 16:19:08 +03001/*
2 * Copyright (c) 2017, The Linux Foundation. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#pragma once
31
32#include "wlct_os.h"
33
34class Util
35{
36public:
37 static bool getFileVersionInfo(const TCHAR *fileNameFillPath, int &mjr, int &mnr, int &mnt, int &build);
38 static BOOL IsNumeric(LPCTSTR pszString, BOOL bIgnoreColon);
39 static DWORD ReadRegistrySettings(LPCTSTR lpszRegistryPath, LPCTSTR valName);
40 static DWORD WriteRegistrySettings(LPCTSTR lpszRegistryPath, LPCTSTR valName, DWORD val);
41 static int IsWlctDevicePlugin();
42// static bool Util::GetWlstPluggedInDevice();
43 static bool ICHDisableEnable();
44 static bool GetPciControllerDevicePath(TCHAR* devicePath);
45
46 // perfrom atomic change value, to acquire resource!
47 // if VAR != FLAG_VALUE, then set VAR to FLAG_VALUE.
48 // loop until timeout (milisec). return success in acheiving resource
49 // Assumes that FLAG_VALUE should be diffrent then current value stored in VAR
50 // turn keepWaiting on to wait infinite
51
52 static BOOL timedResourceInterLockExchange ( LONG* var, LONG flag_value, int timeout, bool keepWaiting );
53
54 static BOOL Is64BitWindows();
55
56private:
57 Util(void);
58 ~Util(void);
59};
60
61#ifdef _WINDOWS
62#include <setupapi.h>
63#include <cfgmgr32.h>
64
65typedef HKEY (__stdcall SETUPDIOPENDEVREGKEY)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, REGSAM);
66typedef BOOL (__stdcall SETUPDICLASSGUIDSFROMNAME)(LPCTSTR, LPGUID, DWORD, PDWORD);
67typedef BOOL (__stdcall SETUPDIDESTROYDEVICEINFOLIST)(HDEVINFO);
68typedef BOOL (__stdcall SETUPDIENUMDEVICEINFO)(HDEVINFO, DWORD, PSP_DEVINFO_DATA);
69typedef HDEVINFO (__stdcall SETUPDIGETCLASSDEVS)(LPGUID, LPCTSTR, HWND, DWORD);
70typedef BOOL (__stdcall SETUPDIGETDEVICEREGISTRYPROPERTY)(HDEVINFO, PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD);
71typedef DWORD (__stdcall CM_GET_DEVICE_ID)(DEVINST, PTCHAR, ULONG, ULONG);
72#endif