Jump to content

Help needed - compile a .cpp file into a .dll


Recommended Posts

...hmm, so - if we could hexedit the v2.7.6 .dll file and search for 05907F18 (I found 187f9005 at location 37DD6) and replace it with 058CEE98, then do Regren's patch (https://www.nexusmods.com/fallout4/mods/37856/) to trick it into using the latest F4SE version - that might do the trick?

 

 

I can't figure out how Rengren converts 1.10.98 to 1.10.120 or even 1.10.130. The bytes 0780 and 0620 don't convert to anything relevant! I don't get it.

0620 = 1568
0780 = 1920

Link to comment
Share on other sites

  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

I don't think it will work.

 

F4SE is shipped as a dynamic library (a DLL file), but for extensions it must be built as a static library (a LIB file).

Now I see that you tricked me, because when F4SE is compiled as a static library the result is f4se_1_10_138.lib, not f4se_1_10_138.dll. So you didn't change Configuration Type from Dynamic Library to Static Library as instructed.

 

Because the F4SE extensions are statically linked against F4SE => some code from F4SE (the parts used by the extension) is actually included in extension.dll file.

This is why usually most of the extensions must be updated whenever F4SE is updated.

 

And the code from F4SE comes with many hard-coded addresses. So is not only about the hard-coded addresses from extension's main.cpp file, but also about the ones from F4SE itself.

Some authors created F4SE extensions that are version independent. What they did was to use signatures to scan the memory at run-time to find the addresses, instead having them hard-coded. They did this for their own addresses, but they also had to do this for the ones from F4SE.

 

Now if you check the f4se_versions.h file you'll find this:

#define RUNTIME_VERSION_1_10_98 MAKE_EXE_VERSION(1, 10, 98) // 0x010A0620 creation club update 9
#define RUNTIME_VERSION_1_10_106 MAKE_EXE_VERSION(1, 10, 106) // 0x010A06A0 creation club update 10 (no addresses changed)
#define RUNTIME_VERSION_1_10_111 MAKE_EXE_VERSION(1, 10, 111) // 0x010A06F0 creation club update 11 (no addresses changed)
#define RUNTIME_VERSION_1_10_114 MAKE_EXE_VERSION(1, 10, 114) // 0x010A0720 creation club update 12 (no addresses changed)
#define RUNTIME_VERSION_1_10_120 MAKE_EXE_VERSION(1, 10, 120) // 0x010A0780 creation club update 13 (no addresses changed)
#define RUNTIME_VERSION_1_10_130 MAKE_EXE_VERSION(1, 10, 130) // 0x010A0820 creation club update 14
#define RUNTIME_VERSION_1_10_138 MAKE_EXE_VERSION(1, 10, 138) // 0x010A08A0 creation club update 15

So Regren's trick was possible because no addresses changed between 1.10.98 and 1.10.120. This is not true between 1.10.120 and 1.10.138.

 

Link to comment
Share on other sites

Regarding Regen's trick, in f4se_versions you'll find this:

#define MAKE_EXE_VERSION_EX(major, minor, build, sub) ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | (((build) & 0xFFF) << 4) | ((sub) & 0xF))
#define MAKE_EXE_VERSION(major, minor, build) MAKE_EXE_VERSION_EX(major, minor, build, 0)

So 1.10.98 is (1 << 24) | (10 < 16) | (98 << 4) => 0x10A0620
1 << 24 = 16777216 = 0x1000000
10 << 16 = 655360 = 0xA0000
98 << 4 = 1568 = 0x620
And 1.10.120 is 0x10A0780

Link to comment
Share on other sites

Good news - I managed to track down Struckur and he gave me permission to share his reply:

 

 

 

Greetings,

I’m genuinely surprised people still use Clipboard, it seemed pretty niche back in the day.
I fear the last year has not been so kind, neither financially nor health wise. At present I don’t have access to a computer capable of running Fallout 4 so any help I can offer is limited.
Clipboard used some of the same tricks F4SE uses, most notably it calls function in the Fallout 4 executable by their native address. Those address can change with each release of Fallout 4. I was never able to figure out how to look up those addresses myself but got help from Expired, the main author of F4SE.
I can see three possible ways to get Clipboard working with modern Fallout 4:
1: Find someone who can look up the native addresses and recompile the project with each update.
2: Convince the F4SE team to add the needed functions to those they extend. Then Clipboard could be modified to use those instead and the mod would work without needing to be recompiled on subsequent Fallout 4 updates.
3: Convert Clipboard to use the Papyrus methods in place of the native ones, this would slow the mod down to the equivalent of Transfer Settlements, but would require no further effort to maintain.
The F4SE team has a discord that proved most useful when contacting them in past.
Feel free to pass any of this onto other people, ask any questions, and modify/repost any of Clipboard.

Everett Sands
[email protected]

 

 

It seems the poor lad has been going through a really hard time, that's why he suddenly vanished last year.

 

I hope this info is useful.

 

Regards :).

Link to comment
Share on other sites

OK, I deleted all the rubbish I did and started again from scratch using your files Wolfmark.

 

I did the test compile of F4SE and it succeeded.

 

I then went through your instructions and got stuck at this point here:

 

http://repo.duckdns.org/pub/junk/clipboard/Capture.PNG

 

 

The only options I see that contain "library", "windows" and "C++" are the following:

 

http://repo.duckdns.org/pub/junk/clipboard/Capture01.PNG

 

http://repo.duckdns.org/pub/junk/clipboard/Capture02.PNG

 

http://repo.duckdns.org/pub/junk/clipboard/Capture03.PNG

 

 

 

Which one do I choose?

Link to comment
Share on other sites

You can have multiple configurations for a project. By default there are 2: Debug and Release.

The current configuration used when building the project is selected from a combo-box from toolbar.

 

Most settings are the same for both configurations, but some (like Preprocessor Definitions and Runtime Library) are different.

So you can't change their value while having All Configurations selected (there's a combo box in the settings page from which you select for which configuration the settings are displayed).

And you have All Configurations selected because <different options> is displayed.

If you already changed Preprocessor Definitions while having All Configurations selected then you have to start again.

 

https://imgur.com/a/ju1HT3h

Edited by Wolfmark
Link to comment
Share on other sites

Yes, I did have "Debug" selected at the time - I just didn't want to post the entire screen but here it is again showing that "Debug" was actually selected:

 

 

http://repo.duckdns.org/pub/junk/clipboard/Capture06.PNG

 

 

I also got the same options when I selected "Release":

 

 

http://repo.duckdns.org/pub/junk/clipboard/Capture07.PNG

 

 

....so the options are - /MT or /MD for release, or /MTd or /MDd for debug, I'm not sure which option is correct.

 

 

EDIT - OK, I just looked closer at the screenshots you gave me and saw that I need /MT and /MTd

Link to comment
Share on other sites

OK, it compiled perfectly -

 

 

http://repo.duckdns.org/pub/junk/clipboard/Capture08.PNG

 

 

I built the "release" version, which came out at a filesize of 293kb. Renamed it to ClipboardExtension and repackaged Clipboard using the new .dll file - sadly it didn't work :sad:.

 

No complaints about version or other error messages though.

 

The clipboard tool goes straight to "selection area size" when I place the tool and it finds no objects in the entire settlement to scan and nothing can be selected.

 

Here's the repackaged version if anyone else want to try it.

 

Any new thoughts, suggestions or ideas are welcome :smile:.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...