|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
danrevella Master Cheater Reputation: 2
Joined: 11 Jun 2008 Posts: 290
|
Posted: Tue Jul 17, 2018 1:37 am Post subject: |
|
|
OldCheatEngineUser wrote: | either the process have one thread which is the main thread, and ce pause that thread.
or in win98 pausing the main thread result pausing the whole process.
at least try to pause the process main thread, and see what happens. |
I know what you mean, BTW pausing main thread sometime does works, but f.e. Tie Fighter by Lucas does NOT work, BTW CE (5.6.1) is able in pausing it.
Maybe CE does use his dll for pause? Maybe I may use the same dll for my purpose?
Many thanks for you patience with a donkey like me....
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Tue Jul 17, 2018 1:50 am Post subject: |
|
|
yeah, 98 doesn't have those functions
But as I said, https://github.com/cheat-engine/cheat-engine/blob/Cheat_Engine_Old/AdvancedOptionsUnit.pas#L580 is how 5.6.1 suspends it
( https://github.com/cheat-engine/cheat-engine/tree/Cheat_Engine_Old is 5.6.1 )
In short:
If hypermode is used or no process is selected or the process is CE itself, pause won't work
Then it checks if it's currently being debugged, and if not check if ntsuspendprocess is available (Not in 98 case).
If no debugger is available and ntsuspendprocess is also not available then call startdebuggerifneeded. Which returns true if the user agrees to attach the debugger, and the debugger attaching was successful
If that was successful and the debuggerloop has been started then it pauses the debuggerloop and calls suspendthread on all the threads it has seen
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
danrevella Master Cheater Reputation: 2
Joined: 11 Jun 2008 Posts: 290
|
Posted: Thu Jul 19, 2018 4:15 am Post subject: |
|
|
Hi!
Finally some progress, BTW an error lock me....
how the program works:
-run the prog
-switch to a game
-press the hotkey "END"
-debugactiveprocess attach to the game and pause it (no need to enumerate and suspend threads... all is done by "debugactiveprocess"
-now myprog is waiting for another hotkey "*" numlock
-pressing this hotkey my prog run createtoolhelp32, and walk into all thread (filtering only threads that belong to the pid of the game) and try to resume all.
-but I get an error from the compiler somethingh about an illegal conversion from Dw to handle in the do while loop part???? (It's too much complicate for me...)
May you still give a look to my souce, please?
Code: |
// freeze98.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
//maurizio
#include "windows.h"
#include <tlhelp32.h>
//maurizio
int main(int argc, char* argv[])
{
int codeclef=35;
bool PrimaVolta; //global variable
HWND Handle_Win_Game;//this is a GLOBAL variable
HWND MainWnd;
unsigned long dwProcessIdgame;
PrimaVolta=true;
// VK_MULTIPLY corrisponde al * del tast.numerico
// codeclef==35 corrisponde al tasto END
while (GetAsyncKeyState(codeclef) == 0)
{ /* attendi e basta!!!*/ }
if (PrimaVolta == true)
//ovvero: una volta che si e' attivato il debugger
//non si puo' piu' cambiare idea!!!!
{
PrimaVolta=false;
//Ottengo l'handle alla finestra del gioco
//che sta attualmente girando
Handle_Win_Game=::GetForegroundWindow();
///Aggiunta per il debugger
MainWnd=::GetForegroundWindow();
//Qui otteniamo il PID del gioco
//Questa funzione ritorna un TID (identificativo del
//thread, che comunque non e' un handle, che ha creato
//la finestra il cui handle e' stato specificato), e
//l'indirizzo della stringa definita nel 2^ parametro
//viene riempito con il PID del processo che ha creato
//la finestra; tutti e due i valori sono riportati
// sotto forma di DWORD
//unsigned long dwProcessIdgame;
::GetWindowThreadProcessId(Handle_Win_Game,&dwProcessIdgame);
//MessageBox("premuta hotkey");
//A questo punto se tutto e' filato liscio, la variable
//dwProcessIdgame contiene il PID del gioco
//PrimaVolta = true;
::SetFocus(Handle_Win_Game);
::SetForegroundWindow(Handle_Win_Game);
::ShowWindow(Handle_Win_Game,SW_SHOWMAXIMIZED);
::ShowWindow(Handle_Win_Game, SW_SHOW);
::ShowWindow(Handle_Win_Game,SW_SHOWMINIMIZED);
::ShowWindow(Handle_Win_Game, SW_SHOW);
DWORD TargetPid = dwProcessIdgame;
DebugActiveProcess(TargetPid);
// VK_MULTIPLY corrisponde al * del tast.numerico
while (GetAsyncKeyState(VK_MULTIPLY) == 0);
{ /* attendi e basta!!!*/ }
HANDLE hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (hThreadSnap != INVALID_HANDLE_VALUE)
{
THREADENTRY32 te;
te.dwSize = sizeof(te);
if (Thread32First(hThreadSnap , &te))
{
do
{
//in THREADENTRY32 structure there is a member called th32OwnerProcessID
//you can check owner process of thread like this:
if (te.th32OwnerProcessID == TargetPid)
{
HANDLE ThreadToResume = te.th32ThreadID;
ResumeThread(ThreadToResume); // then resume thread
//wprintf(L"Process %u IdThred=%u\n", te.th32OwnerProcessID, te.th32ThreadID);
}
} while (Thread32Next(hThreadSnap , &te));
}
CloseHandle(hThreadSnap );
}
};//end if (PrimaVolta == true)
//}//end while (GetAsyncKeyState(codeclef) == 0)
return 0;
}
|
Many thanks!!!
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|