+class DllTracer(Tracer):
+
+ def __init__(self, dllname):
+ self.dllname = dllname
+
+ def get_function_address(self, function):
+ return '__%s' % (function.name,)
+
+ def header(self, api):
+ print '''
+static HINSTANCE g_hDll = NULL;
+
+static PROC
+__getPublicProcAddress(LPCSTR lpProcName)
+{
+ if (!g_hDll) {
+ char szDll[MAX_PATH] = {0};
+
+ if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
+ return NULL;
+ }
+
+ strcat(szDll, "\\\\%s");
+
+ g_hDll = LoadLibraryA(szDll);
+ if (!g_hDll) {
+ return NULL;
+ }
+ }
+
+ return GetProcAddress(g_hDll, lpProcName);
+}
+
+ ''' % self.dllname
+
+ dispatcher = Dispatcher()
+ dispatcher.dispatch_api(api)
+
+ Tracer.header(self, api)
+