X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=winapi.py;h=3777dcbf3c8baab08f5a3818a1b64da977e91f0d;hb=e2dfa2ec912e22d838fcbe8ae019b6b3cfab3103;hp=5345a0dc5bd62ec527298d7cdf371051a06d1fa5;hpb=f2efceaae999b2c5b9f2a6561915f9765e22dcc7;p=apitrace diff --git a/winapi.py b/winapi.py index 5345a0d..3777dcb 100644 --- a/winapi.py +++ b/winapi.py @@ -151,73 +151,3 @@ IUnknown.methods = ( ) -class DllFunction(Function): - - def get_true_pointer(self): - ptype = self.pointer_type() - pvalue = self.pointer_value() - print ' if(!g_hDll) {' - print ' g_hDll = LoadLibrary(g_szDll);' - print ' if(!g_hDll)' - self.fail_impl() - print ' }' - print ' if(!%s) {' % (pvalue,) - print ' %s = (%s)GetProcAddress(g_hDll, "%s");' % (pvalue, ptype, self.name) - print ' if(!%s)' % (pvalue,) - self.fail_impl() - print ' }' - - -class Dll: - - def __init__(self, name): - self.name = name - self.functions = [] - if self not in towrap: - towrap.append(self) - - def wrap_name(self): - return "Wrap" + self.name - - def wrap_pre_decl(self): - pass - - def wrap_decl(self): - print 'static HINSTANCE g_hDll = NULL;' - print 'static TCHAR g_szDll[MAX_PATH] = {0};' - print - print 'BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);' - print - for function in self.functions: - function.wrap_decl() - print - - def wrap_impl(self): - print r'BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {' - print r' switch(fdwReason) {' - print r' case DLL_PROCESS_ATTACH:' - print r' if(!GetSystemDirectory(g_szDll, MAX_PATH))' - print r' return FALSE;' - print r' _tcscat(g_szDll, TEXT("\\%s.dll"));' % self.name - print r' Trace::Open("%s");' % self.name - print r' case DLL_THREAD_ATTACH:' - print r' return TRUE;' - print r' case DLL_THREAD_DETACH:' - print r' return TRUE;' - print r' case DLL_PROCESS_DETACH:' - print r' Trace::Close();' - print r' if(g_hDll) {' - print r' FreeLibrary(g_hDll);' - print r' g_hDll = NULL;' - print r' }' - print r' return TRUE;' - print r' }' - print r' (void)hinstDLL;' - print r' (void)lpvReserved;' - print r' return TRUE;' - print r'}' - print - for function in self.functions: - function.wrap_impl() - print -