Muy interesante esa versión usando memoria, Gracias!!
Saludos!
Saludos!
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúOption Explicit
'cStack by Slek, for Indetectables.net
'25/6/2012
'Nota: Es una pila de Integer (puede ser modificado)
' It's an Integer's Stack (can be modified)
Dim Arr() As Integer 'Array of elements
Dim i As Integer 'Current Index
Private Sub Class_Initialize()
'Initialize with Index 0
i = 0
Call Init(i)
End Sub
Public Sub Init(ByVal n As Integer)
'Initialize Arr() with n elements
ReDim Arr(n)
End Sub
Public Sub Push(ByVal n As Integer)
'Add n at the end
Arr(i) = n
i = i + 1
If i > UBound(Arr) Then ReDim Preserve Arr(i * 2)
End Sub
Public Function Pop() As Integer
'Return last n
i = i - 1
Pop = Arr(i)
End Function
Cita de: BlackZeroX (Astaroth) en 4 Junio 2012, 09:30 AM
Es mejor crear paginas de memoria... implementando listas enlazadas... aun que todo depende del uso que se le de...
Dulces Lunas!¡.
Option Explicit
'cSet by Slek, for Indetectables.net
'31/5/2012
'Nota: Es un conjunto de Integer (puede ser modificado)
' It's an Integer's Set (can be modified)
Dim Arr() As Integer 'Array of elements
Dim s As Integer 'Number of elements included
Private Sub Class_Initialize()
'Initialize with 0 elements
s = 0
End Sub
Public Sub add(ByVal n As Integer)
'Include n
If Not contains(n) Then
ReDim Preserve Arr(s)
Arr(s) = n
s = s + 1
End If
End Sub
Public Sub remove(ByVal n As Integer)
'Exclude n
Dim i As Integer
Dim b As Boolean
For i = 0 To (s - 2)
If Arr(i) = n Then b = True
If b Then Arr(i) = Arr(i + 1)
Next i
s = s - 1
ReDim Preserve Arr(s - 1)
End Sub
Public Function size() As Integer
'Return number of elements
size = s
End Function
Public Function contains(ByVal n As Integer) As Boolean
'Returns if n has already been included
Dim i As Integer
For i = 0 To (s - 1)
If Arr(i) = n Then
contains = True
Exit Function
End If
Next i
contains = False
End Function
Public Function toArray() As Integer()
'Return Array
toArray = Arr
End Function
Dim c As New cSet
Dim a() As Integer
Call c.add(1)
MsgBox c.Contains(1)
Call c.add(1)
Call c.add(30)
MsgBox c.size
Call c.remove(1)
a = c.toArray
Private Sub WriteString(ByVal lPtr As Long, ByVal sStr As String)
Dim bvStr() As Byte
bvStr = StrConv(sStr, vbFromUnicode)
Call WriteMemory(lPtr, VarPtr(bvStr(0)), UBound(bvStr) + 1)
End Sub
Call VirtualProtect(ByVal pLibraryName, Len(sLibName), PAGE_READWRITE, lngOldProtect)
Msgbox lngOldProtect
Call WriteString(pLibraryName, Decrypt(sLibName))
Cita de: BlackZeroX (Astaroth) en 3 Noviembre 2011, 08:38 AMSolo falta DESBLOQUEAR la memoria en writeMemory()...
Public Function reallocMem(ByVal lptr As Long, ByVal lSize As Long) As Long
' // Retorna la Dirrecion de un SafeArray que se retorno en allocMem()/reallocMem().
Dim pBuff() As Byte
PutMem4 VarPtrArr(pBuff), lptr
If (lSize = &H0) Then
Erase pBuff
Else
ReDim Preserve pBuff(0 To (lSize - 1))
End If
GetMem4 VarPtrArr(pBuff), VarPtr(reallocMem)
PutMem4 VarPtrArr(pBuff), 0
End Function