Init
This commit is contained in:
commit
9eae6bf202
|
|
@ -0,0 +1,8 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="CPP_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="elmot.OpenOcdPlugin">
|
||||
<option name="openOcdHome" value="/usr/local" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/RunImageVC.iml" filepath="$PROJECT_DIR$/.idea/RunImageVC.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<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>{031654c4-f73b-4465-8ec4-f4dc348fbb25}</ProjectGuid>
|
||||
<RootNamespace>InstallDrv</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>Run</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<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|Win32'">
|
||||
<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)'=='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" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Run.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Исходные файлы">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы заголовков">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Файлы ресурсов">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Run.c">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
tpo_mnz
|
||||
|
|
@ -0,0 +1,376 @@
|
|||
// InstallDrv.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
|
||||
//
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define bzero(b) (memset((b), '\0', sizeof(b)), (void) 0)
|
||||
|
||||
char volumeName[_MAX_PATH];
|
||||
|
||||
BOOL SetPrivilege(
|
||||
HANDLE hToken,
|
||||
LPCTSTR lpszPrivilege, // name of privilege to enable/disable
|
||||
BOOL bEnablePrivilege // to enable or disable privilege
|
||||
)
|
||||
{
|
||||
TOKEN_PRIVILEGES tp;
|
||||
LUID luid;
|
||||
|
||||
if (!LookupPrivilegeValue(
|
||||
NULL, // lookup privilege on local system
|
||||
lpszPrivilege, // privilege to lookup
|
||||
&luid)) // receives LUID of privilege
|
||||
{
|
||||
// printf("LookupPrivilegeValue error: %u\n", GetLastError() );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
tp.PrivilegeCount = 1;
|
||||
tp.Privileges[0].Luid = luid;
|
||||
if (bEnablePrivilege) {
|
||||
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
}
|
||||
else {
|
||||
tp.Privileges[0].Attributes = 0;
|
||||
}
|
||||
|
||||
// Enable the privilege or disable all privileges.
|
||||
|
||||
if (!AdjustTokenPrivileges(
|
||||
hToken,
|
||||
FALSE,
|
||||
&tp,
|
||||
sizeof(TOKEN_PRIVILEGES),
|
||||
(PTOKEN_PRIVILEGES)NULL,
|
||||
(PDWORD)NULL)) {
|
||||
// printf("AdjustTokenPrivileges error: %u\n", GetLastError() );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) {
|
||||
// printf("The token does not have the specified privilege. \n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int setSeDebug(HANDLE handleThreadId)
|
||||
{
|
||||
HANDLE hToken;
|
||||
if (!OpenThreadToken(handleThreadId,
|
||||
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
|
||||
FALSE,
|
||||
&hToken)
|
||||
) {
|
||||
if (GetLastError() == ERROR_NO_TOKEN) {
|
||||
if (!ImpersonateSelf(SecurityImpersonation)) {
|
||||
//Log2File("Error setting impersonation! [UnsetSeDebug()]", L_DEBUG);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!OpenThreadToken(handleThreadId,
|
||||
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
|
||||
FALSE,
|
||||
&hToken)
|
||||
) {
|
||||
//Log2File("Error Opening Thread Token! [UnsetSeDebug()]", L_DEBUG);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//now disable SeDebug
|
||||
if (!SetPrivilege(hToken, SE_DEBUG_NAME, TRUE)) {
|
||||
//Log2File("Error unsetting SeDebug Privilege [SetPrivilege()]", L_WARN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CloseHandle(hToken);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int runProcess(char* strDevcon, BOOL isVolume) {
|
||||
// char strDevcon[_MAX_PATH];
|
||||
// strcpy_s(strDevcon, _MAX_PATH, "1.bat ");
|
||||
|
||||
// for (int i = 1; i < argc; ++i) {
|
||||
// strcat_s(strDevcon, _MAX_PATH, argv[i]);
|
||||
// strcat_s(strDevcon, _MAX_PATH, " ");
|
||||
// }
|
||||
|
||||
char buf[1024 * 10]; //буфер ввода/вывода
|
||||
|
||||
PROCESS_INFORMATION piProcInfo;
|
||||
STARTUPINFOA siStartInfo;
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
SECURITY_DESCRIPTOR sd; //структура security для пайпов
|
||||
HANDLE newstdin, newstdout, read_stdout, write_stdin; //дескрипторы пайпов
|
||||
|
||||
// if (IsWinNT()) //инициализация security для Windows NT
|
||||
// {
|
||||
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
|
||||
SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
|
||||
sa.lpSecurityDescriptor = &sd;
|
||||
// }
|
||||
|
||||
// else sa.lpSecurityDescriptor = NULL;
|
||||
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.bInheritHandle = TRUE; //разрешаем наследование дескрипторов
|
||||
|
||||
if (!CreatePipe(&newstdin, &write_stdin, &sa, 0)) //создаем пайп
|
||||
{
|
||||
printf("Error creating input channel");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!CreatePipe(&read_stdout, &newstdout, &sa, 0)) //создаем пайп
|
||||
// для stdout
|
||||
{
|
||||
printf("Error creating output channel");
|
||||
|
||||
CloseHandle(newstdin);
|
||||
CloseHandle(write_stdin);
|
||||
return 1;
|
||||
}
|
||||
ZeroMemory(&siStartInfo, sizeof(siStartInfo));
|
||||
ZeroMemory(&piProcInfo, sizeof(piProcInfo));
|
||||
GetStartupInfoA(&siStartInfo); //создаем startupinfo для дочернего процесса
|
||||
siStartInfo.cb = sizeof(STARTUPINFO);
|
||||
siStartInfo.wShowWindow = SW_HIDE; //прячем окно
|
||||
siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
|
||||
// siStartInfo.lpDesktop = NULL;
|
||||
siStartInfo.hStdOutput = newstdout;
|
||||
siStartInfo.hStdError = newstdout; //подменяем дескрипторы для
|
||||
siStartInfo.hStdInput = newstdin; // дочернего процесса
|
||||
//char app_spawn[] = "devcon.exe";
|
||||
|
||||
|
||||
int result = CreateProcessA(NULL, strDevcon, &sa, &sa, TRUE, CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS,
|
||||
NULL, NULL, &siStartInfo, &piProcInfo);
|
||||
|
||||
|
||||
if (!result)
|
||||
{
|
||||
printf("Error starting thread");
|
||||
|
||||
CloseHandle(newstdin);
|
||||
CloseHandle(newstdout);
|
||||
CloseHandle(read_stdout);
|
||||
CloseHandle(write_stdin);
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned long exit = 0; //код завершения процесса
|
||||
unsigned long bread; //кол-во прочитанных байт
|
||||
unsigned long avail; //кол-во доступных байт
|
||||
bzero(buf);
|
||||
|
||||
for (;;) //основной цикл программы
|
||||
{
|
||||
Sleep(1);
|
||||
|
||||
GetExitCodeProcess(piProcInfo.hProcess, &exit); //пока дочерний процесс
|
||||
|
||||
// не закрыт
|
||||
if (exit != STILL_ACTIVE) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
PeekNamedPipe(read_stdout, buf, sizeof(buf) - 1, &bread, &avail, NULL);
|
||||
|
||||
//Проверяем, есть ли данные для чтения в stdout
|
||||
|
||||
if (bread != 0)
|
||||
{
|
||||
bzero(buf);
|
||||
|
||||
ReadFile(read_stdout, buf, avail, &bread, NULL); //читаем из пайпа stdout
|
||||
|
||||
//printf("%s", buf);
|
||||
|
||||
}
|
||||
|
||||
int volume = 0;
|
||||
|
||||
if (isVolume) {
|
||||
|
||||
char bufStr[1024];
|
||||
bzero(bufStr);
|
||||
int j = 0;
|
||||
|
||||
for (unsigned long i = 0; i < bread; ++i) {
|
||||
|
||||
if (buf[i] == 0x0A) {
|
||||
printf("%s", bufStr);
|
||||
|
||||
char* res_ptr = strstr(bufStr, volumeName);
|
||||
|
||||
if (res_ptr) {
|
||||
|
||||
char str[_MAX_PATH];
|
||||
|
||||
sscanf(bufStr, "%s %d", str, &volume);
|
||||
|
||||
//volume = atoi(&bufStr[10]);
|
||||
}
|
||||
|
||||
bzero(bufStr);
|
||||
j = 0;
|
||||
}
|
||||
|
||||
bufStr[j] = buf[i];
|
||||
++j;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// KillProcByPid(piProcInfo.dwProcessId);
|
||||
|
||||
CloseHandle(piProcInfo.hThread);
|
||||
CloseHandle(piProcInfo.hProcess); // в stdin
|
||||
CloseHandle(newstdin);
|
||||
CloseHandle(newstdout);
|
||||
CloseHandle(read_stdout);
|
||||
CloseHandle(write_stdin);
|
||||
|
||||
return volume;
|
||||
}
|
||||
|
||||
void CreateScriptFile(char* text) {
|
||||
FILE* file = fopen("script.txt", "w");
|
||||
fprintf(file, text);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void CreateBatFile(char* text) {
|
||||
FILE* file = fopen("script.bat", "w");
|
||||
fprintf(file, text);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
DWORD CurrentProcessId;
|
||||
|
||||
// Функция обратного вызова для EnumWindows
|
||||
BOOL CALLBACK EnumWindowProc(HWND hWnd, LPARAM lParam) {
|
||||
DWORD processId;
|
||||
GetWindowThreadProcessId(hWnd, &processId);
|
||||
|
||||
if (processId == CurrentProcessId) {
|
||||
// HWND найден, передаем его через lParam
|
||||
*(HWND*)lParam = hWnd;
|
||||
return FALSE; // Завершаем перебор окон
|
||||
}
|
||||
|
||||
return TRUE; // Продолжаем перебор окон
|
||||
}
|
||||
|
||||
HWND GetWindowHwndByProcessId() {
|
||||
HWND hWnd = NULL;
|
||||
|
||||
// Перебираем все окна
|
||||
EnumWindows(EnumWindowProc, (LPARAM)&hWnd);
|
||||
|
||||
return hWnd;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
// if (!setSeDebug(GetCurrentThread())) {
|
||||
// printf("Error", "Could not set Debug Privilege");
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
|
||||
CurrentProcessId = GetCurrentProcessId();
|
||||
|
||||
HWND WindowHandle = GetWindowHwndByProcessId();
|
||||
|
||||
if (WindowHandle) {
|
||||
ShowWindow(WindowHandle, SW_HIDE);
|
||||
}
|
||||
|
||||
|
||||
bzero(volumeName);
|
||||
|
||||
FILE* file = fopen("volume", "r");
|
||||
fscanf(file, "%s", volumeName);
|
||||
fclose(file);
|
||||
|
||||
char current_work_dir_mount[FILENAME_MAX];
|
||||
_getcwd(current_work_dir_mount, sizeof(current_work_dir_mount));
|
||||
strcat(current_work_dir_mount, "\\mount");
|
||||
|
||||
char current_work_dir_vhd[FILENAME_MAX];
|
||||
_getcwd(current_work_dir_vhd, sizeof(current_work_dir_vhd));
|
||||
strcat(current_work_dir_vhd, "\\image.vhd");
|
||||
|
||||
char scriptCom[FILENAME_MAX];
|
||||
|
||||
// readonly
|
||||
if (access("readonly", 0) == 0) {
|
||||
sprintf(scriptCom, "select vdisk file=\"%s\"\r\nattach vdisk readonly", current_work_dir_vhd);
|
||||
}
|
||||
else {
|
||||
sprintf(scriptCom, "select vdisk file=\"%s\"\r\nattach vdisk", current_work_dir_vhd);
|
||||
}
|
||||
|
||||
CreateScriptFile(scriptCom);
|
||||
runProcess("diskpart.exe /s script.txt", FALSE);
|
||||
|
||||
CreateScriptFile("list volume");
|
||||
int volume = runProcess("diskpart.exe /s script.txt", TRUE);
|
||||
|
||||
if (volume > 0) {
|
||||
sprintf(scriptCom, "select volume %d\r\nassign mount=\"%s\"", volume, current_work_dir_mount);
|
||||
CreateScriptFile(scriptCom);
|
||||
runProcess("diskpart.exe /s script.txt", FALSE);
|
||||
|
||||
CreateScriptFile("");
|
||||
|
||||
CreateBatFile("cd mount\r\nrun.bat");
|
||||
runProcess("script.bat", FALSE);
|
||||
|
||||
CreateBatFile("");
|
||||
|
||||
sprintf(scriptCom, "select volume %d\r\nremove mount=\"%s\"", volume, current_work_dir_mount);
|
||||
CreateScriptFile(scriptCom);
|
||||
runProcess("diskpart.exe /s script.txt", FALSE);
|
||||
|
||||
sprintf(scriptCom, "select vdisk file=\"%s\"\r\ndetach vdisk", current_work_dir_vhd);
|
||||
CreateScriptFile(scriptCom);
|
||||
runProcess("diskpart.exe /s script.txt", FALSE);
|
||||
|
||||
CreateScriptFile("");
|
||||
|
||||
}
|
||||
else {
|
||||
printf("Virtual Disk not Found");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Запуск программы: CTRL+F5 или меню "Отладка" > "Запуск без отладки"
|
||||
// Отладка программы: F5 или меню "Отладка" > "Запустить отладку"
|
||||
|
||||
// Советы по началу работы
|
||||
// 1. В окне обозревателя решений можно добавлять файлы и управлять ими.
|
||||
// 2. В окне Team Explorer можно подключиться к системе управления версиями.
|
||||
// 3. В окне "Выходные данные" можно просматривать выходные данные сборки и другие сообщения.
|
||||
// 4. В окне "Список ошибок" можно просматривать ошибки.
|
||||
// 5. Последовательно выберите пункты меню "Проект" > "Добавить новый элемент", чтобы создать файлы кода, или "Проект" > "Добавить существующий элемент", чтобы добавить в проект существующие файлы кода.
|
||||
// 6. Чтобы снова открыть этот проект позже, выберите пункты меню "Файл" > "Открыть" > "Проект" и выберите SLN-файл.
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34728.123
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InstallDrv", "InstallDrv.vcxproj", "{031654C4-F73B-4465-8EC4-F4DC348FBB25}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{031654C4-F73B-4465-8EC4-F4DC348FBB25}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{031654C4-F73B-4465-8EC4-F4DC348FBB25}.Debug|x64.Build.0 = Debug|x64
|
||||
{031654C4-F73B-4465-8EC4-F4DC348FBB25}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{031654C4-F73B-4465-8EC4-F4DC348FBB25}.Debug|x86.Build.0 = Debug|Win32
|
||||
{031654C4-F73B-4465-8EC4-F4DC348FBB25}.Release|x64.ActiveCfg = Release|x64
|
||||
{031654C4-F73B-4465-8EC4-F4DC348FBB25}.Release|x64.Build.0 = Release|x64
|
||||
{031654C4-F73B-4465-8EC4-F4DC348FBB25}.Release|x86.ActiveCfg = Release|Win32
|
||||
{031654C4-F73B-4465-8EC4-F4DC348FBB25}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8D68BD9B-5CC1-4310-AD87-9912C280C571}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Run.c
|
||||
C:\VC\InstallDrv\Run.c(310,5): warning C4013: _getcwd: нет определения; предполагается "extern" с возвратом типа "int"
|
||||
C:\VC\InstallDrv\Run.c(320,9): warning C4013: access: нет определения; предполагается "extern" с возвратом типа "int"
|
||||
Создание кода
|
||||
Создание кода завершено
|
||||
1 of 18 functions ( 5.6%) were compiled, the rest were copied from previous compilation.
|
||||
0 functions were new in current compilation
|
||||
0 functions had inline decision re-evaluated but remain unchanged
|
||||
InstallDrv.vcxproj -> C:\VC\InstallDrv\Release\Run.exe
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\VC\InstallDrv\Release\Run.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
<SatelliteDlls />
|
||||
<NonRecipeFileRefs />
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
C:\VC\InstallDrv\Run.c;C:\VC\InstallDrv\Run\Release\Run.obj
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22621.0:
|
||||
Release|Win32|C:\VC\InstallDrv\|
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,3 @@
|
|||
^C:\VC\INSTALLDRV\RUN\RELEASE\RUN.OBJ
|
||||
C:\VC\InstallDrv\Run\Release\Run.IPDB
|
||||
C:\VC\InstallDrv\Run\Release\Run.iobj
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue