Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Access Violation on calling ce.closeCE() from dll

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source -> Plugin development
View previous topic :: View next topic  
Author Message
redplug
How do I cheat?
Reputation: 0

Joined: 20 Jun 2012
Posts: 9

PostPosted: Thu Jun 21, 2012 5:27 am    Post subject: Access Violation on calling ce.closeCE() from dll Reply with quote

Hi,

I am writing a Plugin and want to close the CE Window if you close my created form. So i created an OnClose event.

But if i close the form i get an Access Violation error from CE.

Any idea why?

Code:
unit WoWBotFormUnit;

{$mode objfpc}{$H+}

interface

uses
  Windows, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
  StdCtrls, Grids, ExtCtrls, CEPluginSDK, WoWApi;

type

  { TWoWBotForm }

  TWoWBotForm = class(TForm)
    ButtonSend: TButton;
    ButtonHideCEMAinWindow: TButton;
    ButtonShowCEMainWindow: TButton;
    EditCommand: TEdit;
    MemoStatus: TMemo;
    procedure ButtonHideCEMAinWindowClick(Sender: TObject);
    procedure ButtonShowCEMainWindowClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
  private
    { private declarations }
  public
    { public declarations }
  end;


  function GetVersion(var PluginVersion: TPluginVersion; SizeOfPluginVersion: Integer): BOOL; stdcall;
  function InitializePlugin(ExportedFunctions: PExportedFunctions; PluginId: DWord): BOOL; stdcall;
  function DisablePlugin: BOOL; stdcall;


var
  CEExported: TExportedFunctions;
  WoWBotForm: TWoWBotForm;

implementation

{$R *.lfm}

{ TWoWBotForm }

procedure TWoWBotForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  CEExported.closeCE();
end;

procedure TWoWBotForm.ButtonShowCEMainWindowClick(Sender: TObject);
begin
  CEExported.unhideMainCEwindow();
end;

procedure TWoWBotForm.ButtonHideCEMAinWindowClick(Sender: TObject);
begin
  CEExported.hideAllCEWindows();
end;

function GetVersion(var PluginVersion: TPluginVersion; SizeOfPluginVersion: Integer): BOOL; stdcall;
begin
  Result := false;
  if SizeOfPluginVersion <> SizeOf(TPluginVersion) then exit;

  PluginVersion.version := 1;
  PluginVersion.pluginname := 'WoW Bot';


  Result := true;
end;


function InitializePlugin(ExportedFunctions: PExportedFunctions; PluginId: DWord): BOOL; stdcall;
begin
  Application.Initialize;
  CEExported := ExportedFunctions^;

  CEExported.hideAllCEWindows();

  WoWBotForm := TWoWBotForm.Create(Application);
  WoWBotForm.Show();
  Result := true;

end;

function DisablePlugin:BOOL; stdcall;
begin
  Result := true;
end;



end.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25252
Location: The netherlands

PostPosted: Thu Jun 21, 2012 6:59 am    Post subject: Reply with quote

Not sure, I think because your application.initialize is called inside the same thread as Cheat engine's gui thread

And when ce closes, it disables the plugins, so might be responsible for a crash as well (when it returns it has nothing to return to)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source -> Plugin development All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites