Remko Weijnen's Blog (Remko's Blog)

About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like

Archive for the ‘Delphi’ Category

RAD Studio Tokyo 10.2(.2) Data Collection

Just a very quick note: I was just installing RAD Studio 10.2.2 when I noticed the installer has an Options button:

image

So I clicked it to see what options are available and noticed that the "Embarcadero Customer Experience Program" is opted-in by default:

(more…)

Returning a string from unmanaged dll to .net

I write most of my code in unmanaged languages such as Delphi and C/C++. Sometimes customers ask me to interface my code to their .net code in which case I create a dll for them.

A recurring thing is that I need to return string to .net.

There are many ways to do this of course but in all cases we need to manage memory: who will allocate the memory for the string and who is responsible for freeing it?

(more…)

  • 3 Comments
  • Filed under: .NET, C#, C++, Delphi
  • Get Process Id of a running Service

    Sometimes you need to know the Process Id (PID) of a running service. Since Windows 2003 you can use the tasklist.exe tool with the /SVC switch. But how to do this programmatically?

    The QueryServiceStatusEx API returns a SERVICE_STATUS_PROCESS structure that contains the PID.

    The code is not very complicated:

  • 0 Comments
  • Filed under: Delphi
  • Decoding Citrix IMA Datastore Password

    This morning Arjan Beijer sent me an interesting link to a youtube video about obtaining the Citrix IMA Datastore password using Windbg.

    The video shows a method, discovered by Denis Gundarev to obtain the IMA Datastore password. Basically he uses DSMaint.exe and set’s a breakpoint on the call to CryptUnprotectData and then reads the password from memory.

    I tried to call the CryptUnprotectData API with the data read from the registry directly but this failed with error NTE_BAD_KEY_STATE, this is defined in winerror.h and it means “Key not valid for use in specified state”.

    (more…)

    Citrix Launcher Progress Update 1

    After figuring out how to encode and decode the Citrix passwords my next step for the upcoming Citrix Launcher is experiment with config.xml and authenticating to the Citrix Web Interface.

    imageI imported the NFuse.dtd from the Citrix Web Interface into Delphi with the XML Data Binding Wizard. The results in an NFuse Unit so I can easily create the XML data.

    To create an authentication packet I use the following code:

    (more…)

  • 0 Comments
  • Filed under: Citrix, Delphi
  • Switching to the Services Session

    Just read a tweet from @andyjmorgan about Interactive Service Detection. This made me remember that it’s possible to switch to the Session 0 with an undocumented api in winsta.dll.

    For this API to work you must have the Interactive Services Detection (UI0Detect) service running.

    (more…)

    Logon SIDToday I was reusing some old (pre vista) code the retrieves the Logon SID that I wrote a few years ago. The Logon SID is a special SID that identifies a logon session that has the form S-1-5-5-X-Y.

    You can view your Logon SID with Process Explorer, right click a GUI process, select Properties and goto the Security Tab:

    Process Explorer|Security Tab|Logon SID

     

    (more…)

    Snippet below can be used to programmatically determine if User Account Control is enabled:

    In my SATA Controller Identification tool I was using the TSaveDialog (Delphi 2010) but I got a report that under Windows PE the dialog is never shown.

    There’s no exception and I didn’t really bother to check why it fails. Instead I decided to replace it with the GetSaveFileName API which does work under Windows PE.

    Example:

  • 4 Comments
  • Filed under: Delphi
  • Determining stack size

    I just read an answer on StackOverflow with this code:

    Unfortunately it lacked explanation, so what does this code do?

    It reads offset $4 from the Thread Information Block (the top of stack) into eax and then offset $8 (stack base) into ebx.

    Then it substracts the two and moves that into variable eu, that’s all!

    Blogroll


    Categories


    Archives