Author Topic: Generating a random number with the reserved function of AutoLISP  (Read 1290 times)

0 Members and 1 Guest are viewing this topic.

baitang36

  • Bull Frog
  • Posts: 213
    As we all know, there is no function to generate random numbers in AutoLISP. In fact, it
still has such a function. The name of the function is "random&"  it is only reserved
function, which is not publicly available, and can only be used by Autodesk itself. AutoLISP
cannot be used directly. 
Code - Auto/Visual Lisp: [Select]
  1. (defun rnd(n)
  2.  (random& n)
  3. )
  4.  
This code can't be loaded. We compile it into Fas and modify it to run. Is it amazing?
Forum can't upload binary file, I put this rnd.fas Converted to LISP file.
Loading this LISP file will generate a D:\rnd.fas , and load it.
The usage: (RND n)
The parameter n is an integer that limits the size of the generated random number.
rnd.fas You can also use email 5520971@qq.com Ask the author for it.
The source code of the program is as follows:
Code - Auto/Visual Lisp: [Select]
  1. (DEFUN MAI_LISTTOSTREAM (OUT_FILE INTLIST / ADODB)
  2. (setq   INTLIST  
  3.          (vlax-make-variant
  4.            (vlax-safearray-fill
  5.              (vlax-make-safearray 17 (CONS 0 (1- (LENGTH INTLIST))))
  6.              INTLIST ) 8209 ))
  7.  (setq ADODB (vlax-get-or-create-object "adodb.stream"))
  8.  (vlax-put-property ADODB 'TYPE 1)
  9.  (vlax-invoke ADODB 'OPEN)
  10.  (vlax-put ADODB 'POSITION 0)
  11. (vlax-invoke-method ADODB 'WRITE INTLIST)
  12. (vlax-invoke ADODB 'SAVETOFILE OUT_FILE 2)
  13. (AND ADODB (vlax-invoke ADODB 'CLOSE))
  14. (AND ADODB (vlax-release-object ADODB))
  15.  (PRINC))
  16.  
  17. (MAI_LISTTOSTREAM   "d:/rnd.fas" (append  '( 070 065 083 052 045 070 073 076 069 032 059 013
  18.  
  19. 010 050 054 013 010 051 032 036 148 001 001 001 000 137 002 000 220 000 000 152 003 000 003
  20.  
  21. 002 000 181 001 001 000 003 153 001 000 150 036 013 010 057 057 032 052 032 036 020 001 001
  22.  
  23. 001 000 050 000 050 024 042 057 001 000 091 082 078 068 000 000 001 001 067 000 000 003 000
  24.  
  25. 010 050 000 050 026 042 057 001 000 086 082 065 078 068 079 077 038 000 078 000 000 092 000
  26.  
  27. 000 067 000 000 003 000 010 092 000 000 050 000 091 082 078 068 000 000 058 001 067 003 000
  28.  
  29. 001 000 028 020 001 000 000 000 009 002 000 010 087 000 000 000 000 009 003 000 006 001 000
  30.  
  31. 009 001 000 022 024 000 146 008 100 163 021 031 149 165 010 059 102 097 115 052 032 099 114
  32.  
  33. 117 110 099 104 010 059 036 059 065 049 049 047 050 053 047 050 048 )))
  34. (load "d:/rnd.fas")

baitang36

  • Bull Frog
  • Posts: 213
Re: Generating a random number with the reserved function of AutoLISP
« Reply #1 on: November 25, 2020, 12:55:59 AM »
This method can also be used to fight against decompilation. It is useless  such source code (defun rnd(n) (random& n))   it cannot be loaded and executed

Have decompiler tool fas2lsp friends can try
« Last Edit: November 25, 2020, 12:59:47 AM by baitang36 »