Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Momchill Zarev authored and Momchill Zarev committed Dec 10, 2023
1 parent 203c543 commit 8f2ba69
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions nbscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net"
"time"
"os"
// "syscall"
"syscall"
"flag"
"strings"
"errors"
Expand Down Expand Up @@ -242,29 +242,29 @@ func parseReply(bbuff []byte, result *NBResult) uint16 {
}


//func initWindows() {
// stdout := syscall.Handle(os.Stdout.Fd())
// stderr := syscall.Handle(os.Stdout.Fd())
//
// var originalMode uint32
//
// syscall.GetConsoleMode(stdout, &originalMode)
// originalMode |= 0x0004
//
// syscall.MustLoadDLL("kernel32").MustFindProc("SetConsoleMode").Call(uintptr(stdout), uintptr(originalMode))
//
// syscall.GetConsoleMode(stderr, &originalMode)
// originalMode |= 0x0004
//
// syscall.MustLoadDLL("kernel32").MustFindProc("SetConsoleMode").Call(uintptr(stderr), uintptr(originalMode))
//}
func initWindows() {
stdout := syscall.Handle(os.Stdout.Fd())
stderr := syscall.Handle(os.Stdout.Fd())

var originalMode uint32

syscall.GetConsoleMode(stdout, &originalMode)
originalMode |= 0x0004

syscall.MustLoadDLL("kernel32").MustFindProc("SetConsoleMode").Call(uintptr(stdout), uintptr(originalMode))

syscall.GetConsoleMode(stderr, &originalMode)
originalMode |= 0x0004

syscall.MustLoadDLL("kernel32").MustFindProc("SetConsoleMode").Call(uintptr(stderr), uintptr(originalMode))
}

var verbose *bool
var quite *bool
var json *bool

func main() {
//initWindows()
initWindows()
flag.Usage = func() {
fmt.Println("NBScan v1.0. Scan a list of networks for NetBIOS information")
fmt.Println("")
Expand Down Expand Up @@ -373,7 +373,6 @@ func main() {
}

if msDelay > 0 {
//var msPassed = -lastSent.Sub(time.Now()).Milliseconds()
var msPassed = time.Now().Sub(lastSent).Milliseconds()
if msPassed < msDelay {
// 10ms correction to compensate this if block
Expand All @@ -391,7 +390,7 @@ func main() {
}
}()

for time.Now().Sub(lastComm).Milliseconds() > 1000 * int64(*timeout) {
for time.Now().Sub(lastComm).Milliseconds() < 1000 * int64(*timeout) {
time.Sleep(time.Second)
}
socket.Close()
Expand Down

0 comments on commit 8f2ba69

Please sign in to comment.