Author Topic: Hacking a linked library for Cortex M  (Read 4842 times)

0 Members and 2 Guests are viewing this topic.

Offline ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 2139
  • Country: ca
Hacking a linked library for Cortex M
« on: December 18, 2018, 10:08:37 am »
Hi,
There are several excellent libraries for ARM Cortex M parts, but some of them are restricted to a certain family, like for example the STM32 libraries, and I found that all of the ST libraries use the CRC engine to disable the library on none ST parts, maybe they have used something simple like this code

Code: [Select]
while(! compute this CRC based on our CRC IO);

So if it passes this test, it would continue with the init of the library, so I'm sure there is a way to manipulate the lib, so the question is how?

For example see the attached libraries , they will work only on STM32 parts.change the extension of the file to .a
« Last Edit: December 18, 2018, 10:14:16 am by ali_asadzadeh »
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2867
  • Country: us
Re: Hacking a linked library for Cortex M
« Reply #1 on: December 20, 2018, 07:20:24 am »
Sure it's possible to hack the library to make it work on other families.  It may or may not be easy to do so.  The question is, does the license under which the library was published permit you to do run it on other families?  If they bothered to include protection against this exact thing, then the answer is clearly no.
 
The following users thanked this post: Kilrah

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4589
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Hacking a linked library for Cortex M
« Reply #2 on: December 20, 2018, 07:59:50 am »
If you have already found how it validates the hardware. You can easily decompile it, replace all branch-if instructions after a MOV from the CRC, and recompile it. Right?
I do not see if this is worth the effort. You're obviously violating some license agreement.
This is probably not allowed to further discuss on this forum.
 

Offline ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 2139
  • Country: ca
Re: Hacking a linked library for Cortex M
« Reply #3 on: December 20, 2018, 09:01:06 am »
Ok, thanks for the info. I think it maybe useful for our code libraries too
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1981
  • Country: 00
Re: Hacking a linked library for Cortex M
« Reply #4 on: December 20, 2018, 09:02:16 am »
Agreed. 2 points:
- The object files does not specify STM32 in any of filenames, instead it says ARMv4, so why would that indicate it's targetted for STM32 only CRC hardware?
- You seem to post the library files of a commercial product made by Spirit DSP. Maybe you have taken it from an evaluation file delivery, but I don't think you own the copyright to post these files on this forum.

If you really want to undertake any modification, know that you're probably doing something illegal and you're on your own.
 

Offline nick_d

  • Regular Contributor
  • *
  • Posts: 120
Re: Hacking a linked library for Cortex M
« Reply #5 on: December 20, 2018, 10:06:48 am »
Whilst I wouldn't have moral qualms about hacking into something like this, at least for personal use, it is really a bad investment to put ANY effort at all into a closed source solution. A lot of people take the view "oh thousands of hours of R&D have gone into this super special optimized code, you can't compete blahblah" but if you actually had the source code you would probably find it's not that special. And in this day and age no matter what you want to do there is an open source solution somewhere. It's often not complete or might be suboptimal or whatever. But overall you will get a better return on your investment if you take that, which maybe does 50-60% of what you want to do, and improve it -- than if you get a commercial version which does 90-95% of what you want and does it very well, but wastes a lot of time trying to understand the interface and requires elaborate workarounds to deal with the 5-10% that isn't what you need and can't be changed (or pray for good support...).
cheers, Nick
 
The following users thanked this post: Kilrah

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3534
  • Country: us
Re: Hacking a linked library for Cortex M
« Reply #6 on: December 27, 2018, 06:13:34 pm »
This depends entirely on the source and the target.

The biggest issue is dependencies. It's common to encounter code that the code is portable, but the libraries it uses are not.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3958
  • Country: de
Re: Hacking a linked library for Cortex M
« Reply #7 on: December 27, 2018, 06:41:00 pm »
Sure it's possible to hack the library to make it work on other families.  It may or may not be easy to do so.  The question is, does the license under which the library was published permit you to do run it on other families?  If they bothered to include protection against this exact thing, then the answer is clearly no.

Who cares? He is from Iran, and by US laws he shouldn't be receiving anything with any trace of US technology.
Crime is not a shame, if you have no other way out.

But this forum isn't hosted in Iran and debating how to break this sort of software protection here could be a good way for Dave (or his hosting) to get a legal nastygram from the actual copyright owners.

So yes, one needs to care about such minutiae.
 
The following users thanked this post: newbrain

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17807
  • Country: fr
Re: Hacking a linked library for Cortex M
« Reply #8 on: December 27, 2018, 07:13:20 pm »
Yeah, I don't think encouraging people to "hack" copyrighted stuff is a good idea either. This is not a hackers' forum.

As to the non-legal aspects of this, I don't think this is a good idea either. Using hacked libraries would make your developments a hell to maintain, and you'd get zero support nor any guarantee that it does what it's supposed to. I wouldn't invest any significant amount of development time with something I have no control over whatsoever, to the point of using it illegally. To me it's wasted time in the long run, and people's development time is much more valuable than development tools IMO.

The op's best bet, especially on a forum like this one, would be to ask people for pointers to existing libraries that do what he needs done. There may even be open-source ones that he's not aware of. Would be more productive. I guess.
 

Offline ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 2139
  • Country: ca
Re: Hacking a linked library for Cortex M
« Reply #9 on: December 27, 2018, 08:33:15 pm »
Dear Guys, thanks for all your concerns, I do not do this hack, because There are lot's of other open source solutions out there, so why bother ? :) ;) There is the MAD MP3 decoder and there is Lame for encoder :D
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 10088
  • Country: us
Re: Hacking a linked library for Cortex M
« Reply #10 on: December 27, 2018, 09:59:17 pm »
Even if the library could be opened and disassembled, all that would result is highly optimized assembly output from a compiler set to maximum optimization.  The result is that even an experienced assembly language coder is going to have a terrible time following the logic flow.

ARM specifies the core but the manufacturer implements the IO devices including addresses, registers, bit definitions, specifications - everything is unique to the manufacturer if they implement their own peripherals.  They could license certain peripherals from ARM but they could still make sweeping changes.  Maybe the documentation gives some insight into what the library code is doing but how the code gets it done will probably be a mystery.

I see two choices:  First, use the library and call it good or, second, create your own library from scratch.  I don't see any chance of success by cracking the library protection.
 

Offline abyrvalg

  • Frequent Contributor
  • **
  • Posts: 898
  • Country: es
Re: Hacking a linked library for Cortex M
« Reply #11 on: December 28, 2018, 09:33:00 am »
Simulate that missing CRC peripheral in data abort handler :D
 

Offline ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 2139
  • Country: ca
Re: Hacking a linked library for Cortex M
« Reply #12 on: December 28, 2018, 04:25:31 pm »
Quote
Simulate that missing CRC peripheral in data abort handler :D
how?

Something like this?

Code: [Select]
void HardFault_Handler(void){
//get the input data from what reg

//calculate CRC

//Send back the calculated CRC to what Reg


}

Some C to ARM ASM would help alot :)
« Last Edit: December 28, 2018, 05:31:25 pm by ali_asadzadeh »
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4589
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Hacking a linked library for Cortex M
« Reply #13 on: December 29, 2018, 02:11:00 pm »
You can’t return from a hardfault though. It makes a hardware stackframe.
You must insert calls to a function that calculates crc.
 

Offline ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 2139
  • Country: ca
Re: Hacking a linked library for Cortex M
« Reply #14 on: December 29, 2018, 02:50:41 pm »
Code: [Select]
You can’t return from a hardfault though. It makes a hardware stackframe.
You must insert calls to a function that calculates crc.
Thanks, any hints how that should be done is highly appreciated ;)
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: Hacking a linked library for Cortex M
« Reply #15 on: December 30, 2018, 08:37:14 am »
I think circumventing copy protection violates the DMCA. You may not care if you are outside US jurisdiction, but it's just a bad idea for forum hosts to entertain discussion of it, it could be construed as "providing services".

And anyway, if you have enough knowledge to circumvent it, you could probably write your own version of the library.
Bob
"All you said is just a bunch of opinions."
 

Offline ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 2139
  • Country: ca
Re: Hacking a linked library for Cortex M
« Reply #16 on: December 30, 2018, 01:14:33 pm »
Quote
I think circumventing copy protection violates the DMCA. You may not care if you are outside US jurisdiction, but it's just a bad idea for forum hosts to entertain discussion of it, it could be construed as "providing services".

And anyway, if you have enough knowledge to circumvent it, you could probably write your own version of the library.

I would not use if for anything, AS I said there are open source version for the lib, it's for education only, In here there has been several hacks like the rigol Scope etc...
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->