Jump to content

sp0987

Members
  • Content Count

    61
  • Joined

  • Last visited

Everything posted by sp0987

  1. Hi, We are using Db express components in our Delphi 11 IDE to connect to Database. We are getting Argument Out of Range exception under the following scenario 1. Note: dys parameter has an prefix of '-' to subtract the days from getdate(); In Scenario 1 , we are getting the exception "ArgumentOutOfRange. In Scenario 2 , we gave a space between the '-' operator and the dys parameter. In this case we didn't get any exception. Scenario 1: q.SQL.Add('DECLARE @MinEffDate date = DATEADD(DAY, -:dys, getdate())'); q.SQL.Add('DECLARE @MinRefDate date = :dt'); q.SQL.Add( 'select CONVERT(varchar(10), @MinEffDate, 101) AS MinEffDate,CONVERT(varchar(10), @MinRefDate, 101) AS MinRefDate'); q.ParamByName('dys').AsInteger := 30; q.ParamByName('dt').AsDateTime := StrToDateTimedef('2018-11-01 00:00:00', 2); Scenario 2: q.SQL.Add('DECLARE @MinEffDate date = DATEADD(DAY, - :dys, getdate())'); q.SQL.Add('DECLARE @MinRefDate date = :dt'); q.SQL.Add( 'select CONVERT(varchar(10), @MinEffDate, 101) AS MinEffDate,CONVERT(varchar(10), @MinRefDate, 101) AS MinRefDate'); q.ParamByName('dys').AsInteger := 30; q.ParamByName('dt').AsDateTime := StrToDateTimedef('2018-11-01 00:00:00', 2); Thankyou
  2. sp0987

    Argument out of range Exception

    q.SQL.Add('DECLARE @MinEffDate date = DATEADD(DAY, -:dys, getdate())'); q.ParamByName('dys').AsInteger := 30; It works well in D11 without space too when the query has only this argument. If the query has more than one argument with the combination of "DATEADD(DAY, - :dys, getdate())');" , then it results in error
  3. sp0987

    Argument out of range Exception

    Was it an enhancement in D11? It was working good in D7
  4. Hi, We have a windows service sample application developed using D11. Observed that even after the service destroyed, the executable still showing in the background for 20sec's. When looked for help i found this "When a Windows service is destroyed , the service itself is removed from the running processes, but the executable file (.exe) might still appear in the process list because the underlying process hosting the service (often "svchost.exe") remains running, even if it no longer actively manages the service you deleted; essentially, the executable is still in memory but is not actively performing any service-related functions". Though it's a zombie exe, but still when we run the same exe multiple times , we could able to see the more than one zombie exe's in the process tab in task manager.
  5. Am sorry... As per this was it ok for the exe to stay in the background for a period of time?
  6. I am writing an HTTP server (TIdHTTPServer) program that services GET requests for images. This 'OnCommandGet ' procedure of Httpserver, calls other procedures to do various tasks, and then finally gets back to the client via TIdHTTPResponseInfo. procedure TVRMEditor.HTTPServerCommandGet(AContext: TIdContext; req: TIdHTTPRequestInfo; res: TIdHTTPResponseInfo); var act, DocExt: string; begin try res.SERVER := 'VRM Editor'; res.ContentType := 'text/html;charset="UTF-8"'; res.ResponseNo := 200; act := UpperCase(copy(req.Document, 2, Length(req.Document) - 1)); DocExt := UpperCase(ExtractFileExt(act)); self.Log(fcomp_name + ': ' + copy(req.RawHTTPCommand, 1, Length(req.RawHTTPCommand) - 9), allowed); -- allowed is a flag to print all the req commands when set to true if DocExt = '.MAX' then begin self.ProcessResponse(req, res); end else self.SendFileToClient(req, res); -- access all the js/css/jpg/css files which are needed to open a web page except on E: Exception do begin self.Log(req.URI + ' : ' + req.Document + sLineBreak + E.ClassName + ' : ' + E.Message); end; end; end; When the Allowed flag is set to true, it prints al the request commands and opens the webpage without any error. If it sets to false, am getting AV / Invalid pointer and couldn't open the page. Am not sure whether you can get the log, but you can see the exceptions. Allowed = true.log Allowed=false.log
  7. Procedure GLog(Msg: String); var gLogger: TFileLogger = nil; begin if Assigned(gLogger) and Assigned(gLogger.Memo) then begin gLogger.fmLock.Enter; gLogger.Memo.Lines.BeginUpdate; while gLogger.Memo.Lines.Count > 600 do gLogger.Memo.Lines.Delete(0); gLogger.Memo.Lines.Add(Msg); gLogger.Memo.Lines.EndUpdate; gLogger.Memo.Perform(EM_SCROLLCARET, 0, 0); gLogger.fmLock.Leave; end; _Log(Msg); end; Upon my observation, when log prints all the requests from web page, there was no AV/ Invalid pointer Exception. Am not sure that log function was the culprit...
  8. procedure TVRMEditor.SendFileToClient(req: TIdHTTPRequestInfo; res: TIdHTTPResponseInfo); var doc, ext, Data, fname, err: String; b: boolean; rlst: TStringList; begin Data := ''; fname := req.Document; doc := ExpandFilename(self.RootDir + fname); if not FileExists(doc) then begin self.Log(fcomp_name + ': ' + fname + ' not in editor''s webroot!', LogServer); doc := ExpandFilename(fclirootdir + '\webroot\' + fname); if not FileExists(doc) then begin self.Log(fcomp_name + ': ' + fname + ' not found in any webroot!'); doc := ''; end; end; if doc <> '' then begin ext := UpperCase(ExtractFileExt(fname)); b := (ext = '.CSS') or (ext = '.HTM') or (ext = '.HTML') or (ext = '.JS'); if not b then begin res.ContentType := fMIMEMap.GetFileMIMEType(doc); res.ContentStream := TFileStream.Create(doc, fmOpenRead or fmShareCompat); end else begin try rlst := TStringList.Create; GetConstantGroup('Global_Skin', rlst); Data := LoadDataFromFile(doc); Data := ReplaceAllStringParams(Data, [rlst], '#S', '#', true); if not ReplaceForIncludFiles(Data, err, rlst, true) then self.Log(' #Include Replace Error: ' + err); res.ContentType := fMIMEMap.GetFileMIMEType(doc); res.ContentStream := TStringStream.Create(Data); finally rlst.Free; end; end; end; end; Code to sendfiletoclient
  9. Hi, I am trying to create a .JSON file in Delphi 11 64-bit. While writing sample data to .json file , the &nbsp character was weird in 64-bit. In 32-bit version , it was like "u00A0" and when coming to 64-bit version it was like "u=<68" and sometimes "u3<78". When I parse this resulted json file in .JS files , it throws an error like "invalid JSON". Attached are samples from 32-bit and 64-bit. Please suggest. 32-bit.json 64-bit.json
  10. Attaching a sample project. The project will create a json file, which when we try to use in javascript reults in error "invalid Json". can be run in bot 32-bit and 64-bit with few changes. The changes were mentioned in the respected .pas files as comments. TestJson.7z
  11. Am having issue with "u3<78" . Instead of "u1618", am getting "u3<78" in some areas. When we see the 32-bit , it was 'u00A0' all over.
  12. It was just a part of json file, not the whole thing.
  13. We have introduced a new variable to the interface part and a function to the implementation portion of the Delphi 11 System.Sysutils.pas, in accordance with project requirements. The freshly generated variable is not accessible to me, and when I try to access it, I get the "Undefined Identifier" error. In Delphi 7, the same procedure was effective.
  14. Much grateful for you response. It worked. The problem is with this LOC. Without stdcall it worked in D7.
  15. AM sure, it's not working. When the call the Now() after "Interceptcreate", then as we hooked the "gettbttime" it will go to GetTBTtime proc and then decode the date which was given in the code. And then it goes to function Now() in sysutils.pas. In that function , the SystemTime var will be filled with either '0''s or weird numbers. The same code when in debugged using D7, the SystemTime var in Now() of sysutils.pas was filled with the date given in "gettbttime"
  16. In the DecodeDateTime, we will not use that param.
  17. Does DDetours offer support for Delphi 11? I'm having trouble using the library right now. DDetours was utilized in place of editing the sysutils.pas file, as advised. However, it functions properly with Delphi 7 but returns a "Inavalid Date to EncodeDate" issue with Delphi 11. This code sample, which functions well in D7 but not in D11, was supplied. implementation {$R *.dfm} var windows_GetLocalTime: procedure(var st: TSystemTime); stdcall; procedure getTbtTime(var st: TSystemTime); var dt: TDateTime; begin dt := strtodatetime('12/06/2024'); DecodeDateTime(dt, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); end; procedure TForm1.FormCreate(Sender: TObject); begin windows_GetLocalTime := Windows.GetLocalTime; end; procedure TForm1.Button1Click(Sender: TObject); var dt, value: TDateTime; s: string; begin dt := Now; showmessage('before hook:- ' + datetimetostr(dt)); windows_GetLocalTime := InterceptCreate(@Windows.GetLocalTime, @getTbtTime); dt := Now; // Returns error "Invalid date to Encodedate" s := FormatDateTime('mm/dd/yyyy : hh:nn:ss.zzz - ', dt); // showmessage('after hook:- ' + datetimetostr(dt)); end;
  18. I didn't fully go through their WiKi and examples before, but the "Hooking WinAPI function" example is exactly what I need. I've got the idea how it works now. Thank you ALL for helping out pointing me the right direction!
  19. I was planning to use the suggested DDetours library and since I didn't have it nor D11 in front of me I called it createNewDetour(). This is the actual function: function InterceptCreate(const TargetProc, InterceptProc: Pointer; const Param: Pointer = nil; const Options: TInterceptOptions = DefaultInterceptOptions): Pointer; overload; Calling reference of the original function will not work then. Thank you for the explanation of the internal DDetours implementation. If there is no other way than I'll look into modifying the PE imports table. That is something I never had to do. Hopefully it is easy.
  20. Great idea, thank you. I will save the original reference before the detour and use that from within. FYI, I'm going to rewrite the existing D7 implementation using the mentioned DDetour library and use same or built in D11 as well.
  21. before I start, how do I ensure that calling the original Windows.GetLocalTime from within my detoured function does not get also detoured causing circular reference errors? Or that will no longer possible? Example: procedure myNewLocalTime(var st: TSystemTime); begin st := Windows.GetLocalTime(st); // now further modify st end; createNewDetour(@Window.GetLocalTime, @myNewLocalTime, ...);
  22. Because our software needs to operate/tested through time from past to the future in cycles and we can't change the OS time as we did in past.
  23. Thanks for this suggestion too. GetLocalTime is just reference into external Windows DLL in Windows unit I think. I'll need to create a wrapper with same name around it with additional logic somewhere within my project which can be reached by the original GetLocalTime in sysUtils? Correction: it doesn't need to have same name. I could do something like: // excuse wrong code as I do not have D11 in front of me createNewDetour(@Window.GetLocalTime, @myNewLocalTime, ...); yes?
  24. If detours take care of this than that would be exactly what I need! I will attach detours in main's object constructor and test even 3rd party code goes through them. Thank you all for this suggestion!
×