Hasp4.pas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. unit Hasp4;
  2. interface
  3. uses
  4. windows,
  5. sysutils;
  6. (******************************************************************************
  7. *
  8. * HASPAPI.INC - Service constants and declaration of the hasp() routine.
  9. *
  10. * Copyright (c) 2002 Aladdin Knowledge Systems Ltd.
  11. *
  12. ******************************************************************************)
  13. {$IFOPT O+}
  14. {$DEFINE HASPAPI_OPT_O}
  15. {$ENDIF}
  16. {$O-} { Optimizations must be off for HASP API }
  17. (******************************************************************************
  18. *
  19. * HASP function
  20. *
  21. ******************************************************************************)
  22. {$IFDEF HASP_DLL}
  23. procedure hasp ( Service,
  24. SeedCode,
  25. LptNum,
  26. Pass1, Pass2 : longint;
  27. var p1, p2, p3, p4 : longint);
  28. stdcall;
  29. external 'haspms32.dll';
  30. {$ELSE}
  31. procedure _hasp ( Service,
  32. SeedCode,
  33. LptNum,
  34. Pass1, Pass2 : longint;
  35. var p1, p2, p3, p4 : longint);
  36. stdcall;
  37. external;
  38. procedure hasp ( Service,
  39. SeedCode,
  40. LptNum,
  41. Pass1, Pass2 : longint;
  42. var p1, p2, p3, p4 : longint);
  43. var
  44. HaspRandInitialized : boolean = false;
  45. function _rand : integer; stdcall;
  46. function __grunzelsepp_ : dword; stdcall; external;
  47. procedure _api_open_r; stdcall; external;
  48. procedure _api_read; stdcall; external;
  49. procedure _api_close; stdcall; external;
  50. procedure _apfelschdrudl16; stdcall; external;
  51. procedure _THUNK_W32S; stdcall; external;
  52. procedure _CPG_GetVersion_360; stdcall; external;
  53. procedure _sprintf; stdcall;
  54. {$L sdelphi.obj }
  55. {$L haspntry_omf.obj }
  56. {$L apibchn.obj }
  57. {$L ns_bc_omf.obj }
  58. {$ENDIF}
  59. (******************************************************************************
  60. *
  61. * HASP Services
  62. *
  63. ******************************************************************************)
  64. const
  65. (* Services common to all local keys. HASP3, MEMOHASP, TIMEHASP. *)
  66. LOCALHASP_ISHASP = 1;
  67. LOCALHASP_HASPCODE = 2;
  68. LOCALHASP_HASPSTATUS = 5;
  69. HASPAPI_VERSION = 5;
  70. LOCALHASP_HASPGENERATION = 8;
  71. LOCALHASP_HASPNETSTATUS = 9;
  72. (* Services supported by HASP4. *)
  73. LOCALHASP_ENCODEDATA = 60;
  74. LOCALHASP_DECODEDATA = 61;
  75. NETHASP_ENCODEDATA = 88;
  76. NETHASP_DECODEDATA = 89;
  77. (* MemoHASP Memory services. *)
  78. MEMOHASP_READMEMO = 3;
  79. MEMOHASP_WRITEMEMO = 4;
  80. MEMOHASP_HASPID = 6;
  81. MEMOHASP_READBLOCK = 50;
  82. MEMOHASP_WRITEBLOCK = 51;
  83. (* TimeHASP clock services. *)
  84. TIMEHASP_SETTIME = 70;
  85. TIMEHASP_GETTIME = 71;
  86. TIMEHASP_SETDATE = 72;
  87. TIMEHASP_GETDATE = 73;
  88. (* TimeHASP memory services. *)
  89. TIMEHASP_READMEMO = 75;
  90. TIMEHASP_READBYTE = 75;
  91. TIMEHASP_WRITEMEMO = 74;
  92. TIMEHASP_WRITEBYTE = 74;
  93. TIMEHASP_HASPID = 78;
  94. TIMEHASP_READBLOCK = 77;
  95. TIMEHASP_WRITEBLOCK = 76;
  96. (* NetHASP network services. *)
  97. NETHASP_LASTSTATUS = 40;
  98. NETHASP_HASPCODE = 41;
  99. NETHASP_LOGIN = 42;
  100. NETHASP_LOGOUT = 43;
  101. NETHASP_LOGIN_PROCESS = 110;
  102. NETHASP_SETIDLETIME = 48;
  103. NETHASP_GET_CURRENT_SERVER = 230;
  104. (* NetHASP memory services. *)
  105. NETHASP_READMEMO = 44;
  106. NETHASP_WRITEMEMO = 45;
  107. NETHASP_HASPID = 46;
  108. NETHASP_READBLOCK = 52;
  109. NETHASP_WRITEBLOCK = 53;
  110. (* NetHASP License Manager configuration services. *)
  111. NETHASP_SET_CONFIG_FILENAME = 85;
  112. NETHASP_SET_SERVER_BY_NAME = 96;
  113. NETHASP_QUERY_LICENSE = 104;
  114. NETHASP_GETPROTOCOL = 120;
  115. NETHASP_SETPROTOCOL = 121;
  116. NETHASP_DEFAULTCONFIG = 125;
  117. (******************************************************************************
  118. *
  119. * Miscellaneous HASP API constants
  120. *
  121. ******************************************************************************)
  122. (* LPT numbers for HASP and HASP36 on PC and NEC. *)
  123. HASP25 = 0;
  124. HASP36 = 50;
  125. HASP36NEC = 60;
  126. (* Logical LPT numbers for USB. *)
  127. USBHASP_DEFAULT = 200;
  128. USBHASP_MIN = 201;
  129. USBHASP_MAX = 255;
  130. (* Capacity in bytes of each HASP type *)
  131. MEMOHASP1_CAPACITY = 112;
  132. MEMOHASP4_CAPACITY = 496;
  133. TIMEHASP_CAPACITY = 16;
  134. NETHASP_CAPACITY = 496;
  135. (* HASP type constants as returned in p2 for HaspStatus service *)
  136. HASPTYPE_HASP3 = 0;
  137. HASPTYPE_MEMOHASP = 1;
  138. HASPTYPE_TIMEHASP = 3;
  139. HASPTYPE_TIMEHASP4 = 5;
  140. (******************************************************************************
  141. *
  142. * HASP Errors
  143. * ~~~~~~~~~~~
  144. * Some symbols use the following abbreviations:
  145. *
  146. * HDD HASP Device Driver
  147. * MH MemoHASP
  148. * TH TimeHASP
  149. * NH NetHASP
  150. * NHLM NetHASP License Manager
  151. * NHCF NetHASP Configuration File
  152. * SSBN Set Server By Name
  153. *
  154. ******************************************************************************)
  155. HASPERR_SUCCESS = 0; (* Operation successful *)
  156. HASPERR_INVALID_SERVICE = -999; (* HASP Invalid Service *)
  157. HASPERR_CANT_FREE_DOSMEM = -121; (* Cannot free DOS Memory *)
  158. HASPERR_CANT_ALLOC_DOSMEM = -120; (* Cannot allocate DOS Memory *)
  159. HASPERR_DOS_CANT_CLOSE_HDD = -112; (* Cannot close the HASP Device Driver *)
  160. HASPERR_DOS_CANT_READ_HDD = -111; (* Cannot read the HASP Device Driver *)
  161. HASPERR_DOS_CANT_OPEN_HDD = -110; (* Cannot open the HASP Device Driver *)
  162. HASPERR_CANT_CLOSE_HDD = -102; (* Cannot close the HASP Device Driver *)
  163. HASPERR_CANT_READ_HDD = -101; (* Cannot read the HASP Device Driver *)
  164. HASPERR_CANT_OPEN_HDD = -100; (* Cannot open the HASP Device Driver *)
  165. HASPERR_NOT_A_TIMEHASP = -29; (* A HASP was found but it is not a TimeHASP *)
  166. HASPERR_TH_INVALID_PASSWORDS = -28; (* A HASP with specified passwords was not found *)
  167. HASPERR_TH_TIMEOUT = -27; (* Timeout - Write operation failed *)
  168. HASPERR_TH_INVALID_ADDRESS = -26; (* Invalid address - Address is not in 0 - 15 *)
  169. HASPERR_TH_INVALID_HOUR = -25; (* Invalid Hour *)
  170. HASPERR_TH_INVALID_MINUTE = -24; (* Invalid Minute *)
  171. HASPERR_TH_INVALID_SECOND = -23; (* Invalid Second *)
  172. HASPERR_TH_INVALID_YEAR = -22; (* Invalid year *)
  173. HASPERR_TH_INVALID_MONTH = -21; (* Invalid month *)
  174. HASPERR_TH_INVALID_DAY = -20; (* Invalid day *)
  175. HASPERR_VERSION_MISMATCH = -13; (* Driver version mismatch *)
  176. HASPERR_INVALID_PARAMETER = -12; (* Invalid parameter *)
  177. HASPERR_TS_SP3_FOUND = -11; (* Terminal Server under SP3 is not supported *)
  178. HASPERR_TS_FOUND = -10; (* Terminal Server was found. *)
  179. HASPERR_INVALID_POINTER = -9; (* Invalid pointer used by Encode Data *)
  180. HASPERR_HARDWARE_NOT_SUPPORTED = -8; (* The hardware does not support the service *)
  181. HASPERR_DATA_TOO_SHORT = -7; (* The data length is too short *)
  182. HASPERR_PORT_BUSY = -6; (* Parallel port is busy. *)
  183. HASPERR_MH_WRITE_FAIL = -5; (* Unsuccessful Write operation *)
  184. HASPERR_NOT_A_MEMOHASP = -4; (* A HASP was found but it is not a MemoHASP *)
  185. HASPERR_MH_INVALID_PASSWORDS = -3; (* A HASP with specified passwords was not found *)
  186. HASPERR_HASP_NOT_FOUND = -3; (* A HASP with specified passwords was not found *)
  187. HASPERR_MH_INVALID_ADDRESS = -2; (* Address out of range *)
  188. HASPERR_MH_TIMEOUT = -1; (* Timeout - Write operation failed *)
  189. HASPERR_NO_PROTOCOLS = 1; (* IPX, NetBIOS, or TCP/IP protocols have not been installed properly. *)
  190. HASPERR_NO_SOCKET_NUMBER = 2; (* Communication Error - unable to get the socket number (TCP/IP, IPX) *)
  191. HASPERR_COMM_ERROR = 3; (* Communication Error. *)
  192. HASPERR_NO_NHLM = 4; (* No NetHASP License Manager was found. *)
  193. HASPERR_NO_NHLM_ADDRFILE = 5; (* Cannot read NetHASP License Manager address file *)
  194. HASPERR_CANT_CLOSE_NHLM_ADDRFILE = 6; (* Cannot close NetHASP License Manager address file *)
  195. HASPERR_CANT_SEND_PACKET = 7; (* Communication error - failed to send packet (IPX, NetBIOS *)
  196. HASPERR_SILENT_NHLM = 8; (* No answer from the NetHASP License Manager. *)
  197. HASPERR_NO_LOGIN = 10; (* Service requested before LOGIN *)
  198. HASPERR_ADAPTER_ERROR = 11; (* NetBIOS: Communication error - adapter error *)
  199. HASPERR_NO_ACTIVE_NHLM = 15; (* No active NetHASP Licence Manager was found *)
  200. HASPERR_SSBN_FAILED = 18; (* Cannot perform LOGIN - SetServerByName failed *)
  201. HASPERR_NHCF_SYNTAX_ERROR = 19; (* NetHASP configuration file syntax error *)
  202. HASPERR_NHCF_GENERIC_ERROR = 20; (* Error handling NetHASP configuration file *)
  203. HASPERR_NH_ENOMEM = 21; (* Memory allocation error *)
  204. HASPERR_NH_CANT_FREE_MEM = 22; (* Memory release error *)
  205. HASPERR_NH_INVALID_ADDRESS = 23; (* Invalid NetHASP memory address *)
  206. HASPERR_NH_ENCDEC_ERR = 24; (* Error trying to Encrypt/Decrypt *)
  207. HASPERR_CANT_LOAD_WINSOCK = 25; (* TCP/IP: failed to load WINSOCK.DLL *)
  208. HASPERR_CANT_UNLOAD_WINSOCK = 26; (* TCP/IP: failed to unload WINSOCK.DLL *)
  209. HASPERR_WINSOCK_ERROR = 28; (* TCP/IP: WINSOCK.DLL startup error *)
  210. HASPERR_CANT_CLOSE_SOCKET = 30; (* TCP/IP: Failed to close socket. *)
  211. HASPERR_SETPROTOCOL_FAILED = 33; (* SetProtocol service requested without performing LOGOUT *)
  212. HASPERR_NH_NOT_SUPPORTED = 40; (* NetHASP services are not supported *)
  213. HASPERR_NH_HASPNOTFOUND = 129; (* NetHASP key is not connected to the NetHASP Licence Manager *)
  214. HASPERR_INVALID_PROGNUM = 130; (* Program Number is not in the Program List of the NetHASP memory *)
  215. HASPERR_NH_READ_ERROR = 131; (* Error reading NetHASP memory *)
  216. HASPERR_NH_WRITE_ERROR = 132; (* Error writing NetHASP memory *)
  217. HASPERR_NO_MORE_STATIONS = 133; (* Number of stations exceeded *)
  218. HASPERR_NO_MORE_ACTIVATIONS = 134; (* Number of activations exceeded *)
  219. HASPERR_LOGOUT_BEFORE_LOGIN = 135; (* LOGOUT called without LOGIN *)
  220. HASPERR_NHLM_BUSY = 136; (* NetHASP Licence Manager is busy *)
  221. HASPERR_NHLM_FULL = 137; (* No space in NetHASP Log Table *)
  222. HASPERR_NH_INTERNAL_ERROR = 138; (* NetHASP Internal error *)
  223. HASPERR_NHLM_CRASHED = 139; (* NetHASP Licence Manager crashed and reactivated *)
  224. HASPERR_NHLM_UNSUPPORTED_NETWORK = 140; (* NetHASP Licence Manager does not support the station's network *)
  225. HASPERR_NH_INVALID_SERVICE_2 = 141; (* Invalid Service NetHASP Licence Manager does not support the station's network *)
  226. HASPERR_NHCF_INVALID_NHLM = 142; (* Invalid NetHASP Licence Manager name in configuration file *)
  227. HASPERR_SSBN_INVALID_NHLM = 150; (* Invalid NetHASP Licence Manager name in SetServerByName *)
  228. HASPERR_ENC_ERROR_NHLM = 152; (* Error trying to encrypt by the LM *)
  229. HASPERR_DEC_ERROR_NHLM = 153; (* Error trying to decrypt by the LM *)
  230. HASPERR_OLD_LM_VERSION_NHLM = 155; (* LM old version was found *)
  231. (******************************************************************************
  232. *
  233. * NetHASP Warnings
  234. *
  235. ******************************************************************************)
  236. HASPERR_IPX_UNAVAILABLE = 1; (* IPX is enabled but it is not installed *)
  237. HASPERR_NETBIOS_UNAVAILABLE = 2; (* NetBIOS is enabled but it is not installed *)
  238. HASPERR_IPX_NETBIOS_UNAVAILABLE = 3; (* IPX and NetBIOS are enabled but both are not installed *)
  239. HASPERR_TCPIP_UNAVAILABLE = 4; (* TCP/IP is enabled but it is not installed *)
  240. HASPERR_IPX_TCPIP_UNAVAILABLE = 5; (* IPX and TCP/IP are enabled but both are not installed *)
  241. HASPERR_TCPIP_NETBIOS_UNAVAILABLE = 6; (* TCP/IP and NetBIOS are enabled but are not installed *)
  242. HASPERR_PROTOCOLS_UNAVAILABLE = 7; (* IPX; NetBIOS and TCP/IP are enabled but not installed *)
  243. HASPERR_SUSPICIOUS_LOGOUT = 18; (* Suspicious LOGOUT *)
  244. HASPERR_NHCF_BAD_TOKEN = 19; (* Invalid keyword or value in configuration file *)
  245. HASPERR_MISSING_IP_ADDR = 20; (* TCP or UDP were not employed due to missing IP address *)
  246. HASPERR_CANT_FREE_MEM = 22; (* HASP API cannot free memory *)
  247. implementation
  248. procedure hasp ( Service,
  249. SeedCode,
  250. LptNum,
  251. Pass1, Pass2 : longint;
  252. var p1, p2, p3, p4 : longint);
  253. begin
  254. _hasp(Service, SeedCode, LptNum, Pass1, Pass2, p1, p2, p3, p4);
  255. end;
  256. function _rand : integer; stdcall;
  257. begin
  258. if not HaspRandInitialized then begin
  259. Randomize;
  260. HaspRandInitialized:= TRUE;
  261. end;
  262. _rand:= random(maxint);
  263. end;
  264. procedure _sprintf; stdcall;
  265. begin
  266. end;
  267. {$IFDEF HASPAPI_OPT_O}
  268. {$O+}
  269. {$UNDEF HASPAPI_OPT_O}
  270. {$ENDIF}
  271. end.