Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Strange memory access error after calling dll

Reply
Thread Tools

Strange memory access error after calling dll

 
 
Mongoose7
Guest
Posts: n/a
 
      03-08-2006
Hi,

I am using vc7 to call a dll function from another dll. The function
seems to execute correctly (it writes binary data to the registry) but
when it comes out of the function, and tries to execute a standard
windows debug trace (or any other line of code for that matter, I tried
replacing the debug line with) it crashes giving a first chance
exception, and then a access violation. I have a feeling that this has
something to do with the target dll being called, though I am not sure
what.

Below is the debug disassembly.

if (_ProfileRegistryWriteBinary( HKEY_CURRENT_USER, szSubKey,
sKey, pDataOut.cbData, pDataOut.pbData )) // Local stub to the dll
method.
0475132D mov eax,dword ptr [ebp-18h]
04751330 push eax
04751331 mov ecx,dword ptr [pDataOut]
04751334 push ecx
04751335 mov edx,dword ptr [sKey]
04751338 push edx
04751339 mov eax,dword ptr [szSubKey]
0475133C push eax
0475133D push 80000001h
04751342 call _ProfileRegistryWriteBinary (47515D0h)
04751347 add esp,14h
0475134A movzx ecx,al
0475134D test ecx,ecx
0475134F je _StorePrivateData+118h (4751378h)
{
debug ("Private data has been written successfully ");
04751351 push ecx
04751352 mov ecx,esp

/************************************************** ***************
04751354 mov dword ptr [ebp-118h],esp <- Crashes on this line
************************************************** ***************/

0475135A push offset string "Private data has been written
su"... (4815D04h)
0475135F call
ATL::CStringT<char,StrTraitMFC<char,ATL::ChTraitsC RT<char> >
>::CStringT<char,StrTraitMFC<char,ATL::ChTraitsCRT <char> > > (4751710h)

04751364 mov dword ptr [ebp-144h],eax
0475136A call debug (4751450h)
0475136F add esp,4
bRetval = true;
04751372 mov byte ptr [bRetval],1
}

Thanks a Lot!

Mongoose7

 
Reply With Quote
 
 
 
 
Ben Pope
Guest
Posts: n/a
 
      03-08-2006
Mongoose7 wrote:
> Hi,
>
> I am using vc7 to call a dll function from another dll. The function
> seems to execute correctly (it writes binary data to the registry) but
> when it comes out of the function, and tries to execute a standard
> windows debug trace (or any other line of code for that matter, I tried
> replacing the debug line with) it crashes giving a first chance
> exception, and then a access violation. I have a feeling that this has
> something to do with the target dll being called, though I am not sure
> what.
>
> Below is the debug disassembly.
>
> if (_ProfileRegistryWriteBinary( HKEY_CURRENT_USER, szSubKey,
> sKey, pDataOut.cbData, pDataOut.pbData )) // Local stub to the dll
> method.
> 0475132D mov eax,dword ptr [ebp-18h]
> 04751330 push eax
> 04751331 mov ecx,dword ptr [pDataOut]
> 04751334 push ecx
> 04751335 mov edx,dword ptr [sKey]
> 04751338 push edx
> 04751339 mov eax,dword ptr [szSubKey]
> 0475133C push eax
> 0475133D push 80000001h
> 04751342 call _ProfileRegistryWriteBinary (47515D0h)
> 04751347 add esp,14h
> 0475134A movzx ecx,al
> 0475134D test ecx,ecx
> 0475134F je _StorePrivateData+118h (4751378h)
> {
> debug ("Private data has been written successfully ");
> 04751351 push ecx
> 04751352 mov ecx,esp
>
> /************************************************** ***************
> 04751354 mov dword ptr [ebp-118h],esp <- Crashes on this line
> ************************************************** ***************/
>
> 0475135A push offset string "Private data has been written
> su"... (4815D04h)
> 0475135F call
> ATL::CStringT<char,StrTraitMFC<char,ATL::ChTraitsC RT<char> >
>> ::CStringT<char,StrTraitMFC<char,ATL::ChTraitsCRT< char> > > (4751710h)

> 04751364 mov dword ptr [ebp-144h],eax
> 0475136A call debug (4751450h)
> 0475136F add esp,4
> bRetval = true;
> 04751372 mov byte ptr [bRetval],1
> }
>
> Thanks a Lot!
>
> Mongoose7


Could be anything, but I suspect one of your char* are invalid, probably
not pointing to an array of char long enough to hold the result, or not
pointing to anything at all.

In case you hadn't noticed, this is a C++ language group, not a VC7,
Windows, or assembler group. As such 99% of your post is off topic.

Try posting your C++ code to a relevant newsgroup, probably something in
the microsoft.public. hierarchy.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
 
Reply With Quote
 
 
 
 
Kaz Kylheku
Guest
Posts: n/a
 
      03-08-2006
Mongoose7 wrote:
> Hi,
>
> I am using vc7 to call a dll function from another dll.


Off topic. This has nothing to do with C++, but with Windows
architectural issues.

> The function
> seems to execute correctly (it writes binary data to the registry) but
> when it comes out of the function, and tries to execute a standard
> windows debug trace (or any other line of code for that matter, I tried
> replacing the debug line with) it crashes giving a first chance
> exception, and then a access violation.


Perhaps the calling conventions are wrong.

> /************************************************** ***************
> 04751354 mov dword ptr [ebp-118h],esp <- Crashes on this line
> ************************************************** ***************/


Perhaps the function clobbered the EBP register (frame pointer) but did
not restore it.

Maybe that could happen in code that is compiled to not use frame
pointers for stack frame linkage, freeing that register for general
use. .

Or an EBP value was restored, but from corrupt memory.

Anyway, the newsgroup you want is

microsoft.public.win32.programmer

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
API returns memory related error when calling inside a DLL Pradeep C++ 2 07-23-2008 03:36 PM
How to determine if a DLL is a COM DLL or .NET DLL Anushi ASP .Net 5 10-28-2004 01:59 PM
Why does Ruby use both tcl83.dll and tk83.dll (instead of just tk83.dll)? H. Simpson Ruby 4 08-03-2004 04:45 PM
mprapi.dll --> samlib.dll --> ntdll.dll issue. Some1 Computer Support 4 04-05-2004 02:02 AM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments