|
1 // ltkutils.h |
|
2 // |
|
3 // Copyright (c) 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 #ifndef FSHELL_UTILS |
|
13 #define FSHELL_UTILS |
|
14 |
|
15 #include <e32base.h> |
|
16 class RIoWriteHandle; |
|
17 class RFs; |
|
18 |
|
19 namespace LtkUtils |
|
20 { |
|
21 /* This function makes the object allocated at aPtr be ignored by __UHEAP_MARK/__UHEAP_MARK_END etc |
|
22 * This is useful for objects whose lifetime is carefully managed (ie they really aren't leaked) but have |
|
23 * no suitable place to be cleaned up. Objects stored in TLS are a good example. |
|
24 * Has no effect if run against a UREL euser.dll |
|
25 */ |
|
26 IMPORT_C void MakeHeapCellInvisible(TAny* aPtr); |
|
27 |
|
28 IMPORT_C TInt InjectRawKeyEvent(TInt aScanCode, TInt aModifiers, TInt aRepeatCount); |
|
29 |
|
30 IMPORT_C HBufC* HexDumpL(const TDesC8& aBuf); |
|
31 IMPORT_C void HexDumpToOutput(const TDesC8& aBuf, RIoWriteHandle& aHandle); |
|
32 IMPORT_C void HexDumpToOutput(const TDesC8& aBuf, RIoWriteHandle& aHandle, TInt& aOffset); |
|
33 IMPORT_C void HexDumpToRDebug(const TDesC8& aBuf); |
|
34 IMPORT_C void HexDumpToRDebug(const TDesC8& aBuf, TInt& aOffset); |
|
35 IMPORT_C void RawPrint(const TDesC8& aDes); // 9.1 doesn't have the 8-bit overload |
|
36 |
|
37 IMPORT_C void GetFriendlyThreadName(RThread aThread, TFullName& aFriendly); |
|
38 IMPORT_C void MakeThreadNameFriendly(TFullName& aFullThreadName); |
|
39 IMPORT_C void GetFriendlyProcessName(const RProcess& aProcess, TDes& aFriendly); |
|
40 IMPORT_C void MakeProcessNameFriendly(TDes& aFullProcessName); |
|
41 |
|
42 IMPORT_C TUint HexLexL(TLex16& aLex); |
|
43 IMPORT_C TInt HexLex(TLex16& aLex, TUint& aResult); |
|
44 IMPORT_C TUint HexLexL(TLex8& aLex); |
|
45 IMPORT_C TInt HexLex(TLex8& aLex, TUint& aResult); |
|
46 |
|
47 IMPORT_C TBool HasPrefix(const TDesC16& aDes, const TDesC16& aPrefix); |
|
48 IMPORT_C TBool HasPrefix(const TDesC8& aDes, const TDesC8& aPrefix); |
|
49 |
|
50 /* Replace all occurences of aFrom with aTo, in aDescriptor. Returns number of replacements, |
|
51 * or KErrOverflow if aDescriptor was not big enough to hold all the replacements |
|
52 */ |
|
53 IMPORT_C TInt ReplaceText(TDes& aDescriptor, const TDesC& aFrom, const TDesC& aTo); |
|
54 |
|
55 IMPORT_C HBufC8* Utf8L(const TDesC& aString); // For more control see LtkUtils::RLtkBuf8::CopyAsUtf8L() |
|
56 IMPORT_C HBufC16* DecodeUtf8L(const TDesC8& aUtf8EncodedText); // For more control see LtkUtils::RLtkBuf16::AppendUtf8L() |
|
57 |
|
58 IMPORT_C void FormatSize(TDes16& aBuf, TInt64 aSizeInBytes); |
|
59 IMPORT_C void FormatSize(TDes8& aBuf, TInt64 aSizeInBytes); |
|
60 |
|
61 /* Some cleanup stack helper functions (defined in ltkutils.inl) |
|
62 */ |
|
63 template <class T> |
|
64 inline void CleanupResetAndDestroyPushL(T& aRef); |
|
65 template <class T> |
|
66 inline void CleanupResetPushL(T& aRef); |
|
67 |
|
68 /**** |
|
69 * The functions below are not available if you're linking against ltkutils-tcb.dll. They |
|
70 * rely on being able to link against All -TCB dlls. |
|
71 ****/ |
|
72 |
|
73 /* W32CrackL loads our btrace-compatible wserv logging engine, dlogev.dll, into the existing wserv process. |
|
74 * This enables Autometric to capture i/o events like key & pointer presses, and text drawn to screen. |
|
75 * It also enables btrace logging of windowgroup names. Does nothing if dlogev is already loaded. |
|
76 */ |
|
77 const TUid KW32CrackCategory = { 0x10003B20 }; |
|
78 const TInt KW32CrackKey = 0x102864C5; |
|
79 IMPORT_C void W32CrackL(); |
|
80 IMPORT_C TBool W32CrackIsEnabled(); |
|
81 |
|
82 /* These functions convert a resource identifier (of the format given in the rez.exe docs) into |
|
83 * the localised equivalent. |
|
84 */ |
|
85 IMPORT_C HBufC* RezL(const TDesC& aIdentifier, RFs* aFs = NULL, HBufC** aError=NULL); |
|
86 IMPORT_C HBufC* RezLC(const TDesC& aIdentifier, RFs* aFs = NULL, HBufC** aError=NULL); |
|
87 IMPORT_C HBufC8* Rez8L(const TDesC& aIdentifier, RFs* aFs = NULL, HBufC** aError=NULL); |
|
88 IMPORT_C HBufC8* Rez8LC(const TDesC& aIdentifier, RFs* aFs = NULL, HBufC** aError=NULL); |
|
89 |
|
90 IMPORT_C void CopyToClipboardL(const TDesC& aText, RFs* aFs = NULL); |
|
91 IMPORT_C HBufC* GetFromClipboardL(RFs* aFs = NULL); |
|
92 |
|
93 |
|
94 /* Programatically cause a breakpoint to occur. On emulator this translates to a call to __BREAKPOINT, |
|
95 * on target this will break if fdb is installed, otherwise will crash the thread. |
|
96 */ |
|
97 IMPORT_C void Breakpoint(); |
|
98 |
|
99 IMPORT_C void BreakpointPushL(); // Push a TCleanupItem onto the CleanupStack that calls LtkUtils::Breakpoint() if a leave occurs |
|
100 IMPORT_C TLinAddr BreakpointAddr(); // Internal helper function, only for use by fdb.exe |
|
101 } |
|
102 |
|
103 #include <fshell/ltkutils.inl> |
|
104 |
|
105 #endif |