

TurboMagic
-
Content Count
255 -
Joined
-
Last visited
-
Days Won
9
Posts posted by TurboMagic
-
-
In order to test something, I'd need to have the Hash_Console Demo console application from
https://github.com/MHumm/DelphiEncryptionCompendium (DEC) translated to C++ Builder.
Why do I need this?
In DECOptions.inc there are some switches which would enable 32 bit asm optimized variants of
some hash algorithms. The previous developers left a comment there that those are commented out
due to some C++ Builder issue. Now if I could check whether this issue still persists and if yes, whether
I can selectively disable them via some define, I could improve the library's performance at leastfor Delphi users and if the issue no longer persists maybe even for C++ Builder users.
-
If you like you can contribute this as option via pull request... 😉
-
Yes, it needs the classes to be compiled in, which was ok for my purpose and didn't require to download another library (AST).
It is self contained that way but requires source code distribution.
-
16 hours ago, Dany Marmur said:Excuse my stressed question (i do not have the time to...) what is the difference between this (OT) and DelphiAST?
TIA,
/Dany
My variant generates the hierarchy via RTTI (I don't know how DelphiAST works) and it only considers classes and it can render the tree into
textual form (if you use a font containing the needed glyphs). See the GitHub project page, I added two screenshots now. -
19 hours ago, corneliusdavid said:Nice, that works pretty well.
(You accidentally listed the URL twice so you might want to edit your post and correct it.)
Why did you include the DelphiEncryptionCompendium units? Was that just to test? They aren't really needed for the functionality of the app.
It'd be cool if there was a search button so you could quickly find a specific class in the huge generated list.
Thanks!
I fixed the link. I also had thought I had removed the DEC units...! Grr!
I wrote this tool because I needed it for generating some tree for DEC's documentation.If you like to have a search facility you may add this and either create a pull request or contact me otherwise to submit your improvement... 😉
-
Hello,
I just released a new little utility on GitHub:
https://github.com/MHumm/ClassTree
It can be used to generate class tree representations for documentation purposes.
I hope you like it and don't mind that it's a first version which might still be a bit raw.
It fullfiled at least my purposes.Cheers
TurboMagic-
1
-
-
This is the info that I just released a bugfix version 6.2.1 here:
https://github.com/MHumm/DelphiEncryptionCompendium/releases/tag/V6.2.1
What was fixed?
- fixes bugs preventing use of the demos on older versions, demos have been tested with XE8 Win32 and newer.
- fixes a bug introduced by Git in a deployproj file of a demo making it non-loadable completely.
GetIt submission has already been sent...
-
Just to let you know that I just turned in the submission of the Lite version for GetIt publication. So hopefully it should appear there soon...
-
Hello,
good news is, that I just released a new version of DEC (Delphi Encryption Compendium):
https://github.com/MHumm/DelphiEncry...eases/tag/V6.2
What's new?- Fixed some regressions, among them some which hindered compilation with older Delphi versions (support for older compilers might be reduced in future versions!)
- Fixed bugs in the SCOP and SHARK cipher algorithms
- The unit test for the hash classes got improved by adding original test vectors to those algorithms which didn't already use original test vectors and where we could find those (for most we could)
-
The SHA3 hash algorithm has been added for 224, 256, 384 and 512 bit including support for message lengths not being a multiple of whole bytes. Our implementation uses Eric Grange's
optimizes permutation kernel ASM implementation on WIn32 and WIn64 (with his friendly permission of course!) - A new demo got added: Hash Benchmark FMX
Now have fun with this. The GetIt provided Lite version should follow within the next few days.TurboMagic
-
8
-
4
-
It works now, last failure was to not declare the last function parameter as pointer in the header file they use as this is a var param on my side.
-
Thanks for the answer.
I changed it to use Move now like this:Move(ResStr[1], CalcRes[0], Length(ResStr));
In my Delphi test application it works flawlessly, but the LabView application calling the DLL still crashes it.
Access violation at address 184E140E ... Read of address 00000003I will try to log the address of the PChar passed in now and if possible it's contents at that time, but
I don't know how to read raw RAM for getting a bit more loginfo... -
I'm writing a DLL which shall be called by LabView (among other environments).
Calling a simple function which gets 2 numbers, adds them and returns the result works.
That one uses calling convention cdecl, as specified by the "client".But strings are a problem. For getting this tested I developed the following simple function,
which shall be called by a LabView test application but this always crashes inside the DLL.
Currently it crashes here: "Exception beim Stringrückliefern", if I make a var parameter out
of CalcRes it immediately crashes here: "Exception in Berechnung".What might cause this? The caller shall pass a string which a number of chars allocated for
and the number of chars he allocated the string for + the #0 terminator in CalcResSize.
If the result fits in that, it is returned in the string. CalcResSize will represent the number of
bytes needed for the string including the #0 after the call so if the caller didn't pass a long
enough string he can call the function again using a longer string.Here's the code:
uses System.SysUtils, System.AnsiStrings; function Add(Number1, Number2: UInt8; CalcRes: PAnsiChar; var CalcResSize: UInt8): UInt16; cdecl; var Res : UInt16; ResStr : AnsiString; begin try Res := Number1 + Number2; ResStr := AnsiString(Res.ToString); except On E:Exception do begin OutputDebugString(PWideChar('Exception in Berechnung: ' + E.Message)); Result := 2; Exit; end; end; try if Assigned(CalcRes) and ((Length(ResStr) {* SizeOf(Char)} + 1) <= CalcResSize) then begin System.AnsiStrings.StrPLCopy(CalcRes, ResStr, CalcResSize); Result := 0; end else Result := 1; except On E:Exception do begin OutputDebugString(PWideChar('Exception beim Stringrückliefern: ' + E.Message + ' / ' + madExcept.GetCrashStackTrace)); Result := 2; Exit; end; end; try CalcResSize := (Length(ResStr) {* SizeOf(Char)} + 1); except On E:Exception do begin OutputDebugString(PWideChar('Exception in CalcResSize Berechnung: ' + E.Message + ' / ' + madExcept.GetCrashStackTrace)); Result := 2; Exit; end; end; end;
Cheers
TurboMagic
-
Setting UsePNGAlpha and transparency in the PDF settings do the trick for PDF output, but for preview and print output this
(this = using a PNG image with partial transparent contents) still fails. The watermark image is put into the background and
then overlapped with everything else. -
Thanks in the first place.
1. I do think that image transparent was set to false as I used a PNG. It looked good in designer but not in preview or PDF. I need to check where I can set transparency to true in PDF exportfilter.
In my case it had simply put the image behind everything else in preview and PDF.2. About the OverlayBand: I see references to that and find it in designer, but I don't know how it works. I didn't manage to get it working and I didn't find any documentation for this.
Can you give me more information about what to do with this? -
I'm using the Embarcadero FR 6 version in D10.4.2 and want to add a watermark.
Which way looks properly?
I already tried to place a image on top. It contained the text in semi transparent. Image format was PNG.
It looked ok in designer but at runtime in preview an PDF output everything else was put in front of it!
Even when I had put these other items into the background in designer!The other solution found was adding a frxMemo in EndDoc event. It sourt of works but doesn't cut it either.
I could neither find any way to put it the background as all (but then most likely the TCharts would be placed
on top in such a fashion that they'd cover my watermark) nor did I see any way to make the text semi transparent.I read about using an OverlayBand, but no description of how to properly use that. Drop in on the page in
designer and add a memo with my text to it? Where does it render when? How to make it covering the other things
but in a semi transparent way? -
I just found a little bit of time now and made a new attempt.
I record what's happening using Wireshark now and that clearly shows that my device receives my message and it sends something back to the local port my socket got assigned by Windows.But my application never receives anything.
I used the UDPSend example as starting point. I initially had tried out this 2 sockets solution but since it didn't work I changed it. I added a new socket and dont use the other one at the moment.
Here's the relevant code part:
procedure TMainForm.SendButtonClick(Sender: TObject); begin WSocketReceive.Proto := 'udp'; WSocketReceive.SocketFamily := sfIPv4; WSocketReceive.Port := '0'; WSocketReceive.Addr := '0.0.0.0'; WSocketReceive.Listen; MemoReceive.Lines.Add('Local Port: ' + WSocket.LocalPort); end; procedure TMainForm.WSocketReceiveDataAvailable(Sender: TObject; ErrCode: Word); begin // This is never called!!! MemoReceive.Lines.Add(TimeToStr(Now) + ' ' + WSocketReceive.ReceiveStr); end; procedure TMainForm.WSocketReceiveSessionConnected(Sender: TObject; ErrCode: Word); var Src : TSockAddr; Str : RawByteString; begin Src.sin_family := SOCK_DGRAM; Src.sin_port := 8513; // I don't know how to write this one less cumbersome: Src.sin_addr.S_un_b.s_b1 := #255; Src.sin_addr.S_un_b.s_b1 := #255; Src.sin_addr.S_un_b.s_b1 := #255; Src.sin_addr.S_un_b.s_b1 := #255; // This gets sent: WSocketReceive.SendTo(Src, SizeOf(Src), BytesOf(Str), Length(Str)); end; procedure TMainForm.WSocketSessionAvailable(Sender: TObject; ErrCode: Word); begin // This is never called MemoReceive.Lines.Add('Port: ' + WSocketReceive.Port); end;
As you can see I added a memo for output. But the only thing ever shown in it is the 'Local port' message posted directly after Listen.
What am I'm doing wrong?
-
This is not relevant to my still not working UDP problem. I just tried to find that demo quicker by opening that project group and thought I report the errors popping up loading that group so they can be fixed eventually.
Back to my problem:
The demo you mentioned is a quite big and complex one and the component used in it is equally big.
So I tried to go back to the simple pair of OverbyteIcsUdpSend and OverbyteIcsUdpLstn demos.
Btw. at lease those two demos are set to release mode and thus have no debug info and breakpoints are disabled though.
In my view it would make more sense to have debug mode and debug info on in the demos.
The listen one does get a packet on the port it listens and it sends something back to the sender's port.
I write that in a memo for logging now and the port number logged as LocalPort on the sending site is
the same as on the receiving side.Now the only thing left is to receive something on the UDP sending socket. DataAvailable event is never called and
if I tried to set up a 2nd socket as recommended by you that fails on Listen call because the port assigned, the LocalPort
of the sending socket is of course already in use. But that is the port the sender will get the reply to his request, as that
is the port number the receiver gets by receiving the request.I could try Remy's ReceiveFrom but that seems to be a synchronized/blocking call, which is of course not desired.
So I'm a bit puzzled and think there must be some easier solution.
Strange thing is, that the old code I'm trying to replace simply defined Addr as 255.255.255.255, set Port, set local address
to the IP of the interface it was sending out the broadcast for (it looped through all interfaces on that PC), did a Connect
on that socket and then received an answer in OnDataAvailable event. It has to be replaced because after sending I entereda loop calling Socket.MessagePump; for a certain time, which is of course no good and often crashes.
Now the only thing in my new code is, that OnDataAvailable on the sending socket is never called but the receiver does a
WSocket.SendTo(PSockAddr(@Src)^, SrcLen, @FWuT, SizeOf(FWuT)); in OnDataAvailable. And since I added this to your example
Src is populated by ReceiveFrom and thus contains the correct data.Hey, I just have found some solution now, but I don't think this is perfect.
I just saw, that you are closing the sending socket in the sender demo in OnDataSent event.
When I set up a 2nd socket directly after connect of the first I get the LocalPort but I don't
do Listen yet.Now in OnDataSent I do close the sending socket and then do a Listen on the other one and
in my example that one now receives OnDataAvailable and thus the data sent back by the receiver demo. -
Something else: when trying to open the Delphi\AllDemos project group (current ICS version from GetIt) I get some failures.
One is: Failure reading SslSmtpTestForm -> Class TIcsRestEMail not found. The same class is not found for POP3ExcercizerForm and HttpRestForm.For IcsIsapiWebModule failures for properties do not exist are shown for the following properties: ClientHeight, ClientWidth, Color, Font.Charset,
Font.Color, Font.Height, Font.Style, PixelsPerInch, TextHeight.Are they known to you?
-
If I should use a 2nd socket for listening, how would I set that up? Do a connect with the sending one first, so it can send as broadcast and in the OnSessionConnected create the 2nd socket so that it can listen on the port the sending one used?
The party receiving and replying to my broadcast needs to send the answer to the port from which the broadcast message was sent, otherwise it wouldn't know where to send it to (and I don't have influence on how the other device does this anyway). -
30 minutes ago, Angus Robertson said:Further to my original message about using SendTo, for broadcasting or multicasting you must also set property Addr to the broadcast address before calling Connect, otherwise the socket will not be opened with the correct SO_BROADCAST flag. Send should also work, as used in various components and samples, but SendTo is required for UDP servers to reply to the source address, and works as well for clients.
Angus
Hm ok, but it looks like I don't yet understand 100% what I need to do to make it work.
This is my code for setting up the socket:
FWuTSocket.SocketFamily := sfIPv4; FWuTSocket.Addr := '255.255.255.255'; //ICS_ANY_HOST_V4; //'255.255.255.255'; FWuTSocket.MultiCast := FALSE; FWuTSocket.MultiCastAddrStr := ''; FWuTSocket.Proto := 'udp'; FWuTSocket.Port := '0'; //cWuTUDPPort; FWuTSocket.LocalAddr := '0.0.0.0'; FWuTSocket.LocalPort := '0'; FWuTSocket.LineMode := false; FWuTSocket.OnSessionConnected := OnWuTSearchSessionConnected; FWuTSocket.OnDataAvailable := OnWuTSearchDataAvailable; FWuTSocket.OnSessionClosed := OnWuTSearchSessionClosed; // FWuTSocket.Connect; FWuTSocket.Listen;
I thought I need to use listen instead of connect so I can receive data on that socket as well. But when I change Addr to the above 255.255.255.255 I get an
"address not available" #10049 in listen: Bind error from Winsock...
Now how to set up the socket properly to send via broadcast but listen for the answers as well?
-
Another small question: I had seen that TWSocket offers a LastError property as well.
But when replacing WSocket_WSAGetLastError with it the error code is 0.What is this meant for?
-
From this albeit German description here:
https://helpdesk.ebertlang.com/kb/a507/winsock-fehlercode-beschreibung.aspx
Ok, found the exact same description in English on a Microsoft site:https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
I take it that I should call this one:
setsockopt(SO_BROADCAST)
because I'm using SendTo in conjunction with a broadcast address.
Any idea how I'd call this via ICS and if this is really a good idea?
The other idea would be to use a variant of my old code which fetched a list of all network interfaces and looped through those
and send the request on each one separately.TurboMagic
-
Hello,
I added your error message code but I had to modify it.
I had to use this one: WSocket_WSAGetLastError because the other one is not exported in OverbyteIcsWSocket.pas.
I get the following error message now: "Permission denied" ErrorCode: 10013
TurboMagic
-
Thanks so far, but I still don't properly manage this.
In my application I try to send like this, but in the UDP listener demo nothing arrives and SentTo returns -1:
procedure TDeviceSearch.OnWuTSearchSessionConnected(Sender: TObject; Error: Word); var Src : TSockAddrIn; SrcLen : Integer; Data : RawByteString; begin if (Error = 0) then begin try SrcLen := SizeOf(TSockAddrIn); // I want to send to everybody I can reach (broadcast) Src.sin_addr.S_addr := WSocket_inet_addr('255.255.255.255'); Src.sin_port := 1234; Src.sa_family := AF_INET; Data := 'Hallo?'; // This posts -1 into my log. I'd expect 6 instead... log.Send('Bytes: ' + (Sender As TWSocket).SendTo(Src, SrcLen, @Data[low(Data)], Length(Data)).ToString); except On E:Exception do log.SendException'Failure in OnWuTSearchSessionConnected: ' + E.Message, E); end; end else log.Send('Failure in UDP handling: ' + Error.ToString); end;
What am I making wrong/missing?
Can somebody help me to translate a short Delphi console app to C++ Builder?
in General Help
Posted
Ok, thanks for this rough translation Remy!
Now I simply need to get some DECFormat.hpp and DECHash.hpp.
Is there a way to get them generated or do I need to craft/create them manually?