Skip to content

Commit 3b2acde

Browse files
Merge pull request #29 from ModOrganizer2/Develop
Stage for release 2.2.2
2 parents de611de + cfb0132 commit 3b2acde

41 files changed

Lines changed: 996 additions & 265 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@
1919
*.vcxproj.user
2020
msbuild.log
2121

22+
/stderr.log
23+
/stderr_32.log
24+
/stdout.log
25+
/stdout_32.log

appveyor.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
version: 1.0.{build}
2-
image: Visual Studio 2019 Preview
2+
image: Visual Studio 2019
33
configuration: Release
44
platform:
55
- x64
66
- x86
77
environment:
88
GTEST_PATH: C:\Libraries\googletest
9-
BOOST_PATH: C:\Libraries\boost_1_70_0
9+
BOOST_PATH: C:\Libraries\boost_1_71_0
1010
WEBHOOK_URL:
1111
secure: gOKbXaZM9ImtMD5XrYITvdyZUW/az082G9OIN1EC1VZ2CuYaUUM6WY2eiNxaFeOL7/9Jyu/m+Vm1fH54CEyigcUUaxA7d8F5IMWlOgE/7YYdaAFSMUTFD7EK+++3FBYfmU1F/nZ61wsiWE6hB9Au5FpGBSCeQ0Tf8U8m0ybPmD0=
1212
before_build:
13-
- ps: "echo $env:Platform\nif (${env:Platform} -eq \"x64\") {\n set-item -path Env:BOOST_LIBPATH -value ${Env:BOOST_PATH}\\lib64-msvc-14.1\n set-item -path Env:GTEST_BUILDDIR -value c:\\libraries\\googletest\\build \n}\nElse {\n set-item -path Env:BOOST_LIBPATH -value ${Env:BOOST_PATH}\\lib32-msvc-14.1\n set-item -path Env:GTEST_BUILDDIR -value c:\\libraries\\googletest\\build_32\n}\n\n. git clone --depth=1 --branch=master https://github.com/google/googletest.git c:\\libraries\\googletest 2> $null\nNew-Item $Env:GTEST_BUILDDIR -type directory\nSet-Location -Path $Env:GTEST_BUILDDIR\n. cmd /c \"`\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat`\" $env:Platform && cmake -G `\"NMake Makefiles`\" -DCMAKE_BUILD_TYPE=Release ..`\"\"\n. cmd /c \"`\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat`\" $env:Platform && nmake\"\n\nSet-Location -Path c:\\projects\\usvfs\\vsbuild\n#Tempory fix due to that appveyor has boost lib files in a custom output folder\nGet-ChildItem -Path *.props -recurse | ForEach {If (Get-Content $_.FullName | Select-String -Pattern '\\$\\(BOOST_PATH\\)\\\\.*\\\\lib') {(Get-Content $_ | ForEach {$_ -replace '\\$\\(BOOST_PATH\\)\\\\.*\\\\lib', \"$Env:BOOST_LIBPATH\"}) | Set-Content $_ }}\n\n#Need to tell usvfs to not use the BOOST_BUILDID\nGet-ChildItem -Path *.props -recurse | ForEach {If (Get-Content $_.FullName | Select-String -Pattern 'BOOST_LIB_BUILDID=x86;') {(Get-Content $_ | ForEach {$_ -replace 'BOOST_LIB_BUILDID=x86;', \"\"}) | Set-Content $_ }}\n\nSet-Location -Path c:\\projects\\usvfs\ngit submodule -q update --init --recursive"
13+
- ps: "echo $env:Platform\nif (${env:Platform} -eq \"x64\") {\n set-item -path Env:BOOST_LIBPATH -value ${Env:BOOST_PATH}\\lib64-msvc-14.2\n set-item -path Env:GTEST_BUILDDIR -value c:\\libraries\\googletest\\build \n}\nElse {\n set-item -path Env:BOOST_LIBPATH -value ${Env:BOOST_PATH}\\lib32-msvc-14.2\n set-item -path Env:GTEST_BUILDDIR -value c:\\libraries\\googletest\\build_32\n}\n\n. git clone --depth=1 --branch=master https://github.com/google/googletest.git c:\\libraries\\googletest 2> $null\nNew-Item $Env:GTEST_BUILDDIR -type directory\nSet-Location -Path $Env:GTEST_BUILDDIR\n. cmd /c \"`\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat`\" $env:Platform && cmake -G `\"NMake Makefiles`\" -DCMAKE_BUILD_TYPE=Release ..`\"\"\n. cmd /c \"`\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat`\" $env:Platform && nmake\"\n\nSet-Location -Path c:\\projects\\usvfs\\vsbuild\n#Tempory fix due to that appveyor has boost lib files in a custom output folder\nGet-ChildItem -Path *.props -recurse | ForEach {If (Get-Content $_.FullName | Select-String -Pattern '\\$\\(BOOST_PATH\\)\\\\.*\\\\lib') {(Get-Content $_ | ForEach {$_ -replace '\\$\\(BOOST_PATH\\)\\\\.*\\\\lib', \"$Env:BOOST_LIBPATH\"}) | Set-Content $_ }}\n\n#Need to tell usvfs to not use the BOOST_BUILDID\nGet-ChildItem -Path *.props -recurse | ForEach {If (Get-Content $_.FullName | Select-String -Pattern 'BOOST_LIB_BUILDID=x86;') {(Get-Content $_ | ForEach {$_ -replace 'BOOST_LIB_BUILDID=x86;', \"\"}) | Set-Content $_ }}\n\nSet-Location -Path c:\\projects\\usvfs\ngit submodule -q update --init --recursive"
1414
build:
1515
project: vsbuild/usvfs.sln
1616
parallel: true

include/sharedparameters.h

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#pragma once
2+
3+
#include "usvfsparameters.h"
4+
#include "dllimport.h"
5+
#include <shared_memory.h>
6+
7+
#include <string>
8+
#include <boost/interprocess/containers/string.hpp>
9+
#include <boost/interprocess/containers/flat_set.hpp>
10+
#include <boost/interprocess/containers/slist.hpp>
11+
12+
namespace usvfs
13+
{
14+
15+
class ForcedLibrary
16+
{
17+
public:
18+
ForcedLibrary(
19+
const std::string& processName, const std::string& libraryPath,
20+
const shared::VoidAllocatorT &allocator);
21+
22+
std::string processName() const;
23+
std::string libraryPath() const;
24+
25+
private:
26+
shared::StringT m_processName;
27+
shared::StringT m_libraryPath;
28+
};
29+
30+
31+
class DLLEXPORT SharedParameters
32+
{
33+
public:
34+
SharedParameters() = delete;
35+
SharedParameters(const SharedParameters &reference) = delete;
36+
SharedParameters &operator=(const SharedParameters &reference) = delete;
37+
38+
SharedParameters(const usvfsParameters& reference,
39+
const shared::VoidAllocatorT &allocator);
40+
41+
usvfsParameters makeLocal() const;
42+
43+
std::string instanceName() const;
44+
std::string currentSHMName() const;
45+
std::string currentInverseSHMName() const;
46+
void setSHMNames(const std::string& current, const std::string& inverse);
47+
48+
void setDebugParameters(
49+
LogLevel level, CrashDumpsType dumpType, const std::string& dumpPath,
50+
std::chrono::milliseconds delayProcess);
51+
52+
std::size_t userConnected();
53+
std::size_t userDisconnected();
54+
std::size_t userCount();
55+
56+
std::size_t registeredProcessCount() const;
57+
std::vector<DWORD> registeredProcesses() const;
58+
void registerProcess(DWORD pid);
59+
void unregisterProcess(DWORD pid);
60+
61+
void blacklistExecutable(const std::string& name);
62+
void clearExecutableBlacklist();
63+
bool executableBlacklisted(const std::string& app, const std::string& cmd) const;
64+
65+
void addForcedLibrary(const std::string& process, const std::string& path);
66+
std::vector<std::string> forcedLibraries(const std::string& processName);
67+
void clearForcedLibraries();
68+
69+
private:
70+
using StringAllocatorT =
71+
shared::VoidAllocatorT::rebind<shared::StringT>::other;
72+
73+
using DWORDAllocatorT = shared::VoidAllocatorT::rebind<DWORD>::other;
74+
75+
using ForcedLibraryAllocatorT =
76+
shared::VoidAllocatorT::rebind<ForcedLibrary>::other;
77+
78+
79+
using ProcessBlacklist = boost::container::flat_set<
80+
shared::StringT, std::less<shared::StringT>, StringAllocatorT>;
81+
82+
using ProcessList = boost::container::flat_set<
83+
DWORD, std::less<DWORD>, DWORDAllocatorT>;
84+
85+
using ForcedLibraries = boost::container::slist<
86+
ForcedLibrary, ForcedLibraryAllocatorT>;
87+
88+
89+
mutable bi::interprocess_mutex m_mutex;
90+
shared::StringT m_instanceName;
91+
shared::StringT m_currentSHMName;
92+
shared::StringT m_currentInverseSHMName;
93+
bool m_debugMode;
94+
LogLevel m_logLevel;
95+
CrashDumpsType m_crashDumpsType;
96+
shared::StringT m_crashDumpsPath;
97+
std::chrono::milliseconds m_delayProcess;
98+
uint32_t m_userCount;
99+
ProcessBlacklist m_processBlacklist;
100+
ProcessList m_processList;
101+
ForcedLibraries m_forcedLibraries;
102+
};
103+
104+
} // namespace

include/usvfs.h

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,20 @@ DLLEXPORT BOOL WINAPI VirtualLinkDirectoryStatic(LPCWSTR source, LPCWSTR destina
8080
* connect to a virtual filesystem as a controller, without hooking the calling process. Please note that
8181
* you can only be connected to one vfs, so this will silently disconnect from a previous vfs.
8282
*/
83+
[[deprecated("deprecated, use usvfsConnectVFS()")]]
8384
DLLEXPORT BOOL WINAPI ConnectVFS(const USVFSParameters *parameters);
8485

86+
DLLEXPORT BOOL WINAPI usvfsConnectVFS(const usvfsParameters* p);
87+
8588
/**
8689
* @brief create a new VFS. This is similar to ConnectVFS except it guarantees
8790
* the vfs is reset before use.
8891
*/
92+
[[deprecated("deprecated, use usvfsCreateVFS()")]]
8993
DLLEXPORT BOOL WINAPI CreateVFS(const USVFSParameters *parameters);
9094

95+
DLLEXPORT BOOL WINAPI usvfsCreateVFS(const usvfsParameters* p);
96+
9197
/**
9298
* disconnect from a virtual filesystem. This removes hooks if necessary
9399
*/
@@ -100,6 +106,20 @@ DLLEXPORT void WINAPI GetCurrentVFSName(char *buffer, size_t size);
100106
*/
101107
DLLEXPORT BOOL WINAPI GetVFSProcessList(size_t *count, LPDWORD processIDs);
102108

109+
// retrieve a list of all processes connected to the vfs, stores an array
110+
// of `count` elements in `*buffer`
111+
//
112+
// if this returns TRUE and `count` is not 0, the caller must release the buffer
113+
// with `free(*buffer)`
114+
//
115+
// return values:
116+
// - ERROR_INVALID_PARAMETERS: either `count` or `buffer` is NULL
117+
// - ERROR_TOO_MANY_OPEN_FILES: there seems to be way too many usvfs processes
118+
// running, probably some internal error
119+
// - ERROR_NOT_ENOUGH_MEMORY: malloc() failed
120+
//
121+
DLLEXPORT BOOL WINAPI GetVFSProcessList2(size_t* count, DWORD** buffer);
122+
103123
/**
104124
* spawn a new process that can see the virtual file system. The signature is identical to CreateProcess
105125
*/
@@ -117,11 +137,6 @@ DLLEXPORT BOOL WINAPI CreateProcessHooked(
117137
*/
118138
DLLEXPORT bool WINAPI GetLogMessages(LPSTR buffer, size_t size, bool blocking = false);
119139

120-
/**
121-
* @brief Used to change parameters which can be changed in runtime
122-
*/
123-
DLLEXPORT void WINAPI USVFSUpdateParams(LogLevel level, CrashDumpsType type);
124-
125140
/**
126141
* retrieves a readable representation of the vfs tree
127142
* @param buffer the buffer to write to. this may be null if you only want to determine the required
@@ -170,14 +185,26 @@ DLLEXPORT void WINAPI InitLogging(bool toLocal = false);
170185
*/
171186
DLLEXPORT void __cdecl InitHooks(LPVOID userData, size_t userDataSize);
172187

173-
188+
[[deprecated("deprecated, use usvfsCreateParameters()")]]
174189
DLLEXPORT void WINAPI USVFSInitParameters(USVFSParameters *parameters,
175190
const char *instanceName,
176191
bool debugMode,
177192
LogLevel logLevel,
178193
CrashDumpsType crashDumpsType,
179194
const char *crashDumpsPath);
180195

196+
/**
197+
* @brief Used to change parameters which can be changed in runtime
198+
*/
199+
[[deprecated("deprecated, use usvfsUpdateParameters()")]]
200+
DLLEXPORT void WINAPI USVFSUpdateParams(LogLevel level, CrashDumpsType type);
201+
202+
// the instance and shm names are not updated
203+
//
204+
DLLEXPORT void WINAPI usvfsUpdateParameters(usvfsParameters* p);
205+
181206
DLLEXPORT int WINAPI CreateMiniDump(PEXCEPTION_POINTERS exceptionPtrs, CrashDumpsType type, const wchar_t* dumpPath);
182207

208+
DLLEXPORT const char* WINAPI USVFSVersionString();
209+
183210
}

include/usvfs_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define USVFS_VERSION_MAJOR 0
44
#define USVFS_VERSION_MINOR 4
55
#define USVFS_VERSION_BUILD 4
6-
#define USVFS_VERSION_REVISION 0
6+
#define USVFS_VERSION_REVISION 6
77

88
#define USVFS_BUILD_STRING ""
99
#define USVFS_BUILD_WSTRING L""

include/usvfsparameters.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ along with usvfs. If not, see <http://www.gnu.org/licenses/>.
2222

2323
#include "logging.h"
2424
#include "dllimport.h"
25+
#include <chrono>
2526

2627
enum class CrashDumpsType : uint8_t {
2728
None,
@@ -30,8 +31,11 @@ enum class CrashDumpsType : uint8_t {
3031
Full
3132
};
3233

33-
extern "C" {
34+
extern "C"
35+
{
3436

37+
// deprecated, use usvfsParameters and usvfsCreateParameters()
38+
//
3539
struct USVFSParameters {
3640
char instanceName[65];
3741
char currentSHMName[65];
@@ -42,4 +46,22 @@ struct USVFSParameters {
4246
char crashDumpsPath[260];
4347
};
4448

49+
50+
struct usvfsParameters;
51+
52+
DLLEXPORT usvfsParameters* usvfsCreateParameters();
53+
DLLEXPORT usvfsParameters* usvfsDupeParameters(usvfsParameters* p);
54+
DLLEXPORT void usvfsCopyParameters(const usvfsParameters* source, usvfsParameters* dest);
55+
DLLEXPORT void usvfsFreeParameters(usvfsParameters* p);
56+
57+
DLLEXPORT void usvfsSetInstanceName(usvfsParameters* p, const char* name);
58+
DLLEXPORT void usvfsSetDebugMode(usvfsParameters* p, BOOL debugMode);
59+
DLLEXPORT void usvfsSetLogLevel(usvfsParameters* p, LogLevel level);
60+
DLLEXPORT void usvfsSetCrashDumpType(usvfsParameters* p, CrashDumpsType type);
61+
DLLEXPORT void usvfsSetCrashDumpPath(usvfsParameters* p, const char* path);
62+
DLLEXPORT void usvfsSetProcessDelay(usvfsParameters* p, int milliseconds);
63+
64+
DLLEXPORT const char* usvfsLogLevelToString(LogLevel lv);
65+
DLLEXPORT const char* usvfsCrashDumpTypeToString(CrashDumpsType t);
66+
4567
}

include/usvfsparametersprivate.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#pragma once
2+
#include "usvfsparameters.h"
3+
4+
struct usvfsParameters
5+
{
6+
char instanceName[65];
7+
char currentSHMName[65];
8+
char currentInverseSHMName[65];
9+
bool debugMode;
10+
LogLevel logLevel{LogLevel::Debug};
11+
CrashDumpsType crashDumpsType{CrashDumpsType::None};
12+
char crashDumpsPath[260];
13+
int delayProcessMs;
14+
15+
usvfsParameters();
16+
usvfsParameters(const usvfsParameters&) = default;
17+
usvfsParameters& operator=(const usvfsParameters&) = default;
18+
19+
usvfsParameters(
20+
const char* instanceName,
21+
const char* currentSHMName,
22+
const char* currentInverseSHMName,
23+
bool debugMode,
24+
LogLevel logLevel,
25+
CrashDumpsType crashDumpsType,
26+
const char* crashDumpsPath,
27+
int delayProcessMs);
28+
29+
usvfsParameters(const USVFSParameters& oldParams);
30+
31+
void setInstanceName(const char* name);
32+
void setDebugMode(bool debugMode);
33+
void setLogLevel(LogLevel level);
34+
void setCrashDumpType(CrashDumpsType type);
35+
void setCrashDumpPath(const char* path);
36+
void setProcessDelay(int milliseconds);
37+
};

src/shared/test_helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace test {
6969
FILE* m_f;
7070
};
7171

72-
using std::experimental::filesystem::path;
72+
using std::filesystem::path;
7373

7474
// path functions assume they are called by a test executable
7575
// (calculate the requested path relative to the current executable path)

0 commit comments

Comments
 (0)