-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesign to user PID in .ini filename.
- Loading branch information
Showing
8 changed files
with
140 additions
and
20 deletions.
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
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
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
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,78 @@ | ||
#pragma once | ||
|
||
#include <windows.h> | ||
#include <wchar.h> | ||
#include <tlhelp32.h> | ||
|
||
#include <type_traits> | ||
|
||
namespace jbhack { | ||
|
||
template<typename Fn> | ||
struct on_exit_scope final | ||
{ | ||
template<typename Fn1> | ||
on_exit_scope(Fn1 && fn) : | ||
fn_(std::forward<Fn1>(fn)) | ||
{ | ||
} | ||
|
||
on_exit_scope(on_exit_scope const &) = delete; | ||
on_exit_scope & operator=(on_exit_scope const &) = delete; | ||
|
||
on_exit_scope(on_exit_scope &&) = delete; | ||
on_exit_scope & operator=(on_exit_scope &&) = delete; | ||
|
||
~on_exit_scope() | ||
{ | ||
try | ||
{ | ||
std::move(fn_)(); | ||
} | ||
catch (...) | ||
{ | ||
} | ||
} | ||
|
||
private: | ||
Fn fn_; | ||
}; | ||
|
||
template<typename Fn> | ||
on_exit_scope<std::decay_t<Fn>> make_on_exit_scope(Fn && fn) | ||
{ | ||
return{ std::forward<Fn>(fn) }; | ||
} | ||
|
||
template <typename Type, DWORD size> | ||
constexpr DWORD elements_of(Type (&)[size]) noexcept { return size; } | ||
|
||
inline DWORD get_parent_process_id() noexcept | ||
{ | ||
HANDLE const handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); | ||
if (handle != INVALID_HANDLE_VALUE) | ||
{ | ||
auto && on_exit = make_on_exit_scope([handle] { CloseHandle(handle); }); | ||
PROCESSENTRY32 pe; | ||
pe.dwSize = sizeof pe; | ||
if (Process32First(handle, &pe)) | ||
do | ||
if (pe.th32ProcessID == GetCurrentProcessId()) | ||
return pe.th32ParentProcessID; | ||
while (Process32Next(handle, &pe)); | ||
} | ||
return 0xFFFFFFFFu; // Note: Zero is reserved for system process!!! | ||
} | ||
|
||
template<size_t size> | ||
bool get_ini_file(WCHAR (&ini_file)[size]) | ||
{ | ||
DWORD pos = GetEnvironmentVariableW(L"ProgramData", ini_file, elements_of(ini_file)); | ||
if (pos == elements_of(ini_file)) | ||
return false; | ||
if (swprintf_s(ini_file + pos, size - pos, format_ini_file, get_parent_process_id()) < 0) | ||
return false; | ||
return true; | ||
} | ||
|
||
} |
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
Binary file not shown.
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,23 @@ | ||
if ($PSVersionTable.PSVersion.Major -lt 3) { | ||
throw "PS Version $($PSVersionTable.PSVersion) is below 3.0." | ||
} | ||
|
||
Set-StrictMode -Version Latest | ||
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop | ||
$script:VerbosePreference = "Continue" | ||
|
||
$_IniFile = "$env:ProgramData\AELoader.$([uint32]$pid).ini" | ||
Write-Host "Configuration file: $_IniFile" | ||
Copy-Item AELoader.ini -Destination $_IniFile | ||
|
||
& recdisc.exe | ||
|
||
Start-Sleep 1 | ||
if (Test-Path $_IniFile -PathType Leaf) { | ||
Remove-Item $_IniFile | ||
Write-Host "Injection was failed" -ForegroundColor Red | ||
} | ||
else { | ||
Write-Host "Success" -ForegroundColor Green | ||
} | ||
|