benoithenry
Messages postés14Date d'inscriptionvendredi 25 juillet 2003StatutMembreDernière intervention15 octobre 2003
-
1 oct. 2003 à 10:57
ShareVB
Messages postés2676Date d'inscriptionvendredi 28 juin 2002StatutMembreDernière intervention13 janvier 2016
-
27 oct. 2003 à 19:50
Bonjour,
Voila maintenant j'ai un code propre je pense, le programme ne me renvoie aucune erreur mais la mémoire allouée avec VirtualAllocEx n'est jamais libérée.
J'ai fait un test en allouant 10 Mo dans explorer.
Regardez dans le gestionnaire des taches la mémoire augmente sans jamais se libérer! (pour la libérer fermer le processus explorer et le relancer)
J'ai repris le code de plein de programmes différents qui utilisent VirtualAllocEx et VirtualFreeEx et ca fait exactement la meme chose. A croire qu'il y a un bug dans la fonction ou que beaucoup de monde ne sait pas l'utiliser !
Avis a la population, le premier qui trouve a gagné....
Public Const PAGE_READWRITE As Long = &H4
Public Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Public Const SYNCHRONIZE As Long = &H100000
Public Const PROCESS_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
Public L_FI As Long, R_FI1 As Long, R_FI2 As Long, R_FI3 As Long, R_FI4 As Long, R_FI5 As Long, R_FI6 As Long, R_FI7 As Long, R_FI8 As Long
Public Const MEM_RELEASE = &H8000
Public Const MEM_COMMIT As Long = &H1000
Public Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String)
Private Declare Function FindWindowEx& Lib "user32" Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpClassName As String, ByVal lpWindowName As String)
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Function GetSysLVHwnd() As Long
Dim h As Long
h = FindWindow("Progman", vbNullString)
h = FindWindowEx(h, 0, "SHELLDLL_defVIEW", vbNullString)
GetSysLVHwnd = FindWindowEx(h, 0, "SysListView32", vbNullString)
End Function
Sub Main()
Dim pid As Long
Dim h As Long
Dim AllocMemory As Long
ShareVB
Messages postés2676Date d'inscriptionvendredi 28 juin 2002StatutMembreDernière intervention13 janvier 201626 27 oct. 2003 à 19:50
salut
bon je viens de retester : tu changes
Public Const MEM_RELEASE = &H8000
Public Const MEM_COMMIT As Long = &H1000
Public Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
en
Public Const MEM_RELEASE = &H8000&
Public Const MEM_COMMIT As Long = &H1000&
Public Declare Function VirtualFreeEx Lib "kernel32" (ByVal hProcess As Long,byval lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long