www.pudn.com > Client599.rar > NPGameDLL.pas


unit NPGAMEDLL; 
{**************************************************************************} 
{                                                                          } 
{    This C DLL header file first (automatic) conversion generated by:     } 
{    HeadConv 4.0 (c) 2000 by Bob Swart (aka Dr.Bob - www.drbob42.com)     } 
{      Final Delphi-Jedi (Darth) command-line units edition                } 
{                                                                          } 
{    Generated Date: 2005-10-13                                            } 
{    Generated Time: ¿ÀÈÄ 2:55:02                                              } 
{                                                                          } 
{**************************************************************************} 
 
interface 
uses 
{$IFDEF WIN32} 
  Windows; 
{$ELSE} 
  Wintypes, WinProcs; 
{$ENDIF} 
 
 
{///============================================================================= } 
{/// File : NPGameDLL.pas } 
{/// Use : Handle Communication between Game and GameMon } 
{/// Author : Kim Chan Ho (chkim@inca.co.kr) } 
{/// Date : 2005/10/13 } 
{/// Modify : } 
{///============================================================================= } 
 
{/// Callback Message } 
const 
  NPGAMEMON_UNDEFINED = 1000; {// Undefined message} 
const 
  NPGAMEMON_COMM_ERROR = 1001; {// Communication error} 
const 
  NPGAMEMON_COMM_CLOSE = 1002; {// Communication closing} 
 
const 
  NPGAMEMON_SPEEDHACK = 1011; {// SpeedHack detected} 
const 
  NPGAMEMON_GAMEHACK_KILLED = 1012; {// GameHack killed} 
const 
  NPGAMEMON_GAMEHACK_DETECT = 1013; {// GameHack detected} 
const 
  NPGAMEMON_INIT_ERROR = 1014; {// GameMon Init Error} 
const 
  NPGAMEMON_GAMEHACK_DOUBT = 1015; {// GameHack doubt} 
const 
  NPGAMEMON_CHECK_CSAUTH = 1016; {// CSAuth} 
const 
  NPGAMEMON_CHECK_CSAUTH2 = 1017; {// CSAuth2} 
 
{/// Error Code 110 - 300 } 
const 
  NPGAMEMON_ERROR_EXIST = 110; {// GameMon Already Exist} 
const 
  NPGAMEMON_ERROR_CREATE = 111; {// GameGuard Directory Create Error} 
const 
  NPGAMEMON_ERROR_NPSCAN = 112; {// npscan.des Error} 
const 
  NPGAMEMON_ERROR_THREAD = 113; {// CreateThread Error} 
const 
  NPGAMEMON_ERROR_INIT = 114; {// GameMon Initialize Error} 
const 
  NPGAMEMON_ERROR_GAME_EXIST = 115; {// Game Instance Already Exist} 
const 
  NPGAMEMON_ERROR_AUTH_INI = 120; {// .ini Authentication Fail} 
const 
  NPGAMEMON_ERROR_AUTH_NPGMUP = 121; {// npgmup.des Authentication Fail} 
const 
  NPGAMEMON_ERROR_AUTH_GAMEMON = 122; {// GameMon.des Authentication Fail} 
const 
  NPGAMEMON_ERROR_AUTH_NEWUP = 123; {// npgmup.des.new Auth Fail} 
const 
  NPGAMEMON_ERROR_AUTH_GAMEGUARD = 124; {// GameGuard.des Authentication Fail} 
const 
  NPGAMEMON_ERROR_AUTH_DLL = 125; {// NPGameDLL.dll Authentication Fail} 
const 
  NPGAMEMON_ERROR_DECRYPT = 130; {// .ini File Decryption Fail} 
const 
  NPGAMEMON_ERROR_CORRUPT_INI = 141; {// Corrupt ini file Error} 
const 
  NPGAMEMON_ERROR_CORRUPT_INI2 = 142; {// Not match GameName in ini file Error} 
const 
  NPGAMEMON_ERROR_NFOUND_INI = 150; {// ini File not Found} 
const 
  NPGAMEMON_ERROR_NFOUND_NPGMUP = 151; {// npgmup.des not found} 
const 
  NPGAMEMON_ERROR_NFOUND_NEWUP = 152; {// npgmup.des.new not found} 
const 
  NPGAMEMON_ERROR_NFOUND_GG = 153; {// GameGuard.des not found} 
const 
  NPGAMEMON_ERROR_NFOUND_GM = 154; {// GameMon.des not found} 
const 
  NPGAMEMON_ERROR_CRYPTOAPI = 155; {// rsabase.dll is corrupted} 
const 
  NPGAMEMON_ERROR_COMM = 160; {// Communication Init Error} 
const 
  NPGAMEMON_ERROR_EXECUTE = 170; {// GameMon Execute Error} 
const 
  NPGAMEMON_ERROR_EVENT = 171; {// GameMon Event Create Error} 
const 
  NPGAMEMON_ERROR_NPGMUP = 180; {// npgmup.dll Error} 
const 
  NPGAMEMON_ERROR_MOVE_INI = 191; {// Move ini Error} 
const 
  NPGAMEMON_ERROR_MOVE_NEWUP = 192; {// Move npgmup.des.new Error} 
 
const 
  NPGAMEMON_ERROR_ILLEGAL_PRG = 200; {// Detected a illegal program} 
 
const 
  NPGAMEMON_ERROR_GAMEMON = 210; {// GameMon Init Error} 
const 
  NPGAMEMON_ERROR_SPEEDCHECK = 220; {// SpeedCheck Init Error} 
const 
  NPGAMEMON_ERROR_GAMEGUARD = 230; {// GameGuard Init Error} 
 
{/// Error Code 310 - 400 } 
{/// Update Error Code } 
const 
  NPGMUP_ERROR_DOWNCFG = 340; {// Download Error} 
const 
  NPGMUP_ERROR_ABORT = 350; {// Canceled by User} 
const 
  NPGMUP_ERROR_AUTH = 360; {// File Authentication Error} 
const 
  NPGMUP_ERROR_AUTH_INI = 361; {// .ini Authentication Error} 
const 
  NPGMUP_ERROR_DECRYPT = 370; {// .ini Decrypt Error} 
const 
  NPGMUP_ERROR_CONNECT = 380; {// Connect to update server Fail} 
const 
  NPGMUP_ERROR_INI = 390; {// .ini is corrupted} 
 
const 
  NPGAMEMON_SUCCESS = $755; {// GameMon Initialize Success} 
 
 
{/// gameguard auth data } 
type 
  _GG_AUTH_DATA = record 
    dwIndex: LongInt; 
    dwValue1: LongInt; 
    dwValue2: LongInt; 
    dwValue3: LongInt; 
  end {_GG_AUTH_DATA}; 
  GG_AUTH_DATA = _GG_AUTH_DATA; 
 
 
var 
  CheckNPGameMon: function: LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  CloseNPGameMon: function: Bool cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  InitNPGameMon: function: LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  SetHwndToGameMon: procedure(hWnd: HWND) cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  PreInitNPGameMonA: function(szGameName: PChar): LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
//  PreInitNPGameMonW: function(var szGameName: WCHAR_T): LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
  PreInitNPGameMonW: function(var szGameName: WideChar): LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
var 
  SendUserIDToGameMonA: function(szUserID: PChar): Bool cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
//  SendUserIDToGameMonW: function(var szUserID: WCHAR_T): Bool cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
  SendUserIDToGameMonW: function(var szUserID: WideChar): Bool cdecl  {$IFDEF WIN32} stdcall {$ENDIF}; 
var 
  SendCSAuthToGameMon: function(dwAuth: LongInt): Bool cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  SendCSAuth2ToGameMon: function(var pAuth: GG_AUTH_DATA): Bool cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  GetInfoFromGameMon: function: PChar cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
 
var 
  InitPacketProtect: function(lpszUserKey: PChar): LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  EncryptPacket: function(lpData: Pointer;  
                          dwLength: LongInt): LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  DecryptPacket: function(lpData: Pointer;  
                          dwLength: LongInt): LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  EncryptPeerPacket: function(lpData: Pointer;  
                              dwLength: LongInt): LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  DecryptPeerPacket: function(lpData: Pointer;  
                              dwLength: LongInt): LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
var 
  PPGetLastError: function: LongInt cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
 
var 
  SetCallbackToGameMon: procedure(fnCallback: Pointer) cdecl  {$IFDEF WIN32} stdcall {$ENDIF};  
 
 
var 
  DLLLoaded: Boolean { is DLL (dynamically) loaded already? } 
    {$IFDEF WIN32} = False; {$ENDIF} 
 
implementation 
 
var 
  SaveExit: pointer; 
  DLLHandle: THandle; 
{$IFNDEF MSDOS} 
  ErrorMode: Integer; 
{$ENDIF} 
 
  procedure NewExit; far; 
  begin 
    ExitProc := SaveExit; 
    FreeLibrary(DLLHandle) 
  end {NewExit}; 
 
procedure LoadDLL; 
begin 
  if DLLLoaded then Exit; 
{$IFNDEF MSDOS} 
  ErrorMode := SetErrorMode($8000{SEM_NoOpenFileErrorBox}); 
{$ENDIF} 
  DLLHandle := LoadLibrary('NPGAMEDLL.DLL'); 
  if DLLHandle >= 32 then 
  begin 
    DLLLoaded := True; 
    SaveExit := ExitProc; 
    ExitProc := @NewExit; 
    @CheckNPGameMon := GetProcAddress(DLLHandle,'CheckNPGameMon'); 
  {$IFDEF WIN32} 
    Assert(@CheckNPGameMon <> nil); 
  {$ENDIF} 
    @CloseNPGameMon := GetProcAddress(DLLHandle,'CloseNPGameMon'); 
  {$IFDEF WIN32} 
    Assert(@CloseNPGameMon <> nil); 
  {$ENDIF} 
    @InitNPGameMon := GetProcAddress(DLLHandle,'InitNPGameMon'); 
  {$IFDEF WIN32} 
    Assert(@InitNPGameMon <> nil); 
  {$ENDIF} 
    @SetHwndToGameMon := GetProcAddress(DLLHandle,'SetHwndToGameMon'); 
  {$IFDEF WIN32} 
    Assert(@SetHwndToGameMon <> nil); 
  {$ENDIF} 
    @PreInitNPGameMonA := GetProcAddress(DLLHandle,'PreInitNPGameMonA'); 
  {$IFDEF WIN32} 
    Assert(@PreInitNPGameMonA <> nil); 
  {$ENDIF} 
    @PreInitNPGameMonW := GetProcAddress(DLLHandle,'PreInitNPGameMonW'); 
  {$IFDEF WIN32} 
    Assert(@PreInitNPGameMonW <> nil); 
  {$ENDIF} 
    @SendUserIDToGameMonA := GetProcAddress(DLLHandle,'SendUserIDToGameMonA'); 
  {$IFDEF WIN32} 
    Assert(@SendUserIDToGameMonA <> nil); 
  {$ENDIF} 
    @SendUserIDToGameMonW := GetProcAddress(DLLHandle,'SendUserIDToGameMonW'); 
  {$IFDEF WIN32} 
    Assert(@SendUserIDToGameMonW <> nil); 
  {$ENDIF} 
    @SendCSAuthToGameMon := GetProcAddress(DLLHandle,'SendCSAuthToGameMon'); 
  {$IFDEF WIN32} 
    Assert(@SendCSAuthToGameMon <> nil); 
  {$ENDIF} 
    @SendCSAuth2ToGameMon := GetProcAddress(DLLHandle,'SendCSAuth2ToGameMon'); 
  {$IFDEF WIN32} 
    Assert(@SendCSAuth2ToGameMon <> nil); 
  {$ENDIF} 
    @GetInfoFromGameMon := GetProcAddress(DLLHandle,'GetInfoFromGameMon'); 
  {$IFDEF WIN32} 
    Assert(@GetInfoFromGameMon <> nil); 
  {$ENDIF} 
    @InitPacketProtect := GetProcAddress(DLLHandle,'InitPacketProtect'); 
  {$IFDEF WIN32} 
    Assert(@InitPacketProtect <> nil); 
  {$ENDIF} 
    @EncryptPacket := GetProcAddress(DLLHandle,'EncryptPacket'); 
  {$IFDEF WIN32} 
    Assert(@EncryptPacket <> nil); 
  {$ENDIF} 
    @DecryptPacket := GetProcAddress(DLLHandle,'DecryptPacket'); 
  {$IFDEF WIN32} 
    Assert(@DecryptPacket <> nil); 
  {$ENDIF} 
    @EncryptPeerPacket := GetProcAddress(DLLHandle,'EncryptPeerPacket'); 
  {$IFDEF WIN32} 
    Assert(@EncryptPeerPacket <> nil); 
  {$ENDIF} 
    @DecryptPeerPacket := GetProcAddress(DLLHandle,'DecryptPeerPacket'); 
  {$IFDEF WIN32} 
    Assert(@DecryptPeerPacket <> nil); 
  {$ENDIF} 
    @PPGetLastError := GetProcAddress(DLLHandle,'PPGetLastError'); 
  {$IFDEF WIN32} 
    Assert(@PPGetLastError <> nil); 
  {$ENDIF} 
    @SetCallbackToGameMon := GetProcAddress(DLLHandle,'SetCallbackToGameMon'); 
  {$IFDEF WIN32} 
    Assert(@SetCallbackToGameMon <> nil); 
  {$ENDIF} 
  end 
  else 
  begin 
    DLLLoaded := False; 
    { Error: NPGAMEDLL.DLL could not be loaded !! } 
  end; 
{$IFNDEF MSDOS} 
  SetErrorMode(ErrorMode) 
{$ENDIF} 
end {LoadDLL}; 
 
begin 
  LoadDLL; 
end.