|
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
How Can I View the Dll file function and return Types or Params types?
thx.
msn:Flashcutreg@hotmail.com
|
|
|
|
|
For exported functions use
dumpbin /exports my.dll
For exported COM-components use oleview and choose "View TypeLib" from File menu.
|
|
|
|
|
Shi Zhu wrote: How Can I View the Dll file function and return Types or Params types?
Depend.exe well help.. this is present in the tool folder of Visual Studio!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
For example, as I have 2 USB keyboard linked to one PC, And I use one of them to press "K" key, and how can i know which one is inputting "K" key.
does any API can do this? Thanks
|
|
|
|
|
No - it's coming from 'the' keyboard, if you have more than one, they are both 'the' keyboard when you press a key on them.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Two keyboards? Why?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
lpy_chl wrote: For example, as I have 2 USB keyboard linked to one PC, And I use one of them to press "K" key, and how can i know which one is inputting "K" key.
does any API can do this? Thanks
this is not possible AFAIK i know... window will present problem~
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
I would like to know how to do the screen capture?
Please help!
|
|
|
|
|
But not enough to search the site ? There's at least two articles on this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
Hi to All,
I have a problem in VC++.
Im using ado object for database application.
Is there any method exists in _RecordsetPtr to reteive all Column_Names and
Data_types of columns(Fields).
I have tried a lot,but failed.
plz suggest me.....
Thanks a lot in advance
Nagaraju
|
|
|
|
|
This might work, assuming recordset is a _RecordsetPtr:
ADODB::FieldPtr field;
CString name;
int type;
for (int i = 0; i < recordset->Fields->GetCount(); i++ )
{
field = recordset->Fields->GetItem(COleVariant(i));
if (field)
{
name = field->GetName();
type = field->GetType();
}
}
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
ADO wrapper class C_Recordset has method GetFields ,which returns CFields . Use this class for information you required.
|
|
|
|
|
Hello,
This is in continuation with my previous post.
I have scuccessfully created the digital signature of an XMl file with the help of crypto APIs and have saved this signature in a separate file (with .binary extension).
Now I have to write another code which should take this signature and the original XML file and verify the signature against the original XML file. This is to be done in C++. Kindly provide me the code for the signature verification if someone have it.
Thnx
|
|
|
|
|
How on earth can we do that ?
You are the only one who knows what crypto APIs you used, and if you're looking to verify the signature against the file, doesn't that mean just creating it again ?
If there's a standard for digital signing of XML files, I'd like to know about it. If there's not ( and I don't know of one ), you're making this up as you go, and you're still not providing anywhere near enough info for anyone to be able to give you an answer.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I'll take a stab at this one:
class XMLSignatureVerifier
{
public:
static bool Verify(const TCHAR *pszXMLPathname, const TCHAR *pszSigFilePathname);
}
bool XMLSignatureVerifier::Verify(const TCHAR *pszXMLPathname, const TCHAR *pszSigFilePathname)
{
return true;
}
Example how to use the class:
if (XMLSignatureVerifier::Verify(_T("Test.XML"), _T("Test.binary")))
{
}
else
{
}
That should work.
|
|
|
|
|
Assumptions:
- you used the Win crypto api's (you didn't say which you are using)
- you obtained a hash of the file and then used CryptSignHash()
You then have to:
- get the key that was used to sign the hash (from the same container e.g. AT_SIGNATURE from default user container)
- use CryptVerifySignature()
... or, as was mentioned, just (re)sign the file and compare signatures.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thanks to all who took time and replied to my post.
I too admit that I was not very clear in my earlier post so here I am giving the details.
First I have written a code (in C) which should write a signature of an XML file, generate a keyBLOB which I am storing on some speciied path in my PC and then it stroes the signature at some specified location.
In my second code I want to take the input of the orginal XMl file, the kep BLOB from the path where I stored it and the signature of the file and then have to verify the signature.
Now I give the code details which I have done in two parts, the first part tells about creating signature and 2nd part tells about the verification:
1. In the first part (signing of XML file)
HANDLE hFileHandle = CreateFile("C:\\\\SampleConfig.xml",GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
HANDLE hsigHandle;
HANDLE hkeyHandle;
if(hFileHandle==INVALID_HANDLE_VALUE)
{
return FALSE;
}
if(dwFileSize==0)
{
CloseHandle(hFileHandle);
return FALSE;
}
SetFilePointer(hFileHandle,0,0,FILE_BEGIN);
ZeroMemory(pXMLData, dwFileSize);
if(!ReadFile(hFileHandle,pXMLData, dwFileSize,&dwBytesRead,NULL))
{
CloseHandle(hFileHandle);
delete[] pXMLData;
return FALSE;
}
printf("XML file extracted ....\n");
if(CryptAcquireContext( &hProv, UserName, MS_DEF_PROV, PROV_RSA_FULL, 0)) //changed the CSP name from NULL to MS_DEF_PROV
{
printf("CSP context with %s named key container has been acquired.\n", UserName);
}
else
{
{
if(CryptAcquireContext(&hProv, UserName, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET))
{
printf("A new key container has been created.\n");
}
else
{
printf("Could not create a new key container.\n");
MyHandleError("Error in creating a new key container.");
exit(1);
}
}
else
{
printf("A cryptographic service handle could not be acquired.\n");
MyHandleError("A cryptographic service handle could not be acquired.");
exit(1);
}
} // End of else.
if(CryptGetUserKey(hProv, AT_SIGNATURE, &hKey))
{
printf("The signature key has been acquired. \n");
}
else
{
if (NTE_NO_KEY == GetLastError ())
{
// Create signature key pair.
if (! CryptGenKey (hProv, AT_SIGNATURE, 0, &hKey))
{
// Error during CryptGenKey!
return FALSE;
}
else
{
CryptDestroyKey (hKey);
}
MyHandleError("Error during CryptGetUserKey for signkey.");
}
}
if(CryptExportKey(hKey, NULL, PUBLICKEYBLOB, 0, NULL, &dwBlobLen))
{
printf("Size of the BLOB for the public key determined. and its %d long\n", dwBlobLen);
}
else
{
MyHandleError("Error computing BLOB length.");
}
// Allocate memory for the pbKeyBlob.
if(pbKeyBlob = (BYTE*)malloc(dwBlobLen))
{
printf("Memory has been allocated for the BLOB. \n");
}
else
{
MyHandleError("Out of memory. \n");
}
// Do the actual exporting into the key BLOB.
if(CryptExportKey( hKey, NULL, PUBLICKEYBLOB, 0, pbKeyBlob, &dwBlobLen))
{
printf("Contents have been written to the BLOB. \n");
hkeyHandle = CreateFile("D:\\pubkey.txt",GENERIC_WRITE,0,NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hkeyHandle==INVALID_HANDLE_VALUE)
{
return FALSE;
}
SetFilePointer(hkeyHandle,0,0,FILE_BEGIN);
if(!WriteFile(hkeyHandle,pbKeyBlob,dwBlobLen,&dwkeyBytesWritten,NULL))
{
CloseHandle(hkeyHandle);
return FALSE;
}
printf("\nKey FILE CREATED\n\n");
}
else
{
MyHandleError("Error during CryptExportKey.");
}
//-------------------------------------------------------------------
// Create the hash object.
if(CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash))
{
printf("Hash object created. \n");
}
else
{
MyHandleError("Error during CryptCreateHash.");
}
// Compute the cryptographic hash of the buffer.
if(CryptHashData(hHash, pXMLData, dwBufferLen, 0))
{
printf("The data buffer has been hashed.\n");
}
else
{
MyHandleError("Error during CryptHashData.");
}
// Determine the size of the signature and allocate memory.
dwSigLen= 0;
if(CryptSignHash(hHash, AT_SIGNATURE, NULL, 0, NULL, &dwSigLen))
{
printf("Signature length %d found.\n",dwSigLen);
}
else
{
MyHandleError("Error during CryptSignHash.");
}
// Allocate memory for the signature buffer.
if(pbSignature = (BYTE *)malloc(dwSigLen))
{
printf("Memory allocated for the signature.\n");
}
else
{
MyHandleError("Out of memory.");
}
// Sign the hash object.
if(CryptSignHash(hHash, AT_SIGNATURE, NULL, 0, pbSignature, &dwSigLen))
{
printf("pbSignature is the hash signature.\n");
printf("\n");
hsigHandle = CreateFile("D:\\signature.binary",GENERIC_WRITE,0,NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hsigHandle==INVALID_HANDLE_VALUE)
{
return FALSE;
}
SetFilePointer(hsigHandle,0,0,FILE_BEGIN);
if(!WriteFile(hsigHandle,pbSignature, dwSigLen,&dwBytesWritten,NULL))
{
CloseHandle(hsigHandle);
return FALSE;
}
printf("SIGNATURE FILE CREATED\n\n");
}
else
{
MyHandleError("Error during CryptSignHash.");
}
// Destroy the hash object.
if(hHash)
{
if (CryptReleaseContext(hProv,0))
{
printf("The handle has been released.\n");
}
else
{
printf("The handle could not be released.\n");
}
}
printf("The hash object has been destroyed.\n");
printf("The signing phase of this program is completed.\n\n");
}// End of main
void MyHandleError(char *s)
{
fprintf(stderr,"An error occurred in running the program. \n");
fprintf(stderr,"%s\n",s);
fprintf(stderr, "Error number %x.\n", GetLastError());
fprintf(stderr, "Program terminating. \n");
exit(1);
} // End of MyHandleError
The above code successfully signs the XML file and I can store the key and signature on the hard disk.
2. Now I am writing a separate code for the verification of the created signature whioch would run on separte PC which I am intending to write in this manner.
---
HANDLE hFileHandle = CreateFile("D:\\Priyanka\\PLUTUS\\Citibank\\CitiCode\\CitiInit\\SampleConfig.xml",GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
DWORD dwFileSize= GetFileSize(hFileHandle,NULL);
BYTE* pXMLData = new BYTE[dwFileSize];
DWORD dwBufferLen = strlen((char *)pXMLData)+1;
HANDLE hsigHandle = CreateFile("D:\\signature.binary",GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
DWORD dwSigFileSize= GetFileSize(hsigHandle,NULL);
BYTE* pbSignature = new BYTE[dwSigFileSize];
DWORD dwSigLen = strlen((char *)pbSignature)+1;
HANDLE hkeyHandle = CreateFile("D:\\pubkey.txt",GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
DWORD dwKeyFileSize= GetFileSize(hkeyHandle,NULL);
BYTE* pbKeyBlob = new BYTE[dwKeyFileSize];
DWORD dwBlobLen = strlen((char *)pbKeyBlob)+1;
Then I will read the contents of the XML file, Public key file and the signature file and store the data in pXMLData, pbKeyBlob and pbSignature.
Now I am planning to do the verificatiion in this manner that
a)if(CryptImportKey(hProv, pbKeyBlob, dwBlobLen, 0, 0, &hPubKey))
{
printf("The key has been imported.\n");
}
else
{
MyHandleError("Public key import failed.");
}
if(CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash))
{
printf("The hash object has been recreated. \n");
}
else
{
MyHandleError("Error during CryptCreateHash.");
}
if(CryptHashData(hHash, pbBuffer, dwBufferLen, 0))
{
printf("The new has been created.\n");
}
else
{
MyHandleError("Error during CryptHashData.");
}
if(CryptVerifySignature(hHash, pbSignature, dwSigLen, hPubKey, NULL,0))
{
printf("The signature has been verified.\n");
}
else
{
printf("Signature not validated!\n");
}
free(pbSignature);
CryptDestroyHash(hHash);
here I want to know tht whether I would have to acquire the CSP context again in the 2nd part in the verification code with the similar parameters which I used at the time of creatin gthe signature or would have to use the same handle hProv which was create in the first part? I think that I should acquire the CSP context again and when I am doing that and then does the CryptImportKey it gives me the NTE_BAD_DATA error (from the GetLastError()).
Please help me how should I verify it and tell me is the way of creating the signature and the kepBLOB correct or not?
Please reply soon as I am stuck now ...
Thnx
|
|
|
|
|
Hi All!
i have some problem in attatching a SOCKET handle to a CSocket object.
I'm creating a Socket on Server side, and accepting the conncetion using a
temperory socket object, and retrieving the SOCKET handle by using
CSocket::Detach(), below is the code i used...
At Server: in the main thread.
CListeningSocket ServerSocket;// class CListeningSocket : public CSocket
CSocket TempSocket;
ServerSocket.Create(port);
ServerSocket.Listen();
ServerSocket.Accept(TempSocket);
SOCKET hSocket = TempSocket.Detach();
and i'm passing this handle to a Thread. (trying to create a separate thread for each client)
( this techinque is mentioned in one of the articles from Microsoft
the link is [url]http://support.microsoft.com/kb/175668[/url] )
In the CSocketThread: i'll receive the SOCKET handle as parameter
(even tried taking the SOCKET handle as a member variable, using a member function to set the m_hSocket)
CClientSocket *pSocketForClient = new CClientSocket;
SOCKET hSocket = (SOCKET)Param;
pSocketForClient->Attatch(hSocket); // Problem is here
The problem is while trying to attatch its trowing some exception. I tried using ::GetLastError() to find
the error code, but its returning ZERO.
Even i tried to catch exception but, i'm unable to catch using catch(CException e).
i modified the code as
try {
pSocketForClient->Attatch(hSocket);
}
catch(CException e)
{ // some code to find exception
}
but its not catching the exception. i'm able to catch the exception by catch(...)
but as u know, it is of no use to find the error
Client code:
CSocket Socket;
Socket.Create();
Socket.Connect(ip, port);
PLAESE HELP ME
ramana.
|
|
|
|
|
I would suggest you to check if the SOCKET handle, obtained by Accept and then passed to your thread, is valid, i.e. is not "-1". Then put a breakpoint at Attach line and then continue execution using Step Into (F11). You should see the MFC source code and found the cause of the exception.
In order to catch the exception, try a different declaration:
try
{
. . .
}
catch( const CException * e)
{
. . .
}
catch( const CException & e)
{
. . .
}
I hope this helps.
|
|
|
|
|
Is this in an MFC app (yes, I know you're using an MFC class CSocket)? Is it a console/service
application or a GUI application?
|
|
|
|
|
its a GUI based application
|
|
|
|
|
I would start by stepping into your CClientSocket::Attatch() function in the debugger
and you'll see what line the exception occurs on. Put a breakpoint on this line
pSocketForClient->Attatch(hSocket); // Problem is here
and use F11 key to step into the Attatch() function. There' s probably a pointer issue of
some kind. If you post the code for Attatch() maybe I can help a little
Mark
|
|
|
|
|
Hi Mark
I dint override the Attatch() member function of CAsyncSocket class.
I stepped in to the framework code of MFC.
i'm giving the details, where it is going wrong.
File : MAP_PP.CPP
Function : void* CMapPtrToPtr::GetValueAt(void* key) const
Line: 179
Code: if (m_pHashTable == NULL)
return NULL;
because of the abov code, some runtime error is occuring.
Pls suggest me, where it may go wrong?
ramana.
|
|
|
|
|