Skip to content

Commit

Permalink
injectdll code revert
Browse files Browse the repository at this point in the history
  • Loading branch information
erfg12 committed Jan 7, 2022
1 parent 2cd8a5d commit 444b6b6
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions Memory/memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,7 @@ public void CloseProcess()
/// Inject a DLL file.
/// </summary>
/// <param name="strDllName">path and name of DLL file. Ex: "C:\MyTrainer\inject.dll" or "inject.dll" if the DLL file is in the same directory as the trainer.</param>
/// <param name="Execute">execute dll method on injection. Default: false</param>
/// <param name="LoadLibrary">library load method. Options: LoadLibraryA, LoadLibraryExA, LoadLibraryW, LoadLibraryExW. Default: LoadLibraryA</param>
public bool InjectDll(String strDllName, bool Execute = false, string LoadLibrary = "LoadLibraryA")
public bool InjectDll(String strDllName)
{
IntPtr bytesout;

Expand All @@ -645,20 +643,12 @@ public bool InjectDll(String strDllName, bool Execute = false, string LoadLibrar
UIntPtr allocMem = VirtualAllocEx(mProc.Handle, (UIntPtr)null, (uint)lenWrite, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);

WriteProcessMemory(mProc.Handle, allocMem, strDllName, (UIntPtr)lenWrite, out bytesout);
UIntPtr GameProc = GetProcAddress(GetModuleHandle("kernel32.dll"), LoadLibrary);
UIntPtr GameProc = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");

if (GameProc == null)
return false;

IntPtr hThread = (IntPtr)null;

if (!Execute)
hThread = CreateRemoteThread(mProc.Handle, (IntPtr)null, 0, GameProc, allocMem, 0, out bytesout);
else
{
object _allocMem = allocMem;
NTSTATUS status = NtCreateThreadEx(out hThread, AccessMask.StandardRightsAll, (IntPtr)null, GameProc, mProc.MainModule.BaseAddress, (IntPtr)_allocMem, ThreadCreationFlags.Immediately, 0, 0, 0, (IntPtr)null);
}
IntPtr hThread = CreateRemoteThread(mProc.Handle, (IntPtr)null, 0, GameProc, allocMem, 0, out bytesout);

int Result = WaitForSingleObject(hThread, 10 * 1000);
if (Result == 0x00000080L || Result == 0x00000102L)
Expand Down

0 comments on commit 444b6b6

Please sign in to comment.