|
Yes. This code should point you in the right direction. It outputs the names of all the functions exported by name from "Kernel32.dll":
#include "stdafx.h"
#include <iostream>
#include <windows.h>
LPVOID PrintFunctions(HMODULE hMod)
{
PIMAGE_DOS_HEADER pDOS = (PIMAGE_DOS_HEADER)hMod;
PIMAGE_NT_HEADERS pNew = (PIMAGE_NT_HEADERS)((char*)pDOS+pDOS->e_lfanew);
PIMAGE_OPTIONAL_HEADER pOpt = &(pNew->OptionalHeader);
PIMAGE_EXPORT_DIRECTORY pExport =
(PIMAGE_EXPORT_DIRECTORY)((char*)pDOS+pOpt->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
UINT_PTR *pNameArray = (UINT_PTR*)((char*)pDOS+pExport->AddressOfNames);
for (DWORD i=0; i<pExport->NumberOfNames; ++i)
{
LPCSTR pName = (LPCSTR)((char*)pDOS+pNameArray[i]);
std::cout << pName << std::endl;
}
return NULL;
}
int main(int arvc, char* argv[])
{
HMODULE hMod = GetModuleHandle("kernel32.dll");
PrintFunctions(hMod);
return 0;
}
Steve
|
|
|
|
|
Hi,
Where I could learn this kind of learning. Please point me to the right guides to do kernel/system programming?
|
|
|
|
|
|
Dear all,
What is the MTS funtion and what is the advantage of using MTS Funtion....
Thanks in advance
vikas da
vikas da
|
|
|
|
|
Hi All,
I need to define some array that will hold one bit in each cell.
I want to do it with BitArray - but i don't find in any place the size of each cell in this array.
Someone know the size of elements in bitArray ?
How can i define array that each element is only one bit ?
Thanks for any help.
|
|
|
|
|
Yanshof wrote: I want to do it with BitArray
This is a .NET class. Either this is not the right forum or it is the wrong type (have a look to std::bitset , std::vector< bool > classes).
Yanshof wrote: but i don't find in any place the size of each cell in this array.
Someone know the size of elements in bitArray ?
Why do yoou need the above?
How can i define array that each element is only one bit ?
see std::bitset , and std::vector< bool > documentation.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I want to display a separate dialog with list control when pushing a button in main dialog,
and to get the selected list item text when the dialog is closed.
My code is as follows:
In main dialog button click:
<br />
NewDlg obj= new NewDlg();<br />
obj.DoModal();<br />
In the dialog class constructor:
CListBox *pList;<br />
pList = (CListBox*)GetDlgItem(IDC_LIST1);<br />
pList->AddString("1");<br />
pList->AddString("2");<br />
An error saying "Debug assertion failed" is coming at AddString().
Any help would be greatly appreciable.
Best Regards,
Suman
|
|
|
|
|
Maybe you can use of this code:
CMain* m_main=(CMain*)GetParent();
m_main->yourcontrol
if we suppose CMain is your class.
|
|
|
|
|
Move the code from your constructor to the end of th OnInitDialog function and you should not get the assertion. When the constructor is called your dialog has not been created yet, so GetDlgItem(IDC_LIST1) returns NULL as it can not find the specified resource. You can not call an member of a pointer when the pointer is NULL.
Artificial Intelligence is no match for Natural Stupidity
No one can understand the truth until he drinks of coffee's frothy goodness. ~Sheik Abd-al-Kadir
I can't always be wrong ... or can I?
|
|
|
|
|
rp_suman wrote: NewDlg obj= new NewDlg();
obj.DoModal();
What is this? If you are going to use the new operator, you have to have a pointer:
NewDlg *obj= new NewDlg();
obj->DoModal(); But this is unnecessary. Just use:
NewDlg obj;
obj.DoModal(); The calls to AddString() must be done in the OnInitDialog() method.
"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,
Thanks for your great help.
I changed the code as you mentioned.
I am displaying the new dialog from the main dialog's OnInitDialog() function.
But how can I get the text of selected list item in new dialog after user clicked "OK".
My code is as follows:
NewDlg obj;<br />
obj.DoModal();<br />
<br />
CListBox* pList;<br />
pList = (CListBox*)obj.GetDlgItem(IDD_DIALOG1);<br />
DWORD strSelect = pList->GetItemData(pList->GetCurSel());
I am getting Debug Assertion when calling GetDlgItem() .
Best Regards,
Suman
|
|
|
|
|
rp_suman wrote: But how can I get the text of selected list item in new dialog after user clicked "OK".
By doing so in the OnOK() method.
rp_suman wrote: I am getting Debug Assertion when calling GetDlgItem().
Because you are trying to access a non-existent window. Once DoModal() returns, any windows it owned are destroyed.
"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
|
|
|
|
|
A task infront of me is to develop local chat server
which will just accept data from everyone and pass it to person whom it is to be send.
Server compiles fine but as soon as I run it ,it fails. Errors come at Accept statement.
The requirement is due to internet is not allowed.
And way for instant communication is required as comapany
layout is very complecated to reach from one room to other. Official mail is too inconvenient for small messages.
//CSocket cs,cr[500]; defined in h file
// bool connected;
BOOL CChatserverDlg::OnInitDialog()
{
CDialog::OnInitDialog();
---------------
------------------
----------------
count = 0;
connected = false;
connected = cs.Create(4000,SOCK_STREAM);
SilentWork();
return TRUE;
}
void CChatserverDlg::SilentWork()
{
bool check = false;
check = cs.Listen();
for(int i = 0;i < 500;i++) //even I reduce number error comes
{
AfxBeginThread(&thread,0);
count++;
}
}
UINT thread(LPVOID p)
{
CChatserverDlg* dlg = (CChatserverDlg*)AfxGetApp()->GetMainWnd();
SOCKADDR* lpSockAddr;
dlg->cs.Accept(dlg->cr[count],lpSockAddr );
while(dlg->connected)
{
ULONG nBytesToReceive=0;
DWORD dwErr;
if( !dlg->cr[count].IOCtl(FIONREAD, &nBytesToReceive))
{
dwErr = WSAGetLastError();
}
if( nBytesToReceive==0 )
{ }
else
{
char* buff = new char[15];
try
{
dlg->cr[count].Receive(buff,15,0);
}
catch(CException e)
{
}
dlg->m_ldList1.AddString(buff);
char* data = new char[1024];
bool continueloop = true;
do
{
ULONG ToReceive=0;
if( !dlg->cr[count].IOCtl(FIONREAD, &ToReceive))
{
dwErr = WSAGetLastError();
}
if( ToReceive==0 )
{ }
else
{
dlg->cr[count].Receive(data,1023,0);
dlg->cr[count].SendTo(data,1023,4000,buff,0);
if(NULL != strstr("diconnected",data))
continueloop = false;
}
}while(continueloop);
|| ART OF LIVING ||
|| ART OF LIVING ||
|
|
|
|
|
Dear all,
i have been requested to post my question on C here.Thanks
Here is my problem:
Am doing some analysis on RC4 TKIP.I want to create an RC4 key and XOR it with data.My RC4 key is Ok.But i want to pass it as a parameter so as to do encryption.
Can anyone among you help,as i have the RC4 keys in an array.But i want to pass this result in the second part of my program so as to do encryption with that key.
kind regards and thanks
NB
rc4key[0] = tsc2 % 256; <br />
rc4key[1] = (((tsc2 / 256) % 256) | 0x20) & 0x7f;<br />
rc4key[2] = (tsc2 / 256) % 256; <br />
rc4key[3] = ((ppk5 ^ ((256*key[1]) + key[0])) >> 1) % 256;<br />
<br />
rc4key[4] = ppk0 % 256;<br />
rc4key[5] = (ppk0 / 256) % 256;<br />
<br />
rc4key[6] = ppk1 % 256;<br />
rc4key[7] = (ppk1 / 256) % 256;<br />
<br />
rc4key[8] = ppk2 % 256;<br />
rc4key[9] = (ppk2 / 256) % 256;<br />
<br />
rc4key[10] = ppk3 % 256;<br />
rc4key[11] = (ppk3 / 256) % 256;<br />
<br />
rc4key[12] = ppk4 % 256;<br />
rc4key[13] = (ppk4 / 256) % 256;<br />
<br />
rc4key[14] = ppk5 % 256;<br />
rc4key[15] = (ppk5 / 256) % 256;<br />
void rc4(<br />
unsigned char *rc4key,<br />
<br />
int cipherstream_length,<br />
unsigned char *cipherstream<br />
);<br />
void rc4_encrypt(<br />
unsigned char *rc4key,<br />
<br />
unsigned char *data,<br />
int data_length,<br />
unsigned char *ciphertext<br />
);<br />
<br />
these are the codes, I wanted to use the result in the array above and used it as a pointer!!!
am nt getting any syntax error..but isthere any logical error?
please advice.
nb
|
|
|
|
|
If rc4key is an unsigned char array, then just pass rc4key, which is the same as &rc4key[0].
What is the line(s) of code you're getting syntax error on?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I want to dock the views in my MFC Application that means views can be drag and drop from one place of my frame area to other.How can it possible? Please help me
ganesh
|
|
|
|
|
I dotn know about Views but you can dock dialogs using CDialogBar
which View types you wanna make docable??
|
|
|
|
|
I want to dock the views which are derived from CView.
|
|
|
|
|
i am in need of how to add the checkbox image to the header of a CListCtrl i have a child dialog in the main dialog ive looked in msdn but im lost
CImageList * imagelist;<br />
CHeaderCtrl * m_pHdrCtrl;<br />
imagelist = new CImageList();<br />
ASSERT(imagelist != NULL);<br />
imagelist->Create(13, 13, ILC_COLOR24, 3, 1);<br />
CBitmap bm;<br />
bm.LoadBitmap(IDB_CHECKBOXES);<br />
imagelist->Add(&bm, RGB(255, 0, 255));<br />
m_pHdrCtrl->SetImageList(imagelist);
that gives no errors on compiling it
m_pHdrCtrl->SetImageList(imagelist); <-- wont allow me to build the exe
im a beginner be gentle when telling me how wrong it is i cant figure out how to add the imagelist to the header.
|
|
|
|
|
locoone wrote: m_pHdrCtrl->SetImageList(imagelist); <-- wont allow me to build the exe
What do you mean? After puttin the above statement your not getting the output exe?
|
|
|
|
|
|
now only i noticed you are not assigning any thing in to the CHeaderCtrl * m_pHdrCtrl;
you must call the GetHeaderCtrl() function and set that pointer to the m_pHdrCtrl. like
CHeaderCtrl * m_pHdrCtrl = m_ListCTrl.GetHeaderCtrl();
|
|
|
|
|
|
Hi,
if this is the code you wrote it cannot work. You declared a pointer to CHeaderCtrl and some lines below you access this pointer which you never set. This code compiles fine but certainly it results in a crash! You have to ask your CListCtrl instance for the pointer to its header control...
Try the following:
CHeaderCtrl* m_pHdrCtrl = m_YourListCtrl.GetHeaderCtrl();
if(m_pHdrCtrl != NULL)
{
CImageList * imagelist;
imagelist = new CImageList();
ASSERT(imagelist != NULL);
imagelist->Create(13, 13, ILC_COLOR24, 3, 1);
CBitmap bm;
bm.LoadBitmap(IDB_CHECKBOXES);
imagelist->Add(&bm, RGB(255, 0, 255));
m_pHdrCtrl->SetImageList(imagelist);
}
cheers,
mykel
OMM: "Let us be thankful we have an occupation to fill. Work hard, increase production, prevent accidents and be happy."
|
|
|
|
|
Hi,
Is it possible to have multiple thumbs along a slider control, if so can anyone direct me as to where I can find informantion on how to do this..
Thanks in advance!
Stefan.
All answers have a question? All code has an end.
|
|
|
|