Jump to content

Hwid problem


Zagor
 Share

Recommended Posts

Hello Im trying to protect my app with online hwid system but Im stuck on this.Program dont read txt file from my website and there is always error msg "HWID NotFound"

can someone help me with this?

#include <Array.au3>
#include <String.au3>

If _GetHWID('7390647.387001DEXIF20') Then
    MsgBox(4096, '', 'HWID Found.')
Else
    MsgBox(4096, '', 'HWID NOT Found.')
    ProcessClose("test.exe")
EndIf

Func _GetHWID($sHWID)
    Local $aArray = StringSplit(BinaryToString(InetRead('http://mywebsite.com/hwid.txt')), @LF)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    Return _ArrayBinarySearch($aArray, $sHWID) > 0
EndFunc   ;==>_GetHWID

Func _HWID()
    Local $sOSDrive = StringLeft(@SystemDir, 3)
    Local $sHWID = '0' & @CPUArch & @KBLayout & DriveGetSerial(@HomeDrive) & StringUpper(DriveGetType($sOSDrive)) & DriveSpaceTotal($sOSDrive)
    $sHWID = StringMid($sHWID, Round(StringLen($sHWID) / 2), Round(StringLen($sHWID) / 2))
    $sHWID = _StringReverse($sHWID)
    Return $sHWID
EndFunc   ;==>_HWID



 MsgBox(4096, '', 'Hello this is test.')
Link to comment
Share on other sites

When run like this...

#include <Array.au3>
#include <String.au3>

If _GetHWID('7390647.387001DEXIF20') Then
    MsgBox(4096, '', 'HWID Found.')
Else
    MsgBox(4096, '', 'HWID NOT Found.')
    ProcessClose("test.exe")
EndIf

Func _GetHWID($sHWID)
    Local $aArray = StringSplit(BinaryToString(InetRead('http://mywebsite.com/hwid.txt')), @LF)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    ;Return _ArrayBinarySearch($aArray, $sHWID) > 0
    Return true
EndFunc   ;==>_GetHWID

Func _HWID()
    Local $sOSDrive = StringLeft(@SystemDir, 3)
    Local $sHWID = '0' & @CPUArch & @KBLayout & DriveGetSerial(@HomeDrive) & StringUpper(DriveGetType($sOSDrive)) & DriveSpaceTotal($sOSDrive)
    $sHWID = StringMid($sHWID, Round(StringLen($sHWID) / 2), Round(StringLen($sHWID) / 2))
    ;$sHWID = _StringReverse($sHWID)
    Return $sHWID
EndFunc   ;==>_HWID



 MsgBox(4096, '', 'Hello this is test.')

the logic works therefore the HWID you are looking for is not on the file or the file is not being downloaded.

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Zagor,

_arraybinarysearch requires the input to be sorted.  Use _arraysearch or sort the array before searching...

kylomas

edit:

if you don't want to goof around with arrays you might consider an SRE like this...

Func _GetHWID($sHWID)

    Local $sHWIDS = BinaryToString(InetRead('http://mywebsite.com/hwid.txt'))
    If @error Then
        Return SetError(1, 0, 0)
    EndIf

    return stringregexp($sHWIDs,'(?m)^' & $sHWID & '\R')

EndFunc   ;==>_GetHWID

note - tested against a file only

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

I think the errors reside in this line:

Return _ArrayBinarySearch($aArray, $sHWID) > 0

- _ArrayBinarySearch has to be replaced by _ArraySearch

- The right condition is "> -1" instead of "> 0"

So the correct line is:

Return _ArraySearch($aArray, $sHWID, 0, 0, 1) > -1 ;case sensitive match
Edited by j0kky
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...