Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/06/19 in all areas

  1. If you configure the Uses Clause Manager to use the map file to build the list of Project Units in a Windows 64-bit program then the list of Project Units does not contain the units from the map file: It contains only the list of units from the project file (.dpr). I have investigated the problem and found out that the compiler generates a different map file with 32-bit programs and with 64-bit programs respectively: • 32-bit programs: The ACBP alignment denomination is used • 64-bit programs: The ALIGN alignment denomination is used I will now fix this bug in GExperts and post a patch here.
  2. Remy Lebeau

    Shellexecute @ UBUNTU platform

    Why were you using ShellExecute() for that? You should have been using CreateProcess() instead. To detect when the process ends, use WaitForSingleObject() or related function on the returned process handle. On Linux, you can start an external process using the fork(), exec...(), or posix_spawn() functions. To detect when the process ends, use wait() on the returned process ID.
  3. Why are you using AnsiString at all? You should be using (Unicode)String instead, since that is what the TMemo expects. In any case, Char is WideChar in D2009+, so SizeOf(Char) is 2 not 1, so you are allocating memory for your AnsiString for only 1/2 of the file data, but then reading the full file into that memory. So you are going to corrupt surrounding memory. Use SizeOf(AnsiChar) instead, which is 1 so you can just drop the SizeOf() altogether. var LoadString: AnsiString; FS: TFileStream; begin FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone); try SetLength(LoadString, FS.Size); FS.ReadBuffer(Pointer(LoadString)^, FS.Size); finally FS.Free; end; Memo.Lines.Add(String(LoadString)); end; Alternatively, there are other options, such as TMemoryStream.LoadFromFile(): uses System.Classes; var LoadString: AnsiString; MS: TMemoryStream; begin MS := TMemoryStream.Create; try MS.LoadFromFile(FileName); SetString(LoadString, PAnsiChar(MS.Memory), MS.Size); finally MS.Free; end; Memo.Lines.Add(String(LoadString)); end; Or TStreamReader: uses System.Classes, System.SysUtils; var LoadString: String; Reader: TStreamReader; begin Reader := TStreamReader.Create(FileName, TEncoding.ANSI); try LoadString := Reader.ReadToEnd; finally Reader.Free; end; Memo.Lines.Add(LoadString); end; Or TFile.ReadAllText(): uses System.IOUtils, System.SysUtils; var LoadString: String; begin LoadString := TFile.ReadAllText(FileName, TEncoding.ANSI); Memo.Lines.Add(LoadString); end;
  4. Simple example on how to display, add graphics and manipulate JPEG, PNG and BMP images by pixels. http://foersom.org/SwDev/Delphi/ImagesGraphics.html
  5. Like this? var S: String; F: TFileStream; B: TBytes; begin S := ''; F := TFileStream.Create('test.txt', fmOpenRead); try if F.Size > 0 then begin SetLength(B, F.Size); F.Read(B[0], Length(B)); S := TEncoding.ANSI.GetString(B); WriteLn('S = ', S); end; finally F.Free; end; end;
  6. if FS.Size > 0 then FS.Read(LoadString[low(LoadString)], FS.Size);
  7. Dalija Prasnikar

    64bit testing hardware/emulation

    Play Store allows uploading separate APKs, but using AppBundle is easier.
  8. Uwe Raabe

    Deal - breaker: Registration Limit Increase

    I guess it is meant for different VMs using the same Windows license.
  9. Remy Lebeau

    Patch a private virtual method

    You can use Extended RTTI for that. TRttiMethod has a VirtualIndex property.
  10. David Heffernan

    Patch a private virtual method

    @Stefan Glienke Your code above (and in spring4d) uses WriteProcessMemory to modify executable pages. This relies on an undocumented implementation detail of WriteProcessMemory. Namely that it will handle the protection flags on your behalf. Personally I would prefer to use VirtualProtect with this sort of pattern: procedure PatchCode(Address: Pointer; const NewCode; Size: Integer); var OldProtect: DWORD; begin if not VirtualProtect(Address, Size, PAGE_EXECUTE_READWRITE, OldProtect) then begin Fail; end; Move(NewCode, Address^, Size); FlushInstructionCache(GetCurrentProcess, nil, 0); if not VirtualProtect(Address, Size, OldProtect, @OldProtect) then begin Fail; end; end;
  11. Stefan Glienke

    Patch a private virtual method

    {$APPTYPE CONSOLE} uses Windows; type TFoo = class procedure Bar; virtual; end; procedure TFoo.Bar; begin Writeln('broken'); end; procedure FixedBar(Self: TFoo); begin Writeln('fixed'); end; var f: TFoo; p: Pointer; n: UINT_PTR; begin {$POINTERMATH ON} p := @FixedBar; WriteProcessMemory(GetCurrentProcess, @PPointer(TFoo)[0], @p, SizeOf(Pointer), n); // 0 is the virtual index of the method to be replaced f := TFoo.Create; f.Bar; end. The virtual method index can also be found out programmatically.
  12. Marco Cantu

    Deal - breaker: Registration Limit Increase

    This is odd, because what you explain does not match the process that was discussed internally in the company. You should be able to contact your sales contact or partners and ask for an increase of the registration limits. The main difference from the past is this is not automatic, but requires talking with sales (we know, not always what developers love doing). We have given some automatic bumps in registration increases, others are generally provide by sales -- that is unless the numbers become suspiciously high. Feel free to email be directly, if this proves to be an issue -- I mean getting in touch with sales/reseller.
  13. PeterPanettone

    Uses Clause Manager in Tree in r2809

    MAD PEOPLE certainly should not participate in an IT forum. MAD PEOPLE should rather search for psychiatric help, maybe in a psychotherapeutic forum where they can criticize each other for writing too much.
×