elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


  Mostrar Mensajes
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [17] 18 19 20 21 22 23
161  Programación / Programación Visual Basic / Re: [RESUELTO] CopyMem Array VarTypes en: 29 Junio 2013, 07:55 am
Sí, es mejor VarType, no lo hice así porque tenía pereza de crear constantes y asignarles ese número :D :D :D
162  Programación / Programación Visual Basic / Re: [RESUELTO] CopyMem Array VarTypes en: 22 Junio 2013, 02:51 am
Gracias por su ayuda, creo que así está bien:

Modulo:
Código
  1. Option Explicit
  2.  
  3. Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
  4. Public Declare Function VirtualProtect Lib "kernel32" (lpAddress As Any, ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long
  5.  
  6. Public Const PAGE_EXECUTE_READWRITE As Long = &H40&
  7.  
  8. Public Function GetMem(ByVal lpAddr As Long, ByVal pData As Long, ByVal dlen As Long) As Boolean
  9. Dim lngOldProtect   As Long
  10.  
  11. If 0 = VirtualProtect(ByVal lpAddr, dlen, PAGE_EXECUTE_READWRITE, lngOldProtect) Then
  12.    Exit Function
  13. End If
  14.  
  15. CopyMemory ByVal pData, ByVal lpAddr, dlen
  16. VirtualProtect ByVal lpAddr, dlen, lngOldProtect, lngOldProtect
  17.  
  18. GetMem = True
  19. End Function
  20.  
  21. Public Function PutMem(ByVal lpAddr As Long, ByVal pData As Long, ByVal dlen As Long) As Boolean
  22. Dim lngOldProtect   As Long
  23.  
  24. If 0 = VirtualProtect(ByVal lpAddr, dlen, PAGE_EXECUTE_READWRITE, lngOldProtect) Then
  25.    Exit Function
  26. End If
  27.  
  28. CopyMemory ByVal lpAddr, ByVal pData, dlen
  29. VirtualProtect ByVal lpAddr, dlen, lngOldProtect, lngOldProtect
  30.  
  31. PutMem = True
  32. End Function
  33.  

Código
  1. Option Explicit
  2.  
  3. 'http://msdn.microsoft.com/en-us/library/aa263420(v=vs.60).aspx
  4.  
  5. 'http://www.codeguru.com/vb/gen/vb_misc/algorithms/article.php/c7495/How-Visual-Basic-6-Stores-Data.htm
  6.  
  7. 'http://msdn.microsoft.com/en-us/library/windows/desktop/ms221627(v=vs.85).aspx
  8. 'http://msdn.microsoft.com/en-us/library/windows/desktop/ms221069(v=vs.85).aspx
  9. 'http://www.roblocher.com/whitepapers/oletypes.aspx
  10.  
  11. Private Sub Form_Load()
  12. Dim ESI(3 To 6) As Variant
  13. Dim EDI(3 To 6) As Variant
  14.  
  15. Dim i As Byte
  16.  
  17. ESI(3) = "2NE1" '255 '32767 '2147483647
  18. ESI(4) = "CL"
  19. ESI(5) = "THE BADDEST FEMALE"
  20. ESI(6) = "This is for all my bad girls around the world, Not bad meaning bad but bad meaning good u know, Let’s light it up and let it burn like we don’t care, Let em know how it feels damn good to be bad"
  21.  
  22. 'For i = LBound(ESI) To UBound(ESI)
  23. '    MsgBox i & ": " & (ESI(i) = EDI(i)) & vbCrLf & ESI(i) & " = " & EDI(i) & vbCrLf & "ESI: &H" & Hex(VarPtr(ESI(i))) & vbCrLf & "EDI: &H" & Hex(VarPtr(EDI(i)))
  24. 'Next i
  25. 'Stop
  26.  
  27. 'Call PutMem(VarPtr(EDI(LBound(EDI))), VarPtr(ESI(LBound(ESI))), GetSizeArray(ESI))
  28. Call PutMem(VarPtr(EDI(LBound(EDI))), VarPtr(ESI(LBound(ESI))), GetSizeArray(ESI)) '60 tmb
  29.  
  30. For i = LBound(ESI) To UBound(ESI)
  31.    MsgBox i & ": " & (ESI(i) = EDI(i)) & vbCrLf & ESI(i) & " = " & EDI(i) & vbCrLf & "ESI: &H" & Hex(VarPtr(ESI(i))) & vbCrLf & "EDI: &H" & Hex(VarPtr(EDI(i)))
  32. Next i
  33. End
  34. End Sub
  35.  
  36. Private Function GetSizeArray(ByRef vArray)
  37. Dim BaseBytes As Byte
  38.  
  39. 'MsgBox TypeName(vArray)
  40.  
  41. Select Case TypeName(vArray)
  42.    Case "Byte()"
  43.        BaseBytes = 1
  44.    Case "Boolean()", "Integer()"
  45.        BaseBytes = 2
  46.    Case "Long()", "Single()"
  47.        BaseBytes = 4
  48.    Case "Double()", "Currency()", "Date()"
  49.        BaseBytes = 8
  50.    Case "Variant()"
  51.        'The variant is 16 bytes large.
  52.        'It has 2 bytes to describe the type of data it is storing, 6 reserved bytes, and 8 bytes to store the data (each block represents a byte).
  53.        BaseBytes = 16
  54.    Case "String()"
  55.        BaseBytes = 4 'ReadMem del VarPtr está el Address al string con su len 4 bytes antes
  56. End Select
  57.  
  58. GetSizeArray = BaseBytes * (UBound(vArray) - LBound(vArray) + 1)
  59. End Function
  60.  
163  Programación / Programación Visual Basic / Re: [AYUDA] CopyMem Array VarTypes en: 18 Junio 2013, 11:46 am
Ya la había visto esa página, pero no funciona como dice ahí, ya que el string son 4 bytes, porque hace referencia a un puntero y no a la longitud del mismo, con hacer mov eax, [strvar] está moviendo el puntero del str hacia eax, lo mismo que hace StrPtr supongo.
164  Programación / Programación Visual Basic / Re: AYUDA cargar datos en: 16 Mayo 2013, 11:18 am
Tu dices algo así?

Código
  1. Dim i As Integer
  2.  
  3. For i = 0 To (List1.ListCount -1)
  4.    Label1(i).Caption = List1.List(i)
  5. Next i
  6.  
165  Programación / Programación Visual Basic / [RESUELTO] CopyMem Array VarTypes en: 9 Mayo 2013, 21:45 pm
Estaba tratando de mover memoria entre arrays.

Hice este ejemplo, tal vez puedan mejorarlo y/o ayudame con Variant :P

Código
  1. Modulo:
  2. Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
  3.        (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
  4.  
  5. Form:
  6. Private Sub Form_Load()
  7. Dim ESI(3 To 6) As Variant
  8. Dim EDI(3 To 6) As Variant
  9.  
  10. ESI(3) = "asdasdasdasdsd12312331231asdasd" '255 '32767 '2147483647
  11. ESI(4) = ESI(3)
  12. ESI(5) = ESI(3)
  13. ESI(6) = ESI(3)
  14.  
  15. EDI(3) = 0
  16. EDI(4) = EDI(3)
  17. EDI(5) = EDI(3)
  18. EDI(6) = EDI(3)
  19.  
  20. CopyMemory EDI(LBound(EDI)), ESI(LBound(ESI)), GetSizeArray(ESI)
  21.  
  22. Dim i As Byte
  23.  
  24. For i = LBound(ESI) To UBound(ESI)
  25.    MsgBox i & ": " & (ESI(i) = EDI(i)) & vbCrLf & "&H" & Hex(VarPtr(ESI(i)))
  26. Next i
  27.  
  28. End
  29. End Sub
  30.  
  31. Private Function GetSizeArray(ByRef vArray)
  32. Dim BaseBytes As Byte
  33.  
  34. 'MsgBox TypeName(vArray)
  35.  
  36. Select Case TypeName(vArray)
  37.    Case "Byte()"
  38.        BaseBytes = 1
  39.    Case "Boolean()", "Integer()"
  40.        BaseBytes = 2
  41.    Case "Long()", "Single()"
  42.        BaseBytes = 4
  43.    Case "Double()", "Currency()", "Date()"
  44.        BaseBytes = 8
  45.    Case "Variant()"
  46.        BaseBytes = 0 'DUNNO
  47.    Case "String()"
  48.        BaseBytes = 4 'ReadMem del VarPtr está el Address al string con su len 4 bytes antes
  49. End Select
  50.  
  51. GetSizeArray = BaseBytes * (UBound(vArray) - LBound(vArray) + 1)
  52. End Function
  53.  

Edit:
Se podría tomar como un reto *-)
166  Programación / Programación Visual Basic / Re: excluir numeros de la funcion Rnd(x,y)? en: 3 Mayo 2013, 23:54 pm
Yo usualmente uso una función que tiene un juego llamado Argentum Online:

Código
  1. Public Function RandomNumber(ByVal LowerBound As Long, ByVal UpperBound As Long) As Long
  2.    'Initialize randomizer
  3.    Randomize Timer
  4.  
  5.    'Generate random number
  6.    RandomNumber = (UpperBound - LowerBound) * Rnd + LowerBound
  7. End Function
  8.  

Se usa como: var = RandomNumber(1,9)
167  Programación / Programación Visual Basic / Re: SOS Leer Serie Procesador en: 26 Abril 2012, 16:19 pm
Hola, me interesa ese tema, me podrías decir a qué te refieres exactamente?; y si es posible un ejemplo con resultado, a ver si puedo ayudar en algo. (Y)
168  Programación / Programación C/C++ / [Resuelto] C++ + ASM en: 19 Abril 2012, 05:24 am
Hola, en C++ abrí una etiqueta asm como __asm{}, en la cual dentro quise hacer lo siguiente:

__asm
{
     .... //CÓDIGO

    mov dword ptr [ebx], RetFakeSinPrologo
    .... //MÁS CÓDIGO

RetFakeSinPrologo:
   jmp eax

   .... //MÁS CÓDIGO
}

En la línea del mov dword obtengo el error: "error C2415: improper operand type", en ASM puedo hacerlo así, acá hay alguna forma de lograr éso?

Desde ya muchas gracias.
169  Programación / Programación Visual Basic / Re: [AYUDA] Puntero de controles en: 24 Marzo 2012, 09:31 am
En realidad es así, tengo una funcion en VB que tiene 2 parámetros, en un exe que no es mio.
El 1er parametro es un RichTextBox, y el 2do es la cadena, en otro lenguaje hice o en uno X (no importa) hice en asm push cadena (por ejemplo) y push PTR, call función, donde el PTR es pasado a la función como ByRef MiRichTextBox As RichTextBox, según por lo que debuguié es:

SUB FUNC(ByRef XXXX As RichTextBox, ByVal Cadena As String)

Entonces necesito el puntero XXXX para que termine de llamar a esa función, pero no encuentro como conseguir ese puntero desde otra aplicacion, me explico?
170  Programación / Programación Visual Basic / [AYUDA] Puntero de controles en: 24 Marzo 2012, 08:42 am
Hola, yo desde un programa que genero desde 0, he obtenido el puntero de un control, como por ejemplo:

Código
  1. Me.Caption = VarPtr(Text1) & " - Hex: " & Hex(VarPtr(Text1)
  2.  

Pero, lo que quiero hacer es obtener ese mismo puntero desde otro programa, alguien tiene alguna idea de como lo puedo obtener? (También para otros controles).
Desde ya muchas gracias.
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [17] 18 19 20 21 22 23
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines