473,781 Members | 2,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 (_ProfileRegist ryWriteBinary( HKEY_CURRENT_US ER, 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 _ProfileRegistr yWriteBinary (47515D0h)
04751347 add esp,14h
0475134A movzx ecx,al
0475134D test ecx,ecx
0475134F je _StorePrivateDa ta+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<c har,StrTraitMFC <char,ATL::ChTr aitsCRT<char> >
::CStringT<cha r,StrTraitMFC<c har,ATL::ChTrai tsCRT<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 2317
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 (_ProfileRegist ryWriteBinary( HKEY_CURRENT_US ER, 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 _ProfileRegistr yWriteBinary (47515D0h)
04751347 add esp,14h
0475134A movzx ecx,al
0475134D test ecx,ecx
0475134F je _StorePrivateDa ta+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<c har,StrTraitMFC <char,ATL::ChTr aitsCRT<char> >
::CStringT<char ,StrTraitMFC<ch ar,ATL::ChTrait sCRT<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.publi c. 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.publi c.win32.program mer

Mar 8 '06 #3

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

Similar topics

16
2891
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, or other controls depending on the particular form. This application is setup with one MDI parent calling MDI children with the exception of one Modal form (the report viewer). When I run the application and run one of the screens that pulls...
30
3751
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 = 111; cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl;
10
14057
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 file to use purify. However, my code is a rather simple single-source C program, and I didn't write a Makefile for it. I'm wondering if anybody can tell me which commands are to be entered at the Unix prompt to use purify. And, I don't know if...
6
1386
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 appl errors that they get can only come up when a static member variable inside a class is set to NULL. The setting of that value is pretty controlled and I don't believe that the value is changing to NULL through normal logic flow. the class...
2
4115
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 inside it I get this strange exception: Unable to load DLL 'DB_Forms.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6)
3
1875
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 this array for future use? The code is: ********************** caller() {
9
2519
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 *after* calling increase_arrays(), I received segmentation fault. I tried to step it through gdb, and I found out that after calling increase_arrays(), words's original value is modified, and if I tried to access it, I get <address 0x11 out of...
5
3508
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 problem just started about a week ago, before all was fine. I'm using the code below to access a mysql database. On the line indicated when the connection is opened, the application has been sporatically drawing an error. It doesn't occur very often -...
5
2681
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) (); void *arg; struct threadpool_work *next; } threadpool_work_t;
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10143
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7486
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.