} PLUGINFUNCTIONEND #else // System log debugging turned off #define SYSTEM_EVENT(a) #define SYSTEM_LOG_ADD(a) #define SYSTEM_LOG_POST #endif PLUGINFUNCTION(Get) { SystemProc *proc = PrepareProc(FALSE); if (proc == NULL) { pushstring("error"); return; } SYSTEM_LOG_ADD("Get "); SYSTEM_LOG_ADD(proc->DllName); SYSTEM_LOG_ADD("::"); SYSTEM_LOG_ADD(proc->ProcName); SYSTEM_LOG_ADD("\n"); SYSTEM_LOG_POST; if ((proc->Options & POPT_ALWRETURN) != 0) { // Always return flag set -> return separate proc and result pushint((int) proc); GlobalFree(pushstring(GetResultStr(proc))); } else { if (proc->ProcResult != PR_OK) { // No always return flag and error result - return result GlobalFree(pushstring(GetResultStr(proc))); // If proc is permanent? if ((proc->Options & POPT_PERMANENT) == 0) GlobalFree((HANDLE) proc); // No, free it } else // Ok result, return proc pushint((int) proc); } } PLUGINFUNCTIONEND
PLUGINFUNCTIONEND PLUGINFUNCTION(Get) { SystemProc *proc = PrepareProc(FALSE); if (proc == NULL) { system_pushstring(_T("error")); return; } SYSTEM_LOG_ADD(_T("Get ")); SYSTEM_LOG_ADD(proc->DllName); SYSTEM_LOG_ADD(_T("::")); SYSTEM_LOG_ADD(proc->ProcName); //SYSTEM_LOG_ADD(_T("\n")); SYSTEM_LOG_POST; if ((proc->Options & POPT_ALWRETURN) != 0) { // Always return flag set -> return separate proc and result system_pushintptr((INT_PTR) proc); GlobalFree(system_pushstring(GetResultStr(proc))); } else { if (proc->ProcResult != PR_OK) { // No always return flag and error result - return result GlobalFree(system_pushstring(GetResultStr(proc))); // If proc is permanent? if ((proc->Options & POPT_PERMANENT) == 0) GlobalFree((HGLOBAL) proc); // No, free it } else // Ok result, return proc system_pushintptr((INT_PTR) proc); } } PLUGINFUNCTIONEND
//********************************************************************** // // void ImeUIComposition() // // This handles WM_IME_COMPOSITION message. It here just handles // composition string and result string. For normal case, it should // examine all posibile flags indicated by CompFlag, then do some // actitions to reflect what kinds of composition info. IME conversion // engine informs. // //********************************************************************** void ImeUIComposition( HWND hwnd, WPARAM wParam, LPARAM CompFlag ) { if ( CompFlag & GCS_RESULTSTR ) { GetResultStr( hwnd ); } else { if ( CompFlag & GCS_COMPSTR ) { GetCompositionStr( hwnd, CompFlag ); } } }
void CompStr::GetLog(LogCompStr& log) { FOOTMARK(); log.dwCursorPos = dwCursorPos; log.dwDeltaStart = dwDeltaStart; log.comp_read_attr.assign(GetCompReadAttr(), GetCompReadAttr() + dwCompReadAttrLen); log.comp_read_clause.assign(GetCompReadClause(), GetCompReadClause() + dwCompReadClauseLen / sizeof(DWORD)); log.comp_read_str.assign(GetCompReadStr(), dwCompReadStrLen); log.comp_attr.assign(GetCompAttr(), GetCompAttr() + dwCompAttrLen); log.comp_clause.assign(GetCompClause(), GetCompClause() + dwCompClauseLen / sizeof(DWORD)); log.comp_str.assign(GetCompStr(), dwCompStrLen); log.result_read_clause.assign(GetResultReadClause(), GetResultReadClause() + dwResultReadClauseLen / sizeof(DWORD)); log.result_read_str.assign(GetResultReadStr(), dwResultReadStrLen); log.result_clause.assign(GetResultClause(), GetResultClause() + dwResultClauseLen / sizeof(DWORD)); log.result_str.assign(GetResultStr(), dwResultStrLen); COMPSTREXTRA *extra = GetExtra(); if (extra && extra->dwSignature == 0xDEADFACE) { extra->GetLog(log.extra); log.fix(); } }
void CompStr::Dump() { FOOTMARK(); #ifndef NDEBUG DebugPrintA("dwSize: %08X\n", dwSize); DebugPrintA("dwCursorPos: %08X\n", dwCursorPos); DebugPrintA("dwDeltaStart: %08X\n", dwDeltaStart); DebugPrintA("CompReadAttr: "); if (dwCompReadAttrLen) { BYTE *attrs = GetCompReadAttr(); for (DWORD i = 0; i < dwCompReadAttrLen; ++i) { DebugPrintA("%02X ", attrs[i]); } } DebugPrintA("\n"); DebugPrintA("CompReadClause: "); if (dwCompReadClauseLen) { DWORD *clauses = GetCompReadClause(); for (DWORD i = 0; i < dwCompReadClauseLen / 4; ++i) { DebugPrintA("%08X ", clauses[i]); } } DebugPrintA("\n"); DebugPrintA("CompReadStr: "); if (dwCompReadStrLen) { WCHAR *str = GetCompReadStr(); DebugPrintA("%ls", str); } DebugPrintA("\n"); DebugPrintA("CompAttr: "); if (dwCompAttrLen) { BYTE *attrs = GetCompAttr(); for (DWORD i = 0; i < dwCompAttrLen; ++i) { DebugPrintA("%02X ", attrs[i]); } } DebugPrintA("\n"); DebugPrintA("CompClause: "); if (dwCompClauseLen) { DWORD *clauses = GetCompClause(); for (DWORD i = 0; i < dwCompClauseLen / 4; ++i) { DebugPrintA("%08X ", clauses[i]); } } DebugPrintA("\n"); DebugPrintA("CompStr: "); if (dwCompStrLen) { WCHAR *str = GetCompStr(); DebugPrintA("%ls", str); } DebugPrintA("\n"); DebugPrintA("ResultReadClause: "); if (dwResultReadClauseLen) { DWORD *clauses = GetResultReadClause(); for (DWORD i = 0; i < dwResultReadClauseLen / 4; ++i) { DebugPrintA("%08X ", clauses[i]); } } DebugPrintA("\n"); DebugPrintA("ResultReadStr: "); if (dwResultReadStrLen) { WCHAR *str = GetResultReadStr(); DebugPrintA("%ls", str); } DebugPrintA("\n"); DebugPrintA("ResultClause: "); if (dwResultClauseLen) { DWORD *clauses = GetResultClause(); for (DWORD i = 0; i < dwResultClauseLen / 4; ++i) { DebugPrintA("%08X ", clauses[i]); } } DebugPrintA("\n"); DebugPrintA("ResultStr: "); if (dwResultStrLen) { WCHAR *str = GetResultStr(); DebugPrintA("%ls", str); } DebugPrintA("\n"); #endif // ndef NDEBUG } // CompStr::Dump
} PLUGINFUNCTIONEND PLUGINFUNCTION(Call) { // Prepare input SystemProc *proc = PrepareProc(TRUE); SYSTEM_LOG_ADD("Call "); SYSTEM_LOG_ADD(proc->DllName); SYSTEM_LOG_ADD("::"); SYSTEM_LOG_ADD(proc->ProcName); SYSTEM_LOG_ADD("\n"); if (proc->ProcResult != PR_CALLBACK) ParamAllocate(proc); ParamsIn(proc); // Make the call if (proc->ProcResult != PR_ERROR) { switch (proc->ProcType) { case PT_NOTHING: if (proc->ProcResult == PR_CALLBACK) proc = CallBack(proc); break; case PT_PROC: case PT_VTABLEPROC: proc = CallProc(proc); break; case PT_STRUCT: CallStruct(proc); break; } } // Process output if ((proc->Options & POPT_ALWRETURN) != 0) { // Always return flag set - return separate return and result ParamsOut(proc); GlobalFree(pushstring(GetResultStr(proc))); } else { if (proc->ProcResult != PR_OK) { ProcParameter pp; // Save old return param pp = proc->Params[0]; // Return result instead of return value proc->Params[0].Value = (int) GetResultStr(proc); proc->Params[0].Type = PAT_STRING; // Return all params ParamsOut(proc); // Restore old return param proc->Params[0] = pp; } else ParamsOut(proc); } if (proc->ProcResult != PR_CALLBACK) { // Deallocate params if not callback ParamsDeAllocate(proc); // if not callback - check for unload library option if ((proc->Options & POPT_UNLOAD) && (proc->ProcType == PT_PROC) && (proc->Dll != NULL)) FreeLibrary(proc->Dll); // and unload it :) // In case of POPT_ERROR - first pop will be proc error if ((proc->Options & POPT_ERROR) != 0) pushint(LastError); } // If proc is permanent? if ((proc->Options & POPT_PERMANENT) == 0) GlobalFree((HANDLE) proc); // No, free it } PLUGINFUNCTIONEND
} PLUGINFUNCTIONEND PLUGINFUNCTION(Call) { // Prepare input SystemProc *proc = PrepareProc(TRUE); if (proc == NULL) return; SYSTEM_LOG_ADD(_T("Call ")); SYSTEM_LOG_ADD(proc->DllName); SYSTEM_LOG_ADD(_T("::")); SYSTEM_LOG_ADD(proc->ProcName); //SYSTEM_LOG_ADD(_T("\n")); SYSTEM_LOG_POST; if (proc->ProcResult != PR_CALLBACK) ParamAllocate(proc); ParamsIn(proc); #ifndef SYSTEM_X64 // Make the call if (proc->ProcResult != PR_ERROR) { switch (proc->ProcType) { case PT_NOTHING: if (proc->ProcResult == PR_CALLBACK) proc = CallBack(proc); break; case PT_PROC: case PT_VTABLEPROC: proc = CallProc(proc); break; case PT_STRUCT: CallStruct(proc); break; } } // Process output if ((proc->Options & POPT_ALWRETURN) != 0) { // Always return flag set - return separate return and result ParamsOut(proc); GlobalFree(system_pushstring(GetResultStr(proc))); } else { if (proc->ProcResult != PR_OK) { ProcParameter pp; // Save old return param pp = proc->Params[0]; // Return result instead of return value proc->Params[0].Value = BUGBUG64(int) GetResultStr(proc); proc->Params[0].Type = PAT_TSTRING; // Return all params ParamsOut(proc); // Restore old return param proc->Params[0] = pp; } else ParamsOut(proc); } if (proc->ProcResult != PR_CALLBACK) { // Deallocate params if not callback ParamsDeAllocate(proc); // if not callback - check for unload library option if ((proc->Options & POPT_UNLOAD) && (proc->ProcType == PT_PROC) && (proc->Dll != NULL)) FreeLibrary(proc->Dll); // and unload it :) // In case of POPT_ERROR - first pop will be proc error if ((proc->Options & POPT_ERROR) != 0) system_pushint(LastError); } // If proc is permanent? if ((proc->Options & POPT_PERMANENT) == 0) GlobalFree((HANDLE) proc); // No, free it #else // Fake the behavior of the System plugin for the LoadImage API function. // Otherwise, it is not yet implemented on 64-bit Windows. if (lstrcmp(proc->ProcName, "LoadImageA") == 0) { HANDLE res = LoadImage((HINSTANCE)proc->Params[1].Value, (LPCSTR)proc->Params[2].Value, (UINT)proc->Params[3].Value, (int)proc->Params[4].Value, (int)proc->Params[5].Value, (UINT)proc->Params[6].Value); ParamsOut(proc); system_pushintptr((INT_PTR)res); } else { ParamsOut(proc); system_pushintptr(0); } #endif } PLUGINFUNCTIONEND