Patch routine call in delphi

I use the following code: procedure PatchCode(Address: Pointer; const NewCode; Size: Integer); var OldProtect: DWORD; begin if VirtualProtect(Address, Size, PAGE_EXECUTE_READWRITE, OldProtect) then begin Move(NewCode, Address^, Size); FlushInstructionCache(GetCurrentProcess, Address, Size); VirtualProtect(Address, Size, OldProtect, @OldProtect); end; end; type PInstruction = ^TInstruction; TInstruction = packed record Opcode: Byte; Offset: Integer; end; procedure RedirectProcedure(OldAddress, NewAddress: Pointer); var NewCode: TInstruction; … Read more

Accessing protected event of TWinControl

You don’t need RTTI. Any code has implicit access to the protected members of any class declared in the same unit. You can take advantage of this by declaring a new TWinControl descendant in the unit that needs access to that class’s members. The declaration is very simple: type TProtectedWinControl = class(TWinControl); Then type-cast any … Read more

WWW server reports error after POST Request by Internet Direct components in Delphi

I’m very sure that I’m POSTing the right data Since it does not work – obviously you do not (or Delphi does not – that makes no difference for server). You should start usual debugging loop: Observe reference working behaviour. Observe your program behavior Spot the difference Eliminate the difference Check if the program works … Read more

My program never releases the memory back. Why?

Task Manager is not the right tool to detect memory leaks. Delphi allocates large blocks of memory and keeps them later for future use, so certain increase in allocated memory is expected even after you release all resources. Any other results (and more detailed answers) can be obtained only by using specialize memory analysis tools. … Read more

How can I display Crystal XI reports inside a Delphi 2007 application?

This is the solution I’ve found, using ActiveX: First, register the Active X control like this: In Delphi, choose Component -> Import Component Click on “Type Library”, click Next Choose “Crystal ActiveX Report Viewer Library 11.5” Pick whatever Palette Page you want (I went with “Data Access”) Choose an import location Exit out of the … Read more