#ifndef __ITSUTILS_H__ /* (C) 2003 XDA Developers itsme@xs4all.nl * * $Header$ * * Do not use 'TCHAR' in this file, this is not a platform independent type!! * */ #ifdef _WIN32_WCE #ifdef ITSUTILS_EXPORTS #define ITSUTILS_API extern "C" __declspec(dllexport) #else //#define ITSUTILS_API extern "C" __declspec(dllimport) #define ITSUTILS_API #endif #endif #include #include #include #define LOG_NONE 0 #define LOG_DEBUGSTRING 1 #define LOG_FILE 2 #define LOG_NETWORK 3 typedef struct _tagGetVersionParams { DWORD logtype; char szLogfile[1]; } GetVersionParams; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetVersion( DWORD cbInput, GetVersionParams*pbInput, DWORD *pcbOutput, void **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagTerminateProcessParams { DWORD dwProcessHandle; bool bWait; WCHAR wszProcessName[1]; } TerminateProcessParams; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITTerminateProcess( DWORD cbInput, TerminateProcessParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagTerminateThreadParams { DWORD dwThreadHandle; } TerminateThreadParams; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITTerminateThread( DWORD cbInput, TerminateThreadParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagWaitForProcessParams { DWORD dwProcessHandle; } WaitForProcessParams; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITWaitForProcess( DWORD cbInput, WaitForProcessParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif //HANDLE GetProcessHandle(WCHAR *wszProcessName); typedef struct _tagGetProcessHandleParams { WCHAR wszProcessName[1]; } GetProcessHandleParams; typedef struct _tagGetProcessHandleResult { HANDLE hProc; } GetProcessHandleResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetProcessHandle( DWORD cbInput, GetProcessHandleParams *pbInput, DWORD *pcbOutput, GetProcessHandleResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagReadProcessMemoryParams { // 2 special values: // NULL - directly read virtual memory // INVALID_HANDLE_VALUE - read physical memory HANDLE hProcess; DWORD dwOffset; DWORD nSize; DWORD nDataAccess; // how to access memory, 1=byte, 2=wor,d 4=dword, 0=memcpy } ReadProcessMemoryParams; typedef struct _tagReadProcessMemoryResult { DWORD dwNumberOfBytesRead; BYTE buffer[1]; } ReadProcessMemoryResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITReadProcessMemory( DWORD cbInput, ReadProcessMemoryParams *pbInput, DWORD *pcbOutput, ReadProcessMemoryResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagWriteProcessMemoryParams { HANDLE hProcess; DWORD dwOffset; DWORD nSize; DWORD nDataAccess; // how to access memory, 1=byte, 2=wor,d 4=dword, 0=memcpy BYTE buffer[1]; } WriteProcessMemoryParams; typedef struct _tagWriteProcessMemoryResult { DWORD dwNumberOfBytesWritten; } WriteProcessMemoryResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITWriteProcessMemory( DWORD cbInput, WriteProcessMemoryParams *pbInput, DWORD *pcbOutput, WriteProcessMemoryResult **ppbOutput, IRAPIStream *pStream); #endif //------------------------------- typedef struct _tagSDCardInfoParams { DWORD dwDiskNr; } SDCardInfoParams; typedef struct _tagSDCardInfoResult { DWORD blockSize; DWORD totalBlocks; DWORD cardidLength; BYTE cardid[16]; } SDCardInfoResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITSDCardInfo( DWORD cbInput, SDCardInfoParams *pbInput, DWORD *pcbOutput, SDCardInfoResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagReadSDCardParams { DWORD dwDiskNr; DWORD dwOffset; DWORD dwSize; } ReadSDCardParams; typedef struct _tagReadSDCardResult { DWORD dwNumberOfBytesRead; // DWORD start; // DWORD number; BYTE buffer[1]; } ReadSDCardResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITReadSDCard( DWORD cbInput, ReadSDCardParams *pbInput, DWORD *pcbOutput, ReadSDCardResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagWriteSDCardParams { DWORD dwDiskNr; DWORD dwOffset; DWORD dwSize; BYTE buffer[1]; } WriteSDCardParams; typedef struct _tagWriteSDCardResult { DWORD dwNumberOfBytesWritten; } WriteSDCardResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITWriteSDCard( DWORD cbInput, WriteSDCardParams *pbInput, DWORD *pcbOutput, WriteSDCardResult **ppbOutput, IRAPIStream *pStream); #endif //------------------------------- typedef struct _tagFlashROMParams { DWORD dwType; DWORD dwOffset; DWORD dwSize; DWORD dwCheckSum; BYTE buffer[1]; } FlashROMParams; #define FLASH_TYPE_XIPFLASH 0 #define FLASH_TYPE_MAGICIAN 1 typedef struct _tagFlashROMResult { DWORD dwResult; } FlashROMResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITFlashROM( DWORD cbInput, FlashROMParams *pbInput, DWORD *pcbOutput, FlashROMResult **ppbOutput, IRAPIStream *pStream); #endif //------------------------------- typedef struct _tagGetContextResult { DWORD dwProcessId; HANDLE hProcess; DWORD dwThreadId; HANDLE hThread; DWORD dwCurrentTrust; DWORD dwCallerTrust; DWORD dwMemoryUsed; DWORD dwMemoryFree; DWORD dwKernelMemory; WCHAR wszCmdLine[1]; } GetContextResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetContext( DWORD cbInput, BYTE *pbInput, DWORD *pcbOutput, GetContextResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct tagCEPROCESSENTRY { //DWORD cntUsage; DWORD dwProcessID; //DWORD dwDefaultHeapID; //DWORD dwModuleID; //DWORD cntThreads; //DWORD dwParentProcessID; //DWORD dwFlags; WCHAR szExeFile[MAX_PATH]; WCHAR szCmdLine[MAX_PATH]; DWORD dwMemoryBase; DWORD dwAccessKey; DWORD dwMemoryUsage; //DWORD dwKernelTime; //DWORD dwUserTime; } CEPROCESSENTRY; typedef std::vector CeProcessList; typedef struct _tagGetProcessListParams { bool bIncludeHeapUsage; } GetProcessListParams; typedef struct _tagGetProcessListResult { int nEntries; CEPROCESSENTRY pe[1]; } GetProcessListResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetProcessList( DWORD cbInput, GetProcessListParams *pbInput, DWORD *pcbOutput, GetProcessListResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct tagCEMODULEENTRY { WCHAR szModuleName[MAX_PATH]; DWORD dwMemoryBase; DWORD dwVBase; DWORD dwDBase; DWORD dwUsage; } CEMODULEENTRY; typedef struct _tagGetModuleListParams { bool bDirectRead; } GetModuleListParams; typedef struct _tagGetModuleListResult { int nEntries; CEMODULEENTRY me[1]; } GetModuleListResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetModuleList( DWORD cbInput, GetModuleListParams *pbInput, DWORD *pcbOutput, GetModuleListResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagSearchMemoryParams { DWORD hProcess; // 0 : direct read, -1 : phys read, other: process DWORD dwOffset; DWORD dwType; // 1: search asc+unicode : -a // 2: search case insensitive : -i // 4: search regex : /pattern/ // 8: search arm-relative : -r // 16: search ranges : only dwords, stored as {start,end} list // 32: return match // 64: search hword aligned //128: search dword aligned //256: with bitmasks DWORD dwLength; BYTE data[1]; } SearchMemoryParams; typedef struct _tagSearchMemoryResult { DWORD dwFoundOffset; DWORD dwFoundLength; BYTE data[1]; } SearchMemoryResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITSearchMemory( DWORD cbInput, SearchMemoryParams *pbInput, DWORD *pcbOutput, SearchMemoryResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagGetThreadTimesParams { HANDLE hThread; } GetThreadTimesParams; typedef struct _tagGetThreadTimesResult { FILETIME tCreate; FILETIME tExit; FILETIME tKernel; FILETIME tUser; } GetThreadTimesResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetThreadTimes( DWORD cbInput, GetThreadTimesParams *pbInput, DWORD *pcbOutput, GetThreadTimesResult **ppbOutput, IRAPIStream *pStream); #endif #ifndef MAX_PROCESSES #define MAX_PROCESSES 32 #endif typedef struct _tagProcSummaryInfo { HANDLE hProc; DWORD tKernel; DWORD tUser; DWORD nThreads; } ProcSummaryInfo; typedef struct _tagGetProcessUsageListParams { } GetProcessUsageListParams; typedef struct _tagGetProcessUsageListResult { DWORD tQuery; ProcSummaryInfo list[MAX_PROCESSES]; } GetProcessUsageListResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetProcessUsageList( DWORD cbInput, GetProcessUsageListParams *pbInput, DWORD *pcbOutput, GetProcessUsageListResult **ppbOutput, IRAPIStream *pStream); #endif // todo: split into a 'info' function, and a 'times' function. #define MAX_THREADS 512 typedef struct _tagThreadSummaryInfo { HANDLE hProc; HANDLE hThread; DWORD dwStartAddr; DWORD dwCurPC; DWORD dwCurLR; DWORD dwCurSP; DWORD tKernel; DWORD tUser; WORD baseprio; WORD curprio; WCHAR szModname[256]; } ThreadSummaryInfo; typedef struct _tagGetThreadUsageListParams { bool resolve_modulenames; } GetThreadUsageListParams; typedef struct _tagGetThreadUsageListResult { DWORD tQuery; DWORD nThreads; // todo: make this a variable sized list ThreadSummaryInfo list[MAX_THREADS]; } GetThreadUsageListResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetThreadUsageList( DWORD cbInput, GetThreadUsageListParams *pbInput, DWORD *pcbOutput, GetThreadUsageListResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagStartDebuggingProcessParams { DWORD dwProcessId; bool bFilterForProcess; bool bSysMessagesOnly; WCHAR wszExeName[MAX_PATH]; WCHAR wszCmdLine[MAX_PATH]; } StartDebuggingProcessParams; typedef struct _tagStartDebuggingProcessResult { DWORD debugger; } StartDebuggingProcessResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITStartDebuggingProcess( DWORD cbInput, StartDebuggingProcessParams *pbInput, DWORD *pcbOutput, StartDebuggingProcessResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagStopDebuggingProcessParams { DWORD debugger; } StopDebuggingProcessParams; //typedef struct _tagStopDebuggingProcessResult { //} StopDebuggingProcessResult; typedef BYTE StopDebuggingProcessResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITStopDebuggingProcess( DWORD cbInput, StopDebuggingProcessParams *pbInput, DWORD *pcbOutput, StopDebuggingProcessResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagWaitForDebugEventParams { DWORD debugger; } WaitForDebugEventParams; typedef struct _tagWaitForDebugEventResult { DWORD dwMissedEvents; DWORD dwProcessId; DWORD dwThreadId; DWORD dwDebugEventCode; int len; char description[1]; } WaitForDebugEventResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITWaitForDebugEvent( DWORD cbInput, WaitForDebugEventParams *pbInput, DWORD *pcbOutput, WaitForDebugEventResult **ppbOutput, IRAPIStream *pStream); #endif //-------------------------- typedef struct _tagReadGsmMemoryParams { DWORD dwOffset; DWORD nSize; } ReadGsmMemoryParams; typedef struct _tagReadGsmMemoryResult { DWORD dwNumberOfBytesRead; BYTE buffer[1]; } ReadGsmMemoryResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITReadGsmMemory( DWORD cbInput, ReadGsmMemoryParams *pbInput, DWORD *pcbOutput, ReadGsmMemoryResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagWriteGsmMemoryParams { HANDLE hProcess; DWORD dwOffset; DWORD nSize; BYTE buffer[1]; } WriteGsmMemoryParams; typedef struct _tagWriteGsmMemoryResult { DWORD dwNumberOfBytesWritten; } WriteGsmMemoryResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITWriteGsmMemory( DWORD cbInput, WriteGsmMemoryParams *pbInput, DWORD *pcbOutput, WriteGsmMemoryResult **ppbOutput, IRAPIStream *pStream); #endif #define GSM_RESET 0x01 #define GSM_STOPRIL 0x02 #define GSM_STARTRIL 0x03 typedef struct _tagGsmControlParams { DWORD nCmd; } GsmControlParams; typedef struct _tagGsmControlResult { DWORD dwResult; } GsmControlResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGsmControl( DWORD cbInput, GsmControlParams *pbInput, DWORD *pcbOutput, GsmControlResult **ppbOutput, IRAPIStream *pStream); #endif #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITReboot( DWORD cbInput, BYTE *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITColdboot( DWORD cbInput, BYTE *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagSetSystemTimeParams { BOOL bSetLocal; BOOL bSetSystem; BOOL bSetTz; SYSTEMTIME time; TIME_ZONE_INFORMATION tzinfo; } SetSystemTimeParams; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITSetSystemTime( DWORD cbInput, SetSystemTimeParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagGetSystemTimeParams { BOOL bGetLocal; } GetSystemTimeParams; typedef struct _tagGetSystemTimeResult { SYSTEMTIME time; TIME_ZONE_INFORMATION tzinfo; DWORD tzid; } GetSystemTimeResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetSystemTime( DWORD cbInput, GetSystemTimeParams *pbInput, DWORD *pcbOutput, GetSystemTimeResult **ppbOutput, IRAPIStream *pStream); #endif //void FindModuleNameForProcessAddress(DWORD pid, DWORD dwAddress, WCHAR *szModname, int maxmodname); /* #define SW_HIDE 0 #define SW_SHOWNORMAL 1 #define SW_SHOWNOACTIVATE 4 #define SW_SHOW 5 #define SW_MINIMIZE 6 #define SW_SHOWNA 8 #define SW_SHOWMAXIMIZED 11 #define SW_MAXIMIZE 12 #define SW_RESTORE 13 */ #define SW_SETFOREGROUND 100 #define SW_SETACTIVE 101 #define SW_SETCAPTURE 102 #define SW_BRINGTOTOP 103 #define SW_DRAWMENUBAR 104 #define SW_DESTROYWINDOW 105 #define SW_UPDATEWINDOW 106 #define SW_HIDECARET 107 #define SW_SHOWCARET 108 #define SW_SETFOCUS 109 #define SW_ENABLEWINDOW 110 #define SW_DISABLEWINDOW 111 #define SW_ENDDIALOGOK 112 #define SW_ENDDIALOGCANCEL 113 #define SW_ENDDIALOGCLOSE 114 #define SW_ENDDIALOGABORT 115 typedef struct _tagShowWindowParams { HWND hWnd; DWORD dwShow; } ShowWindowParams; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITShowWindow( DWORD cbInput, ShowWindowParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagFindWindowParams { WCHAR szClassName[MAX_PATH]; WCHAR szWindowName[MAX_PATH]; } FindWindowParams; typedef struct _tagFindWindowResult { HWND hWnd; } FindWindowResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITFindWindow( DWORD cbInput, FindWindowParams *pbInput, DWORD *pcbOutput, FindWindowResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagSendMessageParams { DWORD dwFlags; DWORD dwResultAlloc; HWND hWnd; DWORD nMsg; DWORD wParam; DWORD lParam; BYTE buf[1]; } SendMessageParams; typedef struct _tagSendMessageResult { DWORD lResult; BYTE buf[1]; } SendMessageResult; #define SMGS_WPARAM_IS_INPUTOFS 1 #define SMGS_WPARAM_IS_OUTPUTOFS 2 #define SMGS_LPARAM_IS_INPUTOFS 4 #define SMGS_LPARAM_IS_OUTPUTOFS 8 #define SMGS_POSTMESSAGE 16 #define SMGS_WAITWINDOW 32 #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITSendMessage( DWORD cbInput, SendMessageParams *pbInput, DWORD *pcbOutput, SendMessageResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagGetForegroundWindowResult { HWND hwnd; } GetForegroundWindowResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetForegroundWindow( DWORD cbInput, BYTE *pbInput, DWORD *pcbOutput, GetForegroundWindowResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagITSWindowInfo { int level; HWND hwnd; HWND nextsibling; // dw 00 HWND parent; // dw 01 HWND firstchild; // dw 02 WCHAR wtitle[32]; // dw 1a WCHAR wclass[32]; // dw 1f.05 DWORD msgq; // dw 1b DWORD ime; // dw 1c DWORD style; // dw 1d DWORD exstyle; // dw 1e DWORD usrdata; // dw 21 DWORD pid; // dw 22 DWORD tid; // dw 23 DWORD pid2; // dw 24 DWORD wndproc; // dw 25 RECT wrect; // dw 08 RECT crect; // dw 0c DWORD nlongs; // w 1f.00:hi DWORD wlongs[8]; // dw 2e } ITSWindowInfo; typedef struct _tagGetWindowListResult { int count; ITSWindowInfo info[1]; } GetWindowListResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITGetWindowList( DWORD cbInput, BYTE *pbInput, DWORD *pcbOutput, GetWindowListResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagCallAddressParams { HANDLE hProcess; DWORD dwAddress; } CallAddressParams; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITCallAddress( DWORD cbInput, CallAddressParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITRegistryFlush( DWORD cbInput, BYTE *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif #define ITSCOMP_XPR_DECODE 0 #define ITSCOMP_XPR_ENCODE 1 #define ITSCOMP_LZX_DECODE 2 #define ITSCOMP_LZX_ENCODE 3 typedef struct _tagCompressParams { DWORD dwType; // lzx/xpr compress/decompress DWORD dwMaxBlockSize; // from volume header DWORD outlength; DWORD insize; BYTE data[1]; } CompressParams; typedef struct _tagCompressResult { DWORD outlength; BYTE data[1]; } CompressResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITS_XPRLZX_Compress( DWORD cbInput, CompressParams *pbInput, DWORD *pcbOutput, CompressResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagSendSmsParams { char number[32]; DWORD msglen; char msg[1]; } SendSmsParams; typedef struct _tagSendSmsResult { DWORD status; } SendSmsResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITSendSms( DWORD cbInput, SendSmsParams *pbInput, DWORD *pcbOutput, SendSmsResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagDialNumberParams { char number[32]; } DialNumberParams; typedef struct _tagDialNumberResult { DWORD status; } DialNumberResult; #ifdef _WIN32_WCE ITSUTILS_API HRESULT STDAPICALLTYPE ITDialNumber( DWORD cbInput, DialNumberParams *pbInput, DWORD *pcbOutput, DialNumberResult **ppbOutput, IRAPIStream *pStream); #endif #define __ITSUTILS_H__ #endif