#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 #if defined(_WIN32_WCE) && !defined(_NO_ITS_PROTOTYPES) #define _DECLARE_FUNCTIONS 1 #endif #ifdef _DECLARE_FUNCTIONS #include #endif #include "procthreadstructs.h" #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 _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITGetVersion( DWORD cbInput, GetVersionParams*pbInput, DWORD *pcbOutput, void **ppbOutput, IRAPIStream *pStream); #endif #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITStartStream( DWORD cbInput, void*pbInput, DWORD *pcbOutput, void **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagTerminateProcessParams { DWORD dwProcessHandle; bool bWait; WCHAR wszProcessName[1]; } TerminateProcessParams; #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITTerminateProcess( DWORD cbInput, TerminateProcessParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagTerminateThreadParams { DWORD dwThreadHandle; } TerminateThreadParams; #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITTerminateThread( DWORD cbInput, TerminateThreadParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagWaitForProcessParams { DWORD dwProcessHandle; } WaitForProcessParams; #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITWaitForProcess( DWORD cbInput, WaitForProcessParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagShellExecuteParams { WCHAR verb[32]; WCHAR wszProcessName[MAX_PATH]; WCHAR wszArguments[MAX_PATH]; } ShellExecuteParams; #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITShellExecute( DWORD cbInput, ShellExecuteParams *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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITGetContext( DWORD cbInput, BYTE *pbInput, DWORD *pcbOutput, GetContextResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagGetProcessListParams { bool bIncludeHeapUsage; } GetProcessListParams; typedef struct _tagGetProcessListResult { int nEntries; CEPROCESSENTRY pe[1]; } GetProcessListResult; #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITGetProcessList( DWORD cbInput, GetProcessListParams *pbInput, DWORD *pcbOutput, GetProcessListResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagGetModuleListParams { bool bDirectRead; } GetModuleListParams; typedef struct _tagGetModuleListResult { int nEntries; CEMODULEENTRY me[1]; } GetModuleListResult; #ifdef _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITGetThreadTimes( DWORD cbInput, GetThreadTimesParams *pbInput, DWORD *pcbOutput, GetThreadTimesResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagGetProcessUsageListParams { } GetProcessUsageListParams; typedef struct _tagGetProcessUsageListResult { DWORD tQuery; // note: not all entries contain an active process. int nEntries; ProcSummaryInfo list[1]; } GetProcessUsageListResult; #ifdef _DECLARE_FUNCTIONS 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. typedef struct _tagGetThreadUsageListParams { bool resolve_modulenames; } GetThreadUsageListParams; typedef struct _tagGetThreadUsageListResult { DWORD tQuery; DWORD nThreads; ThreadSummaryInfo list[1]; } GetThreadUsageListResult; #ifdef _DECLARE_FUNCTIONS 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; char exename[MAX_PATH]; char cmdline[MAX_PATH]; } StartDebuggingProcessParams; typedef struct _tagStartDebuggingProcessResult { DWORD debugger; } StartDebuggingProcessResult; #ifdef _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITGsmControl( DWORD cbInput, GsmControlParams *pbInput, DWORD *pcbOutput, GsmControlResult **ppbOutput, IRAPIStream *pStream); #endif #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITReboot( DWORD cbInput, BYTE *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif #ifdef _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITSendMessage( DWORD cbInput, SendMessageParams *pbInput, DWORD *pcbOutput, SendMessageResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagGetForegroundWindowResult { HWND hwnd; } GetForegroundWindowResult; #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITGetForegroundWindow( DWORD cbInput, BYTE *pbInput, DWORD *pcbOutput, GetForegroundWindowResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagGetWindowListParams { DWORD hWnd; DWORD hProc; BOOL bVerbose; } GetWindowListParams; typedef struct _tagGetWindowListResult { int count; ITSWindowInfo info[1]; } GetWindowListResult; #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITGetWindowList( DWORD cbInput, GetWindowListParams *pbInput, DWORD *pcbOutput, GetWindowListResult **ppbOutput, IRAPIStream *pStream); #endif typedef struct _tagCallAddressParams { HANDLE hProcess; DWORD dwAddress; } CallAddressParams; #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITCallAddress( DWORD cbInput, CallAddressParams *pbInput, DWORD *pcbOutput, BYTE **ppbOutput, IRAPIStream *pStream); #endif #ifdef _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS 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 _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITDialNumber( DWORD cbInput, DialNumberParams *pbInput, DWORD *pcbOutput, DialNumberResult **ppbOutput, IRAPIStream *pStream); #endif struct HandleInfo { HANDLE handle; char type[8]; HANDLE hProc; DWORD pvObj; int descstart; int descend; }; typedef std::vector HandleInfoVector; typedef struct _tagGetHandlesParams { HANDLE hProc; char type[1]; } GetHandlesParams; typedef struct _tagGetHandlesResult { unsigned count; HandleInfo data[1]; // followed by strbuf } GetHandlesResult; #ifdef _DECLARE_FUNCTIONS ITSUTILS_API HRESULT STDAPICALLTYPE ITGetHandles( DWORD cbInput, GetHandlesParams *pbInput, DWORD *pcbOutput, GetHandlesResult **ppbOutput, IRAPIStream *pStream); #endif #define __ITSUTILS_H__ #endif