0 Replies - 1624 Views - Last Post: 23 July 2011 - 09:04 PM

#1 GunnerInc   User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 918
  • View blog
  • Posts: 2,358
  • Joined: 28-March 11

IsCurrentlyOnline

Posted 23 July 2011 - 09:04 PM

Description: Checks to see if we have an active internet connection Returns TRUE/FALSE
.586
.model flat, stdcall
option casemap:none

include windows.inc
include kernel32.inc
include user32.inc
include	wsock32.inc

includelib kernel32.lib
includelib user32.lib
includelib wsock32.lib

.data
szYup		db	"We are connected!", 0
szNope		db	"Um, we are NOT connected!", 0

.data?
wsadata 	WSADATA 

.code
start:
    
    push	offset wsadata
    push	101H
    call	WSAStartup
    
    call	IsCurrentlyOnline
    test	eax, eax
    jnz		Connected
    
    push	MB_IConerror
    push	NULL
    push	offset szNope
    push	HWND_DESKTOP
    call	MessageBox
    jmp		@F

Connected:	
    push	MB_ICONINFORMATION
    push	offset szYup
    push	offset szYup
    push	HWND_DESKTOP
    call	MessageBox
    
@@:	
    call	WSACleanup
    
    push	0
    call	ExitProcess

IsCurrentlyOnline:
    enter	256, 0
        
    push	256
    lea		eax, [ebp-256]
    push	eax
    call	gethostname
    test	eax, eax
    js		Nope
    
    lea		eax, [ebp-256]
    push	eax
    call	gethostbyname
    test	eax, eax
    jz		Nope
    
    mov 	eax, dword ptr [eax + 12]
    mov 	eax, dword ptr [eax]
    mov 	eax, dword ptr [eax]
    sub 	eax, 1 * 256 * 256 * 256 + 127 
    jmp		Done
    
Nope:
    xor		eax, eax
    
Done:		
    leave
    ret
end start



Is This A Good Question/Topic? 0
  • +

Page 1 of 1