Skip to content

Instantly share code, notes, and snippets.

@mak
Created Apr 29, 2020
Embed
What would you like to do?
get_win_name
BOOL __cdecl get_win_name(int a1, _DWORD *a2)
{
BOOL result; // eax
bool v3; // zf
struct _OSVERSIONINFOA VersionInformation; // [esp+8h] [ebp-98h]
std::string::operator=(a1, "unknown Windows version");
*a2 = 0;
VersionInformation.dwOSVersionInfoSize = 148;
result = GetVersionExA(&VersionInformation);
if ( result )
{
if ( VersionInformation.dwPlatformId != 1 )
{
if ( VersionInformation.dwPlatformId == 2 )
{
switch ( VersionInformation.dwMajorVersion )
{
case 3u:
if ( VersionInformation.dwMinorVersion == 51 )
{
std::string::operator=(a1, "Windows NT 3.51");
*a2 = 101;
}
break;
case 4u:
if ( !VersionInformation.dwMinorVersion )
{
std::string::operator=(a1, "Windows NT 4");
*a2 = 102;
}
break;
case 5u:
if ( VersionInformation.dwMinorVersion )
{
if ( VersionInformation.dwMinorVersion == 1 )
{
std::string::operator=(a1, "Windows XP");
*a2 = 104;
}
}
else
{
std::string::operator=(a1, "Windows 2000");
*a2 = 103;
}
break;
}
}
else if ( VersionInformation.dwPlatformId == 3 )
{
std::string::operator=(a1, "Windows CE");
*a2 = 201;
}
goto LABEL_35;
}
if ( VersionInformation.dwMajorVersion == 4 )
{
v3 = VersionInformation.dwMinorVersion == 10;
if ( VersionInformation.dwMinorVersion < 0xA )
{
if ( LOWORD(VersionInformation.dwBuildNumber) == 950 )
{
std::string::operator=(a1, "Windows 95");
*a2 = 1;
goto LABEL_35;
}
if ( (unsigned int)LOWORD(VersionInformation.dwBuildNumber) - 951 <= 0x81 )
{
std::string::operator=(a1, "Windows 95 SP1");
*a2 = 2;
goto LABEL_35;
}
if ( LOWORD(VersionInformation.dwBuildNumber) > 0x438u )
{
std::string::operator=(a1, "Windows 95 OSR2");
*a2 = 3;
goto LABEL_35;
}
v3 = VersionInformation.dwMinorVersion == 10;
}
if ( v3 )
{
if ( LOWORD(VersionInformation.dwBuildNumber) == 1998 )
{
std::string::operator=(a1, "Windows 98");
*a2 = 4;
}
else if ( (unsigned int)LOWORD(VersionInformation.dwBuildNumber) - 1999 > 0xB7 )
{
if ( LOWORD(VersionInformation.dwBuildNumber) >= 0x887u )
{
std::string::operator=(a1, "Windows 98 SE");
*a2 = 6;
}
}
else
{
std::string::operator=(a1, "Windows 98 SP1");
*a2 = 5;
}
}
else if ( VersionInformation.dwMinorVersion == 90 )
{
std::string::operator=(a1, "Windows ME");
*a2 = 7;
}
}
LABEL_35:
result = 1;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment