Skip to content

Commit

Permalink
- initial release version 0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dspBlackT@gmail.com authored and dspBlackT@gmail.com committed Jul 19, 2010
0 parents commit 57dea97
Show file tree
Hide file tree
Showing 33 changed files with 7,414 additions and 0 deletions.
778 changes: 778 additions & 0 deletions BTMemoryModule/BTMemoryModule.pas

Large diffs are not rendered by default.

193 changes: 193 additions & 0 deletions BTMemoryModule/license.txt

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions DelphiDemo/DemoApp/DemoApp.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
program DemoApp;

{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Memory DLL loading code Demo Application *
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
* Copyright (c) 2005-2010 by Martin Offenwanger / coder@dsplayer.de *
* http://www.dsplayer.de *
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
* Mozilla Public License Version 1.1: *
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
* The contents of this file are used with permission, subject to the *
* Mozilla Public License Version 1.1 (the "License"); you may *
* not use this file except in compliance with the License. You may *
* obtain a copy of the License at *
* http://www.mozilla.org/MPL/MPL-1.1.html *
* +
* Software distributed under the License is distributed on an *
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or *
* implied. See the License for the specific language governing *
* rights and limitations under the License. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
{
@author(Martin Offenwanger: coder@dsplayer.de)
@created(Mar 20, 2005)
@lastmod(Jul 16, 2010)
@supported operationg systems(Windows 98 up to Windows 7)
@tested Delphi compilers(Delphi 7, Delphi 2007 , Delphi 2010)
}

uses
Forms,
Main in 'Main.pas' {Form1},
BTMemoryModule in '..\..\BTMemoryModule\BTMemoryModule.pas';

{$R *.res}

begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
36 changes: 36 additions & 0 deletions DelphiDemo/DemoApp/Main.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
object Form1: TForm1
Left = 373
Top = 231
Caption = 'MemoryModule Demo Application'
ClientHeight = 53
ClientWidth = 314
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object BtnFileCAll: TButton
Left = 24
Top = 16
Width = 121
Height = 25
Caption = 'file call'
TabOrder = 0
OnClick = BtnFileCAllClick
end
object BtnMemCall: TButton
Left = 168
Top = 16
Width = 129
Height = 25
Caption = 'memory call'
TabOrder = 1
OnClick = BtnMemCallClick
end
end
150 changes: 150 additions & 0 deletions DelphiDemo/DemoApp/Main.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
unit Main;

{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Memory DLL loading code Demo Application *
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
* Copyright (c) 2005-2010 by Martin Offenwanger / coder@dsplayer.de *
* http://www.dsplayer.de *
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
* Mozilla Public License Version 1.1: *
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
* The contents of this file are used with permission, subject to the *
* Mozilla Public License Version 1.1 (the "License"); you may *
* not use this file except in compliance with the License. You may *
* obtain a copy of the License at *
* http://www.mozilla.org/MPL/MPL-1.1.html *
* +
* Software distributed under the License is distributed on an *
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or *
* implied. See the License for the specific language governing *
* rights and limitations under the License. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
{
@author(Martin Offenwanger: coder@dsplayer.de)
@created(Mar 20, 2005)
@lastmod(Jul 16, 2010)
@supported operationg systems(Windows 98 up to Windows 7)
@tested Delphi compilers(Delphi 7, Delphi 2007 , Delphi 2010)
}

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BTMemoryModule, StdCtrls, xpman;

type
TTestCallstdA = procedure(f_Text: PAnsiChar); stdcall;
TTestCallstdW = procedure(f_Text: PWideChar); stdcall;
TTestCallcdelA = procedure(f_Text: PAnsiChar); cdecl;
TTestCallcdelW = procedure(f_Text: PWideChar); cdecl;

TForm1 = class(TForm)
BtnFileCAll: TButton;
BtnMemCall: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure BtnFileCAllClick(Sender: TObject);
procedure BtnMemCallClick(Sender: TObject);
private
m_TestCallstdA: TTestCallstdA;
m_TestCallstdW: TTestCallstdW;
m_TestCallcdelA: TTestCallcdelA;
m_TestCallcdelW: TTestCallcdelW;
mp_DllData: Pointer;
m_DllDataSize: Integer;
mp_MemoryModule: PBTMemoryModule;
m_DllHandle: Cardinal;
public
{ Public declarations }
end;

var
Form1: TForm1;


implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
MemoryStream: TMemoryStream;
begin
Position := poScreenCenter;
MemoryStream := TMemoryStream.Create;
MemoryStream.LoadFromFile('DemoDLL.dll');
MemoryStream.Position := 0;
m_DllDataSize := MemoryStream.Size;
mp_DllData := GetMemory(m_DllDataSize);
MemoryStream.Read(mp_DllData^, m_DllDataSize);
MemoryStream.Free;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeMemory(mp_DllData);
end;

procedure TForm1.BtnFileCAllClick(Sender: TObject);
begin
m_DllHandle := LoadLibrary('DemoDLL.dll');
try
if m_DllHandle = 0 then
Abort;
@m_TestCallstdA := GetProcAddress(m_DllHandle, 'TestCallstdA');
if @m_TestCallstdA = nil then
Abort;
@m_TestCallstdW := GetProcAddress(m_DllHandle, 'TestCallstdW');
if @m_TestCallstdW = nil then
Abort;
@m_TestCallcdelA := GetProcAddress(m_DllHandle, 'TestCallcdelA');
if @m_TestCallcdelA = nil then
Abort;
@m_TestCallcdelW := GetProcAddress(m_DllHandle, 'TestCallcdelW');
if @m_TestCallcdelW = nil then
Abort;
m_TestCallstdA('This is a Dll File call!');
m_TestCallstdW('This is a Dll File call!');
m_TestCallcdelA('This is a Dll File call!');
m_TestCallcdelW('This is a Dll File call!');
except
Showmessage('An error occoured while loading the dll');
end;
if m_DllHandle <> 0 then
FreeLibrary(m_DllHandle)
end;

procedure TForm1.BtnMemCallClick(Sender: TObject);
begin
mp_MemoryModule := BTMemoryLoadLibary(mp_DllData, m_DllDataSize);
try
if mp_MemoryModule = nil then
Abort;
@m_TestCallstdA := BTMemoryGetProcAddress(mp_MemoryModule, 'TestCallstdA');
if @m_TestCallstdA = nil then
Abort;
@m_TestCallstdW := BTMemoryGetProcAddress(mp_MemoryModule, 'TestCallstdW');
if @m_TestCallstdW = nil then
Abort;
@m_TestCallcdelA := BTMemoryGetProcAddress(mp_MemoryModule, 'TestCallcdelA');
if @m_TestCallcdelA = nil then
Abort;
@m_TestCallcdelW := BTMemoryGetProcAddress(mp_MemoryModule, 'TestCallcdelW');
if @m_TestCallcdelW = nil then
Abort;
m_TestCallstdA('This is a Dll Memory call!');
m_TestCallstdW('This is a Dll Memory call!');
m_TestCallcdelA('This is a Dll Memory call!');
m_TestCallcdelW('This is a Dll Memory call!');
except
Showmessage('An error occoured while loading the dll: ' +
BTMemoryGetLastError);
end;
if mp_MemoryModule <> nil then
BTMemoryFreeLibrary(mp_MemoryModule);
end;


end.

62 changes: 62 additions & 0 deletions DelphiDemo/DemoDll/DemoDLL.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
library DemoDLL;

{ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Memory DLL loading code Demo Dll *
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
* Copyright (c) 2005-2010 by Martin Offenwanger / coder@dsplayer.de *
* http://www.dsplayer.de *
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
* Mozilla Public License Version 1.1: *
*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
* The contents of this file are used with permission, subject to the *
* Mozilla Public License Version 1.1 (the "License"); you may *
* not use this file except in compliance with the License. You may *
* obtain a copy of the License at *
* http://www.mozilla.org/MPL/MPL-1.1.html *
* +
* Software distributed under the License is distributed on an *
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or *
* implied. See the License for the specific language governing *
* rights and limitations under the License. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * }
{
@author(Martin Offenwanger: coder@dsplayer.de)
@created(Mar 20, 2005)
@lastmod(Jul 16, 2010)
@supported operationg systems(Windows 98 up to Windows 7)
@tested Delphi compilers(Delphi 7, Delphi 2007 , Delphi 2010)
}

uses
windows;

procedure TestCallstdA(f_Text: PAnsiChar); stdcall;
begin
MessageBoxA(0, f_Text, 'Dll Dialog Ansi (stdcall)', 0);
end;

procedure TestCallstdW(f_Text: PWideChar); stdcall;
begin
MessageBoxW(0, f_Text, 'Dll Dialog Unicode (stdcall)', 0);
end;

procedure TestCallcdelA(f_Text: PAnsiChar); cdecl;
begin
MessageBoxA(0, f_Text, 'Dll Dialog Ansi (cdecl)', 0);
end;

procedure TestCallcdelW(f_Text: PWideChar); cdecl;
begin
MessageBoxW(0, f_Text, 'Dll Dialog Unicode (cdecl)', 0);
end;


exports
TestCallstdA,
TestCallstdW,
TestCallcdelA,
TestCallcdelW;

begin
end.

Binary file added LazarusDemo/DemoApp/BTMemoryModule.ppu
Binary file not shown.
5 changes: 5 additions & 0 deletions LazarusDemo/DemoApp/DemoApp.compiled
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<CONFIG>
<Compiler Value="c:\lazarus\fpc\2.2.4\bin\i386-win32\fpc.exe" Date="995711722"/>
<Params Value=" -MObjFPC -Scgi -O1 -Xs -WG -vewnhi -l -FiC:\development\lazarus32\BTMemoryModule_0.0.4\LazarusDemo\DemoApp\ -FuC:\development\lazarus32\BTMemoryModule\BTMemoryModule\ -Fuc:\lazarus\lcl\units\i386-win32\ -Fuc:\lazarus\lcl\units\i386-win32\win32\ -Fuc:\lazarus\packager\units\i386-win32\ -FuC:\development\lazarus32\BTMemoryModule_0.0.4\LazarusDemo\DemoApp\ -Fu. -FEC:\development\lazarus32\BTMemoryModule_0.0.4\LazarusDemo\DemoApp\ -oDemoApp.exe -dLCL -dLCLwin32 DemoApp.lpr"/>
</CONFIG>
Binary file added LazarusDemo/DemoApp/DemoApp.ico
Binary file not shown.
Loading

0 comments on commit 57dea97

Please sign in to comment.