-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerateVariable.cpp
66 lines (49 loc) · 2.33 KB
/
GenerateVariable.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "resource.h"
const unsigned int m_uicAbsoluteMinVariables = 25; // the variables
const string m_uicTypeArray[3] =
{
"db", // define byte
"dw", // define word
"dd", // define dword
};
// initiates the variable list, and puts into the global list
string GenerateVariableDeclaration(string m_szVarName, string m_szVarType, string m_szVarValue)
{
// ie m_dwExampleVar dd 20
// ie m_dwExampleVar2 dd ?
stringstream m_ssFormatted;
m_ssFormatted << m_szVarName << " ";
m_ssFormatted << m_szVarType << " ";
m_ssFormatted << m_szVarValue;
return m_ssFormatted.str();
}
extern void InitiateVariableList()
{
unsigned int m_uiNumberOfVariables;
unsigned int m_uiMinimumVariable = 25; // these are how many trash variables will be generated ontop
unsigned int m_uiMaximumVariable = 75; // of the actual variables
m_uiNumberOfVariables = (GenerateRandom(m_uiMinimumVariable,m_uiMaximumVariable) + m_uicAbsoluteMinVariables);
/*
for (unsigned int i = 0; i < m_uicAbsoluteMinVariables; i++)
{ // generate the LEGITIMATE variables FIRST
} // then generate the JUNK variables LAST
*/
// m_uicAbsoluteMinVariables
for (unsigned int i = 0; i < m_uiNumberOfVariables; i++)
{
string m_szValue = "50";
VARIABLE m_stTempVariable;
m_stTempVariable.m_bJunkVariable = true;
m_stTempVariable.m_bVariableInUse = false;
m_stTempVariable.m_szVariableName = CreateLabel();
m_stTempVariable.m_uiTypeVariable = GenerateRandom(0,2); // 0 - 8bit, 1 - 16bit, 2 - 32bit
// Generate what value it will initially hold, do this later, for now it will hold the value 50
m_stTempVariable.m_szVariableDeclaration = GenerateVariableDeclaration(m_stTempVariable.m_szVariableName,m_uicTypeArray[m_stTempVariable.m_uiTypeVariable],m_szValue);
g_lsGlobalVariable.push_back(m_stTempVariable); // push back this value back into the list
}
}
// Generates a variable from a global list of class VARIABLE struct generated by the current program
// using the index of max variables in the vector
// it is then checked if the operand is source or destination
// if destination, then we must check if in use by main program, if in use then generate another variable
// else then we can use it as source as direct modification of memory isn't possible