X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=winapi.py;h=3777dcbf3c8baab08f5a3818a1b64da977e91f0d;hb=041e5be6105ab6b43841f525b17afb6d982323b0;hp=eec3fde014470244d7f44d2aedca964c3d6ad7df;hpb=f20c12630e0f1e12c4740478ab760b0013592946;p=apitrace diff --git a/winapi.py b/winapi.py index eec3fde..3777dcb 100644 --- a/winapi.py +++ b/winapi.py @@ -25,7 +25,7 @@ """Win32 API type description.""" -from base import * +from stdapi import * SHORT = Alias("SHORT", Short) USHORT = Alias("USHORT", UShort) @@ -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' Log::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' Log::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 -