Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/30/20 in all areas

  1. Anders Melander

    Manage overloaded IfThen functions

    I think I'll put that on a t-shirt: "Hope - Helping Delphi survive since 1996"
  2. Attila Kovacs

    Manage overloaded IfThen functions

    for sure H := (C = 0 ? 0 : V = r ? (g - b) / C : V = g ? (b - r) / C + 2 : (r - g) / C + 4 );
  3. David Heffernan

    Manage overloaded IfThen functions

    Seems odd to replicate a function that already exists in the RTL. Also to implement it by potentially assigning the result variable twice. And the default parameters are very odd. It would never make any sense to omit these parameters.
  4. Lars Fosdal

    Manage overloaded IfThen functions

    If it exists, it can be abused.
  5. I just had to do it... Go with the flow! It's the Black Friday / Cyber Monday "season", so I had to rush the book offer The book was actually scheduled for release in early December, but then the Black Friday deals started popping up all over the place... pressure was building... and I finally caved in! I cut the darn thing in two, and decided to offer Part I at a discount, and will give Part II for free to all Buyers. Not really a 97% BF discount but hey... Junior is still studying, and we still have to pay the bills (Corona doesn't help, either)! So, here it is! I hope you'll like it like you did Delphi Memory Management! https://dalija.prasnikar.info/delphiebap/index.html Thank you all for the support!
  6. Anders Melander

    Catch details on AV

    I don't know but I think in this case it has more to do with limiting the deployment size than with limiting the consumed address space.
  7. Wil van Antwerpen

    Catch details on AV

    Hi, Thanks for all the tips. I will check out the 3rd party products, but am a bit wary of adding 3rd party controls that are working at this low level to already released software. Especially if the component comes without source so I that it becomes more difficult for me to estimate the impact on stability, or if I need to look for another solution once the next version of macOS is released. If I start working on a new product it makes more sense to me as I will then have more time to test. Looks like the grjji github code might get me the basics I need for now. The website is very unclear and that does not give me a good feeling about the product itself. Version history 0.99beta... There's more text in the screenshots then there is text detailing the functionality about the product, several typo's in there as well. Time limited how? After a year the code stops working? After a year I need to buy a new license if I want to include it into a new application? Something else? Does it come with source? Does it work with FMX? (I only see VCL even on the macOS/Linux screenshots) Does it work with Delphi 10.3/10.4? I believe that the people behind it are very very smart, but I need more details to even consider it as a solution. Like you say.. no thanks.
  8. Remy Lebeau

    TidTCPClient fails to discover a lost connection

    The only way to detect a closed connection is to perform I/O on the connection and see if it fails. The Connected() method performs a read operation internally. That will detect a *graceful* disconnect fairly quickly. But if the connection is *lost abnormally* (network issues, etc), then by default it may take the OS a long while (minutes, hours) to invalidate the connection, during which time I/O operations will not fail (reads will simply report no data is available to read, and sends will be buffered until the buffer fills up). So, the best way to handle this is to employ timeouts/keepalives in your own protocol code and just close the connection yourself if you detect it is not being responsive enough for your needs. Or, at the very least, enable keepalives at the TCP layer (see the TIdTCPClient.Socket.Binding.SetKeepAliveValues() method) so the OS can invalidate a lost connection sooner rather than later. See above. In the case of an abnormal connection loss, the OS will happily carry on with I/O operations until the connection has been invalidated. In the meantime, outbound data will simply be queued in the socket's internal buffer, until the buffer eventually fills up, blocking subsequent writes. The default time is up to the OS to decide. Which is why you should rely on using your own timeouts/keepalives instead. That is because modern networking software is usually smart enough to invalidate existing connections fairly quickly when users do things like that manually. That wasn't always the case in the past. Neither Indy, nor the OS, care about connections being idle, as long as they are truly alive. But, your network might care about idleness, depending on its setup. No.
  9. Antony Danby

    ANN: Better Translation Manager released

    I'll have to do that later today ! Anything I find if it's significant then I'll share it with you
  10. Anders Melander

    Manage overloaded IfThen functions

    What's the point? The arguments would still be evaluated up front. You need the cooperation of the compiler to avoid that.
  11. Somebody just asked me whether there is a simple way to migrate GExperts settings from Delphi XE7 to a new version. The short answer is: No, but some experts (or rather: some functionality, because not everything is wrapped into an expert) have an ex- and import function. I also started to write a general ex- and import function for GExperts but never finished it. Real life tends to intrude on open source programming. 😉 The long answer would be: Yes, you can do that by copying the registry entries and configuration files: read on in the blog post
  12. Yes, I understood that. My point is that searching for this pattern, which is a perfectly normal and valid pattern, would be premature optimization. If there is a performance problem in an application then you analyze the application (for example with a profiler) and locate the hot spots. It is then then easy to identify this pattern in those hot spots just by reading the code. You don't need a tool for that. It's like having a tool for identifying loops because loops are slower than no loops.
  13. If your main window pops up immediately, you may not need that splash at all. What is it supposed to tell the user? Why not put the db connections in threads? Everything and anything can be asynchronous if you do it right.
  14. Yes that's right ! I've seen your proposal as well and I've a better proposal that solves your proposal issues(Step Over/replicating the codes) and it's a little bit slightly faster ! To begin, the issue arise because there was a mismatch between a call and a ret instruction (a ret instruction that doesn't correspond to a call instruction). In your proposal, you introduced a call to fix the issue but that also introduced Step Over issue ! Here is my proposal : if we jumped without using a call instruction then we simply return without using a ret instruction. How ? we do a lazy stack pop (add esp, 4) to remove the return address from the stack then we jump back to the return address (jmp [esp - 4]). Program Test; {$APPTYPE CONSOLE} {$R *.res} {$O+,W-} uses Diagnostics, Windows; {$DEFINE PATCH_TRY_FINALLY} {$DEFINE REPLACE_RET_WITH_JMP} procedure Test; var i: Integer; begin i := 0; try Inc(i); asm nop nop end; finally Dec(i); Dec(i); Dec(i); {$IFDEF REPLACE_RET_WITH_JMP} { payload : --------- add esp, 4 // remove return address from the stack jmp [esp - 4] // jmp back (return address) } Dec(i); Dec(i); {$ENDIF} end; if i = 0 then; end; procedure PatchTryFinally1(address: Pointer); const jmp: array [0 .. 14] of Byte = ($33, $C0, $5A, $59, $59, $64, $89, $10, $E8, $02, $00, $00, $00, $EB, $00); var n: NativeUInt; target: Pointer; offset: Byte; begin target := PPointer(PByte(address) + 11)^; offset := PByte(target) - (PByte(address) + 10) - 5; WriteProcessMemory(GetCurrentProcess, address, @jmp, SizeOf(jmp), n); WriteProcessMemory(GetCurrentProcess, PByte(address) + SizeOf(jmp) - 1, @offset, 1, n); FlushInstructionCache(GetCurrentProcess, address, SizeOf(jmp)); end; procedure PatchTryFinally2(address: Pointer); const Data: array [0 .. 6] of Byte = ($83, $C4, $04, $FF, $64, $24, $FC); var n: NativeUInt; begin WriteProcessMemory(GetCurrentProcess, address, @Data, SizeOf(Data), n); end; procedure PatchTryFinally(address: Pointer); begin {$IFDEF REPLACE_RET_WITH_JMP} PatchTryFinally2(PByte(@Test) + $32); {$ELSE} PatchTryFinally1(PByte(@Test) + 26); {$ENDIF} end; var i: Integer; sw: TStopwatch; begin {$IFDEF PATCH_TRY_FINALLY} PatchTryFinally(PByte(@Test)); {$ENDIF} sw := TStopwatch.StartNew; Sleep(1); sw.ElapsedMilliseconds; sw := TStopwatch.StartNew; for i := 1 to 100000000 do Test; Writeln(sw.ElapsedMilliseconds); Readln; end.
  15. Lars Fosdal

    Catch details on AV

    The magicians at Grijjy made something for iOS and Android. https://github.com/grijjy/JustAddCode/tree/master/ErrorReporting Nothing for MacOS or Linux yet. IMO, basic cross platform stack tracing should come out of the box from EMBT. MadExcept and EurekaLog could still make a living, dealing with more bells and whistles and with the reporting bit.
  16. Anders Melander

    Catch details on AV

    On Windows you can use an exception logger such as MadExcept or Eurekalog. I don't know of any solutions for maxOS.
  17. Carlo Barazzetta

    Native Svg parsing and painting in Windows

    The work on https://github.com/EtheaDev/SVGIconImageList continues, many issues have been solved. Now it's possible also to use native VirtualImageList (from 10.3 or 10.4) linked to a TSVGIconImageCollection! If you have an older Delphi version you can use TSVGIconsVirtualImageList. With the help of VincentParrent and pyscripter the components and the SVG library improve day by day ... Stay tuned!
×