mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[idd] helper: add clipboard file primitives
This commit is contained in:
1968
idd/LGIddHelper/CClipboardFiles.cpp
Normal file
1968
idd/LGIddHelper/CClipboardFiles.cpp
Normal file
File diff suppressed because it is too large
Load Diff
115
idd/LGIddHelper/CClipboardFiles.h
Normal file
115
idd/LGIddHelper/CClipboardFiles.h
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/**
|
||||||
|
* Looking Glass
|
||||||
|
* Copyright © 2017-2026 The Looking Glass Authors
|
||||||
|
* https://looking-glass.io
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
|
* Software Foundation; either version 2 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||||
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <ObjIdl.h>
|
||||||
|
#include <OleIdl.h>
|
||||||
|
#include <ShellAPI.h>
|
||||||
|
|
||||||
|
#include <common/KVMFRClipboard.h>
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct ClipboardRemoteFileEntry
|
||||||
|
{
|
||||||
|
uint64_t node = 0;
|
||||||
|
uint64_t parent = 0;
|
||||||
|
uint64_t size = 0;
|
||||||
|
uint64_t createdNs = 0;
|
||||||
|
uint64_t modifiedNs = 0;
|
||||||
|
KVMFRClipboardFileType type = KVMFR_CLIPBOARD_FILE_TYPE_REGULAR;
|
||||||
|
std::wstring name;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CLocalClipboardFiles final
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct Node
|
||||||
|
{
|
||||||
|
uint64_t id = 0;
|
||||||
|
uint64_t size = 0;
|
||||||
|
uint64_t createdNs = 0;
|
||||||
|
uint64_t modifiedNs = 0;
|
||||||
|
KVMFRClipboardFileType type = KVMFR_CLIPBOARD_FILE_TYPE_REGULAR;
|
||||||
|
std::wstring name;
|
||||||
|
std::wstring path;
|
||||||
|
bool childrenLoaded = false;
|
||||||
|
DWORD volumeSerial = 0;
|
||||||
|
DWORD fileIndexHigh = 0;
|
||||||
|
DWORD fileIndexLow = 0;
|
||||||
|
std::vector<uint64_t> children;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::mutex m_lock;
|
||||||
|
std::vector<Node> m_nodes;
|
||||||
|
std::vector<uint64_t> m_roots;
|
||||||
|
HANDLE m_userToken = nullptr;
|
||||||
|
bool m_published = false;
|
||||||
|
|
||||||
|
explicit CLocalClipboardFiles(HANDLE userToken);
|
||||||
|
bool AddRoot(const std::wstring& path, KVMFRClipboardFileError& error);
|
||||||
|
bool RefreshRoots(KVMFRClipboardFileError& error);
|
||||||
|
bool LoadChildren(size_t index, KVMFRClipboardFileError& error);
|
||||||
|
bool CaptureIdentity(Node& node, KVMFRClipboardFileError& error) const;
|
||||||
|
bool CheckIdentity(const Node& node, KVMFRClipboardFileError& error) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
~CLocalClipboardFiles();
|
||||||
|
|
||||||
|
CLocalClipboardFiles(const CLocalClipboardFiles&) = delete;
|
||||||
|
CLocalClipboardFiles& operator=(const CLocalClipboardFiles&) = delete;
|
||||||
|
|
||||||
|
static std::shared_ptr<CLocalClipboardFiles> Capture(HDROP drop,
|
||||||
|
KVMFRClipboardFileError& error);
|
||||||
|
|
||||||
|
size_t RootCount() const;
|
||||||
|
bool List(uint64_t node, std::vector<uint8_t>& data,
|
||||||
|
KVMFRClipboardFileError& error);
|
||||||
|
bool Read(uint64_t node, uint64_t offset, uint32_t length,
|
||||||
|
std::vector<uint8_t>& data, KVMFRClipboardFileError& error);
|
||||||
|
};
|
||||||
|
|
||||||
|
class IRemoteClipboardFileProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IRemoteClipboardFileProvider() = default;
|
||||||
|
|
||||||
|
virtual HRESULT ReadClipboardFile(uint64_t dataset, uint64_t acquisition,
|
||||||
|
uint64_t node, uint64_t offset, void * data, ULONG length,
|
||||||
|
ULONG& read) = 0;
|
||||||
|
virtual void ReleaseClipboardFileDataset(uint64_t dataset,
|
||||||
|
uint64_t acquisition) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
HRESULT ParseClipboardFileList(uint64_t parent, const uint8_t * data,
|
||||||
|
size_t length, std::vector<ClipboardRemoteFileEntry>& entries);
|
||||||
|
|
||||||
|
HRESULT CreateClipboardFileDataObject(uint64_t dataset, uint64_t acquisition,
|
||||||
|
std::vector<ClipboardRemoteFileEntry>&& entries,
|
||||||
|
std::shared_ptr<IRemoteClipboardFileProvider> provider,
|
||||||
|
IDataObject ** object);
|
||||||
@@ -187,10 +187,14 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
|||||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||||
<CallingConvention>StdCall</CallingConvention>
|
<CallingConvention>StdCall</CallingConvention>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>%(AdditionalDependencies);Ole32.lib;Shell32.lib;Wtsapi32.lib</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="CButton.cpp" />
|
<ClCompile Include="CButton.cpp" />
|
||||||
<ClCompile Include="CCheckbox.cpp" />
|
<ClCompile Include="CCheckbox.cpp" />
|
||||||
|
<ClCompile Include="CClipboardFiles.cpp" />
|
||||||
<ClCompile Include="CClipboardManager.cpp" />
|
<ClCompile Include="CClipboardManager.cpp" />
|
||||||
<ClCompile Include="CConfigWindow.cpp" />
|
<ClCompile Include="CConfigWindow.cpp" />
|
||||||
<ClCompile Include="CEditWidget.cpp" />
|
<ClCompile Include="CEditWidget.cpp" />
|
||||||
@@ -208,6 +212,7 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="CButton.h" />
|
<ClInclude Include="CButton.h" />
|
||||||
<ClInclude Include="CCheckbox.h" />
|
<ClInclude Include="CCheckbox.h" />
|
||||||
|
<ClInclude Include="CClipboardFiles.h" />
|
||||||
<ClInclude Include="CClipboardManager.h" />
|
<ClInclude Include="CClipboardManager.h" />
|
||||||
<ClInclude Include="CConfigWindow.h" />
|
<ClInclude Include="CConfigWindow.h" />
|
||||||
<ClInclude Include="CEditWidget.h" />
|
<ClInclude Include="CEditWidget.h" />
|
||||||
|
|||||||
@@ -60,6 +60,9 @@
|
|||||||
<ClCompile Include="CClipboardManager.cpp">
|
<ClCompile Include="CClipboardManager.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="CClipboardFiles.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="CPipeClient.h">
|
<ClInclude Include="CPipeClient.h">
|
||||||
@@ -104,6 +107,9 @@
|
|||||||
<ClInclude Include="CClipboardManager.h">
|
<ClInclude Include="CClipboardManager.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="CClipboardFiles.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="Resources.h">
|
<ClInclude Include="Resources.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
Reference in New Issue
Block a user