Skip to main content
gamedev.net
🔒 Locked

[Solved] Runtime error

Started by Wardyahh 8 replies 700+ views
Original Post
Wardyahh
Wardyahh
i am so very aggravated at this error i can't even figure out what the problem is let alone begin to fix it i am using d3d to create a texture from file like so:


if (FAILED(D3DXCreateTextureFromFileEx(*m_dev,
                                        fileName, 
					0, 
					0, 
					1, 
					0,
					D3DFMT_A8R8G8B8, 
					D3DPOOL_MANAGED, 
					D3DX_FILTER_NONE, 
					D3DX_DEFAULT,
					m_Temp->ColourKey, 
					&m_Temp->SrcInfo, 
					NULL, 
					&m_Temp->Pointer))){
    return NULL;
  }



the variable in the call are as follows

LPDIRECT3DDEVICE9 *m_dev



m_Temp is an instance of the following struct

struct MAN_TEXTURE{
	IDirect3DTexture9* Pointer;				
	int RefNo;							
	D3DXIMAGE_INFO SrcInfo;					
	DWORD ColourKey;	
};



i keep getting a runtime error (more specifically an access violation) at the call to D3DXCreateTextureFromFileEx and its driving me nuts trying to figure out what i have broken it was working previously but i have done something unknown to break it and would appreciate some help in at least figuring out what the problem is Many Thanks Edit: fixed typo in code [Edited by - Wardyahh on June 17, 2007 7:51:18 PM]
--------------------------------------EvilMonkeySoft Blog
LessBread
LessBread
In the call

D3DXCreateTextureFromFileEx(*m_dev, fileName, 0, ...)

are you sure that first argument pointer should be dereferenced?
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Omega147
Omega147
What's the runtime error? I would guess that you've got a null pointer access violation. Can't tell much more without a bit of extra information regarding the error, though.
Wardyahh
Wardyahh
yeah

m_dev's type is:
LPDIRECT3DDEVICE9 *m_dev


and the function requires a LPDIRECT3DDEVICE9 as its first parameter so the dereferenced m_dev is actually of the correct type

(i know this because it throws a compiler error stating this if i dont dereference m_dev )
--------------------------------------EvilMonkeySoft Blog
Wardyahh
Wardyahh
the specific error is

First-chance exception at 0x00d66a33 in gt.exe: 0xC0000005: Access violation writing location 0x70feeffe.
Unhandled exception at 0x00d66a33 in gt.exe: 0xC0000005: Access violation writing location 0x70feeffe.

now having looked this us with the wonders of google apparently a lot of these problems are indeed cause by either null or uninitiated pointers

to the best of my knowledge the only pointer that needs to be initialised in this call is m_dev (the d3d device)

i'm not sure if i need to initialise the pointer to a texture contained within MAN_TEXTURE


Edit: looking at the memory addresses of my pointers i notice that m_dev(once dereferenced) is pointing to 0x00d66a28 not sure if it is significant or not :)
--------------------------------------EvilMonkeySoft Blog
Omega147
Omega147
Quote:
Original post by Wardyahh
the specific error is

First-chance exception at 0x00d66a33 in gt.exe: 0xC0000005: Access violation writing location 0x70feeffe.
Unhandled exception at 0x00d66a33 in gt.exe: 0xC0000005: Access violation writing location 0x70feeffe.

now having looked this us with the wonders of google apparently a lot of these problems are indeed cause by either null or uninitiated pointers

Knowing that, set up a few if checks just before the call to create the texture, checking if either m_dev, fileName, m_Temp, m_Temp->ColourKey, m_temp->SrcInfo, or m_temp->Pointer are null (assuming they're all pointers, that is; if any of them aren't pointers, make certain that they have the values you expect them to have). Once you discover which of those is not behaving properly, you should be able to trace it back to find out what wasn't getting initialized correctly.
Driv3MeFar
Driv3MeFar
Quote:
Original post by Omega147
Quote:
Original post by Wardyahh
the specific error is

First-chance exception at 0x00d66a33 in gt.exe: 0xC0000005: Access violation writing location 0x70feeffe.
Unhandled exception at 0x00d66a33 in gt.exe: 0xC0000005: Access violation writing location 0x70feeffe.

now having looked this us with the wonders of google apparently a lot of these problems are indeed cause by either null or uninitiated pointers

Knowing that, set up a few if checks just before the call to create the texture, checking if either m_dev, fileName, m_Temp, m_Temp->ColourKey, m_temp->SrcInfo, or m_temp->Pointer are null (assuming they're all pointers, that is; if any of them aren't pointers, make certain that they have the values you expect them to have). Once you discover which of those is not behaving properly, you should be able to trace it back to find out what wasn't getting initialized correctly.


They wouldn't be NULL, if that were the case you would get an access violation writing to 0x00000000. The address you're writing to (0x70feeffe) looks to me like an address that has already been deleted (hence the feeffe code).

OP: Step through your code in the debugger, see which pointer points to that address, and see why it is set as such.
LessBread
LessBread
Quote:
Original post by Wardyahh
yeah

m_dev's type is:
*** Source Snippet Removed ***

and the function requires a LPDIRECT3DDEVICE9 as its first parameter so the dereferenced m_dev is actually of the correct type

(i know this because it throws a compiler error stating this if i dont dereference m_dev )


Is there some other reason why you're using a pointer pointer there?

Why not simply

LPDIRECT3DDEVICE9 m_dev

???
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Wardyahh
Wardyahh
originally it was because the device was initialised in a seperate class and i was referencing the original device but i now realise that the typecast is of a pointer anyway so i dont need it

i will change it but i know that isnt the problem :)

i have been through most of my valuse and have yet to find the pointer to the memory address its referencing although the pointer to the device is always very close to it

thanks for the help so far btw
--------------------------------------EvilMonkeySoft Blog
Wardyahh
Wardyahh
ok i fixed it ...only took 4 hours


i changed the m_dev to a regular LPDIRECT3DDEVICE9 instead of a pointer to one
(although i doubt this fixed the problem as i had tried this previously)
((but...saying that it did work right ater i changed this and the references))

i also completely removed the m_temp variable and instead had the function return directly to a vector of MAN_TEXTURE's(which is where they were going anyway)
by way of &m_Tex[position].Pointer etc.

Thanks for all of your help guys

--------------------------------------EvilMonkeySoft Blog

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.