diff --git a/winver.py b/winver.py index 8346f8f..e239690 100644 --- a/winver.py +++ b/winver.py @@ -25,30 +25,25 @@ def getWindowsVersion(path): if(os.path.isfile(getWindowsDirectory(path) + "/System32/ntdll.dll")): version = "" pe = pefile.PE(getWindowsDirectory(path) + "/System32/ntdll.dll") - for entry in pe.FileInfo: - if hasattr(entry, 'StringTable'): - for st in entry.StringTable: - for k, v in st.entries.items(): - if k == "ProductVersion": - version = v - if re.match("(3|4)\.",version) != None: - return _WIN_NT - elif re.match("5\.0", version) != None: - return _WIN_2k - elif re.match("5\.1", version) != None: - return _WIN_XP - elif re.match("5\.2", version) != None: - return _WIN_2k3 - elif re.match("6\.0", version) != None: - return _WIN_VISTA - elif re.match("6\.1", version) != None: - return _WIN_7 - elif re.match("6\.2", version) != None: - return _WIN_8 - elif re.match("6\.3", version) != None: - return _WIN_81 - elif re.match("10\.", version) != None: - return _WIN_10 + version = str(pe.FileInfo[0].StringTable[0].entries[b'ProductVersion'],'utf-8') + if re.match("(3|4)\.",version) != None: + return _WIN_NT + elif re.match("5\.0", version) != None: + return _WIN_2k + elif re.match("5\.1", version) != None: + return _WIN_XP + elif re.match("5\.2", version) != None: + return _WIN_2k3 + elif re.match("6\.0", version) != None: + return _WIN_VISTA + elif re.match("6\.1", version) != None: + return _WIN_7 + elif re.match("6\.2", version) != None: + return _WIN_8 + elif re.match("6\.3", version) != None: + return _WIN_81 + elif re.match("10\.", version) != None: + return _WIN_10 else: if(os.path.isfile(getWindowsDirectory(path) + "/CLASSES.DAT")): return _WIN_ME @@ -84,4 +79,6 @@ def getUserProfiles(path): profiles.append(profilepath + "/" + elem) return profiles - pass \ No newline at end of file + pass + +