Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entities 18(0x12) #4

Open
leshasoft opened this issue Feb 14, 2023 · 19 comments
Open

Entities 18(0x12) #4

leshasoft opened this issue Feb 14, 2023 · 19 comments

Comments

@leshasoft
Copy link

Entities 18(0x12) is magical entities, a pointer to other entities (POLYLINE, INSERT, TEXT, Another Entities 18(0x12) ).

1 byte - kind
1 byte - entities property
2 bytes - length
3 bytes - if flag 0x80 offset in Extra Entities Table, if the flag is 0x0 then address Entities section
1 byte - flag
2 bytes - crc16
(optional, variable) - unknown data

@michal-josef-spacek
Copy link
Owner

@leshasoft Good catch, thanks.

I believe that "2 bytes - length" isn't true.
Other is fine.

@michal-josef-spacek
Copy link
Owner

Nice example to identify what these 2 bytes means is:

PL2.scr.gz
PL2.DXF.gz
PL2.DWG.gz

@leshasoft
Copy link
Author

ENTITIES
    0006CF 12 00    unknown, entprop 0H (0)
    0006D1 0A 00    length AH (10)
    0006D3 87 01 00 80    ent loc 80000187H

    0006D7 F5 3B                                             .;              

    0006D9 12 00    unknown, entprop 0H (0)
    0006DB 1A 00    length 1AH (26)
    0006DD 00 00 00 80    ent loc 80000000H

    0006E1 8E DF 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
    0006F1 D0 CB                                             ..              

    0006F3 12 00    unknown, entprop 0H (0)
    0006F5 1A 00    length 1AH (26)
    0006F7 25 00 00 80    ent loc 80000025H

    0006FB 85 D3 00 00 00 00 F0 3F-00 00 00 00 00 00 00 40   .......?.......@
    00070B C1 09                                             ..              

    00070D 12 00    unknown, entprop 0H (0)
    00070F 1A 00    length 1AH (26)
    000711 4A 00 00 80    ent loc 8000004AH

    000715 98 C7 00 00 00 00 00 40-00 00 00 00 00 00 F0 3F   .......@.......?
    000725 E5 18                                             ..              

    000727 11 00    seqend, entprop 0H (0)
    000729 0E 00    length EH (14)
    00072B 00 00    layer index 0H (0)
    00072D 00 00    entflag 0H (0)
    00072F CF 06 00 00 80 5D                                 .....]          

SENTINEL
    000735 3B 91 97 AB 07 91 CC CF-9C C1 3E 7A D5 23 6B FE   ;.........>z.#k.
    000745 

Perhaps the size of the entity, the calculation of offsets is the same.

0x6cf + 0x000a = 0x6d9
0x6d9 + 0x001a = 0x6f3
0x6f3 + 0x001a = 0x70d
0x70d + 0x001a = 0x727

You can add huge extended data to the POLYLINE and see how those 2 bytes change.

@michal-josef-spacek
Copy link
Owner

@leshasoft sorry, yes, this is the size of this entity. Data are fitting precisely. The only thing is unknown data, which are long sometimes.

@leshasoft
Copy link
Author

I also noticed that the unknown data is part of the data of the target entity starting from 11 byte.
The length of this part varies and does not include the last 2 or 3 bytes.

@michal-josef-spacek
Copy link
Owner

@leshasoft I applied some changes related to this entity.

I don't know what unknown data mean still.

In AC1009 last two bytes are CRC16

@leshasoft
Copy link
Author

I still don’t understand the purpose of unknown data either, I tend version to the junk data.
If the last two bytes of this entity are a checksum, then it is calculated using an unknown algorithm.
I tried to find the magic value, it turned out to be different for each file and even for entities of different sizes within the same file.
For Example:
In PL2.DWG
for length 0x001a Value 0x4033
for length 0x001b Value 0x1503

@michal-josef-spacek
Copy link
Owner

@leshasoft

Important is to look to saved PL2.DWG in R11. This is result of cleanup with jump entities.
PL2-saved_by_R11.DWG.gz

This is case with polyline only. There are probably another cases (like ROZA.DWG, which you send me).
BTW: Could you send me a CYRILLC.SHX file? I have issues with this file (ROZA.DWG) in R10.

@leshasoft
Copy link
Author

CYRILLC.SHX.gz

@michal-josef-spacek
Copy link
Owner

Ok, thanks. I couldn't open in R10 still.

Maybe could help ROZA.DWG saved in R11 (after JUMP cleanup)
ROZA-saved_in_r11.DWG.gz

@leshasoft
Copy link
Author

It is strange that drawing in AutoCAD 10 does not open for you.
I look that in the saved file after JUMP cleanup Entities 18 replaced to LINE and TEXT.

@michal-josef-spacek
Copy link
Owner

@leshasoft

Ad not opening in R10) This could be because of emulation. Not important now.

Ad jumps) If I correctly understand the concept is like this:

Entity in normal section
Go to all entities in normal section to first jump.
Jump to extra section
Go to another entities in extra section to first jump.
Jump to normal section.
....

@leshasoft
Copy link
Author

Sorry, been busy. The concept is correct, only there is one clarification the jump can be inside extra section.

@michal-josef-spacek
Copy link
Owner

michal-josef-spacek commented Mar 3, 2023

The concept is correct, only there is one clarification the jump can be inside extra section.

correct

I cannot compute the correct crc16 in the case when there are unknown data. Do you know what data are in the calculation? I tested 2 bytes on the end and 2 bytes after 10 bytes, but not correct.

@leshasoft
Copy link
Author

The only thing I found is that 9 and 10 bytes is the crc16 of the first 8 bytes, regardless of the presence of unknown data.
I wrote a program that calculated the CRC16 in increments of 1 byte both from the beginning and from the end, and did not receive anything similar to the last two bytes.

@leshasoft
Copy link
Author

In the case where there is unknown data, the last two bytes are not CRC16.
When changing them in a hex editor, when opening a drawing in AutoCAD, there is no message that the drawing is damaged.

@michal-josef-spacek
Copy link
Owner

The only thing I found is that 9 and 10 bytes is the crc16 of the first 8 bytes, regardless of the presence of unknown data. I wrote a program that calculated the CRC16 in increments of 1 byte both from the beginning and from the end, and did not receive anything similar to the last two bytes.

Thanks.
hm, this calculation wasn't working for me. I need to recheck. :-/ :-)

This probably means, that unknown data are random data, not used. Because outside of CRC16

@leshasoft
Copy link
Author

PL2_NoErr.DWG.gz
PL2_W_Err.DWG.gz

PL2.DWG files with modified Entities

Comparing files PL2.DWG and PL2_W_ERR.DWG
000006E2: DF EF

Comparing files PL2.DWG and PL2_NOERR.DWG
000006E3: 00 54
000006E4: 00 65
000006E5: 00 73
000006E6: 00 74
000006E7: 00 20
000006E8: 00 44
000006E9: 00 61
000006EA: 00 74
000006EB: 00 61
000006EC: 00 4E
000006ED: 00 6F
000006EE: 00 45
000006EF: 00 72
000006F0: 00 72

@michal-josef-spacek
Copy link
Owner

@leshasoft I understand, thanks

Same no error when i changed last two bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants