| 1 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // NSClient++ Base Service |
|---|
| 3 | // |
|---|
| 4 | // Copyright (c) 2004 MySolutions NORDIC (http://www.medin.name) |
|---|
| 5 | // |
|---|
| 6 | // Date: 2004-03-13 |
|---|
| 7 | // Author: Michael Medin (michael@medin.name) |
|---|
| 8 | // |
|---|
| 9 | // Part of this file is based on work by Bruno Vais (bvais@usa.net) |
|---|
| 10 | // |
|---|
| 11 | // This software is provided "AS IS", without a warranty of any kind. |
|---|
| 12 | // You are free to use/modify this code but leave this header intact. |
|---|
| 13 | // |
|---|
| 14 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 15 | #include "stdafx.h" |
|---|
| 16 | #include <winsvc.h> |
|---|
| 17 | #include "NSClient++.h" |
|---|
| 18 | #include "Settings.h" |
|---|
| 19 | #include <charEx.h> |
|---|
| 20 | |
|---|
| 21 | NSClient mainClient; // Global core instance. |
|---|
| 22 | bool g_bConsoleLog = false; |
|---|
| 23 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 24 | // Startup code |
|---|
| 25 | |
|---|
| 26 | /** |
|---|
| 27 | * Application startup point |
|---|
| 28 | * |
|---|
| 29 | * @param argc Argument count |
|---|
| 30 | * @param argv[] Argument array |
|---|
| 31 | * @param envp[] Environment array |
|---|
| 32 | * @return exit status |
|---|
| 33 | */ |
|---|
| 34 | int main(int argc, TCHAR* argv[], TCHAR* envp[]) |
|---|
| 35 | { |
|---|
| 36 | int nRetCode = 0; |
|---|
| 37 | |
|---|
| 38 | if ( (argc > 1) && ((*argv[1] == '-') || (*argv[1] == '/')) ) { |
|---|
| 39 | if ( _stricmp( "install", argv[1]+1 ) == 0 ) { |
|---|
| 40 | g_bConsoleLog = true; |
|---|
| 41 | try { |
|---|
| 42 | serviceControll::Install(SZSERVICENAME, SZSERVICEDISPLAYNAME, SZDEPENDENCIES); |
|---|
| 43 | } catch (const serviceControll::SCException& e) { |
|---|
| 44 | LOG_MESSAGE_STD("Service installation failed: " + e.error_); |
|---|
| 45 | return -1; |
|---|
| 46 | } |
|---|
| 47 | LOG_MESSAGE("Service installed!"); |
|---|
| 48 | } else if ( _stricmp( "uninstall", argv[1]+1 ) == 0 ) { |
|---|
| 49 | g_bConsoleLog = true; |
|---|
| 50 | try { |
|---|
| 51 | serviceControll::Uninstall(SZSERVICENAME); |
|---|
| 52 | } catch (const serviceControll::SCException& e) { |
|---|
| 53 | LOG_MESSAGE_STD("Service deinstallation failed; " + e.error_); |
|---|
| 54 | return -1; |
|---|
| 55 | } |
|---|
| 56 | } else if ( _stricmp( "start", argv[1]+1 ) == 0 ) { |
|---|
| 57 | g_bConsoleLog = true; |
|---|
| 58 | serviceControll::Start(SZSERVICENAME); |
|---|
| 59 | } else if ( _stricmp( "stop", argv[1]+1 ) == 0 ) { |
|---|
| 60 | g_bConsoleLog = true; |
|---|
| 61 | serviceControll::Stop(SZSERVICENAME); |
|---|
| 62 | } else if ( _stricmp( "about", argv[1]+1 ) == 0 ) { |
|---|
| 63 | g_bConsoleLog = true; |
|---|
| 64 | LOG_MESSAGE(SZAPPNAME " (C) Michael Medin"); |
|---|
| 65 | LOG_MESSAGE("Version " SZVERSION); |
|---|
| 66 | } else if ( _stricmp( "version", argv[1]+1 ) == 0 ) { |
|---|
| 67 | g_bConsoleLog = true; |
|---|
| 68 | LOG_MESSAGE(SZAPPNAME " Version: " SZVERSION); |
|---|
| 69 | } else if ( _stricmp( "test", argv[1]+1 ) == 0 ) { |
|---|
| 70 | g_bConsoleLog = true; |
|---|
| 71 | mainClient.InitiateService(); |
|---|
| 72 | LOG_MESSAGE("Enter command to inject or exit to terminate..."); |
|---|
| 73 | std::string s = ""; |
|---|
| 74 | std::cin >> s; |
|---|
| 75 | while (s != "exit") { |
|---|
| 76 | // mainClient.inject(s); |
|---|
| 77 | std::cin >> s; |
|---|
| 78 | } |
|---|
| 79 | mainClient.TerminateService(); |
|---|
| 80 | LOG_MESSAGE("DONE!"); |
|---|
| 81 | |
|---|
| 82 | return 0; |
|---|
| 83 | } else { |
|---|
| 84 | LOG_MESSAGE("Usage: -version, -about, -install, -uninstall, -start, -stop"); |
|---|
| 85 | } |
|---|
| 86 | return nRetCode; |
|---|
| 87 | } |
|---|
| 88 | mainClient.StartServiceCtrlDispatcher(); |
|---|
| 89 | return nRetCode; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 93 | // Service functions |
|---|
| 94 | |
|---|
| 95 | /** |
|---|
| 96 | * Service control handler startup point. |
|---|
| 97 | * When the program is started as a service this will be the entry point. |
|---|
| 98 | */ |
|---|
| 99 | void NSClientT::InitiateService(void) { |
|---|
| 100 | Settings::getInstance()->setFile(getBasePath() + "NSC.ini"); |
|---|
| 101 | |
|---|
| 102 | SettingsT::sectionList list = Settings::getInstance()->getSection("modules"); |
|---|
| 103 | for (SettingsT::sectionList::iterator it = list.begin(); it != list.end(); it++) { |
|---|
| 104 | try { |
|---|
| 105 | LOG_DEBUG_STD("Loading: " + getBasePath() + "modules\\" + (*it)); |
|---|
| 106 | loadPlugin(getBasePath() + "modules\\" + (*it)); |
|---|
| 107 | } catch(const NSPluginException& e) { |
|---|
| 108 | LOG_ERROR_STD("Exception raised: " + e.error_ + " in module: " + e.file_); |
|---|
| 109 | } |
|---|
| 110 | } |
|---|
| 111 | } |
|---|
| 112 | /** |
|---|
| 113 | * Service control handler termination point. |
|---|
| 114 | * When the program is stopped as a service this will be the "exit point". |
|---|
| 115 | */ |
|---|
| 116 | void NSClientT::TerminateService(void) { |
|---|
| 117 | try { |
|---|
| 118 | LOG_DEBUG("Socket closed, unloading plugins..."); |
|---|
| 119 | mainClient.unloadPlugins(); |
|---|
| 120 | LOG_DEBUG("Plugins unloaded..."); |
|---|
| 121 | } catch(NSPluginException *e) { |
|---|
| 122 | std::cout << "Exception raised: " << e->error_ << " in module: " << e->file_ << std::endl;; |
|---|
| 123 | } |
|---|
| 124 | Settings::destroyInstance(); |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | /** |
|---|
| 128 | * Forward this to the main service dispatcher helper class |
|---|
| 129 | * @param dwArgc |
|---|
| 130 | * @param *lpszArgv |
|---|
| 131 | */ |
|---|
| 132 | void WINAPI NSClientT::service_main_dispatch(DWORD dwArgc, LPTSTR *lpszArgv) { |
|---|
| 133 | mainClient.service_main(dwArgc, lpszArgv); |
|---|
| 134 | } |
|---|
| 135 | /** |
|---|
| 136 | * Forward this to the main service dispatcher helper class |
|---|
| 137 | * @param dwCtrlCode |
|---|
| 138 | */ |
|---|
| 139 | void WINAPI NSClientT::service_ctrl_dispatch(DWORD dwCtrlCode) { |
|---|
| 140 | mainClient.service_ctrl(dwCtrlCode); |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 144 | // Member functions |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | /** |
|---|
| 148 | * Load a list of plug-ins |
|---|
| 149 | * @param plugins A list with plug-ins (DLL files) to load |
|---|
| 150 | */ |
|---|
| 151 | void NSClientT::loadPlugins(const std::list<std::string> plugins) { |
|---|
| 152 | MutexLock lock(pluginMutex); |
|---|
| 153 | if (!lock.hasMutex()) { |
|---|
| 154 | LOG_ERROR("FATAL ERROR: Could not get mutex."); |
|---|
| 155 | return; |
|---|
| 156 | } |
|---|
| 157 | std::list<std::string>::const_iterator it; |
|---|
| 158 | for (it = plugins.begin(); it != plugins.end(); ++it) { |
|---|
| 159 | loadPlugin(*it); |
|---|
| 160 | } |
|---|
| 161 | } |
|---|
| 162 | /** |
|---|
| 163 | * Unload all plug-ins (in reversed order) |
|---|
| 164 | */ |
|---|
| 165 | void NSClientT::unloadPlugins() { |
|---|
| 166 | MutexLock lock(pluginMutex,20000); |
|---|
| 167 | if (!lock.hasMutex()) { |
|---|
| 168 | LOG_ERROR("FATAL ERROR: Could not get mutex."); |
|---|
| 169 | return; |
|---|
| 170 | } |
|---|
| 171 | pluginList::reverse_iterator it; |
|---|
| 172 | for (it = plugins_.rbegin(); it != plugins_.rend(); ++it) { |
|---|
| 173 | LOG_DEBUG_STD("Unloading plugin: " + (*it)->getName() + "..."); |
|---|
| 174 | (*it)->unload(); |
|---|
| 175 | } |
|---|
| 176 | { |
|---|
| 177 | MutexLock lock2(messageMutex,20000); |
|---|
| 178 | if (!lock2.hasMutex()) { |
|---|
| 179 | LOG_ERROR("FATAL ERROR: Could not get mutex (we will now crash BTW)."); |
|---|
| 180 | } else { |
|---|
| 181 | messageHandlers_.clear(); |
|---|
| 182 | } |
|---|
| 183 | } |
|---|
| 184 | commandHandlers_.clear(); |
|---|
| 185 | for (it = plugins_.rbegin(); it != plugins_.rend(); ++it) { |
|---|
| 186 | delete (*it); |
|---|
| 187 | } |
|---|
| 188 | plugins_.clear(); |
|---|
| 189 | } |
|---|
| 190 | /** |
|---|
| 191 | * Load a single plug-in using a DLL filename |
|---|
| 192 | * @param file The DLL file |
|---|
| 193 | */ |
|---|
| 194 | void NSClientT::loadPlugin(const std::string file) { |
|---|
| 195 | addPlugin(new NSCPlugin(file)); |
|---|
| 196 | } |
|---|
| 197 | /** |
|---|
| 198 | * Load and add a plugin to various internal structures |
|---|
| 199 | * @param *plugin The plug-ininstance to load. The pointer is managed by the |
|---|
| 200 | */ |
|---|
| 201 | void NSClientT::addPlugin(plugin_type plugin) { |
|---|
| 202 | MutexLock lock(pluginMutex); |
|---|
| 203 | if (!lock.hasMutex()) { |
|---|
| 204 | LOG_ERROR("FATAL ERROR: Could not get mutex."); |
|---|
| 205 | return; |
|---|
| 206 | } |
|---|
| 207 | plugin->load(); |
|---|
| 208 | LOG_DEBUG_STD("Loading: " + plugin->getName()); |
|---|
| 209 | // @todo Catch here and unload if we fail perhaps ? |
|---|
| 210 | plugins_.push_back(plugin); |
|---|
| 211 | if (plugin->hasCommandHandler()) |
|---|
| 212 | commandHandlers_.push_back(plugin); |
|---|
| 213 | if (plugin->hasMessageHandler()) |
|---|
| 214 | messageHandlers_.push_back(plugin); |
|---|
| 215 | } |
|---|
| 216 | /** |
|---|
| 217 | * Inject a command into the plug-in stack. |
|---|
| 218 | * |
|---|
| 219 | * @param buffer A command string to inject. This should be a unparsed command string such as command&arg1&arg2&arg... |
|---|
| 220 | * @return The result, empty string if no result |
|---|
| 221 | */ |
|---|
| 222 | NSCAPI::nagiosReturn NSClientT::injectRAW(const char* command, const unsigned int argLen, char **argument, char *returnMessageBuffer, unsigned int returnMessageBufferLen, char *returnPerfBuffer, unsigned int returnPerfBufferLen) { |
|---|
| 223 | MutexLock lock(pluginMutex); |
|---|
| 224 | |
|---|
| 225 | LOG_MESSAGE_STD("Injecting: " + command); |
|---|
| 226 | |
|---|
| 227 | pluginList::const_iterator plit; |
|---|
| 228 | for (plit = commandHandlers_.begin(); plit != commandHandlers_.end(); ++plit) { |
|---|
| 229 | try { |
|---|
| 230 | NSCAPI::nagiosReturn c = (*plit)->handleCommand(command, argLen, argument, returnMessageBuffer, returnMessageBufferLen, returnPerfBuffer, returnPerfBufferLen); |
|---|
| 231 | switch (c) { |
|---|
| 232 | case NSCAPI::returnInvalidBufferLen: |
|---|
| 233 | LOG_ERROR("Return buffer to small to handle this command."); |
|---|
| 234 | return c; |
|---|
| 235 | case NSCAPI::returnIgnored: |
|---|
| 236 | LOG_DEBUG("A module ignored this message"); |
|---|
| 237 | break; |
|---|
| 238 | case NSCAPI::returnOK: |
|---|
| 239 | case NSCAPI::returnWARN: |
|---|
| 240 | case NSCAPI::returnCRIT: |
|---|
| 241 | case NSCAPI::returnUNKNOWN: |
|---|
| 242 | LOG_DEBUG_STD("Injected Result: " +(std::string) returnMessageBuffer); |
|---|
| 243 | LOG_DEBUG_STD("Injected Performance Result: " +(std::string) returnPerfBuffer); |
|---|
| 244 | return c; |
|---|
| 245 | default: |
|---|
| 246 | LOG_ERROR_STD("Unknown error from handleCommand: " + strEx::itos(c)); |
|---|
| 247 | return c; |
|---|
| 248 | } |
|---|
| 249 | } catch(const NSPluginException& e) { |
|---|
| 250 | LOG_ERROR_STD("Exception raised: " + e.error_ + " in module: " + e.file_); |
|---|
| 251 | return NSCAPI::returnCRIT; |
|---|
| 252 | } |
|---|
| 253 | } |
|---|
| 254 | LOG_MESSAGE_STD("No handler for command: " + command); |
|---|
| 255 | return NSCAPI::returnIgnored; |
|---|
| 256 | } |
|---|
| 257 | /** |
|---|
| 258 | * Helper function to return the current password (perhaps this should be static ?) |
|---|
| 259 | * |
|---|
| 260 | * @return The current password |
|---|
| 261 | */ |
|---|
| 262 | std::string NSClientT::getPassword() { |
|---|
| 263 | return Settings::getInstance()->getString("generic", "password", ""); |
|---|
| 264 | } |
|---|
| 265 | /** |
|---|
| 266 | * Execute a command. |
|---|
| 267 | * |
|---|
| 268 | * @param password The password |
|---|
| 269 | * @param cmd The command |
|---|
| 270 | * @param args Arguments as a list<string> |
|---|
| 271 | * @return The result if any, empty string if no result. |
|---|
| 272 | * |
|---|
| 273 | * @todo Make an int return value to set critical/warning/ok/unknown status. |
|---|
| 274 | * ie. pair<int,string> |
|---|
| 275 | */ |
|---|
| 276 | /* |
|---|
| 277 | std::string NSClientT::execute(std::string password, std::string cmd, std::list<std::string> args) { |
|---|
| 278 | MutexLock lock(pluginMutex); |
|---|
| 279 | if (!lock.hasMutex()) { |
|---|
| 280 | LOG_ERROR("FATAL ERROR: Could not execute command with a reasonable timeframe. (could not get mutex so core is most likely locked down)."); |
|---|
| 281 | return "ERROR: Core was locked down"; |
|---|
| 282 | } |
|---|
| 283 | static unsigned int bufferSize = 0; |
|---|
| 284 | if (bufferSize == 0) |
|---|
| 285 | bufferSize = static_cast<unsigned int>(Settings::getInstance()->getInt("main", "bufferSize", 4096)); |
|---|
| 286 | |
|---|
| 287 | if (password != getPassword()) |
|---|
| 288 | return "ERROR: Authorization denied."; |
|---|
| 289 | |
|---|
| 290 | std::string ret; |
|---|
| 291 | unsigned int len; |
|---|
| 292 | char **arguments = NSCHelper::list2arrayBuffer(args, len); |
|---|
| 293 | // Allocate return buffer |
|---|
| 294 | char* returnbuffer = new char[bufferSize+1]; |
|---|
| 295 | pluginList::const_iterator plit; |
|---|
| 296 | for (plit = commandHandlers_.begin(); plit != commandHandlers_.end(); ++plit) { |
|---|
| 297 | try { |
|---|
| 298 | int c = (*plit)->handleCommand(cmd.c_str(), len, arguments, returnbuffer, bufferSize); |
|---|
| 299 | if (c == NSCAPI::handled) { // module handled the message "we are done..." |
|---|
| 300 | ret = returnbuffer; |
|---|
| 301 | break; |
|---|
| 302 | } else if (c == NSCAPI::isfalse) { // Module ignored the message |
|---|
| 303 | LOG_DEBUG("A module ignored this message"); |
|---|
| 304 | } else if (c == NSCAPI::invalidBufferLen) { // Buffer is to small |
|---|
| 305 | LOG_ERROR("Return buffer to small, need to increase it in the ini file."); |
|---|
| 306 | } else { // Something else went wrong... |
|---|
| 307 | LOG_ERROR_STD("Unknown error from handleCommand: " + strEx::itos(c)); |
|---|
| 308 | } |
|---|
| 309 | } catch(const NSPluginException& e) { |
|---|
| 310 | LOG_ERROR_STD("Exception raised: " + e.error_ + " in module: " + e.file_); |
|---|
| 311 | } |
|---|
| 312 | } |
|---|
| 313 | // delete buffers |
|---|
| 314 | delete [] returnbuffer; |
|---|
| 315 | NSCHelper::destroyArrayBuffer(arguments, len); |
|---|
| 316 | return ret; |
|---|
| 317 | } |
|---|
| 318 | */ |
|---|
| 319 | /** |
|---|
| 320 | * Report a message to all logging enabled modules. |
|---|
| 321 | * |
|---|
| 322 | * @param msgType Message type |
|---|
| 323 | * @param file Filename generally __FILE__ |
|---|
| 324 | * @param line Line number, generally __LINE__ |
|---|
| 325 | * @param message The message as a human readable string. |
|---|
| 326 | */ |
|---|
| 327 | void NSClientT::reportMessage(int msgType, const char* file, const int line, std::string message) { |
|---|
| 328 | MutexLock lock(messageMutex); |
|---|
| 329 | if (!lock.hasMutex()) { |
|---|
| 330 | std::cout << "Message was lost as the core was locked..." << std::endl; |
|---|
| 331 | std::cout << message << std::endl; |
|---|
| 332 | return; |
|---|
| 333 | } |
|---|
| 334 | if (g_bConsoleLog) { |
|---|
| 335 | std::cout << NSCHelper::translateMessageType(msgType) << " " << file << "(" << line << ") " << message << std::endl; |
|---|
| 336 | } |
|---|
| 337 | if (msgType == NSCAPI::debug) { |
|---|
| 338 | typedef enum status {unknown, debug, nodebug }; |
|---|
| 339 | static status d = unknown; |
|---|
| 340 | if (d == unknown) { |
|---|
| 341 | if (Settings::getInstance()->getInt("log", "debug", 0) == 1) |
|---|
| 342 | d = debug; |
|---|
| 343 | else |
|---|
| 344 | d = nodebug; |
|---|
| 345 | } |
|---|
| 346 | if (d == nodebug) |
|---|
| 347 | return; |
|---|
| 348 | } |
|---|
| 349 | pluginList::const_iterator plit; |
|---|
| 350 | for (plit = messageHandlers_.begin(); plit != messageHandlers_.end(); ++plit) { |
|---|
| 351 | try { |
|---|
| 352 | (*plit)->handleMessage(msgType, file, line, message.c_str()); |
|---|
| 353 | } catch(const NSPluginException& e) { |
|---|
| 354 | // Here we are pretty much fucked! (as logging this might cause a loop :) |
|---|
| 355 | std::cout << "Caught: " << e.error_ << " when trying to log a message..." << std::endl; |
|---|
| 356 | std::cout << "This is *really really* bad, now the world is about to end..." << std::endl; |
|---|
| 357 | } |
|---|
| 358 | } |
|---|
| 359 | } |
|---|
| 360 | std::string NSClientT::getBasePath(void) { |
|---|
| 361 | MutexLock lock(pluginMutex); |
|---|
| 362 | if (!lock.hasMutex()) { |
|---|
| 363 | LOG_ERROR("FATAL ERROR: Could not get mutex."); |
|---|
| 364 | return "FATAL ERROR"; |
|---|
| 365 | } |
|---|
| 366 | if (!basePath.empty()) |
|---|
| 367 | return basePath; |
|---|
| 368 | char* buffer = new char[1024]; |
|---|
| 369 | GetModuleFileName(NULL, buffer, 1023); |
|---|
| 370 | std::string path = buffer; |
|---|
| 371 | std::string::size_type pos = path.rfind('\\'); |
|---|
| 372 | basePath = path.substr(0, pos) + "\\"; |
|---|
| 373 | delete [] buffer; |
|---|
| 374 | Settings::getInstance()->setFile(basePath + "NSC.ini"); |
|---|
| 375 | return basePath; |
|---|
| 376 | } |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | NSCAPI::errorReturn NSAPIGetSettingsString(const char* section, const char* key, const char* defaultValue, char* buffer, unsigned int bufLen) { |
|---|
| 380 | return NSCHelper::wrapReturnString(buffer, bufLen, Settings::getInstance()->getString(section, key, defaultValue), NSCAPI::isSuccess); |
|---|
| 381 | } |
|---|
| 382 | int NSAPIGetSettingsInt(const char* section, const char* key, int defaultValue) { |
|---|
| 383 | return Settings::getInstance()->getInt(section, key, defaultValue); |
|---|
| 384 | } |
|---|
| 385 | NSCAPI::errorReturn NSAPIGetBasePath(char*buffer, unsigned int bufLen) { |
|---|
| 386 | return NSCHelper::wrapReturnString(buffer, bufLen, mainClient.getBasePath(), NSCAPI::isSuccess); |
|---|
| 387 | } |
|---|
| 388 | NSCAPI::errorReturn NSAPIGetApplicationName(char*buffer, unsigned int bufLen) { |
|---|
| 389 | return NSCHelper::wrapReturnString(buffer, bufLen, SZAPPNAME, NSCAPI::isSuccess); |
|---|
| 390 | } |
|---|
| 391 | NSCAPI::errorReturn NSAPIGetApplicationVersionStr(char*buffer, unsigned int bufLen) { |
|---|
| 392 | return NSCHelper::wrapReturnString(buffer, bufLen, SZVERSION, NSCAPI::isSuccess); |
|---|
| 393 | } |
|---|
| 394 | void NSAPIMessage(int msgType, const char* file, const int line, const char* message) { |
|---|
| 395 | mainClient.reportMessage(msgType, file, line, message); |
|---|
| 396 | } |
|---|
| 397 | void NSAPIStopServer(void) { |
|---|
| 398 | serviceControll::Stop(SZSERVICENAME); |
|---|
| 399 | } |
|---|
| 400 | NSCAPI::nagiosReturn NSAPIInject(const char* command, const unsigned int argLen, char **argument, char *returnMessageBuffer, unsigned int returnMessageBufferLen, char *returnPerfBuffer, unsigned int returnPerfBufferLen) { |
|---|
| 401 | return mainClient.injectRAW(command, argLen, argument, returnMessageBuffer, returnMessageBufferLen, returnPerfBuffer, returnPerfBufferLen); |
|---|
| 402 | } |
|---|
| 403 | |
|---|
| 404 | LPVOID NSAPILoader(char*buffer) { |
|---|
| 405 | if (stricmp(buffer, "NSAPIGetApplicationName") == 0) |
|---|
| 406 | return &NSAPIGetApplicationName; |
|---|
| 407 | if (stricmp(buffer, "NSAPIGetApplicationVersionStr") == 0) |
|---|
| 408 | return &NSAPIGetApplicationVersionStr; |
|---|
| 409 | if (stricmp(buffer, "NSAPIGetSettingsString") == 0) |
|---|
| 410 | return &NSAPIGetSettingsString; |
|---|
| 411 | if (stricmp(buffer, "NSAPIGetSettingsInt") == 0) |
|---|
| 412 | return &NSAPIGetSettingsInt; |
|---|
| 413 | if (stricmp(buffer, "NSAPIMessage") == 0) |
|---|
| 414 | return &NSAPIMessage; |
|---|
| 415 | if (stricmp(buffer, "NSAPIStopServer") == 0) |
|---|
| 416 | return &NSAPIStopServer; |
|---|
| 417 | if (stricmp(buffer, "NSAPIInject") == 0) |
|---|
| 418 | return &NSAPIInject; |
|---|
| 419 | if (stricmp(buffer, "NSAPIGetBasePath") == 0) |
|---|
| 420 | return &NSAPIGetBasePath; |
|---|
| 421 | return NULL; |
|---|
| 422 | } |
|---|