Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bugs of softice.ASM, "Execution Timing", and "Guard Pages". #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ASMsrc/guardpage.ASM
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
include 'win32ax.inc'

.code

start:
xor ebx, ebx
invoke VirtualAlloc,ebx,1,1000h,40h
mov byte [eax], 0c3h
push eax
xchg ebp, eax
invoke VirtualProtect,ebp,1,140h,esp
push .exit
push dword [fs:ebx]
mov [fs:ebx], esp
push .being_debugged
;execution resumes at being_debugged
;if ret instruction is executed
jmp ebp
.being_debugged:
invoke MessageBox,HWND_DESKTOP,"Debugger Found!",invoke GetCommandLine,MB_OK
invoke ExitProcess, 0
.exit:
invoke MessageBox,HWND_DESKTOP,"Debugger Not Found!",invoke GetCommandLine,MB_OK
invoke ExitProcess,0

.end start
3 changes: 2 additions & 1 deletion ASMsrc/softice.ASM
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ include 'win32ax.inc'

start:
xor eax, eax
push .exception
push dword [fs:0]
mov [fs:0],esp
int1
int 1
.exception:
mov eax,[esp+0x4]
cmp dword[eax], 0x80000004
Expand Down
18 changes: 9 additions & 9 deletions Csrc/fcall_examples/fcall_examples/fcall_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ void sGetTickCount() {

initial = GetTickCount();
end = GetTickCount();
if ((initial - end) >= 10)
if ((end - initial) >= 10)
printf("Debugger detected\n");
else
printf("Debugger not detected\n");
Expand All @@ -592,7 +592,7 @@ void stimeGetTime() {

initial = timeGetTime();
end = timeGetTime();
if ((initial - end) >= 10)
if ((end - initial) >= 10)
printf("Debugger detected\n");
else
printf("Debugger not detected\n");
Expand All @@ -608,7 +608,7 @@ void sGetSystemTime() {
GetSystemTime(&end);
SystemTimeToFileTime(&initial, &finitial);
SystemTimeToFileTime(&end, &fend);
if (((finitial.dwHighDateTime - fend.dwHighDateTime) > 10) || ((finitial.dwLowDateTime - fend.dwLowDateTime) > 10))
if (((fend.dwHighDateTime - finitial.dwHighDateTime) > 10) || ((fend.dwLowDateTime - finitial.dwLowDateTime) > 10))
printf("Debugger detected\n");
else
printf("Debugger not detected\n");
Expand All @@ -624,7 +624,7 @@ void sGetLocalTime() {
GetLocalTime(&end);
SystemTimeToFileTime(&initial, &finitial);
SystemTimeToFileTime(&end, &fend);
if (((finitial.dwHighDateTime - fend.dwHighDateTime) > 10) || ((finitial.dwLowDateTime - fend.dwLowDateTime) > 10))
if (((fend.dwHighDateTime - finitial.dwHighDateTime) > 10) || ((fend.dwLowDateTime - finitial.dwLowDateTime) > 10))
printf("Debugger detected\n");
else
printf("Debugger not detected\n");
Expand All @@ -641,7 +641,7 @@ void sQueryPerformanceCounter() {
if (QueryPerformanceCounter(&end)) {
printf("\ninitial.LowPart %02d \n" , initial.LowPart);
printf("\nend.LowPart %02d \n" , end.LowPart);
if ((initial.QuadPart - end.QuadPart) > 0x10)
if ((end.QuadPart - initial.QuadPart) > 0x10)
printf("Debugger detected\n");
else
printf("Debugger not detected\n");
Expand Down Expand Up @@ -750,7 +750,7 @@ int _tmain(int argc, _TCHAR* argv[])
printf("19 - 3.19 FindWindow\n");
printf("20 - 3.20 SuspendThread\n");
printf("21 - 3.23 UnhandledExceptionFilter\n");
printf("22 - 3.24 Guard Pages\n");
//printf("22 - 3.24 Guard Pages\n");
printf("23 - 3.25 Execution Timing - GetTickCount()\n");
printf("24 - 3.25 Execution Timing - timeGetTime\n");
printf("25 - 3.25 Execution Timing - GetSystemTime()\n");
Expand Down Expand Up @@ -825,9 +825,9 @@ int _tmain(int argc, _TCHAR* argv[])
case 21:
fSetUnhandledExceptionFilter();
break;
case 22:
ret = psVirtuaAlloc_VirtualProtect();
break;
// case 22:
// ret = psVirtuaAlloc_VirtualProtect();
// break;
case 23:
sGetTickCount();
break;
Expand Down