Delphi XE: Reading basic information from a DCP-File

During this Article, I’ll show how to read some very basic information from Delphi’s DCP-Files. This includes name of BPL to link with, required DCPs and contained Units.During the last past weeks, i wrote a Project-Analyzationtool, which is able to completely unwire all Unit-Dependencies and fix searchpathes. However, to do so, i had to work with DCPs, too. Some searching didn’t reveal much (besides the same questions as i had). I know that things might have changed from XE to XE8, but i hope this article is still helpfull to get anybody outside of XE started.

So let’s get started with our dirty work. For analyzing a DCP, i created a new Package, called TestPackage.bpl. It requires only the RTL and has 2 empty units: MyUnit and Foo.OtherUnit. This should do the job for experimenting. Grab a Hex-Editor of your choice and look into it. You’ll see something like this:

Overview

Something you’ll notice is, that the Stream starts with the 4 AnsiChars “PKX0”. All DCP seem to start with it, so i declared it as our DCP-Signature. YOu may validate this when loading a file to make sure you have a DCP. On line 3 you’ll see “TestPackage.bpl”. This is the name fo the BPL the linker will link to. This is required when dealing with BPLs which have Postfixes. For example, for VCL150.bpl only a VCL.dcp exists. And this is the place where you’ll find the final BPL-Name. By comparing different DCPs, you’ll notice, that the BPL-Name always starts at the same position (Byte 33). So our first 32 Bytes are for sure some kind of Header. Let’s take a close look:

Header

I have outline the fields i already analyzed and describe them here. The Red-Field is our Signature as discussed before. Green and Blue contain numbers, which change depending on the Number of contained Units and required DCPs. By fiddling around, you’ll notice that Green is the number of required DCPs and Blue the number of Contained Units. Wait, we have to units, why does it tell me that there are 3? Quite simple, the DPK-File of your Package (In this case TestPackage.dpk) is included in this list, too. The Orange box simply contains the lengths in Bytes of the BPL-Name which follows the header (Excluding the terminating NULL-Character). So to sum it up, our header looks like this in Delphi:

DelphiDCPHeader

But wait, there is more!

ListOfDCPsAndUnits

Right after our BPL-Name, we’ll notice “RTL”. This is because it is directly followed by a list of zero-terminated strings which include the names of required DCPs. In our case it is just “RTL”. So to get a list of required DCPs, you simply read zero-terminated string after zero-terminated string based on the number of required DCPs as noted in our header. After that, a list of contained units with their own header follows. To sum it up here, each element of this list contains of a 60 Byte-Blob i haven’t investigated, yet. And 2 zero-terminated strings after each block. The first string is our Unit-Name, the second one seems to be some kind of NameSpace. When your unit is not dotted, the second string is always empty and consists only of the NULL-Character. But when your unit is dotted like “Foo.OtherUnit”, it’ll contain “Foo”. This pattern goes on with units like “Foo.Bar.MyUnit”, where the NameSpace is “Foo.Bar”. I highlighted theses fields in Green/Brown and Blue/Orange. So to get a list of contained units here, you simply skipp 60 Bytes and read 2 strings per element based on the number of contained units in our header. The last element is always the Package-DPK unit. So if you’ve done everything right, you can get an output like this:

Result

Something to note here: The last entry, which is the DPK-Entry seems to have a Header with a length of 61. I just looped with a pattern of 60 Bytes here, that’s why i have an extra character here in front of the last name. You might want to skip that one.

I hope this article gets you started on Delphi’s DCP-File.

Posted in Delphi and tagged , , , .

13 Comments

  1. Nice one. But if you want to really be admired try doing that with the .dproj. 😉
    That one baffles me every time I have to look at it.

  2. Hi there,

    We run a YouTube growth service, which increases your number of subscribers both safely and practically.

    – We guarantee to gain you 700-1500 new subscribers per month.
    – People subscribe because they are interested in your videos/channel, increasing video likes, comments and interaction.
    – All actions are made manually by our team. We do not use any ‘bots’.

    The price is just $60 (USD) per month, and we can start immediately.

    If you’d like to see some of our previous work, let me know, and we can discuss it further.

    Kind Regards,
    Amelia

  3. Hi there,

    We run an Instagram growth service, which increases your number of followers both safely and practically.

    – Guaranteed: We guarantee to gain you 300-1000+ followers per month.
    – Real, human followers: People follow you because they are interested in your business or niche.
    – Safe: All actions are made manually. We do not use any bots.

    The price is just $60 (USD) per month, and we can start immediately.

    If you are interested, and have any questions, reply back and we can discuss further.

    Kind Regards,
    Megan

  4. Hi there,

    We run a Youtube growth service, where we can increase your subscriber count safely and practically.

    – Guaranteed: We guarantee to gain you 700-1500 new subscribers each month.
    – Real, human subscribers who subscribe because they are interested in your channel/videos.
    – Safe: All actions are done, without using any automated tasks / bots.

    Our price is just $60 (USD) per month and we can start immediately.

    If you are interested then we can discuss further.

    Kind Regards,
    Emily

  5. Hi there,

    We run a Youtube growth service, where we can increase your
    subscriber count safely and practically.

    Our focus is on organic growth strategies that nurture a
    thriving community around your channel. We don’t use bots or
    gimmicks, just targeted engagement tactics to help you reach the
    right people.

    Our price is just $60 (USD) per month and we can start immediately.

    If you are interested then we can discuss further.

    Kind Regards,
    Emily

  6. Hi,

    I just visited memnarch.bplaced.net and wondered if you’d ever thought about having an engaging video to explain what you do?

    Our prices start from just $195.

    Let me know if you’re interested in seeing samples of our previous work.

    Regards,
    Joanna

  7. Hi there,

    We run a YouTube growth service, which increases your number of subscribers both safely and practically.

    – We guarantee to gain you 700-1500+ subscribers per month.
    – People subscribe because they are interested in your channel/videos, increasing likes, comments and interaction.
    – All actions are made manually by our team. We do not use any ‘bots’.

    The price is just $60 (USD) per month, and we can start immediately.

    If you have any questions, let me know, and we can discuss further.

    Kind Regards,
    Amelia

  8. Hello Admin,

    I am selling something you or your company might be interested.

    I am selling LinkedIn Premium for the cheapest price. if you require LinkedIn business or career premium reply to me on This email
    For reference, the 6-month LinkedIn business premium is going to cost you $30.

    Thanks
    Pantu

  9. Hi there,

    We run a Youtube growth service, where we can increase your subscriber count safely and practically.

    – Guaranteed: We guarantee to gain you 700-1500 new subscribers each month.
    – Real, human subscribers who subscribe because they are interested in your channel/videos.
    – Safe: All actions are done, without using any automated tasks / bots.

    Our price is just $60 (USD) per month and we can start immediately.

    If you are interested then we can discuss further.

    Kind Regards,
    Katelyn

  10. Hi there,

    We run a TikTok growth service, which can increase your number of followers safely and practically.

    – 400-1200+ followers per month.
    – Real people who follow because they are interested in your profile.
    – No automated techniques, everything is safe and manual.

    Our price is just $60 (USD) per month.

    If you are interested, we are happy to send you some further information.

    Kind Regards,
    Jada

  11. Hi there,

    We run a Youtube growth service, where we can increase your subscriber count safely and practically.

    – Guaranteed: We guarantee to gain you 700-1500 new subscribers each month.
    – Real, human subscribers who subscribe because they are interested in your channel/videos.
    – Safe: All actions are done, without using any automated tasks / bots.

    Our price is just $60 (USD) per month and we can start immediately.

    If you are interested then we can discuss further.

    Kind Regards,
    Amelia

  12. Hi there,

    We run a YouTube growth service, which increases your number of subscribers both safely and practically.

    – We guarantee to gain you 700-1500+ subscribers per month.
    – People subscribe because they are interested in your channel/videos, increasing likes, comments and interaction.
    – All actions are made manually by our team. We do not use any ‘bots’.

    The price is just $60 (USD) per month, and we can start immediately.

    If you have any questions, let me know, and we can discuss further.

    Kind Regards,
    Felicity

  13. Hi there,

    We run a YouTube growth service, which increases your number of subscribers both safely and practically.

    – We guarantee to gain you 700-1500+ subscribers per month.
    – People subscribe because they are interested in your channel/videos, increasing likes, comments and interaction.
    – All actions are made manually by our team. We do not use any ‘bots’.

    The price is just $60 (USD) per month, and we can start immediately.

    If you have any questions, let me know, and we can discuss further.

    Kind Regards,
    Katelyn

Leave a Reply

Your email address will not be published. Required fields are marked *