Exetools

Exetools (https://forum.exetools.com/index.php)
-   General Discussion (https://forum.exetools.com/forumdisplay.php?f=2)
-   -   How to repack a lib file, any tools for that? (https://forum.exetools.com/showthread.php?t=20097)

DavidXanatos 03-01-2022 21:50

How to repack a lib file, any tools for that?
 
I want to make a dll not dependent on the C Runtime,
normally that is easy enough, just exclude standard libs and don't use any thing that requires imports from clr, or import manually what you can from ntdll.dll and for x64, x86, arm and arm64 this approach works just fine.
Howe ever it does not for arm64ec here some imports are missing which are no ware to be found in the ntdll, namely:
__chkstk_arm64ec
__icall_helper_arm64ec
__os_arm64x_dispatch_icall
__os_arm64x_dispatch_call_no_redirect
__os_arm64x_dispatch_ret

these are only to be found in libcmt.lib unpacking the lib (using 7zip) and adding a selection of extracted obj to my dll, namely:
chkstk_arm64ec.obj
chpev2_support.obj
guard_check_arm64ec.obj
guard_dispatch.obj
icall_helper_arm64ec.obj
vcall32_helper.obj

made the linking not fail, just spit out the following warming
LINK : warning LNK4294: missing EC Side version of load config symbol for ARM64X image

but the created dll fails to load

I tried including a couple more obj files from the lib but to no avail.

Apparently there is some additional data in that lib, so I was thinking the best approach would be to use a copy of the lib with everything removed that I don't need.

But I'm lacking a tool that would be able to edit a lib file, any one her knows of such a tool or tool chain that would allow me to achieve my goal?

DavidXanatos 03-01-2022 23:43

1 Attachment(s)
problem solved I gave up adding random obj files to early with
loadcfg.obj
guard_support.obj
added it works :D

I attach a collection of all that's needed to build x86, x64, arm, arm64 and arm64ec binaries only dependent on the ntdll.dll

RamMerLabs 03-02-2022 01:45

>>LINK : warning LNK4294: missing EC Side version of load config symbol for ARM64X image
Lib files for arm64ec contain an additional member /<ECSYMBOLS>/.
PEAnatomist shows it too (lib-files and obj-files are supported with much details)

__chkstk_arm64ec
__icall_helper_arm64ec
__os_arm64x_dispatch_icall
__os_arm64x_dispatch_call_no_redirect
__os_arm64x_dispatch_ret
this is simply a variables initialized with functions pointers to fill a HybridPE header, like a loadconfig header ("loadcfg.c" in MS CRT source, available via VisaulStudio installer)

DavidXanatos 03-02-2022 02:11

ah that's nice didn't know that MS is shipping those sources :D

DavidXanatos 03-07-2022 18:49

1 Attachment(s)
Here a improved version its a stand alone project that creates 2 (two) lib files booth need to be linked into the target project in order to work.
uCRT.lib provides implementations missing functions and
NtCRT.lib provides missing imports from the ntdll.dll


All times are GMT +8. The time now is 17:28.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX