2002-03-10 00:29:33 +01:00
|
|
|
#
|
|
|
|
# Copyright 1999, 2000, 2001 Patrik Stridvall
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
package winapi_local;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2001-07-24 01:20:56 +02:00
|
|
|
use nativeapi qw($nativeapi);
|
|
|
|
use options qw($options);
|
|
|
|
use output qw($output);
|
|
|
|
use winapi qw($win16api $win32api @winapis);
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub _check_function($$$$$$) {
|
1999-09-23 17:14:20 +02:00
|
|
|
my $return_type = shift;
|
|
|
|
my $calling_convention = shift;
|
2000-04-24 20:02:32 +02:00
|
|
|
my $external_name = shift;
|
|
|
|
my $internal_name = shift;
|
1999-09-23 17:14:20 +02:00
|
|
|
my $refargument_types = shift;
|
|
|
|
my @argument_types = @$refargument_types;
|
|
|
|
my $winapi = shift;
|
|
|
|
|
2001-06-19 05:34:52 +02:00
|
|
|
my $module = $winapi->function_internal_module($internal_name);
|
2002-06-01 04:55:48 +02:00
|
|
|
|
1999-10-24 23:45:39 +02:00
|
|
|
if($winapi->name eq "win16") {
|
2001-07-13 00:22:05 +02:00
|
|
|
if($winapi->is_function_stub_in_module($module, $internal_name)) {
|
1999-10-24 23:45:39 +02:00
|
|
|
if($options->implemented) {
|
2000-06-11 22:02:29 +02:00
|
|
|
$output->write("function implemented but declared as stub in .spec file\n");
|
1999-10-24 23:45:39 +02:00
|
|
|
}
|
|
|
|
return;
|
2001-07-13 00:22:05 +02:00
|
|
|
} elsif($winapi->is_function_stub_in_module($module, $internal_name)) {
|
1999-10-24 23:45:39 +02:00
|
|
|
if($options->implemented_win32) {
|
2000-06-11 22:02:29 +02:00
|
|
|
$output->write("32-bit variant of function implemented but declared as stub in .spec file\n");
|
1999-10-24 23:45:39 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2001-07-13 00:22:05 +02:00
|
|
|
} elsif($winapi->is_function_stub_in_module($module, $internal_name)) {
|
1999-10-24 23:45:39 +02:00
|
|
|
if($options->implemented) {
|
2000-06-11 22:02:29 +02:00
|
|
|
$output->write("function implemented but declared as stub in .spec file\n");
|
1999-10-24 23:45:39 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
my $forbidden_return_type = 0;
|
|
|
|
my $implemented_return_kind;
|
1999-10-24 23:45:39 +02:00
|
|
|
$winapi->type_used_in_module($return_type,$module);
|
1999-09-23 17:14:20 +02:00
|
|
|
if(!defined($implemented_return_kind = $winapi->translate_argument($return_type))) {
|
2002-03-23 22:39:31 +01:00
|
|
|
$winapi->declare_argument($return_type, "unknown");
|
1999-09-23 17:14:20 +02:00
|
|
|
if($return_type ne "") {
|
2005-04-20 16:24:52 +02:00
|
|
|
$output->write("no win*.api translation defined: " . $return_type . "\n");
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
2002-03-23 22:39:31 +01:00
|
|
|
} elsif(!$winapi->is_allowed_kind($implemented_return_kind) ||
|
2002-06-01 04:55:48 +02:00
|
|
|
!$winapi->is_allowed_type_in_module($return_type, $module))
|
2002-03-23 22:39:31 +01:00
|
|
|
{
|
1999-09-23 17:14:20 +02:00
|
|
|
$forbidden_return_type = 1;
|
2002-03-23 22:39:31 +01:00
|
|
|
$winapi->allow_kind($implemented_return_kind);
|
|
|
|
$winapi->allow_type_in_module($return_type, $module);
|
1999-09-23 17:14:20 +02:00
|
|
|
if($options->report_argument_forbidden($return_type)) {
|
2000-06-23 17:46:26 +02:00
|
|
|
$output->write("return type is forbidden: $return_type ($implemented_return_kind)\n");
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
my $segmented = 0;
|
2004-10-22 21:55:42 +02:00
|
|
|
if(defined($implemented_return_kind) && $implemented_return_kind =~ /^seg[sp]tr$/) {
|
1999-09-23 17:14:20 +02:00
|
|
|
$segmented = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $implemented_calling_convention;
|
|
|
|
if($winapi->name eq "win16") {
|
2004-10-22 21:55:42 +02:00
|
|
|
if($calling_convention eq "__cdecl") {
|
1999-09-23 17:14:20 +02:00
|
|
|
$implemented_calling_convention = "cdecl";
|
2004-10-22 21:55:42 +02:00
|
|
|
} elsif($calling_convention =~ /^(?:VFWAPIV|WINAPIV)$/) {
|
2000-01-08 23:20:32 +01:00
|
|
|
$implemented_calling_convention = "varargs";
|
2005-11-04 12:14:41 +01:00
|
|
|
} elsif($calling_convention =~ /^(?:__stdcall|__RPC_STUB|NET_API_FUNCTION|RPC_ENTRY|VFWAPI|WINAPI|CALLBACK)$/) {
|
2004-10-22 21:55:42 +02:00
|
|
|
if(defined($implemented_return_kind) && $implemented_return_kind =~ /^(?:s_word|word|void)$/) {
|
1999-09-23 17:14:20 +02:00
|
|
|
$implemented_calling_convention = "pascal16";
|
|
|
|
} else {
|
|
|
|
$implemented_calling_convention = "pascal";
|
|
|
|
}
|
2004-10-22 21:55:42 +02:00
|
|
|
} elsif($calling_convention eq "__asm") {
|
2001-02-12 04:44:41 +01:00
|
|
|
$implemented_calling_convention = "asm";
|
|
|
|
} else {
|
|
|
|
$implemented_calling_convention = "cdecl";
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
} elsif($winapi->name eq "win32") {
|
2004-10-22 21:55:42 +02:00
|
|
|
if($calling_convention eq "__cdecl") {
|
1999-09-23 17:14:20 +02:00
|
|
|
$implemented_calling_convention = "cdecl";
|
2004-10-22 21:55:42 +02:00
|
|
|
} elsif($calling_convention =~ /^(?:VFWAPIV|WINAPIV)$/) {
|
1999-09-23 17:14:20 +02:00
|
|
|
$implemented_calling_convention = "varargs";
|
2005-11-04 12:14:41 +01:00
|
|
|
} elsif($calling_convention =~ /^(?:__stdcall|__RPC_STUB|NET_API_FUNCTION|RPC_ENTRY|VFWAPI|WINAPI|CALLBACK)$/) {
|
2004-10-22 21:55:42 +02:00
|
|
|
if(defined($implemented_return_kind) && $implemented_return_kind eq "longlong") {
|
2000-11-30 02:31:44 +01:00
|
|
|
$implemented_calling_convention = "stdcall"; # FIXME: Check entry flags
|
2000-10-02 05:34:14 +02:00
|
|
|
} else {
|
|
|
|
$implemented_calling_convention = "stdcall";
|
|
|
|
}
|
2004-10-22 21:55:42 +02:00
|
|
|
} elsif($calling_convention eq "__asm") {
|
2001-02-12 04:44:41 +01:00
|
|
|
$implemented_calling_convention = "asm";
|
1999-10-24 23:45:39 +02:00
|
|
|
} else {
|
2000-06-07 04:11:42 +02:00
|
|
|
$implemented_calling_convention = "cdecl";
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-20 20:57:42 +01:00
|
|
|
my $declared_calling_convention = $winapi->function_internal_calling_convention($internal_name) || "";
|
2001-06-19 05:34:52 +02:00
|
|
|
my @declared_argument_kinds = split(/\s+/, $winapi->function_internal_arguments($internal_name));
|
1999-09-23 17:14:20 +02:00
|
|
|
|
2002-11-27 21:11:10 +01:00
|
|
|
my $declared_register = 0;
|
|
|
|
if ($declared_calling_convention =~ /^(\w+) -register$/) {
|
|
|
|
$declared_register = 1;
|
|
|
|
$declared_calling_convention = $1;
|
|
|
|
}
|
|
|
|
|
2004-10-21 22:58:13 +02:00
|
|
|
if ($declared_register)
|
|
|
|
{
|
|
|
|
if ($implemented_calling_convention eq "stdcall")
|
|
|
|
{
|
|
|
|
$output->write("-register functions should not be implemented as stdcall\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif($implemented_calling_convention ne $declared_calling_convention &&
|
2001-02-12 04:44:41 +01:00
|
|
|
$implemented_calling_convention ne "asm" &&
|
2000-01-08 23:20:32 +01:00
|
|
|
!($declared_calling_convention =~ /^pascal/ && $forbidden_return_type) &&
|
2004-10-22 21:55:42 +02:00
|
|
|
!($implemented_calling_convention =~ /^(?:cdecl|varargs)$/ && $declared_calling_convention =~ /^(?:cdecl|varargs)$/))
|
1999-09-23 17:14:20 +02:00
|
|
|
{
|
2000-06-07 04:11:42 +02:00
|
|
|
if($options->calling_convention && (
|
|
|
|
($options->calling_convention_win16 && $winapi->name eq "win16") ||
|
|
|
|
($options->calling_convention_win32 && $winapi->name eq "win32")) &&
|
|
|
|
!$nativeapi->is_function($internal_name))
|
|
|
|
{
|
2000-06-11 22:02:29 +02:00
|
|
|
$output->write("calling convention mismatch: $implemented_calling_convention != $declared_calling_convention\n");
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($declared_calling_convention eq "varargs") {
|
2004-02-20 20:57:42 +01:00
|
|
|
if ($#argument_types != -1 &&
|
|
|
|
(($winapi->name eq "win32" && $argument_types[$#argument_types] eq "...") ||
|
|
|
|
($winapi->name eq "win16" && $argument_types[$#argument_types] eq "VA_LIST16")))
|
|
|
|
{
|
1999-09-23 17:14:20 +02:00
|
|
|
pop @argument_types;
|
|
|
|
} else {
|
2004-02-20 20:57:42 +01:00
|
|
|
$output->write("function not implemented as varargs\n");
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
2004-02-20 20:57:42 +01:00
|
|
|
} elsif ($#argument_types != -1 &&
|
|
|
|
(($winapi->name eq "win32" && $argument_types[$#argument_types] eq "...") ||
|
|
|
|
($winapi->name eq "win16" && $argument_types[$#argument_types] eq "VA_LIST16")))
|
|
|
|
{
|
|
|
|
if($#argument_types == 0) {
|
2001-06-19 05:34:52 +02:00
|
|
|
pop @argument_types;
|
|
|
|
} else {
|
2004-02-20 20:57:42 +01:00
|
|
|
$output->write("function not declared as varargs\n");
|
2001-06-19 05:34:52 +02:00
|
|
|
}
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
1999-12-12 00:01:45 +01:00
|
|
|
|
|
|
|
if($#argument_types != -1 && $argument_types[$#argument_types] eq "CONTEXT *" &&
|
2002-11-27 21:11:10 +01:00
|
|
|
$internal_name =~ /^(?:RtlRaiseException|RtlUnwind|NtRaiseException)$/) # FIXME: Kludge
|
1999-12-12 00:01:45 +01:00
|
|
|
{
|
|
|
|
$#argument_types--;
|
|
|
|
}
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2004-10-22 21:55:42 +02:00
|
|
|
if($internal_name =~ /^(?:NTDLL__ftol|NTDLL__CIpow)$/) { # FIXME: Kludge
|
1999-09-23 17:14:20 +02:00
|
|
|
# ignore
|
|
|
|
} else {
|
|
|
|
my $n = 0;
|
|
|
|
my @argument_kinds = map {
|
|
|
|
my $type = $_;
|
|
|
|
my $kind = "unknown";
|
1999-10-24 23:45:39 +02:00
|
|
|
$winapi->type_used_in_module($type,$module);
|
2002-01-07 22:08:18 +01:00
|
|
|
if($type eq "CONTEXT86 *") {
|
|
|
|
$kind = "context86";
|
|
|
|
} elsif(!defined($kind = $winapi->translate_argument($type))) {
|
2002-03-23 22:39:31 +01:00
|
|
|
$winapi->declare_argument($type, "unknown");
|
2005-04-20 16:24:52 +02:00
|
|
|
$output->write("no win*.api translation defined: " . $type . "\n");
|
1999-09-23 17:14:20 +02:00
|
|
|
} elsif(!$winapi->is_allowed_kind($kind) ||
|
2002-06-01 04:55:48 +02:00
|
|
|
!$winapi->is_allowed_type_in_module($type, $module))
|
2002-03-23 22:39:31 +01:00
|
|
|
{
|
|
|
|
$winapi->allow_kind($kind);
|
|
|
|
$winapi->allow_type_in_module($type, $module);
|
1999-09-23 17:14:20 +02:00
|
|
|
if($options->report_argument_forbidden($type)) {
|
2002-03-23 22:39:31 +01:00
|
|
|
$output->write("argument " . ($n + 1) . " type is forbidden: " . $type . " (" . $kind . ")\n");
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
}
|
2000-06-23 17:46:26 +02:00
|
|
|
|
|
|
|
# FIXME: Kludge
|
2002-09-24 05:07:38 +02:00
|
|
|
if(defined($kind) && $kind eq "struct16") {
|
1999-10-24 23:45:39 +02:00
|
|
|
$n+=2;
|
2005-09-26 11:52:09 +02:00
|
|
|
("double", "double");
|
|
|
|
} elsif(defined($kind) && $kind eq "longlong") {
|
|
|
|
$n+=1;
|
|
|
|
"double";
|
1999-10-24 23:45:39 +02:00
|
|
|
} else {
|
|
|
|
$n++;
|
|
|
|
$kind;
|
|
|
|
}
|
1999-09-23 17:14:20 +02:00
|
|
|
} @argument_types;
|
|
|
|
|
2002-11-27 21:11:10 +01:00
|
|
|
if ($declared_register && $argument_kinds[$#argument_kinds] ne "context86") {
|
|
|
|
$output->write("function declared as register, but CONTEXT86 * is not last argument\n");
|
|
|
|
}
|
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
for my $n (0..$#argument_kinds) {
|
|
|
|
if(!defined($argument_kinds[$n]) || !defined($declared_argument_kinds[$n])) { next; }
|
|
|
|
|
2004-10-22 21:55:42 +02:00
|
|
|
if($argument_kinds[$n] =~ /^seg[ps]tr$/ ||
|
|
|
|
$declared_argument_kinds[$n] =~ /^seg[ps]tr$/)
|
1999-09-23 17:14:20 +02:00
|
|
|
{
|
|
|
|
$segmented = 1;
|
|
|
|
}
|
|
|
|
|
2000-06-23 17:46:26 +02:00
|
|
|
# FIXME: Kludge
|
|
|
|
if(!defined($argument_types[$n])) {
|
|
|
|
$argument_types[$n] = "";
|
|
|
|
}
|
|
|
|
|
2002-01-07 22:08:18 +01:00
|
|
|
if($argument_kinds[$n] eq "context86") {
|
|
|
|
# Nothing
|
|
|
|
} elsif(!$winapi->is_allowed_kind($argument_kinds[$n]) ||
|
2002-06-01 04:55:48 +02:00
|
|
|
!$winapi->is_allowed_type_in_module($argument_types[$n], $module))
|
2000-06-23 17:46:26 +02:00
|
|
|
{
|
2002-03-23 22:39:31 +01:00
|
|
|
$winapi->allow_kind($argument_kinds[$n]);
|
|
|
|
$winapi->allow_type_in_module($argument_types[$n],, $module);
|
2000-06-23 17:46:26 +02:00
|
|
|
if($options->report_argument_forbidden($argument_types[$n])) {
|
|
|
|
$output->write("argument " . ($n + 1) . " type is forbidden: " .
|
|
|
|
"$argument_types[$n] ($argument_kinds[$n])\n");
|
|
|
|
}
|
|
|
|
} elsif($argument_kinds[$n] ne $declared_argument_kinds[$n]) {
|
1999-09-23 17:14:20 +02:00
|
|
|
if($options->report_argument_kind($argument_kinds[$n]) ||
|
|
|
|
$options->report_argument_kind($declared_argument_kinds[$n]))
|
|
|
|
{
|
2000-06-11 22:02:29 +02:00
|
|
|
$output->write("argument " . ($n + 1) . " type mismatch: " .
|
2002-06-01 04:55:48 +02:00
|
|
|
$argument_types[$n] . " ($argument_kinds[$n]) != " .
|
2000-06-11 22:02:29 +02:00
|
|
|
$declared_argument_kinds[$n] . "\n");
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-12 04:44:41 +01:00
|
|
|
|
2004-10-21 21:57:15 +02:00
|
|
|
if ($options->argument_count &&
|
|
|
|
$implemented_calling_convention ne "asm")
|
2001-02-12 04:44:41 +01:00
|
|
|
{
|
2004-10-21 21:57:15 +02:00
|
|
|
if ($#argument_kinds != $#declared_argument_kinds and
|
|
|
|
$#argument_types != $#declared_argument_kinds) {
|
2002-06-01 04:55:48 +02:00
|
|
|
$output->write("argument count differs: " .
|
2004-10-21 21:57:15 +02:00
|
|
|
($#argument_kinds + 1) . " != " .
|
2000-06-11 22:02:29 +02:00
|
|
|
($#declared_argument_kinds + 1) . "\n");
|
2004-10-21 21:57:15 +02:00
|
|
|
} elsif ($#argument_kinds != $#declared_argument_kinds or
|
|
|
|
$#argument_types != $#declared_argument_kinds) {
|
|
|
|
$output->write("argument count differs: " .
|
|
|
|
($#argument_kinds + 1) . "/" . ($#argument_types + 1) .
|
|
|
|
" != " . ($#declared_argument_kinds + 1) .
|
|
|
|
" (long vs. long long problem?)\n");
|
1999-10-24 23:45:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
|
2001-07-11 19:27:45 +02:00
|
|
|
if($segmented && $options->shared_segmented && $winapi->is_shared_internal_function($internal_name)) {
|
2004-10-21 21:57:15 +02:00
|
|
|
$output->write("function using segmented pointers shared between Win16 and Win32\n");
|
1999-09-23 17:14:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-30 04:11:19 +02:00
|
|
|
sub check_function($) {
|
2001-07-24 01:20:56 +02:00
|
|
|
my $function = shift;
|
|
|
|
|
2004-10-30 04:11:19 +02:00
|
|
|
my $return_type = $function->return_type;
|
|
|
|
my $calling_convention = $function->calling_convention;
|
|
|
|
my $calling_convention16 = $function->calling_convention16;
|
|
|
|
my $calling_convention32 = $function->calling_convention32;
|
|
|
|
my $internal_name = $function->internal_name;
|
|
|
|
my $external_name16 = $function->external_name16;
|
|
|
|
my $external_name32 = $function->external_name32;
|
2001-07-24 01:20:56 +02:00
|
|
|
my $module16 = $function->module16;
|
|
|
|
my $module32 = $function->module32;
|
2004-10-30 04:11:19 +02:00
|
|
|
my $refargument_types = $function->argument_types;
|
|
|
|
|
|
|
|
if(!defined($refargument_types)) {
|
|
|
|
return;
|
|
|
|
}
|
2001-07-24 01:20:56 +02:00
|
|
|
|
|
|
|
if($options->win16 && $options->report_module($module16)) {
|
2004-10-30 04:11:19 +02:00
|
|
|
_check_function($return_type,
|
|
|
|
$calling_convention, $external_name16,
|
|
|
|
$internal_name, $refargument_types,
|
|
|
|
$win16api);
|
2001-07-24 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if($options->win32 && $options->report_module($module32)) {
|
2004-10-30 04:11:19 +02:00
|
|
|
_check_function($return_type,
|
|
|
|
$calling_convention, $external_name32,
|
|
|
|
$internal_name, $refargument_types,
|
|
|
|
$win32api);
|
2001-07-24 01:20:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub _check_statements($$$) {
|
2000-05-11 23:46:17 +02:00
|
|
|
my $winapi = shift;
|
|
|
|
my $functions = shift;
|
|
|
|
my $function = shift;
|
|
|
|
|
|
|
|
my $module = $function->module;
|
|
|
|
my $internal_name = $function->internal_name;
|
|
|
|
|
|
|
|
my $first_debug_message = 1;
|
|
|
|
local $_ = $function->statements;
|
|
|
|
while(defined($_)) {
|
|
|
|
if(s/(\w+)\s*(?:\(\s*(\w+)\s*\))?\s*\(\s*((?:\"[^\"]*\"|\([^\)]*\)|[^\)])*?)\s*\)//) {
|
|
|
|
my $called_name = $1;
|
|
|
|
my $channel = $2;
|
|
|
|
my $called_arguments = $3;
|
2004-10-22 21:55:42 +02:00
|
|
|
if($called_name =~ /^(?:if|for|while|switch|sizeof)$/) {
|
2000-05-11 23:46:17 +02:00
|
|
|
# Nothing
|
2004-10-22 21:55:42 +02:00
|
|
|
} elsif($called_name =~ /^(?:ERR|FIXME|MSG|TRACE|WARN)$/) {
|
|
|
|
if($first_debug_message && $called_name =~ /^(?:FIXME|TRACE)$/) {
|
2000-05-11 23:46:17 +02:00
|
|
|
$first_debug_message = 0;
|
|
|
|
if($called_arguments =~ /^\"\((.*?)\)(.*?)\"\s*,\s*(.*?)$/) {
|
|
|
|
my $formating = $1;
|
|
|
|
my $extra = $2;
|
|
|
|
my $arguments = $3;
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2000-05-11 23:46:17 +02:00
|
|
|
my $format;
|
|
|
|
my $argument;
|
|
|
|
my $n = 0;
|
|
|
|
while($formating && ($formating =~ s/^([^,]*),?//, $format = $1, $format =~ s/^\s*(.*?)\s*$/$1/) &&
|
|
|
|
$arguments && ($arguments =~ s/^([^,]*),?//, $argument = $1, $argument =~ s/^\s*(.*?)\s*$/$1/))
|
|
|
|
{
|
|
|
|
my $type = @{$function->argument_types}[$n];
|
|
|
|
my $name = @{$function->argument_names}[$n];
|
|
|
|
|
|
|
|
$n++;
|
|
|
|
|
|
|
|
if(!defined($type)) { last; }
|
2002-06-01 04:55:48 +02:00
|
|
|
|
2000-05-11 23:46:17 +02:00
|
|
|
$format =~ s/^\w+\s*[:=]?\s*//;
|
|
|
|
$format =~ s/\s*\{[^\{\}]*\}$//;
|
|
|
|
$format =~ s/\s*\[[^\[\]]*\]$//;
|
|
|
|
$format =~ s/^\'(.*?)\'$/$1/;
|
|
|
|
$format =~ s/^\\\"(.*?)\\\"$/$1/;
|
|
|
|
|
2001-06-28 20:01:39 +02:00
|
|
|
if($options->debug_messages) {
|
|
|
|
if($argument !~ /$name/) {
|
|
|
|
$output->write("$called_name: argument $n is wrong ($name != '$argument')\n");
|
|
|
|
} elsif(!$winapi->is_allowed_type_format($module, $type, $format)) {
|
|
|
|
$output->write("$called_name: argument $n ($type $name) has illegal format ($format)\n");
|
|
|
|
}
|
2000-05-11 23:46:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-28 20:01:39 +02:00
|
|
|
if($options->debug_messages) {
|
2002-06-01 04:55:48 +02:00
|
|
|
my $count = $#{$function->argument_types} + 1;
|
2001-06-28 20:01:39 +02:00
|
|
|
if($n != $count) {
|
|
|
|
$output->write("$called_name: argument count mismatch ($n != $count)\n");
|
|
|
|
}
|
2000-05-11 23:46:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-30 20:49:10 +02:00
|
|
|
} elsif($options->cross_call) {
|
2002-11-11 20:55:11 +01:00
|
|
|
# $output->write("$internal_name: called $called_name\n");
|
2000-05-11 23:46:17 +02:00
|
|
|
$$functions{$internal_name}->function_called($called_name);
|
|
|
|
if(!defined($$functions{$called_name})) {
|
2002-11-11 20:55:11 +01:00
|
|
|
my $called_function = 'winapi_function'->new;
|
|
|
|
|
|
|
|
$called_function->internal_name($called_name);
|
|
|
|
|
|
|
|
$$functions{$called_name} = $called_function;
|
2000-05-11 23:46:17 +02:00
|
|
|
}
|
|
|
|
$$functions{$called_name}->function_called_by($internal_name);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
undef $_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-30 04:11:19 +02:00
|
|
|
sub check_statements($$) {
|
|
|
|
my $functions = shift;
|
|
|
|
my $function = shift;
|
|
|
|
|
|
|
|
my $module16 = $function->module16;
|
|
|
|
my $module32 = $function->module32;
|
|
|
|
|
|
|
|
if($options->win16 && $options->report_module($module16)) {
|
|
|
|
_check_statements($win16api, $functions, $function);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($options->win32 && $options->report_module($module32)) {
|
2005-08-11 12:32:10 +02:00
|
|
|
_check_statements($win32api, $functions, $function);
|
2004-10-30 04:11:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-07 20:53:56 +02:00
|
|
|
sub check_file($$) {
|
1999-10-31 03:08:38 +01:00
|
|
|
my $file = shift;
|
|
|
|
my $functions = shift;
|
|
|
|
|
|
|
|
if($options->cross_call) {
|
|
|
|
my @names = sort(keys(%$functions));
|
|
|
|
for my $name (@names) {
|
2002-11-11 20:55:11 +01:00
|
|
|
my $function = $$functions{$name};
|
|
|
|
|
|
|
|
my @called_names = $function->called_function_names;
|
|
|
|
my @called_by_names = $function->called_by_function_names;
|
|
|
|
my $module = $function->module;
|
2000-04-29 16:24:11 +02:00
|
|
|
|
|
|
|
if($options->cross_call_win32_win16) {
|
2002-11-11 20:55:11 +01:00
|
|
|
my $module16 = $function->module16;
|
|
|
|
my $module32 = $function->module32;
|
2000-04-29 16:24:11 +02:00
|
|
|
|
2002-06-01 04:55:48 +02:00
|
|
|
if($#called_names >= 0 && (defined($module16) || defined($module32)) ) {
|
2000-04-29 16:24:11 +02:00
|
|
|
for my $called_name (@called_names) {
|
2002-11-11 20:55:11 +01:00
|
|
|
my $called_function = $$functions{$called_name};
|
|
|
|
|
|
|
|
my $called_module16 = $called_function->module16;
|
|
|
|
my $called_module32 = $called_function->module32;
|
2000-04-29 16:24:11 +02:00
|
|
|
if(defined($module32) &&
|
|
|
|
defined($called_module16) && !defined($called_module32) &&
|
2002-06-01 04:55:48 +02:00
|
|
|
$name ne $called_name)
|
2000-04-29 16:24:11 +02:00
|
|
|
{
|
|
|
|
$output->write("$file: $module: $name: illegal call to $called_name (Win32 -> Win16)\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($options->cross_call_unicode_ascii) {
|
2003-01-02 20:26:11 +01:00
|
|
|
if($name =~ /(?<!A)W$/) {
|
2000-04-29 16:24:11 +02:00
|
|
|
for my $called_name (@called_names) {
|
|
|
|
if($called_name =~ /A$/) {
|
|
|
|
$output->write("$file: $module: $name: illegal call to $called_name (Unicode -> ASCII)\n");
|
|
|
|
}
|
1999-10-31 03:08:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-23 17:14:20 +02:00
|
|
|
1;
|