From fdb75fa47dd72522b705e94be5a201c4e1a731cb Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 3 Oct 2007 12:43:01 +0000 Subject: New plugin SDK added Some more debug information for windows builds (Does this work in lazarus?) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@466 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPluginInterface.pas | 179 +++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 Game/Code/Classes/UPluginInterface.pas (limited to 'Game/Code/Classes/UPluginInterface.pas') diff --git a/Game/Code/Classes/UPluginInterface.pas b/Game/Code/Classes/UPluginInterface.pas new file mode 100644 index 00000000..6d17d51d --- /dev/null +++ b/Game/Code/Classes/UPluginInterface.pas @@ -0,0 +1,179 @@ +unit uPluginInterface; +{********************* + uPluginInterface + Unit fills a TPluginInterface Structur with Method Pointers + Unit Contains all Functions called directly by Plugins +*********************} + +interface +uses uPluginDefs; + +//--------------- +// Procedure that Sets the PluginInterface Record +//--------------- + Procedure Init_PluginInterface; + +//--------------- +// Methods for Plugin +//--------------- + {******** Hook specific Methods ********} + {Function Creates a new Hookable Event and Returns the Handle + or 0 on Failure. (Name already exists)} + Function CreateHookableEvent (EventName: PChar): THandle; stdcall; + + {Function Destroys an Event and Unhooks all Hooks to this Event. + 0 on success, not 0 on Failure} + Function DestroyHookableEvent (hEvent: THandle): integer; stdcall; + + {Function start calling the Hook Chain + 0 if Chain is called until the End, -1 if Event Handle is not valid + otherwise Return Value of the Hook that breaks the Chain} + Function NotivyEventHooks (hEvent: THandle; wParam, lParam: dWord): integer; stdcall; + + {Function Hooks an Event by Name. + Returns Hook Handle on Success, otherwise 0} + Function HookEvent (EventName: PChar; HookProc: TUS_Hook): THandle; stdcall; + + {Function Removes the Hook from the Chain + Returns 0 on Success} + Function UnHookEvent (hHook: THandle): Integer; stdcall; + + {Function Returns Non Zero if a Event with the given Name Exists, + otherwise 0} + Function EventExists (EventName: PChar): Integer; stdcall; + + {******** Service specific Methods ********} + {Function Creates a new Service and Returns the Services Handle + or 0 on Failure. (Name already exists)} + Function CreateService (ServiceName: PChar; ServiceProc: TUS_Service): THandle; stdcall; + + {Function Destroys a Service. + 0 on success, not 0 on Failure} + Function DestroyService (hService: THandle): integer; stdcall; + + {Function Calls a Services Proc + Returns Services Return Value or SERVICE_NOT_FOUND on Failure} + Function CallService (ServiceName: PChar; wParam, lParam: dWord): integer; stdcall; + + {Function Returns Non Zero if a Service with the given Name Exists, + otherwise 0} + Function ServiceExists (ServiceName: PChar): Integer; stdcall; + +var + PluginInterface: TUS_PluginInterface; + +implementation + +//--------------- +// Procedure that Sets the PluginInterface Record +//--------------- +Procedure Init_PluginInterface; +begin + PluginInterface.CreateHookableEvent := CreateHookableEvent; + PluginInterface.DestroyHookableEvent := DestroyHookableEvent; + PluginInterface.NotivyEventHooks := NotivyEventHooks; + PluginInterface.HookEvent := HookEvent; + PluginInterface.UnHookEvent := UnHookEvent; + PluginInterface.EventExists := EventExists; + + PluginInterface.CreateService := CreateService; + PluginInterface.DestroyService := DestroyService; + PluginInterface.CallService := CallService; + PluginInterface.ServiceExists := ServiceExists; +end; + + +{******** Hook specific Methods ********} +//--------------- +// Function Creates a new Hookable Event and Returns the Handle +// or 0 on Failure. (Name already exists) +//--------------- +Function CreateHookableEvent (EventName: PChar): THandle; stdcall; +begin + +end; + +//--------------- +// Function Destroys an Event and Unhooks all Hooks to this Event. +// 0 on success, not 0 on Failure +//--------------- +Function DestroyHookableEvent (hEvent: THandle): integer; stdcall; +begin + +end; + +//--------------- +// Function start calling the Hook Chain +// 0 if Chain is called until the End, -1 if Event Handle is not valid +// otherwise Return Value of the Hook that breaks the Chain +//--------------- +Function NotivyEventHooks (hEvent: THandle; wParam, lParam: dWord): integer; stdcall; +begin + +end; + +//--------------- +// Function Hooks an Event by Name. +// Returns Hook Handle on Success, otherwise 0 +//--------------- +Function HookEvent (EventName: PChar; HookProc: TUS_Hook): THandle; stdcall; +begin + +end; + +//--------------- +// Function Removes the Hook from the Chain +// Returns 0 on Success +//--------------- +Function UnHookEvent (hHook: THandle): Integer; stdcall; +begin + +end; + +//--------------- +// Function Returns Non Zero if a Event with the given Name Exists, +// otherwise 0 +//--------------- +Function EventExists (EventName: PChar): Integer; stdcall; +begin + +end; + + {******** Service specific Methods ********} +//--------------- +// Function Creates a new Service and Returns the Services Handle +// or 0 on Failure. (Name already exists) +//--------------- +Function CreateService (ServiceName: PChar; ServiceProc: TUS_Service): THandle; stdcall; +begin + +end; + +//--------------- +// Function Destroys a Service. +// 0 on success, not 0 on Failure +//--------------- +Function DestroyService (hService: THandle): integer; stdcall; +begin + +end; + +//--------------- +// Function Calls a Services Proc +// Returns Services Return Value or SERVICE_NOT_FOUND on Failure +//--------------- +Function CallService (ServiceName: PChar; wParam, lParam: dWord): integer; stdcall; +begin + +end; + +//--------------- +// Function Returns Non Zero if a Service with the given Name Exists, +// otherwise 0 +//--------------- +Function ServiceExists (ServiceName: PChar): Integer; stdcall; +begin + +end; + +end. -- cgit v1.2.3 From e270d3193a2a5b958e6416ce340246e790f7bd86 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 27 Oct 2007 09:10:29 +0000 Subject: Finished pluginloader, plugininterface Some fixes and error management (needs improvement) in Core and Service/Hook classes. "Clean Plugin Unloading on Error" finished Some debuging messages on startup. to Fix this remove old Plugins from Pluginfolder git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@535 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPluginInterface.pas | 48 ++++++++-------------------------- 1 file changed, 11 insertions(+), 37 deletions(-) (limited to 'Game/Code/Classes/UPluginInterface.pas') diff --git a/Game/Code/Classes/UPluginInterface.pas b/Game/Code/Classes/UPluginInterface.pas index 6d17d51d..a9cc7e46 100644 --- a/Game/Code/Classes/UPluginInterface.pas +++ b/Game/Code/Classes/UPluginInterface.pas @@ -8,11 +8,6 @@ unit uPluginInterface; interface uses uPluginDefs; -//--------------- -// Procedure that Sets the PluginInterface Record -//--------------- - Procedure Init_PluginInterface; - //--------------- // Methods for Plugin //--------------- @@ -59,29 +54,8 @@ uses uPluginDefs; otherwise 0} Function ServiceExists (ServiceName: PChar): Integer; stdcall; -var - PluginInterface: TUS_PluginInterface; - implementation - -//--------------- -// Procedure that Sets the PluginInterface Record -//--------------- -Procedure Init_PluginInterface; -begin - PluginInterface.CreateHookableEvent := CreateHookableEvent; - PluginInterface.DestroyHookableEvent := DestroyHookableEvent; - PluginInterface.NotivyEventHooks := NotivyEventHooks; - PluginInterface.HookEvent := HookEvent; - PluginInterface.UnHookEvent := UnHookEvent; - PluginInterface.EventExists := EventExists; - - PluginInterface.CreateService := CreateService; - PluginInterface.DestroyService := DestroyService; - PluginInterface.CallService := CallService; - PluginInterface.ServiceExists := ServiceExists; -end; - +uses UCore; {******** Hook specific Methods ********} //--------------- @@ -90,7 +64,7 @@ end; //--------------- Function CreateHookableEvent (EventName: PChar): THandle; stdcall; begin - + Result := Core.Hooks.AddEvent(EventName); end; //--------------- @@ -99,7 +73,7 @@ end; //--------------- Function DestroyHookableEvent (hEvent: THandle): integer; stdcall; begin - + Result := Core.Hooks.DelEvent(hEvent); end; //--------------- @@ -109,7 +83,7 @@ end; //--------------- Function NotivyEventHooks (hEvent: THandle; wParam, lParam: dWord): integer; stdcall; begin - + Result := Core.Hooks.CallEventChain(hEvent, wParam, lParam); end; //--------------- @@ -118,7 +92,7 @@ end; //--------------- Function HookEvent (EventName: PChar; HookProc: TUS_Hook): THandle; stdcall; begin - + Result := Core.Hooks.AddSubscriber(EventName, HookProc); end; //--------------- @@ -127,7 +101,7 @@ end; //--------------- Function UnHookEvent (hHook: THandle): Integer; stdcall; begin - + Result := Core.Hooks.DelSubscriber(hHook); end; //--------------- @@ -136,7 +110,7 @@ end; //--------------- Function EventExists (EventName: PChar): Integer; stdcall; begin - + Result := Core.Hooks.EventExists(EventName); end; {******** Service specific Methods ********} @@ -146,7 +120,7 @@ end; //--------------- Function CreateService (ServiceName: PChar; ServiceProc: TUS_Service): THandle; stdcall; begin - + Result := Core.Services.AddService(ServiceName, ServiceProc); end; //--------------- @@ -155,7 +129,7 @@ end; //--------------- Function DestroyService (hService: THandle): integer; stdcall; begin - + Result := Core.Services.DelService(hService); end; //--------------- @@ -164,7 +138,7 @@ end; //--------------- Function CallService (ServiceName: PChar; wParam, lParam: dWord): integer; stdcall; begin - + Result := Core.Services.CallService(ServiceName, wParam, lParam); end; //--------------- @@ -173,7 +147,7 @@ end; //--------------- Function ServiceExists (ServiceName: PChar): Integer; stdcall; begin - + Result := Core.Services.ServiceExists(ServiceName); end; end. -- cgit v1.2.3 From 391d30716d48dc709f6444b19c008e82311623b9 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 1 Nov 2007 19:34:40 +0000 Subject: Mac OS X version compiles and links. I hope I didn't break too many files on windows/linux. Added switches.inc to all files. Changed many IFDEFs. For Windows-only code please use MSWINDOWS instead of WIN32 now. WIN32 is also used by the Mac port. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@546 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPluginInterface.pas | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Game/Code/Classes/UPluginInterface.pas') diff --git a/Game/Code/Classes/UPluginInterface.pas b/Game/Code/Classes/UPluginInterface.pas index a9cc7e46..56293848 100644 --- a/Game/Code/Classes/UPluginInterface.pas +++ b/Game/Code/Classes/UPluginInterface.pas @@ -6,6 +6,9 @@ unit uPluginInterface; *********************} interface + +{$I switches.inc} + uses uPluginDefs; //--------------- -- cgit v1.2.3 From a1a9c43dcd6f61610eb3afea542aec5de5dabf30 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 6 Nov 2007 19:40:06 +0000 Subject: Some changes to PluginInterface to fit with 64 Bit Systems. lParam is maily for use as Pointer, therefore standardtype: Pointer. wParam should mainly be used for ordinals. (Integer or Int64 on 64Bit Systems). Don't return addresses. Result is not assured to be Int64 on 64 Bit Systems. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@592 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPluginInterface.pas | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Game/Code/Classes/UPluginInterface.pas') diff --git a/Game/Code/Classes/UPluginInterface.pas b/Game/Code/Classes/UPluginInterface.pas index 56293848..6a83d7c3 100644 --- a/Game/Code/Classes/UPluginInterface.pas +++ b/Game/Code/Classes/UPluginInterface.pas @@ -26,7 +26,7 @@ uses uPluginDefs; {Function start calling the Hook Chain 0 if Chain is called until the End, -1 if Event Handle is not valid otherwise Return Value of the Hook that breaks the Chain} - Function NotivyEventHooks (hEvent: THandle; wParam, lParam: dWord): integer; stdcall; + Function NotivyEventHooks (hEvent: THandle; wParam: TwParam; lParam: TlParam): integer; stdcall; {Function Hooks an Event by Name. Returns Hook Handle on Success, otherwise 0} @@ -51,7 +51,7 @@ uses uPluginDefs; {Function Calls a Services Proc Returns Services Return Value or SERVICE_NOT_FOUND on Failure} - Function CallService (ServiceName: PChar; wParam, lParam: dWord): integer; stdcall; + Function CallService (ServiceName: PChar; wParam: TwParam; lParam: TlParam): integer; stdcall; {Function Returns Non Zero if a Service with the given Name Exists, otherwise 0} @@ -84,7 +84,7 @@ end; // 0 if Chain is called until the End, -1 if Event Handle is not valid // otherwise Return Value of the Hook that breaks the Chain //--------------- -Function NotivyEventHooks (hEvent: THandle; wParam, lParam: dWord): integer; stdcall; +Function NotivyEventHooks (hEvent: THandle; wParam: TwParam; lParam: TlParam): integer; stdcall; begin Result := Core.Hooks.CallEventChain(hEvent, wParam, lParam); end; @@ -139,7 +139,7 @@ end; // Function Calls a Services Proc // Returns Services Return Value or SERVICE_NOT_FOUND on Failure //--------------- -Function CallService (ServiceName: PChar; wParam, lParam: dWord): integer; stdcall; +Function CallService (ServiceName: PChar; wParam: TwParam; lParam: TlParam): integer; stdcall; begin Result := Core.Services.CallService(ServiceName, wParam, lParam); end; -- cgit v1.2.3