Wednesday, December 21, 2016

Windows does not keep track of last-access time by default

One might wonder why the last-access time never seems to update when files are opened. After all, a file has to be accessed to open its contents.

The reason is that Windows, as of Vista, no longer updates the last-access time by default because that would involve a write every time a file is opened, even if it was just supposed to be a read. If you really want that updating back, you can run this command:

fsutil behavior set DisableLastAccess 0

Based on my Super User answer.

Tuesday, December 20, 2016

When does text direction get affected by a previous RTL character?

Suppose you have this text in a text field:

abc123'ߡ'

That triangle character is U+07E1 NKO LETTER MA. It's marked as a right-to-left character, since it comes from the N'Ko alphabet, which is written from right to left.

Now for some experiments. Try typing a number after the triangle but before the closing quote. It will appear to be inserted before the triangle! Hit Backspace, then move to the very end of the string. Type a normal dash. It's not teleported. That character's bidi class is "European separator", which is listed as weak. But now type a number after that, and the string gets shuffled into this:

abc123'ߡ'-4

The order of the last quote, hyphen, and number appears to be flipped. Interestingly, digits have the "European number" bidi class, which is also weak. So why did the number cause the flip?

Unicode RTL rendering rules mandate that number characters (that don't already have their direction forced upon them) take on the direction of the last character behind them that had a strong preference. Neither the quote nor the hyphen did, so the new number becomes RTL, and it takes the in-between characters along for the ride.

Based on my Super User answer.

Monday, December 19, 2016

Holding an executable inside a batch file

Suppose you want to include an EXE inside a batch file and have the batch script extract the program from itself and run it. Just pasting the EXE into the file will almost certainly butcher it, because programs are binary files and batch scripts are text files. Therefore, you'll need to encode the binary data.

Start with this batch file:

@echo off
powershell -command "[IO.File]::WriteAllBytes('extracted.exe', [Convert]::FromBase64String((gc '%0')[-1]))"
extracted
del extracted.exe
exit

REM Base64-encoded program will be inserted below


The extra blank line at the end is important.

Notice that the PowerShell script embedded in the second line takes a Base64 string from the end of the batch file. To put it there, use this PowerShell command:

[Convert]::ToBase64String([IO.File]::ReadAllBytes('C:\fullPathTo\file.exe')) | Out-File 'batchFile.bat' -Append -Encoding ASCII

Running the batch file will decode the executable, save it to disk, run it, and delete it once it finishes.

Based on my Super User answer.

Sunday, December 18, 2016

AbiathRPC - Anonymous is not a person

Today I realized that the usefulness of the VeriMapsApproved setting (which allows any VeriMaps-authenticated user to connect) for the AbiathRPC server is undermined by the public availability of the Anonymous key. Server operators might enable that option think it will allow in known members of the community - since only I can issue new certificates - but it actually allows anyone who bothers to download the Anonymous key. Therefore, I made that account an exception to the approval granted by that server option.

If server operators want to allow the Anonymous certificate to be used for authentication, they can still add it as a normal account without a password.

Saturday, December 17, 2016

AbiathRPC - Save levels locally

If you're working on a leveling project with some people, it's great to have a centralized copy of the levels (on the AbiathRPC server), but you also need to be able to get the newest version so you can test your changes in a game. Today, I added an option to the RPC menu that saves the current state of the levels to local files. Its implementation is very straightforward; the only special thing it does is check for the presence of a GAMEMAPS file in the current folder and fill the suggested file names with that file's extension.

Friday, December 16, 2016

AbiathRPC - Administration GUI

Yesterday I wrote the AbiathRPC server functions for user management. Today I put together the client UI that actually uses those.


In the above screenshot, Anonymous can only authenticate with VeriMaps; it has no password set. It is also a server administrator. The Test account can authenticate with a password, but it is not an admin.

The buttons are fairly intuitive: New Account adds a user, Set Password adds or sets a password for a selected user, Disable Password removes a user's password (allowing VeriMaps only), Promote/Demote toggles administrative privileges, and Delete Account removes the account from the server's configuration.

Changes to user configuration are saved to disk when the server shuts down.

Thursday, December 15, 2016

AbiathRPC - Administration APIs

There should definitely be a way for AbiathRPC server operators to manage their servers without having to actually remote in to the host machine, stop the server program, fiddle a textual config file, and restart the program. I think it makes sense for some management tools to be included in the Abiathar extension itself. So today I added a few WCF endpoints on the server: to get the allowed users, to delete a user, to create a user, to reset a user's password, and to set a user's access level. Those are all implemented, but I haven't yet put together a GUI on the client to use them.

I also adjusted the part of the server that decides a newly connected user's authentication plan. Now, even on an open-access server, users with a definite password will actually be required to enter their password if they use their registered username. Users without accounts are still free to pick whatever name they want and use it with no special access or authentication.