Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. Remy Lebeau

    How to solve System Out of Resources in TScrollBox

    Set TListView.OwnerData=true, set TListView.Items.Count to the number of items you want to display, and use the TListView.OnData event to provide details for each item on demand. The scrollbar will be handled for you. Because those are TListBox styles, not TListView styles. In this situation, set TListView.ViewStyle=vsReport, and add some columns to the TListView.Columns. Then, in the TListView.OnData event, you can provide data for the 1st column using TListItem.Caption, and data for the subsequent columns using TListItem.SubItems. Use the TListView.OnData... events for that purpose. Yes. Probably because you didn't populate the TListView with data yet (see above). Yes. You should not be putting any child controls on to the TListView at all. It is not designed for that. Let it handle the items for you. You just worry about supplying the items with data. And using the TListView.On...Draw... events if you want to custom-draw the items. No. It is just a wrapper for the native behavior provided by Microsoft, see: How to Use Virtual List-View Controls
  3. Yesterday
  4. araujoarthur

    How to solve System Out of Resources in TScrollBox

    UPDATE: By setting its viewstyle to vsReport I got a scroll bar that isn't functional (in the sense that it doesn't move between controls even if all have been drawn). Is it related to the fact that I'm inserting controls via TListView.InsertControl() procedure? Or do I have to write the scroll procedure myself? Edit: I guess I'm also failing to understand what is a TListView operating in virtual mode.
  5. Here is one of my projects which was written in an earlier version of C++ Builder. You will notice that I'm using #include<conio.h> plus I'm using getch(); // This program demonstrates writing a simple function to cube a number #include <iostream> #include <conio.h> using namespace std; int cube(int y); // function prototype int main() { int x; cout << "Enter an integer value: "; cin >> x; int answer = cube(x); // call the cube function and pass x as an argument and assign result to the variable answer cout << "That number cubed is " << answer << endl; // print the result getch(); return 0; } int cube(int y) // function definition { return y * y * y; }
  6. corneliusdavid

    The Advent of Code 2024.

    I haven't had time to get past #11, which I rewrote using a recursive function for part 2 but then found out that was foolish--I killed it after letting it run for 24 hours! My favorite (so far) was #3; if you know regular expressions, it was snap. I hope to have some time over the holidays to tackle a few more.
  7. Patrick PREMARTIN

    Anybody have Delphi running in a VM on M-series Mac?

    I'm on a Parallels VM of Windows ARM since the release of the ARM version of Parallels. All is working fine (except the debugger some times). My Mac mini M1 has 8Gb RAM and 256Gb SSD. It's enough to work but 16Gb RAM is better to open more than 1 VM and 1To of SSD is better to not have external SSD on each USB port... 😉 You can leave your Intel Mac or use it to test your x32/x64 programs compiled for macOS or Windows with Delphi.
  8. Brandon Staggs

    Anybody have Delphi running in a VM on M-series Mac?

    That is simply incorrect. My ARM64 (Snapdragon) Windows laptop runs 32-bit x86 code just fine. Delphi is still a 32-bit IDE. They have 64-bit compilers now if you want to pay for an Enterprise license but the rest of us are slumming it in 32-bits and that's not a problem for ARM-based Windows.
  9. JohnLM

    The Advent of Code 2024.

    I liked the Day 19 and 23 puzzles. They were easy to solve, but 19 was solved while I was at work while I was walking out into one of my isles to pack out products and where it came to me, but getting it out in code is still a challenge. I know what I have to do but coding it is a real challenge. And as for 23, I did solve it in around 12 minutes, but I found a "cosmetic" bug in the output and I am trying to fix that. Both of these are just part 1.
  10. corneliusdavid

    The Advent of Code 2024.

    Yeah, that helped me not feel so bad! I'm not in this for a gold medal, I'm happy if I can figure it out on my own given the time constraints of job, family, etc.
  11. corneliusdavid

    Delphi 12.2 Toolbars strange behavior

    I hardly ever use the toolbars in Delphi. The only one I usually have up there is the Debug one--and even then, I use the hotkeys. One of the first things I do after installing Delphi, is removing all (or most) of the toolbars as they just take up space (been doing that over a decade). I can't remember what all those icons mean anyway and most all the functions I need are either a right+click or hot-key away.
  12. pmcgee

    The Advent of Code 2024.

    The speed thing is addressed in the 'Behind the Scenes' video ... people who are the Olympic athletes at this event have entire solution systems pre-prepared for reading in and manipulating data, and then solving the puzzle. The head guy mentions that people will blast through, ignoring the text, maybe even guessing at the problem being asked in the quest for a fastest solution. He specifically says that that endeavour is not "programming" as such ... it's an entirely different beast.
  13. David Schwartz

    Anybody have Delphi running in a VM on M-series Mac?

    Yep, this is pretty much what I've concluded after about 10 hours of messing around and digging through all of the explanations about how to do what y'all say is impossible. Will any version of D10.4 run on an M-series Mac? I've read where 32-bit code will NOT run on an x64 ARM version of Windows, and I'm not aware of when Delphi was fully converted to x64 architecture. I'm leaning more towards using my Intel-based Mac Mini to just running the VM with Delphi in it, along with just a few other things, for maximum performance. (It has a 6-core i7 with 36GB of RAM, so without a bunch of browser windows open, it really screams.)
  14. corneliusdavid

    The Advent of Code 2024.

    That's what I think--I just don't see how that can be. After initially looking at the leaderboards and trying a couple of puzzles with some faint hopes of my abilities, I quickly realized I would never make it anywhere close to a leaderboard and stopped looking at them! LOL! Now I'm just happy if I can SOLVE a puzzle; and especially happy if I also solve part 2! I have come to believe that Delphi is not the best language for solving puzzles like this--at least in a contest of speed. The Pascal language is very type-strict and I find myself many times having to convert numbers to string or vice-versa. I get boxed in thinking only in terms of strings (then having to extract or convert a number) or thinking only in terms of number (then having to concatenate a string or something). Several additions to the RTL over the years have helped but I look at some of these 1- or 2-line Python or Go solutions and just shake my head, partially to try and understand them but also because you just can't always do stuff that succinctly in Delphi. Either that or I'm just so used to laying out variables and record structures and doing things in a "proper" way for code readability and maintainability that it's hard for me to get in the mind-set of being super terse and brief to solve a very specific problem where there's no need to do any checking of the input data.
  15. JohnLM

    The Advent of Code 2024.

    Note, in my previous post above, that the video I was talking about was for Day 20, not Day 23.
  16. araujoarthur

    How to solve System Out of Resources in TScrollBox

    Hello! Although I have been able to add controls to the TListView I wasn't able to make it scrollable. I have set both OwnerData and OwnerDrawn to true. I couldn't find a property Style that can hold dlOwnerDrawFixed or lbOwnerDrawVariable. Once I can make it scrollable I'd like to implement caching. You do so by storing a chunk of the file and the visible ones in a separate (from the visual control) data structure?
  17. JohnLM

    The Advent of Code 2024.

    re: Day-23 puzzle -- Note, I am not complaining but giving my observations thus far. I don't know. I mean, it took me a moment to read through the instructions, about 1m:48s. If I added that to my final time it took me to solve that puzzle, then it was 14 minutes to solve. I was thinking 12 minutes and thought I could have made that Leaderboard--just joking. And that includes the building of the app, which I over-do too much in, everytime. Oh well. I am usually pretty quick at thinking for a solution and then writing down (building) the code. Well, there was a least two puzzles that I did solve. And sometimes I will solve a puzzle during the coding part as I am building and working out the code, it may come to me. But then I find issues or I don't quite like it, etc. etc.. I believe that the languages those people are using are a lot more sugar-coated in solving the puzzles in AoC2024. Take for example, Day 20's puzzle. I watched most of this YT video: "tWhwcORztSY" and saw how supper quick this person was at solving it, not to mention his detailed step-by-step description of how he was solving different parts and how fast he was writing out the code. I mean, the guy sounded like he wrote the puzzle! Now mind you, I was not trying to solve that puzzle. Reading through that puzzle part-way was enough to tell me I would never solve it at the time I was reading it. I still believe that today, even after watching a video of it. If you look at the Leaderboard for Day 1's puzzle, you will see a time reading of "1) Dec 01 00:00:04 - qianxyz (AoC++)". No way anyone could complete it after reading, writing and submitting in 4 seconds. That's got to be 4 minutes. I believe that the time layout I showed in my last post for "00:00:21" is: Days/Hours/Minutes. As much as I could not solve most of these puzzles--and that's okay--I have enjoyed trying to solve them, to date. I am still trying to solve some, while others are on the back-burner and I will eventually get back to those. I have very much enjoyed this adventure. It gave me a chance to challenge myself and enjoy each day's puzzles. I looked forward to each puzzle with antisipation every day, with only two days/puzzles left.
  18. Dave Novo

    CreateObservableList example in Spring4D

    ok, perfect, I got that working. thanks!
  19. Remy Lebeau

    This is a change

    That is an extremely old header file for DOS development. If you are using C++ iostreams for console I/O (as you should be, ie std::cin and std::cout) then you don't need that header. Or std::cin.get(). But yes, to keep the window open, you have to wait for user input. Otherwise, open the console window first before then running the program in it. The window closes automatically only if the program launched the window in the first place. When you run a console program directly, it creates a new console window for itself. Not that I'm aware of. But without seeing the actual code, it is difficult to explain what you are experiencing.
  20. 357mag

    This is a change

    There is no code that behaves differently.
  21. Does EhLib.Fmx.Types.pas have the FMX.Controls unit in its 'interface' uses clause? Does the generated EhLib.Fmx.Type.hpp file have an #include <FMX.Controls.hpp> statement?
  22. Brandon Staggs

    Anybody have Delphi running in a VM on M-series Mac?

    Your VM does not have the correct operating system installed on it for that to work. It's the responsibility of the installed Windows OS on the VM to translate x86/x64 code to ARM instructions. Your version of Windows won't do that.
  23. Shrinavat

    RSA decryption from JavaScript

    Hey everyone, I’m trying to reverse engineer a piece of JavaScript code found within an HTML file. It has this get_cookie_spsc_encrypted_part function, which contains an RSA private key embedded within a comment, and also an encrypted string. It uses some JavaScript crypto lib, KJUR.crypto.Cipher.decrypt, to decrypt this string. Here’s the Javascript code: function get_cookie_spsc_encrypted_part() { let func = function () {/*-----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQDFoP5AJIv1KFGRpv/Uw7drFXjWbZG6wNsO7P58ocZIcxyKGU6u TgXw8N1IvTmd9yXRSdcb2fCWB7J/QUQDJQ3YuuXSOQCVOdi8Wy9UoZ5jNdqtZ6CM CvnK/v4Wy38ZhrB0CRkeiuyjmUdfQhe8mh3pE3iFBusYd1TVCxQt3VBkqQIDAQAB AoGAaYBaeo+ID6YodWL7a+/XeNkLmxz/EP1nc/5clNgf7AlXkPmVoUORtGBBIVWy 7ntDuwh6Ryn/X3hYd8q1riAX1UwVuUduOENmgyzmO1rRIoB/17vzYwVMYOB2h+qb xEqjg4dUfk/1occyDwpehWel+1NIgvQLNYLcn2JXxkAyrMkCQQD37+3Y8sjYxwAp giIClsCjrla73cS/QwzArGEnOjBs86LyzCc0pNzmP2OD0a9VlD3k6dMnhT2Oj+2k nZs8dUlHAkEAzA4/mQeFvdiKIkzUBECn3w9Ylu2IfpKnQt/0EFUENxS9ONZ1jj4p zDBfZosgwnE1GiECELM3R/6Pzl+uIGrajwJBALm5HG3az+CykMiHFnrh+kOiII5x vSOYUkEx30THLecvSeyeSPACXwaKjTz9IV31wbdsACQmhsn3vogFF3feU5kCQARP 9MYeI5RshBbPeteQKjwLjfq6kFzkaoZ+RyElOs6TMKCH37oe1DFNgGahYBLb45xm wC1sLCnoVk+tM/fZaj8CQGQyIlxwbgNBBdV3wnmtX9yPDflOsjpo3FuBMOu3nZAD KEpmTXFgdwP4oMMbCmDvH3dav92LE5JN1cPik9z0Piw= -----END RSA PRIVATE KEY----- */}; let pem = func.toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; return KJUR.crypto.Cipher.decrypt("82a4fa1da959701407ae4a80b48c0dca57d68fb5e54df1794418b03ba43ef9022328e4be4011ffbeb74d9d22769634a21537ba32788342f8abe6cfddc22512a39373ea2488af389740ac4f93699da92fcd86895c64bd6760a5aea27e172052947361177f3674ec68c52480744a75163c892556ec526387c92c0b50ab0b3a4ea5", KEYUTIL.getKey(pem)); } I’ve managed to replicate the decryption in C# using System.Security.Cryptography. Here’s the C# code: using System.Text.RegularExpressions; using System.Security.Cryptography; var pemKey = Regex.Match(html, "-----BEGIN RSA PRIVATE KEY-----[\\s\\S]*?-----END RSA PRIVATE KEY-----").Value; var encryptedDataHex = Regex.Match(html, @"KJUR.crypto.Cipher.decrypt\(""(.*)""").Groups[1].Value; using var rsa = RSA.Create(); rsa.ImportFromPem(pemKey); var decryptedData = rsa.Decrypt(Convert.FromHexString(encryptedDataHex), RSAEncryptionPadding.Pkcs1); // Perform Decryption Now, I’m trying to do the same in Delphi, and I’d like to use TurboPower LockBox 3. Unfortunately, the official documentation seems to be offline. I am struggling to understand how to use LockBox 3, or other suitable free libraries for this purpose. Could anyone provide some Delphi code examples and guidance on how to do the RSA decryption, using LockBox or any other free library? Any help would be greatly appreciated! Here's my code: program RSA_test; {$APPTYPE CONSOLE} uses System.SysUtils, System.Classes, System.RegularExpressions, uTPLb_Codec, uTPLb_CryptographicLibrary, uTPLb_BaseNonVisualComponent, uTPLb_Signatory, uTPLb_Constants, uTPLb_Asymetric, uTPLb_RSA_Engine, uTPLb_OpenSSL; const HTML = '<html><head><script>function get_cookie_spsc_encrypted_part() {' + ' let func = function () {/*-----BEGIN RSA PRIVATE KEY-----' + 'MIICXAIBAAKBgQDFoP5AJIv1KFGRpv/Uw7drFXjWbZG6wNsO7P58ocZIcxyKGU6u' + 'TgXw8N1IvTmd9yXRSdcb2fCWB7J/QUQDJQ3YuuXSOQCVOdi8Wy9UoZ5jNdqtZ6CM' + 'CvnK/v4Wy38ZhrB0CRkeiuyjmUdfQhe8mh3pE3iFBusYd1TVCxQt3VBkqQIDAQAB' + 'AoGAaYBaeo+ID6YodWL7a+/XeNkLmxz/EP1nc/5clNgf7AlXkPmVoUORtGBBIVWy' + '7ntDuwh6Ryn/X3hYd8q1riAX1UwVuUduOENmgyzmO1rRIoB/17vzYwVMYOB2h+qb' + 'xEqjg4dUfk/1occyDwpehWel+1NIgvQLNYLcn2JXxkAyrMkCQQD37+3Y8sjYxwAp' + 'giIClsCjrla73cS/QwzArGEnOjBs86LyzCc0pNzmP2OD0a9VlD3k6dMnhT2Oj+2k' + 'nZs8dUlHAkEAzA4/mQeFvdiKIkzUBECn3w9Ylu2IfpKnQt/0EFUENxS9ONZ1jj4p' + 'zDBfZosgwnE1GiECELM3R/6Pzl+uIGrajwJBALm5HG3az+CykMiHFnrh+kOiII5x' + 'vSOYUkEx30THLecvSeyeSPACXwaKjTz9IV31wbdsACQmhsn3vogFF3feU5kCQARP' + '9MYeI5RshBbPeteQKjwLjfq6kFzkaoZ+RyElOs6TMKCH37oe1DFNgGahYBLb45xm' + 'wC1sLCnoVk+tM/fZaj8CQGQyIlxwbgNBBdV3wnmtX9yPDflOsjpo3FuBMOu3nZAD' + 'KEpmTXFgdwP4oMMbCmDvH3dav92LE5JN1cPik9z0Piw=' + '-----END RSA PRIVATE KEY-----' + '*/};' + ' let pem = func.toString().match(/[^]*\\/\\*([^]*)\\*\\/\\}$/)[1];' + ' return KJUR.crypto.Cipher.decrypt("82a4fa1da959701407ae4a80b48c0dca57d68fb5e54df1794418b03ba43ef9022328e4be4011ffbeb74d9d22769634a21537ba32788342f8abe6cfddc22512a39373ea2488af389740ac4f93699da92fcd86895c64bd6760a5aea27e172052947361177f3674ec68c52480744a75163c892556ec526387c92c0b50ab0b3a4ea5", KEYUTIL.getKey(pem));' + '} </script></head><body></body></html>'; var PEMKey, EncryptedDataHex, DecryptedData: string; Codec: TCodec; CryptoLib: TCryptographicLibrary; Signatory: TSignatory; EncryptedBytes, DecryptedBytes: TBytes; MemStream: TMemoryStream; StringStream: TStringStream; begin try Codec := TCodec.Create(nil); CryptoLib := TCryptographicLibrary.Create(nil); Signatory := TSignatory.Create(nil); try with TRegEx.Match(HTML, '-----BEGIN RSA PRIVATE KEY-----[\s\S]*?-----END RSA PRIVATE KEY-----') do if Success then PEMKey := Value; with TRegEx.Match(HTML, 'KJUR\.crypto\.Cipher\.decrypt\("(.*)\"') do if Success then EncryptedDataHex := Groups[1].Value; // Convert base64-string to bytes EncryptedBytes := TNetEncoding.Base64.DecodeStringToBytes(EncryptedDataHex); // Setup encryption components Codec.CryptoLibrary := CryptoLib; Codec.StreamCipherId := 'native.RSA'; Codec.ChainModeId := 'native.CBC'; Codec.AsymetricKeySizeInBits := 1024; // ??? StringStream := TStringStream.Create(PEMKey); try Signatory.Codec := Codec; Signatory.LoadKeysFromStream(StringStream, [partPrivate]); // !!! raised exception class EReadError with message 'Stream read error' finally StringStream.Free; end; // Decrypt data MemStream := TMemoryStream.Create; try MemStream.WriteBuffer(EncryptedBytes[0], Length(EncryptedBytes)); MemStream.Position := 0; Codec.DecryptStream(MemStream, MemStream); // In-place decryption // Get decrypted data SetLength(DecryptedBytes, MemStream.Size); MemStream.Position := 0; MemStream.ReadBuffer(DecryptedBytes[0], MemStream.Size); DecryptedData := TEncoding.UTF8.GetString(DecryptedBytes); finally MemStream.Free; end; finally Codec.Free; CryptoLib.Free; Signatory.Free; end; except on E: Exception do WriteLn(E.ClassName, ': ', E.Message); end; ReadLn; end.
  24. Rollo62

    Anybody have Delphi running in a VM on M-series Mac?

    I'm afraid a "move" from older to newer is not possible, but I also would always recommend a new, fresh VM anyway, even if it would be possible, to ensure the always best performance on a new platform. Since the setup of such new machines always may take up to one week, until a setup is fully configured on all platforms, I usually proceed a strict checklist for that. There is a 2 year old post from Germany, about running Delphi on Apple Silicon, maybe that's helpful too ( should be able to be auto-translated ). https://www.youtube.com/watch?v=vc2mLROXWcQ
  25. Uwe Raabe

    The Advent of Code 2024.

    I would rather say that are 21 seconds (which is probably less than I actually need to just read the description). This is backed by this quote from the About text: Since the start time of each puzzle is way out of my awake periods a day, I can thankfully ignore the ranking system completely. This allows me to concentrate on finding a suitable solution, sometimes even a clever one.
  26. Patrick PREMARTIN

    Anybody have Delphi running in a VM on M-series Mac?

    the virtualisation software don't convert x64 to ARM code on a Mx Mac you need to use Windows ARM you can't move an x64 VM to an ARM computer, neither on PC nor Mac on the other hand, everything can be installed without any problem, as long as there's no need for a specific driver that hasn't been ported to ARM.
  27. Dave Nottage

    Anybody have Delphi running in a VM on M-series Mac?

    I can imagine that is the case. From (my sketchy) memory, I think I did investigate moving from an older VM, but in the end I started a new one. I tend to have as little installed on the VM as possible, so it wasn't difficult to bring one "up to speed" I have a Macbook Pro with an M1 Max, running a Windows 11 Arm VM (one with Delphi 12.2 and one with Delphi 11.3) using Parallels 20.1.1
  1. Load more activity
×