Translate

Sunday, November 24, 2013

Enumerating physical display adapters on Windows.

 While working on RealBench v2 I had to enumerate the physical display adapters available on the user's system. There are several ways of doing this. I only found one that works the way I wanted it to work though.

 The most common suggested solution for this is EnumDisplayDevices(). The problem with this approach is that it returns one device per available output display port. So for my development system with reference design Geforce 680 2xSLI cards, it actually returned 4xGeforce 680 devices. You can filter devices that are connected to a screen but that doesn't help at all in enumerating physical display adapters for any user configuration.

 The second most suggested method is using DirectX's DXGI IDXGIFactory::EnumAdapters(). This is very easy to implement even for programmers who have never touched DirectX before BUT it still doesn't work as I needed it to work. As in the case of SLI/Crossfire it returns a single adapter instead of the amount of adapters present in the SLI/Crossfire array.

 The one I used is the Setup API method which includes SetupDiGetClassDevs(), SetupDiEnumDeviceInfo() and SetupDiGetDeviceRegistryProperty(). This one works exactly like I wanted it to. It will return exactly what I need it to. The actual physical display adapter devices. Here's sample code (it includes a couple of QStrings as I'm using Qt):

-------------------------------------------------------
    HDEVINFO deviceInfoSet;
    GUID *guidDev = (GUID*) &GUID_DEVCLASS_DISPLAY;
    deviceInfoSet = SetupDiGetClassDevs(guidDev, NULL, NULL, DIGCF_PRESENT | DIGCF_PROFILE);
    DWORD DataT;
    WCHAR *buffer[4000];
    DWORD buffersize = 4000;
    int memberIndex = 0;
    while (true)
    {
        SP_DEVINFO_DATA deviceInfoData;
        ZeroMemory(&deviceInfoData, sizeof(SP_DEVINFO_DATA));
        deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
        if (SetupDiEnumDeviceInfo(deviceInfoSet, memberIndex, &deviceInfoData) == FALSE)
        {
            if (GetLastError() == ERROR_NO_MORE_ITEMS)
            {
                break;
            }
        }
        SetupDiGetDeviceRegistryProperty(deviceInfoSet, &deviceInfoData, SPDRP_DEVICEDESC, &DataT, (PBYTE)buffer, buffersize, NULL);
                  
        qDebug() << QString::fromWCharArray((WCHAR*)buffer);
        gpuInfo.append(QString::fromWCharArray((WCHAR*)buffer));

        memberIndex++;
    }
    if (deviceInfoSet)
    {
        SetupDiDestroyDeviceInfoList(deviceInfoSet);
    }
-------------------------------------------------------

There are a couple of other ways suggested. Namely, WMI and CCD API. Truth be told I never looked into these ways as Setup API did exactly what I wanted it to do and frankly I hate WMI. The CCD QueryDisplayConfig() function looks interesting and would be the next to try out if Setup API did not apply to my needs. :)

Sunday, November 17, 2013

RealBench v2 Public Beta release.

 I released earlier today the public beta of RealBench v2. The free benchmarking software I am developing for ASUS Republic of Gamers. There were a couple of issues due to my hastiness but nothing really serious. Hopefully it won't need lots of hours on the debugger..*wishful thinking*.

Link: RealBench-v2.0-Public-Beta!

ASUS OEM License Restorer

 So we had a lot of people, at the Republic of Gamers forums, with ASUS laptops that had lost their Windows recovery image or had simply wanted to install Windows from another iso, without the default vendor stuff. Yet they wanted to keep their ASUS OEM Windows license that is tied to their laptop or ASUS PC.

 So I cooked up this tool, with ASUS' permission, to restore the Win7 ASUS OEM license to ASUS laptops/PCs no matter how the user installed Windows.

Note: This is not a tool to activate Windows when you don't own a license. This will do absolutely nothing unless your ASUS laptop or PC has a valid ASUS OEM Windows license.


More about it and download link here: ASUS OEM License Restorer (Win7)

Sunday, October 27, 2013

Convert ANSI text file to Unicode Shell Extension

 Generally I prefer to set locale for non-Unicode applications to US-English on my Windows PCs because several applications have the nasty habit to autotranslate their interfaces (eg *coughInteldriverscoughcough*) according to that setting and I absolutely hate any kind of translation of technical terminology  .

 This has the nasty side-effect of not being able to read text files written in my native language (eg movie subtitles) unless they're of course in Unicode encoding . That was not much of a problem because I could always use my favorite text editor, Notepad++, to set the encoding to Windows-1253 (CP1253) and then convert to UTF-8 Unicode. After a while though this process became quite tedious. Specially when I had to convert several files in a row.

 So I came up with this idea. How about an explorer shell extension that would allow me to right click the file and convert it with a single click? Then I went ahead and cooked something up really fast!

 So here it is: ConvertToUTF8_v1.0
(Ad displayed for 5 seconds before download starts).

 The default setting is to convert CP1253 to UTF8 but there are instructions inside the "Readme_First.txt" file in order to change this to any encoding/language you want/need. It also includes very simple installation/uninstallation instructions.

  If you really found this useful and got nothing better to do with your money, hit the "Coffee to Code Conversion Fund" Donate button, to allow me to convert coffee into a full blown and configurable .dll shell extension! :)

If you want to, you can also use this to convert to other encodings instead of UTF-8.. you may want to convert files to UTF-16 or whatever. It's your call, just adjust the iconv.exe in and out parameters.

You can also make multiple settings by copying the.cmd file to another name, edit the in out parameters. Then copy with another name and edit the install/uninstall .reg files accordingly.
The idea is flexible, do what you want with it:)

Quoting the "Readme_First.txt" file below:

 This is a shell extension that will allow you to convert any text file to Unicode UTF8 by
right clicking and selecting "Convert Greek To UTF8". It says Greek because that's the default
setting. Below I will explain how to change that to another ANSI codepage (language) and how
to install and uninstall it.

 This package was made by Nodens (Panagiotis Kalogiratos) and depends on iconv.exe tool which is licensed under GPL!

Note: If you want to set it to another language you have to do it prior to installing.
If you have installed, use the uninstallation procedure first or else the extension name will still
say "Greek" even after you edit the files.


Installation:
1. Copy "convertToUTF8.cmd", "iconv.exe" and "libiconv-2__.dll" to "C:\Windows"
2. Double-click the "convertToUTF8_install.reg" file.

Unistallation:
1. Double-click the "convertToUTF8_uninstall.reg" file.
2. Delete "convertToUTF8.cmd" and "iconv.exe" from "C:\Windows"



Customize to other encodings/languages:

1. Edit the two ".reg" files and change "Convert Greek to Unicode" string in it to any language you want (eg. "Convert Arabic to Unicode").

2. Edit "convertToUTF8.cmd" and change "CP1253" to any other supported ANSI codepage:
(This list can also be obtained via running "iconv -l").
-----------------------------------
ANSI_X3.4-1968 ANSI_X3.4-1986 ASCII CP367 IBM367 ISO-IR-6 ISO646-US ISO_646.IRV:
1991 US US-ASCII CSASCII
UTF-8
ISO-10646-UCS-2 UCS-2 CSUNICODE
UCS-2BE UNICODE-1-1 UNICODEBIG CSUNICODE11
UCS-2LE UNICODELITTLE
ISO-10646-UCS-4 UCS-4 CSUCS4
UCS-4BE
UCS-4LE
UTF-16
UTF-16BE
UTF-16LE
UTF-32
UTF-32BE
UTF-32LE
UNICODE-1-1-UTF-7 UTF-7 CSUNICODE11UTF7
UCS-2-INTERNAL
UCS-2-SWAPPED
UCS-4-INTERNAL
UCS-4-SWAPPED
C99
JAVA
CP819 IBM819 ISO-8859-1 ISO-IR-100 ISO8859-1 ISO_8859-1 ISO_8859-1:1987 L1 LATIN1 CSISOLATIN1
ISO-8859-2 ISO-IR-101 ISO8859-2 ISO_8859-2 ISO_8859-2:1987 L2 LATIN2 CSISOLATIN2
ISO-8859-3 ISO-IR-109 ISO8859-3 ISO_8859-3 ISO_8859-3:1988 L3 LATIN3 CSISOLATIN3
ISO-8859-4 ISO-IR-110 ISO8859-4 ISO_8859-4 ISO_8859-4:1988 L4 LATIN4 CSISOLATIN4
CYRILLIC ISO-8859-5 ISO-IR-144 ISO8859-5 ISO_8859-5 ISO_8859-5:1988 CSISOLATINCYRILLIC
ARABIC ASMO-708 ECMA-114 ISO-8859-6 ISO-IR-127 ISO8859-6 ISO_8859-6 ISO_8859-6:1987 CSISOLATINARABIC
ECMA-118 ELOT_928 GREEK GREEK8 ISO-8859-7 ISO-IR-126 ISO8859-7 ISO_8859-7 ISO_8859-7:1987 ISO_8859-7:2003 CSISOLATINGREEK
HEBREW ISO-8859-8 ISO-IR-138 ISO8859-8 ISO_8859-8 ISO_8859-8:1988 CSISOLATINHEBREW
ISO-8859-9 ISO-IR-148 ISO8859-9 ISO_8859-9 ISO_8859-9:1989 L5 LATIN5 CSISOLATIN5
ISO-8859-10 ISO-IR-157 ISO8859-10 ISO_8859-10 ISO_8859-10:1992 L6 LATIN6 CSISOLATIN6
ISO-8859-11 ISO8859-11 ISO_8859-11
ISO-8859-13 ISO-IR-179 ISO8859-13 ISO_8859-13 L7 LATIN7
ISO-8859-14 ISO-CELTIC ISO-IR-199 ISO8859-14 ISO_8859-14 ISO_8859-14:1998 L8 LATIN8
ISO-8859-15 ISO-IR-203 ISO8859-15 ISO_8859-15 ISO_8859-15:1998 LATIN-9
ISO-8859-16 ISO-IR-226 ISO8859-16 ISO_8859-16 ISO_8859-16:2001 L10 LATIN10
KOI8-R CSKOI8R
KOI8-U
KOI8-RU
CP1250 MS-EE WINDOWS-1250
CP1251 MS-CYRL WINDOWS-1251
CP1252 MS-ANSI WINDOWS-1252
CP1253 MS-GREEK WINDOWS-1253
CP1254 MS-TURK WINDOWS-1254
CP1255 MS-HEBR WINDOWS-1255
CP1256 MS-ARAB WINDOWS-1256
CP1257 WINBALTRIM WINDOWS-1257
CP1258 WINDOWS-1258
850 CP850 IBM850 CSPC850MULTILINGUAL
862 CP862 IBM862 CSPC862LATINHEBREW
866 CP866 IBM866 CSIBM866
CP1131
MAC MACINTOSH MACROMAN CSMACINTOSH
MACCENTRALEUROPE
MACICELAND
MACCROATIAN
MACROMANIA
MACCYRILLIC
MACUKRAINE
MACGREEK
MACTURKISH
MACHEBREW
MACARABIC
MACTHAI
HP-ROMAN8 R8 ROMAN8 CSHPROMAN8
NEXTSTEP
ARMSCII-8
GEORGIAN-ACADEMY
GEORGIAN-PS
KOI8-T
CP154 CYRILLIC-ASIAN PT154 PTCP154 CSPTCP154
KZ-1048 RK1048 STRK1048-2002 CSKZ1048
MULELAO-1
CP1133 IBM-CP1133
ISO-IR-166 TIS-620 TIS620 TIS620-0 TIS620.2529-1 TIS620.2533-0 TIS620.2533-1
CP874 WINDOWS-874
VISCII VISCII1.1-1 CSVISCII
TCVN TCVN-5712 TCVN5712-1 TCVN5712-1:1993
ISO-IR-14 ISO646-JP JIS_C6220-1969-RO JP CSISO14JISC6220RO
JISX0201-1976 JIS_X0201 X0201 CSHALFWIDTHKATAKANA
ISO-IR-87 JIS0208 JIS_C6226-1983 JIS_X0208 JIS_X0208-1983 JIS_X0208-1990 X0208 CSISO87JISX0208
ISO-IR-159 JIS_X0212 JIS_X0212-1990 JIS_X0212.1990-0 X0212 CSISO159JISX02121990
CN GB_1988-80 ISO-IR-57 ISO646-CN CSISO57GB1988
CHINESE GB_2312-80 ISO-IR-58 CSISO58GB231280
CN-GB-ISOIR165 ISO-IR-165
ISO-IR-149 KOREAN KSC_5601 KS_C_5601-1987 KS_C_5601-1989 CSKSC56011987
EUC-JP EUCJP EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE CSEUCPKDFMTJAPANESE
MS_KANJI SHIFT-JIS SHIFT_JIS SJIS CSSHIFTJIS
CP932
ISO-2022-JP CSISO2022JP
ISO-2022-JP-1
ISO-2022-JP-2 CSISO2022JP2
CN-GB EUC-CN EUCCN GB2312 CSGB2312
GBK
CP936 MS936 WINDOWS-936
GB18030
ISO-2022-CN CSISO2022CN
ISO-2022-CN-EXT
HZ HZ-GB-2312
EUC-TW EUCTW CSEUCTW
BIG-5 BIG-FIVE BIG5 BIGFIVE CN-BIG5 CSBIG5
CP950
BIG5-HKSCS:1999
BIG5-HKSCS:2001
BIG5-HKSCS:2004
BIG5-HKSCS BIG5-HKSCS:2008 BIG5HKSCS
EUC-KR EUCKR CSEUCKR
CP949 UHC
CP1361 JOHAB
ISO-2022-KR CSISO2022KR
437 CP437 IBM437 CSPC8CODEPAGE437
CP737
CP775 IBM775 CSPC775BALTIC
852 CP852 IBM852 CSPCP852
CP853
855 CP855 IBM855 CSIBM855
857 CP857 IBM857 CSIBM857
CP858
860 CP860 IBM860 CSIBM860
861 CP-IS CP861 IBM861 CSIBM861
863 CP863 IBM863 CSIBM863
CP864 IBM864 CSIBM864
865 CP865 IBM865 CSIBM865
869 CP-GR CP869 IBM869 CSIBM869
CP1125

Thursday, October 24, 2013

X79 chipset and PCIe 3.0

 There has been a lot of misunderstanding regarding this since the release of the platform and Sandy Bridge-E CPUs. This is mainly due to wording.

 SB-E CPUs are PCIe 3.0 "capable" but not "certified". This means that they theoretically support PCIe 3.0 but they have not actually been tested and certified for it. The reality of things is that PCIe cards were not out yet so there was nothing to certify against.

 Then nVidia's 6xx series came out and people found the hard way that team green is disabling 3.0 mode with their driver installers for this platform.

  There was a lot of fuss about it and certain registry changes began to circulate, that would enable 3.0 mode on these cards. nVidia then went ahead with this public statement and the release of a tool that
would basically apply and revert these registry changes directly so GEN3 support could be manually enabled on X79: nVidia Statement & Tool

 My own personal testing, while profiling code, showed several driver stalls/timeouts when GEN3 support was enabled. The driver could actually recover from (in most cases) BUT it did actually slow the performance down, as was expected. I went ahead and tested 8x SB-E CPU samples that I had access to and the results where similar. The difference was in severity of the issue only. Some samples produced stop errors, others seemed fine when in fact they were not.
 The result of this was me acquiring a personal habit of suggesting, to everyone asking for advice, to not enable GEN3 support on this platform at all. There are no benefits from GEN3 anyhow since the bandwidth of GEN2 is still not getting saturated by the top end cards.

 Now that this background info is out of the way, I can get to the point that the newly released Ivy Bridge-E CPUs for the X79 platform solve these issues. X79 platform owners can now utilize PCIe GEN3 without any issues whatsoever!
 Of course the benefits of doing so are still non-existent. Perhaps GEN3 RAID SAS/SATA HBAs can benefit from it but when it comes to video cards, you will not see any performance increase that is outside the margin of error unless you are utilizing huge "Surround" type resolutions. 4K monitor booths anyone?

Tuesday, October 22, 2013

Microsoft Security Essentials (admitted fluke)

 Well we all knew it was weak. The heuristics engine, which is what is really important in an AV product, is very very weak. But now comes confirmation from Microsoft themselves that the product is intended as a "baseline" of defense that will always be at the bottom of the AV products list.

 What I find extremely funny though was this statement by Holly Stewart, who, I hope, managed to keep her position in Microsoft after this statement. She basically claims that Microsoft had a team trying to cheat the AV tests, instead of focusing on developing a better product:

"Previously, Microsoft would spend resources trying to improve Security Essentials' performance in tests. "We used to have part of our team directed towards predicting test results and figuring out what might be in someone’s test. There’s always a cost to that," she said. "If they are doing that work they are not looking at those threats that are affecting our customers. We always felt that was wrong. There’s something not right about that – we’re not doing the best job for our customers.""

You can read the entire article here: Microsoft: Security Essentials is designed to be bottom of the antivirus rankings

 I wonder if Microsoft will update the product information pages with this "new" information and if Microsoft affiliates will now stop presenting MSE as the end of all desktop security, or even as "equally good to the other solutions on the market" on sites such as the Technet forums.

The case of UEFI GOP and ASUS video cards

  As many of you know, in order to benefit to the maximum from the Fast Boot features of Windows 8+, you need a UEFI installation and to entirely disable the CSM (Compatibility Support Module) of the EFI. This in turn allows the simultaneous initialization of components, without support for legacy hardware or operating systems/bootloaders.
 In order for one to be able to completely disable the CSM module, the system components must be entirely UEFI compatible. The particular elusive point in many systems is the video card because the majority of the cards out there feature a legacy VBIOS instead of a UEFI GOP.

 Many companies out there are handing out manual UEFI GOP updates for their video cards. ASUS on the other hand, playing safe against the people that would go ahead and flash their card with UEFI GOP while not having a UEFI compliant motherboard (which will result in a bricked/unbootable system), released a UEFI GOP updater tool that checks the motherboard for compliance. This in turn had the effect of not allowing flashing of ASUS video cards with UEFI GOP unless they are connected to ASUS motherboards.

 I perfectly understand ASUS' decision to play safe because I can only imagine the amount of disgruntled users and RMA cases of people that, without the technical knowledge or research, decided to flash their cards with something their system does not support. This leaves the case, though, of those users that actually know what they are doing and are unable to flash their cards because they have no ASUS motherboards. For this particular reason, I chose to patch the ASUS UEFI GOP updater tool so that anyone can blindingly flash their card. I posted the patched tool up on ASUS ROG forums with very noticeable disclaimers.

 If this is something that you can use, you can find it here: Patched ASUS UEFI GOP Tool

 Be absolutely certain that you read all directions and disclaimers carefully!