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

 

 


Tema destacado: Curso de javascript por TickTack


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  [HELP] Using MoveMem and Removing Types
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [HELP] Using MoveMem and Removing Types  (Leído 3,375 veces)
Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
[HELP] Using MoveMem and Removing Types
« en: 8 Mayo 2012, 20:33 pm »

Hi! Can anyone help me removing Type declares and using MoveMem alternative in that code:

Spanish:

¡Hola! ¿Puede alguien ayudarme a eliminar el tipo de declara y el uso de alternativas MoveMem en ese código:

Código:
Option Explicit

Private Declare Function GetModuleHandle Lib "KERNEL32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long

Private Type IMAGE_DOS_HEADER
    e_magic                 As Integer
    e_cblp                  As Integer
    e_cp                    As Integer
    e_crlc                  As Integer
    e_cparhdr               As Integer
    e_minalloc              As Integer
    e_maxalloc              As Integer
    e_ss                    As Integer
    e_sp                    As Integer
    e_csum                  As Integer
    e_ip                    As Integer
    e_cs                    As Integer
    e_lfarlc                As Integer
    e_onvo                  As Integer
    e_res(0 To 3)           As Integer
    e_oemid                 As Integer
    e_oeminfo               As Integer
    e_res2(0 To 9)          As Integer
    e_lfanew                As Long
End Type

Private Type IMAGE_FILE_HEADER
    Machine                 As Integer
    NumberOfSections        As Integer
    TimeDataStamp           As Long
    PointerToSymbolTable    As Long
    NumberOfSymbols         As Long
    SizeOfOptionalHeader    As Integer
    Characteristics         As Integer
End Type

Private Type IMAGE_DATA_DIRECTORY
  VirtualAddress As Long
  isize As Long
End Type

Private Type IMAGE_OPTIONAL_HEADER32
    Magic                   As Integer
    MajorLinkerVersion      As Byte
    MinorLinkerVersion      As Byte
    SizeOfCode              As Long
    SizeOfInitalizedData    As Long
    SizeOfUninitalizedData  As Long
    AddressOfEntryPoint     As Long
    BaseOfCode              As Long
    BaseOfData              As Long
    ImageBase               As Long
    SectionAlignment        As Long
    FileAlignment           As Long
    MajorOperatingSystemVer As Integer
    MinorOperatingSystemVer As Integer
    MajorImageVersion       As Integer
    MinorImageVersion       As Integer
    MajorSubsystemVersion   As Integer
    MinorSubsystemVersion   As Integer
    Reserved1               As Long
    SizeOfImage             As Long
    SizeOfHeaders           As Long
    CheckSum                As Long
    Subsystem               As Integer
    DllCharacteristics      As Integer
    SizeOfStackReserve      As Long
    SizeOfStackCommit       As Long
    SizeOfHeapReserve       As Long
    SizeOfHeapCommit        As Long
    LoaerFlags              As Long
    NumberOfRvaAndSizes     As Long
    DataDirectory(0 To 15) As IMAGE_DATA_DIRECTORY
End Type

Private Type IMAGE_SECTION_HEADER
    Name As String * 8
    VirtualSize As Long
    VirtualAddress As Long
    SizeOfRawData As Long
    PointerToRawData As Long
    PointerToRelocations As Long
    PointerToLinenumbers As Long
    NumberOfRelocations As Integer
    NumberOfLinenumbers As Integer
    Characteristics As Long
End Type

Private Type IMAGE_NT_HEADERS
    Signature As Long
    FileHeader As IMAGE_FILE_HEADER
    OptionalHeader As IMAGE_OPTIONAL_HEADER32
End Type

Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Private Function GetSettings(ByVal szTargetSectionName As String) As String
Dim MZHeader As IMAGE_DOS_HEADER
Dim PEHeader As IMAGE_NT_HEADERS
Dim Section As IMAGE_SECTION_HEADER
Dim pMe As Long, pSection As Long
Dim i As Integer
    If Len(szTargetSectionName) < 1 Then Exit Function
        If Len(szTargetSectionName) > 8 Then szTargetSectionName = Left$(szTargetSectionName, 8)
        pMe = GetModuleHandle(vbNullString)
            If pMe Then
                CopyMemory MZHeader, ByVal pMe, Len(MZHeader)
                If MZHeader.e_magic = "&H5A4D" Then
                CopyMemory PEHeader, ByVal pMe + MZHeader.e_lfanew, Len(PEHeader)
                If PEHeader.Signature = "&H4550" Then
                pSection = pMe + MZHeader.e_lfanew + 24 + PEHeader.FileHeader.SizeOfOptionalHeader
                For i = 0 To PEHeader.FileHeader.NumberOfSections - 1
                    CopyMemory Section, ByVal pSection, Len(Section)
                    If Left(Section.Name, Len(szTargetSectionName)) = szTargetSectionName Then
                        GetSettings = String(Section.VirtualSize, Chr(0))
                        CopyMemory ByVal GetSettings, ByVal pMe + Section.VirtualAddress, Section.VirtualSize
                        Exit For
                    End If
                    pSection = pSection + Len(Section)
                Next i
            End If
        End If
    End If
End Function


« Última modificación: 9 Mayo 2012, 11:26 am por Swellow » En línea

x64core


Desconectado Desconectado

Mensajes: 1.908


Ver Perfil
Re: [HELP] Using MoveMem and Removing Types
« Respuesta #1 en: 9 Mayo 2012, 01:28 am »

Usa el traductor:
http://translate.google.com.sv/?hl=es&tab=wT

Aquí en el foro se escribe español/Castellano, no íngles


En línea

Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
Re: [HELP] Using MoveMem and Removing Types
« Respuesta #2 en: 9 Mayo 2012, 11:27 am »

Usa el traductor:
http://translate.google.com.sv/?hl=es&tab=wT

Aquí en el foro se escribe español/Castellano, no íngles

I have just edited to spanish :)

Acabo de editar al español :)
En línea

Karcrack


Desconectado Desconectado

Mensajes: 2.416


Se siente observado ¬¬'


Ver Perfil
Re: [HELP] Using MoveMem and Removing Types
« Respuesta #3 en: 9 Mayo 2012, 18:30 pm »

@RHL: No deberías tú ser quién decida si un usuario puede postear en otro lenguaje, sino un moderador.

@Swellow: I already did those adjustments in the kInvoke, just take a look on it and you'd be able to see how to do it in your code.

Regards.
« Última modificación: 9 Mayo 2012, 18:32 pm por Karcrack » En línea

x64core


Desconectado Desconectado

Mensajes: 1.908


Ver Perfil
Re: [HELP] Using MoveMem and Removing Types
« Respuesta #4 en: 9 Mayo 2012, 18:42 pm »

@RHL: No deberías tú ser quién decida si un usuario puede postear en otro lenguaje, sino un moderador.

@Swellow: I already did those adjustments in the kInvoke, just take a look on it and you'd be able to see how to do it in your code.

Regards.
Qué? Karcrak pero estamos en un foro Español/Castellano no en un foro en ingles, Sabiendo que los dos somos/eramos miembros también de foros de idioma ingles
no escribimos en español... bueno aunque eso es política de cada foro.
Además no siempre tendrás tiempo tú (porque la mayoría las respondes tu), para venir a resolver todas las dudas de todos los usuarios de otros foros para que vienen a que les hagan las tareas o algo por el estilo  >:(
En línea

Karcrack


Desconectado Desconectado

Mensajes: 2.416


Se siente observado ¬¬'


Ver Perfil
Re: [HELP] Using MoveMem and Removing Types
« Respuesta #5 en: 9 Mayo 2012, 21:56 pm »

No desviemos el tema, si quieres discutir mi opinión hagámoslo por chat o por MP.
En línea

rembolso

Desconectado Desconectado

Mensajes: 163



Ver Perfil
Re: [HELP] Using MoveMem and Removing Types
« Respuesta #6 en: 10 Mayo 2012, 05:12 am »

what is your goal, you  put more information
Example :
Código
  1. Private Sub Form_Load()
  2.  
  3. ' Use a block of memory as an intermediary step to copy
  4. ' the contents of array s() to array t(). Yes, you could copy them directly,
  5. ' but this demonstrates a few different memory functions.
  6. Dim s(0 To 255) As Integer, t(0 To 255) As Integer ' arrays to copy from/to
  7. Dim c As Integer, retval As Long ' counter variable & return value
  8. Dim hMem As Long, pMem As Long ' handle and pointer to memory block
  9.  
  10. ' Initialize the source array s()'s data
  11. For c = 0 To 255
  12. s(c) = 2 * c ' each element equals double its index
  13. Next c
  14.  
  15. ' Allocate a moveable block of memory (returns a handle) (Integer type = 2 bytes)
  16. hMem = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, 256 * 2)
  17. ' Lock the memory block, returning a pointer to it
  18. pMem = GlobalLock(hMem)
  19. ' Copy the entire contents of s() to the memory block
  20. ' Note that pMem is ByVal because we want its contents, not a pointer to it
  21. CopyMemory ByVal pMem, s(0), 255 * 2
  22. ' Copy the contents of the memory block to t() (we could have just copied s() to t())
  23. CopyMemory t(0), ByVal pMem, 256 * 2
  24. ' Unlock the memory block, destroying the pointer and freeing resources
  25. x = GlobalUnlock(hMem)
  26. ' Free the memory block (de-allocate it)
  27. x = GlobalFree(hMem)
  28.  
  29. ' Verify that t() = s(), which it should
  30. For c = 0 To 255
  31. If s(c) <> t(c) Then Debug.Print "Copy attempt failed."
  32. List1.AddItem t(c)
  33.  
  34. Next
  35.  
  36.  
  37. End Sub
'''
module
Código
  1. Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
  2. Declare Function GlobalAlloc Lib "kernel32.dll" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
  3. Declare Function GlobalLock Lib "kernel32.dll" (ByVal hMem As Long) As Long
  4. Declare Function GlobalUnlock Lib "kernel32.dll" (ByVal hMem As Long) As Long
  5. Declare Function GlobalFree Lib "kernel32.dll" (ByVal hMem As Long) As Long
  6.  
En línea

Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
Re: [HELP] Using MoveMem and Removing Types
« Respuesta #7 en: 20 Mayo 2012, 05:13 am »

I want to remove all type declares and if possible using MoveMem alternative func but I think I can do this by my own.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
mime types
PHP
mirfre10 1 1,778 Último mensaje 15 Julio 2010, 20:19 pm
por MinusFour
How to remove types « 1 2 »
Programación Visual Basic
pgs.lancelot 12 5,852 Último mensaje 24 Noviembre 2011, 19:08 pm
por Swellow
Problema con MoveMem - Reemplazando RtlMoveMemory.
Programación Visual Basic
Shackles 4 2,684 Último mensaje 23 Junio 2012, 17:19 pm
por Shackles
Incompatible types
Java
padiuwu 1 1,639 Último mensaje 16 Abril 2019, 19:31 pm
por rub'n
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines