|
Thanks for ur Response,
I had tried LVN_ITEMCHANGED event. I write following code in MASSAGE MAP
as
BEGIN_MESSAGE_MAP(CSelectBusCategory, CPropertyPage) // Line 1
//{{AFX_MSG_MAP(CSelectBusCategory) // Line 2
LVN_ITEMCHANGED(IDC_PREVIEWLISTCTRL, OnSelectItemFromList) // Line 3
//}}AFX_MSG_MAP Line 4
END_MESSAGE_MAP() // Line 5
I also write definition for it as
void
CSelectBusCategory::OnSelectItemFromList(NMHDR* pNMHDR, LRESULT* pResult)
{
MessageBox(" Hiii");
}
When I compile this code, I got error in between
BEGIN_MESSAGE_MAP and END_MESSAGE_MAP(). These are
1)term does not evaluate to a function (Line 3)
2)syntax error : ';' (Line 5)
3)missing function header (old-style formal list?) (Line 5)
4)syntax error : missing ';' before '}' (Line 5)
5)syntax error : missing ';' before '}' (Line 5)
I could not find the reason why these errors are occure though the syntax are correct.I have solution then plz forward it.
Thanks in Advance
Atul
|
|
|
|
|
Atulmahajan wrote: LVN_ITEMCHANGED(IDC_PREVIEWLISTCTRL, OnSelectItemFromList) // Line 3
The proper way of handling a notification message is likewise
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LISTID, OnListSelectionChanged)
|
|
|
|
|
Thanks Nibbu,
I can capture the select item event. Now I want to get the item text so for this I write following code in message function but returns me blank string. The code is as
CString strJPEGFileName = " ";
int nItem,nSubItem;
strJPEGFileName = mWebPagePrvListCtrl.GetItemText(nItem,nSubItem);
Is there any method to retrive text data of selected item.
Thanks in Advance
Atul
|
|
|
|
|
Atulmahajan wrote: I can capture the select item event. Now I want to get the item text so for this I write following code in message function but returns me blank string. The code is as
CString strJPEGFileName = " ";
int nItem,nSubItem;
strJPEGFileName = mWebPagePrvListCtrl.GetItemText(nItem,nSubItem);
Here is an example...
void CDlg::OnItemChanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
CString csText = m_clstAnyList.GetItemText( pNMListView->iItem, pNMListView->iSubItem );
}
|
|
|
|
|
Hi Nibu
Thanks for reply..
I use same code in my application though it return me blank string. The code is as
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
CString strJPEGFileName = mWebPagePrvListCtrl.GetItemText(pNMListView->iItem,pNMListView->iSubItem);
plz give me solution to this.
Thanks in Advance
Atul
|
|
|
|
|
I am using VS2005 for VC++ application, and my solution contains many projects. I added project to source control using VS2005 "Add projects to source control" menu. It added all *.h & cpp files. But some other files having named "*.vcproj.vspscc" also got added to source control. Why? what is use of this file?
Also what all files from VS2005 project & solution to be added to VSS? I mean which files excluded from Adding to VSS, for a smooth working of group of people in a solution/project
Thanks
Anil
|
|
|
|
|
For Visual Studio 2005, you need to add these files to the source control (and of course, all your .cpp and .h files):
- .sln file: contains the information about the different projects that are in the solution. So, if someone adds or remove a project from the solution, it should be 'saved' for others also.
- .vcproj files: contains all the settings for each projects (you will have one vcproj file for each project). This contain for example the files that are in your project (so if someone adds a new file, it should be reflected), contains also the project properties (all the option that you can configure by clicking 'Project' -> 'Properties').
All the other files are not needed and will be automatically recreated.
|
|
|
|
|
Thanks very much
|
|
|
|
|
Actually , I want to deal with chracter & strings and my problem is....
1) I have an edit control and I just put some text into them when i clicked on next it will go into a single linked list again & again it will take some data
2) When I close my dialog , all the linked list data will store into file
and vise versa for retrieving at the "end of file".
If someone help me then it is benefial for me.
Thank you
Manoj Srivastava
Software Developer New Delhi
|
|
|
|
|
Where did you get struck?
- NS -
|
|
|
|
|
Manoj Srivastava wrote: 1) I have an edit control and I just put some text into them when i clicked on next it will go into a single linked list again & again it will take some data
2) When I close my dialog , all the linked list data will store into file
So are you usng CList for this? What problem(s) are you having?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi!
I need create a dll in VC++ and use in C#... But i can´t make this work
I made a new project:
New project > Visual C++ > CLR > Class Library
And write the files above, but when i import to C#´s project i can´t see the "test" function
So, anybody can help me?
Thank´s for the attention!
//########[Tsai7.cpp]########
#include "stdafx.h"
#include "Tsai7.h"
#include "math.h"
using namespace Tsai7;
public class Tsi
{
public: int test(int valor)
{
return valor;
}
};
//########[Tsai7.cpp]########
//#########[Tsai7.h]#########
#pragma once
using namespace System;
namespace Tsai7 {
public ref class Class1
{
public:
test(int valor);
};
}
//#########[Tsai7.h]#########
Rui Sousa
|
|
|
|
|
try and make a
COM dll if u can b'cause it does a lot of interface coding on its own.
try this link:
http://www.codeproject.com/com/Inside_COM.asp[^]
Regards,
Pankaj Sachdeva
"There is no future lies in any job"
"but"
"future lies in the person who holds the job"
|
|
|
|
|
Hi Pankaj!
Thanks for the help, but i don´t undertand C++ You know a more easy way to make this?
I explain: I have a old code in C++ and, now, i need use this code in a C# application, but the code is very big and i don´t have time to re-make everting.
So, i belive the more easy way is create a DLL with the old code, but not a COM object... or not
Rapbs
|
|
|
|
|
Why you cant your dll and use of it on the C# I think it must easy way for you.
|
|
|
|
|
I start process which does CreateFilemapping as follows.
=====================================================================================
hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, // Current file handle.
&sa, // Default security.
PAGE_READWRITE, // Read/write permission.
0, // Max. object size.
1, // Size of hFile.
NONWTS_SERVICE_FILE_MAPOBJ); // Name of mapping object.
lpMapAddress = MapViewOfFile(hMapFile, // Handle to mapping object.
FILE_MAP_ALL_ACCESS, // Read/write permission
0, // Max. object size.
0, // Size of hFile.
0); // Map entire file.
.....
FlushViewOfFile(lpMapAddress, 0);
=====================================================================================
This process is running under session id = 1 and running under administrator user
without Administrative previlages.
From my other application(process) i call OpenFileMapping. This process is running under system context with session id = 0.
=====================================================================================
hMapFile = OpenFileMapping(
FILE_MAP_ALL_ACCESS, // Read permission.
FALSE, // Inherit handle
NONWTS_SERVICE_FILE_MAPOBJ); // Name of mapping object. //Non WTS Environment
=====================================================================================
Here the OpenFileMapping call fails. This same thing works fine if i have done the CreateFilemapping
from an application running under administrator user with Administrative previlages.
Can any one please help me in overcoming this problem.
Thanks in advance,
Praveen
|
|
|
|
|
I'm writing to the memory of another process using VirtualProtectEx() with the PAGE_EXECUTE_READWRITE flag set, the previous flag comes back as PAGE_READONLY . When trying to reset the protection with PAGE_READONLY or PAGE_EXECUTE_READONLY the newly created process crashes "Blah Blah Blah has stopped working"! The strange thing is, when resetting the flag, the previous comes nack as PAGE_EXECUTE_WRITECOPY .
I tried this without modifying the memory in any way, a simple set and reset crashes the process!
BUT, not resetting the protection enables the process to run. BUT modifying the memory of the process causes the page to be copied Leaving the origional app intact.
What is the point of having the WriteProcessMemory() API if windows refuses to allow us to write?
|
|
|
|
|
WalderMort wrote: I tried this without modifying the memory in any way, a simple set and reset crashes the process!
Can u show how you wrote it?
|
|
|
|
|
Well, it's a bit long winded, but something like this:
STARTUPINFO si;
PROCESS_INFORMATION pi;
LPTSTR szExeName = GetCommandLine();
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if( ! ::CreateProcess( L"Demo.exe", 0, 0, 0, 0, CREATE_SUSPENDED, 0, 0, &si, &pi ) )
return NULL;
HANDLE hProcess = OpenProcess( PROCESS_ALL_ACCESS , FALSE, pi.dwProcessId );
CONTEXT context;
ZeroMemory( &context, sizeof( CONTEXT ) );
context.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS;
if ( ! GetThreadContext( pi.hThread, &context ) )
return 0;
LDT_ENTRY entry;
ZeroMemory( &entry, sizeof( LDT_ENTRY ) );
GetThreadSelectorEntry( pi.hThread, context.SegFs, &entry );
DWORD dwFSBase = ( entry.HighWord.Bits.BaseHi << 24 ) | ( entry.HighWord.Bits.BaseMid << 16 ) | ( entry.BaseLow );
DWORD read;
Local::TEB teb; ZeroMemory( &teb, sizeof( Local::TEB ) );
Local::PPEB pPeb = NULL;
if ( ReadProcessMemory( hProcess, (LPCVOID)(DWORD_PTR)dwFSBase, &teb, sizeof( Local::TEB ), &read ) )
pPeb = teb.Peb;
else
return NULL;
IMAGE_DOS_HEADER DosHeader;
IMAGE_NT_HEADERS NtHeader;
DWORD dwBase = (DWORD)(DWORD_PTR)pPeb->ImageBaseAddress;
DWORD dwSize = 0;
ReadProcessMemory( hProcess, (LPCVOID)(DWORD_PTR)dwBase, &DosHeader, sizeof( IMAGE_DOS_HEADER ), &read );
if ( DosHeader.e_magic != IMAGE_DOS_SIGNATURE )
throw "Not a valid executable file.\n";
ReadProcessMemory( hProcess, (LPCVOID)(DWORD_PTR)(dwBase + DosHeader.e_lfanew), &NtHeader, sizeof( IMAGE_NT_HEADERS ), &read );
if ( NtHeader.Signature != IMAGE_NT_SIGNATURE )
throw "No PE header found.\n";
dwSize = NtHeader.OptionalHeader.SizeOfImage;
BOOL bSuccess = FALSE;
DWORD dwOldProtect;
bSuccess = VirtualProtectEx( hProcess, (PVOID)dwBase, m_dwImageSize, PAGE_EXECUTE_READWRITE, &dwOldProtect );
...
bSuccess = VirtualProtectEx( hProcess, (PVOID)dwBase, m_dwImageSize, PAGE_EXECUTE, &dwOldProtect );
CloseHandle( hProcess );
ResumeThread( pi.hThread );
return pi.hProcess;
I realize CreateProcess() should return with ALL_ACCESS_RIGHTS but I thought I would try the OpenProcess() also.
|
|
|
|
|
WalderMort wrote: if( ! ::CreateProcess( L"Demo.exe", 0, 0, 0, 0, CREATE_SUSPENDED, 0, 0, &si, &pi ) )
I doubt the create suspended is making some problem. can you change it to NULL and try?
Also i found you are doing som much code to find the base address of the code. you can achive the same by the following code
HANDLE hSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, pi.dwProcessId );<br />
MODULEENTRY32 stEntry = {0};<br />
stEntry.dwSize = sizeof(MODULEENTRY32);<br />
Module32First( hSnap, &stEntry );
But I found that the above code is not working when the process is created in suspended mode.
Also one more information regarding what we discussed yesterday. When a process is created only kernel32.dll and ntdll.dll is loaded.
|
|
|
|
|
The trouble is I neeed to get my hands on those PEB and TEB structures, so while I have them I might aswell use my method.
You say only kernel32 and ntdll are loaded, but I have found this not to be the case. When it's created in a suspended state, no code has been executed, including the code which builds the IAT. That's why most code injection tricks also have to inject the addresses of the API's they require.
I don't suppose you tried out my code on your machine? I have found a few references to the same problem on the web. All relating to VistaX64, which happens to be all I have installed right now.
|
|
|
|
|
WalderMort wrote: You say only kernel32 and ntdll are loaded
I just used the process explorer and checked.
WalderMort wrote: I don't suppose you tried out my code on your machine
I tried. But with some modifications. i found with that PEB and TEB ur trying to get the image base address and that codes where making some many compilation error( since some structures are not defined ). So I too the base address through another method and tried. But as I mentioned eariler that method requires the process to be created in normal way. Not in suspended.
I am running in XP.
|
|
|
|
|
Ah yes, I had to use my own defiition of those structures, from www.ntinternals.net
|
|
|
|
|
WalderMort wrote: DWORD dwFSBase = ( entry.HighWord.Bits.BaseHi << 24 ) | ( entry.HighWord.Bits.BaseMid << 16 ) | ( entry.BaseLow );
One doubt. if your using a 64 bit mechine, are you sure the above shifting is correct?. I found the original code was written for 32 bit mechine. Also confirm the TEB have same size in both 64 bit and 32 OS. Expecially in VISTA.
|
|
|
|
|
It may be a 64bit machine, but the exe is 32bit. Also, if you look at the code, before accepting the entry point, I check the PE headers to validate that it points to the correct location.
As far as this project goes, I'm going to have to give up, at least until I install VmWare. For now I will stick with being able to run only console apps, which is the main reason I started this.
The strange thing is, every single article I have found on the topic is the same as my code. I have played around with the TOKEN and SECURITY_DESCRIPTOR structs. But, when the initial pages are allocated for the process, they are done so with the PAGE_EXECUTE_WRITECOPY protection, and I can find no way around this.
I really must test this code on other machines to test if it is a Vista x64 'feature'!
|
|
|
|
|