//K = 0x0D;
K = N1;
X = 0;
K = 0;
//
K = 0xB3D097F555179B6A;
X = 0x0000000453E8A6DE;
for (;;)
{
if (((K % N2) & 0xFFFFFFFF) == 0x0D)
{
printf("%8X%08X\n", (DWORD)(X >> 32), (DWORD)X);
}
K = K + N1;//利用加法,加快计算速度
X++;
if (X == 0) break;
}
printf("Test\n");
if GetWindowThreadProcessId(hWnd, @dwProcessId) = 0 then Exit;
hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, dwProcessId);
if hSnap = INVALID_HANDLE_VALUE then Exit;
te.dwSize := SizeOf(te);
if Thread32First(hSnap, te) then
begin
repeat
if te.th32OwnerProcessID <> dwProcessId then continue;
dwThreadId := te.th32ThreadID;
if dwThreadId <> 0 then
begin
hThread := OpenThread(THREAD_TERMINATE, False, dwThreadId);
if hThread <> 0 then
begin
TerminateThread(hThread, 0);
CloseHandle(hThread);
end;
end;
until not Thread32Next(hSnap, te);
end;
CloseHandle(hSnap);
HOOK->
hJob := CreateJobObject(nil, 'CRACKME.JOB');
if hJob = 0 then
begin
CloseHandle(hProcess);
Exit;
end;
if AssignProcessToJobObject(hJob, hProcess) then
begin
TerminateJobObject(hJob, 0);
end;
CloseHandle(hProcess);
CloseHandle(hJob);
HOOK->RemoteThread
procedure StartRemoteThread(hProcess: THandle);
var
VM: Pointer;
hThread: THandle;
dwThreadId: THandle;
RemoteThreadCode: TRemoteThreadCode;
dw: DWORD;
begin
VM := VirtualAllocEx(hProcess, nil, $1000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if VM = nil then Exit;
HookOn(GetWindowThreadProcessId(hWnd, nil));
Sleep(500);
HookOff();
if GetWindowThreadProcessId(hWnd, @dwProcessId) = 0 then Exit;
hProcess := ReadProcessHandle();
if hProcess = 0 then Exit;
hJob := CreateJobObject(nil, 'CRACKME.JOB');
if hJob = 0 then
begin
CloseHandle(hProcess);
Exit;
end;
if AssignProcessToJobObject(hJob, hProcess) then
begin
TerminateJobObject(hJob, 0);
end;
CloseHandle(hProcess);
CloseHandle(hJob);
HOOK->
HookOn(GetWindowThreadProcessId(hWnd, nil));
Sleep(500);
HookOff();
GetWindowThreadProcessId(hWnd, @dwProcessId);
if DbgUiConnectToDbg() < 0 then Exit;
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, dwProcessid);
DbgUiDebugActiveProcess(hProcess);
CloseHandle(hProcess);
HookOn(GetWindowThreadProcessId(hWnd, nil));
Sleep(500);
HookOff();
if GetWindowThreadProcessId(hWnd, @dwProcessId) = 0 then Exit;
hProcess := ReadProcessHandle();
if hProcess = 0 then Exit;
hJob := CreateJobObject(nil, 'CRACKME.JOB');
if hJob = 0 then
begin
CloseHandle(hProcess);
Exit;
end;
if AssignProcessToJobObject(hJob, hProcess) then
begin
TerminateJobObject(hJob, 0);
end;
CloseHandle(hProcess);
CloseHandle(hJob);
HookOn(GetWindowThreadProcessId(hWnd, nil));
Sleep(200);
HookOff();
if GetWindowThreadProcessId(hWnd, @dwProcessId) = 0 then Exit;
hProcess := ReadProcessHandle();
if hProcess = 0 then Exit;
StartRemoteThread(hProcess);
CloseHandle(hProcess);
HookOn(GetWindowThreadProcessId(hWnd, nil));
Sleep(200);
HookOff();
GetWindowThreadProcessId(hWnd, @dwProcessId);
if DbgUiConnectToDbg() < 0 then Exit;
hProcess := ReadProcessHandle();
DbgUiDebugActiveProcess(hProcess);
CloseHandle(hProcess);
if GetWindowThreadProcessId(hWnd, @dwProcessId) <> 0 then
begin
Len := $1000;
GetMem(P,Len);
while NtQuerySystemInformation(SystemProcessesAndThreadsInformation, P, Len, nil) = STATUS_INFO_LENGTH_MISMATCH do
begin
FreeMem(P);
Len := Len * 2;
GetMem(P, Len);
end;
P1 := PSYSTEM_PROCESSES(P);
while P1^.NextEntryDelta <> 0 do
begin
if P1^.ProcessId = dwProcessId then
begin
//开始终止所有线程
for I := 0 to P1^.ThreadCount - 1 do
begin
P2 := PSYSTEM_THREADS(@P1^.Threads);
hThread := OpenThread(THREAD_TERMINATE , False, P2^.ClientId.UniqueThread);
TerminateThread(hThread, 0);
CloseHandle(hThread);
Inc(P2);
end;
break;
end;
P1 := PSYSTEM_PROCESSES(DWORD(P1) + P1^.NextEntryDelta);
end;
FreeMem(P);
end;