New upstream version 0.16.2+dfsg1

This commit is contained in:
Sebastian Ramacher 2016-10-10 21:01:40 +02:00
parent 67704ac59c
commit 6efda2859e
377 changed files with 7938 additions and 696 deletions

View file

@ -84,9 +84,24 @@ void *os_dlopen(const char *path)
if (wpath_slash)
SetDllDirectoryW(NULL);
if (!h_library)
blog(LOG_INFO, "LoadLibrary failed for '%s', error: %ld",
path, GetLastError());
if (!h_library) {
DWORD error = GetLastError();
char *message = NULL;
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, error,
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
(LPSTR)&message, 0, NULL);
blog(LOG_INFO, "LoadLibrary failed for '%s': %s (%lu)",
path, message, error);
if (message)
LocalFree(message);
}
return h_library;
}
@ -717,7 +732,7 @@ bool get_dll_ver(const wchar_t *lib, struct win_version_info *ver_info)
}
data = bmalloc(size);
if (!get_file_version_info(L"kernel32", 0, size, data)) {
if (!get_file_version_info(lib, 0, size, data)) {
blog(LOG_ERROR, "Failed to get windows version info");
bfree(data);
return false;
@ -739,6 +754,8 @@ bool get_dll_ver(const wchar_t *lib, struct win_version_info *ver_info)
return true;
}
#define WINVER_REG_KEY L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
void get_win_ver(struct win_version_info *info)
{
static struct win_version_info ver = {0};
@ -750,6 +767,26 @@ void get_win_ver(struct win_version_info *info)
if (!got_version) {
get_dll_ver(L"kernel32", &ver);
got_version = true;
if (ver.major == 10 && ver.revis == 0) {
HKEY key;
DWORD size, win10_revision;
LSTATUS status;
status = RegOpenKeyW(HKEY_LOCAL_MACHINE,
WINVER_REG_KEY, &key);
if (status != ERROR_SUCCESS)
return;
size = sizeof(win10_revision);
status = RegQueryValueExW(key, L"UBR", NULL, NULL,
(LPBYTE)&win10_revision, &size);
if (status == ERROR_SUCCESS)
ver.revis = (int)win10_revision;
RegCloseKey(key);
}
}
*info = ver;

View file

@ -164,7 +164,6 @@ size_t os_fread_mbs(FILE *file, char **pstr)
size_t os_fread_utf8(FILE *file, char **pstr)
{
size_t size = 0;
size_t size_read;
size_t len = 0;
*pstr = NULL;
@ -177,11 +176,13 @@ size_t os_fread_utf8(FILE *file, char **pstr)
char *utf8str;
off_t offset;
bom[0] = 0;
bom[1] = 0;
bom[2] = 0;
/* remove the ghastly BOM if present */
fseek(file, 0, SEEK_SET);
size_read = fread(bom, 1, 3, file);
if (size_read != 3)
return 0;
fread(bom, 1, 3, file);
offset = (astrcmp_n(bom, "\xEF\xBB\xBF", 3) == 0) ? 3 : 0;