raSystem  1.0 bata
raMain.cpp
Go to the documentation of this file.
1 #include "..\include\raMain.h"
2 
3 raString System::RASYSTEMPATH;
4 #pragma unmanaged
5 
6 static DWORD dwTlsIndex;
7 
8 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved )
9 {
10  LPVOID lpvData;
11  BOOL fIgnore;
12 
13  switch (fdwReason)
14  {
15  // The DLL is loading due to process
16  // initialization or a call to LoadLibrary.
17  case DLL_PROCESS_ATTACH:
18 
19  // Allocate a TLS index.
20  if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES)
21  return FALSE;
22  // No break: Initialize the index for first thread.
23  // The attached process creates a new thread.
24 
25  case DLL_THREAD_ATTACH:
26  // Initialize the TLS index for this thread.
27  lpvData = (LPVOID) LocalAlloc(LPTR, 256);
28  if (lpvData != NULL)
29  fIgnore = TlsSetValue(dwTlsIndex, lpvData);
30 
31  break;
32 
33  // The thread of the attached process terminates.
34  case DLL_THREAD_DETACH:
35 
36  // Release the allocated memory for this thread.
37  lpvData = TlsGetValue(dwTlsIndex);
38  if (lpvData != NULL)
39  LocalFree((HLOCAL) lpvData);
40 
41  break;
42 
43  // DLL unload due to process termination or FreeLibrary.
44  case DLL_PROCESS_DETACH:
45 
46  // Release the allocated memory for this thread.
47  lpvData = TlsGetValue(dwTlsIndex);
48  if (lpvData != NULL)
49  LocalFree((HLOCAL) lpvData);
50 
51  // Release the TLS index.
52  TlsFree(dwTlsIndex);
53  break;
54 
55  default:
56  break;
57  }
58  return TRUE;
59  UNREFERENCED_PARAMETER(hinstDLL);
60  UNREFERENCED_PARAMETER(lpReserved);
61 }
62 #ifdef __cplusplus // If used by C++ code,
63 extern "C" { // we need to export the C interface
64 #endif
65 
66 __declspec(dllexport)
67 BOOL WINAPI StoreData(DWORD dw)
68 {
69  LPVOID lpvData;
70  DWORD * pData; // The stored memory pointer
71 
72  lpvData = TlsGetValue(dwTlsIndex);
73  if (lpvData == NULL)
74  {
75  lpvData = (LPVOID) LocalAlloc(LPTR, 256);
76  if (lpvData == NULL)
77  return FALSE;
78  if (!TlsSetValue(dwTlsIndex, lpvData))
79  return FALSE;
80  }
81 
82  pData = (DWORD *) lpvData; // Cast to my data type.
83  // In this example, it is only a pointer to a DWORD
84  // but it can be a structure pointer to contain more complicated data.
85 
86  (*pData) = dw;
87  return TRUE;
88 }
89 
90 __declspec(dllexport)
91 BOOL WINAPI GetData(DWORD *pdw)
92 {
93  LPVOID lpvData;
94  DWORD * pData; // The stored memory pointer
95 
96  lpvData = TlsGetValue(dwTlsIndex);
97  if (lpvData == NULL)
98  return FALSE;
99 
100  pData = (DWORD *) lpvData;
101  (*pdw) = (*pData);
102  return TRUE;
103 }
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 //-----------------------------------------------------------------
110 {
112  printf("%s", x.c_str());
113 }
115 {
116  System::raWriteToLog("<b><font color=\"#008000\">OK:</font></b>" + x);
117  printf("OK: %s\n", x.c_str());
118 }
120 {
121  System::raWriteToLog("<b><font color=\"#008000\">INFO:</font></b> " + x);
122  printf("INFO: %s\n", x.c_str());
123 }
125 {
126  System::raWriteToLog("<b><font color=\"#FF0000\">WARNUNG:</font></b>" + x);
127  printf("WARNUNG: %s\n", x.c_str());
128 }
130 {
131  System::raWriteToLog("<b><font color=\"#FF0000\">FEHLER:</font></b>" + x);
132  printf("ERROR: %s\n", x.c_str());
133 }
135 {
136  System::raWriteToLog("<b><font color=\"#FF0000\">FEHLER:</font></b> <i>" + x + "</i> ist NULL!");
137  printf("ERROR: %s ist NULL\n", x.c_str());
138 }
140 {
141  System::raWriteToLog("<b><font color=\"#FF0000\">FEHLER:</font></b> <i>" + x + "</i> hat einen ungültigen Wert!");
142  printf("ERROR: %s invalidvalue\n", x.c_str());
143 }
145 {
146  System::raWriteToLog("<b><font color=\"#FF0000\">FEHLER:</font></b> Nicht genug Speicher!");
147  printf("Out Of Mem\n");
148 }
150 {
151  char temp[512];
152  sprintf(temp,"<tr><td><font size=\"2\"><b><font color=\"#FF0000\">FEHLER:</font></b> Die Datei <i>%s</i> konnte nicht geöffnet, gelesen, erstellt oder beschrieben werden!</font></td>", f.c_str());
153  System::raWriteToLog(temp);
154  printf("ERROR: %s konnte nicht geöffnet, gelesen, erstellt oder beschrieben werden", f.c_str());
155 }
156 void RAPI RERROR_DX11(raString x, HRESULT h)
157 {
158  System::raWriteToLog("<b><font color=\"#FF8000\">FEHLER-DIRECTX:</font></b>" + x + "["+ DXGetErrorString(h) + " " + DXGetErrorDescription(h) + "]</font></td>");
159  printf("ERROR-DX11: %s [ %s - %s ]\n", x.c_str(), DXGetErrorString(h), DXGetErrorDescription(h) );
160 }
161 void RAPI RERROR_INPUT(raString x, HRESULT h)
162 {
163 }
164 //void RAPI RERROR_FMOD(FMOD_RESULT fr)
165 //{
166 // raSystem::raWriteToLog("<b><font color=\"#FF8000\">FEHLER-FMOD:</font></b>" + raString(FMOD_ErrorString(fr)) + "</font></td>");
167 // printf("FEHLER-FMOD: %s\n", raString(FMOD_ErrorString(fr)).c_str());
168 //}
void RAPI RWRITE(raString x)
Definition: raMain.cpp:109
void RAPI RERROR_INPUT(raString x, HRESULT h)
Definition: raMain.cpp:161
void RAPI RINFO(raString x)
Definition: raMain.cpp:119
#define RAPI
Definition: raMain.h:11
void RAPI RERROR(raString x)
Definition: raMain.cpp:129
void RAPI RERROR_INVALIDVALUE(raString x)
Definition: raMain.cpp:139
std::string raString
Definition: raMain.h:107
void RAPI RERROR_FILE(raString f)
Definition: raMain.cpp:149
void RAPI RERROR_NULLPOINTER(raString x)
Definition: raMain.cpp:134
ID3D11Buffer D3D11_BUFFER_DESC void * pData
Definition: raSDKmesh.h:238
RAPI bool raWriteToLog(raString pcFormat)
Definition: raLog.cpp:77
void RAPI RERROR_DX11(raString x, HRESULT h)
Definition: raMain.cpp:156
void RAPI RERROR_OUTOFMEM()
Definition: raMain.cpp:144
void RAPI RWARNING(raString x)
Definition: raMain.cpp:124
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
Definition: raMain.cpp:8
__declspec(dllexport) BOOL WINAPI StoreData(DWORD dw)
Definition: raMain.cpp:66
void RAPI ROK(raString x)
Definition: raMain.cpp:114