|
The name1 is "name1" , the value1 is "value1" .
Just kidding!
Maxwell Chen
|
|
|
|
|
I'm trying to write an exe to load my driver into the kernel, I'm getting an error ERROR_PATH_NOT_FOUND. I know my sys file is in the at this path, what am I missing?
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
bool LoadDriver();
int _tmain(int argc, _TCHAR* argv[])
{
bool status;
status = LoadDriver();
if (status)
printf("Driver load Succeeded!\n");
else
printf("Driver load Failed!\n");
return 0;
}
bool LoadDriver()
{
wchar_t PATH[1024] = L"C:\\DLOADER\\DLOADER\\Debug\\target.sys";
wchar_t DRIVERNAME[1024] = L"target.sys";
printf("PATH: %ls\n", PATH);
printf("DRIVERNAME: %ls\n", DRIVERNAME);
SC_HANDLE sh = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(!sh)
return false;
SC_HANDLE rh = CreateService(sh,
DRIVERNAME,
DRIVERNAME,
SERVICE_ALL_ACCESS,
SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
PATH,
NULL,
NULL,
NULL,
NULL,
NULL);
if(!rh)
{
printf("CreateService Failed(error%i)\n",GetLastError());
if (GetLastError() == ERROR_SERVICE_EXISTS)
{
rh = OpenService(sh,
DRIVERNAME,
SERVICE_ALL_ACCESS);
if(!rh)
{
printf("OpenService Failed(error%i)\n",GetLastError());
CloseServiceHandle(sh);
return false;
}
else
printf("OpenService Success\n");
}
else
{
CloseServiceHandle(sh);
return false;
}
}
if(rh)
{
if(0 == StartService(rh, 0, NULL))
{
printf("StartService Failed(error%i)\n",GetLastError());
if(ERROR_SERVICE_ALREADY_RUNNING == GetLastError())
{
}
else
{
CloseServiceHandle(sh);
CloseServiceHandle(rh);
return false;
}
}
else
printf("StartService Success\n");
CloseServiceHandle(sh);
CloseServiceHandle(rh);
}
return true;
}
Here is the output:
PATH: C:\DLOADER\DLOADER\Debug\target.sys
DRIVERNAME: target.sys
CreateService Failed(error1073)
OpenService Success
StartService Failed(error3)
Driver load Failed!
Any help would be appreciated!
Ohh and heres what those error codes are:
ERROR_SERVICE_EXISTS = 1073
ERROR_PATH_NOT_FOUND = 3
|
|
|
|
|
You need to follow the procedure below:
1) Open SC Manager,
2) Open Service, // You need to move this step here before creating service.
3) Create Service.
Maxwell Chen
|
|
|
|
|
Awesome... 5 days after I started I was successful at creating a kernel level driver that I can send commands to from the user mode... wow now I can actually start programming ... Thanks man, that ended up not being the route I took but I got a basic understanding of the SCM now!
Now if I can just read from physical memory correctly without blue-screening my system.. I'm guesstimating a good 10 days... gotta love free time... 
|
|
|
|
|
|
whenever you see errors like those (mutliply-defined std lib symbols), you can assume that you are building one or more subprojects with a different runtime library version (Props / C++ / Code Generation Runtime Library).
|
|
|
|
|
In this case all the libraries are compiled with a Multi-thread (/MT) Option.
|
|
|
|
|
How do I replace the old streambuf out_waiting function?
|
|
|
|
|
I have a list of states Id like to return from a function.
So I call a class:
<br />
CStates dlg;<br />
if (dlg.DoModal() == IDOK)<br />
{<br />
std::deque text;<br />
<br />
text = dlg.GetStates();<br />
}<br />
How can I return that deque from the class GetStates()? I
just cant get it to work?
|
|
|
|
|
Why don't you accept a reference to a deque object as function argument?
For instance:
bool GetStates(deque<string> & states)
{
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Code:
using namespace std;
<b>typedef map<CPDMGuiMainDlg*, void (TClass::*m_pFunctionPointer)(unsigned int,unsigned int)> g_ClassFuncPointerTDMap;</b>
g_ClassFuncPointerTDMap g_ClassFuncPointerMap;
typedef map<unsigned int, g_ClassFuncPointerTDMap > g_SignalClassFPTDMap; //, g_ClassFuncPointerTDMap
g_SignalClassFPTDMap g_SignalClassFPMap;
template <class TClass>
void attach(int iSignalValue, TClass* m_pClassPointer, void (TClass::*m_pFunctionPointer)(unsigned int,unsigned int))
{
if (g_SignalClassFPMap.find(iSignalValue) == g_SignalClassFPMap.end())
{
g_SignalClassFPMap.insert (make_pair (iSignalValue, g_ClassFuncPointerTDMap()));
g_SignalClassFPMap[iSignalValue].insert(make_pair (m_pClassPointer, m_pFunctionPointer));
}
else
{
//g_SignalClassFPMap[iSignalValue].insert(make_pair (m_pClassPointer, m_pFunctionPointer));
}
}
We are saving function pointer in g_ClassFuncPointerTDMap map. We are getting following error:
error C2653: 'TClass' : is not a class or namespace name.
how to decalre template TClass before using it.
|
|
|
|
|
|
if you design permits,
you can use boost library, boost:: bind and boost::function objects
|
|
|
|
|
VC6, MFC, XP
Hi - I need to prevent a CView from being closed before a thread operation is complete. The mainframe also has a secondary thread and I've handled that situation by reacting to the WM_CLOSE message. The view, which has it's own worker thread, doesn't seem to get the WM_CLOSE message (even if I put the code in) and reacting to WM_DESTROY in the view is too late to stop it from being closed.
Any suggestions?
Thank you,
Paul
|
|
|
|
|
Paul Belikian wrote: Hi - I need to prevent a CView from being closed before a thread operation is complete.
One way would be to use a CEvent object. When the view is being closed, call WaitForSingleObject() to wait for the event to become signaled. When the thread operation is complete, signal the event.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks David, that is a good suggestion.
I think my issue is that I'm not sure which (or what) message to hook in the view in order to wait for the event. The messages I've tried do not stop the view from being closed; for example, if I put a Sleep(5000) call in the view's WM_DESTROY handler, the window is still closed instantly. I need a place where the view will remain open if I delay the WM_xxxxxx message.
I'm doing this in case the user kills the app with the upper 'X' in the application's window ...perhaps I should look into that aspect. This is the only thread related thing I need to clean up. If the user doesn't kill the app while the background process is running (i.e. in the middle of loading a large database), all is well (but when do users wait for anything ? ), however if they do kill the app, I need to stop the views from being closed before the thread is dead. The threads can be stopped in an orderly manner at any time.
Thanks for your suggestion.
Paul
|
|
|
|
|
Paul Belikian wrote: I think my issue is that I'm not sure which (or what) message to hook in the view in order to wait for the event.
Have you tried responding to WM_CLOSE (i.e., returning 0 ) in the frame class?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Mainframe seems to work fine and stops the thread running in the mainframe. However I need to stop the view from closing before the view's thread is stopped (each view has it's own thread and the mainframe has another thread):
void CMainFrame::OnClose()
{
#ifdef _USE_BACKGROUND_THREAD_
DWORD dwExitCode;
m_pBackThread->Stop(dwExitCode, 0);
if(m_pBackThread->GetActivityStatus() != CThread::THREAD_RUNNING)
{
TRACE("Mainframe: Thread Busy, Can't close yet...\n");
PostMessage(WM_CLOSE);
}
else
{
TRACE("Mainframe: Can close now\n");
m_pBackThread->Stop(dwExitCode);
SaveCommandBars(_T("CommandBars"));
CXTPDockingPaneLayout layoutNormal(&m_paneManager);
m_paneManager.GetLayout(&layoutNormal);
layoutNormal.Save(_T("NormalLayout"));
CMDIFrameWnd::OnClose();
}
#else
SaveCommandBars(_T("CommandBars"));
CXTPDockingPaneLayout layoutNormal(&m_paneManager);
m_paneManager.GetLayout(&layoutNormal);
layoutNormal.Save(_T("NormalLayout"));
CMDIFrameWnd::OnClose();
#endif
}
|
|
|
|
|
The mainframe should know all its child views. Create a function in each view that the mainframe calls from its OnClose which can wait / allow / disallow the close.
Judy
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
 Hello Judy, yes, thank you for the suggestion. I actually did go that route using the DocTemplate to find all the views that I needed to check before closing. I chose this method because I also have multiple types of documents in the app - here is the code: forgive the mess, I'm self-taught
void CMainFrame::OnClose()
{
#ifdef _USE_CMC6INVOICE_THREAD_
POSITION pos, posView;
pos = theApp.m_pCmc6InvoiceDocTemplate->GetFirstDocPosition();
while(pos != NULL)
{
CDocument *pDoc = theApp.m_pCmc6InvoiceDocTemplate->GetNextDoc(pos);
if(pDoc!= NULL)
{
posView = pDoc->GetFirstViewPosition();
while(posView != NULL)
{
CView * pView = pDoc->GetNextView(posView);
if(pView->IsKindOf(RUNTIME_CLASS(CCMC6InvoiceView)))
{
CCMC6InvoiceView * pInv = (CCMC6InvoiceView *) pView;
if(pInv->m_clsInvoice->m_pThread != NULL)
{
if(pInv->m_clsInvoice->m_pThread->GetActivityStatus() == THREAD_NOTPREPARED_TO_TERMINATE)
{
TRACE("Mainframe: OnClose() ->CMC6InvoiceView Thread Busy, Can't close yet...\n");
Sleep(200);
PostMessage(WM_CLOSE);
return;
}
}
}
}
}
}
#endif
#ifdef _USE_BACKGROUND_THREAD_
DWORD dwExitCode;
m_pBackThread->Stop(dwExitCode, 0);
if(m_pBackThread->GetActivityStatus() == THREAD_NOTPREPARED_TO_TERMINATE)
{
TRACE("Mainframe: OnClose() ->BackProcess Thread Busy, Can't close yet...\n");
Sleep(200);
PostMessage(WM_CLOSE);
}
else
{
TRACE("Mainframe: OnClose() ->Can close now\n");
m_pBackThread->Stop(dwExitCode);
SaveCommandBars(_T("CommandBars"));
CXTPDockingPaneLayout layoutNormal(&m_paneManager);
m_paneManager.GetLayout(&layoutNormal);
layoutNormal.Save(_T("NormalLayout"));
CMDIFrameWnd::OnClose();
}
#else
SaveCommandBars(_T("CommandBars"));
CXTPDockingPaneLayout layoutNormal(&m_paneManager);
m_paneManager.GetLayout(&layoutNormal);
layoutNormal.Save(_T("NormalLayout"));
CMDIFrameWnd::OnClose();
#endif
}
|
|
|
|
|
I want to create a console like dialog, I was thinking like in a multi-line edit boxt, but I don't know how so I need some ideas to start with.
It should work like a "real" console, where you only can write at the prompt, only delete what you just have written, but not yet executed and so on.
Many games have a console like this, to send messages etc, maybe there's some code to start with?
What the result should be is an interactive console for Python, but intergrated in my application as a modeless window or a dialog. Python is easy to embed with, for example PyRun_InteractiveLoop, reading and writing to stdin/out.
Any ideas how this can be archived?
Thanks!
|
|
|
|
|
Well you can paint it back bg with CTL_COLORSTATIC notification message, you can use keyboard handler to do pretty cool stuff or you can simply trace for keywrds like record for keyboard msgs in wnd proc, and use gettickcount know make if a word is typed.then you can simply use GetDlgItemText to get text then append, i recommend use sstream.h for string formatting. then simply set the text to edit box with setdlgitemtext
|
|
|
|
|
Hi,
Is there any way to execute XQuery through MFC Code, I know How to use MSXML.DLL to load xml documents and navigate the XML document But I am looking for a method like ExecuteSQL("") to execute my XQuery statements?
|
|
|
|
|
When my article will be publish?How many days in general?Who have the right to publish the article?
|
|
|
|
|
The Lounge [^] is possibly more appropriate.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|