-
Content Count
1090 -
Joined
-
Last visited
-
Days Won
23
Posts posted by aehimself
-
-
Nice!
I used HxD before and I really liked it. I just always have VSCode open and it's easier with it's addon. It doesn't do as much as your program does, though.
Good job, you just created an awesome tool in an awesome language!
-
Hello all,
After switching from D7 to D10.2 I re-wrote one of my multithreaded apps with proper OOP, using the "new" language features. Each thread has a work queue, which used to be a Array Of String, storing the properties separated with tabs. Now, the work queue is a TObjectList, and work queue items are classes, created upon adding, freed after successful processing. Everything works like a charm, there are no memory leaks reported whatsoever even after a stress-test of the work item part.
After about a week of uptime my Windows 2000 test system reaches 0% of free memory and becomes unstable, requiring a reboot. Unfortunately there are a lot of factors to consider here:
- The ESX host the test VM is running on was patched a couple of times (and because of that vmWare tools got updated on the guests)
- The obvious, Array to TList and String to Class conversion
- Only a Windows 2000 system is affected, Windows 2003 and above accepted the change well
I will attempt to create a new Windows 2000 machine without vmWare tools to see if it makes any difference, however I believe that TList will be the root cause here; which got reinforced after seeing
Did anyone met this symptom before? How can I be sure the root cause is my application and not the prehistoric OS? Maybe the combination of both? Is there a (even a hacky) way to force a Delphi application to release any currently not used memory?
Thanks all!
-
On 3/4/2020 at 1:39 PM, A.M. Hoornweg said:I find formats like Xmldoc totally obnoxious because it interrupts the source code and the text is never in the place where I need to consult it.
Could not agree more. I spent a week, 12 hours a day to XMLDoc document a mid-sized project. The result was so ugly and unreadable I pushed it to a separate branch only. It is really good to see tooltip insights, or a PasDoc created documentation, but it creates a painful mess for the eye.
I'm glad I'm not the only one seeing it this way.
-
On 2/27/2020 at 8:53 AM, Fr0sT.Brutal said:Anyway if a user has admin rights in your system, he is able to dump process memory or even debug it.
For way too long this is haunting my coding experience. A simple Hello World is becoming thousands of lines due to encryption, obfuscation and filler NoOps. At the end of the day you are only making the life of the attacker harder. Never impossible.
On 2/27/2020 at 8:53 AM, Fr0sT.Brutal said:If he hasn't, encrypt your data and transfer it in any manner.
True and not true. If password is sent as a parameter and the application is stored in %APPDATA% for example, you can replace the secondary .EXE to just dump the password. Command line passwords are a really bad idea from this perspective.
-
16 hours ago, David Heffernan said:Nope. It's an HWND. A THandle is quite different.
Also, https://devblogs.microsoft.com/oldnewthing/20130412-00/?p=4683
Hmm, seems I messed up the declarations all along:
TSSHConnection = Class(TConnection) strict private _puttyhandle: THandle;
At the end of the day Delphi considers them the same, this is why my code works:
WinApi.Windows.THandle = System.THandle = System.NativeUInt
WinApi.Windows.HWND = WinApi.Windows.UINT_PTR = System.UIntPtr = System.NativeUInt
I'll correct it anyway 🙂 Thanks for the heads-up!
-
Thank you for sharing the looks of before-after! I love to see the dramatic change from using colors to monochrome is causing... it indeed looks cleaner and more professional. I do have troubles with a good UI design and it's hard to come by with useful tips and tricks.
Good luck with your application 🙂
-
Docking is easy. _puttyhandle is a THandle, value comes from FindWindow. _owner should be a TWinControl, where you want your external application to be docked. I docked Putty, but Notepad also works fine 🙂
procedure TSSHConnection.Dock; var WindowStyle : Integer; FAppThreadID: Cardinal; begin WindowStyle := GetWindowLong(_puttyhandle, GWL_STYLE); WindowStyle := WindowStyle - WS_CAPTION - WS_BORDER - WS_OVERLAPPED - WS_THICKFRAME; SetWindowLong(_puttyhandle,GWL_STYLE,WindowStyle); /// Attach container app input thread to the running app input thread, so that the running app receives user input. FAppThreadID := GetWindowThreadProcessId(_puttyhandle, nil); AttachThreadInput(GetCurrentThreadId, FAppThreadID, True); /// Changing parent of the running app to our provided container control Windows.SetParent(_puttyhandle, TWinControl(_owner).Handle); SendMessage(TWinControl(_owner).Handle, WM_UPDATEUISTATE, UIS_INITIALIZE, 0); UpdateWindow(_puttyhandle); /// This prevents the parent control to redraw on the area of its child windows (the running app) SetWindowLong(TWinControl(_owner).Handle, GWL_STYLE, GetWindowLong(TWinControl(_owner).Handle,GWL_STYLE) or WS_CLIPCHILDREN); /// Make the running app to fill all the client area of the container SetWindowPos(_puttyhandle,0,0,0,TWinControl(_owner).ClientWidth,TWinControl(_owner).ClientHeight,SWP_NOZORDER); // SetForegroundWindow(WindowHandle); // SetFocus(WindowHandle); end;
Importing MSTSCAX as a VCL component is tricky, but I found a solution a couple of years ago which still works. I don't have the link anymore, so I don't know who to credit for it 😞
- Component -> Import Component -> Import ActiveX Control -> Select Terminal Services (mstscax.dll)
- Palette page: MsTSC, unit dir name: Delphi Lib folder, Search path: empty. Check Generate component wrappers
- Install to New package
- Enter the same name (MsTSCLib_TLB.dproj) under Delphi Lib folder
- Try to build package just to fail
- Change Property type of ConnectWithEndpoint to "OleVariant", build package again
- Right-click on MsTSCLib_TLB.bpl in Project manager and select "Install"As for the modified PageControl, you can check it out at https://www.aecentral.org/index.php?post/35. Idk why I used a global variable as the OnClose event... feel free to change it, you can even add a Register procedure to have a VCL component.
-
As time progressed, more and more new possible solutions were introduced, but since it's 20+ year old legacy code which was designed to have their filters this way... changing the frameworks filtering would require us to check and modify ~1000 frames on the Windows client and I guess it would break the web app too. There's close to no chance on changing this anymore 😞
I'm not a DB expert, I personally never used temporary tables; but I have a slight memory having issues / limitations with temporary tables on some engines. I could be wrong on this one, though.
-
32 minutes ago, Fr0sT.Brutal said:[...] one could be called oldschool just for using 1-year-old techniques )))
This is something I really did not consider, and you could not be more right.
Especially if you speak the trendy JavaScript as new libraries (frameworks, my bad) are popping up like mushrooms.
-
2 hours ago, Fr0sT.Brutal said:[...] not causing too much eye pain to oldschool guys 😉
Wow, I'm not even 35 yet and being called oldschool 😞 I guess "OK boomer" is next in my bucket list 😄
-
2 hours ago, Fr0sT.Brutal said:I saw multiple opinions that such big IN's are bad design. Where they come from?
Client - Server architecture, mostly. User opens up the Client and selects which records to process / manipulate. We do have filtering capabilities (so instead of an array of IDs we could send a filter) but it requires critical thinking so users are afraid of it.
So we simply send 1-2-5-10k IDs to the Server. An other case would be if you need to fix data corruption in the database.
-
The bitter-sweet memories are for the archived version of fPrint. I remember my first website I created (it was in the early 2000's though) but browser capabilities did not allow too much freedom (index.html, browserdetect.js, index_ie.html, index_ns.html; anyone? 🙂) and they were kinda similar.
The (d)evolution of websites does not apply on it, nor yours. It's the mass: dynamic content loading causing browsers to eat up the memory of NASA's supercomputers, JavaScript attempting to behave like a real programming language, ads, consents, facebook integration with everything so you can't check an article without a profile (or registering), stuff like this.
Things were much more simple in the early days.
-
1
-
-
Ooooooooh, shadows under everything, rough edge of transparent GIFs and default (times?) font... brings back some bitter-sweet memories.
I don't like the way webpages are "evolving" but I'm glad we broke free from these designs 🙂
-
Back in the days when I was a sysadmin we chose mRemote and nothing served us better. The developement stopped but then was forked and continued as mRemoteNG.
At the end I just wrote my own tabbed application using TMsRDPClient9NotSafeForScripting for RDP, and for everything else launching the external application and docking it to the tabsheet.
I also expanded TPageControl with drag-and-drop rearrangement with tab picture, close buttons, middle-click tab closing and full VCL styling support for the above. Let me know if interested, I can share the code.
-
On 1/21/2020 at 11:38 PM, Attila Kovacs said:SELECT * FROM tTableName WHERE Status IN (:ST0,:ST1)
Be careful with DB engine limitations. I can not count how many times my code failed, because Oracle can't handle more than 1000 entries in a single IN operator.
I wrote a method to create the IN statement for me, which breaks the array up to chunks of 900:
( IDFIELD IN (:pVal1, :pVal2, [...], :pVal900) OR IDFIELD IN (:pVar901, :pVar902, ...) )
-
1
-
-
29 minutes ago, Fr0sT.Brutal said:or, in newer Delphis, you can use inline variable inits
Please no... 😄 Even at work we agreed that we'll not use inline variable declarations when we upgraded to 10.3.3. In my humble opinion this feature was utterly useless and will make Pascal code harder to read - at least for me, that is.
-
3
-
-
The issue is present using the ISO and network installer too but only if you start a project file directly. When launching the IDE and opening the same project the layout is displayed correctly. The strange thing is that if you unpin (collapse?) a sidebar, it will load correctly, but the uncollapsed ones are still too narrow.
My two cents are that the problem will be with the .DST file somewhere; it is just a bit large to attempt to debug what is the cause.
It's a minor inconvenience, but as it seems only present in my team I'll keep searching online for solutions.
-
@Kryvich I recently started to use generics myself so I guess I'm far away of harvesting their true potential. I like your solution, though; it's really elegant 🙂
-
I personally use nr 2 really often. Imagine a simple encoder:
TBaseEncoder = Class [...] TEncoderV1 = Class(TBaseEncoder) [...] TEncoderV2 = Class(TBaseEncoder) [...] TEncoderV3 = Class(TEncoderV2) [...]
Basically you have a bunch of encoders, containing new methods, improvements, etc. Now let's say you want your application to be backwards compatible and be able to use previous encoders. If you add:
TBaseEncoderClass = Class Of TBaseEncoder;
...and define your application as:
TMyApplication = Class strict private _myencoder: TBaseEncoder; public Constructor Create(inMyEncoderClass: TBaseEncoderClass); ReIntroduce; End; Constructor TMyApplication.Create(inMyEncoderClass: TBaseEncoderClass); Begin inherited; _myencoder := inMyEncoderClass.Create; End;
then you simply can call:
TMyApplication.Create(TBaseEncoder);
or
TMyApplication.Create(TEncoderV3);
to create and make your application to use the specified version of your encoder.
-
1
-
-
18 hours ago, Silver Black said:Try checking that Autosave setting in "Sving and Desktop".
Did that, still no joy; default layout is still getting reverted to the ridiculously narrow side panels whenever I open a project.
-
10.3.3 here, and layout is always messed up when I'm starting Delphi with a project. If I simply start Delphi and create a new project (VCL Forms application for example) layout is loaded properly. In the Settings -> IDE -> Saving and Desktop -> Autosave section both is unchecked.
I'll try with a fresh install, maybe my previously exported and imported registry has something bad inside it....
-
It's a bit old thread, I know - but has this issue been resolved already? Always re-selecting the Default layout when opening a project is getting a bit annoying.
-
Good day Remy, I was wondering when you'll show up 🙂
So it seems the way was right from the beginning, I just had no idea Indy is automatically creating a thread for each connection and simply hang them while waiting for data. Sounds logical.
19 minutes ago, Remy Lebeau said:Then you should read Introduction to Indy.
To be completely honest I never had much luck with documentations. I prefer the bang-my-head-against-a-brick-wall method, which is a slower learning curve but makes the knowledge to stick around.
I smiled on this though:
// Sleep is substituted for a long DB or other call Sleep(5000);
Some of our DB actions at work take 30+ seconds, especially on a shared test DB or a production database over the Internet.
Well, with the very basics covered I can slowly can move to more advanced features (DoS protection, throttling, timeouts and so on) and if I like Indy I might even change the webserver component I'm using to create a REST-like interface.
Just one question though. Are all the events of the component are called from within the connections thread context? Where should I prepare locks / synchronizations?
-
Actually, closing the client socket before exiting does get rid of the exception!
I made some further tests, and indeed it seems that it is a debugger issue. Put a breakpoint on s := and press F8. First run it does, second time it does not reach the TThread.Queue line. Now put a breakpoint on both; F8 will step through them nicely.
I also think I get the point of the double Execute event... first time is does not read anything from the socket - I guess the context is just being initialized. On the second run text gets read successfully.
So it seems the Hello World implementation is working properly, I just hit an other debugger anomaly 😞
Thank you very much for your help! 🙂
Generics and Classes on Windows 2000 = OOM
in General Help
Posted · Edited by aehimself
I did, this is why I linked a post, not the topic itself. I personally don't have this deep knowledge of how the language works but as noone opposed Pawel's statement I considered it true.
I not just went back to ensure all blocks are surrounded by a Try ... Finally ... FreeAndNil ... End; FastMM and MadExcept both says there are no leaks at all. The average alive time of a work queue item is a couple of seconds, and as I'm using TObjectList.Create(True) as the queue, I can be sure that work items are disposed upon removal.
Furthermore, as I mentioned the problem only appears on a Windows 2000 machine with (currently) 1 GB of memory (previous solution ran fine on 64 MB); a Windows 2003 R2 with 128 MB and a 2008 with 512 MB is running the tool fine for weeks now (since the latest patch).
In the mean time, I set up a basic VM with 128 MB of RAM and no vmWare tools. We'll see how long it will last.
P.s.: I don't want anyone to find the issue for me; I'm looking for directions on how to find these by myself. So any tips are highly welcome.