# HG changeset patch # User Andre Heinecke # Date 1397494661 0 # Node ID d10d9bc2e84f51dafeef5175dd83b790d04bac9b # Parent 857ae1ffdd6fb33764ea51894db290a526e10859 Update Windows api usage. Warning: To build on windows you need a shell32.dll with SHGetKnownFolder diff -r 857ae1ffdd6f -r d10d9bc2e84f CMakeLists.txt --- a/CMakeLists.txt Sat Apr 12 17:20:30 2014 +0200 +++ b/CMakeLists.txt Mon Apr 14 16:57:41 2014 +0000 @@ -54,6 +54,12 @@ set(PROFILING_LIBS gcov) endif() +if(WIN32) + add_definitions(-D_WIN32_WINNT=0x0600) # Windows vista + add_definitions(-DWINVER=0x0600) + add_definitions(-DMINGW_HAS_SECURE_API) # for _s functions +endif(WIN32) + if(UNIX) set(HARDENING_FLAGS " ${HARDENING_FLAGS} -pie -fPIE -ftrapv") set(HARDENING_FLAGS " ${HARDENING_FLAGS} -Wl,-z,relro,-z,now") diff -r 857ae1ffdd6f -r d10d9bc2e84f cinst/CMakeLists.txt --- a/cinst/CMakeLists.txt Sat Apr 12 17:20:30 2014 +0200 +++ b/cinst/CMakeLists.txt Mon Apr 14 16:57:41 2014 +0000 @@ -13,7 +13,7 @@ add_executable(cinst ${CINST_SOURCES}) if (WIN32) - set(WIN_EXTRA_LIBS -lcrypt32 -luserenv) + set(WIN_EXTRA_LIBS -lcrypt32 -luserenv -lshell32) endif(WIN32) target_link_libraries(cinst diff -r 857ae1ffdd6f -r d10d9bc2e84f cinst/nssstore_win.c --- a/cinst/nssstore_win.c Sat Apr 12 17:20:30 2014 +0200 +++ b/cinst/nssstore_win.c Mon Apr 14 16:57:41 2014 +0000 @@ -158,8 +158,8 @@ cmd_line_len = wcslen (lpApplicationName) + wcslen(selection_file) + 1; lpCommandLine = xmalloc (cmd_line_len * sizeof(wchar_t)); - wcscpy (lpCommandLine, lpApplicationName); - wcscat (lpCommandLine, selection_file); + wcscpy_s (lpCommandLine, cmd_line_len, lpApplicationName); + wcscat_s (lpCommandLine, cmd_line_len, selection_file); success = CreateProcessAsUserW (hToken, lpApplicationName, @@ -201,7 +201,7 @@ * This creates a security attributes structure that restricts * write access to the Administrators group but allows everyone to read files * in that directory. - * Basically a very complicated vetrsion of mkdir path -m 604 + * Basically a very complicated version of mkdir path -m 644 * * If the directory exists the permissions of that directory are checked if * they are acceptable and true or false is returned accordingly. @@ -365,16 +365,11 @@ /* TODO */ } -#if 0 - result = SHGetKnownFolderPath (FOLDERID_ProgramData, /* Get program data dir */ + result = SHGetKnownFolderPath (&FOLDERID_ProgramData, /* Get program data dir */ KF_FLAG_CREATE | /* Create if it does not exist */ KF_FLAG_INIT, /* Initialize it if created */ - -1, /* Get it for the default user */ + INVALID_HANDLE_VALUE, /* Get it for the default user */ &folder_name); -#endif - /* TODO figure out how to do this with mingw */ - result = S_OK; - folder_name = L"C:\\ProgramData"; if (result != S_OK) { @@ -394,12 +389,12 @@ } path = xmalloc (path_len * sizeof (wchar_t)); - if (wcscpy (path, folder_name) != 0) + if (wcscpy_s (path, path_len, folder_name) != 0) { ERRORPRINTF ("Failed to copy folder name.\n"); -#if 0 + CoTaskMemFree (folder_name); -#endif + return NULL; } @@ -407,14 +402,14 @@ CoTaskMemFree (folder_name); #endif - if (wcscat (path, L"\\") != 0) + if (wcscat_s (path, path_len, L"\\") != 0) { ERRORPRINTF ("Failed to cat dirsep.\n"); xfree(path); return NULL; } - if (wcscat (path, APPNAME) != 0) + if (wcscat_s (path, path_len, APPNAME) != 0) { ERRORPRINTF ("Failed to cat appname.\n"); xfree(path); @@ -432,14 +427,14 @@ return NULL; } - if (wcscat (path, L"\\") != 0) + if (wcscat_s (path, path_len, L"\\") != 0) { ERRORPRINTF ("Failed to cat dirsep.\n"); xfree(path); return NULL; } - if (wcscat (path, SELECTION_FILE_NAME) != 0) + if (wcscat_s (path, path_len, SELECTION_FILE_NAME) != 0) { ERRORPRINTF ("Failed to cat filename.\n"); xfree(path);