forked from dashingsoft/pyarmor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_multiple_machine.py
More file actions
35 lines (30 loc) · 1.14 KB
/
check_multiple_machine.py
File metadata and controls
35 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def check_multiple_machine():
from ctypes import c_char, py_object, PYFUNCTYPE
def _get_license_data():
try:
from pytransform import _pytransform
except Exception:
# For super mode
from pytransform import get_user_data
return get_user_data().decode()
prototype = PYFUNCTYPE(py_object)
dlfunc = prototype(('get_registration_code', _pytransform))
rcode = dlfunc().decode()
index = rcode.find(';', rcode.find('*CODE:'))
return rcode[index+1:]
def _get_hd_info():
HT_HARDDISK = 0
try:
from pytransform import _pytransform
except Exception:
# For super mode
from pytransform import get_hd_info
return get_hd_info(0)
size = 256
t_buf = c_char * size
buf = t_buf()
if (_pytransform.get_hd_info(HT_HARDDISK, buf, size) == -1):
raise RuntimeError('Get hardware information failed')
return buf.value.decode()
if _get_hd_info() not in _get_license_data().split(';'):
raise RuntimeError('This license is not for this machine')