Einzelnen Beitrag anzeigen

napsterxx

Registriert seit: 18. Mär 2007
Ort: Borland
556 Beiträge
 
Delphi 7 Enterprise
 
#22

Re: C++ Plugin-Code in Delphi (DLL)

  Alt 26. Okt 2008, 10:48
Genau, ein eigenes Plugin welches richtig erkannt werden soll.

Der C++ Wrapper Quelltext:
Delphi-Quellcode:
#ifndef _GARENA_H_
#define _GARENA_H_

#pragma comment(lib, "Garena.lib")

struct ExportUserInfo_t
{
    int Id;              /* user id */
    WCHAR Name[16];      /* user name */
    WCHAR Password[50];  /* user hashed password */
}
;

struct ExportRoomInfo_t
{
    int GameId;  /* game type id */
    int RoomId;  /* room id */
    int AreaId;  /* area id */
}
;

struct RoomMsg_t
{
    int FromId;    /* id of user who sent the message */
    WCHAR * pMsg;  /* message string */
}
;

struct PrivateChat_t
{
    CHARFORMAT cf;  /* defined in richedit.h. Display format in RichEdit,
                      check MSDN for details */
    int FromId;    /* id of user who sent the message */
    WCHAR * pMsg;  /* message string */
}
;

/* for CanAccess() */
#define ROOM_ANNOUNCEMENT_BROADCAST 0x2
#define ADMIN_UNBAN_ID 0x4
#define KICK_USER_FROM_ROOM 0x8
#define BAN_ROOM_CHAT 0x1000
#define ADD_CHANNEL_ADMIN 0x2000
#define BAN_ID_PERMANENT 0x4000
#define SYSTEM_BROADCAST 0x8000

/* for GetRoomType() */
#define ROOMTYPE_PUBLIC 1
#define ROOMTYPE_LADDER 2
#define ROOMTYPE_LEAGUE 4

#ifdef __cplusplus
extern "C"
{
#endif
void WINAPI RegisterUIEvent(const wchar_t *szEvent, LPTHREAD_START_ROUTINE pProc);
void WINAPI CurrentRoomDisplaySystemInfo(const wchar_t * pMsg);
bool WINAPI GetGamePathByGameId(int gameId, wchar_t * szPath, wchar_t * szParam);
HWND WINAPI GetWnd(const char * szName);
bool WINAPI CanAccess(int nRight);
bool WINAPI GetMyInfo(ExportUserInfo_t *pInfo);
bool WINAPI GetCurrentRoomInfo(ExportRoomInfo_t * pInfo);
bool WINAPI SendToUser(int nToUserId, const char * pData, int nLen);
bool WINAPI NotifyTrayMsg(const wchar_t * szName);
#ifdef __cplusplus
}
;
#endif

#endif // _GARENA_H_

Hier der "automatisch" übersetzte Code in Delphi (viele Fehler):
Delphi-Quellcode:
unit Garena_h;

interface

uses   Windows, Messages, SysUtils, Classes;


#ifndef _GARENA_H_
const _GARENA_H_ =;

//pragma comment(lib, 'Garena.lib')

struct ExportUserInfo_t
begin
    integer Id; (* user id *)
     Name: array[0..16-1] of WCHAR; (* user name *)
     Password: array[0..50-1] of WCHAR; (* user hashed password *)
);

struct ExportRoomInfo_t
begin
    integer GameId; (* game type id *)
    integer RoomId; (* room id *)
    integer AreaId; (* area id *)
);

struct RoomMsg_t
begin
    integer FromId; (* id of user who sent the message *)
    WCHAR * pMsg; (* message string *)
);

struct PrivateChat_t
begin
    CHARFORMAT cf; (* defined in richedit.h. Display format in RichEdit,
                       check MSDN for details *)

    integer FromId; (* id of user who sent the message *)
    WCHAR * pMsg; (* message string *)
);

(* for CanAccess() *)
const ROOM_ANNOUNCEMENT_BROADCAST = $2;
const ADMIN_UNBAN_ID = $4;
const KICK_USER_FROM_ROOM = $8;
const BAN_ROOM_CHAT = $1000;
const ADD_CHANNEL_ADMIN = $2000;
const BAN_ID_PERMANENT = $4000;
const SYSTEM_BROADCAST = $8000;

(* for GetRoomType() *)
const ROOMTYPE_PUBLIC = 1;
const ROOMTYPE_LADDER = 2;
const ROOMTYPE_LEAGUE = 4;

#ifdef __cplusplus
 'C'
begin
//endif
procedure WINAPI RegisterUIEvent(szEvent: PChar; pProc: LPTHREAD_START_ROUTINE);
procedure WINAPI CurrentRoomDisplaySystemInfo(pMsg: PChar);
function WINAPI GetGamePathByGameId(gameId: integer; szPath: PChar; szParam: PChar): bool;
function WINAPI GetWnd(szName: PChar): HWND;
function WINAPI CanAccess(nRight: integer): bool;
function WINAPI GetMyInfo(var pInfo: ExportUserInfo_t): bool;
function WINAPI GetCurrentRoomInfo(var pInfo: ExportRoomInfo_t): bool;
function WINAPI SendToUser(nToUserId: integer; pData: PChar; nLen: integer): bool;
function WINAPI NotifyTrayMsg(szName: PChar): bool;
#ifdef __cplusplus
);
//endif

//endif // _GARENA_H_

implementation


end.
Soweit ich jetzt alles verstanden habe ist dieser Wrapper eigentlich überflüssig, denn man braucht nur dein Einsprungspunkt für die Funktionen. Diese Adresse kann man doch über GetProcAddress herrausfinden und dann da wir die Parameter und alles kennen können wir die Funktion aufrufen? Wobei ich nicht erkennen kann wo diese Funktionen stehen sollen (ich nehme an in der Garena.exe). Außerdem was für Klassen??
Du derefernzierst p2 einmal und weißt die Adresse von i zu. Das heißt p2 (also der Zeiger auf einen Zeiger) zeigt auf den Zeiger p1 welchen du so auf i zeigen lässt.
  Mit Zitat antworten Zitat