Basic Univers
; ***************************************
; *  Code pour empéchecher le débuggage *
; *        et donc le cracking          *
; ***************************************



Structure LL
     Low.l
     High.l
EndStructure
Global Debut.LL, Fin.LL, CyclesHorloge.l
CyclesHorloge = 999999999
!RDTSC
MOV Debut\Low, eax
MOV Debut\High, edx
!RDTSC
MOV Fin\Low, eax
MOV Fin\High, edx
!fild qword [v_Fin]
!fild qword [v_Debut]
!fsubp
!fistp dword[v_CyclesHorloge]

If OpenWindow(0, 0, 0, 230, 60, #PB_Window_SystemMenu|#PB_Window_WindowCentered, "Cherche espion", hwnd)
     CreateGadgetList(WindowID())
     If CyclesHorloge > 150
          TextGadget(1, 10, 10, 210, 50, "ATTENTION, ce programme est espionné!")
     Else
          TextGadget(1, 10, 10, 210, 50, "O.K., c'est tranquille pas d'espions en vue !")
     EndIf
     SetGadgetFont(1, LoadFont(0, "Verdana", 12))
     Repeat
          Select WaitWindowEvent()
               Case #PB_EventCloseWindow
                    quit = #True
          EndSelect
     Until quit
EndIf




End

; --------------------------------------------------
;  Partie 2 : même mais sans utiliser RDTSC : $0F31
; --------------------------------------------------


Structure LL
     Low.l
     High.l
EndStructure
Global Debut.LL, Fin.LL, CyclesHorloge.l
Var1 = 14
CyclesHorloge = 999999999
Var2 = 49
Var3 = 40
#PROCESS_ALL_ACCESS = $1F0FFF
hID = GetCurrentProcessId_()
hProcessID = OpenProcess_(#PROCESS_ALL_ACCESS, #True, hID)
; J'enlève la protection en écriture de mon exécutable.
VirtualProtectEx_(hProcessID, ?Debut1_ASM, ?Fin_ASM -?Debut1_ASM, #PAGE_EXECUTE_READWRITE, @oldProtect)
Var1 + 1
*pByte1.BYTE = ?Debut1_ASM
*pByte1\b = Var1
Var3 + 9
*pByte2.BYTE = ?Debut2_ASM
*pByte2\b = Var1
*pByte1 + 1
*pByte1\b = Var2
*pByte2 + 1
*pByte2\b = Var3
Debut1_ASM:
!XOR eax, eax
MOV Debut\Low, eax
MOV Debut\High, edx
Debut2_ASM:
!XOR eax, eax
Fin_ASM:
MOV Fin\Low, eax
MOV Fin\High, edx
!fild qword [v_Fin]
!fild qword [v_Debut]
!fsubp
!fistp dword[v_CyclesHorloge]
If OpenWindow(0, 0, 0, 230, 60, #PB_Window_SystemMenu|#PB_Window_WindowCentered, "Cherche espion", hwnd)
     CreateGadgetList(WindowID())
     If CyclesHorloge > 150
          TextGadget(1, 10, 10, 210, 50, "ATTENTION, ce programme est espionné!")
     Else
          TextGadget(1, 10, 10, 210, 50, "O.K., c'est tranquille pas d'espions en vue !")
     EndIf
     SetGadgetFont(1, LoadFont(0, "Verdana", 12))
     Repeat
          Select WaitWindowEvent()
               Case #PB_EventCloseWindow
                    quit = #True
          EndSelect
     Until quit
EndIf