Accueil > > > DEBUGGER DETECTION
DEBUGGER DETECTION
Information sur la source
Description
Il détécte si il y'a présence d'un débugger au lancement de votre programme (4 différentes méthodes)
Source
- 'Les constantes
- Const HKEY_CLASSES_ROOT = &H80000000
- Const HKEY_CURRENT_USER = &H80000001
- Const HKEY_LOCAL_MACHINE = &H80000002
- Const HKEY_USERS = &H80000003
- Const HKEY_DYN_DATA = &H80000004
- Public Const OF_READ = &H0&
- Public Const INVALID_HANDLE_VALUE = -1
- Public Const GENERIC_WRITE = &H40000000
- Public Const OPEN_EXISTING = 3
- Public Const FILE_SHARE_READ = &H1
- Public Const FILE_SHARE_WRITE = &H2
- 'Les API
- Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
- Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
- Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
- Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
- Public Declare Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
- Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
- Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
- Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
- Public Declare Function IsDebuggerPresent Lib "kernel32" () As Long
- Public Enum HCle
- HKeyLocalMachine = 0
- HKeyCurrentUser = 1
- HKeyClassesRoot = 2
- HKeyUsers = 3
- HKeyDynamicData = 4
- End Enum
-
- Private Function HKConvert(HK As HCle) As Long
- If HK = 2 Then HKConvert = HKEY_CLASSES_ROOT
- If HK = 1 Then HKConvert = HKEY_CURRENT_USER
- If HK = 0 Then HKConvert = HKEY_LOCAL_MACHINE
- If HK = 3 Then HKConvert = HKEY_USERS
- If HK = 4 Then HKConvert = HKEY_DYN_DATA
- End Function
-
- Public Function LireValeur(HK As HCle, Chemin As String, Valeur As String) As String
- Buff = 0
- Buff = RegCreateKey(HKConvert(HK), Chemin, lng)
- If Buff = 0 Then RegQueryValueEx lng, Valeur, 0&, 1, 0&, Buff
- If Buff < 2 Then
- LireValeur = ""
- Exit Function
- End If
- LireValeur = String(Buff + 1, " ")
- RegQueryValueEx lng, Valeur, 0&, 1, ByVal LireValeur, Buff
- LireValeur = Left(LireValeur, Buff - 1)
- End Function
-
- Sub Main()
- Call Debugger_Detection
- End Sub
-
-
- Public Sub Debugger_Detection()
- message = "Debugger detected ! Please Diseable It before use our software"
- titre = "Debugger detection !"
- '1e méthode : L'API is debugger present
- If IsDebuggerPresent <> 0 Then GoTo fin
- '2e méthode : Cherche une clé consernant le débugger NuMega Softice
- a = LireValeur(HKEY_LOCAL_MACHINE, "Software\NuMega\SoftICE", "InstallDir")
- If a <> "" Then GoTo fin2
- a = ""
- a = LireValeur(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Uninstall\SoftICE", "UninstallString")
- If a <> "" Then GoTo fin2
- a = ""
- a = LireValeur(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\App Paths\Loader32.Exe", "Path")
- If a <> "" Then GoTo fin2
- '3e methode : Utilisation de createfilea
- si1 = "\\\\.\\SICE" 'Pour
- si2 = "\\\\.\\SIWVID" 'win 9X
- si3 = "\\\\.\\NTICE" 'NT
- lngHandle = CreateFile(si1, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
- If lngHandle <> INVALID_HANDLE_VALUE Then GoTo fin
- lngHandle = CreateFile(si2, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
- If lngHandle <> INVALID_HANDLE_VALUE Then GoTo fin
- lngHandle = CreateFile(si3, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
- If lngHandle <> INVALID_HANDLE_VALUE Then GoTo fin
- '4e méthode : Utilisation de lopen
- Pointer = lOpen(si1, OF_READ)
- If Pointer <> INVALID_HANDLE_VALUE Then GoTo fin
- Pointer = lOpen(si2, OF_READ)
- If Pointer <> INVALID_HANDLE_VALUE Then GoTo fin
- Pointer = lOpen(si3, OF_READ)
- If Pointer <> INVALID_HANDLE_VALUE Then GoTo fin
- Exit Sub
- fin:
- MsgBox message, vbCritical + vbOKOnly, titre
- End
- fin2:
- MsgBox "Debugger is installed in this computer, Please uninstall it before use " & App.EXEName, vbCritical + vbOKOnly, "NuMega Softice installed !"
- End Sub
'Les constantes
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_DYN_DATA = &H80000004
Public Const OF_READ = &H0&
Public Const INVALID_HANDLE_VALUE = -1
Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public Const FILE_SHARE_READ = &H1
Public Const FILE_SHARE_WRITE = &H2
'Les API
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Public Declare Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function IsDebuggerPresent Lib "kernel32" () As Long
Public Enum HCle
HKeyLocalMachine = 0
HKeyCurrentUser = 1
HKeyClassesRoot = 2
HKeyUsers = 3
HKeyDynamicData = 4
End Enum
Private Function HKConvert(HK As HCle) As Long
If HK = 2 Then HKConvert = HKEY_CLASSES_ROOT
If HK = 1 Then HKConvert = HKEY_CURRENT_USER
If HK = 0 Then HKConvert = HKEY_LOCAL_MACHINE
If HK = 3 Then HKConvert = HKEY_USERS
If HK = 4 Then HKConvert = HKEY_DYN_DATA
End Function
Public Function LireValeur(HK As HCle, Chemin As String, Valeur As String) As String
Buff = 0
Buff = RegCreateKey(HKConvert(HK), Chemin, lng)
If Buff = 0 Then RegQueryValueEx lng, Valeur, 0&, 1, 0&, Buff
If Buff < 2 Then
LireValeur = ""
Exit Function
End If
LireValeur = String(Buff + 1, " ")
RegQueryValueEx lng, Valeur, 0&, 1, ByVal LireValeur, Buff
LireValeur = Left(LireValeur, Buff - 1)
End Function
Sub Main()
Call Debugger_Detection
End Sub
Public Sub Debugger_Detection()
message = "Debugger detected ! Please Diseable It before use our software"
titre = "Debugger detection !"
'1e méthode : L'API is debugger present
If IsDebuggerPresent <> 0 Then GoTo fin
'2e méthode : Cherche une clé consernant le débugger NuMega Softice
a = LireValeur(HKEY_LOCAL_MACHINE, "Software\NuMega\SoftICE", "InstallDir")
If a <> "" Then GoTo fin2
a = ""
a = LireValeur(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Uninstall\SoftICE", "UninstallString")
If a <> "" Then GoTo fin2
a = ""
a = LireValeur(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\App Paths\Loader32.Exe", "Path")
If a <> "" Then GoTo fin2
'3e methode : Utilisation de createfilea
si1 = "\\\\.\\SICE" 'Pour
si2 = "\\\\.\\SIWVID" 'win 9X
si3 = "\\\\.\\NTICE" 'NT
lngHandle = CreateFile(si1, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
If lngHandle <> INVALID_HANDLE_VALUE Then GoTo fin
lngHandle = CreateFile(si2, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
If lngHandle <> INVALID_HANDLE_VALUE Then GoTo fin
lngHandle = CreateFile(si3, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
If lngHandle <> INVALID_HANDLE_VALUE Then GoTo fin
'4e méthode : Utilisation de lopen
Pointer = lOpen(si1, OF_READ)
If Pointer <> INVALID_HANDLE_VALUE Then GoTo fin
Pointer = lOpen(si2, OF_READ)
If Pointer <> INVALID_HANDLE_VALUE Then GoTo fin
Pointer = lOpen(si3, OF_READ)
If Pointer <> INVALID_HANDLE_VALUE Then GoTo fin
Exit Sub
fin:
MsgBox message, vbCritical + vbOKOnly, titre
End
fin2:
MsgBox "Debugger is installed in this computer, Please uninstall it before use " & App.EXEName, vbCritical + vbOKOnly, "NuMega Softice installed !"
End Sub
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
GESTION D'EXCEPTION AVEC LES TASKSGESTION D'EXCEPTION AVEC LES TASKS par richardc
Nous avons vu dans un précédent article comment utiliser Task pour effectuer des opérations dans un autre thread.
Malheureusement, comme tout le monde n'est pas parfait, il se peut que cette exécution se passe mal et qu'une exception se produise.
La...
Cliquez pour lire la suite de l'article par richardc DéMARRONS AVEC LES TASKSDéMARRONS AVEC LES TASKS par richardc
Que vous le vouliez ou non, le développement multi-tâche est maintenant une obligation pour toute nouvelle application. Il est donc vital d'en comprendre les mécanismes et de s'y mettre le plus tôt possible.
En attendant le .NET Framework 4.5 avec le...
Cliquez pour lire la suite de l'article par richardc SLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPSSLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPS par Vko
Retrouvez les slides et les démo de ma session Fast & Furious XAML Apps. A ceux qui se posent la question : "est-ce que le code de la DataGrid est disponible?", je vous répondrais "pas encore". Je vais mettre en place un projet codeplex pour part...
Cliquez pour lire la suite de l'article par Vko XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|