Wednesday, June 7, 2017

Profiling a process on a machine without Visual Studio

Today I needed to create a performance profile of a certain program. Usually I would just fire up Visual Studio, but VS is very large and wasn't on that computer. Fortunately, the profiler can be installed without the full IDE. The setup package can be found in this folder on the newest version of Visual Studio:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Team Tools\Performance Tools\Setups

Copy the installer to the other computer and set it up. The tools get installed to that same path, minus the Setups part. Then run the profiler on your application from an administrative command prompt:

vsperf /launch:"C:\path\to\myapp.exe" /file:filetitle

Once the launched process exits, the profiler saves the report to filetitle.vspx. Copy that file back to a computer with Visual Studio. Open it with File | Open | File and you'll get the analysis.

Tuesday, June 6, 2017

Checking who can do what to a table in SQL Anywhere 11

Today I was investigating the security of an SQL Anywhere 11 database and needed to see who had the authority to update a certain table. I managed to find the systableperm system table that holds this information. This query returns a list of users/groups and which actions they can perform on the table:

select user_name, selectauth, insertauth, deleteauth, updateauth 
from sys.systableperm
inner join sys.systable on systable.table_id = systableperm.stable_id
inner join sys.sysuser on sysuser.user_id = systableperm.grantee
where table_name = 'MyTable'

Monday, June 5, 2017

Abiathar Online - Enter ID

The desktop Abiathar program has long had the ability to enter a tile ID to select it. That's a fairly simple feature and one that comes in handy occasionally, so today I added it to Abiathar Online. Clicking the selected tile image for a plane brings up the ID entry form. A "hexadecimal" check box controls whether the text box's contents should be treated as hex.

I also removed the copy-pasted plane control HTML in favor of generating in with JavaScript. That way, it'll be easier and less repetitive to add more plane-related features.

Sunday, June 4, 2017

Abiathar Online - Graphics fixed on Chrome

The last time I worked on Abiathar Online, I found that its graphics were messed up on Chrome - the first time a tile was requested, it wouldn't necessarily display until the level was refreshed. I'm still not sure why it was doing that, or why it worked before, but today I made a change that fixed the problem. This Stack Overflow answer taught me that I don't have to make an Image out of the temporary canvas before using it to draw on the main one. Canvases can be drawn on other canvases just fine. So I switched to caching canvases, only converting them to Base64 URLs when displaying them in the selected tile bay. Abiathar Online now appears as it should in both Chrome and Edge.

Saturday, June 3, 2017

Changing the desktop background color with PowerShell

There is a Registry value under HKCU\Control Panel\Colors to control the background color of the desktop, but writing that value doesn't change the current desktop immediately. For a program trying to update the color, the SetSysColors Windows function is the proper way. That's not so easy to handle from the command line, though.

Fortunately, PowerShell can compile and run C# code, which can use P/Invoke to run native Windows functions. This one-liner does the job of defining a type to invoke SetSysColors:
add-type -typedefinition "using System;`n using System.Runtime.InteropServices;`n public class PInvoke { [DllImport(`"user32.dll`")] public static extern bool SetSysColors(int cElements, int[] lpaElements, int[] lpaRgbValues); }"

That function takes a count and then two arrays of that length, one with setting IDs and one with their values. We're only interested in one, the desktop background color (1). The value is the new color in 0xRRGGBB format.

[PInvoke]::SetSysColors(1, @(1), @(0xAA40C0))

This doesn't affect the Registry, so if you want the change to stick, you need to also write the new data to Registry yourself.

Based on my Super User answer.

Policy Plus - Select list items with Enter

A long time ago, I added a bit of code to the Policy Plus main window to make the Enter key open/activate the currently selected object in the right pane. That greatly improves keyboard navigability and intuitiveness. I found myself missing that on the three newer list forms: Loaded ADMX Files, All Products, and All Support Definitions. So today, I added that functionality.

The changes are live on GitHub.

Thursday, June 1, 2017

Policy Plus - List all support definitions and products

Today I added two dialogs to Policy Plus: All Products and All Support Definitions. The products list allows the user to explore all the defined products. Strictly speaking I only needed to show the top-level products, since the Product Details window can explore the tree of one of those, but I decided it would be weird to have a window named "all products" only show some product entries, so here we are. Selecting an entry in a higher list populates the lower list with its subproducts. Double-clicking any product in any list opens its details.


The support definitions list is just that. It also includes a text box to filter the support definitions because there are so many of them. For example, typing "windows xp" narrows the list to definitions that have names containing that. An ADMX File column shows at a glance which administrative template is responsible for the definition. I didn't bother doing that for products because most if not all of them are from WindowsProducts.admx.


The changes are live on GitHub.