1
0
mirror of https://github.com/solemnwarning/ipxwrapper synced 2024-12-30 16:45:37 +01:00

Record times taken within stub functions

Reporting not done yet.

Call logging broken (for now).
This commit is contained in:
Daniel Collins 2019-08-23 20:25:14 +01:00
parent fd4d78575d
commit 7e6280b560
15 changed files with 594 additions and 226 deletions

View File

@ -1,5 +1,5 @@
# IPXWrapper - Makefile # IPXWrapper - Makefile
# Copyright (C) 2011-2017 Daniel Collins <solemnwarning@solemnwarning.net> # Copyright (C) 2011-2019 Daniel Collins <solemnwarning@solemnwarning.net>
# #
# This program is free software; you can redistribute it and/or modify it # This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by # under the terms of the GNU General Public License version 2 as published by
@ -86,62 +86,62 @@ dist: all
IPXWRAPPER_OBJS := src/ipxwrapper.o src/winsock.o src/ipxwrapper_stubs.o src/log.o src/common.o \ IPXWRAPPER_OBJS := src/ipxwrapper.o src/winsock.o src/ipxwrapper_stubs.o src/log.o src/common.o \
src/interface.o src/router.o src/ipxwrapper.def src/addrcache.o src/config.o src/addr.o \ src/interface.o src/router.o src/ipxwrapper.def src/addrcache.o src/config.o src/addr.o \
src/firewall.o src/wpcap_stubs.o src/ethernet.o src/firewall.o src/ethernet.o src/funcprof.o
ipxwrapper.dll: $(IPXWRAPPER_OBJS) ipxwrapper.dll: $(IPXWRAPPER_OBJS)
echo 'const char *version_string = "$(VERSION)", *compile_time = "'`date`'";' | $(CC) -c -x c -o version.o - echo 'const char *version_string = "$(VERSION)", *compile_time = "'`date`'";' | $(CC) -c -x c -o version.o -
$(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -shared -o $@ $^ version.o -liphlpapi -lversion -lole32 -loleaut32 $(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -shared -o $@ $^ version.o -liphlpapi -lversion -lole32 -loleaut32
src/ipxwrapper_stubs.s: src/ipxwrapper_stubs.txt src/ipxwrapper_stubs.s: src/ipxwrapper_stubs.txt
perl mkstubs.pl src/ipxwrapper_stubs.txt src/ipxwrapper_stubs.s 0 perl mkstubs.pl src/ipxwrapper_stubs.txt src/ipxwrapper_stubs.s
# #
# WSOCK32.DLL # WSOCK32.DLL
# #
wsock32.dll: src/stubdll.o src/wsock32_stubs.o src/log.o src/common.o src/config.o src/addr.o src/wsock32.def wsock32.dll: src/stubdll.o src/wsock32_stubs.o src/log.o src/common.o src/config.o src/addr.o src/funcprof.o src/wsock32.def
$(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -shared -o $@ $^ $(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -shared -o $@ $^
src/wsock32_stubs.s: src/wsock32_stubs.txt src/wsock32_stubs.s: src/wsock32_stubs.txt
perl mkstubs.pl src/wsock32_stubs.txt src/wsock32_stubs.s 1 perl mkstubs.pl src/wsock32_stubs.txt src/wsock32_stubs.s
# #
# MSWSOCK.DLL # MSWSOCK.DLL
# #
mswsock.dll: src/stubdll.o src/mswsock_stubs.o src/log.o src/common.o src/config.o src/addr.o src/mswsock.def mswsock.dll: src/stubdll.o src/mswsock_stubs.o src/log.o src/common.o src/config.o src/addr.o src/funcprof.o src/mswsock.def
$(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -shared -o $@ $^ $(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -shared -o $@ $^
src/mswsock_stubs.s: src/mswsock_stubs.txt src/mswsock_stubs.s: src/mswsock_stubs.txt
perl mkstubs.pl src/mswsock_stubs.txt src/mswsock_stubs.s 2 perl mkstubs.pl src/mswsock_stubs.txt src/mswsock_stubs.s
# #
# DPWSOCKX.DLL # DPWSOCKX.DLL
# #
dpwsockx.dll: src/directplay.o src/log.o src/dpwsockx_stubs.o src/common.o src/config.o src/addr.o src/dpwsockx.def dpwsockx.dll: src/directplay.o src/log.o src/dpwsockx_stubs.o src/common.o src/config.o src/addr.o src/funcprof.o src/dpwsockx.def
$(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -shared -o $@ $^ -lwsock32 $(CC) $(CFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -shared -o $@ $^ -lwsock32
src/dpwsockx_stubs.s: src/dpwsockx_stubs.txt src/dpwsockx_stubs.s: src/dpwsockx_stubs.txt
perl mkstubs.pl src/dpwsockx_stubs.txt src/dpwsockx_stubs.s 3 perl mkstubs.pl src/dpwsockx_stubs.txt src/dpwsockx_stubs.s
# #
# IPXCONFIG.EXE # IPXCONFIG.EXE
# #
IPXCONFIG_OBJS := src/ipxconfig.o icons/ipxconfig.o src/addr.o src/interface.o src/common.o \ IPXCONFIG_OBJS := src/ipxconfig.o icons/ipxconfig.o src/addr.o src/interface.o src/common.o \
src/config.o src/wpcap_stubs.o src/config.o src/ipxconfig_stubs.o src/funcprof.o
ipxconfig.exe: $(IPXCONFIG_OBJS) ipxconfig.exe: $(IPXCONFIG_OBJS)
$(CXX) $(CXXFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -static-libstdc++ -mwindows -o $@ $^ -liphlpapi -lcomctl32 -lws2_32 $(CXX) $(CXXFLAGS) -Wl,--enable-stdcall-fixup -static-libgcc -static-libstdc++ -mwindows -o $@ $^ -liphlpapi -lcomctl32 -lws2_32
src/ipxconfig_stubs.s: src/ipxwrapper_stubs.txt
perl mkstubs.pl src/ipxconfig_stubs.txt src/ipxconfig_stubs.s
# #
# SHARED TARGETS # SHARED TARGETS
# #
src/wpcap_stubs.s: src/wpcap_stubs.txt
perl mkstubs.pl src/wpcap_stubs.txt src/wpcap_stubs.s 5
icons/%.o: icons/%.rc icons/%.ico icons/%.o: icons/%.rc icons/%.ico
$(WINDRES) $< -O coff -o $@ $(WINDRES) $< -O coff -o $@

View File

@ -1,5 +1,5 @@
# IPXWrapper - Generate assembly stub functions # IPXWrapper - Generate assembly stub functions
# Copyright (C) 2008-2011 Daniel Collins <solemnwarning@solemnwarning.net> # Copyright (C) 2008-2019 Daniel Collins <solemnwarning@solemnwarning.net>
# #
# This program is free software; you can redistribute it and/or modify it # This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by # under the terms of the GNU General Public License version 2 as published by
@ -17,75 +17,239 @@
use strict; use strict;
use warnings; use warnings;
if(@ARGV != 3) { if(@ARGV != 2) {
print STDERR "Usage: mkdll.pl <function list> <output file> <dll number>\n"; print STDERR "Usage: mkdll.pl <stub definitions file> <asm output file>\n";
exit(1); exit(1);
} }
# Must be kept in sync with dll_names in common.c!
my %DLL_INDICES = (
"ipxwrapper.dll" => 0,
"wsock32.dll" => 1,
"mswsock.dll" => 2,
"dpwsockx.dll" => 3,
"ws2_32.dll" => 4,
"wpcap.dll" => 5,
);
my $stub_file = $ARGV[0]; my $stub_file = $ARGV[0];
my $asm_file = $ARGV[1]; my $asm_file = $ARGV[1];
my $dllnum = $ARGV[2];
my $do_logging = ($dllnum != 0);
open(STUBS, "<$stub_file") or die("Cannot open $stub_file: $!"); open(STUBS, "<$stub_file") or die("Cannot open $stub_file: $!");
open(CODE, ">$asm_file") or die("Cannot open $asm_file: $!"); open(CODE, ">$asm_file") or die("Cannot open $asm_file: $!");
my @stubs = (); my @stubs = ();
my @stubs_dll = ();
foreach my $line(<STUBS>) { # Skip over header
(scalar <STUBS>);
(scalar <STUBS>);
# Read in stub definitions
foreach my $line(<STUBS>)
{
$line =~ s/[\r\n]//g; $line =~ s/[\r\n]//g;
if($line ne "") { if($line ne "") {
my ($func, $dn) = split(/:/, $line); my ($name, $target_dll, $target_func, $params) = split(/\s+/, $line);
$dn = $dllnum if(!defined($dn));
my $sym = $func; my $target_dll_index = $DLL_INDICES{$target_dll}
$sym =~ s/^r_//; // die "Unknown DLL: $target_dll\n";
push(@stubs, {"name" => $func, "sym" => $sym, "dllnum" => $dn}); push(@stubs, {
name => $name,
target_dll => $target_dll,
target_dll_index => $target_dll_index,
target_func => $target_func,
params => $params,
});
} }
} }
print CODE "section .rdata:\n"; print CODE <<"END";
extern _QueryPerformanceCounter\@4
foreach my $func(@stubs) { extern _find_sym
print CODE "\t".$func->{"name"}."_sym:\tdb\t'".$func->{"sym"}."', 0\n"; extern _log_call
extern _fprof_record_timed
extern _fprof_record_untimed
struc FuncStats
.func_name: resd 1
.min_time: resd 1
.max_time: resd 1
.total_time: resd 1
.n_calls: resd 1
.cs: resb 24
endstruc
END
print CODE <<"END";
section .rdata
END
foreach my $func(@stubs)
{
print CODE <<"END";
$func->{name}_name: db '$func->{name}', 0
$func->{name}_target_func: db '$func->{target_func}', 0
END
} }
print CODE "\nsection .data\n"; print CODE <<"END";
section .data
END
foreach my $func(@stubs) { foreach my $func(@stubs)
print CODE "\t".$func->{"name"}."_addr:\tdd\t0\n"; {
print CODE <<"END";
$func->{name}_addr: dd 0
END
} }
print CODE "\nsection .text\n"; print CODE <<"END";
print CODE "\textern\t_find_sym\n"; global _stub_fstats
print CODE "\textern\t_log_call\n" if($do_logging); _stub_fstats:
END
foreach my $func(@stubs) { foreach my $func(@stubs)
my $f_name = $func->{"name"}; {
print CODE <<"END";
print CODE "\nglobal\t_$f_name\n"; $func->{name}_fstats:
print CODE "_$f_name:\n"; istruc FuncStats
at FuncStats.func_name, dd $func->{name}_name
if($do_logging) { iend
print CODE "\tpush\tdword ".$func->{"dllnum"}."\n"; END
print CODE "\tpush\t$f_name\_sym\n"; }
print CODE "\tpush\tdword $dllnum\n";
print CODE "\tcall\t_log_call\n"; my $num_funcs = (scalar @stubs);
print CODE <<"END";
global _num_stubs
_num_stubs: dd $num_funcs
END
print CODE <<"END";
section .text
END
foreach my $func(@stubs)
{
if(defined $func->{params})
{
my $to_copy = $func->{params};
print CODE <<"END";
global _$func->{name}
_$func->{name}:
; Check if we have address cached
cmp dword [$func->{name}_addr], 0
jne $func->{name}_go
; Fetch target function address
push $func->{name}_target_func
push dword $func->{target_dll_index}
call _find_sym
mov dword [$func->{name}_addr], eax
$func->{name}_go:
push ebp
mov ebp, esp
; Push tick count onto stack (ebp - 8)
sub esp, 8
push esp
call _QueryPerformanceCounter\@4
; Copy original arguments ($to_copy bytes)
END
for(; $to_copy >= 4;)
{
$to_copy -= 4;
print CODE <<"END";
push dword [ebp + 4 + 4 + $to_copy]
END
}
for(; $to_copy >= 2;)
{
$to_copy -= 2;
print CODE <<"END";
push word [ebp + 4 + 4 + $to_copy]
END
}
for(; $to_copy >= 1;)
{
$to_copy -= 1;
print CODE <<"END";
push byte [ebp + 4 + 4 + $to_copy]
END
}
print CODE <<"END";
; Call target function
call [$func->{name}_addr]
; Push target function return value onto stack (ebp - 12)
push eax
; Push tick count onto stack (ebp - 20)
sub esp, 8
push esp
call _QueryPerformanceCounter\@4
; End tick parameter to _fprof_record_timed
push dword ebp
sub dword [esp], 20
; Start tick parameter to _fprof_record_untimed
push dword ebp
sub dword [esp], 8
; FuncStats parameter to _fprof_record_untimed
push dword $func->{name}_fstats
; Record profiling data
call _fprof_record_timed
add esp, 8 ; Pop end tick count
pop eax ; Pop return value
add esp, 8 ; Pop start tick count
pop ebp ; Restore caller's ebp
ret $func->{params}
END
}
else{
print CODE <<"END";
global _$func->{name}
_$func->{name}:
; Check if we have address cached
cmp dword [$func->{name}_addr], 0
jne $func->{name}_go
; Fetch target function address
push $func->{name}_target_func
push dword $func->{target_dll_index}
call _find_sym
mov dword [$func->{name}_addr], eax
$func->{name}_go:
; Record that we were called
push dword $func->{name}_fstats
call _fprof_record_untimed
; Jump into target function. We have left the stack as we found it
; so it can take over our frame.
jmp [$func->{name}_addr]
END
} }
print CODE "\tcmp\tdword [$f_name\_addr], 0\n";
print CODE "\tjne\t$f_name\_jmp\n";
print CODE "\tpush\t$f_name\_sym\n";
print CODE "\tpush\tdword ".$func->{"dllnum"}."\n";
print CODE "\tcall\t_find_sym\n";
print CODE "\tmov\t[$f_name\_addr], eax\n";
print CODE "\t$f_name\_jmp:\n";
print CODE "\tjmp\t[$f_name\_addr]\n";
} }
close(CODE); close(CODE);

View File

@ -1,5 +1,5 @@
/* IPXWrapper - Common functions /* IPXWrapper - Common functions
* Copyright (C) 2011 Daniel Collins <solemnwarning@solemnwarning.net> * Copyright (C) 2011-2019 Daniel Collins <solemnwarning@solemnwarning.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by * under the terms of the GNU General Public License version 2 as published by
@ -23,6 +23,7 @@
enum ipx_log_level min_log_level = LOG_INFO; enum ipx_log_level min_log_level = LOG_INFO;
/* Must be kept in sync with DLL_INDICES in mkstubs.pl! */
static const char *dll_names[] = { static const char *dll_names[] = {
"ipxwrapper.dll", "ipxwrapper.dll",
"wsock32.dll", "wsock32.dll",

View File

@ -1,5 +1,5 @@
/* IPXWrapper - Common header /* IPXWrapper - Common header
* Copyright (C) 2011 Daniel Collins <solemnwarning@solemnwarning.net> * Copyright (C) 2011-2019 Daniel Collins <solemnwarning@solemnwarning.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by * under the terms of the GNU General Public License version 2 as published by
@ -24,6 +24,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "addr.h" #include "addr.h"
#include "funcprof.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -39,6 +40,10 @@ enum ipx_log_level {
extern enum ipx_log_level min_log_level; extern enum ipx_log_level min_log_level;
/* Defined by stubs */
extern struct FuncStats stub_fstats[];
extern unsigned int num_stubs;
const char *w32_error(DWORD errnum); const char *w32_error(DWORD errnum);
HKEY reg_open_main(bool readwrite); HKEY reg_open_main(bool readwrite);

View File

@ -1,5 +1,5 @@
/* ipxwrapper - DirectPlay service provider /* ipxwrapper - DirectPlay service provider
* Copyright (C) 2011 Daniel Collins <solemnwarning@solemnwarning.net> * Copyright (C) 2011-2019 Daniel Collins <solemnwarning@solemnwarning.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by * under the terms of the GNU General Public License version 2 as published by
@ -725,6 +725,8 @@ HRESULT WINAPI SPInit(LPSPINITDATA data) {
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
if(fdwReason == DLL_PROCESS_ATTACH) if(fdwReason == DLL_PROCESS_ATTACH)
{ {
fprof_init(stub_fstats, num_stubs);
log_open("ipxwrapper.log"); log_open("ipxwrapper.log");
min_log_level = get_main_config().log_level; min_log_level = get_main_config().log_level;
@ -743,6 +745,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
unload_dlls(); unload_dlls();
log_close(); log_close();
fprof_cleanup(stub_fstats, num_stubs);
} }
return TRUE; return TRUE;

View File

@ -1,9 +1,10 @@
r_SPInit Function name Target DLL Target function
DPWS_GetEnumPort ------------------------------------------------------------
DPWS_BuildIPMessageHeader r_SPInit dpwsockx.dll SPInit
DPWS_GetEnumPort dpwsockx.dll DPWS_GetEnumPort
WSACreateEvent:4 DPWS_BuildIPMessageHeader dpwsockx.dll DPWS_BuildIPMessageHeader
WSACloseEvent:4 WSACreateEvent ws2_32.dll WSACreateEvent
WSAEventSelect:4 WSACloseEvent ws2_32.dll WSACloseEvent
WSAResetEvent:4 WSAEventSelect ws2_32.dll WSAEventSelect
WSASetEvent:4 WSAResetEvent ws2_32.dll WSAResetEvent
WSASetEvent ws2_32.dll WSASetEvent

128
src/funcprof.c Normal file
View File

@ -0,0 +1,128 @@
/* IPXWrapper - Function profiling functions
* Copyright (C) 2019 Daniel Collins <solemnwarning@solemnwarning.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* This program 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <windows.h>
#include "common.h"
#include "funcprof.h"
void fprof_init(struct FuncStats *fstats, size_t n_fstats)
{
for(size_t i = 0; i < n_fstats; ++i)
{
fstats[i].min_time = 0.0;
fstats[i].max_time = 0.0;
fstats[i].total_time = 0.0;
fstats[i].n_calls = 0;
InitializeCriticalSectionAndSpinCount(&(fstats[i].cs), 0x80000000);
}
}
void fprof_cleanup(struct FuncStats *fstats, size_t n_fstats)
{
for(size_t i = 0; i < n_fstats; ++i)
{
DeleteCriticalSection(&(fstats[i].cs));
}
}
__stdcall void fprof_record_timed(struct FuncStats *fstats, const LARGE_INTEGER *start, const LARGE_INTEGER *end)
{
EnterCriticalSection(&(fstats->cs));
float this_time = end->QuadPart - start->QuadPart;
if(fstats->n_calls == 0)
{
fstats->min_time = this_time;
fstats->max_time = this_time;
fstats->total_time = this_time;
}
else{
if(fstats->min_time > this_time)
{
fstats->min_time = this_time;
}
if(fstats->max_time < this_time)
{
fstats->max_time = this_time;
}
fstats->total_time += this_time;
}
++(fstats->n_calls);
LeaveCriticalSection(&(fstats->cs));
}
__stdcall void fprof_record_untimed(struct FuncStats *fstats)
{
EnterCriticalSection(&(fstats->cs));
++(fstats->n_calls);
LeaveCriticalSection(&(fstats->cs));
}
void fprof_report(const char *dll_name, struct FuncStats *fstats, size_t n_fstats)
{
LARGE_INTEGER freq; /* TODO: Cache somewhere */
QueryPerformanceFrequency(&freq);
const float TICKS_PER_USEC = freq.QuadPart / 1000000.0;
for(size_t i = 0; i < n_fstats; ++i)
{
EnterCriticalSection(&(fstats[i].cs));
float min_time = fstats[i].min_time;
float max_time = fstats[i].max_time;
float total_time = fstats[i].total_time;
unsigned int n_calls = fstats[i].n_calls;
fstats[i].n_calls = 0;
LeaveCriticalSection(&(fstats[i].cs));
if(n_calls > 0)
{
if(total_time > 0.0)
{
log_printf(LOG_INFO,
"%s:%s was called %u times duration min %fus max %fus avg %fus",
dll_name,
fstats[i].func_name,
n_calls,
(min_time / TICKS_PER_USEC),
(max_time / TICKS_PER_USEC),
((total_time / (float)(n_calls)) / TICKS_PER_USEC));
}
else{
log_printf(LOG_INFO,
"%s:%s was called %u times",
dll_name,
fstats[i].func_name,
n_calls);
}
}
}
}

39
src/funcprof.h Normal file
View File

@ -0,0 +1,39 @@
/* IPXWrapper - Function profiling functions
* Copyright (C) 2019 Daniel Collins <solemnwarning@solemnwarning.net>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* This program 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef IPXWRAPPER_FUNCPROF_H
#define IPXWRAPPER_FUNCPROF_H
#include <windows.h>
struct FuncStats
{
const char *func_name;
float min_time, max_time, total_time;
unsigned int n_calls;
CRITICAL_SECTION cs;
};
void fprof_init(struct FuncStats *fstats, size_t n_fstats);
void fprof_cleanup(struct FuncStats *fstats, size_t n_fstats);
__stdcall void fprof_record_timed(struct FuncStats *fstats, const LARGE_INTEGER *start, const LARGE_INTEGER *end);
__stdcall void fprof_record_untimed(struct FuncStats *fstats);
void fprof_report(const char *dll_name, struct FuncStats *fstats, size_t n_fstats);
#endif /* !IPXWRAPPER_FUNCPROF_H */

10
src/ipxconfig_stubs.txt Normal file
View File

@ -0,0 +1,10 @@
Function name Target DLL Target function Parameters (bytes)
-----------------------------------------------------------------------------
pcap_open wpcap.dll pcap_open
pcap_close wpcap.dll pcap_close
pcap_findalldevs_ex wpcap.dll pcap_findalldevs_ex
pcap_freealldevs wpcap.dll pcap_freealldevs
pcap_getevent wpcap.dll pcap_getevent
pcap_dispatch wpcap.dll pcap_dispatch
pcap_geterr wpcap.dll pcap_geterr
pcap_sendpacket wpcap.dll pcap_sendpacket

View File

@ -1,5 +1,5 @@
/* ipxwrapper - Library functions /* ipxwrapper - Library functions
* Copyright (C) 2008-2014 Daniel Collins <solemnwarning@solemnwarning.net> * Copyright (C) 2008-2019 Daniel Collins <solemnwarning@solemnwarning.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by * under the terms of the GNU General Public License version 2 as published by
@ -63,6 +63,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ {
if(fdwReason == DLL_PROCESS_ATTACH) if(fdwReason == DLL_PROCESS_ATTACH)
{ {
fprof_init(stub_fstats, num_stubs);
log_open("ipxwrapper.log"); log_open("ipxwrapper.log");
log_printf(LOG_INFO, "IPXWrapper %s", version_string); log_printf(LOG_INFO, "IPXWrapper %s", version_string);
@ -136,6 +138,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
FreeLibrary(kernel32); FreeLibrary(kernel32);
kernel32 = NULL; kernel32 = NULL;
} }
fprof_cleanup(stub_fstats, num_stubs);
} }
return TRUE; return TRUE;

View File

@ -1,37 +1,48 @@
inet_addr:4 Function name Target DLL Target function Parameters (bytes)
WSAStartup:4 -------------------------------------------------------------------------------
WSACleanup:4 inet_addr ws2_32.dll inet_addr 4
WSASetLastError:4 WSAStartup ws2_32.dll WSAStartup 8
WSAGetLastError:4 WSACleanup ws2_32.dll WSACleanup 0
htonl:4 WSASetLastError ws2_32.dll WSASetLastError 4
ntohl:4 WSAGetLastError ws2_32.dll WSAGetLastError 0
htons:4 htonl ws2_32.dll htonl 4
ntohs:4 ntohl ws2_32.dll ntohl 4
select:4 htons ws2_32.dll htons 4
r_listen:4 ntohs ws2_32.dll ntohs 4
r_accept:4 select ws2_32.dll select 20
WSACreateEvent:4 r_listen ws2_32.dll listen 8
WSAEventSelect:4 r_accept ws2_32.dll accept 12
WSACloseEvent:4 WSACreateEvent ws2_32.dll WSACreateEvent 0
WSAResetEvent:4 WSAEventSelect ws2_32.dll WSAEventSelect 12
WSASetEvent:4 WSACloseEvent ws2_32.dll WSACloseEvent 4
r_EnumProtocolsA:2 WSAResetEvent ws2_32.dll WSAResetEvent 4
r_EnumProtocolsW:2 WSASetEvent ws2_32.dll WSASetEvent 4
r_WSARecvEx:2 r_EnumProtocolsA mswsock.dll EnumProtocolsA 12
r_bind:4 r_EnumProtocolsW mswsock.dll EnumProtocolsW 12
r_closesocket:4 r_WSARecvEx mswsock.dll WSARecvEx 16
r_getsockname:4 r_bind ws2_32.dll bind 12
r_getsockopt:4 r_closesocket ws2_32.dll closesocket 4
r_recv:4 r_getsockname ws2_32.dll getsockname 12
r_recvfrom:4 r_getsockopt ws2_32.dll getsockopt 20
r_sendto:4 r_recv ws2_32.dll recv 16
r_setsockopt:4 r_recvfrom ws2_32.dll recvfrom 24
r_shutdown:4 r_sendto ws2_32.dll sendto 24
r_socket:4 r_setsockopt ws2_32.dll setsockopt 20
r_ioctlsocket:4 r_shutdown ws2_32.dll shutdown 8
r_connect:4 r_socket ws2_32.dll socket 12
r_send:4 r_ioctlsocket ws2_32.dll ioctlsocket 12
r_getpeername:4 r_connect ws2_32.dll connect 12
inet_ntoa:4 r_send ws2_32.dll send 16
__WSAFDIsSet:4 r_getpeername ws2_32.dll getpeername 12
r_WSAAsyncSelect:4 inet_ntoa ws2_32.dll inet_ntoa 4
__WSAFDIsSet ws2_32.dll __WSAFDIsSet 8
r_WSAAsyncSelect ws2_32.dll WSAAsyncSelect 16
pcap_open wpcap.dll pcap_open
pcap_close wpcap.dll pcap_close
pcap_findalldevs_ex wpcap.dll pcap_findalldevs_ex
pcap_freealldevs wpcap.dll pcap_freealldevs
pcap_getevent wpcap.dll pcap_getevent
pcap_dispatch wpcap.dll pcap_dispatch
pcap_geterr wpcap.dll pcap_geterr
pcap_sendpacket wpcap.dll pcap_sendpacket

View File

@ -1,35 +1,37 @@
ServiceMain Function name Target DLL Target function Parameters (bytes)
SvchostPushServiceGlobals --------------------------------------------------------------------------------------------------
AcceptEx ServiceMain mswsock.dll ServiceMain
EnumProtocolsA:0 SvchostPushServiceGlobals mswsock.dll SvchostPushServiceGlobals
EnumProtocolsW:0 AcceptEx mswsock.dll AcceptEx 32
GetAcceptExSockaddrs EnumProtocolsA ipxwrapper.dll EnumProtocolsA 12
GetAddressByNameA EnumProtocolsW ipxwrapper.dll EnumProtocolsW 12
GetAddressByNameW GetAcceptExSockaddrs mswsock.dll GetAcceptExSockaddrs 32
GetNameByTypeA GetAddressByNameA mswsock.dll GetAddressByNameA 40
GetNameByTypeW GetAddressByNameW mswsock.dll GetAddressByNameW 40
GetServiceA GetNameByTypeA mswsock.dll GetNameByTypeA 12
GetServiceW GetNameByTypeW mswsock.dll GetNameByTypeW 12
GetTypeByNameA GetServiceA mswsock.dll GetServiceA 28
GetTypeByNameW GetServiceW mswsock.dll GetServiceW 28
MigrateWinsockConfiguration GetTypeByNameA mswsock.dll GetTypeByNameA 8
NPLoadNameSpaces GetTypeByNameW mswsock.dll GetTypeByNameW 8
NSPStartup MigrateWinsockConfiguration mswsock.dll MigrateWinsockConfiguration
SetServiceA NPLoadNameSpaces mswsock.dll NPLoadNameSpaces
SetServiceW NSPStartup mswsock.dll NSPStartup 8
StartWsdpService SetServiceA mswsock.dll SetServiceA 24
StopWsdpService SetServiceW mswsock.dll SetServiceW 24
TransmitFile StartWsdpService mswsock.dll StartWsdpService
WSARecvEx:0 StopWsdpService mswsock.dll StopWsdpService
WSPStartup TransmitFile mswsock.dll TransmitFile 28
dn_expand WSARecvEx ipxwrapper.dll WSARecvEx 16
getnetbyname WSPStartup mswsock.dll WSPStartup 76
inet_network dn_expand mswsock.dll dn_expand
rcmd getnetbyname mswsock.dll getnetbyname
rexec inet_network mswsock.dll inet_network
rresvport rcmd mswsock.dll rcmd
s_perror rexec mswsock.dll rexec
sethostname rresvport mswsock.dll rresvport
inet_addr s_perror mswsock.dll s_perror
WSHEnumProtocols:0 sethostname mswsock.dll sethostname
ntohs:1 inet_addr mswsock.dll inet_addr 4
WSHEnumProtocols ipxwrapper.dll WSHEnumProtocols 16
ntohs wsock32.dll ntohs 4

View File

@ -1,5 +1,5 @@
/* IPXWrapper - Stub DLL functions /* IPXWrapper - Stub DLL functions
* Copyright (C) 2008-2011 Daniel Collins <solemnwarning@solemnwarning.net> * Copyright (C) 2008-2019 Daniel Collins <solemnwarning@solemnwarning.net>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by * under the terms of the GNU General Public License version 2 as published by
@ -21,10 +21,13 @@
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "funcprof.h"
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
if(fdwReason == DLL_PROCESS_ATTACH) if(fdwReason == DLL_PROCESS_ATTACH)
{ {
fprof_init(stub_fstats, num_stubs);
log_open("ipxwrapper.log"); log_open("ipxwrapper.log");
min_log_level = get_main_config().log_level; min_log_level = get_main_config().log_level;
@ -43,6 +46,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
unload_dlls(); unload_dlls();
log_close(); log_close();
fprof_cleanup(stub_fstats, num_stubs);
} }
return TRUE; return TRUE;

View File

@ -1,8 +0,0 @@
pcap_open
pcap_close
pcap_findalldevs_ex
pcap_freealldevs
pcap_getevent
pcap_dispatch
pcap_geterr
pcap_sendpacket

View File

@ -1,76 +1,78 @@
accept:0 Function name Target DLL Target function Parameters (bytes)
bind:0 --------------------------------------------------------------------------------------------------
closesocket:0 accept ipxwrapper.dll accept 12
connect:0 bind ipxwrapper.dll bind 12
getpeername:0 closesocket ipxwrapper.dll closesocket 4
getsockname:0 connect ipxwrapper.dll connect 12
getsockopt:0 getpeername ipxwrapper.dll getpeername 12
htonl getsockname ipxwrapper.dll getsockname 12
htons getsockopt ipxwrapper.dll getsockopt 20
inet_addr htonl wsock32.dll htonl 4
inet_ntoa htons wsock32.dll htons 4
ioctlsocket:0 inet_addr wsock32.dll inet_addr 4
listen:0 inet_ntoa wsock32.dll inet_ntoa 4
ntohl ioctlsocket ipxwrapper.dll ioctlsocket 12
ntohs listen ipxwrapper.dll listen 8
recv:0 ntohl wsock32.dll ntohl 4
recvfrom:0 ntohs wsock32.dll ntohs 4
select recv ipxwrapper.dll recv 16
send:0 recvfrom ipxwrapper.dll recvfrom 24
sendto:0 select wsock32.dll select 20
setsockopt:0 send ipxwrapper.dll send 16
shutdown:0 sendto ipxwrapper.dll sendto 24
socket:0 setsockopt ipxwrapper.dll setsockopt 20
MigrateWinsockConfiguration shutdown ipxwrapper.dll shutdown 8
gethostbyaddr socket ipxwrapper.dll socket 12
gethostbyname MigrateWinsockConfiguration wsock32.dll MigrateWinsockConfiguration
getprotobyname gethostbyaddr wsock32.dll gethostbyaddr 12
getprotobynumber gethostbyname wsock32.dll gethostbyname 4
getservbyname getprotobyname wsock32.dll getprotobyname 4
getservbyport getprotobynumber wsock32.dll getprotobynumber 4
gethostname getservbyname wsock32.dll getservbyname 8
WSAAsyncSelect:0 getservbyport wsock32.dll getservbyport 8
WSAAsyncGetHostByAddr gethostname wsock32.dll gethostname 8
WSAAsyncGetHostByName WSAAsyncSelect ipxwrapper.dll WSAAsyncSelect 16
WSAAsyncGetProtoByNumber WSAAsyncGetHostByAddr wsock32.dll WSAAsyncGetHostByAddr 28
WSAAsyncGetProtoByName WSAAsyncGetHostByName wsock32.dll WSAAsyncGetHostByName 20
WSAAsyncGetServByPort WSAAsyncGetProtoByNumber wsock32.dll WSAAsyncGetProtoByNumber 20
WSAAsyncGetServByName WSAAsyncGetProtoByName wsock32.dll WSAAsyncGetProtoByName 20
WSACancelAsyncRequest WSAAsyncGetServByPort wsock32.dll WSAAsyncGetServByPort 24
WSASetBlockingHook WSAAsyncGetServByName wsock32.dll WSAAsyncGetServByName 24
WSAUnhookBlockingHook WSACancelAsyncRequest wsock32.dll WSACancelAsyncRequest 4
WSAGetLastError WSASetBlockingHook wsock32.dll WSASetBlockingHook 4
WSASetLastError WSAUnhookBlockingHook wsock32.dll WSAUnhookBlockingHook 0
WSACancelBlockingCall WSAGetLastError wsock32.dll WSAGetLastError 0
WSAIsBlocking WSASetLastError wsock32.dll WSASetLastError 4
WSAStartup WSACancelBlockingCall wsock32.dll WSACancelBlockingCall 0
WSACleanup WSAIsBlocking wsock32.dll WSAIsBlocking 0
__WSAFDIsSet WSAStartup wsock32.dll WSAStartup 8
WEP WSACleanup wsock32.dll WSACleanup 0
WSApSetPostRoutine __WSAFDIsSet wsock32.dll __WSAFDIsSet 8
inet_network WEP wsock32.dll WEP
getnetbyname WSApSetPostRoutine wsock32.dll WSApSetPostRoutine
rcmd inet_network wsock32.dll inet_network
rexec getnetbyname wsock32.dll getnetbyname
rresvport rcmd wsock32.dll rcmd
sethostname rexec wsock32.dll rexec
dn_expand rresvport wsock32.dll rresvport
WSARecvEx:0 sethostname wsock32.dll sethostname
s_perror dn_expand wsock32.dll dn_expand
GetAddressByNameA WSARecvEx ipxwrapper.dll WSARecvEx 16
GetAddressByNameW s_perror wsock32.dll s_perror
EnumProtocolsA:0 GetAddressByNameA wsock32.dll GetAddressByNameA 40
EnumProtocolsW:0 GetAddressByNameW wsock32.dll GetAddressByNameW 40
GetTypeByNameA EnumProtocolsA ipxwrapper.dll EnumProtocolsA 12
GetTypeByNameW EnumProtocolsW ipxwrapper.dll EnumProtocolsW 12
GetNameByTypeA GetTypeByNameA wsock32.dll GetTypeByNameA 8
GetNameByTypeW GetTypeByNameW wsock32.dll GetTypeByNameW 8
SetServiceA GetNameByTypeA wsock32.dll GetNameByTypeA 12
SetServiceW GetNameByTypeW wsock32.dll GetNameByTypeW 12
GetServiceA SetServiceA wsock32.dll SetServiceA 24
GetServiceW SetServiceW wsock32.dll SetServiceW 24
NPLoadNameSpaces GetServiceA wsock32.dll GetServiceA 28
TransmitFile GetServiceW wsock32.dll GetServiceW 28
AcceptEx NPLoadNameSpaces wsock32.dll NPLoadNameSpaces
GetAcceptExSockaddrs TransmitFile wsock32.dll TransmitFile 28
WSHEnumProtocols:0 AcceptEx wsock32.dll AcceptEx 32
GetAcceptExSockaddrs wsock32.dll GetAcceptExSockaddrs 32
WSHEnumProtocols ipxwrapper.dll WSHEnumProtocols 16