SendMessage parece ser lo que necesitas...
Código [Seleccionar]
http://msdn.microsoft.com/en-us/library/ms644950%28VS.85%29.aspx
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úhttp://msdn.microsoft.com/en-us/library/ms644950%28VS.85%29.aspx
Cita de: Dessa en 15 Noviembre 2009, 18:21 PMQue recuerdos eh, Dessa?
Ok, de acuerdo, es solo un ejemplo rapido
PD: WMI, tasklist o taskkill si valen... porque cuando yo los uso me "matan" aqui en el foro.
Public Function GetPID(ByVal sImageName As String) As Long
Dim oExec As Object
Set oExec = CreateObject("WSCRIPT.SHELL").Exec("tasklist /FI ""IMAGENAME eq """ & sImageName & """"" /FO ""CSV"" /NH")
GetPID = Val(Replace$(Split(oExec.StdOut.ReadAll(), ",")(1), Chr$(34), ""))
Set oExec = Nothing
End Function
Public Function GetPID(ByVal sImageName As String) As Long
Dim oProc As Object
For Each oProc In GetObject("winmgmts:\\.\root\cimv2").ExecQuery _
("Select * from Win32_Process Where Name = '" & sImageName & "'")
GetPID = oProc.ProcessId
Next oProc
Set oProc = Nothing
End Function
Cita de: NikNitro en 15 Noviembre 2009, 13:33 PMEstamos en la sección de 'Programacion VB'...
Si está abierto... no te valdría con un simple control+alt+supr???
Option Explicit
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 ''\\ PE\0\0
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
Public ByteArray() As Byte ' Byte array del archivo a leer
Public TempArray() As Byte ' Array temporal para reducir el ByteArray
Public Config() As Byte ' La posible configuración del archivo leido
Public idh As IMAGE_DOS_HEADER ' Cabeceras
Public inh As IMAGE_NT_HEADERS
Public ish() As IMAGE_SECTION_HEADER
Sub RellenarPE(Ruta As String)
Open Ruta For Binary As #1
ReDim ByteArray(LOF(1) - 1)
Get #1, , ByteArray
Close #1
' Leemos el MS-DOS stub
CopyMemory idh, ByteArray(0), Len(idh)
If idh.e_magic <> IMAGE_DOS_SIGNATURE Then
MsgBox "Formato PE no válido", vbCritical, "Small Crypter"
Exit Sub
End If
' Leemos a partir del PE\0\0 comletando a su vez:
' -> IMAGE_FILE_HEADER (COFF File Header)
' -> IMAGE_OPTIONAL_HEADER (Optional Header)
CopyMemory inh, ByteArray(idh.e_lfanew), Len(inh)
If inh.Signature <> IMAGE_NT_SIGNATURE Then
MsgBox "Formato PE no válido", vbCritical, "Small Crypter"
Exit Sub
End If
' Leemos las distintas secciones
Dim i As Integer
ReDim ish(inh.FileHeader.NumberOfSections - 1)
For i = 0 To inh.FileHeader.NumberOfSections - 1
Call CopyMemory(ish(i), ByteArray(idh.e_lfanew + Len(inh) + Len(ish(i)) * i), Len(ish(i)))
Next i
End Sub