EXETOOLS FORUM  

Go Back   EXETOOLS FORUM > General > Developer Section

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-10-2015, 14:25
mudlord's Avatar
mudlord mudlord is offline
Family
 
Join Date: Aug 2015
Posts: 83
Rept. Given: 11
Rept. Rcvd 69 Times in 25 Posts
Thanks Given: 38
Thanks Rcvd at 169 Times in 46 Posts
mudlord Reputation: 69
LZMA1 encoder/decoder (ASM+C)

Ask no questions:
This is the core LZMA depacker and compressor code from the private build of my EXE/DLL packer. Figured it might be useful to some people. Decided not to use LZMA2 since that seems to be just focused on format changes and not actual algorithm changes.

The depacker code is modified from the original to save size and the main compression function focuses on compression ratio.

Example (using lzma.cpp to pack and LzmaDecodeSize.c to depack):
Prototype of decoder is:
Code:
extern "C" { void LzmaDecode(UInt16* workmem,
	const unsigned char *inStream, SizeT inSize,
	unsigned char *outStream, SizeT outSize);
}
Example:
Code:
DWORD compressed;
DWORD original_sz;
BYTE *Original = Load_Input_File("unpacker.bin", &original_sz);
BYTE* compressed_data = compress_lzma(Original, original_sz, &compressed);
PVOID testmem = (unsigned char*)malloc(original_sz);
unsigned char* workmem = (unsigned char*)malloc(0xC4000);
LzmaDecode((UInt16*)workmem, compressed_data + LZMA_PROPS_SIZE, (SizeT)compressed - LZMA_PROPS_SIZE, (unsigned char*)testmem, (SizeT)original_sz);
free(Original);
free(compressed_data);
free(workmem);
free(testmem);
There is a ASM version as well of the C function which is slightly modified for more space savings, which was decompiled from the original MSVC2015 compiled code.
Attached Files
File Type: rar lzma_decenc.rar (34.2 KB, 77 views)

Last edited by mudlord; 12-10-2015 at 14:34.
Reply With Quote
The Following 3 Users Gave Reputation+1 to mudlord For This Useful Post:
dj-siba (12-10-2015), Storm Shadow (12-11-2015), tonyweb (12-12-2015)
The Following 5 Users Say Thank You to mudlord For This Useful Post:
0xall0c (04-06-2018), alephz (12-26-2015), Git (05-05-2016), niculaita (12-12-2015), Spiderz_Soft (12-20-2015)
 

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
XED2 (x86 encoder decoder) c++ library ferrit.rce General Discussion 7 01-05-2014 07:19
MS script decoder tbone General Discussion 2 10-08-2004 11:09


All times are GMT +8. The time now is 00:46.


��ICP��05004977��
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX