Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / DLL from DATA statements

Author
Message
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 12th Mar 2007 03:27 Edited at: 12th Mar 2007 03:31
After read the bytes of a dll file I created the equivalent data statements.
At run time a program reads the data statements and recreates the DLL file.

However the recreated DLL is not recognized by Windows as a DLL.

I suppose there are some sort of extended information in the filename somewhere, but I don't know.

Here is a screenshot of the properties panels of the two files.

Notice that the 'Version' tab on the original DLL is missing on the cloned dll.

Does anyone know why the recreated DLL is not recognized by Windows, and what can be done to make it valid?

I'm unique, just like everybody else.

Attachments

Login to view attachments
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 12th Mar 2007 11:41
Have you actually compared the two files to see that they are identical byte for byte?

Paul.


322 is the time that the world will change.... forever!
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 12th Mar 2007 15:04
They look identical, because it's a dll that I bought I can't post them.

If I run Winsock.dll through the same process, then the cloned dll is recognized by Windows!!!

I can post my routines for you to try on your own dlls.
The first one will run without any alterations.
The second one has the Winsock.dll in data statements.

To convert a different dll, you'd have to change two things in the second program that reads the data and creates the cloned dll.
1) You'd have to transfer the data statements that were output from part 1 to replace the winsock.dll data statements
2) and adjust the DLLSIZE variable to the byte size of your original dll.

I'm unique, just like everybody else.
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 12th Mar 2007 15:09
If you want the cloned dll to have a name other than "winsockclone.dll" you'd also need to change that in the second program.

The DarkBASIC sources are attached.
I hope it won't need any changes in DBP, I'm not sure if the BYTE commands changed or not.

I'm unique, just like everybody else.

Attachments

Login to view attachments
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 12th Mar 2007 15:50
heartbone, I'll have a quick look to see if I can spot anything. The only thing that does ring true, is if you're duplicating a DLL that requires registering via regsvr. Although display of version information should work unless some corruption is in place. Anyway, I'll look.

Paul.


322 is the time that the world will change.... forever!
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 12th Mar 2007 16:22 Edited at: 12th Mar 2007 16:25
Thanks kind sir.

I do not have a binary difference comparison operator,
the files appear to be identical but they may not be.

Perhaps I need to write a diff function.

I'm unique, just like everybody else.
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 12th Mar 2007 17:16 Edited at: 12th Mar 2007 17:33
Hey Paul I just wrote a diff function and it reports differences between the originals and the clones.
Sorry about that.


The first ten differences are always at bytes #80, 96, 112, 416, 496, 576, 656, 1040, 1056, 1072
No matter what the source file those bytes end up as zero in the cloned dll.

I've switched to DBP and I got the same results.

I see the data statements are generated fine.
So it looks like a bug in the data statement values being converted into file bytes (the second routine).

I'm unique, just like everybody else.
heartbone
22
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 12th Mar 2007 17:44 Edited at: 12th Mar 2007 17:51
I found the problem.
In the second routine I had typed
MJBYT= Val(MJBYT$)
and it should have been
MJBYT= Val(MJBYTS$)
Which hammered any nonzero 16th bytes in the cloned dll.

Everything works just fine now.

Thanks for your time Paul.

Now you can bundle your DLLS in DarkBASIC Classic without needing to have extra files in the distribution!

Except for the speed hit on initialization, it's almost as nice as a plugin.

You could speed this up by processing the dlls as words rather than bytes.

I used the string method because if you try to create one data value per byte or word, DarkBASIC Classic will choke with a compiler error of too many data items.

I'm unique, just like everybody else.

Attachments

Login to view attachments
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 12th Mar 2007 17:53 Edited at: 12th Mar 2007 17:56
Yep, I just finished examining these with smaller files as well, there were differences in the files which caused the problem.

I'm glad you fixed it though

[EDIT] On a further note, when older Basic applications used this method for storing assembly files and such within data statements, they used to shorten the source code by holding all of the byte vales as a complete string without delimiters, i.e. "AABBCCDDEEFF0011223344,ABCD" Where the last four digits was a data checksum to ensure data integrity. But this is academic of course. Just thought this might be handy if you ever wanted to checksum the data to make sure it was correct etc.

Paul.


322 is the time that the world will change.... forever!

Login to post a reply

Server time is: 2024-11-22 16:41:26
Your offset time is: 2024-11-22 16:41:26