|
I am using visual c++.net 2010 I get these errors
1>------ Build started: Project: last try, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\trogd\documents\visual studio 2010\projects\last try\last try\main.cpp(18): warning C4007: 'DllMain' : must be '__stdcall'
1>LINK : fatal error LNK1561: entry point must be defined
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
and here is the code also please tell me what is wrong and how I can fix it. thanks!
#include <Windows.h>
#define ADR_Test 0xB7CE50
void HackThread()
{
for(;;)
{
*(DWORD*)ADR_Test = 100000;
}
Sleep(180);
}
BOOL DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)HackThread, 0, 0, 0);
}
return TRUE;
}
|
|
|
|
|
wrote: BOOL DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID) Should be BOOL __stdcall DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID) or BOOL WINAPI DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID)
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hello friends,
I needed some hints/suggestion/brainstorm, so to go in a right direction.
I have lot of different Objects, based on which I need to generate a Text-file. This text is nothing but a Scripting Language with some specific rules or grammars. ( Example, like a VB script ).
A simple/legacy way could be, Iterate all the objects, and Append hard-coded text ( to a global string), with many if and else cases.
Now, I am looking if any framework/design/principle is available, or I can make use of it, to make a clean design/code instead writing lot of if and else. One I found is boost karma, but looking for alternatives to make the best choice.
Seeking your valuable advises.
Thanks in advance,
|
|
|
|
|
Make the object classes inherit from a common interface exposing, say, a toString method an d then call it on all the object instances.
|
|
|
|
|
Thank you for your advice. Sure it is part of the solution.
I was looking more on making the script file ( that is the text of the scripts), as in how should I do that. Shall I simply make a hard-coded string with lot of if and else ( from the objects), and append them one by one, or do we have a fit design Pattern for this. Keeping in mind there would be some rules for the script generation, I would love to make it cleaner with some well design structure.
|
|
|
|
|
If chains can be avoided, if feasible, leveraging on polymorphism.
|
|
|
|
|
Option B is to make a simple program to load them into a database either a standard spec or make your own format.
If you need to do this a lot or need to edit and change the data and save it again then you are effectively dealing with a database you just don't realize it. Say for something like a game often you need leaderboards etc and if you want to deploy on a mobile app you really need to hit one of the cloud databases. So it depends a lot what you are trying to do.
To really be able to give advice we need to know how often is the data accessed .. aka is speed of access an issue or alternatively is the data only ever read once and never touched again AKA its a straight load situation.
In vino veritas
|
|
|
|
|
Thank you so much for your reply.
FYI, there is no db involved, as at the time of making the script all the objects are already available in the memory. I just need to traverse them one by one, make the script out of it.
Keeping in mind there would be rules to make the script, I wish I could do it in a cleaner way ( avoiding lot of if and else while making the text for the script)
|
|
|
|
|
How to create a little game?
|
|
|
|
|
That's not a question we can answer: you do it the same way you do any software project: idea, specification, design, code, test - and move back to any earlier stage as a result of any problems as necessary. The same process occurs if you are producing tic-tac-toe or Skyrim - only the level of detail and the size of the team required changes!
We can't answer "open ended" questions like that - you need to be a whole lot more specific!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
============================================================================
Name : new.c
Author : Abhinav
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/
include <stdio.h>
include <stdlib.h>
void compute(int N[6][6],int Z[6][6])
{
//compute neighbours
int i,j;
for (i = 1; i <=6; i++)
{
for (j = 1; j <= 6; j++)
{
N[i][j]=Z[i-1][j-1]+Z[i][j-1]+Z[i+1][j-1]
+ Z[i-1][j] +Z[i+1][j]+ Z[i-1][j+1]
+Z[i][j+1]+Z[i+1][j+1];
}
}
}
// This method is going to print the Matrix that we have defined in the main method
void show(int Z[6][6])
{
printf("************************************************************\n");
int i,j;
// Incrementing the value of integer i so that it can be used as an index value for matrix 'Z'.
for (i = 0; i < 6; i++)
{
// Incrementing the value of integer j to be used as the second index value for matrix 'Z'.
for (j = 0; j < 6; j++)
{
// This will print the elements present in th array line wise.
printf("%d ", Z[i][j]);
}
printf("\n");
}
printf("************************************************************\n");
}
/* This method is going to take the value of elements
from the array and compute the output according to
some conditions. Like for the rule of UnderPopulation
we have to check that if the element at some index is surrounded
by less than two live elements than the element is going to die.
*/
void iteration(int Z[6][6]){
int N[6][6]= {{0}};
int i,j;
compute(N,Z);
for (i = 0; i < 6; i++)
{
for (j = 0; j < 6; j++)
{
if((Z[i][j] == 1)&&(N[i][j] < 2 || N[i][j] > 3))
{
Z[i][j] = 0;
}
else if((Z[i][j] == 0)&&(N[i][j] == 3))
{
Z[i][j] = 1;
}
}
}
/*
for (i = 0; i < 6; i++)
{
for (j = 0; j < 6; j++)
{
if((N[i][j] < 2 )) // Rule number 1 - Under population
{
if (Z[i][j]==1&&((N[i][j] ==2 )||(N[i][j] == 3 ))) // Rule 4 - Next generation
{
Z[i][j] = 1;
}
else
{
Z[i][j] = 0;
}
}
else if ((Z[i][j] == 0)&&(N[i][j]==3)) // Rule 2 - Dead cell become live
{
Z[i][j] = 1;
}
else if ((N[i][j]>3)) // Rule 3 - Overpopulation
{
Z[i][j] = 0;
}
}
}
*/
}
/*
In this main method all the method are called to execute
all the methods.
*/
int main()
{
// Here I have declared a 6x6, 2D array which contains 36 elements.
int Z[6][6]=
{
// In this array '1' denotes live cell where as '0' denotes dead cell.
{1, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0},
{0, 1, 0, 1, 0, 0},
{0, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},
};
// This will pass the value of elements of array into the method 'show()'
int i;
printf("Here is the array that i have declared for the GAME.\n");
show(Z);
printf("\n");
printf("****************************************************************\n");
printf("Actual output after computing the results\n");
for(i=1; i<= 5; i++) // This will tell us the number of generations to skip before the answer
{
//clear(); //clear screen
iteration(Z);
printf("#################################################");
printf("This is the %d generation",i);
show(Z);
}
printf("****************************************************************\n");
return 0;
}
|
|
|
|
|
|
When calculating the N array, the element of the boundary is overstepped by the Z array access as calculated by your algorithm in your compute function.
for (i = 1; i <=6; i++)
{
for (j = 1; j <= 6; j++)
{
N[i][j]=Z[i-1][j-1]+Z[i][j-1]+Z[i+1][j-1]
+ Z[i-1][j] +Z[i+1][j]+ Z[i-1][j+1]
+Z[i][j+1]+Z[i+1][j+1];
}
}
You can use the recursive algorithm of the stack or compute the boundary element separately.
xgzsChris
|
|
|
|
|
元昊 潘 wrote: When calculating the N array, the element of the boundary is overstepped by the Z array access as calculated by your algorithm in your compute function.
for (i = 1; i <=6; i++)
{
for (j = 1; j <= 6; j++)
{
N[i][j]=Z[i-1][j-1]+Z[i][j-1]+Z[i+1][j-1]
+ Z[i-1][j] +Z[i+1][j]+ Z[i-1][j+1]
+Z[i][j+1]+Z[i+1][j+1];
}
}
Yes.
And the same is for N array itself! The OP tries to set the element with the index 6 while the "allowed" indexes are 0 to 5!
|
|
|
|
|
Hi
I am a C++ beginner and I have looked up a few articles on memory management,but most authors think autoptr should be used. However, I am not familiar with the library of them, and I need your guidance that I want to use linked lists to link to memory pools.
Thank you!
xgzsChris
|
|
|
|
|
You need to provide more information. The statement "I want to use linked lists to link to memory pools" does not really make it clear what you are trying to do.
|
|
|
|
|
When started, a "Memory Pool" allocates a large chunk of Memory and will split the chunk into smaller chunks,such as 100 bytes.Every time you request memory space from a memory pool, it gets chunks that have been allocated previously, not from the operating system.
Though I have such a idea,but I have trouble coming it true.
I'll appreciate it if you could give me some advice or share code after abstraction.
Maybe my request will take you a long time.
Thank you very much!
|
|
|
|
|
元昊 潘 wrote: Maybe my request will take you a long time. Well it would if I was going to try it. But I wonder what actual use this is when the C/C++ systems have a perfectly reasonable set of functions to manage memory already.
|
|
|
|
|
A common problem with using C++ in embedded systems is memory allocation, which is a loss of control over the new and delete operators.
Ironically, the root of the problem is that C++ 's memory management is very easy and secure.Specifically, when an object is eliminated, its destructor can safely free the allocated memory.
This is of course a good thing, but the simplicity of this use makes programmers overuse new and delete without paying attention to cause and effect in an embedded C++ environment.Furthermore, in embedded systems, frequent dynamic allocation of memory of variable size can cause significant problems and risk of heap fragmentation due to memory limitations.
As a warning, conservative use of memory allocation is the first principle in an embedded environment.
But when you have to use new and delete, you have to control memory allocation in C++.You need to replace the system's memory allocation with a global new and delete, and overloads new and delete from class to class.
It maybe also a good solution by operating new and delete,but I think that linking memory blocks with linked lists can be a relatively simple approach, as my teacher said.
|
|
|
|
|
Well you started off by saying you are a C++ beginner, and now you are talking about issues with embedded systems. So I am a little confused as to your actual experience and knowledge levels, and what this question is really all about.
|
|
|
|
|
Well,to tell you the truth,I have just been studying programming for a year,and only learned C and C++.Some of the content in the last post came from articles I read.I've learned about almost three solutions, and it turns out that I think linked list solution is easier, and maybe you haven't heard of it because I've looked through many articles and most of the ones they introduced are the autoptr classes.As long as you can express your opinion, it will be of great help to me.
|
|
|
|
|
The auto_ptr (like most constructs) is just a mechanism that eases the work required to make some piece of code more efficient, or easier to write. It is not a universal solution to every problem. So whatever you use it for you need first to be sure it is the right thing to use: see Smart Pointers (Modern C++)[^] for some more information.
|
|
|
|
|
Thank you very much!By the way, if I want to learn programming well, I need to understand the role and usage of most library functions.
|
|
|
|
|
Very true. And the best way to learn is to take a properly structured course, or buy a good book on the language.
|
|
|
|
|