Hi, DBUser! ^_^
Ok, I'm now completely lost... I got the V3 Template FINALLY to compile, however, I'm having 2 main problems with the DLL, once I call my function in DBPro...
I need to know how I should fix "START MY PLUGIN" in commands.rc , I need to know whether or not I should add "START MY PLUGIN" into main.cpp , and if so, how exactly should I go about adding "START MY PLUGIN" as a function in main.cpp. The other small problem I'm having, is that DBPro is crashing everytime I do 1 of 2 things..
1) I simply startup using my DBPro code like this:
sync on : sync rate 60 : hide mouse
start my plugin
do
sync
loop
OR
2) I use both commands like this:
sync on : sync rate 60 : hide mouse
start my plugin
MessageBox("Title", "Example")
do
sync
loop
Here are my Template codes:
main.cpp
// Include the header
#include "header.h"
// Include other headers here.
// Whatever code here.
// Display a simple messagebox. Notice DLLCMDC, this will export
// the function clearly. Using DLLCMD will export the function
// with a mangled name, then you would have to look through the
// DLL for the name. I don't find that at all useful. However, in
// some cases, as I have heard, it might be better to export the
// function using DLLCMD. However, there is no need for it here.
//DLLCMDC void startup(void);
DLLCMDC int getInteger(void)
{
return 42;
}
DLLCMDC void messageBox(LPSTR message, LPSTR title)
{
// Notice the "gCore->hWnd" part. This will retrieve the
// dbp window's HWND (An integer actually), and so the
// messagebox will belong to the main dbp program. However,
// the core pointer (gCore) must be retrieved before using
// it. You can, however, just use NULL where gCore->hWnd is.
// Anyways, the rest are the messages and titles, and then the
// Other setup which goes there. You can display a blank message
// -box too (I think) by just changing MB_OK to NULL. However,
// this has not been tested.
MessageBoxA(gCore->hWnd,message,title,MB_OK);
}
header.h
/*
There are several flags which can be defined to help the DBPPluginTemplate
best perform to your needs. They are listed and described below:
INCLUDE_DIRECTX - This will include d3d9.h, and d3dx9.h. This
will help you if you are doing some
Direct3D work.
NO_EXTRADX_FUNCTIONS - This will strip out an automatically created
Direct3D Object, and Direct3D Device, which
would be automatically set to DBP's D3D
object, and device.
NO_GLOBSTRUCT - This will keep GlobStruct from being
included. If GlobStruct isn't used, this
will help keep your output DLL small.
EXTRA_DBPDATA - This will include extra internal structures
of DBP, such as the sObject, sMesh, etc.
This is mainly for very special plugins
which deal with manipulation.
NO_EXTRA_DBPCOMMANDS - This will keep all DBP commands from being
able to be used in the plugin. There are a
series of other flags which will help you
keep certain
NO_HELPER_FUNCTIONS - This will keep functions such as dbpstring,
dbpfloat, GetGlobstruct, etc, out of the
plugin.
The following are alternatives to NO_EXTRA_DBPCOMMANDS:
EXCLUDE_ADVANCEDTERRAIN
EXCLUDE_ANIMATION
EXCLUDE_BASIC2D
EXCLUDE_BASIC3D
EXCLUDE_BITMAP
EXCLUDE_CAMERA
EXCLUDE_CORE
EXCLUDE_FILE
EXCLUDE_FTP
EXCLUDE_GAMEFX
EXCLUDE_IMAGE
EXCLUDE_INPUT
EXCLUDE_LIGHT
EXCLUDE_TERRAIN
EXCLUDE_MATRIX
EXCLUDE_MEMBLOCKS
EXCLUDE_MULTIPLAYER
EXCLUDE_MUSIC
EXCLUDE_PARTICLES
EXCLUDE_SETUP
EXCLUDE_SOUND
EXCLUDE_SPRITES
EXCLUDE_SYSTEM
EXCLUDE_TEXT
EXCLUDE_VECTORS
EXCLUDE_WORLD3D
*/
// Main Include
#include "DBPPlugin/DBPPluginTemplate.h"
// Your includes here
commands.rc
// Resource Script
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
//#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""rn"
""
END
3 TEXTINCLUDE
BEGIN
"rn"
""
END
#endif // APSTUDIO_INVOKED
#endif // English resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
// Your string table goes here.
// You must have at least ONE command for this to compile correctly.
// Here is an example:
/*
1 "STARTUP%0%StartupFunction" // void StartupFunction(void);
2 "GETVALUE[%L%GetValueFunction" // int GetValueFunction(void);
3 "GETSUM[%LLL%GetSumFunction" // int GetSumFunction(int p0, int p1);
*/
// 1 "START MY PLUGIN%0%startup" // *void*
// 1 "STARTUP%0%StartupFunction" // void StartupFunction(void);
// 2 "GETVALUE[%L%GetValueFunction" // int GetValueFunction(void);
// 3 "GETSUM[%LLL%GetSumFunction" // int GetSumFunction(int p0, int p1);
1 "MESSAGEBOX%LL%MessageBoxA" // string MessageBoxFunction(string message$, string title$)
// Extra information about the string tables, for quick lookup.
/* L = Integer ( IN use "int" ) ( OUT use "int" )
F = Float ( IN use "float" ) ( OUT use "DWORD" )
S = String ( IN use "LPSTR" ) ( OUT use "DWORD" )
O = Double Float (capital o) ( IN use "double" ) ( OUT use "double" )
R = Double Integer (capital r) ( IN use "LONGLONG" ) ( OUT use "LONGLONG" )
D = Boolean, BYTE, WORD and DWORD ( IN use "DWORD" ) ( OUT use "DWORD" )
0 = Zero Character (no param) ( IN use "VOID" ) ( n/a )
H = Array ( IN use ? ) ( OUT use ? )
X = Any type ( IN use "const void*" ) ( OUT use "const void*" )
A = Special List Processing ( IN use ? ) ( OUT use ? )
* = Designate a return type */
END
#endif // English resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
DBPPluginTemplate.h
/******************************************************************************
>-- The Dev-C++ DBPro Plugin Template (version 3) --<
Created by Aaron J. Miller, Copyright AEX.UNI Software 2007.
This library is distributes in the hopes that it will be found useful to any
individual or group, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For use with Dev-C++ only. Tested on Dev-C++ version 4.9.8.0
******************************************************************************/
// Special thanks to IanM, Three Score, and TKF15H.
/* Required Includes */
#include <windows.h>
#ifdef INCLUDE_DIRECTX
// Include DirectX 9.0c if it is wanted.
#include <d3d9.h>
#include <d3dx9.h>
// Check if the user doesn't want the extra functions.
#ifndef NO_EXTRADX_FUNCTIONS
// The user is assumed to want the extra functions/variables.
IDirect3D9* g_pDirect3D; // The Direct3D Object
IDirect3DDevice9* g_pDirect3DDevice; // The Direct3D Device
#endif
#endif
/* Required Local Includes */
// Check to see if globstruct isn't required.
#ifndef NO_GLOBSTRUCT
// The user is assumed to want GlobStruct.
#include "DBPGlobStruct.h"
// Global variable
GlobStruct* gCore;
#endif
// Check to see if any extra DBP data is wanted.
#ifdef EXTRA_DBPDATA
// Extra DBP Data IS wanted, but we must make sure it can be used...
#ifdef INCLUDE_DIRECTX
// DirectX IS included, we can use the extra data.
#include "DBPExtraData.h"
#endif
#endif
// Check to see if the DBP commands aren't wanted.
#ifndef NO_EXTRA_DBPCOMMANDS
// It is assumed that the extra commands are wanted.
#include "DBPCommands.h"
#else
#ifdef INCLUDE_DIRECTX
#ifndef NO_EXTRADX_FUNCTIONS
// Direct3D Object Function = ?GetDirect3D@@YAPAUIDirect3D9@@XZ
// Direct3D Device Function = ?GetDirect3DDevice@@YAPAUIDirect3DDevice9@@XZ
typedef IDirect3D9* (__stdcall *tGetDirect3D)(void);
typedef IDirect3DDevice9* (__stdcall *tGetDirect3DDevice)(void);
tGetDirect3D dbGetDirect3D;
tGetDirect3DDevice dbGetDirect3DDevice;
#else
void* dbGetDirect3D(void) { return NULL; }
void* dbGetDirect3DDevice9(void) { return NULL; }
#endif
#endif
// To help with commands control
bool g_bDBPInterfaceCommandsActivated=false;
// Allow control over all the commands
inline void ControlCommands(void)
{
// Check if the interface commands have been activated or not
if (g_bDBPInterfaceCommandsActivated==false)
{
g_bDBPInterfaceCommandsActivated=true;
// Check the required needs of DirectX
#ifdef INCLUDE_DIRECTX
// Load up the dll containing the object and device information
HINSTANCE hInstance = LoadLibrary("DBProSetupDebug.dll");
if (hInstance)
{
// Activate the functions
dbGetDirect3D = (tGetDirect3D)GetProcAddress(hInstance,"?GetDirect3D@@YAPAUIDirect3D9@@XZ");
dbGetDirect3DDevice = (tGetDirect3DDevice)GetProcAddress(hInstance,"?GetDirect3DDevice@@YAPAUIDirect3DDevice9@@XZ");
}
// Safely release the dll
FreeLibrary(hInstance);
hInstance=NULL;
#ifndef NO_EXTRADX_FUNCTIONS
// Retrieve the object and device automatically
g_pDirect3D = dbGetDirect3D();
g_pDirect3DDevice = dbGetDirect3DDevice();
#endif
#endif
}
}
#endif
// Check to see if the helper functions aren't wanted.
#ifndef NO_HELPER_FUNCTIONS
// It is assumed that the helper functions are wanted.
#include "DBPPluginHelp.h"
#endif
/* Defines for the dll */
#define DLLCMD __declspec(dllexport)
#define DLLCMDC extern "C" __declspec(dllexport)
// Help out for functions
#define StartFunction ControlCommands();
// End of File
and FINALLY, I've added a few lines, and commented a few lines that you'll probably recognize right off the bat. Anyways, here's my included DBPGlobStruct file:
DBPGlobStruct.h
//
// Global Structure (data shared by DLLs)
//
// Upgrade 6.0
// Requirement of VS2005
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#pragma warning(disable : 4996)
// glob struct
#ifndef _GLOBSTRUCT_H_
#define _GLOBSTRUCT_H_
// Header to support texture ptr
//#include "dxdiag.h"
/* #define INITGUID
#include <dxdiag.h>
#undef INITGUID*/
//#include "D3dx9tex.h"
#define LPDIRECT3DTEXTURE9 void*
#define LPDIRECT3DSURFACE9 void*
//
// Typdefs shared by all DLLs
//
#define DBPRO_COMPILE 1
typedef void ( *PTR_FuncCreateStr ) ( DWORD*, DWORD );
typedef DWORD ( *PTR_ProcessMessages ) ( void );
typedef void ( *PTR_PrintString ) ( LPSTR, bool );
typedef void ( *PTR_VOID ) ( void );
typedef void ( *PTR_DWORD ) ( DWORD );
//
// Struct Defines
//
struct GlobChecklistStruct
{
DWORD dwStringSize;
LPSTR string;
int valuea;
int valueb;
int valuec;
int valued;
float fvaluea;
float fvalueb;
float fvaluec;
float fvalued;
};
struct GlobStruct
{
// Function Ptrs (for remote DLLs)
PTR_FuncCreateStr CreateDeleteString;
PTR_ProcessMessages ProcessMessageFunction;
PTR_PrintString PrintStringFunction;
PTR_DWORD UpdateFilenameFromVirtualTable;
PTR_DWORD Decrypt;
PTR_DWORD Encrypt;
PTR_DWORD ChangeMouseFunction;
PTR_DWORD SpareFunction1;
PTR_VOID SpareFunction2;
PTR_VOID SpareFunction3;
// LEEMOD - 130604 - Access to ALL VARIABLES MEMORY
LPVOID g_pVariableSpace;
// LEEMOD - 150803 - Replace 'SpareFunction5' with 'g_pErrorHandler'
LPVOID g_pErrorHandlerRef;
// DLL Handles and Active Flags
HINSTANCE g_GFX ;
HINSTANCE g_Text ;
HINSTANCE g_Basic2D ;
HINSTANCE g_Sprites ;
HINSTANCE g_Image ;
HINSTANCE g_Input ;
HINSTANCE g_System ;
HINSTANCE g_File ;
HINSTANCE g_FTP ;
HINSTANCE g_Memblocks ;
HINSTANCE g_Bitmap ;
HINSTANCE g_Animation ;
HINSTANCE g_Multiplayer ;
HINSTANCE g_Basic3D ;
HINSTANCE g_Camera3D ;
HINSTANCE g_Matrix3D ;
HINSTANCE g_Light3D ;
HINSTANCE g_World3D ;
HINSTANCE g_Particles ;
HINSTANCE g_PrimObject ;
HINSTANCE g_Vectors ;
HINSTANCE g_XObject ;
HINSTANCE g_3DSObject ;
HINSTANCE g_MDLObject ;
HINSTANCE g_MD2Object ;
HINSTANCE g_MD3Object ;
HINSTANCE g_Sound ;
HINSTANCE g_Music ;
HINSTANCE g_LODTerrain ;
HINSTANCE g_Q2BSP ;
HINSTANCE g_OwnBSP ;
HINSTANCE g_BSPCompiler ;
HINSTANCE g_CSG ;
HINSTANCE g_igLoader ;
HINSTANCE g_GameFX ;
HINSTANCE g_Spare03 ;
HINSTANCE g_Spare04 ;
HINSTANCE g_Spare05 ;
HINSTANCE g_Spare06 ;
HINSTANCE g_Spare07 ;
HINSTANCE g_Spare08 ;
HINSTANCE g_Spare09 ;
HINSTANCE g_Spare10 ;
HINSTANCE g_Spare11 ;
HINSTANCE g_Spare12 ;
HINSTANCE g_Spare13 ;
HINSTANCE g_Spare14 ;
HINSTANCE g_Spare15 ;
HINSTANCE g_Spare16 ;
HINSTANCE g_Spare17 ;
HINSTANCE g_Spare18 ;
HINSTANCE g_Spare19 ;
HINSTANCE g_Spare20 ;
bool g_GFXmade ;
bool g_Textmade ;
bool g_Basic2Dmade ;
bool g_Spritesmade ;
bool g_Imagemade ;
bool g_Inputmade ;
bool g_Systemmade ;
bool g_Filemade ;
bool g_FTPmade ;
bool g_Memblocksmade ;
bool g_Bitmapmade ;
bool g_Animationmade ;
bool g_Multiplayermade ;
bool g_Basic3Dmade ;
bool g_Camera3Dmade ;
bool g_Matrix3Dmade ;
bool g_Light3Dmade ;
bool g_World3Dmade ;
bool g_Particlesmade ;
bool g_PrimObjectmade ;
bool g_Vectorsmade ;
bool g_XObjectmade ;
bool g_3DSObjectmade ;
bool g_MDLObjectmade ;
bool g_MD2Objectmade ;
bool g_MD3Objectmade ;
bool g_Soundmade ;
bool g_Musicmade ;
bool g_LODTerrainmade ;
bool g_Q2BSPmade ;
bool g_OwnBSPmade ;
bool g_BSPCompilermade ;
bool g_CSGmade ;
bool g_igLoadermade ;
bool g_GameFXmade ;
bool g_Spare03made ;
bool g_Spare04made ;
bool g_Spare05made ;
bool g_Spare06made ;
bool g_Spare07made ;
bool g_Spare08made ;
bool g_Spare09made ;
bool g_Spare10made ;
bool g_Spare11made ;
bool g_Spare12made ;
bool g_Spare13made ;
bool g_Spare14made ;
bool g_Spare15made ;
bool g_Spare16made ;
bool g_Spare17made ;
bool g_Spare18made ;
bool g_Spare19made ;
bool g_Spare20made ;
// Executable Media Handling Data
char pEXEUnpackDirectory[_MAX_PATH];
DWORD dwEncryptionUniqueKey;
DWORD ppEXEAbsFilename;
// LEEMOD - 200105 - Replace 'dwEMHDSpare2' with 'dwInternalFunctionCode'
DWORD dwInternalFunctionCode;
DWORD dwEMHDSpare3;
DWORD dwEMHDSpare4;
DWORD dwEMHDSpare5;
// Windows General Data
HWND hWnd;
HINSTANCE hInstance;
LPSTR pWindowsTextEntry;
bool bInvalidFlag;
int dwWindowWidth;
int dwWindowHeight;
HICON hAppIcon;
DWORD dwAppDisplayModeUsing;
DWORD dwWindowX;
DWORD dwWindowY;
HWND hwndIGLoader; // lee - 080306 - igLoader HWND filled if found
DWORD dwWGDSpare2;
DWORD dwWGDSpare3;
DWORD dwWGDSpare4;
DWORD dwWGDSpare5;
// Windows Mouse Data
bool bWindowsMouseVisible;
int iWindowsMouseX;
int iWindowsMouseY;
int iWindowsMouseClick;
DWORD dwWMDSpare2;
DWORD dwWMDSpare3;
DWORD dwWMDSpare4;
DWORD dwWMDSpare5;
// Main Screen Data (backbuffer)
int iScreenWidth;
int iScreenHeight;
int iScreenDepth;
DWORD iNoDrawLeft;
DWORD iNoDrawTop;
DWORD iNoDrawRight;
DWORD iNoDrawBottom;
DWORD dwSafeRectMax;
RECT* pSafeRects;
DWORD dwMSDSpare3;
DWORD dwMSDSpare4;
DWORD dwMSDSpare5;
// Bitmap and Surface Data (for drawing offscreen)
int iCurrentBitmapNumber;
LPDIRECT3DTEXTURE9 pCurrentBitmapTexture;
LPDIRECT3DSURFACE9 pCurrentBitmapSurface;
LPDIRECT3DSURFACE9 pHoldBackBufferPtr;
LPDIRECT3DSURFACE9 pHoldDepthBufferPtr;
DWORD dwBSDSpare1;
DWORD dwBSDSpare2;
DWORD dwBSDSpare3;
DWORD dwBSDSpare4;
DWORD dwBSDSpare5;
// Drawing Data
int iCursorX;
int iCursorY;
DWORD dwForeColor;
DWORD dwBackColor;
DWORD dwRenderCameraID;
float fReflectionPlaneX;
float fReflectionPlaneY;
float fReflectionPlaneZ;
DWORD dwCurrentSetCameraID; // MIKE - DARKSDK - 2011094
LPSTR lpDirectXVersionString; // LEE - DX checking - 080306 - u60
DWORD dw3DBackColor; // LEE - 310306 - u6rc4 - community 3dbackdrop col
DWORD dwDDSpare4;
DWORD dwDDSpare5;
// Checklist Data
bool checklistexists;
bool checklisthasvalues;
bool checklisthasstrings;
int checklistqty;
DWORD dwChecklistArraySize;
GlobChecklistStruct* checklist;
// Dependent 3D Data Exchange
int iFogState;
DWORD dwRedrawPhase;
DWORD dwRedrawCount;
DWORD dwStencilMode;
DWORD dwStencilShadowCount;
DWORD dwStencilReflectionCount;
DWORD dwNumberOfPolygonsDrawn;
DWORD dwNumberOfPrimCalls;
DWORD dwStencilSpare3;
DWORD dwStencilSpare4;
DWORD dwStencilSpare5;
// System States and Global Controls
bool bEscapeKeyEnabled;
bool bSystemKeyEnabled;
bool bSpareBool1;
bool bSpareBool2;
bool bSpareBool3;
bool bSpareBool4;
bool bSpareBool5;
bool bSpareBool6;
bool bSpareBool7;
bool bSpareBool8;
bool bSpareBool9;
LPSTR pExitPromptString;
LPSTR pExitPromptString2;
int iSoftwareVP;
// Dynamic Memory Area for future expansion
DWORD dwDynMemSize;
LPSTR pDynMemPtr;
};
//
// External Reference to Glob Pointer
//
//extern GlobStruct* g_pGlob;
//
// Functions shared by all DLLs to act on Shared Core Data
//
//extern void GlobExpandChecklist( DWORD iIndex, DWORD dwImminentStringSize );
/////////////////////////////////////////////////////////////////////////////////
#endif
ANY help would be GREATLY appreciated
Thanks again, DB! ^_^
~M.W~