Junior Spellweaver
- Joined
- Feb 24, 2007
- Messages
- 189
- Reaction score
- 1
Well I started working on a server sdk so nubs who don't know how to code can make their own servers in their own way.
But anyways here is my problem. I am using libmysql to connect to mysql. and when I start the main executable[included some sample code]
I don't get reffered to a file / line # but in Disassembly I get this.
But the code that im using is the following.
and I am calling it like this.
Thats the code however look @ the disassembly and see how this has anything to do with it because the libmysql exists in the folder :3
But anyways here is my problem. I am using libmysql to connect to mysql. and when I start the main executable[included some sample code]
I don't get reffered to a file / line # but in Disassembly I get this.
PHP:
0040104E xor eax,esp
00401050 mov dword ptr [esp+58h],eax
00401054 push esi
00401055 movzx edx,word ptr ds:[40D3F8h]
0040105C mov eax,dword ptr ds:[0040D3F0h]
00401061 mov ecx,dword ptr ds:[40D3F4h]
00401067 mov dword ptr [esp+8],eax
0040106B mov eax,dword ptr ds:[0040D3FCh]
00401070 mov dword ptr [esp+0Ch],ecx
00401074 mov cx,word ptr ds:[40D400h]
0040107B mov word ptr [esp+10h],dx
00401080 mov dl,byte ptr ds:[40D402h]
00401086 mov dword ptr [esp+38h],eax
0040108A mov dword ptr [esp+28h],eax
0040108E mov eax,dword ptr [esp+4Ch]
00401092 mov word ptr [esp+3Ch],cx
00401097 mov word ptr [esp+2Ch],cx
0040109C mov byte ptr [esp+3Eh],dl
004010A0 mov byte ptr [esp+2Eh],dl
004010A4 mov byte ptr [eax],0 ///// Break point here to mark where error starts
004010A7 mov ecx,dword ptr ds:[40D3FCh]
004010AD movzx edx,word ptr ds:[40D400h]
004010B4 mov al,byte ptr ds:[0040D402h]
004010B9 mov dword ptr [esp+18h],ecx
004010BD mov ecx,dword ptr [esp+54h]
004010C1 push ecx
004010C2 mov dword ptr [esp+4Ch],0CEAh
004010CA mov word ptr [esp+20h],dx
004010CF mov byte ptr [esp+22h],al
004010D3 call 004011B6
004010D8 mov esi,eax
004010DA test esi,esi
But the code that im using is the following.
PHP:
/***************************************/
/* Coded by Night2Dark2 */
/* www.revgamers.net */
/* File : config_mysql.h */
/***************************************/
#ifndef __CONFIG_MYSQL_H_
#define __CONFIG_MYSQL_H_
////// Includes are here /////////////
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "config-win.h"
#include "my_global.h"
#include "my_dbug.h"
#include "my_pthread.h"
#include "mysql.h"
//////////////////////////////////////
typedef struct db_mutex {
char* name;
MYSQL *db;
} db_mutex;
typedef struct db_donfig {
char host[16]; // Host name
char user[16]; // User name
char password[16]; // Password
char dbName[16]; // Database name
unsigned int SQLport; // SQL port
char* socket;
} db_config;
class ZMysql
{
public:
db_config dbc;
db_mutex dbm;
void db_die(char *fmt, ...);
MYSQL *db_connect(MYSQL *db, db_config *dbc);
void db_disconnect(MYSQL *db);
long db_query(MYSQL *db, const char *query);
~ZMysql();
ZMysql();
};
#endif
/***************************************/
PHP:
/***************************************/
/* Coded by Night2Dark2 */
/* www.revgamers.net */
/* File : ZMysql.cpp */
/***************************************/
#include "config_mysql.h"
ZMysql::ZMysql()
{
// Standerd constructer
}
ZMysql::~ZMysql()
{
// Standerd deconstructer
}
void ZMysql::db_die(char *fmt, ...)
{
int i;
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
(void)putc('\n', stderr);
ZMysql::db_disconnect(ZMysql::dbm.db);
exit(EXIT_FAILURE);
}
MYSQL *ZMysql::db_connect(MYSQL *db, db_config *dbc)
{
if(!(db = mysql_init(db)))
{
ZMysql::db_die("mysql_init failed: %s", mysql_error(db));
}
else
{
if(!mysql_real_connect(db, dbc->host, dbc->user, dbc->password, dbc->dbName, dbc->SQLport, dbc->socket, 0))
{
ZMysql::db_die("mysql_real_connect failed: %s", mysql_error(db));
}
return db;
}
}
void ZMysql::db_disconnect(MYSQL *db)
{
if(db)
mysql_close(db);
}
long ZMysql::db_query(MYSQL *db, const char *query)
{
long ret;
ret = mysql_query(db, query);
if(ret != 0) {
db_die("mysql_query failed: %s", mysql_error(db));
}
else
{
MYSQL_RES *res;
res = mysql_store_result(db);
if(res)
{
MYSQL_ROW row, end_row;
unsigned int num_fields;
num_fields = mysql_num_fields(res);
while((row = mysql_fetch_row(res)))
{
for(end_row = row + num_fields; row < end_row; ++row)
{
++ret;
}
mysql_free_result(res);
}
}
else
{
if(mysql_field_count(db) == 0)
{
ret = mysql_affected_rows(db);
}
else
{
ZMysql::db_die("mysql_store_result failed: %s", mysql_error(db));
}
}
}
}
/************************************/
and I am calling it like this.
PHP:
int main()
{
int retValue = 0;
SetConsoleTitle("Initializing Gunz Server");
int initPercent = 0;
Startup st;
st.InitializeServer();
//st.InitializeMySql();
system("pause");
return retValue;
}
int Startup::InitializeServer()
{
// Setup every variable here
int bErrorCode = 0;
printf("Initializing Mysql");
int x = 0;
Startup::InitializeMySql();
printf("completed\n");
return bErrorCode;
}
int Startup::InitializeMySql()
{
// Start MySQL Connection
// and do a test :]
int bErrorCode = 0;
ZMysql ZDB;
strcpy(ZDB.dbc.host,"localhost");
strcpy(ZDB.dbc.dbName,"GunzDB");
strcpy(ZDB.dbc.password,"GunzDB");
strcpy(ZDB.dbc.socket,"");
ZDB.dbc.SQLport=3306;
strcpy(ZDB.dbc.user,"GunzDB");
ZDB.db_connect(ZDB.dbm.db, &ZDB.dbc);
printf("...\t");
return bErrorCode;
}
Thats the code however look @ the disassembly and see how this has anything to do with it because the libmysql exists in the folder :3
Last edited: