ertank
Members-
Content Count
246 -
Joined
-
Last visited
-
Days Won
1
Everything posted by ertank
-
I hope @Ugochukwu Mmaduekwe can make some comments about PKCS7 padding here. I have all below repositories and do not have problem with compilation etc. HlpIhash is part of HashLib4Pascal https://github.com/Xor-el/CryptoLib4Pascal https://github.com/Xor-el/HashLib4Pascal https://github.com/Xor-el/SimpleBaseLib4Pascal
- 35 replies
-
- encryption
- decryption
-
(and 2 more)
Tagged with:
-
Local string variable value is not assigned for 2nd and following calls
ertank posted a topic in RTL and Delphi Object Pascal
Hello, First of all, I am not experienced about technical details of variable initialization and such. I am using Delphi 10.3.3 and targeting Win32 executable. I am running multiple threads in my application. One of the threads is making rest web service calls. Other does SOAP web service calls. Below unit is only used by rest web service thread and that thread only. Rest web service requires me to do logins for every 60 minutes. Problem appears at the second hour. Login requests sent as empty strings. I am sharing only relevant lines (timeout calculations, logging etc are not included below for simplicity): unit MyRestUnit; function Login(const AppKey, SecretKey: string): Boolean; implementation function Login(const AppKey, SecretKey: string): Boolean; var Request: string; Response: string; begin if AppKey.IsEmpty then Exit(False); if SecretKey.IsEmpty then Exit(False); Request := '{"appKey":"' + AppKey + '","secretKey":"' + SecretKey + '"}'; if uUtils.Http.PostIndy(URL, Request, Response) then // Rest of the function code is irrelevant end; Code is just as in above. Request is filled in and HTTP request is made. However, Request variable is filled in for the first time function is used. It is always becoming empty for the remaining calls. My log files says application is actually sending empty request bodies. Rest web service response error also confirms that. No garbage characters just empty. If I use debug run (F9) and check variable value at run time. It holds proper value for first call, second and following calls it is always empty. Same problem exists for Release build and Debug build. Only way I could make it always work is changing above code to something like below Request := EmptyStr; Request := '{"appKey":"' + AppKey + '","secretKey":"' + SecretKey + '"}'; I tried to use different local variable names (more than one) to rule out possible name collision and it still does not work for second calls to function, unless I first make it EmptyStr. It is also interesting that I do not get any compile time hint/warning like "value assigned is not used" or similar for my second example above. I have all hints and warnings turned on in my project. My internet searches did not result in something meaningful to me. My question is: Why first example does not work for the second and following calls? Asking in here because I could not find an explanation at all and I am really curious as to why. Moreover, that is the first time I am facing such a problem. Thanks & Regards, Ertan -
Local string variable value is not assigned for 2nd and following calls
ertank replied to ertank's topic in RTL and Delphi Object Pascal
While trying to prepare minimal reproduction I realize that there is an "else" exists above some explanatory remark lines and my Request variable assignment comes next. Turned out my mistake of leaving an else that should have been deleted at the first place. if TokenExpireTime <> 0 then begin // some other stuff with begin..end blocks end else // problem source line // some remark // another remark // more remark Request := '{"appKey":"' + AppKey + '","secretKey":"' + SecretKey + '"}'; It turned out that Request is conditionally filled in if no line above. Sorry about all the fuss and thanks to all. -
Local string variable value is not assigned for 2nd and following calls
ertank replied to ertank's topic in RTL and Delphi Object Pascal
I just installed and tried madExcept. It doesn't report any buffer overflow or underflow (tried both). Though, there are some leaks reported like Mutex Handle, TCriticalSection, TIdThreadSafe. First one is my code in DPR file, last two being in the initialization sections of relevant units. It was interesting to have leak report even FastMM4 is not reporting any. Unfortunately, I failed to find a corruption using madExcept. I think is is harder to identify than I think it is. Thanks. -
Local string variable value is not assigned for 2nd and following calls
ertank replied to ertank's topic in RTL and Delphi Object Pascal
That did not help. -
Local string variable value is not assigned for 2nd and following calls
ertank replied to ertank's topic in RTL and Delphi Object Pascal
I do have FastMM4 full debug open and it does not report a leak. I do not know if it also reports for corruptions though. Are there any hints/suggestions to search for such corruptions? -
Does MARS work in Delphi 10.3 Community Edition?
ertank replied to lvincent7's topic in MARS-Curiosity REST Library
You can use MARS with Community Edition. Some examples depend on some FireDAC units which belong to higher edition. -
Hello, I have orders and orderdetails tables. There is one method that should be returning several orders when used. I would like to return a json string to such requests as in following example { "orders":[ { "id":1234, "date":"2020-05-29", "details":[ { "item":"1", "amount":3 }, { "item":"5", "amount":2 }, { "item":"116", "amount":1.3 } ] } ] } I know that I can define method to return a TJsonObject and build json piece by piece in method code. However, I would like to avoid that, if possible. I wonder if there is/are some other ways of doing so in MARS. Thanks & regards, Ertan
-
It is released, yes. https://www.embarcadero.com/products/rad-studio/whats-new-in-10-4-sydney
-
FireBird tool, Coworker doing this, 2.0 just released
ertank replied to Tommi Prami's topic in I made this
Actually, there is a new version released 5.0.1 which also fixes problem of opening tables with lowercase letters. -
what is the possibility of having a rest/soap webapi in Delphi 2007
ertank replied to Ugochukwu Mmaduekwe's topic in Network, Cloud and Web
Even it is not just for REST, you can write your own interface based methods and use mORMot as a REST server. Learning curve might be slower compared to some other options. However, it does run from Delphi 6 to Delphi 10.3.3 and has Linux support using Lazarus+FPC. There is no SOAP support as to my knowledge. -
what is the possibility of having a rest/soap webapi in Delphi 2007
ertank replied to Ugochukwu Mmaduekwe's topic in Network, Cloud and Web
If you have the option to choose REST only then you might really would like to consider MARS Curiosity. Edit: Just checked GitHub and it seems no packages exists for Delphi 2007. -
You did not run Delphi. You did not install any kind of plug-in or component. Only thing left is OS itself. Something must have been changed in your system that affects Delphi license. You can try to remember if you did some kind of "restore" or system change (computer name or alike) or hardware change during last week. You can also look for a "cleaning tool" or similar in the system and disable it for a while just for ruling out that possibility.
-
Actually it is possible. License days start counting down from the day you activate it for the first time. Moreover, if you register and get a free license today it will have 366 days left.
-
I am using Delphi 10.3.3 Community Edition right now. I did have license failure just once for a Community Edition. It was after I changed computer name of Windows. I do not remember having frequent IDE crashes at all.
-
Hello, I am using Delphi 10.3.3, targeting Android 64Bit and 32Bit. Attached is a test project I used. If that same project is compiled for Android 32Bit it gets two permission request as can be seen in below pictures However, if same code without changing anything is compiled for Android 64Bit it only asks for a single permission as can be seen in below picture Both bitness apk files are tested on same physical phone running Android 9. I have tried to change order of permissions in request to see if this is related with request order. I always get same above permission asked on 64bit version. Let me know if you think this is a bug in Delphi, please. Thanks & regards, Ertan Android64Bit_Permisions.7z
-
That's it. I should have spotted that. I guess I am still not used to different settings on 32Bit and 64Bit of same OS. Thanks.
-
Changed phone language to English for any possible future questions. Thanks.
-
Segmentation fault while trying to receive UDP broadcast messages on Android
ertank posted a topic in Indy
Hello, I am using Delphi 10.3.3, Indy 10.6.2.5366 (stock Indy version) I am trying to listen broadcast UDP messages on Android (exact version I am testing is 4.4.2, I need to support latest versions, too) connected to a local WiFi. Broadcast messages will be sent in same network. I have found this page https://stackoverflow.com/questions/19040674/delphi-xe5-tidudpserver-does-not-receive-anything-on-android and tried to do it as to my understanding. Project has CHANGE_WIFI_MULTICAST_STATE permission set. UDP server parameters are as following at design time and everything else is left as default: TIdUDPServer.Active = False TIdUDPServer.BroadcastEnable = True TIdUDPServer.DefaultPort = 8080 I have following code where timer is activated as last line in OnFormCreate() event and has 0.5 seconds delay: procedure TForm3.tmrCheckPhoneServiceTimer(Sender: TObject); var WifiManagerObj: JObject; begin // Run just once tmrCheckPhoneService.Enabled := False; // Get necessary OS settings to receive broadcast messages Log('Getting multicast lock...'); WifiManagerObj := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.WIFI_SERVICE); FWifiManager := TJWifiManager.Wrap((WifiManagerObj as ILocalObject).GetObjectID); FMulticastLock := FWifiManager.createMulticastLock(StringToJString('LightFactory Remote')); FMulticastLock.setReferenceCounted(True); FMulticastLock.acquire(); // Try to open a port on Android by sending a broadcast message Log('Sending a broadcast message...'); IdUDPServer1.Broadcast('test', IdUDPServer1.DefaultPort); // Now we can start to listen Log('Activating UDP listener...'); IdUDPServer1.Active := True; if FPhoneDialerService = nil then begin TDialogService.ShowMessage('PhoneDialer service not supported'); Exit(); end; PermissionsService.RequestPermissions([FCallPhonePermission], MakePhoneCallPermissionRequestResult, DisplayRationale); end; I have following code in my OnDestroy() event: procedure TForm3.FormDestroy(Sender: TObject); begin // Stop listenning. IdUDPServer1.Active := False; // Release multicast lock FMulticastLock.release(); end; My broadcast listening code is as following: procedure TForm3.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread; const AData: TIdBytes; ABinding: TIdSocketHandle); var Data: string; begin Data := TEncoding.Default.GetString(AData); TThread.Queue(nil, procedure begin Log('Incoming broadcast message from: ' + ABinding.PeerIP) end); if SameText(Data, 'mytriggerphrase') then begin TThread.Queue(nil, procedure begin TestConnection(ABinding.PeerIP) end); end; end; After I run the app, I have following in my log: 2020-01-14 00:59:33.697 Getting multicast lock... 2020-01-14 00:59:33.736 Sending a broadcast message... 2020-01-14 00:59:33.740 Activating UDP listener... 2020-01-14 00:59:33.804 Incoming broadcast message from: 192.168.1.186 That IP number in above log belongs to Android device itself. I have following problems that I could not figure a solution: 1- I do not get any other broadcast message from my PC application which is sending one broadcast message each second. Is there anything I am doing wrong for that to happen? 2- I get segmentation fault (11) when closing my app. Detailed call stack and exact line is in attached picture. This happens each and every close. I did not understand why. Lastly, I am not sure if my code is doing it correct to keep multicast lock thru all run-time. I read a suggestion to release a multicast lock once finished with it in order to save battery life. So, I wonder if I can release multicast lock right after enabling my TIdUDPServer? Any help is appreciated. Thanks & regards, Ertan -
Segmentation fault while trying to receive UDP broadcast messages on Android
ertank replied to ertank's topic in Indy
So far I have tried following on a fresh project using one TIdTCPServer and one TIdIPMCastServer: - Set Active property to False any Indy component on form manually way before closing app: Failed - Set Active property to False any Indy component on form manually. Free them way before closing app: Failed - Remove all auto-create components. Create them using code without owner. Set Active property of them to False way before closing app: Failed - Remove all auto-create components. Create them using code without owner. Set Active property of them to False. Free them at run-time way before closing app: Failed - Remove all auto-create components. Create them using code without owner. Set Active property of them to False. *Do not* Free them at run-time and close app: Failed (this one was just for my curiosity) I get very similar call stack for all tests above. Then I tried to do some tests using just a single component: - Using run-time created TIdTCPServer with no owner. Active property set to False at run-time. *Did not* free and closing app: No exception (just some memory leak obviously) - Using run-time created TIdTCPServer with no owner. Active property set to False at run-time. Freed before closing app: No exception - Using run-time created TIdTCPServer with no owner. Active property *not* set to False at run-time. Freed before closing app: No exception - Using design-time placed TIdTCPServer with no owner. Active property set to False at run-time way before closing app: Failed - Using run-time created TIdIPMCastServer with no owner. Active property set to True, used TIdIPMCastServer.Send() and property set to False. Freed at run-time way before closing app: No exception It is interesting that using either component alone created at run-time is not failing at all. Mixing them both seems to be having a problem. Using TIdUDPClient for sending broadcast messages with TIdTCPServer also failing. In anyway, it seems to be best creating components at run-time as putting them on form at design time is always failing. -
Need help adding namespaces to SOAP
ertank replied to Stéphane Wierzbicki's topic in Network, Cloud and Web
I was more suggesting alternative way to use your web service. Something like semi-manual Delphi SOAP web service use. It is sometimes easier to explain in code. Please check attached demo. Especially file "ISrvConsultaCartera.WS.pas". I could not test everything as your URL was missing in the first place. I do hope that will help you out. SOAP_before_execute.7z -
Segmentation fault while trying to receive UDP broadcast messages on Android
ertank replied to ertank's topic in Indy
I did not know until I read your reply that there are dedicated components. I am going to try them. Below is all I set on TIdUDPServer. Actually, I set these at design time and activate component at run-time as in my initial post. TIdUDPServer.Active := False; TIdUDPServer.BroadcastEnable := True; TIdUDPServer.DefaultPort := 8080; Using suggested code, I still get segmentation fault (11) when app exists. However, call stack changed a little this time as in attached screen shot. -
Need help adding namespaces to SOAP
ertank replied to Stéphane Wierzbicki's topic in Network, Cloud and Web
There is also a difference of missing empty soap header in Delphi version <soapenv:Header/> You can try creating a soap header and see if it helps. What I do under similar cases is manually creating XML using THTTPRIO.OnBeforeExecute() event. SOAP was using Indy components before. Now it is using THTTPClient in recent versions. Changes presented some bugs like Delphi 10.3.3 version have problem of not reading error message in returned XML if it exists (https://quality.embarcadero.com/browse/RSP-27194). BTW, I do not see any clue about having namespace support for SOAP anywhere. -
Hello, Using Delphi 10.3.3. I have no problem compiling Android apps. I just needed to use a service to test something and I failed to compile. Below is error message I receive on a new Android Service project: [Exec Error] The command ""\bin\javac" -d "C:\Users\Ertan\Documents\Embarcadero\Studio\Projects\JavaClasses\Project2" -Xlint:deprecation -classpath "C:\Users\Public\Documents\Embarcadero\Studio\20.0\CatalogRepository\AndroidSDK-2525_20.0.36039.7899\platforms\android-26\android.jar";"c:\program files (x86)\embarcadero\studio\20.0\lib\Android\Debug\android-support-v4.jar";"c:\program files (x86)\embarcadero\studio\20.0\lib\Android\Debug\fmx.jar" -bootclasspath "C:\Users\Public\Documents\Embarcadero\Studio\20.0\CatalogRepository\AndroidSDK-2525_20.0.36039.7899\platforms\android-26\android.jar" -encoding UTF-8 -target 1.6 -g -source 1.6 .\Android\Debug\Project2.java .\Android\Debug\Project2ProxyInterface.java" exited with code 3. I have no problem running javac on command prompt C:\Users\Ertan>javac Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files and annotation processors -cp <path> Specify where to find user class files and annotation processors -sourcepath <path> Specify where to find input source files -bootclasspath <path> Override location of bootstrap class files -extdirs <dirs> Override location of installed extensions -endorseddirs <dirs> Override location of endorsed standards path -proc:{none,only} Control whether annotation processing and/or compilation is done. -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process -processorpath <path> Specify where to find annotation processors -parameters Generate metadata for reflection on method parameters -d <directory> Specify where to place generated class files -s <directory> Specify where to place generated source files -h <directory> Specify where to place generated native header files -implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files -encoding <encoding> Specify character encoding used by source files -source <release> Provide source compatibility with specified release -target <release> Generate class files for specific VM version -profile <profile> Check that API used is available in the specified profile -version Version information -help Print a synopsis of standard options -Akey[=value] Options to pass to annotation processors -X Print a synopsis of nonstandard options -J<flag> Pass <flag> directly to the runtime system -Werror Terminate compilation if warnings occur @<filename> Read options and filenames from file C:\Users\Ertan> My version of "javac.exe" is located at C:\Program Files\Java\jdk1.8.0_60\bin\javac.exe I have seen some people having exact same error on my searches. No solution that I could find so far. I am planning to setup a virtual machine to install fresh copy of Delphi 10.3.3 and test if working on it. Before I do that I wonder if there is something I need to check. Thanks & regards, Ertan
-
That was it. My same registry key was as below: After making it look like same with your settings Android Service compilation works fine. I am not sure how that registry setting value removed in there. BTW, I did also fix 64bit sdk value, too. Thanks.