Some observations on the use of RTTI lazarus / 21-General ---------------------------------------------------------------------- vfclists · 2024-10-05 15:23 I came across this article on RTTI by Luiz Americo (where and how is he anyway?) - http://lazarusroad.blogspot.com/2010/05/discover-of- rtti.html and realized some applications of RTTI I never truly thought of. I have been looking at RTTI in terms of setting the properties of controls, such as with the RTTI controls unit, but never in terms of passing any arbitrary data to a class in order to get its property setters and getters to operate on that data even if the property doesn't have a corresponding field in the object. I read about how some projects which involving hooking up Lazarus to other languages like Python4Lazarus, VClua etc depend on RTTI, ExtendedRTTI etc and wonder how little of this has to do with updating controls and other UI stuff. Is there more to RTTI than I think, and are there more examples of this kind of usage that has nothing to do with UI controls? Have I been confusing RTTI for UI controls with the purpose and importance of RTTI in general? ---------------------------------------------------------------------- egsuh · 2024-10-07 06:09 RTTI can be linked to any property, calling its setter and getter even if there are no corresponding field. Is this what you are wondering? ---------------------------------------------------------------------- vfclists · 2024-10-07 12:05 Quote from: egsuh on October 07, 2024, 08:09:47 amRTTI can be linked to any property, calling its setter and getter even if there are no corresponding field. Is this what you are wondering? Yes. Although it is logical when you think of it, it escaped me for a while and probably because most of the examples shown involved manipulating UI objects. ---------------------------------------------------------------------- Thaddy · 2024-10-07 12:22 My complete example on the wiki is a console demo.... ---------------------------------------------------------------------- vfclists · 2024-10-07 16:20 Quote from: Thaddy on October 07, 2024, 02:22:27 pmMy complete example on the wiki is a console demo.... Link? Searching for "rtti console" is not revealing it. ---------------------------------------------------------------------- vfclists · 2024-10-07 16:28 Quote from: egsuh on October 07, 2024, 08:09:47 amRTTI can be linked to any property, calling its setter and getter even if there are no corresponding field. Is this what you are wondering? Yes. Although it is logical when you think of it, it escaped me for a while and probably because most of the examples shown involved manipulating UI objects. Do you know of any examples which are less UI oriented? ---------------------------------------------------------------------- Thaddy · 2024-10-07 16:35 Quote from: vfclists on October 07, 2024, 06:20:34 pmink? Searching for "rtti console" is not revealing it. https://wiki.freepascal.org/Custom_Attributes The attributes are still being worked on. i can probably simpyfy that example a bit. And clarify that with the same attribute used like this, you get the day I was born: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [ADateTime(21237.0)]You can see that the other constructor is called. Attributes can have multiple constructors, so you can add what you need. Another example I have is where you annotate a TBufDataSet with field attributes, so you can set e.g. FieldDefs at runtime from values that are defined as attributes at compile time. You can change the main program body of the wiki examle to this and you can see there are more than one way to query the attribute value:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  //adapted from an unrelated Embarcadero example// rest of the code stays as is.var  LContext: TRttiContext;  LType: TRttiType;  LAttr: TCustomAttribute;begin  { Create a new Rtti context }  LContext := TRttiContext.Create;    { Extract type information for TMyDateTimeClass }  LType := LContext.GetType(TypeInfo(TMyDateTimeClass));  { Search for the custom attribute and do some custom processing }  for LAttr in LType.GetAttributes() do    if LAttr is ADateTimeAttribute then      Writeln(DateTimeToStr(ADateTimeAttribute(LAttr).FArg));   { Destroy the context }  LContext.Free;end. ---------------------------------------------------------------------- Warfley · 2024-10-07 19:36 Quote from: vfclists on October 07, 2024, 06:28:18 pmDo you know of any examples which are less UI oriented? There are two man use cases for RTTI. First the most obvious one is data serialization and deserialization. For example, if you want to take a record and serialize it into json, right now you have to do it like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i jsonObject.Strings['MyField1'] := MyRec.MyField1;jsonObject.Integers['MyField2'] := MyRec.MyField2;jsonObject.Arrays['MyArrayField'] := SerializeArray(MyRec.MyArrayField);Extremely annoying and error prone. With Extended RTTI, where field names are written into the RTTI, you could write a serializer that will just take all public fields and writes them down, recursively descending into other records or arrays. Then it would just be: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SerializeRecord(@MyRec, TypeInfo(TMyRec));And when you update your record, rename fields, etc. the serializer will still work because of RTTI. This is especially useful combined with the custom attributes, where you could do things like that: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TMyRecord = record    [SerializeName('Field1'), SerializeOptional('Default')]    FField1: String;    [SkipSerialize]  FHiddenField: Integer;  //...so SerializeName would be an attribute to have a custom name, e.g. for backwards compatibility, or to not have the leading F as in this case. SerializeOptional could be an attribute to say when deserializing and this object is not there, fill it with 'Default'. SkipSerialize would tell the serializer that FHiddenField is an internal field not to be serialized into json. This way you do not need to write a single line of (error prone) code to convert your data into other formats, as all the required information can be encoded into the definition of the type. The second main use case is reflection. Basically altering the behavior of your code at runtime. For example you could have a module system where you scan your filesystem for a module (e.g. in form of a dynamic library) and if a new module is found the module is loaded and RTTI is used to e.g. load these function pointers into existing objects/classes at runtime without having to restart the application. For example you could create a software where classes objects have logger fields, and on startup, the module loader would look if there is a logger module available, and if so, scan the classes, if any has a logger field, and dynamically load the logger into that field. ---------------------------------------------------------------------- egsuh · 2024-10-08 02:29 Quotehttps://wiki.freepascal.org/Custom_Attributes In the second example of previous page, where does [ADateTime] come from? Should it be [ADateTimeAttribute]? I have added comments below. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program testattributes;   {$mode delphi}{$H+}{$M+}{$warn 5079 off} { turn warning experimental off }uses  sysutils, typinfo, rtti, classes; type   ADateTimeAttribute = class(TCustomAttribute)   private     FArg:TDateTime;   public     constructor Create(const aArg: TDateTime);overload;     constructor Create(const aArg: String = {$I %DATE%});overload;    published     property Date:TDateTime read Farg;   end;     {This calls the second constructor }   [ADateTime]   // <== Where does this come from? not [ADateTimeAttribute]?    TMyDateTimeClass = class   private     FDateTime:TDateTime;   public     constructor create;   published     [ADateTime]   // <== And this   property Day:TDateTime read FDatetime write FdateTime;   end; ---------------------------------------------------------------------- Thaddy · 2024-10-08 07:50 That is explained higher up in the wiki and in my comments of the complete wiki example too: you can omit the attribute suffix part. One usually does. The code is correct. Clear? Otherwise, please ask what is not clear. This is also Delphi compatible. ---------------------------------------------------------------------- egsuh · 2024-10-08 08:18 Ah I see. There were explanations already. ---------------------------------------------------------------------- Warfley · 2024-10-08 08:49 Quote from: Thaddy on October 08, 2024, 09:50:31 amThat is explained higher up in the wiki and in my comments of the complete wiki example too: you can omit the attribute suffix part. One usually does. The code is correct. Clear? Otherwise, please ask what is not clear. This is also Delphi compatible. My question to this would be, if people are to lazy to type out ADateTimeAttribute, why name it ADataTimeAttribute and not just ADateTime to begin with? Code should not enforce naming conventions, the programmer should chose the names they seem fit and the compiler should not interfere with that by introducing new names for things without them being specifically declared. Or to put it in a different way, the compiler should not silently add new symbols because it thinks it can do naming better than the programmer ---------------------------------------------------------------------- Thaddy · 2024-10-08 09:09 The attribute post-fix is (seems) only necessary to distinguish between a normal class and an attribute class The attribute class has some special handling (like I showed with the multiple constructors). As I understand it, it is to recognize an attribute, and how to interpret it: [ADateTime] vs [ADateTime(DateTimeValue)] in my example reference the same attribute class. The compiler knows it is an attribute class and based on how the attribute is declared it calls the proper constructor. You do not instantiate an attribute class manually. That happens at runtime or compile time. An Attribute needs not to be ever used and is only created when it is referenced. ---------------------------------------------------------------------- Warfley · 2024-10-08 11:00 Well... I don't think it's a good idea to have semantic embedded in naming conventions. Because in the end it should just be that, a convention. Also it should be mentioned that this is a complete novum for Pascal, there is not a single feature that implies semantic from naming. You can write your programs in any (natural) language (using define macros you can even translate keywords). If you impose meaning to the names, you also impose english as base language for your identifiers. Especially as Attribute is a very common word that you may call your classes that just by "accident". I mean the clearest way of doing that would just be a syntax feature: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TMyAttribute = attribute class ...Or to not introduce new keywords, a synonym for "attribute" would be property, so adding something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TMyAttribute = property class ...would be completely trivial to add to the parser (like <10 lines of code to be added to the FPC kind of trivial) I don't see any advantage in utilizing the naming scheme over something like above, and but I see tons of disadvantages ---------------------------------------------------------------------- Thaddy · 2024-10-10 08:51 It is also the proverbious Delphi compatibility.. ---------------------------------------------------------------------- vfclists · 2024-10-20 10:31 Quote from: Warfley on October 07, 2024, 09:36:33 pmQuote from: vfclists on October 07, 2024, 06:28:18 pmDo you know of any examples which are less UI oriented? There are two man use cases for RTTI. First the most obvious one is data serialization and deserialization. For example, if you want to take a record and serialize it into json, right now you have to do it like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i jsonObject.Strings['MyField1'] := MyRec.MyField1;jsonObject.Integers['MyField2'] := MyRec.MyField2;jsonObject.Arrays['MyArrayField'] := SerializeArray(MyRec.MyArrayField);Extremely annoying and error prone. With Extended RTTI, where field names are written into the RTTI, you could write a serializer that will just take all public fields and writes them down, recursively descending into other records or arrays. Then it would just be: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SerializeRecord(@MyRec, TypeInfo(TMyRec));And when you update your record, rename fields, etc. the serializer will still work because of RTTI. This is especially useful combined with the custom attributes, where you could do things like that: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TMyRecord = record    [SerializeName('Field1'), SerializeOptional('Default')]    FField1: String;    [SkipSerialize]  FHiddenField: Integer;  //...so SerializeName would be an attribute to have a custom name, e.g. for backwards compatibility, or to not have the leading F as in this case. SerializeOptional could be an attribute to say when deserializing and this object is not there, fill it with 'Default'. SkipSerialize would tell the serializer that FHiddenField is an internal field not to be serialized into json. This way you do not need to write a single line of (error prone) code to convert your data into other formats, as all the required information can be encoded into the definition of the type. The second main use case is reflection. Basically altering the behavior of your code at runtime. For example you could have a module system where you scan your filesystem for a module (e.g. in form of a dynamic library) and if a new module is found the module is loaded and RTTI is used to e.g. load these function pointers into existing objects/classes at runtime without having to restart the application. For example you could create a software where classes objects have logger fields, and on startup, the module loader would look if there is a logger module available, and if so, scan the classes, if any has a logger field, and dynamically load the logger into that field. Is the kind of ExtendedRTTI you speak of available in current FreePascal? ---------------------------------------------------------------------- Warfley · 2024-10-20 12:40 In trunk yeah, but not yet stable ---------------------------------------------------------------------- Fibonacci · 2024-10-20 13:50 Another issue with RTTI is that it facilitates reverse engineering of the program. It's extremely frustrating to see all type names (classes, records), unit names, and even the program name (from the first line of code). There should be an option to limit RTTI to the absolute minimum when it's not used. ---------------------------------------------------------------------- Joanna · 2024-10-20 14:10 Quote from: Fibonacci on October 20, 2024, 03:50:56 pmAnother issue with RTTI is that it facilitates reverse engineering of the program. It's extremely frustrating to see all type names (classes, records), unit names, and even the program name (from the first line of code). There should be an option to limit RTTI to the absolute minimum when it's not used. That concerns me too. Does anyone know what was the last version of fpc before rtti was introduced? ---------------------------------------------------------------------- vfclists · 2024-10-20 14:27 Quote from: Fibonacci on October 20, 2024, 03:50:56 pmAnother issue with RTTI is that it facilitates reverse engineering of the program. It's extremely frustrating to see all type names (classes, records), unit names, and even the program name (from the first line of code). There should be an option to limit RTTI to the absolute minimum when it's not used. I believe this depends on some {$M+} compiler directive which is set by default. Others may know more. ---------------------------------------------------------------------- Thaddy · 2024-10-20 15:18 Since today there is some better support for rtti in trunk. I would read the commit discussion if that solves your issue. Note that $M+ works for anything that derives fromTPersistent, because that is compiled in $M+ mode. So not a default otherwise. ---------------------------------------------------------------------- Bogen85 · 2024-10-20 15:30 Quote from: Joanna from IRC on October 20, 2024, 04:10:14 pmQuote from: Fibonacci on October 20, 2024, 03:50:56 pmAnother issue with RTTI is that it facilitates reverse engineering of the program. It's extremely frustrating to see all type names (classes, records), unit names, and even the program name (from the first line of code). There should be an option to limit RTTI to the absolute minimum when it's not used. That concerns me too. Does anyone know what was the last version of fpc before rtti was introduced? Not "facilitating" reverse engineering only makes it difficult for the beginner reverse engineers, not the advanced ones. With AI those that are beginners and want to be advanced, using AI to augment one's effort (if they don't get bogged down in wrong direction and are adaptive, eager, and willing to intelligently embrace and leverage AI) can make the lack of RTTI largely irrelevant. While RTTI might be concerning to some, we are in the 2020s now, lack of RTTI is not going to stop ambitious reverse engineers, even if they are beginners. ---------------------------------------------------------------------- Thaddy · 2024-10-20 15:43 I do not think there is a real concern about rtti. Nowadays it is a firmly rooted part of languages like C++ and Object Pascal. On the Pascal side it started with D1 and Lazarus had to provide for that since it's own day one too. The reason that I do not see a security concern is merely that it allows a standard object streaming mechanism for compiled languages. And you will need that at some point. (ORM comes to mind) If something can be compiled it follows that it can always be decompiled. For a devoted team of programmers that can sureley be done, but I have rarely seen proper decompilers for compiled languages that compile back to compilable sourcecode. But what they do provide is provide insight. ---------------------------------------------------------------------- Joanna · 2024-10-20 16:09 @bogen85 do you have a better way of preventing reverse engineering? ---------------------------------------------------------------------- Thaddy · 2024-10-20 16:19 Other than a complete criminal law article in every country's criminal law??? You would have to forbid compilers and hexbrowsers.(the latter the simplest form of decompiler) It is simply silly. ---------------------------------------------------------------------- Fibonacci · 2024-10-20 16:28 Quote from: Thaddy on October 20, 2024, 06:19:01 pmYou would have to forbid compilers and hexbrowsers.(the latter the simplest form of decompiler) There are always individuals like @Bogen85 who say it doesn’t matter to hide things (RTTI in this case). A sophisticated adversary specialized in this narrow field of binary analysis can reverse engineer your binary… Well, I certainly don’t want just anyone to open my .exe LITERALLY in NOTEPAD and say "oh, so you used FPC and this component, noob, maybe I will do something similar and sell it for half your price". ---------------------------------------------------------------------- Thaddy · 2024-10-20 16:50 Perfect obfuscation. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [unit fourwaylogic;{$mode objfpc}interfacetype  Cauldron = set of (false,true);const  EyeOfNewt:Cauldron = [];  ToeOfFrog:Cauldron = [false];  WoolOfBat:Cauldron = [true];  TongueOfDog:Cauldron = [false,true]; {$push}{$notes off}{$hints off}operator and (const EyeOfNewt,ToeOfFrog:Cauldron):Cauldron;inline;operator or (const EyeOfNewt,ToeOfFrog:Cauldron):Cauldron;inline;operator xor (const EyeOfNewt,ToeOfFrog:Cauldron):Cauldron;inline;operator not (const EyeOfNewt:Cauldron):Cauldron;inline;operator in (const EyeOfNewt,ToeOfFrog:Cauldron):Boolean;inline;{$pop}function stable(const EyeOfNewt:Cauldron):Boolean; implementation operator and (const EyeOfNewt,ToeOfFrog:Cauldron):Cauldron;inline;begin  result := EyeOfNewt * ToeOfFrog;    // intersectionend; operator or (const EyeOfNewt,ToeOfFrog:Cauldron):Cauldron;inline;begin  result := EyeOfNewt + ToeOfFrog;    // unionend; operator xor (const EyeOfNewt,ToeOfFrog:Cauldron):Cauldron;inline;begin  result := EyeOfNewt >< ToeOfFrog;   // symmetric differenceend; operator not (const EyeOfNewt:Cauldron):Cauldron;inline;begin  result := TongueOfDog - EyeOfNewt; // difference, inverseend; operator in (const EyeOfNewt,ToeOfFrog:Cauldron):Boolean;inline;begin  result := EyeOfNewt <= ToeOfFrog;  // containsend; function stable(const EyeOfNewt:Cauldron):Boolean;inline;begin  result := not (EyeOfNewt = TongueOfDog);end;end.I suppose you know your Shakespeare ? ---------------------------------------------------------------------- Joanna · 2024-10-20 17:27 Thaddy that’s some funny code  I’m going to agree with Fibonacci. Should we all get rid of door locks because lock pickers exist? ---------------------------------------------------------------------- Warfley · 2024-10-20 18:15 Quote from: Fibonacci on October 20, 2024, 03:50:56 pmAnother issue with RTTI is that it facilitates reverse engineering of the program. It's extremely frustrating to see all type names (classes, records), unit names, and even the program name (from the first line of code). There should be an option to limit RTTI to the absolute minimum when it's not used. I myself am not that great at reverse engineering, but know a lot of people in the field, and while it's true that using binaries with symbol names left in is usually recommended to beginners, e.g. especially platforms like macOS or Android native where default build setups usually leave the symbols in the executable (e.g. Android native apps are build as a dynamic library thats loaded by a Java app, and while it would be possible to just export the symbols required my java, many build environments export all symbols from the native code), it's at most considered a slight hint. Especially if you consider what information RTTI contains. It does not contain information about the functions called, it doesn't even necessarily contain information about what type is used where. Sure you can find managed types due to their initialization procedures and classes through their constructor but thats it. Additionally names alone don't give you anything So anyone proficient enough in reverse engineering with RTTI enabled will also get there without RTTI. The advantage someone gets for reverse egnineering your code through RTTI is absolutely minimal. Yet RTTI is required by the FPC for the core functionality for Object Pascal. Managed types (Strings, Arrays, Variant, Records) require RTTI for their management operations. Composition types (Classes, Records, Objects) require RTTI to manage their managed children (e.g. a record containing a dynamic string itself becomes managed by extension). So while you gain extremely little advantage by turning off RTTI, changing FPC to a degree that it would support both RTTI enabled and RTTI disabled code, would be a massive challange and workload that basically doubles the maintainance work. So you are requesting adding a lot of additional work for completely miniscule benefits. ---------------------------------------------------------------------- Warfley · 2024-10-20 18:38 Quote from: Joanna from IRC on October 20, 2024, 07:27:08 pmI’m going to agree with Fibonacci. Should we all get rid of door locks because lock pickers exist? I mean it's a question of costs and benefit. Would you buy a doorlock that costs 10k€ but could be easily bypassed my anone with a 5€ tool? Because thats in the end what we are talking about, how much it "costs" (in term of manpower) to implement maintan two different systems in the FPC, compared how much it "costs" (also in term of manpower) the attacker to circumvent this. Also I'm always quite curious whats your use-case, what business risk do you want to mitigate with that measure? Because reverse engineering protection is a very niche use-case. Looking at other dev environments like Java, .Net or even LLVM backed Swift and Objective C on MacOS, do generally publish all their symbols. For the vast majority of System reverse engineering is not a threat that needs to be mitigated. There are commercially available obfuscators for many different languages, but they are a very small niche of products, most developers don't need protection against this. You usually see it in game development and in IT-Security products. Both things that are usually not the main domain of FPC ---------------------------------------------------------------------- marcov · 2024-10-20 20:43 Quote from: Warfley on October 20, 2024, 08:38:03 pmLooking at other dev environments like Java, .Net or even LLVM backed Swift and Objective C on MacOS, do generally publish all their symbols. For the vast majority of System reverse engineering is not a threat that needs to be mitigated. There are commercially available obfuscators for many different languages, but they are a very small niche of products, most developers don't need protection against this. Obfuscating debug info is less of a problem, since the symbols only link reference with definition. Change both and it will be ok. RTTI is harder to change, since some field properties might exist in datastreams that stop working. ---------------------------------------------------------------------- Joanna · 2024-10-20 22:49 It also seems like leaving symbols in would make the exe larger. Does fpc have obfuscation? {If it doesn’t it should be added }Think I once saw it somewhere. If not the only option left it to convert everything you want kept private into jibberish before building. ---------------------------------------------------------------------- MarkMLl · 2024-10-21 07:22 Quote from: Joanna from IRC on October 21, 2024, 12:49:45 amIt also seems like leaving symbols in would make the exe larger. Does fpc have obfuscation? {If it doesn’t it should be added }Think I once saw it somewhere. If not the only option left it to convert everything you want kept private into jibberish before building. I've been watching this thread, and suggest that there's a distinction that might be being overlooked. The first is that the most revealing information is debugging symbols since they provide the name and position of every variable and routine, and they can be omitted or stripped reliably. The second is RTTI, which is less revealing but is problematic in that it cannot be stripped. The third is obfuscation at the source level, which replaces variable names etc. but in general does nothing that a strip could also do (it was originally aimed at making sourcecode difficult to analyze, without changing the generated binary. The fourth is encryption, which is rarely 100% effective unless done by the sort of technology that makes privacy advocates extremely unhappy. But the bottom line is that the transformations applied by compilers are by now well-understood and that tools like Ghidra, originally written (and donated to the community) by the NSA but now embraced by hackers of all hat styles, makes it relatively easy to analyse an unknown binary, even in the complete absence of embedded symbolic information. MarkMLl ---------------------------------------------------------------------- Warfley · 2024-10-21 10:44 Quote from: Joanna from IRC on October 21, 2024, 12:49:45 amIt also seems like leaving symbols in would make the exe larger. It depends, executables are padded up to multiple kilobytes. So if the symbol names total to less than the padding, you will have 0 difference. But sure in any larger program having all symbol names in there adds slightly to the size. But let's do a simple calculation. A 500gb SSD costs around 30€, let's say all the symbol names add up to a whopping 100kb (100kb of raw ASCII text us a lot), we end up with an additional cost of 0.000006€ for your application. I'm pretty sure if your revenue margins are this low that this is a valid concern, you might reconsider your business decisions that lead you there. Quote from: Joanna from IRC on October 21, 2024, 12:49:45 amDoes fpc have obfuscation? {If it doesn’t it should be added }Think I once saw it somewhere. If not the only option left it to convert everything you want kept private into jibberish before building. The FPC is open source, feel free to add it yourself if you need it. The vast vast majority of people will not need it, especially as obfuscation usually impedes performance, so making your app worse with nearly no benefit is not a good tradeoff. Let me ask again, what are you protecting against? If we are talking certification, source code is usually ot considered a primary asset, meaning no one protects source for the sake of protecting source code. What do you want to protect against by protecting the source? ---------------------------------------------------------------------- Joanna · 2024-10-21 11:05 Quote The FPC is open source, feel free to add it yourself if you need it. The vast vast majority of people will not need it, especially as obfuscation usually impedes performance, so making your app worse with nearly no benefit is not a good tradeoff. I didn’t know tha obfuscation slows down code. I know little about how obfuscation a works I know that it is used for web programming. Quote What do you want to protect against by protecting the source? well obviously if you have something like Say a banking app you don’t want people getting into your source code looking for exploits. Also as Fibonacci said earlier. There are people who will clone your apps and sell them as their own ..  who would want that? Not me ! ---------------------------------------------------------------------- Warfley · 2024-10-21 11:23 Quote from: Joanna from IRC on October 21, 2024, 01:05:35 pmI didn’t know tha obfuscation slows down code. I know little about how obfuscation a works I know that it is used for web programming.Basically obfuscation is to replace the obvious way of doing something with a more complicated way. For example, you could replace all Boolean operators with just nand as a simple example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i a And b = (a nand b) nand (a nand b)And as you can see this replaced one operation with 3. This is the slowdown I talked about. With web it's usually not obfuscation for obfuscation sake, but for performance and compatibility. JavaScript source is always open source. The problem is, what is readable might not be what's most efficient. For example, a long variable name requires the Lexer longer to read than a short one, so the Js minimizers first rename all variables to short random few char names. Second it removes all white spaces and stuff like that. The result is unreadable code, but not for the sake of making the code unreadable, but for other utilities Quote well obviously if you have something like Say a banking app you don’t want people getting into your source code looking for exploits. Also as Fibonacci said earlier. There are people who will clone your apps and sell them as their own ..  who would want that? Not me ! Bank apps are very specific because they are security software. But even there it's not the goal to protect the code, it's the goal to protect the primary assets, mainly the user pin, the private keys stored in the secure enclave/keystone and access to their bank account. There obfuscation is just one of many techniques, like anti debugging, root detection, etc. But how many banking apps are written in Pascal? There are not so many written to begin with and those that do exist are usually written in much better maintained languages. Because do you know what's more important than obfuscation? Having a Compiler and libraries which are hardened and well tested and do not accidentally introduce any vulnerabilities. Which is something the FPC cannot provide. Also Pascal is an unsafe language, so I hope that no one is writing security software in it to begin with ---------------------------------------------------------------------- MarkMLl · 2024-10-21 11:53 Quote from: Joanna from IRC on October 21, 2024, 01:05:35 pmwell obviously if you have something like Say a banking app you don’t want people getting into your source code looking for exploits. That is called security by obscurity, and is universally condemned: if somebody can crack your security solely by applying skill and time to it then you're screwed, since apart from anything else that sort of person will specifically target it because it gives him an advantage over those of his felonious competitors who lack those resources. QuoteAlso as Fibonacci said earlier. There are people who will clone your apps and sell them as their own ..  who would want that? Not me ! In that case use a platform where every executable is specifically encrypted for the machine it's going to run on. The only way to do that on a PC is to use an on-CPU TPM, which privacy advocates refuse because they are obsessed with the idea that it will allow Disney (of which the US government is of course a subsidiary) to snoop on them. And at a risk moving further from the original RTTI question (but justifying it as an attempt to focus on the "what are you protecting yourself" issue), a vast amount of software has been hacked by looking for encraption keys in over-the-net updates: once you've cracked one you can apply that knowledge to what's running on just about any PC since they're all fundamentally the same and unserialised. And even if an update was individually encrypted you're at risk of somebody getting at your PC or domestic appliance and recovering its private key: who in here would notice if an intruder opened their PC, applied test probes and read security info from the mainboard? MarkMLl ---------------------------------------------------------------------- Bogen85 · 2024-10-21 12:06 Quote from: Fibonacci on October 20, 2024, 06:28:54 pmQuote from: Thaddy on October 20, 2024, 06:19:01 pmYou would have to forbid compilers and hexbrowsers.(the latter the simplest form of decompiler) There are always individuals like @Bogen85 who say it doesn’t matter to hide things (RTTI in this case). A sophisticated adversary specialized in this narrow field of binary analysis can reverse engineer your binary… Well, I certainly don’t want just anyone to open my .exe LITERALLY in NOTEPAD and say "oh, so you used FPC and this component, noob, maybe I will do something similar and sell it for half your price". Well, always is relative.... I actually did not consider your scenario (some casual end user, not really who I would consider a reverse engineer, opens your .exe in notepad) and the fallout from RTTI exposing things. In the software domains I work in (where there is a lot of closed source and shipped binaries) even with advanced reverse engineering tools if a customer were try the it would take them days (or weeks) to extract anything useful and months (or years) to produce anything viable. And none of that would be taking place in a vaccum, those who developed the software initially would be hearing about, as people always talk in these domains. And when they would start to produce anything viable and selling it, they would be getting sued. When someone does want to make their own product, they start their own company and start from scratch, and how they are developing the new products is chatted about and the other companies all know. So they make sure to develop in such a manner as to not get sued. So, to be fair, I was not taking the time to see your side of it. So yeah, for situations in domains with producers and consumers like you describe, and those producers and consumers are not operating in overlapping chatty spheres of development, then disabling/stripping all RTTI and symbols in the final executable I can see as having merit. The domain you describe is just not one I've operated in, but I do see your point, and it is a valid one. But as MarkMLI pointed out, in cases like you describe, the executable could be encrypted in a way that allows it run, but not be observed so casually. Even if encrypted, it still has to be run, and therefore at some point has to be decrypted, but the difficulty of decrypting for human (or for other machine) analysis increases as the encryption is pushed deeper into the hardware/firmware the program is running on. ---------------------------------------------------------------------- Bogen85 · 2024-10-21 12:49 Quote from: Warfley on October 21, 2024, 01:23:05 pmAlso Pascal is an unsafe language, so I hope that no one is writing security software in it to begin with And then the RTTI would be useful for it made it obvious it was pascal, so a customer who knows about pascal who accidentally opened it up in notepad and saw that, can report with a vendor concern to determine if the app in question (especially if an end user received a binary) is mission critical and mission safe in regard to how it is to be used. ---------------------------------------------------------------------- Joanna · 2024-10-21 21:38 Quote when they would start to produce anything viable and selling it, they would be getting sued. Sure it takes them effort to reverse engineer the code, but it’s probably much less effort than creating all the code to begin with. Not everyone who plagiarizes software can be sued. What if they are located outside of your legal jurisdiction? There are well known companies that have gotten away with claiming other people’s work as their own and have a legal department to handle any lawsuits. I’d much rather that my code can’t be easy to reverse engineer to begin with than hope that the legal system will rescue me after my code is stolen. ---------------------------------------------------------------------- Bogen85 · 2024-10-22 00:49 Quote from: Joanna from IRC on October 21, 2024, 11:38:56 pmQuote when they would start to produce anything viable and selling it, they would be getting sued. Sure it takes them effort to reverse engineer the code, but it’s probably much less effort than creating all the code to begin with. Not everyone who plagiarizes software can be sued. What if they are located outside of your legal jurisdiction? There are well known companies that have gotten away with claiming other people’s work as their own and have a legal department to handle any lawsuits. I’d much rather that my code can’t be easy to reverse engineer to begin with than hope that the legal system will rescue me after my code is stolen. I'm talking about a specific class of companies and customers, where all involved are playing in the same global arena with a lot of people who talk. Those are "small world" arenas (despite being global), and the likelihood of getting caught and found guilty is very high. This does not apply the same way to all other classes of suppliers and consumer of software products. ---------------------------------------------------------------------- Joanna · 2024-10-22 01:16 Sure they will get caught and might get a slap on the wrist ---------------------------------------------------------------------- Bogen85 · 2024-10-22 01:21 Quote from: Joanna from IRC on October 22, 2024, 03:16:55 amSure they will get caught and might get a slap on the wrist  Small worlds. Long memories. ---------------------------------------------------------------------- Thaddy · 2024-10-22 08:27 Quote from: Joanna from IRC on October 21, 2024, 11:38:56 pmNot everyone who plagiarizes software can be sued. What if they are located outside of your legal jurisdiction? There are well known companies that have gotten away with claiming other people’s work as their own and have a legal department to handle any lawsuits. I’d much rather that my code can’t be easy to reverse engineer to begin with than hope that the legal system will rescue me after my code is stolen. One word: Concordsky Even if you reverse enigneer code you run into trouble if you do it bad... Joanna, is it so difficult to understand that if code runs it can be reverse engineered? All other assumptions are naíve. Would not waste my time on it. ---------------------------------------------------------------------- Fibonacci · 2024-10-22 09:20 My post is now buried and invisible, so let me remind what this is about: the level of difficulty. RTTI makes reverse engineering a walk in the park, and there is really no room for debate on that. Everything can be reverse engineered, but the real question is: whats the cost of that? A sophisticated adversary will know exactly what your binary does, but with RTTI, even a kid can pop open your binary in some "exe analyzer", click "gimme list of the strings" and voila! They see all your precious secrets. They know you are using that specific AES256-CTR encryption, that particular TSHA256 hash class, that fancy component to display output in a nice table, and even that licensing component which screams at you to search for "componentname keygen/crack". Simple: RTTI not used should not be visible. ---------------------------------------------------------------------- Joanna · 2024-10-22 10:15 Fibonacci is it possible to revert to an earlier version of Lazarus/fpc before the rtti stuff was introduced? It was not always this way was it? Another option is to rename whatever would be crackers will see to be misleading and confusing. I’m not sure how much that will help though. I really don’t like this idea of everything being visible either. ---------------------------------------------------------------------- Fibonacci · 2024-10-22 10:38 I dont know, RTTI is pretty old, and its only getting worse. Thats what Ive heard somewhere. PascalDragon once said you would have to revert back decades ago IIRC. If you are really interested, I do have a method to disable most of the RTTI (any version, but I use trunk), with modeswitches to turn it on or off. Maybe Ill create a private repo and share it? But Im not sure I want to do that Its more for my personal use. Id need to know what youre coding and why you need it. If you want, PM me, though I’ve been a bit busy for direct messaging lately, so pardon me for the delays. Without RTTI there are side effects tho. ---------------------------------------------------------------------- MarkMLl · 2024-10-22 10:53 Quote from: Fibonacci on October 22, 2024, 11:20:54 amMy post is now buried and invisible, so let me remind what this is about: the level of difficulty. RTTI makes reverse engineering a walk in the park, and there is really no room for debate on that. Everything can be reverse engineered, but the real question is: whats the cost of that? A sophisticated adversary will know exactly what your binary does, but with RTTI, even a kid can pop open your binary in some "exe analyzer", click "gimme list of the strings" and voila! They see all your precious secrets. They know you are using that specific AES256-CTR encryption, that particular TSHA256 hash class, that fancy component to display output in a nice table, and even that licensing component which screams at you to search for "componentname keygen/crack". Simple: RTTI not used should not be visible. While I agree with your conclusions, I think that you're rather trivialising the level of difficulty of effective reverse engineering. Both unstripped binaries and RTTI give substantial information away, but so (on Linux) does the ELF file header. I'd add that my understanding is that non-Windows OSes are at a particular disadvantage, since entries into a .so file can't be specified by numeric index so the function names /have/ to be retained. Yes, it is true that the presence of symbolic information gives information away, but effective exploitation requires detailed disentangling of control flow using specialist tools with substantial learning curves: if your copy protection can be circumvented by somebody who downloads a key from some shady website then you're doing it wrong. To actually intervene in the operation of a binary, as distinct from merely looking for unmangled strings, requires specialist tools, and these days the top of that particular pile is occupied by Ghidra. It appears that somebody is agitating for the development of a plugin to interpret Borland-style RTTI because of its use by C++, I would presume that the format of Lazarus-style RTTI- particularly on Linux- differs. I am not advocating security by obscurity here by arguing that because the population of Pascal developers is insignificant (relative to the total number of software developers) nothing needs to be done. But whether or not the current situation is "good enough", having unstrippable RTTI (unmangled and unencrypted) in a binary will impact security. MarkMLl ---------------------------------------------------------------------- dbannon · 2024-10-22 11:35 Quote from: Warfley on October 21, 2024, 12:44:42 pmQuote from: Joanna from IRC on October 21, 2024, 12:49:45 amIt also seems like leaving symbols in would make the exe larger. It depends, executables are padded up to multiple kilobytes. So if the symbol names total to less than the padding, you will have 0 difference. But sure in any larger program having all symbol names in there adds slightly to the size. But let's do a simple calculation. A 500gb SSD costs around 30€, let's say all the symbol names add up to a whopping 100kb (100kb of raw ASCII text us a lot), we end up with an additional cost of 0.000006€ for your application. Now, that prompted me to look at my application, tomboy-ng, the Qt5 variant. The (unix) strings command shows me that in the 7Meg binary (stripped, no RTTI) there is 1.8Meg of "string like content". Just scrolling through it superficially says most look like LCL identifiers. Few if any of my identifiers ? My application is not large but 18 times your estimate of 100K ?  Hmm.... Now, your argument about cost of disk space is valid, who cares ?  But a bigger binary also takes up more memory and, arguably, is slower, (but I am sure, only by a small margin). Still, I am personally surprised that about 25% of my binary is "string like" content ! So, I looked at Lazarus, 'lazarus' the binary : Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $> strings lazarus > lazarus.strings$> ls -la lazarus* $> ls -lah lazarus*-rwxr- xr-x 1 dbannon dbannon 166M Oct  3 21:57 lazarus-rw-r--r-- 1 dbannon dbannon  60M Oct 22 22:27 lazarus.strings More than a third ? Davo ---------------------------------------------------------------------- Joanna · 2024-10-22 11:48 Quote from: Fibonacci on October 22, 2024, 12:38:28 pmI dont know, RTTI is pretty old, and its only getting worse. Thats what Ive heard somewhere. PascalDragon once said you would have to revert back decades ago IIRC. If you are really interested, I do have a method to disable most of the RTTI (any version, but I use trunk), with modeswitches to turn it on or off. Maybe Ill create a private repo and share it? But Im not sure I want to do that Its more for my personal use. Id need to know what youre coding and why you need it. If you want, PM me, though I’ve been a bit busy for direct messaging lately, so pardon me for the delays. Without RTTI there are side effects tho. Thank you for your generous offer. I’m currently not sharing my application with anyone else but I would like to in the future. What sort of side effects might I expect without rtti? If it’s secret feel free to pm me ---------------------------------------------------------------------- MarkMLl · 2024-10-22 11:49 Quote from: dbannon on October 22, 2024, 01:35:58 pmMore than a third ? So the next question is: how much of that is taken up by stuff that you're definitely not using, e.g. generics support which is now compiled into a program that predates FPC's use of generics. MarkMLl ---------------------------------------------------------------------- Bogen85 · 2024-10-22 12:16 Quote from: dbannon on October 22, 2024, 01:35:58 pmSo, I looked at Lazarus, 'lazarus' the binary : Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $> strings lazarus > lazarus.strings$> ls -lah lazarus*-rwxr-xr-x 1 dbannon dbannon 166M Oct  3 21:57 lazarus-rw-r--r-- 1 dbannon dbannon  60M Oct 22 22:27 lazarus.strings More than a third ? Some of that text is labels, menus, other actual text... But it would seem even that is not going to be much compared to the symbols. ---------------------------------------------------------------------- Thaddy · 2024-10-22 12:48 Quote from: MarkMLl on October 22, 2024, 01:49:02 pm e.g. generics support which is now compiled into a program that predates FPC's use of generics. Generics do not end up in a binary....Ever. If you can prove that, that would be a bug, because generics are just code templates ---------------------------------------------------------------------- MarkMLl · 2024-10-22 16:52 Quote from: Thaddy on October 22, 2024, 02:48:25 pmGenerics do not end up in a binary....Ever. If you can prove that, that would be a bug, because generics are just code templates Step into the RTL/FCL and you find yourself going via generics support routines. Updated: https://forum.lazarus.freepascal.org/index.php/topic,57934.ms g433033.html#msg433033 MarkMLl ---------------------------------------------------------------------- Warfley · 2024-10-22 18:15 Quote from: Joanna from IRC on October 21, 2024, 01:05:35 pmwell obviously if you have something like Say a banking app you don’t want people getting into your source code looking for exploits. Also as Fibonacci said earlier. There are people who will clone your apps and sell them as their own ..  who would want that? Not me ! Is this something that actually happens or something you are afraid of because you think it might happen? Because look at the panic software leak a few years ago. Panic software is a company that produces closed source software for MacOS and very successful at that. Recently all their source codes got leaked because hackers got into their source control and they refused to pay the ransom. So it's a prime example, their apps make millions so anyone who could clone their apps could bankrupt them right? Well... Nothing happened. Turns out source is not the most important thing to an app. The hard thing with developing an app is the maintainance. Most apps are not so complex that no one else can clone them. What's important is the experience gained at developing them and using this experience to maintain those apps. The interesting thing about source code is not how things were solved, but why things were solved a certain way. This is why when someone joins a software project they are very useless for like the first 6month to 1year, because they need to build that experience.l, figure out why things were built a certain way, etc. Even if you got the full source code to Microsoft office, to build a competitor that's comparable to MS Office you'd still need a team as big and experienced as what MS can provide. Look at the history of software development, how many cases of companies do you know that went bankrupt after a competitor cloned their app after a source code leak? I do not know of a single case. This is not a concern for the real world ---------------------------------------------------------------------- Warfley · 2024-10-22 18:42 Quote from: dbannon on October 22, 2024, 01:35:58 pmSo, I looked at Lazarus, 'lazarus' the binary : Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $> strings lazarus > lazarus.strings$> ls -la lazarus* $> ls -lah lazarus*-rwxr- xr-x 1 dbannon dbannon 166M Oct  3 21:57 lazarus-rw-r--r-- 1 dbannon dbannon  60M Oct 22 22:27 lazarus.strings More than a third ? Davo You know how Lazarus compiles resources right? All images, icons and co are encoded as strings which are decoded at runtime. Strings just gives you everything that looks like a string within a file. So it's not all Symbols. It's all the graphics, configurations and all the other resources. If you want to figure out how many of those are symbols, go through all entries outputted by strings and check if there's a type definition within the Lazarus source code that corresponds to said string. There's there's a Linux command line tool to get identifiers from source code which you could use for that, it's not perfect as it does not really understand Pascal, but it would give you a first indication But I can't remember the name sadly ---------------------------------------------------------------------- MarkMLl · 2024-10-22 19:34 I think we could do with getting a bit more focused here: simply looking at the amount of recognisable text in a binary is... well frankly pretty pathetic, particularly since tools like binwalk ** are smart enough to look for binary blocks which are "more random than expected" and treat them as candidate encryption keys. Here's a program I wrote over the Summer, which embeds LazMapViewer hence various SSL etc. stuff, which probably makes it fairly typical "I'd rather that people kept their fingers out of this" fodder. Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ ls -lh local1090-x86_64-linux-gtk2-rwxr-xr-x 1 markMLl markMLl 27M Oct 12 09:15 local1090-x86_64-linux-gtk2$ strip local1090-x86_64-linux-gtk2$ ls -lh local1090-x86_64-linux-gtk2-rwxr-xr-x 1 markMLl markMLl 7.8M Oct 22 19:54 local1090-x86_64-linux-gtk2  So, roughly three quarters of the binary is symbolic information which, if left in there, is definitely "of value to the enemy" since the format is entirely understood. What does that leave us? Well the first thing that stands out is the named entry points of all system libraries being used: Code: [Select]$ strings -n 8 local1090-x86_64-linux-gtk2 | less /lib64/ld-linux-x86-64.so.2 pango_layout_get_extents g_type_interface_peek g_value_unset g_list_find gdk_pixbuf_get_height g_slist_free gdk_pixbuf_new_from_data ... That, trivially and (on non-Windows OSes) unavoidably, will tell a miscreant whether any special encryption etc. libraries are being used. After that it gets interesting: there's a great deal of text which looks like assertions in various libraries (which an attacker could match with a bit of Googling), and what looks like more unstripped symbols (which could possibly be RTTI) *** : Code: [Select]... RaiseOwnerCircle AValue= TAnchorSide.SetControl AValue=FOwner TAnchorSide.CheckSidePosition Circle, TAnchorSide.CheckSidePosition invalid anchor control, TAnchorSide.CheckSidePosition invalid Side LCLSTRCONSTS lclstrconsts.rsmbyes lclstrconsts.rsmbno lclstrconsts.rsmbok lclstrconsts.rsmbcancel lclstrconsts.rsmbabort ... I definitely don't want to "do a Joanna" and start screaming that we're all doomed **** . But equally definitely, there's stuff in that binary which would definitely be useful /if/ an attacker thought that it was hiding something interesting. ** I don't claim to be fully up to date, but please note that I'm actually able to "name names" rather than making aggrieved noises about potential script kiddies with hypothetical magic toolkits. *** Note that the FPC used to build Lazarus was low on optimisation and high on debugging checks. **** Even if we're using Pascal. MarkMLl ---------------------------------------------------------------------- Warfley · 2024-10-22 20:23 But assertions have nothing to do with rtti. Also like any messages like error messages or exception names and stuff like that will be visible in the binary. Like let's say you have some software that checks a product key as a form of DRM, and you are a hacker who wants to crack that software to use for free. What you will do is you check what error message pops up when you enter the wrong key, e.g. if there's a pop-up saying "Invalid serial number" you open that binary in ghidra, search that string, then search where that string is used, find the function that triggers the pop-up and you already got the interesting piece of code. There is usually no need to look for RTTI or assertions or stuff like that, because any app that should face the user is full of strings you can use to find where what functionality is called ---------------------------------------------------------------------- PascalDragon · 2024-10-22 20:49 Quote from: Joanna from IRC on October 22, 2024, 12:15:00 pmFibonacci is it possible to revert to an earlier version of Lazarus/fpc before the rtti stuff was introduced? It was not always this way was it? The first commits for RTTI support where around 23 years ago and it expanded since that, so have fun with that. Also the LCL heavily relies on RTTI, so have even more fun with that. Quote from: Warfley on October 22, 2024, 10:23:59 pmThere is usually no need to look for RTTI or assertions or stuff like that, because any app that should face the user is full of strings you can use to find where what functionality is called Indeed. Which is why at work (with C++) we obfuscate strings at compile time for code that's critical to our copy protection system (and only that) plus using a small virtual machine with proof of work concepts to protect it even further and temper detection mechanisms that separate detection and action. The main point of all this is not necessarily to prevent adversaries cracking the software at all, but to be annoying enough that it's so low on the priority list of them that we can release a new version with new features (and adjusted piracy protection) before they're able to crack the released software. (Though to be fair our software is essentially based on a user space virtual machine, so we have a bit more freedom with protecting things than singular binaries have) ---------------------------------------------------------------------- Joanna · 2024-10-23 00:01 Even if rtti information is exposed, Is there any style of writing code that makes it more difficult to reverse engineer maybe? ---------------------------------------------------------------------- dbannon · 2024-10-23 00:17 Quote from: Warfley on October 22, 2024, 08:42:59 pmYou know how Lazarus compiles resources right? All images, icons and co are encoded as strings which are decoded at runtime. Strings just gives you everything that looks like a string within a file. So it's not all Symbols. It's all the graphics, configurations and all the other resources. Indeed. So, still looking at my binary (Lazarus is too big and I'm more likely to recognize my text). By telling 'string' to only show strings of 10 or more characters, I end up with almost as much text content and considerably less random characters that are clearly part of a binary object of some sort. I believe I could read to you at least two thirds of the resulting 1.6Meg, 23K line file.  I doubt either you nor I wish that .... My point was that there is already a lot of readable text in the binary. Adding RTTI would not increase it by that much. I also looked for similar sized apps on my system, like the Crusader's Wife, to make a comparison. Generally, with a very approximate "like for like", there seems a lot more text in a Lazarus app than the C or C++ ones.  But, importantly, I'm not opening the "gee, Pascal makes big binaries" argument ! Please ! Davo ---------------------------------------------------------------------- MarkMLl · 2024-10-23 07:40 Quote from: Warfley on October 22, 2024, 10:23:59 pmBut assertions have nothing to do with rtti. Also like any messages like error messages or exception names and stuff like that will be visible in the binary. Yes, I know. My only point is that they're contributing to the amount of text picked up if one uses a simple evaluation based on the unix strings command: apart from that I'm not judging. MarkMLl ---------------------------------------------------------------------- MarkMLl · 2024-10-23 07:44 Quote from: Joanna from IRC on October 23, 2024, 02:01:24 amEven if rtti information is exposed, Is there any style of writing code that makes it more difficult to reverse engineer maybe? As Sven suggests, obfuscating assertions and other user-facing text would certainly be a good start. However I'm a bit concerned that this would have to be retrofitted to the RTL/FCL/LCL. I wonder whether i18n would help, i.e. a dummy "obfeng" locale for obfuscated English? MarkMLl ---------------------------------------------------------------------- MarkMLl · 2024-10-24 09:53 I think https://hackaday.com/2024/07/04/smartwatch-snitches-on-itself- and-enables-reverse-engineering/ is a nice little illustration of what a "hat wearer"- hostile or otherwise- can do relatively easily these days. Quote...He couldn’t find the IP as a string in the firmware, but he did manage to find a sprintf-like format string for IP addresses, which led him to a likely memory location. Sure enough, the IP and port were right there, so he wrote a script to change the address to a server he had the keys for... If that format string had been even minimally obfuscated, he wouldn't have spotted it. The same applies to RTTI etc. MarkMLl ---------------------------------------------------------------------- marcov · 2024-10-24 11:33 Quote from: PascalDragon on October 22, 2024, 10:49:18 pmIndeed. Which is why at work (with C++) we obfuscate strings at compile time for code that's critical to our copy protection system (and only that) plus using a small virtual machine with proof of work concepts to protect it even further and temper detection mechanisms that separate detection and action. The main point of all this is not necessarily to prevent adversaries cracking the software at all, but to be annoying enough that it's so low on the priority list of them that we can release a new version with new features (and adjusted piracy protection) before they're able to crack the released software. (Though to be fair our software is essentially based on a user space virtual machine, so we have a bit more freedom with protecting things than singular binaries have) We use a commercial dongle with encrypted binary for the same reasons. In addition that also matches the number of licenses to the used number of software. This because for some of our products, the components to build it are readily available to anyone, and the software is our main added value. ---------------------------------------------------------------------- MarkMLl · 2024-10-24 12:13 Quote from: marcov on October 24, 2024, 01:33:47 pmWe use a commercial dongle with encrypted binary for the same reasons. In addition that also matches the number of licenses to the used number of software. This because for some of our products, the components to build it are readily available to anyone, and the software is our main added value. I once knew somebody- a fine, upstanding member of the community and a lay preacher- who spent a year of lunchtimes singlestepping into a CAD package until he found the opcode that decided whether the dongle was plugged in and could patch it. And he professed to not know x86 assembler, just how to single-step... Irrespective of whether one can monitor USB and decrypt challenge/response sequences, and irrespective of whether one can get physical access to a TPM and read it with an RPi Pico, there's always weak points that can be attacked by a determined intruder and the more recognisable patterns he can see the easier his job is. MarkMLl ---------------------------------------------------------------------- PascalDragon · 2024-10-24 20:22 Quote from: Joanna from IRC on October 23, 2024, 02:01:24 amEven if rtti information is exposed, Is there any style of writing code that makes it more difficult to reverse engineer maybe? Not really. ---------------------------------------------------------------------- Sieben · 2024-10-24 21:56 I for my part would like everything to be open source. Of course that has a whole lot of impications but I won't reject them. ---------------------------------------------------------------------- Joanna · 2024-10-24 23:39 Opensource is definitely altruistic from the standpoint of promoting fpc, however not everyone is happy with the possibility of their code being used by for profit enterprises without even giving them credit.