PC Review


Reply
Thread Tools Rate Thread

Deadlock in CloseEncryptedFileRaw()

 
 
toalexjin@gmail.com
Guest
Posts: n/a
 
      2nd Aug 2006
I'm trying to write a simple code to export raw data of an encrypted
file with OpenEncryptedFileRaw(), ReadEncryptedFileRaw() and
CloseEncryptedFileRaw(). If not all raw data of the encrypted file were
exported, calling CloseEncryptedFileRaw() will enter deadlock in
Windows 2000 or Windows 2003. But in Windows XP, the program will work
well.

Here is my sample code:
// efs1.c
#include <windows.h>
#include <tchar.h>

static int st_error_code = 0;
static int st_times = 0;

void help( const TCHAR* exe )
{
_tprintf( _T("Usage: %s efs_file error_code read_times\n"), exe );
}

DWORD WINAPI export_callback(
PBYTE pbData,
PVOID pvCallbackContext,
ULONG ulLength
)
{
int count = ++ *((int*)pvCallbackContext);
_tprintf( _T("export_callback (%d): length:%u.\n"), count, ulLength
);

if ( count >= st_times )
{
return st_error_code;
}
else
{
return 0;
}
}


int _tmain( int argc, TCHAR* argv[] )
{
void* fp = 0;
DWORD result;
int count = 0;

if ( argc != 4
|| ( st_error_code = _ttoi( argv[2] ) ) == 0
|| ( st_times = _ttoi( argv[3] ) ) <= 0 )
{
help( argv[0] );
return -1;
}

result = OpenEncryptedFileRaw( argv[1], 0, &fp );
if ( result != ERROR_SUCCESS )
{
_tprintf( _T("OpenEncryptedFileRaw failed:%u.\n"), result );
return -1;
}
else
{
_tprintf( _T("OpenEncryptedFileRaw ok.\n") );
}

result = ReadEncryptedFileRaw( &export_callback, &count, fp );
if ( result != ERROR_SUCCESS )
{
_tprintf( _T("ReadEncryptedFileRaw failed:%u.\n"), result );
}
else
{
_tprintf( _T("ReadEncryptedFileRaw ok.\n") );
}

CloseEncryptedFileRaw( fp );
fp = 0;

_tprintf( _T("CloseEncryptedFileRaw ok.\n") );

return 0;
}

The command line is "efs1.exe c:\my_encrypted_big_file 1 2", let the
program read only two blocks of raw data and exit, but the program
hangs at line CloseEncryptedFileRaw( fp );

I want to know if anyone can help me, thanks!!

Alex Jin.

 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      6th Aug 2006
Wrong group - try a C++ newsgroup.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to write a simple code to export raw data of an encrypted
> file with OpenEncryptedFileRaw(), ReadEncryptedFileRaw() and
> CloseEncryptedFileRaw(). If not all raw data of the encrypted file were
> exported, calling CloseEncryptedFileRaw() will enter deadlock in
> Windows 2000 or Windows 2003. But in Windows XP, the program will work
> well.
>
> Here is my sample code:
> // efs1.c
> #include <windows.h>
> #include <tchar.h>
>
> static int st_error_code = 0;
> static int st_times = 0;
>
> void help( const TCHAR* exe )
> {
> _tprintf( _T("Usage: %s efs_file error_code read_times\n"), exe );
> }
>
> DWORD WINAPI export_callback(
> PBYTE pbData,
> PVOID pvCallbackContext,
> ULONG ulLength
> )
> {
> int count = ++ *((int*)pvCallbackContext);
> _tprintf( _T("export_callback (%d): length:%u.\n"), count, ulLength
> );
>
> if ( count >= st_times )
> {
> return st_error_code;
> }
> else
> {
> return 0;
> }
> }
>
>
> int _tmain( int argc, TCHAR* argv[] )
> {
> void* fp = 0;
> DWORD result;
> int count = 0;
>
> if ( argc != 4
> || ( st_error_code = _ttoi( argv[2] ) ) == 0
> || ( st_times = _ttoi( argv[3] ) ) <= 0 )
> {
> help( argv[0] );
> return -1;
> }
>
> result = OpenEncryptedFileRaw( argv[1], 0, &fp );
> if ( result != ERROR_SUCCESS )
> {
> _tprintf( _T("OpenEncryptedFileRaw failed:%u.\n"), result );
> return -1;
> }
> else
> {
> _tprintf( _T("OpenEncryptedFileRaw ok.\n") );
> }
>
> result = ReadEncryptedFileRaw( &export_callback, &count, fp );
> if ( result != ERROR_SUCCESS )
> {
> _tprintf( _T("ReadEncryptedFileRaw failed:%u.\n"), result );
> }
> else
> {
> _tprintf( _T("ReadEncryptedFileRaw ok.\n") );
> }
>
> CloseEncryptedFileRaw( fp );
> fp = 0;
>
> _tprintf( _T("CloseEncryptedFileRaw ok.\n") );
>
> return 0;
> }
>
> The command line is "efs1.exe c:\my_encrypted_big_file 1 2", let the
> program read only two blocks of raw data and exit, but the program
> hangs at line CloseEncryptedFileRaw( fp );
>
> I want to know if anyone can help me, thanks!!
>
> Alex Jin.
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
deadlock Tony Johansson Microsoft C# .NET 2 11th May 2010 10:46 AM
NT Loader Deadlock Marko Becirevic Microsoft C# .NET 4 6th Jul 2005 03:51 PM
Deadlock? =?Utf-8?B?TmlsbGU=?= Microsoft Dot NET Compact Framework 3 22nd Nov 2004 12:17 PM
ASP.NET deadlock Kevin Jackson Microsoft ASP .NET 1 5th Feb 2004 03:59 AM
Possible deadlock condition Marc Rosenthal Microsoft Windows 2000 Networking 1 3rd Jul 2003 07:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:32 PM.