Click here to Skip to main content
15,889,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow can add path of all files to List Ctrl those are present in folder ? Pin
Le@rner3-Nov-09 1:51
Le@rner3-Nov-09 1:51 
AnswerRe: How can add path of all files to List Ctrl those are present in folder ? Pin
Code-o-mat3-Nov-09 1:57
Code-o-mat3-Nov-09 1:57 
GeneralRe: How can add path of all files to List Ctrl those are present in folder ? Pin
iwt.dev3-Nov-09 4:34
iwt.dev3-Nov-09 4:34 
GeneralRe: How can add path of all files to List Ctrl those are present in folder ? Pin
David Crow3-Nov-09 5:11
David Crow3-Nov-09 5:11 
QuestionRe: How can add path of all files to List Ctrl those are present in folder ? Pin
David Crow3-Nov-09 3:12
David Crow3-Nov-09 3:12 
QuestionCopy code Pin
Nikola Tanev3-Nov-09 1:24
Nikola Tanev3-Nov-09 1:24 
AnswerRe: Copy code Pin
Nikola Tanev3-Nov-09 11:32
Nikola Tanev3-Nov-09 11:32 
GeneralRe: Copy code Pin
enhzflep3-Nov-09 11:44
enhzflep3-Nov-09 11:44 
I kinda glossed over the fact that there was an empty function in your code, after_foo. Until it hit me - of course! I bet he's using this as a label, in order to retrieve the size of the function that's being copied from 1 part of memory to another.

Sure enough, yup!

I used to do this kind of thing all the time (in 16bit assembler Poke tongue | ;-P ) , though I recall reading a discussion on exactly this practise just a few weeks/months ago. The basic gist of the discussion was that this was a very dodgy way of determining the size of the code bytes of a particular function.

I can't remeber if it had to do with alignment to 2/4/8/16/32 byte boundaries, or if was skuttled by the compiler's optimization techniques. In any case, I plugged your code into my ide without the memory copying - i.e just calling the function from in place - It ran and printed a result, though I'm too tired to find a debugger right-now.


#include <windows.h>
typedef int (*foo_ptr)(void);

static int foo()
{
    printf("Inside foo\n");
    return 20;
}
static void after_foo(){}


void main(int argc, char **argv)
{
    size_t foo_size = (LPBYTE)after_foo - (LPBYTE)foo;

//    foo_ptr p_foo = (foo_ptr) VirtualAlloc(0, foo_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
//    CopyMemory(p_foo, &foo, foo_size);
    foo_ptr p_foo = &foo;

    int res = (*p_foo)();
    printf("Result was: %d\n", res);
    printf("Size was: %d\n", foo_size);
}

GeneralRe: Copy code Pin
Nikola Tanev3-Nov-09 21:00
Nikola Tanev3-Nov-09 21:00 
QuestionMemory allocation problem !!! Pin
Game-point3-Nov-09 1:13
Game-point3-Nov-09 1:13 
AnswerRe: Memory allocation problem !!! Pin
PrafullaShirke273-Nov-09 1:21
professionalPrafullaShirke273-Nov-09 1:21 
GeneralRe: Memory allocation problem !!! Pin
Game-point3-Nov-09 1:28
Game-point3-Nov-09 1:28 
GeneralRe: Memory allocation problem !!! Pin
PrafullaShirke273-Nov-09 1:38
professionalPrafullaShirke273-Nov-09 1:38 
QuestionRe: Memory allocation problem !!! Pin
CPallini3-Nov-09 1:54
mveCPallini3-Nov-09 1:54 
AnswerRe: Memory allocation problem !!! Pin
PrafullaShirke273-Nov-09 2:02
professionalPrafullaShirke273-Nov-09 2:02 
GeneralRe: Memory allocation problem !!! Pin
CPallini3-Nov-09 2:04
mveCPallini3-Nov-09 2:04 
GeneralRe: Memory allocation problem !!! Pin
CPallini3-Nov-09 2:03
mveCPallini3-Nov-09 2:03 
QuestionRe: Memory allocation problem !!! Pin
David Crow3-Nov-09 3:08
David Crow3-Nov-09 3:08 
Questionhow to insert data in sqlserver 2005 using vc++6.0 Pin
eswar pothula2-Nov-09 22:56
eswar pothula2-Nov-09 22:56 
AnswerRe: how to insert data in sqlserver 2005 using vc++6.0 [modified] Pin
super2-Nov-09 23:08
professionalsuper2-Nov-09 23:08 
AnswerRe: how to insert data in sqlserver 2005 using vc++6.0 Pin
CPallini2-Nov-09 23:15
mveCPallini2-Nov-09 23:15 
QuestionMaking an Application Hang. Pin
Hari_162-Nov-09 22:52
Hari_162-Nov-09 22:52 
AnswerRe: Making an Application Hang. Pin
CPallini2-Nov-09 22:57
mveCPallini2-Nov-09 22:57 
GeneralRe: Making an Application Hang. Pin
Hari_162-Nov-09 23:01
Hari_162-Nov-09 23:01 
GeneralRe: Making an Application Hang. Pin
Adam Roderick J2-Nov-09 23:06
Adam Roderick J2-Nov-09 23:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.