summaryrefslogtreecommitdiff
path: root/tools/HPMHookGen/HPMHookGen.pl
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-03-30 23:58:17 +0200
committerHaru <haru@dotalux.com>2016-04-16 03:42:41 +0200
commit79d9aced64738cb86feca087b7d0dfc4185c8507 (patch)
tree3213e4469bfce7818f74a684dc10fb2d30ed226a /tools/HPMHookGen/HPMHookGen.pl
parentc7410453a15110a12d9fffb06b70e9557fb9f73a (diff)
downloadhercules-79d9aced64738cb86feca087b7d0dfc4185c8507.tar.gz
hercules-79d9aced64738cb86feca087b7d0dfc4185c8507.tar.bz2
hercules-79d9aced64738cb86feca087b7d0dfc4185c8507.tar.xz
hercules-79d9aced64738cb86feca087b7d0dfc4185c8507.zip
Added support for private headers to the HPMDataCheck/HPMHooking generators
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'tools/HPMHookGen/HPMHookGen.pl')
-rwxr-xr-xtools/HPMHookGen/HPMHookGen.pl25
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/HPMHookGen/HPMHookGen.pl b/tools/HPMHookGen/HPMHookGen.pl
index d471b874d..9b6fcdf8b 100755
--- a/tools/HPMHookGen/HPMHookGen.pl
+++ b/tools/HPMHookGen/HPMHookGen.pl
@@ -3,7 +3,7 @@
# This file is part of Hercules.
# http://herc.ws - http://github.com/HerculesWS/Hercules
#
-# Copyright (C) 2013-2015 Hercules Dev Team
+# Copyright (C) 2013-2016 Hercules Dev Team
#
# Hercules is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -40,7 +40,7 @@ sub parse($$) {
$p =~ s/^.*?\)\((.*)\).*$/$1/; # Clean up extra parentheses )(around the arglist)
# Retrieve return type
- unless ($d =~ /^(.+)\(\*\s*[a-zA-Z0-9_]+_interface::([^\)]+)\s*\)\s*\(.*\)$/) {
+ unless ($d =~ /^(.+)\(\*\s*[a-zA-Z0-9_]+_interface(?:_private)?::([^\)]+)\s*\)\s*\(.*\)$/) {
print "Error: unable to parse '$d'\n";
return {};
}
@@ -273,6 +273,7 @@ sub parse($$) {
}
my %key2original;
+my %key2pointer;
my @files = grep { -f } glob 'doxyoutput/xml/*interface*.xml';
my %ifs;
my %keys = (
@@ -308,8 +309,9 @@ foreach my $file (@files) { # Loop through the xml files
}
my @filepath = split(/[\/\\]/, $loc->{file});
my $foldername = uc($filepath[-2]);
- my $filename = uc($filepath[-1]); $filename =~ s/-/_/g; $filename =~ s/\.[^.]*$//;
- my $guardname = "${foldername}_${filename}_H";
+ my $filename = uc($filepath[-1]); $filename =~ s/[.-]/_/g; $filename =~ s/\.[^.]*$//;
+ my $guardname = "${foldername}_${filename}";
+ my $private = $key =~ /_interface_private$/ ? 1 : 0;
# Some known interfaces with different names
if ($key =~ /battleground/) {
@@ -344,6 +346,9 @@ foreach my $file (@files) { # Loop through the xml files
} else {
$key =~ s/_interface//;
}
+ $key =~ s/^(.*)_private$/PRIV__$1/ if $private;
+ my $pointername = $key;
+ $pointername =~ s/^PRIV__(.*)$/$1->p/ if $private;
my $sectiondef = $data->{compounddef}->{$filekey}->{sectiondef};
foreach my $v (@$sectiondef) { # Loop through the sections
@@ -431,6 +436,7 @@ foreach my $file (@files) { # Loop through the xml files
$if->{origcall} .= ");";
$key2original{$key} = $original;
+ $key2pointer{$key} = $pointername;
$ifs{$key} = [] unless $ifs{$key};
push(@{ $ifs{$key} }, $if);
}
@@ -442,6 +448,7 @@ foreach my $file (@files) { # Loop through the xml files
$fileguards{$key} = {
guard => $guardname,
type => $servermask,
+ private => $private,
};
}
@@ -495,6 +502,7 @@ foreach my $servertype (keys %keys) {
EOF
foreach my $key (@$keysref) {
+ next if $fileguards{$key}->{private};
print FH <<"EOF";
#ifdef $fileguards{$key}->{guard} /* $key */
struct $key2original{$key} *$key;
@@ -510,6 +518,7 @@ HPExport const char *HPM_shared_symbols(int server_type)
EOF
foreach my $key (@$keysref) {
+ next if $fileguards{$key}->{private};
print FH <<"EOF";
#ifdef $fileguards{$key}->{guard} /* $key */
if ((server_type&($fileguards{$key}->{type})) && !HPM_SYMBOL("$exportsymbols{$key}", $key)) return "$exportsymbols{$key}";
@@ -558,11 +567,11 @@ struct HookingPointData HookingPoints[] = {
EOF
foreach my $key (@$keysref) {
- print FH "/* ".$key." */\n";
+ print FH "/* $key2original{$key} */\n";
foreach my $if (@{ $ifs{$key} }) {
print FH <<"EOF";
- { HP_POP($key\->$if->{name}, $if->{hname}) },
+ { HP_POP($key2pointer{$key}\->$if->{name}, $if->{hname}) },
EOF
$idx += 2;
@@ -610,7 +619,7 @@ EOF
foreach my $key (@$keysref) {
print FH <<"EOF";
-memcpy(&HPMHooks.source.$key, $key, sizeof(struct $key2original{$key}));
+memcpy(&HPMHooks.source.$key, $key2pointer{$key}, sizeof(struct $key2original{$key}));
EOF
}
close FH;
@@ -724,7 +733,7 @@ EOF
foreach my $key (@$keysref) {
print FH <<"EOF";
-/* $key */
+/* $key2original{$key} */
EOF
foreach my $if (@{ $ifs{$key} }) {