|
Hey fellas,
Right now I am pretty much stuck at a point I am modifying a device driver and well I don't really have much prior experience doing such stuff. For debugging reasons I need to write some data to a disk file. For this purpose I am using the following code :-
NTSTATUS Status;
LARGE_INTEGER ByteOffset;
IO_STATUS_BLOCK IoStatusBlock;
OBJECT_ATTRIBUTES InitializedAttributes;
UNICODE_STRING ustr;
HANDLE handle;
WCHAR fname[] = L"\\??\\D:\\Output.txt";
RtlInitUnicodeString(&ustr,fname);
InitializeObjectAttributes(&InitializedAttributes,&ustr,0, 0, NULL);
Status = ZwCreateFile(
&handle,GENERIC_WRITE|SYNCHRONIZE,
&InitializedAttributes,
&IoStatusBlock,
0,FILE_ATTRIBUTE_NORMAL,
0, FILE_OVERWRITE_IF, FILE_NON_DIRECTORY_FILE|
FILE_WRITE_THROUGH|
FILE_SYNCHRONOUS_IO_ALERT,
NULL,0);
ByteOffset.QuadPart = 0;
ZwWriteFile(handle,NULL,NULL,NULL,&IoStatusBlock,
data,512,NULL,NULL);
ZwClose(handle);
My problem is that the file is not getting created at all! Can anyone tell me what I doing wrong here?
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Hi Nish,
if u have win2k ddk(ntddk) ,there u can find a sample at the following directory.
root\ntddk\src\kernel\parclass\debug.c
this file debug.c has a sample on how to create a file from the kernel device driver..u can compare u r program with this and check out where u r going out of wrong..
regards,
shiv
|
|
|
|
|
I have developed my application using DirectShow for play MP3 file. I developed with DirectX 8.1 SDK.
How can I know which minimum version of DirectX runtime does my application require?
|
|
|
|
|
Is it possible to obtain the main window handle of a running application if I have the process ID?
I actually got the handle by enumerating the windows and searching by the window title. But, I feel like there must be a better way.
Thanks for any help
|
|
|
|
|
You can make the invert process using GetWindowThreadProcessId..
But for find that you need go to "Process and Thread Functions" in MSDN....
Carlos Antollini.
Pi Five[^]Creator
Sonork ID 100.10529 cantollini
|
|
|
|
|
I actually want to do just the reverse of what GetWindowThreadProcessId does. But, that gives me an idea, thanks..
|
|
|
|
|
It can't be done since it isn't unique (one process having 2 or more main windows). But if you are sure you have a unique window, the brute force method should work.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
hi,
if i have thread A, B to access variable C, so, i need to used CCriticalSecion to lock it, right?
however, if thead A, B access variable C in a structure and some other variables D,E,F in the same structure will only accessed by thread B. so, do i need to lock when thread B access these variables D,E,F?
my worry due to they are in same structure. but, some are public resource from multi-thread but some are private resource...
thanks,
jim
|
|
|
|
|
You only have to lock access for C, not DEF if they are truly independent. It doesn't really matter if they are all in the same structure.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi,
I have been working on this program for quite a while and have been doing quite well. Somehow, however I seem to have done something wrong. Being new to this I am at a total loss trying to decipher this error message. I checked MSDN and got something that doesn't seem to help me. I'd really appreciate it if someone could please tell me what this error might mean. The program worked yesterday, and today it doesn't, with no changes by me in between.
Project4 error LNK2019: unresolved external symbol "protected: __thiscall CProject4Doc::CProject4Doc(void)" (??0CProject4Doc@@IAE@XZ) referenced in function "public: static class CObject * __stdcall CProject4Doc::CreateObject(void)" (?CreateObject@CProject4Doc@@SGPAVCObject@@XZ)
Thanks a lot
Garry
|
|
|
|
|
Most likely you have not defined your function. You have in your .h file something like:
class CProject4Doc {
CProject4Doc();
.
.
.
};
But in your .cpp you do not have this function/constructor defined.
Thats the most obvious though unlikely reason. The fact that it worked one day and not another without code change... well ..... something had to have changed. Or maybe your compile yesterday was not a rebuild all and the file dates were kind of screwed up so the compiler did not pick the file in question and so the error did not show up.
|
|
|
|
|
WOW!!!! As unlikely as it mat have been I must have somehow deleted the constructor/destructor. I don't remember doing it but must have somehow. THANKS INCREDIBLY!!!!
Garry
|
|
|
|
|
i use CHtmlView to laod a html page which includes a swing.class object, the page is ok (text etc. are shown) but swing.class (extends JApplet)is not shown.
do u know how to use CHtmlView to display a JApplet.class object?
thx
includeh10
|
|
|
|
|
|
How does one get the processor speed from windows -- without actually testing it myself?
Windows seems to know it, but how can I get the same info?
|
|
|
|
|
From the registry:
HKEY_LOCAL_MACHINE > HARDWARE > DESCRIPTION > CentralProcessor > 0 > ~MHz
If you just want to know, use regedit.exe. If you need an application to read it, use the windows registry access functions.
|
|
|
|
|
Sorry, I forgot that my previous answer is only good on NT/2K/XP.
Check out the CPUTest article here on CodeProject:
http://www.codeproject.com/system/cputest.asp
I believe this should work on 95/98/Me, but only with CPUs that have the RDTSC instruction. Also, the code in this article does actually measure the speed, but it allows the measurement to be done rather quickly.
Win95/98/Me probably also stores the CPU information in the registry. I just don't happen to know where. I suggest doing a search here on CodeProject, on Google, or on CodeGuru.
- Kevin
|
|
|
|
|
|
How do I get the hwnd of the edit control portion of a combobox?
In a dialog I need to know if a certain control has focus.
CComboBox m_cLookup;
if(GetFocus()->GetSafeHwnd() == m_cLookup.GetSafeHwnd()){<br />
}
Doesn't work for a combobox, but works fine for a CEdit, so I'm assuming the hwnd of the edit control portion of the combobox is different from the hwnd of the combobox itself.
Ed
|
|
|
|
|
Need to find the edit window on the control.... see below...
HWND EditWnd = NULL;
::EnumChildWindows(cLookup.m_hWnd, EditFindProc, (LPARAM)&EditWnd);
BOOL CALLBACK CFindBar::EditFindProc(HWND hWnd, LPARAM lParam)
{
char szBuffer[255];
::GetClassName(hWnd, szBuffer, sizeof(szBuffer));
if (!::lstrcmp(szBuffer, "Edit"))
{
*((HWND*)lParam) = hWnd;
return FALSE;
}
return TRUE;
}
|
|
|
|
|
Hi,
I just recently used Marcio Ritter's tutorial on game programming to make a directX app. Sadly, it's not working (the OnIdle() function is causing problems). I asked Marcio about it, but I believe he is pretty busy, and was hoping that maybe some could glance at the code. It's very basic, and I'm sure it's something very simple that's causing it to crash. Oh well, if you would like to look at it, my e-mail is nreveles@austin.rr.com
Thanks for your time,
~ Selevercin
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
If you think OnIdle() crashes just post some source code.
Gero
|
|
|
|
|
I didn't think it would be much help by itself, but here it is anyway
<code>
HRESULT hRet;
g_Brick.Draw(g_pDDSBack, 10, 10, 2, 2, 10, 10);
while( 1 )
{
hRet = g_pDDSFront->Flip(NULL, 0 );
if( hRet == DD_OK )
{
break;
}
if( hRet == DDERR_SURFACELOST )
{
g_pDDSFront->Restore();
}
if( hRet != DDERR_WASSTILLDRAWING )
{
break;
}
}
If you have a problem with my spelling, just remember that's not my fault. I [as well as everyone
else who learned to spell after 1976] blame it on
Robert A. Kolpek for U.S. Patent 4,136,395.
|
|
|
|
|
Have you stepped through it with a debugger?
Where does it crash? Does it crash the first time through the loop? At the very least I would add some trace statements so that you can tell what happens each time through the loop.
With out any more information I dont really know how to help you.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|