From 79d9aced64738cb86feca087b7d0dfc4185c8507 Mon Sep 17 00:00:00 2001 From: Haru Date: Wed, 30 Mar 2016 23:58:17 +0200 Subject: Added support for private headers to the HPMDataCheck/HPMHooking generators Signed-off-by: Haru --- tools/HPMHookGen/HPMDataCheckGen.pl | 8 ++++---- tools/HPMHookGen/HPMHookGen.pl | 25 +++++++++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) (limited to 'tools/HPMHookGen') diff --git a/tools/HPMHookGen/HPMDataCheckGen.pl b/tools/HPMHookGen/HPMDataCheckGen.pl index 3965668d9..68751a4ad 100644 --- a/tools/HPMHookGen/HPMDataCheckGen.pl +++ b/tools/HPMHookGen/HPMDataCheckGen.pl @@ -3,7 +3,7 @@ # This file is part of Hercules. # http://herc.ws - http://github.com/HerculesWS/Hercules # -# Copyright (C) 2014-2015 Hercules Dev Team +# Copyright (C) 2014-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 @@ -42,10 +42,10 @@ foreach my $file (@files) { my @filepath = split(/[\/\\]/, $data->{compounddef}->{$filekey}->{location}->[0]->{file}); my $foldername = uc($filepath[-2]); next if $filepath[-1] eq "HPM.h"; # Skip the HPM core, plugins don't need it - my $filename = uc($filepath[-1]); $filename =~ s/-/_/g; $filename =~ s/\.[^.]*$//; + my $filename = uc($filepath[-1]); $filename =~ s/[.-]/_/g; $filename =~ s/\.[^.]*$//; my $plugintypes = 'SERVER_TYPE_UNKNOWN'; if ($foldername eq 'COMMON') { - if ($filename eq 'MAPINDEX') { + if ($filename eq 'MAPINDEX_H') { $plugintypes = 'SERVER_TYPE_CHAR|SERVER_TYPE_MAP'; } else { $plugintypes = 'SERVER_TYPE_ALL'; @@ -57,7 +57,7 @@ foreach my $file (@files) { name => $data->{compounddef}->{$filekey}->{compoundname}->[0], type => $plugintypes, }; - my $name = "${foldername}_${filename}_H"; + my $name = "${foldername}_${filename}"; push @{ $out{$name} }, $symboldata; } 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} }) { -- cgit v1.2.3-60-g2f50