|
Disabling the optimizations did the trick, the other two were already selected.
Now I have some API's failing that were not doing so in the debug build :/
|
|
|
|
|
WalderMort wrote: Now I have some API's failing
Windows API's?
|
|
|
|
|
It's all ok, I was getting my peb's and teb's mixed up, any easy thing to do. I wonder why it didn't throw a runtime error in debug mode?
BTW. I think I have finaly solved this whole running an exe from a resource
|
|
|
|
|
WalderMort wrote: BTW. I think I have finaly solved this whole running an exe from a resource
Congratulation! so we can expect your article soon..
|
|
|
|
|
If and when I manage to get it done, I will create an article on how to create a process from an exe in the resource. But, like I said before, I am worried about this being missused. So I will not detail how to run the resource from within the same process ( which any virus killer would ignore ).
|
|
|
|
|
WalderMort wrote: which any virus killer would ignore
Thats not a problem. Send a mail to symantec giving a link to your article
|
|
|
|
|
...And a bill :p
It wouldn't do them much good though, using this method any number of encyption techniques could be used. And I won't even go into self modifying code.
|
|
|
|
|
WalderMort wrote: So I will not detail how to run the resource from within the same process ( which any virus killer would ignore ).
Now, as we have numerous articles about DLL injection here, you would not give away a real secret.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
I've run into this issue as well. I find it ludicrous that optimization that will break correct stepping through of a debug build is not disabled by default. All this does is confuse users that run into this problem for the first time.
|
|
|
|
|
Like I said, this is the first time I have performed this on VS2005, guess there will be more similar problems after I upgrade to VS2008
|
|
|
|
|
Hi,
in my VC++ 2005 application I am using FileSystemWatcher in order to look for a new file. This code works so far:
void OnCreated (Object* source, FileSystemEventArgs* e)<br />
{<br />
SendEventInfo(e->FullPath);<br />
}<br />
<br />
void CAxControlDlg::StartWaitforStatusFile(void)<br />
{<br />
FileSystemWatcher* pWatcher = new FileSystemWatcher(path);<br />
pWatcher->Filter = m_statusfile_name;<br />
<br />
FileWatcherEvents* fileEvents = new FileWatcherEvents(pWatcher, GetSafeHwnd(), WM_FILE_CREATED);<br />
pWatcher->Created += new FileSystemEventHandler(fileEvents, &FileWatcherEvents::OnCreated); <br />
}
The open question is how to stop the FileSystemWatcher. If a file has been created and processed a new FileSystemWatcher should be started again. But then the task is running twice, i.e. the file is found two times etc..
I would like to stop pWatcher, but as this is defined in a function I can't stop it in another function. The solution would be to declare pWatcher as a member variable. But if I add
FileSystemWatcher* pWatcher;
to the header file
I get error C3265 (cannot declare a managed 'managed construct' in an unmanaged 'unmanaged construct').
Any ideas how to solve that? The code is compiled with the "/clr:oldSyntax" option.
Thanks in advance for your help.
|
|
|
|
|
The FileSystemWatcher class is for managed code, ie .NET
There is an article demonstrating a similar C++ class here on CP, I can't remember where exactly though.
|
|
|
|
|
Thanks. I know it uses the .net library. The problem comes indeed form mixing managed and unmanaged.
As mentioned it works already, apart that I cannot stop it.
-- modified at 7:25 Thursday 30th August, 2007
|
|
|
|
|
The following code fails and return "0x80004002" error Invalid Syntax.
Can any one provide me direction to solve this problem.
Is there any sample VC++ to get list domain in Primary Domain Controller, and to list the users in one domain
WCHAR szTest [100];
swprintf(szTest,L"%s","WinNT://development/ilanthendralr,user");
HRESULT hr = CoInitialize(NULL);
IADsUser *pUser;
hr = ADsGetObject(szTest,IID_IADsUser,(void**)&pUser);
if (FAILED(hr))
{return ;}
BSTR bstr;
hr = pUser->get_FullName(&bstr);
printf("User: %S\n", bstr);
SysFreeString(bstr);
CoUninitialize();
for thendral
|
|
|
|
|
I'm trying to port a project (workspace / solution) from VC6 to .NET 2002.
The workspace consists of a DLL front-end, a DLL back-end, and a static library of utilities. They depend on each other in the order listed.
In Release and Debug under VC6, they compile (rebuild all) with no problems whatsoever.
When I import the projects into a new workspace in VS7 and rebuild all, I get a big wodge of linker errors like this:
yyy error LNK2005: "public: __thiscall CPoint::CPoint(int,int)" (??0CPoint@@QAE@HH@Z) already defined in xxx.lib(xxx.obj)
where xxx is the static library back-end.
I used Project Dependencies to instruct VS7 as to which project depended on which; if I do not, I get linker errors regarding classes in the static lib needed by the middle layer (I haven't even got to the front end).
Both static lib and DLL are multi-threaded.
Curiously, it's MFC simple classes like CRect, CSize, CPoint and their member functions that are involved; none of our classes or methods.
Any ideas on how to resolve this, and why it changed between Visual Studio versions?
|
|
|
|
|
You have "DLL Hell": different versions of MFC.
There is not way out: You got to recompile the static lib!!!
Greetings from Germany
|
|
|
|
|
Unfortunately this is not the problem - it was from a full recompile. The lowest project compiles fine; when I try and compile the layer above, which depends on it, it then throws out the multiply defined symbols. I already compiled the static lib again {:v(
|
|
|
|
|
Static linking of the MFC is the bug. You cant do that. Blame MS for it!!!
Greetings from Germany
|
|
|
|
|
Hi,
I have written some program in VS6.0, to parse an XML file,
CoInitialize(NULL);
CComPtr<ixmldomdocument> spXMLDOM;
CComPtr<ixmldomnode> spXMLNode;
IXMLDOMAttribute *pIXMLDOMAttribute = NULL;
IXMLDOMElement *pIXMLDOMElement = NULL;
HRESULT hr = spXMLDOM.CoCreateInstance(__uuidof(DOMDocument));
VARIANT_BOOL bSuccess = false;
USES_CONVERSION;
_variant_t fileNameValue=T2W(RegFile);
FILE *fp=fopen(RegFile,"r");
if(fp && !(spXMLDOM->load(fileNameValue,&bSuccess)))
{
hr = spXMLDOM->get_documentElement(&pIXMLDOMElement); _variant_t nameValue;
if(!hr && !(pIXMLDOMElement->getAttribute(CComBSTR(L"source- name"),&nameValue)))
{
if ( nameValue.vt == VT_BSTR )
{
USES_CONVERSION;
sourceName = W2T(nameValue.bstrVal);
}
}
spXMLDOM.Release();
// Stop COM
CoUninitialize();
For this i have installed Microsoft SDK, and i am setting the path of this in Tools->Options->Directories...
It builds correctly from the workspace, but if i try to build from make file using "NMAKE /f "Test.mak" CFG="Test - Win32 Release",
It gives many errors,
some are::
cl.exe @C:\DOCUME~1\chikkall\LOCALS~1\Temp\nma03112.
DCRegistry.cpp
DCRegistry.cpp(386) : error C2065: 'IXMLDOMDocument' : undeclared identifier
DCRegistry.cpp(386) : error C2955: 'CComPtr' : use of class template requires template argu
ment list
C:\PROGRA~1\MICROS~3\VC98\ATL\INCLUDE\atlbase.h(563) : see declaration of 'CComPtr'
DCRegistry.cpp(386) : error C2133: 'spXMLDOM' : unknown size
DCRegistry.cpp(386) : error C2512: 'CComPtr' : no appropriate default constructor available
DCRegistry.cpp(386) : error C2262: 'spXMLDOM' : cannot be destroyed
DCRegistry.cpp(387) : error C2065: 'IXMLDOMNode' : undeclared identifier
DCRegistry.cpp(387) : error C2955: 'CComPtr' : use of class template requires template argu
These errors indicate me that Microsoft SDK directory is not getting linked for building, how to make SDK directory available for build in mak file ????
|
|
|
|
|
One way of doing this is to move the location where you tell the Workspace about the Include directory from Tools->Options->Directories to Project Settings C/C++(tab) Category:Preprocessor Additional include Directories (dont forget to also add the library path to Project Settings Link(tab) Category:Input Additional Library Path) and then save the workspace and Export Makefile. This will add the neccessary directory paths to the .MAK file.
The other way is to change the environment variables INCLUDE and LIB that VCVARS32.BAT sets up.
|
|
|
|
|
SUPERB!!!!!
EXCELLENT answer,.............i followed your method 1, it works i am able to build thro make file...
THANKS A LOOOOOOOOOTTTT!!!!!!!!!!!
|
|
|
|
|
Hi all!
I wrote something like 3D Engine with Delphi, but I had to use a C++ DLL for loading GLSL shaders, because it seemed impossible to write it on delphi (problem with text files and PCHAR-s)
so, now my DLL or app doesn't crash, but shaders work incorrectly.
Do anyone know what can be the reason?
Here's my DLL (MS Vcpp 6.0)
#include "stdafx.h"<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <windows.h><br />
#include <string.h><br />
#include <iostream.h><br />
<br />
#include <glew\glew.h><br />
<br />
BOOL APIENTRY DllMain( HANDLE hModule, <br />
DWORD ul_reason_for_call, <br />
LPVOID lpReserved<br />
)<br />
{<br />
return TRUE;<br />
}<br />
<br />
struct TshaderDescribtor<br />
{<br />
int Shader_prog; <br />
int Shader_vert;<br />
int Shader_frag;<br />
char *info;<br />
};<br />
<br />
bool glewinited=false;<br />
<br />
char *textFileRead(char *fn) {<br />
<br />
FILE *fp;<br />
char *content = NULL;<br />
<br />
int count=0;<br />
<br />
if (fn != NULL) {<br />
fp = fopen(fn,"rt");<br />
<br />
if (fp != NULL) {<br />
<br />
fseek(fp, 0, SEEK_END);<br />
count = ftell(fp);<br />
rewind(fp);<br />
<br />
if (count > 0) {<br />
content = (char *)malloc(sizeof(char) * (count+1));<br />
count = fread(content,sizeof(char),count,fp);<br />
content[count] = '\0';<br />
}<br />
fclose(fp);<br />
}<br />
}<br />
return content;<br />
}<br />
<br />
extern "C"<br />
{<br />
void __declspec(dllexport) __cdecl writeln(char *text,bool endline)<br />
{<br />
if (endline)<br />
cout << endl;<br />
printf(text);<br />
}<br />
<br />
void __declspec(dllexport) __cdecl InitGlew()<br />
{<br />
glewInit();<br />
glewinited=true;<br />
}<br />
<br />
<br />
void __declspec(dllexport) __cdecl LoadTextFile(char *fn, char *content) {<br />
content = textFileRead(fn); <br />
}<br />
<br />
TshaderDescribtor _declspec(dllexport) __cdecl glocLoadShaders(char *vertfile,char *fragfile,int testsize,bool useprog)<br />
{<br />
TshaderDescribtor tmpshader; <br />
if (glewinited)<br />
{<br />
tmpshader.Shader_vert = glCreateShader(GL_VERTEX_SHADER);<br />
tmpshader.Shader_frag = glCreateShader(GL_FRAGMENT_SHADER);<br />
<br />
BOOL fileloaded = true;<br />
<br />
char * vs;<br />
char * fs;<br />
<br />
vs = textFileRead(vertfile);<br />
fs = textFileRead(fragfile);<br />
<br />
writeln("vertex shader filename:",true);<br />
writeln(vertfile,true);<br />
writeln("vertex shader source:",true);<br />
writeln(vs,true);<br />
<br />
writeln("fragment shader filename:",true);<br />
writeln(fragfile,true);<br />
writeln("fragment shader source:",true);<br />
writeln(fs,true); <br />
<br />
const char * vv = vs;<br />
const char * ff = fs;<br />
<br />
glShaderSource(tmpshader.Shader_vert, 1, &vv,NULL);<br />
glShaderSource(tmpshader.Shader_frag, 1, &ff,NULL);<br />
<br />
free(vs);free(fs);<br />
<br />
glCompileShader(tmpshader.Shader_vert);<br />
glCompileShader(tmpshader.Shader_frag);<br />
<br />
tmpshader.Shader_prog = glCreateProgram();<br />
<br />
glAttachShader(tmpshader.Shader_prog,tmpshader.Shader_vert);<br />
glAttachShader(tmpshader.Shader_prog,tmpshader.Shader_frag);<br />
<br />
glLinkProgram(tmpshader.Shader_prog);<br />
if (useprog)<br />
glUseProgram(tmpshader.Shader_prog);<br />
tmpshader.info="AEEEEE! :D";<br />
} <br />
else<br />
writeln("GLEW is not initialized! (did you forget to call 'InitGlew?')",true);<br />
return tmpshader;<br />
}<br />
}<br />
<br />
and I use it so:
<br />
procedure setshaderparameters(progobj:integer);<br />
begin<br />
glActiveTexture(GL_TEXTURE0);<br />
glBindTexture(GL_TEXTURE_2D, texture[8]);<br />
tex1_loc := glGetUniformLocation(s_prog, 'TextureUnit0');<br />
glUniform1i(tex1_loc, 0);<br />
<br />
glActiveTexture(GL_TEXTURE1);<br />
glBindTexture(GL_TEXTURE_2D, texture[9]);<br />
tex2_loc := glGetUniformLocation(s_prog, 'TextureUnit1');<br />
glUniform1i(tex2_loc, 1);<br />
<br />
efcoe_loc := glGetUniformLocation(progobj,'efcoe');<br />
<br />
time_loc := glGetUniformLocation(progobj,'TIME_FROM_INIT'); <br />
glUniform1iARB(tex1_loc,texture[8]);<br />
glUniform1iARB(tex2_loc, texture[9]);<br />
<br />
<br />
end;<br />
<br />
procedure LoadShaders()<br />
begin<br />
tmpshad:=glocLoadShaders(pchar(cur_dir+'\shaders\toon_vert.txt'),pchar(cur_dir+'\shaders\toon_frag.txt'),1,false);<br />
end;<br />
Thanks "by force"
|
|
|
|
|
In my app, I need better data type for data with both integer and factional part - in general, we use double for it - but double is not good enough for my app.
For example, an data is changed by C++ automatically if it is over 2^32 with or without fractional part.
in <float.h>, I see data type "long double".
but the "long double" is not working - sizeof(long double) is 8, siame as sizeof(double).
any suggestion for a better data type to replace "double" in my app?
|
|
|
|
|
you'll have to either write your own type, or find and use a Mathematics Library which provides a larger floating point type...
|
|
|
|
|
includeh10 wrote: In my app, I need better data type for data with both integer and factional part
If you can get away with a fixed number of decimal digits, you could use a scaled 64Bit integer.
E.G. If you have money, you convert any numbers in from dollars to cent (multiply be 100), and store this number as an integer.
TO display, you divide by 100.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|