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

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


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

Desconectado Desconectado

Mensajes: 77


Ver Perfil
[HELP] Invoke InternetReadFile API
« en: 6 Noviembre 2011, 22:17 pm »

I've tried almost everything to Invoke that API and I always failed...

I suceed with InternetOpen/InternetOpelUrl/InternetCloseHandle but not that one :/

Código:
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal dwNumberOfBytesToRead As Long, lNumberOfBytesRead As Long) As Integer

        bDoLoop = InternetReadFile(hInternetOpen, strArray, Len(strArray), lNumberOfBytes)

Can anyone help please?


En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: [HELP] Invoke InternetReadFile API
« Respuesta #1 en: 6 Noviembre 2011, 22:36 pm »

.
Código
  1.  
  2. Const scUserAgent = "API-Guide test program"
  3. Const INTERNET_OPEN_TYPE_DIRECT = 1
  4. Const INTERNET_OPEN_TYPE_PROXY = 3
  5. Const INTERNET_FLAG_RELOAD = &H80000000
  6. Const sURL = "http://www.microsoft.com/index.htm"
  7. Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
  8. Private Declare Function InternetCloseHandle Lib "wininet" (ByRef hInet As Long) As Long
  9. Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
  10. Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
  11. Private Sub Form_Load()
  12.    'KPD-Team 1999
  13.    'URL: http://www.allapi.net/
  14.    'E-Mail: KPDTeam@Allapi.net
  15.  
  16.    Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
  17.    'Create a buffer for the file we're going to download
  18.    sBuffer = Space(1000)
  19.    'Create an internet connection
  20.    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
  21.    'Open the url
  22.    hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
  23.    'Read the first 1000 bytes of the file
  24.    InternetReadFile hFile, sBuffer, 1000, Ret
  25.    'clean up
  26.    InternetCloseHandle hFile
  27.    InternetCloseHandle hOpen
  28.    'Show our file
  29.    MsgBox sBuffer
  30. End Sub
  31.  
  32.  

http://allapi.mentalis.org/apilist/InternetReadFile.shtml

Dulces Lunas!¡.


En línea

The Dark Shadow is my passion.
Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
Re: [HELP] Invoke InternetReadFile API
« Respuesta #2 en: 6 Noviembre 2011, 22:44 pm »

Thanks for your answer man but its not that that I want. I want to Invoke the API using CallAPIByName.
En línea

x64core


Desconectado Desconectado

Mensajes: 1.908


Ver Perfil
Re: [HELP] Invoke InternetReadFile API
« Respuesta #3 en: 6 Noviembre 2011, 23:20 pm »

Thanks for your answer man but its not that that I want. I want to Invoke the API using CallAPIByName.

which callApibyname use?
En línea

Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
Re: [HELP] Invoke InternetReadFile API
« Respuesta #4 en: 6 Noviembre 2011, 23:21 pm »

Modded CallAPIByName by cobein.
En línea

x64core


Desconectado Desconectado

Mensajes: 1.908


Ver Perfil
Re: [HELP] Invoke InternetReadFile API
« Respuesta #5 en: 6 Noviembre 2011, 23:25 pm »

made several cobein  :-\
specify link or the code
En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: [HELP] Invoke InternetReadFile API
« Respuesta #6 en: 6 Noviembre 2011, 23:26 pm »

.
I do not see the problem.

for more information: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385103%28v=vs.85%29.aspx

prototype:
Código
  1. Public Function CallAPIByName(ByVal sLib As String, ByVal sMod As String, ParamArray Params()) As Long
  2.  

API to Call

Código
  1.  
  2. BOOL InternetReadFile(
  3.  __in   HINTERNET hFile,
  4.  __out  LPVOID lpBuffer,
  5.  __in   DWORD dwNumberOfBytesToRead,
  6.  __out  LPDWORD lpdwNumberOfBytesRead
  7. );
  8.  
  9. Requirements
  10.  
  11. Minimum supported client Windows 2000 Professional
  12. Minimum supported server Windows 2000 Server
  13. Header Wininet.h
  14. Library Wininet.lib
  15. DLL Wininet.dll
  16.  
  17.  

Código
  1.  
  2. dim hFile as long
  3. dim bBuff(0 to 999) as byte ' lpBuffer = varptr(bBuff(0))
  4. dim dwNumberOfBytesToRead as long
  5. dim lpdwNumberOfBytesRead as long
  6. dim bRes as boolean
  7.  
  8. dwNumberOfBytesToRead = 1000
  9. bRes = callapybyname("wininet", "InternetReadFile", hFile, varptr(bBuff(0)), dwNumberOfBytesToRead, varptr(lpdwNumberOfBytesRead) )
  10.  
  11.  

Dulces Lunas!¡.
« Última modificación: 6 Noviembre 2011, 23:53 pm por BlackZeroX (Astaroth) » En línea

The Dark Shadow is my passion.
BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: [HELP] Invoke InternetReadFile API
« Respuesta #7 en: 6 Noviembre 2011, 23:42 pm »

Example FULL:

Código
  1.  
  2. Option Explicit
  3.  
  4. Const scUserAgent = "UserAngent InfraExplorer Plugin."
  5. Const INTERNET_OPEN_TYPE_DIRECT = 1
  6. Const INTERNET_OPEN_TYPE_PROXY = 3
  7. Const INTERNET_FLAG_RELOAD = &H80000000
  8. Const sURL = "http://infrangelux.sytes.net/ScanX/?ip=www.google.com.mx&port=80&nohtml=3"
  9.  
  10. Private Sub Form_Load()
  11.    Dim hOpen       As Long
  12.    Dim hFile       As Long
  13.    Dim bBuffer()   As Byte
  14.    Dim Ret         As Long
  15.    ReDim bBuffer(0 To 0)
  16.    hOpen = lCallApiByName("wininet", "InternetOpenW", StrPtr(scUserAgent), INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0)
  17.    hFile = lCallApiByName("wininet", "InternetOpenUrlW", hOpen, StrPtr(sURL), 0, 0, INTERNET_FLAG_RELOAD, 0)
  18.    Call lCallApiByName("wininet", "InternetReadFile", hFile, VarPtr(bBuffer(0)), 1, VarPtr(Ret))
  19.    Call lCallApiByName("wininet", "InternetCloseHandle", hFile)
  20.    Call lCallApiByName("wininet", "InternetCloseHandle", hOpen)
  21.    MsgBox IIf(Val(StrConv(bBuffer, vbUnicode)) = 1, "Port Enabled", "Port Disabled")
  22. End Sub
  23.  
  24.  

Dulces Lunas!¡.
« Última modificación: 6 Noviembre 2011, 23:51 pm por BlackZeroX (Astaroth) » En línea

The Dark Shadow is my passion.
Swellow

Desconectado Desconectado

Mensajes: 77


Ver Perfil
Re: [HELP] Invoke InternetReadFile API
« Respuesta #8 en: 6 Noviembre 2011, 23:55 pm »

@BlackZeroX (Astaroth)
Thanks a lot man!
« Última modificación: 7 Noviembre 2011, 00:00 am por Swellow » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[ASM+VB6][INVOKE] Llamas APIs sin declararlas - kInvoke.bas « 1 2 3 »
Programación Visual Basic
Karcrack 26 20,371 Último mensaje 2 Noviembre 2011, 20:03 pm
por Karcrack
Ayuda con el metodo Invoke y varias Dudas Sockets
.NET (C#, VB.NET, ASP)
CATBro 2 2,702 Último mensaje 28 Octubre 2011, 07:00 am
por CATBro
[HELP]Invoke by Hash
Programación Visual Basic
Swellow 7 10,440 Último mensaje 15 Diciembre 2011, 20:37 pm
por Karcrack
Invoke WININET y CopyMemory
Programación Visual Basic
STARZ 6 2,856 Último mensaje 30 Enero 2012, 08:56 am
por BlackZeroX
[HELP] Invoke or Alternative to InternetReadFile API
Programación Visual Basic
Swellow 2 1,977 Último mensaje 22 Junio 2012, 04:31 am
por Swellow
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines