release
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
.vs/
|
||||
bin/
|
||||
obj/
|
||||
Debug/
|
||||
x64/
|
||||
*.user
|
||||
*.suo
|
||||
*.VC.db
|
||||
*.VC.opendb
|
||||
*.obj
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.iobj
|
||||
*.ilk
|
||||
*.exp
|
||||
*.lib
|
||||
*.tlog
|
||||
*.lastbuildstate
|
||||
*.recipe
|
||||
@@ -0,0 +1,46 @@
|
||||
# ScreenPrivacy
|
||||
|
||||
ScreenPrivacy é um plugin nativo para Notepad++ que oculta a janela inteira do editor em capturas de tela compatíveis com a proteção de conteúdo do Windows.
|
||||
|
||||
A proteção é global e inicia ativada automaticamente. O conteúdo permanece visível e editável no monitor local, mas não aparece em compartilhamentos ou capturas que respeitem `WDA_EXCLUDEFROMCAPTURE`.
|
||||
|
||||
## Requisitos
|
||||
|
||||
- Windows 10 versão 2004 ou superior, ou Windows 11;
|
||||
- Notepad++ x64.
|
||||
|
||||
## Instalação
|
||||
|
||||
1. Feche o Notepad++.
|
||||
2. Crie a pasta:
|
||||
|
||||
```text
|
||||
C:\Program Files\Notepad++\plugins\ScreenPrivacy
|
||||
```
|
||||
|
||||
3. Baixe `ScreenPrivacy.dll` na página de [Releases](https://git.raulbank.com/Master/ScreenPrivacy/releases) e copie o arquivo para essa pasta.
|
||||
4. Abra o Notepad++ novamente.
|
||||
|
||||
## Compilação
|
||||
|
||||
Instale o Visual Studio 2022 ou Visual Studio 2022 Build Tools com a workload `Desktop development with C++`, o MSVC v143 e um Windows 10/11 SDK.
|
||||
|
||||
Abra o Developer PowerShell for Visual Studio na pasta do projeto e execute:
|
||||
|
||||
```powershell
|
||||
msbuild ScreenPrivacy.sln /m /t:Rebuild /p:Configuration=Release /p:Platform=x64
|
||||
```
|
||||
|
||||
O DLL compilado será gerado em:
|
||||
|
||||
```text
|
||||
bin\Release\ScreenPrivacy.dll
|
||||
```
|
||||
|
||||
## Uso
|
||||
|
||||
A proteção inicia ligada. Para desativar ou reativar, use:
|
||||
|
||||
```text
|
||||
Plugins > ScreenPrivacy > Proteção global contra captura
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{BC8A1FFA-BEE3-4634-8014-F334798102B3}") = "ScreenPrivacy", "ScreenPrivacy.vcxproj", "{BD13C572-E131-489D-9667-D1BA520026EC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BD13C572-E131-489D-9667-D1BA520026EC}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BD13C572-E131-489D-9667-D1BA520026EC}.Debug|x64.Build.0 = Debug|x64
|
||||
{BD13C572-E131-489D-9667-D1BA520026EC}.Release|x64.ActiveCfg = Release|x64
|
||||
{BD13C572-E131-489D-9667-D1BA520026EC}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{BD13C572-E131-489D-9667-D1BA520026EC}</ProjectGuid>
|
||||
<RootNamespace>ScreenPrivacy</RootNamespace>
|
||||
<ProjectName>ScreenPrivacy</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings" />
|
||||
<ImportGroup Label="Shared" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<OutDir>$(SolutionDir)bin\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\</IntDir>
|
||||
<TargetName>ScreenPrivacy</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PreprocessorDefinitions>UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;NOMINMAX;_WIN32_WINNT=0x0A00;WINVER=0x0A00;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalOptions>/utf-8 /permissive- %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PreprocessorDefinitions>UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;NOMINMAX;_WIN32_WINNT=0x0A00;WINVER=0x0A00;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<AdditionalOptions>/utf-8 /permissive- %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AdditionalOptions>/DEBUG:NONE /NOCOFFGRPINFO /EMITTOOLVERSIONINFO:NO %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "$p='$(TargetPath)'; $b=[System.IO.File]::ReadAllBytes($p); $o=[BitConverter]::ToInt32($b,60); [Array]::Clear($b,$o+8,4); [Array]::Clear($b,$o+26,2); [System.IO.File]::WriteAllBytes($p,$b)"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\PluginApi.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\ScreenPrivacy.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
||||
constexpr UINT NPPMSG = WM_USER + 1000;
|
||||
constexpr UINT NPPM_SETMENUITEMCHECK = NPPMSG + 40;
|
||||
constexpr UINT NPPN_FIRST = 1000;
|
||||
constexpr UINT NPPN_READY = NPPN_FIRST + 1;
|
||||
constexpr UINT NPPN_SHUTDOWN = NPPN_FIRST + 9;
|
||||
|
||||
struct NppData
|
||||
{
|
||||
HWND nppHandle;
|
||||
HWND scintillaMainHandle;
|
||||
HWND scintillaSecondHandle;
|
||||
};
|
||||
|
||||
using PluginCommand = void(__cdecl*)();
|
||||
|
||||
struct ShortcutKey
|
||||
{
|
||||
bool isCtrl;
|
||||
bool isAlt;
|
||||
bool isShift;
|
||||
UCHAR key;
|
||||
};
|
||||
|
||||
struct FuncItem
|
||||
{
|
||||
wchar_t itemName[64];
|
||||
PluginCommand function;
|
||||
int commandId;
|
||||
bool checkedOnInit;
|
||||
ShortcutKey* shortcut;
|
||||
};
|
||||
|
||||
struct SCNotification
|
||||
{
|
||||
NMHDR header;
|
||||
};
|
||||
@@ -0,0 +1,171 @@
|
||||
#include "PluginApi.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr DWORD CaptureExcluded = 0x00000011;
|
||||
constexpr wchar_t PluginName[] = L"ScreenPrivacy";
|
||||
|
||||
NppData nppData{};
|
||||
DWORD originalAffinity = WDA_NONE;
|
||||
DWORD currentAffinity = WDA_NONE;
|
||||
bool affinityKnown = false;
|
||||
bool failureReported = false;
|
||||
bool protectionEnabled = true;
|
||||
|
||||
void toggleProtection();
|
||||
|
||||
FuncItem functions[] = {
|
||||
{L"Proteção global contra captura", toggleProtection, 0, true, nullptr}
|
||||
};
|
||||
|
||||
void showAffinityError(DWORD errorCode)
|
||||
{
|
||||
std::wstring message = L"Não foi possível alterar a proteção contra captura da janela do Notepad++.\n\nErro do Windows: ";
|
||||
message += std::to_wstring(errorCode);
|
||||
|
||||
wchar_t* systemMessage = nullptr;
|
||||
const DWORD length = FormatMessageW(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
nullptr,
|
||||
errorCode,
|
||||
0,
|
||||
reinterpret_cast<wchar_t*>(&systemMessage),
|
||||
0,
|
||||
nullptr
|
||||
);
|
||||
|
||||
if (length != 0 && systemMessage != nullptr)
|
||||
{
|
||||
message += L"\n";
|
||||
message.append(systemMessage, length);
|
||||
LocalFree(systemMessage);
|
||||
}
|
||||
|
||||
MessageBoxW(nppData.nppHandle, message.c_str(), PluginName, MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
bool setAffinity(DWORD affinity, bool reportFailure)
|
||||
{
|
||||
if (nppData.nppHandle == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (affinityKnown && currentAffinity == affinity)
|
||||
{
|
||||
failureReported = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
if (SetWindowDisplayAffinity(nppData.nppHandle, affinity) != FALSE)
|
||||
{
|
||||
currentAffinity = affinity;
|
||||
affinityKnown = true;
|
||||
failureReported = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (reportFailure && !failureReported)
|
||||
{
|
||||
failureReported = true;
|
||||
showAffinityError(GetLastError());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void setMenuCheck(bool checked)
|
||||
{
|
||||
SendMessageW(
|
||||
nppData.nppHandle,
|
||||
NPPM_SETMENUITEMCHECK,
|
||||
static_cast<WPARAM>(functions[0].commandId),
|
||||
static_cast<LPARAM>(checked ? TRUE : FALSE)
|
||||
);
|
||||
}
|
||||
|
||||
void toggleProtection()
|
||||
{
|
||||
const bool requestedState = !protectionEnabled;
|
||||
const DWORD requestedAffinity = requestedState ? CaptureExcluded : originalAffinity;
|
||||
if (setAffinity(requestedAffinity, true))
|
||||
{
|
||||
protectionEnabled = requestedState;
|
||||
setMenuCheck(protectionEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID)
|
||||
{
|
||||
if (reason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
DisableThreadLibraryCalls(module);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void setInfo(NppData data)
|
||||
{
|
||||
nppData = data;
|
||||
DWORD affinity = WDA_NONE;
|
||||
if (GetWindowDisplayAffinity(nppData.nppHandle, &affinity) != FALSE)
|
||||
{
|
||||
originalAffinity = affinity;
|
||||
currentAffinity = affinity;
|
||||
affinityKnown = true;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) const wchar_t* getName()
|
||||
{
|
||||
return PluginName;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) FuncItem* getFuncsArray(int* count)
|
||||
{
|
||||
if (count != nullptr)
|
||||
{
|
||||
*count = static_cast<int>(sizeof(functions) / sizeof(functions[0]));
|
||||
}
|
||||
return functions;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void beNotified(SCNotification* notification)
|
||||
{
|
||||
if (notification == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (notification->header.code)
|
||||
{
|
||||
case NPPN_READY:
|
||||
if (!setAffinity(CaptureExcluded, true))
|
||||
{
|
||||
protectionEnabled = false;
|
||||
}
|
||||
setMenuCheck(protectionEnabled);
|
||||
break;
|
||||
|
||||
case NPPN_SHUTDOWN:
|
||||
setAffinity(originalAffinity, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) LRESULT messageProc(UINT, WPARAM, LPARAM)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) BOOL isUnicode()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
Reference in New Issue
Block a user