// (c) 2008 willem jan hengeveld, itsme@xs4all.nl // // this tool loads a library in contiguous kernel memory, and executes it. // the wince LoadKernelLibrary has a limitation, that it can only // load dll's which are in rom. // // loadklib allocates physical memory, loads and relocates the specified dll, and calls its entrypoint. #include #include "dllloader.h" #include "debug.h" #include "stringutils.h" #include "cenk.h" std::string cmdline; void setcmdline(LPTSTR lpCmdLine) { cmdline= ToString(lpCmdLine); } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { DebugSetLogfile("loadklib.log"); BOOL bMode = SetKMode(TRUE); DWORD dwPerm = SetProcPermissions(0xFFFFFFFF); setcmdline(lpCmdLine); __try { HMODULE hLib= MyLoadKernelLibrary(cmdline.c_str()); printf("loadklib: hlib=%08lx err=%08lx\n", hLib, MyGetLastError()); FARPROC fp= MyGetProcAddress(hLib, "dumpstack"); printf("loadklib: testproc=%08lx\n", fp); } __except(1) { debug("EXCEPTION\n"); } while(1) Sleep(100000); SetProcPermissions(dwPerm); SetKMode(bMode); return 0; }