/* (C) 2003 XDA Developers itsme@xs4all.nl * * $Header$ */ #include #include #include "debug.h" #include "cenk.h" #include "vectorutils.h" #include "stringutils.h" bool getspidword(UINT action, const std::string& desc) { DWORD dwReply; if (!SystemParametersInfo(action, sizeof(dwReply), &dwReply, 0)) { error("SystemParametersInfo(%hs[%d], DWORD)", desc.c_str(), action); return false; } debug("SystemParametersInfo(%hs[%d], DWORD): %08lx\n", desc.c_str(), action, dwReply); return true; } bool getspistring(UINT action, const std::string& desc, int maxlength) { std::vector reply; reply.resize(maxlength+1); if (!SystemParametersInfo(action, maxlength, vectorptr(reply), 0)) { error("SystemParametersInfo(%hs[%d], LPTSTR)", desc.c_str(), action); return false; } debug("SystemParametersInfo(%hs[%d], LPTSTR): %ls\n", desc.c_str(), action, vectorptr(reply)); return true; } bool getspi(UINT action, const std::string& desc, DWORD dwSize) { ByteVector reply; BV_AppendDword(reply, dwSize); reply.resize(dwSize); if (!SystemParametersInfo(action, dwSize, vectorptr(reply), 0)) { error("SystemParametersInfo(%hs[%d], %d)", desc.c_str(), action, dwSize); return false; } debug("SystemParametersInfo(%hs[%d], %d)\n", desc.c_str(), action, dwSize); debug("%hs\n", hexdump(reply, 4).c_str()); return true; } bool getProcessorInfo() { PROCESSOR_INFO pi; DWORD nReturned; if (!KernelIoControl(IOCTL_PROCESSOR_INFORMATION, NULL, 0, &pi, sizeof(pi), &nReturned)) { error("IOCTL_PROCESSOR_INFORMATION"); return false; } debug("v=%08lx core=%ls rev=%04x\n", pi.wVersion, pi.szProcessCore, pi.wCoreRevision); debug("proc=%ls rev=%04x\n", pi.szProcessorName, pi.wProcessorRevision); debug("cat=%ls vendor=%ls\n", pi.szCatalogNumber, pi.szVendor); debug("set=%08lx speed=%08lx\n", pi.dwInstructionSet, pi.dwClockSpeed); return true; } bool getDeviceId() { ByteVector bv; bv.resize(4096); DEVICE_ID *di= (DEVICE_ID *)vectorptr(bv); di->dwSize= bv.size(); DWORD nReturned; if (!KernelIoControl(IOCTL_HAL_GET_DEVICEID, NULL, 0, di, di->dwSize, &nReturned)) { error("IOCTL_HAL_GET_DEVICEID"); return false; } debug("size=%08lx\n", di->dwSize); debug("preset=%08lx:%08lx : %s\n", di->dwPresetIDOffset, di->dwPresetIDBytes, hexdump(&bv[di->dwPresetIDOffset], di->dwPresetIDBytes).c_str()); debug("platform=%08lx:%08lx : %s\n", di->dwPlatformIDOffset, di->dwPlatformIDBytes, hexdump(&bv[di->dwPlatformIDOffset], di->dwPlatformIDBytes).c_str()); return true; } bool getDeviceId2() { ByteVector bv; bv.resize(16); memset(vectorptr(bv), 0xaa, 16); DWORD nReturned; if (!KernelIoControl(IOCTL_HAL_GET_DEVICEID, NULL, 0, vectorptr(bv), 16, &nReturned)) { error("IOCTL_HAL_GET_DEVICEID-2"); return false; } debug("devid: ret=%08lx %hs\n", nReturned, hexdump(bv).c_str()); return true; } bool getOsVersion() { OSVERSIONINFO oi; oi.dwOSVersionInfoSize= sizeof(OSVERSIONINFO); if (!GetVersionEx(&oi)) { error("GetVersionEx"); return false; } debug("%08lx.%08lx.%08lx.%08lx %ls\n", oi.dwMajorVersion, oi.dwMinorVersion, oi.dwBuildNumber, oi.dwPlatformId, oi.szCSDVersion); return true; } void getSysInfo() { SYSTEM_INFO si; GetSystemInfo(&si); debug("arch=%04x res=%04x ps=%08lx appaddr=%08lx-%08lx\n", si.wProcessorArchitecture, si.wReserved, si.dwPageSize, si.lpMinimumApplicationAddress, si.lpMaximumApplicationAddress); debug("cpumask=%08lx ncpu=%08lx cput=%08lx granul=%08lx cpul=%04x cpur=%04x\n", si.dwActiveProcessorMask, si.dwNumberOfProcessors, si.dwProcessorType, si.dwAllocationGranularity, si.wProcessorLevel, si.wProcessorRevision); } bool dumpspecialpath(int id) { TCHAR path[MAX_PATH]; if (!SHGetSpecialFolderPath(NULL, path, id, false)) { //error("SHGetSpecialFolderPath(%d)", id); return false; } debug("%04x: %ls\n", id, path); return true; } void getspecialpaths() { for (int i=0 ; i<0x40 ; i++) dumpspecialpath(i); } void get_ceshell76() { HMODULE hLib= LoadLibrary(_T("CEShell.dll")); if (hLib==NULL || hLib==INVALID_HANDLE_VALUE) return; typedef DWORD (*fn)(DWORD dw0, WCHAR *buffer, DWORD csidl, BOOL bCreate); fn call= (fn)GetProcAddress(hLib, (LPCWSTR)76); if (call==NULL) { FreeLibrary(hLib); return; } for (int i=0 ; i<0x40 ; i++) { WCHAR pathbuf[MAX_PATH]; memset(pathbuf, 0, sizeof(pathbuf)); DWORD res= call(0, pathbuf, i, FALSE); if (res) debug("ceshell76(%02x): %08lx, %ls\n", i, res, pathbuf); } FreeLibrary(hLib); } void get_ceshell77() { HMODULE hLib= LoadLibrary(_T("CEShell.dll")); if (hLib==NULL || hLib==INVALID_HANDLE_VALUE) return; typedef DWORD (*fn)(DWORD id, WCHAR *buffer); fn call= (fn)GetProcAddress(hLib, (LPCWSTR)77); if (call==NULL) { FreeLibrary(hLib); return; } for (int i=0 ; i<0x40 ; i++) { WCHAR pathbuf[MAX_PATH]; memset(pathbuf, 0, sizeof(pathbuf)); DWORD res= call(i, pathbuf); if (!(res&0x80000000)) debug("ceshell77(%02x): %08lx, %ls\n", i, res, pathbuf); } FreeLibrary(hLib); } void get_ossvcs130() { HMODULE hLib= LoadLibrary(_T("ossvcs.dll")); if (hLib==NULL || hLib==INVALID_HANDLE_VALUE) return; typedef DWORD (*fn)(WCHAR *buf, int buflen); fn call= (fn)GetProcAddress(hLib, (LPCWSTR)130); if (call==NULL) { FreeLibrary(hLib); return; } WCHAR pathbuf[MAX_PATH]; memset(pathbuf, 0, sizeof(pathbuf)); DWORD res= call(pathbuf, MAX_PATH); debug("ossvcs130: %08lx %ls\n", res, pathbuf); FreeLibrary(hLib); } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { DebugSetLogfile("getspi.log"); debug("test\n"); Sleep(2000); //getspi(SPI_GETACCESSTIMEOUT, "ACCESSTIMEOUT", sizeof(ACCESSTIMEOUT)); getspidword(SPI_GETBATTERYIDLETIMEOUT, "BATTERYIDLETIMEOUT"); // 0 getspidword(SPI_GETEXTERNALIDLETIMEOUT, "EXTERNALIDLETIMEOUT"); // 0 getspidword(SPI_GETFONTSMOOTHINGCONTRAST, "FONTSMOOTHINGCONTRAST"); // 1500 //getspi(SPI_GETHIGHCONTRAST, "HIGHCONTRAST", sizeof(HIGHCONTRAST)); getspi(SPI_GETMOUSE, "MOUSE", 256); //getspi(SPI_GETMOUSEKEYS, "MOUSEKEYS", sizeof(MOUSEKEYS)); getspistring(SPI_GETOEMINFO, "OEMINFO", 256); // SP3i / PM10A / .... getspistring(SPI_GETPLATFORMTYPE, "PLATFORMTYPE", 256); // SmartPhone / PocketPC getspi(0xe0, "spi_0xe0", 8); getspi(SPI_GETPLATFORMVERSION, "PLATFORMVERSION", 256); // 3.1 / 3.0.4.2 getspidword(SPI_GETSCREENSAVETIMEOUT, "SCREENSAVETIMEOUT"); // 0 getspidword(SPI_GETSHOWSOUNDS, "SHOWSOUNDS"); // 0 //getspi(SPI_GETSOUNDSENTRY, "SOUNDSENTRY", sizeof(SOUNDSENTRY)); //getspi(SPI_GETSTICKYKEYS, "STICKYKEYS", sizeof(STICKYKEYS)); //getspi(SPI_GETTOGGLEKEYS, "TOGGLEKEYS", sizeof(TOGGLEKEYS)); getspidword(SPI_GETWAKEUPIDLETIMEOUT, "WAKEUPIDLETIMEOUT"); // 0 getspidword(SPI_GETWHEELSCROLLLINES, "WHEELSCROLLLINES"); // 3 getspi(SPI_GETWORKAREA, "WORKAREA", sizeof(RECT)); // 0,20,176,200 / 0,26,240,320 getProcessorInfo(); // ARM / Intel(R) | OMAP730 / PXA272 | getOsVersion(); // 4.21.1088.3 getSysInfo(); // arch=5 ps=0x1000 apps=0x10000-0x7fffffff getDeviceId(); // 10 + 6 bytes getDeviceId2(); // 10 + 6 bytes getspecialpaths(); get_ceshell77(); get_ceshell76(); get_ossvcs130(); return 0; }