Password Protect User C Programs
Posted: Wed Jun 29, 2022 2:58 pm
Hello!
There is a file called KflopToKMotionCNCFunctions.c that contains a function called InputBox. It is as follows
#define GATH_OFF 0
int InputBox(char *s, float *value)
{
char *p=(char *)gather_buffer+GATH_OFF*sizeof(int);
int i;
do
{
*p++ = *s++;
} while (s[-1]);
DoPCInt(PC_COMM_INPUT, GATH_OFF);
*value = *(float *)&persist.UserData[PC_COMM_PERSIST+2];
return persist.UserData[PC_COMM_PERSIST+3];
}
I've been using that function to bring up a dialog box and input a value. The two options in the box are "Cancel" and "Set". I am able to use this to set and retrieve a password locking out certain functions for the CNC. However, when this function is called again, there is a dropdown box that includes the last 11 entries into that box. If you close KMotionCNC.exe and reopen it, those entries are cleared out. I would like to clear out those entries after every input but I'm having trouble finding them. I tried searching for some of the passwords in the KMotion folder and nothing came up. I tried looking at the persist.UserData and there was nothing in there. The only thing I haven't checked so far is the gather_buffer as a potential location holding onto all those values. The issue here is that someone could put in the correct password and then someone who shouldn't have access could just look at the previous entries.
Do you know where KMotionCNC stores previous data from dialog boxes?
There is a file called KflopToKMotionCNCFunctions.c that contains a function called InputBox. It is as follows
#define GATH_OFF 0
int InputBox(char *s, float *value)
{
char *p=(char *)gather_buffer+GATH_OFF*sizeof(int);
int i;
do
{
*p++ = *s++;
} while (s[-1]);
DoPCInt(PC_COMM_INPUT, GATH_OFF);
*value = *(float *)&persist.UserData[PC_COMM_PERSIST+2];
return persist.UserData[PC_COMM_PERSIST+3];
}
I've been using that function to bring up a dialog box and input a value. The two options in the box are "Cancel" and "Set". I am able to use this to set and retrieve a password locking out certain functions for the CNC. However, when this function is called again, there is a dropdown box that includes the last 11 entries into that box. If you close KMotionCNC.exe and reopen it, those entries are cleared out. I would like to clear out those entries after every input but I'm having trouble finding them. I tried searching for some of the passwords in the KMotion folder and nothing came up. I tried looking at the persist.UserData and there was nothing in there. The only thing I haven't checked so far is the gather_buffer as a potential location holding onto all those values. The issue here is that someone could put in the correct password and then someone who shouldn't have access could just look at the previous entries.
Do you know where KMotionCNC stores previous data from dialog boxes?