Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

3ds max 2024 .ini file read/write error?

k.alexandrov
Participant

3ds max 2024 .ini file read/write error?

k.alexandrov
Participant
Participant

Hi,

I have a custom rollout floater toolbar that reads/writes setting in a .ini file, which is located in #userscripts.  After updating from 3dsMax 2020 to 3dsMax 2024, the new security feature is blocking the read/write to that file due to suspicion of malicious code execution. 
Probably, the reason for this is the fact that the macroscript in #usermacros is only container that is calling the script from a separate network directory with filein command and the whole code related to the .ini file is stored in the that file. 
How can I resolve this issue or is there any workaround?  

0 Likes
Replies (7)

denisT.MaxDoctor
Advisor
Advisor

Based on your description, I can conclude that there is nothing secret in the contents of this MCR file... So send the complete file, and then I can tell you if and how the problem can be solved.

0 Likes

k.alexandrov
Participant
Participant

Hi @denisT.MaxDoctor,

 

Thank you for helping me with this headache! Here is the source code: 

 

macroScript RV_Tools
Category: "RV Tools"
tooltip: "RV Tools"
buttonText:"RV Tools"
icon: #("RVTools",1)


(	
	local RVT_UserPath = ((getDir #userScripts) + "\RV_Tools\\")
	local RVT_INIfile = RVT_UserPath + "RV_Tools.ini"
	local RV_tools_path = getINISetting RVT_INIfile "UIpaths" "RVtoolsPath" 
	
		function fn_SetPath =
		(
			
			local NewPath = undefined 
			NewPath = getSavePath () + "\\"
			
			if NewPath != undefined then (				

			setINISetting RVT_INIfile "UIpaths" "RVtoolsPath" NewPath
				return true;
			) else (return false;)
			
		)

	on execute do(
		if doesFileExist (RV_tools_path + "\\" + "RV_Tools.ms") then
						(
						filein (RV_tools_path + "\\" + "RV_Tools.ms")
						)
					else(
						if doesFileExist RV_tools_path 
									then(
											if queryBox "@RV_Tools.ms@ does not exist in the folder. Change the folder?"  then (
												if fn_setPath() then (
													RV_tools_path = getINISetting RVT_INIfile "UIpaths" "RVtoolsPath" 
													filein (RV_tools_path + "\\" + "RV_Tools.ms")
													) else())
											)
											else(
												if queryBox "Folder does not exist. Change it?"  then (
												if fn_setPath() then (
													RV_tools_path = getINISetting RVT_INIfile "UIpaths" "RVtoolsPath" 
													filein (RV_tools_path + "\\" + "RV_Tools.ms"
														)) else())
												)
							
							)
						)
)

 

 

As you can see, the MCR is calling a MS file from a remote directory, which stores the actual code. In that MS file there are functions for reading/writing to that same .ini file and the Security Preference is blocking them. 

 

 I suspect that the problem appears because the MCR is calling a MS from the server, which is writing settings into INI in the local machine. (position, opened rollouts, size, docking state and etc.)

Probably Security preference is preventing malicious codes from behaving like that but this is a controlled network and intentional behavior. The reason for that is to share the same source code across multiple workstations, while in the same time it is handled from a single file, globally. I can not find is any information for whitelisting in that new(to me) security feature. Any ideas?

 

Looking forward to your response,

Kiril

0 Likes

denisT.MaxDoctor
Advisor
Advisor

I don't see anything wrong with the code that would confuse the security system. Do you have any warnings or error messages from the system or security tool while running the code or loading the MAX?

0 Likes

k.alexandrov
Participant
Participant

Yep, the code in the MCR is perfectly fine and there is no problem when the MCR tries to access the INI file. The problem appears after the MCR runs the MS file and this MS file tries to write in the INI. In general, the tool is working flawlessly in 3dsMax 2020 environment, while in 2024, the Security Preference is blocking filein-ed MS files from writing into INI files.

0 Likes

denisT.MaxDoctor
Advisor
Advisor

Try this MCR. I hope it is easy to understand how it works.

 

macroscript TEST_FILEIN
	category:"TESTS"
	buttonText:"TEST FILEIN"
	toolTip:"TEST_FILEIN"
	autoUndoEnabled:off
	silentErrors:off
(
	local filepath = pathConfig.appendPath (getdir #temp) @"test.ms"
	local filebody = 
"
try(destroydialog test_rol) catch ()
rollout test_rol \"RO:5D42632A\" width:191
(
	button test_bt \"Test\" width:180 	
	on test_bt pressed do
	(
		format \"\\t\\ttest...\\n\"
	)
)
createdialog test_rol
"
	
	on execute do
	(
		if not doesfileexist filepath then
		(
			fs = createfile filepath
			if fs != undefined do 
			(
				format filebody to:fs
				format ">> make file... %\n" filepath
				close fs
			)
		)
		else
		(
			format "\t >> filein...\n"
			filein filepath
			deletefile filepath
		)
	)
)

 

 

It works as expected for me in 2023.

 

0 Likes

denisT.MaxDoctor
Advisor
Advisor

Here is a new, more advanced test:

 

macroscript TEST_FILEIN
	category:"TESTS"
	buttonText:"TEST FILEIN"
	toolTip:"TEST_FILEIN"
	autoUndoEnabled:off
	silentErrors:off
(
	local filepath = pathConfig.appendPath (getdir #temp) @"test.ms"
	local filebody = 
"
try(destroydialog test_rol) catch ()
rollout test_rol \"RO:5D42632A\" width:191
(
	local ini_file = pathConfig.appendPath (getdir #temp) @\"max_tests.ini\"
	
	button test_bt \"...\" width:180 	
	on test_bt pressed do
	(
		format \"\\t\\ttest...\\n\"
	)
	on test_rol open do
	(
		if doesfileexist ini_file do test_bt.text = getINISetting ini_file #test_filein #the_time
	)
)
createdialog test_rol
"
	local ini_file = pathConfig.appendPath (getdir #temp) @"max_tests.ini"
	local the_time = if doesfileexist ini_file do getINISetting ini_file #test_filein #the_time
	
	on execute do
	(
		if not doesfileexist filepath then
		(
			fs = createfile filepath
			if fs != undefined do 
			(
				format filebody to:fs
				format ">> make file... %\n" filepath
				close fs
			)
		)
		else
		(
			format "\t >> settings... %\n" localTime			
			setINISetting ini_file #test_filein #the_time localTime
			
			format "\t >> filein...\n"
			filein filepath
			deletefile filepath
		)
	)
)

 

 

It confirms that the getinisettings, setinisettings, and filein functions work as expected in the MCR file for MAX 2023. Although there was no way to test them on the MAX 2024 version, I assume that the relevant section of the security tools has not been changed from the previous version.

 

0 Likes

denisT.MaxDoctor
Advisor
Advisor

My last example shows that there are no unexpected limitations due to security tool rules. The only recommendation is to move the functionality code of the fn_SetPath function from the body of the macros to the execute block.

0 Likes