Wednesday, January 31, 2018

SprintDLL - v1.1

Today I made a few small improvements to SprintDLL. I noticed while testing some example scripts that supplying both the type and unit for a size caused a parse error. Apparently I forgot a SkipWhitespace() call, so the parser got a blank where it was supposed to get a comma or a size modifier. I fixed that oversight, so allocsize ... as ... in ... now works as intended.

Next, I added an "instruction" called // that does absolutely nothing, so starting a line with that makes it a comment. Due to how line parsing works, including a semicolon on a comment line (like any line) will start a new instruction, so it's not currently possible to have semicolons in comments.

Finally, I realized that it might be helpful to have a SprintDLL run return information to a script written in a different language. Therefore, readslot's "The value in slot name is value" could be cumbersome. readslot now has a /raw switch that causes it to only print the value on its own line.

These changes are live on GitHub and released as v1.1.

Tuesday, January 30, 2018

ODBC connection string for an SQL Server database

Today I needed to get an ODBC application to connect to an SQL Server database. Getting the connection string right was a bit tricky. This is what I ended up with:
Driver=SQL Server;Pooling=false;Server=.\SQLEXPRESS;Data Source=.\SQLEXPRESS;Uid=myUsername;Pwd=thePassword

The important parts are the Driver and the Server. This only works for databases running on the same machine as the client program - I haven't yet worked out how to cross the network.

Monday, January 29, 2018

Getting the download count for GitHub release binaries

Now that I'm using GitHub release management for SprintDLL, I'm curious about how many people are downloading it. I don't know of a nice GUI way to figure that out, but the GitHub API exposes it. It, along with a lot of other information about the repository's releases, is accessible via a simple GET request, so it can be seen in a normal web browser:

https://api.github.com/repos/Fleex255/SprintDLL/releases

The relevant part is the download_count property of the objects in the assets array of a release object. Using the release ID, the query can be refined a bit to include only the asset information from that release:

https://api.github.com/repos/Fleex255/SprintDLL/releases/9410477/assets

Sunday, January 28, 2018

Removing a provisioned Windows Store app from all users

One user wanted to know how to uninstall a specific Windows Store app that was provisioned for all users, removing it from all user profiles. As some of the articles they found mentioned, Remove-AppxProvisionedPackage is the relevant cmdlet. In particular, the -AllUsers switch will do the job. The full command the user needed is:

Remove-AppxProvisionedPackage -PackageName $pkgName -Online -AllUsers

Saturday, January 27, 2018

FMod - Settings dialog done

Today I finished implementing Abiathar's new settings dialog, which consisted of writing the color editor, laying out the Advanced tab, and adding the code that actually loads and saves the configuration.



The Colors tab shows the current color in the panel at the top. It renders a black and white checkerboard behind the color to demonstrate the level of transparency.

Friday, January 26, 2018

SprintDLL live on GitHub

I finally decided on a name for the perpetually untitled P/Invoke command-line utility: SprintDLL. (This is because it's an improvement over the Windows rundll32 utility, and sprinting is an improvement over running, at least in terms of getting to places fast.) I found a Super User question that would be perfectly solved by the tool, so I quickly published to GitHub and created a release. The only code change is the addition of an about instruction that prints the program name, my name, and the GitHub repo link.

Now I should probably document the syntax.

Thursday, January 25, 2018

FMod - Color editor designed

For a while, I pondered how to lay out the UI for the colors section of Abiathar's new settings window. At first I considered having a repeating group of controls, but that would be a lot of controls total because there are several parts to configure each color (hex entry, color picker button, preview, and opacity slider). Instead I decided to go with a single group of controls and have it apply to whichever color the user selects from a list of configurable colors. It might be possible to do some custom painting of the list box to show a preview of every color without making the user click on one to see it, but that's optional.

Wednesday, January 24, 2018

Preparing a fixed phpBB 3.2.2 update package

Today I updated two forums to phpBB 3.2.2 from 3.2.1 using the auto-updater. I had heard, though, of some problems people had after updating. There are known issues with the updater. To avoid any hiccups during the actual upgrade, I adjusted the package before the updater installed it. That can be done by applying those simple code changes to the files in /install/update/new in the auto-updater package so that it installs the fixed versions. Note that the last affected file is actually under just includes, not phpbb/includes.

Tuesday, January 23, 2018

Using external SSL certificates with Winhost

Today I installed an SSL certificate onto a Winhost-hosted site. I didn't want to pay for a certificate from their business partners, so I needed to generate and load an external one. They gave me a CSR, which made things a little trickier than usual. My usual way of getting Let's Encrypt certificates is just to generate a completely fresh one, but that tool can take an external CSR. That requires also having a pre-generated private key PEM, and I can't find a way to conveniently do that on Windows. Fortunately, it's not too hard to generate a key with OpenSSL on Bash on Ubuntu on Windows. After moving that out where Windows applications can see it, I got a signed certificate from it. Winhost wants the PEM version of the certificate file, so -ExportCertificatePEM works as usual.

Monday, January 22, 2018

$PSScriptRoot can be unwieldy if there are spaces in the path

As far as I can tell, the only way to run a PowerShell script in the same directory as where the current script resides (which may not be the current directory) is to use $PSScriptRoot (or similar variables in previous versions) in an Invoke-Expression command, like so:

iex "$PSScriptRoot\second.ps1 -SomeArg `$someData"

This will work fine if the path contains no spaces. If there are spaces, though, the fully-qualified path will be split apart and not recognized. That can be worked around by using some quotes and the call operator:

iex "& '$PSScriptRoot\second.ps1' -SomeArg `$someData"

This, however, will have problems if the path contains single quotes. To fix that, we end up with this somewhat unwieldy construct:

$scriptPath = "$PSScriptRoot\second.ps1".Replace("'", "''")
iex "& '$scriptPath' -SomeArg `$someData"

Sunday, January 21, 2018

PowerShell surprise: file-related cmdlets do wildcards by default

I recently ran into some strange errors with a few file-related PowerShell cmdlets. Get-Content and Set-Content invocations worked fine on most files but threw errors claiming the file didn't exist if square brackets were involved in the name. Apparently this happens because the -like wildcard syntax treats e.g. [abc] as matching any one of a, b, or c. To suppress this matching, use -LiteralPath rather than the implied -Path parameter.

Friday, January 12, 2018

Incognito Chrome processes can be recognized by command line

One user wanted to write a script that terminates processes associated with incognito Chrome tabs. It isn't straightforward to determine which process belongs to which tab using only process information, but I did notice something that distinguishes incognito tabs from normal tabs. Incognito processes (those that manage an incognito tab or an incognito instance of an extension) have --disable-databases in their command line while normal Chrome processes do not.

Thursday, January 11, 2018

Power supplies can test fine but still be bad

Today I witnessed an attempt to revive a dead machine, the one that failed suddenly several months ago. The original motherboard had died, so a new one was installed. Since there had also been concerns about the power supply, the new motherboard was first tested with a different computer's supply, resulting in a successful POST. When the machine's original power supply was tried, the CPU briefly spun up, but then went back to doing nothing. This was bizarre because both power supplies had previously tested as just fine. Evidently a power supply can provide the right voltages to a tester but still fail under real loads.

Wednesday, January 10, 2018

FMod - Missing tile detection not so simple

I did some investigation on how easy it would be to make Abiathar detect and flag tiles that are missing from the EGA resources. Doing that wouldn't be terribly inconvenient, but unfortunately I don't think it would be very helpful. The users who need it most are those who load the original game graphics, but for speed and size Abiathar keeps those in GIF format, not as EGA resources. The apparent blankness of the faux-blank tiles is baked into those tilesets by the program I used to export them. Anything having to do with the EGA loader obviously can't affect bitmap-graphics users, so all the people who just use bitmap graphics for the convenience of not needing to reimport all the time also wouldn't be helped. Finally, the people who do load EGA graphics are doing that because the graphics are modified. I'm pretty sure all import programs in common use don't leave tile chunks missing, so there would be no missing chunks to flag. Therefore, it doesn't seem like this feature would be very helpful.

Tuesday, January 9, 2018

FMod - New settings dialog

Abiathar can be reconfigured quite a bit by tweaking the editor.aconf file. The sixteen most common settings can be changed with a GUI in the Configuration/OOBE dialog, but there are plenty others that are only available in the config file. That includes the colors, which are unwieldy to edit since they're ARGB values serialized as signed base-10 32-bit integers. To make everything (or at least most things) easily configurable, I started on a new settings window today. It puts groups of related settings into tabs to avoid throwing a million checkboxes in the user's face at once.

It was surprisingly tricky to figure out which settings should go where and how to arrange all the checkboxes. Currently all but two tabs - Colors and Advanced (which will be something of a miscellaneous section as well) - are laid out.

Monday, January 8, 2018

FMod - Tour complete

Today I hammered out the remainder of the Abiathar tour. The first stop I implemented today asks the user to switch to the foreground tileset and pick a tile from it. To watch for that happening, I introduced a watchdog plane for the tile palette. The next task was to try a different tool: the Copier. To watch for the current tool being changed, the tour extension subscribes to the text-changed event of the current tool label - not the most elegant solution, but simple and effective. The tour then asks the user to copy an area and paste it elsewhere. To finish up, it asks the user to switch back to the familiar Tile Placer, test the undo feature, and activate contextual help for more detailed assistance on any tool.

Sunday, January 7, 2018

Named pipe connections might need to be enabled for some SQL Server clients

I recently had some trouble getting an application connected to an SQL Server database. In SSMS, logon sometimes failed with a message about named-pipe connections not being enabled on the server. Apparently applications won't always fall back to a supported connection method if their preferred one isn't enabled?

Connection methods can be managed with the SQL Server Configuration Manager. There are several sections in the SSCM; for me, named pipes only seemed disabled in one of them. After enabling such connections there, this error was no longer a problem.

Saturday, January 6, 2018

Some apparently blank tiles may render as garbage in-game

The Keen Galaxy games' tilesets have a lot of unused slots. To save space, the developers completely deleted these chunks from the EGA files. Attempting to use them produces visual garbage - the game hits junk memory when it tries to get their images. Programs that extract the EGA files to bitmap images, however, display these missing chunks as blank. Therefore, what you see as a blank tile in the level editor might be glitched in game. (It's particularly easy to get these tiles into a level by copying nonrectangular multi-tile structures from a tile palette.)

I don't know of an easy way for users to deal with this. Level editors might be able to help by rendering missing chunks differently, maybe as hex numbers on a glaring background. Alas, this can only work if the level editor uses the EGA resources directly, which only Abiathar can. I'll have to see if I can implement something helpful.

Friday, January 5, 2018

Some OEM keys are not actual Windows product keys

I recently worked with a Windows 10 computer that, despite coming straight from the Microsoft-authorized refurbisher, claimed to not have Windows activated. ProduKey showed that it had an OEM key as I expected, but it continued to show an error in the activation section of Settings. Using the phone activation system, I managed to get to the part where I enter the very long installation ID and get a very long confirmation code, but activation still failed even with the code.

After another series of steps through automated systems and discussions with real people, I eventually learned that the product key in use by the machine is actually a public, placeholder product key - the refurbisher didn't install a real key. The Microsoft support person who helped me generated a new product key and installed that.

Thursday, January 4, 2018

SQL authentication might not be enabled by default in SQL Server

Recently I needed to get a third-party application connected to an SQL Server database. The application uses an SQL Server account rather than integrated Windows authentication. Even though I was very certain I had created the account correctly, the application reported that logon failed. Looking through the SQL Server event logs, I found the explanation: logging in with database accounts was not enabled. (That seems to be the default configuration? I'm not sure why.) Such logons can be enabled in the security section of the server properties in SSMS.

Wednesday, January 3, 2018

Not all Windows COM objects are available on both bitnesses

I discovered while trying to test my P/Invoke command-line tool on the File History API that CLSID_FhConfigMgr can't be instantiated from a 32-bit program on a 64-bit system. The class is simply not registered for 32-bit programs; there is no Registry configuration for it under WOW6432Node and the DLL that implements it (fhcfg.dll) doesn't exist under SysWOW64. Therefore, applications that work with File History (or any other COM object that isn't implemented on both bitnesses at once) must be compiled for 32-bit and 64-bit separately, otherwise they'll break on one architecture.

Tuesday, January 2, 2018

BSTR support in the P/Invoke tool

Strings used by COM methods are passed as BSTRs. My P/Invoke command-line tool previously had no way to use such methods, except possibly by manually constructing the BSTR structure, which would have been a huge pain. So today, I introduced a slot kind that manages text as BSTRs. Implementation was made very easy by .NET's PtrToStringBSTR and StringToBSTR methods.

Monday, January 1, 2018

SQL Server sysadmins can affect the host machine

Microsoft SQL Server has an xp_cmdshell procedure that runs the a given program with arguments. It's unavailable by default, but can be enabled by server sysadmins. The account under which SQL Server runs is roughly equivalent to a standard user, but it has a couple extra privileges enabled. Most relevantly, it has SeManageVolumePrivilege, which permits the use of SetFileValidData (which is how the fsutil file setvaliddata command works). Therefore, if an attacker can gain sysadmin privileges on an SQL Server, they can exfiltrate deleted data from the disk like so: create a blank file, write a zero byte at a large address in that file, set the valid data to that point, and read the file's contents. PowerShell makes the first and last steps pretty easy.