Skip to content

Commit

Permalink
Merge pull request #29 from ModOrganizer2/Develop
Browse files Browse the repository at this point in the history
Stage for release 2.2.2
  • Loading branch information
LostDragonist authored Jan 6, 2020
2 parents de611de + cfb0132 commit 3b2acde
Show file tree
Hide file tree
Showing 41 changed files with 996 additions and 265 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@
*.vcxproj.user
msbuild.log

/stderr.log
/stderr_32.log
/stdout.log
/stdout_32.log
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
version: 1.0.{build}
image: Visual Studio 2019 Preview
image: Visual Studio 2019
configuration: Release
platform:
- x64
- x86
environment:
GTEST_PATH: C:\Libraries\googletest
BOOST_PATH: C:\Libraries\boost_1_70_0
BOOST_PATH: C:\Libraries\boost_1_71_0
WEBHOOK_URL:
secure: gOKbXaZM9ImtMD5XrYITvdyZUW/az082G9OIN1EC1VZ2CuYaUUM6WY2eiNxaFeOL7/9Jyu/m+Vm1fH54CEyigcUUaxA7d8F5IMWlOgE/7YYdaAFSMUTFD7EK+++3FBYfmU1F/nZ61wsiWE6hB9Au5FpGBSCeQ0Tf8U8m0ybPmD0=
before_build:
- 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"
- 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"
build:
project: vsbuild/usvfs.sln
parallel: true
Expand Down
104 changes: 104 additions & 0 deletions include/sharedparameters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#pragma once

#include "usvfsparameters.h"
#include "dllimport.h"
#include <shared_memory.h>

#include <string>
#include <boost/interprocess/containers/string.hpp>
#include <boost/interprocess/containers/flat_set.hpp>
#include <boost/interprocess/containers/slist.hpp>

namespace usvfs
{

class ForcedLibrary
{
public:
ForcedLibrary(
const std::string& processName, const std::string& libraryPath,
const shared::VoidAllocatorT &allocator);

std::string processName() const;
std::string libraryPath() const;

private:
shared::StringT m_processName;
shared::StringT m_libraryPath;
};


class DLLEXPORT SharedParameters
{
public:
SharedParameters() = delete;
SharedParameters(const SharedParameters &reference) = delete;
SharedParameters &operator=(const SharedParameters &reference) = delete;

SharedParameters(const usvfsParameters& reference,
const shared::VoidAllocatorT &allocator);

usvfsParameters makeLocal() const;

std::string instanceName() const;
std::string currentSHMName() const;
std::string currentInverseSHMName() const;
void setSHMNames(const std::string& current, const std::string& inverse);

void setDebugParameters(
LogLevel level, CrashDumpsType dumpType, const std::string& dumpPath,
std::chrono::milliseconds delayProcess);

std::size_t userConnected();
std::size_t userDisconnected();
std::size_t userCount();

std::size_t registeredProcessCount() const;
std::vector<DWORD> registeredProcesses() const;
void registerProcess(DWORD pid);
void unregisterProcess(DWORD pid);

void blacklistExecutable(const std::string& name);
void clearExecutableBlacklist();
bool executableBlacklisted(const std::string& app, const std::string& cmd) const;

void addForcedLibrary(const std::string& process, const std::string& path);
std::vector<std::string> forcedLibraries(const std::string& processName);
void clearForcedLibraries();

private:
using StringAllocatorT =
shared::VoidAllocatorT::rebind<shared::StringT>::other;

using DWORDAllocatorT = shared::VoidAllocatorT::rebind<DWORD>::other;

using ForcedLibraryAllocatorT =
shared::VoidAllocatorT::rebind<ForcedLibrary>::other;


using ProcessBlacklist = boost::container::flat_set<
shared::StringT, std::less<shared::StringT>, StringAllocatorT>;

using ProcessList = boost::container::flat_set<
DWORD, std::less<DWORD>, DWORDAllocatorT>;

using ForcedLibraries = boost::container::slist<
ForcedLibrary, ForcedLibraryAllocatorT>;


mutable bi::interprocess_mutex m_mutex;
shared::StringT m_instanceName;
shared::StringT m_currentSHMName;
shared::StringT m_currentInverseSHMName;
bool m_debugMode;
LogLevel m_logLevel;
CrashDumpsType m_crashDumpsType;
shared::StringT m_crashDumpsPath;
std::chrono::milliseconds m_delayProcess;
uint32_t m_userCount;
ProcessBlacklist m_processBlacklist;
ProcessList m_processList;
ForcedLibraries m_forcedLibraries;
};

} // namespace
39 changes: 33 additions & 6 deletions include/usvfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,20 @@ DLLEXPORT BOOL WINAPI VirtualLinkDirectoryStatic(LPCWSTR source, LPCWSTR destina
* connect to a virtual filesystem as a controller, without hooking the calling process. Please note that
* you can only be connected to one vfs, so this will silently disconnect from a previous vfs.
*/
[[deprecated("deprecated, use usvfsConnectVFS()")]]
DLLEXPORT BOOL WINAPI ConnectVFS(const USVFSParameters *parameters);

DLLEXPORT BOOL WINAPI usvfsConnectVFS(const usvfsParameters* p);

/**
* @brief create a new VFS. This is similar to ConnectVFS except it guarantees
* the vfs is reset before use.
*/
[[deprecated("deprecated, use usvfsCreateVFS()")]]
DLLEXPORT BOOL WINAPI CreateVFS(const USVFSParameters *parameters);

DLLEXPORT BOOL WINAPI usvfsCreateVFS(const usvfsParameters* p);

/**
* disconnect from a virtual filesystem. This removes hooks if necessary
*/
Expand All @@ -100,6 +106,20 @@ DLLEXPORT void WINAPI GetCurrentVFSName(char *buffer, size_t size);
*/
DLLEXPORT BOOL WINAPI GetVFSProcessList(size_t *count, LPDWORD processIDs);

// retrieve a list of all processes connected to the vfs, stores an array
// of `count` elements in `*buffer`
//
// if this returns TRUE and `count` is not 0, the caller must release the buffer
// with `free(*buffer)`
//
// return values:
// - ERROR_INVALID_PARAMETERS: either `count` or `buffer` is NULL
// - ERROR_TOO_MANY_OPEN_FILES: there seems to be way too many usvfs processes
// running, probably some internal error
// - ERROR_NOT_ENOUGH_MEMORY: malloc() failed
//
DLLEXPORT BOOL WINAPI GetVFSProcessList2(size_t* count, DWORD** buffer);

/**
* spawn a new process that can see the virtual file system. The signature is identical to CreateProcess
*/
Expand All @@ -117,11 +137,6 @@ DLLEXPORT BOOL WINAPI CreateProcessHooked(
*/
DLLEXPORT bool WINAPI GetLogMessages(LPSTR buffer, size_t size, bool blocking = false);

/**
* @brief Used to change parameters which can be changed in runtime
*/
DLLEXPORT void WINAPI USVFSUpdateParams(LogLevel level, CrashDumpsType type);

/**
* retrieves a readable representation of the vfs tree
* @param buffer the buffer to write to. this may be null if you only want to determine the required
Expand Down Expand Up @@ -170,14 +185,26 @@ DLLEXPORT void WINAPI InitLogging(bool toLocal = false);
*/
DLLEXPORT void __cdecl InitHooks(LPVOID userData, size_t userDataSize);


[[deprecated("deprecated, use usvfsCreateParameters()")]]
DLLEXPORT void WINAPI USVFSInitParameters(USVFSParameters *parameters,
const char *instanceName,
bool debugMode,
LogLevel logLevel,
CrashDumpsType crashDumpsType,
const char *crashDumpsPath);

/**
* @brief Used to change parameters which can be changed in runtime
*/
[[deprecated("deprecated, use usvfsUpdateParameters()")]]
DLLEXPORT void WINAPI USVFSUpdateParams(LogLevel level, CrashDumpsType type);

// the instance and shm names are not updated
//
DLLEXPORT void WINAPI usvfsUpdateParameters(usvfsParameters* p);

DLLEXPORT int WINAPI CreateMiniDump(PEXCEPTION_POINTERS exceptionPtrs, CrashDumpsType type, const wchar_t* dumpPath);

DLLEXPORT const char* WINAPI USVFSVersionString();

}
2 changes: 1 addition & 1 deletion include/usvfs_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define USVFS_VERSION_MAJOR 0
#define USVFS_VERSION_MINOR 4
#define USVFS_VERSION_BUILD 4
#define USVFS_VERSION_REVISION 0
#define USVFS_VERSION_REVISION 6

#define USVFS_BUILD_STRING ""
#define USVFS_BUILD_WSTRING L""
Expand Down
24 changes: 23 additions & 1 deletion include/usvfsparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ along with usvfs. If not, see <http://www.gnu.org/licenses/>.

#include "logging.h"
#include "dllimport.h"
#include <chrono>

enum class CrashDumpsType : uint8_t {
None,
Expand All @@ -30,8 +31,11 @@ enum class CrashDumpsType : uint8_t {
Full
};

extern "C" {
extern "C"
{

// deprecated, use usvfsParameters and usvfsCreateParameters()
//
struct USVFSParameters {
char instanceName[65];
char currentSHMName[65];
Expand All @@ -42,4 +46,22 @@ struct USVFSParameters {
char crashDumpsPath[260];
};


struct usvfsParameters;

DLLEXPORT usvfsParameters* usvfsCreateParameters();
DLLEXPORT usvfsParameters* usvfsDupeParameters(usvfsParameters* p);
DLLEXPORT void usvfsCopyParameters(const usvfsParameters* source, usvfsParameters* dest);
DLLEXPORT void usvfsFreeParameters(usvfsParameters* p);

DLLEXPORT void usvfsSetInstanceName(usvfsParameters* p, const char* name);
DLLEXPORT void usvfsSetDebugMode(usvfsParameters* p, BOOL debugMode);
DLLEXPORT void usvfsSetLogLevel(usvfsParameters* p, LogLevel level);
DLLEXPORT void usvfsSetCrashDumpType(usvfsParameters* p, CrashDumpsType type);
DLLEXPORT void usvfsSetCrashDumpPath(usvfsParameters* p, const char* path);
DLLEXPORT void usvfsSetProcessDelay(usvfsParameters* p, int milliseconds);

DLLEXPORT const char* usvfsLogLevelToString(LogLevel lv);
DLLEXPORT const char* usvfsCrashDumpTypeToString(CrashDumpsType t);

}
37 changes: 37 additions & 0 deletions include/usvfsparametersprivate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once
#include "usvfsparameters.h"

struct usvfsParameters
{
char instanceName[65];
char currentSHMName[65];
char currentInverseSHMName[65];
bool debugMode;
LogLevel logLevel{LogLevel::Debug};
CrashDumpsType crashDumpsType{CrashDumpsType::None};
char crashDumpsPath[260];
int delayProcessMs;

usvfsParameters();
usvfsParameters(const usvfsParameters&) = default;
usvfsParameters& operator=(const usvfsParameters&) = default;

usvfsParameters(
const char* instanceName,
const char* currentSHMName,
const char* currentInverseSHMName,
bool debugMode,
LogLevel logLevel,
CrashDumpsType crashDumpsType,
const char* crashDumpsPath,
int delayProcessMs);

usvfsParameters(const USVFSParameters& oldParams);

void setInstanceName(const char* name);
void setDebugMode(bool debugMode);
void setLogLevel(LogLevel level);
void setCrashDumpType(CrashDumpsType type);
void setCrashDumpPath(const char* path);
void setProcessDelay(int milliseconds);
};
2 changes: 1 addition & 1 deletion src/shared/test_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace test {
FILE* m_f;
};

using std::experimental::filesystem::path;
using std::filesystem::path;

// path functions assume they are called by a test executable
// (calculate the requested path relative to the current executable path)
Expand Down
Loading

0 comments on commit 3b2acde

Please sign in to comment.