20 Apr
Posted by: Remko in: Common, JEDI Windows API Headers, JEDI Windows Security Code Lib, JWA Downloads, JWSCL Downloads
The JEDI API Library project (JWA) has been successfully revived from a sleep status to an active project with lots of ambitions. Some recent achievements are the new include model of JWA, the release of JWSCL (the Security Library) and of course the “birth” of this blog.
03 Apr
Posted by: Christian Wimmer in: Common, JEDI Windows API Headers, JEDI Windows Security Code Lib
Do you need help? We can support you creating application using JWA and/or JWSCL.
Visit the Get Service site on SourceForge for more information like pricing.
01 Jul
Posted by: Christian Wimmer in: Common
If you create a COM Server to serve some clients with COM interfaces (or better their functionality), you maybe get sometimes a dialog box that tells you that there are client connections opened. This happens as soon as you try to close your app. If you want to close it though, you have to explicitly click “Yes”.
If you are going to write a service you should consider why you need it to be a service at all. If you can run your application as a standard user, you should do it. A service is a high privileged application that should be created with care and clear thoughts.
So think about your task you want to solve with the application. Read the rest of this entry »
After making some changes to the A-records of the DNS servers responsible for *.delphi-jedi.net, a different host was queried by the clients (e.g. your browsers) for the contents of this blog. Obviously the other host didn’t know how to react and thus gave back a simple “no idea what file that is” (i.e. HTTP error 404) in most cases. The issue has been resolved, but it may take some more time for some people until the DNS changes propagate to their DNS servers.
Mail traffic (the MX-record) was not influenced by this at any time. Jabber communication, however, may have been affected by it.
// Oliver
If you want to use CreateProcess or CreateProcessAsUser and you also want to set the target desktop, you should make sure that the target winstation (usual winsta0) and desktop name (usual default) is spelled correctly.
If you misspell the name (say defaut instead of default - missing l ) the process creation may succeed but your application won’t show but start running.
17 Jun
Posted by: NeutralGeneral in: JEDI Windows Security Code Lib, JWSCL Downloads
Calculating Binary Hashes using TJwFileStreamEx
Why should I use TJwFileStreamEx instead of any other common stream class from the VCL?
Well this question is quite easily answered.
The first thing is that TJwFileStreamEx is based on Memory Mapped Files (MMF). MMF might be the fastest way to access files on your hard disk. Another good reason for using TJwFileStreamEx is its Memory property which is well known from the VCL TMemoryStream class. This property will reduce the effort remarkably.
Getting Started
First you have to include following units to your project:
The signature of our hashing-function looks like this:
The first parameter is used to specify the Algorithm which is used to hash the file data. The second parameter defines the path to the file which hash you want to compute.
So what do we need to calculate the hash of a file? All we need is an instance of TJwFileStreamEx to open the file and an instance of TJwHash to calculate the hash:
This is the basic framework of our function. To calculate the hash of the file we need 2 methods:
HashData tells our instance of TJwHash which data is to be hashed and which size this data has. RetrieveHash calculates the Hash and retrieves a pointer to the hash data.
Finally we have to free the Buffer using the class method
Now our function looks like this:
At last we need to convert the binary hash into a hex-string:
Now we’re done and finally our function looks like this:
How do I use this function?
OK, but what is the advantage of TJwFileStreamEx over other Streams?
Well, you don’t have to load the file into a TMemoryStream and thus the file will not be loaded completely into memory. Furthermore this solution is much faster than a solution using TMemoryStream and similar…
Download the source and binaries of this example (260kiB). This includes the new and necessary JWSCL source files. However you need to download the whole package separately.
The JEDI Community has an issue tracker where you can submit bugs, features and fixes. Please use this tracker for both JEDI projects API and WSCL.
http://homepages.borland.com/jedi/issuetracker
Switch to project “JEDI API” in the drop down field in the top right corner of the page.
27 May
Posted by: Christian Wimmer in: JEDI Windows API Headers, JWA Downloads
What is that? MSDN say’s: A Winlogon Notification Package is a DLL that exports functions that handle Winlogon events. For example, when a user logs onto the system, Winlogon calls each notification package’s logon event handler function to provide information about the event.
So you might know, the mechanism of Winlogon Notification Package is available in Windows 2000, Windows XP and Windows 2003 Server. In contrast to Windows Vista, it is completely different, maybe I’ll come back with separate tutorial describing how to build a notification package for Windows Vista.
I’m going to demonstrate here, how to create such a notification package and as a special gift, we will learn how to create a PNG image with drop shadow effect, which we will use later to draw a transparent window inside the Winlogon Desktop.
It’s time for our Winlogon Notification Package. Start Delphi and create a new DLL project.
What we need to do next is to define the Message Callback and the WLXNotificationInfo, as described in MSDN
Our Prototype, is ready to use. The compiled DLL has to be in the following folder:
C:\Windows\System32 (adapt it to your environment)
Now we can inform the operating system that we created a Winlogon Notification Package. This step will be done in the registry under the following key:
HKey_Local_Machine\Software\Microsoft\WindowsNT\
CurrentVersion\Winlogon\Notify\YourNotification
|
Name |
Type |
Value |
|
DLLName |
REG_SZ |
C:\Windows\System32\YourDLLName.dll |
|
Asynchronous |
REG_DWORD |
0 |
|
Impersonate |
REG_DWORD |
0 |
|
Logon |
REG_SZ |
LogonHandler |
The valid values are described in this MSDN article.
Creating the PNG Image
For completing this Project you will need to download the following:
Graphics32 Library
Graphics32 is a graphics library for Delphi and Kylix/CLX. Optimized for 32-bit pixel formats, it provides fast operations with pixels and graphic primitives. In most cases Graphics32 considerably outperforms the standard TBitmap/TCanvas methods.
PNG Components
Delphi VCL Components with PNG Image support.
What you’ll need is an already exisiting PNG or a new one. I’ll use with the Jedi Api WSCL Logo.
Open the Logo in Photoshop but remember this can be done in almost any other Graphic Application which supports PNG and layer based drawing.
The Logo from this site is already a PNG, so you will see a transparent background when it is opened in Photoshop. If you like to add a drop shadow style to it, you won’t see it,because of the mentioned transparent background. It is also a problem on a black background, btw. So first thing to do is to add a temporary background layer into the Logo. To do so, click on the “Create New Layer Symbol” in the layer palette (indicated as a small notepad icon).
Now select the new created layer by clicking on it and drag it behind the Logo layer. With the new layer still selected, switch to the “Tools Window” and select the “Paint Bucket Tool“. Select white as your foreground color. If you have another color as foreground color, simply press d and then x. In this way it will reset the foreground and backgound colors. Now click inside your image on the transparent part and you’ll see the Logo with a white background applied.
Switch to your layers palette and double click on the Logo layer. The “Layers Styles Dialog” should be visible now. Select “Drop Shadow” and you can adjust the angle of the drop shadow and its size. While you adjust it, also watch the Logo. Photoshop shows you a preview of the changes. If you’re satisfied with your settings hit ok.
At this time, we don’t need our white background layer anymore, so select it and drag it to the trash can symbol in the layer palette. It will be deleted then. Afterwards save the Logo, select PNG as the file format and a new window will appear (PNG Options). Select none and hit ok.
There also exists a small video presentation which will help you.
Drawing the PNG onto the Form Canvas
The following source is kindly provided by Coder90. He wrote a nice example in a german delphi forum
The Sources
I won’t go into any details here, basically the procedure will load the PNG into a Bitmap32 Object and blends it to the forms canvas.
Call it in the FormOnCreate handler and don’t forget to free the Bitmap32 Object, a good place e.g. would be on the FormOnDestroy Handler.
Additional informations for you
I have to tell you that the first version of this package was slightly different than the one I’ll post here.
Well I used an external executeable which was called from my DLL when the LogonEvent was called.
But I encountered a big problem with that technique. One of the biggest problems were that my external application was executed more then once. Additionally I wasn’t able to close it. Neither Application.Terminate nor Application.Mainform.Close worked here. I did some experiments with a mutex which worked in some cases, but then, Christian Wimmer gave me many good ideas and suggestions.
So the improvements were:
The following Delphi packages are necessary. They are not included and must therfore downloaded and installed (if necessary) separately. Please, also recognize the license of these packages. The winlogon examples does only have a Copyright and no Warranty license.
3rd Party Components and Library’s you need to download:
Graphics32
PNG Components
Jedi Tutorial Files:
Photoshop Tutorial
(dowload size: 2.12 MB Format: AVI)
winlogon
(dowload size: 82.2 KB Format: ZIP)
If you want to use such a Winlogon Notification DLL in a productive system you have to make sure that the wrong person can’t manipulate the DLL file. This can be done by setting the file’s access control list to allow only write access to SYSTEM and Administrators. There is no need for other users to have even read access, since the DLL is only used by winlogon. Furthermore you should save this file in a save place like the System32 folder.
Conclusion:
I hope you learned something new and had as much fun as I had writing this little tutorial for you!
My biggest thanks fly out to Christian Wimmer for all his support and help for making me finish this project.
Kindest regards
stOrM!
(contact by comments or mail @ JEDI)