|
|
Thanks!
I am off to download it! will post the results here.
[editted]
It says Intel 64-bit, so I really doubt it to be AMD64 compatible but I might find something interesting inside.
[/editted]
[editted2]
As I thought it is IA64. In its Lib directory it has an AMD64 directory but there is only one 4KB file named authz.lib
[/editted2]
|
|
|
|
|
I have an SDI program, and I need to access the variables in CFormView from CMainFrame. I cant figure out how to do that.
I'm catching WM_CLOSE in CMainFrame, and whether or not the program will be
allowed to close will depend on a variable thats in CFormView. So, I need to
access this variable from CMainFrame. Any help?
Thanks,
Daniel
|
|
|
|
|
Actually, you can expose a get accessor to your property.
BOOL GetAllowClosing()
{
}
You can get at in CMainFrame by:
CFormView pForm = (CFormView)GetActiveView();
Then you just use the return the value of pForm->GetAllowClosing()
|
|
|
|
|
|
You may be reinventing the wheel.
CDocument has CanCloseFrame(), which currently checks the dirty bit of the document and then prompts if you want to save.
You can override this, and have the document ask the form if it's OK to close, and return false if not.
You then don't need to handle WM_CLOSE in CMainFrame, unless you need to for other reasons.
Steve S
|
|
|
|
|
Steve S is right, Daniel. It actually makes things easier than handling WM_CLOSE in the Main Frame, although that's perfectly OK as well...
Just inject the check on your CFormView derived View's CanCloseView() (or whatever you call it) into your override of CanCloseFrame() :
BOOL CMyDocument::CanCloseFrame(CFrameWnd* pFrame)
{
CMyFormView pView = (CMyFormView)pFrame->GetActiveView();
if (FALSE == pView->CanCloseView()) return FALSE;
return CDocument::CanCloseFrame(pFrame);
}
|
|
|
|
|
Don't know if this is right plac to post, but i have a question. I'm making a program that reads files with have hundreds of lines that begin with the same thing like ObjectTemplate.whatever (variable i need). My quesion is i've read these in as a CString line by line. How to i get rid of the ObjectTemplate part so it leaves the .whatever and i want to get rid of the part after the space which is the variable. So what i want to do is use the .whatever to tell the program what variable it is supposed to change. This is a noob question, and i've looked thorugh the strings section and could not find what i need.
|
|
|
|
|
Look up CString::Right(), CString::Left(), CString::Mid() in MSDN.
|
|
|
|
|
Along with the Right() Left() and Mid() functions, look at the Find() function. Find the . and take everything from the right of the .
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
I have a weird one, here. I have a class that uses a linked list of pointers to another class (ie. a mbr var that has a pointer to the next object). In my processing, I loop to create the necessary instances of the "outside" class. As part of the constructor of that object, the linked list is built by calling new inside of a loop. The first "outside" object is created flawlessly. When the second "outside" object is created, while the first mbr of the linked list is being created, HeapAlloc bombs out. Does anyone have any clues on what this could be? I tried wrapping the "obj = new objclass" in a try/catch(...), but nothing is caught.
I'm at my wit's end on this one.
|
|
|
|
|
Recursive memory alloc, perhaps? A TRACE() statement in a constructor or two might identify this if it's the problem.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
It took me going home last night and clearing my head. When I came in today, I started walking through all the memory allocation in that process. I found a copy/paste error that was corrupting the heap.
|
|
|
|
|
I have defined a managed C++ project to call into an unmanaged MFC project. The MFC project builds successfully. However, the build of the managed project fails because the linker cannot resolve the external symbols for the methods defined in the unmanaged class. Attached is the class definition for the managed class:
public __gc class MTracker
{
public:
MTracker(Control* pControl,Control* cControl)
{
m_CTracker = new CComTrackerApp();
IntPtr pPtr = pControl->Handle;
IntPtr cPtr = cControl->Handle;
HWND pHwnd = (HWND)pPtr.ToPointer();
HWND cHwnd = (HWND)cPtr.ToPointer();
m_CTracker->Create(pHwnd,cHwnd);
}
protected:
void Dispose(bool b)
{
MTracker::Dispose(b);
if (m_CTracker != NULL)
{
delete m_CTracker;
m_CTracker = NULL;
}
}
private:
CComTrackerApp* m_CTracker;
};
The CCOMTrackerAPP class is defined in the MFC project. The linker cannot resolve the addresses for CComTracker::CComTracker() or CComTracker::Create(HWND pHwnd,HWND cHwnd). Any suggestions would be appreciated.
|
|
|
|
|
Hello
I need integrate me own topics into MSDN (Document Explorer). Does anybody have any ideas about how this could be done&
|
|
|
|
|
|
whats the best way to create random numbers in C++ so that everytime u call it, it gives you a differnet number?
int code =0,i=0;
srand(time(NULL));
code = rand()%10; // I want the number to be between 1 and 10
cout<
|
|
|
|
|
Only seed the random number generator once. Then call rand() over and over.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
The problem is that you are calling seed() multiple times.
John
|
|
|
|
|
Hi everybody.
I don't understand these functions and MSDN doesn't help me.
¿When does the framework invoke them?. ¿Wich parameters does it pass in each invocation context?
¿What's the meaning of these parameters and it possible values?
Maybe that's too general for a good explanation, but if only i could get into some good article or tutorial...
Thanks ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Hey guys... It's me again.
I'm looking for the Windows SDK and DDK for AMD64 platform.
MSDN search didn't find anything although AMD already wrote an article about a beta version of them IN OCTOBER '03.
Any ideas?
Don't try it, just do it! ![Wink | ;-)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_wink.gif)
|
|
|
|
|
The only thing I have found on this subject is that compiler support for AMD64 is in VC8 beta.
[EDIT]
As many companies are writing drivers for AMD64 the DDK must have been released in some fassion...
[/EDIT]
John
|
|
|
|
|
|
OK, I'm tryin to make a cheat-program wich should be able to bypass an anti-cheatprogram. I have the source code but I dont know wich lines I can edit to make it able to bypass it and still work correctly...
This is the file which should be edited:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include "apihijack.h"
// This function must be __cdecl!!!
void __cdecl DelayLoadProfileDLL_UpdateCount( PVOID dummy );
PIMAGE_IMPORT_DESCRIPTOR g_pFirstImportDesc;
//===========================================================================
// Given an HMODULE, returns a pointer to the PE header
PIMAGE_NT_HEADERS PEHeaderFromHModule(HMODULE hModule)
{
PIMAGE_NT_HEADERS pNTHeader = 0;
if (hModule == NULL)
return pNTHeader;
__try
{
if (PIMAGE_DOS_HEADER(hModule)->e_magic != IMAGE_DOS_SIGNATURE)
__leave;
pNTHeader = PIMAGE_NT_HEADERS(PBYTE(hModule)
+ PIMAGE_DOS_HEADER(hModule)->e_lfanew);
if (pNTHeader->Signature != IMAGE_NT_SIGNATURE)
pNTHeader = 0;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
return pNTHeader;
}
//===========================================================================
// Builds stubs for and redirects the IAT for one DLL (pImportDesc)
bool RedirectIAT(SDLLHook* DLLHook, PIMAGE_IMPORT_DESCRIPTOR pImportDesc, PVOID pBaseLoadAddr)
{
PIMAGE_THUNK_DATA pIAT; // Ptr to import address table
PIMAGE_THUNK_DATA pINT; // Ptr to import names table
PIMAGE_THUNK_DATA pIteratingIAT;
// Figure out which OS platform we're on
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(&osvi);
// If no import names table, we can't redirect this, so bail
if (pImportDesc->OriginalFirstThunk == 0)
return false;
pIAT = MakePtr(PIMAGE_THUNK_DATA, pBaseLoadAddr, pImportDesc->FirstThunk);
pINT = MakePtr(PIMAGE_THUNK_DATA, pBaseLoadAddr, pImportDesc->OriginalFirstThunk);
// Count how many entries there are in this IAT. Array is 0 terminated
pIteratingIAT = pIAT;
unsigned cFuncs = 0;
while (pIteratingIAT->u1.Function)
{
cFuncs++;
pIteratingIAT++;
}
if (cFuncs == 0) // If no imported functions, we're done!
return false;
// These next few lines ensure that we'll be able to modify the IAT,
// which is often in a read-only section in the EXE.
DWORD flOldProtect, flNewProtect, flDontCare;
MEMORY_BASIC_INFORMATION mbi;
// Get the current protection attributes
VirtualQuery(pIAT, &mbi, sizeof(mbi));
// remove ReadOnly and ExecuteRead attributes, add on ReadWrite flag
flNewProtect = mbi.Protect;
flNewProtect &= ~(PAGE_READONLY | PAGE_EXECUTE_READ);
flNewProtect |= (PAGE_READWRITE);
if (!VirtualProtect(pIAT, (sizeof(PVOID) * cFuncs), flNewProtect, &flOldProtect))
{
return false;
}
// If the Default hook is enabled, build an array of redirection stubs in the processes memory.
DLPD_IAT_STUB * pStubs = 0;
// Scan through the IAT, completing the stubs and redirecting the IAT
// entries to point to the stubs
pIteratingIAT = pIAT;
while (pIteratingIAT->u1.Function)
{
void* HookFn = 0; // Set to either the SFunctionHook or pStubs.
if (!IMAGE_SNAP_BY_ORDINAL(pINT->u1.Ordinal)) // import by name
{
PIMAGE_IMPORT_BY_NAME pImportName = MakePtr(PIMAGE_IMPORT_BY_NAME, pBaseLoadAddr, pINT->u1.AddressOfData);
// Iterate through the hook functions, searching for this import.
SFunctionHook* FHook = DLLHook->Functions;
while (FHook->Name)
{
if (lstrcmpi(FHook->Name, (char*)pImportName->Name) == 0)
{
// Save the old function in the SFunctionHook structure and get the new one.
FHook->OrigFn = (void*)pIteratingIAT->u1.Function;
HookFn = FHook->HookFn;
break;
}
FHook++;
}
}
// Replace the IAT function pointer if we have a hook.
if (HookFn)
{
// Cheez-o hack to see if what we're importing is code or data.
// If it's code, we shouldn't be able to write to it
if (IsBadWritePtr((PVOID)pIteratingIAT->u1.Function, 1))
{
pIteratingIAT->u1.Function = (DWORD)HookFn;
}
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
// Special hack for Win9X, which builds stubs for imported
// functions in system DLLs (Loaded above 2GB). These stubs are
// writeable, so we have to explicitly check for this case
if (pIteratingIAT->u1.Function > (DWORD)0x80000000)
pIteratingIAT->u1.Function = (DWORD)HookFn;
}
}
if (DLLHook->UseDefault)
pStubs++; // Advance to next stub
pIteratingIAT++; // Advance to next IAT entry
pINT++; // Advance to next INT entry
}
// Put the page attributes back the way they were.
VirtualProtect(pIAT, (sizeof(PVOID) * cFuncs), flOldProtect, &flDontCare);
return true;
}
//===========================================================================
// Builds stubs for and redirects the IAT for one DLL (pImportDesc)
bool UnRedirectIAT(SDLLHook* DLLHook, PIMAGE_IMPORT_DESCRIPTOR pImportDesc, PVOID pBaseLoadAddr)
{
PIMAGE_THUNK_DATA pIAT; // Ptr to import address table
PIMAGE_THUNK_DATA pINT; // Ptr to import names table
PIMAGE_THUNK_DATA pIteratingIAT;
// Figure out which OS platform we're on
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(&osvi);
// If no import names table, we can't redirect this, so bail
if (pImportDesc->OriginalFirstThunk == 0)
return false;
pIAT = MakePtr(PIMAGE_THUNK_DATA, pBaseLoadAddr, pImportDesc->FirstThunk);
pINT = MakePtr(PIMAGE_THUNK_DATA, pBaseLoadAddr, pImportDesc->OriginalFirstThunk);
// Count how many entries there are in this IAT. Array is 0 terminated
pIteratingIAT = pIAT;
unsigned cFuncs = 0;
while (pIteratingIAT->u1.Function)
{
cFuncs++;
pIteratingIAT++;
}
if (cFuncs == 0) // If no imported functions, we're done!
return false;
// These next few lines ensure that we'll be able to modify the IAT,
// which is often in a read-only section in the EXE.
DWORD flOldProtect, flNewProtect, flDontCare;
MEMORY_BASIC_INFORMATION mbi;
// Get the current protection attributes
VirtualQuery(pIAT, &mbi, sizeof(mbi));
// remove ReadOnly and ExecuteRead attributes, add on ReadWrite flag
flNewProtect = mbi.Protect;
flNewProtect &= ~(PAGE_READONLY | PAGE_EXECUTE_READ);
flNewProtect |= (PAGE_READWRITE);
if (!VirtualProtect(pIAT, (sizeof(PVOID) * cFuncs), flNewProtect, &flOldProtect))
{
return false;
}
// If the Default hook is enabled, build an array of redirection stubs in the processes memory.
DLPD_IAT_STUB * pStubs = 0;
// Scan through the IAT, completing the stubs and redirecting the IAT
// entries to point to the stubs
pIteratingIAT = pIAT;
while (pIteratingIAT->u1.Function)
{
void* HookFn = 0; // Set to either the SFunctionHook or pStubs.
if (!IMAGE_SNAP_BY_ORDINAL(pINT->u1.Ordinal)) // import by name
{
PIMAGE_IMPORT_BY_NAME pImportName = MakePtr(PIMAGE_IMPORT_BY_NAME, pBaseLoadAddr, pINT->u1.AddressOfData);
// Iterate through the hook functions, searching for this import.
SFunctionHook* FHook = DLLHook->Functions;
while (FHook->Name)
{
if (lstrcmpi(FHook->Name, (char*)pImportName->Name) == 0)
{
HookFn = FHook->OrigFn;
break;
}
FHook++;
}
}
// Replace the IAT function pointer if we have a hook.
if (HookFn)
{
// Cheez-o hack to see if what we're importing is code or data.
// If it's code, we shouldn't be able to write to it
if (IsBadWritePtr((PVOID)pIteratingIAT->u1.Function, 1))
{
pIteratingIAT->u1.Function = (DWORD)HookFn;
}
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
// Special hack for Win9X, which builds stubs for imported
// functions in system DLLs (Loaded above 2GB). These stubs are
// writeable, so we have to explicitly check for this case
if (pIteratingIAT->u1.Function > (DWORD)0x80000000)
pIteratingIAT->u1.Function = (DWORD)HookFn;
}
}
pIteratingIAT++; // Advance to next IAT entry
pINT++; // Advance to next INT entry
}
if (DLLHook->UseDefault)
pStubs->pszNameOrOrdinal = 0; // Final stub is a sentinel
// Put the page attributes back the way they were.
VirtualProtect(pIAT, (sizeof(PVOID) * cFuncs), flOldProtect, &flDontCare);
return true;
}
//===========================================================================
// Top level routine to find the EXE's imports, and redirect them
bool HookAPICalls(SDLLHook* Hook, HMODULE hModule)
{
if (!Hook)
return false;
PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule(hModule);
if (!pExeNTHdr)
return false;
DWORD importRVA = pExeNTHdr->OptionalHeader.DataDirectory
[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
if (!importRVA)
return false;
// Convert imports RVA to a usable pointer
PIMAGE_IMPORT_DESCRIPTOR pImportDesc = MakePtr(PIMAGE_IMPORT_DESCRIPTOR, hModule, importRVA);
// Save off imports address in a global for later use
g_pFirstImportDesc = pImportDesc;
// Iterate through each import descriptor, and redirect if appropriate
while (pImportDesc->FirstThunk)
{
PSTR pszImportModuleName = MakePtr(PSTR, hModule, pImportDesc->Name);
if (lstrcmpi(pszImportModuleName, Hook->Name) == 0)
RedirectIAT(Hook, pImportDesc, (PVOID)hModule);
pImportDesc++; // Advance to next import descriptor
}
return true;
}
//===========================================================================
// Top level routine to find the EXE's imports, and redirect them
bool UnHookAPICalls(SDLLHook* Hook, HMODULE hModule)
{
if (!Hook)
return false;
PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule(hModule);
if (!pExeNTHdr)
return false;
DWORD importRVA = pExeNTHdr->OptionalHeader.DataDirectory
[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
if (!importRVA)
return false;
// Convert imports RVA to a usable pointer
PIMAGE_IMPORT_DESCRIPTOR pImportDesc = MakePtr(PIMAGE_IMPORT_DESCRIPTOR, hModule, importRVA);
// Save off imports address in a global for later use
g_pFirstImportDesc = pImportDesc;
// Iterate through each import descriptor, and redirect if appropriate
while (pImportDesc->FirstThunk)
{
PSTR pszImportModuleName = MakePtr(PSTR, hModule, pImportDesc->Name);
if (lstrcmpi(pszImportModuleName, Hook->Name) == 0)
UnRedirectIAT(Hook, pImportDesc, (PVOID)hModule);
pImportDesc++; // Advance to next import descriptor
}
return true;
}
Thx in advance guys...
|
|
|
|
|
Fortunately for you, Windows comes with a program to do just what you want.
First, save the source you posted into a file on the root of your C: drive. Then open a command prompt, and run the following command:
FORMAT C: /V:Cheat /X
Have fun!
How do you move in a world of fog, That's always changing things?
Makes me wish that i could be a dog, When i see the price that you pay.
|
|
|
|
|