|
Hello,
I had written an application to hook 'CreateProcess()' in Windows CE.
But this is only for application level, that is hook is applicable only for current process.
Now in order to hook this API system-wide, i need to load the HookDLL.dll (in which i have written the code for API hooking) to all the processes.
On the internet i found that it can be done using registry.
We need to insert the DLL name at following location
HKEY_LOCAL_MACHINE\SYSTEM\KERNEL
"InjectDLL" = REG_MULTI_SZ : "MyDLL1.DLL","MyDLL2.DLL",
But i am not able to locate 'Kernel' key under the registry of Win CE.
Is there any security issue involved with this?
Thanks in Advance!!
|
|
|
|
|
tony_udz wrote: Is there any security issue involved with this?
You seriously don't know the answer to this question? Think about it. You're trying to inject an arbitrary .DLL with any code you want into every process in the system. Yep! If that doesn't define a huge security risk, I don't know what does.
tony_udz wrote: We need to insert the DLL name at following location
HKEY_LOCAL_MACHINE\SYSTEM\KERNEL
"InjectDLL" = REG_MULTI_SZ : "MyDLL1.DLL","MyDLL2.DLL",
But i am not able to locate 'Kernel' key under the registry of Win CE.
Is there something stopping you from adding the KERNEL key yourself??
|
|
|
|
|
Thanks Dave for your response.
Actually i am naive to this enviornment.
I agree with you that logically ishould be able to put any DLL in all the processes.
I inferred it from the microsoft's blog: -
=======================================================================
Susan Loh [MS] (Moderator):
Q: My app uses the undocumented function PerformCallBack4 on Windows CE 2003. This now fails on Mobile 5. I know it's undocumented, and used at my own risk, but is there an alternative in Mobile 5?
A: No. We are killing that off. We really should discuss why you needed it. MikeThom tells me you were using it to implement DLL injection into another application. There are ways to inject DLLs like that (our tools use them) but I'm not sure how accessible they are to you. Is your program running on PocketPC (which has low security) or Smartphone (which protects a lot of things)? I presume PPC since you probably couldn't PerformCallBack4 on SP anyway?
MikeThom-MS (Expert):
Q: My app uses the undocumented function PerformCallBack4 on Windows CE 2003. This now fails on Mobile 5. I know it's undocumented, and used at my own risk, but is there an alternative in Mobile 5?
A: For security reasons this API was disabled. The only alternative to injecting a DLL would be to use the reg key "InjectDLL". The problem though still is that on a SmartPhone this maybe a secure key that you can not modify. PPC may still have this key open. Look in the Platform builder docs for information.
Susan Loh [MS] (Moderator):
Q: If DLL injection / sub classing controls is becoming impossible, will there be alternative methods (now or in the future) for applications to get access to global keyboard & mouse events?
A: We have been discussing this and basically think there isn't any supported way to do it. For security reasons we don't want to expose that sort of thing (prevent hackers from stealing your password / credit card #). Maybe there's a way to use our IME (input method -something) interface. Otherwise you might have to wait for something better to be added for this scenario.
=======================================================================
Do you think we cant inject DLL using this?
Please let me know if you know any other method to do this.
|
|
|
|
|
tony_udz wrote: Do you think we cant inject DLL using this?
The only way to tell is going to be to try it.
tony_udz wrote: Please let me know if you know any other method to do this.
I don't know of any other ways to do this, and, apparently, Microsoft isn't telling either.
|
|
|
|
|
|
Hey,
Thanks for your reply.
I had gone through this article at Dr. Dobb's forum.
In this code 'PerformCallBack4()' is used to inject DLL in other process.
And as per my research this API is not supported on Win CE >= 5.0 platform.
I have also read a article in which a gentleman claims that 'PerformCallBack4' API can be used in Win CE 5.0 platform all you require is the trusted application.
I have tried it as well but it was not working.Please let me know if you have any idea regarding this.
I found one more method of injecting DLL using registry keys.
HKEY_LOCAL_MACHINE\SYSTEM\KERNEL
"InjectDLL" = REG_MULTI_SZ : "MyDLL1.DLL","MyDLL2.DLL",
The data type is REG_MULTI_SZ or an array of strings, which can list more than one DLL. The name of the DLL can contain the full path and file name, or just the file name.
Here you need to take care of two things:
1) You need to create key and its subkey.
2) Dll you are injecting must be signed as trusted.
Using this approach i can load my DLL to every processes except system processes.still my functionality is not working for the same. I'll work in this issue today and update you if you say.
Thanks again and please correct me if i am wrong anywhere.
modified on Monday, April 28, 2008 11:25 PM
|
|
|
|
|
I have not tried using registry for injecting DLL. I tested today the CeAPISpy application (from mentioned web page) and it worked on WM6 (HTCP6500) (hooked were CreateFile, CreateEvent, OpenEvent). I was not able to create any new process while the application was running though. The source code is more up to date than the article, it provides some work around for lack of proper PerformCallBack4 functionality on Smartphones 2005. You might want to check it out.
|
|
|
|
|
I searched out for the workaround for calling 'PerformCallBack4' API, somebody had tried this function on WinCE 5.0 using the trusted/signature. I also tried the same thing i.e imade my application trusted by getting it privileged certificate but 'PerformCallBack4()' was returning NULL.
|
|
|
|
|
i am trying to load a dataset from XML file, but i am getting an Error.
"OutOfMemoryException"
here is the code
DataSet DSRead = new DataSet();
DSRead.ReadXml("\\Program Files\\Smartdeviceproject1\\output.xml");
i used the same code on windows application and its working fine.
|
|
|
|
|
How big is this file and how much RAM does the device have free before you try to load the file??
|
|
|
|
|
the xml file is 10 MB that's why i was getting an Error OutOfMemoryException, i used Emulator Properties Dialog Box, to increase
memeory size from 128 to 256. the original xml file is around 27 MB,
i can't copy it to the emulator, how can i increase the space in the emulator, i add Flash Memory File in the Emulator Properties Dialog Box.
but i still can't copy it. i guess it's read only ?
|
|
|
|
|
.NET CF Windows Mobile 6 Std
VS 2005
Hi everyone,
I am writing a mobile app in vb that returns stock data in xml format from a web service. This works fine but it returns it all in xml format. I want to parse the xml so that each item is on a separate line. I cant get it to work.
I would be grateful if you could have a look for me . The error that I am getting is "Overload resolution failed because no accessible 'New' can be called without a narrowing conversion:
'Public Sub New(path As String, encoding As System.Text.Encoding)': Argument matching parameter 'path' narrows from 'Object' to 'String'.
'Public Sub New(stream As System.IO.Stream, encoding As System.Text.Encoding)': Argument matching parameter 'stream' narrows from 'Object' to 'System.IO.Stream'.
Many thanks for taking the time to help,.
JB
____________________________________________________________________________
Imports System.Xml
Imports System.Text.RegularExpressions
Imports System.IO
Imports System.Net
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Focus()
End Sub
Function DownloadFeeds()
Dim xml As New XmlDocument
Dim ws As New stock.StockQuote
ws.Url = "http://www.webservicex.net/stockquote.asmx"
Dim str = ws.GetQuote(TextBox1.Text)
Dim reader As StreamReader
reader = New StreamReader(str, System.Text.Encoding.UTF8)
xml.Load(reader)
Dim titleNode As XmlNode = xml.SelectSingleNode("StockQuotes/Stock/Symbol")
Dim title = titleNode.InnerText
'---select all <stockquotes><stock> elements---
Dim nodes As XmlNodeList = xml.SelectNodes("StockQuotes/Stock")
Dim result As String = String.Empty
For Each node As XmlNode In nodes
'select each post's <title> and <description> elements
TextBox3.Text = node.SelectSingleNode("Symbol").InnerText & Chr(3)
TextBox4.Text= node.SelectSingleNode("Last").InnerText & Chr(12)
TextBox5.Text= node.SelectSingleNode("Date").InnerText & Chr(12)
TextBox6.Text= node.SelectSingleNode("Time").InnerText & Chr(12)
TextBox7.Text= node.SelectSingleNode("Change").InnerText & Chr(12)
TextBox8.Text= node.SelectSingleNode("Open").InnerText & Chr(12)
TextBox9.Text= node.SelectSingleNode("AnnRange").InnerText & Chr(12)
TextBox10.Text= node.SelectSingleNode("Earns").InnerText & Chr(12)
TextBox11.Text= node.SelectSingleNode("P-E").InnerText & Chr(12)
TextBox12.Text= node.SelectSingleNode("Name").InnerText & Chr(12)
Next
Return
End Function
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
DownloadFeeds()
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Close()
End Sub
End Class </description>
|
|
|
|
|
The problem is occurring because the variable str is (implicitly) declared as Object . There are two overrides of StreamReader 's constructor which take two arguments, and the conversion from Object to either one is equally good in VB's eyes. To fix the problem, declare str as an appropriate data type. Given the name of the variable I'm guessing that it was meant to be a String .
Function DownloadFeeds()
Dim xml As New XmlDocument
Dim ws As New stock.StockQuote
ws.Url = "http://www.webservicex.net/stockquote.asmx"
Dim str As String = ws.GetQuote(TextBox1.Text) I recommend you go into Project Properties and set Option Strict to On.
DoEvents: Generating unexpected recursion since 1991
modified on Monday, April 21, 2008 9:11 AM
|
|
|
|
|
Hello,
I need to open serial port using a C dll which is developed using win32 project of Smart devices in Visual C++.net 2005. I get an Error: "INVALID_HANDLE_VALUE" when I use CreateFile function and the serial port does not open.. Can anybody help?
Thanks,
Sushma
|
|
|
|
|
On Windows CE you must specify the colon after the device name, that is, you must use "COM1:" for example. You must also specify OPEN_EXISTING for the dwCreationDisposition parameter.
If that doesn't help, check the return value of GetLastError for more error information.
Also, be aware that only one handle can be open to a serial port at a time. Check that nothing else, including ActiveSync, has the serial port open. In ActiveSync press the Menu soft button, Connections, then check that under When Cradled, the drop-down list says USB rather than e.g. 115200 Default.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Thanks for the reply,
I have tried the things you suggested.It does not work
The GetLastError() gives FILE_NOT_FOUND error(Error: 2)
Right now I am using Windows mobile 5.0 emulator and have mapped Serial Port 0 to COM1 of PC
|
|
|
|
|
Hi All,
I am trying to create a service for smartphone which uses Windows Mobile 5.
When ever I switch on the Smartphone that service should run.
How can we do it?
Please give some suggestions/ideas/links.
I am using C#.net, Compact Framework and Windows Mobile 5 SmartPhone SDK.
Thanks in advance
LTCCTL
--------------------------------------------------------------------------------
|
|
|
|
|
Use the OpenNetCF notification namespace:
OpenNETCF.WindowsCE.Notification.Notify.RunAppAtEvent.
Alternatively you can p/invoke the CeRunAppAt function
|
|
|
|
|
Hi All,
I have written an application for the SmartPhone using Windows Mobile 5.
I want to call the application/function i.e Launch the application/function when a specific button/key is pressed and is held for few seconds, say 5 seconds
I have used C#.net and Windows Mobile 5.
Can anyone give me suggestions/ideas/links so that I can perform this.
Thanks in advance
Parasmani Swamy
|
|
|
|
|
Hi
When You Os is come from the wake up state, Start a timer
Then u can press ur key and start ur Applciation via timer started applcaition, This timer start application can get Key press event.
Did u get the , what i'm saying?
Thank you
|
|
|
|
|
Hi RRave,
I have done it.
Thanks for your help
Regards
Parasmani Swamy
|
|
|
|
|
Hi,
Can someone tell me what I need to do to use a web service in a mobile application. I need to know what to do on the service end and on the mobile end. I am using VS.NET 2005, Vista, and IIS 7.
Thanks,
|
|
|
|
|
CodingYoshi
Good questions,
How long time in programming?
because of just I'm ask. And web service is platform independent services.
Anyhow please check in web there lot of article for this subject.
|
|
|
|
|
hi
i am currently wrking in win ce application in cpp
The problem is whenever i have plug out the storage card and before getting any notification, if it executes any os function calls ( like filecopy, filemove etc ) the application hangs. It will not come out of these functions.
what is the reason for that ?
is any way to resolve this issue?
thanks in advance
modified on Thursday, April 17, 2008 10:45 AM
|
|
|
|
|
The docs on this are sparse, to say the least...
My problem: I'm trying to embed a WebBrowser object in a Windows Mobile application. I can create it and query its size and window handle, but IWebBrowser2::Navigate2 fails with E_FAIL .
Can anyone give me any hints to why it fails?
Code (yes, C++):
My host control is declared like this:
class HtmlControl : public Window
{
public:
HtmlControl(HWND window)
: Window(window)
, iOleObject_(NULL)
{
iOleSite_.host = this;
iOleFrame_.host = this;
CreateWebControl();
}
Site iOleSite_;
Frame iOleFrame_;
IOleObject* iOleObject_;
private:
void CreateWebControl();
}; Where Site and Frame are declared like this:
struct Site : public IOleClientSite,
public IOleInPlaceSite
{
HtmlControl* host;
STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP SaveObject();
STDMETHODIMP GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker,
IMoniker** ppmk);
STDMETHODIMP GetContainer(LPOLECONTAINER FAR* ppContainer);
STDMETHODIMP ShowObject();
STDMETHODIMP OnShowWindow(BOOL fShow);
STDMETHODIMP RequestNewObjectLayout();
STDMETHODIMP GetWindow(HWND FAR* lphwnd);
STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
STDMETHODIMP CanInPlaceActivate();
STDMETHODIMP OnInPlaceActivate();
STDMETHODIMP OnUIActivate();
STDMETHODIMP GetWindowContext(LPOLEINPLACEFRAME FAR* lplpFrame,
LPOLEINPLACEUIWINDOW FAR* lplpDoc,
LPRECT lprcPosRect,
LPRECT lprcClipRect,
LPOLEINPLACEFRAMEINFO lpFrameInfo);
STDMETHODIMP Scroll(SIZE scrollExtent);
STDMETHODIMP OnUIDeactivate(BOOL fUndoable);
STDMETHODIMP OnInPlaceDeactivate();
STDMETHODIMP DiscardUndoState();
STDMETHODIMP DeactivateAndUndo();
STDMETHODIMP OnPosRectChange(LPCRECT lprcPosRect);
};
struct Frame : public IOleInPlaceFrame
{
HtmlControl* host;
STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP GetWindow(HWND FAR* lphwnd);
STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
STDMETHODIMP GetBorder(LPRECT lprectBorder);
STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS pborderwidths);
STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS pborderwidths);
STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject* pActiveObject,
LPCOLESTR pszObjName);
STDMETHODIMP InsertMenus(HMENU hmenuShared,
LPOLEMENUGROUPWIDTHS lpMenuWidths);
STDMETHODIMP SetMenu(HMENU hmenuShared, HOLEMENU holemenu,
HWND hwndActiveObject);
STDMETHODIMP RemoveMenus(HMENU hmenuShared);
STDMETHODIMP SetStatusText(LPCOLESTR pszStatusText);
STDMETHODIMP EnableModeless(BOOL fEnable);
STDMETHODIMP TranslateAccelerator(LPMSG lpmsg, WORD wID);
}; The implementations of Site and Frame will be provided if needed, so that this space isn't cluttered too much.
So, the interesting function here is HtmlControl::CreateWebControl() . Let's walk it through, so that the possible strangeness of the IWebBrowser2::Navigate2 failure can be better seen.
First, an instance of the WebBrowser COM object is created and its associated IOleObject is retrieved:
IUnknown* iUnknown = NULL;
HRESULT hr = ::CoCreateInstance(CLSID_WebBrowser,
NULL,
CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
IID_IUnknown,
(void*)(&iUnknown));
VERIFY(SUCCEEDED(hr));
hr = iUnknown->QueryInterface(IID_IOleObject, (void*)(&iOleObject_));
VERIFY(SUCCEEDED(hr)); These operations were all successful in the sense that hr == S_OK .
After getting the WebControl object, I want to show/activate it using our IOleClientSite implementation:
hr = iOleObject_->SetClientSite(&iOleSite_);
VERIFY(SUCCEEDED(hr));
const RECT rect = GetClientRect();
hr = iOleObject_->DoVerb(OLEIVERB_SHOW, NULL, &iOleSite_, 0, GetHwnd(), &rect);
VERIFY(SUCCEEDED(hr)); These operations were also successful in the sense that hr == S_OK . However, the end result (the IWebBrowser2::Navigate2 failure) occurs also if OLEIVERB_SHOW is changed to OLEIVERB_UIACTIVATE or OLEIVERB_INPLACEACTIVATE .
Next, I dig the IWebBrowser2 out of the WebControl object and checks if the browser HWND is sane:
IWebBrowser2* iWebBrowser = NULL;
hr = iOleObject_->QueryInterface(IID_IWebBrowser2, (void**)&iWebBrowser);
VERIFY(SUCCEEDED(hr));
HWND hwndBrowser = NULL;
hr = iWebBrowser->get_HWND((long*)&hwndBrowser);
VERIFY(SUCCEEDED(hr));
VERIFY(hwndBrowser != NULL);
VERIFY(::GetParent(hwndBrowser) == GetHwnd());
IOleWindow* iOleWindow = NULL;
hr = iOleObject_->QueryInterface(IID_IOleWindow, (void*)(&iOleWindow));
VERIFY(SUCCEEDED(hr));
hwndBrowser = NULL;
hr = iOleWindow->GetWindow(&hwndBrowser);
VERIFY(hwndBrowser != NULL);
VERIFY(::GetParent(hwndBrowser) == GetHwnd()); Again, these operations were successful in the sense that hr == S_OK . Also, the browser HWND is equal in both method 1 and 2 and its parent is indeed our host control. I see this as some kind of indication that something works.
But... the thing I need doesn't work; the precious IWebBrowser2::Navigate2 :
VARIANT vURL;
vURL.vt = VT_BSTR;
vURL.bstrVal = ::SysAllocString(L"about:blank");
VARIANT vEmpty;
vEmpty.vt = VT_EMPTY;
hr = iWebBrowser->Navigate2(&vURL, &vEmpty, &vEmpty, &vEmpty, &vEmpty);
VERIFY(SUCCEEDED(hr)); Now I get hr == E_FAIL .
I cannot really see the problem, since everything up to this point worked successfully, and the last call seems trivial.
Is anyone still around all the way down here with some guess as to what might be going on?
Thanks for any input!
--
Time you enjoy wasting is not wasted time - Bertrand Russel
|
|
|
|
|