diff options
-rw-r--r-- | src/login/lclif.c | 22 | ||||
-rw-r--r-- | src/login/lclif.h | 4 | ||||
-rw-r--r-- | src/login/lclif.p.h | 12 | ||||
-rwxr-xr-x | tools/HPMHookGen/HPMHookGen.pl | 7 |
4 files changed, 37 insertions, 8 deletions
diff --git a/src/login/lclif.c b/src/login/lclif.c index 9e672bab9..c869282c9 100644 --- a/src/login/lclif.c +++ b/src/login/lclif.c @@ -450,7 +450,7 @@ const struct login_packet_db *lclif_packet(int16 packet_id) enum parsefunc_rcode lclif_parse_packet(const struct login_packet_db *lpd, int fd, struct login_session_data *sd) { int result; - result = lpd->pFunc(fd, sd); + result = (*lpd->pFunc)(fd, sd); RFIFOSKIP(fd, (lpd->len == -1) ? RFIFOW(fd, 2) : lpd->len); return result; } @@ -461,10 +461,10 @@ void packetdb_loaddb(void) struct packet { int16 packet_id; int16 packet_len; - int (*pFunc)(int, struct login_session_data *); + LoginParseFunc **pFunc; } packet[] = { -#define packet_def(name) { PACKET_ID_ ## name, sizeof(struct packet_ ## name), lclif_parse_ ## name } -#define packet_def2(name, len) { PACKET_ID_ ## name, (len), lclif_parse_ ## name } +#define packet_def(name) { PACKET_ID_ ## name, sizeof(struct packet_ ## name), &lclif->p->parse_ ## name } +#define packet_def2(name, len) { PACKET_ID_ ## name, (len), &lclif->p->parse_ ## name } packet_def(CA_CONNECT_INFO_CHANGED), packet_def(CA_EXE_HASHCHECK), packet_def(CA_LOGIN), @@ -491,7 +491,7 @@ void packetdb_loaddb(void) //Explict case, we will save character login packet in position 0 which is unused and not valid by normal packet_db[0].len = sizeof(struct packet_CA_CHARSERVERCONNECT); - packet_db[0].pFunc = lclif_parse_CA_CHARSERVERCONNECT; + packet_db[0].pFunc = &lclif->p->parse_CA_CHARSERVERCONNECT; } void lclif_init(void) @@ -523,4 +523,16 @@ void lclif_defaults(void) lclif->p->packetdb_loaddb = packetdb_loaddb; lclif->p->parse_sub = lclif_parse_sub; + + lclif->p->parse_CA_CONNECT_INFO_CHANGED = lclif_parse_CA_CONNECT_INFO_CHANGED; + lclif->p->parse_CA_EXE_HASHCHECK = lclif_parse_CA_EXE_HASHCHECK; + lclif->p->parse_CA_LOGIN = lclif_parse_CA_LOGIN; + lclif->p->parse_CA_LOGIN2 = lclif_parse_CA_LOGIN2; + lclif->p->parse_CA_LOGIN3 = lclif_parse_CA_LOGIN3; + lclif->p->parse_CA_LOGIN4 = lclif_parse_CA_LOGIN4; + lclif->p->parse_CA_LOGIN_PCBANG = lclif_parse_CA_LOGIN_PCBANG; + lclif->p->parse_CA_LOGIN_HAN = lclif_parse_CA_LOGIN_HAN; + lclif->p->parse_CA_SSO_LOGIN_REQ = lclif_parse_CA_SSO_LOGIN_REQ; + lclif->p->parse_CA_REQ_HASH = lclif_parse_CA_REQ_HASH; + lclif->p->parse_CA_CHARSERVERCONNECT = lclif_parse_CA_CHARSERVERCONNECT; } diff --git a/src/login/lclif.h b/src/login/lclif.h index cf6314fc8..5eb5a75aa 100644 --- a/src/login/lclif.h +++ b/src/login/lclif.h @@ -43,8 +43,8 @@ typedef enum parsefunc_rcode (LoginParseFunc)(int fd, struct login_session_data /* Structs */ /// Login packet DB entry struct login_packet_db { - int16 len; ///< Packet length - LoginParseFunc *pFunc; ///< Packet parsing function + int16 len; ///< Packet length + LoginParseFunc **pFunc; ///< Packet parsing function }; struct lclif_interface { diff --git a/src/login/lclif.p.h b/src/login/lclif.p.h index ad9a08e4d..b0811c7c6 100644 --- a/src/login/lclif.p.h +++ b/src/login/lclif.p.h @@ -259,6 +259,18 @@ struct packet_AC_ACK_HASH { struct lclif_interface_private { void (*packetdb_loaddb)(void); enum parsefunc_rcode (*parse_sub)(int fd, struct login_session_data *sd); + + LoginParseFunc *parse_CA_CONNECT_INFO_CHANGED; + LoginParseFunc *parse_CA_EXE_HASHCHECK; + LoginParseFunc *parse_CA_LOGIN; + LoginParseFunc *parse_CA_LOGIN2; + LoginParseFunc *parse_CA_LOGIN3; + LoginParseFunc *parse_CA_LOGIN4; + LoginParseFunc *parse_CA_LOGIN_PCBANG; + LoginParseFunc *parse_CA_LOGIN_HAN; + LoginParseFunc *parse_CA_SSO_LOGIN_REQ; + LoginParseFunc *parse_CA_REQ_HASH; + LoginParseFunc *parse_CA_CHARSERVERCONNECT; }; #endif // LOGIN_LCLIF_P_H diff --git a/tools/HPMHookGen/HPMHookGen.pl b/tools/HPMHookGen/HPMHookGen.pl index 74cc0f863..0e33fd002 100755 --- a/tools/HPMHookGen/HPMHookGen.pl +++ b/tools/HPMHookGen/HPMHookGen.pl @@ -361,9 +361,14 @@ foreach my $file (@files) { # Loop through the xml files $astart <=> $bstart } @$memberdef) { # Loop through the members my $t = $f->{argsstring}->[0]; + my $def = $f->{definition}->[0]; + if ($f->{type}->[0] =~ /^\s*LoginParseFunc\s*\*\s*$/) { + $t = ')(int fd, struct login_session_data *sd)'; # typedef LoginParseFunc + $def =~ s/^LoginParseFunc\s*\*\s*(.*)$/enum parsefunc_rcode(* $1) (int fd, struct login_session_data *sd)/; + } next unless ref $t ne 'HASH' and $t =~ /^[^\[]/; # If it's not a string, or if it starts with an array subscript, we can skip it - my $if = parse($t, $f->{definition}->[0]); + my $if = parse($t, $def); next unless scalar keys %$if; # If it returns an empty hash reference, an error must've occurred # Skip variadic functions, we only allow hooks on their arglist equivalents. |