|
 Well I got it finally, documentation is poor, but it was there.
getline - gets the line, and keeps the /n
gets - get the line, and discards the /n
I used a do loop with a while (sqlDBFile->get()) at the end, so it was chopping off the first char of the next line.
So this is what I ended up with, but I'm not sure if I need the conv at the top
typedef std::codecvt<wchar_t, wchar_t, mbstate_t> nullcodecvt;
const nullcodecvt &conv =
std::use_facet<nullcodecvt>(std::wcin.getloc());
const std::locale from(std::wcin.getloc(), &conv);
std::wifstream *sqlDBFile = new std::wifstream;
sqlDBFile->open( szFilePath, std::ios_base::in );
if (sqlDBFile->is_open() ) {
if (_wcsicmp(szEncoding, L"UTF8") == 0 ) {
sqlDBFile->seekg(3, std::ios::beg);
}
WCHAR *pzSQLCommand = new WCHAR[8192];
wcsncpy_s(pzSQLCommand, 8192, L"-- SQL Command Buffer --\n", wcslen(L"-- SQL Command Buffer --\n") );
while (sqlDBFile->good() ) {
while (!sqlDBFile->eof() ) {
WCHAR szCommandLine[1024];
for (int i = 0; i<1024; ++i) {
szCommandLine[i] = 0xcccc;
}
sqlDBFile->getline(szCommandLine, 1024);
if (szCommandLine[0] == 0x002d)
continue;
if ((szCommandLine[0] == 0x0000) && (szCommandLine[1] == 0x0000))
continue;
if ((szCommandLine[0] == 0x0000) && (szCommandLine[1] == 0xcccc))
continue;
if (_wcsicmp(szCommandLine, L"GO") == 0 ) {
hr = pICommandText->SetCommandText( DBGUID_DBSQL, pzSQLCommand );
hr = pICommandText->QueryInterface( IID_ICommandProperties, ( void ** ) &pICommandProperties );
hr = pICommandText->Execute( NULL, IID_IRowset, NULL, &cRowsAffected, ( IUnknown ** ) &pIRowset );
for (int i = 0; i<8192; ++i) {
pzSQLCommand[i] = 0xcccc;
}
}
else {
szCommandLine[wcslen(szCommandLine)] = L'\0';
wcsncat_s(pzSQLCommand, 8196, szCommandLine, wcslen(szCommandLine) );
continue;
}
}
}
delete pzSQLCommand;
sqlDBFile->close();
sqlDBFile = NULL;
}
|
|
|
|
|
RTL_QUERY_REGISTRY_TABLE query_table[2];
RtlZeroMemory(&query_table[0],sizeof(query_table));
RtlZeroMemory gives error
please guide..
Answer:
Firstly sorry for late reply,
It was really a very strange error, or one can call it a bug.
I just uninstalled the visual studio express ide and re-installed it. After that RtlZeroMemory error had gone. I guess some exception or bug had occured in the ide or compiler or god knows. But it worked.
Thank you all, for sharing your precious time with me.
Regards,
Vishal
|
|
|
|
|
RtlZeroMemory(query_table, sizeof(query_table));
As described in the document use the ZeroMemory macro instead of the function.
|
|
|
|
|
i had done the same thing but still the same error pops.
Regards,
Vishal
|
|
|
|
|
|
|
Doesnt say it should be used in place of the Rtl though.
==============================
Nothing to say.
|
|
|
|
|
That's a struct , try this...
RtlZeroMemory((void *)query_table,sizeof(RTL_QUERY_REGISTRY_TABLE)*2);
|
|
|
|
|
Albert Holguin wrote: RtlZeroMemory((void *)query_table,sizeof(RTL_QUERY_REGISTRY_TABLE)*2);
tried this but the result is same as earlier..
Error: expression must have (pointer-to-)function type
I am stuck at a dead end...
Regards,
Vishal
|
|
|
|
|
This must be something weird with the definition of the function (or macro)... why not use memset() instead?
..post the definition of the function (or macro) if you can see it...
|
|
|
|
|
#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
I had included
ntddk.h, ntifs.h
I had even tried memset, but still the error is same
memset(query_table,0,sizeof(query_table));
Error: expression must have (pointer-to-)function type
Regards,
Vishal
|
|
|
|
|
Did you type cast query_table within the memset() ?
With the type casting, even if it's completely wrong (and would crash at run-time if it's wrong), it would compile. I think you must be doing something wrong. I, like Richard, don't have the DDK so I can't try this.
|
|
|
|
|
I think RtlZeroMemory() may not be defined in this compilation unit. Have you #include d one of Wdm.h , Ntddk.h , or Ntifs.h in this compilation?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yes, header is ok.
I had already included
ntddk.h, ntifs.h
but, still same error..
I had even tried
memset But the result is same
Error: expression must have (pointer-to-)function type
Regards,
Vishal
|
|
|
|
|
There must be some other code near this line that is causing the problem. Can you post the code about 5 lines before to 5 lines after this, and also the exact text (copied and pasted) of all error messages from the compiler?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath)
{
UNICODE_STRING parameter_path;
RTL_QUERY_REGISTRY_TABLE query_table[2];
parameter_path.Length = 0;
parameter_path.MaximumLength = RegistryPath->Length + sizeof(PARAMETER_KEY);
parameter_path.Buffer = (PWSTR) ExAllocatePool(PagedPool, parameter_path.MaximumLength);
if (parameter_path.Buffer == NULL) return STATUS_INSUFFICIENT_RESOURCES;
RtlCopyUnicodeString(¶meter_path, RegistryPath);
RtlAppendUnicodeToString(¶meter_path, PARAMETER_KEY);
RtlZeroMemory(&query_table[0], sizeof(query_table));
query_table[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
query_table[0].Name = NUMBEROFDEVICES_VALUE;
query_table[0].EntryContext = &n_devices;
}
Regards,
Vishal
|
|
|
|
|
Well, I've looked at this and looked at all the documentation I can find and am no nearer an answer. Also, I do not have a copy of the DDK so cannot even try compiling your small sample.
Sorry, but I'm out of suggestions, but I would be really interested to know what the resolution is; let's hope one of the driver experts sees this question tomorrow when everyone is back from their weekend R&R.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I had too tried every possible ways, but i am unable to understand why this error is occurred.
Hope some driver experts shed some light on this matter. Anyways thanx for giving your valuable time.
Regards,
Vishal
|
|
|
|
|
I have also tried as many ways that I could to "fix" some sample code to reproduce the error, but have not been able to, nor can I find any examples via Google. Are you using the standard Microsoft DDK, and which version of the compiler are you using?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I discovered, by chance, that it can be caused by something like:
int RtlZeroMemory;
RtlZeroMemory(&query_table[0],sizeof(query_table));
because RtlZeroMemory has been defined somewhere as something that is not a function. So you need to track backwards through your source and header files to the definition of RtlZeroMemory , and resolve why it is doing this.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Using a DDK set compiler I doubt doing this would compile since it would give a duplicate definition error.
--edit--
Oddly it doesn't complain for int RtlZeroMemory, it compiles OK (I guess because it is a #define) however int memset does not compile due to a duplicate deffition error.
So, means he is not using a DDK compiler and build macro by the looks of it, but some other compiler, or doing something else odd in his code.
==============================
Nothing to say.
modified 5-Dec-11 13:04pm.
|
|
|
|
|
Erudite_Eric wrote: or doing something else odd in his code.
I think that's a given, I'm just trying to find out what.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Firstly sorry for late reply,
It was really a very strange error, or one can call it a bug.
I just uninstalled the visual studio express ide and re-installed it. After that RtlZeroMemory error had gone. I guess some exception or bug had occured in the ide or compiler or god knows.
Thank you all, for sharing your precious time with me.
Regards,
Vishal
|
|
|
|
|
Richard MacCutchan wrote: let's hope one of the driver experts sees this question tomorrow
I am here.
See my reply...
==============================
Nothing to say.
|
|
|
|
|
Mmmh, this should be fine.
For testing use also:
RTL_QUERY_REGISTRY_TABLE query_table[2] = {0};
IS this the correct line, where the error comes from ???
Maybe it is:
Table[0].QueryRoutine = &XQueryRoutine;
And XQueryRoutine is wrong defined ?
|
|
|
|