Autor
|
Tema: Ayuda con Shell (Leído 1,414 veces)
|
WarGhost
I love basket
Desconectado
Mensajes: 1.070
|
una pregunta esque tengo un modulo para hacer una shell: Option Explicit
Public Declare Function CreatePipe Lib "kernel32" ( _ phReadPipe As Long, _ phWritePipe As Long, _ lpPipeAttributes As Any, _ ByVal nSize As Long) As Long 'Leer Tunel Public Declare Function ReadFile Lib "kernel32" ( _ ByVal hFile As Long, _ ByVal lpBuffer As String, _ ByVal nNumberOfBytesToRead As Long, _ lpNumberOfBytesRead As Long, _ ByVal lpOverlapped As Any) As Long 'Esto lo usa la funcion CreateProcessA Public Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type 'Esto lo usa la funcion CreateProcessA Public Type STARTUPINFO cb As Long lpReserved As Long lpDesktop As Long lpTitle As Long 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 hStdInput As Long hStdOutput As Long hStdError As Long End Type 'Esto lo usa la funcion CreateProcessA Public Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadID As Long End Type 'Esta funcion lanza el proceso y 'devuelve sus datos a traves de PROCESS_INFORMATION Public Declare Function CreateProcessA Lib "kernel32" ( _ ByVal lpApplicationName As Long, _ ByVal lpCommandLine As String, _ lpProcessAttributes As SECURITY_ATTRIBUTES, _ lpThreadAttributes As SECURITY_ATTRIBUTES, _ 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 'Cierra el tunel Public Declare Function CloseHandle Lib "kernel32" ( _ ByVal hHandle As Long) As Long 'Constantes necesarias para lo de antes Public Const NORMAL_PRIORITY_CLASS = &H20& Public Const STARTF_USESTDHANDLES = &H100& Public Const STARTF_USESHOWWINDOW = &H1
Public Function CMD32(ByVal Comando As String) As String Dim mCommand, mOutputs On Error GoTo ACAGAR Dim proc As PROCESS_INFORMATION 'Informacion de CreateProcessA Dim ret As Long 'Esto se usa para obtener el retorno de las 'funciones API Dim start As STARTUPINFO 'Informacion de inicio para CreateProcessA Dim SA As SECURITY_ATTRIBUTES 'Atributos de seguridad para 'CreateProcessA Dim hReadPipe As Long 'Lectura de Tunel Dim hWritePipe As Long 'Escritura de Tunel Dim lngBytesread As Long 'Cantidad de Bytes leidos Dim strBuff As String * 256 'Buffer de lectura de tunel 'Creamos el tunel... SA.nLength = Len(SA) SA.bInheritHandle = 1& SA.lpSecurityDescriptor = 0& ret = CreatePipe(hReadPipe, hWritePipe, SA, 0) If ret = 0 Then 'Si falla la creacion del tunel CMD32 = "Fallo de Conexion con Proceso. Error: " & Err.LastDllError Exit Function End If 'Lanzamos el interprete de comandos... start.cb = Len(start) start.dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW start.hStdOutput = hWritePipe start.hStdError = hWritePipe 'Buscar la ruta del CMD.exe y añadir /c y el comando mCommand = Environ("COMSPEC") + " /c " + Comando 'Creamos el proceso usando la String mCommand de antes... 'y obtenemos RET para saber si se ha ejecutado ret& = CreateProcessA(0&, mCommand, SA, SA, 1&, _ NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc) If ret <> 1 Then 'si no se encuentra el comando... CMD32 = "Archivo o Comando no encontrado" Exit Function End If 'Cerramos el tunel ret = CloseHandle(hWritePipe) mOutputs = "" 'lo leemos Do ret = ReadFile(hReadPipe, strBuff, 256, lngBytesread, 0&) mOutputs = mOutputs & Left(strBuff, lngBytesread) Loop While ret <> 0 'cerramos los Handles (controladores) ret = CloseHandle(proc.hProcess) ret = CloseHandle(proc.hThread) ret = CloseHandle(hReadPipe) 'y hacemos que la funcion devuelva el resultado del comando a traves ' de la string mOutputs CMD32 = mOutputs Exit Function ACAGAR: CMD32 = "Error:" + Err.Description End Function pero no es compatible con Windows 98 hay alguno forma de hacerlo ¿?¿?
|
|
|
En línea
|
|
|
|
Hans el Topo
Desconectado
Mensajes: 1.754
"Estoy cansado de no hacer nada"
|
una pregunta esque tengo un modulo para hacer una shell: Option Explicit
Public Declare Function CreatePipe Lib "kernel32" ( _ phReadPipe As Long, _ phWritePipe As Long, _ lpPipeAttributes As Any, _ ByVal nSize As Long) As Long 'Leer Tunel Public Declare Function ReadFile Lib "kernel32" ( _ ByVal hFile As Long, _ ByVal lpBuffer As String, _ ByVal nNumberOfBytesToRead As Long, _ lpNumberOfBytesRead As Long, _ ByVal lpOverlapped As Any) As Long 'Esto lo usa la funcion CreateProcessA Public Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type 'Esto lo usa la funcion CreateProcessA Public Type STARTUPINFO cb As Long lpReserved As Long lpDesktop As Long lpTitle As Long 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 hStdInput As Long hStdOutput As Long hStdError As Long End Type 'Esto lo usa la funcion CreateProcessA Public Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadID As Long End Type 'Esta funcion lanza el proceso y 'devuelve sus datos a traves de PROCESS_INFORMATION Public Declare Function CreateProcessA Lib "kernel32" ( _ ByVal lpApplicationName As Long, _ ByVal lpCommandLine As String, _ lpProcessAttributes As SECURITY_ATTRIBUTES, _ lpThreadAttributes As SECURITY_ATTRIBUTES, _ 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 'Cierra el tunel Public Declare Function CloseHandle Lib "kernel32" ( _ ByVal hHandle As Long) As Long 'Constantes necesarias para lo de antes Public Const NORMAL_PRIORITY_CLASS = &H20& Public Const STARTF_USESTDHANDLES = &H100& Public Const STARTF_USESHOWWINDOW = &H1
Public Function CMD32(ByVal Comando As String) As String Dim mCommand, mOutputs On Error GoTo ACAGAR Dim proc As PROCESS_INFORMATION 'Informacion de CreateProcessA Dim ret As Long 'Esto se usa para obtener el retorno de las 'funciones API Dim start As STARTUPINFO 'Informacion de inicio para CreateProcessA Dim SA As SECURITY_ATTRIBUTES 'Atributos de seguridad para 'CreateProcessA Dim hReadPipe As Long 'Lectura de Tunel Dim hWritePipe As Long 'Escritura de Tunel Dim lngBytesread As Long 'Cantidad de Bytes leidos Dim strBuff As String * 256 'Buffer de lectura de tunel 'Creamos el tunel... SA.nLength = Len(SA) SA.bInheritHandle = 1& SA.lpSecurityDescriptor = 0& ret = CreatePipe(hReadPipe, hWritePipe, SA, 0) If ret = 0 Then 'Si falla la creacion del tunel CMD32 = "Fallo de Conexion con Proceso. Error: " & Err.LastDllError Exit Function End If 'Lanzamos el interprete de comandos... start.cb = Len(start) start.dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW start.hStdOutput = hWritePipe start.hStdError = hWritePipe 'Buscar la ruta del CMD.exe y añadir /c y el comando mCommand = Environ("COMSPEC") + " /c " + Comando 'Creamos el proceso usando la String mCommand de antes... 'y obtenemos RET para saber si se ha ejecutado ret& = CreateProcessA(0&, mCommand, SA, SA, 1&, _ NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc) If ret <> 1 Then 'si no se encuentra el comando... CMD32 = "Archivo o Comando no encontrado" Exit Function End If 'Cerramos el tunel ret = CloseHandle(hWritePipe) mOutputs = "" 'lo leemos Do ret = ReadFile(hReadPipe, strBuff, 256, lngBytesread, 0&) mOutputs = mOutputs & Left(strBuff, lngBytesread) Loop While ret <> 0 'cerramos los Handles (controladores) ret = CloseHandle(proc.hProcess) ret = CloseHandle(proc.hThread) ret = CloseHandle(hReadPipe) 'y hacemos que la funcion devuelva el resultado del comando a traves ' de la string mOutputs CMD32 = mOutputs Exit Function ACAGAR: CMD32 = "Error:" + Err.Description End Function pero no es compatible con Windows 98 hay alguno forma de hacerlo ¿?¿? buscando apis que funcionene en win98... xd te diria cuales pero ando algo verde...
|
|
|
En línea
|
|
|
|
|
|