473,327 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Strange memory access error after calling dll

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

Mar 8 '06 #1
2 2283
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...
Mar 8 '06 #2
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

Mar 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Justin Lazanowski | last post by:
Cross posting this question on the recommendation of an I have a .NET application that I am developing in C# I am loading information in from a dataset, and then pushing the dataset to a grid,...
30
by: jimjim | last post by:
Hello, This is a simple question for you all, I guess . int main(){ double *g= new double; *g = 9; delete g; cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl; *g =...
10
by: eyh5 | last post by:
Hi, My C code (running on Soalris Unix) has some "segmentation fault" that I wish to use purify to do it. I poked around the web, and found some information about adding some lines in a Makefile...
6
by: Rob C | last post by:
We have a C# app that runs on the PocketPC. We are having some odd behavior reported from our users that I have been unable to recreate. It made me start to look at memory issues. One of the...
2
by: Torben Laursen | last post by:
Hi I have a dll written in C++ builder that I have been using for several years by calling it using VBA or C++ from VS. But I cannot use it from a C# program. When I try to use a function...
3
by: william | last post by:
My situation is here: an array of two dimension can only be defined locally within a function(because the caller don't know the exact size ). Then the question is: how should the caller access...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
5
by: Jeff | last post by:
Okay, I'm still new to vb.net 2005 - throught this was a hardware problem, but now I don't know. (I'm having some problem with my newgroup provider, so hopefully this will go through) This...
5
by: Mahendra Kumar Kutare | last post by:
I am trying to implement a webserver with boss-worker model thread pool implementation - I have a header declaration threadpool.h as - typedef struct threadpool_work { void (*routine) ();...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.