|
If you follow Win32_SystemDevices to Win32_PnPEntity, you should find a leaf with a device id something like USBSTOR.....
From there, you can get (look under Win32_PnPDevice) the correct DeviceId to use for Win32_DiskDrive.
From there, you can get (look under Win32_DiskDriveToDiskPartition) the correct DeviceId to use for Win32_DiskPartition.
From there, you can get (look under Win32_LogicalDiskToPartition) the correct DeviceId to use for Win32_LogicalDisk.
That final device id is the logical drive number.
(Whew!! <wiping brow="">)
Getting that first USBSTOR... monster string is what's usually the hardest part of this sort of thing since you have to use the SetupDi API. That is truly nasty!!
Judy
|
|
|
|
|
Wow! I need an elevator to come back to the surface from drilling down that deep. It works, though.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm looking for a way of identifying the data members of a number of classes that need to be serialized
Boost serialization would be used - but what I'm looking for is a way to automatically generate the serialization helpers.
The idea would be to:
1) Run an utility (parser) that scans the C++ code and identifies the data members
2) From the data members generate .inl files (one for each class) that would contain the boost::serialize() method
3) Have the .inl files included in the corresponding cpps
4) Compile and link...
These are classes that are modified on a daily basis by other people. Maintaining the serialization code manually would not be an option - looking for an automated way.
Definitely someone else had solved this problem (with this approach or a different one). Let me know if you know anything about that.
Thanks,
Adrian
|
|
|
|
|
Adrian R. wrote: 2) From the data members generate .inl files (one for each class) that would contain the boost::serialize() method
What about pointers?
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
|
|
|
|
|
I'm using a Gdiplus::Bitmap object as a buffer bitmap.
When do some, I can't open the file used by the bitmap in CFile::modeRead mode.
Is there any mehod to make it read-share?
|
|
|
|
|
i want to hook the windows API such as messagebox, i find the code in the net, but it dosn't work, why? the code as follows:
typedef struct tag_HOOKAPI
{
LPCSTR szFunc;
PROC pNewProc;
PROC pOldProc;
}HOOKAPI, *LPHOOKAPI;
HOOKAPI api[1];
api[0].szFunc ="MessageBoxA";
api[0].pNewProc = (PROC)MessageBoxA1;
HookAPIByName(GetModuleHandle(NULL),"User32.dll",&api[0]);
extern "C" __declspec(dllexport)PIMAGE_IMPORT_DESCRIPTOR
LocationIAT(HMODULE hModule, LPCSTR szImportMod)
{
PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER) hModule;
if(pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE) return NULL;
PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((DWORD)pDOSHeader+
(DWORD)(pDOSHeader->e_lfanew));
if(pNTHeader->Signature != IMAGE_NT_SIGNATURE) return NULL;
if(pNTHeader->OptionalHeader.DataDirectory
[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress == 0)
return NULL;
PIMAGE_IMPORT_DESCRIPTOR pImportDesc =
(PIMAGE_IMPORT_DESCRIPTOR)((DWORD)pDOSHeader + (DWORD)
(pNTHeader->OptionalHeader.DataDirectory
[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress));
while (pImportDesc->Name)
{
PSTR szCurrMod = (PSTR)((DWORD)pDOSHeader +
(DWORD)(pImportDesc->Name));
if (stricmp(szCurrMod, szImportMod) == 0) break;
pImportDesc++;
}
if(pImportDesc->Name == NULL) return NULL;
return pImportDesc;
}
extern "C" __declspec(dllexport) HookAPIByName( HMODULE hModule, LPCSTR szImportMod, LPHOOKAPI pHookApi)
{
PIMAGE_IMPORT_DESCRIPTOR pImportDesc = LocationIAT(hModule, szImportMod);
if (pImportDesc == NULL) return FALSE;
PIMAGE_THUNK_DATA pOrigThunk = (PIMAGE_THUNK_DATA)((DWORD)hModule + (DWORD)(pImportDesc->OriginalFirstThunk));
PIMAGE_THUNK_DATA pRealThunk = (PIMAGE_THUNK_DATA)((DWORD)hModule + (DWORD)(pImportDesc->FirstThunk));
while(pOrigThunk->u1.Function)
{
if((pOrigThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) != IMAGE_ORDINAL_FLAG)
{
PIMAGE_IMPORT_BY_NAME pByName =(PIMAGE_IMPORT_BY_NAME)((DWORD)hModule+(DWORD)(pOrigThunk->u1.AddressOfData));
if(pByName->Name[0] == '\0') return FALSE;
if(strcmpi(pHookApi->szFunc, (char*)pByName->Name) == 0)
{
MEMORY_BASIC_INFORMATION mbi_thunk;
VirtualQuery(pRealThunk, &mbi_thunk, sizeof(MEMORY_BASIC_INFORMATION));
VirtualProtect(mbi_thunk.BaseAddress,mbi_thunk.RegionSize, PAGE_READWRITE, &mbi_thunk.Protect);
if(pHookApi->pOldProc == NULL)
pHookApi->pOldProc = (PROC)pRealThunk->u1.Function;
pRealThunk->u1.Function = (PDWORD)pHookApi->pNewProc;
DWORD dwOldProtect;
VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize, mbi_thunk.Protect, &dwOldProtect);
}
}
pOrigThunk++;
pRealThunk++;
}
SetLastError(ERROR_SUCCESS);
return TRUE;
}
static int WINAPI MessageBoxA1 (HWND hWnd , LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
{
return MessageBox(hWnd, "Hook API OK!", "Hook API", uType);
}
|
|
|
|
|
OK - you are not getting any replies because of the following issues, which I suggest you correct ASAP:
1: You code snippet neets to be inbetween <PRE> tags
2: In order to ask why something does not work, you have to specify what exactly is not working (error codes, crashes, etc.)
I have successfully used a CBT hook to capture, log the contents of, and pop MessageBox(...) -based dialogs successfully in the past, so I know this is not too hard.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
1. Format your code so it's readable. I know it's a pain, but it's also a pain from this end: I don't even bother to look at such messes.
2. What's going wrong?
Steve
|
|
|
|
|
yes, it was my fault to post such long and boring code!
but ,frankly to say, i got the code from the website, i didn't understand it with my little HOOK and DLL knoledge. i debuged the code , and found that it cound not get the User32.dll IAT location, i didn't know the matter.
my aim is to hook the window API , such as messagebox or winsocket, would you please give me some help? refering materials or codes?
thanks!
|
|
|
|
|
I have exe file generated of compile C++ code using Microsoft Visual Studio 2005 on my Laptop , and i need to take this exe file to run it on my pocket PC.
Is it possible to run this exe file on pocket PC ?????
ahmed.rayan@hotmail.com
|
|
|
|
|
Member 4174639 wrote: Help me please
Is it urgent?
led mike
|
|
|
|
|
led mike wrote: Is it urgent?
Of course it is. Did you not notice the five question marks?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Did you not notice the five question marks?
No and based on the thread below it's probably due to the inter-dimensional rift I seem to be caught in.
led mike
|
|
|
|
|
yes
It is urgent ,If u have time
|
|
|
|
|
So it's urgent, but depending on other people spare time, right?
Anyway, did you compile it for Pocket PC ?
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
|
|
|
|
|
Thanks for your time , but how can i compile it for Pocket PC?
|
|
|
|
|
Ask the Mobile Development [^] forum.
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
|
|
|
|
|
CPallini wrote: Ask the Mobile Development [^] forum.
no. Ask you compiler !
|
|
|
|
|
|
Hello everyone,
http://www.gotw.ca/gotw/059.htm
The reason why we can not write an exception safe copy assignment for class Widget, is because (suppose we assign t1_, then assign t2_) if T1::operator=() does not throw exception, and T2::operator=() throws exception, then since all operations on T1 may throw, it means we can not find any operations on T1 which could rollback the original status to T1 without exception thrown (if exception is thrown during rollback, means rollback is not successful, and T1 will be in an in-consistent status which is different from original status -- which violates the strong exception safe guideline).
My understanding correct?
I quote the related paragraph below as well.
--------------------
3. Consider the following class:
class Widget
{
private:
T1 t1_;
T2 t2_;
};
Assume that any T1 or T2 operation might throw. Without changing the structure of the class, is it possible to write a strongly exception-safe Widget::operator=( const Widget& )? Why or why not? Draw conclusions.
Short answer: In general, no, it can't be done without changing the structure of Widget.
In the Example 3 case, it's not possible to write a strongly exception-safe Widget::operator=() because there's no way that we can change the state of both of the t1_ and t2_ members atomically. Say that we attempt to change t1_, then attempt to change t2_. The problem is twofold:
1. If the attempt to change t1_ throws, t1_ must be unchanged. That is, to make Widget::operator=() strongly exception-safe relies fundamentally on the exception safety guarantees provided by T1, namely that T1::operator=() (or whatever mutating function we are using) either succeeds or does not change its target. This comes close to requiring the strong guarantee of T1::operator=(). (The same reasoning applies to T2::operator=().)
2. If the attempt to change t1_ succeeds, but the attempt to change t2_ throws, we've entered a "halfway" state and cannot in general roll back the change already made to t1_.
--------------------
thanks in advance,
George
|
|
|
|
|
George_George wrote: My understanding correct?
Maybe. I can't tell what it is you think you understand. The entire concept seems incredibly obvious to me. Anyone else?
led mike
|
|
|
|
|
Thanks led mike,
What I do not understand and also the quoted paragraph is not clear is about "cannot in general roll back the change already made to t1_.". Why can not rollback in general? Because of exception occurs in rollback operation of t1_?
regards,
George
|
|
|
|
|
George_George wrote: The reason why we can not write an exception safe copy assignment for class Widget, is because (suppose we assign t1_, then assign t2_) if T1::operator=() does not throw exception, and T2::operator=() throws exception, then since all operations on T1 may throw, it means we can not find any operations on T1 which could rollback the original status to T1 without exception thrown (if exception is thrown during rollback, means rollback is not successful, and T1 will be in an in-consistent status which is different from original status -- which violates the strong exception safe guideline).
You're interpretation is correct, but is not the whole scenario: it maybe also impossible to roll back because T1 class public interface simply doesn't allow it.
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
|
|
|
|
|
Thanks CPallini,
CPallini wrote: it maybe also impossible to roll back because T1 class public interface simply doesn't allow it.
To rollback, we can simply make assignment again. If we keep the original object's status into a temp object. I do not agree with you there is no public interface -- assignment is enough.
Any comments?
regards,
George
|
|
|
|
|
George_George wrote: To rollback, we can simply make assignment again.
What? And the user is going to know about this rollback how? Did I wake up in an alternate dimension this morning? Has anyone here read Meyers? Have I completely misremembered his entire point on operators?
led mike
|
|
|
|
|