EugeneK 23 Posted 13 hours ago I'm using DDetours to intercept Windows functions for unit testing purposes, but don't know how to intercept UuidCreate function because its declaration is hidden in implementation section of System.SysUtils unit. Is there a way to do it? Share this post Link to post
Remy Lebeau 1601 Posted 11 hours ago (edited) UuidCreate() is a Win32 API function, not a Delphi function. If you can't reach Delphi's declaration, then just make your own declaration in your own code. There is only one physical function to detour (residing in rpcrt4.dll), it doesn't matter how many declarations there are to reach it. Edited 11 hours ago by Remy Lebeau Share this post Link to post
Vincent Parrett 842 Posted 1 hour ago Intercepting functions for unit testing is a terrible idea. A better option would be to create abstractions and a concrete implementation (ie actually calls UuidCreate), that abstraction can be easily mocked using Delphi Mocks or Spring4D for uinit tests. The same applies to code that relies on things like Now or NowUTC - e.g - https://github.com/VSoftTechnologies/VSoft.System.TimeProvider Share this post Link to post
Artem Razin 12 Posted 21 minutes ago UuidCreate is exported from rpcrt4.dll: function UuidCreate(out guid: TGUID): Longint; stdcall; external 'rpcrt4.dll' name 'UuidCreate' delayed; However, for testing purposes, I would use a custom implementation that returns a predefined GUID. Share this post Link to post