Skip to content

Commit

Permalink
Better admin check
Browse files Browse the repository at this point in the history
  • Loading branch information
erfg12 committed Oct 10, 2020
1 parent 10571a5 commit 145f917
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Memory/memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ public void UnfreezeValue(string address)
/// <returns></returns>
public bool OpenProcess(int pid)
{
/*if (!IsAdmin())
if (!IsAdmin())
{
Debug.WriteLine("WARNING: This program may not be running with raised privileges! Visit https://github.com/erfg12/memory.dll/wiki/Administrative-Privileges");
}*/
}

if (pid <= 0)
{
Expand All @@ -434,7 +434,7 @@ public bool OpenProcess(int pid)
try {
Process.EnterDebugMode();
} catch (Win32Exception) {
Debug.WriteLine("WARNING: You are not running with raised privileges! Visit https://github.com/erfg12/memory.dll/wiki/Administrative-Privileges");
//Debug.WriteLine("WARNING: You are not running with raised privileges! Visit https://github.com/erfg12/memory.dll/wiki/Administrative-Privileges");
}

if (pHandle == IntPtr.Zero)
Expand Down
7 changes: 7 additions & 0 deletions Test/TestApp/MemoryTestApp/Classes/Processing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public void OpenTheProc()

if (ProcOpen) // if process opens successfully
{
OpenProcessBtn.Invoke((MethodInvoker)delegate
{
OpenProcessBtn.Text = "Close Process";
OpenProcessBtn.ForeColor = Color.Red;
});

ModuleList.Invoke((MethodInvoker)delegate
{
if (ModuleList.Items.Count <= 0)
Expand All @@ -48,6 +54,7 @@ public void OpenTheProc()
if (ModuleList.Items.Count > 0)
ModuleList.Items.Clear();
});
StopWorker = true;
}
}

Expand Down
1 change: 1 addition & 0 deletions Test/TestApp/MemoryTestApp/Forms/TrainerForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion Test/TestApp/MemoryTestApp/Forms/TrainerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public TrainerForm()
}

Mem m = new Mem(); // Declare m as our Memory.dll function reference variable.
bool StopWorker = false;

private void TrainerForm_Shown(object sender, EventArgs e)
{
Expand All @@ -40,7 +41,14 @@ private void TrainerForm_Shown(object sender, EventArgs e)

private void OpenProcessBtn_Click(object sender, EventArgs e)
{
BackgroundWork.RunWorkerAsync();
if (!BackgroundWork.IsBusy)
{
BackgroundWork.RunWorkerAsync();
}
else
{
StopWorker = true;
}
}

private void WriteButton_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -96,6 +104,16 @@ private void BackgroundWork_DoWork(object sender, DoWorkEventArgs e)
{
OpenTheProc();
System.Threading.Thread.Sleep(1000);
if (StopWorker)
{
StopWorker = false;
OpenProcessBtn.Invoke((MethodInvoker)delegate
{
OpenProcessBtn.Text = "Close Process";
OpenProcessBtn.ForeColor = Color.Red;
});
break;
}
}
}

Expand Down
10 changes: 0 additions & 10 deletions Test/TestApp/MemoryTestApp/TestApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Security.Principal.Windows, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.4.7.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -121,11 +118,4 @@
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets'))" />
</Target>
</Project>
2 changes: 0 additions & 2 deletions Test/TestApp/MemoryTestApp/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.NETCore.Platforms" version="3.1.3" targetFramework="net472" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="net472" />
<package id="System.Security.Principal.Windows" version="4.7.0" targetFramework="net472" />
</packages>
12 changes: 4 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
image: Visual Studio 2019
platform:
platform:
- x86
- x64
configuration: Debug

before_build:
- nuget restore

after_build:
- cmd: >-
'mv %APPVEYOR_BUILD_FOLDER%\Memory\bin\x64\Debug\*.nupkg %APPVEYOR_BUILD_FOLDER%\Memory\bin\x64\Debug\Memory_x64.nupkg'
'mv %APPVEYOR_BUILD_FOLDER%\Memory\bin\x86\Debug\*.nupkg %APPVEYOR_BUILD_FOLDER%\Memory\bin\x86\Debug\Memory_x86.nupkg'
'7z a Latest.zip %APPVEYOR_BUILD_FOLDER%\Memory\bin\x64\Debug\*.nupkg %APPVEYOR_BUILD_FOLDER%\Memory\bin\x86\Debug\*.nupkg'
after_build: "7z a Build_%PLATFORM%.zip %APPVEYOR_BUILD_FOLDER%\\Memory\\bin\\%PLATFORM%\\Debug\\*.nupkg %APPVEYOR_BUILD_FOLDER%\\Memory\\bin\\%PLATFORM%\\Debug\\*.nupkg"

build:
project: Memory.sln

artifacts:
path: Latest.zip
path: Build_%PLATFORM%.zip
name: Latest

deploy:
Expand All @@ -27,6 +23,6 @@ deploy:
description: Latest Compile Date %APPVEYOR_REPO_COMMIT_TIMESTAMP%
auth_token:
secure: aefoG8dMwSeQHm/FO6ydUZ591jX/M5fOms12ehz1obL4hnj8P7AIVrWqhztUK0cm
artifact: Latest.zip
artifact: Build_%PLATFORM%.zip
force_update: true
draft: false

0 comments on commit 145f917

Please sign in to comment.