| View previous topic :: View next topic |
| Author |
Message |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Tue Jul 29, 2008 10:17 pm Post subject: Iterating the Section Table errors |
|
|
I'm trying to iterate the section table and I'm getting 5 errors that I can't seem to fix (I fixed the other 5 x_x), and I was wondering if you guys could help. And the only reason I'm only listing the name is because I can't figure out how to set items in different columns Here's my code:
| Code: |
void IterateSections() {
LPVOID lpSection = (LPVOID)(pImageNtHeaders->OptionalHeader.ImageBase+pImageNtHeaders->OptionalHeader.SizeOfHeaders);
WORD wNumSections = pImageNtHeaders->FileHeader.NumberOfSections;
PIMAGE_SECTION_HEADER pImageSectionHeader = (PIMAGE_SECTION_HEADER)calloc(wNumSections, sizeof(IMAGE_SECTION_HEADER));
for(int i = 0; i<wNumSections; i++) {
pImageSectionHeader[i] = (PIMAGE_SECTION_HEADER)lpSection;
InsertItem(LVIF_TEXT, 0, 0, (LPSTR)pImageSectionHeader[i]->Name);
lpSection += sizeof(IMAGE_SECTION_HEADER);
}
}
|
Here are my errors:
| Quote: |
------ Build started: Project: PE Loader Emulator, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\oib\my documents\visual studio 2008\projects\pe loader emulator\pe loader emulator\main.cpp(23) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'PIMAGE_SECTION_HEADER' (or there is no acceptable conversion)
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(9637): could be '_IMAGE_SECTION_HEADER &_IMAGE_SECTION_HEADER::operator =(const _IMAGE_SECTION_HEADER &)'
while trying to match the argument list '(_IMAGE_SECTION_HEADER, PIMAGE_SECTION_HEADER)'
c:\documents and settings\oib\my documents\visual studio 2008\projects\pe loader emulator\pe loader emulator\main.cpp(24) : error C2819: type '_IMAGE_SECTION_HEADER' does not have an overloaded member 'operator ->'
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(9623) : see declaration of '_IMAGE_SECTION_HEADER'
did you intend to use '.' instead?
c:\documents and settings\oib\my documents\visual studio 2008\projects\pe loader emulator\pe loader emulator\main.cpp(24) : error C2232: '->_IMAGE_SECTION_HEADER::Name' : left operand has 'struct' type, use '.'
c:\documents and settings\oib\my documents\visual studio 2008\projects\pe loader emulator\pe loader emulator\main.cpp(24) : error C3861: 'InsertItem': identifier not found
c:\documents and settings\oib\my documents\visual studio 2008\projects\pe loader emulator\pe loader emulator\main.cpp(25) : error C2036: 'LPVOID' : unknown size
Build log was saved at "file://c:\Documents and Settings\OIB\My Documents\Visual Studio 2008\Projects\PE Loader Emulator\PE Loader Emulator\Debug\BuildLog.htm"
PE Loader Emulator - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Jul 29, 2008 10:26 pm Post subject: |
|
|
| Code: | void IterateSections()
{
DWORD dwSection = (DWORD)(pImageNtHeaders->OptionalHeader.ImageBase+pImageNtHeaders->OptionalHeader.SizeOfHeaders);
WORD wNumSections = pImageNtHeaders->FileHeader.NumberOfSections;
PIMAGE_SECTION_HEADER pImageSectionHeader = (PIMAGE_SECTION_HEADER)calloc(wNumSections, sizeof(IMAGE_SECTION_HEADER));
for(int i = 0; i < wNumSections; i++)
{
pImageSectionHeader[i] = (PIMAGE_SECTION_HEADER)dwSection;
InsertItem(LVIF_TEXT, 0, 0, (LPSTR)pImageSectionHeader[i].Name);
dwSection += sizeof(IMAGE_SECTION_HEADER);
}
} |
Leaves 1 Error.
I'm still working on it. (pImageSectionHeader[i] = (PIMAGE_SECTION_HEADER)dwSection)
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Tue Jul 29, 2008 10:31 pm Post subject: |
|
|
Thanks. But just another question, since this one can be quickly answered, how do I add items to a specific column?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Jul 29, 2008 10:34 pm Post subject: |
|
|
LVM_SETITEM message (or the macro ListView_SetItem)
Edit:
Try replacing that line that causes the error with this and see if it works.
| Code: | | memcpy( &pImageSectionHeader[i], (void*)dwSection, sizeof(dwSection) ); |
or
| Code: | | memcpy( (void*)pImageSectionHeader[i], (void*)dwSection, sizeof(dwSection) ); |
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Tue Jul 29, 2008 10:56 pm Post subject: |
|
|
Thanks it compiles fine. But it's not listing anything. And LVM_SETITEM didn't help because that just sets an items attributes. I want to insert the item at a specific column.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Jul 29, 2008 10:59 pm Post subject: |
|
|
LVM_INSERTITEM : Inserts an item into the first column using a filled LVITEM struct. Once there is an item in the first column you must use LVM_SETITEM to place items in the column's to the right (ListView control must be created with the LVS_REPORT style).
LVM_SETITEM : Sets an item definition (LVITEM struct) to a specified column. (LVITEM - iSubItem = ColumnNumber)
Btw Make sure when you create your columns via LVCOLUMN struct that you set the mask to LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH. If you want to utilize sub items.
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Tue Jul 29, 2008 11:15 pm Post subject: |
|
|
Oh lol. Thanks. But still, it won't list anything.
| Code: |
for(int i = 0; i<wNumSections; i++) {
memcpy(&pImageSectionHeader[i], (LPVOID)dwSection, sizeof(dwSection));
InsertItem(LVIF_TEXT, i, 0, (LPSTR)pImageSectionHeader[i].Name, FALSE);
dwSection += sizeof(IMAGE_SECTION_HEADER);
}
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Wed Jul 30, 2008 12:49 am Post subject: |
|
|
| Did you change the iSubItem value?
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Wed Jul 30, 2008 8:52 am Post subject: |
|
|
To what are you referring to?
And I can't get it to even list the names in the first column. And I can't get it to list anything in the second/third/fourth/fifth column. I set each column to LVCF_SUBITEM, I set their subitem 0-4 and tried assigning an item with iItem at 0 and iSubItem at the columns number.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
|