sp0987
Members-
Content Count
56 -
Joined
-
Last visited
Community Reputation
0 NeutralRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
Access Violation and Invalid Pointer exception while accessing files from web pages
sp0987 replied to sp0987's topic in Indy
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... -
Access Violation and Invalid Pointer exception while accessing files from web pages
sp0987 replied to sp0987's topic in Indy
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 -
Access Violation and Invalid Pointer exception while accessing files from web pages
sp0987 posted a topic in Indy
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 -
Unicode NBSP(u00A0) No-Break Space character for 64-bit
sp0987 replied to sp0987's topic in RTL and Delphi Object Pascal
Am sorry i didn't get you -
Unicode NBSP(u00A0) No-Break Space character for 64-bit
sp0987 replied to sp0987's topic in RTL and Delphi Object Pascal
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 -
Unicode NBSP(u00A0) No-Break Space character for 64-bit
sp0987 replied to sp0987's topic in RTL and Delphi Object Pascal
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. -
Unicode NBSP(u00A0) No-Break Space character for 64-bit
sp0987 replied to sp0987's topic in RTL and Delphi Object Pascal
It was just a part of json file, not the whole thing. -
Unicode NBSP(u00A0) No-Break Space character for 64-bit
sp0987 posted a topic in RTL and Delphi Object Pascal
Hi, I am trying to create a .JSON file in Delphi 11 64-bit. While writing sample data to .json file , the   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 -
Changes in System.sysutils.pas were not reflecting in other unit in Delphi 11
sp0987 replied to sp0987's topic in General Help
Much grateful for you response. It worked. The problem is with this LOC. Without stdcall it worked in D7. -
Changes in System.sysutils.pas were not reflecting in other unit in Delphi 11
sp0987 replied to sp0987's topic in General Help
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" -
Changes in System.sysutils.pas were not reflecting in other unit in Delphi 11
sp0987 replied to sp0987's topic in General Help
In the DecodeDateTime, we will not use that param. -
Changes in System.sysutils.pas were not reflecting in other unit in Delphi 11
sp0987 replied to sp0987's topic in General Help
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; -
Changes in System.sysutils.pas were not reflecting in other unit in Delphi 11
sp0987 replied to sp0987's topic in General Help
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! -
Changes in System.sysutils.pas were not reflecting in other unit in Delphi 11
sp0987 replied to sp0987's topic in General Help
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. -
Changes in System.sysutils.pas were not reflecting in other unit in Delphi 11
sp0987 replied to sp0987's topic in General Help
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.