-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56c00ce
commit e92202e
Showing
3 changed files
with
199 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
program ChangeCurrentDir; | ||
|
||
{$APPTYPE CONSOLE} | ||
{$R *.res} | ||
|
||
uses | ||
NtUtils, | ||
NtUtils.Files, | ||
NtUiLib.Errors, | ||
NtUtils.Processes.Info, | ||
NtUtils.Processes.Snapshots, | ||
NtUtils.Environment.Remote, | ||
NtUtils.Console; | ||
|
||
function Main: TNtxStatus; | ||
var | ||
hxProcess: IHandle; | ||
CurrentDirectory, ExpandedCurrentDirectory: String; | ||
begin | ||
writeln('Current directory changer by diversenok.'); | ||
writeln; | ||
|
||
write('Process name or PID: '); | ||
Result := NtxOpenProcessByName(hxProcess, ReadString(False), | ||
PROCESS_READ_PEB or PROCESS_SET_DIRECTORY, [pnAllowShortNames, pnAllowPIDs]); | ||
|
||
if not Result.IsSuccess then | ||
Exit; | ||
|
||
Result := NtxReadPebStringProcess(hxProcess.Handle, PebStringCurrentDirectory, | ||
CurrentDirectory); | ||
|
||
if not Result.IsSuccess then | ||
CurrentDirectory := '(Unknown)'; | ||
|
||
writeln('Old: ', CurrentDirectory); | ||
|
||
write('New: '); | ||
CurrentDirectory := ReadString(False); | ||
ExpandedCurrentDirectory := RtlxGetFullDosPath(CurrentDirectory); | ||
|
||
if CurrentDirectory <> ExpandedCurrentDirectory then | ||
writeln('New (expanded): ', ExpandedCurrentDirectory); | ||
|
||
Result := RtlxSetDirectoryProcess(hxProcess, ExpandedCurrentDirectory); | ||
end; | ||
|
||
procedure RunMain; | ||
var | ||
Status: TNtxStatus; | ||
begin | ||
Status := Main; | ||
writeln; | ||
|
||
if Status.IsSuccess then | ||
writeln('Success.') | ||
else | ||
writeln(Status.ToString); | ||
end; | ||
|
||
begin | ||
RunMain; | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ProjectGuid>{EDC5FA93-A28C-434F-BBFE-02BF243EC232}</ProjectGuid> | ||
<ProjectVersion>19.2</ProjectVersion> | ||
<FrameworkType>None</FrameworkType> | ||
<Base>True</Base> | ||
<Config Condition="'$(Config)'==''">Release</Config> | ||
<Platform Condition="'$(Platform)'==''">Win64</Platform> | ||
<TargetedPlatforms>3</TargetedPlatforms> | ||
<AppType>Console</AppType> | ||
<MainSource>ChangeCurrentDir.dpr</MainSource> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''"> | ||
<Base>true</Base> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''"> | ||
<Base_Win32>true</Base_Win32> | ||
<CfgParent>Base</CfgParent> | ||
<Base>true</Base> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''"> | ||
<Base_Win64>true</Base_Win64> | ||
<CfgParent>Base</CfgParent> | ||
<Base>true</Base> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''"> | ||
<Cfg_1>true</Cfg_1> | ||
<CfgParent>Base</CfgParent> | ||
<Base>true</Base> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''"> | ||
<Cfg_1_Win32>true</Cfg_1_Win32> | ||
<CfgParent>Cfg_1</CfgParent> | ||
<Cfg_1>true</Cfg_1> | ||
<Base>true</Base> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''"> | ||
<Cfg_2>true</Cfg_2> | ||
<CfgParent>Base</CfgParent> | ||
<Base>true</Base> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Base)'!=''"> | ||
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput> | ||
<DCC_ExeOutput>.\$(Platform)\$(Config)</DCC_ExeOutput> | ||
<DCC_E>false</DCC_E> | ||
<DCC_N>false</DCC_N> | ||
<DCC_S>false</DCC_S> | ||
<DCC_F>false</DCC_F> | ||
<DCC_K>false</DCC_K> | ||
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace> | ||
<SanitizedProjectName>ChangeCurrentDir</SanitizedProjectName> | ||
<DCC_UnitSearchPath>..\NtUtils\Headers;..\NtUtils;$(DCC_UnitSearchPath)</DCC_UnitSearchPath> | ||
<VerInfo_Locale>1033</VerInfo_Locale> | ||
<VerInfo_Keys>CompanyName=diversenok;FileDescription=ChangeCurrentDir - a tool for changing the current directory of other processes;FileVersion=1.0.0.0;InternalName=;LegalCopyright=diversenok;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys> | ||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> | ||
<DCC_TypedAtParameter>true</DCC_TypedAtParameter> | ||
<DCC_MapFile>3</DCC_MapFile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Base_Win32)'!=''"> | ||
<DCC_UsePackage>DBXSqliteDriver;IndyIPCommon;RESTComponents;bindcompdbx;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;bindcompvclsmp;tethering;svnui;bindcompvclwinx;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;FireDAC;vcltouch;vcldb;bindcompfmx;svn;FireDACSqliteDriver;FireDACPgDriver;inetdb;VirtualTreesDR;soaprtl;DbxCommonDriver;VirtualTreesExtension;fmx;FireDACIBDriver;fmxdae;xmlrtl;soapmidas;vcledge;fmxobj;vclwinx;rtl;DbxClientDriver;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;IndyProtocols;inetdbxpress;VclExtension;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage)</DCC_UsePackage> | ||
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace> | ||
<BT_BuildType>Debug</BT_BuildType> | ||
<DCC_ConsoleTarget>true</DCC_ConsoleTarget> | ||
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44> | ||
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150> | ||
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Base_Win64)'!=''"> | ||
<DCC_UsePackage>DBXSqliteDriver;IndyIPCommon;RESTComponents;bindcompdbx;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;vclFireDAC;IndySystem;bindcompvclsmp;tethering;bindcompvclwinx;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;FireDAC;vcltouch;vcldb;bindcompfmx;FireDACSqliteDriver;FireDACPgDriver;inetdb;VirtualTreesDR;soaprtl;DbxCommonDriver;VirtualTreesExtension;fmx;FireDACIBDriver;fmxdae;xmlrtl;soapmidas;vcledge;fmxobj;vclwinx;rtl;DbxClientDriver;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;IndyProtocols;inetdbxpress;VclExtension;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage)</DCC_UsePackage> | ||
<DCC_ConsoleTarget>true</DCC_ConsoleTarget> | ||
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44> | ||
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150> | ||
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace)</DCC_Namespace> | ||
<BT_BuildType>Debug</BT_BuildType> | ||
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Cfg_1)'!=''"> | ||
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define> | ||
<DCC_DebugDCUs>true</DCC_DebugDCUs> | ||
<DCC_Optimize>false</DCC_Optimize> | ||
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames> | ||
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe> | ||
<DCC_RemoteDebug>true</DCC_RemoteDebug> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''"> | ||
<DCC_RemoteDebug>false</DCC_RemoteDebug> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Cfg_2)'!=''"> | ||
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols> | ||
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define> | ||
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo> | ||
<DCC_DebugInformation>0</DCC_DebugInformation> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<DelphiCompile Include="$(MainSource)"> | ||
<MainSource>MainSource</MainSource> | ||
</DelphiCompile> | ||
<BuildConfiguration Include="Release"> | ||
<Key>Cfg_2</Key> | ||
<CfgParent>Base</CfgParent> | ||
</BuildConfiguration> | ||
<BuildConfiguration Include="Base"> | ||
<Key>Base</Key> | ||
</BuildConfiguration> | ||
<BuildConfiguration Include="Debug"> | ||
<Key>Cfg_1</Key> | ||
<CfgParent>Base</CfgParent> | ||
</BuildConfiguration> | ||
</ItemGroup> | ||
<ProjectExtensions> | ||
<Borland.Personality>Delphi.Personality.12</Borland.Personality> | ||
<Borland.ProjectType>Application</Borland.ProjectType> | ||
<BorlandProject> | ||
<Delphi.Personality> | ||
<Source> | ||
<Source Name="MainSource">ChangeCurrentDir.dpr</Source> | ||
</Source> | ||
<Excluded_Packages> | ||
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k270.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages> | ||
<Excluded_Packages Name="$(BDSBIN)\dclofficexp270.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages> | ||
</Excluded_Packages> | ||
</Delphi.Personality> | ||
<Deployment Version="3"/> | ||
<Platforms> | ||
<Platform value="Win32">True</Platform> | ||
<Platform value="Win64">True</Platform> | ||
</Platforms> | ||
</BorlandProject> | ||
<ProjectFileVersion>12</ProjectFileVersion> | ||
</ProjectExtensions> | ||
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/> | ||
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/> | ||
<Import Project="$(MSBuildProjectName).deployproj" Condition="Exists('$(MSBuildProjectName).deployproj')"/> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
# NtTools | ||
|
||
This project is a collection of random system tools for Windows that are interesting enough to publish but too small or simple to put into a dedicated repository. | ||
This project is a collection of random system tools for Windows that are interesting or useful enough to publish but too small or simple to put into a dedicated repository. | ||
|
||
Tool | Description | Release Link | ||
------------ | ----------- | :----------: | ||
**RunAsS4U** | RunAsS4U allows administrators to start processes under other users without knowing their passwords. It relies on the Service for User (S4U) logon in its operation. | [v2.0](https://github.com/diversenok/NtTools/releases/tag/v2.0-RunAsS4U) | ||
**InjectDLL** | InjectDLL is a simple yet reliable DLL injector that understands process names and relative paths, prints the reasons for failures, prevents deadlocks, and works against Native, Win32, and WoW64 processes. | [v1.0](https://github.com/diversenok/NtTools/releases/tag/v1.0-InjectDll) | ||
**ChangeCurrentDir** | ChangeCurrentDir allows changing the current directory of other processes. The tool supports Native, Win32, and WoW64 processes and understands process names and relative paths. | [v1.0](https://github.com/diversenok/NtTools/releases/tag/v1.0-ChangeCurrentDir) |