Hello Guest it is April 17, 2024, 09:54:26 PM

Author Topic: Mach4 PCID to get for LUA.  (Read 2587 times)

0 Members and 1 Guest are viewing this topic.

Mach4 PCID to get for LUA.
« on: December 28, 2017, 03:15:28 AM »
Hi,
Can I get a PCID for LUA?
I want my module to be used only on a specific copy of Mach4.
How is this best done?

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Mach4 PCID to get for LUA.
« Reply #1 on: December 28, 2017, 03:45:14 AM »
To get the PCID as in the same as you use for your Mach4 License then you can get it using

Code: [Select]
local inst = mc.mcGetInstance()
local PCID = mc.mcCntlGetComputerID(inst)
wx.wxMessageBox(PCID)

from here then just use an if statement to compare IE

Code: [Select]
if (PCID == "key to match") then
Succces
end

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Mach4 PCID to get for LUA.
« Reply #2 on: December 28, 2017, 05:18:53 AM »
Thank you, DazTheGas.
mcCntlGetComputerID is in Mach4CoreAPI, I did not read well   ::)
Made reading the file Mach4Lic.dat, but I will use mcCntlGetComputerID
Code: [Select]
local inst = mc.mcGetInstance()
local Mach4Lic = io.open("C:\\Mach4Hobby\\Licenses\\Mach4Lic.dat","r")
if not Mach4Lic then
    wx.wxMessageBox("Fail open Mach4Lic.dat!")
else
    local a = Mach4Lic:seek("set", 329)
    local b = Mach4Lic:read (10)
    Mach4Lic:close()
    local c = 'AAEAAAzPf9'
    if b ~= c then
        wx.wxMessageBox("Fail licensed module!")
    end
end
The problem is using a license check. If you put the script in "Screen Load Script" then it can be removed from there.
If you use the password (Operator - Lock), then it can be reset to "Machine.ini".
If you put the script in the module, then what is it to bind to? "Enable" button? Then you can go into "Edit Screen" and remove the function call in the module ...

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Mach4 PCID to get for LUA.
« Reply #3 on: December 28, 2017, 06:01:35 AM »
Just compile your module and include the PCID check within it, then its not readable.
Have a look at one of the mcc files in your macro folder to see what a compiled file looks like.
DazTheGas
New For 2022 - Instagram: dazthegas
Re: Mach4 PCID to get for LUA.
« Reply #4 on: December 28, 2017, 06:16:48 AM »
I compiled the module into mcc.
I can not figure out what to do if the key is not checked ...

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Mach4 PCID to get for LUA.
« Reply #5 on: December 28, 2017, 06:59:51 AM »
This isnt tested but should give you an idea.

Code: [Select]
local MyModule = {}

function PCID_CHECK() -- this becomes a private function that users cant access
local inst = mc.mcGetInstance()
local PCID = mc.mcCntlGetComputerID(inst)
if (PCID == "key to match") then
return
else
package.loaded.MyModule = nil -- unload the module so it cant be used
end
end

function MyModule.whatever()
PCID_CHECK() -- include where-ever you like
-- rest off function
end

return MyModule

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Mach4 PCID to get for LUA.
« Reply #6 on: December 28, 2017, 07:25:32 AM »
package.loaded.MyModule = nil -- unload the module so it cant be used
Thank you will test.
Re: Mach4 PCID to get for LUA.
« Reply #7 on: December 29, 2017, 08:09:33 AM »
It works now:  ;D
Code: [Select]
local testmod = require "mymodule"
testmod = nil
package.loaded["mymodule"] = nil