Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-01-2022, 21:50
DavidXanatos DavidXanatos is offline
Family
 
Join Date: Jun 2018
Posts: 167
Rept. Given: 2
Rept. Rcvd 39 Times in 26 Posts
Thanks Given: 52
Thanks Rcvd at 307 Times in 105 Posts
DavidXanatos Reputation: 39
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?

Last edited by DavidXanatos; 03-01-2022 at 22:15.
Reply With Quote
The Following 2 Users Say Thank You to DavidXanatos For This Useful Post:
sh3dow (03-03-2022), user1 (03-08-2022)
  #2  
Old 03-01-2022, 23:43
DavidXanatos DavidXanatos is offline
Family
 
Join Date: Jun 2018
Posts: 167
Rept. Given: 2
Rept. Rcvd 39 Times in 26 Posts
Thanks Given: 52
Thanks Rcvd at 307 Times in 105 Posts
DavidXanatos Reputation: 39
problem solved I gave up adding random obj files to early with
loadcfg.obj
guard_support.obj
added it works

I attach a collection of all that's needed to build x86, x64, arm, arm64 and arm64ec binaries only dependent on the ntdll.dll
Attached Files
File Type: zip NtCRT.zip (49.3 KB, 13 views)
Reply With Quote
The Following 4 Users Gave Reputation+1 to DavidXanatos For This Useful Post:
deepzero (03-02-2022), Fyyre (03-05-2022), MarcElBichon (03-04-2022), sh3dow (03-03-2022)
The Following 3 Users Say Thank You to DavidXanatos For This Useful Post:
chants (03-08-2022), Mahmoudnia (03-02-2022), sh3dow (03-03-2022)
  #3  
Old 03-02-2022, 01:45
RamMerLabs RamMerLabs is offline
Family
 
Join Date: Feb 2020
Posts: 37
Rept. Given: 0
Rept. Rcvd 37 Times in 16 Posts
Thanks Given: 9
Thanks Rcvd at 173 Times in 31 Posts
RamMerLabs Reputation: 37
>>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)
Reply With Quote
The Following 3 Users Say Thank You to RamMerLabs For This Useful Post:
Abaddon (03-02-2022), DavidXanatos (03-02-2022), sh3dow (03-03-2022)
  #4  
Old 03-02-2022, 02:11
DavidXanatos DavidXanatos is offline
Family
 
Join Date: Jun 2018
Posts: 167
Rept. Given: 2
Rept. Rcvd 39 Times in 26 Posts
Thanks Given: 52
Thanks Rcvd at 307 Times in 105 Posts
DavidXanatos Reputation: 39
ah that's nice didn't know that MS is shipping those sources
Reply With Quote
  #5  
Old 03-07-2022, 18:49
DavidXanatos DavidXanatos is offline
Family
 
Join Date: Jun 2018
Posts: 167
Rept. Given: 2
Rept. Rcvd 39 Times in 26 Posts
Thanks Given: 52
Thanks Rcvd at 307 Times in 105 Posts
DavidXanatos Reputation: 39
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
Attached Files
File Type: zip uCRT.zip (50.6 KB, 7 views)
Reply With Quote
The Following User Gave Reputation+1 to DavidXanatos For This Useful Post:
user1 (03-08-2022)
The Following 2 Users Say Thank You to DavidXanatos For This Useful Post:
MarcElBichon (03-07-2022), user1 (03-08-2022)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT +8. The time now is 21:06.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX
( 1998 - 2022 )